| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* Copyright (c) 2019, Intel Corporation. */ |
| 3 |
|
| 4 |
#ifndef _ICE_FLOW_H_ |
| 5 |
#define _ICE_FLOW_H_ |
| 6 |
|
| 7 |
#include <linux/net/intel/libie/pctype.h> |
| 8 |
|
| 9 |
#include "ice_flex_type.h" |
| 10 |
#include "ice_parser.h" |
| 11 |
|
| 12 |
#define ICE_FLOW_ENTRY_HANDLE_INVAL 0 |
| 13 |
#define ICE_FLOW_FLD_OFF_INVAL 0xffff |
| 14 |
|
| 15 |
/* Generate flow hash field from flow field type(s) */ |
| 16 |
#define ICE_FLOW_HASH_ETH \ |
| 17 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_DA) | \ |
| 18 |
BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_SA)) |
| 19 |
#define ICE_FLOW_HASH_IPV4 \ |
| 20 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) | \ |
| 21 |
BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA)) |
| 22 |
#define ICE_FLOW_HASH_IPV6 \ |
| 23 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) | \ |
| 24 |
BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA)) |
| 25 |
#define ICE_FLOW_HASH_IPV6_PRE32 \ |
| 26 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PRE32_SA) | \ |
| 27 |
BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PRE32_DA)) |
| 28 |
#define ICE_FLOW_HASH_IPV6_PRE48 \ |
| 29 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PRE48_SA) | \ |
| 30 |
BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PRE48_DA)) |
| 31 |
#define ICE_FLOW_HASH_IPV6_PRE64 \ |
| 32 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PRE64_SA) | \ |
| 33 |
BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PRE64_DA)) |
| 34 |
#define ICE_FLOW_HASH_TCP_PORT \ |
| 35 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT) | \ |
| 36 |
BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT)) |
| 37 |
#define ICE_FLOW_HASH_UDP_PORT \ |
| 38 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT) | \ |
| 39 |
BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT)) |
| 40 |
#define ICE_FLOW_HASH_SCTP_PORT \ |
| 41 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT) | \ |
| 42 |
BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT)) |
| 43 |
|
| 44 |
#define ICE_HASH_INVALID 0 |
| 45 |
#define ICE_HASH_TCP_IPV4 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_TCP_PORT) |
| 46 |
#define ICE_HASH_TCP_IPV6 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_TCP_PORT) |
| 47 |
#define ICE_HASH_UDP_IPV4 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_UDP_PORT) |
| 48 |
#define ICE_HASH_UDP_IPV6 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_UDP_PORT) |
| 49 |
#define ICE_HASH_SCTP_IPV4 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_SCTP_PORT) |
| 50 |
#define ICE_HASH_SCTP_IPV6 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_SCTP_PORT) |
| 51 |
|
| 52 |
#define ICE_HASH_TCP_IPV6_PRE32 \ |
| 53 |
(ICE_FLOW_HASH_IPV6_PRE32 | ICE_FLOW_HASH_TCP_PORT) |
| 54 |
#define ICE_HASH_UDP_IPV6_PRE32 \ |
| 55 |
(ICE_FLOW_HASH_IPV6_PRE32 | ICE_FLOW_HASH_UDP_PORT) |
| 56 |
#define ICE_HASH_SCTP_IPV6_PRE32 \ |
| 57 |
(ICE_FLOW_HASH_IPV6_PRE32 | ICE_FLOW_HASH_SCTP_PORT) |
| 58 |
#define ICE_HASH_TCP_IPV6_PRE48 \ |
| 59 |
(ICE_FLOW_HASH_IPV6_PRE48 | ICE_FLOW_HASH_TCP_PORT) |
| 60 |
#define ICE_HASH_UDP_IPV6_PRE48 \ |
| 61 |
(ICE_FLOW_HASH_IPV6_PRE48 | ICE_FLOW_HASH_UDP_PORT) |
| 62 |
#define ICE_HASH_SCTP_IPV6_PRE48 \ |
| 63 |
(ICE_FLOW_HASH_IPV6_PRE48 | ICE_FLOW_HASH_SCTP_PORT) |
| 64 |
#define ICE_HASH_TCP_IPV6_PRE64 \ |
| 65 |
(ICE_FLOW_HASH_IPV6_PRE64 | ICE_FLOW_HASH_TCP_PORT) |
| 66 |
#define ICE_HASH_UDP_IPV6_PRE64 \ |
| 67 |
(ICE_FLOW_HASH_IPV6_PRE64 | ICE_FLOW_HASH_UDP_PORT) |
| 68 |
#define ICE_HASH_SCTP_IPV6_PRE64 \ |
| 69 |
(ICE_FLOW_HASH_IPV6_PRE64 | ICE_FLOW_HASH_SCTP_PORT) |
| 70 |
|
| 71 |
#define ICE_FLOW_HASH_GTP_TEID \ |
| 72 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPC_TEID)) |
| 73 |
|
| 74 |
#define ICE_FLOW_HASH_GTP_IPV4_TEID \ |
| 75 |
(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_TEID) |
| 76 |
#define ICE_FLOW_HASH_GTP_IPV6_TEID \ |
| 77 |
(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_TEID) |
| 78 |
|
| 79 |
#define ICE_FLOW_HASH_GTP_C_TEID \ |
| 80 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPC_TEID)) |
| 81 |
|
| 82 |
#define ICE_FLOW_HASH_GTP_C_IPV4_TEID \ |
| 83 |
(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_C_TEID) |
| 84 |
#define ICE_FLOW_HASH_GTP_C_IPV6_TEID \ |
| 85 |
(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_C_TEID) |
| 86 |
|
| 87 |
#define ICE_FLOW_HASH_GTP_U_TEID \ |
| 88 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID)) |
| 89 |
|
| 90 |
#define ICE_FLOW_HASH_GTP_U_IPV4_TEID \ |
| 91 |
(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_TEID) |
| 92 |
#define ICE_FLOW_HASH_GTP_U_IPV6_TEID \ |
| 93 |
(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_TEID) |
| 94 |
|
| 95 |
#define ICE_FLOW_HASH_GTP_U_EH_TEID \ |
| 96 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_EH_TEID)) |
| 97 |
|
| 98 |
#define ICE_FLOW_HASH_GTP_U_EH_QFI \ |
| 99 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_EH_QFI)) |
| 100 |
|
| 101 |
#define ICE_FLOW_HASH_GTP_U_IPV4_EH \ |
| 102 |
(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_EH_TEID | \ |
| 103 |
ICE_FLOW_HASH_GTP_U_EH_QFI) |
| 104 |
#define ICE_FLOW_HASH_GTP_U_IPV6_EH \ |
| 105 |
(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_EH_TEID | \ |
| 106 |
ICE_FLOW_HASH_GTP_U_EH_QFI) |
| 107 |
|
| 108 |
#define ICE_FLOW_HASH_GTP_U_UP \ |
| 109 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_UP_TEID)) |
| 110 |
#define ICE_FLOW_HASH_GTP_U_DWN \ |
| 111 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_DWN_TEID)) |
| 112 |
|
| 113 |
#define ICE_FLOW_HASH_GTP_U_IPV4_UP \ |
| 114 |
(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_UP) |
| 115 |
#define ICE_FLOW_HASH_GTP_U_IPV6_UP \ |
| 116 |
(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_UP) |
| 117 |
#define ICE_FLOW_HASH_GTP_U_IPV4_DWN \ |
| 118 |
(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_DWN) |
| 119 |
#define ICE_FLOW_HASH_GTP_U_IPV6_DWN \ |
| 120 |
(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_DWN) |
| 121 |
|
| 122 |
#define ICE_FLOW_HASH_PPPOE_SESS_ID \ |
| 123 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_PPPOE_SESS_ID)) |
| 124 |
|
| 125 |
#define ICE_FLOW_HASH_PPPOE_SESS_ID_ETH \ |
| 126 |
(ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_PPPOE_SESS_ID) |
| 127 |
#define ICE_FLOW_HASH_PPPOE_TCP_ID \ |
| 128 |
(ICE_FLOW_HASH_TCP_PORT | ICE_FLOW_HASH_PPPOE_SESS_ID) |
| 129 |
#define ICE_FLOW_HASH_PPPOE_UDP_ID \ |
| 130 |
(ICE_FLOW_HASH_UDP_PORT | ICE_FLOW_HASH_PPPOE_SESS_ID) |
| 131 |
|
| 132 |
#define ICE_FLOW_HASH_PFCP_SEID \ |
| 133 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_PFCP_SEID)) |
| 134 |
#define ICE_FLOW_HASH_PFCP_IPV4_SEID \ |
| 135 |
(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_PFCP_SEID) |
| 136 |
#define ICE_FLOW_HASH_PFCP_IPV6_SEID \ |
| 137 |
(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_PFCP_SEID) |
| 138 |
|
| 139 |
#define ICE_FLOW_HASH_L2TPV3_SESS_ID \ |
| 140 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_L2TPV3_SESS_ID)) |
| 141 |
#define ICE_FLOW_HASH_L2TPV3_IPV4_SESS_ID \ |
| 142 |
(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_L2TPV3_SESS_ID) |
| 143 |
#define ICE_FLOW_HASH_L2TPV3_IPV6_SESS_ID \ |
| 144 |
(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_L2TPV3_SESS_ID) |
| 145 |
|
| 146 |
#define ICE_FLOW_HASH_ESP_SPI \ |
| 147 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_ESP_SPI)) |
| 148 |
#define ICE_FLOW_HASH_ESP_IPV4_SPI \ |
| 149 |
(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_ESP_SPI) |
| 150 |
#define ICE_FLOW_HASH_ESP_IPV6_SPI \ |
| 151 |
(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_ESP_SPI) |
| 152 |
|
| 153 |
#define ICE_FLOW_HASH_AH_SPI \ |
| 154 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_AH_SPI)) |
| 155 |
#define ICE_FLOW_HASH_AH_IPV4_SPI \ |
| 156 |
(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_AH_SPI) |
| 157 |
#define ICE_FLOW_HASH_AH_IPV6_SPI \ |
| 158 |
(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_AH_SPI) |
| 159 |
|
| 160 |
#define ICE_FLOW_HASH_NAT_T_ESP_SPI \ |
| 161 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_NAT_T_ESP_SPI)) |
| 162 |
#define ICE_FLOW_HASH_NAT_T_ESP_IPV4_SPI \ |
| 163 |
(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_NAT_T_ESP_SPI) |
| 164 |
#define ICE_FLOW_HASH_NAT_T_ESP_IPV6_SPI \ |
| 165 |
(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_NAT_T_ESP_SPI) |
| 166 |
|
| 167 |
#define ICE_FLOW_HASH_L2TPV2_SESS_ID \ |
| 168 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_L2TPV2_SESS_ID)) |
| 169 |
#define ICE_FLOW_HASH_L2TPV2_SESS_ID_ETH \ |
| 170 |
(ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_L2TPV2_SESS_ID) |
| 171 |
|
| 172 |
#define ICE_FLOW_HASH_L2TPV2_LEN_SESS_ID \ |
| 173 |
(BIT_ULL(ICE_FLOW_FIELD_IDX_L2TPV2_LEN_SESS_ID)) |
| 174 |
#define ICE_FLOW_HASH_L2TPV2_LEN_SESS_ID_ETH \ |
| 175 |
(ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_L2TPV2_LEN_SESS_ID) |
| 176 |
|
| 177 |
#define ICE_FLOW_FIELD_IPV4_SRC_OFFSET 12 |
| 178 |
#define ICE_FLOW_FIELD_IPV4_DST_OFFSET 16 |
| 179 |
#define ICE_FLOW_FIELD_IPV6_SRC_OFFSET 8 |
| 180 |
#define ICE_FLOW_FIELD_IPV6_DST_OFFSET 24 |
| 181 |
#define ICE_FLOW_FIELD_SRC_PORT_OFFSET 0 |
| 182 |
#define ICE_FLOW_FIELD_DST_PORT_OFFSET 2 |
| 183 |
|
| 184 |
/* Protocol header fields within a packet segment. A segment consists of one or |
| 185 |
* more protocol headers that make up a logical group of protocol headers. Each |
| 186 |
* logical group of protocol headers encapsulates or is encapsulated using/by |
| 187 |
* tunneling or encapsulation protocols for network virtualization such as GRE, |
| 188 |
* VxLAN, etc. |
| 189 |
*/ |
| 190 |
enum ice_flow_seg_hdr { |
| 191 |
ICE_FLOW_SEG_HDR_NONE = 0x00000000, |
| 192 |
ICE_FLOW_SEG_HDR_ETH = 0x00000001, |
| 193 |
ICE_FLOW_SEG_HDR_VLAN = 0x00000002, |
| 194 |
ICE_FLOW_SEG_HDR_IPV4 = 0x00000004, |
| 195 |
ICE_FLOW_SEG_HDR_IPV6 = 0x00000008, |
| 196 |
ICE_FLOW_SEG_HDR_ARP = 0x00000010, |
| 197 |
ICE_FLOW_SEG_HDR_ICMP = 0x00000020, |
| 198 |
ICE_FLOW_SEG_HDR_TCP = 0x00000040, |
| 199 |
ICE_FLOW_SEG_HDR_UDP = 0x00000080, |
| 200 |
ICE_FLOW_SEG_HDR_SCTP = 0x00000100, |
| 201 |
ICE_FLOW_SEG_HDR_GRE = 0x00000200, |
| 202 |
ICE_FLOW_SEG_HDR_GTPC = 0x00000400, |
| 203 |
ICE_FLOW_SEG_HDR_GTPC_TEID = 0x00000800, |
| 204 |
ICE_FLOW_SEG_HDR_GTPU_IP = 0x00001000, |
| 205 |
ICE_FLOW_SEG_HDR_GTPU_EH = 0x00002000, |
| 206 |
ICE_FLOW_SEG_HDR_GTPU_DWN = 0x00004000, |
| 207 |
ICE_FLOW_SEG_HDR_GTPU_UP = 0x00008000, |
| 208 |
ICE_FLOW_SEG_HDR_PPPOE = 0x00010000, |
| 209 |
ICE_FLOW_SEG_HDR_PFCP_NODE = 0x00020000, |
| 210 |
ICE_FLOW_SEG_HDR_PFCP_SESSION = 0x00040000, |
| 211 |
ICE_FLOW_SEG_HDR_L2TPV3 = 0x00080000, |
| 212 |
ICE_FLOW_SEG_HDR_ESP = 0x00100000, |
| 213 |
ICE_FLOW_SEG_HDR_AH = 0x00200000, |
| 214 |
ICE_FLOW_SEG_HDR_NAT_T_ESP = 0x00400000, |
| 215 |
ICE_FLOW_SEG_HDR_ETH_NON_IP = 0x00800000, |
| 216 |
ICE_FLOW_SEG_HDR_GTPU_NON_IP = 0x01000000, |
| 217 |
ICE_FLOW_SEG_HDR_L2TPV2 = 0x10000000, |
| 218 |
/* The following is an additive bit for ICE_FLOW_SEG_HDR_IPV4 and |
| 219 |
* ICE_FLOW_SEG_HDR_IPV6. |
| 220 |
*/ |
| 221 |
ICE_FLOW_SEG_HDR_IPV_FRAG = 0x40000000, |
| 222 |
ICE_FLOW_SEG_HDR_IPV_OTHER = 0x80000000, |
| 223 |
}; |
| 224 |
|
| 225 |
/* These segments all have the same PTYPES, but are otherwise distinguished by |
| 226 |
* the value of the gtp_eh_pdu and gtp_eh_pdu_link flags: |
| 227 |
* |
| 228 |
* gtp_eh_pdu gtp_eh_pdu_link |
| 229 |
* ICE_FLOW_SEG_HDR_GTPU_IP 0 0 |
| 230 |
* ICE_FLOW_SEG_HDR_GTPU_EH 1 don't care |
| 231 |
* ICE_FLOW_SEG_HDR_GTPU_DWN 1 0 |
| 232 |
* ICE_FLOW_SEG_HDR_GTPU_UP 1 1 |
| 233 |
*/ |
| 234 |
#define ICE_FLOW_SEG_HDR_GTPU (ICE_FLOW_SEG_HDR_GTPU_IP | \ |
| 235 |
ICE_FLOW_SEG_HDR_GTPU_EH | \ |
| 236 |
ICE_FLOW_SEG_HDR_GTPU_DWN | \ |
| 237 |
ICE_FLOW_SEG_HDR_GTPU_UP) |
| 238 |
#define ICE_FLOW_SEG_HDR_PFCP (ICE_FLOW_SEG_HDR_PFCP_NODE | \ |
| 239 |
ICE_FLOW_SEG_HDR_PFCP_SESSION) |
| 240 |
|
| 241 |
enum ice_flow_field { |
| 242 |
/* L2 */ |
| 243 |
ICE_FLOW_FIELD_IDX_ETH_DA, |
| 244 |
ICE_FLOW_FIELD_IDX_ETH_SA, |
| 245 |
ICE_FLOW_FIELD_IDX_S_VLAN, |
| 246 |
ICE_FLOW_FIELD_IDX_C_VLAN, |
| 247 |
ICE_FLOW_FIELD_IDX_ETH_TYPE, |
| 248 |
/* L3 */ |
| 249 |
ICE_FLOW_FIELD_IDX_IPV4_DSCP, |
| 250 |
ICE_FLOW_FIELD_IDX_IPV6_DSCP, |
| 251 |
ICE_FLOW_FIELD_IDX_IPV4_TTL, |
| 252 |
ICE_FLOW_FIELD_IDX_IPV4_PROT, |
| 253 |
ICE_FLOW_FIELD_IDX_IPV6_TTL, |
| 254 |
ICE_FLOW_FIELD_IDX_IPV6_PROT, |
| 255 |
ICE_FLOW_FIELD_IDX_IPV4_SA, |
| 256 |
ICE_FLOW_FIELD_IDX_IPV4_DA, |
| 257 |
ICE_FLOW_FIELD_IDX_IPV6_SA, |
| 258 |
ICE_FLOW_FIELD_IDX_IPV6_DA, |
| 259 |
ICE_FLOW_FIELD_IDX_IPV4_CHKSUM, |
| 260 |
ICE_FLOW_FIELD_IDX_IPV4_ID, |
| 261 |
ICE_FLOW_FIELD_IDX_IPV6_ID, |
| 262 |
ICE_FLOW_FIELD_IDX_IPV6_PRE32_SA, |
| 263 |
ICE_FLOW_FIELD_IDX_IPV6_PRE32_DA, |
| 264 |
ICE_FLOW_FIELD_IDX_IPV6_PRE48_SA, |
| 265 |
ICE_FLOW_FIELD_IDX_IPV6_PRE48_DA, |
| 266 |
ICE_FLOW_FIELD_IDX_IPV6_PRE64_SA, |
| 267 |
ICE_FLOW_FIELD_IDX_IPV6_PRE64_DA, |
| 268 |
/* L4 */ |
| 269 |
ICE_FLOW_FIELD_IDX_TCP_SRC_PORT, |
| 270 |
ICE_FLOW_FIELD_IDX_TCP_DST_PORT, |
| 271 |
ICE_FLOW_FIELD_IDX_UDP_SRC_PORT, |
| 272 |
ICE_FLOW_FIELD_IDX_UDP_DST_PORT, |
| 273 |
ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT, |
| 274 |
ICE_FLOW_FIELD_IDX_SCTP_DST_PORT, |
| 275 |
ICE_FLOW_FIELD_IDX_TCP_FLAGS, |
| 276 |
ICE_FLOW_FIELD_IDX_TCP_CHKSUM, |
| 277 |
ICE_FLOW_FIELD_IDX_UDP_CHKSUM, |
| 278 |
ICE_FLOW_FIELD_IDX_SCTP_CHKSUM, |
| 279 |
/* ARP */ |
| 280 |
ICE_FLOW_FIELD_IDX_ARP_SIP, |
| 281 |
ICE_FLOW_FIELD_IDX_ARP_DIP, |
| 282 |
ICE_FLOW_FIELD_IDX_ARP_SHA, |
| 283 |
ICE_FLOW_FIELD_IDX_ARP_DHA, |
| 284 |
ICE_FLOW_FIELD_IDX_ARP_OP, |
| 285 |
/* ICMP */ |
| 286 |
ICE_FLOW_FIELD_IDX_ICMP_TYPE, |
| 287 |
ICE_FLOW_FIELD_IDX_ICMP_CODE, |
| 288 |
/* GRE */ |
| 289 |
ICE_FLOW_FIELD_IDX_GRE_KEYID, |
| 290 |
/* GTPC_TEID */ |
| 291 |
ICE_FLOW_FIELD_IDX_GTPC_TEID, |
| 292 |
/* GTPU_IP */ |
| 293 |
ICE_FLOW_FIELD_IDX_GTPU_IP_TEID, |
| 294 |
/* GTPU_EH */ |
| 295 |
ICE_FLOW_FIELD_IDX_GTPU_EH_TEID, |
| 296 |
ICE_FLOW_FIELD_IDX_GTPU_EH_QFI, |
| 297 |
/* GTPU_UP */ |
| 298 |
ICE_FLOW_FIELD_IDX_GTPU_UP_TEID, |
| 299 |
ICE_FLOW_FIELD_IDX_GTPU_UP_QFI, |
| 300 |
/* GTPU_DWN */ |
| 301 |
ICE_FLOW_FIELD_IDX_GTPU_DWN_TEID, |
| 302 |
ICE_FLOW_FIELD_IDX_GTPU_DWN_QFI, |
| 303 |
ICE_FLOW_FIELD_IDX_PPPOE_SESS_ID, |
| 304 |
/* PFCP */ |
| 305 |
ICE_FLOW_FIELD_IDX_PFCP_SEID, |
| 306 |
ICE_FLOW_FIELD_IDX_L2TPV3_SESS_ID, |
| 307 |
/* ESP */ |
| 308 |
ICE_FLOW_FIELD_IDX_ESP_SPI, |
| 309 |
/* AH */ |
| 310 |
ICE_FLOW_FIELD_IDX_AH_SPI, |
| 311 |
/* NAT_T ESP */ |
| 312 |
ICE_FLOW_FIELD_IDX_NAT_T_ESP_SPI, |
| 313 |
/* L2TPV2 SESSION ID*/ |
| 314 |
ICE_FLOW_FIELD_IDX_L2TPV2_SESS_ID, |
| 315 |
/* L2TPV2_LEN SESSION ID */ |
| 316 |
ICE_FLOW_FIELD_IDX_L2TPV2_LEN_SESS_ID, |
| 317 |
/* The total number of enums must not exceed 64 */ |
| 318 |
ICE_FLOW_FIELD_IDX_MAX |
| 319 |
}; |
| 320 |
|
| 321 |
static_assert(ICE_FLOW_FIELD_IDX_MAX <= 64, "The total number of enums must not exceed 64"); |
| 322 |
|
| 323 |
#define ICE_FLOW_HASH_FLD_IPV4_SA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) |
| 324 |
#define ICE_FLOW_HASH_FLD_IPV6_SA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) |
| 325 |
#define ICE_FLOW_HASH_FLD_IPV4_DA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA) |
| 326 |
#define ICE_FLOW_HASH_FLD_IPV6_DA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA) |
| 327 |
#define ICE_FLOW_HASH_FLD_TCP_SRC_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT) |
| 328 |
#define ICE_FLOW_HASH_FLD_TCP_DST_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT) |
| 329 |
#define ICE_FLOW_HASH_FLD_UDP_SRC_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT) |
| 330 |
#define ICE_FLOW_HASH_FLD_UDP_DST_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT) |
| 331 |
#define ICE_FLOW_HASH_FLD_SCTP_SRC_PORT \ |
| 332 |
BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT) |
| 333 |
#define ICE_FLOW_HASH_FLD_SCTP_DST_PORT \ |
| 334 |
BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT) |
| 335 |
|
| 336 |
#define ICE_FLOW_HASH_FLD_GTPC_TEID BIT_ULL(ICE_FLOW_FIELD_IDX_GTPC_TEID) |
| 337 |
#define ICE_FLOW_HASH_FLD_GTPU_IP_TEID BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID) |
| 338 |
#define ICE_FLOW_HASH_FLD_GTPU_EH_TEID BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_EH_TEID) |
| 339 |
#define ICE_FLOW_HASH_FLD_GTPU_UP_TEID BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_UP_TEID) |
| 340 |
#define ICE_FLOW_HASH_FLD_GTPU_DWN_TEID \ |
| 341 |
BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_DWN_TEID) |
| 342 |
|
| 343 |
/* Supported RSS offloads This macro is defined to support |
| 344 |
* VIRTCHNL_OP_GET_RSS_HASHCFG_CAPS ops. PF driver sends the RSS hardware |
| 345 |
* capabilities to the caller of this ops. |
| 346 |
*/ |
| 347 |
#define ICE_DEFAULT_RSS_HASHCFG ( \ |
| 348 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV4_UDP) | \ |
| 349 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV4_SCTP) | \ |
| 350 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV4_TCP) | \ |
| 351 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV4_OTHER) | \ |
| 352 |
BIT_ULL(LIBIE_FILTER_PCTYPE_FRAG_IPV4) | \ |
| 353 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV6_UDP) | \ |
| 354 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV6_TCP) | \ |
| 355 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV6_SCTP) | \ |
| 356 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV6_OTHER) | \ |
| 357 |
BIT_ULL(LIBIE_FILTER_PCTYPE_FRAG_IPV6) | \ |
| 358 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV4_TCP_SYN_NO_ACK) | \ |
| 359 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP) | \ |
| 360 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_MULTICAST_IPV4_UDP) | \ |
| 361 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV6_TCP_SYN_NO_ACK) | \ |
| 362 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_UNICAST_IPV6_UDP) | \ |
| 363 |
BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_MULTICAST_IPV6_UDP)) |
| 364 |
|
| 365 |
enum ice_rss_cfg_hdr_type { |
| 366 |
ICE_RSS_OUTER_HEADERS, /* take outer headers as inputset. */ |
| 367 |
ICE_RSS_INNER_HEADERS, /* take inner headers as inputset. */ |
| 368 |
/* take inner headers as inputset for packet with outer ipv4. */ |
| 369 |
ICE_RSS_INNER_HEADERS_W_OUTER_IPV4, |
| 370 |
/* take inner headers as inputset for packet with outer ipv6. */ |
| 371 |
ICE_RSS_INNER_HEADERS_W_OUTER_IPV6, |
| 372 |
/* take outer headers first then inner headers as inputset */ |
| 373 |
/* take inner as inputset for GTPoGRE with outer IPv4 + GRE. */ |
| 374 |
ICE_RSS_INNER_HEADERS_W_OUTER_IPV4_GRE, |
| 375 |
/* take inner as inputset for GTPoGRE with outer IPv6 + GRE. */ |
| 376 |
ICE_RSS_INNER_HEADERS_W_OUTER_IPV6_GRE, |
| 377 |
ICE_RSS_ANY_HEADERS |
| 378 |
}; |
| 379 |
|
| 380 |
struct ice_vsi; |
| 381 |
struct ice_rss_hash_cfg { |
| 382 |
u32 addl_hdrs; /* protocol header fields */ |
| 383 |
u64 hash_flds; /* hash bit field (ICE_FLOW_HASH_*) to configure */ |
| 384 |
enum ice_rss_cfg_hdr_type hdr_type; /* to specify inner or outer */ |
| 385 |
bool symm; /* symmetric or asymmetric hash */ |
| 386 |
}; |
| 387 |
|
| 388 |
enum ice_flow_dir { |
| 389 |
ICE_FLOW_RX = 0x02, |
| 390 |
}; |
| 391 |
|
| 392 |
enum ice_flow_priority { |
| 393 |
ICE_FLOW_PRIO_LOW, |
| 394 |
ICE_FLOW_PRIO_NORMAL, |
| 395 |
ICE_FLOW_PRIO_HIGH |
| 396 |
}; |
| 397 |
|
| 398 |
#define ICE_FLOW_SEG_SINGLE 1 |
| 399 |
#define ICE_FLOW_SEG_MAX 2 |
| 400 |
#define ICE_FLOW_SEG_RAW_FLD_MAX 2 |
| 401 |
#define ICE_FLOW_SW_FIELD_VECTOR_MAX 48 |
| 402 |
#define ICE_FLOW_FV_EXTRACT_SZ 2 |
| 403 |
|
| 404 |
#define ICE_FLOW_SET_HDRS(seg, val) ((seg)->hdrs |= (u32)(val)) |
| 405 |
|
| 406 |
struct ice_flow_seg_xtrct { |
| 407 |
u8 prot_id; /* Protocol ID of extracted header field */ |
| 408 |
u16 off; /* Starting offset of the field in header in bytes */ |
| 409 |
u8 idx; /* Index of FV entry used */ |
| 410 |
u8 disp; /* Displacement of field in bits fr. FV entry's start */ |
| 411 |
u16 mask; /* Mask for field */ |
| 412 |
}; |
| 413 |
|
| 414 |
enum ice_flow_fld_match_type { |
| 415 |
ICE_FLOW_FLD_TYPE_REG, /* Value, mask */ |
| 416 |
ICE_FLOW_FLD_TYPE_RANGE, /* Value, mask, last (upper bound) */ |
| 417 |
ICE_FLOW_FLD_TYPE_PREFIX, /* IP address, prefix, size of prefix */ |
| 418 |
ICE_FLOW_FLD_TYPE_SIZE, /* Value, mask, size of match */ |
| 419 |
}; |
| 420 |
|
| 421 |
struct ice_flow_fld_loc { |
| 422 |
/* Describe offsets of field information relative to the beginning of |
| 423 |
* input buffer provided when adding flow entries. |
| 424 |
*/ |
| 425 |
u16 val; /* Offset where the value is located */ |
| 426 |
u16 mask; /* Offset where the mask/prefix value is located */ |
| 427 |
u16 last; /* Length or offset where the upper value is located */ |
| 428 |
}; |
| 429 |
|
| 430 |
struct ice_flow_fld_info { |
| 431 |
enum ice_flow_fld_match_type type; |
| 432 |
/* Location where to retrieve data from an input buffer */ |
| 433 |
struct ice_flow_fld_loc src; |
| 434 |
/* Location where to put the data into the final entry buffer */ |
| 435 |
struct ice_flow_fld_loc entry; |
| 436 |
struct ice_flow_seg_xtrct xtrct; |
| 437 |
}; |
| 438 |
|
| 439 |
struct ice_flow_seg_fld_raw { |
| 440 |
struct ice_flow_fld_info info; |
| 441 |
u16 off; /* Offset from the start of the segment */ |
| 442 |
}; |
| 443 |
|
| 444 |
struct ice_flow_seg_info { |
| 445 |
u32 hdrs; /* Bitmask indicating protocol headers present */ |
| 446 |
u64 match; /* Bitmask indicating header fields to be matched */ |
| 447 |
u64 range; /* Bitmask indicating header fields matched as ranges */ |
| 448 |
|
| 449 |
struct ice_flow_fld_info fields[ICE_FLOW_FIELD_IDX_MAX]; |
| 450 |
|
| 451 |
u8 raws_cnt; /* Number of raw fields to be matched */ |
| 452 |
struct ice_flow_seg_fld_raw raws[ICE_FLOW_SEG_RAW_FLD_MAX]; |
| 453 |
}; |
| 454 |
|
| 455 |
/* This structure describes a flow entry, and is tracked only in this file */ |
| 456 |
struct ice_flow_entry { |
| 457 |
struct list_head l_entry; |
| 458 |
|
| 459 |
u64 id; |
| 460 |
struct ice_flow_prof *prof; |
| 461 |
enum ice_flow_priority priority; |
| 462 |
u16 vsi_handle; |
| 463 |
}; |
| 464 |
|
| 465 |
#define ICE_FLOW_ENTRY_HNDL(e) ((u64)(uintptr_t)e) |
| 466 |
#define ICE_FLOW_ENTRY_PTR(h) ((struct ice_flow_entry *)(uintptr_t)(h)) |
| 467 |
|
| 468 |
struct ice_flow_prof { |
| 469 |
struct list_head l_entry; |
| 470 |
|
| 471 |
u64 id; |
| 472 |
enum ice_flow_dir dir; |
| 473 |
u8 segs_cnt; |
| 474 |
|
| 475 |
/* Keep track of flow entries associated with this flow profile */ |
| 476 |
struct mutex entries_lock; |
| 477 |
struct list_head entries; |
| 478 |
|
| 479 |
struct ice_flow_seg_info segs[ICE_FLOW_SEG_MAX]; |
| 480 |
|
| 481 |
/* software VSI handles referenced by this flow profile */ |
| 482 |
DECLARE_BITMAP(vsis, ICE_MAX_VSI); |
| 483 |
|
| 484 |
bool symm; /* Symmetric Hash for RSS */ |
| 485 |
}; |
| 486 |
|
| 487 |
struct ice_rss_raw_cfg { |
| 488 |
struct ice_parser_profile prof; |
| 489 |
bool raw_ena; |
| 490 |
bool symm; |
| 491 |
}; |
| 492 |
|
| 493 |
struct ice_rss_cfg { |
| 494 |
struct list_head l_entry; |
| 495 |
/* bitmap of VSIs added to the RSS entry */ |
| 496 |
DECLARE_BITMAP(vsis, ICE_MAX_VSI); |
| 497 |
struct ice_rss_hash_cfg hash; |
| 498 |
}; |
| 499 |
|
| 500 |
int |
| 501 |
ice_flow_add_prof(struct ice_hw *hw, enum ice_block blk, enum ice_flow_dir dir, |
| 502 |
struct ice_flow_seg_info *segs, u8 segs_cnt, |
| 503 |
bool symm, struct ice_flow_prof **prof); |
| 504 |
int ice_flow_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id); |
| 505 |
int |
| 506 |
ice_flow_set_parser_prof(struct ice_hw *hw, u16 dest_vsi, u16 fdir_vsi, |
| 507 |
struct ice_parser_profile *prof, enum ice_block blk); |
| 508 |
int |
| 509 |
ice_flow_add_entry(struct ice_hw *hw, enum ice_block blk, u64 prof_id, |
| 510 |
u64 entry_id, u16 vsi, enum ice_flow_priority prio, |
| 511 |
void *data, u64 *entry_h); |
| 512 |
int ice_flow_rem_entry(struct ice_hw *hw, enum ice_block blk, u64 entry_h); |
| 513 |
void |
| 514 |
ice_flow_set_fld(struct ice_flow_seg_info *seg, enum ice_flow_field fld, |
| 515 |
u16 val_loc, u16 mask_loc, u16 last_loc, bool range); |
| 516 |
void |
| 517 |
ice_flow_add_fld_raw(struct ice_flow_seg_info *seg, u16 off, u8 len, |
| 518 |
u16 val_loc, u16 mask_loc); |
| 519 |
int ice_flow_rem_vsi_prof(struct ice_hw *hw, u16 vsi_handle, u64 prof_id); |
| 520 |
void ice_rem_vsi_rss_list(struct ice_hw *hw, u16 vsi_handle); |
| 521 |
int ice_replay_rss_cfg(struct ice_hw *hw, u16 vsi_handle); |
| 522 |
int ice_set_rss_cfg_symm(struct ice_hw *hw, struct ice_vsi *vsi, bool symm); |
| 523 |
int ice_add_avf_rss_cfg(struct ice_hw *hw, struct ice_vsi *vsi, |
| 524 |
u64 hashed_flds); |
| 525 |
int ice_rem_vsi_rss_cfg(struct ice_hw *hw, u16 vsi_handle); |
| 526 |
int ice_add_rss_cfg(struct ice_hw *hw, struct ice_vsi *vsi, |
| 527 |
const struct ice_rss_hash_cfg *cfg); |
| 528 |
int ice_rem_rss_cfg(struct ice_hw *hw, u16 vsi_handle, |
| 529 |
const struct ice_rss_hash_cfg *cfg); |
| 530 |
u64 ice_get_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u32 hdrs, bool *symm); |
| 531 |
void ice_rss_update_raw_symm(struct ice_hw *hw, |
| 532 |
struct ice_rss_raw_cfg *cfg, u64 id); |
| 533 |
#endif /* _ICE_FLOW_H_ */ |