TAS
TCP Acceleration as an OS Service
fastemu.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 FASTEMU_H_
26 #define FASTEMU_H_
27 
28 
29 #include "tcp_common.h"
30 
31 /*****************************************************************************/
32 /* fast_kernel.c */
33 int fast_kernel_poll(struct dataplane_context *ctx,
34  struct network_buf_handle *nbh, uint32_t ts);
35 void fast_kernel_packet(struct dataplane_context *ctx,
36  struct network_buf_handle *nbh);
37 
38 /* fast_appctx.c */
39 void fast_appctx_poll_pf(struct dataplane_context *ctx, uint32_t id);
40 int fast_appctx_poll_fetch(struct dataplane_context *ctx, uint32_t id,
41  void **pqe);
42 int fast_appctx_poll_bump(struct dataplane_context *ctx, void *pqe,
43  struct network_buf_handle *nbh, uint32_t ts);
44 
45 int fast_appctx_poll(struct dataplane_context *ctx, uint32_t id,
46  struct network_buf_handle *nbh, uint32_t ts);
47 int fast_actx_rxq_alloc(struct dataplane_context *ctx,
48  struct flextcp_pl_appctx *actx, struct flextcp_pl_arx **arx);
49 int fast_actx_rxq_probe(struct dataplane_context *ctx, uint32_t id);
50 
51 /* fast_flows.c */
52 void fast_flows_qman_pf(struct dataplane_context *ctx, uint32_t *queues,
53  uint16_t n);
54 void fast_flows_qman_pfbufs(struct dataplane_context *ctx, uint32_t *queues,
55  uint16_t n);
56 int fast_flows_qman(struct dataplane_context *ctx, uint32_t queue,
57  struct network_buf_handle *nbh, uint32_t ts);
58 int fast_flows_qman_fwd(struct dataplane_context *ctx,
59  struct flextcp_pl_flowst *fs);
60 int fast_flows_packet(struct dataplane_context *ctx,
61  struct network_buf_handle *nbh, void *fs, struct tcp_opts *opts,
62  uint32_t ts);
63 void fast_flows_packet_fss(struct dataplane_context *ctx,
64  struct network_buf_handle **nbhs, void **fss, uint16_t n);
65 void fast_flows_packet_parse(struct dataplane_context *ctx,
66  struct network_buf_handle **nbhs, void **fss, struct tcp_opts *tos,
67  uint16_t n);
68 void fast_flows_packet_pfbufs(struct dataplane_context *ctx,
69  void **fss, uint16_t n);
70 void fast_flows_kernelxsums(struct network_buf_handle *nbh,
71  struct pkt_tcp *p);
72 
73 int fast_flows_bump(struct dataplane_context *ctx, uint32_t flow_id,
74  uint16_t bump_seq, uint32_t rx_tail, uint32_t tx_head, uint8_t flags,
75  struct network_buf_handle *nbh, uint32_t ts);
76 void fast_flows_retransmit(struct dataplane_context *ctx, uint32_t flow_id);
77 
78 /*****************************************************************************/
79 /* Helpers */
80 
81 static inline void tx_send(struct dataplane_context *ctx,
82  struct network_buf_handle *nbh, uint16_t off, uint16_t len)
83 {
84  uint32_t i = ctx->tx_num;
85 
86  if (i >= TXBUF_SIZE) {
87  fprintf(stderr, "tx_send: transmit buffer full, unexpected\n");
88  abort();
89  }
90 
91  network_buf_setoff(nbh, off);
92  network_buf_setlen(nbh, len);
93  ctx->tx_handles[i] = nbh;
94  ctx->tx_num = i + 1;
95 }
96 
97 static inline uint16_t tx_xsum_enable(struct network_buf_handle *nbh,
98  struct ip_hdr *iph, beui32_t ip_s, beui32_t ip_d, uint16_t l3_paylen)
99 {
100  return network_buf_tcpxsums(nbh, sizeof(struct eth_hdr), sizeof(*iph), iph,
101  ip_s, ip_d, IP_PROTO_TCP, l3_paylen);
102 }
103 
104 static inline void arx_cache_add(struct dataplane_context *ctx, uint16_t ctx_id,
105  uint64_t opaque, uint32_t rx_bump, uint32_t rx_pos, uint32_t tx_bump,
106  uint16_t type_flags)
107 {
108  uint16_t id = ctx->arx_num++;
109 
110  ctx->arx_ctx[id] = ctx_id;
111  ctx->arx_cache[id].type = type_flags & 0xff;
112  ctx->arx_cache[id].msg.connupdate.opaque = opaque;
113  ctx->arx_cache[id].msg.connupdate.rx_bump = rx_bump;
114  ctx->arx_cache[id].msg.connupdate.rx_pos = rx_pos;
115  ctx->arx_cache[id].msg.connupdate.tx_bump = tx_bump;
116  ctx->arx_cache[id].msg.connupdate.flags = type_flags >> 8;
117 }
118 
119 #endif /* ndef FASTEMU_H_ */
Definition: qman.c:57
Definition: utils.h:45