TAS
TCP Acceleration as an OS Service
fastpath.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 FASTPATH_H_
26 #define FASTPATH_H_
27 
28 #include <stdbool.h>
29 #include <stdint.h>
30 
31 #include <rte_interrupts.h>
32 
33 #include <tas_memif.h>
34 #include <utils_rng.h>
35 
36 #define BATCH_SIZE 16
37 #define BUFCACHE_SIZE 128
38 #define TXBUF_SIZE (2 * BATCH_SIZE)
39 
40 
42  struct rte_mempool *pool;
43  uint16_t queue_id;
44 };
45 
47 #define QMAN_SKIPLIST_LEVELS 4
48 
49 struct qman_thread {
50  /************************************/
51  /* read-only */
52  struct queue *queues;
53 
54  /************************************/
55  /* modified by owner thread */
56  uint32_t head_idx[QMAN_SKIPLIST_LEVELS];
57  uint32_t nolimit_head_idx;
58  uint32_t nolimit_tail_idx;
59  uint32_t ts_real;
60  uint32_t ts_virtual;
61  struct utils_rng rng;
62  bool nolimit_first;
63 };
64 
65 
67  struct network_thread net;
68  struct qman_thread qman;
69  struct rte_ring *qman_fwd_ring;
70  uint16_t id;
71  int evfd;
72  struct rte_epoll_event ev;
73 
74  /********************************************************/
75  /* arx cache */
76  struct flextcp_pl_arx arx_cache[BATCH_SIZE];
77  uint16_t arx_ctx[BATCH_SIZE];
78  uint16_t arx_num;
79 
80  /********************************************************/
81  /* send buffer */
82  struct network_buf_handle *tx_handles[TXBUF_SIZE];
83  uint16_t tx_num;
84 
85  /********************************************************/
86  /* polling queues */
87  uint32_t poll_next_ctx;
88 
89  /********************************************************/
90  /* pre-allocated buffers for polling doorbells and queue manager */
91  struct network_buf_handle *bufcache_handles[BUFCACHE_SIZE];
92  uint16_t bufcache_num;
93  uint16_t bufcache_head;
94 
95  uint64_t loadmon_cyc_busy;
96 
97  uint64_t kernel_drop;
98 #ifdef DATAPLANE_STATS
99  /********************************************************/
100  /* Stats */
101  uint64_t stat_qm_poll;
102  uint64_t stat_qm_empty;
103  uint64_t stat_qm_total;
104 
105  uint64_t stat_rx_poll;
106  uint64_t stat_rx_empty;
107  uint64_t stat_rx_total;
108 
109  uint64_t stat_qs_poll;
110  uint64_t stat_qs_empty;
111  uint64_t stat_qs_total;
112 
113  uint64_t stat_cyc_db;
114  uint64_t stat_cyc_qm;
115  uint64_t stat_cyc_rx;
116  uint64_t stat_cyc_qs;
117 #endif
118 };
119 
120 extern struct dataplane_context **ctxs;
121 
122 int dataplane_init(void);
123 int dataplane_context_init(struct dataplane_context *ctx);
124 void dataplane_context_destroy(struct dataplane_context *ctx);
125 void dataplane_loop(struct dataplane_context *ctx);
126 #ifdef DATAPLANE_STATS
127 void dataplane_dump_stats(void);
128 #endif
129 
130 #endif /* ndef FASTPATH_H_ */
Definition: qman.c:57