Commit 390bd141 authored by Qi Zhang's avatar Qi Zhang Committed by Tony Nguyen

ice: Add more basic protocol support for flow filter

Add more protocol and field support for flow filter include:
ETH, VLAN, ICMP, ARP and TCP flag.
Signed-off-by: default avatarKevin Scott <kevin.c.scott@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 a1e6f641
...@@ -492,6 +492,16 @@ static void ice_pkt_insert_u32(u8 *pkt, int offset, __be32 data) ...@@ -492,6 +492,16 @@ static void ice_pkt_insert_u32(u8 *pkt, int offset, __be32 data)
memcpy(pkt + offset, &data, sizeof(data)); memcpy(pkt + offset, &data, sizeof(data));
} }
/**
* ice_pkt_insert_mac_addr - insert a MAC addr into a memory buffer.
* @pkt: packet buffer
* @addr: MAC address to convert and insert into pkt at offset
*/
static void ice_pkt_insert_mac_addr(u8 *pkt, u8 *addr)
{
ether_addr_copy(pkt, addr);
}
/** /**
* ice_fdir_get_gen_prgm_pkt - generate a training packet * ice_fdir_get_gen_prgm_pkt - generate a training packet
* @hw: pointer to the hardware structure * @hw: pointer to the hardware structure
...@@ -580,6 +590,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input, ...@@ -580,6 +590,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
input->ip.v4.dst_ip); input->ip.v4.dst_ip);
ice_pkt_insert_u16(loc, ICE_IPV4_TCP_SRC_PORT_OFFSET, ice_pkt_insert_u16(loc, ICE_IPV4_TCP_SRC_PORT_OFFSET,
input->ip.v4.dst_port); input->ip.v4.dst_port);
ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
if (frag) if (frag)
loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF; loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
break; break;
...@@ -592,6 +603,9 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input, ...@@ -592,6 +603,9 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
input->ip.v4.dst_ip); input->ip.v4.dst_ip);
ice_pkt_insert_u16(loc, ICE_IPV4_UDP_SRC_PORT_OFFSET, ice_pkt_insert_u16(loc, ICE_IPV4_UDP_SRC_PORT_OFFSET,
input->ip.v4.dst_port); input->ip.v4.dst_port);
ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
ice_pkt_insert_mac_addr(loc + ETH_ALEN,
input->ext_data.src_mac);
break; break;
case ICE_FLTR_PTYPE_NONF_IPV4_SCTP: case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET, ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
...@@ -602,6 +616,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input, ...@@ -602,6 +616,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
input->ip.v4.dst_ip); input->ip.v4.dst_ip);
ice_pkt_insert_u16(loc, ICE_IPV4_SCTP_SRC_PORT_OFFSET, ice_pkt_insert_u16(loc, ICE_IPV4_SCTP_SRC_PORT_OFFSET,
input->ip.v4.dst_port); input->ip.v4.dst_port);
ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
break; break;
case ICE_FLTR_PTYPE_NONF_IPV4_OTHER: case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET, ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
...@@ -609,6 +624,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input, ...@@ -609,6 +624,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET, ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
input->ip.v4.dst_ip); input->ip.v4.dst_ip);
ice_pkt_insert_u16(loc, ICE_IPV4_PROTO_OFFSET, 0); ice_pkt_insert_u16(loc, ICE_IPV4_PROTO_OFFSET, 0);
ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
break; break;
case ICE_FLTR_PTYPE_NONF_IPV6_TCP: case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET, ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
...@@ -619,6 +635,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input, ...@@ -619,6 +635,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
input->ip.v6.src_port); input->ip.v6.src_port);
ice_pkt_insert_u16(loc, ICE_IPV6_TCP_SRC_PORT_OFFSET, ice_pkt_insert_u16(loc, ICE_IPV6_TCP_SRC_PORT_OFFSET,
input->ip.v6.dst_port); input->ip.v6.dst_port);
ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
break; break;
case ICE_FLTR_PTYPE_NONF_IPV6_UDP: case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET, ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
...@@ -629,6 +646,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input, ...@@ -629,6 +646,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
input->ip.v6.src_port); input->ip.v6.src_port);
ice_pkt_insert_u16(loc, ICE_IPV6_UDP_SRC_PORT_OFFSET, ice_pkt_insert_u16(loc, ICE_IPV6_UDP_SRC_PORT_OFFSET,
input->ip.v6.dst_port); input->ip.v6.dst_port);
ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
break; break;
case ICE_FLTR_PTYPE_NONF_IPV6_SCTP: case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET, ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
...@@ -639,12 +657,14 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input, ...@@ -639,12 +657,14 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
input->ip.v6.src_port); input->ip.v6.src_port);
ice_pkt_insert_u16(loc, ICE_IPV6_SCTP_SRC_PORT_OFFSET, ice_pkt_insert_u16(loc, ICE_IPV6_SCTP_SRC_PORT_OFFSET,
input->ip.v6.dst_port); input->ip.v6.dst_port);
ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
break; break;
case ICE_FLTR_PTYPE_NONF_IPV6_OTHER: case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET, ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
input->ip.v6.src_ip); input->ip.v6.src_ip);
ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET, ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
input->ip.v6.dst_ip); input->ip.v6.dst_ip);
ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
break; break;
default: default:
return ICE_ERR_PARAM; return ICE_ERR_PARAM;
......
...@@ -103,6 +103,7 @@ struct ice_fdir_v6 { ...@@ -103,6 +103,7 @@ struct ice_fdir_v6 {
struct ice_fdir_extra { struct ice_fdir_extra {
u8 dst_mac[ETH_ALEN]; /* dest MAC address */ u8 dst_mac[ETH_ALEN]; /* dest MAC address */
u8 src_mac[ETH_ALEN]; /* src MAC address */
u32 usr_def[2]; /* user data */ u32 usr_def[2]; /* user data */
__be16 vlan_type; /* VLAN ethertype */ __be16 vlan_type; /* VLAN ethertype */
__be16 vlan_tag; /* VLAN tag info */ __be16 vlan_tag; /* VLAN tag info */
......
This diff is collapsed.
...@@ -38,8 +38,12 @@ ...@@ -38,8 +38,12 @@
*/ */
enum ice_flow_seg_hdr { enum ice_flow_seg_hdr {
ICE_FLOW_SEG_HDR_NONE = 0x00000000, ICE_FLOW_SEG_HDR_NONE = 0x00000000,
ICE_FLOW_SEG_HDR_ETH = 0x00000001,
ICE_FLOW_SEG_HDR_VLAN = 0x00000002,
ICE_FLOW_SEG_HDR_IPV4 = 0x00000004, ICE_FLOW_SEG_HDR_IPV4 = 0x00000004,
ICE_FLOW_SEG_HDR_IPV6 = 0x00000008, ICE_FLOW_SEG_HDR_IPV6 = 0x00000008,
ICE_FLOW_SEG_HDR_ARP = 0x00000010,
ICE_FLOW_SEG_HDR_ICMP = 0x00000020,
ICE_FLOW_SEG_HDR_TCP = 0x00000040, ICE_FLOW_SEG_HDR_TCP = 0x00000040,
ICE_FLOW_SEG_HDR_UDP = 0x00000080, ICE_FLOW_SEG_HDR_UDP = 0x00000080,
ICE_FLOW_SEG_HDR_SCTP = 0x00000100, ICE_FLOW_SEG_HDR_SCTP = 0x00000100,
...@@ -47,6 +51,12 @@ enum ice_flow_seg_hdr { ...@@ -47,6 +51,12 @@ enum ice_flow_seg_hdr {
}; };
enum ice_flow_field { enum ice_flow_field {
/* L2 */
ICE_FLOW_FIELD_IDX_ETH_DA,
ICE_FLOW_FIELD_IDX_ETH_SA,
ICE_FLOW_FIELD_IDX_S_VLAN,
ICE_FLOW_FIELD_IDX_C_VLAN,
ICE_FLOW_FIELD_IDX_ETH_TYPE,
/* L3 */ /* L3 */
ICE_FLOW_FIELD_IDX_IPV4_SA, ICE_FLOW_FIELD_IDX_IPV4_SA,
ICE_FLOW_FIELD_IDX_IPV4_DA, ICE_FLOW_FIELD_IDX_IPV4_DA,
...@@ -59,6 +69,16 @@ enum ice_flow_field { ...@@ -59,6 +69,16 @@ enum ice_flow_field {
ICE_FLOW_FIELD_IDX_UDP_DST_PORT, ICE_FLOW_FIELD_IDX_UDP_DST_PORT,
ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT, ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT,
ICE_FLOW_FIELD_IDX_SCTP_DST_PORT, ICE_FLOW_FIELD_IDX_SCTP_DST_PORT,
ICE_FLOW_FIELD_IDX_TCP_FLAGS,
/* ARP */
ICE_FLOW_FIELD_IDX_ARP_SIP,
ICE_FLOW_FIELD_IDX_ARP_DIP,
ICE_FLOW_FIELD_IDX_ARP_SHA,
ICE_FLOW_FIELD_IDX_ARP_DHA,
ICE_FLOW_FIELD_IDX_ARP_OP,
/* ICMP */
ICE_FLOW_FIELD_IDX_ICMP_TYPE,
ICE_FLOW_FIELD_IDX_ICMP_CODE,
/* GRE */ /* GRE */
ICE_FLOW_FIELD_IDX_GRE_KEYID, ICE_FLOW_FIELD_IDX_GRE_KEYID,
/* The total number of enums must not exceed 64 */ /* The total number of enums must not exceed 64 */
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
enum ice_prot_id { enum ice_prot_id {
ICE_PROT_ID_INVAL = 0, ICE_PROT_ID_INVAL = 0,
ICE_PROT_MAC_OF_OR_S = 1, ICE_PROT_MAC_OF_OR_S = 1,
ICE_PROT_MAC_IL = 4,
ICE_PROT_ETYPE_OL = 9,
ICE_PROT_ETYPE_IL = 10,
ICE_PROT_IPV4_OF_OR_S = 32, ICE_PROT_IPV4_OF_OR_S = 32,
ICE_PROT_IPV4_IL = 33, ICE_PROT_IPV4_IL = 33,
ICE_PROT_IPV6_OF_OR_S = 40, ICE_PROT_IPV6_OF_OR_S = 40,
...@@ -22,6 +25,9 @@ enum ice_prot_id { ...@@ -22,6 +25,9 @@ enum ice_prot_id {
ICE_PROT_UDP_IL_OR_S = 53, ICE_PROT_UDP_IL_OR_S = 53,
ICE_PROT_GRE_OF = 64, ICE_PROT_GRE_OF = 64,
ICE_PROT_SCTP_IL = 96, ICE_PROT_SCTP_IL = 96,
ICE_PROT_ICMP_IL = 98,
ICE_PROT_ICMPV6_IL = 100,
ICE_PROT_ARP_OF = 118,
ICE_PROT_META_ID = 255, /* when offset == metadata */ ICE_PROT_META_ID = 255, /* when offset == metadata */
ICE_PROT_INVALID = 255 /* when offset == ICE_FV_OFFSET_INVAL */ ICE_PROT_INVALID = 255 /* when offset == ICE_FV_OFFSET_INVAL */
}; };
......
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