1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (C) 2024 Intel Corporation */
4 #include <linux/net/intel/libie/rx.h>
6 /* O(1) converting i40e/ice/iavf's 8/10-bit hardware packet type to a parsed
10 /* A few supplementary definitions for when XDP hash types do not coincide
11 * with what can be generated from ptype definitions by means of preprocessor
14 #define XDP_RSS_L3_L2 XDP_RSS_TYPE_NONE
15 #define XDP_RSS_L4_NONE XDP_RSS_TYPE_NONE
16 #define XDP_RSS_L4_TIMESYNC XDP_RSS_TYPE_NONE
17 #define XDP_RSS_TYPE_L3 XDP_RSS_TYPE_NONE
18 #define XDP_RSS_TYPE_L4 XDP_RSS_L4
20 #define LIBIE_RX_PT(oip, ofrag, tun, tp, tefr, iprot, pl) { \
21 .outer_ip = LIBETH_RX_PT_OUTER_##oip, \
22 .outer_frag = LIBETH_RX_PT_##ofrag, \
23 .tunnel_type = LIBETH_RX_PT_TUNNEL_IP_##tun, \
24 .tunnel_end_prot = LIBETH_RX_PT_TUNNEL_END_##tp, \
25 .tunnel_end_frag = LIBETH_RX_PT_##tefr, \
26 .inner_prot = LIBETH_RX_PT_INNER_##iprot, \
27 .payload_layer = LIBETH_RX_PT_PAYLOAD_##pl, \
28 .hash_type = XDP_RSS_L3_##oip | \
29 XDP_RSS_L4_##iprot | \
33 #define LIBIE_RX_PT_UNUSED { }
35 #define __LIBIE_RX_PT_L2(iprot, pl) \
36 LIBIE_RX_PT(L2, NOT_FRAG, NONE, NONE, NOT_FRAG, iprot, pl)
37 #define LIBIE_RX_PT_L2 __LIBIE_RX_PT_L2(NONE, L2)
38 #define LIBIE_RX_PT_TS __LIBIE_RX_PT_L2(TIMESYNC, L2)
39 #define LIBIE_RX_PT_L3 __LIBIE_RX_PT_L2(NONE, L3)
41 #define LIBIE_RX_PT_IP_FRAG(oip) \
42 LIBIE_RX_PT(IPV##oip, FRAG, NONE, NONE, NOT_FRAG, NONE, L3)
43 #define LIBIE_RX_PT_IP_L3(oip, tun, teprot, tefr) \
44 LIBIE_RX_PT(IPV##oip, NOT_FRAG, tun, teprot, tefr, NONE, L3)
45 #define LIBIE_RX_PT_IP_L4(oip, tun, teprot, iprot) \
46 LIBIE_RX_PT(IPV##oip, NOT_FRAG, tun, teprot, NOT_FRAG, iprot, L4)
48 #define LIBIE_RX_PT_IP_NOF(oip, tun, ver) \
49 LIBIE_RX_PT_IP_L3(oip, tun, ver, NOT_FRAG), \
50 LIBIE_RX_PT_IP_L4(oip, tun, ver, UDP), \
52 LIBIE_RX_PT_IP_L4(oip, tun, ver, TCP), \
53 LIBIE_RX_PT_IP_L4(oip, tun, ver, SCTP), \
54 LIBIE_RX_PT_IP_L4(oip, tun, ver, ICMP)
56 /* IPv oip --> tun --> IPv ver */
57 #define LIBIE_RX_PT_IP_TUN_VER(oip, tun, ver) \
58 LIBIE_RX_PT_IP_L3(oip, tun, ver, FRAG), \
59 LIBIE_RX_PT_IP_NOF(oip, tun, ver)
61 /* Non Tunneled IPv oip */
62 #define LIBIE_RX_PT_IP_RAW(oip) \
63 LIBIE_RX_PT_IP_FRAG(oip), \
64 LIBIE_RX_PT_IP_NOF(oip, NONE, NONE)
66 /* IPv oip --> tun --> { IPv4, IPv6 } */
67 #define LIBIE_RX_PT_IP_TUN(oip, tun) \
68 LIBIE_RX_PT_IP_TUN_VER(oip, tun, IPV4), \
69 LIBIE_RX_PT_IP_TUN_VER(oip, tun, IPV6)
71 /* IPv oip --> GRE/NAT tun --> { x, IPv4, IPv6 } */
72 #define LIBIE_RX_PT_IP_GRE(oip, tun) \
73 LIBIE_RX_PT_IP_L3(oip, tun, NONE, NOT_FRAG), \
74 LIBIE_RX_PT_IP_TUN(oip, tun)
76 /* Non Tunneled IPv oip
77 * IPv oip --> { IPv4, IPv6 }
78 * IPv oip --> GRE/NAT --> { x, IPv4, IPv6 }
79 * IPv oip --> GRE/NAT --> MAC --> { x, IPv4, IPv6 }
80 * IPv oip --> GRE/NAT --> MAC/VLAN --> { x, IPv4, IPv6 }
82 #define LIBIE_RX_PT_IP(oip) \
83 LIBIE_RX_PT_IP_RAW(oip), \
84 LIBIE_RX_PT_IP_TUN(oip, IP), \
85 LIBIE_RX_PT_IP_GRE(oip, GRENAT), \
86 LIBIE_RX_PT_IP_GRE(oip, GRENAT_MAC), \
87 LIBIE_RX_PT_IP_GRE(oip, GRENAT_MAC_VLAN)
89 /* Lookup table mapping for O(1) parsing */
90 const struct libeth_rx_pt libie_rx_pt_lut
[LIBIE_RX_PT_NUM
] = {
119 EXPORT_SYMBOL_NS_GPL(libie_rx_pt_lut
, "LIBIE");
121 MODULE_DESCRIPTION("Intel(R) Ethernet common library");
122 MODULE_IMPORT_NS("LIBETH");
123 MODULE_LICENSE("GPL");