DPDK patches and discussions
 help / color / mirror / Atom feed
From: <skori@marvell.com>
To: Cristian Dumitrescu <cristian.dumitrescu@intel.com>,
	Aman Singh <aman.deep.singh@intel.com>,
	Yuying Zhang <yuying.zhang@intel.com>,
	"Nithin Dabilpuram" <ndabilpuram@marvell.com>,
	Kiran Kumar K <kirankumark@marvell.com>,
	Sunil Kumar Kori <skori@marvell.com>,
	Satha Rao <skoteshwar@marvell.com>,
	Jasvinder Singh <jasvinder.singh@intel.com>,
	"Thomas Monjalon" <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@xilinx.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Cc: <dev@dpdk.org>
Subject: [PATCH v2 1/1] ethdev: add protocol param to color table update
Date: Tue, 23 Aug 2022 15:52:55 +0530	[thread overview]
Message-ID: <20220823102255.2905191-1-skori@marvell.com> (raw)
In-Reply-To: <20220707065743.76932-1-skori@marvell.com>

From: Sunil Kumar Kori <skori@marvell.com>

Using rte_mtr_color_in_protocol_set(), user can configure
combination of protocol headers, like outer_vlan and outer_ip,
can be enabled on given meter object.

But rte_mtr_meter_vlan_table_update() and
rte_mtr_meter_dscp_table_update() do not have information that
which table needs to be updated corresponding to protocol header
i.e. inner or outer.

Adding protocol paramreter will allow user to provide required
protocol information so that corresponding inner or outer table
can be updated corresponding to protocol header.

If user wishes to configure both inner and outer table then
API must be called twice with correct protocol information.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v1..v2:
 - Rebase on ToT of dpdk-next-net-mrvl/for-next-net branch.
 - Remove "Depends On:" tag as dependent patch is merged.

 app/test-pmd/cmdline_mtr.c                  | 42 ++++++++++++++++-----
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  8 ++--
 drivers/net/cnxk/cnxk_ethdev_mtr.c          | 20 +++++++++-
 drivers/net/softnic/rte_eth_softnic_meter.c |  4 +-
 lib/ethdev/rte_mtr.c                        |  8 ++--
 lib/ethdev/rte_mtr.h                        |  7 +++-
 lib/ethdev/rte_mtr_driver.h                 |  4 +-
 7 files changed, 70 insertions(+), 23 deletions(-)

diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index 833273da0d..f517a328b7 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -297,8 +297,8 @@ parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
 }
 
 static int
-parse_multi_token_string(char *t_str, uint16_t *port_id,
-	uint32_t *mtr_id, enum rte_color **dscp_table)
+parse_multi_token_string(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
+	enum rte_mtr_color_in_protocol *proto, enum rte_color **dscp_table)
 {
 	char *token;
 	uint64_t val;
@@ -326,6 +326,16 @@ parse_multi_token_string(char *t_str, uint16_t *port_id,
 
 	*mtr_id = val;
 
+	/* Third token: protocol  */
+	token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+	if (token == NULL)
+		return 0;
+
+	if (strcmp(token, "outer_ip") == 0)
+		*proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
+	else if (strcmp(token, "inner_ip") == 0)
+		*proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
+
 	ret = parse_dscp_table_entries(t_str, dscp_table);
 	if (ret != 0)
 		return -1;
@@ -335,7 +345,7 @@ parse_multi_token_string(char *t_str, uint16_t *port_id,
 
 static int
 parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
-	enum rte_color **vlan_table)
+	enum rte_mtr_color_in_protocol *proto, enum rte_color **vlan_table)
 {
 	uint64_t val;
 	char *token;
@@ -363,6 +373,16 @@ parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
 
 	*mtr_id = val;
 
+	/* Third token: protocol  */
+	token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+	if (token == NULL)
+		return 0;
+
+	if (strcmp(token, "outer_vlan") == 0)
+		*proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
+	else if (strcmp(token, "inner_vlan") == 0)
+		*proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
+
 	ret = parse_vlan_table_entries(t_str, vlan_table);
 	if (ret != 0)
 		return -1;
@@ -1388,6 +1408,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
 	__rte_unused void *data)
 {
 	struct cmd_set_port_meter_dscp_table_result *res = parsed_result;
+	enum rte_mtr_color_in_protocol proto = 0;
 	struct rte_mtr_error error;
 	enum rte_color *dscp_table = NULL;
 	char *t_str = res->token_string;
@@ -1396,7 +1417,8 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
 	int ret;
 
 	/* Parse string */
-	ret = parse_multi_token_string(t_str, &port_id, &mtr_id, &dscp_table);
+	ret = parse_multi_token_string(t_str, &port_id, &mtr_id, &proto,
+				       &dscp_table);
 	if (ret) {
 		fprintf(stderr, " Multi token string parse error\n");
 		return;
@@ -1406,7 +1428,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
 		goto free_table;
 
 	/* Update Meter DSCP Table*/
-	ret = rte_mtr_meter_dscp_table_update(port_id, mtr_id,
+	ret = rte_mtr_meter_dscp_table_update(port_id, mtr_id, proto,
 		dscp_table, &error);
 	if (ret != 0)
 		print_err_msg(&error);
@@ -1418,7 +1440,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
 cmdline_parse_inst_t cmd_set_port_meter_dscp_table = {
 	.f = cmd_set_port_meter_dscp_table_parsed,
 	.data = NULL,
-	.help_str = "set port meter dscp table <port_id> <mtr_id> "
+	.help_str = "set port meter dscp table <port_id> <mtr_id> <proto> "
 		"[<dscp_tbl_entry0> <dscp_tbl_entry1> ... <dscp_tbl_entry63>]",
 	.tokens = {
 		(void *)&cmd_set_port_meter_dscp_table_set,
@@ -1461,6 +1483,7 @@ static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
 	__rte_unused void *data)
 {
 	struct cmd_set_port_meter_vlan_table_result *res = parsed_result;
+	enum rte_mtr_color_in_protocol proto = 0;
 	struct rte_mtr_error error;
 	enum rte_color *vlan_table = NULL;
 	char *t_str = res->token_string;
@@ -1469,7 +1492,8 @@ static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
 	int ret;
 
 	/* Parse string */
-	ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &vlan_table);
+	ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &proto,
+					 &vlan_table);
 	if (ret) {
 		fprintf(stderr, " Multi token string parse error\n");
 		return;
@@ -1479,7 +1503,7 @@ static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
 		goto free_table;
 
 	/* Update Meter VLAN Table*/
-	ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id,
+	ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id, proto,
 		vlan_table, &error);
 	if (ret != 0)
 		print_err_msg(&error);
@@ -1491,7 +1515,7 @@ static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
 cmdline_parse_inst_t cmd_set_port_meter_vlan_table = {
 	.f = cmd_set_port_meter_vlan_table_parsed,
 	.data = NULL,
-	.help_str = "set port meter vlan table <port_id> <mtr_id> "
+	.help_str = "set port meter vlan table <port_id> <mtr_id> <proto> "
 		"[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry15>]",
 	.tokens = {
 		(void *)&cmd_set_port_meter_vlan_table_set,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 330e34427d..ce40e3b6f2 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2597,15 +2597,15 @@ set port meter dscp table
 
 Set meter dscp table for the ethernet device::
 
-   testpmd> set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0) \
-   (dscp_tbl_entry1)...(dscp_tbl_entry63)]
+   testpmd> set port meter dscp table (port_id) (mtr_id) (proto) \
+   [(dscp_tbl_entry0) (dscp_tbl_entry1)...(dscp_tbl_entry63)]
 
 set port meter vlan table
 ~~~~~~~~~~~~~~~~~~~~~~~~~
 Set meter VLAN table for the Ethernet device::
 
-   testpmd> set port meter vlan table (port_id) (mtr_id) [(vlan_tbl_entry0) \
-   (vlan_tbl_entry1)...(vlan_tbl_entry15)]
+   testpmd> set port meter vlan table (port_id) (mtr_id) (proto) \
+   [(vlan_tbl_entry0) (vlan_tbl_entry1)...(vlan_tbl_entry15)]
 
 set port meter protocol
 ~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c
index be2cb7d628..0fa18f01c7 100644
--- a/drivers/net/cnxk/cnxk_ethdev_mtr.c
+++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c
@@ -720,6 +720,7 @@ cnxk_nix_mtr_disable(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
 
 static int
 cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+			       enum rte_mtr_color_in_protocol proto,
 			       enum rte_color *dscp_table,
 			       struct rte_mtr_error *error)
 {
@@ -750,7 +751,7 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
 
 	table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
 
-	switch (dev->proto) {
+	switch (proto) {
 	case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
 		table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
 		break;
@@ -764,6 +765,13 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
 		goto exit;
 	}
 
+	if (dev->proto != proto) {
+		rc = -rte_mtr_error_set(error, EINVAL,
+			RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+			"input color protocol is not configured");
+		goto exit;
+	}
+
 	for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
 		table.color[i] = nix_dscp_tbl[i];
 
@@ -784,6 +792,7 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
 
 static int
 cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+			       enum rte_mtr_color_in_protocol proto,
 			       enum rte_color *vlan_table,
 			       struct rte_mtr_error *error)
 {
@@ -814,7 +823,7 @@ cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
 
 	table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
 
-	switch (dev->proto) {
+	switch (proto) {
 	case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
 		table.mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
 		break;
@@ -828,6 +837,13 @@ cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
 		goto exit;
 	}
 
+	if (dev->proto != proto) {
+		rc = -rte_mtr_error_set(error, EINVAL,
+			RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+			"input color protocol is not configured");
+		goto exit;
+	}
+
 	for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
 		table.color[i] = nix_vlan_tbl[i];
 
diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c b/drivers/net/softnic/rte_eth_softnic_meter.c
index 6b02f43e31..3e635a3cfe 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -636,7 +636,7 @@ pmd_mtr_meter_profile_update(struct rte_eth_dev *dev,
 /* MTR object meter DSCP table update */
 static int
 pmd_mtr_meter_dscp_table_update(struct rte_eth_dev *dev,
-	uint32_t mtr_id,
+	uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error)
 {
@@ -648,6 +648,8 @@ pmd_mtr_meter_dscp_table_update(struct rte_eth_dev *dev,
 	uint32_t table_id, i;
 	int status;
 
+	RTE_SET_USED(proto);
+
 	/* MTR object id must be valid */
 	m = softnic_mtr_find(p, mtr_id);
 	if (m == NULL)
diff --git a/lib/ethdev/rte_mtr.c b/lib/ethdev/rte_mtr.c
index c460e4f4e0..e4dff20f76 100644
--- a/lib/ethdev/rte_mtr.c
+++ b/lib/ethdev/rte_mtr.c
@@ -197,25 +197,25 @@ rte_mtr_meter_policy_update(uint16_t port_id,
 /** MTR object meter DSCP table update */
 int
 rte_mtr_meter_dscp_table_update(uint16_t port_id,
-	uint32_t mtr_id,
+	uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 	return RTE_MTR_FUNC(port_id, meter_dscp_table_update)(dev,
-		mtr_id, dscp_table, error);
+		mtr_id, proto, dscp_table, error);
 }
 
 /** MTR object meter VLAN table update */
 int
 rte_mtr_meter_vlan_table_update(uint16_t port_id,
-	uint32_t mtr_id,
+	uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
 	enum rte_color *vlan_table,
 	struct rte_mtr_error *error)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 	return RTE_MTR_FUNC(port_id, meter_vlan_table_update)(dev,
-		mtr_id, vlan_table, error);
+		mtr_id, proto, vlan_table, error);
 }
 
 /** Set the input color protocol on MTR object */
diff --git a/lib/ethdev/rte_mtr.h b/lib/ethdev/rte_mtr.h
index 008bc84f0d..5e4f7ba73b 100644
--- a/lib/ethdev/rte_mtr.h
+++ b/lib/ethdev/rte_mtr.h
@@ -913,6 +913,8 @@ rte_mtr_meter_policy_update(uint16_t port_id,
  *   The port identifier of the Ethernet device.
  * @param[in] mtr_id
  *   MTR object ID. Needs to be valid.
+ * @param[in] proto
+ *   Input color protocol.
  * @param[in] dscp_table
  *   When non-NULL: it points to a pre-allocated and pre-populated table with
  *   exactly 64 elements providing the input color for each value of the
@@ -927,7 +929,7 @@ rte_mtr_meter_policy_update(uint16_t port_id,
 __rte_experimental
 int
 rte_mtr_meter_dscp_table_update(uint16_t port_id,
-	uint32_t mtr_id,
+	uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
@@ -938,6 +940,8 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
  *   The port identifier of the Ethernet device.
  * @param[in] mtr_id
  *   MTR object ID. Needs to be valid.
+ * @param[in] proto
+ *   Input color protocol.
  * @param[in] vlan_table
  *   When non-NULL: it points to a pre-allocated and pre-populated table with
  *   exactly 16 elements providing the input color for each value of the
@@ -952,6 +956,7 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
 __rte_experimental
 int
 rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
+				enum rte_mtr_color_in_protocol proto,
 				enum rte_color *vlan_table,
 				struct rte_mtr_error *error);
 
diff --git a/lib/ethdev/rte_mtr_driver.h b/lib/ethdev/rte_mtr_driver.h
index f7dca9a54c..a8b652a607 100644
--- a/lib/ethdev/rte_mtr_driver.h
+++ b/lib/ethdev/rte_mtr_driver.h
@@ -93,13 +93,13 @@ typedef int (*rte_mtr_meter_policy_update_t)(struct rte_eth_dev *dev,
 
 /** @internal MTR object meter DSCP table update. */
 typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
-	uint32_t mtr_id,
+	uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
 /** @internal mtr object meter vlan table update. */
 typedef int (*rte_mtr_meter_vlan_table_update_t)(struct rte_eth_dev *dev,
-	uint32_t mtr_id,
+	uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
 	enum rte_color *vlan_table,
 	struct rte_mtr_error *error);
 
-- 
2.25.1


  parent reply	other threads:[~2022-08-23 10:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07  6:57 [PATCH] " skori
2022-07-21  7:32 ` Sunil Kumar Kori
2022-08-16  5:56   ` Sunil Kumar Kori
2022-08-23 10:22 ` skori [this message]
2022-08-23 13:34   ` [PATCH v2 1/1] " Dumitrescu, Cristian
2022-10-03 14:42     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220823102255.2905191-1-skori@marvell.com \
    --to=skori@marvell.com \
    --cc=aman.deep.singh@intel.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@xilinx.com \
    --cc=jasvinder.singh@intel.com \
    --cc=kirankumark@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=skoteshwar@marvell.com \
    --cc=thomas@monjalon.net \
    --cc=yuying.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).