1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 /* Copyright (C) 2017-2018 Netronome Systems, Inc. */
4 #ifndef NFP_FLOWER_CMSG_H
5 #define NFP_FLOWER_CMSG_H
7 #include <linux/bitfield.h>
8 #include <linux/skbuff.h>
9 #include <linux/types.h>
10 #include <net/geneve.h>
12 #include <net/vxlan.h>
14 #include "../nfp_app.h"
15 #include "../nfpcore/nfp_cpp.h"
17 #define NFP_FLOWER_LAYER_EXT_META BIT(0)
18 #define NFP_FLOWER_LAYER_PORT BIT(1)
19 #define NFP_FLOWER_LAYER_MAC BIT(2)
20 #define NFP_FLOWER_LAYER_TP BIT(3)
21 #define NFP_FLOWER_LAYER_IPV4 BIT(4)
22 #define NFP_FLOWER_LAYER_IPV6 BIT(5)
23 #define NFP_FLOWER_LAYER_CT BIT(6)
24 #define NFP_FLOWER_LAYER_VXLAN BIT(7)
26 #define NFP_FLOWER_LAYER2_GRE BIT(0)
27 #define NFP_FLOWER_LAYER2_QINQ BIT(4)
28 #define NFP_FLOWER_LAYER2_GENEVE BIT(5)
29 #define NFP_FLOWER_LAYER2_GENEVE_OP BIT(6)
30 #define NFP_FLOWER_LAYER2_TUN_IPV6 BIT(7)
32 #define NFP_FLOWER_MASK_VLAN_PRIO GENMASK(15, 13)
33 #define NFP_FLOWER_MASK_VLAN_PRESENT BIT(12)
34 #define NFP_FLOWER_MASK_VLAN_VID GENMASK(11, 0)
36 #define NFP_FLOWER_MASK_MPLS_LB GENMASK(31, 12)
37 #define NFP_FLOWER_MASK_MPLS_TC GENMASK(11, 9)
38 #define NFP_FLOWER_MASK_MPLS_BOS BIT(8)
39 #define NFP_FLOWER_MASK_MPLS_Q BIT(0)
41 #define NFP_FL_IP_FRAG_FIRST BIT(7)
42 #define NFP_FL_IP_FRAGMENTED BIT(6)
44 /* GRE Tunnel flags */
45 #define NFP_FL_GRE_FLAG_KEY BIT(2)
47 /* Compressed HW representation of TCP Flags */
48 #define NFP_FL_TCP_FLAG_URG BIT(4)
49 #define NFP_FL_TCP_FLAG_PSH BIT(3)
50 #define NFP_FL_TCP_FLAG_RST BIT(2)
51 #define NFP_FL_TCP_FLAG_SYN BIT(1)
52 #define NFP_FL_TCP_FLAG_FIN BIT(0)
54 #define NFP_FL_SC_ACT_DROP 0x80000000
55 #define NFP_FL_SC_ACT_USER 0x7D000000
56 #define NFP_FL_SC_ACT_POPV 0x6A000000
57 #define NFP_FL_SC_ACT_NULL 0x00000000
59 /* The maximum action list size (in bytes) supported by the NFP.
61 #define NFP_FL_MAX_A_SIZ 1216
62 #define NFP_FL_LW_SIZ 2
64 /* Maximum allowed geneve options */
65 #define NFP_FL_MAX_GENEVE_OPT_ACT 32
66 #define NFP_FL_MAX_GENEVE_OPT_CNT 64
67 #define NFP_FL_MAX_GENEVE_OPT_KEY 32
68 #define NFP_FL_MAX_GENEVE_OPT_KEY_V6 8
71 #define NFP_FL_ACTION_OPCODE_OUTPUT 0
72 #define NFP_FL_ACTION_OPCODE_PUSH_VLAN 1
73 #define NFP_FL_ACTION_OPCODE_POP_VLAN 2
74 #define NFP_FL_ACTION_OPCODE_PUSH_MPLS 3
75 #define NFP_FL_ACTION_OPCODE_POP_MPLS 4
76 #define NFP_FL_ACTION_OPCODE_SET_TUNNEL 6
77 #define NFP_FL_ACTION_OPCODE_SET_ETHERNET 7
78 #define NFP_FL_ACTION_OPCODE_SET_MPLS 8
79 #define NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS 9
80 #define NFP_FL_ACTION_OPCODE_SET_IPV4_TTL_TOS 10
81 #define NFP_FL_ACTION_OPCODE_SET_IPV6_SRC 11
82 #define NFP_FL_ACTION_OPCODE_SET_IPV6_DST 12
83 #define NFP_FL_ACTION_OPCODE_SET_IPV6_TC_HL_FL 13
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_LAG 16
87 #define NFP_FL_ACTION_OPCODE_PRE_TUNNEL 17
88 #define NFP_FL_ACTION_OPCODE_METER 24
89 #define NFP_FL_ACTION_OPCODE_PUSH_GENEVE 26
90 #define NFP_FL_ACTION_OPCODE_NUM 32
92 #define NFP_FL_OUT_FLAGS_LAST BIT(15)
93 #define NFP_FL_OUT_FLAGS_USE_TUN BIT(4)
94 #define NFP_FL_OUT_FLAGS_TYPE_IDX GENMASK(2, 0)
96 #define NFP_FL_PUSH_VLAN_PRIO GENMASK(15, 13)
97 #define NFP_FL_PUSH_VLAN_VID GENMASK(11, 0)
100 #define NFP_FL_LAG_OUT 0xC0DE0000
103 #define NFP_FL_PORT_TYPE_TUN 0x50000000
104 #define NFP_FL_TUNNEL_TYPE GENMASK(7, 4)
105 #define NFP_FL_PRE_TUN_INDEX GENMASK(2, 0)
107 #define NFP_FLOWER_WORKQ_MAX_SKBS 30000
109 /* Cmesg reply (empirical) timeout*/
110 #define NFP_FL_REPLY_TIMEOUT msecs_to_jiffies(40)
112 #define nfp_flower_cmsg_warn(app, fmt, args...) \
114 if (net_ratelimit()) \
115 nfp_warn((app)->cpp, fmt, ## args); \
118 enum nfp_flower_tun_type
{
119 NFP_FL_TUNNEL_NONE
= 0,
120 NFP_FL_TUNNEL_GRE
= 1,
121 NFP_FL_TUNNEL_VXLAN
= 2,
122 NFP_FL_TUNNEL_GENEVE
= 4,
125 struct nfp_fl_act_head
{
130 struct nfp_fl_set_eth
{
131 struct nfp_fl_act_head head
;
133 u8 eth_addr_mask
[ETH_ALEN
* 2];
134 u8 eth_addr_val
[ETH_ALEN
* 2];
137 struct nfp_fl_set_ip4_addrs
{
138 struct nfp_fl_act_head head
;
140 __be32 ipv4_src_mask
;
142 __be32 ipv4_dst_mask
;
146 struct nfp_fl_set_ip4_ttl_tos
{
147 struct nfp_fl_act_head head
;
155 struct nfp_fl_set_ipv6_tc_hl_fl
{
156 struct nfp_fl_act_head head
;
158 u8 ipv6_hop_limit_mask
;
162 __be32 ipv6_label_mask
;
166 struct nfp_fl_set_ipv6_addr
{
167 struct nfp_fl_act_head head
;
175 struct nfp_fl_set_tport
{
176 struct nfp_fl_act_head head
;
182 struct nfp_fl_output
{
183 struct nfp_fl_act_head head
;
188 struct nfp_fl_push_vlan
{
189 struct nfp_fl_act_head head
;
195 struct nfp_fl_pop_vlan
{
196 struct nfp_fl_act_head head
;
200 struct nfp_fl_pre_lag
{
201 struct nfp_fl_act_head head
;
207 #define NFP_FL_PRE_LAG_VER_OFF 8
209 struct nfp_fl_pre_tunnel
{
210 struct nfp_fl_act_head head
;
214 struct in6_addr ipv6_dst
;
218 #define NFP_FL_PRE_TUN_IPV6 BIT(0)
220 struct nfp_fl_set_tun
{
221 struct nfp_fl_act_head head
;
223 __be64 tun_id __packed
;
224 __be32 tun_type_index
;
228 __be16 outer_vlan_tpid
;
229 __be16 outer_vlan_tci
;
235 struct nfp_fl_push_geneve
{
236 struct nfp_fl_act_head head
;
244 struct nfp_fl_push_mpls
{
245 struct nfp_fl_act_head head
;
250 struct nfp_fl_pop_mpls
{
251 struct nfp_fl_act_head head
;
255 struct nfp_fl_set_mpls
{
256 struct nfp_fl_act_head head
;
262 struct nfp_fl_meter
{
263 struct nfp_fl_act_head head
;
268 /* Metadata with L2 (1W/4B)
269 * ----------------------------------------------------------------
271 * 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
272 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
273 * | key_type | mask_id | PCP |p| vlan outermost VID |
274 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
277 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
279 struct nfp_flower_meta_tci
{
280 u8 nfp_flow_key_layer
;
285 /* Extended metadata for additional key_layers (1W/4B)
286 * ----------------------------------------------------------------
288 * 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
289 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
290 * | nfp_flow_key_layer2 |
291 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
293 struct nfp_flower_ext_meta
{
294 __be32 nfp_flow_key_layer2
;
297 /* Port details (1W/4B)
298 * ----------------------------------------------------------------
300 * 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
301 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
303 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
305 struct nfp_flower_in_port
{
309 /* L2 details (4W/16B)
311 * 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
312 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
313 * | mac_addr_dst, 31 - 0 |
314 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
315 * | mac_addr_dst, 47 - 32 | mac_addr_src, 15 - 0 |
316 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
317 * | mac_addr_src, 47 - 16 |
318 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
319 * | mpls outermost label | TC |B| reserved |q|
320 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
322 struct nfp_flower_mac_mpls
{
328 /* VLAN details (2W/8B)
330 * 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
331 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
332 * | outer_tpid | outer_tci |
333 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
334 * | inner_tpid | inner_tci |
335 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
337 struct nfp_flower_vlan
{
344 /* L4 ports (for UDP, TCP, SCTP) (1W/4B)
346 * 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
347 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
348 * | port_src | port_dst |
349 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
351 struct nfp_flower_tp_ports
{
356 struct nfp_flower_ip_ext
{
363 /* L3 IPv4 details (3W/12B)
365 * 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
366 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
367 * | DSCP |ECN| protocol | ttl | flags |
368 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
370 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
372 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
374 struct nfp_flower_ipv4
{
375 struct nfp_flower_ip_ext ip_ext
;
380 /* L3 IPv6 details (10W/40B)
382 * 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
383 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
384 * | DSCP |ECN| protocol | ttl | flags |
385 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
386 * | ipv6_exthdr | res | ipv6_flow_label |
387 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
388 * | ipv6_addr_src, 31 - 0 |
389 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
390 * | ipv6_addr_src, 63 - 32 |
391 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
392 * | ipv6_addr_src, 95 - 64 |
393 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
394 * | ipv6_addr_src, 127 - 96 |
395 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
396 * | ipv6_addr_dst, 31 - 0 |
397 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
398 * | ipv6_addr_dst, 63 - 32 |
399 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
400 * | ipv6_addr_dst, 95 - 64 |
401 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
402 * | ipv6_addr_dst, 127 - 96 |
403 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
405 struct nfp_flower_ipv6
{
406 struct nfp_flower_ip_ext ip_ext
;
407 __be32 ipv6_flow_label_exthdr
;
408 struct in6_addr ipv6_src
;
409 struct in6_addr ipv6_dst
;
412 struct nfp_flower_tun_ipv4
{
417 struct nfp_flower_tun_ipv6
{
422 struct nfp_flower_tun_ip_ext
{
427 /* Flow Frame IPv4 UDP TUNNEL --> Tunnel details (4W/16B)
428 * -----------------------------------------------------------------
430 * 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
431 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
433 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
435 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
436 * | Reserved | tos | ttl |
437 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
439 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
441 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
443 struct nfp_flower_ipv4_udp_tun
{
444 struct nfp_flower_tun_ipv4 ipv4
;
446 struct nfp_flower_tun_ip_ext ip_ext
;
451 /* Flow Frame IPv6 UDP TUNNEL --> Tunnel details (11W/44B)
452 * -----------------------------------------------------------------
454 * 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
455 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
456 * | ipv6_addr_src, 31 - 0 |
457 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
458 * | ipv6_addr_src, 63 - 32 |
459 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
460 * | ipv6_addr_src, 95 - 64 |
461 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
462 * | ipv6_addr_src, 127 - 96 |
463 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
464 * | ipv6_addr_dst, 31 - 0 |
465 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
466 * | ipv6_addr_dst, 63 - 32 |
467 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
468 * | ipv6_addr_dst, 95 - 64 |
469 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
470 * | ipv6_addr_dst, 127 - 96 |
471 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
472 * | Reserved | tos | ttl |
473 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
475 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
477 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
479 struct nfp_flower_ipv6_udp_tun
{
480 struct nfp_flower_tun_ipv6 ipv6
;
482 struct nfp_flower_tun_ip_ext ip_ext
;
487 /* Flow Frame GRE TUNNEL --> Tunnel details (6W/24B)
488 * -----------------------------------------------------------------
490 * 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
491 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
493 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
495 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
496 * | tun_flags | tos | ttl |
497 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
498 * | Reserved | Ethertype |
499 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
501 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
503 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
506 struct nfp_flower_ipv4_gre_tun
{
507 struct nfp_flower_tun_ipv4 ipv4
;
509 struct nfp_flower_tun_ip_ext ip_ext
;
516 /* Flow Frame GRE TUNNEL V6 --> Tunnel details (12W/48B)
517 * -----------------------------------------------------------------
519 * 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
520 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
521 * | ipv6_addr_src, 31 - 0 |
522 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
523 * | ipv6_addr_src, 63 - 32 |
524 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
525 * | ipv6_addr_src, 95 - 64 |
526 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
527 * | ipv6_addr_src, 127 - 96 |
528 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
529 * | ipv6_addr_dst, 31 - 0 |
530 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
531 * | ipv6_addr_dst, 63 - 32 |
532 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
533 * | ipv6_addr_dst, 95 - 64 |
534 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
535 * | ipv6_addr_dst, 127 - 96 |
536 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
537 * | tun_flags | tos | ttl |
538 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
539 * | Reserved | Ethertype |
540 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
542 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
544 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
546 struct nfp_flower_ipv6_gre_tun
{
547 struct nfp_flower_tun_ipv6 ipv6
;
549 struct nfp_flower_tun_ip_ext ip_ext
;
556 struct nfp_flower_geneve_options
{
557 u8 data
[NFP_FL_MAX_GENEVE_OPT_KEY
];
560 #define NFP_FL_TUN_VNI_OFFSET 8
562 /* The base header for a control message packet.
563 * Defines an 8-bit version, and an 8-bit type, padded
564 * to a 32-bit word. Rest of the packet is type-specific.
566 struct nfp_flower_cmsg_hdr
{
572 #define NFP_FLOWER_CMSG_HLEN sizeof(struct nfp_flower_cmsg_hdr)
573 #define NFP_FLOWER_CMSG_VER1 1
575 /* Types defined for port related control messages */
576 enum nfp_flower_cmsg_type_port
{
577 NFP_FLOWER_CMSG_TYPE_FLOW_ADD
= 0,
578 NFP_FLOWER_CMSG_TYPE_FLOW_MOD
= 1,
579 NFP_FLOWER_CMSG_TYPE_FLOW_DEL
= 2,
580 NFP_FLOWER_CMSG_TYPE_LAG_CONFIG
= 4,
581 NFP_FLOWER_CMSG_TYPE_PORT_REIFY
= 6,
582 NFP_FLOWER_CMSG_TYPE_MAC_REPR
= 7,
583 NFP_FLOWER_CMSG_TYPE_PORT_MOD
= 8,
584 NFP_FLOWER_CMSG_TYPE_MERGE_HINT
= 9,
585 NFP_FLOWER_CMSG_TYPE_NO_NEIGH
= 10,
586 NFP_FLOWER_CMSG_TYPE_TUN_MAC
= 11,
587 NFP_FLOWER_CMSG_TYPE_ACTIVE_TUNS
= 12,
588 NFP_FLOWER_CMSG_TYPE_TUN_NEIGH
= 13,
589 NFP_FLOWER_CMSG_TYPE_TUN_IPS
= 14,
590 NFP_FLOWER_CMSG_TYPE_FLOW_STATS
= 15,
591 NFP_FLOWER_CMSG_TYPE_PORT_ECHO
= 16,
592 NFP_FLOWER_CMSG_TYPE_QOS_MOD
= 18,
593 NFP_FLOWER_CMSG_TYPE_QOS_DEL
= 19,
594 NFP_FLOWER_CMSG_TYPE_QOS_STATS
= 20,
595 NFP_FLOWER_CMSG_TYPE_PRE_TUN_RULE
= 21,
596 NFP_FLOWER_CMSG_TYPE_TUN_IPS_V6
= 22,
597 NFP_FLOWER_CMSG_TYPE_NO_NEIGH_V6
= 23,
598 NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V6
= 24,
599 NFP_FLOWER_CMSG_TYPE_ACTIVE_TUNS_V6
= 25,
600 NFP_FLOWER_CMSG_TYPE_MAX
= 32,
603 /* NFP_FLOWER_CMSG_TYPE_MAC_REPR */
604 struct nfp_flower_cmsg_mac_repr
{
615 #define NFP_FLOWER_CMSG_MAC_REPR_NBI GENMASK(1, 0)
617 /* NFP_FLOWER_CMSG_TYPE_PORT_MOD */
618 struct nfp_flower_cmsg_portmod
{
625 #define NFP_FLOWER_CMSG_PORTMOD_INFO_LINK BIT(0)
626 #define NFP_FLOWER_CMSG_PORTMOD_MTU_CHANGE_ONLY BIT(1)
628 /* NFP_FLOWER_CMSG_TYPE_PORT_REIFY */
629 struct nfp_flower_cmsg_portreify
{
635 #define NFP_FLOWER_CMSG_PORTREIFY_INFO_EXIST BIT(0)
637 /* NFP_FLOWER_CMSG_TYPE_FLOW_MERGE_HINT */
638 struct nfp_flower_cmsg_merge_hint
{
647 enum nfp_flower_cmsg_port_type
{
648 NFP_FLOWER_CMSG_PORT_TYPE_UNSPEC
= 0x0,
649 NFP_FLOWER_CMSG_PORT_TYPE_PHYS_PORT
= 0x1,
650 NFP_FLOWER_CMSG_PORT_TYPE_PCIE_PORT
= 0x2,
651 NFP_FLOWER_CMSG_PORT_TYPE_OTHER_PORT
= 0x3,
654 enum nfp_flower_cmsg_port_vnic_type
{
655 NFP_FLOWER_CMSG_PORT_VNIC_TYPE_VF
= 0x0,
656 NFP_FLOWER_CMSG_PORT_VNIC_TYPE_PF
= 0x1,
657 NFP_FLOWER_CMSG_PORT_VNIC_TYPE_CTRL
= 0x2,
660 #define NFP_FLOWER_CMSG_PORT_TYPE GENMASK(31, 28)
661 #define NFP_FLOWER_CMSG_PORT_SYS_ID GENMASK(27, 24)
662 #define NFP_FLOWER_CMSG_PORT_NFP_ID GENMASK(23, 22)
663 #define NFP_FLOWER_CMSG_PORT_PCI GENMASK(15, 14)
664 #define NFP_FLOWER_CMSG_PORT_VNIC_TYPE GENMASK(13, 12)
665 #define NFP_FLOWER_CMSG_PORT_VNIC GENMASK(11, 6)
666 #define NFP_FLOWER_CMSG_PORT_PCIE_Q GENMASK(5, 0)
667 #define NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM GENMASK(7, 0)
669 static inline u32
nfp_flower_internal_port_get_port_id(u8 internal_port
)
671 return FIELD_PREP(NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM
, internal_port
) |
672 FIELD_PREP(NFP_FLOWER_CMSG_PORT_TYPE
,
673 NFP_FLOWER_CMSG_PORT_TYPE_OTHER_PORT
);
676 static inline u32
nfp_flower_cmsg_phys_port(u8 phys_port
)
678 return FIELD_PREP(NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM
, phys_port
) |
679 FIELD_PREP(NFP_FLOWER_CMSG_PORT_TYPE
,
680 NFP_FLOWER_CMSG_PORT_TYPE_PHYS_PORT
);
684 nfp_flower_cmsg_pcie_port(u8 nfp_pcie
, enum nfp_flower_cmsg_port_vnic_type type
,
687 return FIELD_PREP(NFP_FLOWER_CMSG_PORT_PCI
, nfp_pcie
) |
688 FIELD_PREP(NFP_FLOWER_CMSG_PORT_VNIC_TYPE
, type
) |
689 FIELD_PREP(NFP_FLOWER_CMSG_PORT_VNIC
, vnic
) |
690 FIELD_PREP(NFP_FLOWER_CMSG_PORT_PCIE_Q
, q
) |
691 FIELD_PREP(NFP_FLOWER_CMSG_PORT_TYPE
,
692 NFP_FLOWER_CMSG_PORT_TYPE_PCIE_PORT
);
695 static inline void *nfp_flower_cmsg_get_data(struct sk_buff
*skb
)
697 return (unsigned char *)skb
->data
+ NFP_FLOWER_CMSG_HLEN
;
700 static inline int nfp_flower_cmsg_get_data_len(struct sk_buff
*skb
)
702 return skb
->len
- NFP_FLOWER_CMSG_HLEN
;
706 nfp_fl_netdev_is_tunnel_type(struct net_device
*netdev
,
707 enum nfp_flower_tun_type tun_type
)
709 if (netif_is_vxlan(netdev
))
710 return tun_type
== NFP_FL_TUNNEL_VXLAN
;
711 if (netif_is_gretap(netdev
) || netif_is_ip6gretap(netdev
))
712 return tun_type
== NFP_FL_TUNNEL_GRE
;
713 if (netif_is_geneve(netdev
))
714 return tun_type
== NFP_FL_TUNNEL_GENEVE
;
719 static inline bool nfp_fl_is_netdev_to_offload(struct net_device
*netdev
)
721 if (!netdev
->rtnl_link_ops
)
723 if (!strcmp(netdev
->rtnl_link_ops
->kind
, "openvswitch"))
725 if (netif_is_vxlan(netdev
))
727 if (netif_is_geneve(netdev
))
729 if (netif_is_gretap(netdev
))
731 if (netif_is_ip6gretap(netdev
))
738 nfp_flower_cmsg_mac_repr_start(struct nfp_app
*app
, unsigned int num_ports
);
740 nfp_flower_cmsg_mac_repr_add(struct sk_buff
*skb
, unsigned int idx
,
741 unsigned int nbi
, unsigned int nbi_port
,
742 unsigned int phys_port
);
743 int nfp_flower_cmsg_portmod(struct nfp_repr
*repr
, bool carrier_ok
,
744 unsigned int mtu
, bool mtu_only
);
745 int nfp_flower_cmsg_portreify(struct nfp_repr
*repr
, bool exists
);
746 void nfp_flower_cmsg_process_rx(struct work_struct
*work
);
747 void nfp_flower_cmsg_rx(struct nfp_app
*app
, struct sk_buff
*skb
);
749 nfp_flower_cmsg_alloc(struct nfp_app
*app
, unsigned int size
,
750 enum nfp_flower_cmsg_type_port type
, gfp_t flag
);