net/ngbe: support RSS hash
[dpdk.git] / drivers / net / ngbe / ngbe_ptypes.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
3  */
4
5 #ifndef _NGBE_PTYPE_H_
6 #define _NGBE_PTYPE_H_
7
8 /**
9  * PTID(Packet Type Identifier, 8bits)
10  * - Bit 3:0 detailed types.
11  * - Bit 5:4 basic types.
12  * - Bit 7:6 tunnel types.
13  **/
14 #define NGBE_PTID_NULL                 0
15 #define NGBE_PTID_MAX                  256
16 #define NGBE_PTID_MASK                 0xFF
17 #define NGBE_PTID_MASK_TUNNEL          0x7F
18
19 /* TUN */
20 #define NGBE_PTID_TUN_IPV6             0x40
21 #define NGBE_PTID_TUN_EI               0x00 /* IP */
22 #define NGBE_PTID_TUN_EIG              0x10 /* IP+GRE */
23 #define NGBE_PTID_TUN_EIGM             0x20 /* IP+GRE+MAC */
24 #define NGBE_PTID_TUN_EIGMV            0x30 /* IP+GRE+MAC+VLAN */
25
26 /* PKT for !TUN */
27 #define NGBE_PTID_PKT_TUN             (0x80)
28 #define NGBE_PTID_PKT_MAC             (0x10)
29 #define NGBE_PTID_PKT_IP              (0x20)
30
31 /* TYP for PKT=mac */
32 #define NGBE_PTID_TYP_MAC             (0x01)
33 #define NGBE_PTID_TYP_TS              (0x02) /* time sync */
34 #define NGBE_PTID_TYP_FIP             (0x03)
35 #define NGBE_PTID_TYP_LLDP            (0x04)
36 #define NGBE_PTID_TYP_CNM             (0x05)
37 #define NGBE_PTID_TYP_EAPOL           (0x06)
38 #define NGBE_PTID_TYP_ARP             (0x07)
39 #define NGBE_PTID_TYP_ETF             (0x08)
40
41 /* TYP for PKT=ip */
42 #define NGBE_PTID_PKT_IPV6            (0x08)
43 #define NGBE_PTID_TYP_IPFRAG          (0x01)
44 #define NGBE_PTID_TYP_IPDATA          (0x02)
45 #define NGBE_PTID_TYP_UDP             (0x03)
46 #define NGBE_PTID_TYP_TCP             (0x04)
47 #define NGBE_PTID_TYP_SCTP            (0x05)
48
49 /* packet type non-ip values */
50 enum ngbe_l2_ptids {
51         NGBE_PTID_L2_ABORTED = (NGBE_PTID_PKT_MAC),
52         NGBE_PTID_L2_MAC = (NGBE_PTID_PKT_MAC | NGBE_PTID_TYP_MAC),
53         NGBE_PTID_L2_TMST = (NGBE_PTID_PKT_MAC | NGBE_PTID_TYP_TS),
54         NGBE_PTID_L2_FIP = (NGBE_PTID_PKT_MAC | NGBE_PTID_TYP_FIP),
55         NGBE_PTID_L2_LLDP = (NGBE_PTID_PKT_MAC | NGBE_PTID_TYP_LLDP),
56         NGBE_PTID_L2_CNM = (NGBE_PTID_PKT_MAC | NGBE_PTID_TYP_CNM),
57         NGBE_PTID_L2_EAPOL = (NGBE_PTID_PKT_MAC | NGBE_PTID_TYP_EAPOL),
58         NGBE_PTID_L2_ARP = (NGBE_PTID_PKT_MAC | NGBE_PTID_TYP_ARP),
59
60         NGBE_PTID_L2_IPV4_FRAG = (NGBE_PTID_PKT_IP | NGBE_PTID_TYP_IPFRAG),
61         NGBE_PTID_L2_IPV4 = (NGBE_PTID_PKT_IP | NGBE_PTID_TYP_IPDATA),
62         NGBE_PTID_L2_IPV4_UDP = (NGBE_PTID_PKT_IP | NGBE_PTID_TYP_UDP),
63         NGBE_PTID_L2_IPV4_TCP = (NGBE_PTID_PKT_IP | NGBE_PTID_TYP_TCP),
64         NGBE_PTID_L2_IPV4_SCTP = (NGBE_PTID_PKT_IP | NGBE_PTID_TYP_SCTP),
65         NGBE_PTID_L2_IPV6_FRAG = (NGBE_PTID_PKT_IP | NGBE_PTID_PKT_IPV6 |
66                         NGBE_PTID_TYP_IPFRAG),
67         NGBE_PTID_L2_IPV6 = (NGBE_PTID_PKT_IP | NGBE_PTID_PKT_IPV6 |
68                         NGBE_PTID_TYP_IPDATA),
69         NGBE_PTID_L2_IPV6_UDP = (NGBE_PTID_PKT_IP | NGBE_PTID_PKT_IPV6 |
70                         NGBE_PTID_TYP_UDP),
71         NGBE_PTID_L2_IPV6_TCP = (NGBE_PTID_PKT_IP | NGBE_PTID_PKT_IPV6 |
72                         NGBE_PTID_TYP_TCP),
73         NGBE_PTID_L2_IPV6_SCTP = (NGBE_PTID_PKT_IP | NGBE_PTID_PKT_IPV6 |
74                         NGBE_PTID_TYP_SCTP),
75
76         NGBE_PTID_L2_TUN4_MAC = (NGBE_PTID_PKT_TUN |
77                         NGBE_PTID_TUN_EIGM),
78         NGBE_PTID_L2_TUN6_MAC = (NGBE_PTID_PKT_TUN |
79                         NGBE_PTID_TUN_IPV6 | NGBE_PTID_TUN_EIGM),
80 };
81
82
83 /*
84  * PTYPE(Packet Type, 32bits)
85  * - Bit 3:0 is for L2 types.
86  * - Bit 7:4 is for L3 or outer L3 (for tunneling case) types.
87  * - Bit 11:8 is for L4 or outer L4 (for tunneling case) types.
88  * - Bit 15:12 is for tunnel types.
89  * - Bit 19:16 is for inner L2 types.
90  * - Bit 23:20 is for inner L3 types.
91  * - Bit 27:24 is for inner L4 types.
92  * - Bit 31:28 is reserved.
93  * please ref to rte_mbuf.h: rte_mbuf.packet_type
94  */
95 struct rte_ngbe_ptype {
96         u32 l2:4;  /* outer mac */
97         u32 l3:4;  /* outer internet protocol */
98         u32 l4:4;  /* outer transport protocol */
99         u32 tun:4; /* tunnel protocol */
100
101         u32 el2:4; /* inner mac */
102         u32 el3:4; /* inner internet protocol */
103         u32 el4:4; /* inner transport protocol */
104         u32 rsv:3;
105         u32 known:1;
106 };
107
108 #define RTE_PTYPE_L2_ETHER_FIP              RTE_PTYPE_L2_ETHER
109 #define RTE_PTYPE_L2_ETHER_CNM              RTE_PTYPE_L2_ETHER
110 #define RTE_PTYPE_L2_ETHER_EAPOL            RTE_PTYPE_L2_ETHER
111 #define RTE_PTYPE_L2_ETHER_FILTER           RTE_PTYPE_L2_ETHER
112
113 u32 *ngbe_get_supported_ptypes(void);
114 u32 ngbe_decode_ptype(u8 ptid);
115 u8 ngbe_encode_ptype(u32 ptype);
116
117 /**
118  * PT(Packet Type, 32bits)
119  * - Bit 3:0 is for L2 types.
120  * - Bit 7:4 is for L3 or outer L3 (for tunneling case) types.
121  * - Bit 11:8 is for L4 or outer L4 (for tunneling case) types.
122  * - Bit 15:12 is for tunnel types.
123  * - Bit 19:16 is for inner L2 types.
124  * - Bit 23:20 is for inner L3 types.
125  * - Bit 27:24 is for inner L4 types.
126  * - Bit 31:28 is reserved.
127  * PT is a more accurate version of PTYPE
128  **/
129 #define NGBE_PT_ETHER                   0x00
130 #define NGBE_PT_IPV4                    0x01
131 #define NGBE_PT_IPV4_TCP                0x11
132 #define NGBE_PT_IPV4_UDP                0x21
133 #define NGBE_PT_IPV4_SCTP               0x41
134 #define NGBE_PT_IPV4_EXT                0x03
135 #define NGBE_PT_IPV4_EXT_TCP            0x13
136 #define NGBE_PT_IPV4_EXT_UDP            0x23
137 #define NGBE_PT_IPV4_EXT_SCTP           0x43
138 #define NGBE_PT_IPV6                    0x04
139 #define NGBE_PT_IPV6_TCP                0x14
140 #define NGBE_PT_IPV6_UDP                0x24
141 #define NGBE_PT_IPV6_SCTP               0x44
142 #define NGBE_PT_IPV6_EXT                0x0C
143 #define NGBE_PT_IPV6_EXT_TCP            0x1C
144 #define NGBE_PT_IPV6_EXT_UDP            0x2C
145 #define NGBE_PT_IPV6_EXT_SCTP           0x4C
146 #define NGBE_PT_IPV4_IPV6               0x05
147 #define NGBE_PT_IPV4_IPV6_TCP           0x15
148 #define NGBE_PT_IPV4_IPV6_UDP           0x25
149 #define NGBE_PT_IPV4_IPV6_SCTP          0x45
150 #define NGBE_PT_IPV4_EXT_IPV6           0x07
151 #define NGBE_PT_IPV4_EXT_IPV6_TCP       0x17
152 #define NGBE_PT_IPV4_EXT_IPV6_UDP       0x27
153 #define NGBE_PT_IPV4_EXT_IPV6_SCTP      0x47
154 #define NGBE_PT_IPV4_IPV6_EXT           0x0D
155 #define NGBE_PT_IPV4_IPV6_EXT_TCP       0x1D
156 #define NGBE_PT_IPV4_IPV6_EXT_UDP       0x2D
157 #define NGBE_PT_IPV4_IPV6_EXT_SCTP      0x4D
158 #define NGBE_PT_IPV4_EXT_IPV6_EXT       0x0F
159 #define NGBE_PT_IPV4_EXT_IPV6_EXT_TCP   0x1F
160 #define NGBE_PT_IPV4_EXT_IPV6_EXT_UDP   0x2F
161 #define NGBE_PT_IPV4_EXT_IPV6_EXT_SCTP  0x4F
162
163 #define NGBE_PT_MAX    256
164
165 /* ether type filter list: one static filter per filter consumer. This is
166  *                 to avoid filter collisions later. Add new filters
167  *                 here!!
168  *      EAPOL 802.1x (0x888e): Filter 0
169  *      FCoE (0x8906):   Filter 2
170  *      1588 (0x88f7):   Filter 3
171  *      FIP  (0x8914):   Filter 4
172  *      LLDP (0x88CC):   Filter 5
173  *      LACP (0x8809):   Filter 6
174  *      FC   (0x8808):   Filter 7
175  */
176 #define NGBE_ETF_ID_EAPOL        0
177 #define NGBE_ETF_ID_FCOE         2
178 #define NGBE_ETF_ID_1588         3
179 #define NGBE_ETF_ID_FIP          4
180 #define NGBE_ETF_ID_LLDP         5
181 #define NGBE_ETF_ID_LACP         6
182 #define NGBE_ETF_ID_FC           7
183 #define NGBE_ETF_ID_MAX          8
184
185 #define NGBE_PTID_ETF_MIN  0x18
186 #define NGBE_PTID_ETF_MAX  0x1F
187 static inline int ngbe_etflt_id(u8 ptid)
188 {
189         if (ptid >= NGBE_PTID_ETF_MIN && ptid <= NGBE_PTID_ETF_MAX)
190                 return ptid - NGBE_PTID_ETF_MIN;
191         else
192                 return -1;
193 }
194
195 #endif /* _NGBE_PTYPE_H_ */