All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] support replace filter function
@ 2017-03-03  9:31 Beilei Xing
  2017-03-03  9:31 ` [PATCH 1/4] net/i40e: support replace filter type Beilei Xing
                   ` (5 more replies)
  0 siblings, 6 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-03  9:31 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, dev

This patchset adds replace filter function according
to DCR288 and supports cloud filter to VF.
This patchset serves for QinQ and MPLSoUDP/MPLSoGRE.

Beilei Xing (4):
  net/i40e: support replace filter type
  net/i40e: rework tunnel filter functions
  net/i40e: support tunnel filter to VF
  net/i40e: refine consistent tunnel filter

 drivers/net/i40e/i40e_ethdev.c | 222 +++++++++++++++++++++++++++----
 drivers/net/i40e/i40e_ethdev.h | 153 +++++++++++++++++++++
 drivers/net/i40e/i40e_flow.c   | 292 ++++++++++++++++++++++++++++++++---------
 3 files changed, 574 insertions(+), 93 deletions(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 1/4] net/i40e: support replace filter type
  2017-03-03  9:31 [PATCH 0/4] support replace filter function Beilei Xing
@ 2017-03-03  9:31 ` Beilei Xing
  2017-03-08 15:50   ` Ferruh Yigit
  2017-03-03  9:31 ` [PATCH 2/4] net/i40e: rework tunnel filter functions Beilei Xing
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 39+ messages in thread
From: Beilei Xing @ 2017-03-03  9:31 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, dev, Bernard Iremonger, Stroe Laura

Add new admin queue function and extended fields
in DCR 288:
 - Add admin queue function for Replace filter
   command (Opcode: 0x025F)
 - Add General fields for Add/Remove Cloud filters
   command

This patch will be removed to base driver in future.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Signed-off-by: Stroe Laura <laura.stroe@intel.com>
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.h | 106 ++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_flow.c   | 152 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 258 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index f545850..3a49865 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -729,6 +729,100 @@ struct i40e_valid_pattern {
 	parse_filter_t parse_filter;
 };
 
+/* Support replace filter */
+
+/* i40e_aqc_add_remove_cloud_filters_element_big_data is used when
+ * I40E_AQC_ADD_REM_CLOUD_CMD_BIG_BUFFER flag is set. refer to
+ * DCR288
+ */
+struct i40e_aqc_add_remove_cloud_filters_element_big_data {
+	struct i40e_aqc_add_remove_cloud_filters_element_data element;
+	uint16_t     general_fields[32];
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0	0
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1	1
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2	2
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0	3
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1	4
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2	5
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0	6
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1	7
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2	8
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0	9
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1	10
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2	11
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X14_WORD0	12
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X14_WORD1	13
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X14_WORD2	14
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X16_WORD0	15
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X16_WORD1	16
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X16_WORD2	17
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X16_WORD3	18
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X16_WORD4	19
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X16_WORD5	20
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X16_WORD6	21
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X16_WORD7	22
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X17_WORD0	23
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X17_WORD1	24
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X17_WORD2	25
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X17_WORD3	26
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X17_WORD4	27
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X17_WORD5	28
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X17_WORD6	29
+#define I40E_AQC_ADD_CLOUD_FV_FLU_0X17_WORD7	30
+};
+
+/* Replace filter Command 0x025F
+ * uses the i40e_aqc_replace_cloud_filters,
+ * and the generic indirect completion structure
+ */
+struct i40e_filter_data {
+	uint8_t filter_type;
+	uint8_t input[3];
+};
+
+struct i40e_aqc_replace_cloud_filters_cmd {
+	uint8_t  valid_flags;
+#define I40E_AQC_REPLACE_L1_FILTER	0x0
+#define I40E_AQC_REPLACE_CLOUD_FILTER	0x1
+#define I40E_AQC_GET_CLOUD_FILTERS	0x2
+#define I40E_AQC_MIRROR_CLOUD_FILTER	0x4
+#define I40E_AQC_HIGH_PRIORITY_CLOUD_FILTER	0x8
+	uint8_t  old_filter_type;
+	uint8_t  new_filter_type;
+	uint8_t  tr_bit;
+	uint8_t  valid_bit_mask;
+#define I40E_AQC_REPLACE_CLOUD_CMD_ENABLE_INPUT	0x80
+	uint8_t  reserved[4];
+	uint32_t addr_high;
+	uint32_t addr_low;
+};
+
+struct i40e_aqc_replace_cloud_filters_cmd_buf {
+	uint8_t  data[32];
+	/* Filter type INPUT codes*/
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_ENTRIES_MAX	3
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_VALIDATED	(1 << 7UL)
+
+	/* Field Vector offsets */
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_MAC_DA	0
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_STAG_ETH	6
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_STAG	7
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_VLAN	8
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_STAG_OVLAN	9
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_STAG_IVLAN	10
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TUNNLE_KEY	11
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_IMAC	12
+	/* big FLU */
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_IP_DA	14
+	/* big FLU */
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_OIP_DA	15
+
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_INNER_VLAN	37
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TEID_WORD0	44
+#define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TEID_WORD1	45
+	struct i40e_filter_data filters[8];
+};
+
 int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
 int i40e_vsi_release(struct i40e_vsi *vsi);
 struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf,
@@ -806,6 +900,18 @@ int i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 			       uint8_t add);
 int i40e_fdir_flush(struct rte_eth_dev *dev);
 
+enum i40e_status_code i40e_aq_add_cloud_filters_big_buffer(struct i40e_hw *hw,
+	   uint16_t seid,
+	   struct i40e_aqc_add_remove_cloud_filters_element_big_data *filters,
+	   uint8_t filter_count);
+enum i40e_status_code i40e_aq_remove_cloud_filters_big_buffer(
+	struct i40e_hw *hw, uint16_t seid,
+	struct i40e_aqc_add_remove_cloud_filters_element_big_data *filters,
+	uint8_t filter_count);
+enum i40e_status_code i40e_aq_replace_cloud_filters(struct i40e_hw *hw,
+		    struct i40e_aqc_replace_cloud_filters_cmd *filters,
+		    struct i40e_aqc_replace_cloud_filters_cmd_buf *cmd_buf);
+
 #define I40E_DEV_TO_PCI(eth_dev) \
 	RTE_DEV_TO_PCI((eth_dev)->device)
 
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index f163ce5..3c49228 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -1874,3 +1874,155 @@ i40e_flow_flush_tunnel_filter(struct i40e_pf *pf)
 
 	return ret;
 }
+
+#define i40e_aqc_opc_replace_cloud_filters 0x025F
+#define I40E_AQC_ADD_REM_CLOUD_CMD_BIG_BUFFER 1
+/**
+ * i40e_aq_add_cloud_filters_big_buffer
+ * @hw: pointer to the hardware structure
+ * @seid: VSI seid to add cloud filters from
+ * @filters: Buffer which contains the filters in big buffer to be added
+ * @filter_count: number of filters contained in the buffer
+ *
+ * Set the cloud filters for a given VSI.  The contents of the
+ * i40e_aqc_add_remove_cloud_filters_element_big_data are filled
+ * in by the caller of the function.
+ *
+ **/
+enum i40e_status_code i40e_aq_add_cloud_filters_big_buffer(
+	struct i40e_hw *hw, uint16_t seid,
+	struct i40e_aqc_add_remove_cloud_filters_element_big_data *filters,
+	uint8_t filter_count)
+{
+	struct i40e_aq_desc desc;
+	struct i40e_aqc_add_remove_cloud_filters *cmd =
+		(struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
+	enum i40e_status_code status;
+	uint16_t buff_len;
+	int i;
+
+	i40e_fill_default_direct_cmd_desc(&desc,
+					  i40e_aqc_opc_add_cloud_filters);
+
+	buff_len = filter_count * sizeof(*filters);
+	desc.datalen = CPU_TO_LE16(buff_len);
+	desc.flags |= CPU_TO_LE16(
+		(uint16_t)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
+	cmd->num_filters = filter_count;
+	cmd->seid = CPU_TO_LE16(seid);
+	cmd->reserved2[0] = I40E_AQC_ADD_REM_CLOUD_CMD_BIG_BUFFER;
+
+	/* adjust Geneve VNI for HW issue */
+	for (i = 0; i < filter_count; i++) {
+		uint16_t tnl_type;
+		uint32_t ti;
+
+		tnl_type = (LE16_TO_CPU(filters[i].element.flags) &
+			    I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK) >>
+			I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT;
+		if (tnl_type == I40E_AQC_ADD_CLOUD_TNL_TYPE_GENEVE) {
+			ti = LE32_TO_CPU(filters[i].element.tenant_id);
+			filters[i].element.tenant_id = CPU_TO_LE32(ti << 8);
+		}
+	}
+
+	status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
+
+	return status;
+}
+
+/**
+ * i40e_aq_remove_cloud_filters_big_buffer
+ * @hw: pointer to the hardware structure
+ * @seid: VSI seid to remove cloud filters from
+ * @filters: Buffer which contains the filters in big buffer to be removed
+ * @filter_count: number of filters contained in the buffer
+ *
+ * Remove the cloud filters for a given VSI.  The contents of the
+ * i40e_aqc_add_remove_cloud_filters_element_big_data are filled
+ * in by the caller of the function.
+ *
+ **/
+enum i40e_status_code i40e_aq_remove_cloud_filters_big_buffer(
+	struct i40e_hw *hw, uint16_t seid,
+	struct i40e_aqc_add_remove_cloud_filters_element_big_data *filters,
+	uint8_t filter_count)
+{
+	struct i40e_aq_desc desc;
+	struct i40e_aqc_add_remove_cloud_filters *cmd =
+		(struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
+	enum i40e_status_code status;
+	uint16_t buff_len;
+	int i;
+
+	i40e_fill_default_direct_cmd_desc(&desc,
+					  i40e_aqc_opc_remove_cloud_filters);
+
+	buff_len = filter_count * sizeof(*filters);
+	desc.datalen = CPU_TO_LE16(buff_len);
+	desc.flags |= CPU_TO_LE16(
+		(uint16_t)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
+	cmd->num_filters = filter_count;
+	cmd->seid = CPU_TO_LE16(seid);
+	cmd->reserved2[0] = I40E_AQC_ADD_REM_CLOUD_CMD_BIG_BUFFER;
+
+	/* adjust Geneve VNI for HW issue */
+	for (i = 0; i < filter_count; i++) {
+		uint16_t tnl_type;
+		uint32_t ti;
+
+		tnl_type = (LE16_TO_CPU(filters[i].element.flags) &
+			    I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK) >>
+			I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT;
+		if (tnl_type == I40E_AQC_ADD_CLOUD_TNL_TYPE_GENEVE) {
+			ti = LE32_TO_CPU(filters[i].element.tenant_id);
+			filters[i].element.tenant_id = CPU_TO_LE32(ti << 8);
+		}
+	}
+
+	status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
+
+	return status;
+}
+
+/**
+ * i40e_aq_replace_cloud_filters - Replace cloud filter command
+ * @hw: pointer to the hw struct
+ * @filters: pointer to the i40e_aqc_replace_cloud_filter_cmd struct
+ * @cmd_buf: pointer to the i40e_aqc_replace_cloud_filter_cmd_buf struct
+ **/
+enum
+i40e_status_code i40e_aq_replace_cloud_filters(struct i40e_hw *hw,
+	       struct i40e_aqc_replace_cloud_filters_cmd *filters,
+	       struct i40e_aqc_replace_cloud_filters_cmd_buf *cmd_buf)
+{
+	struct i40e_aq_desc desc;
+	struct i40e_aqc_replace_cloud_filters_cmd *cmd =
+		(struct i40e_aqc_replace_cloud_filters_cmd *)&desc.params.raw;
+	enum i40e_status_code status = I40E_SUCCESS;
+	int i = 0;
+
+	i40e_fill_default_direct_cmd_desc(&desc,
+					  i40e_aqc_opc_replace_cloud_filters);
+
+	desc.datalen = CPU_TO_LE16(32);
+	desc.flags |= CPU_TO_LE16(
+		(uint16_t)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
+	cmd->old_filter_type = filters->old_filter_type;
+	cmd->new_filter_type = filters->new_filter_type;
+	cmd->valid_flags = filters->valid_flags;
+	cmd->tr_bit = filters->tr_bit;
+
+	status = i40e_asq_send_command(hw, &desc, cmd_buf,
+	       sizeof(struct i40e_aqc_replace_cloud_filters_cmd_buf),  NULL);
+
+	/* for get cloud filters command */
+	for (i = 0; i < 32; i += 4) {
+		cmd_buf->filters[i / 4].filter_type = cmd_buf->data[i];
+		cmd_buf->filters[i / 4].input[0] = cmd_buf->data[i + 1];
+		cmd_buf->filters[i / 4].input[1] = cmd_buf->data[i + 2];
+		cmd_buf->filters[i / 4].input[2] = cmd_buf->data[i + 3];
+	}
+
+	return status;
+}
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 2/4] net/i40e: rework tunnel filter functions
  2017-03-03  9:31 [PATCH 0/4] support replace filter function Beilei Xing
  2017-03-03  9:31 ` [PATCH 1/4] net/i40e: support replace filter type Beilei Xing
@ 2017-03-03  9:31 ` Beilei Xing
  2017-03-08 15:50   ` Ferruh Yigit
  2017-03-03  9:31 ` [PATCH 3/4] net/i40e: support tunnel filter to VF Beilei Xing
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 39+ messages in thread
From: Beilei Xing @ 2017-03-03  9:31 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, dev

Rework tunnel filter functions to align with the
new command buffer for add/remove cloud filter.
This patch also changes tunnel filter function
name to VXLAN filter function, it will be easy to
add other tunnel type parsing function.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 77 +++++++++++++++++++++++---------------
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_flow.c   | 84 +++++++++++++++++++-----------------------
 3 files changed, 87 insertions(+), 75 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 508fcc8..8de68b5 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -410,7 +410,7 @@ static int i40e_sw_ethertype_filter_insert(struct i40e_pf *pf,
 				   struct i40e_ethertype_filter *filter);
 
 static int i40e_tunnel_filter_convert(
-	struct i40e_aqc_add_remove_cloud_filters_element_data *cld_filter,
+	struct i40e_aqc_add_remove_cloud_filters_element_big_data *cld_filter,
 	struct i40e_tunnel_filter *tunnel_filter);
 static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,
 				struct i40e_tunnel_filter *tunnel_filter);
@@ -6703,24 +6703,28 @@ i40e_dev_get_filter_type(uint16_t filter_type, uint16_t *flag)
 
 /* Convert tunnel filter structure */
 static int
-i40e_tunnel_filter_convert(struct i40e_aqc_add_remove_cloud_filters_element_data
-			   *cld_filter,
-			   struct i40e_tunnel_filter *tunnel_filter)
+i40e_tunnel_filter_convert(
+	struct i40e_aqc_add_remove_cloud_filters_element_big_data
+	*cld_filter,
+	struct i40e_tunnel_filter *tunnel_filter)
 {
-	ether_addr_copy((struct ether_addr *)&cld_filter->outer_mac,
+	ether_addr_copy((struct ether_addr *)&cld_filter->element.outer_mac,
 			(struct ether_addr *)&tunnel_filter->input.outer_mac);
-	ether_addr_copy((struct ether_addr *)&cld_filter->inner_mac,
+	ether_addr_copy((struct ether_addr *)&cld_filter->element.inner_mac,
 			(struct ether_addr *)&tunnel_filter->input.inner_mac);
-	tunnel_filter->input.inner_vlan = cld_filter->inner_vlan;
-	if ((rte_le_to_cpu_16(cld_filter->flags) &
+	tunnel_filter->input.inner_vlan = cld_filter->element.inner_vlan;
+	if ((rte_le_to_cpu_16(cld_filter->element.flags) &
 	     I40E_AQC_ADD_CLOUD_FLAGS_IPV6) ==
 	    I40E_AQC_ADD_CLOUD_FLAGS_IPV6)
 		tunnel_filter->input.ip_type = I40E_TUNNEL_IPTYPE_IPV6;
 	else
 		tunnel_filter->input.ip_type = I40E_TUNNEL_IPTYPE_IPV4;
-	tunnel_filter->input.flags = cld_filter->flags;
-	tunnel_filter->input.tenant_id = cld_filter->tenant_id;
-	tunnel_filter->queue = cld_filter->queue_number;
+	tunnel_filter->input.flags = cld_filter->element.flags;
+	tunnel_filter->input.tenant_id = cld_filter->element.tenant_id;
+	tunnel_filter->queue = cld_filter->element.queue_number;
+	rte_memcpy(tunnel_filter->input.general_fields,
+		   cld_filter->general_fields,
+		   sizeof(cld_filter->general_fields));
 
 	return 0;
 }
@@ -6799,15 +6803,16 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	int val, ret = 0;
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_vsi *vsi = pf->main_vsi;
-	struct i40e_aqc_add_remove_cloud_filters_element_data  *cld_filter;
-	struct i40e_aqc_add_remove_cloud_filters_element_data  *pfilter;
+	struct i40e_aqc_add_remove_cloud_filters_element_big_data  *cld_filter;
+	struct i40e_aqc_add_remove_cloud_filters_element_big_data  *pfilter;
 	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
 	struct i40e_tunnel_filter *tunnel, *node;
 	struct i40e_tunnel_filter check_filter; /* Check if filter exists */
+	bool big_buffer = 0;
 
 	cld_filter = rte_zmalloc("tunnel_filter",
-		sizeof(struct i40e_aqc_add_remove_cloud_filters_element_data),
-		0);
+	sizeof(struct i40e_aqc_add_remove_cloud_filters_element_big_data),
+	0);
 
 	if (NULL == cld_filter) {
 		PMD_DRV_LOG(ERR, "Failed to alloc memory.");
@@ -6815,24 +6820,28 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	}
 	pfilter = cld_filter;
 
-	ether_addr_copy(&tunnel_filter->outer_mac, (struct ether_addr*)&pfilter->outer_mac);
-	ether_addr_copy(&tunnel_filter->inner_mac, (struct ether_addr*)&pfilter->inner_mac);
+	ether_addr_copy(&tunnel_filter->outer_mac,
+			(struct ether_addr *)&pfilter->element.outer_mac);
+	ether_addr_copy(&tunnel_filter->inner_mac,
+			(struct ether_addr *)&pfilter->element.inner_mac);
 
-	pfilter->inner_vlan = rte_cpu_to_le_16(tunnel_filter->inner_vlan);
+	pfilter->element.inner_vlan =
+		rte_cpu_to_le_16(tunnel_filter->inner_vlan);
 	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
 		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
 		ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
-		rte_memcpy(&pfilter->ipaddr.v4.data,
+		rte_memcpy(&pfilter->element.ipaddr.v4.data,
 				&rte_cpu_to_le_32(ipv4_addr),
-				sizeof(pfilter->ipaddr.v4.data));
+				sizeof(pfilter->element.ipaddr.v4.data));
 	} else {
 		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
 		for (i = 0; i < 4; i++) {
 			convert_ipv6[i] =
 			rte_cpu_to_le_32(rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv6_addr[i]));
 		}
-		rte_memcpy(&pfilter->ipaddr.v6.data, &convert_ipv6,
-				sizeof(pfilter->ipaddr.v6.data));
+		rte_memcpy(&pfilter->element.ipaddr.v6.data,
+			   &convert_ipv6,
+			   sizeof(pfilter->element.ipaddr.v6.data));
 	}
 
 	/* check tunneled type */
@@ -6854,17 +6863,18 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	}
 
 	val = i40e_dev_get_filter_type(tunnel_filter->filter_type,
-						&pfilter->flags);
+				       &pfilter->element.flags);
 	if (val < 0) {
 		rte_free(cld_filter);
 		return -EINVAL;
 	}
 
-	pfilter->flags |= rte_cpu_to_le_16(
+	pfilter->element.flags |= rte_cpu_to_le_16(
 		I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE |
 		ip_type | (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT));
-	pfilter->tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
-	pfilter->queue_number = rte_cpu_to_le_16(tunnel_filter->queue_id);
+	pfilter->element.tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
+	pfilter->element.queue_number =
+		rte_cpu_to_le_16(tunnel_filter->queue_id);
 
 	/* Check if there is the filter in SW list */
 	memset(&check_filter, 0, sizeof(check_filter));
@@ -6881,7 +6891,12 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	}
 
 	if (add) {
-		ret = i40e_aq_add_cloud_filters(hw, vsi->seid, cld_filter, 1);
+		if (big_buffer)
+			ret = i40e_aq_add_cloud_filters_big_buffer(hw,
+						   vsi->seid, cld_filter, 1);
+		else
+			ret = i40e_aq_add_cloud_filters(hw,
+					vsi->seid, &cld_filter->element, 1);
 		if (ret < 0) {
 			PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
 			return ret;
@@ -6890,8 +6905,12 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 		rte_memcpy(tunnel, &check_filter, sizeof(check_filter));
 		ret = i40e_sw_tunnel_filter_insert(pf, tunnel);
 	} else {
-		ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
-						   cld_filter, 1);
+		if (big_buffer)
+			ret = i40e_aq_remove_cloud_filters_big_buffer(
+				hw, vsi->seid, cld_filter, 1);
+		else
+			ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
+					   &cld_filter->element, 1);
 		if (ret < 0) {
 			PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter.");
 			return ret;
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 3a49865..adf26f4 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -512,6 +512,7 @@ struct i40e_tunnel_filter_input {
 	enum i40e_tunnel_iptype ip_type;
 	uint16_t flags;          /* Filter type flag */
 	uint32_t tenant_id;      /* Tenant id to match */
+	uint16_t general_fields[32];  /* Big buffer */
 };
 
 struct i40e_tunnel_filter {
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 3c49228..62f5842 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -90,10 +90,6 @@ static int i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
 				       const struct rte_flow_action *actions,
 				       struct rte_flow_error *error,
 				       struct rte_eth_fdir_filter *filter);
-static int i40e_flow_parse_tunnel_pattern(__rte_unused struct rte_eth_dev *dev,
-				  const struct rte_flow_item *pattern,
-				  struct rte_flow_error *error,
-				  struct rte_eth_tunnel_filter_conf *filter);
 static int i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
 				 const struct rte_flow_action *actions,
 				 struct rte_flow_error *error,
@@ -112,12 +108,12 @@ static int i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 				       const struct rte_flow_action actions[],
 				       struct rte_flow_error *error,
 				       union i40e_filter_t *filter);
-static int i40e_flow_parse_tunnel_filter(struct rte_eth_dev *dev,
-					 const struct rte_flow_attr *attr,
-					 const struct rte_flow_item pattern[],
-					 const struct rte_flow_action actions[],
-					 struct rte_flow_error *error,
-					 union i40e_filter_t *filter);
+static int i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
+					const struct rte_flow_attr *attr,
+					const struct rte_flow_item pattern[],
+					const struct rte_flow_action actions[],
+					struct rte_flow_error *error,
+					union i40e_filter_t *filter);
 static int i40e_flow_destroy_ethertype_filter(struct i40e_pf *pf,
 				      struct i40e_ethertype_filter *filter);
 static int i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
@@ -303,10 +299,10 @@ static struct i40e_valid_pattern i40e_supported_patterns[] = {
 	{ pattern_fdir_ipv6_sctp, i40e_flow_parse_fdir_filter },
 	{ pattern_fdir_ipv6_sctp_ext, i40e_flow_parse_fdir_filter },
 	/* tunnel */
-	{ pattern_vxlan_1, i40e_flow_parse_tunnel_filter },
-	{ pattern_vxlan_2, i40e_flow_parse_tunnel_filter },
-	{ pattern_vxlan_3, i40e_flow_parse_tunnel_filter },
-	{ pattern_vxlan_4, i40e_flow_parse_tunnel_filter },
+	{ pattern_vxlan_1, i40e_flow_parse_vxlan_filter },
+	{ pattern_vxlan_2, i40e_flow_parse_vxlan_filter },
+	{ pattern_vxlan_3, i40e_flow_parse_vxlan_filter },
+	{ pattern_vxlan_4, i40e_flow_parse_vxlan_filter },
 };
 
 #define NEXT_ITEM_OF_ACTION(act, actions, index)                        \
@@ -1205,7 +1201,8 @@ i40e_check_tenant_id_mask(const uint8_t *mask)
  *    filled with 0.
  */
 static int
-i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
+i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
+			      const struct rte_flow_item *pattern,
 			      struct rte_flow_error *error,
 			      struct rte_eth_tunnel_filter_conf *filter)
 {
@@ -1469,32 +1466,19 @@ i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
 }
 
 static int
-i40e_flow_parse_tunnel_pattern(__rte_unused struct rte_eth_dev *dev,
-			       const struct rte_flow_item *pattern,
-			       struct rte_flow_error *error,
-			       struct rte_eth_tunnel_filter_conf *filter)
-{
-	int ret;
-
-	ret = i40e_flow_parse_vxlan_pattern(pattern, error, filter);
-
-	return ret;
-}
-
-static int
-i40e_flow_parse_tunnel_filter(struct rte_eth_dev *dev,
-			      const struct rte_flow_attr *attr,
-			      const struct rte_flow_item pattern[],
-			      const struct rte_flow_action actions[],
-			      struct rte_flow_error *error,
-			      union i40e_filter_t *filter)
+i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
+			     const struct rte_flow_attr *attr,
+			     const struct rte_flow_item pattern[],
+			     const struct rte_flow_action actions[],
+			     struct rte_flow_error *error,
+			     union i40e_filter_t *filter)
 {
 	struct rte_eth_tunnel_filter_conf *tunnel_filter =
 		&filter->tunnel_filter;
 	int ret;
 
-	ret = i40e_flow_parse_tunnel_pattern(dev, pattern,
-					     error, tunnel_filter);
+	ret = i40e_flow_parse_vxlan_pattern(dev, pattern,
+					    error, tunnel_filter);
 	if (ret)
 		return ret;
 
@@ -1725,23 +1709,31 @@ i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_vsi *vsi = pf->main_vsi;
-	struct i40e_aqc_add_remove_cloud_filters_element_data cld_filter;
+	struct i40e_aqc_add_remove_cloud_filters_element_big_data cld_filter;
 	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
 	struct i40e_tunnel_filter *node;
+	bool big_buffer = 0;
 	int ret = 0;
 
 	memset(&cld_filter, 0, sizeof(cld_filter));
 	ether_addr_copy((struct ether_addr *)&filter->input.outer_mac,
-			(struct ether_addr *)&cld_filter.outer_mac);
+			(struct ether_addr *)&cld_filter.element.outer_mac);
 	ether_addr_copy((struct ether_addr *)&filter->input.inner_mac,
-			(struct ether_addr *)&cld_filter.inner_mac);
-	cld_filter.inner_vlan = filter->input.inner_vlan;
-	cld_filter.flags = filter->input.flags;
-	cld_filter.tenant_id = filter->input.tenant_id;
-	cld_filter.queue_number = filter->queue;
-
-	ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
-					   &cld_filter, 1);
+			(struct ether_addr *)&cld_filter.element.inner_mac);
+	cld_filter.element.inner_vlan = filter->input.inner_vlan;
+	cld_filter.element.flags = filter->input.flags;
+	cld_filter.element.tenant_id = filter->input.tenant_id;
+	cld_filter.element.queue_number = filter->queue;
+	rte_memcpy(cld_filter.general_fields,
+		   filter->input.general_fields,
+		   sizeof(cld_filter.general_fields));
+
+	if (big_buffer)
+		ret = i40e_aq_remove_cloud_filters_big_buffer(hw, vsi->seid,
+							      &cld_filter, 1);
+	else
+		ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
+						   &cld_filter.element, 1);
 	if (ret < 0)
 		return ret;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 3/4] net/i40e: support tunnel filter to VF
  2017-03-03  9:31 [PATCH 0/4] support replace filter function Beilei Xing
  2017-03-03  9:31 ` [PATCH 1/4] net/i40e: support replace filter type Beilei Xing
  2017-03-03  9:31 ` [PATCH 2/4] net/i40e: rework tunnel filter functions Beilei Xing
@ 2017-03-03  9:31 ` Beilei Xing
  2017-03-08 15:50   ` Ferruh Yigit
  2017-03-03  9:31 ` [PATCH 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 39+ messages in thread
From: Beilei Xing @ 2017-03-03  9:31 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, dev, Bernard Iremonger, Yong Liu

This patch is to support tunnel filter to VF.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Signed-off-by: Yong Liu <yong.liu@intel.com>
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 145 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.h |  32 +++++++++
 drivers/net/i40e/i40e_flow.c   |  50 +++++++++-----
 3 files changed, 212 insertions(+), 15 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 8de68b5..43afd5b 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -6922,6 +6922,151 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	return ret;
 }
 
+int
+i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
+		      struct i40e_tunnel_filter_conf *tunnel_filter,
+		      uint8_t add)
+{
+	uint16_t ip_type;
+	uint32_t ipv4_addr;
+	uint8_t i, tun_type = 0;
+	/* internal variable to convert ipv6 byte order */
+	uint32_t convert_ipv6[4];
+	int val, ret = 0;
+	struct i40e_pf_vf *vf = NULL;
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	struct i40e_vsi *vsi;
+	struct i40e_aqc_add_remove_cloud_filters_element_big_data  *cld_filter;
+	struct i40e_aqc_add_remove_cloud_filters_element_big_data  *pfilter;
+	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
+	struct i40e_tunnel_filter *tunnel, *node;
+	struct i40e_tunnel_filter check_filter; /* Check if filter exists */
+	bool big_buffer = 0;
+
+	cld_filter = rte_zmalloc("tunnel_filter",
+	sizeof(struct i40e_aqc_add_remove_cloud_filters_element_big_data),
+	0);
+
+	if (cld_filter == NULL) {
+		PMD_DRV_LOG(ERR, "Failed to alloc memory.");
+		return -EINVAL;
+	}
+	pfilter = cld_filter;
+
+	ether_addr_copy(&tunnel_filter->outer_mac,
+			(struct ether_addr *)&pfilter->element.outer_mac);
+	ether_addr_copy(&tunnel_filter->inner_mac,
+			(struct ether_addr *)&pfilter->element.inner_mac);
+
+	pfilter->element.inner_vlan =
+		rte_cpu_to_le_16(tunnel_filter->inner_vlan);
+	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
+		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
+		ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
+		rte_memcpy(&pfilter->element.ipaddr.v4.data,
+				&rte_cpu_to_le_32(ipv4_addr),
+				sizeof(pfilter->element.ipaddr.v4.data));
+	} else {
+		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
+		for (i = 0; i < 4; i++) {
+			convert_ipv6[i] =
+			rte_cpu_to_le_32(rte_be_to_cpu_32(
+					 tunnel_filter->ip_addr.ipv6_addr[i]));
+		}
+		rte_memcpy(&pfilter->element.ipaddr.v6.data,
+			   &convert_ipv6,
+			   sizeof(pfilter->element.ipaddr.v6.data));
+	}
+
+	/* check tunneled type */
+	switch (tunnel_filter->tunnel_type) {
+	case RTE_TUNNEL_TYPE_VXLAN:
+		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN;
+		break;
+	case RTE_TUNNEL_TYPE_NVGRE:
+		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_NVGRE_OMAC;
+		break;
+	case RTE_TUNNEL_TYPE_IP_IN_GRE:
+		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_IP;
+		break;
+	default:
+		/* Other tunnel types is not supported. */
+		PMD_DRV_LOG(ERR, "tunnel type is not supported.");
+		rte_free(cld_filter);
+		return -EINVAL;
+	}
+
+	val = i40e_dev_get_filter_type(tunnel_filter->filter_type,
+				       &pfilter->element.flags);
+	if (val < 0) {
+		rte_free(cld_filter);
+		return -EINVAL;
+	}
+
+	pfilter->element.flags |= rte_cpu_to_le_16(
+		I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE |
+		ip_type | (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT));
+	pfilter->element.tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
+	pfilter->element.queue_number =
+		rte_cpu_to_le_16(tunnel_filter->queue_id);
+
+	if (!tunnel_filter->is_to_vf)
+		vsi = pf->main_vsi;
+	else {
+		if (tunnel_filter->vf_id >= pf->vf_num) {
+			PMD_DRV_LOG(ERR, "Invalid argument.");
+			return -EINVAL;
+		}
+		vf = &pf->vfs[tunnel_filter->vf_id];
+		vsi = vf->vsi;
+	}
+
+	/* Check if there is the filter in SW list */
+	memset(&check_filter, 0, sizeof(check_filter));
+	i40e_tunnel_filter_convert(cld_filter, &check_filter);
+	node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &check_filter.input);
+	if (add && node) {
+		PMD_DRV_LOG(ERR, "Conflict with existing tunnel rules!");
+		return -EINVAL;
+	}
+
+	if (!add && !node) {
+		PMD_DRV_LOG(ERR, "There's no corresponding tunnel filter!");
+		return -EINVAL;
+	}
+
+	if (add) {
+		if (big_buffer)
+			ret = i40e_aq_add_cloud_filters_big_buffer(hw,
+						   vsi->seid, cld_filter, 1);
+		else
+			ret = i40e_aq_add_cloud_filters(hw,
+					vsi->seid, &cld_filter->element, 1);
+		if (ret < 0) {
+			PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
+			return ret;
+		}
+		tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0);
+		rte_memcpy(tunnel, &check_filter, sizeof(check_filter));
+		ret = i40e_sw_tunnel_filter_insert(pf, tunnel);
+	} else {
+		if (big_buffer)
+			ret = i40e_aq_remove_cloud_filters_big_buffer(
+				hw, vsi->seid, cld_filter, 1);
+		else
+			ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
+					   &cld_filter->element, 1);
+		if (ret < 0) {
+			PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter.");
+			return ret;
+		}
+		ret = i40e_sw_tunnel_filter_del(pf, &node->input);
+	}
+
+	rte_free(cld_filter);
+	return ret;
+}
+
 static int
 i40e_get_vxlan_port_idx(struct i40e_pf *pf, uint16_t port)
 {
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index adf26f4..3c8a420 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -513,6 +513,7 @@ struct i40e_tunnel_filter_input {
 	uint16_t flags;          /* Filter type flag */
 	uint32_t tenant_id;      /* Tenant id to match */
 	uint16_t general_fields[32];  /* Big buffer */
+	uint16_t vf_id;         /* VF id for tunnel filtering. */
 };
 
 struct i40e_tunnel_filter {
@@ -529,6 +530,33 @@ struct i40e_tunnel_rule {
 	struct rte_hash *hash_table;
 };
 
+/**
+ * Tunneling Packet filter configuration.
+ */
+struct i40e_tunnel_filter_conf {
+	struct ether_addr outer_mac;    /**< Outer MAC address to match. */
+	struct ether_addr inner_mac;    /**< Inner MAC address to match. */
+	uint16_t inner_vlan;            /**< Inner VLAN to match. */
+	uint32_t outer_vlan;            /**< Outer VLAN to match */
+	enum rte_tunnel_iptype ip_type; /**< IP address type. */
+	/**
+	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
+	 * is set in filter_type, or inner destination IP address to match
+	 * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
+	 */
+	union {
+		uint32_t ipv4_addr;     /**< IPv4 address in big endian. */
+		uint32_t ipv6_addr[4];  /**< IPv6 address in big endian. */
+	} ip_addr;
+	/** Flags from ETH_TUNNEL_FILTER_XX - see above. */
+	uint16_t filter_type;
+	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+	uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
+	uint16_t queue_id;      /**< Queue assigned to if match. */
+	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
+	uint16_t vf_id;         /**< VF id for tunnel filter insertion. */
+};
+
 #define I40E_MIRROR_MAX_ENTRIES_PER_RULE   64
 #define I40E_MAX_MIRROR_RULES           64
 /*
@@ -717,6 +745,7 @@ union i40e_filter_t {
 	struct rte_eth_ethertype_filter ethertype_filter;
 	struct rte_eth_fdir_filter fdir_filter;
 	struct rte_eth_tunnel_filter_conf tunnel_filter;
+	struct i40e_tunnel_filter_conf consistent_tunnel_filter;
 };
 
 typedef int (*parse_filter_t)(struct rte_eth_dev *dev,
@@ -899,6 +928,9 @@ int i40e_add_del_fdir_filter(struct rte_eth_dev *dev,
 int i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 			       struct rte_eth_tunnel_filter_conf *tunnel_filter,
 			       uint8_t add);
+int i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
+				  struct i40e_tunnel_filter_conf *tunnel_filter,
+				  uint8_t add);
 int i40e_fdir_flush(struct rte_eth_dev *dev);
 
 enum i40e_status_code i40e_aq_add_cloud_filters_big_buffer(struct i40e_hw *hw,
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 62f5842..03c7026 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -93,7 +93,7 @@ static int i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
 static int i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
 				 const struct rte_flow_action *actions,
 				 struct rte_flow_error *error,
-				 struct rte_eth_tunnel_filter_conf *filter);
+				 struct i40e_tunnel_filter_conf *filter);
 static int i40e_flow_parse_attr(const struct rte_flow_attr *attr,
 				struct rte_flow_error *error);
 static int i40e_flow_parse_ethertype_filter(struct rte_eth_dev *dev,
@@ -1127,34 +1127,54 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 }
 
 /* Parse to get the action info of a tunnle filter
- * Tunnel action only supports QUEUE.
+ * Tunnel action only supports PF, VF and QUEUE.
  */
 static int
 i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
 			      const struct rte_flow_action *actions,
 			      struct rte_flow_error *error,
-			      struct rte_eth_tunnel_filter_conf *filter)
+			      struct i40e_tunnel_filter_conf *filter)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	const struct rte_flow_action *act;
 	const struct rte_flow_action_queue *act_q;
+	const struct rte_flow_action_vf *act_vf;
 	uint32_t index = 0;
 
-	/* Check if the first non-void action is QUEUE. */
+	/* Check if the first non-void action is PF or VF. */
 	NEXT_ITEM_OF_ACTION(act, actions, index);
-	if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE) {
+	if (act->type != RTE_FLOW_ACTION_TYPE_PF &&
+	    act->type != RTE_FLOW_ACTION_TYPE_VF) {
 		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
 				   act, "Not supported action.");
 		return -rte_errno;
 	}
 
-	act_q = (const struct rte_flow_action_queue *)act->conf;
-	filter->queue_id = act_q->index;
-	if (filter->queue_id >= pf->dev_data->nb_rx_queues) {
-		rte_flow_error_set(error, EINVAL,
+	if (act->type == RTE_FLOW_ACTION_TYPE_VF) {
+		act_vf = (const struct rte_flow_action_vf *)act->conf;
+		filter->vf_id = act_vf->id;
+		filter->is_to_vf = 1;
+		if (filter->vf_id >= pf->vf_num) {
+			rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_ACTION,
+				   act, "Invalid VF ID for tunnel filter");
+			return -rte_errno;
+		}
+	}
+
+	/* Check if the next non-void item is QUEUE */
+	index++;
+	NEXT_ITEM_OF_ACTION(act, actions, index);
+	if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
+		act_q = (const struct rte_flow_action_queue *)act->conf;
+		filter->queue_id = act_q->index;
+		if (!filter->is_to_vf)
+			if (filter->queue_id >= pf->dev_data->nb_rx_queues) {
+				rte_flow_error_set(error, EINVAL,
 				   RTE_FLOW_ERROR_TYPE_ACTION,
 				   act, "Invalid queue ID for tunnel filter");
-		return -rte_errno;
+				return -rte_errno;
+			}
 	}
 
 	/* Check if the next non-void item is END */
@@ -1204,7 +1224,7 @@ static int
 i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			      const struct rte_flow_item *pattern,
 			      struct rte_flow_error *error,
-			      struct rte_eth_tunnel_filter_conf *filter)
+			      struct i40e_tunnel_filter_conf *filter)
 {
 	const struct rte_flow_item *item = pattern;
 	const struct rte_flow_item_eth *eth_spec;
@@ -1473,8 +1493,8 @@ i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
 			     struct rte_flow_error *error,
 			     union i40e_filter_t *filter)
 {
-	struct rte_eth_tunnel_filter_conf *tunnel_filter =
-		&filter->tunnel_filter;
+	struct i40e_tunnel_filter_conf *tunnel_filter =
+		&filter->consistent_tunnel_filter;
 	int ret;
 
 	ret = i40e_flow_parse_vxlan_pattern(dev, pattern,
@@ -1605,8 +1625,8 @@ i40e_flow_create(struct rte_eth_dev *dev,
 					i40e_fdir_filter_list);
 		break;
 	case RTE_ETH_FILTER_TUNNEL:
-		ret = i40e_dev_tunnel_filter_set(pf,
-					 &cons_filter.tunnel_filter, 1);
+		ret = i40e_dev_consistent_tunnel_filter_set(pf,
+			    &cons_filter.consistent_tunnel_filter, 1);
 		if (ret)
 			goto free_flow;
 		flow->rule = TAILQ_LAST(&pf->tunnel.tunnel_list,
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 4/4] net/i40e: refine consistent tunnel filter
  2017-03-03  9:31 [PATCH 0/4] support replace filter function Beilei Xing
                   ` (2 preceding siblings ...)
  2017-03-03  9:31 ` [PATCH 3/4] net/i40e: support tunnel filter to VF Beilei Xing
@ 2017-03-03  9:31 ` Beilei Xing
  2017-03-08 15:50   ` Ferruh Yigit
  2017-03-08 15:50 ` [PATCH 0/4] support replace filter function Ferruh Yigit
  2017-03-23 10:46 ` [PATCH v2 0/4] Rework tunnel filter functions Beilei Xing
  5 siblings, 1 reply; 39+ messages in thread
From: Beilei Xing @ 2017-03-03  9:31 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, dev

Add i40e_tunnel_type enumeration type to refine consistent
tunnel filter, it will be esay to add new tunnel type for
i40e.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c |  8 ++++----
 drivers/net/i40e/i40e_ethdev.h | 18 ++++++++++++++++--
 drivers/net/i40e/i40e_flow.c   |  6 +++---
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 43afd5b..91bfd73 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -6960,7 +6960,7 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
 
 	pfilter->element.inner_vlan =
 		rte_cpu_to_le_16(tunnel_filter->inner_vlan);
-	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
+	if (tunnel_filter->ip_type == I40E_TUNNEL_IPTYPE_IPV4) {
 		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
 		ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
 		rte_memcpy(&pfilter->element.ipaddr.v4.data,
@@ -6980,13 +6980,13 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
 
 	/* check tunneled type */
 	switch (tunnel_filter->tunnel_type) {
-	case RTE_TUNNEL_TYPE_VXLAN:
+	case I40E_TUNNEL_TYPE_VXLAN:
 		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN;
 		break;
-	case RTE_TUNNEL_TYPE_NVGRE:
+	case I40E_TUNNEL_TYPE_NVGRE:
 		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_NVGRE_OMAC;
 		break;
-	case RTE_TUNNEL_TYPE_IP_IN_GRE:
+	case I40E_TUNNEL_TYPE_IP_IN_GRE:
 		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_IP;
 		break;
 	default:
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 3c8a420..3e9b129 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -531,6 +531,20 @@ struct i40e_tunnel_rule {
 };
 
 /**
+ * Tunnel type.
+ */
+enum i40e_tunnel_type {
+	I40E_TUNNEL_TYPE_NONE = 0,
+	I40E_TUNNEL_TYPE_VXLAN,
+	I40E_TUNNEL_TYPE_GENEVE,
+	I40E_TUNNEL_TYPE_TEREDO,
+	I40E_TUNNEL_TYPE_NVGRE,
+	I40E_TUNNEL_TYPE_IP_IN_GRE,
+	I40E_L2_TUNNEL_TYPE_E_TAG,
+	I40E_TUNNEL_TYPE_MAX,
+};
+
+/**
  * Tunneling Packet filter configuration.
  */
 struct i40e_tunnel_filter_conf {
@@ -538,7 +552,7 @@ struct i40e_tunnel_filter_conf {
 	struct ether_addr inner_mac;    /**< Inner MAC address to match. */
 	uint16_t inner_vlan;            /**< Inner VLAN to match. */
 	uint32_t outer_vlan;            /**< Outer VLAN to match */
-	enum rte_tunnel_iptype ip_type; /**< IP address type. */
+	enum i40e_tunnel_iptype ip_type; /**< IP address type. */
 	/**
 	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
 	 * is set in filter_type, or inner destination IP address to match
@@ -550,7 +564,7 @@ struct i40e_tunnel_filter_conf {
 	} ip_addr;
 	/** Flags from ETH_TUNNEL_FILTER_XX - see above. */
 	uint16_t filter_type;
-	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+	enum i40e_tunnel_type tunnel_type; /**< Tunnel Type. */
 	uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
 	uint16_t queue_id;      /**< Queue assigned to if match. */
 	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 03c7026..3e8c63a 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -1324,7 +1324,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			}
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
-			filter->ip_type = RTE_TUNNEL_IPTYPE_IPV4;
+			filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
 			/* IPv4 is used to describe protocol,
 			 * spec and mask should be NULL.
 			 */
@@ -1337,7 +1337,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			}
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
-			filter->ip_type = RTE_TUNNEL_IPTYPE_IPV6;
+			filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
 			/* IPv6 is used to describe protocol,
 			 * spec and mask should be NULL.
 			 */
@@ -1480,7 +1480,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 		return -rte_errno;
 	}
 
-	filter->tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
+	filter->tunnel_type = I40E_TUNNEL_TYPE_VXLAN;
 
 	return 0;
 }
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH 0/4] support replace filter function
  2017-03-03  9:31 [PATCH 0/4] support replace filter function Beilei Xing
                   ` (3 preceding siblings ...)
  2017-03-03  9:31 ` [PATCH 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
@ 2017-03-08 15:50 ` Ferruh Yigit
  2017-03-09  5:13   ` Xing, Beilei
  2017-03-23 10:46 ` [PATCH v2 0/4] Rework tunnel filter functions Beilei Xing
  5 siblings, 1 reply; 39+ messages in thread
From: Ferruh Yigit @ 2017-03-08 15:50 UTC (permalink / raw)
  To: Beilei Xing, jingjing.wu; +Cc: helin.zhang, dev

On 3/3/2017 9:31 AM, Beilei Xing wrote:
> This patchset adds replace filter function according
> to DCR288 and supports cloud filter to VF.

Is "cloud filter" common term, or specific to i40e ?

Can you please provide small description about "cloud filter" here and
provide links for more detailed information? Please feel free to update
i40e documentation if required.

> This patchset serves for QinQ and MPLSoUDP/MPLSoGRE.
> 
> Beilei Xing (4):
>   net/i40e: support replace filter type
>   net/i40e: rework tunnel filter functions
>   net/i40e: support tunnel filter to VF
>   net/i40e: refine consistent tunnel filter
> 
>  drivers/net/i40e/i40e_ethdev.c | 222 +++++++++++++++++++++++++++----
>  drivers/net/i40e/i40e_ethdev.h | 153 +++++++++++++++++++++
>  drivers/net/i40e/i40e_flow.c   | 292 ++++++++++++++++++++++++++++++++---------
>  3 files changed, 574 insertions(+), 93 deletions(-)
> 

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/4] net/i40e: support replace filter type
  2017-03-03  9:31 ` [PATCH 1/4] net/i40e: support replace filter type Beilei Xing
@ 2017-03-08 15:50   ` Ferruh Yigit
  2017-03-09  5:59     ` Xing, Beilei
  0 siblings, 1 reply; 39+ messages in thread
From: Ferruh Yigit @ 2017-03-08 15:50 UTC (permalink / raw)
  To: Beilei Xing, jingjing.wu; +Cc: helin.zhang, dev, Bernard Iremonger, Stroe Laura

On 3/3/2017 9:31 AM, Beilei Xing wrote:
> Add new admin queue function and extended fields
> in DCR 288:
>  - Add admin queue function for Replace filter
>    command (Opcode: 0x025F)
>  - Add General fields for Add/Remove Cloud filters
>    command
> 
> This patch will be removed to base driver in future.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> Signed-off-by: Stroe Laura <laura.stroe@intel.com>
> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev.h | 106 ++++++++++++++++++++++++++++
>  drivers/net/i40e/i40e_flow.c   | 152 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 258 insertions(+)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
> index f545850..3a49865 100644
> --- a/drivers/net/i40e/i40e_ethdev.h
> +++ b/drivers/net/i40e/i40e_ethdev.h
> @@ -729,6 +729,100 @@ struct i40e_valid_pattern {
>  	parse_filter_t parse_filter;
>  };
>  
> +/* Support replace filter */
> +
> +/* i40e_aqc_add_remove_cloud_filters_element_big_data is used when
> + * I40E_AQC_ADD_REM_CLOUD_CMD_BIG_BUFFER flag is set. refer to
> + * DCR288

Please do not refer to DCR, unless you can provide a public link for it.

> + */
> +struct i40e_aqc_add_remove_cloud_filters_element_big_data {
> +	struct i40e_aqc_add_remove_cloud_filters_element_data element;

What is the difference between
"i40e_aqc_add_remove_cloud_filters_element_big_data" and
"i40e_aqc_add_remove_cloud_filters_element_data", why need big_data one?

> +	uint16_t     general_fields[32];

Not very useful variable name.

<...>

> +/* Replace filter Command 0x025F
> + * uses the i40e_aqc_replace_cloud_filters,
> + * and the generic indirect completion structure
> + */
> +struct i40e_filter_data {
> +	uint8_t filter_type;
> +	uint8_t input[3];
> +};
> +
> +struct i40e_aqc_replace_cloud_filters_cmd {

Is replace does something different than remove old and add new cloud
filter?

<...>

> +enum i40e_status_code i40e_aq_add_cloud_filters_big_buffer(struct i40e_hw *hw,
> +	   uint16_t seid,
> +	   struct i40e_aqc_add_remove_cloud_filters_element_big_data *filters,
> +	   uint8_t filter_count);
> +enum i40e_status_code i40e_aq_remove_cloud_filters_big_buffer(
> +	struct i40e_hw *hw, uint16_t seid,
> +	struct i40e_aqc_add_remove_cloud_filters_element_big_data *filters,
> +	uint8_t filter_count);
> +enum i40e_status_code i40e_aq_replace_cloud_filters(struct i40e_hw *hw,
> +		    struct i40e_aqc_replace_cloud_filters_cmd *filters,
> +		    struct i40e_aqc_replace_cloud_filters_cmd_buf *cmd_buf);
> +

Do you need these function declarations?

>  #define I40E_DEV_TO_PCI(eth_dev) \
>  	RTE_DEV_TO_PCI((eth_dev)->device)
>  
> diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
> index f163ce5..3c49228 100644
> --- a/drivers/net/i40e/i40e_flow.c
> +++ b/drivers/net/i40e/i40e_flow.c
> @@ -1874,3 +1874,155 @@ i40e_flow_flush_tunnel_filter(struct i40e_pf *pf)
>  
>  	return ret;
>  }
> +
> +#define i40e_aqc_opc_replace_cloud_filters 0x025F
> +#define I40E_AQC_ADD_REM_CLOUD_CMD_BIG_BUFFER 1
> +/**
> + * i40e_aq_add_cloud_filters_big_buffer
> + * @hw: pointer to the hardware structure
> + * @seid: VSI seid to add cloud filters from
> + * @filters: Buffer which contains the filters in big buffer to be added
> + * @filter_count: number of filters contained in the buffer
> + *
> + * Set the cloud filters for a given VSI.  The contents of the
> + * i40e_aqc_add_remove_cloud_filters_element_big_data are filled
> + * in by the caller of the function.
> + *
> + **/
> +enum i40e_status_code i40e_aq_add_cloud_filters_big_buffer(

There are already non big_buffer versions of these functions, like
"i40e_aq_add_cloud_filters()" why big_data version required, what it
does differently?

And is there a reason that these functions are not static? (For this
patch they are not used at all and will cause build error, but my
question is after they started to be used)

<...>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/4] net/i40e: rework tunnel filter functions
  2017-03-03  9:31 ` [PATCH 2/4] net/i40e: rework tunnel filter functions Beilei Xing
@ 2017-03-08 15:50   ` Ferruh Yigit
  2017-03-09  6:00     ` Xing, Beilei
  0 siblings, 1 reply; 39+ messages in thread
From: Ferruh Yigit @ 2017-03-08 15:50 UTC (permalink / raw)
  To: Beilei Xing, jingjing.wu; +Cc: helin.zhang, dev

On 3/3/2017 9:31 AM, Beilei Xing wrote:
> Rework tunnel filter functions to align with the
> new command buffer for add/remove cloud filter.

> This patch also changes tunnel filter function
> name to VXLAN filter function, it will be easy to
> add other tunnel type parsing function.

Can you please do renaming in different patch in this patchset, that
change should be trivial, but looking more confusing with other change.

> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
<...>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/4] net/i40e: support tunnel filter to VF
  2017-03-03  9:31 ` [PATCH 3/4] net/i40e: support tunnel filter to VF Beilei Xing
@ 2017-03-08 15:50   ` Ferruh Yigit
  2017-03-09  6:08     ` Xing, Beilei
  0 siblings, 1 reply; 39+ messages in thread
From: Ferruh Yigit @ 2017-03-08 15:50 UTC (permalink / raw)
  To: Beilei Xing, jingjing.wu; +Cc: helin.zhang, dev, Bernard Iremonger, Yong Liu

On 3/3/2017 9:31 AM, Beilei Xing wrote:
> This patch is to support tunnel filter to VF.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> Signed-off-by: Yong Liu <yong.liu@intel.com>
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> ---

<...>

> +/**
> + * Tunneling Packet filter configuration.
> + */
> +struct i40e_tunnel_filter_conf {

There is already "rte_eth_tunnel_filter_conf", why driver is creating
its own version of structure instead of using / updating public one?

> +	struct ether_addr outer_mac;    /**< Outer MAC address to match. */
> +	struct ether_addr inner_mac;    /**< Inner MAC address to match. */
> +	uint16_t inner_vlan;            /**< Inner VLAN to match. */
> +	uint32_t outer_vlan;            /**< Outer VLAN to match */
> +	enum rte_tunnel_iptype ip_type; /**< IP address type. */
> +	/**
> +	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
> +	 * is set in filter_type, or inner destination IP address to match
> +	 * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
> +	 */
> +	union {
> +		uint32_t ipv4_addr;     /**< IPv4 address in big endian. */
> +		uint32_t ipv6_addr[4];  /**< IPv6 address in big endian. */
> +	} ip_addr;
> +	/** Flags from ETH_TUNNEL_FILTER_XX - see above. */
> +	uint16_t filter_type;
> +	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
> +	uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
> +	uint16_t queue_id;      /**< Queue assigned to if match. */
> +	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
> +	uint16_t vf_id;         /**< VF id for tunnel filter insertion. */
> +};
> +

<...>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 4/4] net/i40e: refine consistent tunnel filter
  2017-03-03  9:31 ` [PATCH 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
@ 2017-03-08 15:50   ` Ferruh Yigit
  2017-03-09  6:11     ` Xing, Beilei
  0 siblings, 1 reply; 39+ messages in thread
From: Ferruh Yigit @ 2017-03-08 15:50 UTC (permalink / raw)
  To: Beilei Xing, jingjing.wu; +Cc: helin.zhang, dev

On 3/3/2017 9:31 AM, Beilei Xing wrote:
> Add i40e_tunnel_type enumeration type to refine consistent
> tunnel filter, it will be esay to add new tunnel type for

s/esay/easy

> i40e.
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>

<...>

>  /**
> + * Tunnel type.
> + */
> +enum i40e_tunnel_type {
> +	I40E_TUNNEL_TYPE_NONE = 0,
> +	I40E_TUNNEL_TYPE_VXLAN,
> +	I40E_TUNNEL_TYPE_GENEVE,
> +	I40E_TUNNEL_TYPE_TEREDO,
> +	I40E_TUNNEL_TYPE_NVGRE,
> +	I40E_TUNNEL_TYPE_IP_IN_GRE,
> +	I40E_L2_TUNNEL_TYPE_E_TAG,
> +	I40E_TUNNEL_TYPE_MAX,
> +};

Same question here, there is already "rte_eth_tunnel_type", why driver
is duplicating the structure?

<...>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 0/4] support replace filter function
  2017-03-08 15:50 ` [PATCH 0/4] support replace filter function Ferruh Yigit
@ 2017-03-09  5:13   ` Xing, Beilei
  0 siblings, 0 replies; 39+ messages in thread
From: Xing, Beilei @ 2017-03-09  5:13 UTC (permalink / raw)
  To: Yigit, Ferruh, Wu, Jingjing; +Cc: Zhang, Helin, dev



> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Wednesday, March 8, 2017 11:50 PM
> To: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 0/4] support replace filter function
> 
> On 3/3/2017 9:31 AM, Beilei Xing wrote:
> > This patchset adds replace filter function according to DCR288 and
> > supports cloud filter to VF.
> 
> Is "cloud filter" common term, or specific to i40e ?
> 
> Can you please provide small description about "cloud filter" here and
> provide links for more detailed information? Please feel free to update i40e
> documentation if required.

Yes, "Cloud filter" is described in 7.4.9.5.9.11 of datasheet. We only support filter to PF in PMD currently.
Will update the description in next version.

> 
> > This patchset serves for QinQ and MPLSoUDP/MPLSoGRE.
> >
> > Beilei Xing (4):
> >   net/i40e: support replace filter type
> >   net/i40e: rework tunnel filter functions
> >   net/i40e: support tunnel filter to VF
> >   net/i40e: refine consistent tunnel filter
> >
> >  drivers/net/i40e/i40e_ethdev.c | 222 +++++++++++++++++++++++++++--
> --
> > drivers/net/i40e/i40e_ethdev.h | 153 +++++++++++++++++++++
> >  drivers/net/i40e/i40e_flow.c   | 292
> ++++++++++++++++++++++++++++++++---------
> >  3 files changed, 574 insertions(+), 93 deletions(-)
> >

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/4] net/i40e: support replace filter type
  2017-03-08 15:50   ` Ferruh Yigit
@ 2017-03-09  5:59     ` Xing, Beilei
  2017-03-09 10:01       ` Ferruh Yigit
  0 siblings, 1 reply; 39+ messages in thread
From: Xing, Beilei @ 2017-03-09  5:59 UTC (permalink / raw)
  To: Yigit, Ferruh, Wu, Jingjing
  Cc: Zhang, Helin, dev, Iremonger, Bernard, Stroe, Laura



> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Wednesday, March 8, 2017 11:50 PM
> To: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org; Iremonger,
> Bernard <bernard.iremonger@intel.com>; Stroe, Laura
> <laura.stroe@intel.com>
> Subject: Re: [dpdk-dev] [PATCH 1/4] net/i40e: support replace filter type
> 
> On 3/3/2017 9:31 AM, Beilei Xing wrote:
> > Add new admin queue function and extended fields in DCR 288:
> >  - Add admin queue function for Replace filter
> >    command (Opcode: 0x025F)
> >  - Add General fields for Add/Remove Cloud filters
> >    command
> >
> > This patch will be removed to base driver in future.
> >
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > Signed-off-by: Stroe Laura <laura.stroe@intel.com>
> > Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> > Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> > ---
> >  drivers/net/i40e/i40e_ethdev.h | 106 ++++++++++++++++++++++++++++
> >  drivers/net/i40e/i40e_flow.c   | 152
> +++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 258 insertions(+)
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev.h
> > b/drivers/net/i40e/i40e_ethdev.h index f545850..3a49865 100644
> > --- a/drivers/net/i40e/i40e_ethdev.h
> > +++ b/drivers/net/i40e/i40e_ethdev.h
> > @@ -729,6 +729,100 @@ struct i40e_valid_pattern {
> >  	parse_filter_t parse_filter;
> >  };
> >
> > +/* Support replace filter */
> > +
> > +/* i40e_aqc_add_remove_cloud_filters_element_big_data is used when
> > + * I40E_AQC_ADD_REM_CLOUD_CMD_BIG_BUFFER flag is set. refer to
> > + * DCR288
> 
> Please do not refer to DCR, unless you can provide a public link for it.
OK, got it.

> 
> > + */
> > +struct i40e_aqc_add_remove_cloud_filters_element_big_data {
> > +	struct i40e_aqc_add_remove_cloud_filters_element_data element;
> 
> What is the difference between
> "i40e_aqc_add_remove_cloud_filters_element_big_data" and
> "i40e_aqc_add_remove_cloud_filters_element_data", why need big_data
> one?

As ' Add/Remove Cloud filters -command buffer ' is changed in the DCR288, 'general fields' exists only when big_buffer is set.
But we don't want to change the  " i40e_aqc_add_remove_cloud_filters_element_data " as it will cause ABI/API change in kernel driver.

> 
> > +	uint16_t     general_fields[32];
> 
> Not very useful variable name.

It's the name from DCR.

> 
> <...>
> 
> > +/* Replace filter Command 0x025F
> > + * uses the i40e_aqc_replace_cloud_filters,
> > + * and the generic indirect completion structure  */ struct
> > +i40e_filter_data {
> > +	uint8_t filter_type;
> > +	uint8_t input[3];
> > +};
> > +
> > +struct i40e_aqc_replace_cloud_filters_cmd {
> 
> Is replace does something different than remove old and add new cloud
> filter?

It's just like remove an old filter and add a new filter.
It can replace both l1 filter and cloud filter.

> 
> <...>
> 
> > +enum i40e_status_code i40e_aq_add_cloud_filters_big_buffer(struct
> i40e_hw *hw,
> > +	   uint16_t seid,
> > +	   struct i40e_aqc_add_remove_cloud_filters_element_big_data
> *filters,
> > +	   uint8_t filter_count);
> > +enum i40e_status_code i40e_aq_remove_cloud_filters_big_buffer(
> > +	struct i40e_hw *hw, uint16_t seid,
> > +	struct i40e_aqc_add_remove_cloud_filters_element_big_data
> *filters,
> > +	uint8_t filter_count);
> > +enum i40e_status_code i40e_aq_replace_cloud_filters(struct i40e_hw
> *hw,
> > +		    struct i40e_aqc_replace_cloud_filters_cmd *filters,
> > +		    struct i40e_aqc_replace_cloud_filters_cmd_buf
> *cmd_buf);
> > +
> 
> Do you need these function declarations?
We can remove it if we define them with "static".

> 
> >  #define I40E_DEV_TO_PCI(eth_dev) \
> >  	RTE_DEV_TO_PCI((eth_dev)->device)
> >
> > diff --git a/drivers/net/i40e/i40e_flow.c
> > b/drivers/net/i40e/i40e_flow.c index f163ce5..3c49228 100644
> > --- a/drivers/net/i40e/i40e_flow.c
> > +++ b/drivers/net/i40e/i40e_flow.c
> > @@ -1874,3 +1874,155 @@ i40e_flow_flush_tunnel_filter(struct i40e_pf
> > *pf)
> >
> >  	return ret;
> >  }
> > +
> > +#define i40e_aqc_opc_replace_cloud_filters 0x025F #define
> > +I40E_AQC_ADD_REM_CLOUD_CMD_BIG_BUFFER 1
> > +/**
> > + * i40e_aq_add_cloud_filters_big_buffer
> > + * @hw: pointer to the hardware structure
> > + * @seid: VSI seid to add cloud filters from
> > + * @filters: Buffer which contains the filters in big buffer to be
> > +added
> > + * @filter_count: number of filters contained in the buffer
> > + *
> > + * Set the cloud filters for a given VSI.  The contents of the
> > + * i40e_aqc_add_remove_cloud_filters_element_big_data are filled
> > + * in by the caller of the function.
> > + *
> > + **/
> > +enum i40e_status_code i40e_aq_add_cloud_filters_big_buffer(
> 
> There are already non big_buffer versions of these functions, like
> "i40e_aq_add_cloud_filters()" why big_data version required, what it does
> differently?

Parameters are different.
We add i40e_aq_add_cloud_filters_big_buffer to handle structure " i40e_aqc_add_remove_cloud_filters_element_data " which includes general_fields.

> 
> And is there a reason that these functions are not static? (For this patch they
> are not used at all and will cause build error, but my question is after they
> started to be used)

No.. same with the patch for Pipeline Personalization Profile, it's designed according to base code style.

> 
> <...>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 2/4] net/i40e: rework tunnel filter functions
  2017-03-08 15:50   ` Ferruh Yigit
@ 2017-03-09  6:00     ` Xing, Beilei
  0 siblings, 0 replies; 39+ messages in thread
From: Xing, Beilei @ 2017-03-09  6:00 UTC (permalink / raw)
  To: Yigit, Ferruh, Wu, Jingjing; +Cc: Zhang, Helin, dev



> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Wednesday, March 8, 2017 11:50 PM
> To: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 2/4] net/i40e: rework tunnel filter functions
> 
> On 3/3/2017 9:31 AM, Beilei Xing wrote:
> > Rework tunnel filter functions to align with the new command buffer
> > for add/remove cloud filter.
> 
> > This patch also changes tunnel filter function name to VXLAN filter
> > function, it will be easy to add other tunnel type parsing function.
> 
> Can you please do renaming in different patch in this patchset, that change
> should be trivial, but looking more confusing with other change.

Yes, will update in next version.

> 
> >
> > Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> <...>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/4] net/i40e: support tunnel filter to VF
  2017-03-08 15:50   ` Ferruh Yigit
@ 2017-03-09  6:08     ` Xing, Beilei
  2017-03-27 16:34       ` Ferruh Yigit
  0 siblings, 1 reply; 39+ messages in thread
From: Xing, Beilei @ 2017-03-09  6:08 UTC (permalink / raw)
  To: Yigit, Ferruh, Wu, Jingjing
  Cc: Zhang, Helin, dev, Iremonger, Bernard, Liu, Yong



> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Wednesday, March 8, 2017 11:50 PM
> To: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org; Iremonger,
> Bernard <bernard.iremonger@intel.com>; Liu, Yong <yong.liu@intel.com>
> Subject: Re: [dpdk-dev] [PATCH 3/4] net/i40e: support tunnel filter to VF
> 
> On 3/3/2017 9:31 AM, Beilei Xing wrote:
> > This patch is to support tunnel filter to VF.
> >
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > Signed-off-by: Yong Liu <yong.liu@intel.com>
> > Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> > ---
> 
> <...>
> 
> > +/**
> > + * Tunneling Packet filter configuration.
> > + */
> > +struct i40e_tunnel_filter_conf {
> 
> There is already "rte_eth_tunnel_filter_conf", why driver is creating its own
> version of structure instead of using / updating public one?

Marvin has an announcement for this change before, but it's rejected as consistent filter API is available. 
http://www.dpdk.org/dev/patchwork/patch/19772/

So we add this new feature in PMD:
+	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
+	uint16_t vf_id;         /**< VF id for tunnel filter insertion. */


> 
> > +	struct ether_addr outer_mac;    /**< Outer MAC address to match.
> */
> > +	struct ether_addr inner_mac;    /**< Inner MAC address to match. */
> > +	uint16_t inner_vlan;            /**< Inner VLAN to match. */
> > +	uint32_t outer_vlan;            /**< Outer VLAN to match */
> > +	enum rte_tunnel_iptype ip_type; /**< IP address type. */
> > +	/**
> > +	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
> > +	 * is set in filter_type, or inner destination IP address to match
> > +	 * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
> > +	 */
> > +	union {
> > +		uint32_t ipv4_addr;     /**< IPv4 address in big endian. */
> > +		uint32_t ipv6_addr[4];  /**< IPv6 address in big endian. */
> > +	} ip_addr;
> > +	/** Flags from ETH_TUNNEL_FILTER_XX - see above. */
> > +	uint16_t filter_type;
> > +	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
> > +	uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
> > +	uint16_t queue_id;      /**< Queue assigned to if match. */
> > +	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
> > +	uint16_t vf_id;         /**< VF id for tunnel filter insertion. */
> > +};
> > +
> 
> <...>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 4/4] net/i40e: refine consistent tunnel filter
  2017-03-08 15:50   ` Ferruh Yigit
@ 2017-03-09  6:11     ` Xing, Beilei
  0 siblings, 0 replies; 39+ messages in thread
From: Xing, Beilei @ 2017-03-09  6:11 UTC (permalink / raw)
  To: Yigit, Ferruh, Wu, Jingjing; +Cc: Zhang, Helin, dev



> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Wednesday, March 8, 2017 11:51 PM
> To: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 4/4] net/i40e: refine consistent tunnel filter
> 
> On 3/3/2017 9:31 AM, Beilei Xing wrote:
> > Add i40e_tunnel_type enumeration type to refine consistent tunnel
> > filter, it will be esay to add new tunnel type for
> 
> s/esay/easy
> 
> > i40e.
> >
> > Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> 
> <...>
> 
> >  /**
> > + * Tunnel type.
> > + */
> > +enum i40e_tunnel_type {
> > +	I40E_TUNNEL_TYPE_NONE = 0,
> > +	I40E_TUNNEL_TYPE_VXLAN,
> > +	I40E_TUNNEL_TYPE_GENEVE,
> > +	I40E_TUNNEL_TYPE_TEREDO,
> > +	I40E_TUNNEL_TYPE_NVGRE,
> > +	I40E_TUNNEL_TYPE_IP_IN_GRE,
> > +	I40E_L2_TUNNEL_TYPE_E_TAG,
> > +	I40E_TUNNEL_TYPE_MAX,
> > +};
> 
> Same question here, there is already "rte_eth_tunnel_type", why driver is
> duplicating the structure?
> 

Same with " struct i40e_tunnel_filter_conf ", to avoid ABI change, we create it in PMD to add new tunnel type easily, like MPLS.

> <...>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/4] net/i40e: support replace filter type
  2017-03-09  5:59     ` Xing, Beilei
@ 2017-03-09 10:01       ` Ferruh Yigit
  2017-03-09 10:43         ` Xing, Beilei
  0 siblings, 1 reply; 39+ messages in thread
From: Ferruh Yigit @ 2017-03-09 10:01 UTC (permalink / raw)
  To: Xing, Beilei, Wu, Jingjing
  Cc: Zhang, Helin, dev, Iremonger, Bernard, Stroe, Laura

On 3/9/2017 5:59 AM, Xing, Beilei wrote:
> 
> 
>> -----Original Message-----
>> From: Yigit, Ferruh
>> Sent: Wednesday, March 8, 2017 11:50 PM
>> To: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
>> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org; Iremonger,
>> Bernard <bernard.iremonger@intel.com>; Stroe, Laura
>> <laura.stroe@intel.com>
>> Subject: Re: [dpdk-dev] [PATCH 1/4] net/i40e: support replace filter type
>>
>> On 3/3/2017 9:31 AM, Beilei Xing wrote:
>>> Add new admin queue function and extended fields in DCR 288:
>>>  - Add admin queue function for Replace filter
>>>    command (Opcode: 0x025F)
>>>  - Add General fields for Add/Remove Cloud filters
>>>    command
>>>
>>> This patch will be removed to base driver in future.
>>>
>>> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
>>> Signed-off-by: Stroe Laura <laura.stroe@intel.com>
>>> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
>>> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
>>> ---
>>>  drivers/net/i40e/i40e_ethdev.h | 106 ++++++++++++++++++++++++++++
>>>  drivers/net/i40e/i40e_flow.c   | 152
>> +++++++++++++++++++++++++++++++++++++++++
>>>  2 files changed, 258 insertions(+)
>>>
>>> diff --git a/drivers/net/i40e/i40e_ethdev.h
>>> b/drivers/net/i40e/i40e_ethdev.h index f545850..3a49865 100644
>>> --- a/drivers/net/i40e/i40e_ethdev.h
>>> +++ b/drivers/net/i40e/i40e_ethdev.h
>>> @@ -729,6 +729,100 @@ struct i40e_valid_pattern {
>>>  	parse_filter_t parse_filter;
>>>  };
>>>
>>> +/* Support replace filter */
>>> +
>>> +/* i40e_aqc_add_remove_cloud_filters_element_big_data is used when
>>> + * I40E_AQC_ADD_REM_CLOUD_CMD_BIG_BUFFER flag is set. refer to
>>> + * DCR288
>>
>> Please do not refer to DCR, unless you can provide a public link for it.
> OK, got it.
> 
>>
>>> + */
>>> +struct i40e_aqc_add_remove_cloud_filters_element_big_data {
>>> +	struct i40e_aqc_add_remove_cloud_filters_element_data element;
>>
>> What is the difference between
>> "i40e_aqc_add_remove_cloud_filters_element_big_data" and
>> "i40e_aqc_add_remove_cloud_filters_element_data", why need big_data
>> one?
> 
> As ' Add/Remove Cloud filters -command buffer ' is changed in the DCR288, 'general fields' exists only when big_buffer is set.

What does it mean having "big_buffer" set? What changes functionally
being big_buffer set or not?

> But we don't want to change the  " i40e_aqc_add_remove_cloud_filters_element_data " as it will cause ABI/API change in kernel driver.
> 
<...>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/4] net/i40e: support replace filter type
  2017-03-09 10:01       ` Ferruh Yigit
@ 2017-03-09 10:43         ` Xing, Beilei
  0 siblings, 0 replies; 39+ messages in thread
From: Xing, Beilei @ 2017-03-09 10:43 UTC (permalink / raw)
  To: Yigit, Ferruh, Wu, Jingjing
  Cc: Zhang, Helin, dev, Iremonger, Bernard, Stroe, Laura



> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Thursday, March 9, 2017 6:02 PM
> To: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org; Iremonger,
> Bernard <bernard.iremonger@intel.com>; Stroe, Laura
> <laura.stroe@intel.com>
> Subject: Re: [dpdk-dev] [PATCH 1/4] net/i40e: support replace filter type
> 
> On 3/9/2017 5:59 AM, Xing, Beilei wrote:
> >
> >
> >> -----Original Message-----
> >> From: Yigit, Ferruh
> >> Sent: Wednesday, March 8, 2017 11:50 PM
> >> To: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing
> >> <jingjing.wu@intel.com>
> >> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org; Iremonger,
> >> Bernard <bernard.iremonger@intel.com>; Stroe, Laura
> >> <laura.stroe@intel.com>
> >> Subject: Re: [dpdk-dev] [PATCH 1/4] net/i40e: support replace filter
> >> type
> >>
> >> On 3/3/2017 9:31 AM, Beilei Xing wrote:
> >>> Add new admin queue function and extended fields in DCR 288:
> >>>  - Add admin queue function for Replace filter
> >>>    command (Opcode: 0x025F)
> >>>  - Add General fields for Add/Remove Cloud filters
> >>>    command
> >>>
> >>> This patch will be removed to base driver in future.
> >>>
> >>> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> >>> Signed-off-by: Stroe Laura <laura.stroe@intel.com>
> >>> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> >>> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> >>> ---
> >>>  drivers/net/i40e/i40e_ethdev.h | 106
> ++++++++++++++++++++++++++++
> >>>  drivers/net/i40e/i40e_flow.c   | 152
> >> +++++++++++++++++++++++++++++++++++++++++
> >>>  2 files changed, 258 insertions(+)
> >>>
> >>> diff --git a/drivers/net/i40e/i40e_ethdev.h
> >>> b/drivers/net/i40e/i40e_ethdev.h index f545850..3a49865 100644
> >>> --- a/drivers/net/i40e/i40e_ethdev.h
> >>> +++ b/drivers/net/i40e/i40e_ethdev.h
> >>> @@ -729,6 +729,100 @@ struct i40e_valid_pattern {
> >>>  	parse_filter_t parse_filter;
> >>>  };
> >>>
> >>> +/* Support replace filter */
> >>> +
> >>> +/* i40e_aqc_add_remove_cloud_filters_element_big_data is used
> when
> >>> + * I40E_AQC_ADD_REM_CLOUD_CMD_BIG_BUFFER flag is set. refer to
> >>> + * DCR288
> >>
> >> Please do not refer to DCR, unless you can provide a public link for it.
> > OK, got it.
> >
> >>
> >>> + */
> >>> +struct i40e_aqc_add_remove_cloud_filters_element_big_data {
> >>> +	struct i40e_aqc_add_remove_cloud_filters_element_data element;
> >>
> >> What is the difference between
> >> "i40e_aqc_add_remove_cloud_filters_element_big_data" and
> >> "i40e_aqc_add_remove_cloud_filters_element_data", why need
> big_data
> >> one?
> >
> > As ' Add/Remove Cloud filters -command buffer ' is changed in the DCR288,
> 'general fields' exists only when big_buffer is set.
> 
> What does it mean having "big_buffer" set? What changes functionally being
> big_buffer set or not?

According to DCR288, "Add/Remove Cloud Filter Command" should add 'Big Buffer' in byte20, but we can't change ' struct i40e_aqc_add_remove_cloud_filters ' in base code,
struct i40e_aqc_add_remove_cloud_filters {
        u8      num_filters;
        u8      reserved;
        __le16  seid;
#define I40E_AQC_ADD_CLOUD_CMD_SEID_NUM_SHIFT   0
#define I40E_AQC_ADD_CLOUD_CMD_SEID_NUM_MASK    (0x3FF << \
                                        I40E_AQC_ADD_CLOUD_CMD_SEID_NUM_SHIFT)
        u8      reserved2[4];
        __le32  addr_high;
        __le32  addr_low;
};

So we use reserverd[0] for 'Big Buffer' here, in the patch for ND, we changed above structure with following:

struct i40e_aqc_add_remove_cloud_filters {
        u8      num_filters;
        u8      reserved;
        __le16  seid;
#define I40E_AQC_ADD_CLOUD_CMD_SEID_NUM_SHIFT   0
#define I40E_AQC_ADD_CLOUD_CMD_SEID_NUM_MASK    (0x3FF << \
                                        I40E_AQC_ADD_CLOUD_CMD_SEID_NUM_SHIFT)
        u8      big_buffer;
        u8      reserved2[3];
        __le32  addr_high;
        __le32  addr_low;
};


> 
> > But we don't want to change the  "
> i40e_aqc_add_remove_cloud_filters_element_data " as it will cause ABI/API
> change in kernel driver.
> >
> <...>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v2 0/4] Rework tunnel filter functions
  2017-03-03  9:31 [PATCH 0/4] support replace filter function Beilei Xing
                   ` (4 preceding siblings ...)
  2017-03-08 15:50 ` [PATCH 0/4] support replace filter function Ferruh Yigit
@ 2017-03-23 10:46 ` Beilei Xing
  2017-03-23 10:46   ` [PATCH v2 1/4] net/i40e: rework " Beilei Xing
                     ` (4 more replies)
  5 siblings, 5 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-23 10:46 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, dev

1. Rework tunnel filter functions to align with the new
   added cloud filer command buffer structure.
2. Support tunnel filter to VF for consistent filter API.

v2 changes:
 Remove replace cloud filter function as it's in share code.

Beilei Xing (4):
  net/i40e: rework tunnel filter functions
  net/i40e: change tunnel filter function name
  net/i40e: support tunnel filter to VF
  net/i40e: refine consistent tunnel filter

 drivers/net/i40e/i40e_ethdev.c | 245 +++++++++++++++++++++++++++++++++++------
 drivers/net/i40e/i40e_ethdev.h |  47 ++++++++
 drivers/net/i40e/i40e_flow.c   | 142 +++++++++++++-----------
 3 files changed, 336 insertions(+), 98 deletions(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v2 1/4] net/i40e: rework tunnel filter functions
  2017-03-23 10:46 ` [PATCH v2 0/4] Rework tunnel filter functions Beilei Xing
@ 2017-03-23 10:46   ` Beilei Xing
  2017-03-27  9:47     ` Wu, Jingjing
  2017-03-23 10:46   ` [PATCH v2 2/4] net/i40e: change tunnel filter function name Beilei Xing
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 39+ messages in thread
From: Beilei Xing @ 2017-03-23 10:46 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, dev

Rework tunnel filter functions to align with the
new command buffer for add/remove cloud filter.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 100 +++++++++++++++++++++++++++--------------
 drivers/net/i40e/i40e_ethdev.h |   1 +
 drivers/net/i40e/i40e_flow.c   |  28 +++++++-----
 3 files changed, 86 insertions(+), 43 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 9c0441b..5e6cc59 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -410,7 +410,7 @@ static int i40e_sw_ethertype_filter_insert(struct i40e_pf *pf,
 				   struct i40e_ethertype_filter *filter);
 
 static int i40e_tunnel_filter_convert(
-	struct i40e_aqc_add_remove_cloud_filters_element_data *cld_filter,
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter,
 	struct i40e_tunnel_filter *tunnel_filter);
 static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,
 				struct i40e_tunnel_filter *tunnel_filter);
@@ -6717,24 +6717,27 @@ i40e_dev_get_filter_type(uint16_t filter_type, uint16_t *flag)
 
 /* Convert tunnel filter structure */
 static int
-i40e_tunnel_filter_convert(struct i40e_aqc_add_remove_cloud_filters_element_data
-			   *cld_filter,
-			   struct i40e_tunnel_filter *tunnel_filter)
+i40e_tunnel_filter_convert(
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter,
+	struct i40e_tunnel_filter *tunnel_filter)
 {
-	ether_addr_copy((struct ether_addr *)&cld_filter->outer_mac,
+	ether_addr_copy((struct ether_addr *)&cld_filter->element.outer_mac,
 			(struct ether_addr *)&tunnel_filter->input.outer_mac);
-	ether_addr_copy((struct ether_addr *)&cld_filter->inner_mac,
+	ether_addr_copy((struct ether_addr *)&cld_filter->element.inner_mac,
 			(struct ether_addr *)&tunnel_filter->input.inner_mac);
-	tunnel_filter->input.inner_vlan = cld_filter->inner_vlan;
-	if ((rte_le_to_cpu_16(cld_filter->flags) &
+	tunnel_filter->input.inner_vlan = cld_filter->element.inner_vlan;
+	if ((rte_le_to_cpu_16(cld_filter->element.flags) &
 	     I40E_AQC_ADD_CLOUD_FLAGS_IPV6) ==
 	    I40E_AQC_ADD_CLOUD_FLAGS_IPV6)
 		tunnel_filter->input.ip_type = I40E_TUNNEL_IPTYPE_IPV6;
 	else
 		tunnel_filter->input.ip_type = I40E_TUNNEL_IPTYPE_IPV4;
-	tunnel_filter->input.flags = cld_filter->flags;
-	tunnel_filter->input.tenant_id = cld_filter->tenant_id;
-	tunnel_filter->queue = cld_filter->queue_number;
+	tunnel_filter->input.flags = cld_filter->element.flags;
+	tunnel_filter->input.tenant_id = cld_filter->element.tenant_id;
+	tunnel_filter->queue = cld_filter->element.queue_number;
+	rte_memcpy(tunnel_filter->input.general_fields,
+		   cld_filter->general_fields,
+		   sizeof(cld_filter->general_fields));
 
 	return 0;
 }
@@ -6813,15 +6816,16 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	int val, ret = 0;
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_vsi *vsi = pf->main_vsi;
-	struct i40e_aqc_add_remove_cloud_filters_element_data  *cld_filter;
-	struct i40e_aqc_add_remove_cloud_filters_element_data  *pfilter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *pfilter;
 	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
 	struct i40e_tunnel_filter *tunnel, *node;
 	struct i40e_tunnel_filter check_filter; /* Check if filter exists */
+	bool big_buffer = 0;
 
 	cld_filter = rte_zmalloc("tunnel_filter",
-		sizeof(struct i40e_aqc_add_remove_cloud_filters_element_data),
-		0);
+			 sizeof(struct i40e_aqc_add_rm_cloud_filt_elem_ext),
+	0);
 
 	if (NULL == cld_filter) {
 		PMD_DRV_LOG(ERR, "Failed to alloc memory.");
@@ -6829,24 +6833,28 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	}
 	pfilter = cld_filter;
 
-	ether_addr_copy(&tunnel_filter->outer_mac, (struct ether_addr*)&pfilter->outer_mac);
-	ether_addr_copy(&tunnel_filter->inner_mac, (struct ether_addr*)&pfilter->inner_mac);
+	ether_addr_copy(&tunnel_filter->outer_mac,
+			(struct ether_addr *)&pfilter->element.outer_mac);
+	ether_addr_copy(&tunnel_filter->inner_mac,
+			(struct ether_addr *)&pfilter->element.inner_mac);
 
-	pfilter->inner_vlan = rte_cpu_to_le_16(tunnel_filter->inner_vlan);
+	pfilter->element.inner_vlan =
+		rte_cpu_to_le_16(tunnel_filter->inner_vlan);
 	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
 		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
 		ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
-		rte_memcpy(&pfilter->ipaddr.v4.data,
+		rte_memcpy(&pfilter->element.ipaddr.v4.data,
 				&rte_cpu_to_le_32(ipv4_addr),
-				sizeof(pfilter->ipaddr.v4.data));
+				sizeof(pfilter->element.ipaddr.v4.data));
 	} else {
 		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
 		for (i = 0; i < 4; i++) {
 			convert_ipv6[i] =
 			rte_cpu_to_le_32(rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv6_addr[i]));
 		}
-		rte_memcpy(&pfilter->ipaddr.v6.data, &convert_ipv6,
-				sizeof(pfilter->ipaddr.v6.data));
+		rte_memcpy(&pfilter->element.ipaddr.v6.data,
+			   &convert_ipv6,
+			   sizeof(pfilter->element.ipaddr.v6.data));
 	}
 
 	/* check tunneled type */
@@ -6868,17 +6876,18 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	}
 
 	val = i40e_dev_get_filter_type(tunnel_filter->filter_type,
-						&pfilter->flags);
+				       &pfilter->element.flags);
 	if (val < 0) {
 		rte_free(cld_filter);
 		return -EINVAL;
 	}
 
-	pfilter->flags |= rte_cpu_to_le_16(
+	pfilter->element.flags |= rte_cpu_to_le_16(
 		I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE |
 		ip_type | (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT));
-	pfilter->tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
-	pfilter->queue_number = rte_cpu_to_le_16(tunnel_filter->queue_id);
+	pfilter->element.tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
+	pfilter->element.queue_number =
+		rte_cpu_to_le_16(tunnel_filter->queue_id);
 
 	/* Check if there is the filter in SW list */
 	memset(&check_filter, 0, sizeof(check_filter));
@@ -6895,7 +6904,12 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	}
 
 	if (add) {
-		ret = i40e_aq_add_cloud_filters(hw, vsi->seid, cld_filter, 1);
+		if (big_buffer)
+			ret = i40e_aq_add_cloud_filters_big_buffer(hw,
+						   vsi->seid, cld_filter, 1);
+		else
+			ret = i40e_aq_add_cloud_filters(hw,
+					vsi->seid, &cld_filter->element, 1);
 		if (ret < 0) {
 			PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
 			return ret;
@@ -6904,8 +6918,12 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 		rte_memcpy(tunnel, &check_filter, sizeof(check_filter));
 		ret = i40e_sw_tunnel_filter_insert(pf, tunnel);
 	} else {
-		ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
-						   cld_filter, 1);
+		if (big_buffer)
+			ret = i40e_aq_remove_cloud_filters_big_buffer(
+				hw, vsi->seid, cld_filter, 1);
+		else
+			ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
+					   &cld_filter->element, 1);
 		if (ret < 0) {
 			PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter.");
 			return ret;
@@ -10289,13 +10307,29 @@ i40e_tunnel_filter_restore(struct i40e_pf *pf)
 	struct i40e_tunnel_filter_list
 		*tunnel_list = &pf->tunnel.tunnel_list;
 	struct i40e_tunnel_filter *f;
-	struct i40e_aqc_add_remove_cloud_filters_element_data cld_filter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext cld_filter;
+	bool big_buffer = 0;
 
 	TAILQ_FOREACH(f, tunnel_list, rules) {
 		memset(&cld_filter, 0, sizeof(cld_filter));
-		rte_memcpy(&cld_filter, &f->input, sizeof(f->input));
-		cld_filter.queue_number = f->queue;
-		i40e_aq_add_cloud_filters(hw, vsi->seid, &cld_filter, 1);
+		ether_addr_copy((struct ether_addr *)&f->input.outer_mac,
+			(struct ether_addr *)&cld_filter.element.outer_mac);
+		ether_addr_copy((struct ether_addr *)&f->input.inner_mac,
+			(struct ether_addr *)&cld_filter.element.inner_mac);
+		cld_filter.element.inner_vlan = f->input.inner_vlan;
+		cld_filter.element.flags = f->input.flags;
+		cld_filter.element.tenant_id = f->input.tenant_id;
+		cld_filter.element.queue_number = f->queue;
+		rte_memcpy(cld_filter.general_fields,
+			   f->input.general_fields,
+			   sizeof(f->input.general_fields));
+
+		if (big_buffer)
+			i40e_aq_add_cloud_filters_big_buffer(hw, vsi->seid,
+							     &cld_filter, 1);
+		else
+			i40e_aq_add_cloud_filters(hw, vsi->seid,
+						  &cld_filter.element, 1);
 	}
 }
 
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index f0be7a3..2ca0fe5 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -513,6 +513,7 @@ struct i40e_tunnel_filter_input {
 	enum i40e_tunnel_iptype ip_type;
 	uint16_t flags;          /* Filter type flag */
 	uint32_t tenant_id;      /* Tenant id to match */
+	uint16_t general_fields[32];  /* Big buffer */
 };
 
 struct i40e_tunnel_filter {
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index f163ce5..5513c3c 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -1725,23 +1725,31 @@ i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_vsi *vsi = pf->main_vsi;
-	struct i40e_aqc_add_remove_cloud_filters_element_data cld_filter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext cld_filter;
 	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
 	struct i40e_tunnel_filter *node;
+	bool big_buffer = 0;
 	int ret = 0;
 
 	memset(&cld_filter, 0, sizeof(cld_filter));
 	ether_addr_copy((struct ether_addr *)&filter->input.outer_mac,
-			(struct ether_addr *)&cld_filter.outer_mac);
+			(struct ether_addr *)&cld_filter.element.outer_mac);
 	ether_addr_copy((struct ether_addr *)&filter->input.inner_mac,
-			(struct ether_addr *)&cld_filter.inner_mac);
-	cld_filter.inner_vlan = filter->input.inner_vlan;
-	cld_filter.flags = filter->input.flags;
-	cld_filter.tenant_id = filter->input.tenant_id;
-	cld_filter.queue_number = filter->queue;
-
-	ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
-					   &cld_filter, 1);
+			(struct ether_addr *)&cld_filter.element.inner_mac);
+	cld_filter.element.inner_vlan = filter->input.inner_vlan;
+	cld_filter.element.flags = filter->input.flags;
+	cld_filter.element.tenant_id = filter->input.tenant_id;
+	cld_filter.element.queue_number = filter->queue;
+	rte_memcpy(cld_filter.general_fields,
+		   filter->input.general_fields,
+		   sizeof(cld_filter.general_fields));
+
+	if (big_buffer)
+		ret = i40e_aq_remove_cloud_filters_big_buffer(hw, vsi->seid,
+							      &cld_filter, 1);
+	else
+		ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
+						   &cld_filter.element, 1);
 	if (ret < 0)
 		return ret;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 2/4] net/i40e: change tunnel filter function name
  2017-03-23 10:46 ` [PATCH v2 0/4] Rework tunnel filter functions Beilei Xing
  2017-03-23 10:46   ` [PATCH v2 1/4] net/i40e: rework " Beilei Xing
@ 2017-03-23 10:46   ` Beilei Xing
  2017-03-23 10:46   ` [PATCH v2 3/4] net/i40e: support tunnel filter to VF Beilei Xing
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-23 10:46 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, dev

Change tunnel filter function name to VXLAN filter
function, prepare for other tunnel filter function.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_flow.c | 58 ++++++++++++++++----------------------------
 1 file changed, 21 insertions(+), 37 deletions(-)

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 5513c3c..412cd22 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -90,10 +90,6 @@ static int i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
 				       const struct rte_flow_action *actions,
 				       struct rte_flow_error *error,
 				       struct rte_eth_fdir_filter *filter);
-static int i40e_flow_parse_tunnel_pattern(__rte_unused struct rte_eth_dev *dev,
-				  const struct rte_flow_item *pattern,
-				  struct rte_flow_error *error,
-				  struct rte_eth_tunnel_filter_conf *filter);
 static int i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
 				 const struct rte_flow_action *actions,
 				 struct rte_flow_error *error,
@@ -112,12 +108,12 @@ static int i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 				       const struct rte_flow_action actions[],
 				       struct rte_flow_error *error,
 				       union i40e_filter_t *filter);
-static int i40e_flow_parse_tunnel_filter(struct rte_eth_dev *dev,
-					 const struct rte_flow_attr *attr,
-					 const struct rte_flow_item pattern[],
-					 const struct rte_flow_action actions[],
-					 struct rte_flow_error *error,
-					 union i40e_filter_t *filter);
+static int i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
+					const struct rte_flow_attr *attr,
+					const struct rte_flow_item pattern[],
+					const struct rte_flow_action actions[],
+					struct rte_flow_error *error,
+					union i40e_filter_t *filter);
 static int i40e_flow_destroy_ethertype_filter(struct i40e_pf *pf,
 				      struct i40e_ethertype_filter *filter);
 static int i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
@@ -302,11 +298,11 @@ static struct i40e_valid_pattern i40e_supported_patterns[] = {
 	{ pattern_fdir_ipv6_tcp_ext, i40e_flow_parse_fdir_filter },
 	{ pattern_fdir_ipv6_sctp, i40e_flow_parse_fdir_filter },
 	{ pattern_fdir_ipv6_sctp_ext, i40e_flow_parse_fdir_filter },
-	/* tunnel */
-	{ pattern_vxlan_1, i40e_flow_parse_tunnel_filter },
-	{ pattern_vxlan_2, i40e_flow_parse_tunnel_filter },
-	{ pattern_vxlan_3, i40e_flow_parse_tunnel_filter },
-	{ pattern_vxlan_4, i40e_flow_parse_tunnel_filter },
+	/* VXLAN */
+	{ pattern_vxlan_1, i40e_flow_parse_vxlan_filter },
+	{ pattern_vxlan_2, i40e_flow_parse_vxlan_filter },
+	{ pattern_vxlan_3, i40e_flow_parse_vxlan_filter },
+	{ pattern_vxlan_4, i40e_flow_parse_vxlan_filter },
 };
 
 #define NEXT_ITEM_OF_ACTION(act, actions, index)                        \
@@ -1205,7 +1201,8 @@ i40e_check_tenant_id_mask(const uint8_t *mask)
  *    filled with 0.
  */
 static int
-i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
+i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
+			      const struct rte_flow_item *pattern,
 			      struct rte_flow_error *error,
 			      struct rte_eth_tunnel_filter_conf *filter)
 {
@@ -1469,32 +1466,19 @@ i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
 }
 
 static int
-i40e_flow_parse_tunnel_pattern(__rte_unused struct rte_eth_dev *dev,
-			       const struct rte_flow_item *pattern,
-			       struct rte_flow_error *error,
-			       struct rte_eth_tunnel_filter_conf *filter)
-{
-	int ret;
-
-	ret = i40e_flow_parse_vxlan_pattern(pattern, error, filter);
-
-	return ret;
-}
-
-static int
-i40e_flow_parse_tunnel_filter(struct rte_eth_dev *dev,
-			      const struct rte_flow_attr *attr,
-			      const struct rte_flow_item pattern[],
-			      const struct rte_flow_action actions[],
-			      struct rte_flow_error *error,
-			      union i40e_filter_t *filter)
+i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
+			     const struct rte_flow_attr *attr,
+			     const struct rte_flow_item pattern[],
+			     const struct rte_flow_action actions[],
+			     struct rte_flow_error *error,
+			     union i40e_filter_t *filter)
 {
 	struct rte_eth_tunnel_filter_conf *tunnel_filter =
 		&filter->tunnel_filter;
 	int ret;
 
-	ret = i40e_flow_parse_tunnel_pattern(dev, pattern,
-					     error, tunnel_filter);
+	ret = i40e_flow_parse_vxlan_pattern(dev, pattern,
+					    error, tunnel_filter);
 	if (ret)
 		return ret;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 3/4] net/i40e: support tunnel filter to VF
  2017-03-23 10:46 ` [PATCH v2 0/4] Rework tunnel filter functions Beilei Xing
  2017-03-23 10:46   ` [PATCH v2 1/4] net/i40e: rework " Beilei Xing
  2017-03-23 10:46   ` [PATCH v2 2/4] net/i40e: change tunnel filter function name Beilei Xing
@ 2017-03-23 10:46   ` Beilei Xing
  2017-03-27  9:54     ` Wu, Jingjing
  2017-03-23 10:46   ` [PATCH v2 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
  2017-03-28  3:23   ` [PATCH v3 0/4] Rework tunnel filter functions Beilei Xing
  4 siblings, 1 reply; 39+ messages in thread
From: Beilei Xing @ 2017-03-23 10:46 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, dev

Previously, only tunnel filter to PF is supported.
This patch adds i40e_dev_consistent_tunnel_filter_set
function for consistent filter API to support tunnel
filter to VF.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 145 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.h |  32 +++++++++
 drivers/net/i40e/i40e_flow.c   |  50 +++++++++-----
 3 files changed, 212 insertions(+), 15 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 5e6cc59..2b3d41b 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -6935,6 +6935,151 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	return ret;
 }
 
+int
+i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
+		      struct i40e_tunnel_filter_conf *tunnel_filter,
+		      uint8_t add)
+{
+	uint16_t ip_type;
+	uint32_t ipv4_addr;
+	uint8_t i, tun_type = 0;
+	/* internal variable to convert ipv6 byte order */
+	uint32_t convert_ipv6[4];
+	int val, ret = 0;
+	struct i40e_pf_vf *vf = NULL;
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	struct i40e_vsi *vsi;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *pfilter;
+	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
+	struct i40e_tunnel_filter *tunnel, *node;
+	struct i40e_tunnel_filter check_filter; /* Check if filter exists */
+	bool big_buffer = 0;
+
+	cld_filter = rte_zmalloc("tunnel_filter",
+			 sizeof(struct i40e_aqc_add_rm_cloud_filt_elem_ext),
+			 0);
+
+	if (cld_filter == NULL) {
+		PMD_DRV_LOG(ERR, "Failed to alloc memory.");
+		return -EINVAL;
+	}
+	pfilter = cld_filter;
+
+	ether_addr_copy(&tunnel_filter->outer_mac,
+			(struct ether_addr *)&pfilter->element.outer_mac);
+	ether_addr_copy(&tunnel_filter->inner_mac,
+			(struct ether_addr *)&pfilter->element.inner_mac);
+
+	pfilter->element.inner_vlan =
+		rte_cpu_to_le_16(tunnel_filter->inner_vlan);
+	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
+		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
+		ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
+		rte_memcpy(&pfilter->element.ipaddr.v4.data,
+				&rte_cpu_to_le_32(ipv4_addr),
+				sizeof(pfilter->element.ipaddr.v4.data));
+	} else {
+		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
+		for (i = 0; i < 4; i++) {
+			convert_ipv6[i] =
+			rte_cpu_to_le_32(rte_be_to_cpu_32(
+					 tunnel_filter->ip_addr.ipv6_addr[i]));
+		}
+		rte_memcpy(&pfilter->element.ipaddr.v6.data,
+			   &convert_ipv6,
+			   sizeof(pfilter->element.ipaddr.v6.data));
+	}
+
+	/* check tunneled type */
+	switch (tunnel_filter->tunnel_type) {
+	case RTE_TUNNEL_TYPE_VXLAN:
+		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN;
+		break;
+	case RTE_TUNNEL_TYPE_NVGRE:
+		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_NVGRE_OMAC;
+		break;
+	case RTE_TUNNEL_TYPE_IP_IN_GRE:
+		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_IP;
+		break;
+	default:
+		/* Other tunnel types is not supported. */
+		PMD_DRV_LOG(ERR, "tunnel type is not supported.");
+		rte_free(cld_filter);
+		return -EINVAL;
+	}
+
+	val = i40e_dev_get_filter_type(tunnel_filter->filter_type,
+				       &pfilter->element.flags);
+	if (val < 0) {
+		rte_free(cld_filter);
+		return -EINVAL;
+	}
+
+	pfilter->element.flags |= rte_cpu_to_le_16(
+		I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE |
+		ip_type | (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT));
+	pfilter->element.tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
+	pfilter->element.queue_number =
+		rte_cpu_to_le_16(tunnel_filter->queue_id);
+
+	if (!tunnel_filter->is_to_vf)
+		vsi = pf->main_vsi;
+	else {
+		if (tunnel_filter->vf_id >= pf->vf_num) {
+			PMD_DRV_LOG(ERR, "Invalid argument.");
+			return -EINVAL;
+		}
+		vf = &pf->vfs[tunnel_filter->vf_id];
+		vsi = vf->vsi;
+	}
+
+	/* Check if there is the filter in SW list */
+	memset(&check_filter, 0, sizeof(check_filter));
+	i40e_tunnel_filter_convert(cld_filter, &check_filter);
+	node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &check_filter.input);
+	if (add && node) {
+		PMD_DRV_LOG(ERR, "Conflict with existing tunnel rules!");
+		return -EINVAL;
+	}
+
+	if (!add && !node) {
+		PMD_DRV_LOG(ERR, "There's no corresponding tunnel filter!");
+		return -EINVAL;
+	}
+
+	if (add) {
+		if (big_buffer)
+			ret = i40e_aq_add_cloud_filters_big_buffer(hw,
+						   vsi->seid, cld_filter, 1);
+		else
+			ret = i40e_aq_add_cloud_filters(hw,
+					vsi->seid, &cld_filter->element, 1);
+		if (ret < 0) {
+			PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
+			return ret;
+		}
+		tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0);
+		rte_memcpy(tunnel, &check_filter, sizeof(check_filter));
+		ret = i40e_sw_tunnel_filter_insert(pf, tunnel);
+	} else {
+		if (big_buffer)
+			ret = i40e_aq_remove_cloud_filters_big_buffer(
+				hw, vsi->seid, cld_filter, 1);
+		else
+			ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
+					   &cld_filter->element, 1);
+		if (ret < 0) {
+			PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter.");
+			return ret;
+		}
+		ret = i40e_sw_tunnel_filter_del(pf, &node->input);
+	}
+
+	rte_free(cld_filter);
+	return ret;
+}
+
 static int
 i40e_get_vxlan_port_idx(struct i40e_pf *pf, uint16_t port)
 {
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 2ca0fe5..d976f7a 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -514,6 +514,7 @@ struct i40e_tunnel_filter_input {
 	uint16_t flags;          /* Filter type flag */
 	uint32_t tenant_id;      /* Tenant id to match */
 	uint16_t general_fields[32];  /* Big buffer */
+	uint16_t vf_id;         /* VF id for tunnel filtering. */
 };
 
 struct i40e_tunnel_filter {
@@ -530,6 +531,33 @@ struct i40e_tunnel_rule {
 	struct rte_hash *hash_table;
 };
 
+/**
+ * Tunneling Packet filter configuration.
+ */
+struct i40e_tunnel_filter_conf {
+	struct ether_addr outer_mac;    /**< Outer MAC address to match. */
+	struct ether_addr inner_mac;    /**< Inner MAC address to match. */
+	uint16_t inner_vlan;            /**< Inner VLAN to match. */
+	uint32_t outer_vlan;            /**< Outer VLAN to match */
+	enum rte_tunnel_iptype ip_type; /**< IP address type. */
+	/**
+	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
+	 * is set in filter_type, or inner destination IP address to match
+	 * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
+	 */
+	union {
+		uint32_t ipv4_addr;     /**< IPv4 address in big endian. */
+		uint32_t ipv6_addr[4];  /**< IPv6 address in big endian. */
+	} ip_addr;
+	/** Flags from ETH_TUNNEL_FILTER_XX - see above. */
+	uint16_t filter_type;
+	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+	uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
+	uint16_t queue_id;      /**< Queue assigned to if match. */
+	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
+	uint16_t vf_id;         /**< VF id for tunnel filter insertion. */
+};
+
 #define I40E_MIRROR_MAX_ENTRIES_PER_RULE   64
 #define I40E_MAX_MIRROR_RULES           64
 /*
@@ -718,6 +746,7 @@ union i40e_filter_t {
 	struct rte_eth_ethertype_filter ethertype_filter;
 	struct rte_eth_fdir_filter fdir_filter;
 	struct rte_eth_tunnel_filter_conf tunnel_filter;
+	struct i40e_tunnel_filter_conf consistent_tunnel_filter;
 };
 
 typedef int (*parse_filter_t)(struct rte_eth_dev *dev,
@@ -811,6 +840,9 @@ int i40e_add_del_fdir_filter(struct rte_eth_dev *dev,
 int i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 			       struct rte_eth_tunnel_filter_conf *tunnel_filter,
 			       uint8_t add);
+int i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
+				  struct i40e_tunnel_filter_conf *tunnel_filter,
+				  uint8_t add);
 int i40e_fdir_flush(struct rte_eth_dev *dev);
 
 #define I40E_DEV_TO_PCI(eth_dev) \
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 412cd22..449299a 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -93,7 +93,7 @@ static int i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
 static int i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
 				 const struct rte_flow_action *actions,
 				 struct rte_flow_error *error,
-				 struct rte_eth_tunnel_filter_conf *filter);
+				 struct i40e_tunnel_filter_conf *filter);
 static int i40e_flow_parse_attr(const struct rte_flow_attr *attr,
 				struct rte_flow_error *error);
 static int i40e_flow_parse_ethertype_filter(struct rte_eth_dev *dev,
@@ -1127,34 +1127,54 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 }
 
 /* Parse to get the action info of a tunnle filter
- * Tunnel action only supports QUEUE.
+ * Tunnel action only supports PF, VF and QUEUE.
  */
 static int
 i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
 			      const struct rte_flow_action *actions,
 			      struct rte_flow_error *error,
-			      struct rte_eth_tunnel_filter_conf *filter)
+			      struct i40e_tunnel_filter_conf *filter)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	const struct rte_flow_action *act;
 	const struct rte_flow_action_queue *act_q;
+	const struct rte_flow_action_vf *act_vf;
 	uint32_t index = 0;
 
-	/* Check if the first non-void action is QUEUE. */
+	/* Check if the first non-void action is PF or VF. */
 	NEXT_ITEM_OF_ACTION(act, actions, index);
-	if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE) {
+	if (act->type != RTE_FLOW_ACTION_TYPE_PF &&
+	    act->type != RTE_FLOW_ACTION_TYPE_VF) {
 		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
 				   act, "Not supported action.");
 		return -rte_errno;
 	}
 
-	act_q = (const struct rte_flow_action_queue *)act->conf;
-	filter->queue_id = act_q->index;
-	if (filter->queue_id >= pf->dev_data->nb_rx_queues) {
-		rte_flow_error_set(error, EINVAL,
+	if (act->type == RTE_FLOW_ACTION_TYPE_VF) {
+		act_vf = (const struct rte_flow_action_vf *)act->conf;
+		filter->vf_id = act_vf->id;
+		filter->is_to_vf = 1;
+		if (filter->vf_id >= pf->vf_num) {
+			rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_ACTION,
+				   act, "Invalid VF ID for tunnel filter");
+			return -rte_errno;
+		}
+	}
+
+	/* Check if the next non-void item is QUEUE */
+	index++;
+	NEXT_ITEM_OF_ACTION(act, actions, index);
+	if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
+		act_q = (const struct rte_flow_action_queue *)act->conf;
+		filter->queue_id = act_q->index;
+		if (!filter->is_to_vf)
+			if (filter->queue_id >= pf->dev_data->nb_rx_queues) {
+				rte_flow_error_set(error, EINVAL,
 				   RTE_FLOW_ERROR_TYPE_ACTION,
 				   act, "Invalid queue ID for tunnel filter");
-		return -rte_errno;
+				return -rte_errno;
+			}
 	}
 
 	/* Check if the next non-void item is END */
@@ -1204,7 +1224,7 @@ static int
 i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			      const struct rte_flow_item *pattern,
 			      struct rte_flow_error *error,
-			      struct rte_eth_tunnel_filter_conf *filter)
+			      struct i40e_tunnel_filter_conf *filter)
 {
 	const struct rte_flow_item *item = pattern;
 	const struct rte_flow_item_eth *eth_spec;
@@ -1473,8 +1493,8 @@ i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
 			     struct rte_flow_error *error,
 			     union i40e_filter_t *filter)
 {
-	struct rte_eth_tunnel_filter_conf *tunnel_filter =
-		&filter->tunnel_filter;
+	struct i40e_tunnel_filter_conf *tunnel_filter =
+		&filter->consistent_tunnel_filter;
 	int ret;
 
 	ret = i40e_flow_parse_vxlan_pattern(dev, pattern,
@@ -1605,8 +1625,8 @@ i40e_flow_create(struct rte_eth_dev *dev,
 					i40e_fdir_filter_list);
 		break;
 	case RTE_ETH_FILTER_TUNNEL:
-		ret = i40e_dev_tunnel_filter_set(pf,
-					 &cons_filter.tunnel_filter, 1);
+		ret = i40e_dev_consistent_tunnel_filter_set(pf,
+			    &cons_filter.consistent_tunnel_filter, 1);
 		if (ret)
 			goto free_flow;
 		flow->rule = TAILQ_LAST(&pf->tunnel.tunnel_list,
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v2 4/4] net/i40e: refine consistent tunnel filter
  2017-03-23 10:46 ` [PATCH v2 0/4] Rework tunnel filter functions Beilei Xing
                     ` (2 preceding siblings ...)
  2017-03-23 10:46   ` [PATCH v2 3/4] net/i40e: support tunnel filter to VF Beilei Xing
@ 2017-03-23 10:46   ` Beilei Xing
  2017-03-28  3:23   ` [PATCH v3 0/4] Rework tunnel filter functions Beilei Xing
  4 siblings, 0 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-23 10:46 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, dev

Add i40e_tunnel_type enumeration type to refine consistent
tunnel filter, it will be esay to add new tunnel type for
i40e.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c |  8 ++++----
 drivers/net/i40e/i40e_ethdev.h | 18 ++++++++++++++++--
 drivers/net/i40e/i40e_flow.c   |  6 +++---
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2b3d41b..506b957 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -6973,7 +6973,7 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
 
 	pfilter->element.inner_vlan =
 		rte_cpu_to_le_16(tunnel_filter->inner_vlan);
-	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
+	if (tunnel_filter->ip_type == I40E_TUNNEL_IPTYPE_IPV4) {
 		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
 		ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
 		rte_memcpy(&pfilter->element.ipaddr.v4.data,
@@ -6993,13 +6993,13 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
 
 	/* check tunneled type */
 	switch (tunnel_filter->tunnel_type) {
-	case RTE_TUNNEL_TYPE_VXLAN:
+	case I40E_TUNNEL_TYPE_VXLAN:
 		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN;
 		break;
-	case RTE_TUNNEL_TYPE_NVGRE:
+	case I40E_TUNNEL_TYPE_NVGRE:
 		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_NVGRE_OMAC;
 		break;
-	case RTE_TUNNEL_TYPE_IP_IN_GRE:
+	case I40E_TUNNEL_TYPE_IP_IN_GRE:
 		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_IP;
 		break;
 	default:
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index d976f7a..7d86ca2 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -532,6 +532,20 @@ struct i40e_tunnel_rule {
 };
 
 /**
+ * Tunnel type.
+ */
+enum i40e_tunnel_type {
+	I40E_TUNNEL_TYPE_NONE = 0,
+	I40E_TUNNEL_TYPE_VXLAN,
+	I40E_TUNNEL_TYPE_GENEVE,
+	I40E_TUNNEL_TYPE_TEREDO,
+	I40E_TUNNEL_TYPE_NVGRE,
+	I40E_TUNNEL_TYPE_IP_IN_GRE,
+	I40E_L2_TUNNEL_TYPE_E_TAG,
+	I40E_TUNNEL_TYPE_MAX,
+};
+
+/**
  * Tunneling Packet filter configuration.
  */
 struct i40e_tunnel_filter_conf {
@@ -539,7 +553,7 @@ struct i40e_tunnel_filter_conf {
 	struct ether_addr inner_mac;    /**< Inner MAC address to match. */
 	uint16_t inner_vlan;            /**< Inner VLAN to match. */
 	uint32_t outer_vlan;            /**< Outer VLAN to match */
-	enum rte_tunnel_iptype ip_type; /**< IP address type. */
+	enum i40e_tunnel_iptype ip_type; /**< IP address type. */
 	/**
 	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
 	 * is set in filter_type, or inner destination IP address to match
@@ -551,7 +565,7 @@ struct i40e_tunnel_filter_conf {
 	} ip_addr;
 	/** Flags from ETH_TUNNEL_FILTER_XX - see above. */
 	uint16_t filter_type;
-	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+	enum i40e_tunnel_type tunnel_type; /**< Tunnel Type. */
 	uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
 	uint16_t queue_id;      /**< Queue assigned to if match. */
 	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 449299a..ffc14a9 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -1324,7 +1324,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			}
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
-			filter->ip_type = RTE_TUNNEL_IPTYPE_IPV4;
+			filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
 			/* IPv4 is used to describe protocol,
 			 * spec and mask should be NULL.
 			 */
@@ -1337,7 +1337,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			}
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
-			filter->ip_type = RTE_TUNNEL_IPTYPE_IPV6;
+			filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
 			/* IPv6 is used to describe protocol,
 			 * spec and mask should be NULL.
 			 */
@@ -1480,7 +1480,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 		return -rte_errno;
 	}
 
-	filter->tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
+	filter->tunnel_type = I40E_TUNNEL_TYPE_VXLAN;
 
 	return 0;
 }
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 1/4] net/i40e: rework tunnel filter functions
  2017-03-23 10:46   ` [PATCH v2 1/4] net/i40e: rework " Beilei Xing
@ 2017-03-27  9:47     ` Wu, Jingjing
  2017-03-27 10:33       ` Xing, Beilei
  0 siblings, 1 reply; 39+ messages in thread
From: Wu, Jingjing @ 2017-03-27  9:47 UTC (permalink / raw)
  To: Xing, Beilei; +Cc: Zhang, Helin, dev, Iremonger, Bernard



> -----Original Message-----
> From: Xing, Beilei
> Sent: Thursday, March 23, 2017 6:46 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org
> Subject: [PATCH v2 1/4] net/i40e: rework tunnel filter functions
> 
> Rework tunnel filter functions to align with the new command buffer for
> add/remove cloud filter.
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev.c | 100 +++++++++++++++++++++++++++----------
> ----
>  drivers/net/i40e/i40e_ethdev.h |   1 +
>  drivers/net/i40e/i40e_flow.c   |  28 +++++++-----
>  3 files changed, 86 insertions(+), 43 deletions(-)
> 


> @@ -10289,13 +10307,29 @@ i40e_tunnel_filter_restore(struct i40e_pf *pf)
>  	struct i40e_tunnel_filter_list
>  		*tunnel_list = &pf->tunnel.tunnel_list;
>  	struct i40e_tunnel_filter *f;
> -	struct i40e_aqc_add_remove_cloud_filters_element_data cld_filter;
> +	struct i40e_aqc_add_rm_cloud_filt_elem_ext cld_filter;
> +	bool big_buffer = 0;
> 
>  	TAILQ_FOREACH(f, tunnel_list, rules) {
>  		memset(&cld_filter, 0, sizeof(cld_filter));
> -		rte_memcpy(&cld_filter, &f->input, sizeof(f->input));
> -		cld_filter.queue_number = f->queue;
> -		i40e_aq_add_cloud_filters(hw, vsi->seid, &cld_filter, 1);
> +		ether_addr_copy((struct ether_addr *)&f->input.outer_mac,
> +			(struct ether_addr *)&cld_filter.element.outer_mac);
> +		ether_addr_copy((struct ether_addr *)&f->input.inner_mac,
> +			(struct ether_addr *)&cld_filter.element.inner_mac);
> +		cld_filter.element.inner_vlan = f->input.inner_vlan;
> +		cld_filter.element.flags = f->input.flags;
> +		cld_filter.element.tenant_id = f->input.tenant_id;
> +		cld_filter.element.queue_number = f->queue;
> +		rte_memcpy(cld_filter.general_fields,
> +			   f->input.general_fields,
> +			   sizeof(f->input.general_fields));
> +
> +		if (big_buffer)
> +			i40e_aq_add_cloud_filters_big_buffer(hw, vsi->seid,
> +							     &cld_filter, 1);
> +		else
> +			i40e_aq_add_cloud_filters(hw, vsi->seid,
> +						  &cld_filter.element, 1);
>  	}

Big_buffer is always 0, why we need to check it?

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 3/4] net/i40e: support tunnel filter to VF
  2017-03-23 10:46   ` [PATCH v2 3/4] net/i40e: support tunnel filter to VF Beilei Xing
@ 2017-03-27  9:54     ` Wu, Jingjing
  2017-03-27 10:37       ` Xing, Beilei
  0 siblings, 1 reply; 39+ messages in thread
From: Wu, Jingjing @ 2017-03-27  9:54 UTC (permalink / raw)
  To: Xing, Beilei; +Cc: Zhang, Helin, dev



> -----Original Message-----
> From: Xing, Beilei
> Sent: Thursday, March 23, 2017 6:46 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org
> Subject: [PATCH v2 3/4] net/i40e: support tunnel filter to VF
> 
> Previously, only tunnel filter to PF is supported.
> This patch adds i40e_dev_consistent_tunnel_filter_set
> function for consistent filter API to support tunnel filter to VF.
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev.c | 145
> +++++++++++++++++++++++++++++++++++++++++
>  drivers/net/i40e/i40e_ethdev.h |  32 +++++++++
>  drivers/net/i40e/i40e_flow.c   |  50 +++++++++-----
>  3 files changed, 212 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 5e6cc59..2b3d41b 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -6935,6 +6935,151 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
>  	return ret;
>  }
> 
> +int
> +i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
> +		      struct i40e_tunnel_filter_conf *tunnel_filter,
> +		      uint8_t add)
> +{
> +	uint16_t ip_type;
> +	uint32_t ipv4_addr;
> +	uint8_t i, tun_type = 0;
> +	/* internal variable to convert ipv6 byte order */
> +	uint32_t convert_ipv6[4];
> +	int val, ret = 0;
> +	struct i40e_pf_vf *vf = NULL;
> +	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
> +	struct i40e_vsi *vsi;
> +	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter;
> +	struct i40e_aqc_add_rm_cloud_filt_elem_ext *pfilter;
> +	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
> +	struct i40e_tunnel_filter *tunnel, *node;
> +	struct i40e_tunnel_filter check_filter; /* Check if filter exists */
> +	bool big_buffer = 0;
> +
> +	cld_filter = rte_zmalloc("tunnel_filter",
> +			 sizeof(struct i40e_aqc_add_rm_cloud_filt_elem_ext),
> +			 0);
> +
> +	if (cld_filter == NULL) {
> +		PMD_DRV_LOG(ERR, "Failed to alloc memory.");
> +		return -EINVAL;
-EINVAL? I think -ENOMEM is better.


> +	if (add) {
> +		if (big_buffer)
> +			ret = i40e_aq_add_cloud_filters_big_buffer(hw,
> +						   vsi->seid, cld_filter, 1);
> +		else
> +			ret = i40e_aq_add_cloud_filters(hw,
> +					vsi->seid, &cld_filter->element, 1);
> +		if (ret < 0) {
> +			PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
> +			return ret;
Ret is type of "enum i40e_status_code". It will not be consistent.


> +
>  #define I40E_MIRROR_MAX_ENTRIES_PER_RULE   64
>  #define I40E_MAX_MIRROR_RULES           64
>  /*
> @@ -718,6 +746,7 @@ union i40e_filter_t {
>  	struct rte_eth_ethertype_filter ethertype_filter;
>  	struct rte_eth_fdir_filter fdir_filter;
>  	struct rte_eth_tunnel_filter_conf tunnel_filter;
> +	struct i40e_tunnel_filter_conf consistent_tunnel_filter;
>  };
> 
I like to use driver specified structures instead of the old rte_eth_XX.
Glad to see this change, it will be better to change other structs. :)

Acked-by Jingjing Wu <jingjing.wu@intel.com>

Thanks
Jingjing

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 1/4] net/i40e: rework tunnel filter functions
  2017-03-27  9:47     ` Wu, Jingjing
@ 2017-03-27 10:33       ` Xing, Beilei
  0 siblings, 0 replies; 39+ messages in thread
From: Xing, Beilei @ 2017-03-27 10:33 UTC (permalink / raw)
  To: Wu, Jingjing; +Cc: Zhang, Helin, dev, Iremonger, Bernard



> -----Original Message-----
> From: Wu, Jingjing
> Sent: Monday, March 27, 2017 5:47 PM
> To: Xing, Beilei <beilei.xing@intel.com>
> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org; Iremonger,
> Bernard <bernard.iremonger@intel.com>
> Subject: RE: [PATCH v2 1/4] net/i40e: rework tunnel filter functions
> 
> 
> 
> > -----Original Message-----
> > From: Xing, Beilei
> > Sent: Thursday, March 23, 2017 6:46 PM
> > To: Wu, Jingjing <jingjing.wu@intel.com>
> > Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org
> > Subject: [PATCH v2 1/4] net/i40e: rework tunnel filter functions
> >
> > Rework tunnel filter functions to align with the new command buffer
> > for add/remove cloud filter.
> >
> > Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> > ---
> >  drivers/net/i40e/i40e_ethdev.c | 100
> > +++++++++++++++++++++++++++----------
> > ----
> >  drivers/net/i40e/i40e_ethdev.h |   1 +
> >  drivers/net/i40e/i40e_flow.c   |  28 +++++++-----
> >  3 files changed, 86 insertions(+), 43 deletions(-)
> >
> 
> 
> > @@ -10289,13 +10307,29 @@ i40e_tunnel_filter_restore(struct i40e_pf *pf)
> >  	struct i40e_tunnel_filter_list
> >  		*tunnel_list = &pf->tunnel.tunnel_list;
> >  	struct i40e_tunnel_filter *f;
> > -	struct i40e_aqc_add_remove_cloud_filters_element_data cld_filter;
> > +	struct i40e_aqc_add_rm_cloud_filt_elem_ext cld_filter;
> > +	bool big_buffer = 0;
> >
> >  	TAILQ_FOREACH(f, tunnel_list, rules) {
> >  		memset(&cld_filter, 0, sizeof(cld_filter));
> > -		rte_memcpy(&cld_filter, &f->input, sizeof(f->input));
> > -		cld_filter.queue_number = f->queue;
> > -		i40e_aq_add_cloud_filters(hw, vsi->seid, &cld_filter, 1);
> > +		ether_addr_copy((struct ether_addr *)&f->input.outer_mac,
> > +			(struct ether_addr *)&cld_filter.element.outer_mac);
> > +		ether_addr_copy((struct ether_addr *)&f->input.inner_mac,
> > +			(struct ether_addr *)&cld_filter.element.inner_mac);
> > +		cld_filter.element.inner_vlan = f->input.inner_vlan;
> > +		cld_filter.element.flags = f->input.flags;
> > +		cld_filter.element.tenant_id = f->input.tenant_id;
> > +		cld_filter.element.queue_number = f->queue;
> > +		rte_memcpy(cld_filter.general_fields,
> > +			   f->input.general_fields,
> > +			   sizeof(f->input.general_fields));
> > +
> > +		if (big_buffer)
> > +			i40e_aq_add_cloud_filters_big_buffer(hw, vsi->seid,
> > +							     &cld_filter, 1);
> > +		else
> > +			i40e_aq_add_cloud_filters(hw, vsi->seid,
> > +						  &cld_filter.element, 1);
> >  	}
> 
> Big_buffer is always 0, why we need to check it?

Big_buffer will be 1 if the filter_type is MPLSoGRE/MPLSoUDP. But MPLS enabling in the next patchset. Will update in next version.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 3/4] net/i40e: support tunnel filter to VF
  2017-03-27  9:54     ` Wu, Jingjing
@ 2017-03-27 10:37       ` Xing, Beilei
  0 siblings, 0 replies; 39+ messages in thread
From: Xing, Beilei @ 2017-03-27 10:37 UTC (permalink / raw)
  To: Wu, Jingjing; +Cc: Zhang, Helin, dev



> -----Original Message-----
> From: Wu, Jingjing
> Sent: Monday, March 27, 2017 5:55 PM
> To: Xing, Beilei <beilei.xing@intel.com>
> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org
> Subject: RE: [PATCH v2 3/4] net/i40e: support tunnel filter to VF
> 
> 
> 
> > -----Original Message-----
> > From: Xing, Beilei
> > Sent: Thursday, March 23, 2017 6:46 PM
> > To: Wu, Jingjing <jingjing.wu@intel.com>
> > Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org
> > Subject: [PATCH v2 3/4] net/i40e: support tunnel filter to VF
> >
> > Previously, only tunnel filter to PF is supported.
> > This patch adds i40e_dev_consistent_tunnel_filter_set
> > function for consistent filter API to support tunnel filter to VF.
> >
> > Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> > ---
> >  drivers/net/i40e/i40e_ethdev.c | 145
> > +++++++++++++++++++++++++++++++++++++++++
> >  drivers/net/i40e/i40e_ethdev.h |  32 +++++++++
> >  drivers/net/i40e/i40e_flow.c   |  50 +++++++++-----
> >  3 files changed, 212 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev.c
> > b/drivers/net/i40e/i40e_ethdev.c index 5e6cc59..2b3d41b 100644
> > --- a/drivers/net/i40e/i40e_ethdev.c
> > +++ b/drivers/net/i40e/i40e_ethdev.c
> > @@ -6935,6 +6935,151 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
> >  	return ret;
> >  }
> >
> > +int
> > +i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
> > +		      struct i40e_tunnel_filter_conf *tunnel_filter,
> > +		      uint8_t add)
> > +{
> > +	uint16_t ip_type;
> > +	uint32_t ipv4_addr;
> > +	uint8_t i, tun_type = 0;
> > +	/* internal variable to convert ipv6 byte order */
> > +	uint32_t convert_ipv6[4];
> > +	int val, ret = 0;
> > +	struct i40e_pf_vf *vf = NULL;
> > +	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
> > +	struct i40e_vsi *vsi;
> > +	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter;
> > +	struct i40e_aqc_add_rm_cloud_filt_elem_ext *pfilter;
> > +	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
> > +	struct i40e_tunnel_filter *tunnel, *node;
> > +	struct i40e_tunnel_filter check_filter; /* Check if filter exists */
> > +	bool big_buffer = 0;
> > +
> > +	cld_filter = rte_zmalloc("tunnel_filter",
> > +			 sizeof(struct
> i40e_aqc_add_rm_cloud_filt_elem_ext),
> > +			 0);
> > +
> > +	if (cld_filter == NULL) {
> > +		PMD_DRV_LOG(ERR, "Failed to alloc memory.");
> > +		return -EINVAL;
> -EINVAL? I think -ENOMEM is better.
Agree.

> 
> 
> > +	if (add) {
> > +		if (big_buffer)
> > +			ret = i40e_aq_add_cloud_filters_big_buffer(hw,
> > +						   vsi->seid, cld_filter, 1);
> > +		else
> > +			ret = i40e_aq_add_cloud_filters(hw,
> > +					vsi->seid, &cld_filter->element, 1);
> > +		if (ret < 0) {
> > +			PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
> > +			return ret;
> Ret is type of "enum i40e_status_code". It will not be consistent.
> 
> 
> > +
> >  #define I40E_MIRROR_MAX_ENTRIES_PER_RULE   64
> >  #define I40E_MAX_MIRROR_RULES           64
> >  /*
> > @@ -718,6 +746,7 @@ union i40e_filter_t {
> >  	struct rte_eth_ethertype_filter ethertype_filter;
> >  	struct rte_eth_fdir_filter fdir_filter;
> >  	struct rte_eth_tunnel_filter_conf tunnel_filter;
> > +	struct i40e_tunnel_filter_conf consistent_tunnel_filter;
> >  };
> >
> I like to use driver specified structures instead of the old rte_eth_XX.
> Glad to see this change, it will be better to change other structs. :)

Thanks, what do you think we change other structures after this release?

> 
> Acked-by Jingjing Wu <jingjing.wu@intel.com>
> 
> Thanks
> Jingjing

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 3/4] net/i40e: support tunnel filter to VF
  2017-03-09  6:08     ` Xing, Beilei
@ 2017-03-27 16:34       ` Ferruh Yigit
  0 siblings, 0 replies; 39+ messages in thread
From: Ferruh Yigit @ 2017-03-27 16:34 UTC (permalink / raw)
  To: Xing, Beilei, Wu, Jingjing, Jerin Jacob, Thomas Monjalon
  Cc: Zhang, Helin, dev, Iremonger, Bernard, Liu, Yong

On 3/9/2017 6:08 AM, Xing, Beilei wrote:
> 
> 
>> -----Original Message-----
>> From: Yigit, Ferruh
>> Sent: Wednesday, March 8, 2017 11:50 PM
>> To: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
>> Cc: Zhang, Helin <helin.zhang@intel.com>; dev@dpdk.org; Iremonger,
>> Bernard <bernard.iremonger@intel.com>; Liu, Yong <yong.liu@intel.com>
>> Subject: Re: [dpdk-dev] [PATCH 3/4] net/i40e: support tunnel filter to VF
>>
>> On 3/3/2017 9:31 AM, Beilei Xing wrote:
>>> This patch is to support tunnel filter to VF.
>>>
>>> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
>>> Signed-off-by: Yong Liu <yong.liu@intel.com>
>>> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
>>> ---
>>
>> <...>
>>
>>> +/**
>>> + * Tunneling Packet filter configuration.
>>> + */
>>> +struct i40e_tunnel_filter_conf {
>>
>> There is already "rte_eth_tunnel_filter_conf", why driver is creating its own
>> version of structure instead of using / updating public one?
> 
> Marvin has an announcement for this change before, but it's rejected as consistent filter API is available. 
> http://www.dpdk.org/dev/patchwork/patch/19772/
> 
> So we add this new feature in PMD:
> +	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
> +	uint16_t vf_id;         /**< VF id for tunnel filter insertion. */

Cc'ed Jerin and Thomas, which seems commented to Marvin's patch.

Jerin, Thomas,

Can you please comment if it is OK to localize the component and modify
it in the PMD comparing the previous updating ethdev approach?

Thanks,
ferruh


> 
> 
>>
>>> +	struct ether_addr outer_mac;    /**< Outer MAC address to match.
>> */
>>> +	struct ether_addr inner_mac;    /**< Inner MAC address to match. */
>>> +	uint16_t inner_vlan;            /**< Inner VLAN to match. */
>>> +	uint32_t outer_vlan;            /**< Outer VLAN to match */
>>> +	enum rte_tunnel_iptype ip_type; /**< IP address type. */
>>> +	/**
>>> +	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
>>> +	 * is set in filter_type, or inner destination IP address to match
>>> +	 * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
>>> +	 */
>>> +	union {
>>> +		uint32_t ipv4_addr;     /**< IPv4 address in big endian. */
>>> +		uint32_t ipv6_addr[4];  /**< IPv6 address in big endian. */
>>> +	} ip_addr;
>>> +	/** Flags from ETH_TUNNEL_FILTER_XX - see above. */
>>> +	uint16_t filter_type;
>>> +	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
>>> +	uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
>>> +	uint16_t queue_id;      /**< Queue assigned to if match. */
>>> +	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
>>> +	uint16_t vf_id;         /**< VF id for tunnel filter insertion. */
>>> +};
>>> +
>>
>> <...>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v3 0/4] Rework tunnel filter functions
  2017-03-23 10:46 ` [PATCH v2 0/4] Rework tunnel filter functions Beilei Xing
                     ` (3 preceding siblings ...)
  2017-03-23 10:46   ` [PATCH v2 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
@ 2017-03-28  3:23   ` Beilei Xing
  2017-03-28  3:23     ` [PATCH v3 1/4] net/i40e: rework " Beilei Xing
                       ` (4 more replies)
  4 siblings, 5 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-28  3:23 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, bernard.iremonger, dev

This patch set servers for MPLS and QinQ support.
1. Rework tunnel filter functions to align with the new
   added cloud filer command buffer structure.
2. Support tunnel filter to VF for consistent filter API.

v3 changes:
 Remove big_buffer conditions to the other patch set.
 Change some return values.
v2 changes:
 Remove replace cloud filter function as it's in share code.

Beilei Xing (4):
  net/i40e: rework tunnel filter functions
  net/i40e: change tunnel filter function name
  net/i40e: support tunnel filter to VF
  net/i40e: refine consistent tunnel filter

 drivers/net/i40e/i40e_ethdev.c | 226 ++++++++++++++++++++++++++++++++++-------
 drivers/net/i40e/i40e_ethdev.h |  47 +++++++++
 drivers/net/i40e/i40e_flow.c   | 133 ++++++++++++------------
 3 files changed, 308 insertions(+), 98 deletions(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v3 1/4] net/i40e: rework tunnel filter functions
  2017-03-28  3:23   ` [PATCH v3 0/4] Rework tunnel filter functions Beilei Xing
@ 2017-03-28  3:23     ` Beilei Xing
  2017-03-28  3:23     ` [PATCH v3 2/4] net/i40e: change tunnel filter function name Beilei Xing
                       ` (3 subsequent siblings)
  4 siblings, 0 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-28  3:23 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, bernard.iremonger, dev

Rework tunnel filter functions to align with the
new command buffer for add/remove cloud filter.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 90 ++++++++++++++++++++++++++----------------
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_flow.c   | 19 +++++----
 3 files changed, 67 insertions(+), 43 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 50a4e01..3a9e939 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -410,7 +410,7 @@ static int i40e_sw_ethertype_filter_insert(struct i40e_pf *pf,
 				   struct i40e_ethertype_filter *filter);
 
 static int i40e_tunnel_filter_convert(
-	struct i40e_aqc_add_remove_cloud_filters_element_data *cld_filter,
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter,
 	struct i40e_tunnel_filter *tunnel_filter);
 static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,
 				struct i40e_tunnel_filter *tunnel_filter);
@@ -6717,24 +6717,27 @@ i40e_dev_get_filter_type(uint16_t filter_type, uint16_t *flag)
 
 /* Convert tunnel filter structure */
 static int
-i40e_tunnel_filter_convert(struct i40e_aqc_add_remove_cloud_filters_element_data
-			   *cld_filter,
-			   struct i40e_tunnel_filter *tunnel_filter)
+i40e_tunnel_filter_convert(
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter,
+	struct i40e_tunnel_filter *tunnel_filter)
 {
-	ether_addr_copy((struct ether_addr *)&cld_filter->outer_mac,
+	ether_addr_copy((struct ether_addr *)&cld_filter->element.outer_mac,
 			(struct ether_addr *)&tunnel_filter->input.outer_mac);
-	ether_addr_copy((struct ether_addr *)&cld_filter->inner_mac,
+	ether_addr_copy((struct ether_addr *)&cld_filter->element.inner_mac,
 			(struct ether_addr *)&tunnel_filter->input.inner_mac);
-	tunnel_filter->input.inner_vlan = cld_filter->inner_vlan;
-	if ((rte_le_to_cpu_16(cld_filter->flags) &
+	tunnel_filter->input.inner_vlan = cld_filter->element.inner_vlan;
+	if ((rte_le_to_cpu_16(cld_filter->element.flags) &
 	     I40E_AQC_ADD_CLOUD_FLAGS_IPV6) ==
 	    I40E_AQC_ADD_CLOUD_FLAGS_IPV6)
 		tunnel_filter->input.ip_type = I40E_TUNNEL_IPTYPE_IPV6;
 	else
 		tunnel_filter->input.ip_type = I40E_TUNNEL_IPTYPE_IPV4;
-	tunnel_filter->input.flags = cld_filter->flags;
-	tunnel_filter->input.tenant_id = cld_filter->tenant_id;
-	tunnel_filter->queue = cld_filter->queue_number;
+	tunnel_filter->input.flags = cld_filter->element.flags;
+	tunnel_filter->input.tenant_id = cld_filter->element.tenant_id;
+	tunnel_filter->queue = cld_filter->element.queue_number;
+	rte_memcpy(tunnel_filter->input.general_fields,
+		   cld_filter->general_fields,
+		   sizeof(cld_filter->general_fields));
 
 	return 0;
 }
@@ -6813,40 +6816,44 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	int val, ret = 0;
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_vsi *vsi = pf->main_vsi;
-	struct i40e_aqc_add_remove_cloud_filters_element_data  *cld_filter;
-	struct i40e_aqc_add_remove_cloud_filters_element_data  *pfilter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *pfilter;
 	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
 	struct i40e_tunnel_filter *tunnel, *node;
 	struct i40e_tunnel_filter check_filter; /* Check if filter exists */
 
 	cld_filter = rte_zmalloc("tunnel_filter",
-		sizeof(struct i40e_aqc_add_remove_cloud_filters_element_data),
-		0);
+			 sizeof(struct i40e_aqc_add_rm_cloud_filt_elem_ext),
+	0);
 
 	if (NULL == cld_filter) {
 		PMD_DRV_LOG(ERR, "Failed to alloc memory.");
-		return -EINVAL;
+		return -ENOMEM;
 	}
 	pfilter = cld_filter;
 
-	ether_addr_copy(&tunnel_filter->outer_mac, (struct ether_addr*)&pfilter->outer_mac);
-	ether_addr_copy(&tunnel_filter->inner_mac, (struct ether_addr*)&pfilter->inner_mac);
+	ether_addr_copy(&tunnel_filter->outer_mac,
+			(struct ether_addr *)&pfilter->element.outer_mac);
+	ether_addr_copy(&tunnel_filter->inner_mac,
+			(struct ether_addr *)&pfilter->element.inner_mac);
 
-	pfilter->inner_vlan = rte_cpu_to_le_16(tunnel_filter->inner_vlan);
+	pfilter->element.inner_vlan =
+		rte_cpu_to_le_16(tunnel_filter->inner_vlan);
 	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
 		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
 		ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
-		rte_memcpy(&pfilter->ipaddr.v4.data,
+		rte_memcpy(&pfilter->element.ipaddr.v4.data,
 				&rte_cpu_to_le_32(ipv4_addr),
-				sizeof(pfilter->ipaddr.v4.data));
+				sizeof(pfilter->element.ipaddr.v4.data));
 	} else {
 		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
 		for (i = 0; i < 4; i++) {
 			convert_ipv6[i] =
 			rte_cpu_to_le_32(rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv6_addr[i]));
 		}
-		rte_memcpy(&pfilter->ipaddr.v6.data, &convert_ipv6,
-				sizeof(pfilter->ipaddr.v6.data));
+		rte_memcpy(&pfilter->element.ipaddr.v6.data,
+			   &convert_ipv6,
+			   sizeof(pfilter->element.ipaddr.v6.data));
 	}
 
 	/* check tunneled type */
@@ -6868,17 +6875,18 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	}
 
 	val = i40e_dev_get_filter_type(tunnel_filter->filter_type,
-						&pfilter->flags);
+				       &pfilter->element.flags);
 	if (val < 0) {
 		rte_free(cld_filter);
 		return -EINVAL;
 	}
 
-	pfilter->flags |= rte_cpu_to_le_16(
+	pfilter->element.flags |= rte_cpu_to_le_16(
 		I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE |
 		ip_type | (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT));
-	pfilter->tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
-	pfilter->queue_number = rte_cpu_to_le_16(tunnel_filter->queue_id);
+	pfilter->element.tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
+	pfilter->element.queue_number =
+		rte_cpu_to_le_16(tunnel_filter->queue_id);
 
 	/* Check if there is the filter in SW list */
 	memset(&check_filter, 0, sizeof(check_filter));
@@ -6895,20 +6903,21 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	}
 
 	if (add) {
-		ret = i40e_aq_add_cloud_filters(hw, vsi->seid, cld_filter, 1);
+		ret = i40e_aq_add_cloud_filters(hw,
+					vsi->seid, &cld_filter->element, 1);
 		if (ret < 0) {
 			PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
-			return ret;
+			return -ENOTSUP;
 		}
 		tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0);
 		rte_memcpy(tunnel, &check_filter, sizeof(check_filter));
 		ret = i40e_sw_tunnel_filter_insert(pf, tunnel);
 	} else {
 		ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
-						   cld_filter, 1);
+						   &cld_filter->element, 1);
 		if (ret < 0) {
 			PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter.");
-			return ret;
+			return -ENOTSUP;
 		}
 		ret = i40e_sw_tunnel_filter_del(pf, &node->input);
 	}
@@ -10289,13 +10298,24 @@ i40e_tunnel_filter_restore(struct i40e_pf *pf)
 	struct i40e_tunnel_filter_list
 		*tunnel_list = &pf->tunnel.tunnel_list;
 	struct i40e_tunnel_filter *f;
-	struct i40e_aqc_add_remove_cloud_filters_element_data cld_filter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext cld_filter;
 
 	TAILQ_FOREACH(f, tunnel_list, rules) {
 		memset(&cld_filter, 0, sizeof(cld_filter));
-		rte_memcpy(&cld_filter, &f->input, sizeof(f->input));
-		cld_filter.queue_number = f->queue;
-		i40e_aq_add_cloud_filters(hw, vsi->seid, &cld_filter, 1);
+		ether_addr_copy((struct ether_addr *)&f->input.outer_mac,
+			(struct ether_addr *)&cld_filter.element.outer_mac);
+		ether_addr_copy((struct ether_addr *)&f->input.inner_mac,
+			(struct ether_addr *)&cld_filter.element.inner_mac);
+		cld_filter.element.inner_vlan = f->input.inner_vlan;
+		cld_filter.element.flags = f->input.flags;
+		cld_filter.element.tenant_id = f->input.tenant_id;
+		cld_filter.element.queue_number = f->queue;
+		rte_memcpy(cld_filter.general_fields,
+			   f->input.general_fields,
+			   sizeof(f->input.general_fields));
+
+		i40e_aq_add_cloud_filters(hw, vsi->seid,
+					  &cld_filter.element, 1);
 	}
 }
 
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index aebb097..23c117e 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -513,6 +513,7 @@ struct i40e_tunnel_filter_input {
 	enum i40e_tunnel_iptype ip_type;
 	uint16_t flags;          /* Filter type flag */
 	uint32_t tenant_id;      /* Tenant id to match */
+	uint16_t general_fields[32];  /* Big buffer */
 };
 
 struct i40e_tunnel_filter {
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index f163ce5..4e3abf7 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -1725,23 +1725,26 @@ i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_vsi *vsi = pf->main_vsi;
-	struct i40e_aqc_add_remove_cloud_filters_element_data cld_filter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext cld_filter;
 	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
 	struct i40e_tunnel_filter *node;
 	int ret = 0;
 
 	memset(&cld_filter, 0, sizeof(cld_filter));
 	ether_addr_copy((struct ether_addr *)&filter->input.outer_mac,
-			(struct ether_addr *)&cld_filter.outer_mac);
+			(struct ether_addr *)&cld_filter.element.outer_mac);
 	ether_addr_copy((struct ether_addr *)&filter->input.inner_mac,
-			(struct ether_addr *)&cld_filter.inner_mac);
-	cld_filter.inner_vlan = filter->input.inner_vlan;
-	cld_filter.flags = filter->input.flags;
-	cld_filter.tenant_id = filter->input.tenant_id;
-	cld_filter.queue_number = filter->queue;
+			(struct ether_addr *)&cld_filter.element.inner_mac);
+	cld_filter.element.inner_vlan = filter->input.inner_vlan;
+	cld_filter.element.flags = filter->input.flags;
+	cld_filter.element.tenant_id = filter->input.tenant_id;
+	cld_filter.element.queue_number = filter->queue;
+	rte_memcpy(cld_filter.general_fields,
+		   filter->input.general_fields,
+		   sizeof(cld_filter.general_fields));
 
 	ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
-					   &cld_filter, 1);
+					   &cld_filter.element, 1);
 	if (ret < 0)
 		return ret;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v3 2/4] net/i40e: change tunnel filter function name
  2017-03-28  3:23   ` [PATCH v3 0/4] Rework tunnel filter functions Beilei Xing
  2017-03-28  3:23     ` [PATCH v3 1/4] net/i40e: rework " Beilei Xing
@ 2017-03-28  3:23     ` Beilei Xing
  2017-03-28  3:23     ` [PATCH v3 3/4] net/i40e: support tunnel filter to VF Beilei Xing
                       ` (2 subsequent siblings)
  4 siblings, 0 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-28  3:23 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, bernard.iremonger, dev

Change tunnel filter function name to VXLAN filter
function, prepare for other tunnel filter function.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_flow.c | 58 ++++++++++++++++----------------------------
 1 file changed, 21 insertions(+), 37 deletions(-)

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 4e3abf7..b535555 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -90,10 +90,6 @@ static int i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
 				       const struct rte_flow_action *actions,
 				       struct rte_flow_error *error,
 				       struct rte_eth_fdir_filter *filter);
-static int i40e_flow_parse_tunnel_pattern(__rte_unused struct rte_eth_dev *dev,
-				  const struct rte_flow_item *pattern,
-				  struct rte_flow_error *error,
-				  struct rte_eth_tunnel_filter_conf *filter);
 static int i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
 				 const struct rte_flow_action *actions,
 				 struct rte_flow_error *error,
@@ -112,12 +108,12 @@ static int i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 				       const struct rte_flow_action actions[],
 				       struct rte_flow_error *error,
 				       union i40e_filter_t *filter);
-static int i40e_flow_parse_tunnel_filter(struct rte_eth_dev *dev,
-					 const struct rte_flow_attr *attr,
-					 const struct rte_flow_item pattern[],
-					 const struct rte_flow_action actions[],
-					 struct rte_flow_error *error,
-					 union i40e_filter_t *filter);
+static int i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
+					const struct rte_flow_attr *attr,
+					const struct rte_flow_item pattern[],
+					const struct rte_flow_action actions[],
+					struct rte_flow_error *error,
+					union i40e_filter_t *filter);
 static int i40e_flow_destroy_ethertype_filter(struct i40e_pf *pf,
 				      struct i40e_ethertype_filter *filter);
 static int i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
@@ -302,11 +298,11 @@ static struct i40e_valid_pattern i40e_supported_patterns[] = {
 	{ pattern_fdir_ipv6_tcp_ext, i40e_flow_parse_fdir_filter },
 	{ pattern_fdir_ipv6_sctp, i40e_flow_parse_fdir_filter },
 	{ pattern_fdir_ipv6_sctp_ext, i40e_flow_parse_fdir_filter },
-	/* tunnel */
-	{ pattern_vxlan_1, i40e_flow_parse_tunnel_filter },
-	{ pattern_vxlan_2, i40e_flow_parse_tunnel_filter },
-	{ pattern_vxlan_3, i40e_flow_parse_tunnel_filter },
-	{ pattern_vxlan_4, i40e_flow_parse_tunnel_filter },
+	/* VXLAN */
+	{ pattern_vxlan_1, i40e_flow_parse_vxlan_filter },
+	{ pattern_vxlan_2, i40e_flow_parse_vxlan_filter },
+	{ pattern_vxlan_3, i40e_flow_parse_vxlan_filter },
+	{ pattern_vxlan_4, i40e_flow_parse_vxlan_filter },
 };
 
 #define NEXT_ITEM_OF_ACTION(act, actions, index)                        \
@@ -1205,7 +1201,8 @@ i40e_check_tenant_id_mask(const uint8_t *mask)
  *    filled with 0.
  */
 static int
-i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
+i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
+			      const struct rte_flow_item *pattern,
 			      struct rte_flow_error *error,
 			      struct rte_eth_tunnel_filter_conf *filter)
 {
@@ -1469,32 +1466,19 @@ i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
 }
 
 static int
-i40e_flow_parse_tunnel_pattern(__rte_unused struct rte_eth_dev *dev,
-			       const struct rte_flow_item *pattern,
-			       struct rte_flow_error *error,
-			       struct rte_eth_tunnel_filter_conf *filter)
-{
-	int ret;
-
-	ret = i40e_flow_parse_vxlan_pattern(pattern, error, filter);
-
-	return ret;
-}
-
-static int
-i40e_flow_parse_tunnel_filter(struct rte_eth_dev *dev,
-			      const struct rte_flow_attr *attr,
-			      const struct rte_flow_item pattern[],
-			      const struct rte_flow_action actions[],
-			      struct rte_flow_error *error,
-			      union i40e_filter_t *filter)
+i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
+			     const struct rte_flow_attr *attr,
+			     const struct rte_flow_item pattern[],
+			     const struct rte_flow_action actions[],
+			     struct rte_flow_error *error,
+			     union i40e_filter_t *filter)
 {
 	struct rte_eth_tunnel_filter_conf *tunnel_filter =
 		&filter->tunnel_filter;
 	int ret;
 
-	ret = i40e_flow_parse_tunnel_pattern(dev, pattern,
-					     error, tunnel_filter);
+	ret = i40e_flow_parse_vxlan_pattern(dev, pattern,
+					    error, tunnel_filter);
 	if (ret)
 		return ret;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v3 3/4] net/i40e: support tunnel filter to VF
  2017-03-28  3:23   ` [PATCH v3 0/4] Rework tunnel filter functions Beilei Xing
  2017-03-28  3:23     ` [PATCH v3 1/4] net/i40e: rework " Beilei Xing
  2017-03-28  3:23     ` [PATCH v3 2/4] net/i40e: change tunnel filter function name Beilei Xing
@ 2017-03-28  3:23     ` Beilei Xing
  2017-03-28  3:23     ` [PATCH v3 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
  2017-03-28  9:28     ` [PATCH v4 0/4] Rework tunnel filter functions Beilei Xing
  4 siblings, 0 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-28  3:23 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, bernard.iremonger, dev

Previously, only tunnel filter to PF is supported.
This patch adds i40e_dev_consistent_tunnel_filter_set
function for consistent filter API to support tunnel
filter to VF.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 136 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.h |  32 ++++++++++
 drivers/net/i40e/i40e_flow.c   |  50 ++++++++++-----
 3 files changed, 203 insertions(+), 15 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 3a9e939..bf504cc 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -6926,6 +6926,142 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	return ret;
 }
 
+int
+i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
+		      struct i40e_tunnel_filter_conf *tunnel_filter,
+		      uint8_t add)
+{
+	uint16_t ip_type;
+	uint32_t ipv4_addr;
+	uint8_t i, tun_type = 0;
+	/* internal variable to convert ipv6 byte order */
+	uint32_t convert_ipv6[4];
+	int val, ret = 0;
+	struct i40e_pf_vf *vf = NULL;
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	struct i40e_vsi *vsi;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *pfilter;
+	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
+	struct i40e_tunnel_filter *tunnel, *node;
+	struct i40e_tunnel_filter check_filter; /* Check if filter exists */
+
+	cld_filter = rte_zmalloc("tunnel_filter",
+			 sizeof(struct i40e_aqc_add_rm_cloud_filt_elem_ext),
+			 0);
+
+	if (cld_filter == NULL) {
+		PMD_DRV_LOG(ERR, "Failed to alloc memory.");
+		return -ENOMEM;
+	}
+	pfilter = cld_filter;
+
+	ether_addr_copy(&tunnel_filter->outer_mac,
+			(struct ether_addr *)&pfilter->element.outer_mac);
+	ether_addr_copy(&tunnel_filter->inner_mac,
+			(struct ether_addr *)&pfilter->element.inner_mac);
+
+	pfilter->element.inner_vlan =
+		rte_cpu_to_le_16(tunnel_filter->inner_vlan);
+	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
+		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
+		ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
+		rte_memcpy(&pfilter->element.ipaddr.v4.data,
+				&rte_cpu_to_le_32(ipv4_addr),
+				sizeof(pfilter->element.ipaddr.v4.data));
+	} else {
+		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
+		for (i = 0; i < 4; i++) {
+			convert_ipv6[i] =
+			rte_cpu_to_le_32(rte_be_to_cpu_32(
+					 tunnel_filter->ip_addr.ipv6_addr[i]));
+		}
+		rte_memcpy(&pfilter->element.ipaddr.v6.data,
+			   &convert_ipv6,
+			   sizeof(pfilter->element.ipaddr.v6.data));
+	}
+
+	/* check tunneled type */
+	switch (tunnel_filter->tunnel_type) {
+	case RTE_TUNNEL_TYPE_VXLAN:
+		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN;
+		break;
+	case RTE_TUNNEL_TYPE_NVGRE:
+		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_NVGRE_OMAC;
+		break;
+	case RTE_TUNNEL_TYPE_IP_IN_GRE:
+		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_IP;
+		break;
+	default:
+		/* Other tunnel types is not supported. */
+		PMD_DRV_LOG(ERR, "tunnel type is not supported.");
+		rte_free(cld_filter);
+		return -EINVAL;
+	}
+
+	val = i40e_dev_get_filter_type(tunnel_filter->filter_type,
+				       &pfilter->element.flags);
+	if (val < 0) {
+		rte_free(cld_filter);
+		return -EINVAL;
+	}
+
+	pfilter->element.flags |= rte_cpu_to_le_16(
+		I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE |
+		ip_type | (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT));
+	pfilter->element.tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
+	pfilter->element.queue_number =
+		rte_cpu_to_le_16(tunnel_filter->queue_id);
+
+	if (!tunnel_filter->is_to_vf)
+		vsi = pf->main_vsi;
+	else {
+		if (tunnel_filter->vf_id >= pf->vf_num) {
+			PMD_DRV_LOG(ERR, "Invalid argument.");
+			return -EINVAL;
+		}
+		vf = &pf->vfs[tunnel_filter->vf_id];
+		vsi = vf->vsi;
+	}
+
+	/* Check if there is the filter in SW list */
+	memset(&check_filter, 0, sizeof(check_filter));
+	i40e_tunnel_filter_convert(cld_filter, &check_filter);
+	node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &check_filter.input);
+	if (add && node) {
+		PMD_DRV_LOG(ERR, "Conflict with existing tunnel rules!");
+		return -EINVAL;
+	}
+
+	if (!add && !node) {
+		PMD_DRV_LOG(ERR, "There's no corresponding tunnel filter!");
+		return -EINVAL;
+	}
+
+	if (add) {
+		ret = i40e_aq_add_cloud_filters(hw,
+					vsi->seid, &cld_filter->element, 1);
+		if (ret < 0) {
+			PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
+			return -ENOTSUP;
+		}
+		tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0);
+		rte_memcpy(tunnel, &check_filter, sizeof(check_filter));
+		ret = i40e_sw_tunnel_filter_insert(pf, tunnel);
+	} else {
+		ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
+						   &cld_filter->element, 1);
+		if (ret < 0) {
+			PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter.");
+			return -ENOTSUP;
+		}
+		ret = i40e_sw_tunnel_filter_del(pf, &node->input);
+	}
+
+	rte_free(cld_filter);
+	return ret;
+}
+
 static int
 i40e_get_vxlan_port_idx(struct i40e_pf *pf, uint16_t port)
 {
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 23c117e..5567677 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -514,6 +514,7 @@ struct i40e_tunnel_filter_input {
 	uint16_t flags;          /* Filter type flag */
 	uint32_t tenant_id;      /* Tenant id to match */
 	uint16_t general_fields[32];  /* Big buffer */
+	uint16_t vf_id;         /* VF id for tunnel filtering. */
 };
 
 struct i40e_tunnel_filter {
@@ -530,6 +531,33 @@ struct i40e_tunnel_rule {
 	struct rte_hash *hash_table;
 };
 
+/**
+ * Tunneling Packet filter configuration.
+ */
+struct i40e_tunnel_filter_conf {
+	struct ether_addr outer_mac;    /**< Outer MAC address to match. */
+	struct ether_addr inner_mac;    /**< Inner MAC address to match. */
+	uint16_t inner_vlan;            /**< Inner VLAN to match. */
+	uint32_t outer_vlan;            /**< Outer VLAN to match */
+	enum rte_tunnel_iptype ip_type; /**< IP address type. */
+	/**
+	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
+	 * is set in filter_type, or inner destination IP address to match
+	 * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
+	 */
+	union {
+		uint32_t ipv4_addr;     /**< IPv4 address in big endian. */
+		uint32_t ipv6_addr[4];  /**< IPv6 address in big endian. */
+	} ip_addr;
+	/** Flags from ETH_TUNNEL_FILTER_XX - see above. */
+	uint16_t filter_type;
+	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+	uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
+	uint16_t queue_id;      /**< Queue assigned to if match. */
+	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
+	uint16_t vf_id;         /**< VF id for tunnel filter insertion. */
+};
+
 #define I40E_MIRROR_MAX_ENTRIES_PER_RULE   64
 #define I40E_MAX_MIRROR_RULES           64
 /*
@@ -718,6 +746,7 @@ union i40e_filter_t {
 	struct rte_eth_ethertype_filter ethertype_filter;
 	struct rte_eth_fdir_filter fdir_filter;
 	struct rte_eth_tunnel_filter_conf tunnel_filter;
+	struct i40e_tunnel_filter_conf consistent_tunnel_filter;
 };
 
 typedef int (*parse_filter_t)(struct rte_eth_dev *dev,
@@ -806,6 +835,9 @@ int i40e_add_del_fdir_filter(struct rte_eth_dev *dev,
 int i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 			       struct rte_eth_tunnel_filter_conf *tunnel_filter,
 			       uint8_t add);
+int i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
+				  struct i40e_tunnel_filter_conf *tunnel_filter,
+				  uint8_t add);
 int i40e_fdir_flush(struct rte_eth_dev *dev);
 
 #define I40E_DEV_TO_PCI(eth_dev) \
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index b535555..2239c30 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -93,7 +93,7 @@ static int i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
 static int i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
 				 const struct rte_flow_action *actions,
 				 struct rte_flow_error *error,
-				 struct rte_eth_tunnel_filter_conf *filter);
+				 struct i40e_tunnel_filter_conf *filter);
 static int i40e_flow_parse_attr(const struct rte_flow_attr *attr,
 				struct rte_flow_error *error);
 static int i40e_flow_parse_ethertype_filter(struct rte_eth_dev *dev,
@@ -1127,34 +1127,54 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 }
 
 /* Parse to get the action info of a tunnle filter
- * Tunnel action only supports QUEUE.
+ * Tunnel action only supports PF, VF and QUEUE.
  */
 static int
 i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
 			      const struct rte_flow_action *actions,
 			      struct rte_flow_error *error,
-			      struct rte_eth_tunnel_filter_conf *filter)
+			      struct i40e_tunnel_filter_conf *filter)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	const struct rte_flow_action *act;
 	const struct rte_flow_action_queue *act_q;
+	const struct rte_flow_action_vf *act_vf;
 	uint32_t index = 0;
 
-	/* Check if the first non-void action is QUEUE. */
+	/* Check if the first non-void action is PF or VF. */
 	NEXT_ITEM_OF_ACTION(act, actions, index);
-	if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE) {
+	if (act->type != RTE_FLOW_ACTION_TYPE_PF &&
+	    act->type != RTE_FLOW_ACTION_TYPE_VF) {
 		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
 				   act, "Not supported action.");
 		return -rte_errno;
 	}
 
-	act_q = (const struct rte_flow_action_queue *)act->conf;
-	filter->queue_id = act_q->index;
-	if (filter->queue_id >= pf->dev_data->nb_rx_queues) {
-		rte_flow_error_set(error, EINVAL,
+	if (act->type == RTE_FLOW_ACTION_TYPE_VF) {
+		act_vf = (const struct rte_flow_action_vf *)act->conf;
+		filter->vf_id = act_vf->id;
+		filter->is_to_vf = 1;
+		if (filter->vf_id >= pf->vf_num) {
+			rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_ACTION,
+				   act, "Invalid VF ID for tunnel filter");
+			return -rte_errno;
+		}
+	}
+
+	/* Check if the next non-void item is QUEUE */
+	index++;
+	NEXT_ITEM_OF_ACTION(act, actions, index);
+	if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
+		act_q = (const struct rte_flow_action_queue *)act->conf;
+		filter->queue_id = act_q->index;
+		if (!filter->is_to_vf)
+			if (filter->queue_id >= pf->dev_data->nb_rx_queues) {
+				rte_flow_error_set(error, EINVAL,
 				   RTE_FLOW_ERROR_TYPE_ACTION,
 				   act, "Invalid queue ID for tunnel filter");
-		return -rte_errno;
+				return -rte_errno;
+			}
 	}
 
 	/* Check if the next non-void item is END */
@@ -1204,7 +1224,7 @@ static int
 i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			      const struct rte_flow_item *pattern,
 			      struct rte_flow_error *error,
-			      struct rte_eth_tunnel_filter_conf *filter)
+			      struct i40e_tunnel_filter_conf *filter)
 {
 	const struct rte_flow_item *item = pattern;
 	const struct rte_flow_item_eth *eth_spec;
@@ -1473,8 +1493,8 @@ i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
 			     struct rte_flow_error *error,
 			     union i40e_filter_t *filter)
 {
-	struct rte_eth_tunnel_filter_conf *tunnel_filter =
-		&filter->tunnel_filter;
+	struct i40e_tunnel_filter_conf *tunnel_filter =
+		&filter->consistent_tunnel_filter;
 	int ret;
 
 	ret = i40e_flow_parse_vxlan_pattern(dev, pattern,
@@ -1605,8 +1625,8 @@ i40e_flow_create(struct rte_eth_dev *dev,
 					i40e_fdir_filter_list);
 		break;
 	case RTE_ETH_FILTER_TUNNEL:
-		ret = i40e_dev_tunnel_filter_set(pf,
-					 &cons_filter.tunnel_filter, 1);
+		ret = i40e_dev_consistent_tunnel_filter_set(pf,
+			    &cons_filter.consistent_tunnel_filter, 1);
 		if (ret)
 			goto free_flow;
 		flow->rule = TAILQ_LAST(&pf->tunnel.tunnel_list,
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v3 4/4] net/i40e: refine consistent tunnel filter
  2017-03-28  3:23   ` [PATCH v3 0/4] Rework tunnel filter functions Beilei Xing
                       ` (2 preceding siblings ...)
  2017-03-28  3:23     ` [PATCH v3 3/4] net/i40e: support tunnel filter to VF Beilei Xing
@ 2017-03-28  3:23     ` Beilei Xing
  2017-03-28  9:28     ` [PATCH v4 0/4] Rework tunnel filter functions Beilei Xing
  4 siblings, 0 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-28  3:23 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, bernard.iremonger, dev

Add i40e_tunnel_type enumeration type to refine consistent
tunnel filter, it will be esay to add new tunnel type for
i40e.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c |  8 ++++----
 drivers/net/i40e/i40e_ethdev.h | 18 ++++++++++++++++--
 drivers/net/i40e/i40e_flow.c   |  6 +++---
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index bf504cc..8f6d2d2 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -6963,7 +6963,7 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
 
 	pfilter->element.inner_vlan =
 		rte_cpu_to_le_16(tunnel_filter->inner_vlan);
-	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
+	if (tunnel_filter->ip_type == I40E_TUNNEL_IPTYPE_IPV4) {
 		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
 		ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
 		rte_memcpy(&pfilter->element.ipaddr.v4.data,
@@ -6983,13 +6983,13 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
 
 	/* check tunneled type */
 	switch (tunnel_filter->tunnel_type) {
-	case RTE_TUNNEL_TYPE_VXLAN:
+	case I40E_TUNNEL_TYPE_VXLAN:
 		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN;
 		break;
-	case RTE_TUNNEL_TYPE_NVGRE:
+	case I40E_TUNNEL_TYPE_NVGRE:
 		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_NVGRE_OMAC;
 		break;
-	case RTE_TUNNEL_TYPE_IP_IN_GRE:
+	case I40E_TUNNEL_TYPE_IP_IN_GRE:
 		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_IP;
 		break;
 	default:
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 5567677..f917b0c 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -532,6 +532,20 @@ struct i40e_tunnel_rule {
 };
 
 /**
+ * Tunnel type.
+ */
+enum i40e_tunnel_type {
+	I40E_TUNNEL_TYPE_NONE = 0,
+	I40E_TUNNEL_TYPE_VXLAN,
+	I40E_TUNNEL_TYPE_GENEVE,
+	I40E_TUNNEL_TYPE_TEREDO,
+	I40E_TUNNEL_TYPE_NVGRE,
+	I40E_TUNNEL_TYPE_IP_IN_GRE,
+	I40E_L2_TUNNEL_TYPE_E_TAG,
+	I40E_TUNNEL_TYPE_MAX,
+};
+
+/**
  * Tunneling Packet filter configuration.
  */
 struct i40e_tunnel_filter_conf {
@@ -539,7 +553,7 @@ struct i40e_tunnel_filter_conf {
 	struct ether_addr inner_mac;    /**< Inner MAC address to match. */
 	uint16_t inner_vlan;            /**< Inner VLAN to match. */
 	uint32_t outer_vlan;            /**< Outer VLAN to match */
-	enum rte_tunnel_iptype ip_type; /**< IP address type. */
+	enum i40e_tunnel_iptype ip_type; /**< IP address type. */
 	/**
 	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
 	 * is set in filter_type, or inner destination IP address to match
@@ -551,7 +565,7 @@ struct i40e_tunnel_filter_conf {
 	} ip_addr;
 	/** Flags from ETH_TUNNEL_FILTER_XX - see above. */
 	uint16_t filter_type;
-	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+	enum i40e_tunnel_type tunnel_type; /**< Tunnel Type. */
 	uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
 	uint16_t queue_id;      /**< Queue assigned to if match. */
 	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 2239c30..148e519 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -1324,7 +1324,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			}
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
-			filter->ip_type = RTE_TUNNEL_IPTYPE_IPV4;
+			filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
 			/* IPv4 is used to describe protocol,
 			 * spec and mask should be NULL.
 			 */
@@ -1337,7 +1337,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			}
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
-			filter->ip_type = RTE_TUNNEL_IPTYPE_IPV6;
+			filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
 			/* IPv6 is used to describe protocol,
 			 * spec and mask should be NULL.
 			 */
@@ -1480,7 +1480,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 		return -rte_errno;
 	}
 
-	filter->tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
+	filter->tunnel_type = I40E_TUNNEL_TYPE_VXLAN;
 
 	return 0;
 }
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v4 0/4] Rework tunnel filter functions
  2017-03-28  3:23   ` [PATCH v3 0/4] Rework tunnel filter functions Beilei Xing
                       ` (3 preceding siblings ...)
  2017-03-28  3:23     ` [PATCH v3 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
@ 2017-03-28  9:28     ` Beilei Xing
  2017-03-28  9:28       ` [PATCH v4 1/4] net/i40e: rework " Beilei Xing
                         ` (4 more replies)
  4 siblings, 5 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-28  9:28 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, bernard.iremonger, dev

This patch set servers for MPLS and QinQ support.
1. Rework tunnel filter functions to align with the new
   added cloud filer command buffer structure.
2. Support tunnel filter to VF for consistent filter API.

v4 changes:
 Update signed-off for patch 3/4. 
v3 changes:
 Remove big_buffer conditions to the other patch set.
 Change some return values.
v2 changes:
 Remove replace cloud filter function as it's in share code.

Beilei Xing (4):
  net/i40e: rework tunnel filter functions
  net/i40e: change tunnel filter function name
  net/i40e: support tunnel filter to VF
  net/i40e: refine consistent tunnel filter

 drivers/net/i40e/i40e_ethdev.c | 226 ++++++++++++++++++++++++++++++++++-------
 drivers/net/i40e/i40e_ethdev.h |  47 +++++++++
 drivers/net/i40e/i40e_flow.c   | 133 ++++++++++++------------
 3 files changed, 308 insertions(+), 98 deletions(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v4 1/4] net/i40e: rework tunnel filter functions
  2017-03-28  9:28     ` [PATCH v4 0/4] Rework tunnel filter functions Beilei Xing
@ 2017-03-28  9:28       ` Beilei Xing
  2017-03-28  9:28       ` [PATCH v4 2/4] net/i40e: change tunnel filter function name Beilei Xing
                         ` (3 subsequent siblings)
  4 siblings, 0 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-28  9:28 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, bernard.iremonger, dev

Rework tunnel filter functions to align with the
new command buffer for add/remove cloud filter.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 90 ++++++++++++++++++++++++++----------------
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_flow.c   | 19 +++++----
 3 files changed, 67 insertions(+), 43 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 50a4e01..3a9e939 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -410,7 +410,7 @@ static int i40e_sw_ethertype_filter_insert(struct i40e_pf *pf,
 				   struct i40e_ethertype_filter *filter);
 
 static int i40e_tunnel_filter_convert(
-	struct i40e_aqc_add_remove_cloud_filters_element_data *cld_filter,
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter,
 	struct i40e_tunnel_filter *tunnel_filter);
 static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,
 				struct i40e_tunnel_filter *tunnel_filter);
@@ -6717,24 +6717,27 @@ i40e_dev_get_filter_type(uint16_t filter_type, uint16_t *flag)
 
 /* Convert tunnel filter structure */
 static int
-i40e_tunnel_filter_convert(struct i40e_aqc_add_remove_cloud_filters_element_data
-			   *cld_filter,
-			   struct i40e_tunnel_filter *tunnel_filter)
+i40e_tunnel_filter_convert(
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter,
+	struct i40e_tunnel_filter *tunnel_filter)
 {
-	ether_addr_copy((struct ether_addr *)&cld_filter->outer_mac,
+	ether_addr_copy((struct ether_addr *)&cld_filter->element.outer_mac,
 			(struct ether_addr *)&tunnel_filter->input.outer_mac);
-	ether_addr_copy((struct ether_addr *)&cld_filter->inner_mac,
+	ether_addr_copy((struct ether_addr *)&cld_filter->element.inner_mac,
 			(struct ether_addr *)&tunnel_filter->input.inner_mac);
-	tunnel_filter->input.inner_vlan = cld_filter->inner_vlan;
-	if ((rte_le_to_cpu_16(cld_filter->flags) &
+	tunnel_filter->input.inner_vlan = cld_filter->element.inner_vlan;
+	if ((rte_le_to_cpu_16(cld_filter->element.flags) &
 	     I40E_AQC_ADD_CLOUD_FLAGS_IPV6) ==
 	    I40E_AQC_ADD_CLOUD_FLAGS_IPV6)
 		tunnel_filter->input.ip_type = I40E_TUNNEL_IPTYPE_IPV6;
 	else
 		tunnel_filter->input.ip_type = I40E_TUNNEL_IPTYPE_IPV4;
-	tunnel_filter->input.flags = cld_filter->flags;
-	tunnel_filter->input.tenant_id = cld_filter->tenant_id;
-	tunnel_filter->queue = cld_filter->queue_number;
+	tunnel_filter->input.flags = cld_filter->element.flags;
+	tunnel_filter->input.tenant_id = cld_filter->element.tenant_id;
+	tunnel_filter->queue = cld_filter->element.queue_number;
+	rte_memcpy(tunnel_filter->input.general_fields,
+		   cld_filter->general_fields,
+		   sizeof(cld_filter->general_fields));
 
 	return 0;
 }
@@ -6813,40 +6816,44 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	int val, ret = 0;
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_vsi *vsi = pf->main_vsi;
-	struct i40e_aqc_add_remove_cloud_filters_element_data  *cld_filter;
-	struct i40e_aqc_add_remove_cloud_filters_element_data  *pfilter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *pfilter;
 	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
 	struct i40e_tunnel_filter *tunnel, *node;
 	struct i40e_tunnel_filter check_filter; /* Check if filter exists */
 
 	cld_filter = rte_zmalloc("tunnel_filter",
-		sizeof(struct i40e_aqc_add_remove_cloud_filters_element_data),
-		0);
+			 sizeof(struct i40e_aqc_add_rm_cloud_filt_elem_ext),
+	0);
 
 	if (NULL == cld_filter) {
 		PMD_DRV_LOG(ERR, "Failed to alloc memory.");
-		return -EINVAL;
+		return -ENOMEM;
 	}
 	pfilter = cld_filter;
 
-	ether_addr_copy(&tunnel_filter->outer_mac, (struct ether_addr*)&pfilter->outer_mac);
-	ether_addr_copy(&tunnel_filter->inner_mac, (struct ether_addr*)&pfilter->inner_mac);
+	ether_addr_copy(&tunnel_filter->outer_mac,
+			(struct ether_addr *)&pfilter->element.outer_mac);
+	ether_addr_copy(&tunnel_filter->inner_mac,
+			(struct ether_addr *)&pfilter->element.inner_mac);
 
-	pfilter->inner_vlan = rte_cpu_to_le_16(tunnel_filter->inner_vlan);
+	pfilter->element.inner_vlan =
+		rte_cpu_to_le_16(tunnel_filter->inner_vlan);
 	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
 		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
 		ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
-		rte_memcpy(&pfilter->ipaddr.v4.data,
+		rte_memcpy(&pfilter->element.ipaddr.v4.data,
 				&rte_cpu_to_le_32(ipv4_addr),
-				sizeof(pfilter->ipaddr.v4.data));
+				sizeof(pfilter->element.ipaddr.v4.data));
 	} else {
 		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
 		for (i = 0; i < 4; i++) {
 			convert_ipv6[i] =
 			rte_cpu_to_le_32(rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv6_addr[i]));
 		}
-		rte_memcpy(&pfilter->ipaddr.v6.data, &convert_ipv6,
-				sizeof(pfilter->ipaddr.v6.data));
+		rte_memcpy(&pfilter->element.ipaddr.v6.data,
+			   &convert_ipv6,
+			   sizeof(pfilter->element.ipaddr.v6.data));
 	}
 
 	/* check tunneled type */
@@ -6868,17 +6875,18 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	}
 
 	val = i40e_dev_get_filter_type(tunnel_filter->filter_type,
-						&pfilter->flags);
+				       &pfilter->element.flags);
 	if (val < 0) {
 		rte_free(cld_filter);
 		return -EINVAL;
 	}
 
-	pfilter->flags |= rte_cpu_to_le_16(
+	pfilter->element.flags |= rte_cpu_to_le_16(
 		I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE |
 		ip_type | (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT));
-	pfilter->tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
-	pfilter->queue_number = rte_cpu_to_le_16(tunnel_filter->queue_id);
+	pfilter->element.tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
+	pfilter->element.queue_number =
+		rte_cpu_to_le_16(tunnel_filter->queue_id);
 
 	/* Check if there is the filter in SW list */
 	memset(&check_filter, 0, sizeof(check_filter));
@@ -6895,20 +6903,21 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	}
 
 	if (add) {
-		ret = i40e_aq_add_cloud_filters(hw, vsi->seid, cld_filter, 1);
+		ret = i40e_aq_add_cloud_filters(hw,
+					vsi->seid, &cld_filter->element, 1);
 		if (ret < 0) {
 			PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
-			return ret;
+			return -ENOTSUP;
 		}
 		tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0);
 		rte_memcpy(tunnel, &check_filter, sizeof(check_filter));
 		ret = i40e_sw_tunnel_filter_insert(pf, tunnel);
 	} else {
 		ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
-						   cld_filter, 1);
+						   &cld_filter->element, 1);
 		if (ret < 0) {
 			PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter.");
-			return ret;
+			return -ENOTSUP;
 		}
 		ret = i40e_sw_tunnel_filter_del(pf, &node->input);
 	}
@@ -10289,13 +10298,24 @@ i40e_tunnel_filter_restore(struct i40e_pf *pf)
 	struct i40e_tunnel_filter_list
 		*tunnel_list = &pf->tunnel.tunnel_list;
 	struct i40e_tunnel_filter *f;
-	struct i40e_aqc_add_remove_cloud_filters_element_data cld_filter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext cld_filter;
 
 	TAILQ_FOREACH(f, tunnel_list, rules) {
 		memset(&cld_filter, 0, sizeof(cld_filter));
-		rte_memcpy(&cld_filter, &f->input, sizeof(f->input));
-		cld_filter.queue_number = f->queue;
-		i40e_aq_add_cloud_filters(hw, vsi->seid, &cld_filter, 1);
+		ether_addr_copy((struct ether_addr *)&f->input.outer_mac,
+			(struct ether_addr *)&cld_filter.element.outer_mac);
+		ether_addr_copy((struct ether_addr *)&f->input.inner_mac,
+			(struct ether_addr *)&cld_filter.element.inner_mac);
+		cld_filter.element.inner_vlan = f->input.inner_vlan;
+		cld_filter.element.flags = f->input.flags;
+		cld_filter.element.tenant_id = f->input.tenant_id;
+		cld_filter.element.queue_number = f->queue;
+		rte_memcpy(cld_filter.general_fields,
+			   f->input.general_fields,
+			   sizeof(f->input.general_fields));
+
+		i40e_aq_add_cloud_filters(hw, vsi->seid,
+					  &cld_filter.element, 1);
 	}
 }
 
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index aebb097..23c117e 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -513,6 +513,7 @@ struct i40e_tunnel_filter_input {
 	enum i40e_tunnel_iptype ip_type;
 	uint16_t flags;          /* Filter type flag */
 	uint32_t tenant_id;      /* Tenant id to match */
+	uint16_t general_fields[32];  /* Big buffer */
 };
 
 struct i40e_tunnel_filter {
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index f163ce5..4e3abf7 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -1725,23 +1725,26 @@ i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_vsi *vsi = pf->main_vsi;
-	struct i40e_aqc_add_remove_cloud_filters_element_data cld_filter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext cld_filter;
 	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
 	struct i40e_tunnel_filter *node;
 	int ret = 0;
 
 	memset(&cld_filter, 0, sizeof(cld_filter));
 	ether_addr_copy((struct ether_addr *)&filter->input.outer_mac,
-			(struct ether_addr *)&cld_filter.outer_mac);
+			(struct ether_addr *)&cld_filter.element.outer_mac);
 	ether_addr_copy((struct ether_addr *)&filter->input.inner_mac,
-			(struct ether_addr *)&cld_filter.inner_mac);
-	cld_filter.inner_vlan = filter->input.inner_vlan;
-	cld_filter.flags = filter->input.flags;
-	cld_filter.tenant_id = filter->input.tenant_id;
-	cld_filter.queue_number = filter->queue;
+			(struct ether_addr *)&cld_filter.element.inner_mac);
+	cld_filter.element.inner_vlan = filter->input.inner_vlan;
+	cld_filter.element.flags = filter->input.flags;
+	cld_filter.element.tenant_id = filter->input.tenant_id;
+	cld_filter.element.queue_number = filter->queue;
+	rte_memcpy(cld_filter.general_fields,
+		   filter->input.general_fields,
+		   sizeof(cld_filter.general_fields));
 
 	ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
-					   &cld_filter, 1);
+					   &cld_filter.element, 1);
 	if (ret < 0)
 		return ret;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v4 2/4] net/i40e: change tunnel filter function name
  2017-03-28  9:28     ` [PATCH v4 0/4] Rework tunnel filter functions Beilei Xing
  2017-03-28  9:28       ` [PATCH v4 1/4] net/i40e: rework " Beilei Xing
@ 2017-03-28  9:28       ` Beilei Xing
  2017-03-28  9:28       ` [PATCH v4 3/4] net/i40e: support tunnel filter to VF Beilei Xing
                         ` (2 subsequent siblings)
  4 siblings, 0 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-28  9:28 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, bernard.iremonger, dev

Change tunnel filter function name to VXLAN filter
function, prepare for other tunnel filter function.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_flow.c | 58 ++++++++++++++++----------------------------
 1 file changed, 21 insertions(+), 37 deletions(-)

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 4e3abf7..b535555 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -90,10 +90,6 @@ static int i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
 				       const struct rte_flow_action *actions,
 				       struct rte_flow_error *error,
 				       struct rte_eth_fdir_filter *filter);
-static int i40e_flow_parse_tunnel_pattern(__rte_unused struct rte_eth_dev *dev,
-				  const struct rte_flow_item *pattern,
-				  struct rte_flow_error *error,
-				  struct rte_eth_tunnel_filter_conf *filter);
 static int i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
 				 const struct rte_flow_action *actions,
 				 struct rte_flow_error *error,
@@ -112,12 +108,12 @@ static int i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 				       const struct rte_flow_action actions[],
 				       struct rte_flow_error *error,
 				       union i40e_filter_t *filter);
-static int i40e_flow_parse_tunnel_filter(struct rte_eth_dev *dev,
-					 const struct rte_flow_attr *attr,
-					 const struct rte_flow_item pattern[],
-					 const struct rte_flow_action actions[],
-					 struct rte_flow_error *error,
-					 union i40e_filter_t *filter);
+static int i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
+					const struct rte_flow_attr *attr,
+					const struct rte_flow_item pattern[],
+					const struct rte_flow_action actions[],
+					struct rte_flow_error *error,
+					union i40e_filter_t *filter);
 static int i40e_flow_destroy_ethertype_filter(struct i40e_pf *pf,
 				      struct i40e_ethertype_filter *filter);
 static int i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
@@ -302,11 +298,11 @@ static struct i40e_valid_pattern i40e_supported_patterns[] = {
 	{ pattern_fdir_ipv6_tcp_ext, i40e_flow_parse_fdir_filter },
 	{ pattern_fdir_ipv6_sctp, i40e_flow_parse_fdir_filter },
 	{ pattern_fdir_ipv6_sctp_ext, i40e_flow_parse_fdir_filter },
-	/* tunnel */
-	{ pattern_vxlan_1, i40e_flow_parse_tunnel_filter },
-	{ pattern_vxlan_2, i40e_flow_parse_tunnel_filter },
-	{ pattern_vxlan_3, i40e_flow_parse_tunnel_filter },
-	{ pattern_vxlan_4, i40e_flow_parse_tunnel_filter },
+	/* VXLAN */
+	{ pattern_vxlan_1, i40e_flow_parse_vxlan_filter },
+	{ pattern_vxlan_2, i40e_flow_parse_vxlan_filter },
+	{ pattern_vxlan_3, i40e_flow_parse_vxlan_filter },
+	{ pattern_vxlan_4, i40e_flow_parse_vxlan_filter },
 };
 
 #define NEXT_ITEM_OF_ACTION(act, actions, index)                        \
@@ -1205,7 +1201,8 @@ i40e_check_tenant_id_mask(const uint8_t *mask)
  *    filled with 0.
  */
 static int
-i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
+i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
+			      const struct rte_flow_item *pattern,
 			      struct rte_flow_error *error,
 			      struct rte_eth_tunnel_filter_conf *filter)
 {
@@ -1469,32 +1466,19 @@ i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
 }
 
 static int
-i40e_flow_parse_tunnel_pattern(__rte_unused struct rte_eth_dev *dev,
-			       const struct rte_flow_item *pattern,
-			       struct rte_flow_error *error,
-			       struct rte_eth_tunnel_filter_conf *filter)
-{
-	int ret;
-
-	ret = i40e_flow_parse_vxlan_pattern(pattern, error, filter);
-
-	return ret;
-}
-
-static int
-i40e_flow_parse_tunnel_filter(struct rte_eth_dev *dev,
-			      const struct rte_flow_attr *attr,
-			      const struct rte_flow_item pattern[],
-			      const struct rte_flow_action actions[],
-			      struct rte_flow_error *error,
-			      union i40e_filter_t *filter)
+i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
+			     const struct rte_flow_attr *attr,
+			     const struct rte_flow_item pattern[],
+			     const struct rte_flow_action actions[],
+			     struct rte_flow_error *error,
+			     union i40e_filter_t *filter)
 {
 	struct rte_eth_tunnel_filter_conf *tunnel_filter =
 		&filter->tunnel_filter;
 	int ret;
 
-	ret = i40e_flow_parse_tunnel_pattern(dev, pattern,
-					     error, tunnel_filter);
+	ret = i40e_flow_parse_vxlan_pattern(dev, pattern,
+					    error, tunnel_filter);
 	if (ret)
 		return ret;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v4 3/4] net/i40e: support tunnel filter to VF
  2017-03-28  9:28     ` [PATCH v4 0/4] Rework tunnel filter functions Beilei Xing
  2017-03-28  9:28       ` [PATCH v4 1/4] net/i40e: rework " Beilei Xing
  2017-03-28  9:28       ` [PATCH v4 2/4] net/i40e: change tunnel filter function name Beilei Xing
@ 2017-03-28  9:28       ` Beilei Xing
  2017-03-28  9:28       ` [PATCH v4 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
  2017-03-29 13:23       ` [PATCH v4 0/4] Rework tunnel filter functions Wu, Jingjing
  4 siblings, 0 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-28  9:28 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, bernard.iremonger, dev, Yong Liu

Previously, only tunnel filter to PF is supported.
This patch adds i40e_dev_consistent_tunnel_filter_set
function for consistent filter API to support tunnel
filter to VF.

Signed-off-by: Yong Liu <yong.liu@intel.com>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 136 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.h |  32 ++++++++++
 drivers/net/i40e/i40e_flow.c   |  50 ++++++++++-----
 3 files changed, 203 insertions(+), 15 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 3a9e939..bf504cc 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -6926,6 +6926,142 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	return ret;
 }
 
+int
+i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
+		      struct i40e_tunnel_filter_conf *tunnel_filter,
+		      uint8_t add)
+{
+	uint16_t ip_type;
+	uint32_t ipv4_addr;
+	uint8_t i, tun_type = 0;
+	/* internal variable to convert ipv6 byte order */
+	uint32_t convert_ipv6[4];
+	int val, ret = 0;
+	struct i40e_pf_vf *vf = NULL;
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	struct i40e_vsi *vsi;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *cld_filter;
+	struct i40e_aqc_add_rm_cloud_filt_elem_ext *pfilter;
+	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
+	struct i40e_tunnel_filter *tunnel, *node;
+	struct i40e_tunnel_filter check_filter; /* Check if filter exists */
+
+	cld_filter = rte_zmalloc("tunnel_filter",
+			 sizeof(struct i40e_aqc_add_rm_cloud_filt_elem_ext),
+			 0);
+
+	if (cld_filter == NULL) {
+		PMD_DRV_LOG(ERR, "Failed to alloc memory.");
+		return -ENOMEM;
+	}
+	pfilter = cld_filter;
+
+	ether_addr_copy(&tunnel_filter->outer_mac,
+			(struct ether_addr *)&pfilter->element.outer_mac);
+	ether_addr_copy(&tunnel_filter->inner_mac,
+			(struct ether_addr *)&pfilter->element.inner_mac);
+
+	pfilter->element.inner_vlan =
+		rte_cpu_to_le_16(tunnel_filter->inner_vlan);
+	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
+		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
+		ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
+		rte_memcpy(&pfilter->element.ipaddr.v4.data,
+				&rte_cpu_to_le_32(ipv4_addr),
+				sizeof(pfilter->element.ipaddr.v4.data));
+	} else {
+		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
+		for (i = 0; i < 4; i++) {
+			convert_ipv6[i] =
+			rte_cpu_to_le_32(rte_be_to_cpu_32(
+					 tunnel_filter->ip_addr.ipv6_addr[i]));
+		}
+		rte_memcpy(&pfilter->element.ipaddr.v6.data,
+			   &convert_ipv6,
+			   sizeof(pfilter->element.ipaddr.v6.data));
+	}
+
+	/* check tunneled type */
+	switch (tunnel_filter->tunnel_type) {
+	case RTE_TUNNEL_TYPE_VXLAN:
+		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN;
+		break;
+	case RTE_TUNNEL_TYPE_NVGRE:
+		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_NVGRE_OMAC;
+		break;
+	case RTE_TUNNEL_TYPE_IP_IN_GRE:
+		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_IP;
+		break;
+	default:
+		/* Other tunnel types is not supported. */
+		PMD_DRV_LOG(ERR, "tunnel type is not supported.");
+		rte_free(cld_filter);
+		return -EINVAL;
+	}
+
+	val = i40e_dev_get_filter_type(tunnel_filter->filter_type,
+				       &pfilter->element.flags);
+	if (val < 0) {
+		rte_free(cld_filter);
+		return -EINVAL;
+	}
+
+	pfilter->element.flags |= rte_cpu_to_le_16(
+		I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE |
+		ip_type | (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT));
+	pfilter->element.tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
+	pfilter->element.queue_number =
+		rte_cpu_to_le_16(tunnel_filter->queue_id);
+
+	if (!tunnel_filter->is_to_vf)
+		vsi = pf->main_vsi;
+	else {
+		if (tunnel_filter->vf_id >= pf->vf_num) {
+			PMD_DRV_LOG(ERR, "Invalid argument.");
+			return -EINVAL;
+		}
+		vf = &pf->vfs[tunnel_filter->vf_id];
+		vsi = vf->vsi;
+	}
+
+	/* Check if there is the filter in SW list */
+	memset(&check_filter, 0, sizeof(check_filter));
+	i40e_tunnel_filter_convert(cld_filter, &check_filter);
+	node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &check_filter.input);
+	if (add && node) {
+		PMD_DRV_LOG(ERR, "Conflict with existing tunnel rules!");
+		return -EINVAL;
+	}
+
+	if (!add && !node) {
+		PMD_DRV_LOG(ERR, "There's no corresponding tunnel filter!");
+		return -EINVAL;
+	}
+
+	if (add) {
+		ret = i40e_aq_add_cloud_filters(hw,
+					vsi->seid, &cld_filter->element, 1);
+		if (ret < 0) {
+			PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
+			return -ENOTSUP;
+		}
+		tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0);
+		rte_memcpy(tunnel, &check_filter, sizeof(check_filter));
+		ret = i40e_sw_tunnel_filter_insert(pf, tunnel);
+	} else {
+		ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
+						   &cld_filter->element, 1);
+		if (ret < 0) {
+			PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter.");
+			return -ENOTSUP;
+		}
+		ret = i40e_sw_tunnel_filter_del(pf, &node->input);
+	}
+
+	rte_free(cld_filter);
+	return ret;
+}
+
 static int
 i40e_get_vxlan_port_idx(struct i40e_pf *pf, uint16_t port)
 {
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 23c117e..5567677 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -514,6 +514,7 @@ struct i40e_tunnel_filter_input {
 	uint16_t flags;          /* Filter type flag */
 	uint32_t tenant_id;      /* Tenant id to match */
 	uint16_t general_fields[32];  /* Big buffer */
+	uint16_t vf_id;         /* VF id for tunnel filtering. */
 };
 
 struct i40e_tunnel_filter {
@@ -530,6 +531,33 @@ struct i40e_tunnel_rule {
 	struct rte_hash *hash_table;
 };
 
+/**
+ * Tunneling Packet filter configuration.
+ */
+struct i40e_tunnel_filter_conf {
+	struct ether_addr outer_mac;    /**< Outer MAC address to match. */
+	struct ether_addr inner_mac;    /**< Inner MAC address to match. */
+	uint16_t inner_vlan;            /**< Inner VLAN to match. */
+	uint32_t outer_vlan;            /**< Outer VLAN to match */
+	enum rte_tunnel_iptype ip_type; /**< IP address type. */
+	/**
+	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
+	 * is set in filter_type, or inner destination IP address to match
+	 * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
+	 */
+	union {
+		uint32_t ipv4_addr;     /**< IPv4 address in big endian. */
+		uint32_t ipv6_addr[4];  /**< IPv6 address in big endian. */
+	} ip_addr;
+	/** Flags from ETH_TUNNEL_FILTER_XX - see above. */
+	uint16_t filter_type;
+	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+	uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
+	uint16_t queue_id;      /**< Queue assigned to if match. */
+	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
+	uint16_t vf_id;         /**< VF id for tunnel filter insertion. */
+};
+
 #define I40E_MIRROR_MAX_ENTRIES_PER_RULE   64
 #define I40E_MAX_MIRROR_RULES           64
 /*
@@ -718,6 +746,7 @@ union i40e_filter_t {
 	struct rte_eth_ethertype_filter ethertype_filter;
 	struct rte_eth_fdir_filter fdir_filter;
 	struct rte_eth_tunnel_filter_conf tunnel_filter;
+	struct i40e_tunnel_filter_conf consistent_tunnel_filter;
 };
 
 typedef int (*parse_filter_t)(struct rte_eth_dev *dev,
@@ -806,6 +835,9 @@ int i40e_add_del_fdir_filter(struct rte_eth_dev *dev,
 int i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 			       struct rte_eth_tunnel_filter_conf *tunnel_filter,
 			       uint8_t add);
+int i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
+				  struct i40e_tunnel_filter_conf *tunnel_filter,
+				  uint8_t add);
 int i40e_fdir_flush(struct rte_eth_dev *dev);
 
 #define I40E_DEV_TO_PCI(eth_dev) \
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index b535555..2239c30 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -93,7 +93,7 @@ static int i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
 static int i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
 				 const struct rte_flow_action *actions,
 				 struct rte_flow_error *error,
-				 struct rte_eth_tunnel_filter_conf *filter);
+				 struct i40e_tunnel_filter_conf *filter);
 static int i40e_flow_parse_attr(const struct rte_flow_attr *attr,
 				struct rte_flow_error *error);
 static int i40e_flow_parse_ethertype_filter(struct rte_eth_dev *dev,
@@ -1127,34 +1127,54 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 }
 
 /* Parse to get the action info of a tunnle filter
- * Tunnel action only supports QUEUE.
+ * Tunnel action only supports PF, VF and QUEUE.
  */
 static int
 i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
 			      const struct rte_flow_action *actions,
 			      struct rte_flow_error *error,
-			      struct rte_eth_tunnel_filter_conf *filter)
+			      struct i40e_tunnel_filter_conf *filter)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	const struct rte_flow_action *act;
 	const struct rte_flow_action_queue *act_q;
+	const struct rte_flow_action_vf *act_vf;
 	uint32_t index = 0;
 
-	/* Check if the first non-void action is QUEUE. */
+	/* Check if the first non-void action is PF or VF. */
 	NEXT_ITEM_OF_ACTION(act, actions, index);
-	if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE) {
+	if (act->type != RTE_FLOW_ACTION_TYPE_PF &&
+	    act->type != RTE_FLOW_ACTION_TYPE_VF) {
 		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
 				   act, "Not supported action.");
 		return -rte_errno;
 	}
 
-	act_q = (const struct rte_flow_action_queue *)act->conf;
-	filter->queue_id = act_q->index;
-	if (filter->queue_id >= pf->dev_data->nb_rx_queues) {
-		rte_flow_error_set(error, EINVAL,
+	if (act->type == RTE_FLOW_ACTION_TYPE_VF) {
+		act_vf = (const struct rte_flow_action_vf *)act->conf;
+		filter->vf_id = act_vf->id;
+		filter->is_to_vf = 1;
+		if (filter->vf_id >= pf->vf_num) {
+			rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_ACTION,
+				   act, "Invalid VF ID for tunnel filter");
+			return -rte_errno;
+		}
+	}
+
+	/* Check if the next non-void item is QUEUE */
+	index++;
+	NEXT_ITEM_OF_ACTION(act, actions, index);
+	if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
+		act_q = (const struct rte_flow_action_queue *)act->conf;
+		filter->queue_id = act_q->index;
+		if (!filter->is_to_vf)
+			if (filter->queue_id >= pf->dev_data->nb_rx_queues) {
+				rte_flow_error_set(error, EINVAL,
 				   RTE_FLOW_ERROR_TYPE_ACTION,
 				   act, "Invalid queue ID for tunnel filter");
-		return -rte_errno;
+				return -rte_errno;
+			}
 	}
 
 	/* Check if the next non-void item is END */
@@ -1204,7 +1224,7 @@ static int
 i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			      const struct rte_flow_item *pattern,
 			      struct rte_flow_error *error,
-			      struct rte_eth_tunnel_filter_conf *filter)
+			      struct i40e_tunnel_filter_conf *filter)
 {
 	const struct rte_flow_item *item = pattern;
 	const struct rte_flow_item_eth *eth_spec;
@@ -1473,8 +1493,8 @@ i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
 			     struct rte_flow_error *error,
 			     union i40e_filter_t *filter)
 {
-	struct rte_eth_tunnel_filter_conf *tunnel_filter =
-		&filter->tunnel_filter;
+	struct i40e_tunnel_filter_conf *tunnel_filter =
+		&filter->consistent_tunnel_filter;
 	int ret;
 
 	ret = i40e_flow_parse_vxlan_pattern(dev, pattern,
@@ -1605,8 +1625,8 @@ i40e_flow_create(struct rte_eth_dev *dev,
 					i40e_fdir_filter_list);
 		break;
 	case RTE_ETH_FILTER_TUNNEL:
-		ret = i40e_dev_tunnel_filter_set(pf,
-					 &cons_filter.tunnel_filter, 1);
+		ret = i40e_dev_consistent_tunnel_filter_set(pf,
+			    &cons_filter.consistent_tunnel_filter, 1);
 		if (ret)
 			goto free_flow;
 		flow->rule = TAILQ_LAST(&pf->tunnel.tunnel_list,
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH v4 4/4] net/i40e: refine consistent tunnel filter
  2017-03-28  9:28     ` [PATCH v4 0/4] Rework tunnel filter functions Beilei Xing
                         ` (2 preceding siblings ...)
  2017-03-28  9:28       ` [PATCH v4 3/4] net/i40e: support tunnel filter to VF Beilei Xing
@ 2017-03-28  9:28       ` Beilei Xing
  2017-03-29 13:23       ` [PATCH v4 0/4] Rework tunnel filter functions Wu, Jingjing
  4 siblings, 0 replies; 39+ messages in thread
From: Beilei Xing @ 2017-03-28  9:28 UTC (permalink / raw)
  To: jingjing.wu; +Cc: helin.zhang, bernard.iremonger, dev

Add i40e_tunnel_type enumeration type to refine consistent
tunnel filter, it will be esay to add new tunnel type for
i40e.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c |  8 ++++----
 drivers/net/i40e/i40e_ethdev.h | 18 ++++++++++++++++--
 drivers/net/i40e/i40e_flow.c   |  6 +++---
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index bf504cc..8f6d2d2 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -6963,7 +6963,7 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
 
 	pfilter->element.inner_vlan =
 		rte_cpu_to_le_16(tunnel_filter->inner_vlan);
-	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
+	if (tunnel_filter->ip_type == I40E_TUNNEL_IPTYPE_IPV4) {
 		ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
 		ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
 		rte_memcpy(&pfilter->element.ipaddr.v4.data,
@@ -6983,13 +6983,13 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
 
 	/* check tunneled type */
 	switch (tunnel_filter->tunnel_type) {
-	case RTE_TUNNEL_TYPE_VXLAN:
+	case I40E_TUNNEL_TYPE_VXLAN:
 		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN;
 		break;
-	case RTE_TUNNEL_TYPE_NVGRE:
+	case I40E_TUNNEL_TYPE_NVGRE:
 		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_NVGRE_OMAC;
 		break;
-	case RTE_TUNNEL_TYPE_IP_IN_GRE:
+	case I40E_TUNNEL_TYPE_IP_IN_GRE:
 		tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_IP;
 		break;
 	default:
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 5567677..f917b0c 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -532,6 +532,20 @@ struct i40e_tunnel_rule {
 };
 
 /**
+ * Tunnel type.
+ */
+enum i40e_tunnel_type {
+	I40E_TUNNEL_TYPE_NONE = 0,
+	I40E_TUNNEL_TYPE_VXLAN,
+	I40E_TUNNEL_TYPE_GENEVE,
+	I40E_TUNNEL_TYPE_TEREDO,
+	I40E_TUNNEL_TYPE_NVGRE,
+	I40E_TUNNEL_TYPE_IP_IN_GRE,
+	I40E_L2_TUNNEL_TYPE_E_TAG,
+	I40E_TUNNEL_TYPE_MAX,
+};
+
+/**
  * Tunneling Packet filter configuration.
  */
 struct i40e_tunnel_filter_conf {
@@ -539,7 +553,7 @@ struct i40e_tunnel_filter_conf {
 	struct ether_addr inner_mac;    /**< Inner MAC address to match. */
 	uint16_t inner_vlan;            /**< Inner VLAN to match. */
 	uint32_t outer_vlan;            /**< Outer VLAN to match */
-	enum rte_tunnel_iptype ip_type; /**< IP address type. */
+	enum i40e_tunnel_iptype ip_type; /**< IP address type. */
 	/**
 	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
 	 * is set in filter_type, or inner destination IP address to match
@@ -551,7 +565,7 @@ struct i40e_tunnel_filter_conf {
 	} ip_addr;
 	/** Flags from ETH_TUNNEL_FILTER_XX - see above. */
 	uint16_t filter_type;
-	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+	enum i40e_tunnel_type tunnel_type; /**< Tunnel Type. */
 	uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
 	uint16_t queue_id;      /**< Queue assigned to if match. */
 	uint8_t is_to_vf;       /**< 0 - to PF, 1 - to VF */
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 2239c30..148e519 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -1324,7 +1324,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			}
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
-			filter->ip_type = RTE_TUNNEL_IPTYPE_IPV4;
+			filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
 			/* IPv4 is used to describe protocol,
 			 * spec and mask should be NULL.
 			 */
@@ -1337,7 +1337,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			}
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
-			filter->ip_type = RTE_TUNNEL_IPTYPE_IPV6;
+			filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
 			/* IPv6 is used to describe protocol,
 			 * spec and mask should be NULL.
 			 */
@@ -1480,7 +1480,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 		return -rte_errno;
 	}
 
-	filter->tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
+	filter->tunnel_type = I40E_TUNNEL_TYPE_VXLAN;
 
 	return 0;
 }
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH v4 0/4] Rework tunnel filter functions
  2017-03-28  9:28     ` [PATCH v4 0/4] Rework tunnel filter functions Beilei Xing
                         ` (3 preceding siblings ...)
  2017-03-28  9:28       ` [PATCH v4 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
@ 2017-03-29 13:23       ` Wu, Jingjing
  2017-03-30 13:03         ` Ferruh Yigit
  4 siblings, 1 reply; 39+ messages in thread
From: Wu, Jingjing @ 2017-03-29 13:23 UTC (permalink / raw)
  To: Xing, Beilei; +Cc: Zhang, Helin, Iremonger, Bernard, dev



> -----Original Message-----
> From: Xing, Beilei
> Sent: Tuesday, March 28, 2017 5:29 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Zhang, Helin <helin.zhang@intel.com>; Iremonger, Bernard
> <bernard.iremonger@intel.com>; dev@dpdk.org
> Subject: [PATCH v4 0/4] Rework tunnel filter functions
> 
> This patch set servers for MPLS and QinQ support.
> 1. Rework tunnel filter functions to align with the new
>    added cloud filer command buffer structure.
> 2. Support tunnel filter to VF for consistent filter API.
> 
> v4 changes:
>  Update signed-off for patch 3/4.
> v3 changes:
>  Remove big_buffer conditions to the other patch set.
>  Change some return values.
> v2 changes:
>  Remove replace cloud filter function as it's in share code.
> 
> Beilei Xing (4):
>   net/i40e: rework tunnel filter functions
>   net/i40e: change tunnel filter function name
>   net/i40e: support tunnel filter to VF
>   net/i40e: refine consistent tunnel filter
> 
>  drivers/net/i40e/i40e_ethdev.c | 226
> ++++++++++++++++++++++++++++++++++-------
>  drivers/net/i40e/i40e_ethdev.h |  47 +++++++++
>  drivers/net/i40e/i40e_flow.c   | 133 ++++++++++++------------
>  3 files changed, 308 insertions(+), 98 deletions(-)


Series Acked-by Jingjing Wu <jingjing.wu@intel.com>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v4 0/4] Rework tunnel filter functions
  2017-03-29 13:23       ` [PATCH v4 0/4] Rework tunnel filter functions Wu, Jingjing
@ 2017-03-30 13:03         ` Ferruh Yigit
  0 siblings, 0 replies; 39+ messages in thread
From: Ferruh Yigit @ 2017-03-30 13:03 UTC (permalink / raw)
  To: Wu, Jingjing, Xing, Beilei; +Cc: Zhang, Helin, Iremonger, Bernard, dev

On 3/29/2017 2:23 PM, Wu, Jingjing wrote:
> 
> 
>> -----Original Message-----
>> From: Xing, Beilei
>> Sent: Tuesday, March 28, 2017 5:29 PM
>> To: Wu, Jingjing <jingjing.wu@intel.com>
>> Cc: Zhang, Helin <helin.zhang@intel.com>; Iremonger, Bernard
>> <bernard.iremonger@intel.com>; dev@dpdk.org
>> Subject: [PATCH v4 0/4] Rework tunnel filter functions
>>
>> This patch set servers for MPLS and QinQ support.
>> 1. Rework tunnel filter functions to align with the new
>>    added cloud filer command buffer structure.
>> 2. Support tunnel filter to VF for consistent filter API.
>>
>> v4 changes:
>>  Update signed-off for patch 3/4.
>> v3 changes:
>>  Remove big_buffer conditions to the other patch set.
>>  Change some return values.
>> v2 changes:
>>  Remove replace cloud filter function as it's in share code.
>>
>> Beilei Xing (4):
>>   net/i40e: rework tunnel filter functions
>>   net/i40e: change tunnel filter function name
>>   net/i40e: support tunnel filter to VF
>>   net/i40e: refine consistent tunnel filter

> 
> 
> Series Acked-by Jingjing Wu <jingjing.wu@intel.com>

Series applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2017-03-30 13:04 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03  9:31 [PATCH 0/4] support replace filter function Beilei Xing
2017-03-03  9:31 ` [PATCH 1/4] net/i40e: support replace filter type Beilei Xing
2017-03-08 15:50   ` Ferruh Yigit
2017-03-09  5:59     ` Xing, Beilei
2017-03-09 10:01       ` Ferruh Yigit
2017-03-09 10:43         ` Xing, Beilei
2017-03-03  9:31 ` [PATCH 2/4] net/i40e: rework tunnel filter functions Beilei Xing
2017-03-08 15:50   ` Ferruh Yigit
2017-03-09  6:00     ` Xing, Beilei
2017-03-03  9:31 ` [PATCH 3/4] net/i40e: support tunnel filter to VF Beilei Xing
2017-03-08 15:50   ` Ferruh Yigit
2017-03-09  6:08     ` Xing, Beilei
2017-03-27 16:34       ` Ferruh Yigit
2017-03-03  9:31 ` [PATCH 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
2017-03-08 15:50   ` Ferruh Yigit
2017-03-09  6:11     ` Xing, Beilei
2017-03-08 15:50 ` [PATCH 0/4] support replace filter function Ferruh Yigit
2017-03-09  5:13   ` Xing, Beilei
2017-03-23 10:46 ` [PATCH v2 0/4] Rework tunnel filter functions Beilei Xing
2017-03-23 10:46   ` [PATCH v2 1/4] net/i40e: rework " Beilei Xing
2017-03-27  9:47     ` Wu, Jingjing
2017-03-27 10:33       ` Xing, Beilei
2017-03-23 10:46   ` [PATCH v2 2/4] net/i40e: change tunnel filter function name Beilei Xing
2017-03-23 10:46   ` [PATCH v2 3/4] net/i40e: support tunnel filter to VF Beilei Xing
2017-03-27  9:54     ` Wu, Jingjing
2017-03-27 10:37       ` Xing, Beilei
2017-03-23 10:46   ` [PATCH v2 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
2017-03-28  3:23   ` [PATCH v3 0/4] Rework tunnel filter functions Beilei Xing
2017-03-28  3:23     ` [PATCH v3 1/4] net/i40e: rework " Beilei Xing
2017-03-28  3:23     ` [PATCH v3 2/4] net/i40e: change tunnel filter function name Beilei Xing
2017-03-28  3:23     ` [PATCH v3 3/4] net/i40e: support tunnel filter to VF Beilei Xing
2017-03-28  3:23     ` [PATCH v3 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
2017-03-28  9:28     ` [PATCH v4 0/4] Rework tunnel filter functions Beilei Xing
2017-03-28  9:28       ` [PATCH v4 1/4] net/i40e: rework " Beilei Xing
2017-03-28  9:28       ` [PATCH v4 2/4] net/i40e: change tunnel filter function name Beilei Xing
2017-03-28  9:28       ` [PATCH v4 3/4] net/i40e: support tunnel filter to VF Beilei Xing
2017-03-28  9:28       ` [PATCH v4 4/4] net/i40e: refine consistent tunnel filter Beilei Xing
2017-03-29 13:23       ` [PATCH v4 0/4] Rework tunnel filter functions Wu, Jingjing
2017-03-30 13:03         ` Ferruh Yigit

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.