Commit 527691bf authored by Haiyue Wang's avatar Haiyue Wang Committed by Tony Nguyen

iavf: Support IPv4 Flow Director filters

Support the addition and deletion of IPv4 filters.

Supported fields are: src-ip, dst-ip, src-port, dst-port and l4proto
Supported flow-types are: tcp4, udp4, sctp4, ip4, ah4, esp4

Example usage:
ethtool -N ens787f0v0 flow-type tcp4 src-ip 192.168.0.20 \
  dst-ip 192.168.0.21 tos 4 src-port 22 dst-port 23 action 8

L2TPv3 over IP with 'Session ID' 17:
ethtool -N ens787f0v0 flow-type ip4 l4proto 115 l4data 17 action 3
Signed-off-by: default avatarHaiyue Wang <haiyue.wang@intel.com>
Tested-by: default avatarChen Bo <BoX.C.Chen@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 0dbfbabb
...@@ -11,5 +11,5 @@ subdir-ccflags-y += -I$(src) ...@@ -11,5 +11,5 @@ subdir-ccflags-y += -I$(src)
obj-$(CONFIG_IAVF) += iavf.o obj-$(CONFIG_IAVF) += iavf.o
iavf-objs := iavf_main.o iavf_ethtool.o iavf_virtchnl.o \ iavf-objs := iavf_main.o iavf_ethtool.o iavf_virtchnl.o iavf_fdir.o \
iavf_txrx.o iavf_common.o iavf_adminq.o iavf_client.o iavf_txrx.o iavf_common.o iavf_adminq.o iavf_client.o
This diff is collapsed.
...@@ -15,13 +15,53 @@ enum iavf_fdir_fltr_state_t { ...@@ -15,13 +15,53 @@ enum iavf_fdir_fltr_state_t {
IAVF_FDIR_FLTR_ACTIVE, /* Filter is active */ IAVF_FDIR_FLTR_ACTIVE, /* Filter is active */
}; };
enum iavf_fdir_flow_type {
/* NONE - used for undef/error */
IAVF_FDIR_FLOW_NONE = 0,
IAVF_FDIR_FLOW_IPV4_TCP,
IAVF_FDIR_FLOW_IPV4_UDP,
IAVF_FDIR_FLOW_IPV4_SCTP,
IAVF_FDIR_FLOW_IPV4_AH,
IAVF_FDIR_FLOW_IPV4_ESP,
IAVF_FDIR_FLOW_IPV4_OTHER,
/* MAX - this must be last and add anything new just above it */
IAVF_FDIR_FLOW_PTYPE_MAX,
};
struct iavf_ipv4_addrs {
__be32 src_ip;
__be32 dst_ip;
};
struct iavf_fdir_ip {
union {
struct iavf_ipv4_addrs v4_addrs;
};
__be16 src_port;
__be16 dst_port;
__be32 l4_header; /* first 4 bytes of the layer 4 header */
__be32 spi; /* security parameter index for AH/ESP */
union {
u8 tos;
};
u8 proto;
};
/* bookkeeping of Flow Director filters */ /* bookkeeping of Flow Director filters */
struct iavf_fdir_fltr { struct iavf_fdir_fltr {
enum iavf_fdir_fltr_state_t state; enum iavf_fdir_fltr_state_t state;
struct list_head list; struct list_head list;
enum iavf_fdir_flow_type flow_type;
struct iavf_fdir_ip ip_data;
struct iavf_fdir_ip ip_mask;
enum virtchnl_action action;
u32 flow_id; u32 flow_id;
u32 loc; /* Rule location inside the flow table */
u32 q_index;
struct virtchnl_fdir_add vc_add_msg; struct virtchnl_fdir_add vc_add_msg;
}; };
......
...@@ -1464,6 +1464,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, ...@@ -1464,6 +1464,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
dev_info(&adapter->pdev->dev, "Failed to add Flow Director filter, error %s\n", dev_info(&adapter->pdev->dev, "Failed to add Flow Director filter, error %s\n",
iavf_stat_str(&adapter->hw, iavf_stat_str(&adapter->hw,
v_retval)); v_retval));
iavf_print_fdir_fltr(adapter, fdir);
if (msglen) if (msglen)
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
"%s\n", msg); "%s\n", msg);
...@@ -1486,6 +1487,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, ...@@ -1486,6 +1487,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
dev_info(&adapter->pdev->dev, "Failed to del Flow Director filter, error %s\n", dev_info(&adapter->pdev->dev, "Failed to del Flow Director filter, error %s\n",
iavf_stat_str(&adapter->hw, iavf_stat_str(&adapter->hw,
v_retval)); v_retval));
iavf_print_fdir_fltr(adapter, fdir);
} }
} }
spin_unlock_bh(&adapter->fdir_fltr_lock); spin_unlock_bh(&adapter->fdir_fltr_lock);
...@@ -1638,11 +1640,14 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, ...@@ -1638,11 +1640,14 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
list) { list) {
if (fdir->state == IAVF_FDIR_FLTR_ADD_PENDING) { if (fdir->state == IAVF_FDIR_FLTR_ADD_PENDING) {
if (add_fltr->status == VIRTCHNL_FDIR_SUCCESS) { if (add_fltr->status == VIRTCHNL_FDIR_SUCCESS) {
dev_info(&adapter->pdev->dev, "Flow Director filter with location %u is added\n",
fdir->loc);
fdir->state = IAVF_FDIR_FLTR_ACTIVE; fdir->state = IAVF_FDIR_FLTR_ACTIVE;
fdir->flow_id = add_fltr->flow_id; fdir->flow_id = add_fltr->flow_id;
} else { } else {
dev_info(&adapter->pdev->dev, "Failed to add Flow Director filter with status: %d\n", dev_info(&adapter->pdev->dev, "Failed to add Flow Director filter with status: %d\n",
add_fltr->status); add_fltr->status);
iavf_print_fdir_fltr(adapter, fdir);
list_del(&fdir->list); list_del(&fdir->list);
kfree(fdir); kfree(fdir);
adapter->fdir_active_fltr--; adapter->fdir_active_fltr--;
...@@ -1661,6 +1666,8 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, ...@@ -1661,6 +1666,8 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
list) { list) {
if (fdir->state == IAVF_FDIR_FLTR_DEL_PENDING) { if (fdir->state == IAVF_FDIR_FLTR_DEL_PENDING) {
if (del_fltr->status == VIRTCHNL_FDIR_SUCCESS) { if (del_fltr->status == VIRTCHNL_FDIR_SUCCESS) {
dev_info(&adapter->pdev->dev, "Flow Director filter with location %u is deleted\n",
fdir->loc);
list_del(&fdir->list); list_del(&fdir->list);
kfree(fdir); kfree(fdir);
adapter->fdir_active_fltr--; adapter->fdir_active_fltr--;
...@@ -1668,6 +1675,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, ...@@ -1668,6 +1675,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
fdir->state = IAVF_FDIR_FLTR_ACTIVE; fdir->state = IAVF_FDIR_FLTR_ACTIVE;
dev_info(&adapter->pdev->dev, "Failed to delete Flow Director filter with status: %d\n", dev_info(&adapter->pdev->dev, "Failed to delete Flow Director filter with status: %d\n",
del_fltr->status); del_fltr->status);
iavf_print_fdir_fltr(adapter, fdir);
} }
} }
} }
......
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