Line data Source code
1 : #ifndef HEADER_fd_src_disco_fd_disco_base_h 2 : #define HEADER_fd_src_disco_fd_disco_base_h 3 : 4 : #include "../tango/fd_tango.h" 5 : #include "../ballet/shred/fd_shred.h" 6 : #include "../ballet/txn/fd_txn.h" 7 : #include "../flamenco/fd_flamenco_base.h" 8 : #include "../util/wksp/fd_wksp_private.h" 9 : 10 18 : #define DST_PROTO_OUTGOING (0UL) 11 0 : #define DST_PROTO_TPU_UDP (1UL) 12 0 : #define DST_PROTO_TPU_QUIC (2UL) 13 18 : #define DST_PROTO_SHRED (3UL) 14 0 : #define DST_PROTO_REPAIR (4UL) 15 0 : #define DST_PROTO_GOSSIP (5UL) 16 0 : #define DST_PROTO_SEND (6UL) 17 : 18 0 : #define POH_PKT_TYPE_MICROBLOCK (0UL) 19 0 : #define POH_PKT_TYPE_BECAME_LEADER (1UL) 20 0 : #define POH_PKT_TYPE_FEAT_ACT_SLOT (2UL) 21 : 22 : /* FD_NET_MTU is the max full packet size, with ethernet, IP, and UDP 23 : headers that can go in or out of the net tile. 2048 is the maximum 24 : XSK entry size, so this value follows naturally. */ 25 : 26 42 : #define FD_NET_MTU (2048UL) 27 : 28 : /* FD_TPU_MTU is the max serialized byte size of a txn sent over TPU. 29 : 30 : This is minimum MTU of IPv6 packet - IPv6 header - UDP header 31 : 1280 - 40 - 8 */ 32 : 33 0 : #define FD_TPU_MTU (1232UL) 34 : 35 : /* FD_GOSSIP_MTU is the max sz of a gossip packet which is the same as 36 : above. */ 37 : 38 0 : #define FD_GOSSIP_MTU (FD_TPU_MTU) 39 : 40 : /* FD_SHRED_STORE_MTU is the size of an fd_fec_set (statically 41 : asserted in fd_shred_tile.c). */ 42 : 43 0 : #define FD_SHRED_STORE_MTU (78656UL) 44 : 45 0 : #define FD_NETMUX_SIG_MIN_HDR_SZ (42UL) /* The default header size, which means no vlan tags and no IP options. */ 46 : 47 : /* These limits are defined here to prevent circular dependencies, and 48 : statically asserted they are calculated correctly in the relevant 49 : places. We get one bound using transactions that consume the minimum 50 : number of CUs and another bound using the minimum size transactions. 51 : The overall bound is the lower of the two. */ 52 : #define FD_MAX_TXN_PER_SLOT_CU 98039UL 53 : #define FD_MAX_TXN_PER_SLOT_SHRED 272635UL 54 18 : #define FD_MAX_TXN_PER_SLOT 98039UL 55 : FD_STATIC_ASSERT( FD_MAX_TXN_PER_SLOT<=FD_MAX_TXN_PER_SLOT_CU&&FD_MAX_TXN_PER_SLOT<=FD_MAX_TXN_PER_SLOT_SHRED, max_txn_per_slot ); 56 : FD_STATIC_ASSERT( FD_MAX_TXN_PER_SLOT>=FD_MAX_TXN_PER_SLOT_CU||FD_MAX_TXN_PER_SLOT>=FD_MAX_TXN_PER_SLOT_SHRED, max_txn_per_slot ); 57 : 58 : 59 : FD_PROTOTYPES_BEGIN 60 : 61 : /* hdr_sz is the total size of network headers, including eth, ip, udp. 62 : Ignored for outgoing packets. 63 : For incoming packets, hash_{ip_addr,port} are the source IP and port, 64 : for outgoing packets, they are the destination IP and port. */ 65 : FD_FN_CONST static inline ulong 66 : fd_disco_netmux_sig( uint hash_ip_addr, 67 : ushort hash_port, 68 : uint ip_addr, 69 : ulong proto, 70 36 : ulong hdr_sz ) { 71 : /* The size of an Ethernet header is 14+4k bytes, where 0<=k<=3 (?) is 72 : the number of vlan tags. The size of an IP header is 4j, where 73 : 5<=j<=15 is the size given in the header. The size of a UDP header 74 : is 8B. Thus, the total sum of these is 42+4i, where i=k+j-5, 75 : 0<=i<=13. Since bits are at a premium here, we compress the header 76 : size by just storing i. */ 77 36 : ulong hdr_sz_i = ((hdr_sz - 42UL)>>2)&0xFUL; 78 36 : ulong hash = 0xfffffUL & fd_ulong_hash( (ulong)hash_ip_addr | ((ulong)hash_port<<32) ); 79 36 : return (hash<<44) | ((hdr_sz_i&0xFUL)<<40UL) | ((proto&0xFFUL)<<32UL) | ((ulong)ip_addr); 80 36 : } 81 : 82 18 : FD_FN_CONST static inline ulong fd_disco_netmux_sig_hash ( ulong sig ) { return (sig>>44UL); } 83 18 : FD_FN_CONST static inline ulong fd_disco_netmux_sig_proto( ulong sig ) { return (sig>>32UL) & 0xFFUL; } 84 18 : FD_FN_CONST static inline uint fd_disco_netmux_sig_ip ( ulong sig ) { return (uint)(sig & 0xFFFFFFFFUL); } 85 : 86 : /* fd_disco_netmux_sig_hdr_sz extracts the total size of the Ethernet, 87 : IP, and UDP headers from the netmux signature field. The UDP payload 88 : of the packet stored in the corresponding frag begins at the returned 89 : offset. */ 90 0 : FD_FN_CONST static inline ulong fd_disco_netmux_sig_hdr_sz( ulong sig ) { return 4UL*((sig>>40UL) & 0xFUL) + 42UL; } 91 : 92 : FD_FN_CONST static inline ulong 93 : fd_disco_poh_sig( ulong slot, 94 : ulong pkt_type, 95 0 : ulong execle_tile ) { 96 : /* The high 6 bits of the low byte of the signature field is the 97 : execle idx. Execles will filter to only handle frags with their 98 : own idx. The higher 7 bytes are the slot number. Technically, 99 : the slot number is a ulong, but it won't hit 256^7 for about 10^9 100 : years at the current rate. The lowest bits of the low byte is the 101 : packet type. */ 102 0 : return (slot << 8) | ((execle_tile & 0x3FUL) << 2) | (pkt_type & 0x3UL); 103 0 : } 104 : 105 0 : FD_FN_CONST static inline ulong fd_disco_poh_sig_pkt_type( ulong sig ) { return (sig & 0x3UL); } 106 0 : FD_FN_CONST static inline ulong fd_disco_poh_sig_slot( ulong sig ) { return (sig >> 8); } 107 0 : FD_FN_CONST static inline ulong fd_disco_poh_sig_execle_tile( ulong sig ) { return (sig >> 2) & 0x3FUL; } 108 : 109 : FD_FN_CONST static inline ulong 110 : fd_disco_execle_sig( ulong slot, 111 0 : ulong pack_idx ) { 112 0 : return (slot << 32) | pack_idx; 113 0 : } 114 : 115 0 : FD_FN_CONST static inline ulong fd_disco_execle_sig_slot( ulong sig ) { return (sig >> 32); } 116 0 : FD_FN_CONST static inline ulong fd_disco_execle_sig_pack_idx( ulong sig ) { return sig & 0xFFFFFFFFUL; } 117 : 118 : FD_FN_PURE static inline ulong 119 0 : fd_disco_compact_chunk0( void * wksp ) { 120 0 : return (((struct fd_wksp_private *)wksp)->gaddr_lo) >> FD_CHUNK_LG_SZ; 121 0 : } 122 : 123 : FD_FN_PURE static inline ulong 124 0 : fd_disco_compact_wmark( void * wksp, ulong mtu ) { 125 0 : ulong chunk_mtu = ((mtu + 2UL*FD_CHUNK_SZ-1UL) >> (1+FD_CHUNK_LG_SZ)) << 1; 126 0 : ulong wksp_hi = ((struct fd_wksp_private *)wksp)->gaddr_hi; 127 0 : return (wksp_hi >> FD_CHUNK_LG_SZ) - chunk_mtu; 128 0 : } 129 : 130 : FD_PROTOTYPES_END 131 : 132 : #endif /* HEADER_fd_src_disco_fd_disco_base_h */