TAS
TCP Acceleration as an OS Service
kernel_appif.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 KERNEL_APPIF_H_
26 #define KERNEL_APPIF_H_
27 
28 #include <stdint.h>
29 
30 #include <utils.h>
31 
32 /******************************************************************************/
33 /* Unix socket for initialization with application */
34 
35 #define KERNEL_SOCKET_PATH "\0flexnic_os"
36 #define KERNEL_UXSOCK_MAXQ 8
37 
39  uint32_t rxq_len;
40  uint32_t txq_len;
41 } __attribute__((packed));
42 
44  uint64_t app_out_off;
45  uint64_t app_in_off;
46 
47  uint32_t app_out_len;
48  uint32_t app_in_len;
49 
50  uint32_t status;
51  uint16_t flexnic_db_id;
52  uint16_t flexnic_qs_num;
53 
54  struct {
55  uint64_t rxq_off;
56  uint64_t txq_off;
57  } __attribute__((packed)) flexnic_qs[];
58 } __attribute__((packed));
59 
60 /******************************************************************************/
61 /* App -> Kernel */
62 
63 enum kernel_appout_type {
64  KERNEL_APPOUT_INVALID = 0,
65  KERNEL_APPOUT_CONN_OPEN,
66  KERNEL_APPOUT_CONN_CLOSE,
67  KERNEL_APPOUT_CONN_MOVE,
68  KERNEL_APPOUT_LISTEN_OPEN,
69  KERNEL_APPOUT_LISTEN_CLOSE,
70  KERNEL_APPOUT_ACCEPT_CONN,
71  KERNEL_APPOUT_REQ_SCALE,
72 };
73 
76  uint64_t opaque;
77  uint32_t remote_ip;
78  uint32_t flags;
79  uint16_t remote_port;
80 } __attribute__((packed));
81 
82 #define KERNEL_APPOUT_CLOSE_RESET 0x1
83 
85  uint64_t opaque;
86  uint32_t remote_ip;
87  uint32_t local_ip;
88  uint16_t remote_port;
89  uint16_t local_port;
90  uint32_t flags;
91 } __attribute__((packed));
92 
95  uint64_t opaque;
96  uint32_t remote_ip;
97  uint32_t local_ip;
98  uint16_t remote_port;
99  uint16_t local_port;
100  uint16_t db_id;
101 } __attribute__((packed));
102 
103 #define KERNEL_APPOUT_LISTEN_REUSEPORT 0x1
104 
106  uint64_t opaque;
107  uint32_t backlog;
108  uint16_t local_port;
109  uint8_t flags;
110 } __attribute__((packed));
111 
114  uint64_t opaque;
115  uint16_t local_port;
116 } __attribute__((packed));
117 
120  uint64_t listen_opaque;
121  uint64_t conn_opaque;
122  uint16_t local_port;
123 } __attribute__((packed));
124 
127  uint32_t num_cores;
128 } __attribute__((packed));
129 
132  union {
133  struct kernel_appout_conn_open conn_open;
134  struct kernel_appout_conn_close conn_close;
135  struct kernel_appout_conn_move conn_move;
136 
137  struct kernel_appout_listen_open listen_open;
138  struct kernel_appout_listen_close listen_close;
139  struct kernel_appout_accept_conn accept_conn;
140 
141  struct kernel_appout_req_scale req_scale;
142 
143  uint8_t raw[63];
144  } __attribute__((packed)) data;
145  uint8_t type;
146 } __attribute__((packed));
147 
148 STATIC_ASSERT(sizeof(struct kernel_appout) == 64, kernel_appout_size);
149 
150 
151 /******************************************************************************/
152 /* Kernel -> App */
153 
154 enum kernel_appin_type {
155  KERNEL_APPIN_INVALID = 0,
156  KERNEL_APPIN_STATUS_CONN_CLOSE,
157  KERNEL_APPIN_STATUS_CONN_MOVE,
158  KERNEL_APPIN_STATUS_LISTEN_OPEN,
159  KERNEL_APPIN_STATUS_LISTEN_CLOSE,
160  KERNEL_APPIN_STATUS_REQ_SCALE,
161  KERNEL_APPIN_CONN_OPENED,
162  KERNEL_APPIN_LISTEN_NEWCONN,
163  KERNEL_APPIN_ACCEPTED_CONN,
164 };
165 
168  uint64_t opaque;
169  int32_t status;
170 } __attribute__((packed));
171 
174  uint64_t opaque;
175  uint64_t rx_off;
176  uint64_t tx_off;
177  uint32_t rx_len;
178  uint32_t tx_len;
179  int32_t status;
180  uint32_t seq_rx;
181  uint32_t seq_tx;
182  uint32_t flow_id;
183  uint32_t local_ip;
184  uint16_t local_port;
185  uint16_t fn_core;
186 } __attribute__((packed));
187 
190  uint64_t opaque;
191  uint32_t remote_ip;
192  uint16_t remote_port;
193 } __attribute__((packed));
194 
197  uint64_t opaque;
198  uint64_t rx_off;
199  uint64_t tx_off;
200  uint32_t rx_len;
201  uint32_t tx_len;
202  int32_t status;
203  uint32_t seq_rx;
204  uint32_t seq_tx;
205  uint32_t flow_id;
206  uint32_t local_ip;
207  uint32_t remote_ip;
208  uint16_t remote_port;
209  uint16_t fn_core;
210 } __attribute__((packed));
211 
213 struct kernel_appin {
214  union {
215  struct kernel_appin_status status;
216  struct kernel_appin_conn_opened conn_opened;
217  struct kernel_appin_listen_newconn listen_newconn;
218  struct kernel_appin_accept_conn accept_connection;
219  uint8_t raw[63];
220  } __attribute__((packed)) data;
221  uint8_t type;
222 } __attribute__((packed));
223 
224 STATIC_ASSERT(sizeof(struct kernel_appin) == 64, kernel_appin_size);
225 
226 #endif /* ndef KERNEL_APPIF_H_ */