From 2b6d6d71a0992220043b2f5c3b885c486e7921b7 Mon Sep 17 00:00:00 2001 From: Zhirun Yan Date: Tue, 2 Mar 2021 10:54:02 +0800 Subject: [PATCH] net/ice: clean input set macro definition Currently, the macro of input set use 2 bits, one bit for protocol and inner/outer, another bit for src/dst field. But this could not distinguish a rule with inner and outer fields for tunnel packet. Redefine input set macro to make it clear. Only use these two bits for protocol and field. Ignore the redundant inner/outer info. ICE_INSET_TUN_* is used by switch module, should be removed after switch refactor. Signed-off-by: Zhirun Yan Acked-by: Qi Zhang --- drivers/net/ice/ice_fdir_filter.c | 8 +- drivers/net/ice/ice_generic_flow.h | 234 ++++++++++++----------------- 2 files changed, 104 insertions(+), 138 deletions(-) diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index ce6aa09d3d..4e99df1272 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -56,19 +56,19 @@ ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT) #define ICE_FDIR_INSET_VXLAN_IPV4 (\ - ICE_INSET_TUN_IPV4_SRC | ICE_INSET_TUN_IPV4_DST) + ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST) #define ICE_FDIR_INSET_VXLAN_IPV4_TCP (\ ICE_FDIR_INSET_VXLAN_IPV4 | \ - ICE_INSET_TUN_TCP_SRC_PORT | ICE_INSET_TUN_TCP_DST_PORT) + ICE_INSET_TCP_SRC_PORT | ICE_INSET_TCP_DST_PORT) #define ICE_FDIR_INSET_VXLAN_IPV4_UDP (\ ICE_FDIR_INSET_VXLAN_IPV4 | \ - ICE_INSET_TUN_UDP_SRC_PORT | ICE_INSET_TUN_UDP_DST_PORT) + ICE_INSET_UDP_SRC_PORT | ICE_INSET_UDP_DST_PORT) #define ICE_FDIR_INSET_VXLAN_IPV4_SCTP (\ ICE_FDIR_INSET_VXLAN_IPV4 | \ - ICE_INSET_TUN_SCTP_SRC_PORT | ICE_INSET_TUN_SCTP_DST_PORT) + ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT) #define ICE_FDIR_INSET_IPV4_GTPU (\ ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_GTPU_TEID) diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h index 18918769d2..3c648c0f4f 100644 --- a/drivers/net/ice/ice_generic_flow.h +++ b/drivers/net/ice/ice_generic_flow.h @@ -9,177 +9,143 @@ /* protocol */ -#define ICE_PROT_MAC_INNER (1ULL << 1) -#define ICE_PROT_MAC_OUTER (1ULL << 2) -#define ICE_PROT_VLAN_INNER (1ULL << 3) -#define ICE_PROT_VLAN_OUTER (1ULL << 4) -#define ICE_PROT_IPV4_INNER (1ULL << 5) -#define ICE_PROT_IPV4_OUTER (1ULL << 6) -#define ICE_PROT_IPV6_INNER (1ULL << 7) -#define ICE_PROT_IPV6_OUTER (1ULL << 8) -#define ICE_PROT_TCP_INNER (1ULL << 9) -#define ICE_PROT_TCP_OUTER (1ULL << 10) -#define ICE_PROT_UDP_INNER (1ULL << 11) -#define ICE_PROT_UDP_OUTER (1ULL << 12) -#define ICE_PROT_SCTP_INNER (1ULL << 13) -#define ICE_PROT_SCTP_OUTER (1ULL << 14) -#define ICE_PROT_ICMP4_INNER (1ULL << 15) -#define ICE_PROT_ICMP4_OUTER (1ULL << 16) -#define ICE_PROT_ICMP6_INNER (1ULL << 17) -#define ICE_PROT_ICMP6_OUTER (1ULL << 18) -#define ICE_PROT_VXLAN (1ULL << 19) -#define ICE_PROT_NVGRE (1ULL << 20) -#define ICE_PROT_GTPU (1ULL << 21) -#define ICE_PROT_PPPOE_S (1ULL << 22) -#define ICE_PROT_ESP (1ULL << 23) -#define ICE_PROT_AH (1ULL << 24) -#define ICE_PROT_L2TPV3OIP (1ULL << 25) -#define ICE_PROT_PFCP (1ULL << 26) +#define ICE_PROT_MAC BIT_ULL(1) +#define ICE_PROT_VLAN BIT_ULL(2) +#define ICE_PROT_IPV4 BIT_ULL(3) +#define ICE_PROT_IPV6 BIT_ULL(4) +#define ICE_PROT_TCP BIT_ULL(5) +#define ICE_PROT_UDP BIT_ULL(6) +#define ICE_PROT_SCTP BIT_ULL(7) +#define ICE_PROT_ICMP4 BIT_ULL(8) +#define ICE_PROT_ICMP6 BIT_ULL(9) +#define ICE_PROT_VXLAN BIT_ULL(10) +#define ICE_PROT_NVGRE BIT_ULL(11) +#define ICE_PROT_GTPU BIT_ULL(12) +#define ICE_PROT_PPPOE_S BIT_ULL(13) +#define ICE_PROT_ESP BIT_ULL(14) +#define ICE_PROT_AH BIT_ULL(15) +#define ICE_PROT_L2TPV3OIP BIT_ULL(16) +#define ICE_PROT_PFCP BIT_ULL(17) /* field */ -#define ICE_SMAC (1ULL << 63) -#define ICE_DMAC (1ULL << 62) -#define ICE_ETHERTYPE (1ULL << 61) -#define ICE_IP_SRC (1ULL << 60) -#define ICE_IP_DST (1ULL << 59) -#define ICE_IP_PROTO (1ULL << 58) -#define ICE_IP_TTL (1ULL << 57) -#define ICE_IP_TOS (1ULL << 56) -#define ICE_SPORT (1ULL << 55) -#define ICE_DPORT (1ULL << 54) -#define ICE_ICMP_TYPE (1ULL << 53) -#define ICE_ICMP_CODE (1ULL << 52) -#define ICE_VXLAN_VNI (1ULL << 51) -#define ICE_NVGRE_TNI (1ULL << 50) -#define ICE_GTPU_TEID (1ULL << 49) -#define ICE_GTPU_QFI (1ULL << 48) -#define ICE_PPPOE_SESSION (1ULL << 47) -#define ICE_PPPOE_PROTO (1ULL << 46) -#define ICE_ESP_SPI (1ULL << 45) -#define ICE_AH_SPI (1ULL << 44) -#define ICE_L2TPV3OIP_SESSION_ID (1ULL << 43) -#define ICE_PFCP_SEID (1ULL << 42) -#define ICE_PFCP_S_FIELD (1ULL << 41) +#define ICE_SMAC BIT_ULL(63) +#define ICE_DMAC BIT_ULL(62) +#define ICE_ETHERTYPE BIT_ULL(61) +#define ICE_IP_SRC BIT_ULL(60) +#define ICE_IP_DST BIT_ULL(59) +#define ICE_IP_PROTO BIT_ULL(58) +#define ICE_IP_TTL BIT_ULL(57) +#define ICE_IP_TOS BIT_ULL(56) +#define ICE_SPORT BIT_ULL(55) +#define ICE_DPORT BIT_ULL(54) +#define ICE_ICMP_TYPE BIT_ULL(53) +#define ICE_ICMP_CODE BIT_ULL(52) +#define ICE_VXLAN_VNI BIT_ULL(51) +#define ICE_NVGRE_TNI BIT_ULL(50) +#define ICE_GTPU_TEID BIT_ULL(49) +#define ICE_GTPU_QFI BIT_ULL(48) +#define ICE_PPPOE_SESSION BIT_ULL(47) +#define ICE_PPPOE_PROTO BIT_ULL(46) +#define ICE_ESP_SPI BIT_ULL(45) +#define ICE_AH_SPI BIT_ULL(44) +#define ICE_L2TPV3OIP_SESSION_ID BIT_ULL(43) +#define ICE_PFCP_SEID BIT_ULL(42) +#define ICE_PFCP_S_FIELD BIT_ULL(41) /* input set */ -#define ICE_INSET_NONE 0ULL - -/* non-tunnel */ - -#define ICE_INSET_SMAC (ICE_PROT_MAC_OUTER | ICE_SMAC) -#define ICE_INSET_DMAC (ICE_PROT_MAC_OUTER | ICE_DMAC) -#define ICE_INSET_VLAN_INNER (ICE_PROT_VLAN_INNER) -#define ICE_INSET_VLAN_OUTER (ICE_PROT_VLAN_OUTER) -#define ICE_INSET_ETHERTYPE (ICE_ETHERTYPE) - -#define ICE_INSET_IPV4_SRC \ - (ICE_PROT_IPV4_OUTER | ICE_IP_SRC) -#define ICE_INSET_IPV4_DST \ - (ICE_PROT_IPV4_OUTER | ICE_IP_DST) -#define ICE_INSET_IPV4_TOS \ - (ICE_PROT_IPV4_OUTER | ICE_IP_TOS) -#define ICE_INSET_IPV4_PROTO \ - (ICE_PROT_IPV4_OUTER | ICE_IP_PROTO) -#define ICE_INSET_IPV4_TTL \ - (ICE_PROT_IPV4_OUTER | ICE_IP_TTL) -#define ICE_INSET_IPV6_SRC \ - (ICE_PROT_IPV6_OUTER | ICE_IP_SRC) -#define ICE_INSET_IPV6_DST \ - (ICE_PROT_IPV6_OUTER | ICE_IP_DST) -#define ICE_INSET_IPV6_NEXT_HDR \ - (ICE_PROT_IPV6_OUTER | ICE_IP_PROTO) -#define ICE_INSET_IPV6_HOP_LIMIT \ - (ICE_PROT_IPV6_OUTER | ICE_IP_TTL) -#define ICE_INSET_IPV6_TC \ - (ICE_PROT_IPV6_OUTER | ICE_IP_TOS) - -#define ICE_INSET_TCP_SRC_PORT \ - (ICE_PROT_TCP_OUTER | ICE_SPORT) -#define ICE_INSET_TCP_DST_PORT \ - (ICE_PROT_TCP_OUTER | ICE_DPORT) -#define ICE_INSET_UDP_SRC_PORT \ - (ICE_PROT_UDP_OUTER | ICE_SPORT) -#define ICE_INSET_UDP_DST_PORT \ - (ICE_PROT_UDP_OUTER | ICE_DPORT) -#define ICE_INSET_SCTP_SRC_PORT \ - (ICE_PROT_SCTP_OUTER | ICE_SPORT) -#define ICE_INSET_SCTP_DST_PORT \ - (ICE_PROT_SCTP_OUTER | ICE_DPORT) -#define ICE_INSET_ICMP4_SRC_PORT \ - (ICE_PROT_ICMP4_OUTER | ICE_SPORT) -#define ICE_INSET_ICMP4_DST_PORT \ - (ICE_PROT_ICMP4_OUTER | ICE_DPORT) -#define ICE_INSET_ICMP6_SRC_PORT \ - (ICE_PROT_ICMP6_OUTER | ICE_SPORT) -#define ICE_INSET_ICMP6_DST_PORT \ - (ICE_PROT_ICMP6_OUTER | ICE_DPORT) -#define ICE_INSET_ICMP4_TYPE \ - (ICE_PROT_ICMP4_OUTER | ICE_ICMP_TYPE) -#define ICE_INSET_ICMP4_CODE \ - (ICE_PROT_ICMP4_OUTER | ICE_ICMP_CODE) -#define ICE_INSET_ICMP6_TYPE \ - (ICE_PROT_ICMP6_OUTER | ICE_ICMP_TYPE) -#define ICE_INSET_ICMP6_CODE \ - (ICE_PROT_ICMP6_OUTER | ICE_ICMP_CODE) +#define ICE_INSET_NONE 0ULL + +#define ICE_INSET_SMAC (ICE_SMAC) +#define ICE_INSET_DMAC (ICE_DMAC) +#define ICE_INSET_VLAN (ICE_PROT_VLAN) +#define ICE_INSET_VLAN_INNER (ICE_PROT_VLAN) +#define ICE_INSET_VLAN_OUTER (ICE_PROT_VLAN) +#define ICE_INSET_ETHERTYPE (ICE_ETHERTYPE) + +#define ICE_INSET_IPV4_SRC (ICE_PROT_IPV4 | ICE_IP_SRC) +#define ICE_INSET_IPV4_DST (ICE_PROT_IPV4 | ICE_IP_DST) +#define ICE_INSET_IPV4_TOS (ICE_PROT_IPV4 | ICE_IP_TOS) +#define ICE_INSET_IPV4_PROTO (ICE_PROT_IPV4 | ICE_IP_PROTO) +#define ICE_INSET_IPV4_TTL (ICE_PROT_IPV4 | ICE_IP_TTL) +#define ICE_INSET_IPV6_SRC (ICE_PROT_IPV6 | ICE_IP_SRC) +#define ICE_INSET_IPV6_DST (ICE_PROT_IPV6 | ICE_IP_DST) +#define ICE_INSET_IPV6_NEXT_HDR (ICE_PROT_IPV6 | ICE_IP_PROTO) +#define ICE_INSET_IPV6_HOP_LIMIT (ICE_PROT_IPV6 | ICE_IP_TTL) +#define ICE_INSET_IPV6_TC (ICE_PROT_IPV6 | ICE_IP_TOS) + +#define ICE_INSET_TCP_SRC_PORT (ICE_PROT_TCP | ICE_SPORT) +#define ICE_INSET_TCP_DST_PORT (ICE_PROT_TCP | ICE_DPORT) +#define ICE_INSET_UDP_SRC_PORT (ICE_PROT_UDP | ICE_SPORT) +#define ICE_INSET_UDP_DST_PORT (ICE_PROT_UDP | ICE_DPORT) +#define ICE_INSET_SCTP_SRC_PORT (ICE_PROT_SCTP | ICE_SPORT) +#define ICE_INSET_SCTP_DST_PORT (ICE_PROT_SCTP | ICE_DPORT) +#define ICE_INSET_ICMP4_SRC_PORT (ICE_PROT_ICMP4 | ICE_SPORT) +#define ICE_INSET_ICMP4_DST_PORT (ICE_PROT_ICMP4 | ICE_DPORT) +#define ICE_INSET_ICMP6_SRC_PORT (ICE_PROT_ICMP6 | ICE_SPORT) +#define ICE_INSET_ICMP6_DST_PORT (ICE_PROT_ICMP6 | ICE_DPORT) +#define ICE_INSET_ICMP4_TYPE (ICE_PROT_ICMP4 | ICE_ICMP_TYPE) +#define ICE_INSET_ICMP4_CODE (ICE_PROT_ICMP4 | ICE_ICMP_CODE) +#define ICE_INSET_ICMP6_TYPE (ICE_PROT_ICMP6 | ICE_ICMP_TYPE) +#define ICE_INSET_ICMP6_CODE (ICE_PROT_ICMP6 | ICE_ICMP_CODE) /* tunnel */ #define ICE_INSET_TUN_SMAC \ - (ICE_PROT_MAC_INNER | ICE_SMAC) + (ICE_PROT_MAC | ICE_SMAC) #define ICE_INSET_TUN_DMAC \ - (ICE_PROT_MAC_INNER | ICE_DMAC) + (ICE_PROT_MAC | ICE_DMAC) #define ICE_INSET_TUN_IPV4_SRC \ - (ICE_PROT_IPV4_INNER | ICE_IP_SRC) + (ICE_PROT_IPV4 | ICE_IP_SRC) #define ICE_INSET_TUN_IPV4_DST \ - (ICE_PROT_IPV4_INNER | ICE_IP_DST) + (ICE_PROT_IPV4 | ICE_IP_DST) #define ICE_INSET_TUN_IPV4_TTL \ - (ICE_PROT_IPV4_INNER | ICE_IP_TTL) + (ICE_PROT_IPV4 | ICE_IP_TTL) #define ICE_INSET_TUN_IPV4_PROTO \ - (ICE_PROT_IPV4_INNER | ICE_IP_PROTO) + (ICE_PROT_IPV4 | ICE_IP_PROTO) #define ICE_INSET_TUN_IPV4_TOS \ - (ICE_PROT_IPV4_INNER | ICE_IP_TOS) + (ICE_PROT_IPV4 | ICE_IP_TOS) #define ICE_INSET_TUN_IPV6_SRC \ - (ICE_PROT_IPV6_INNER | ICE_IP_SRC) + (ICE_PROT_IPV6 | ICE_IP_SRC) #define ICE_INSET_TUN_IPV6_DST \ - (ICE_PROT_IPV6_INNER | ICE_IP_DST) + (ICE_PROT_IPV6 | ICE_IP_DST) #define ICE_INSET_TUN_IPV6_HOP_LIMIT \ - (ICE_PROT_IPV6_INNER | ICE_IP_TTL) + (ICE_PROT_IPV6 | ICE_IP_TTL) #define ICE_INSET_TUN_IPV6_NEXT_HDR \ - (ICE_PROT_IPV6_INNER | ICE_IP_PROTO) + (ICE_PROT_IPV6 | ICE_IP_PROTO) #define ICE_INSET_TUN_IPV6_TC \ - (ICE_PROT_IPV6_INNER | ICE_IP_TOS) + (ICE_PROT_IPV6 | ICE_IP_TOS) #define ICE_INSET_TUN_TCP_SRC_PORT \ - (ICE_PROT_TCP_INNER | ICE_SPORT) + (ICE_PROT_TCP | ICE_SPORT) #define ICE_INSET_TUN_TCP_DST_PORT \ - (ICE_PROT_TCP_INNER | ICE_DPORT) + (ICE_PROT_TCP | ICE_DPORT) #define ICE_INSET_TUN_UDP_SRC_PORT \ - (ICE_PROT_UDP_INNER | ICE_SPORT) + (ICE_PROT_UDP | ICE_SPORT) #define ICE_INSET_TUN_UDP_DST_PORT \ - (ICE_PROT_UDP_INNER | ICE_DPORT) + (ICE_PROT_UDP | ICE_DPORT) #define ICE_INSET_TUN_SCTP_SRC_PORT \ - (ICE_PROT_SCTP_INNER | ICE_SPORT) + (ICE_PROT_SCTP | ICE_SPORT) #define ICE_INSET_TUN_SCTP_DST_PORT \ - (ICE_PROT_SCTP_INNER | ICE_DPORT) + (ICE_PROT_SCTP | ICE_DPORT) #define ICE_INSET_TUN_ICMP4_SRC_PORT \ - (ICE_PROT_ICMP4_INNER | ICE_SPORT) + (ICE_PROT_ICMP4 | ICE_SPORT) #define ICE_INSET_TUN_ICMP4_DST_PORT \ - (ICE_PROT_ICMP4_INNER | ICE_DPORT) + (ICE_PROT_ICMP4 | ICE_DPORT) #define ICE_INSET_TUN_ICMP6_SRC_PORT \ - (ICE_PROT_ICMP6_INNER | ICE_SPORT) + (ICE_PROT_ICMP6 | ICE_SPORT) #define ICE_INSET_TUN_ICMP6_DST_PORT \ - (ICE_PROT_ICMP6_INNER | ICE_DPORT) + (ICE_PROT_ICMP6 | ICE_DPORT) #define ICE_INSET_TUN_ICMP4_TYPE \ - (ICE_PROT_ICMP4_INNER | ICE_ICMP_TYPE) + (ICE_PROT_ICMP4 | ICE_ICMP_TYPE) #define ICE_INSET_TUN_ICMP4_CODE \ - (ICE_PROT_ICMP4_INNER | ICE_ICMP_CODE) + (ICE_PROT_ICMP4 | ICE_ICMP_CODE) #define ICE_INSET_TUN_ICMP6_TYPE \ - (ICE_PROT_ICMP6_INNER | ICE_ICMP_TYPE) + (ICE_PROT_ICMP6 | ICE_ICMP_TYPE) #define ICE_INSET_TUN_ICMP6_CODE \ - (ICE_PROT_ICMP6_INNER | ICE_ICMP_CODE) + (ICE_PROT_ICMP6 | ICE_ICMP_CODE) #define ICE_INSET_TUN_VXLAN_VNI \ (ICE_PROT_VXLAN | ICE_VXLAN_VNI) -- 2.20.1