summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/intel/iavf/iavf_fdir.c
diff options
context:
space:
mode:
authorHaiyue Wang <haiyue.wang@intel.com>2021-03-09 06:08:14 +0300
committerTony Nguyen <anthony.l.nguyen@intel.com>2021-03-22 21:32:12 +0300
commita6ccffaa8da32b6077e37e7d254d519bc071433a (patch)
tree3c827f85b0614401328485ba43dc0c6977cd26de /drivers/net/ethernet/intel/iavf/iavf_fdir.c
parente90cbc257a6f3f9cc2b257acab561b197c708bab (diff)
downloadlinux-a6ccffaa8da32b6077e37e7d254d519bc071433a.tar.xz
iavf: Support Ethernet Type Flow Director filters
Support the addition and deletion of Ethernet filters. Supported fields are: proto Supported flow-types are: ether Example usage: ethtool -N ens787f0v0 flow-type ether proto 0x8863 action 6 ethtool -N ens787f0v0 flow-type ether proto 0x8864 action 7 Signed-off-by: Haiyue Wang <haiyue.wang@intel.com> Tested-by: Chen Bo <BoX.C.Chen@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/iavf/iavf_fdir.c')
-rw-r--r--drivers/net/ethernet/intel/iavf/iavf_fdir.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/net/ethernet/intel/iavf/iavf_fdir.c b/drivers/net/ethernet/intel/iavf/iavf_fdir.c
index f84f2ab036d5..e1e1af136765 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_fdir.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_fdir.c
@@ -277,9 +277,19 @@ iavf_fill_fdir_eth_hdr(struct iavf_fdir_fltr *fltr,
struct virtchnl_proto_hdrs *proto_hdrs)
{
struct virtchnl_proto_hdr *hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++];
+ struct ethhdr *ehdr = (struct ethhdr *)hdr->buffer;
VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, ETH);
+ if (fltr->eth_mask.etype == htons(U16_MAX)) {
+ if (fltr->eth_data.etype == htons(ETH_P_IP) ||
+ fltr->eth_data.etype == htons(ETH_P_IPV6))
+ return -EOPNOTSUPP;
+
+ ehdr->h_proto = fltr->eth_data.etype;
+ VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, ETH, ETHERTYPE);
+ }
+
return 0;
}
@@ -351,6 +361,8 @@ int iavf_fill_fdir_add_msg(struct iavf_adapter *adapter, struct iavf_fdir_fltr *
err = iavf_fill_fdir_ip6_hdr(fltr, proto_hdrs) |
iavf_fill_fdir_l4_hdr(fltr, proto_hdrs);
break;
+ case IAVF_FDIR_FLOW_NON_IP_L2:
+ break;
default:
err = -EINVAL;
break;
@@ -392,6 +404,8 @@ static const char *iavf_fdir_flow_proto_name(enum iavf_fdir_flow_type flow_type)
case IAVF_FDIR_FLOW_IPV4_OTHER:
case IAVF_FDIR_FLOW_IPV6_OTHER:
return "Other";
+ case IAVF_FDIR_FLOW_NON_IP_L2:
+ return "Ethernet";
default:
return NULL;
}
@@ -468,6 +482,11 @@ void iavf_print_fdir_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *f
fltr->ip_data.proto,
ntohl(fltr->ip_data.l4_header));
break;
+ case IAVF_FDIR_FLOW_NON_IP_L2:
+ dev_info(&adapter->pdev->dev, "Rule ID: %u eth_type: 0x%x\n",
+ fltr->loc,
+ ntohs(fltr->eth_data.etype));
+ break;
default:
break;
}
@@ -489,7 +508,9 @@ bool iavf_fdir_is_dup_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *
if (tmp->flow_type != fltr->flow_type)
continue;
- if (!memcmp(&tmp->ip_data, &fltr->ip_data,
+ if (!memcmp(&tmp->eth_data, &fltr->eth_data,
+ sizeof(fltr->eth_data)) &&
+ !memcmp(&tmp->ip_data, &fltr->ip_data,
sizeof(fltr->ip_data))) {
ret = true;
break;