DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] net/i40e: support input set configuration
@ 2017-11-24 14:59 Beilei Xing
  2017-11-24 14:59 ` [dpdk-dev] [PATCH 1/2] " Beilei Xing
                   ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: Beilei Xing @ 2017-11-24 14:59 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, andrey.chilikin

The patchset adds support input set configuration for
RSS/FDIR/FDIR flexible payload.

Beilei Xing (2):
  net/i40e: support input set configuration
  app/testpmd: add configuration for input set

 app/test-pmd/cmdline.c                    | 124 ++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 +++
 4 files changed, 413 insertions(+)

-- 
2.5.5

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

* [dpdk-dev] [PATCH 1/2] net/i40e: support input set configuration
  2017-11-24 14:59 [dpdk-dev] [PATCH 0/2] net/i40e: support input set configuration Beilei Xing
@ 2017-11-24 14:59 ` Beilei Xing
  2017-11-24 14:59 ` [dpdk-dev] [PATCH 2/2] app/testpmd: add configuration for input set Beilei Xing
  2017-11-27  7:16 ` [dpdk-dev] [PATCH v2 0/2] net/i40e: support input set configuration Beilei Xing
  2 siblings, 0 replies; 30+ messages in thread
From: Beilei Xing @ 2017-11-24 14:59 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, andrey.chilikin

This patch supports getting/setting input set info for
RSS/FDIR/FDIR flexible payload.
Also add some helper functions for input set configuration.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 +++
 3 files changed, 289 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index aeb92af..1f95f91 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -2985,3 +2985,144 @@ int rte_pmd_i40e_flow_add_del_packet_template(
 
 	return i40e_flow_add_del_fdir_filter(dev, &filter_conf, add);
 }
+
+int
+rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	memset(inset, 0, sizeof(struct rte_pmd_i40e_inset));
+
+	switch (inset_type) {
+	case INSET_HASH:
+		/* Get input set */
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, pctype));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, pctype));
+		/* Get field mask */
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(1, pctype));
+		break;
+	case INSET_FDIR:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 1));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 0));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(1, pctype));
+		break;
+	case INSET_FDIR_FLX:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_FLXINSET(pctype));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 0));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 1));
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	inset->inset = inset_reg;
+
+	for (i = 0; i < 2; i++) {
+		inset->mask[i].field_idx = ((mask_reg[i] >> 16) & 0x3F);
+		inset->mask[i].mask = mask_reg[i] & 0xFFFF;
+	}
+
+	return 0;
+}
+
+int
+rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* Clear mask first */
+	for (i = 0; i < 2; i++)
+		i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype), 0);
+
+	inset_reg = inset->inset;
+	for (i = 0; i < 2; i++)
+		mask_reg[i] = (inset->mask[i].field_idx << 16) |
+			inset->mask[i].mask;
+
+	switch (inset_type) {
+	case INSET_HASH:
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(0, pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(1, pctype),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_HASH_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 0),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 1),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR_FLX:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_FLXINSET(pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_PRTQF_FD_MSK(pctype, i),
+					     mask_reg[i]);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	I40E_WRITE_FLUSH(hw);
+	return 0;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 580ca4a..ab898cc 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -317,6 +317,23 @@ struct rte_pmd_i40e_pkt_template_conf {
 	uint32_t soft_id;
 };
 
+enum rte_pmd_i40e_inset_type {
+	INSET_NONE = 0,
+	INSET_HASH,
+	INSET_FDIR,
+	INSET_FDIR_FLX,
+};
+
+struct  rte_pmd_i40e_inset_mask {
+	uint8_t field_idx;
+	uint16_t mask;
+};
+
+struct rte_pmd_i40e_inset {
+	uint64_t inset;
+	struct rte_pmd_i40e_inset_mask mask[2];
+};
+
 /**
  * Add or remove raw packet template filter to Flow Director.
  *
@@ -933,4 +950,125 @@ int rte_pmd_i40e_query_vfid_by_mac(uint16_t port,
 int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
 			enum rte_pmd_i40e_queue_region_op op_type, void *arg);
 
+int rte_pmd_i40e_cfg_hash_inset(uint16_t port,
+				uint64_t pctype, uint64_t inset);
+
+/**
+ * Get input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Buffer for input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Set input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Get bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (1) if set.
+ *   - (0) if cleared.
+ */
+inline int
+rte_pmd_i40e_inset_field_get(uint64_t inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return 0;
+
+	bit_idx = 63 - field_idx;
+	if (inset & (1ULL << bit_idx))
+		return 1;
+
+	return 0;
+}
+
+/**
+ * Set bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+inline int
+rte_pmd_i40e_inset_field_set(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset | (1ULL << bit_idx);
+
+	return 0;
+}
+
+/**
+ * Clear bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+inline int
+rte_pmd_i40e_inset_field_clear(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset & ~(1ULL << bit_idx);
+
+	return 0;
+}
+
 #endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index ebbd24e..82d5e2f 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -58,3 +58,13 @@ DPDK_17.11 {
 	rte_pmd_i40e_rss_queue_region_conf;
 
 } DPDK_17.08;
+
+DPDK_18.02 {
+	global:
+
+	rte_pmd_i40e_inset_get;
+	rte_pmd_i40e_inset_set;
+	rte_pmd_i40e_inset_field_get;
+	rte_pmd_i40e_inset_field_set;
+	rte_pmd_i40e_inset_field_clear;
+}
\ No newline at end of file
-- 
2.5.5

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

* [dpdk-dev] [PATCH 2/2] app/testpmd: add configuration for input set
  2017-11-24 14:59 [dpdk-dev] [PATCH 0/2] net/i40e: support input set configuration Beilei Xing
  2017-11-24 14:59 ` [dpdk-dev] [PATCH 1/2] " Beilei Xing
@ 2017-11-24 14:59 ` Beilei Xing
  2017-11-27  7:16 ` [dpdk-dev] [PATCH v2 0/2] net/i40e: support input set configuration Beilei Xing
  2 siblings, 0 replies; 30+ messages in thread
From: Beilei Xing @ 2017-11-24 14:59 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, andrey.chilikin

This patch adds command to configure input set for
RSS/flow director/flow director flexible payload.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 app/test-pmd/cmdline.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 124 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f71d963..e1fe8a2 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -864,6 +864,10 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config (port_id) pctype mapping update"
 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
 			"    Update a flow type to pctype mapping item on a port\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset set|clear field (field_idx)\n"
+			"    Configure input set for RSS|FDIR|FDIR_FLX"
 		);
 	}
 
@@ -14652,6 +14656,125 @@ cmdline_parse_inst_t cmd_ddp_get_list = {
 	},
 };
 
+/* Configure input set */
+struct cmd_cfg_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t opt;
+	cmdline_fixed_string_t field;
+	uint8_t field_idx;
+};
+
+static void
+cmd_cfg_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_cfg_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset *inset = NULL;
+	int ret;
+#endif
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
+				     inset, inset_type);
+	if (ret) {
+		printf("Failed to get input set.\n");
+		return;
+	}
+
+	if (!strcmp(res->opt, "set"))
+		ret = rte_pmd_i40e_inset_field_set(&inset->inset,
+						   res->pctype_id);
+	else if (!strcmp(res->opt, "clear"))
+		ret = rte_pmd_i40e_inset_field_clear(&inset->inset,
+						     res->pctype_id);
+	if (ret) {
+		printf("Failed to configure input set field.\n");
+		return;
+	}
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     inset, inset_type);
+	if (ret) {
+		printf("Failed to set input set.\n");
+		return;
+	}
+
+#endif
+}
+
+cmdline_parse_token_string_t cmd_cfg_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_cfg_input_set_opt =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 opt, "set#clear");
+cmdline_parse_token_string_t cmd_cfg_input_set_field =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 field, "field");
+cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      field_idx, UINT8);
+
+cmdline_parse_inst_t cmd_cfg_input_set = {
+	.f = cmd_cfg_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset set|clear field <field_idx>",
+	.tokens = {
+		(void *)&cmd_cfg_input_set_port,
+		(void *)&cmd_cfg_input_set_cfg,
+		(void *)&cmd_cfg_input_set_port_id,
+		(void *)&cmd_cfg_input_set_pctype,
+		(void *)&cmd_cfg_input_set_pctype_id,
+		(void *)&cmd_cfg_input_set_inset_type,
+		(void *)&cmd_cfg_input_set_opt,
+		(void *)&cmd_cfg_input_set_field,
+		(void *)&cmd_cfg_input_set_field_idx,
+		NULL,
+	},
+};
+
 /* show vf stats */
 
 /* Common result structure for show vf stats */
@@ -15737,6 +15860,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_ddp_del,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
+	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
-- 
2.5.5

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

* [dpdk-dev] [PATCH v2 0/2] net/i40e: support input set configuration
  2017-11-24 14:59 [dpdk-dev] [PATCH 0/2] net/i40e: support input set configuration Beilei Xing
  2017-11-24 14:59 ` [dpdk-dev] [PATCH 1/2] " Beilei Xing
  2017-11-24 14:59 ` [dpdk-dev] [PATCH 2/2] app/testpmd: add configuration for input set Beilei Xing
@ 2017-11-27  7:16 ` Beilei Xing
  2017-11-27  7:16   ` [dpdk-dev] [PATCH v2 1/2] " Beilei Xing
                     ` (2 more replies)
  2 siblings, 3 replies; 30+ messages in thread
From: Beilei Xing @ 2017-11-27  7:16 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, andrey.chilikin

The patchset adds support input set configuration for
RSS/FDIR/FDIR flexible payload.

v2 changes:
 - Use 'static inline' to replace 'inline'.
 - Add support get status for some filed index of input set.

Beilei Xing (2):
  net/i40e: support input set configuration
  app/testpmd: add configuration for input set

 app/test-pmd/cmdline.c                    | 133 ++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 +++
 4 files changed, 422 insertions(+)

-- 
2.5.5

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

* [dpdk-dev] [PATCH v2 1/2] net/i40e: support input set configuration
  2017-11-27  7:16 ` [dpdk-dev] [PATCH v2 0/2] net/i40e: support input set configuration Beilei Xing
@ 2017-11-27  7:16   ` Beilei Xing
  2017-11-27  7:16   ` [dpdk-dev] [PATCH v2 2/2] app/testpmd: add configuration for input set Beilei Xing
  2017-11-29  9:43   ` [dpdk-dev] [PATCH v3 0/2] net/i40e: support input set configuration Beilei Xing
  2 siblings, 0 replies; 30+ messages in thread
From: Beilei Xing @ 2017-11-27  7:16 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, andrey.chilikin

This patch supports getting/setting input set info for
RSS/FDIR/FDIR flexible payload.
Also add some helper functions for input set configuration.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 +++
 3 files changed, 289 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index aeb92af..1f95f91 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -2985,3 +2985,144 @@ int rte_pmd_i40e_flow_add_del_packet_template(
 
 	return i40e_flow_add_del_fdir_filter(dev, &filter_conf, add);
 }
+
+int
+rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	memset(inset, 0, sizeof(struct rte_pmd_i40e_inset));
+
+	switch (inset_type) {
+	case INSET_HASH:
+		/* Get input set */
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, pctype));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, pctype));
+		/* Get field mask */
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(1, pctype));
+		break;
+	case INSET_FDIR:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 1));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 0));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(1, pctype));
+		break;
+	case INSET_FDIR_FLX:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_FLXINSET(pctype));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 0));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 1));
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	inset->inset = inset_reg;
+
+	for (i = 0; i < 2; i++) {
+		inset->mask[i].field_idx = ((mask_reg[i] >> 16) & 0x3F);
+		inset->mask[i].mask = mask_reg[i] & 0xFFFF;
+	}
+
+	return 0;
+}
+
+int
+rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* Clear mask first */
+	for (i = 0; i < 2; i++)
+		i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype), 0);
+
+	inset_reg = inset->inset;
+	for (i = 0; i < 2; i++)
+		mask_reg[i] = (inset->mask[i].field_idx << 16) |
+			inset->mask[i].mask;
+
+	switch (inset_type) {
+	case INSET_HASH:
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(0, pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(1, pctype),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_HASH_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 0),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 1),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR_FLX:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_FLXINSET(pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_PRTQF_FD_MSK(pctype, i),
+					     mask_reg[i]);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	I40E_WRITE_FLUSH(hw);
+	return 0;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 580ca4a..e987528 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -317,6 +317,23 @@ struct rte_pmd_i40e_pkt_template_conf {
 	uint32_t soft_id;
 };
 
+enum rte_pmd_i40e_inset_type {
+	INSET_NONE = 0,
+	INSET_HASH,
+	INSET_FDIR,
+	INSET_FDIR_FLX,
+};
+
+struct  rte_pmd_i40e_inset_mask {
+	uint8_t field_idx;
+	uint16_t mask;
+};
+
+struct rte_pmd_i40e_inset {
+	uint64_t inset;
+	struct rte_pmd_i40e_inset_mask mask[2];
+};
+
 /**
  * Add or remove raw packet template filter to Flow Director.
  *
@@ -933,4 +950,125 @@ int rte_pmd_i40e_query_vfid_by_mac(uint16_t port,
 int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
 			enum rte_pmd_i40e_queue_region_op op_type, void *arg);
 
+int rte_pmd_i40e_cfg_hash_inset(uint16_t port,
+				uint64_t pctype, uint64_t inset);
+
+/**
+ * Get input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Buffer for input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Set input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Get bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (1) if set.
+ *   - (0) if cleared.
+ */
+static inline int
+rte_pmd_i40e_inset_field_get(uint64_t inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return 0;
+
+	bit_idx = 63 - field_idx;
+	if (inset & (1ULL << bit_idx))
+		return 1;
+
+	return 0;
+}
+
+/**
+ * Set bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_set(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset | (1ULL << bit_idx);
+
+	return 0;
+}
+
+/**
+ * Clear bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_clear(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset & ~(1ULL << bit_idx);
+
+	return 0;
+}
+
 #endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index ebbd24e..82d5e2f 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -58,3 +58,13 @@ DPDK_17.11 {
 	rte_pmd_i40e_rss_queue_region_conf;
 
 } DPDK_17.08;
+
+DPDK_18.02 {
+	global:
+
+	rte_pmd_i40e_inset_get;
+	rte_pmd_i40e_inset_set;
+	rte_pmd_i40e_inset_field_get;
+	rte_pmd_i40e_inset_field_set;
+	rte_pmd_i40e_inset_field_clear;
+}
\ No newline at end of file
-- 
2.5.5

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

* [dpdk-dev] [PATCH v2 2/2] app/testpmd: add configuration for input set
  2017-11-27  7:16 ` [dpdk-dev] [PATCH v2 0/2] net/i40e: support input set configuration Beilei Xing
  2017-11-27  7:16   ` [dpdk-dev] [PATCH v2 1/2] " Beilei Xing
@ 2017-11-27  7:16   ` Beilei Xing
  2017-11-29  9:43   ` [dpdk-dev] [PATCH v3 0/2] net/i40e: support input set configuration Beilei Xing
  2 siblings, 0 replies; 30+ messages in thread
From: Beilei Xing @ 2017-11-27  7:16 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, andrey.chilikin

This patch adds command to configure input set for
RSS/flow director/flow director flexible payload.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 app/test-pmd/cmdline.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 133 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f71d963..49f8266 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -864,6 +864,11 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config (port_id) pctype mapping update"
 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
 			"    Update a flow type to pctype mapping item on a port\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset get|set|clear field\n"
+			" (field_idx)\n"
+			"    Configure input set for RSS|FDIR|FDIR_FLX\n\n"
 		);
 	}
 
@@ -14652,6 +14657,133 @@ cmdline_parse_inst_t cmd_ddp_get_list = {
 	},
 };
 
+/* Configure input set */
+struct cmd_cfg_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t opt;
+	cmdline_fixed_string_t field;
+	uint8_t field_idx;
+};
+
+static void
+cmd_cfg_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_cfg_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+	int ret;
+#endif
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to get input set.\n");
+		return;
+	}
+
+	if (!strcmp(res->opt, "get")) {
+		ret = rte_pmd_i40e_inset_field_get(inset.inset,
+						   res->field_idx);
+		if (ret)
+			printf("Field index %d is set.\n", res->field_idx);
+		else
+			printf("Field index %d is not set.\n", res->field_idx);
+		return;
+	} else if (!strcmp(res->opt, "set"))
+		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
+						   res->field_idx);
+	else if (!strcmp(res->opt, "clear"))
+		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
+						     res->field_idx);
+	if (ret) {
+		printf("Failed to configure input set field.\n");
+		return;
+	}
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to set input set.\n");
+		return;
+	}
+
+#endif
+}
+
+cmdline_parse_token_string_t cmd_cfg_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_cfg_input_set_opt =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 opt, "get#set#clear");
+cmdline_parse_token_string_t cmd_cfg_input_set_field =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 field, "field");
+cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      field_idx, UINT8);
+
+cmdline_parse_inst_t cmd_cfg_input_set = {
+	.f = cmd_cfg_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
+	.tokens = {
+		(void *)&cmd_cfg_input_set_port,
+		(void *)&cmd_cfg_input_set_cfg,
+		(void *)&cmd_cfg_input_set_port_id,
+		(void *)&cmd_cfg_input_set_pctype,
+		(void *)&cmd_cfg_input_set_pctype_id,
+		(void *)&cmd_cfg_input_set_inset_type,
+		(void *)&cmd_cfg_input_set_opt,
+		(void *)&cmd_cfg_input_set_field,
+		(void *)&cmd_cfg_input_set_field_idx,
+		NULL,
+	},
+};
+
 /* show vf stats */
 
 /* Common result structure for show vf stats */
@@ -15737,6 +15869,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_ddp_del,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
+	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
-- 
2.5.5

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

* [dpdk-dev] [PATCH v3 0/2] net/i40e: support input set configuration
  2017-11-27  7:16 ` [dpdk-dev] [PATCH v2 0/2] net/i40e: support input set configuration Beilei Xing
  2017-11-27  7:16   ` [dpdk-dev] [PATCH v2 1/2] " Beilei Xing
  2017-11-27  7:16   ` [dpdk-dev] [PATCH v2 2/2] app/testpmd: add configuration for input set Beilei Xing
@ 2017-11-29  9:43   ` Beilei Xing
  2017-11-29  9:43     ` [dpdk-dev] [PATCH v3 1/2] " Beilei Xing
                       ` (2 more replies)
  2 siblings, 3 replies; 30+ messages in thread
From: Beilei Xing @ 2017-11-29  9:43 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, andrey.chilikin

The patchset adds support RSS/FDIR/FDIR flexible payload input set configuration
for some pctype.

v3 changes:
 - Add support reset RSS/FDIR/FDIR flexible payload input set for some pctype.

v2 changes:
 - Use 'static inline' to replace 'inline'.
 - Add support get status for some filed index of input set.

Beilei Xing (2):
  net/i40e: support input set configuration
  app/testpmd: add configuration for input set

 app/test-pmd/cmdline.c                    | 232 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 ++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 ++
 4 files changed, 521 insertions(+)

-- 
2.5.5

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

* [dpdk-dev] [PATCH v3 1/2] net/i40e: support input set configuration
  2017-11-29  9:43   ` [dpdk-dev] [PATCH v3 0/2] net/i40e: support input set configuration Beilei Xing
@ 2017-11-29  9:43     ` Beilei Xing
  2017-11-29  9:43     ` [dpdk-dev] [PATCH v3 2/2] app/testpmd: add configuration for input set Beilei Xing
  2017-12-07  6:00     ` [dpdk-dev] [PATCH v4 0/2] net/i40e: support input set configuration Beilei Xing
  2 siblings, 0 replies; 30+ messages in thread
From: Beilei Xing @ 2017-11-29  9:43 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, andrey.chilikin

This patch supports getting/setting input set info for
RSS/FDIR/FDIR flexible payload.
Also add some helper functions for input set configuration.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 +++
 3 files changed, 289 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index aeb92af..1f95f91 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -2985,3 +2985,144 @@ int rte_pmd_i40e_flow_add_del_packet_template(
 
 	return i40e_flow_add_del_fdir_filter(dev, &filter_conf, add);
 }
+
+int
+rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	memset(inset, 0, sizeof(struct rte_pmd_i40e_inset));
+
+	switch (inset_type) {
+	case INSET_HASH:
+		/* Get input set */
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, pctype));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, pctype));
+		/* Get field mask */
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(1, pctype));
+		break;
+	case INSET_FDIR:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 1));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 0));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(1, pctype));
+		break;
+	case INSET_FDIR_FLX:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_FLXINSET(pctype));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 0));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 1));
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	inset->inset = inset_reg;
+
+	for (i = 0; i < 2; i++) {
+		inset->mask[i].field_idx = ((mask_reg[i] >> 16) & 0x3F);
+		inset->mask[i].mask = mask_reg[i] & 0xFFFF;
+	}
+
+	return 0;
+}
+
+int
+rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* Clear mask first */
+	for (i = 0; i < 2; i++)
+		i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype), 0);
+
+	inset_reg = inset->inset;
+	for (i = 0; i < 2; i++)
+		mask_reg[i] = (inset->mask[i].field_idx << 16) |
+			inset->mask[i].mask;
+
+	switch (inset_type) {
+	case INSET_HASH:
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(0, pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(1, pctype),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_HASH_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 0),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 1),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR_FLX:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_FLXINSET(pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_PRTQF_FD_MSK(pctype, i),
+					     mask_reg[i]);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	I40E_WRITE_FLUSH(hw);
+	return 0;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 580ca4a..e987528 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -317,6 +317,23 @@ struct rte_pmd_i40e_pkt_template_conf {
 	uint32_t soft_id;
 };
 
+enum rte_pmd_i40e_inset_type {
+	INSET_NONE = 0,
+	INSET_HASH,
+	INSET_FDIR,
+	INSET_FDIR_FLX,
+};
+
+struct  rte_pmd_i40e_inset_mask {
+	uint8_t field_idx;
+	uint16_t mask;
+};
+
+struct rte_pmd_i40e_inset {
+	uint64_t inset;
+	struct rte_pmd_i40e_inset_mask mask[2];
+};
+
 /**
  * Add or remove raw packet template filter to Flow Director.
  *
@@ -933,4 +950,125 @@ int rte_pmd_i40e_query_vfid_by_mac(uint16_t port,
 int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
 			enum rte_pmd_i40e_queue_region_op op_type, void *arg);
 
+int rte_pmd_i40e_cfg_hash_inset(uint16_t port,
+				uint64_t pctype, uint64_t inset);
+
+/**
+ * Get input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Buffer for input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Set input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Get bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (1) if set.
+ *   - (0) if cleared.
+ */
+static inline int
+rte_pmd_i40e_inset_field_get(uint64_t inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return 0;
+
+	bit_idx = 63 - field_idx;
+	if (inset & (1ULL << bit_idx))
+		return 1;
+
+	return 0;
+}
+
+/**
+ * Set bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_set(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset | (1ULL << bit_idx);
+
+	return 0;
+}
+
+/**
+ * Clear bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_clear(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset & ~(1ULL << bit_idx);
+
+	return 0;
+}
+
 #endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index ebbd24e..82d5e2f 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -58,3 +58,13 @@ DPDK_17.11 {
 	rte_pmd_i40e_rss_queue_region_conf;
 
 } DPDK_17.08;
+
+DPDK_18.02 {
+	global:
+
+	rte_pmd_i40e_inset_get;
+	rte_pmd_i40e_inset_set;
+	rte_pmd_i40e_inset_field_get;
+	rte_pmd_i40e_inset_field_set;
+	rte_pmd_i40e_inset_field_clear;
+}
\ No newline at end of file
-- 
2.5.5

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

* [dpdk-dev] [PATCH v3 2/2] app/testpmd: add configuration for input set
  2017-11-29  9:43   ` [dpdk-dev] [PATCH v3 0/2] net/i40e: support input set configuration Beilei Xing
  2017-11-29  9:43     ` [dpdk-dev] [PATCH v3 1/2] " Beilei Xing
@ 2017-11-29  9:43     ` Beilei Xing
  2017-12-07  6:00     ` [dpdk-dev] [PATCH v4 0/2] net/i40e: support input set configuration Beilei Xing
  2 siblings, 0 replies; 30+ messages in thread
From: Beilei Xing @ 2017-11-29  9:43 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, andrey.chilikin

This patch adds command to configure input set for
RSS/flow director/flow director flexible payload.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 app/test-pmd/cmdline.c | 232 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 232 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f71d963..2057dd5 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -864,6 +864,15 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config (port_id) pctype mapping update"
 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
 			"    Update a flow type to pctype mapping item on a port\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset get|set|clear field\n"
+			" (field_idx)\n"
+			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset reset"
+			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
 		);
 	}
 
@@ -14652,6 +14661,227 @@ cmdline_parse_inst_t cmd_ddp_get_list = {
 	},
 };
 
+/* Configure input set */
+struct cmd_cfg_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t opt;
+	cmdline_fixed_string_t field;
+	uint8_t field_idx;
+};
+
+static void
+cmd_cfg_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_cfg_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+	int ret;
+#endif
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to get input set.\n");
+		return;
+	}
+
+	if (!strcmp(res->opt, "get")) {
+		ret = rte_pmd_i40e_inset_field_get(inset.inset,
+						   res->field_idx);
+		if (ret)
+			printf("Field index %d is set.\n", res->field_idx);
+		else
+			printf("Field index %d is not set.\n", res->field_idx);
+		return;
+	} else if (!strcmp(res->opt, "set"))
+		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
+						   res->field_idx);
+	else if (!strcmp(res->opt, "clear"))
+		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
+						     res->field_idx);
+	if (ret) {
+		printf("Failed to configure input set field.\n");
+		return;
+	}
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to set input set.\n");
+		return;
+	}
+
+#endif
+}
+
+cmdline_parse_token_string_t cmd_cfg_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_cfg_input_set_opt =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 opt, "get#set#clear");
+cmdline_parse_token_string_t cmd_cfg_input_set_field =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 field, "field");
+cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      field_idx, UINT8);
+
+cmdline_parse_inst_t cmd_cfg_input_set = {
+	.f = cmd_cfg_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
+	.tokens = {
+		(void *)&cmd_cfg_input_set_port,
+		(void *)&cmd_cfg_input_set_cfg,
+		(void *)&cmd_cfg_input_set_port_id,
+		(void *)&cmd_cfg_input_set_pctype,
+		(void *)&cmd_cfg_input_set_pctype_id,
+		(void *)&cmd_cfg_input_set_inset_type,
+		(void *)&cmd_cfg_input_set_opt,
+		(void *)&cmd_cfg_input_set_field,
+		(void *)&cmd_cfg_input_set_field_idx,
+		NULL,
+	},
+};
+
+/* Reset input set */
+struct cmd_reset_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t reset;
+};
+
+static void
+cmd_reset_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_reset_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+	int ret;
+#endif
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+
+	memset(&inset, 0, sizeof(inset));
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to set input set.\n");
+		return;
+	}
+
+#endif
+}
+
+cmdline_parse_token_string_t cmd_reset_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_reset_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_reset_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_reset_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_reset_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_reset_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_reset_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_reset_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_reset_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_reset_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_reset_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_reset_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_reset_input_set_reset =
+	TOKEN_STRING_INITIALIZER(struct cmd_reset_input_set_result,
+				 reset, "reset");
+
+cmdline_parse_inst_t cmd_reset_input_set = {
+	.f = cmd_reset_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset reset",
+	.tokens = {
+		(void *)&cmd_reset_input_set_port,
+		(void *)&cmd_reset_input_set_cfg,
+		(void *)&cmd_reset_input_set_port_id,
+		(void *)&cmd_reset_input_set_pctype,
+		(void *)&cmd_reset_input_set_pctype_id,
+		(void *)&cmd_reset_input_set_inset_type,
+		(void *)&cmd_reset_input_set_reset,
+		NULL,
+	},
+};
+
 /* show vf stats */
 
 /* Common result structure for show vf stats */
@@ -15737,6 +15967,8 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_ddp_del,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
+	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
+	(cmdline_parse_inst_t *)&cmd_reset_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
-- 
2.5.5

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

* [dpdk-dev] [PATCH v4 0/2] net/i40e: support input set configuration
  2017-11-29  9:43   ` [dpdk-dev] [PATCH v3 0/2] net/i40e: support input set configuration Beilei Xing
  2017-11-29  9:43     ` [dpdk-dev] [PATCH v3 1/2] " Beilei Xing
  2017-11-29  9:43     ` [dpdk-dev] [PATCH v3 2/2] app/testpmd: add configuration for input set Beilei Xing
@ 2017-12-07  6:00     ` Beilei Xing
  2017-12-07  6:00       ` [dpdk-dev] [PATCH v4 1/2] " Beilei Xing
                         ` (2 more replies)
  2 siblings, 3 replies; 30+ messages in thread
From: Beilei Xing @ 2017-12-07  6:00 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, andrey.chilikin

The patchset adds support RSS/FDIR/FDIR flexible payload input set
configuration for some pctype.

v4 changes:
 - Change testpmd command token and print info.

v3 changes:
 - Add support reset RSS/FDIR/FDIR flexible payload input set for some pctype.

v2 changes:
 - Use 'static inline' to replace 'inline'.
 - Add support get status for some filed index of input set.
  

Beilei Xing (2):
  net/i40e: support input set configuration
  app/testpmd: add configuration for input set

 app/test-pmd/cmdline.c                    | 237 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 ++
 4 files changed, 526 insertions(+)

-- 
2.5.5

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

* [dpdk-dev] [PATCH v4 1/2] net/i40e: support input set configuration
  2017-12-07  6:00     ` [dpdk-dev] [PATCH v4 0/2] net/i40e: support input set configuration Beilei Xing
@ 2017-12-07  6:00       ` Beilei Xing
  2017-12-07  6:00       ` [dpdk-dev] [PATCH v4 2/2] app/testpmd: add configuration for input set Beilei Xing
  2017-12-07  8:43       ` [dpdk-dev] [PATCH v5 0/2] net/i40e: support input set configuration Beilei Xing
  2 siblings, 0 replies; 30+ messages in thread
From: Beilei Xing @ 2017-12-07  6:00 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, andrey.chilikin

This patch supports getting/setting input set info for
RSS/FDIR/FDIR flexible payload.
Also add some helper functions for input set configuration.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 +++
 3 files changed, 289 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index aeb92af..1f95f91 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -2985,3 +2985,144 @@ int rte_pmd_i40e_flow_add_del_packet_template(
 
 	return i40e_flow_add_del_fdir_filter(dev, &filter_conf, add);
 }
+
+int
+rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	memset(inset, 0, sizeof(struct rte_pmd_i40e_inset));
+
+	switch (inset_type) {
+	case INSET_HASH:
+		/* Get input set */
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, pctype));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, pctype));
+		/* Get field mask */
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(1, pctype));
+		break;
+	case INSET_FDIR:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 1));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 0));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(1, pctype));
+		break;
+	case INSET_FDIR_FLX:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_FLXINSET(pctype));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 0));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 1));
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	inset->inset = inset_reg;
+
+	for (i = 0; i < 2; i++) {
+		inset->mask[i].field_idx = ((mask_reg[i] >> 16) & 0x3F);
+		inset->mask[i].mask = mask_reg[i] & 0xFFFF;
+	}
+
+	return 0;
+}
+
+int
+rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* Clear mask first */
+	for (i = 0; i < 2; i++)
+		i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype), 0);
+
+	inset_reg = inset->inset;
+	for (i = 0; i < 2; i++)
+		mask_reg[i] = (inset->mask[i].field_idx << 16) |
+			inset->mask[i].mask;
+
+	switch (inset_type) {
+	case INSET_HASH:
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(0, pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(1, pctype),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_HASH_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 0),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 1),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR_FLX:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_FLXINSET(pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_PRTQF_FD_MSK(pctype, i),
+					     mask_reg[i]);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	I40E_WRITE_FLUSH(hw);
+	return 0;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 580ca4a..e987528 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -317,6 +317,23 @@ struct rte_pmd_i40e_pkt_template_conf {
 	uint32_t soft_id;
 };
 
+enum rte_pmd_i40e_inset_type {
+	INSET_NONE = 0,
+	INSET_HASH,
+	INSET_FDIR,
+	INSET_FDIR_FLX,
+};
+
+struct  rte_pmd_i40e_inset_mask {
+	uint8_t field_idx;
+	uint16_t mask;
+};
+
+struct rte_pmd_i40e_inset {
+	uint64_t inset;
+	struct rte_pmd_i40e_inset_mask mask[2];
+};
+
 /**
  * Add or remove raw packet template filter to Flow Director.
  *
@@ -933,4 +950,125 @@ int rte_pmd_i40e_query_vfid_by_mac(uint16_t port,
 int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
 			enum rte_pmd_i40e_queue_region_op op_type, void *arg);
 
+int rte_pmd_i40e_cfg_hash_inset(uint16_t port,
+				uint64_t pctype, uint64_t inset);
+
+/**
+ * Get input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Buffer for input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Set input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Get bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (1) if set.
+ *   - (0) if cleared.
+ */
+static inline int
+rte_pmd_i40e_inset_field_get(uint64_t inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return 0;
+
+	bit_idx = 63 - field_idx;
+	if (inset & (1ULL << bit_idx))
+		return 1;
+
+	return 0;
+}
+
+/**
+ * Set bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_set(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset | (1ULL << bit_idx);
+
+	return 0;
+}
+
+/**
+ * Clear bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_clear(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset & ~(1ULL << bit_idx);
+
+	return 0;
+}
+
 #endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index ebbd24e..82d5e2f 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -58,3 +58,13 @@ DPDK_17.11 {
 	rte_pmd_i40e_rss_queue_region_conf;
 
 } DPDK_17.08;
+
+DPDK_18.02 {
+	global:
+
+	rte_pmd_i40e_inset_get;
+	rte_pmd_i40e_inset_set;
+	rte_pmd_i40e_inset_field_get;
+	rte_pmd_i40e_inset_field_set;
+	rte_pmd_i40e_inset_field_clear;
+}
\ No newline at end of file
-- 
2.5.5

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

* [dpdk-dev] [PATCH v4 2/2] app/testpmd: add configuration for input set
  2017-12-07  6:00     ` [dpdk-dev] [PATCH v4 0/2] net/i40e: support input set configuration Beilei Xing
  2017-12-07  6:00       ` [dpdk-dev] [PATCH v4 1/2] " Beilei Xing
@ 2017-12-07  6:00       ` Beilei Xing
  2017-12-07  8:43       ` [dpdk-dev] [PATCH v5 0/2] net/i40e: support input set configuration Beilei Xing
  2 siblings, 0 replies; 30+ messages in thread
From: Beilei Xing @ 2017-12-07  6:00 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, andrey.chilikin

This patch adds command to configure input set for
RSS/flow director/flow director flexible payload.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 app/test-pmd/cmdline.c | 237 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 237 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f71d963..79fdd0b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -864,6 +864,15 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config (port_id) pctype mapping update"
 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
 			"    Update a flow type to pctype mapping item on a port\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset get|set|clear field\n"
+			" (field_idx)\n"
+			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset clear all"
+			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
 		);
 	}
 
@@ -14652,6 +14661,232 @@ cmdline_parse_inst_t cmd_ddp_get_list = {
 	},
 };
 
+/* Configure input set */
+struct cmd_cfg_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t opt;
+	cmdline_fixed_string_t field;
+	uint8_t field_idx;
+};
+
+static void
+cmd_cfg_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_cfg_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+	int ret;
+#endif
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to get input set.\n");
+		return;
+	}
+
+	if (!strcmp(res->opt, "get")) {
+		ret = rte_pmd_i40e_inset_field_get(inset.inset,
+						   res->field_idx);
+		if (ret)
+			printf("Field index %d is enabled.\n", res->field_idx);
+		else
+			printf("Field index %d is disabled.\n", res->field_idx);
+		return;
+	} else if (!strcmp(res->opt, "set"))
+		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
+						   res->field_idx);
+	else if (!strcmp(res->opt, "clear"))
+		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
+						     res->field_idx);
+	if (ret) {
+		printf("Failed to configure input set field.\n");
+		return;
+	}
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to set input set.\n");
+		return;
+	}
+
+#endif
+}
+
+cmdline_parse_token_string_t cmd_cfg_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_cfg_input_set_opt =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 opt, "get#set#clear");
+cmdline_parse_token_string_t cmd_cfg_input_set_field =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 field, "field");
+cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      field_idx, UINT8);
+
+cmdline_parse_inst_t cmd_cfg_input_set = {
+	.f = cmd_cfg_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
+	.tokens = {
+		(void *)&cmd_cfg_input_set_port,
+		(void *)&cmd_cfg_input_set_cfg,
+		(void *)&cmd_cfg_input_set_port_id,
+		(void *)&cmd_cfg_input_set_pctype,
+		(void *)&cmd_cfg_input_set_pctype_id,
+		(void *)&cmd_cfg_input_set_inset_type,
+		(void *)&cmd_cfg_input_set_opt,
+		(void *)&cmd_cfg_input_set_field,
+		(void *)&cmd_cfg_input_set_field_idx,
+		NULL,
+	},
+};
+
+/* Clear input set */
+struct cmd_clear_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t clear;
+	cmdline_fixed_string_t all;
+};
+
+static void
+cmd_clear_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_clear_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+	int ret;
+#endif
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+
+	memset(&inset, 0, sizeof(inset));
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to clear input set.\n");
+		return;
+	}
+
+#endif
+}
+
+cmdline_parse_token_string_t cmd_clear_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_clear_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_clear_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_clear_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_clear_input_set_clear =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 clear, "clear");
+cmdline_parse_token_string_t cmd_clear_input_set_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 all, "all");
+
+cmdline_parse_inst_t cmd_clear_input_set = {
+	.f = cmd_clear_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset clear all",
+	.tokens = {
+		(void *)&cmd_clear_input_set_port,
+		(void *)&cmd_clear_input_set_cfg,
+		(void *)&cmd_clear_input_set_port_id,
+		(void *)&cmd_clear_input_set_pctype,
+		(void *)&cmd_clear_input_set_pctype_id,
+		(void *)&cmd_clear_input_set_inset_type,
+		(void *)&cmd_clear_input_set_clear,
+		(void *)&cmd_clear_input_set_all,
+		NULL,
+	},
+};
+
 /* show vf stats */
 
 /* Common result structure for show vf stats */
@@ -15737,6 +15972,8 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_ddp_del,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
+	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
+	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
-- 
2.5.5

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

* [dpdk-dev] [PATCH v5 0/2] net/i40e: support input set configuration
  2017-12-07  6:00     ` [dpdk-dev] [PATCH v4 0/2] net/i40e: support input set configuration Beilei Xing
  2017-12-07  6:00       ` [dpdk-dev] [PATCH v4 1/2] " Beilei Xing
  2017-12-07  6:00       ` [dpdk-dev] [PATCH v4 2/2] app/testpmd: add configuration for input set Beilei Xing
@ 2017-12-07  8:43       ` Beilei Xing
  2017-12-07  8:43         ` [dpdk-dev] [PATCH v5 1/2] " Beilei Xing
                           ` (2 more replies)
  2 siblings, 3 replies; 30+ messages in thread
From: Beilei Xing @ 2017-12-07  8:43 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

The patchset adds support RSS/FDIR/FDIR flexible payload input set
configuration for some pctype.

v5 changes:
 - Add DPDK version for new private API.

v4 changes:
 - Change testpmd command token and print info.

v3 changes:
 - Add support reset RSS/FDIR/FDIR flexible payload input set for some pctype.

v2 changes:
 - Use 'static inline' to replace 'inline'.
 - Add support get status for some filed index of input set.

Beilei Xing (2):
  net/i40e: support input set configuration
  app/testpmd: add configuration for input set

 app/test-pmd/cmdline.c                    | 237 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 ++
 4 files changed, 526 insertions(+)

-- 
2.5.5

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

* [dpdk-dev] [PATCH v5 1/2] net/i40e: support input set configuration
  2017-12-07  8:43       ` [dpdk-dev] [PATCH v5 0/2] net/i40e: support input set configuration Beilei Xing
@ 2017-12-07  8:43         ` Beilei Xing
  2017-12-07  8:43         ` [dpdk-dev] [PATCH v5 2/2] app/testpmd: add configuration for input set Beilei Xing
  2017-12-08  7:51         ` [dpdk-dev] [PATCH v6 0/2] net/i40e: support input set configuration Beilei Xing
  2 siblings, 0 replies; 30+ messages in thread
From: Beilei Xing @ 2017-12-07  8:43 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

This patch supports getting/setting input set info for
RSS/FDIR/FDIR flexible payload.
Also add some helper functions for input set configuration.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 +++
 3 files changed, 289 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index aeb92af..1f95f91 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -2985,3 +2985,144 @@ int rte_pmd_i40e_flow_add_del_packet_template(
 
 	return i40e_flow_add_del_fdir_filter(dev, &filter_conf, add);
 }
+
+int
+rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	memset(inset, 0, sizeof(struct rte_pmd_i40e_inset));
+
+	switch (inset_type) {
+	case INSET_HASH:
+		/* Get input set */
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, pctype));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, pctype));
+		/* Get field mask */
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(1, pctype));
+		break;
+	case INSET_FDIR:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 1));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 0));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(1, pctype));
+		break;
+	case INSET_FDIR_FLX:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_FLXINSET(pctype));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 0));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 1));
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	inset->inset = inset_reg;
+
+	for (i = 0; i < 2; i++) {
+		inset->mask[i].field_idx = ((mask_reg[i] >> 16) & 0x3F);
+		inset->mask[i].mask = mask_reg[i] & 0xFFFF;
+	}
+
+	return 0;
+}
+
+int
+rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* Clear mask first */
+	for (i = 0; i < 2; i++)
+		i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype), 0);
+
+	inset_reg = inset->inset;
+	for (i = 0; i < 2; i++)
+		mask_reg[i] = (inset->mask[i].field_idx << 16) |
+			inset->mask[i].mask;
+
+	switch (inset_type) {
+	case INSET_HASH:
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(0, pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(1, pctype),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_HASH_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 0),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 1),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR_FLX:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_FLXINSET(pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_PRTQF_FD_MSK(pctype, i),
+					     mask_reg[i]);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	I40E_WRITE_FLUSH(hw);
+	return 0;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 580ca4a..e987528 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -317,6 +317,23 @@ struct rte_pmd_i40e_pkt_template_conf {
 	uint32_t soft_id;
 };
 
+enum rte_pmd_i40e_inset_type {
+	INSET_NONE = 0,
+	INSET_HASH,
+	INSET_FDIR,
+	INSET_FDIR_FLX,
+};
+
+struct  rte_pmd_i40e_inset_mask {
+	uint8_t field_idx;
+	uint16_t mask;
+};
+
+struct rte_pmd_i40e_inset {
+	uint64_t inset;
+	struct rte_pmd_i40e_inset_mask mask[2];
+};
+
 /**
  * Add or remove raw packet template filter to Flow Director.
  *
@@ -933,4 +950,125 @@ int rte_pmd_i40e_query_vfid_by_mac(uint16_t port,
 int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
 			enum rte_pmd_i40e_queue_region_op op_type, void *arg);
 
+int rte_pmd_i40e_cfg_hash_inset(uint16_t port,
+				uint64_t pctype, uint64_t inset);
+
+/**
+ * Get input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Buffer for input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Set input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Get bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (1) if set.
+ *   - (0) if cleared.
+ */
+static inline int
+rte_pmd_i40e_inset_field_get(uint64_t inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return 0;
+
+	bit_idx = 63 - field_idx;
+	if (inset & (1ULL << bit_idx))
+		return 1;
+
+	return 0;
+}
+
+/**
+ * Set bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_set(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset | (1ULL << bit_idx);
+
+	return 0;
+}
+
+/**
+ * Clear bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_clear(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset & ~(1ULL << bit_idx);
+
+	return 0;
+}
+
 #endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index ebbd24e..d173b51 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -58,3 +58,13 @@ DPDK_17.11 {
 	rte_pmd_i40e_rss_queue_region_conf;
 
 } DPDK_17.08;
+
+DPDK_18.02 {
+	global:
+
+	rte_pmd_i40e_inset_get;
+	rte_pmd_i40e_inset_set;
+	rte_pmd_i40e_inset_field_get;
+	rte_pmd_i40e_inset_field_set;
+	rte_pmd_i40e_inset_field_clear;
+} DPDK_18.02;
\ No newline at end of file
-- 
2.5.5

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

* [dpdk-dev] [PATCH v5 2/2] app/testpmd: add configuration for input set
  2017-12-07  8:43       ` [dpdk-dev] [PATCH v5 0/2] net/i40e: support input set configuration Beilei Xing
  2017-12-07  8:43         ` [dpdk-dev] [PATCH v5 1/2] " Beilei Xing
@ 2017-12-07  8:43         ` Beilei Xing
  2017-12-08  7:51         ` [dpdk-dev] [PATCH v6 0/2] net/i40e: support input set configuration Beilei Xing
  2 siblings, 0 replies; 30+ messages in thread
From: Beilei Xing @ 2017-12-07  8:43 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

This patch adds command to configure input set for
RSS/flow director/flow director flexible payload.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 app/test-pmd/cmdline.c | 237 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 237 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f71d963..79fdd0b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -864,6 +864,15 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config (port_id) pctype mapping update"
 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
 			"    Update a flow type to pctype mapping item on a port\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset get|set|clear field\n"
+			" (field_idx)\n"
+			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset clear all"
+			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
 		);
 	}
 
@@ -14652,6 +14661,232 @@ cmdline_parse_inst_t cmd_ddp_get_list = {
 	},
 };
 
+/* Configure input set */
+struct cmd_cfg_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t opt;
+	cmdline_fixed_string_t field;
+	uint8_t field_idx;
+};
+
+static void
+cmd_cfg_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_cfg_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+	int ret;
+#endif
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to get input set.\n");
+		return;
+	}
+
+	if (!strcmp(res->opt, "get")) {
+		ret = rte_pmd_i40e_inset_field_get(inset.inset,
+						   res->field_idx);
+		if (ret)
+			printf("Field index %d is enabled.\n", res->field_idx);
+		else
+			printf("Field index %d is disabled.\n", res->field_idx);
+		return;
+	} else if (!strcmp(res->opt, "set"))
+		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
+						   res->field_idx);
+	else if (!strcmp(res->opt, "clear"))
+		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
+						     res->field_idx);
+	if (ret) {
+		printf("Failed to configure input set field.\n");
+		return;
+	}
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to set input set.\n");
+		return;
+	}
+
+#endif
+}
+
+cmdline_parse_token_string_t cmd_cfg_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_cfg_input_set_opt =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 opt, "get#set#clear");
+cmdline_parse_token_string_t cmd_cfg_input_set_field =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 field, "field");
+cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      field_idx, UINT8);
+
+cmdline_parse_inst_t cmd_cfg_input_set = {
+	.f = cmd_cfg_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
+	.tokens = {
+		(void *)&cmd_cfg_input_set_port,
+		(void *)&cmd_cfg_input_set_cfg,
+		(void *)&cmd_cfg_input_set_port_id,
+		(void *)&cmd_cfg_input_set_pctype,
+		(void *)&cmd_cfg_input_set_pctype_id,
+		(void *)&cmd_cfg_input_set_inset_type,
+		(void *)&cmd_cfg_input_set_opt,
+		(void *)&cmd_cfg_input_set_field,
+		(void *)&cmd_cfg_input_set_field_idx,
+		NULL,
+	},
+};
+
+/* Clear input set */
+struct cmd_clear_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t clear;
+	cmdline_fixed_string_t all;
+};
+
+static void
+cmd_clear_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_clear_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+	int ret;
+#endif
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+
+	memset(&inset, 0, sizeof(inset));
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to clear input set.\n");
+		return;
+	}
+
+#endif
+}
+
+cmdline_parse_token_string_t cmd_clear_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_clear_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_clear_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_clear_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_clear_input_set_clear =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 clear, "clear");
+cmdline_parse_token_string_t cmd_clear_input_set_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 all, "all");
+
+cmdline_parse_inst_t cmd_clear_input_set = {
+	.f = cmd_clear_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset clear all",
+	.tokens = {
+		(void *)&cmd_clear_input_set_port,
+		(void *)&cmd_clear_input_set_cfg,
+		(void *)&cmd_clear_input_set_port_id,
+		(void *)&cmd_clear_input_set_pctype,
+		(void *)&cmd_clear_input_set_pctype_id,
+		(void *)&cmd_clear_input_set_inset_type,
+		(void *)&cmd_clear_input_set_clear,
+		(void *)&cmd_clear_input_set_all,
+		NULL,
+	},
+};
+
 /* show vf stats */
 
 /* Common result structure for show vf stats */
@@ -15737,6 +15972,8 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_ddp_del,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
+	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
+	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
-- 
2.5.5

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

* [dpdk-dev] [PATCH v6 0/2] net/i40e: support input set configuration
  2017-12-07  8:43       ` [dpdk-dev] [PATCH v5 0/2] net/i40e: support input set configuration Beilei Xing
  2017-12-07  8:43         ` [dpdk-dev] [PATCH v5 1/2] " Beilei Xing
  2017-12-07  8:43         ` [dpdk-dev] [PATCH v5 2/2] app/testpmd: add configuration for input set Beilei Xing
@ 2017-12-08  7:51         ` Beilei Xing
  2017-12-08  7:51           ` [dpdk-dev] [PATCH v6 1/2] " Beilei Xing
                             ` (2 more replies)
  2 siblings, 3 replies; 30+ messages in thread
From: Beilei Xing @ 2017-12-08  7:51 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

The patchset adds support RSS/FDIR/FDIR flexible payload input set
configuration for some pctype.

v6 changes:
 - Fix DPDK version for new private API.

v5 changes:
 - Add DPDK version for new private API.

v4 changes:
 - Change testpmd command token and print info.

v3 changes:
 - Add support reset RSS/FDIR/FDIR flexible payload input set for some pctype.

v2 changes:
 - Use 'static inline' to replace 'inline'.
 - Add support get status for some filed index of input set.

Beilei Xing (2):
  net/i40e: support input set configuration
  app/testpmd: add configuration for input set

 app/test-pmd/cmdline.c                    | 237 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 ++
 4 files changed, 526 insertions(+)

-- 
2.5.5

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

* [dpdk-dev] [PATCH v6 1/2] net/i40e: support input set configuration
  2017-12-08  7:51         ` [dpdk-dev] [PATCH v6 0/2] net/i40e: support input set configuration Beilei Xing
@ 2017-12-08  7:51           ` Beilei Xing
  2018-01-02 12:48             ` Zhang, Qi Z
  2017-12-08  7:51           ` [dpdk-dev] [PATCH v6 2/2] app/testpmd: add configuration for input set Beilei Xing
  2018-01-05  3:03           ` [dpdk-dev] [PATCH v7 0/2] support input set configuration Beilei Xing
  2 siblings, 1 reply; 30+ messages in thread
From: Beilei Xing @ 2017-12-08  7:51 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

This patch supports getting/setting input set info for
RSS/FDIR/FDIR flexible payload.
Also add some helper functions for input set configuration.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 +++
 3 files changed, 289 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index aeb92af..1f95f91 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -2985,3 +2985,144 @@ int rte_pmd_i40e_flow_add_del_packet_template(
 
 	return i40e_flow_add_del_fdir_filter(dev, &filter_conf, add);
 }
+
+int
+rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	memset(inset, 0, sizeof(struct rte_pmd_i40e_inset));
+
+	switch (inset_type) {
+	case INSET_HASH:
+		/* Get input set */
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, pctype));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, pctype));
+		/* Get field mask */
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(1, pctype));
+		break;
+	case INSET_FDIR:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 1));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 0));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(1, pctype));
+		break;
+	case INSET_FDIR_FLX:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_FLXINSET(pctype));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 0));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 1));
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	inset->inset = inset_reg;
+
+	for (i = 0; i < 2; i++) {
+		inset->mask[i].field_idx = ((mask_reg[i] >> 16) & 0x3F);
+		inset->mask[i].mask = mask_reg[i] & 0xFFFF;
+	}
+
+	return 0;
+}
+
+int
+rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* Clear mask first */
+	for (i = 0; i < 2; i++)
+		i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype), 0);
+
+	inset_reg = inset->inset;
+	for (i = 0; i < 2; i++)
+		mask_reg[i] = (inset->mask[i].field_idx << 16) |
+			inset->mask[i].mask;
+
+	switch (inset_type) {
+	case INSET_HASH:
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(0, pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(1, pctype),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_HASH_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 0),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 1),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR_FLX:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_FLXINSET(pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_PRTQF_FD_MSK(pctype, i),
+					     mask_reg[i]);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	I40E_WRITE_FLUSH(hw);
+	return 0;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 580ca4a..e987528 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -317,6 +317,23 @@ struct rte_pmd_i40e_pkt_template_conf {
 	uint32_t soft_id;
 };
 
+enum rte_pmd_i40e_inset_type {
+	INSET_NONE = 0,
+	INSET_HASH,
+	INSET_FDIR,
+	INSET_FDIR_FLX,
+};
+
+struct  rte_pmd_i40e_inset_mask {
+	uint8_t field_idx;
+	uint16_t mask;
+};
+
+struct rte_pmd_i40e_inset {
+	uint64_t inset;
+	struct rte_pmd_i40e_inset_mask mask[2];
+};
+
 /**
  * Add or remove raw packet template filter to Flow Director.
  *
@@ -933,4 +950,125 @@ int rte_pmd_i40e_query_vfid_by_mac(uint16_t port,
 int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
 			enum rte_pmd_i40e_queue_region_op op_type, void *arg);
 
+int rte_pmd_i40e_cfg_hash_inset(uint16_t port,
+				uint64_t pctype, uint64_t inset);
+
+/**
+ * Get input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Buffer for input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Set input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Get bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (1) if set.
+ *   - (0) if cleared.
+ */
+static inline int
+rte_pmd_i40e_inset_field_get(uint64_t inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return 0;
+
+	bit_idx = 63 - field_idx;
+	if (inset & (1ULL << bit_idx))
+		return 1;
+
+	return 0;
+}
+
+/**
+ * Set bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_set(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset | (1ULL << bit_idx);
+
+	return 0;
+}
+
+/**
+ * Clear bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_clear(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset & ~(1ULL << bit_idx);
+
+	return 0;
+}
+
 #endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index ebbd24e..0fafadd 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -58,3 +58,13 @@ DPDK_17.11 {
 	rte_pmd_i40e_rss_queue_region_conf;
 
 } DPDK_17.08;
+
+DPDK_18.02 {
+	global:
+
+	rte_pmd_i40e_inset_get;
+	rte_pmd_i40e_inset_set;
+	rte_pmd_i40e_inset_field_get;
+	rte_pmd_i40e_inset_field_set;
+	rte_pmd_i40e_inset_field_clear;
+} DPDK_17.11;
\ No newline at end of file
-- 
2.5.5

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

* [dpdk-dev] [PATCH v6 2/2] app/testpmd: add configuration for input set
  2017-12-08  7:51         ` [dpdk-dev] [PATCH v6 0/2] net/i40e: support input set configuration Beilei Xing
  2017-12-08  7:51           ` [dpdk-dev] [PATCH v6 1/2] " Beilei Xing
@ 2017-12-08  7:51           ` Beilei Xing
  2018-01-04  6:51             ` Lu, Wenzhuo
  2018-01-05  3:03           ` [dpdk-dev] [PATCH v7 0/2] support input set configuration Beilei Xing
  2 siblings, 1 reply; 30+ messages in thread
From: Beilei Xing @ 2017-12-08  7:51 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

This patch adds command to configure input set for
RSS/flow director/flow director flexible payload.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 app/test-pmd/cmdline.c | 237 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 237 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f71d963..79fdd0b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -864,6 +864,15 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config (port_id) pctype mapping update"
 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
 			"    Update a flow type to pctype mapping item on a port\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset get|set|clear field\n"
+			" (field_idx)\n"
+			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset clear all"
+			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
 		);
 	}
 
@@ -14652,6 +14661,232 @@ cmdline_parse_inst_t cmd_ddp_get_list = {
 	},
 };
 
+/* Configure input set */
+struct cmd_cfg_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t opt;
+	cmdline_fixed_string_t field;
+	uint8_t field_idx;
+};
+
+static void
+cmd_cfg_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_cfg_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+	int ret;
+#endif
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to get input set.\n");
+		return;
+	}
+
+	if (!strcmp(res->opt, "get")) {
+		ret = rte_pmd_i40e_inset_field_get(inset.inset,
+						   res->field_idx);
+		if (ret)
+			printf("Field index %d is enabled.\n", res->field_idx);
+		else
+			printf("Field index %d is disabled.\n", res->field_idx);
+		return;
+	} else if (!strcmp(res->opt, "set"))
+		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
+						   res->field_idx);
+	else if (!strcmp(res->opt, "clear"))
+		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
+						     res->field_idx);
+	if (ret) {
+		printf("Failed to configure input set field.\n");
+		return;
+	}
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to set input set.\n");
+		return;
+	}
+
+#endif
+}
+
+cmdline_parse_token_string_t cmd_cfg_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_cfg_input_set_opt =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 opt, "get#set#clear");
+cmdline_parse_token_string_t cmd_cfg_input_set_field =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 field, "field");
+cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      field_idx, UINT8);
+
+cmdline_parse_inst_t cmd_cfg_input_set = {
+	.f = cmd_cfg_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
+	.tokens = {
+		(void *)&cmd_cfg_input_set_port,
+		(void *)&cmd_cfg_input_set_cfg,
+		(void *)&cmd_cfg_input_set_port_id,
+		(void *)&cmd_cfg_input_set_pctype,
+		(void *)&cmd_cfg_input_set_pctype_id,
+		(void *)&cmd_cfg_input_set_inset_type,
+		(void *)&cmd_cfg_input_set_opt,
+		(void *)&cmd_cfg_input_set_field,
+		(void *)&cmd_cfg_input_set_field_idx,
+		NULL,
+	},
+};
+
+/* Clear input set */
+struct cmd_clear_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t clear;
+	cmdline_fixed_string_t all;
+};
+
+static void
+cmd_clear_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_clear_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+	int ret;
+#endif
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+
+	memset(&inset, 0, sizeof(inset));
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to clear input set.\n");
+		return;
+	}
+
+#endif
+}
+
+cmdline_parse_token_string_t cmd_clear_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_clear_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_clear_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_clear_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_clear_input_set_clear =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 clear, "clear");
+cmdline_parse_token_string_t cmd_clear_input_set_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 all, "all");
+
+cmdline_parse_inst_t cmd_clear_input_set = {
+	.f = cmd_clear_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset clear all",
+	.tokens = {
+		(void *)&cmd_clear_input_set_port,
+		(void *)&cmd_clear_input_set_cfg,
+		(void *)&cmd_clear_input_set_port_id,
+		(void *)&cmd_clear_input_set_pctype,
+		(void *)&cmd_clear_input_set_pctype_id,
+		(void *)&cmd_clear_input_set_inset_type,
+		(void *)&cmd_clear_input_set_clear,
+		(void *)&cmd_clear_input_set_all,
+		NULL,
+	},
+};
+
 /* show vf stats */
 
 /* Common result structure for show vf stats */
@@ -15737,6 +15972,8 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_ddp_del,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
+	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
+	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
-- 
2.5.5

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

* Re: [dpdk-dev] [PATCH v6 1/2] net/i40e: support input set configuration
  2017-12-08  7:51           ` [dpdk-dev] [PATCH v6 1/2] " Beilei Xing
@ 2018-01-02 12:48             ` Zhang, Qi Z
  0 siblings, 0 replies; 30+ messages in thread
From: Zhang, Qi Z @ 2018-01-02 12:48 UTC (permalink / raw)
  To: Xing, Beilei, Wu, Jingjing, Lu, Wenzhuo; +Cc: dev, Chilikin, Andrey



> -----Original Message-----
> From: Xing, Beilei
> Sent: Friday, December 8, 2017 3:52 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; Chilikin, Andrey <andrey.chilikin@intel.com>
> Subject: [PATCH v6 1/2] net/i40e: support input set configuration
> 
> This patch supports getting/setting input set info for RSS/FDIR/FDIR flexible
> payload.
> Also add some helper functions for input set configuration.
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> ---
>  drivers/net/i40e/rte_pmd_i40e.c           | 141
> ++++++++++++++++++++++++++++++
>  drivers/net/i40e/rte_pmd_i40e.h           | 138
> +++++++++++++++++++++++++++++
>  drivers/net/i40e/rte_pmd_i40e_version.map |  10 +++
>  3 files changed, 289 insertions(+)
> 
> diff --git a/drivers/net/i40e/rte_pmd_i40e.c
> b/drivers/net/i40e/rte_pmd_i40e.c index aeb92af..1f95f91 100644
> --- a/drivers/net/i40e/rte_pmd_i40e.c
> +++ b/drivers/net/i40e/rte_pmd_i40e.c
> @@ -2985,3 +2985,144 @@ int
> rte_pmd_i40e_flow_add_del_packet_template(
> 
>  	return i40e_flow_add_del_fdir_filter(dev, &filter_conf, add);  }
> +
> +int
> +rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
> +		       struct rte_pmd_i40e_inset *inset,
> +		       enum rte_pmd_i40e_inset_type inset_type) {
> +	struct rte_eth_dev *dev;
> +	struct i40e_hw *hw;
> +	uint64_t inset_reg;
> +	uint32_t mask_reg[2];
> +	int i;
> +
> +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
> +
> +	dev = &rte_eth_devices[port];
> +
> +	if (!is_i40e_supported(dev))
> +		return -ENOTSUP;
> +
> +	if (pctype > 63)
> +		return -EINVAL;
> +
> +	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	memset(inset, 0, sizeof(struct rte_pmd_i40e_inset));
> +
> +	switch (inset_type) {
> +	case INSET_HASH:
> +		/* Get input set */
> +		inset_reg =
> +			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, pctype));
> +		inset_reg <<= I40E_32_BIT_WIDTH;
> +		inset_reg |=
> +			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, pctype));
> +		/* Get field mask */
> +		mask_reg[0] =
> +			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(0, pctype));
> +		mask_reg[1] =
> +			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(1, pctype));
> +		break;
> +	case INSET_FDIR:
> +		inset_reg =
> +			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 1));
> +		inset_reg <<= I40E_32_BIT_WIDTH;
> +		inset_reg |=
> +			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 0));
> +		mask_reg[0] =
> +			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(0, pctype));
> +		mask_reg[1] =
> +			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(1, pctype));
> +		break;
> +	case INSET_FDIR_FLX:
> +		inset_reg =
> +			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_FLXINSET(pctype));
> +		mask_reg[0] =
> +			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 0));
> +		mask_reg[1] =
> +			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 1));
> +		break;
> +	default:
> +		PMD_DRV_LOG(ERR, "Unsupported input set type.");
> +		return -EINVAL;
> +	}
> +
> +	inset->inset = inset_reg;
> +
> +	for (i = 0; i < 2; i++) {
> +		inset->mask[i].field_idx = ((mask_reg[i] >> 16) & 0x3F);
> +		inset->mask[i].mask = mask_reg[i] & 0xFFFF;
> +	}
> +
> +	return 0;
> +}
> +
> +int
> +rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
> +		       struct rte_pmd_i40e_inset *inset,
> +		       enum rte_pmd_i40e_inset_type inset_type) {
> +	struct rte_eth_dev *dev;
> +	struct i40e_hw *hw;
> +	uint64_t inset_reg;
> +	uint32_t mask_reg[2];
> +	int i;
> +
> +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
> +
> +	dev = &rte_eth_devices[port];
> +
> +	if (!is_i40e_supported(dev))
> +		return -ENOTSUP;
> +
> +	if (pctype > 63)
> +		return -EINVAL;
> +
> +	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +
> +	/* Clear mask first */
> +	for (i = 0; i < 2; i++)
> +		i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype), 0);
> +
> +	inset_reg = inset->inset;
> +	for (i = 0; i < 2; i++)
> +		mask_reg[i] = (inset->mask[i].field_idx << 16) |
> +			inset->mask[i].mask;
> +
> +	switch (inset_type) {
> +	case INSET_HASH:
> +		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(0, pctype),
> +				     (uint32_t)(inset_reg & UINT32_MAX));
> +		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(1, pctype),
> +				     (uint32_t)((inset_reg >>
> +					      I40E_32_BIT_WIDTH) & UINT32_MAX));
> +		for (i = 0; i < 2; i++)
> +			i40e_check_write_reg(hw, I40E_GLQF_HASH_MSK(i, pctype),
> +					     mask_reg[i]);
> +		break;
> +	case INSET_FDIR:
> +		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 0),
> +				     (uint32_t)(inset_reg & UINT32_MAX));
> +		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 1),
> +				     (uint32_t)((inset_reg >>
> +					      I40E_32_BIT_WIDTH) & UINT32_MAX));
> +		for (i = 0; i < 2; i++)
> +			i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype),
> +					     mask_reg[i]);
> +		break;
> +	case INSET_FDIR_FLX:
> +		i40e_check_write_reg(hw, I40E_PRTQF_FD_FLXINSET(pctype),
> +				     (uint32_t)(inset_reg & UINT32_MAX));
> +		for (i = 0; i < 2; i++)
> +			i40e_check_write_reg(hw, I40E_PRTQF_FD_MSK(pctype, i),
> +					     mask_reg[i]);
> +		break;
> +	default:
> +		PMD_DRV_LOG(ERR, "Unsupported input set type.");
> +		return -EINVAL;
> +	}
> +
> +	I40E_WRITE_FLUSH(hw);
> +	return 0;
> +}
> diff --git a/drivers/net/i40e/rte_pmd_i40e.h
> b/drivers/net/i40e/rte_pmd_i40e.h index 580ca4a..e987528 100644
> --- a/drivers/net/i40e/rte_pmd_i40e.h
> +++ b/drivers/net/i40e/rte_pmd_i40e.h
> @@ -317,6 +317,23 @@ struct rte_pmd_i40e_pkt_template_conf {
>  	uint32_t soft_id;
>  };
> 
> +enum rte_pmd_i40e_inset_type {
> +	INSET_NONE = 0,
> +	INSET_HASH,
> +	INSET_FDIR,
> +	INSET_FDIR_FLX,
> +};
> +
> +struct  rte_pmd_i40e_inset_mask {
> +	uint8_t field_idx;
> +	uint16_t mask;
> +};
> +
> +struct rte_pmd_i40e_inset {
> +	uint64_t inset;
> +	struct rte_pmd_i40e_inset_mask mask[2]; };
> +
>  /**
>   * Add or remove raw packet template filter to Flow Director.
>   *
> @@ -933,4 +950,125 @@ int rte_pmd_i40e_query_vfid_by_mac(uint16_t
> port,  int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
>  			enum rte_pmd_i40e_queue_region_op op_type, void *arg);
> 
> +int rte_pmd_i40e_cfg_hash_inset(uint16_t port,
> +				uint64_t pctype, uint64_t inset);
> +
> +/**
> + * Get input set
> + *
> + * @param port
> + *    The port identifier of the Ethernet device.
> + * @param pctype
> + *    HW pctype.
> + * @param inset
> + *    Buffer for input set info.
> + * @param inset_type
> + *    Type of input set.
> + * @return
> + *   - (0) if successful.
> + *   - (-ENODEV) if *port* invalid.
> + *   - (-EINVAL) if bad parameter.
> + *   - (-ENOTSUP) if operation not supported.
> + */
> +int rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
> +			   struct rte_pmd_i40e_inset *inset,
> +			   enum rte_pmd_i40e_inset_type inset_type);
> +
> +/**
> + * Set input set
> + *
> + * @param port
> + *    The port identifier of the Ethernet device.
> + * @param pctype
> + *    HW pctype.
> + * @param inset
> + *    Input set info.
> + * @param inset_type
> + *    Type of input set.
> + * @return
> + *   - (0) if successful.
> + *   - (-ENODEV) if *port* invalid.
> + *   - (-EINVAL) if bad parameter.
> + *   - (-ENOTSUP) if operation not supported.
> + */
> +int rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
> +			   struct rte_pmd_i40e_inset *inset,
> +			   enum rte_pmd_i40e_inset_type inset_type);
> +
> +/**
> + * Get bit value for some field index
> + *
> + * @param inset
> + *    Input set value.
> + * @param field_idx
> + *    Field index for input set.
> + * @return
> + *   - (1) if set.
> + *   - (0) if cleared.
> + */
> +static inline int
> +rte_pmd_i40e_inset_field_get(uint64_t inset, uint8_t field_idx) {
> +	uint8_t bit_idx;
> +
> +	if (field_idx > 63)
> +		return 0;
> +
> +	bit_idx = 63 - field_idx;
> +	if (inset & (1ULL << bit_idx))
> +		return 1;
> +
> +	return 0;
> +}
> +
> +/**
> + * Set bit value for some field index
> + *
> + * @param inset
> + *    Input set value.
> + * @param field_idx
> + *    Field index for input set.
> + * @return
> + *   - (-1) if failed.
> + *   - (0) if success.
> + */
> +static inline int
> +rte_pmd_i40e_inset_field_set(uint64_t *inset, uint8_t field_idx) {
> +	uint8_t bit_idx;
> +
> +	if (field_idx > 63)
> +		return -1;
> +
> +	bit_idx = 63 - field_idx;
> +	*inset = *inset | (1ULL << bit_idx);
> +
> +	return 0;
> +}
> +
> +/**
> + * Clear bit value for some field index
> + *
> + * @param inset
> + *    Input set value.
> + * @param field_idx
> + *    Field index for input set.
> + * @return
> + *   - (-1) if failed.
> + *   - (0) if success.
> + */
> +static inline int
> +rte_pmd_i40e_inset_field_clear(uint64_t *inset, uint8_t field_idx) {
> +	uint8_t bit_idx;
> +
> +	if (field_idx > 63)
> +		return -1;
> +
> +	bit_idx = 63 - field_idx;
> +	*inset = *inset & ~(1ULL << bit_idx);
> +
> +	return 0;
> +}
> +
>  #endif /* _PMD_I40E_H_ */
> diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map
> b/drivers/net/i40e/rte_pmd_i40e_version.map
> index ebbd24e..0fafadd 100644
> --- a/drivers/net/i40e/rte_pmd_i40e_version.map
> +++ b/drivers/net/i40e/rte_pmd_i40e_version.map
> @@ -58,3 +58,13 @@ DPDK_17.11 {
>  	rte_pmd_i40e_rss_queue_region_conf;
> 
>  } DPDK_17.08;
> +
> +DPDK_18.02 {
> +	global:
> +
> +	rte_pmd_i40e_inset_get;
> +	rte_pmd_i40e_inset_set;
> +	rte_pmd_i40e_inset_field_get;
> +	rte_pmd_i40e_inset_field_set;
> +	rte_pmd_i40e_inset_field_clear;
> +} DPDK_17.11;
> \ No newline at end of file
> --
> 2.5.5

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

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

* Re: [dpdk-dev] [PATCH v6 2/2] app/testpmd: add configuration for input set
  2017-12-08  7:51           ` [dpdk-dev] [PATCH v6 2/2] app/testpmd: add configuration for input set Beilei Xing
@ 2018-01-04  6:51             ` Lu, Wenzhuo
  0 siblings, 0 replies; 30+ messages in thread
From: Lu, Wenzhuo @ 2018-01-04  6:51 UTC (permalink / raw)
  To: Xing, Beilei, Wu, Jingjing, Zhang, Qi Z; +Cc: dev, Chilikin, Andrey

Hi Beilei

> -----Original Message-----
> From: Xing, Beilei
> Sent: Friday, December 8, 2017 3:52 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; Chilikin, Andrey <andrey.chilikin@intel.com>
> Subject: [PATCH v6 2/2] app/testpmd: add configuration for input set
> 
> This patch adds command to configure input set for RSS/flow director/flow
> director flexible payload.
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> ---
>  app/test-pmd/cmdline.c | 237
> +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 237 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> f71d963..79fdd0b 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c


> 
> @@ -14652,6 +14661,232 @@ cmdline_parse_inst_t cmd_ddp_get_list = {
>  	},
>  };
> 
> +/* Configure input set */
> +struct cmd_cfg_input_set_result {
> +	cmdline_fixed_string_t port;
> +	cmdline_fixed_string_t cfg;
> +	portid_t port_id;
> +	cmdline_fixed_string_t pctype;
> +	uint8_t pctype_id;
> +	cmdline_fixed_string_t inset_type;
> +	cmdline_fixed_string_t opt;
> +	cmdline_fixed_string_t field;
> +	uint8_t field_idx;
> +};
> +
> +static void
> +cmd_cfg_input_set_parsed(
> +	void *parsed_result,
> +	__attribute__((unused)) struct cmdline *cl,
> +	__attribute__((unused)) void *data)
> +{
> +	struct cmd_cfg_input_set_result *res = parsed_result; #ifdef
> +RTE_LIBRTE_I40E_PMD
> +	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
> +	struct rte_pmd_i40e_inset inset;
> +	int ret;
> +#endif
> +
> +	if (res->port_id > nb_ports) {
> +		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
> +		return;
> +	}
> +
> +	if (!all_ports_stopped()) {
> +		printf("Please stop all ports first\n");
> +		return;
> +	}
> +
> +#ifdef RTE_LIBRTE_I40E_PMD
I don't think it's good to comment all the code below.  Because if you run this CLI on a NIC which is not i40e, the CLI will fail silently. Please reference the existing code about how to use this macro.

> +	if (!strcmp(res->inset_type, "hash_inset"))
> +		inset_type = INSET_HASH;
> +	else if (!strcmp(res->inset_type, "fdir_inset"))
> +		inset_type = INSET_FDIR;
> +	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
> +		inset_type = INSET_FDIR_FLX;
> +	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
> +				     &inset, inset_type);
> +	if (ret) {
> +		printf("Failed to get input set.\n");
> +		return;
> +	}
> +
> +	if (!strcmp(res->opt, "get")) {
> +		ret = rte_pmd_i40e_inset_field_get(inset.inset,
> +						   res->field_idx);
> +		if (ret)
> +			printf("Field index %d is enabled.\n", res->field_idx);
> +		else
> +			printf("Field index %d is disabled.\n", res->field_idx);
> +		return;
> +	} else if (!strcmp(res->opt, "set"))
> +		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
> +						   res->field_idx);
> +	else if (!strcmp(res->opt, "clear"))
> +		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
> +						     res->field_idx);
> +	if (ret) {
> +		printf("Failed to configure input set field.\n");
> +		return;
> +	}
> +
> +	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
> +				     &inset, inset_type);
> +	if (ret) {
> +		printf("Failed to set input set.\n");
> +		return;
> +	}
> +
> +#endif


Another thing, please update the testpmd_funcs.rst for the new CLIs.

> --
> 2.5.5

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

* [dpdk-dev] [PATCH v7 0/2] support input set configuration
  2017-12-08  7:51         ` [dpdk-dev] [PATCH v6 0/2] net/i40e: support input set configuration Beilei Xing
  2017-12-08  7:51           ` [dpdk-dev] [PATCH v6 1/2] " Beilei Xing
  2017-12-08  7:51           ` [dpdk-dev] [PATCH v6 2/2] app/testpmd: add configuration for input set Beilei Xing
@ 2018-01-05  3:03           ` Beilei Xing
  2018-01-05  3:03             ` [dpdk-dev] [PATCH v7 1/2] net/i40e: " Beilei Xing
                               ` (2 more replies)
  2 siblings, 3 replies; 30+ messages in thread
From: Beilei Xing @ 2018-01-05  3:03 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

The patchset adds support RSS/FDIR/FDIR flexible payload
input set configuration for some pctype.

v7 changes:
 - Add info if NIC doesn't support the function.
 - Add doc in testpmd_funcs.rst for the new CLIs.

v6 changes:
 - Fix DPDK version for new private API.

v5 changes:
 - Add DPDK version for new private API.

v4 changes:
 - Change testpmd command token and print info.

v3 changes:
 - Add support reset RSS/FDIR/FDIR flexible payload input set for some pctype.

v2 changes:
 - Use 'static inline' to replace 'inline'.
 - Add support get status for some filed index of input set.
  

Beilei Xing (2):
  net/i40e: support input set configuration
  app/testpmd: add configuration for input set

 app/test-pmd/cmdline.c                      | 239 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 drivers/net/i40e/rte_pmd_i40e.c             | 141 ++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h             | 138 ++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map   |  10 ++
 5 files changed, 544 insertions(+)

-- 
2.5.5

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

* [dpdk-dev] [PATCH v7 1/2] net/i40e: support input set configuration
  2018-01-05  3:03           ` [dpdk-dev] [PATCH v7 0/2] support input set configuration Beilei Xing
@ 2018-01-05  3:03             ` Beilei Xing
  2018-01-05  3:03             ` [dpdk-dev] [PATCH v7 2/2] app/testpmd: add configuration for input set Beilei Xing
  2018-01-08  3:09             ` [dpdk-dev] [PATCH v8 0/2] support input set configuration Beilei Xing
  2 siblings, 0 replies; 30+ messages in thread
From: Beilei Xing @ 2018-01-05  3:03 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

This patch supports getting/setting input set info for
RSS/FDIR/FDIR flexible payload.
Also add some helper functions for input set configuration.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 +++
 3 files changed, 289 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index aeb92af..1f95f91 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -2985,3 +2985,144 @@ int rte_pmd_i40e_flow_add_del_packet_template(
 
 	return i40e_flow_add_del_fdir_filter(dev, &filter_conf, add);
 }
+
+int
+rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	memset(inset, 0, sizeof(struct rte_pmd_i40e_inset));
+
+	switch (inset_type) {
+	case INSET_HASH:
+		/* Get input set */
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, pctype));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, pctype));
+		/* Get field mask */
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(1, pctype));
+		break;
+	case INSET_FDIR:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 1));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 0));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(1, pctype));
+		break;
+	case INSET_FDIR_FLX:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_FLXINSET(pctype));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 0));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 1));
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	inset->inset = inset_reg;
+
+	for (i = 0; i < 2; i++) {
+		inset->mask[i].field_idx = ((mask_reg[i] >> 16) & 0x3F);
+		inset->mask[i].mask = mask_reg[i] & 0xFFFF;
+	}
+
+	return 0;
+}
+
+int
+rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* Clear mask first */
+	for (i = 0; i < 2; i++)
+		i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype), 0);
+
+	inset_reg = inset->inset;
+	for (i = 0; i < 2; i++)
+		mask_reg[i] = (inset->mask[i].field_idx << 16) |
+			inset->mask[i].mask;
+
+	switch (inset_type) {
+	case INSET_HASH:
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(0, pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(1, pctype),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_HASH_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 0),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 1),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR_FLX:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_FLXINSET(pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_PRTQF_FD_MSK(pctype, i),
+					     mask_reg[i]);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	I40E_WRITE_FLUSH(hw);
+	return 0;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 580ca4a..e987528 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -317,6 +317,23 @@ struct rte_pmd_i40e_pkt_template_conf {
 	uint32_t soft_id;
 };
 
+enum rte_pmd_i40e_inset_type {
+	INSET_NONE = 0,
+	INSET_HASH,
+	INSET_FDIR,
+	INSET_FDIR_FLX,
+};
+
+struct  rte_pmd_i40e_inset_mask {
+	uint8_t field_idx;
+	uint16_t mask;
+};
+
+struct rte_pmd_i40e_inset {
+	uint64_t inset;
+	struct rte_pmd_i40e_inset_mask mask[2];
+};
+
 /**
  * Add or remove raw packet template filter to Flow Director.
  *
@@ -933,4 +950,125 @@ int rte_pmd_i40e_query_vfid_by_mac(uint16_t port,
 int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
 			enum rte_pmd_i40e_queue_region_op op_type, void *arg);
 
+int rte_pmd_i40e_cfg_hash_inset(uint16_t port,
+				uint64_t pctype, uint64_t inset);
+
+/**
+ * Get input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Buffer for input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Set input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Get bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (1) if set.
+ *   - (0) if cleared.
+ */
+static inline int
+rte_pmd_i40e_inset_field_get(uint64_t inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return 0;
+
+	bit_idx = 63 - field_idx;
+	if (inset & (1ULL << bit_idx))
+		return 1;
+
+	return 0;
+}
+
+/**
+ * Set bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_set(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset | (1ULL << bit_idx);
+
+	return 0;
+}
+
+/**
+ * Clear bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_clear(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset & ~(1ULL << bit_idx);
+
+	return 0;
+}
+
 #endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index ebbd24e..0fafadd 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -58,3 +58,13 @@ DPDK_17.11 {
 	rte_pmd_i40e_rss_queue_region_conf;
 
 } DPDK_17.08;
+
+DPDK_18.02 {
+	global:
+
+	rte_pmd_i40e_inset_get;
+	rte_pmd_i40e_inset_set;
+	rte_pmd_i40e_inset_field_get;
+	rte_pmd_i40e_inset_field_set;
+	rte_pmd_i40e_inset_field_clear;
+} DPDK_17.11;
\ No newline at end of file
-- 
2.5.5

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

* [dpdk-dev] [PATCH v7 2/2] app/testpmd: add configuration for input set
  2018-01-05  3:03           ` [dpdk-dev] [PATCH v7 0/2] support input set configuration Beilei Xing
  2018-01-05  3:03             ` [dpdk-dev] [PATCH v7 1/2] net/i40e: " Beilei Xing
@ 2018-01-05  3:03             ` Beilei Xing
  2018-01-08  3:09             ` [dpdk-dev] [PATCH v8 0/2] support input set configuration Beilei Xing
  2 siblings, 0 replies; 30+ messages in thread
From: Beilei Xing @ 2018-01-05  3:03 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

This patch adds command to configure input set for
RSS/flow director/flow director flexible payload.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 app/test-pmd/cmdline.c                      | 239 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 2 files changed, 255 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f71d963..ddcc74b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -864,6 +864,15 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config (port_id) pctype mapping update"
 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
 			"    Update a flow type to pctype mapping item on a port\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset get|set|clear field\n"
+			" (field_idx)\n"
+			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset clear all"
+			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
 		);
 	}
 
@@ -14652,6 +14661,234 @@ cmdline_parse_inst_t cmd_ddp_get_list = {
 	},
 };
 
+/* Configure input set */
+struct cmd_cfg_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t opt;
+	cmdline_fixed_string_t field;
+	uint8_t field_idx;
+};
+
+static void
+cmd_cfg_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_cfg_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+#endif
+	int ret = -ENOTSUP;
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to get input set.\n");
+		return;
+	}
+
+	if (!strcmp(res->opt, "get")) {
+		ret = rte_pmd_i40e_inset_field_get(inset.inset,
+						   res->field_idx);
+		if (ret)
+			printf("Field index %d is enabled.\n", res->field_idx);
+		else
+			printf("Field index %d is disabled.\n", res->field_idx);
+		return;
+	} else if (!strcmp(res->opt, "set"))
+		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
+						   res->field_idx);
+	else if (!strcmp(res->opt, "clear"))
+		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
+						     res->field_idx);
+	if (ret) {
+		printf("Failed to configure input set field.\n");
+		return;
+	}
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to set input set.\n");
+		return;
+	}
+#endif
+
+	if (ret == -ENOTSUP)
+		printf("Function not supported\n");
+}
+
+cmdline_parse_token_string_t cmd_cfg_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_cfg_input_set_opt =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 opt, "get#set#clear");
+cmdline_parse_token_string_t cmd_cfg_input_set_field =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 field, "field");
+cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      field_idx, UINT8);
+
+cmdline_parse_inst_t cmd_cfg_input_set = {
+	.f = cmd_cfg_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
+	.tokens = {
+		(void *)&cmd_cfg_input_set_port,
+		(void *)&cmd_cfg_input_set_cfg,
+		(void *)&cmd_cfg_input_set_port_id,
+		(void *)&cmd_cfg_input_set_pctype,
+		(void *)&cmd_cfg_input_set_pctype_id,
+		(void *)&cmd_cfg_input_set_inset_type,
+		(void *)&cmd_cfg_input_set_opt,
+		(void *)&cmd_cfg_input_set_field,
+		(void *)&cmd_cfg_input_set_field_idx,
+		NULL,
+	},
+};
+
+/* Clear input set */
+struct cmd_clear_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t clear;
+	cmdline_fixed_string_t all;
+};
+
+static void
+cmd_clear_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_clear_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+	int ret;
+#endif
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+
+	memset(&inset, 0, sizeof(inset));
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to clear input set.\n");
+		return;
+	}
+
+#endif
+}
+
+cmdline_parse_token_string_t cmd_clear_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_clear_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_clear_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_clear_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_clear_input_set_clear =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 clear, "clear");
+cmdline_parse_token_string_t cmd_clear_input_set_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 all, "all");
+
+cmdline_parse_inst_t cmd_clear_input_set = {
+	.f = cmd_clear_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset clear all",
+	.tokens = {
+		(void *)&cmd_clear_input_set_port,
+		(void *)&cmd_clear_input_set_cfg,
+		(void *)&cmd_clear_input_set_port_id,
+		(void *)&cmd_clear_input_set_pctype,
+		(void *)&cmd_clear_input_set_pctype_id,
+		(void *)&cmd_clear_input_set_inset_type,
+		(void *)&cmd_clear_input_set_clear,
+		(void *)&cmd_clear_input_set_all,
+		NULL,
+	},
+};
+
 /* show vf stats */
 
 /* Common result structure for show vf stats */
@@ -15737,6 +15974,8 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_ddp_del,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
+	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
+	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 2b00be8..0da38fb 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1849,6 +1849,22 @@ where:
 
 * ``flow_type_id``: software flow type id as the index of the pctype mapping table.
 
+port config input set
+~~~~~~~~~~~~~~~~~~~~~
+
+Config RSS/FDIR/FDIR flexible payload input set for some pctype::
+   testpmd> port config (port_id) pctype (pctype_id) \
+            (hash_inset|fdir_inset|fdir_flx_inset) \
+	    (get|set|clear) field (field_idx)
+
+Clear RSS/FDIR/FDIR flexible payload input set for some pctype::
+   testpmd> port config (port_id) pctype (pctype_id) \
+            (hash_inset|fdir_inset|fdir_flx_inset) clear all
+
+where:
+
+* ``pctype_id``: hardware packet classification types.
+* ``field_idx``: hardware field index.
 
 Link Bonding Functions
 ----------------------
-- 
2.5.5

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

* [dpdk-dev] [PATCH v8 0/2] support input set configuration
  2018-01-05  3:03           ` [dpdk-dev] [PATCH v7 0/2] support input set configuration Beilei Xing
  2018-01-05  3:03             ` [dpdk-dev] [PATCH v7 1/2] net/i40e: " Beilei Xing
  2018-01-05  3:03             ` [dpdk-dev] [PATCH v7 2/2] app/testpmd: add configuration for input set Beilei Xing
@ 2018-01-08  3:09             ` Beilei Xing
  2018-01-08  3:09               ` [dpdk-dev] [PATCH v8 1/2] net/i40e: " Beilei Xing
                                 ` (2 more replies)
  2 siblings, 3 replies; 30+ messages in thread
From: Beilei Xing @ 2018-01-08  3:09 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

The patchset adds support RSS/FDIR/FDIR flexible payload input set configuration for some pctype.

v8 changes:
 - Add info if NIC doesn't support the function.

v7 changes:
 - Add info if NIC doesn't support the function.
 - Add doc in testpmd_funcs.rst for the new CLIs.

v6 changes:
 - Fix DPDK version for new private API.

v5 changes:
 - Add DPDK version for new private API.

v4 changes:
 - Change testpmd command token and print info.

v3 changes:
 - Add support reset RSS/FDIR/FDIR flexible payload input set for some pctype.

v2 changes:
 - Use 'static inline' to replace 'inline'.
 - Add support get status for some filed index of input set.

Beilei Xing (2):
  net/i40e: support input set configuration
  app/testpmd: add configuration for input set

 app/test-pmd/cmdline.c                      | 242 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 drivers/net/i40e/rte_pmd_i40e.c             | 141 ++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h             | 138 ++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map   |  10 ++
 5 files changed, 547 insertions(+)

-- 
2.5.5

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

* [dpdk-dev] [PATCH v8 1/2] net/i40e: support input set configuration
  2018-01-08  3:09             ` [dpdk-dev] [PATCH v8 0/2] support input set configuration Beilei Xing
@ 2018-01-08  3:09               ` Beilei Xing
  2018-01-10 12:12                 ` Ferruh Yigit
  2018-01-08  3:09               ` [dpdk-dev] [PATCH v8 2/2] app/testpmd: add configuration for input set Beilei Xing
  2018-01-09  7:44               ` [dpdk-dev] [PATCH v8 0/2] support input set configuration Zhang, Helin
  2 siblings, 1 reply; 30+ messages in thread
From: Beilei Xing @ 2018-01-08  3:09 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

This patch supports getting/setting input set info for
RSS/FDIR/FDIR flexible payload.
Also add some helper functions for input set configuration.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c           | 141 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 138 +++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  10 +++
 3 files changed, 289 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index aeb92af..1f95f91 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -2985,3 +2985,144 @@ int rte_pmd_i40e_flow_add_del_packet_template(
 
 	return i40e_flow_add_del_fdir_filter(dev, &filter_conf, add);
 }
+
+int
+rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	memset(inset, 0, sizeof(struct rte_pmd_i40e_inset));
+
+	switch (inset_type) {
+	case INSET_HASH:
+		/* Get input set */
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, pctype));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, pctype));
+		/* Get field mask */
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_HASH_MSK(1, pctype));
+		break;
+	case INSET_FDIR:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 1));
+		inset_reg <<= I40E_32_BIT_WIDTH;
+		inset_reg |=
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_INSET(pctype, 0));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(0, pctype));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_GLQF_FD_MSK(1, pctype));
+		break;
+	case INSET_FDIR_FLX:
+		inset_reg =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_FLXINSET(pctype));
+		mask_reg[0] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 0));
+		mask_reg[1] =
+			i40e_read_rx_ctl(hw, I40E_PRTQF_FD_MSK(pctype, 1));
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	inset->inset = inset_reg;
+
+	for (i = 0; i < 2; i++) {
+		inset->mask[i].field_idx = ((mask_reg[i] >> 16) & 0x3F);
+		inset->mask[i].mask = mask_reg[i] & 0xFFFF;
+	}
+
+	return 0;
+}
+
+int
+rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+		       struct rte_pmd_i40e_inset *inset,
+		       enum rte_pmd_i40e_inset_type inset_type)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_hw *hw;
+	uint64_t inset_reg;
+	uint32_t mask_reg[2];
+	int i;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	if (pctype > 63)
+		return -EINVAL;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* Clear mask first */
+	for (i = 0; i < 2; i++)
+		i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype), 0);
+
+	inset_reg = inset->inset;
+	for (i = 0; i < 2; i++)
+		mask_reg[i] = (inset->mask[i].field_idx << 16) |
+			inset->mask[i].mask;
+
+	switch (inset_type) {
+	case INSET_HASH:
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(0, pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_GLQF_HASH_INSET(1, pctype),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_HASH_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 0),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 1),
+				     (uint32_t)((inset_reg >>
+					      I40E_32_BIT_WIDTH) & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype),
+					     mask_reg[i]);
+		break;
+	case INSET_FDIR_FLX:
+		i40e_check_write_reg(hw, I40E_PRTQF_FD_FLXINSET(pctype),
+				     (uint32_t)(inset_reg & UINT32_MAX));
+		for (i = 0; i < 2; i++)
+			i40e_check_write_reg(hw, I40E_PRTQF_FD_MSK(pctype, i),
+					     mask_reg[i]);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported input set type.");
+		return -EINVAL;
+	}
+
+	I40E_WRITE_FLUSH(hw);
+	return 0;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 580ca4a..e987528 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -317,6 +317,23 @@ struct rte_pmd_i40e_pkt_template_conf {
 	uint32_t soft_id;
 };
 
+enum rte_pmd_i40e_inset_type {
+	INSET_NONE = 0,
+	INSET_HASH,
+	INSET_FDIR,
+	INSET_FDIR_FLX,
+};
+
+struct  rte_pmd_i40e_inset_mask {
+	uint8_t field_idx;
+	uint16_t mask;
+};
+
+struct rte_pmd_i40e_inset {
+	uint64_t inset;
+	struct rte_pmd_i40e_inset_mask mask[2];
+};
+
 /**
  * Add or remove raw packet template filter to Flow Director.
  *
@@ -933,4 +950,125 @@ int rte_pmd_i40e_query_vfid_by_mac(uint16_t port,
 int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
 			enum rte_pmd_i40e_queue_region_op op_type, void *arg);
 
+int rte_pmd_i40e_cfg_hash_inset(uint16_t port,
+				uint64_t pctype, uint64_t inset);
+
+/**
+ * Get input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Buffer for input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_get(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Set input set
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param pctype
+ *    HW pctype.
+ * @param inset
+ *    Input set info.
+ * @param inset_type
+ *    Type of input set.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ *   - (-ENOTSUP) if operation not supported.
+ */
+int rte_pmd_i40e_inset_set(uint16_t port, uint8_t pctype,
+			   struct rte_pmd_i40e_inset *inset,
+			   enum rte_pmd_i40e_inset_type inset_type);
+
+/**
+ * Get bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (1) if set.
+ *   - (0) if cleared.
+ */
+static inline int
+rte_pmd_i40e_inset_field_get(uint64_t inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return 0;
+
+	bit_idx = 63 - field_idx;
+	if (inset & (1ULL << bit_idx))
+		return 1;
+
+	return 0;
+}
+
+/**
+ * Set bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_set(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset | (1ULL << bit_idx);
+
+	return 0;
+}
+
+/**
+ * Clear bit value for some field index
+ *
+ * @param inset
+ *    Input set value.
+ * @param field_idx
+ *    Field index for input set.
+ * @return
+ *   - (-1) if failed.
+ *   - (0) if success.
+ */
+static inline int
+rte_pmd_i40e_inset_field_clear(uint64_t *inset, uint8_t field_idx)
+{
+	uint8_t bit_idx;
+
+	if (field_idx > 63)
+		return -1;
+
+	bit_idx = 63 - field_idx;
+	*inset = *inset & ~(1ULL << bit_idx);
+
+	return 0;
+}
+
 #endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index ebbd24e..0fafadd 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -58,3 +58,13 @@ DPDK_17.11 {
 	rte_pmd_i40e_rss_queue_region_conf;
 
 } DPDK_17.08;
+
+DPDK_18.02 {
+	global:
+
+	rte_pmd_i40e_inset_get;
+	rte_pmd_i40e_inset_set;
+	rte_pmd_i40e_inset_field_get;
+	rte_pmd_i40e_inset_field_set;
+	rte_pmd_i40e_inset_field_clear;
+} DPDK_17.11;
\ No newline at end of file
-- 
2.5.5

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

* [dpdk-dev] [PATCH v8 2/2] app/testpmd: add configuration for input set
  2018-01-08  3:09             ` [dpdk-dev] [PATCH v8 0/2] support input set configuration Beilei Xing
  2018-01-08  3:09               ` [dpdk-dev] [PATCH v8 1/2] net/i40e: " Beilei Xing
@ 2018-01-08  3:09               ` Beilei Xing
  2018-01-08  3:18                 ` Lu, Wenzhuo
  2018-01-09  7:44               ` [dpdk-dev] [PATCH v8 0/2] support input set configuration Zhang, Helin
  2 siblings, 1 reply; 30+ messages in thread
From: Beilei Xing @ 2018-01-08  3:09 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

This patch adds command to configure input set for
RSS/flow director/flow director flexible payload.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 app/test-pmd/cmdline.c                      | 242 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
 2 files changed, 258 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f71d963..6b74a50 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -864,6 +864,15 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config (port_id) pctype mapping update"
 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
 			"    Update a flow type to pctype mapping item on a port\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset get|set|clear field\n"
+			" (field_idx)\n"
+			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
+
+			"port config (port_id) pctype (pctype_id) hash_inset|"
+			"fdir_inset|fdir_flx_inset clear all"
+			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
 		);
 	}
 
@@ -14652,6 +14661,237 @@ cmdline_parse_inst_t cmd_ddp_get_list = {
 	},
 };
 
+/* Configure input set */
+struct cmd_cfg_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t opt;
+	cmdline_fixed_string_t field;
+	uint8_t field_idx;
+};
+
+static void
+cmd_cfg_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_cfg_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+#endif
+	int ret = -ENOTSUP;
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to get input set.\n");
+		return;
+	}
+
+	if (!strcmp(res->opt, "get")) {
+		ret = rte_pmd_i40e_inset_field_get(inset.inset,
+						   res->field_idx);
+		if (ret)
+			printf("Field index %d is enabled.\n", res->field_idx);
+		else
+			printf("Field index %d is disabled.\n", res->field_idx);
+		return;
+	} else if (!strcmp(res->opt, "set"))
+		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
+						   res->field_idx);
+	else if (!strcmp(res->opt, "clear"))
+		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
+						     res->field_idx);
+	if (ret) {
+		printf("Failed to configure input set field.\n");
+		return;
+	}
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to set input set.\n");
+		return;
+	}
+#endif
+
+	if (ret == -ENOTSUP)
+		printf("Function not supported\n");
+}
+
+cmdline_parse_token_string_t cmd_cfg_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_cfg_input_set_opt =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 opt, "get#set#clear");
+cmdline_parse_token_string_t cmd_cfg_input_set_field =
+	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
+				 field, "field");
+cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
+	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
+			      field_idx, UINT8);
+
+cmdline_parse_inst_t cmd_cfg_input_set = {
+	.f = cmd_cfg_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
+	.tokens = {
+		(void *)&cmd_cfg_input_set_port,
+		(void *)&cmd_cfg_input_set_cfg,
+		(void *)&cmd_cfg_input_set_port_id,
+		(void *)&cmd_cfg_input_set_pctype,
+		(void *)&cmd_cfg_input_set_pctype_id,
+		(void *)&cmd_cfg_input_set_inset_type,
+		(void *)&cmd_cfg_input_set_opt,
+		(void *)&cmd_cfg_input_set_field,
+		(void *)&cmd_cfg_input_set_field_idx,
+		NULL,
+	},
+};
+
+/* Clear input set */
+struct cmd_clear_input_set_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t cfg;
+	portid_t port_id;
+	cmdline_fixed_string_t pctype;
+	uint8_t pctype_id;
+	cmdline_fixed_string_t inset_type;
+	cmdline_fixed_string_t clear;
+	cmdline_fixed_string_t all;
+};
+
+static void
+cmd_clear_input_set_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_clear_input_set_result *res = parsed_result;
+#ifdef RTE_LIBRTE_I40E_PMD
+	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
+	struct rte_pmd_i40e_inset inset;
+#endif
+	int ret = -ENOTSUP;
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (!strcmp(res->inset_type, "hash_inset"))
+		inset_type = INSET_HASH;
+	else if (!strcmp(res->inset_type, "fdir_inset"))
+		inset_type = INSET_FDIR;
+	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
+		inset_type = INSET_FDIR_FLX;
+
+	memset(&inset, 0, sizeof(inset));
+
+	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
+				     &inset, inset_type);
+	if (ret) {
+		printf("Failed to clear input set.\n");
+		return;
+	}
+
+#endif
+
+	if (ret == -ENOTSUP)
+		printf("Function not supported\n");
+}
+
+cmdline_parse_token_string_t cmd_clear_input_set_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 port, "port");
+cmdline_parse_token_string_t cmd_clear_input_set_cfg =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 cfg, "config");
+cmdline_parse_token_num_t cmd_clear_input_set_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
+			      port_id, UINT16);
+cmdline_parse_token_string_t cmd_clear_input_set_pctype =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 pctype, "pctype");
+cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
+			      pctype_id, UINT8);
+cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 inset_type,
+				 "hash_inset#fdir_inset#fdir_flx_inset");
+cmdline_parse_token_string_t cmd_clear_input_set_clear =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 clear, "clear");
+cmdline_parse_token_string_t cmd_clear_input_set_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
+				 all, "all");
+
+cmdline_parse_inst_t cmd_clear_input_set = {
+	.f = cmd_clear_input_set_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
+		    "fdir_inset|fdir_flx_inset clear all",
+	.tokens = {
+		(void *)&cmd_clear_input_set_port,
+		(void *)&cmd_clear_input_set_cfg,
+		(void *)&cmd_clear_input_set_port_id,
+		(void *)&cmd_clear_input_set_pctype,
+		(void *)&cmd_clear_input_set_pctype_id,
+		(void *)&cmd_clear_input_set_inset_type,
+		(void *)&cmd_clear_input_set_clear,
+		(void *)&cmd_clear_input_set_all,
+		NULL,
+	},
+};
+
 /* show vf stats */
 
 /* Common result structure for show vf stats */
@@ -15737,6 +15977,8 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_ddp_del,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
+	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
+	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 2b00be8..0da38fb 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1849,6 +1849,22 @@ where:
 
 * ``flow_type_id``: software flow type id as the index of the pctype mapping table.
 
+port config input set
+~~~~~~~~~~~~~~~~~~~~~
+
+Config RSS/FDIR/FDIR flexible payload input set for some pctype::
+   testpmd> port config (port_id) pctype (pctype_id) \
+            (hash_inset|fdir_inset|fdir_flx_inset) \
+	    (get|set|clear) field (field_idx)
+
+Clear RSS/FDIR/FDIR flexible payload input set for some pctype::
+   testpmd> port config (port_id) pctype (pctype_id) \
+            (hash_inset|fdir_inset|fdir_flx_inset) clear all
+
+where:
+
+* ``pctype_id``: hardware packet classification types.
+* ``field_idx``: hardware field index.
 
 Link Bonding Functions
 ----------------------
-- 
2.5.5

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

* Re: [dpdk-dev] [PATCH v8 2/2] app/testpmd: add configuration for input set
  2018-01-08  3:09               ` [dpdk-dev] [PATCH v8 2/2] app/testpmd: add configuration for input set Beilei Xing
@ 2018-01-08  3:18                 ` Lu, Wenzhuo
  0 siblings, 0 replies; 30+ messages in thread
From: Lu, Wenzhuo @ 2018-01-08  3:18 UTC (permalink / raw)
  To: Xing, Beilei, Wu, Jingjing, Zhang, Qi Z; +Cc: dev, Chilikin, Andrey

Hi,


> -----Original Message-----
> From: Xing, Beilei
> Sent: Monday, January 8, 2018 11:09 AM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; Chilikin, Andrey <andrey.chilikin@intel.com>
> Subject: [PATCH v8 2/2] app/testpmd: add configuration for input set
> 
> This patch adds command to configure input set for RSS/flow director/flow
> director flexible payload.
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>

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

* Re: [dpdk-dev] [PATCH v8 0/2] support input set configuration
  2018-01-08  3:09             ` [dpdk-dev] [PATCH v8 0/2] support input set configuration Beilei Xing
  2018-01-08  3:09               ` [dpdk-dev] [PATCH v8 1/2] net/i40e: " Beilei Xing
  2018-01-08  3:09               ` [dpdk-dev] [PATCH v8 2/2] app/testpmd: add configuration for input set Beilei Xing
@ 2018-01-09  7:44               ` Zhang, Helin
  2 siblings, 0 replies; 30+ messages in thread
From: Zhang, Helin @ 2018-01-09  7:44 UTC (permalink / raw)
  To: Xing, Beilei, Wu, Jingjing, Lu, Wenzhuo, Zhang, Qi Z
  Cc: dev, Chilikin, Andrey



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Beilei Xing
> Sent: Monday, January 8, 2018 11:09 AM
> To: Wu, Jingjing; Lu, Wenzhuo; Zhang, Qi Z
> Cc: dev@dpdk.org; Chilikin, Andrey
> Subject: [dpdk-dev] [PATCH v8 0/2] support input set configuration
> 
> The patchset adds support RSS/FDIR/FDIR flexible payload input set
> configuration for some pctype.
> 
> v8 changes:
>  - Add info if NIC doesn't support the function.
> 
> v7 changes:
>  - Add info if NIC doesn't support the function.
>  - Add doc in testpmd_funcs.rst for the new CLIs.
> 
> v6 changes:
>  - Fix DPDK version for new private API.
> 
> v5 changes:
>  - Add DPDK version for new private API.
> 
> v4 changes:
>  - Change testpmd command token and print info.
> 
> v3 changes:
>  - Add support reset RSS/FDIR/FDIR flexible payload input set for some pctype.
> 
> v2 changes:
>  - Use 'static inline' to replace 'inline'.
>  - Add support get status for some filed index of input set.
> 
> Beilei Xing (2):
>   net/i40e: support input set configuration
>   app/testpmd: add configuration for input set
> 
>  app/test-pmd/cmdline.c                      | 242 ++++++++++++++++++++++++++++
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 ++
>  drivers/net/i40e/rte_pmd_i40e.c             | 141 ++++++++++++++++
>  drivers/net/i40e/rte_pmd_i40e.h             | 138 ++++++++++++++++
>  drivers/net/i40e/rte_pmd_i40e_version.map   |  10 ++
>  5 files changed, 547 insertions(+)
> 
> --
> 2.5.5
Applied to dpdk-next-net-intel, with minor commit log changes. Thanks!

/Helin

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

* Re: [dpdk-dev] [PATCH v8 1/2] net/i40e: support input set configuration
  2018-01-08  3:09               ` [dpdk-dev] [PATCH v8 1/2] net/i40e: " Beilei Xing
@ 2018-01-10 12:12                 ` Ferruh Yigit
  2018-01-10 12:40                   ` Xing, Beilei
  0 siblings, 1 reply; 30+ messages in thread
From: Ferruh Yigit @ 2018-01-10 12:12 UTC (permalink / raw)
  To: Beilei Xing, jingjing.wu, wenzhuo.lu, qi.z.zhang; +Cc: dev, andrey.chilikin

On 1/8/2018 3:09 AM, Beilei Xing wrote:
> +static inline int
> +rte_pmd_i40e_inset_field_clear(uint64_t *inset, uint8_t field_idx)
> +{
> +	uint8_t bit_idx;
> +
> +	if (field_idx > 63)
> +		return -1;
> +
> +	bit_idx = 63 - field_idx;
> +	*inset = *inset & ~(1ULL << bit_idx);
> +
> +	return 0;
> +}
> +
>  #endif /* _PMD_I40E_H_ */
> diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
> index ebbd24e..0fafadd 100644
> --- a/drivers/net/i40e/rte_pmd_i40e_version.map
> +++ b/drivers/net/i40e/rte_pmd_i40e_version.map
> @@ -58,3 +58,13 @@ DPDK_17.11 {
>  	rte_pmd_i40e_rss_queue_region_conf;
>  
>  } DPDK_17.08;
> +
> +DPDK_18.02 {
> +	global:
> +
> +	rte_pmd_i40e_inset_get;
> +	rte_pmd_i40e_inset_set;
> +	rte_pmd_i40e_inset_field_get;
> +	rte_pmd_i40e_inset_field_set;
> +	rte_pmd_i40e_inset_field_clear;

I think we don't need static inline functions in linker script, do we?

> +} DPDK_17.11;

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

* Re: [dpdk-dev] [PATCH v8 1/2] net/i40e: support input set configuration
  2018-01-10 12:12                 ` Ferruh Yigit
@ 2018-01-10 12:40                   ` Xing, Beilei
  0 siblings, 0 replies; 30+ messages in thread
From: Xing, Beilei @ 2018-01-10 12:40 UTC (permalink / raw)
  To: Yigit, Ferruh, Wu, Jingjing, Lu, Wenzhuo, Zhang, Qi Z
  Cc: dev, Chilikin, Andrey

> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Wednesday, January 10, 2018 8:13 PM
> To: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Zhang, Qi
> Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; Chilikin, Andrey <andrey.chilikin@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v8 1/2] net/i40e: support input set
> configuration
> 
> On 1/8/2018 3:09 AM, Beilei Xing wrote:
> > +static inline int
> > +rte_pmd_i40e_inset_field_clear(uint64_t *inset, uint8_t field_idx) {
> > +	uint8_t bit_idx;
> > +
> > +	if (field_idx > 63)
> > +		return -1;
> > +
> > +	bit_idx = 63 - field_idx;
> > +	*inset = *inset & ~(1ULL << bit_idx);
> > +
> > +	return 0;
> > +}
> > +
> >  #endif /* _PMD_I40E_H_ */
> > diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map
> > b/drivers/net/i40e/rte_pmd_i40e_version.map
> > index ebbd24e..0fafadd 100644
> > --- a/drivers/net/i40e/rte_pmd_i40e_version.map
> > +++ b/drivers/net/i40e/rte_pmd_i40e_version.map
> > @@ -58,3 +58,13 @@ DPDK_17.11 {
> >  	rte_pmd_i40e_rss_queue_region_conf;
> >
> >  } DPDK_17.08;
> > +
> > +DPDK_18.02 {
> > +	global:
> > +
> > +	rte_pmd_i40e_inset_get;
> > +	rte_pmd_i40e_inset_set;
> > +	rte_pmd_i40e_inset_field_get;
> > +	rte_pmd_i40e_inset_field_set;
> > +	rte_pmd_i40e_inset_field_clear;
> 
> I think we don't need static inline functions in linker script, do we?

Static inline functions are just used as helper functions, maybe we don't need them in linker script, I will send a new patch to delete it, thanks.

> 
> > +} DPDK_17.11;


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

end of thread, other threads:[~2018-01-10 12:41 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-24 14:59 [dpdk-dev] [PATCH 0/2] net/i40e: support input set configuration Beilei Xing
2017-11-24 14:59 ` [dpdk-dev] [PATCH 1/2] " Beilei Xing
2017-11-24 14:59 ` [dpdk-dev] [PATCH 2/2] app/testpmd: add configuration for input set Beilei Xing
2017-11-27  7:16 ` [dpdk-dev] [PATCH v2 0/2] net/i40e: support input set configuration Beilei Xing
2017-11-27  7:16   ` [dpdk-dev] [PATCH v2 1/2] " Beilei Xing
2017-11-27  7:16   ` [dpdk-dev] [PATCH v2 2/2] app/testpmd: add configuration for input set Beilei Xing
2017-11-29  9:43   ` [dpdk-dev] [PATCH v3 0/2] net/i40e: support input set configuration Beilei Xing
2017-11-29  9:43     ` [dpdk-dev] [PATCH v3 1/2] " Beilei Xing
2017-11-29  9:43     ` [dpdk-dev] [PATCH v3 2/2] app/testpmd: add configuration for input set Beilei Xing
2017-12-07  6:00     ` [dpdk-dev] [PATCH v4 0/2] net/i40e: support input set configuration Beilei Xing
2017-12-07  6:00       ` [dpdk-dev] [PATCH v4 1/2] " Beilei Xing
2017-12-07  6:00       ` [dpdk-dev] [PATCH v4 2/2] app/testpmd: add configuration for input set Beilei Xing
2017-12-07  8:43       ` [dpdk-dev] [PATCH v5 0/2] net/i40e: support input set configuration Beilei Xing
2017-12-07  8:43         ` [dpdk-dev] [PATCH v5 1/2] " Beilei Xing
2017-12-07  8:43         ` [dpdk-dev] [PATCH v5 2/2] app/testpmd: add configuration for input set Beilei Xing
2017-12-08  7:51         ` [dpdk-dev] [PATCH v6 0/2] net/i40e: support input set configuration Beilei Xing
2017-12-08  7:51           ` [dpdk-dev] [PATCH v6 1/2] " Beilei Xing
2018-01-02 12:48             ` Zhang, Qi Z
2017-12-08  7:51           ` [dpdk-dev] [PATCH v6 2/2] app/testpmd: add configuration for input set Beilei Xing
2018-01-04  6:51             ` Lu, Wenzhuo
2018-01-05  3:03           ` [dpdk-dev] [PATCH v7 0/2] support input set configuration Beilei Xing
2018-01-05  3:03             ` [dpdk-dev] [PATCH v7 1/2] net/i40e: " Beilei Xing
2018-01-05  3:03             ` [dpdk-dev] [PATCH v7 2/2] app/testpmd: add configuration for input set Beilei Xing
2018-01-08  3:09             ` [dpdk-dev] [PATCH v8 0/2] support input set configuration Beilei Xing
2018-01-08  3:09               ` [dpdk-dev] [PATCH v8 1/2] net/i40e: " Beilei Xing
2018-01-10 12:12                 ` Ferruh Yigit
2018-01-10 12:40                   ` Xing, Beilei
2018-01-08  3:09               ` [dpdk-dev] [PATCH v8 2/2] app/testpmd: add configuration for input set Beilei Xing
2018-01-08  3:18                 ` Lu, Wenzhuo
2018-01-09  7:44               ` [dpdk-dev] [PATCH v8 0/2] support input set configuration Zhang, Helin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).