1 /*
2  * Copyright (C) 2017 Netronome Systems, Inc.
3  *
4  * This software is dual licensed under the GNU General License Version 2,
5  * June 1991 as shown in the file COPYING in the top-level directory of this
6  * source tree or the BSD 2-Clause License provided below.  You have the
7  * option to license this software under the complete terms of either license.
8  *
9  * The BSD 2-Clause License:
10  *
11  *     Redistribution and use in source and binary forms, with or
12  *     without modification, are permitted provided that the following
13  *     conditions are met:
14  *
15  *      1. Redistributions of source code must retain the above
16  *         copyright notice, this list of conditions and the following
17  *         disclaimer.
18  *
19  *      2. Redistributions in binary form must reproduce the above
20  *         copyright notice, this list of conditions and the following
21  *         disclaimer in the documentation and/or other materials
22  *         provided with the distribution.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31  * SOFTWARE.
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 #include "../nfpcore/nfp_cpp.h"
43 
44 #define NFP_FLOWER_LAYER_META		BIT(0)
45 #define NFP_FLOWER_LAYER_PORT		BIT(1)
46 #define NFP_FLOWER_LAYER_MAC		BIT(2)
47 #define NFP_FLOWER_LAYER_TP		BIT(3)
48 #define NFP_FLOWER_LAYER_IPV4		BIT(4)
49 #define NFP_FLOWER_LAYER_IPV6		BIT(5)
50 #define NFP_FLOWER_LAYER_CT		BIT(6)
51 #define NFP_FLOWER_LAYER_VXLAN		BIT(7)
52 
53 #define NFP_FLOWER_LAYER_ETHER		BIT(3)
54 #define NFP_FLOWER_LAYER_ARP		BIT(4)
55 
56 #define NFP_FLOWER_MASK_VLAN_PRIO	GENMASK(15, 13)
57 #define NFP_FLOWER_MASK_VLAN_CFI	BIT(12)
58 #define NFP_FLOWER_MASK_VLAN_VID	GENMASK(11, 0)
59 
60 #define NFP_FLOWER_MASK_MPLS_LB		GENMASK(31, 12)
61 #define NFP_FLOWER_MASK_MPLS_TC		GENMASK(11, 9)
62 #define NFP_FLOWER_MASK_MPLS_BOS	BIT(8)
63 #define NFP_FLOWER_MASK_MPLS_Q		BIT(0)
64 
65 #define NFP_FL_SC_ACT_DROP		0x80000000
66 #define NFP_FL_SC_ACT_USER		0x7D000000
67 #define NFP_FL_SC_ACT_POPV		0x6A000000
68 #define NFP_FL_SC_ACT_NULL		0x00000000
69 
70 /* The maximum action list size (in bytes) supported by the NFP.
71  */
72 #define NFP_FL_MAX_A_SIZ		1216
73 #define NFP_FL_LW_SIZ			2
74 
75 /* Action opcodes */
76 #define NFP_FL_ACTION_OPCODE_OUTPUT		0
77 #define NFP_FL_ACTION_OPCODE_PUSH_VLAN		1
78 #define NFP_FL_ACTION_OPCODE_POP_VLAN		2
79 #define NFP_FL_ACTION_OPCODE_SET_IPV4_TUNNEL	6
80 #define NFP_FL_ACTION_OPCODE_SET_ETHERNET	7
81 #define NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS	9
82 #define NFP_FL_ACTION_OPCODE_SET_IPV6_SRC	11
83 #define NFP_FL_ACTION_OPCODE_SET_IPV6_DST	12
84 #define NFP_FL_ACTION_OPCODE_SET_UDP		14
85 #define NFP_FL_ACTION_OPCODE_SET_TCP		15
86 #define NFP_FL_ACTION_OPCODE_PRE_TUNNEL		17
87 #define NFP_FL_ACTION_OPCODE_NUM		32
88 
89 #define NFP_FL_OUT_FLAGS_LAST		BIT(15)
90 #define NFP_FL_OUT_FLAGS_USE_TUN	BIT(4)
91 #define NFP_FL_OUT_FLAGS_TYPE_IDX	GENMASK(2, 0)
92 
93 #define NFP_FL_PUSH_VLAN_PRIO		GENMASK(15, 13)
94 #define NFP_FL_PUSH_VLAN_CFI		BIT(12)
95 #define NFP_FL_PUSH_VLAN_VID		GENMASK(11, 0)
96 
97 /* Tunnel ports */
98 #define NFP_FL_PORT_TYPE_TUN		0x50000000
99 #define NFP_FL_IPV4_TUNNEL_TYPE		GENMASK(7, 4)
100 #define NFP_FL_IPV4_PRE_TUN_INDEX	GENMASK(2, 0)
101 
102 #define nfp_flower_cmsg_warn(app, fmt, args...)                         \
103 	do {                                                            \
104 		if (net_ratelimit())                                    \
105 			nfp_warn((app)->cpp, fmt, ## args);             \
106 	} while (0)
107 
108 enum nfp_flower_tun_type {
109 	NFP_FL_TUNNEL_NONE =	0,
110 	NFP_FL_TUNNEL_VXLAN =	2,
111 };
112 
113 struct nfp_fl_act_head {
114 	u8 jump_id;
115 	u8 len_lw;
116 };
117 
118 struct nfp_fl_set_eth {
119 	struct nfp_fl_act_head head;
120 	__be16 reserved;
121 	u8 eth_addr_mask[ETH_ALEN * 2];
122 	u8 eth_addr_val[ETH_ALEN * 2];
123 };
124 
125 struct nfp_fl_set_ip4_addrs {
126 	struct nfp_fl_act_head head;
127 	__be16 reserved;
128 	__be32 ipv4_src_mask;
129 	__be32 ipv4_src;
130 	__be32 ipv4_dst_mask;
131 	__be32 ipv4_dst;
132 };
133 
134 struct nfp_fl_set_ipv6_addr {
135 	struct nfp_fl_act_head head;
136 	__be16 reserved;
137 	struct {
138 		__be32 mask;
139 		__be32 exact;
140 	} ipv6[4];
141 };
142 
143 struct nfp_fl_set_tport {
144 	struct nfp_fl_act_head head;
145 	__be16 reserved;
146 	u8 tp_port_mask[4];
147 	u8 tp_port_val[4];
148 };
149 
150 struct nfp_fl_output {
151 	struct nfp_fl_act_head head;
152 	__be16 flags;
153 	__be32 port;
154 };
155 
156 struct nfp_fl_push_vlan {
157 	struct nfp_fl_act_head head;
158 	__be16 reserved;
159 	__be16 vlan_tpid;
160 	__be16 vlan_tci;
161 };
162 
163 struct nfp_fl_pop_vlan {
164 	struct nfp_fl_act_head head;
165 	__be16 reserved;
166 };
167 
168 /* Metadata without L2 (1W/4B)
169  * ----------------------------------------------------------------
170  *    3                   2                   1
171  *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
172  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
173  * |  key_layers   |    mask_id    |           reserved            |
174  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
175  */
176 struct nfp_flower_meta_one {
177 	u8 nfp_flow_key_layer;
178 	u8 mask_id;
179 	u16 reserved;
180 };
181 
182 struct nfp_fl_pre_tunnel {
183 	struct nfp_fl_act_head head;
184 	__be16 reserved;
185 	__be32 ipv4_dst;
186 	/* reserved for use with IPv6 addresses */
187 	__be32 extra[3];
188 };
189 
190 struct nfp_fl_set_vxlan {
191 	struct nfp_fl_act_head head;
192 	__be16 reserved;
193 	__be64 tun_id;
194 	__be32 tun_type_index;
195 	__be16 tun_flags;
196 	u8 ipv4_ttl;
197 	u8 ipv4_tos;
198 	__be32 extra[2];
199 } __packed;
200 
201 /* Metadata with L2 (1W/4B)
202  * ----------------------------------------------------------------
203  *    3                   2                   1
204  *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
205  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
206  * |    key_type   |    mask_id    | PCP |p|   vlan outermost VID  |
207  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
208  *                                 ^                               ^
209  *                           NOTE: |             TCI               |
210  *                                 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
211  */
212 struct nfp_flower_meta_two {
213 	u8 nfp_flow_key_layer;
214 	u8 mask_id;
215 	__be16 tci;
216 };
217 
218 /* Port details (1W/4B)
219  * ----------------------------------------------------------------
220  *    3                   2                   1
221  *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
222  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
223  * |                         port_ingress                          |
224  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
225  */
226 struct nfp_flower_in_port {
227 	__be32 in_port;
228 };
229 
230 /* L2 details (4W/16B)
231  *    3                   2                   1
232  *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
233  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
234  * |                     mac_addr_dst, 31 - 0                      |
235  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
236  * |      mac_addr_dst, 47 - 32    |     mac_addr_src, 15 - 0      |
237  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
238  * |                     mac_addr_src, 47 - 16                     |
239  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
240  * |       mpls outermost label            |  TC |B|   reserved  |q|
241  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
242  */
243 struct nfp_flower_mac_mpls {
244 	u8 mac_dst[6];
245 	u8 mac_src[6];
246 	__be32 mpls_lse;
247 };
248 
249 /* L4 ports (for UDP, TCP, SCTP) (1W/4B)
250  *    3                   2                   1
251  *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
252  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
253  * |            port_src           |           port_dst            |
254  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
255  */
256 struct nfp_flower_tp_ports {
257 	__be16 port_src;
258 	__be16 port_dst;
259 };
260 
261 /* L3 IPv4 details (3W/12B)
262  *    3                   2                   1
263  *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
264  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
265  * |    DSCP   |ECN|   protocol    |           reserved            |
266  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
267  * |                        ipv4_addr_src                          |
268  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
269  * |                        ipv4_addr_dst                          |
270  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
271  */
272 struct nfp_flower_ipv4 {
273 	u8 tos;
274 	u8 proto;
275 	u8 ttl;
276 	u8 reserved;
277 	__be32 ipv4_src;
278 	__be32 ipv4_dst;
279 };
280 
281 /* L3 IPv6 details (10W/40B)
282  *    3                   2                   1
283  *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
284  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
285  * |    DSCP   |ECN|   protocol    |          reserved             |
286  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
287  * |   ipv6_exthdr   | res |            ipv6_flow_label            |
288  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
289  * |                  ipv6_addr_src,   31 - 0                      |
290  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
291  * |                  ipv6_addr_src,  63 - 32                      |
292  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
293  * |                  ipv6_addr_src,  95 - 64                      |
294  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
295  * |                  ipv6_addr_src, 127 - 96                      |
296  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
297  * |                  ipv6_addr_dst,   31 - 0                      |
298  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
299  * |                  ipv6_addr_dst,  63 - 32                      |
300  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
301  * |                  ipv6_addr_dst,  95 - 64                      |
302  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
303  * |                  ipv6_addr_dst, 127 - 96                      |
304  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
305  */
306 struct nfp_flower_ipv6 {
307 	u8 tos;
308 	u8 proto;
309 	u8 ttl;
310 	u8 reserved;
311 	__be32 ipv6_flow_label_exthdr;
312 	struct in6_addr ipv6_src;
313 	struct in6_addr ipv6_dst;
314 };
315 
316 /* Flow Frame VXLAN --> Tunnel details (4W/16B)
317  * -----------------------------------------------------------------
318  *    3                   2                   1
319  *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
320  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
321  * |                         ipv4_addr_src                         |
322  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
323  * |                         ipv4_addr_dst                         |
324  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
325  * |           tun_flags           |       tos     |       ttl     |
326  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
327  * |   gpe_flags   |            Reserved           | Next Protocol |
328  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
329  * |                     VNI                       |   Reserved    |
330  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
331  */
332 struct nfp_flower_vxlan {
333 	__be32 ip_src;
334 	__be32 ip_dst;
335 	__be16 tun_flags;
336 	u8 tos;
337 	u8 ttl;
338 	u8 gpe_flags;
339 	u8 reserved[2];
340 	u8 nxt_proto;
341 	__be32 tun_id;
342 };
343 
344 #define NFP_FL_TUN_VNI_OFFSET 8
345 
346 /* The base header for a control message packet.
347  * Defines an 8-bit version, and an 8-bit type, padded
348  * to a 32-bit word. Rest of the packet is type-specific.
349  */
350 struct nfp_flower_cmsg_hdr {
351 	__be16 pad;
352 	u8 type;
353 	u8 version;
354 };
355 
356 #define NFP_FLOWER_CMSG_HLEN		sizeof(struct nfp_flower_cmsg_hdr)
357 #define NFP_FLOWER_CMSG_VER1		1
358 
359 /* Types defined for port related control messages  */
360 enum nfp_flower_cmsg_type_port {
361 	NFP_FLOWER_CMSG_TYPE_FLOW_ADD =		0,
362 	NFP_FLOWER_CMSG_TYPE_FLOW_DEL =		2,
363 	NFP_FLOWER_CMSG_TYPE_MAC_REPR =		7,
364 	NFP_FLOWER_CMSG_TYPE_PORT_MOD =		8,
365 	NFP_FLOWER_CMSG_TYPE_NO_NEIGH =		10,
366 	NFP_FLOWER_CMSG_TYPE_TUN_MAC =		11,
367 	NFP_FLOWER_CMSG_TYPE_ACTIVE_TUNS =	12,
368 	NFP_FLOWER_CMSG_TYPE_TUN_NEIGH =	13,
369 	NFP_FLOWER_CMSG_TYPE_TUN_IPS =		14,
370 	NFP_FLOWER_CMSG_TYPE_FLOW_STATS =	15,
371 	NFP_FLOWER_CMSG_TYPE_PORT_ECHO =	16,
372 	NFP_FLOWER_CMSG_TYPE_MAX =		32,
373 };
374 
375 /* NFP_FLOWER_CMSG_TYPE_MAC_REPR */
376 struct nfp_flower_cmsg_mac_repr {
377 	u8 reserved[3];
378 	u8 num_ports;
379 	struct {
380 		u8 idx;
381 		u8 info;
382 		u8 nbi_port;
383 		u8 phys_port;
384 	} ports[0];
385 };
386 
387 #define NFP_FLOWER_CMSG_MAC_REPR_NBI		GENMASK(1, 0)
388 
389 /* NFP_FLOWER_CMSG_TYPE_PORT_MOD */
390 struct nfp_flower_cmsg_portmod {
391 	__be32 portnum;
392 	u8 reserved;
393 	u8 info;
394 	__be16 mtu;
395 };
396 
397 #define NFP_FLOWER_CMSG_PORTMOD_INFO_LINK	BIT(0)
398 
399 enum nfp_flower_cmsg_port_type {
400 	NFP_FLOWER_CMSG_PORT_TYPE_UNSPEC =	0x0,
401 	NFP_FLOWER_CMSG_PORT_TYPE_PHYS_PORT =	0x1,
402 	NFP_FLOWER_CMSG_PORT_TYPE_PCIE_PORT =	0x2,
403 	NFP_FLOWER_CMSG_PORT_TYPE_OTHER_PORT =  0x3,
404 };
405 
406 enum nfp_flower_cmsg_port_vnic_type {
407 	NFP_FLOWER_CMSG_PORT_VNIC_TYPE_VF =	0x0,
408 	NFP_FLOWER_CMSG_PORT_VNIC_TYPE_PF =	0x1,
409 	NFP_FLOWER_CMSG_PORT_VNIC_TYPE_CTRL =	0x2,
410 };
411 
412 #define NFP_FLOWER_CMSG_PORT_TYPE		GENMASK(31, 28)
413 #define NFP_FLOWER_CMSG_PORT_SYS_ID		GENMASK(27, 24)
414 #define NFP_FLOWER_CMSG_PORT_NFP_ID		GENMASK(23, 22)
415 #define NFP_FLOWER_CMSG_PORT_PCI		GENMASK(15, 14)
416 #define NFP_FLOWER_CMSG_PORT_VNIC_TYPE		GENMASK(13, 12)
417 #define NFP_FLOWER_CMSG_PORT_VNIC		GENMASK(11, 6)
418 #define NFP_FLOWER_CMSG_PORT_PCIE_Q		GENMASK(5, 0)
419 #define NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM	GENMASK(7, 0)
420 
421 static inline u32 nfp_flower_cmsg_phys_port(u8 phys_port)
422 {
423 	return FIELD_PREP(NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM, phys_port) |
424 		FIELD_PREP(NFP_FLOWER_CMSG_PORT_TYPE,
425 			   NFP_FLOWER_CMSG_PORT_TYPE_PHYS_PORT);
426 }
427 
428 static inline u32
429 nfp_flower_cmsg_pcie_port(u8 nfp_pcie, enum nfp_flower_cmsg_port_vnic_type type,
430 			  u8 vnic, u8 q)
431 {
432 	return FIELD_PREP(NFP_FLOWER_CMSG_PORT_PCI, nfp_pcie) |
433 		FIELD_PREP(NFP_FLOWER_CMSG_PORT_VNIC_TYPE, type) |
434 		FIELD_PREP(NFP_FLOWER_CMSG_PORT_VNIC, vnic) |
435 		FIELD_PREP(NFP_FLOWER_CMSG_PORT_PCIE_Q, q) |
436 		FIELD_PREP(NFP_FLOWER_CMSG_PORT_TYPE,
437 			   NFP_FLOWER_CMSG_PORT_TYPE_PCIE_PORT);
438 }
439 
440 static inline void *nfp_flower_cmsg_get_data(struct sk_buff *skb)
441 {
442 	return (unsigned char *)skb->data + NFP_FLOWER_CMSG_HLEN;
443 }
444 
445 static inline int nfp_flower_cmsg_get_data_len(struct sk_buff *skb)
446 {
447 	return skb->len - NFP_FLOWER_CMSG_HLEN;
448 }
449 
450 struct sk_buff *
451 nfp_flower_cmsg_mac_repr_start(struct nfp_app *app, unsigned int num_ports);
452 void
453 nfp_flower_cmsg_mac_repr_add(struct sk_buff *skb, unsigned int idx,
454 			     unsigned int nbi, unsigned int nbi_port,
455 			     unsigned int phys_port);
456 int nfp_flower_cmsg_portmod(struct nfp_repr *repr, bool carrier_ok);
457 void nfp_flower_cmsg_process_rx(struct work_struct *work);
458 void nfp_flower_cmsg_rx(struct nfp_app *app, struct sk_buff *skb);
459 struct sk_buff *
460 nfp_flower_cmsg_alloc(struct nfp_app *app, unsigned int size,
461 		      enum nfp_flower_cmsg_type_port type, gfp_t flag);
462 
463 #endif
464