Skip to content

Commit

Permalink
i40e: VLAN field for flow director
Browse files Browse the repository at this point in the history
Allow user to specify VLAN field and add it to flow director. Show VLAN
field in "ethtool -n ethx" command.
Handle VLAN type and tag field provided by ethtool command. Refactored
filter addition, by replacing static arrays with runtime dummy packet
creation, which allows specifying VLAN field.
Previously, VLAN field was omitted.

Signed-off-by: Przemyslaw Patynowski <przemyslawx.patynowski@intel.com>
Tested-by: Tony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
  • Loading branch information
Przemyslaw Patynowski authored and Tony Nguyen committed Feb 10, 2021
1 parent efca91e commit a9219b3
Show file tree
Hide file tree
Showing 4 changed files with 289 additions and 292 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ethernet/intel/i40e/i40e.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ struct i40e_fdir_filter {
__be16 dst_port;
__be32 sctp_v_tag;

__be16 vlan_etype;
__be16 vlan_tag;
/* Flexible data to match within the packet payload */
__be16 flex_word;
u16 flex_offset;
Expand Down
30 changes: 29 additions & 1 deletion drivers/net/ethernet/intel/i40e/i40e_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -3318,6 +3318,14 @@ static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,
else
fsp->ring_cookie = rule->q_index;

if (rule->vlan_tag) {
fsp->h_ext.vlan_etype = rule->vlan_etype;
fsp->m_ext.vlan_etype = htons(0xFFFF);
fsp->h_ext.vlan_tci = rule->vlan_tag;
fsp->m_ext.vlan_tci = htons(0xFFFF);
fsp->flow_type |= FLOW_EXT;
}

if (rule->dest_vsi != pf->vsi[pf->lan_vsi]->id) {
struct i40e_vsi *vsi;

Expand Down Expand Up @@ -4350,6 +4358,19 @@ static int i40e_check_fdir_input_set(struct i40e_vsi *vsi,
return -EOPNOTSUPP;
}

if (fsp->flow_type & FLOW_EXT) {
/* Allow only 802.1Q and no etype defined, as
* later it's modified to 0x8100
*/
if (fsp->h_ext.vlan_etype != htons(ETH_P_8021Q) &&
fsp->h_ext.vlan_etype != 0)
return -EOPNOTSUPP;
if (fsp->m_ext.vlan_tci == htons(0xFFFF))
new_mask |= I40E_VLAN_SRC_MASK;
else
new_mask &= ~I40E_VLAN_SRC_MASK;
}

/* First, clear all flexible filter entries */
new_mask &= ~I40E_FLEX_INPUT_MASK;

Expand Down Expand Up @@ -4529,7 +4550,9 @@ static bool i40e_match_fdir_filter(struct i40e_fdir_filter *a,
a->dst_port != b->dst_port ||
a->src_port != b->src_port ||
a->flow_type != b->flow_type ||
a->ipl4_proto != b->ipl4_proto)
a->ipl4_proto != b->ipl4_proto ||
a->vlan_tag != b->vlan_tag ||
a->vlan_etype != b->vlan_etype)
return false;

return true;
Expand Down Expand Up @@ -4688,6 +4711,11 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
input->src_ip = fsp->h_u.tcp_ip4_spec.ip4dst;
input->flow_type = fsp->flow_type & ~FLOW_EXT;

input->vlan_etype = fsp->h_ext.vlan_etype;
if (!fsp->m_ext.vlan_etype && fsp->h_ext.vlan_tci)
input->vlan_etype = cpu_to_be16(ETH_P_8021Q);
if (fsp->m_ext.vlan_tci && input->vlan_etype)
input->vlan_tag = fsp->h_ext.vlan_tci;
if (input->flow_type == IPV6_USER_FLOW ||
input->flow_type == UDP_V6_FLOW ||
input->flow_type == TCP_V6_FLOW ||
Expand Down
Loading

0 comments on commit a9219b3

Please sign in to comment.