1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34#ifndef NFP_FLOWER_CMSG_H
35#define NFP_FLOWER_CMSG_H
36
37#include <linux/bitfield.h>
38#include <linux/skbuff.h>
39#include <linux/types.h>
40
41#include "../nfp_app.h"
42
43#define NFP_FLOWER_LAYER_META BIT(0)
44#define NFP_FLOWER_LAYER_PORT BIT(1)
45#define NFP_FLOWER_LAYER_MAC BIT(2)
46#define NFP_FLOWER_LAYER_TP BIT(3)
47#define NFP_FLOWER_LAYER_IPV4 BIT(4)
48#define NFP_FLOWER_LAYER_IPV6 BIT(5)
49#define NFP_FLOWER_LAYER_CT BIT(6)
50#define NFP_FLOWER_LAYER_VXLAN BIT(7)
51
52#define NFP_FLOWER_LAYER_ETHER BIT(3)
53#define NFP_FLOWER_LAYER_ARP BIT(4)
54
55#define NFP_FLOWER_MASK_VLAN_PRIO GENMASK(15, 13)
56#define NFP_FLOWER_MASK_VLAN_CFI BIT(12)
57#define NFP_FLOWER_MASK_VLAN_VID GENMASK(11, 0)
58
59#define NFP_FL_SC_ACT_DROP 0x80000000
60#define NFP_FL_SC_ACT_USER 0x7D000000
61#define NFP_FL_SC_ACT_POPV 0x6A000000
62#define NFP_FL_SC_ACT_NULL 0x00000000
63
64
65
66#define NFP_FL_MAX_A_SIZ 1216
67#define NFP_FL_LW_SIZ 2
68
69
70#define NFP_FL_ACTION_OPCODE_OUTPUT 0
71#define NFP_FL_ACTION_OPCODE_PUSH_VLAN 1
72#define NFP_FL_ACTION_OPCODE_POP_VLAN 2
73#define NFP_FL_ACTION_OPCODE_NUM 32
74
75#define NFP_FL_ACT_JMP_ID GENMASK(15, 8)
76#define NFP_FL_ACT_LEN_LW GENMASK(7, 0)
77
78#define NFP_FL_OUT_FLAGS_LAST BIT(15)
79#define NFP_FL_OUT_FLAGS_USE_TUN BIT(4)
80#define NFP_FL_OUT_FLAGS_TYPE_IDX GENMASK(2, 0)
81
82#define NFP_FL_PUSH_VLAN_PRIO GENMASK(15, 13)
83#define NFP_FL_PUSH_VLAN_CFI BIT(12)
84#define NFP_FL_PUSH_VLAN_VID GENMASK(11, 0)
85
86struct nfp_fl_output {
87 __be16 a_op;
88 __be16 flags;
89 __be32 port;
90};
91
92struct nfp_fl_push_vlan {
93 __be16 a_op;
94 __be16 reserved;
95 __be16 vlan_tpid;
96 __be16 vlan_tci;
97};
98
99struct nfp_fl_pop_vlan {
100 __be16 a_op;
101 __be16 reserved;
102};
103
104
105
106
107
108
109
110
111
112struct nfp_flower_meta_one {
113 u8 nfp_flow_key_layer;
114 u8 mask_id;
115 u16 reserved;
116};
117
118
119
120
121
122
123
124
125
126
127
128
129struct nfp_flower_meta_two {
130 u8 nfp_flow_key_layer;
131 u8 mask_id;
132 __be16 tci;
133};
134
135
136
137
138
139
140
141
142
143struct nfp_flower_in_port {
144 __be32 in_port;
145};
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160struct nfp_flower_mac_mpls {
161 u8 mac_dst[6];
162 u8 mac_src[6];
163 __be32 mpls_lse;
164};
165
166
167
168
169
170
171
172
173struct nfp_flower_tp_ports {
174 __be16 port_src;
175 __be16 port_dst;
176};
177
178
179
180
181
182
183
184
185
186
187
188
189struct nfp_flower_ipv4 {
190 u8 tos;
191 u8 proto;
192 u8 ttl;
193 u8 reserved;
194 __be32 ipv4_src;
195 __be32 ipv4_dst;
196};
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223struct nfp_flower_ipv6 {
224 u8 tos;
225 u8 proto;
226 u8 ttl;
227 u8 reserved;
228 __be32 ipv6_flow_label_exthdr;
229 struct in6_addr ipv6_src;
230 struct in6_addr ipv6_dst;
231};
232
233
234
235
236
237struct nfp_flower_cmsg_hdr {
238 __be16 pad;
239 u8 type;
240 u8 version;
241};
242
243#define NFP_FLOWER_CMSG_HLEN sizeof(struct nfp_flower_cmsg_hdr)
244#define NFP_FLOWER_CMSG_VER1 1
245
246
247enum nfp_flower_cmsg_type_port {
248 NFP_FLOWER_CMSG_TYPE_FLOW_ADD = 0,
249 NFP_FLOWER_CMSG_TYPE_FLOW_DEL = 2,
250 NFP_FLOWER_CMSG_TYPE_PORT_MOD = 8,
251 NFP_FLOWER_CMSG_TYPE_FLOW_STATS = 15,
252 NFP_FLOWER_CMSG_TYPE_PORT_ECHO = 16,
253 NFP_FLOWER_CMSG_TYPE_MAX = 32,
254};
255
256
257struct nfp_flower_cmsg_portmod {
258 __be32 portnum;
259 u8 reserved;
260 u8 info;
261 __be16 mtu;
262};
263
264#define NFP_FLOWER_CMSG_PORTMOD_INFO_LINK BIT(0)
265
266enum nfp_flower_cmsg_port_type {
267 NFP_FLOWER_CMSG_PORT_TYPE_UNSPEC = 0x0,
268 NFP_FLOWER_CMSG_PORT_TYPE_PHYS_PORT = 0x1,
269 NFP_FLOWER_CMSG_PORT_TYPE_PCIE_PORT = 0x2,
270};
271
272enum nfp_flower_cmsg_port_vnic_type {
273 NFP_FLOWER_CMSG_PORT_VNIC_TYPE_VF = 0x0,
274 NFP_FLOWER_CMSG_PORT_VNIC_TYPE_PF = 0x1,
275 NFP_FLOWER_CMSG_PORT_VNIC_TYPE_CTRL = 0x2,
276};
277
278#define NFP_FLOWER_CMSG_PORT_TYPE GENMASK(31, 28)
279#define NFP_FLOWER_CMSG_PORT_SYS_ID GENMASK(27, 24)
280#define NFP_FLOWER_CMSG_PORT_NFP_ID GENMASK(23, 22)
281#define NFP_FLOWER_CMSG_PORT_PCI GENMASK(15, 14)
282#define NFP_FLOWER_CMSG_PORT_VNIC_TYPE GENMASK(13, 12)
283#define NFP_FLOWER_CMSG_PORT_VNIC GENMASK(11, 6)
284#define NFP_FLOWER_CMSG_PORT_PCIE_Q GENMASK(5, 0)
285#define NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM GENMASK(7, 0)
286
287static inline u32 nfp_flower_cmsg_phys_port(u8 phys_port)
288{
289 return FIELD_PREP(NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM, phys_port) |
290 FIELD_PREP(NFP_FLOWER_CMSG_PORT_TYPE,
291 NFP_FLOWER_CMSG_PORT_TYPE_PHYS_PORT);
292}
293
294static inline u32
295nfp_flower_cmsg_pcie_port(u8 nfp_pcie, enum nfp_flower_cmsg_port_vnic_type type,
296 u8 vnic, u8 q)
297{
298 return FIELD_PREP(NFP_FLOWER_CMSG_PORT_PCI, nfp_pcie) |
299 FIELD_PREP(NFP_FLOWER_CMSG_PORT_VNIC_TYPE, type) |
300 FIELD_PREP(NFP_FLOWER_CMSG_PORT_VNIC, vnic) |
301 FIELD_PREP(NFP_FLOWER_CMSG_PORT_PCIE_Q, q) |
302 FIELD_PREP(NFP_FLOWER_CMSG_PORT_TYPE,
303 NFP_FLOWER_CMSG_PORT_TYPE_PCIE_PORT);
304}
305
306static inline void *nfp_flower_cmsg_get_data(struct sk_buff *skb)
307{
308 return (unsigned char *)skb->data + NFP_FLOWER_CMSG_HLEN;
309}
310
311int nfp_flower_cmsg_portmod(struct nfp_repr *repr, bool carrier_ok);
312void nfp_flower_cmsg_rx(struct nfp_app *app, struct sk_buff *skb);
313struct sk_buff *
314nfp_flower_cmsg_alloc(struct nfp_app *app, unsigned int size,
315 enum nfp_flower_cmsg_type_port type);
316
317#endif
318