Line data Source code
1 : #ifndef HEADER_fd_src_disco_net_sock_fd_sock_tile_private_h 2 : #define HEADER_fd_src_disco_net_sock_fd_sock_tile_private_h 3 : 4 : #if FD_HAS_HOSTED 5 : 6 : #include "../../../util/fd_util_base.h" 7 : #include "../../metrics/generated/fd_metrics_enums.h" 8 : #include <poll.h> 9 : #include <sys/socket.h> 10 : 11 : /* FD_SOCK_TILE_MAX_SOCKETS controls the max number of UDP ports that a 12 : sock tile can bind to. */ 13 : 14 0 : #define FD_SOCK_TILE_MAX_SOCKETS (8) 15 : 16 : /* MAX_NET_INS controls the max number of TX links that a sock tile can 17 : serve. */ 18 : 19 : #define MAX_NET_INS (32UL) 20 : 21 : /* MAX_NET_OUTS controls the max number of RX links that a sock tile can 22 : serve. */ 23 : 24 : #define MAX_NET_OUTS (6UL) 25 : 26 : /* Local metrics. Periodically copied to the metric_in shm region. */ 27 : 28 : struct fd_sock_tile_metrics { 29 : ulong sys_recvmmsg_cnt; 30 : ulong sys_sendmmsg_cnt[ FD_METRICS_ENUM_SOCKET_ERROR_CNT ]; 31 : ulong rx_pkt_cnt; 32 : ulong tx_pkt_cnt; 33 : ulong tx_drop_cnt; 34 : ulong rx_bytes_total; 35 : ulong tx_bytes_total; 36 : }; 37 : 38 : typedef struct fd_sock_tile_metrics fd_sock_tile_metrics_t; 39 : 40 : /* Tile private state */ 41 : 42 : struct fd_sock_link_tx { 43 : void * base; 44 : ulong chunk0; 45 : ulong wmark; 46 : }; 47 : 48 : typedef struct fd_sock_link_tx fd_sock_link_tx_t; 49 : 50 : struct fd_sock_link_rx { 51 : void * base; 52 : ulong chunk0; 53 : ulong wmark; 54 : ulong chunk; 55 : }; 56 : 57 : typedef struct fd_sock_link_rx fd_sock_link_rx_t; 58 : 59 : struct fd_sock_tile { 60 : /* RX SOCK_DGRAM sockets */ 61 : struct pollfd pollfd[ FD_SOCK_TILE_MAX_SOCKETS ]; 62 : uint sock_cnt; 63 : uchar proto_id[ FD_SOCK_TILE_MAX_SOCKETS ]; 64 : 65 : /* TX SOCK_RAW socket */ 66 : int tx_sock; 67 : uint tx_idle_cnt; 68 : uint bind_address; 69 : 70 : /* RX/TX batches 71 : FIXME transpose arrays for better cache locality? */ 72 : ulong batch_cnt; /* <=STEM_BURST */ 73 : struct iovec * batch_iov; 74 : void * batch_cmsg; 75 : struct sockaddr_in * batch_sa; 76 : struct mmsghdr * batch_msg; 77 : 78 : /* RX links */ 79 : ushort rx_sock_port[ FD_SOCK_TILE_MAX_SOCKETS ]; 80 : uchar link_rx_map [ FD_SOCK_TILE_MAX_SOCKETS ]; 81 : uchar repair_rx; 82 : uint repair_shred_sock_idx; 83 : fd_sock_link_rx_t link_rx[ MAX_NET_OUTS ]; 84 : 85 : /* TX links */ 86 : fd_sock_link_tx_t link_tx[ MAX_NET_INS ]; 87 : 88 : /* TX scratch memory */ 89 : uchar * tx_scratch0; 90 : uchar * tx_scratch1; 91 : uchar * tx_ptr; /* in [tx_scratch0,tx_scratch1) */ 92 : 93 : /* Values parsed from the current frag in during_frag, validated in 94 : after_frag */ 95 : struct { 96 : int invalid; /* set if the frag failed validation in during_frag */ 97 : uint ip_version; 98 : uint ip_protocol; 99 : } parsed; 100 : 101 : fd_sock_tile_metrics_t metrics; 102 : }; 103 : 104 : typedef struct fd_sock_tile fd_sock_tile_t; 105 : 106 : #endif /* FD_HAS_HOSTED */ 107 : 108 : #endif /* HEADER_fd_src_disco_net_sock_fd_sock_tile_private_h */