Commit 7012dfd1 authored by Qi Zhang's avatar Qi Zhang Committed by Tony Nguyen

ice: Enhanced IPv4 and IPv6 flow filter

Separate IPv4 and IPv6 ptype bit mask table into 2 tables:
with or without L4 protocols.

When a flow filter without any l4 type is specified, the
ICE_FLOW_SEG_HDR_IPV_OTHER flag can be used to describe if user
want to create a IP rule target for all IP packet or just IP
packet without l4 header.
Signed-off-by: default avatarDan Nowlin <dan.nowlin@intel.com>
Signed-off-by: default avatarQi Zhang <qi.z.zhang@intel.com>
Tested-by: default avatarChen Bo <BoX.C.Chen@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent cbad5db8
...@@ -157,7 +157,9 @@ static const u32 ice_ptypes_macvlan_il[] = { ...@@ -157,7 +157,9 @@ static const u32 ice_ptypes_macvlan_il[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
}; };
/* Packet types for packets with an Outer/First/Single IPv4 header */ /* Packet types for packets with an Outer/First/Single IPv4 header, does NOT
* include IPv4 other PTYPEs
*/
static const u32 ice_ptypes_ipv4_ofos[] = { static const u32 ice_ptypes_ipv4_ofos[] = {
0x1DC00000, 0x04000800, 0x00000000, 0x00000000, 0x1DC00000, 0x04000800, 0x00000000, 0x00000000,
0x00000000, 0x00000155, 0x00000000, 0x00000000, 0x00000000, 0x00000155, 0x00000000, 0x00000000,
...@@ -167,6 +169,18 @@ static const u32 ice_ptypes_ipv4_ofos[] = { ...@@ -167,6 +169,18 @@ static const u32 ice_ptypes_ipv4_ofos[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
};
/* Packet types for packets with an Outer/First/Single IPv4 header, includes
* IPv4 other PTYPEs
*/
static const u32 ice_ptypes_ipv4_ofos_all[] = {
0x1DC00000, 0x04000800, 0x00000000, 0x00000000,
0x00000000, 0x00000155, 0x00000000, 0x00000000,
0x00000000, 0x000FC000, 0x83E0F800, 0x00000101,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
}; };
...@@ -183,7 +197,9 @@ static const u32 ice_ptypes_ipv4_il[] = { ...@@ -183,7 +197,9 @@ static const u32 ice_ptypes_ipv4_il[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
}; };
/* Packet types for packets with an Outer/First/Single IPv6 header */ /* Packet types for packets with an Outer/First/Single IPv6 header, does NOT
* include IPv6 other PTYPEs
*/
static const u32 ice_ptypes_ipv6_ofos[] = { static const u32 ice_ptypes_ipv6_ofos[] = {
0x00000000, 0x00000000, 0x77000000, 0x10002000, 0x00000000, 0x00000000, 0x77000000, 0x10002000,
0x00000000, 0x000002AA, 0x00000000, 0x00000000, 0x00000000, 0x000002AA, 0x00000000, 0x00000000,
...@@ -193,6 +209,18 @@ static const u32 ice_ptypes_ipv6_ofos[] = { ...@@ -193,6 +209,18 @@ static const u32 ice_ptypes_ipv6_ofos[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
};
/* Packet types for packets with an Outer/First/Single IPv6 header, includes
* IPv6 other PTYPEs
*/
static const u32 ice_ptypes_ipv6_ofos_all[] = {
0x00000000, 0x00000000, 0x77000000, 0x10002000,
0x00000000, 0x000002AA, 0x00000000, 0x00000000,
0x00080F00, 0x03F00000, 0x7C1F0000, 0x00000206,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
}; };
...@@ -577,6 +605,9 @@ struct ice_flow_prof_params { ...@@ -577,6 +605,9 @@ struct ice_flow_prof_params {
#define ICE_FLOW_SEG_HDRS_L4_MASK \ #define ICE_FLOW_SEG_HDRS_L4_MASK \
(ICE_FLOW_SEG_HDR_ICMP | ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_UDP | \ (ICE_FLOW_SEG_HDR_ICMP | ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_UDP | \
ICE_FLOW_SEG_HDR_SCTP) ICE_FLOW_SEG_HDR_SCTP)
/* mask for L4 protocols that are NOT part of IPv4/6 OTHER PTYPE groups */
#define ICE_FLOW_SEG_HDRS_L4_MASK_NO_OTHER \
(ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_SCTP)
/** /**
* ice_flow_val_hdrs - validates packet segments for valid protocol headers * ice_flow_val_hdrs - validates packet segments for valid protocol headers
...@@ -692,8 +723,21 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params) ...@@ -692,8 +723,21 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params)
(const unsigned long *)ice_ptypes_arp_of, (const unsigned long *)ice_ptypes_arp_of,
ICE_FLOW_PTYPE_MAX); ICE_FLOW_PTYPE_MAX);
} }
if ((hdrs & ICE_FLOW_SEG_HDR_IPV4) && if ((hdrs & ICE_FLOW_SEG_HDR_IPV4) &&
!(hdrs & ICE_FLOW_SEG_HDRS_L4_MASK)) { (hdrs & ICE_FLOW_SEG_HDR_IPV_OTHER)) {
src = i ? (const unsigned long *)ice_ptypes_ipv4_il :
(const unsigned long *)ice_ptypes_ipv4_ofos_all;
bitmap_and(params->ptypes, params->ptypes, src,
ICE_FLOW_PTYPE_MAX);
} else if ((hdrs & ICE_FLOW_SEG_HDR_IPV6) &&
(hdrs & ICE_FLOW_SEG_HDR_IPV_OTHER)) {
src = i ? (const unsigned long *)ice_ptypes_ipv6_il :
(const unsigned long *)ice_ptypes_ipv6_ofos_all;
bitmap_and(params->ptypes, params->ptypes, src,
ICE_FLOW_PTYPE_MAX);
} else if ((hdrs & ICE_FLOW_SEG_HDR_IPV4) &&
!(hdrs & ICE_FLOW_SEG_HDRS_L4_MASK_NO_OTHER)) {
src = !i ? (const unsigned long *)ice_ipv4_ofos_no_l4 : src = !i ? (const unsigned long *)ice_ipv4_ofos_no_l4 :
(const unsigned long *)ice_ipv4_il_no_l4; (const unsigned long *)ice_ipv4_il_no_l4;
bitmap_and(params->ptypes, params->ptypes, src, bitmap_and(params->ptypes, params->ptypes, src,
...@@ -704,7 +748,7 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params) ...@@ -704,7 +748,7 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params)
bitmap_and(params->ptypes, params->ptypes, src, bitmap_and(params->ptypes, params->ptypes, src,
ICE_FLOW_PTYPE_MAX); ICE_FLOW_PTYPE_MAX);
} else if ((hdrs & ICE_FLOW_SEG_HDR_IPV6) && } else if ((hdrs & ICE_FLOW_SEG_HDR_IPV6) &&
!(hdrs & ICE_FLOW_SEG_HDRS_L4_MASK)) { !(hdrs & ICE_FLOW_SEG_HDRS_L4_MASK_NO_OTHER)) {
src = !i ? (const unsigned long *)ice_ipv6_ofos_no_l4 : src = !i ? (const unsigned long *)ice_ipv6_ofos_no_l4 :
(const unsigned long *)ice_ipv6_il_no_l4; (const unsigned long *)ice_ipv6_il_no_l4;
bitmap_and(params->ptypes, params->ptypes, src, bitmap_and(params->ptypes, params->ptypes, src,
...@@ -1793,7 +1837,7 @@ ice_flow_set_rss_seg_info(struct ice_flow_seg_info *segs, u64 hash_fields, ...@@ -1793,7 +1837,7 @@ ice_flow_set_rss_seg_info(struct ice_flow_seg_info *segs, u64 hash_fields,
ICE_FLOW_SET_HDRS(segs, flow_hdr); ICE_FLOW_SET_HDRS(segs, flow_hdr);
if (segs->hdrs & ~ICE_FLOW_RSS_SEG_HDR_VAL_MASKS & if (segs->hdrs & ~ICE_FLOW_RSS_SEG_HDR_VAL_MASKS &
~ICE_FLOW_RSS_HDRS_INNER_MASK) ~ICE_FLOW_RSS_HDRS_INNER_MASK & ~ICE_FLOW_SEG_HDR_IPV_OTHER)
return ICE_ERR_PARAM; return ICE_ERR_PARAM;
val = (u64)(segs->hdrs & ICE_FLOW_RSS_SEG_HDR_L3_MASKS); val = (u64)(segs->hdrs & ICE_FLOW_RSS_SEG_HDR_L3_MASKS);
......
...@@ -135,6 +135,10 @@ enum ice_flow_seg_hdr { ...@@ -135,6 +135,10 @@ enum ice_flow_seg_hdr {
ICE_FLOW_SEG_HDR_ESP = 0x00100000, ICE_FLOW_SEG_HDR_ESP = 0x00100000,
ICE_FLOW_SEG_HDR_AH = 0x00200000, ICE_FLOW_SEG_HDR_AH = 0x00200000,
ICE_FLOW_SEG_HDR_NAT_T_ESP = 0x00400000, ICE_FLOW_SEG_HDR_NAT_T_ESP = 0x00400000,
/* The following is an additive bit for ICE_FLOW_SEG_HDR_IPV4 and
* ICE_FLOW_SEG_HDR_IPV6 which include the IPV4 other PTYPEs
*/
ICE_FLOW_SEG_HDR_IPV_OTHER = 0x20000000,
}; };
/* These segments all have the same PTYPES, but are otherwise distinguished by /* These segments all have the same PTYPES, but are otherwise distinguished by
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment