TAS
TCP Acceleration as an OS Service
tas_memif.h
1 /*
2  * Copyright 2019 University of Washington, Max Planck Institute for
3  * Software Systems, and The University of Texas at Austin
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef FLEXTCP_PLIF_H_
26 #define FLEXTCP_PLIF_H_
27 
28 #include <stdint.h>
29 #include <utils.h>
30 #include <packet_defs.h>
31 
38 #define FLEXNIC_HUGE_PREFIX "/dev/hugepages"
39 
41 #define FLEXNIC_NAME_INFO "tas_info"
42 
43 #define FLEXNIC_NAME_DMA_MEM "tas_memory"
44 
45 #define FLEXNIC_NAME_INTERNAL_MEM "tas_internal"
46 
48 #define FLEXNIC_INFO_BYTES 0x1000
49 
51 #define FLEXNIC_FLAG_READY 1
52 
53 #define FLEXNIC_FLAG_HUGEPAGES 2
54 
56 struct flexnic_info {
58  uint64_t flags;
60  uint64_t dma_mem_size;
64  uint64_t mac_address;
66  uint64_t poll_cycle_app;
68  uint64_t poll_cycle_tas;
70  uint32_t qmq_num;
72  uint32_t cores_num;
73 } __attribute__((packed));
74 
75 
76 
77 /******************************************************************************/
78 /* Kernel RX queue */
79 
80 #define FLEXTCP_PL_KRX_INVALID 0x0
81 #define FLEXTCP_PL_KRX_PACKET 0x1
82 
85  uint64_t addr;
86  union {
87  struct {
88  uint16_t len;
89  uint16_t fn_core;
90  uint16_t flow_group;
91  } packet;
92  uint8_t raw[55];
93  } __attribute__((packed)) msg;
94  volatile uint8_t type;
95 } __attribute__((packed));
96 
97 STATIC_ASSERT(sizeof(struct flextcp_pl_krx) == 64, krx_size);
98 
99 
100 /******************************************************************************/
101 /* Kernel TX queue */
102 
103 #define FLEXTCP_PL_KTX_INVALID 0x0
104 #define FLEXTCP_PL_KTX_PACKET 0x1
105 #define FLEXTCP_PL_KTX_CONNRETRAN 0x2
106 #define FLEXTCP_PL_KTX_PACKET_NOTS 0x3
107 
110  union {
111  struct {
112  uint64_t addr;
113  uint16_t len;
114  } packet;
115  struct {
116  uint32_t flow_id;
117  } connretran;
118  uint8_t raw[63];
119  } __attribute__((packed)) msg;
120  volatile uint8_t type;
121 } __attribute__((packed));
122 
123 STATIC_ASSERT(sizeof(struct flextcp_pl_ktx) == 64, ktx_size);
124 
125 
126 /******************************************************************************/
127 /* App RX queue */
128 
129 #define FLEXTCP_PL_ARX_INVALID 0x0
130 #define FLEXTCP_PL_ARX_CONNUPDATE 0x1
131 
132 #define FLEXTCP_PL_ARX_FLRXDONE 0x1
133 
136  uint64_t opaque;
137  uint32_t rx_bump;
138  uint32_t rx_pos;
139  uint32_t tx_bump;
140  uint8_t flags;
141 } __attribute__((packed));
142 
145  union {
146  struct flextcp_pl_arx_connupdate connupdate;
147  uint8_t raw[31];
148  } __attribute__((packed)) msg;
149  volatile uint8_t type;
150 } __attribute__((packed));
151 
152 STATIC_ASSERT(sizeof(struct flextcp_pl_arx) == 32, arx_size);
153 
154 /******************************************************************************/
155 /* App TX queue */
156 
157 #define FLEXTCP_PL_ATX_CONNUPDATE 0x1
158 
159 #define FLEXTCP_PL_ATX_FLTXDONE 0x1
160 
163  union {
164  struct {
165  uint32_t rx_bump;
166  uint32_t tx_bump;
167  uint32_t flow_id;
168  uint16_t bump_seq;
169  uint8_t flags;
170  } __attribute__((packed)) connupdate;
171  uint8_t raw[15];
172  } __attribute__((packed)) msg;
173  volatile uint8_t type;
174 } __attribute__((packed));
175 
176 STATIC_ASSERT(sizeof(struct flextcp_pl_atx) == 16, atx_size);
177 
178 /******************************************************************************/
179 /* Internal flexnic memory */
180 
181 #define FLEXNIC_PL_APPST_NUM 8
182 #define FLEXNIC_PL_APPST_CTX_NUM 31
183 #define FLEXNIC_PL_APPST_CTX_MCS 16
184 #define FLEXNIC_PL_APPCTX_NUM 16
185 #define FLEXNIC_PL_FLOWST_NUM (128 * 1024)
186 #define FLEXNIC_PL_FLOWHT_ENTRIES (FLEXNIC_PL_FLOWST_NUM * 2)
187 #define FLEXNIC_PL_FLOWHT_NBSZ 4
188 
191  /********************************************************/
192  /* read-only fields */
193 
195  uint16_t ctx_num;
196 
198  uint16_t ctx_ids[FLEXNIC_PL_APPST_CTX_NUM];
199 } __attribute__((packed));
200 
201 
204  /********************************************************/
205  /* read-only fields */
206  uint64_t rx_base;
207  uint64_t tx_base;
208  uint32_t rx_len;
209  uint32_t tx_len;
210  uint32_t appst_id;
211  int evfd;
212 
213  /********************************************************/
214  /* read-write fields */
215  uint64_t last_ts;
216  uint32_t rx_head;
217  uint32_t tx_head;
218  uint32_t rx_avail;
219 } __attribute__((packed));
220 
222 #define FLEXNIC_PL_OOO_RECV 1
223 
224 #define FLEXNIC_PL_FLOWST_SLOWPATH 1
225 #define FLEXNIC_PL_FLOWST_ECN 8
226 #define FLEXNIC_PL_FLOWST_TXFIN 16
227 #define FLEXNIC_PL_FLOWST_RXFIN 32
228 #define FLEXNIC_PL_FLOWST_RX_MASK (~63ULL)
229 
232  /********************************************************/
233  /* read-only fields */
234 
236  uint64_t opaque;
237 
239  uint64_t rx_base_sp;
241  uint64_t tx_base;
242 
244  uint32_t rx_len;
246  uint32_t tx_len;
247 
248  beui32_t local_ip;
249  beui32_t remote_ip;
250 
251  beui16_t local_port;
252  beui16_t remote_port;
253 
255  struct eth_addr remote_mac;
256 
258  uint16_t db_id;
259 
261  uint16_t flow_group;
263  uint16_t bump_seq;
264 
265  // 56
266 
267  /********************************************************/
268  /* read-write fields */
269 
271  volatile uint32_t lock;
272 
274  uint32_t rx_avail;
275  // 64
277  uint32_t rx_next_pos;
279  uint32_t rx_next_seq;
281  uint32_t rx_remote_avail;
283  uint32_t rx_dupack_cnt;
284 
285 #ifdef FLEXNIC_PL_OOO_RECV
286  /* Start of interval of out-of-order received data */
287  uint32_t rx_ooo_start;
288  /* Length of interval of out-of-order received data */
289  uint32_t rx_ooo_len;
290 #endif
291 
293  uint32_t tx_avail;
296  uint32_t tx_sent;
298  uint32_t tx_next_pos;
300  uint32_t tx_next_seq;
302  uint32_t tx_next_ts;
303 
305  uint32_t tx_rate;
307  uint16_t cnt_tx_drops;
309  uint16_t cnt_rx_acks;
315  uint32_t rtt_est;
316 
317 // 128
318 } __attribute__((packed, aligned(64)));
319 
320 #define FLEXNIC_PL_FLOWHTE_VALID (1 << 31)
321 #define FLEXNIC_PL_FLOWHTE_POSSHIFT 29
322 
325  uint32_t flow_id;
326  uint32_t flow_hash;
327 } __attribute__((packed));
328 
329 
330 #define FLEXNIC_PL_MAX_FLOWGROUPS 4096
331 
334  /* registers for application context queues */
335  struct flextcp_pl_appctx appctx[FLEXNIC_PL_APPST_CTX_MCS][FLEXNIC_PL_APPCTX_NUM];
336 
337  /* registers for flow state */
338  struct flextcp_pl_flowst flowst[FLEXNIC_PL_FLOWST_NUM];
339 
340  /* flow lookup table */
341  struct flextcp_pl_flowhte flowht[FLEXNIC_PL_FLOWHT_ENTRIES];
342 
343  /* registers for kernel queues */
344  struct flextcp_pl_appctx kctx[FLEXNIC_PL_APPST_CTX_MCS];
345 
346  /* registers for application state */
347  struct flextcp_pl_appst appst[FLEXNIC_PL_APPST_NUM];
348 
349  uint8_t flow_group_steering[FLEXNIC_PL_MAX_FLOWGROUPS];
350 } __attribute__((packed));
351 
354 #endif /* ndef FLEXTCP_PLIF_H_ */
uint32_t tx_next_seq
Definition: tas_memif.h:300
uint64_t poll_cycle_app
Definition: tas_memif.h:66
uint32_t tx_len
Definition: tas_memif.h:246
uint16_t bump_seq
Definition: tas_memif.h:263
uint16_t db_id
Definition: tas_memif.h:258
uint32_t tx_avail
Definition: tas_memif.h:293
uint32_t cores_num
Definition: tas_memif.h:72
uint32_t rx_len
Definition: tas_memif.h:244
uint64_t flags
Definition: tas_memif.h:58
uint64_t internal_mem_size
Definition: tas_memif.h:62
uint32_t rx_remote_avail
Definition: tas_memif.h:281
volatile uint32_t lock
Definition: tas_memif.h:271
uint64_t poll_cycle_tas
Definition: tas_memif.h:68
uint32_t rx_dupack_cnt
Definition: tas_memif.h:283
uint64_t rx_base_sp
Definition: tas_memif.h:239
uint32_t tx_next_ts
Definition: tas_memif.h:302
uint32_t rtt_est
Definition: tas_memif.h:315
uint32_t qmq_num
Definition: tas_memif.h:70
Definition: utils.h:44
uint32_t tx_rate
Definition: tas_memif.h:305
Definition: utils.h:45
uint32_t rx_next_seq
Definition: tas_memif.h:279
uint16_t cnt_rx_acks
Definition: tas_memif.h:309
uint16_t flow_group
Definition: tas_memif.h:261
uint64_t opaque
Definition: tas_memif.h:236
uint64_t tx_base
Definition: tas_memif.h:241
uint16_t ctx_num
Definition: tas_memif.h:195
uint16_t cnt_tx_drops
Definition: tas_memif.h:307
uint32_t cnt_rx_ack_bytes
Definition: tas_memif.h:311
uint32_t tx_next_pos
Definition: tas_memif.h:298
uint32_t rx_avail
Definition: tas_memif.h:274
uint32_t tx_sent
Definition: tas_memif.h:296
uint64_t dma_mem_size
Definition: tas_memif.h:60
uint32_t rx_next_pos
Definition: tas_memif.h:277
uint32_t cnt_rx_ecn_bytes
Definition: tas_memif.h:313
uint64_t mac_address
Definition: tas_memif.h:64