* [PATCH v1 1/3] common/cnxk: update precolor table setup for VLAN
@ 2022-03-01 9:00 skori
2022-03-01 9:00 ` [PATCH v1 2/3] net/cnxk: support ops to update precolor VLAN table skori
2022-03-01 9:00 ` [PATCH v1 3/3] app/testpmd: support different input color method skori
0 siblings, 2 replies; 30+ messages in thread
From: skori @ 2022-03-01 9:00 UTC (permalink / raw)
To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao; +Cc: dev
From: Sunil Kumar Kori <skori@marvell.com>
As per new spec in DPDK, VLAN priority is supported for
precoloring of input packet.
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
drivers/common/cnxk/roc_nix.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h
index 5e6eb58c0c..e92363f7f3 100644
--- a/drivers/common/cnxk/roc_nix.h
+++ b/drivers/common/cnxk/roc_nix.h
@@ -42,6 +42,12 @@ enum roc_nix_bpf_level_flag {
ROC_NIX_BPF_LEVEL_F_TOP = BIT(2),
};
+enum roc_nix_bpf_precolor_tbl_size {
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_GEN = 16,
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN = 16,
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP = 64,
+};
+
enum roc_nix_bpf_pc_mode {
ROC_NIX_BPF_PC_MODE_VLAN_INNER,
ROC_NIX_BPF_PC_MODE_VLAN_OUTER,
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v1 2/3] net/cnxk: support ops to update precolor VLAN table
2022-03-01 9:00 [PATCH v1 1/3] common/cnxk: update precolor table setup for VLAN skori
@ 2022-03-01 9:00 ` skori
2022-06-16 9:48 ` [PATCH v2 1/2] common/cnxk: update precolor table setup for VLAN skori
2022-03-01 9:00 ` [PATCH v1 3/3] app/testpmd: support different input color method skori
1 sibling, 1 reply; 30+ messages in thread
From: skori @ 2022-03-01 9:00 UTC (permalink / raw)
To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao; +Cc: dev
From: Sunil Kumar Kori <skori@marvell.com>
Implement API to update VLAN table for pre-coloring for
incoming packet per nixlf for CN10K platform.
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
drivers/net/cnxk/cnxk_ethdev.h | 2 +-
drivers/net/cnxk/cnxk_ethdev_mtr.c | 214 +++++++++++++++++++++++++----
2 files changed, 188 insertions(+), 28 deletions(-)
diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
index ccdf496860..7c7e013c42 100644
--- a/drivers/net/cnxk/cnxk_ethdev.h
+++ b/drivers/net/cnxk/cnxk_ethdev.h
@@ -409,7 +409,7 @@ struct cnxk_eth_dev {
uint64_t clk_delta;
/* Ingress policer */
- enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
+ enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
struct cnxk_mtr_profiles mtr_profiles;
struct cnxk_mtr_policy mtr_policy;
struct cnxk_mtr mtr;
diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c
index c8183aa12d..1d6a4807d5 100644
--- a/drivers/net/cnxk/cnxk_ethdev_mtr.c
+++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c
@@ -48,7 +48,13 @@ static struct rte_mtr_capabilities mtr_capa = {
RTE_MTR_STATS_N_PKTS_RED | RTE_MTR_STATS_N_PKTS_DROPPED |
RTE_MTR_STATS_N_BYTES_GREEN |
RTE_MTR_STATS_N_BYTES_YELLOW | RTE_MTR_STATS_N_BYTES_RED |
- RTE_MTR_STATS_N_BYTES_DROPPED};
+ RTE_MTR_STATS_N_BYTES_DROPPED,
+ .methods_mask = RTE_MTR_INPUT_COLOR_METHOD_COLOR_BLIND |
+ RTE_MTR_INPUT_COLOR_METHOD_VLAN |
+ RTE_MTR_INPUT_COLOR_METHOD_DSCP |
+ RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN |
+ RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP,
+ .separate_input_color_table_per_port = true};
static struct cnxk_meter_node *
nix_mtr_find(struct cnxk_eth_dev *dev, uint32_t meter_id)
@@ -470,6 +476,7 @@ cnxk_nix_mtr_create(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
struct cnxk_mtr_profile_node *profile;
struct cnxk_mtr_policy_node *policy;
struct cnxk_mtr *fm = &dev->mtr;
+ enum rte_color *table = NULL;
struct cnxk_meter_node *mtr;
int i;
@@ -521,18 +528,49 @@ cnxk_nix_mtr_create(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
mtr->is_next = false;
mtr->level = ROC_NIX_BPF_LEVEL_IDX_INVALID;
- if (params->dscp_table) {
- mtr->params.dscp_table =
- plt_zmalloc(ROC_NIX_BPF_PRE_COLOR_MAX, ROC_ALIGN);
- if (mtr->params.dscp_table == NULL) {
+ switch (params->input_color_method) {
+ case RTE_MTR_INPUT_COLOR_METHOD_DSCP:
+ case RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP:
+ table = (enum rte_color *)
+ plt_zmalloc(sizeof(enum rte_color) *
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP, ROC_ALIGN);
+ if (table == NULL) {
plt_free(mtr);
return -rte_mtr_error_set(error, ENOMEM,
RTE_MTR_ERROR_TYPE_UNSPECIFIED,
NULL, "Memory alloc failed.");
}
+ if (params->dscp_table) {
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
+ table[i] = params->dscp_table[i];
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
- mtr->params.dscp_table[i] = params->dscp_table[i];
+ mtr->params.dscp_table = table;
+ }
+ break;
+ case RTE_MTR_INPUT_COLOR_METHOD_VLAN:
+ case RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN:
+ table = (enum rte_color *)
+ plt_zmalloc(sizeof(enum rte_color) *
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN, ROC_ALIGN);
+ if (table == NULL) {
+ plt_free(mtr);
+ return -rte_mtr_error_set(error, ENOMEM,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Memory alloc failed.");
+ }
+ if (params->vlan_table) {
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ table[i] = params->vlan_table[i];
+
+ mtr->params.vlan_table = table;
+ }
+ break;
+ default:
+ plt_free(table);
+ plt_free(mtr);
+ return -rte_mtr_error_set(error, ENOMEM,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "Invalid input color method");
}
profile->ref_cnt++;
@@ -619,7 +657,13 @@ cnxk_nix_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
mtr->policy->ref_cnt--;
mtr->profile->ref_cnt--;
TAILQ_REMOVE(fm, mtr, next);
- plt_free(mtr->params.dscp_table);
+
+ if (mtr->params.input_color_method == RTE_MTR_INPUT_COLOR_METHOD_DSCP)
+ plt_free(mtr->params.dscp_table);
+ else if (mtr->params.input_color_method ==
+ RTE_MTR_INPUT_COLOR_METHOD_VLAN)
+ plt_free(mtr->params.vlan_table);
+
plt_free(mtr);
exit:
@@ -689,7 +733,7 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
enum rte_color *dscp_table,
struct rte_mtr_error *error)
{
- enum roc_nix_bpf_color nix_dscp_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
+ enum roc_nix_bpf_color nix_dscp_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
ROC_NIX_BPF_COLOR_YELLOW,
ROC_NIX_BPF_COLOR_RED};
@@ -707,16 +751,22 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
}
if (!dscp_table) {
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
nix_dscp_tbl[i] = ROC_NIX_BPF_COLOR_GREEN;
} else {
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
nix_dscp_tbl[i] = color_map[dscp_table[i]];
}
- table.count = ROC_NIX_BPF_PRE_COLOR_MAX;
- table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
+
+ if (mtr->params.input_color_method ==
+ RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP)
+ table.mode = ROC_NIX_BPF_PC_MODE_DSCP_INNER;
+ else
+ table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
table.color[i] = nix_dscp_tbl[i];
rc = roc_nix_bpf_pre_color_tbl_setup(nix, mtr->bpf_id,
@@ -727,13 +777,69 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
goto exit;
}
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
dev->precolor_tbl[i] = nix_dscp_tbl[i];
exit:
return rc;
}
+static int
+cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ enum rte_color *vlan_table,
+ struct rte_mtr_error *error)
+{
+ enum roc_nix_bpf_color nix_vlan_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN];
+ enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
+ ROC_NIX_BPF_COLOR_YELLOW,
+ ROC_NIX_BPF_COLOR_RED};
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct roc_nix_bpf_precolor table;
+ struct roc_nix *nix = &dev->nix;
+ struct cnxk_meter_node *mtr;
+ int rc, i;
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ if (!vlan_table) {
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ nix_vlan_tbl[i] = ROC_NIX_BPF_COLOR_GREEN;
+ } else {
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ nix_vlan_tbl[i] = color_map[vlan_table[i]];
+ }
+
+ table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
+
+ if (mtr->params.input_color_method ==
+ RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN)
+ table.mode = ROC_NIX_BPF_PC_MODE_VLAN_INNER;
+ else
+ table.mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ table.color[i] = nix_vlan_tbl[i];
+
+ rc = roc_nix_bpf_pre_color_tbl_setup(nix, mtr->bpf_id,
+ lvl_map[mtr->level], &table);
+ if (rc) {
+ rte_mtr_error_set(error, rc, RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+ NULL, NULL);
+ goto exit;
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ dev->precolor_tbl[i] = nix_vlan_tbl[i];
+
+exit:
+ return rc;
+}
+
static int
cnxk_nix_mtr_stats_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
uint64_t stats_mask, struct rte_mtr_error *error)
@@ -870,6 +976,7 @@ const struct rte_mtr_ops nix_mtr_ops = {
.meter_enable = cnxk_nix_mtr_enable,
.meter_disable = cnxk_nix_mtr_disable,
.meter_dscp_table_update = cnxk_nix_mtr_dscp_table_update,
+ .meter_vlan_table_update = cnxk_nix_mtr_vlan_table_update,
.stats_update = cnxk_nix_mtr_stats_update,
.stats_read = cnxk_nix_mtr_stats_read,
};
@@ -1041,6 +1148,9 @@ nix_mtr_level_update(struct rte_eth_dev *eth_dev, uint32_t id, uint32_t level)
static void
nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
{
+ enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
+ ROC_NIX_BPF_COLOR_YELLOW,
+ ROC_NIX_BPF_COLOR_RED};
enum roc_nix_bpf_algo alg_map[] = {
ROC_NIX_BPF_ALGO_NONE, ROC_NIX_BPF_ALGO_2697,
ROC_NIX_BPF_ALGO_2698, ROC_NIX_BPF_ALGO_4115};
@@ -1049,6 +1159,28 @@ nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
cfg->alg = alg_map[profile->profile.alg];
cfg->lmode = profile->profile.packet_mode;
+ cfg->icolor = color_map[mtr->params.default_input_color];
+
+ switch (mtr->params.input_color_method) {
+ case RTE_MTR_INPUT_COLOR_METHOD_DSCP:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
+ cfg->tnl_ena = false;
+ break;
+ case RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_DSCP_INNER;
+ cfg->tnl_ena = true;
+ break;
+ case RTE_MTR_INPUT_COLOR_METHOD_VLAN:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
+ cfg->tnl_ena = false;
+ break;
+ case RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_VLAN_INNER;
+ cfg->tnl_ena = true;
+ break;
+ default:
+ break;
+ }
switch (cfg->alg) {
case ROC_NIX_BPF_ALGO_2697:
@@ -1090,23 +1222,51 @@ nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
}
static void
-nix_dscp_table_map(struct cnxk_meter_node *mtr,
- struct roc_nix_bpf_precolor *tbl)
+nix_precolor_table_map(struct cnxk_meter_node *mtr,
+ struct roc_nix_bpf_precolor *tbl)
{
enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
ROC_NIX_BPF_COLOR_YELLOW,
ROC_NIX_BPF_COLOR_RED};
int i;
- tbl->count = ROC_NIX_BPF_PRE_COLOR_MAX;
- tbl->mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
-
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
- tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
-
- if (mtr->params.dscp_table) {
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
- tbl->color[i] = color_map[mtr->params.dscp_table[i]];
+ switch (mtr->params.input_color_method) {
+ case RTE_MTR_INPUT_COLOR_METHOD_DSCP:
+ case RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP:
+ tbl->count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
+ tbl->mode = (mtr->params.input_color_method ==
+ RTE_MTR_INPUT_COLOR_METHOD_DSCP) ?
+ ROC_NIX_BPF_PC_MODE_DSCP_OUTER :
+ ROC_NIX_BPF_PC_MODE_DSCP_INNER;
+
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
+
+ if (mtr->params.dscp_table) {
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] =
+ color_map[mtr->params.dscp_table[i]];
+ }
+ break;
+ case RTE_MTR_INPUT_COLOR_METHOD_VLAN:
+ case RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN:
+ tbl->count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
+ tbl->mode = (mtr->params.input_color_method ==
+ RTE_MTR_INPUT_COLOR_METHOD_VLAN) ?
+ ROC_NIX_BPF_PC_MODE_VLAN_OUTER :
+ ROC_NIX_BPF_PC_MODE_VLAN_INNER;
+
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
+
+ if (mtr->params.vlan_table) {
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] =
+ color_map[mtr->params.vlan_table[i]];
+ }
+ break;
+ default:
+ break;
}
}
@@ -1245,7 +1405,7 @@ nix_mtr_configure(struct rte_eth_dev *eth_dev, uint32_t id)
memset(&tbl, 0,
sizeof(struct roc_nix_bpf_precolor));
- nix_dscp_table_map(mtr[i], &tbl);
+ nix_precolor_table_map(mtr[i], &tbl);
rc = roc_nix_bpf_pre_color_tbl_setup(nix,
mtr[i]->bpf_id, lvl_map[mtr[i]->level],
&tbl);
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v1 3/3] app/testpmd: support different input color method
2022-03-01 9:00 [PATCH v1 1/3] common/cnxk: update precolor table setup for VLAN skori
2022-03-01 9:00 ` [PATCH v1 2/3] net/cnxk: support ops to update precolor VLAN table skori
@ 2022-03-01 9:00 ` skori
2022-05-20 22:09 ` Ferruh Yigit
2022-05-24 7:35 ` [PATCH v2 1/1] " skori
1 sibling, 2 replies; 30+ messages in thread
From: skori @ 2022-03-01 9:00 UTC (permalink / raw)
To: Xiaoyun Li, Aman Singh, Yuying Zhang; +Cc: dev, Sunil Kumar Kori
From: Sunil Kumar Kori <skori@marvell.com>
Support for input coloring is added based on VLAN. Patch
adds support for the same.
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
app/test-pmd/cmdline.c | 1 +
app/test-pmd/cmdline_mtr.c | 348 ++++++++++++++++++++++++++++++++++++-
app/test-pmd/cmdline_mtr.h | 1 +
3 files changed, 342 insertions(+), 8 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 7ab0575e64..163e9c3fc9 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -17974,6 +17974,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
+ (cmdline_parse_inst_t *)&cmd_set_port_meter_vlan_table,
(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
(cmdline_parse_inst_t *)&cmd_mcast_addr,
diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index ad7ef6ad98..7532d454ae 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -14,6 +14,7 @@
#include "cmdline_mtr.h"
#define PARSE_DELIMITER " \f\n\r\t\v"
+#define MAX_VLAN_TABLE_ENTRIES 16
#define MAX_DSCP_TABLE_ENTRIES 64
/** Display Meter Error Message */
@@ -82,6 +83,125 @@ parse_uint(uint64_t *value, const char *str)
return 0;
}
+static int
+parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
+ enum rte_color **vlan_table)
+{
+ enum rte_color *vlan, *dscp;
+ char *token;
+ int i = 0;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for dscp table */
+ dscp = (enum rte_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (dscp == NULL)
+ return -1;
+
+ while (1) {
+ if (strcmp(token, "G") == 0 || strcmp(token, "g") == 0)
+ dscp[i++] = RTE_COLOR_GREEN;
+ else if (strcmp(token, "Y") == 0 || strcmp(token, "y") == 0)
+ dscp[i++] = RTE_COLOR_YELLOW;
+ else if (strcmp(token, "R") == 0 || strcmp(token, "r") == 0)
+ dscp[i++] = RTE_COLOR_RED;
+ else {
+ free(dscp);
+ return -1;
+ }
+ if (i == MAX_DSCP_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(dscp);
+ return -1;
+ }
+ }
+
+ *dscp_table = dscp;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for vlan tables */
+ vlan = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (vlan == NULL)
+ return -1;
+
+ i = 0;
+ while (1) {
+ if (strcmp(token, "G") == 0 || strcmp(token, "g") == 0)
+ vlan[i++] = RTE_COLOR_GREEN;
+ else if (strcmp(token, "Y") == 0 || strcmp(token, "y") == 0)
+ vlan[i++] = RTE_COLOR_YELLOW;
+ else if (strcmp(token, "R") == 0 || strcmp(token, "r") == 0)
+ vlan[i++] = RTE_COLOR_RED;
+ else {
+ free(vlan);
+ return -1;
+ }
+ if (i == MAX_VLAN_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(vlan);
+ return -1;
+ }
+ }
+
+ *vlan_table = vlan;
+ return 0;
+}
+
+static int
+parse_vlan_table_entries(char *str, enum rte_color **vlan_table)
+{
+ char *token;
+ int i = 0;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for vlan table */
+ *vlan_table = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (*vlan_table == NULL)
+ return -1;
+
+ while (1) {
+ if (strcmp(token, "G") == 0 ||
+ strcmp(token, "g") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_GREEN;
+ else if (strcmp(token, "Y") == 0 ||
+ strcmp(token, "y") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_YELLOW;
+ else if (strcmp(token, "R") == 0 ||
+ strcmp(token, "r") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_RED;
+ else {
+ free(*vlan_table);
+ return -1;
+ }
+ if (i == MAX_VLAN_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(*vlan_table);
+ return -1;
+ }
+ }
+ return 0;
+}
+
static int
parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
{
@@ -124,9 +244,59 @@ parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
return 0;
}
+static int
+parse_input_color_method(char *str, uint64_t *input_color_method)
+{
+ char *token;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ if (strcmp(token, "blind") == 0)
+ *input_color_method = RTE_MTR_INPUT_COLOR_METHOD_COLOR_BLIND;
+ else if (strcmp(token, "vlan") == 0)
+ *input_color_method = RTE_MTR_INPUT_COLOR_METHOD_VLAN;
+ else if (strcmp(token, "dscp") == 0)
+ *input_color_method = RTE_MTR_INPUT_COLOR_METHOD_DSCP;
+ else if (strcmp(token, "vlan_dscp") == 0)
+ *input_color_method = RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP;
+ else if (strcmp(token, "inner_vlan") == 0)
+ *input_color_method = RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN;
+ else if (strcmp(token, "inner_dscp") == 0)
+ *input_color_method = RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP;
+ else if (strcmp(token, "inner_vlan_dscp") == 0)
+ *input_color_method = RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP;
+ else
+ return -1;
+
+ return 0;
+}
+
+static int
+parse_default_input_color_str(char *str, uint64_t *def_inp_color)
+{
+ char *token;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ if ((strcmp(token, "G") == 0) || (strcmp(token, "g") == 0))
+ *def_inp_color = RTE_COLOR_GREEN;
+ else if ((strcmp(token, "Y") == 0) || (strcmp(token, "y") == 0))
+ *def_inp_color = RTE_COLOR_YELLOW;
+ else if ((strcmp(token, "R") == 0) || (strcmp(token, "r") == 0))
+ *def_inp_color = RTE_COLOR_RED;
+ else
+ return -1;
+
+ return 0;
+}
+
static int
parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
- enum rte_color **dscp_table)
+ enum rte_color **vlan_table, enum rte_color **dscp_table)
{
char *token;
uint64_t previous_mtr_color = 0;
@@ -147,8 +317,7 @@ parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
return 0;
}
- /* Parse dscp table entries */
- ret = parse_dscp_table_entries(c_str, dscp_table);
+ ret = parse_input_color_table_entries(c_str, dscp_table, vlan_table);
if (ret != 0)
return -1;
@@ -192,6 +361,43 @@ parse_multi_token_string(char *t_str, uint16_t *port_id,
return 0;
}
+static int
+parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
+ enum rte_color **vlan_table)
+{
+ uint64_t val;
+ char *token;
+ int ret;
+
+ /* First token: port id */
+ token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+ if (token == NULL)
+ return -1;
+
+ ret = parse_uint(&val, token);
+ if (ret != 0 || val > UINT16_MAX)
+ return -1;
+
+ *port_id = val;
+
+ /* Second token: meter id */
+ token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+ if (token == NULL)
+ return 0;
+
+ ret = parse_uint(&val, token);
+ if (ret != 0 || val > UINT32_MAX)
+ return -1;
+
+ *mtr_id = val;
+
+ ret = parse_vlan_table_entries(t_str, vlan_table);
+ if (ret != 0)
+ return -1;
+
+ return 0;
+}
+
/* *** Show Port Meter Capabilities *** */
struct cmd_show_port_meter_cap_result {
cmdline_fixed_string_t show;
@@ -277,6 +483,9 @@ static void cmd_show_port_meter_cap_parsed(void *parsed_result,
printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
cap.trtcm_rfc4115_packet_mode_supported);
printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
+ printf("cap.methods_mask 0x%" PRIx64 "\n", cap.methods_mask);
+ printf("cap.separate_input_color_table_per_port %" PRId32 "\n",
+ cap.separate_input_color_table_per_port);
}
cmdline_parse_inst_t cmd_show_port_meter_cap = {
@@ -721,6 +930,8 @@ struct cmd_create_port_meter_result {
cmdline_fixed_string_t r_action;
uint64_t statistics_mask;
uint32_t shared;
+ cmdline_fixed_string_t input_color_method;
+ cmdline_fixed_string_t default_input_color;
cmdline_multi_string_t meter_input_color;
};
@@ -763,6 +974,12 @@ cmdline_parse_token_num_t cmd_create_port_meter_statistics_mask =
cmdline_parse_token_num_t cmd_create_port_meter_shared =
TOKEN_NUM_INITIALIZER(struct cmd_create_port_meter_result,
shared, RTE_UINT32);
+cmdline_parse_token_string_t cmd_create_port_meter_input_color_method =
+ TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
+ input_color_method, "blind#vlan#dscp#vlan_dscp#inner_vlan#inner_dscp#inner_vlan_dscp");
+cmdline_parse_token_string_t cmd_create_port_meter_default_input_color =
+ TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
+ default_input_color, "R#Y#G#r#y#g");
cmdline_parse_token_string_t cmd_create_port_meter_input_color =
TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
meter_input_color, TOKEN_STRING_MULTI);
@@ -778,7 +995,12 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
uint32_t shared = res->shared;
uint32_t use_prev_meter_color = 0;
uint16_t port_id = res->port_id;
+ uint64_t input_color_method = 0;
+ uint64_t def_inp_color = 0;
enum rte_color *dscp_table = NULL;
+ enum rte_color *vlan_table = NULL;
+ char *def_color_str = res->default_input_color;
+ char *method_str = res->input_color_method;
char *c_str = res->meter_input_color;
int ret;
@@ -789,16 +1011,48 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
memset(¶ms, 0, sizeof(struct rte_mtr_params));
params.meter_profile_id = res->profile_id;
params.meter_policy_id = res->policy_id;
+
+ /* Parse meter input color method string params */
+ ret = parse_input_color_method(method_str, &input_color_method);
+ if (ret) {
+ fprintf(stderr,
+ " Meter input color method is invalid\n");
+ return;
+ }
+
+ /* Parse meter default input color string params */
+ ret = parse_default_input_color_str(def_color_str, &def_inp_color);
+ if (ret) {
+ fprintf(stderr,
+ " Meter default input color is invalid\n");
+ return;
+ }
+
/* Parse meter input color string params */
- ret = parse_meter_color_str(c_str, &use_prev_meter_color, &dscp_table);
+ ret = parse_meter_color_str(c_str, &use_prev_meter_color, &vlan_table,
+ &dscp_table);
if (ret) {
fprintf(stderr,
" Meter input color params string parse error\n");
return;
}
+ params.input_color_method = input_color_method;
params.use_prev_mtr_color = use_prev_meter_color;
- params.dscp_table = dscp_table;
+
+ if (input_color_method & RTE_MTR_INPUT_COLOR_METHOD_VLAN ||
+ input_color_method & RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN)
+ params.vlan_table = vlan_table;
+ else if (input_color_method & RTE_MTR_INPUT_COLOR_METHOD_DSCP ||
+ input_color_method & RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP)
+ params.dscp_table = dscp_table;
+ else if (input_color_method & RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP ||
+ input_color_method & RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP) {
+ params.vlan_table = vlan_table;
+ params.dscp_table = dscp_table;
+ }
+
+ params.default_input_color = def_inp_color;
if (strcmp(res->meter_enable, "yes") == 0)
params.meter_enable = 1;
@@ -817,9 +1071,12 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
cmdline_parse_inst_t cmd_create_port_meter = {
.f = cmd_create_port_meter_parsed,
.data = NULL,
- .help_str = "create port meter <port_id> <mtr_id> <profile_id> <meter_enable>(yes|no) "
- "<stats_mask> <shared> <use_pre_meter_color> "
- "[<dscp_tbl_entry0> <dscp_tbl_entry1> ...<dscp_tbl_entry63>]",
+ .help_str = "create port meter <port_id> <mtr_id> <profile_id> <policy_id> "
+ "<meter_enable>(yes|no) <stats_mask> <shared> "
+ "<input_color_method>(blind|vlan|dscp|vlan_dscp|inner_vlan|inner_dscp|inner_vlan_dscp) "
+ "<default_input_color>(g|y|r) <use_pre_meter_color> "
+ "[<dscp_tbl_entry0> <dscp_tbl_entry1> ... <dscp_tbl_entry63>]"
+ "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry16>]",
.tokens = {
(void *)&cmd_create_port_meter_create,
(void *)&cmd_create_port_meter_port,
@@ -831,6 +1088,8 @@ cmdline_parse_inst_t cmd_create_port_meter = {
(void *)&cmd_create_port_meter_meter_enable,
(void *)&cmd_create_port_meter_statistics_mask,
(void *)&cmd_create_port_meter_shared,
+ (void *)&cmd_create_port_meter_input_color_method,
+ (void *)&cmd_create_port_meter_default_input_color,
(void *)&cmd_create_port_meter_input_color,
NULL,
},
@@ -1233,6 +1492,79 @@ cmdline_parse_inst_t cmd_set_port_meter_dscp_table = {
},
};
+/* *** Set Port Meter VLAN Table *** */
+struct cmd_set_port_meter_vlan_table_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t vlan_table;
+ cmdline_multi_string_t token_string;
+};
+
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_set =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, set, "set");
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, port, "port");
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, meter, "meter");
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_vlan_table =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result,
+ vlan_table, "vlan table");
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_token_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_port_meter_vlan_table_result,
+ token_string, TOKEN_STRING_MULTI);
+
+static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_vlan_table_result *res = parsed_result;
+ struct rte_mtr_error error;
+ enum rte_color *vlan_table = NULL;
+ char *t_str = res->token_string;
+ uint32_t mtr_id = 0;
+ uint16_t port_id;
+ int ret;
+
+ /* Parse string */
+ ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &vlan_table);
+ if (ret) {
+ fprintf(stderr, " Multi token string parse error\n");
+ return;
+ }
+
+ if (port_id_is_invalid(port_id, ENABLED_WARN))
+ goto free_table;
+
+ /* Update Meter VLAN Table*/
+ ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id,
+ vlan_table, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+
+free_table:
+ free(vlan_table);
+}
+
+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> "
+ "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry15>]",
+ .tokens = {
+ (void *)&cmd_set_port_meter_vlan_table_set,
+ (void *)&cmd_set_port_meter_vlan_table_port,
+ (void *)&cmd_set_port_meter_vlan_table_meter,
+ (void *)&cmd_set_port_meter_vlan_table_vlan_table,
+ (void *)&cmd_set_port_meter_vlan_table_token_string,
+ NULL,
+ },
+};
+
/* *** Set Port Meter Stats Mask *** */
struct cmd_set_port_meter_stats_mask_result {
cmdline_fixed_string_t set;
diff --git a/app/test-pmd/cmdline_mtr.h b/app/test-pmd/cmdline_mtr.h
index 2415fc16c3..e11cd6a23b 100644
--- a/app/test-pmd/cmdline_mtr.h
+++ b/app/test-pmd/cmdline_mtr.h
@@ -19,6 +19,7 @@ extern cmdline_parse_inst_t cmd_del_port_meter;
extern cmdline_parse_inst_t cmd_del_port_meter_policy;
extern cmdline_parse_inst_t cmd_set_port_meter_profile;
extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;
+extern cmdline_parse_inst_t cmd_set_port_meter_vlan_table;
extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;
extern cmdline_parse_inst_t cmd_show_port_meter_stats;
void print_mtr_err_msg(struct rte_mtr_error *error);
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v1 3/3] app/testpmd: support different input color method
2022-03-01 9:00 ` [PATCH v1 3/3] app/testpmd: support different input color method skori
@ 2022-05-20 22:09 ` Ferruh Yigit
2022-05-21 7:07 ` [EXT] " Sunil Kumar Kori
2022-05-24 7:35 ` [PATCH v2 1/1] " skori
1 sibling, 1 reply; 30+ messages in thread
From: Ferruh Yigit @ 2022-05-20 22:09 UTC (permalink / raw)
To: Aman Singh, Yuying Zhang, Dumitrescu, Cristian; +Cc: dev, Xiaoyun Li, skori
On 3/1/2022 9:00 AM, skori@marvell.com wrote:
> From: Sunil Kumar Kori <skori@marvell.com>
>
> Support for input coloring is added based on VLAN. Patch
> adds support for the same.
>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Hi Aman, Yuying, Cristian,
Can you please review this patch?
For reference, patchwork link:
https://patches.dpdk.org/project/dpdk/patch/20220301090056.1042866-3-skori@marvell.com/
Thanks,
ferruh
<...>
^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [EXT] Re: [PATCH v1 3/3] app/testpmd: support different input color method
2022-05-20 22:09 ` Ferruh Yigit
@ 2022-05-21 7:07 ` Sunil Kumar Kori
2022-05-23 8:43 ` Ferruh Yigit
0 siblings, 1 reply; 30+ messages in thread
From: Sunil Kumar Kori @ 2022-05-21 7:07 UTC (permalink / raw)
To: Ferruh Yigit, Aman Singh, Yuying Zhang, Dumitrescu, Cristian
Cc: dev, Xiaoyun Li
Hi All,
Please hold on for review as this version is not aligned with latest spec changes for input coloring mechanism.
I will be sending the next version soon.
Regards
Sunil Kumar Kori
> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@amd.com>
> Sent: Saturday, May 21, 2022 3:40 AM
> To: Aman Singh <aman.deep.singh@intel.com>; Yuying Zhang
> <yuying.zhang@intel.com>; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org; Xiaoyun Li <xiaoyun.li@intel.com>; Sunil Kumar Kori
> <skori@marvell.com>
> Subject: [EXT] Re: [PATCH v1 3/3] app/testpmd: support different input color
> method
>
> External Email
>
> ----------------------------------------------------------------------
> On 3/1/2022 9:00 AM, skori@marvell.com wrote:
> > From: Sunil Kumar Kori <skori@marvell.com>
> >
> > Support for input coloring is added based on VLAN. Patch adds support
> > for the same.
> >
> > Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
>
> Hi Aman, Yuying, Cristian,
>
> Can you please review this patch?
>
> For reference, patchwork link:
> https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__patches.dpdk.org_project_dpdk_patch_20220301090056.1042866-2D3-
> 2Dskori-
> 40marvell.com_&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=dXeXaAMkP5
> COgn1zxHMyaF1_d9IIuq6vHQO6NrIPjaE&m=uIZoPQrybNRc6RaCYoz6lsx8OQ
> m-1PThzgOBgBfL8h20GBu0JfP6oMBiNjYar1aV&s=WheQ6sKU9cqUgxfRSIKeK-
> MPmvalcreMKqAUKnNsmLA&e=
>
> Thanks,
> ferruh
>
> <...>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [EXT] Re: [PATCH v1 3/3] app/testpmd: support different input color method
2022-05-21 7:07 ` [EXT] " Sunil Kumar Kori
@ 2022-05-23 8:43 ` Ferruh Yigit
0 siblings, 0 replies; 30+ messages in thread
From: Ferruh Yigit @ 2022-05-23 8:43 UTC (permalink / raw)
To: Sunil Kumar Kori, Aman Singh, Yuying Zhang, Dumitrescu, Cristian
Cc: dev, Xiaoyun Li
On 5/21/2022 8:07 AM, Sunil Kumar Kori wrote:
>> -----Original Message-----
>> From: Ferruh Yigit <ferruh.yigit@amd.com>
>> Sent: Saturday, May 21, 2022 3:40 AM
>> To: Aman Singh <aman.deep.singh@intel.com>; Yuying Zhang
>> <yuying.zhang@intel.com>; Dumitrescu, Cristian
>> <cristian.dumitrescu@intel.com>
>> Cc: dev@dpdk.org; Xiaoyun Li <xiaoyun.li@intel.com>; Sunil Kumar Kori
>> <skori@marvell.com>
>> Subject: [EXT] Re: [PATCH v1 3/3] app/testpmd: support different input color
>> method
>>
>> External Email
>>
>> ----------------------------------------------------------------------
>> On 3/1/2022 9:00 AM, skori@marvell.com wrote:
>>> From: Sunil Kumar Kori <skori@marvell.com>
>>>
>>> Support for input coloring is added based on VLAN. Patch adds support
>>> for the same.
>>>
>>> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
>>
>> Hi Aman, Yuying, Cristian,
>>
>> Can you please review this patch?
>>
>> For reference, patchwork link:
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.proofpoint.com%2Fv2%2Furl%3Fu%3Dhttps-&data=05%7C01%7Cferruh.yigit%40amd.com%7Ce3cbe685c77d437747d608da3af89455%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637887136571202419%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=aIc21bBnNI6YnIo7p0FFxWWibeNsJJbr53IoI15SUJY%3D&reserved=0
>> 3A__patches.dpdk.org_project_dpdk_patch_20220301090056.1042866-2D3-
>> 2Dskori-
>> 40marvell.com_&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=dXeXaAMkP5
>> COgn1zxHMyaF1_d9IIuq6vHQO6NrIPjaE&m=uIZoPQrybNRc6RaCYoz6lsx8OQ
>> m-1PThzgOBgBfL8h20GBu0JfP6oMBiNjYar1aV&s=WheQ6sKU9cqUgxfRSIKeK-
>> MPmvalcreMKqAUKnNsmLA&e=
>>
>> Thanks,
>> ferruh
>> >
> Hi All,
>
> Please hold on for review as this version is not aligned with latest
spec changes for input coloring mechanism.
> I will be sending the next version soon.
>
Thanks for heads up Sunil,
I updated patch status as "Changes Requested".
> Regards
> Sunil Kumar Kori
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v2 1/1] app/testpmd: support different input color method
2022-03-01 9:00 ` [PATCH v1 3/3] app/testpmd: support different input color method skori
2022-05-20 22:09 ` Ferruh Yigit
@ 2022-05-24 7:35 ` skori
2022-05-25 12:36 ` Dumitrescu, Cristian
2022-05-25 14:37 ` skori
1 sibling, 2 replies; 30+ messages in thread
From: skori @ 2022-05-24 7:35 UTC (permalink / raw)
To: Xiaoyun Li, Aman Singh, Yuying Zhang, Cristian Dumitrescu
Cc: dev, Sunil Kumar Kori
From: Sunil Kumar Kori <skori@marvell.com>
To enable input coloring, based on VLAN or DSCP, patch adds
command line interface to configure the following:
- configuring input coloring using VLAN or DSCP while creating
meter i.e. during rte_mtr_create()
- Update VLAN input coloring table at runtime.
- configures protocol priorities.
- retrieve protocol and priority information
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v1..v2:
- Rebased to branch dpdk-next-net
- add CLIs for input coloring mechanism
app/test-pmd/cmdline.c | 4 +
app/test-pmd/cmdline_mtr.c | 558 ++++++++++++++++++++++++++++++++++++-
app/test-pmd/cmdline_mtr.h | 4 +
3 files changed, 559 insertions(+), 7 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 1e5b294ab3..03647b2543 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -17972,6 +17972,10 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
+ (cmdline_parse_inst_t *)&cmd_set_port_meter_vlan_table,
+ (cmdline_parse_inst_t *)&cmd_set_port_meter_in_proto,
+ (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto,
+ (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto_prio,
(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
(cmdline_parse_inst_t *)&cmd_mcast_addr,
diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index ad7ef6ad98..28ec92ad50 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -14,6 +14,7 @@
#include "cmdline_mtr.h"
#define PARSE_DELIMITER " \f\n\r\t\v"
+#define MAX_VLAN_TABLE_ENTRIES 16
#define MAX_DSCP_TABLE_ENTRIES 64
/** Display Meter Error Message */
@@ -82,6 +83,125 @@ parse_uint(uint64_t *value, const char *str)
return 0;
}
+static int
+parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
+ enum rte_color **vlan_table)
+{
+ enum rte_color *vlan, *dscp;
+ char *token;
+ int i = 0;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for dscp table */
+ dscp = (enum rte_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (dscp == NULL)
+ return -1;
+
+ while (1) {
+ if (strcmp(token, "G") == 0 || strcmp(token, "g") == 0)
+ dscp[i++] = RTE_COLOR_GREEN;
+ else if (strcmp(token, "Y") == 0 || strcmp(token, "y") == 0)
+ dscp[i++] = RTE_COLOR_YELLOW;
+ else if (strcmp(token, "R") == 0 || strcmp(token, "r") == 0)
+ dscp[i++] = RTE_COLOR_RED;
+ else {
+ free(dscp);
+ return -1;
+ }
+ if (i == MAX_DSCP_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(dscp);
+ return -1;
+ }
+ }
+
+ *dscp_table = dscp;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for vlan table */
+ vlan = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (vlan == NULL)
+ return -1;
+
+ i = 0;
+ while (1) {
+ if (strcmp(token, "G") == 0 || strcmp(token, "g") == 0)
+ vlan[i++] = RTE_COLOR_GREEN;
+ else if (strcmp(token, "Y") == 0 || strcmp(token, "y") == 0)
+ vlan[i++] = RTE_COLOR_YELLOW;
+ else if (strcmp(token, "R") == 0 || strcmp(token, "r") == 0)
+ vlan[i++] = RTE_COLOR_RED;
+ else {
+ free(vlan);
+ return -1;
+ }
+ if (i == MAX_VLAN_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(vlan);
+ return -1;
+ }
+ }
+
+ *vlan_table = vlan;
+ return 0;
+}
+
+static int
+parse_vlan_table_entries(char *str, enum rte_color **vlan_table)
+{
+ char *token;
+ int i = 0;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for vlan table */
+ *vlan_table = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (*vlan_table == NULL)
+ return -1;
+
+ while (1) {
+ if (strcmp(token, "G") == 0 ||
+ strcmp(token, "g") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_GREEN;
+ else if (strcmp(token, "Y") == 0 ||
+ strcmp(token, "y") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_YELLOW;
+ else if (strcmp(token, "R") == 0 ||
+ strcmp(token, "r") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_RED;
+ else {
+ free(*vlan_table);
+ return -1;
+ }
+ if (i == MAX_VLAN_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(*vlan_table);
+ return -1;
+ }
+ }
+ return 0;
+}
+
static int
parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
{
@@ -124,9 +244,30 @@ parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
return 0;
}
+static int
+parse_default_input_color_str(char *str, uint64_t *def_inp_color)
+{
+ char *token;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ if ((strcmp(token, "G") == 0) || (strcmp(token, "g") == 0))
+ *def_inp_color = RTE_COLOR_GREEN;
+ else if ((strcmp(token, "Y") == 0) || (strcmp(token, "y") == 0))
+ *def_inp_color = RTE_COLOR_YELLOW;
+ else if ((strcmp(token, "R") == 0) || (strcmp(token, "r") == 0))
+ *def_inp_color = RTE_COLOR_RED;
+ else
+ return -1;
+
+ return 0;
+}
+
static int
parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
- enum rte_color **dscp_table)
+ enum rte_color **vlan_table, enum rte_color **dscp_table)
{
char *token;
uint64_t previous_mtr_color = 0;
@@ -147,8 +288,7 @@ parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
return 0;
}
- /* Parse dscp table entries */
- ret = parse_dscp_table_entries(c_str, dscp_table);
+ ret = parse_input_color_table_entries(c_str, dscp_table, vlan_table);
if (ret != 0)
return -1;
@@ -192,6 +332,43 @@ parse_multi_token_string(char *t_str, uint16_t *port_id,
return 0;
}
+static int
+parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
+ enum rte_color **vlan_table)
+{
+ uint64_t val;
+ char *token;
+ int ret;
+
+ /* First token: port id */
+ token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+ if (token == NULL)
+ return -1;
+
+ ret = parse_uint(&val, token);
+ if (ret != 0 || val > UINT16_MAX)
+ return -1;
+
+ *port_id = val;
+
+ /* Second token: meter id */
+ token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+ if (token == NULL)
+ return 0;
+
+ ret = parse_uint(&val, token);
+ if (ret != 0 || val > UINT32_MAX)
+ return -1;
+
+ *mtr_id = val;
+
+ ret = parse_vlan_table_entries(t_str, vlan_table);
+ if (ret != 0)
+ return -1;
+
+ return 0;
+}
+
/* *** Show Port Meter Capabilities *** */
struct cmd_show_port_meter_cap_result {
cmdline_fixed_string_t show;
@@ -277,6 +454,10 @@ static void cmd_show_port_meter_cap_parsed(void *parsed_result,
printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
cap.trtcm_rfc4115_packet_mode_supported);
printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
+ printf("cap.input_color_proto_mask 0x%" PRIx64 "\n",
+ cap.input_color_proto_mask);
+ printf("cap.separate_input_color_table_per_port %" PRId32 "\n",
+ cap.separate_input_color_table_per_port);
}
cmdline_parse_inst_t cmd_show_port_meter_cap = {
@@ -721,6 +902,7 @@ struct cmd_create_port_meter_result {
cmdline_fixed_string_t r_action;
uint64_t statistics_mask;
uint32_t shared;
+ cmdline_fixed_string_t default_input_color;
cmdline_multi_string_t meter_input_color;
};
@@ -763,6 +945,9 @@ cmdline_parse_token_num_t cmd_create_port_meter_statistics_mask =
cmdline_parse_token_num_t cmd_create_port_meter_shared =
TOKEN_NUM_INITIALIZER(struct cmd_create_port_meter_result,
shared, RTE_UINT32);
+cmdline_parse_token_string_t cmd_create_port_meter_default_input_color =
+ TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
+ default_input_color, "R#Y#G#r#y#g");
cmdline_parse_token_string_t cmd_create_port_meter_input_color =
TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
meter_input_color, TOKEN_STRING_MULTI);
@@ -778,7 +963,10 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
uint32_t shared = res->shared;
uint32_t use_prev_meter_color = 0;
uint16_t port_id = res->port_id;
+ uint64_t def_inp_color = 0;
enum rte_color *dscp_table = NULL;
+ enum rte_color *vlan_table = NULL;
+ char *def_color_str = res->default_input_color;
char *c_str = res->meter_input_color;
int ret;
@@ -789,8 +977,18 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
memset(¶ms, 0, sizeof(struct rte_mtr_params));
params.meter_profile_id = res->profile_id;
params.meter_policy_id = res->policy_id;
+
+ /* Parse meter default input color string params */
+ ret = parse_default_input_color_str(def_color_str, &def_inp_color);
+ if (ret) {
+ fprintf(stderr,
+ " Meter default input color is invalid\n");
+ return;
+ }
+
/* Parse meter input color string params */
- ret = parse_meter_color_str(c_str, &use_prev_meter_color, &dscp_table);
+ ret = parse_meter_color_str(c_str, &use_prev_meter_color, &vlan_table,
+ &dscp_table);
if (ret) {
fprintf(stderr,
" Meter input color params string parse error\n");
@@ -798,16 +996,20 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
}
params.use_prev_mtr_color = use_prev_meter_color;
+ params.vlan_table = vlan_table;
params.dscp_table = dscp_table;
+ params.default_input_color = def_inp_color;
if (strcmp(res->meter_enable, "yes") == 0)
params.meter_enable = 1;
else
params.meter_enable = 0;
+
params.stats_mask = res->statistics_mask;
ret = rte_mtr_create(port_id, mtr_id, ¶ms, shared, &error);
if (ret != 0) {
+ free(vlan_table);
free(dscp_table);
print_err_msg(&error);
return;
@@ -817,9 +1019,11 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
cmdline_parse_inst_t cmd_create_port_meter = {
.f = cmd_create_port_meter_parsed,
.data = NULL,
- .help_str = "create port meter <port_id> <mtr_id> <profile_id> <meter_enable>(yes|no) "
- "<stats_mask> <shared> <use_pre_meter_color> "
- "[<dscp_tbl_entry0> <dscp_tbl_entry1> ...<dscp_tbl_entry63>]",
+ .help_str = "create port meter <port_id> <mtr_id> <profile_id> <policy_id> "
+ "<meter_enable>(yes|no) <stats_mask> <shared> "
+ "<default_input_color>(g|y|r) <use_pre_meter_color> "
+ "[<dscp_tbl_entry0> <dscp_tbl_entry1> ... <dscp_tbl_entry63>]"
+ "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry16>]",
.tokens = {
(void *)&cmd_create_port_meter_create,
(void *)&cmd_create_port_meter_port,
@@ -831,6 +1035,7 @@ cmdline_parse_inst_t cmd_create_port_meter = {
(void *)&cmd_create_port_meter_meter_enable,
(void *)&cmd_create_port_meter_statistics_mask,
(void *)&cmd_create_port_meter_shared,
+ (void *)&cmd_create_port_meter_default_input_color,
(void *)&cmd_create_port_meter_input_color,
NULL,
},
@@ -1233,6 +1438,345 @@ cmdline_parse_inst_t cmd_set_port_meter_dscp_table = {
},
};
+/* *** Set Port Meter VLAN Table *** */
+struct cmd_set_port_meter_vlan_table_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t vlan_table;
+ cmdline_multi_string_t token_string;
+};
+
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_set =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, set, "set");
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, port, "port");
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, meter, "meter");
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_vlan_table =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result,
+ vlan_table, "vlan table");
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_token_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_port_meter_vlan_table_result,
+ token_string, TOKEN_STRING_MULTI);
+
+static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_vlan_table_result *res = parsed_result;
+ struct rte_mtr_error error;
+ enum rte_color *vlan_table = NULL;
+ char *t_str = res->token_string;
+ uint32_t mtr_id = 0;
+ uint16_t port_id;
+ int ret;
+
+ /* Parse string */
+ ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &vlan_table);
+ if (ret) {
+ fprintf(stderr, " Multi token string parse error\n");
+ return;
+ }
+
+ if (port_id_is_invalid(port_id, ENABLED_WARN))
+ goto free_table;
+
+ /* Update Meter VLAN Table*/
+ ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id,
+ vlan_table, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+
+free_table:
+ free(vlan_table);
+}
+
+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> "
+ "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry15>]",
+ .tokens = {
+ (void *)&cmd_set_port_meter_vlan_table_set,
+ (void *)&cmd_set_port_meter_vlan_table_port,
+ (void *)&cmd_set_port_meter_vlan_table_meter,
+ (void *)&cmd_set_port_meter_vlan_table_vlan_table,
+ (void *)&cmd_set_port_meter_vlan_table_token_string,
+ NULL,
+ },
+};
+
+/* *** Set Port Meter input protocol *** */
+struct cmd_set_port_meter_in_proto_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ cmdline_fixed_string_t proto;
+ uint32_t prio;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+cmdline_parse_token_string_t cmd_set_port_meter_in_proto_set =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, set, "set");
+
+cmdline_parse_token_string_t cmd_set_port_meter_in_proto_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, port, "port");
+
+cmdline_parse_token_string_t cmd_set_port_meter_in_proto_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, meter, "meter");
+
+cmdline_parse_token_string_t cmd_set_port_meter_in_proto_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, protocol, "proto");
+
+cmdline_parse_token_string_t cmd_set_port_meter_in_proto_proto =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, proto,
+ "outer_vlan#inner_vlan#outer_ip#inner_ip");
+
+cmdline_parse_token_num_t cmd_set_port_meter_in_proto_prio =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, prio, RTE_UINT32);
+
+cmdline_parse_token_num_t cmd_set_port_meter_in_proto_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, port_id, RTE_UINT16);
+
+cmdline_parse_token_num_t cmd_set_port_meter_in_proto_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, mtr_id, RTE_UINT32);
+
+static void cmd_set_port_meter_in_proto_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_in_proto_result *res = parsed_result;
+ enum rte_mtr_color_in_protocol proto = 0;
+ struct rte_mtr_error error;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ if (strcmp(res->proto, "outer_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
+ else if (strcmp(res->proto, "inner_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
+ else if (strcmp(res->proto, "outer_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
+ else if (strcmp(res->proto, "inner_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
+ else {
+ printf("Invalid protocol\n");
+ return;
+ }
+
+ /* Update Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_set(res->port_id, res->mtr_id,
+ proto, res->prio, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+}
+
+cmdline_parse_inst_t cmd_set_port_meter_in_proto = {
+ .f = cmd_set_port_meter_in_proto_parsed,
+ .data = NULL,
+ .help_str = "set port meter proto <port_id> <mtr_id> <proto> "
+ "<prio>",
+ .tokens = {
+ (void *)&cmd_set_port_meter_in_proto_set,
+ (void *)&cmd_set_port_meter_in_proto_port,
+ (void *)&cmd_set_port_meter_in_proto_meter,
+ (void *)&cmd_set_port_meter_in_proto_protocol,
+ (void *)&cmd_set_port_meter_in_proto_port_id,
+ (void *)&cmd_set_port_meter_in_proto_mtr_id,
+ (void *)&cmd_set_port_meter_in_proto_proto,
+ (void *)&cmd_set_port_meter_in_proto_prio,
+ NULL,
+ },
+};
+
+/* *** Get Port Meter input protocol *** */
+struct cmd_get_port_meter_in_proto_result {
+ cmdline_fixed_string_t get;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_get =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, get, "get");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, port, "port");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, meter, "meter");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, protocol, "proto");
+
+cmdline_parse_token_num_t cmd_get_port_meter_in_proto_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, port_id, RTE_UINT16);
+
+cmdline_parse_token_num_t cmd_get_port_meter_in_proto_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, mtr_id, RTE_UINT32);
+
+static void cmd_get_port_meter_in_proto_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_in_proto_result *res = parsed_result;
+ struct rte_mtr_error error;
+ uint64_t proto_mask = 0;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ /* Update Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_get(res->port_id, res->mtr_id,
+ &proto_mask, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+
+ printf("Enabled protocols:\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN)
+ printf("\touter_vlan\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_VLAN)
+ printf("\tinner_vlan\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_IP)
+ printf("\touter_ip\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_IP)
+ printf("\tinner_ip\n");
+}
+
+cmdline_parse_inst_t cmd_get_port_meter_in_proto = {
+ .f = cmd_get_port_meter_in_proto_parsed,
+ .data = NULL,
+ .help_str = "get port meter proto <port_id> <mtr_id>",
+ .tokens = {
+ (void *)&cmd_get_port_meter_in_proto_get,
+ (void *)&cmd_get_port_meter_in_proto_port,
+ (void *)&cmd_get_port_meter_in_proto_meter,
+ (void *)&cmd_get_port_meter_in_proto_protocol,
+ (void *)&cmd_get_port_meter_in_proto_port_id,
+ (void *)&cmd_get_port_meter_in_proto_mtr_id,
+ NULL,
+ },
+};
+
+/* *** Get Port Meter input protocol priority *** */
+struct cmd_get_port_meter_in_proto_prio_result {
+ cmdline_fixed_string_t get;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ cmdline_fixed_string_t proto;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_get =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, get, "get");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, port, "port");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, meter, "meter");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, protocol,
+ "proto_prio");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_proto =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, proto,
+ "outer_vlan#inner_vlan#outer_ip#inner_ip");
+
+cmdline_parse_token_num_t cmd_get_port_meter_in_proto_prio_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, port_id,
+ RTE_UINT16);
+
+cmdline_parse_token_num_t cmd_get_port_meter_in_proto_prio_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, mtr_id,
+ RTE_UINT32);
+
+
+static void cmd_get_port_meter_in_proto_prio_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_get_port_meter_in_proto_prio_result *res = parsed_result;
+ enum rte_mtr_color_in_protocol proto;
+ struct rte_mtr_error error;
+ uint32_t prio = 0;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ if (strcmp(res->proto, "outer_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
+ else if (strcmp(res->proto, "inner_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
+ else if (strcmp(res->proto, "outer_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
+ else if (strcmp(res->proto, "inner_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
+ else {
+ printf("Invalid protocol\n");
+ return;
+ }
+
+ /* Get Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_priority_get(res->port_id, res->mtr_id,
+ proto, &prio, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+}
+
+cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio = {
+ .f = cmd_get_port_meter_in_proto_prio_parsed,
+ .data = NULL,
+ .help_str = "get port meter proto_prio <port_id> <mtr_id> <proto>",
+ .tokens = {
+ (void *)&cmd_get_port_meter_in_proto_prio_get,
+ (void *)&cmd_get_port_meter_in_proto_prio_port,
+ (void *)&cmd_get_port_meter_in_proto_prio_meter,
+ (void *)&cmd_get_port_meter_in_proto_prio_protocol,
+ (void *)&cmd_get_port_meter_in_proto_prio_port_id,
+ (void *)&cmd_get_port_meter_in_proto_prio_mtr_id,
+ (void *)&cmd_get_port_meter_in_proto_prio_proto,
+ NULL,
+ },
+};
+
/* *** Set Port Meter Stats Mask *** */
struct cmd_set_port_meter_stats_mask_result {
cmdline_fixed_string_t set;
diff --git a/app/test-pmd/cmdline_mtr.h b/app/test-pmd/cmdline_mtr.h
index 2415fc16c3..23eaa5bc03 100644
--- a/app/test-pmd/cmdline_mtr.h
+++ b/app/test-pmd/cmdline_mtr.h
@@ -19,6 +19,10 @@ extern cmdline_parse_inst_t cmd_del_port_meter;
extern cmdline_parse_inst_t cmd_del_port_meter_policy;
extern cmdline_parse_inst_t cmd_set_port_meter_profile;
extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;
+extern cmdline_parse_inst_t cmd_set_port_meter_vlan_table;
+extern cmdline_parse_inst_t cmd_set_port_meter_in_proto;
+extern cmdline_parse_inst_t cmd_get_port_meter_in_proto;
+extern cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio;
extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;
extern cmdline_parse_inst_t cmd_show_port_meter_stats;
void print_mtr_err_msg(struct rte_mtr_error *error);
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [PATCH v2 1/1] app/testpmd: support different input color method
2022-05-24 7:35 ` [PATCH v2 1/1] " skori
@ 2022-05-25 12:36 ` Dumitrescu, Cristian
2022-05-25 14:32 ` Sunil Kumar Kori
2022-05-25 14:37 ` skori
1 sibling, 1 reply; 30+ messages in thread
From: Dumitrescu, Cristian @ 2022-05-25 12:36 UTC (permalink / raw)
To: skori, Li, Xiaoyun, Singh, Aman Deep, Zhang, Yuying; +Cc: dev
> -----Original Message-----
> From: skori@marvell.com <skori@marvell.com>
> Sent: Tuesday, May 24, 2022 8:36 AM
> To: Li, Xiaoyun <xiaoyun.li@intel.com>; Singh, Aman Deep
> <aman.deep.singh@intel.com>; Zhang, Yuying <yuying.zhang@intel.com>;
> Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org; Sunil Kumar Kori <skori@marvell.com>
> Subject: [PATCH v2 1/1] app/testpmd: support different input color method
>
> From: Sunil Kumar Kori <skori@marvell.com>
>
> To enable input coloring, based on VLAN or DSCP, patch adds
> command line interface to configure the following:
>
> - configuring input coloring using VLAN or DSCP while creating
> meter i.e. during rte_mtr_create()
>
> - Update VLAN input coloring table at runtime.
>
> - configures protocol priorities.
>
> - retrieve protocol and priority information
>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> ---
Sunil,
Please send a V2 with the "Depends on: " properly set to indicate that Jerin's patch needs to be apply first in order to avoid patch apply failure.
Regards,
Cristian
^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [PATCH v2 1/1] app/testpmd: support different input color method
2022-05-25 12:36 ` Dumitrescu, Cristian
@ 2022-05-25 14:32 ` Sunil Kumar Kori
0 siblings, 0 replies; 30+ messages in thread
From: Sunil Kumar Kori @ 2022-05-25 14:32 UTC (permalink / raw)
To: Dumitrescu, Cristian, Li, Xiaoyun, Singh, Aman Deep, Zhang, Yuying; +Cc: dev
> -----Original Message-----
> From: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Sent: Wednesday, May 25, 2022 6:07 PM
> To: Sunil Kumar Kori <skori@marvell.com>; Li, Xiaoyun
> <xiaoyun.li@intel.com>; Singh, Aman Deep <aman.deep.singh@intel.com>;
> Zhang, Yuying <yuying.zhang@intel.com>
> Cc: dev@dpdk.org
> Subject: [EXT] RE: [PATCH v2 1/1] app/testpmd: support different input color
> method
>
> External Email
>
> ----------------------------------------------------------------------
>
>
> > -----Original Message-----
> > From: skori@marvell.com <skori@marvell.com>
> > Sent: Tuesday, May 24, 2022 8:36 AM
> > To: Li, Xiaoyun <xiaoyun.li@intel.com>; Singh, Aman Deep
> > <aman.deep.singh@intel.com>; Zhang, Yuying <yuying.zhang@intel.com>;
> > Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> > Cc: dev@dpdk.org; Sunil Kumar Kori <skori@marvell.com>
> > Subject: [PATCH v2 1/1] app/testpmd: support different input color
> > method
> >
> > From: Sunil Kumar Kori <skori@marvell.com>
> >
> > To enable input coloring, based on VLAN or DSCP, patch adds command
> > line interface to configure the following:
> >
> > - configuring input coloring using VLAN or DSCP while creating
> > meter i.e. during rte_mtr_create()
> >
> > - Update VLAN input coloring table at runtime.
> >
> > - configures protocol priorities.
> >
> > - retrieve protocol and priority information
> >
> > Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> > ---
>
> Sunil,
>
> Please send a V2 with the "Depends on: " properly set to indicate that Jerin's
> patch needs to be apply first in order to avoid patch apply failure.
>
Sure, Will update.
> Regards,
> Cristian
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v2 1/1] app/testpmd: support different input color method
2022-05-24 7:35 ` [PATCH v2 1/1] " skori
2022-05-25 12:36 ` Dumitrescu, Cristian
@ 2022-05-25 14:37 ` skori
2022-05-25 14:41 ` Dumitrescu, Cristian
2022-06-03 13:06 ` [PATCH v3 " skori
1 sibling, 2 replies; 30+ messages in thread
From: skori @ 2022-05-25 14:37 UTC (permalink / raw)
To: Xiaoyun Li, Aman Singh, Yuying Zhang, Cristian Dumitrescu
Cc: dev, Sunil Kumar Kori
From: Sunil Kumar Kori <skori@marvell.com>
To enable input coloring, based on VLAN or DSCP, patch adds
command line interface to configure the following:
- configuring input coloring using VLAN or DSCP while creating
meter i.e. during rte_mtr_create()
- Update VLAN input coloring table at runtime.
- configures protocol priorities.
- retrieve protocol and priority information
Depends-on: patch-22751 ("ethdev: mtr: support protocol based input color selection")
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v1..v2:
- Rebased to branch dpdk-next-net
- add CLIs for input coloring mechanism
app/test-pmd/cmdline.c | 4 +
app/test-pmd/cmdline_mtr.c | 558 ++++++++++++++++++++++++++++++++++++-
app/test-pmd/cmdline_mtr.h | 4 +
3 files changed, 559 insertions(+), 7 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 1e5b294ab3..03647b2543 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -17972,6 +17972,10 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
+ (cmdline_parse_inst_t *)&cmd_set_port_meter_vlan_table,
+ (cmdline_parse_inst_t *)&cmd_set_port_meter_in_proto,
+ (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto,
+ (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto_prio,
(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
(cmdline_parse_inst_t *)&cmd_mcast_addr,
diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index ad7ef6ad98..28ec92ad50 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -14,6 +14,7 @@
#include "cmdline_mtr.h"
#define PARSE_DELIMITER " \f\n\r\t\v"
+#define MAX_VLAN_TABLE_ENTRIES 16
#define MAX_DSCP_TABLE_ENTRIES 64
/** Display Meter Error Message */
@@ -82,6 +83,125 @@ parse_uint(uint64_t *value, const char *str)
return 0;
}
+static int
+parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
+ enum rte_color **vlan_table)
+{
+ enum rte_color *vlan, *dscp;
+ char *token;
+ int i = 0;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for dscp table */
+ dscp = (enum rte_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (dscp == NULL)
+ return -1;
+
+ while (1) {
+ if (strcmp(token, "G") == 0 || strcmp(token, "g") == 0)
+ dscp[i++] = RTE_COLOR_GREEN;
+ else if (strcmp(token, "Y") == 0 || strcmp(token, "y") == 0)
+ dscp[i++] = RTE_COLOR_YELLOW;
+ else if (strcmp(token, "R") == 0 || strcmp(token, "r") == 0)
+ dscp[i++] = RTE_COLOR_RED;
+ else {
+ free(dscp);
+ return -1;
+ }
+ if (i == MAX_DSCP_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(dscp);
+ return -1;
+ }
+ }
+
+ *dscp_table = dscp;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for vlan table */
+ vlan = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (vlan == NULL)
+ return -1;
+
+ i = 0;
+ while (1) {
+ if (strcmp(token, "G") == 0 || strcmp(token, "g") == 0)
+ vlan[i++] = RTE_COLOR_GREEN;
+ else if (strcmp(token, "Y") == 0 || strcmp(token, "y") == 0)
+ vlan[i++] = RTE_COLOR_YELLOW;
+ else if (strcmp(token, "R") == 0 || strcmp(token, "r") == 0)
+ vlan[i++] = RTE_COLOR_RED;
+ else {
+ free(vlan);
+ return -1;
+ }
+ if (i == MAX_VLAN_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(vlan);
+ return -1;
+ }
+ }
+
+ *vlan_table = vlan;
+ return 0;
+}
+
+static int
+parse_vlan_table_entries(char *str, enum rte_color **vlan_table)
+{
+ char *token;
+ int i = 0;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for vlan table */
+ *vlan_table = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (*vlan_table == NULL)
+ return -1;
+
+ while (1) {
+ if (strcmp(token, "G") == 0 ||
+ strcmp(token, "g") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_GREEN;
+ else if (strcmp(token, "Y") == 0 ||
+ strcmp(token, "y") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_YELLOW;
+ else if (strcmp(token, "R") == 0 ||
+ strcmp(token, "r") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_RED;
+ else {
+ free(*vlan_table);
+ return -1;
+ }
+ if (i == MAX_VLAN_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(*vlan_table);
+ return -1;
+ }
+ }
+ return 0;
+}
+
static int
parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
{
@@ -124,9 +244,30 @@ parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
return 0;
}
+static int
+parse_default_input_color_str(char *str, uint64_t *def_inp_color)
+{
+ char *token;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ if ((strcmp(token, "G") == 0) || (strcmp(token, "g") == 0))
+ *def_inp_color = RTE_COLOR_GREEN;
+ else if ((strcmp(token, "Y") == 0) || (strcmp(token, "y") == 0))
+ *def_inp_color = RTE_COLOR_YELLOW;
+ else if ((strcmp(token, "R") == 0) || (strcmp(token, "r") == 0))
+ *def_inp_color = RTE_COLOR_RED;
+ else
+ return -1;
+
+ return 0;
+}
+
static int
parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
- enum rte_color **dscp_table)
+ enum rte_color **vlan_table, enum rte_color **dscp_table)
{
char *token;
uint64_t previous_mtr_color = 0;
@@ -147,8 +288,7 @@ parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
return 0;
}
- /* Parse dscp table entries */
- ret = parse_dscp_table_entries(c_str, dscp_table);
+ ret = parse_input_color_table_entries(c_str, dscp_table, vlan_table);
if (ret != 0)
return -1;
@@ -192,6 +332,43 @@ parse_multi_token_string(char *t_str, uint16_t *port_id,
return 0;
}
+static int
+parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
+ enum rte_color **vlan_table)
+{
+ uint64_t val;
+ char *token;
+ int ret;
+
+ /* First token: port id */
+ token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+ if (token == NULL)
+ return -1;
+
+ ret = parse_uint(&val, token);
+ if (ret != 0 || val > UINT16_MAX)
+ return -1;
+
+ *port_id = val;
+
+ /* Second token: meter id */
+ token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+ if (token == NULL)
+ return 0;
+
+ ret = parse_uint(&val, token);
+ if (ret != 0 || val > UINT32_MAX)
+ return -1;
+
+ *mtr_id = val;
+
+ ret = parse_vlan_table_entries(t_str, vlan_table);
+ if (ret != 0)
+ return -1;
+
+ return 0;
+}
+
/* *** Show Port Meter Capabilities *** */
struct cmd_show_port_meter_cap_result {
cmdline_fixed_string_t show;
@@ -277,6 +454,10 @@ static void cmd_show_port_meter_cap_parsed(void *parsed_result,
printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
cap.trtcm_rfc4115_packet_mode_supported);
printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
+ printf("cap.input_color_proto_mask 0x%" PRIx64 "\n",
+ cap.input_color_proto_mask);
+ printf("cap.separate_input_color_table_per_port %" PRId32 "\n",
+ cap.separate_input_color_table_per_port);
}
cmdline_parse_inst_t cmd_show_port_meter_cap = {
@@ -721,6 +902,7 @@ struct cmd_create_port_meter_result {
cmdline_fixed_string_t r_action;
uint64_t statistics_mask;
uint32_t shared;
+ cmdline_fixed_string_t default_input_color;
cmdline_multi_string_t meter_input_color;
};
@@ -763,6 +945,9 @@ cmdline_parse_token_num_t cmd_create_port_meter_statistics_mask =
cmdline_parse_token_num_t cmd_create_port_meter_shared =
TOKEN_NUM_INITIALIZER(struct cmd_create_port_meter_result,
shared, RTE_UINT32);
+cmdline_parse_token_string_t cmd_create_port_meter_default_input_color =
+ TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
+ default_input_color, "R#Y#G#r#y#g");
cmdline_parse_token_string_t cmd_create_port_meter_input_color =
TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
meter_input_color, TOKEN_STRING_MULTI);
@@ -778,7 +963,10 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
uint32_t shared = res->shared;
uint32_t use_prev_meter_color = 0;
uint16_t port_id = res->port_id;
+ uint64_t def_inp_color = 0;
enum rte_color *dscp_table = NULL;
+ enum rte_color *vlan_table = NULL;
+ char *def_color_str = res->default_input_color;
char *c_str = res->meter_input_color;
int ret;
@@ -789,8 +977,18 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
memset(¶ms, 0, sizeof(struct rte_mtr_params));
params.meter_profile_id = res->profile_id;
params.meter_policy_id = res->policy_id;
+
+ /* Parse meter default input color string params */
+ ret = parse_default_input_color_str(def_color_str, &def_inp_color);
+ if (ret) {
+ fprintf(stderr,
+ " Meter default input color is invalid\n");
+ return;
+ }
+
/* Parse meter input color string params */
- ret = parse_meter_color_str(c_str, &use_prev_meter_color, &dscp_table);
+ ret = parse_meter_color_str(c_str, &use_prev_meter_color, &vlan_table,
+ &dscp_table);
if (ret) {
fprintf(stderr,
" Meter input color params string parse error\n");
@@ -798,16 +996,20 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
}
params.use_prev_mtr_color = use_prev_meter_color;
+ params.vlan_table = vlan_table;
params.dscp_table = dscp_table;
+ params.default_input_color = def_inp_color;
if (strcmp(res->meter_enable, "yes") == 0)
params.meter_enable = 1;
else
params.meter_enable = 0;
+
params.stats_mask = res->statistics_mask;
ret = rte_mtr_create(port_id, mtr_id, ¶ms, shared, &error);
if (ret != 0) {
+ free(vlan_table);
free(dscp_table);
print_err_msg(&error);
return;
@@ -817,9 +1019,11 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
cmdline_parse_inst_t cmd_create_port_meter = {
.f = cmd_create_port_meter_parsed,
.data = NULL,
- .help_str = "create port meter <port_id> <mtr_id> <profile_id> <meter_enable>(yes|no) "
- "<stats_mask> <shared> <use_pre_meter_color> "
- "[<dscp_tbl_entry0> <dscp_tbl_entry1> ...<dscp_tbl_entry63>]",
+ .help_str = "create port meter <port_id> <mtr_id> <profile_id> <policy_id> "
+ "<meter_enable>(yes|no) <stats_mask> <shared> "
+ "<default_input_color>(g|y|r) <use_pre_meter_color> "
+ "[<dscp_tbl_entry0> <dscp_tbl_entry1> ... <dscp_tbl_entry63>]"
+ "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry16>]",
.tokens = {
(void *)&cmd_create_port_meter_create,
(void *)&cmd_create_port_meter_port,
@@ -831,6 +1035,7 @@ cmdline_parse_inst_t cmd_create_port_meter = {
(void *)&cmd_create_port_meter_meter_enable,
(void *)&cmd_create_port_meter_statistics_mask,
(void *)&cmd_create_port_meter_shared,
+ (void *)&cmd_create_port_meter_default_input_color,
(void *)&cmd_create_port_meter_input_color,
NULL,
},
@@ -1233,6 +1438,345 @@ cmdline_parse_inst_t cmd_set_port_meter_dscp_table = {
},
};
+/* *** Set Port Meter VLAN Table *** */
+struct cmd_set_port_meter_vlan_table_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t vlan_table;
+ cmdline_multi_string_t token_string;
+};
+
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_set =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, set, "set");
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, port, "port");
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, meter, "meter");
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_vlan_table =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result,
+ vlan_table, "vlan table");
+cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_token_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_port_meter_vlan_table_result,
+ token_string, TOKEN_STRING_MULTI);
+
+static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_vlan_table_result *res = parsed_result;
+ struct rte_mtr_error error;
+ enum rte_color *vlan_table = NULL;
+ char *t_str = res->token_string;
+ uint32_t mtr_id = 0;
+ uint16_t port_id;
+ int ret;
+
+ /* Parse string */
+ ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &vlan_table);
+ if (ret) {
+ fprintf(stderr, " Multi token string parse error\n");
+ return;
+ }
+
+ if (port_id_is_invalid(port_id, ENABLED_WARN))
+ goto free_table;
+
+ /* Update Meter VLAN Table*/
+ ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id,
+ vlan_table, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+
+free_table:
+ free(vlan_table);
+}
+
+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> "
+ "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry15>]",
+ .tokens = {
+ (void *)&cmd_set_port_meter_vlan_table_set,
+ (void *)&cmd_set_port_meter_vlan_table_port,
+ (void *)&cmd_set_port_meter_vlan_table_meter,
+ (void *)&cmd_set_port_meter_vlan_table_vlan_table,
+ (void *)&cmd_set_port_meter_vlan_table_token_string,
+ NULL,
+ },
+};
+
+/* *** Set Port Meter input protocol *** */
+struct cmd_set_port_meter_in_proto_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ cmdline_fixed_string_t proto;
+ uint32_t prio;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+cmdline_parse_token_string_t cmd_set_port_meter_in_proto_set =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, set, "set");
+
+cmdline_parse_token_string_t cmd_set_port_meter_in_proto_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, port, "port");
+
+cmdline_parse_token_string_t cmd_set_port_meter_in_proto_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, meter, "meter");
+
+cmdline_parse_token_string_t cmd_set_port_meter_in_proto_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, protocol, "proto");
+
+cmdline_parse_token_string_t cmd_set_port_meter_in_proto_proto =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, proto,
+ "outer_vlan#inner_vlan#outer_ip#inner_ip");
+
+cmdline_parse_token_num_t cmd_set_port_meter_in_proto_prio =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, prio, RTE_UINT32);
+
+cmdline_parse_token_num_t cmd_set_port_meter_in_proto_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, port_id, RTE_UINT16);
+
+cmdline_parse_token_num_t cmd_set_port_meter_in_proto_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, mtr_id, RTE_UINT32);
+
+static void cmd_set_port_meter_in_proto_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_in_proto_result *res = parsed_result;
+ enum rte_mtr_color_in_protocol proto = 0;
+ struct rte_mtr_error error;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ if (strcmp(res->proto, "outer_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
+ else if (strcmp(res->proto, "inner_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
+ else if (strcmp(res->proto, "outer_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
+ else if (strcmp(res->proto, "inner_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
+ else {
+ printf("Invalid protocol\n");
+ return;
+ }
+
+ /* Update Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_set(res->port_id, res->mtr_id,
+ proto, res->prio, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+}
+
+cmdline_parse_inst_t cmd_set_port_meter_in_proto = {
+ .f = cmd_set_port_meter_in_proto_parsed,
+ .data = NULL,
+ .help_str = "set port meter proto <port_id> <mtr_id> <proto> "
+ "<prio>",
+ .tokens = {
+ (void *)&cmd_set_port_meter_in_proto_set,
+ (void *)&cmd_set_port_meter_in_proto_port,
+ (void *)&cmd_set_port_meter_in_proto_meter,
+ (void *)&cmd_set_port_meter_in_proto_protocol,
+ (void *)&cmd_set_port_meter_in_proto_port_id,
+ (void *)&cmd_set_port_meter_in_proto_mtr_id,
+ (void *)&cmd_set_port_meter_in_proto_proto,
+ (void *)&cmd_set_port_meter_in_proto_prio,
+ NULL,
+ },
+};
+
+/* *** Get Port Meter input protocol *** */
+struct cmd_get_port_meter_in_proto_result {
+ cmdline_fixed_string_t get;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_get =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, get, "get");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, port, "port");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, meter, "meter");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, protocol, "proto");
+
+cmdline_parse_token_num_t cmd_get_port_meter_in_proto_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, port_id, RTE_UINT16);
+
+cmdline_parse_token_num_t cmd_get_port_meter_in_proto_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, mtr_id, RTE_UINT32);
+
+static void cmd_get_port_meter_in_proto_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_in_proto_result *res = parsed_result;
+ struct rte_mtr_error error;
+ uint64_t proto_mask = 0;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ /* Update Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_get(res->port_id, res->mtr_id,
+ &proto_mask, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+
+ printf("Enabled protocols:\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN)
+ printf("\touter_vlan\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_VLAN)
+ printf("\tinner_vlan\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_IP)
+ printf("\touter_ip\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_IP)
+ printf("\tinner_ip\n");
+}
+
+cmdline_parse_inst_t cmd_get_port_meter_in_proto = {
+ .f = cmd_get_port_meter_in_proto_parsed,
+ .data = NULL,
+ .help_str = "get port meter proto <port_id> <mtr_id>",
+ .tokens = {
+ (void *)&cmd_get_port_meter_in_proto_get,
+ (void *)&cmd_get_port_meter_in_proto_port,
+ (void *)&cmd_get_port_meter_in_proto_meter,
+ (void *)&cmd_get_port_meter_in_proto_protocol,
+ (void *)&cmd_get_port_meter_in_proto_port_id,
+ (void *)&cmd_get_port_meter_in_proto_mtr_id,
+ NULL,
+ },
+};
+
+/* *** Get Port Meter input protocol priority *** */
+struct cmd_get_port_meter_in_proto_prio_result {
+ cmdline_fixed_string_t get;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ cmdline_fixed_string_t proto;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_get =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, get, "get");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, port, "port");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, meter, "meter");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, protocol,
+ "proto_prio");
+
+cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_proto =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, proto,
+ "outer_vlan#inner_vlan#outer_ip#inner_ip");
+
+cmdline_parse_token_num_t cmd_get_port_meter_in_proto_prio_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, port_id,
+ RTE_UINT16);
+
+cmdline_parse_token_num_t cmd_get_port_meter_in_proto_prio_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, mtr_id,
+ RTE_UINT32);
+
+
+static void cmd_get_port_meter_in_proto_prio_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_get_port_meter_in_proto_prio_result *res = parsed_result;
+ enum rte_mtr_color_in_protocol proto;
+ struct rte_mtr_error error;
+ uint32_t prio = 0;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ if (strcmp(res->proto, "outer_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
+ else if (strcmp(res->proto, "inner_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
+ else if (strcmp(res->proto, "outer_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
+ else if (strcmp(res->proto, "inner_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
+ else {
+ printf("Invalid protocol\n");
+ return;
+ }
+
+ /* Get Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_priority_get(res->port_id, res->mtr_id,
+ proto, &prio, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+}
+
+cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio = {
+ .f = cmd_get_port_meter_in_proto_prio_parsed,
+ .data = NULL,
+ .help_str = "get port meter proto_prio <port_id> <mtr_id> <proto>",
+ .tokens = {
+ (void *)&cmd_get_port_meter_in_proto_prio_get,
+ (void *)&cmd_get_port_meter_in_proto_prio_port,
+ (void *)&cmd_get_port_meter_in_proto_prio_meter,
+ (void *)&cmd_get_port_meter_in_proto_prio_protocol,
+ (void *)&cmd_get_port_meter_in_proto_prio_port_id,
+ (void *)&cmd_get_port_meter_in_proto_prio_mtr_id,
+ (void *)&cmd_get_port_meter_in_proto_prio_proto,
+ NULL,
+ },
+};
+
/* *** Set Port Meter Stats Mask *** */
struct cmd_set_port_meter_stats_mask_result {
cmdline_fixed_string_t set;
diff --git a/app/test-pmd/cmdline_mtr.h b/app/test-pmd/cmdline_mtr.h
index 2415fc16c3..23eaa5bc03 100644
--- a/app/test-pmd/cmdline_mtr.h
+++ b/app/test-pmd/cmdline_mtr.h
@@ -19,6 +19,10 @@ extern cmdline_parse_inst_t cmd_del_port_meter;
extern cmdline_parse_inst_t cmd_del_port_meter_policy;
extern cmdline_parse_inst_t cmd_set_port_meter_profile;
extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;
+extern cmdline_parse_inst_t cmd_set_port_meter_vlan_table;
+extern cmdline_parse_inst_t cmd_set_port_meter_in_proto;
+extern cmdline_parse_inst_t cmd_get_port_meter_in_proto;
+extern cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio;
extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;
extern cmdline_parse_inst_t cmd_show_port_meter_stats;
void print_mtr_err_msg(struct rte_mtr_error *error);
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [PATCH v2 1/1] app/testpmd: support different input color method
2022-05-25 14:37 ` skori
@ 2022-05-25 14:41 ` Dumitrescu, Cristian
2022-05-31 15:41 ` Andrew Rybchenko
2022-06-03 13:06 ` [PATCH v3 " skori
1 sibling, 1 reply; 30+ messages in thread
From: Dumitrescu, Cristian @ 2022-05-25 14:41 UTC (permalink / raw)
To: skori, Li, Xiaoyun, Singh, Aman Deep, Zhang, Yuying; +Cc: dev
> -----Original Message-----
> From: skori@marvell.com <skori@marvell.com>
> Sent: Wednesday, May 25, 2022 3:37 PM
> To: Li, Xiaoyun <xiaoyun.li@intel.com>; Singh, Aman Deep
> <aman.deep.singh@intel.com>; Zhang, Yuying <yuying.zhang@intel.com>;
> Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org; Sunil Kumar Kori <skori@marvell.com>
> Subject: [PATCH v2 1/1] app/testpmd: support different input color method
>
> From: Sunil Kumar Kori <skori@marvell.com>
>
> To enable input coloring, based on VLAN or DSCP, patch adds
> command line interface to configure the following:
>
> - configuring input coloring using VLAN or DSCP while creating
> meter i.e. during rte_mtr_create()
>
> - Update VLAN input coloring table at runtime.
>
> - configures protocol priorities.
>
> - retrieve protocol and priority information
>
> Depends-on: patch-22751 ("ethdev: mtr: support protocol based input color
> selection")
>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> ---
> v1..v2:
> - Rebased to branch dpdk-next-net
> - add CLIs for input coloring mechanism
>
> app/test-pmd/cmdline.c | 4 +
> app/test-pmd/cmdline_mtr.c | 558
> ++++++++++++++++++++++++++++++++++++-
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v2 1/1] app/testpmd: support different input color method
2022-05-25 14:41 ` Dumitrescu, Cristian
@ 2022-05-31 15:41 ` Andrew Rybchenko
2022-06-03 13:03 ` [EXT] " Sunil Kumar Kori
0 siblings, 1 reply; 30+ messages in thread
From: Andrew Rybchenko @ 2022-05-31 15:41 UTC (permalink / raw)
To: Dumitrescu, Cristian, skori, Li, Xiaoyun, Singh, Aman Deep,
Zhang, Yuying
Cc: dev
On 5/25/22 17:41, Dumitrescu, Cristian wrote:
>
>
>> -----Original Message-----
>> From: skori@marvell.com <skori@marvell.com>
>> Sent: Wednesday, May 25, 2022 3:37 PM
>> To: Li, Xiaoyun <xiaoyun.li@intel.com>; Singh, Aman Deep
>> <aman.deep.singh@intel.com>; Zhang, Yuying <yuying.zhang@intel.com>;
>> Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
>> Cc: dev@dpdk.org; Sunil Kumar Kori <skori@marvell.com>
>> Subject: [PATCH v2 1/1] app/testpmd: support different input color method
>>
>> From: Sunil Kumar Kori <skori@marvell.com>
>>
>> To enable input coloring, based on VLAN or DSCP, patch adds
>> command line interface to configure the following:
>>
>> - configuring input coloring using VLAN or DSCP while creating
>> meter i.e. during rte_mtr_create()
>>
>> - Update VLAN input coloring table at runtime.
>>
>> - configures protocol priorities.
>>
>> - retrieve protocol and priority information
>>
>> Depends-on: patch-22751 ("ethdev: mtr: support protocol based input color
>> selection")
>>
>> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
>> ---
>> v1..v2:
>> - Rebased to branch dpdk-next-net
>> - add CLIs for input coloring mechanism
>>
>> app/test-pmd/cmdline.c | 4 +
>> app/test-pmd/cmdline_mtr.c | 558
>> ++++++++++++++++++++++++++++++++++++-
>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
>
The patch breaks build as reported by CI [1].
Please, fix and send v4 (since since one should be v3 in fact).
[1]
https://patches.dpdk.org/project/dpdk/patch/20220525143716.996398-1-skori@marvell.com/
Note that you need to rebase on top of dpdk-next-net/main since
nearby lines change due to static keyword addition. Don't forget
to add to newly added cmdline_parse_* structs which are used in
the file only.
^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [EXT] Re: [PATCH v2 1/1] app/testpmd: support different input color method
2022-05-31 15:41 ` Andrew Rybchenko
@ 2022-06-03 13:03 ` Sunil Kumar Kori
0 siblings, 0 replies; 30+ messages in thread
From: Sunil Kumar Kori @ 2022-06-03 13:03 UTC (permalink / raw)
To: Andrew Rybchenko, Dumitrescu, Cristian, Li, Xiaoyun, Singh,
Aman Deep, Zhang, Yuying
Cc: dev
> -----Original Message-----
> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Sent: Tuesday, May 31, 2022 9:12 PM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Sunil Kumar Kori
> <skori@marvell.com>; Li, Xiaoyun <xiaoyun.li@intel.com>; Singh, Aman
> Deep <aman.deep.singh@intel.com>; Zhang, Yuying
> <yuying.zhang@intel.com>
> Cc: dev@dpdk.org
> Subject: [EXT] Re: [PATCH v2 1/1] app/testpmd: support different input color
> method
>
> External Email
>
> ----------------------------------------------------------------------
> On 5/25/22 17:41, Dumitrescu, Cristian wrote:
> >
> >
> >> -----Original Message-----
> >> From: skori@marvell.com <skori@marvell.com>
> >> Sent: Wednesday, May 25, 2022 3:37 PM
> >> To: Li, Xiaoyun <xiaoyun.li@intel.com>; Singh, Aman Deep
> >> <aman.deep.singh@intel.com>; Zhang, Yuying
> <yuying.zhang@intel.com>;
> >> Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> >> Cc: dev@dpdk.org; Sunil Kumar Kori <skori@marvell.com>
> >> Subject: [PATCH v2 1/1] app/testpmd: support different input color
> >> method
> >>
> >> From: Sunil Kumar Kori <skori@marvell.com>
> >>
> >> To enable input coloring, based on VLAN or DSCP, patch adds command
> >> line interface to configure the following:
> >>
> >> - configuring input coloring using VLAN or DSCP while creating
> >> meter i.e. during rte_mtr_create()
> >>
> >> - Update VLAN input coloring table at runtime.
> >>
> >> - configures protocol priorities.
> >>
> >> - retrieve protocol and priority information
> >>
> >> Depends-on: patch-22751 ("ethdev: mtr: support protocol based input
> >> color
> >> selection")
> >>
> >> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> >> ---
> >> v1..v2:
> >> - Rebased to branch dpdk-next-net
> >> - add CLIs for input coloring mechanism
> >>
> >> app/test-pmd/cmdline.c | 4 +
> >> app/test-pmd/cmdline_mtr.c | 558
> >> ++++++++++++++++++++++++++++++++++++-
> >
> > Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> >
>
> The patch breaks build as reported by CI [1].
> Please, fix and send v4 (since since one should be v3 in fact).
>
> [1]
> https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__patches.dpdk.org_project_dpdk_patch_20220525143716.996398-2D1-
> 2Dskori-
> 40marvell.com_&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=dXeXaAMkP5
> COgn1zxHMyaF1_d9IIuq6vHQO6NrIPjaE&m=lkdKT4ugU3ZTqTy2ee3r4GXH3m
> UCXIAOjWy80VtchoG__s3ty0EDuqXy3jL5y-
> 48&s=XHgyW7qwxFzk4FTe3Ul3gGCFbvRDegKDCAcqr1sAe1g&e=
>
> Note that you need to rebase on top of dpdk-next-net/main since nearby
> lines change due to static keyword addition. Don't forget to add to newly
> added cmdline_parse_* structs which are used in the file only.
Sure, I will rebase the changes on dpdk-next-net/main after fixing static keyword for
cmdline_parse_*.
Based on build error logs, I am suspecting that source is being compile against the dpdk/main.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v3 1/1] app/testpmd: support different input color method
2022-05-25 14:37 ` skori
2022-05-25 14:41 ` Dumitrescu, Cristian
@ 2022-06-03 13:06 ` skori
2022-06-08 12:06 ` Andrew Rybchenko
2022-06-14 10:05 ` [PATCH v4 " skori
1 sibling, 2 replies; 30+ messages in thread
From: skori @ 2022-06-03 13:06 UTC (permalink / raw)
To: Xiaoyun Li, Aman Singh, Yuying Zhang, Cristian Dumitrescu
Cc: dev, Sunil Kumar Kori
From: Sunil Kumar Kori <skori@marvell.com>
To enable input coloring, based on VLAN or DSCP, patch adds
command line interface to configure the following:
- configuring input coloring using VLAN or DSCP while creating
meter i.e. during rte_mtr_create()
- Update VLAN input coloring table at runtime.
- configures protocol priorities.
- retrieve protocol and priority information
Depends-on: patch-22751 ("ethdev: mtr: support protocol based input color selection")
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
v2..v3:
- Rebased to branch ToT dpdk-next-net/main
- Fix static keyword for newly added token parsing symbols
v1..v2:
- Rebased to branch dpdk-next-net
- add CLIs for input coloring mechanism
app/test-pmd/cmdline.c | 4 +
app/test-pmd/cmdline_mtr.c | 555 ++++++++++++++++++++++++++++++++++++-
app/test-pmd/cmdline_mtr.h | 4 +
3 files changed, 557 insertions(+), 6 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index fdd0cada3b..5276b4221c 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -17994,6 +17994,10 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
+ (cmdline_parse_inst_t *)&cmd_set_port_meter_vlan_table,
+ (cmdline_parse_inst_t *)&cmd_set_port_meter_in_proto,
+ (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto,
+ (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto_prio,
(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
(cmdline_parse_inst_t *)&cmd_mcast_addr,
diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index 57050ec9af..e81e678e45 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -14,6 +14,7 @@
#include "cmdline_mtr.h"
#define PARSE_DELIMITER " \f\n\r\t\v"
+#define MAX_VLAN_TABLE_ENTRIES 16
#define MAX_DSCP_TABLE_ENTRIES 64
/** Display Meter Error Message */
@@ -82,6 +83,125 @@ parse_uint(uint64_t *value, const char *str)
return 0;
}
+static int
+parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
+ enum rte_color **vlan_table)
+{
+ enum rte_color *vlan, *dscp;
+ char *token;
+ int i = 0;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for dscp table */
+ dscp = (enum rte_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (dscp == NULL)
+ return -1;
+
+ while (1) {
+ if (strcmp(token, "G") == 0 || strcmp(token, "g") == 0)
+ dscp[i++] = RTE_COLOR_GREEN;
+ else if (strcmp(token, "Y") == 0 || strcmp(token, "y") == 0)
+ dscp[i++] = RTE_COLOR_YELLOW;
+ else if (strcmp(token, "R") == 0 || strcmp(token, "r") == 0)
+ dscp[i++] = RTE_COLOR_RED;
+ else {
+ free(dscp);
+ return -1;
+ }
+ if (i == MAX_DSCP_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(dscp);
+ return -1;
+ }
+ }
+
+ *dscp_table = dscp;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for vlan table */
+ vlan = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (vlan == NULL)
+ return -1;
+
+ i = 0;
+ while (1) {
+ if (strcmp(token, "G") == 0 || strcmp(token, "g") == 0)
+ vlan[i++] = RTE_COLOR_GREEN;
+ else if (strcmp(token, "Y") == 0 || strcmp(token, "y") == 0)
+ vlan[i++] = RTE_COLOR_YELLOW;
+ else if (strcmp(token, "R") == 0 || strcmp(token, "r") == 0)
+ vlan[i++] = RTE_COLOR_RED;
+ else {
+ free(vlan);
+ return -1;
+ }
+ if (i == MAX_VLAN_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(vlan);
+ return -1;
+ }
+ }
+
+ *vlan_table = vlan;
+ return 0;
+}
+
+static int
+parse_vlan_table_entries(char *str, enum rte_color **vlan_table)
+{
+ char *token;
+ int i = 0;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for vlan table */
+ *vlan_table = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (*vlan_table == NULL)
+ return -1;
+
+ while (1) {
+ if (strcmp(token, "G") == 0 ||
+ strcmp(token, "g") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_GREEN;
+ else if (strcmp(token, "Y") == 0 ||
+ strcmp(token, "y") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_YELLOW;
+ else if (strcmp(token, "R") == 0 ||
+ strcmp(token, "r") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_RED;
+ else {
+ free(*vlan_table);
+ return -1;
+ }
+ if (i == MAX_VLAN_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(*vlan_table);
+ return -1;
+ }
+ }
+ return 0;
+}
+
static int
parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
{
@@ -124,9 +244,30 @@ parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
return 0;
}
+static int
+parse_default_input_color_str(char *str, uint64_t *def_inp_color)
+{
+ char *token;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ if ((strcmp(token, "G") == 0) || (strcmp(token, "g") == 0))
+ *def_inp_color = RTE_COLOR_GREEN;
+ else if ((strcmp(token, "Y") == 0) || (strcmp(token, "y") == 0))
+ *def_inp_color = RTE_COLOR_YELLOW;
+ else if ((strcmp(token, "R") == 0) || (strcmp(token, "r") == 0))
+ *def_inp_color = RTE_COLOR_RED;
+ else
+ return -1;
+
+ return 0;
+}
+
static int
parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
- enum rte_color **dscp_table)
+ enum rte_color **vlan_table, enum rte_color **dscp_table)
{
char *token;
uint64_t previous_mtr_color = 0;
@@ -147,8 +288,7 @@ parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
return 0;
}
- /* Parse dscp table entries */
- ret = parse_dscp_table_entries(c_str, dscp_table);
+ ret = parse_input_color_table_entries(c_str, dscp_table, vlan_table);
if (ret != 0)
return -1;
@@ -192,6 +332,43 @@ parse_multi_token_string(char *t_str, uint16_t *port_id,
return 0;
}
+static int
+parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
+ enum rte_color **vlan_table)
+{
+ uint64_t val;
+ char *token;
+ int ret;
+
+ /* First token: port id */
+ token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+ if (token == NULL)
+ return -1;
+
+ ret = parse_uint(&val, token);
+ if (ret != 0 || val > UINT16_MAX)
+ return -1;
+
+ *port_id = val;
+
+ /* Second token: meter id */
+ token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+ if (token == NULL)
+ return 0;
+
+ ret = parse_uint(&val, token);
+ if (ret != 0 || val > UINT32_MAX)
+ return -1;
+
+ *mtr_id = val;
+
+ ret = parse_vlan_table_entries(t_str, vlan_table);
+ if (ret != 0)
+ return -1;
+
+ return 0;
+}
+
/* *** Show Port Meter Capabilities *** */
struct cmd_show_port_meter_cap_result {
cmdline_fixed_string_t show;
@@ -277,6 +454,10 @@ static void cmd_show_port_meter_cap_parsed(void *parsed_result,
printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
cap.trtcm_rfc4115_packet_mode_supported);
printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
+ printf("cap.input_color_proto_mask 0x%" PRIx64 "\n",
+ cap.input_color_proto_mask);
+ printf("cap.separate_input_color_table_per_port %" PRId32 "\n",
+ cap.separate_input_color_table_per_port);
}
cmdline_parse_inst_t cmd_show_port_meter_cap = {
@@ -721,6 +902,7 @@ struct cmd_create_port_meter_result {
cmdline_fixed_string_t r_action;
uint64_t statistics_mask;
uint32_t shared;
+ cmdline_fixed_string_t default_input_color;
cmdline_multi_string_t meter_input_color;
};
@@ -754,6 +936,9 @@ static cmdline_parse_token_num_t cmd_create_port_meter_statistics_mask =
static cmdline_parse_token_num_t cmd_create_port_meter_shared =
TOKEN_NUM_INITIALIZER(struct cmd_create_port_meter_result,
shared, RTE_UINT32);
+static cmdline_parse_token_string_t cmd_create_port_meter_default_input_color =
+ TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
+ default_input_color, "R#Y#G#r#y#g");
static cmdline_parse_token_string_t cmd_create_port_meter_input_color =
TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
meter_input_color, TOKEN_STRING_MULTI);
@@ -769,7 +954,10 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
uint32_t shared = res->shared;
uint32_t use_prev_meter_color = 0;
uint16_t port_id = res->port_id;
+ uint64_t def_inp_color = 0;
enum rte_color *dscp_table = NULL;
+ enum rte_color *vlan_table = NULL;
+ char *def_color_str = res->default_input_color;
char *c_str = res->meter_input_color;
int ret;
@@ -780,8 +968,18 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
memset(¶ms, 0, sizeof(struct rte_mtr_params));
params.meter_profile_id = res->profile_id;
params.meter_policy_id = res->policy_id;
+
+ /* Parse meter default input color string params */
+ ret = parse_default_input_color_str(def_color_str, &def_inp_color);
+ if (ret) {
+ fprintf(stderr,
+ " Meter default input color is invalid\n");
+ return;
+ }
+
/* Parse meter input color string params */
- ret = parse_meter_color_str(c_str, &use_prev_meter_color, &dscp_table);
+ ret = parse_meter_color_str(c_str, &use_prev_meter_color, &vlan_table,
+ &dscp_table);
if (ret) {
fprintf(stderr,
" Meter input color params string parse error\n");
@@ -789,16 +987,20 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
}
params.use_prev_mtr_color = use_prev_meter_color;
+ params.vlan_table = vlan_table;
params.dscp_table = dscp_table;
+ params.default_input_color = def_inp_color;
if (strcmp(res->meter_enable, "yes") == 0)
params.meter_enable = 1;
else
params.meter_enable = 0;
+
params.stats_mask = res->statistics_mask;
ret = rte_mtr_create(port_id, mtr_id, ¶ms, shared, &error);
if (ret != 0) {
+ free(vlan_table);
free(dscp_table);
print_err_msg(&error);
return;
@@ -809,8 +1011,10 @@ cmdline_parse_inst_t cmd_create_port_meter = {
.f = cmd_create_port_meter_parsed,
.data = NULL,
.help_str = "create port meter <port_id> <mtr_id> <profile_id> <policy_id> "
- "<meter_enable>(yes|no) <stats_mask> <shared> <use_pre_meter_color> "
- "[<dscp_tbl_entry0> <dscp_tbl_entry1> ...<dscp_tbl_entry63>]",
+ "<meter_enable>(yes|no) <stats_mask> <shared> "
+ "<default_input_color>(g|y|r) <use_pre_meter_color> "
+ "[<dscp_tbl_entry0> <dscp_tbl_entry1> ...<dscp_tbl_entry63>] "
+ "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry16>]",
.tokens = {
(void *)&cmd_create_port_meter_create,
(void *)&cmd_create_port_meter_port,
@@ -822,6 +1026,7 @@ cmdline_parse_inst_t cmd_create_port_meter = {
(void *)&cmd_create_port_meter_meter_enable,
(void *)&cmd_create_port_meter_statistics_mask,
(void *)&cmd_create_port_meter_shared,
+ (void *)&cmd_create_port_meter_default_input_color,
(void *)&cmd_create_port_meter_input_color,
NULL,
},
@@ -1224,6 +1429,344 @@ cmdline_parse_inst_t cmd_set_port_meter_dscp_table = {
},
};
+/* *** Set Port Meter VLAN Table *** */
+struct cmd_set_port_meter_vlan_table_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t vlan_table;
+ cmdline_multi_string_t token_string;
+};
+
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_set =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, set, "set");
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, port, "port");
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, meter, "meter");
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_vlan_table =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result,
+ vlan_table, "vlan table");
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_token_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_port_meter_vlan_table_result,
+ token_string, TOKEN_STRING_MULTI);
+
+static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_vlan_table_result *res = parsed_result;
+ struct rte_mtr_error error;
+ enum rte_color *vlan_table = NULL;
+ char *t_str = res->token_string;
+ uint32_t mtr_id = 0;
+ uint16_t port_id;
+ int ret;
+
+ /* Parse string */
+ ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &vlan_table);
+ if (ret) {
+ fprintf(stderr, " Multi token string parse error\n");
+ return;
+ }
+
+ if (port_id_is_invalid(port_id, ENABLED_WARN))
+ goto free_table;
+
+ /* Update Meter VLAN Table*/
+ ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id,
+ vlan_table, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+
+free_table:
+ free(vlan_table);
+}
+
+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> "
+ "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry15>]",
+ .tokens = {
+ (void *)&cmd_set_port_meter_vlan_table_set,
+ (void *)&cmd_set_port_meter_vlan_table_port,
+ (void *)&cmd_set_port_meter_vlan_table_meter,
+ (void *)&cmd_set_port_meter_vlan_table_vlan_table,
+ (void *)&cmd_set_port_meter_vlan_table_token_string,
+ NULL,
+ },
+};
+
+/* *** Set Port Meter input protocol *** */
+struct cmd_set_port_meter_in_proto_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ cmdline_fixed_string_t proto;
+ uint32_t prio;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_set =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, set, "set");
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, port, "port");
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, meter, "meter");
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, protocol, "proto");
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_proto =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, proto,
+ "outer_vlan#inner_vlan#outer_ip#inner_ip");
+
+static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_prio =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, prio, RTE_UINT32);
+
+static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, port_id, RTE_UINT16);
+
+static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, mtr_id, RTE_UINT32);
+
+static void cmd_set_port_meter_in_proto_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_in_proto_result *res = parsed_result;
+ enum rte_mtr_color_in_protocol proto;
+ struct rte_mtr_error error;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ if (strcmp(res->proto, "outer_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
+ else if (strcmp(res->proto, "inner_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
+ else if (strcmp(res->proto, "outer_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
+ else if (strcmp(res->proto, "inner_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
+ else {
+ printf("Invalid protocol\n");
+ return;
+ }
+
+ /* Update Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_set(res->port_id, res->mtr_id,
+ proto, res->prio, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+}
+
+cmdline_parse_inst_t cmd_set_port_meter_in_proto = {
+ .f = cmd_set_port_meter_in_proto_parsed,
+ .data = NULL,
+ .help_str = "set port meter proto <port_id> <mtr_id> <proto> "
+ "<prio>",
+ .tokens = {
+ (void *)&cmd_set_port_meter_in_proto_set,
+ (void *)&cmd_set_port_meter_in_proto_port,
+ (void *)&cmd_set_port_meter_in_proto_meter,
+ (void *)&cmd_set_port_meter_in_proto_protocol,
+ (void *)&cmd_set_port_meter_in_proto_port_id,
+ (void *)&cmd_set_port_meter_in_proto_mtr_id,
+ (void *)&cmd_set_port_meter_in_proto_proto,
+ (void *)&cmd_set_port_meter_in_proto_prio,
+ NULL,
+ },
+};
+
+/* *** Get Port Meter input protocol *** */
+struct cmd_get_port_meter_in_proto_result {
+ cmdline_fixed_string_t get;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_get =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, get, "get");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, port, "port");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, meter, "meter");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, protocol, "proto");
+
+static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, port_id, RTE_UINT16);
+
+static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, mtr_id, RTE_UINT32);
+
+static void cmd_get_port_meter_in_proto_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_in_proto_result *res = parsed_result;
+ struct rte_mtr_error error;
+ uint64_t proto_mask = 0;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ /* Update Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_get(res->port_id, res->mtr_id,
+ &proto_mask, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+
+ printf("Enabled protocols:\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN)
+ printf("\touter_vlan\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_VLAN)
+ printf("\tinner_vlan\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_IP)
+ printf("\touter_ip\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_IP)
+ printf("\tinner_ip\n");
+}
+
+cmdline_parse_inst_t cmd_get_port_meter_in_proto = {
+ .f = cmd_get_port_meter_in_proto_parsed,
+ .data = NULL,
+ .help_str = "get port meter proto <port_id> <mtr_id>",
+ .tokens = {
+ (void *)&cmd_get_port_meter_in_proto_get,
+ (void *)&cmd_get_port_meter_in_proto_port,
+ (void *)&cmd_get_port_meter_in_proto_meter,
+ (void *)&cmd_get_port_meter_in_proto_protocol,
+ (void *)&cmd_get_port_meter_in_proto_port_id,
+ (void *)&cmd_get_port_meter_in_proto_mtr_id,
+ NULL,
+ },
+};
+
+/* *** Get Port Meter input protocol priority *** */
+struct cmd_get_port_meter_in_proto_prio_result {
+ cmdline_fixed_string_t get;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ cmdline_fixed_string_t proto;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_get =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, get, "get");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, port, "port");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, meter, "meter");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, protocol,
+ "proto_prio");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_proto =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, proto,
+ "outer_vlan#inner_vlan#outer_ip#inner_ip");
+
+static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_prio_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, port_id,
+ RTE_UINT16);
+
+static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_prio_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, mtr_id,
+ RTE_UINT32);
+
+static void cmd_get_port_meter_in_proto_prio_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_get_port_meter_in_proto_prio_result *res = parsed_result;
+ enum rte_mtr_color_in_protocol proto;
+ struct rte_mtr_error error;
+ uint32_t prio = 0;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ if (strcmp(res->proto, "outer_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
+ else if (strcmp(res->proto, "inner_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
+ else if (strcmp(res->proto, "outer_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
+ else if (strcmp(res->proto, "inner_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
+ else {
+ printf("Invalid protocol\n");
+ return;
+ }
+
+ /* Get Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_priority_get(res->port_id, res->mtr_id,
+ proto, &prio, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+}
+
+cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio = {
+ .f = cmd_get_port_meter_in_proto_prio_parsed,
+ .data = NULL,
+ .help_str = "get port meter proto_prio <port_id> <mtr_id> <proto>",
+ .tokens = {
+ (void *)&cmd_get_port_meter_in_proto_prio_get,
+ (void *)&cmd_get_port_meter_in_proto_prio_port,
+ (void *)&cmd_get_port_meter_in_proto_prio_meter,
+ (void *)&cmd_get_port_meter_in_proto_prio_protocol,
+ (void *)&cmd_get_port_meter_in_proto_prio_port_id,
+ (void *)&cmd_get_port_meter_in_proto_prio_mtr_id,
+ (void *)&cmd_get_port_meter_in_proto_prio_proto,
+ NULL,
+ },
+};
+
/* *** Set Port Meter Stats Mask *** */
struct cmd_set_port_meter_stats_mask_result {
cmdline_fixed_string_t set;
diff --git a/app/test-pmd/cmdline_mtr.h b/app/test-pmd/cmdline_mtr.h
index 2415fc16c3..23eaa5bc03 100644
--- a/app/test-pmd/cmdline_mtr.h
+++ b/app/test-pmd/cmdline_mtr.h
@@ -19,6 +19,10 @@ extern cmdline_parse_inst_t cmd_del_port_meter;
extern cmdline_parse_inst_t cmd_del_port_meter_policy;
extern cmdline_parse_inst_t cmd_set_port_meter_profile;
extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;
+extern cmdline_parse_inst_t cmd_set_port_meter_vlan_table;
+extern cmdline_parse_inst_t cmd_set_port_meter_in_proto;
+extern cmdline_parse_inst_t cmd_get_port_meter_in_proto;
+extern cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio;
extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;
extern cmdline_parse_inst_t cmd_show_port_meter_stats;
void print_mtr_err_msg(struct rte_mtr_error *error);
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v3 1/1] app/testpmd: support different input color method
2022-06-03 13:06 ` [PATCH v3 " skori
@ 2022-06-08 12:06 ` Andrew Rybchenko
2022-06-14 10:05 ` [PATCH v4 " skori
1 sibling, 0 replies; 30+ messages in thread
From: Andrew Rybchenko @ 2022-06-08 12:06 UTC (permalink / raw)
To: skori, Xiaoyun Li, Aman Singh, Yuying Zhang, Cristian Dumitrescu; +Cc: dev
On 6/3/22 16:06, skori@marvell.com wrote:
> From: Sunil Kumar Kori <skori@marvell.com>
>
> To enable input coloring, based on VLAN or DSCP, patch adds
> command line interface to configure the following:
>
> - configuring input coloring using VLAN or DSCP while creating
> meter i.e. during rte_mtr_create()
>
> - Update VLAN input coloring table at runtime.
>
> - configures protocol priorities.
>
> - retrieve protocol and priority information
>
> Depends-on: patch-22751 ("ethdev: mtr: support protocol based input color selection")
>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
[snip]
> + if (strcmp(token, "G") == 0 || strcmp(token, "g") == 0)
strcasecmp() will help to make it a bit simpler.
Here and in many similar cases below.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v4 1/1] app/testpmd: support different input color method
2022-06-03 13:06 ` [PATCH v3 " skori
2022-06-08 12:06 ` Andrew Rybchenko
@ 2022-06-14 10:05 ` skori
2022-06-23 11:05 ` Andrew Rybchenko
2022-06-23 12:57 ` [PATCH v5 " skori
1 sibling, 2 replies; 30+ messages in thread
From: skori @ 2022-06-14 10:05 UTC (permalink / raw)
To: Xiaoyun Li, Aman Singh, Yuying Zhang, Cristian Dumitrescu
Cc: dev, Sunil Kumar Kori
From: Sunil Kumar Kori <skori@marvell.com>
To enable input coloring, based on VLAN or DSCP, patch adds
command line interface to configure the following:
- configuring input coloring using VLAN or DSCP while creating
meter i.e. during rte_mtr_create()
- Update VLAN input coloring table at runtime.
- configures protocol priorities.
- retrieve protocol and priority information
Depends-on: patch-22751 ("ethdev: mtr: support protocol based input color selection")
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
v3..v4:
- Replace strcmp with strcasecmp whereever is needed.
v2..v3:
- Rebased to branch ToT dpdk-next-net/main
- Fix static keyword for newly added token parsing symbols
v1..v2:
- Rebased to branch dpdk-next-net
- add CLIs for input coloring mechanism
app/test-pmd/cmdline.c | 4 +
app/test-pmd/cmdline_mtr.c | 552 ++++++++++++++++++++++++++++++++++++-
app/test-pmd/cmdline_mtr.h | 4 +
3 files changed, 554 insertions(+), 6 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index a59e6166d5..9a2ae2fee3 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -18066,6 +18066,10 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
+ (cmdline_parse_inst_t *)&cmd_set_port_meter_vlan_table,
+ (cmdline_parse_inst_t *)&cmd_set_port_meter_in_proto,
+ (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto,
+ (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto_prio,
(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
(cmdline_parse_inst_t *)&cmd_mcast_addr,
diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index 57050ec9af..3aef91c364 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -14,6 +14,7 @@
#include "cmdline_mtr.h"
#define PARSE_DELIMITER " \f\n\r\t\v"
+#define MAX_VLAN_TABLE_ENTRIES 16
#define MAX_DSCP_TABLE_ENTRIES 64
/** Display Meter Error Message */
@@ -82,6 +83,122 @@ parse_uint(uint64_t *value, const char *str)
return 0;
}
+static int
+parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
+ enum rte_color **vlan_table)
+{
+ enum rte_color *vlan, *dscp;
+ char *token;
+ int i = 0;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for dscp table */
+ dscp = (enum rte_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (dscp == NULL)
+ return -1;
+
+ while (1) {
+ if (strcasecmp(token, "G") == 0)
+ dscp[i++] = RTE_COLOR_GREEN;
+ else if (strcasecmp(token, "Y") == 0)
+ dscp[i++] = RTE_COLOR_YELLOW;
+ else if (strcasecmp(token, "R") == 0)
+ dscp[i++] = RTE_COLOR_RED;
+ else {
+ free(dscp);
+ return -1;
+ }
+ if (i == MAX_DSCP_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(dscp);
+ return -1;
+ }
+ }
+
+ *dscp_table = dscp;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for vlan table */
+ vlan = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (vlan == NULL)
+ return -1;
+
+ i = 0;
+ while (1) {
+ if (strcasecmp(token, "G") == 0)
+ vlan[i++] = RTE_COLOR_GREEN;
+ else if (strcasecmp(token, "Y") == 0)
+ vlan[i++] = RTE_COLOR_YELLOW;
+ else if (strcasecmp(token, "R") == 0)
+ vlan[i++] = RTE_COLOR_RED;
+ else {
+ free(vlan);
+ return -1;
+ }
+ if (i == MAX_VLAN_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(vlan);
+ return -1;
+ }
+ }
+
+ *vlan_table = vlan;
+ return 0;
+}
+
+static int
+parse_vlan_table_entries(char *str, enum rte_color **vlan_table)
+{
+ char *token;
+ int i = 0;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for vlan table */
+ *vlan_table = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (*vlan_table == NULL)
+ return -1;
+
+ while (1) {
+ if (strcasecmp(token, "G") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_GREEN;
+ else if (strcasecmp(token, "Y") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_YELLOW;
+ else if (strcasecmp(token, "R") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_RED;
+ else {
+ free(*vlan_table);
+ return -1;
+ }
+ if (i == MAX_VLAN_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(*vlan_table);
+ return -1;
+ }
+ }
+ return 0;
+}
+
static int
parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
{
@@ -124,9 +241,30 @@ parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
return 0;
}
+static int
+parse_default_input_color_str(char *str, uint64_t *def_inp_color)
+{
+ char *token;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ if (strcasecmp(token, "G") == 0)
+ *def_inp_color = RTE_COLOR_GREEN;
+ else if (strcasecmp(token, "Y") == 0)
+ *def_inp_color = RTE_COLOR_YELLOW;
+ else if (strcasecmp(token, "R") == 0)
+ *def_inp_color = RTE_COLOR_RED;
+ else
+ return -1;
+
+ return 0;
+}
+
static int
parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
- enum rte_color **dscp_table)
+ enum rte_color **vlan_table, enum rte_color **dscp_table)
{
char *token;
uint64_t previous_mtr_color = 0;
@@ -147,8 +285,7 @@ parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
return 0;
}
- /* Parse dscp table entries */
- ret = parse_dscp_table_entries(c_str, dscp_table);
+ ret = parse_input_color_table_entries(c_str, dscp_table, vlan_table);
if (ret != 0)
return -1;
@@ -192,6 +329,43 @@ parse_multi_token_string(char *t_str, uint16_t *port_id,
return 0;
}
+static int
+parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
+ enum rte_color **vlan_table)
+{
+ uint64_t val;
+ char *token;
+ int ret;
+
+ /* First token: port id */
+ token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+ if (token == NULL)
+ return -1;
+
+ ret = parse_uint(&val, token);
+ if (ret != 0 || val > UINT16_MAX)
+ return -1;
+
+ *port_id = val;
+
+ /* Second token: meter id */
+ token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+ if (token == NULL)
+ return 0;
+
+ ret = parse_uint(&val, token);
+ if (ret != 0 || val > UINT32_MAX)
+ return -1;
+
+ *mtr_id = val;
+
+ ret = parse_vlan_table_entries(t_str, vlan_table);
+ if (ret != 0)
+ return -1;
+
+ return 0;
+}
+
/* *** Show Port Meter Capabilities *** */
struct cmd_show_port_meter_cap_result {
cmdline_fixed_string_t show;
@@ -277,6 +451,10 @@ static void cmd_show_port_meter_cap_parsed(void *parsed_result,
printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
cap.trtcm_rfc4115_packet_mode_supported);
printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
+ printf("cap.input_color_proto_mask 0x%" PRIx64 "\n",
+ cap.input_color_proto_mask);
+ printf("cap.separate_input_color_table_per_port %" PRId32 "\n",
+ cap.separate_input_color_table_per_port);
}
cmdline_parse_inst_t cmd_show_port_meter_cap = {
@@ -721,6 +899,7 @@ struct cmd_create_port_meter_result {
cmdline_fixed_string_t r_action;
uint64_t statistics_mask;
uint32_t shared;
+ cmdline_fixed_string_t default_input_color;
cmdline_multi_string_t meter_input_color;
};
@@ -754,6 +933,9 @@ static cmdline_parse_token_num_t cmd_create_port_meter_statistics_mask =
static cmdline_parse_token_num_t cmd_create_port_meter_shared =
TOKEN_NUM_INITIALIZER(struct cmd_create_port_meter_result,
shared, RTE_UINT32);
+static cmdline_parse_token_string_t cmd_create_port_meter_default_input_color =
+ TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
+ default_input_color, "R#Y#G#r#y#g");
static cmdline_parse_token_string_t cmd_create_port_meter_input_color =
TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
meter_input_color, TOKEN_STRING_MULTI);
@@ -769,7 +951,10 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
uint32_t shared = res->shared;
uint32_t use_prev_meter_color = 0;
uint16_t port_id = res->port_id;
+ uint64_t def_inp_color = 0;
enum rte_color *dscp_table = NULL;
+ enum rte_color *vlan_table = NULL;
+ char *def_color_str = res->default_input_color;
char *c_str = res->meter_input_color;
int ret;
@@ -780,8 +965,18 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
memset(¶ms, 0, sizeof(struct rte_mtr_params));
params.meter_profile_id = res->profile_id;
params.meter_policy_id = res->policy_id;
+
+ /* Parse meter default input color string params */
+ ret = parse_default_input_color_str(def_color_str, &def_inp_color);
+ if (ret) {
+ fprintf(stderr,
+ " Meter default input color is invalid\n");
+ return;
+ }
+
/* Parse meter input color string params */
- ret = parse_meter_color_str(c_str, &use_prev_meter_color, &dscp_table);
+ ret = parse_meter_color_str(c_str, &use_prev_meter_color, &vlan_table,
+ &dscp_table);
if (ret) {
fprintf(stderr,
" Meter input color params string parse error\n");
@@ -789,16 +984,20 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
}
params.use_prev_mtr_color = use_prev_meter_color;
+ params.vlan_table = vlan_table;
params.dscp_table = dscp_table;
+ params.default_input_color = def_inp_color;
if (strcmp(res->meter_enable, "yes") == 0)
params.meter_enable = 1;
else
params.meter_enable = 0;
+
params.stats_mask = res->statistics_mask;
ret = rte_mtr_create(port_id, mtr_id, ¶ms, shared, &error);
if (ret != 0) {
+ free(vlan_table);
free(dscp_table);
print_err_msg(&error);
return;
@@ -809,8 +1008,10 @@ cmdline_parse_inst_t cmd_create_port_meter = {
.f = cmd_create_port_meter_parsed,
.data = NULL,
.help_str = "create port meter <port_id> <mtr_id> <profile_id> <policy_id> "
- "<meter_enable>(yes|no) <stats_mask> <shared> <use_pre_meter_color> "
- "[<dscp_tbl_entry0> <dscp_tbl_entry1> ...<dscp_tbl_entry63>]",
+ "<meter_enable>(yes|no) <stats_mask> <shared> "
+ "<default_input_color>(g|y|r) <use_pre_meter_color> "
+ "[<dscp_tbl_entry0> <dscp_tbl_entry1> ...<dscp_tbl_entry63>] "
+ "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry16>]",
.tokens = {
(void *)&cmd_create_port_meter_create,
(void *)&cmd_create_port_meter_port,
@@ -822,6 +1023,7 @@ cmdline_parse_inst_t cmd_create_port_meter = {
(void *)&cmd_create_port_meter_meter_enable,
(void *)&cmd_create_port_meter_statistics_mask,
(void *)&cmd_create_port_meter_shared,
+ (void *)&cmd_create_port_meter_default_input_color,
(void *)&cmd_create_port_meter_input_color,
NULL,
},
@@ -1224,6 +1426,344 @@ cmdline_parse_inst_t cmd_set_port_meter_dscp_table = {
},
};
+/* *** Set Port Meter VLAN Table *** */
+struct cmd_set_port_meter_vlan_table_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t vlan_table;
+ cmdline_multi_string_t token_string;
+};
+
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_set =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, set, "set");
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, port, "port");
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, meter, "meter");
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_vlan_table =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result,
+ vlan_table, "vlan table");
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_token_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_port_meter_vlan_table_result,
+ token_string, TOKEN_STRING_MULTI);
+
+static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_vlan_table_result *res = parsed_result;
+ struct rte_mtr_error error;
+ enum rte_color *vlan_table = NULL;
+ char *t_str = res->token_string;
+ uint32_t mtr_id = 0;
+ uint16_t port_id;
+ int ret;
+
+ /* Parse string */
+ ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &vlan_table);
+ if (ret) {
+ fprintf(stderr, " Multi token string parse error\n");
+ return;
+ }
+
+ if (port_id_is_invalid(port_id, ENABLED_WARN))
+ goto free_table;
+
+ /* Update Meter VLAN Table*/
+ ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id,
+ vlan_table, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+
+free_table:
+ free(vlan_table);
+}
+
+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> "
+ "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry15>]",
+ .tokens = {
+ (void *)&cmd_set_port_meter_vlan_table_set,
+ (void *)&cmd_set_port_meter_vlan_table_port,
+ (void *)&cmd_set_port_meter_vlan_table_meter,
+ (void *)&cmd_set_port_meter_vlan_table_vlan_table,
+ (void *)&cmd_set_port_meter_vlan_table_token_string,
+ NULL,
+ },
+};
+
+/* *** Set Port Meter input protocol *** */
+struct cmd_set_port_meter_in_proto_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ cmdline_fixed_string_t proto;
+ uint32_t prio;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_set =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, set, "set");
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, port, "port");
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, meter, "meter");
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, protocol, "proto");
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_proto =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, proto,
+ "outer_vlan#inner_vlan#outer_ip#inner_ip");
+
+static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_prio =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, prio, RTE_UINT32);
+
+static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, port_id, RTE_UINT16);
+
+static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, mtr_id, RTE_UINT32);
+
+static void cmd_set_port_meter_in_proto_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_in_proto_result *res = parsed_result;
+ enum rte_mtr_color_in_protocol proto;
+ struct rte_mtr_error error;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ if (strcmp(res->proto, "outer_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
+ else if (strcmp(res->proto, "inner_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
+ else if (strcmp(res->proto, "outer_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
+ else if (strcmp(res->proto, "inner_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
+ else {
+ printf("Invalid protocol\n");
+ return;
+ }
+
+ /* Update Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_set(res->port_id, res->mtr_id,
+ proto, res->prio, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+}
+
+cmdline_parse_inst_t cmd_set_port_meter_in_proto = {
+ .f = cmd_set_port_meter_in_proto_parsed,
+ .data = NULL,
+ .help_str = "set port meter proto <port_id> <mtr_id> <proto> "
+ "<prio>",
+ .tokens = {
+ (void *)&cmd_set_port_meter_in_proto_set,
+ (void *)&cmd_set_port_meter_in_proto_port,
+ (void *)&cmd_set_port_meter_in_proto_meter,
+ (void *)&cmd_set_port_meter_in_proto_protocol,
+ (void *)&cmd_set_port_meter_in_proto_port_id,
+ (void *)&cmd_set_port_meter_in_proto_mtr_id,
+ (void *)&cmd_set_port_meter_in_proto_proto,
+ (void *)&cmd_set_port_meter_in_proto_prio,
+ NULL,
+ },
+};
+
+/* *** Get Port Meter input protocol *** */
+struct cmd_get_port_meter_in_proto_result {
+ cmdline_fixed_string_t get;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_get =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, get, "get");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, port, "port");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, meter, "meter");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, protocol, "proto");
+
+static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, port_id, RTE_UINT16);
+
+static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, mtr_id, RTE_UINT32);
+
+static void cmd_get_port_meter_in_proto_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_in_proto_result *res = parsed_result;
+ struct rte_mtr_error error;
+ uint64_t proto_mask = 0;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ /* Update Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_get(res->port_id, res->mtr_id,
+ &proto_mask, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+
+ printf("Enabled protocols:\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN)
+ printf("\touter_vlan\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_VLAN)
+ printf("\tinner_vlan\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_IP)
+ printf("\touter_ip\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_IP)
+ printf("\tinner_ip\n");
+}
+
+cmdline_parse_inst_t cmd_get_port_meter_in_proto = {
+ .f = cmd_get_port_meter_in_proto_parsed,
+ .data = NULL,
+ .help_str = "get port meter proto <port_id> <mtr_id>",
+ .tokens = {
+ (void *)&cmd_get_port_meter_in_proto_get,
+ (void *)&cmd_get_port_meter_in_proto_port,
+ (void *)&cmd_get_port_meter_in_proto_meter,
+ (void *)&cmd_get_port_meter_in_proto_protocol,
+ (void *)&cmd_get_port_meter_in_proto_port_id,
+ (void *)&cmd_get_port_meter_in_proto_mtr_id,
+ NULL,
+ },
+};
+
+/* *** Get Port Meter input protocol priority *** */
+struct cmd_get_port_meter_in_proto_prio_result {
+ cmdline_fixed_string_t get;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ cmdline_fixed_string_t proto;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_get =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, get, "get");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, port, "port");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, meter, "meter");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, protocol,
+ "proto_prio");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_proto =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, proto,
+ "outer_vlan#inner_vlan#outer_ip#inner_ip");
+
+static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_prio_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, port_id,
+ RTE_UINT16);
+
+static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_prio_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, mtr_id,
+ RTE_UINT32);
+
+static void cmd_get_port_meter_in_proto_prio_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_get_port_meter_in_proto_prio_result *res = parsed_result;
+ enum rte_mtr_color_in_protocol proto;
+ struct rte_mtr_error error;
+ uint32_t prio = 0;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ if (strcmp(res->proto, "outer_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
+ else if (strcmp(res->proto, "inner_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
+ else if (strcmp(res->proto, "outer_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
+ else if (strcmp(res->proto, "inner_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
+ else {
+ printf("Invalid protocol\n");
+ return;
+ }
+
+ /* Get Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_priority_get(res->port_id, res->mtr_id,
+ proto, &prio, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+}
+
+cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio = {
+ .f = cmd_get_port_meter_in_proto_prio_parsed,
+ .data = NULL,
+ .help_str = "get port meter proto_prio <port_id> <mtr_id> <proto>",
+ .tokens = {
+ (void *)&cmd_get_port_meter_in_proto_prio_get,
+ (void *)&cmd_get_port_meter_in_proto_prio_port,
+ (void *)&cmd_get_port_meter_in_proto_prio_meter,
+ (void *)&cmd_get_port_meter_in_proto_prio_protocol,
+ (void *)&cmd_get_port_meter_in_proto_prio_port_id,
+ (void *)&cmd_get_port_meter_in_proto_prio_mtr_id,
+ (void *)&cmd_get_port_meter_in_proto_prio_proto,
+ NULL,
+ },
+};
+
/* *** Set Port Meter Stats Mask *** */
struct cmd_set_port_meter_stats_mask_result {
cmdline_fixed_string_t set;
diff --git a/app/test-pmd/cmdline_mtr.h b/app/test-pmd/cmdline_mtr.h
index 2415fc16c3..23eaa5bc03 100644
--- a/app/test-pmd/cmdline_mtr.h
+++ b/app/test-pmd/cmdline_mtr.h
@@ -19,6 +19,10 @@ extern cmdline_parse_inst_t cmd_del_port_meter;
extern cmdline_parse_inst_t cmd_del_port_meter_policy;
extern cmdline_parse_inst_t cmd_set_port_meter_profile;
extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;
+extern cmdline_parse_inst_t cmd_set_port_meter_vlan_table;
+extern cmdline_parse_inst_t cmd_set_port_meter_in_proto;
+extern cmdline_parse_inst_t cmd_get_port_meter_in_proto;
+extern cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio;
extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;
extern cmdline_parse_inst_t cmd_show_port_meter_stats;
void print_mtr_err_msg(struct rte_mtr_error *error);
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v2 1/2] common/cnxk: update precolor table setup for VLAN
2022-03-01 9:00 ` [PATCH v1 2/3] net/cnxk: support ops to update precolor VLAN table skori
@ 2022-06-16 9:48 ` skori
2022-06-16 9:48 ` [PATCH v2 2/2] net/cnxk: support ops to update precolor VLAN table skori
0 siblings, 1 reply; 30+ messages in thread
From: skori @ 2022-06-16 9:48 UTC (permalink / raw)
To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao; +Cc: dev
From: Sunil Kumar Kori <skori@marvell.com>
As per new spec in DPDK, VLAN priority is supported for
precoloring of input packet.
Depends-on: patch-23516 ("app/testpmd: support different input color method")
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v1..v2:
- Aligned with latest input color spec.
drivers/common/cnxk/roc_nix.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h
index aedde1c10f..98ff513cb7 100644
--- a/drivers/common/cnxk/roc_nix.h
+++ b/drivers/common/cnxk/roc_nix.h
@@ -42,6 +42,12 @@ enum roc_nix_bpf_level_flag {
ROC_NIX_BPF_LEVEL_F_TOP = BIT(2),
};
+enum roc_nix_bpf_precolor_tbl_size {
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_GEN = 16,
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN = 16,
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP = 64,
+};
+
enum roc_nix_bpf_pc_mode {
ROC_NIX_BPF_PC_MODE_VLAN_INNER,
ROC_NIX_BPF_PC_MODE_VLAN_OUTER,
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v2 2/2] net/cnxk: support ops to update precolor VLAN table
2022-06-16 9:48 ` [PATCH v2 1/2] common/cnxk: update precolor table setup for VLAN skori
@ 2022-06-16 9:48 ` skori
2022-06-16 11:54 ` [PATCH v3 1/2] common/cnxk: update precolor table setup for VLAN skori
0 siblings, 1 reply; 30+ messages in thread
From: skori @ 2022-06-16 9:48 UTC (permalink / raw)
To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao; +Cc: dev
From: Sunil Kumar Kori <skori@marvell.com>
Implement API to update VLAN table for pre-coloring for
incoming packet per nixlf for CN10K platform.
Depends-on: patch-23516 ("app/testpmd: support different input color method")
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v1..v2:
- Aligned with latest input color spec.
drivers/net/cnxk/cnxk_ethdev.c | 1 +
drivers/net/cnxk/cnxk_ethdev.h | 3 +-
drivers/net/cnxk/cnxk_ethdev_mtr.c | 282 ++++++++++++++++++++++++++---
3 files changed, 259 insertions(+), 27 deletions(-)
diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index 09e57361d2..55945456c1 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -1679,6 +1679,7 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
dev->eth_dev = eth_dev;
dev->configured = 0;
dev->ptype_disable = 0;
+ dev->proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
TAILQ_INIT(&dev->inb.list);
TAILQ_INIT(&dev->outb.list);
diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
index e99230285c..feb24f2839 100644
--- a/drivers/net/cnxk/cnxk_ethdev.h
+++ b/drivers/net/cnxk/cnxk_ethdev.h
@@ -412,7 +412,8 @@ struct cnxk_eth_dev {
uint64_t clk_delta;
/* Ingress policer */
- enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
+ enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
+ enum rte_mtr_color_in_protocol proto;
struct cnxk_mtr_profiles mtr_profiles;
struct cnxk_mtr_policy mtr_policy;
struct cnxk_mtr mtr;
diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c
index 02803bdf75..5afa1e7083 100644
--- a/drivers/net/cnxk/cnxk_ethdev_mtr.c
+++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c
@@ -48,7 +48,12 @@ static struct rte_mtr_capabilities mtr_capa = {
RTE_MTR_STATS_N_PKTS_RED | RTE_MTR_STATS_N_PKTS_DROPPED |
RTE_MTR_STATS_N_BYTES_GREEN |
RTE_MTR_STATS_N_BYTES_YELLOW | RTE_MTR_STATS_N_BYTES_RED |
- RTE_MTR_STATS_N_BYTES_DROPPED};
+ RTE_MTR_STATS_N_BYTES_DROPPED,
+ .input_color_proto_mask = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN |
+ RTE_MTR_COLOR_IN_PROTO_INNER_VLAN |
+ RTE_MTR_COLOR_IN_PROTO_OUTER_IP |
+ RTE_MTR_COLOR_IN_PROTO_INNER_IP,
+ .separate_input_color_table_per_port = true};
static struct cnxk_meter_node *
nix_mtr_find(struct cnxk_eth_dev *dev, uint32_t meter_id)
@@ -470,6 +475,7 @@ cnxk_nix_mtr_create(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
struct cnxk_mtr_profile_node *profile;
struct cnxk_mtr_policy_node *policy;
struct cnxk_mtr *fm = &dev->mtr;
+ enum rte_color *table = NULL;
struct cnxk_meter_node *mtr;
int i;
@@ -521,18 +527,40 @@ cnxk_nix_mtr_create(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
mtr->is_next = false;
mtr->level = ROC_NIX_BPF_LEVEL_IDX_INVALID;
+ /* populate dscp table for input coloring */
if (params->dscp_table) {
- mtr->params.dscp_table =
- plt_zmalloc(ROC_NIX_BPF_PRE_COLOR_MAX, ROC_ALIGN);
- if (mtr->params.dscp_table == NULL) {
+ table = (enum rte_color *)plt_zmalloc(sizeof(enum rte_color) *
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP, ROC_ALIGN);
+ if (table == NULL) {
plt_free(mtr);
return -rte_mtr_error_set(error, ENOMEM,
RTE_MTR_ERROR_TYPE_UNSPECIFIED,
NULL, "Memory alloc failed.");
}
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
- mtr->params.dscp_table[i] = params->dscp_table[i];
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
+ table[i] = params->dscp_table[i];
+
+ mtr->params.dscp_table = table;
+ }
+
+
+ /* populate vlan table for input coloring */
+ if (params->vlan_table) {
+ table = (enum rte_color *)plt_zmalloc(sizeof(enum rte_color) *
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN, ROC_ALIGN);
+ if (table == NULL) {
+ plt_free(mtr->params.dscp_table);
+ plt_free(mtr);
+ return -rte_mtr_error_set(error, ENOMEM,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Memory alloc failed.");
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ table[i] = params->vlan_table[i];
+
+ mtr->params.vlan_table = table;
}
profile->ref_cnt++;
@@ -619,7 +647,13 @@ cnxk_nix_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
mtr->policy->ref_cnt--;
mtr->profile->ref_cnt--;
TAILQ_REMOVE(fm, mtr, next);
- plt_free(mtr->params.dscp_table);
+
+ if (mtr->params.dscp_table)
+ plt_free(mtr->params.dscp_table);
+
+ if (mtr->params.vlan_table)
+ plt_free(mtr->params.vlan_table);
+
plt_free(mtr);
exit:
@@ -689,7 +723,7 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
enum rte_color *dscp_table,
struct rte_mtr_error *error)
{
- enum roc_nix_bpf_color nix_dscp_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
+ enum roc_nix_bpf_color nix_dscp_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
ROC_NIX_BPF_COLOR_YELLOW,
ROC_NIX_BPF_COLOR_RED};
@@ -707,16 +741,28 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
}
if (!dscp_table) {
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
nix_dscp_tbl[i] = ROC_NIX_BPF_COLOR_GREEN;
} else {
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
nix_dscp_tbl[i] = color_map[dscp_table[i]];
}
- table.count = ROC_NIX_BPF_PRE_COLOR_MAX;
- table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
+
+ switch (dev->proto) {
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
+ table.mode = ROC_NIX_BPF_PC_MODE_DSCP_INNER;
+ break;
+ default:
+ rc = -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "Invalid input color protocol");
+ goto exit;
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
table.color[i] = nix_dscp_tbl[i];
rc = roc_nix_bpf_pre_color_tbl_setup(nix, mtr->bpf_id,
@@ -727,13 +773,138 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
goto exit;
}
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
dev->precolor_tbl[i] = nix_dscp_tbl[i];
exit:
return rc;
}
+static int
+cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ enum rte_color *vlan_table,
+ struct rte_mtr_error *error)
+{
+ enum roc_nix_bpf_color nix_vlan_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN];
+ enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
+ ROC_NIX_BPF_COLOR_YELLOW,
+ ROC_NIX_BPF_COLOR_RED};
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct roc_nix_bpf_precolor table;
+ struct roc_nix *nix = &dev->nix;
+ struct cnxk_meter_node *mtr;
+ int rc, i;
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ if (!vlan_table) {
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ nix_vlan_tbl[i] = ROC_NIX_BPF_COLOR_GREEN;
+ } else {
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ nix_vlan_tbl[i] = color_map[vlan_table[i]];
+ }
+
+ table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
+
+ switch (dev->proto) {
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
+ table.mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
+ table.mode = ROC_NIX_BPF_PC_MODE_VLAN_INNER;
+ break;
+ default:
+ rc = -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "Invalid input color protocol");
+ goto exit;
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ table.color[i] = nix_vlan_tbl[i];
+
+ rc = roc_nix_bpf_pre_color_tbl_setup(nix, mtr->bpf_id,
+ lvl_map[mtr->level], &table);
+ if (rc) {
+ rte_mtr_error_set(error, rc, RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+ NULL, NULL);
+ goto exit;
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ dev->precolor_tbl[i] = nix_vlan_tbl[i];
+
+exit:
+ return rc;
+}
+
+static int
+cnxk_nix_mtr_in_proto_set(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ enum rte_mtr_color_in_protocol proto,
+ uint32_t priority, struct rte_mtr_error *error)
+{
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct cnxk_meter_node *mtr;
+
+ RTE_SET_USED(priority);
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ dev->proto = proto;
+ return 0;
+}
+
+static int
+cnxk_nix_mtr_in_proto_get(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ uint64_t *proto_mask, struct rte_mtr_error *error)
+{
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct cnxk_meter_node *mtr;
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ *proto_mask = dev->proto;
+ return 0;
+}
+
+static int
+cnxk_nix_mtr_in_proto_prio_get(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ enum rte_mtr_color_in_protocol proto,
+ uint32_t *priority, struct rte_mtr_error *error)
+{
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct cnxk_meter_node *mtr;
+
+ RTE_SET_USED(proto);
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ plt_info("Only single priority supported i.e. 0");
+ *priority = 0;
+ return 0;
+}
+
static int
cnxk_nix_mtr_stats_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
uint64_t stats_mask, struct rte_mtr_error *error)
@@ -870,6 +1041,10 @@ const struct rte_mtr_ops nix_mtr_ops = {
.meter_enable = cnxk_nix_mtr_enable,
.meter_disable = cnxk_nix_mtr_disable,
.meter_dscp_table_update = cnxk_nix_mtr_dscp_table_update,
+ .meter_vlan_table_update = cnxk_nix_mtr_vlan_table_update,
+ .in_proto_set = cnxk_nix_mtr_in_proto_set,
+ .in_proto_get = cnxk_nix_mtr_in_proto_get,
+ .in_proto_prio_get = cnxk_nix_mtr_in_proto_prio_get,
.stats_update = cnxk_nix_mtr_stats_update,
.stats_read = cnxk_nix_mtr_stats_read,
};
@@ -1041,6 +1216,9 @@ nix_mtr_level_update(struct rte_eth_dev *eth_dev, uint32_t id, uint32_t level)
static void
nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
{
+ enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
+ ROC_NIX_BPF_COLOR_YELLOW,
+ ROC_NIX_BPF_COLOR_RED};
enum roc_nix_bpf_algo alg_map[] = {
ROC_NIX_BPF_ALGO_NONE, ROC_NIX_BPF_ALGO_2697,
ROC_NIX_BPF_ALGO_2698, ROC_NIX_BPF_ALGO_4115};
@@ -1049,6 +1227,28 @@ nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
cfg->alg = alg_map[profile->profile.alg];
cfg->lmode = profile->profile.packet_mode;
+ cfg->icolor = color_map[mtr->params.default_input_color];
+
+ switch (RTE_MTR_COLOR_IN_PROTO_OUTER_IP) {
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
+ cfg->tnl_ena = false;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_DSCP_INNER;
+ cfg->tnl_ena = true;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
+ cfg->tnl_ena = false;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_VLAN_INNER;
+ cfg->tnl_ena = true;
+ break;
+ default:
+ break;
+ }
switch (cfg->alg) {
case ROC_NIX_BPF_ALGO_2697:
@@ -1090,23 +1290,52 @@ nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
}
static void
-nix_dscp_table_map(struct cnxk_meter_node *mtr,
- struct roc_nix_bpf_precolor *tbl)
+nix_precolor_table_map(struct cnxk_meter_node *mtr,
+ struct roc_nix_bpf_precolor *tbl,
+ enum rte_mtr_color_in_protocol proto)
{
enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
ROC_NIX_BPF_COLOR_YELLOW,
ROC_NIX_BPF_COLOR_RED};
int i;
- tbl->count = ROC_NIX_BPF_PRE_COLOR_MAX;
- tbl->mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
-
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
- tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
-
- if (mtr->params.dscp_table) {
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
- tbl->color[i] = color_map[mtr->params.dscp_table[i]];
+ switch (proto) {
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
+ case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
+ tbl->count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
+ tbl->mode = (RTE_MTR_COLOR_IN_PROTO_OUTER_IP ==
+ RTE_MTR_COLOR_IN_PROTO_OUTER_IP) ?
+ ROC_NIX_BPF_PC_MODE_DSCP_OUTER :
+ ROC_NIX_BPF_PC_MODE_DSCP_INNER;
+
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
+
+ if (mtr->params.dscp_table) {
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] =
+ color_map[mtr->params.dscp_table[i]];
+ }
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
+ case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
+ tbl->count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
+ tbl->mode = (RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN ==
+ RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN) ?
+ ROC_NIX_BPF_PC_MODE_VLAN_OUTER :
+ ROC_NIX_BPF_PC_MODE_VLAN_INNER;
+
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
+
+ if (mtr->params.vlan_table) {
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] =
+ color_map[mtr->params.vlan_table[i]];
+ }
+ break;
+ default:
+ break;
}
}
@@ -1245,7 +1474,8 @@ nix_mtr_configure(struct rte_eth_dev *eth_dev, uint32_t id)
memset(&tbl, 0,
sizeof(struct roc_nix_bpf_precolor));
- nix_dscp_table_map(mtr[i], &tbl);
+ nix_precolor_table_map(mtr[i], &tbl,
+ dev->proto);
rc = roc_nix_bpf_pre_color_tbl_setup(nix,
mtr[i]->bpf_id, lvl_map[mtr[i]->level],
&tbl);
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v3 1/2] common/cnxk: update precolor table setup for VLAN
2022-06-16 9:48 ` [PATCH v2 2/2] net/cnxk: support ops to update precolor VLAN table skori
@ 2022-06-16 11:54 ` skori
2022-06-16 11:54 ` [PATCH v3 2/2] net/cnxk: support ops to update precolor VLAN table skori
0 siblings, 1 reply; 30+ messages in thread
From: skori @ 2022-06-16 11:54 UTC (permalink / raw)
To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao; +Cc: dev
From: Sunil Kumar Kori <skori@marvell.com>
As per new spec in DPDK, VLAN priority is supported for
precoloring of input packet.
Depends-on: patch-23516 ("app/testpmd: support different input color method")
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v2..v3:
- No changes.
v1..v2:
- Aligned with latest input color spec.
drivers/common/cnxk/roc_nix.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h
index aedde1c10f..98ff513cb7 100644
--- a/drivers/common/cnxk/roc_nix.h
+++ b/drivers/common/cnxk/roc_nix.h
@@ -42,6 +42,12 @@ enum roc_nix_bpf_level_flag {
ROC_NIX_BPF_LEVEL_F_TOP = BIT(2),
};
+enum roc_nix_bpf_precolor_tbl_size {
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_GEN = 16,
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN = 16,
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP = 64,
+};
+
enum roc_nix_bpf_pc_mode {
ROC_NIX_BPF_PC_MODE_VLAN_INNER,
ROC_NIX_BPF_PC_MODE_VLAN_OUTER,
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v3 2/2] net/cnxk: support ops to update precolor VLAN table
2022-06-16 11:54 ` [PATCH v3 1/2] common/cnxk: update precolor table setup for VLAN skori
@ 2022-06-16 11:54 ` skori
2022-06-20 17:44 ` Jerin Jacob
2022-06-21 7:35 ` [PATCH v4 1/2] common/cnxk: update precolor table setup for VLAN skori
0 siblings, 2 replies; 30+ messages in thread
From: skori @ 2022-06-16 11:54 UTC (permalink / raw)
To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao; +Cc: dev
From: Sunil Kumar Kori <skori@marvell.com>
Implement API to update VLAN table for pre-coloring for
incoming packet per nixlf for CN10K platform.
Depends-on: patch-23516 ("app/testpmd: support different input color method")
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v2..v3:
- Fix dscp table runtime update error.
v1..v2:
- Aligned with latest input color spec.
drivers/net/cnxk/cnxk_ethdev.c | 1 +
drivers/net/cnxk/cnxk_ethdev.h | 3 +-
drivers/net/cnxk/cnxk_ethdev_mtr.c | 284 ++++++++++++++++++++++++++---
3 files changed, 261 insertions(+), 27 deletions(-)
diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index 09e57361d2..55945456c1 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -1679,6 +1679,7 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
dev->eth_dev = eth_dev;
dev->configured = 0;
dev->ptype_disable = 0;
+ dev->proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
TAILQ_INIT(&dev->inb.list);
TAILQ_INIT(&dev->outb.list);
diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
index e99230285c..feb24f2839 100644
--- a/drivers/net/cnxk/cnxk_ethdev.h
+++ b/drivers/net/cnxk/cnxk_ethdev.h
@@ -412,7 +412,8 @@ struct cnxk_eth_dev {
uint64_t clk_delta;
/* Ingress policer */
- enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
+ enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
+ enum rte_mtr_color_in_protocol proto;
struct cnxk_mtr_profiles mtr_profiles;
struct cnxk_mtr_policy mtr_policy;
struct cnxk_mtr mtr;
diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c
index 02803bdf75..5405015436 100644
--- a/drivers/net/cnxk/cnxk_ethdev_mtr.c
+++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c
@@ -48,7 +48,12 @@ static struct rte_mtr_capabilities mtr_capa = {
RTE_MTR_STATS_N_PKTS_RED | RTE_MTR_STATS_N_PKTS_DROPPED |
RTE_MTR_STATS_N_BYTES_GREEN |
RTE_MTR_STATS_N_BYTES_YELLOW | RTE_MTR_STATS_N_BYTES_RED |
- RTE_MTR_STATS_N_BYTES_DROPPED};
+ RTE_MTR_STATS_N_BYTES_DROPPED,
+ .input_color_proto_mask = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN |
+ RTE_MTR_COLOR_IN_PROTO_INNER_VLAN |
+ RTE_MTR_COLOR_IN_PROTO_OUTER_IP |
+ RTE_MTR_COLOR_IN_PROTO_INNER_IP,
+ .separate_input_color_table_per_port = true};
static struct cnxk_meter_node *
nix_mtr_find(struct cnxk_eth_dev *dev, uint32_t meter_id)
@@ -470,6 +475,7 @@ cnxk_nix_mtr_create(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
struct cnxk_mtr_profile_node *profile;
struct cnxk_mtr_policy_node *policy;
struct cnxk_mtr *fm = &dev->mtr;
+ enum rte_color *table = NULL;
struct cnxk_meter_node *mtr;
int i;
@@ -521,18 +527,40 @@ cnxk_nix_mtr_create(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
mtr->is_next = false;
mtr->level = ROC_NIX_BPF_LEVEL_IDX_INVALID;
+ /* populate dscp table for input coloring */
if (params->dscp_table) {
- mtr->params.dscp_table =
- plt_zmalloc(ROC_NIX_BPF_PRE_COLOR_MAX, ROC_ALIGN);
- if (mtr->params.dscp_table == NULL) {
+ table = (enum rte_color *)plt_zmalloc(sizeof(enum rte_color) *
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP, ROC_ALIGN);
+ if (table == NULL) {
plt_free(mtr);
return -rte_mtr_error_set(error, ENOMEM,
RTE_MTR_ERROR_TYPE_UNSPECIFIED,
NULL, "Memory alloc failed.");
}
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
- mtr->params.dscp_table[i] = params->dscp_table[i];
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
+ table[i] = params->dscp_table[i];
+
+ mtr->params.dscp_table = table;
+ }
+
+
+ /* populate vlan table for input coloring */
+ if (params->vlan_table) {
+ table = (enum rte_color *)plt_zmalloc(sizeof(enum rte_color) *
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN, ROC_ALIGN);
+ if (table == NULL) {
+ plt_free(mtr->params.dscp_table);
+ plt_free(mtr);
+ return -rte_mtr_error_set(error, ENOMEM,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Memory alloc failed.");
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ table[i] = params->vlan_table[i];
+
+ mtr->params.vlan_table = table;
}
profile->ref_cnt++;
@@ -619,7 +647,13 @@ cnxk_nix_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
mtr->policy->ref_cnt--;
mtr->profile->ref_cnt--;
TAILQ_REMOVE(fm, mtr, next);
- plt_free(mtr->params.dscp_table);
+
+ if (mtr->params.dscp_table)
+ plt_free(mtr->params.dscp_table);
+
+ if (mtr->params.vlan_table)
+ plt_free(mtr->params.vlan_table);
+
plt_free(mtr);
exit:
@@ -689,7 +723,7 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
enum rte_color *dscp_table,
struct rte_mtr_error *error)
{
- enum roc_nix_bpf_color nix_dscp_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
+ enum roc_nix_bpf_color nix_dscp_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
ROC_NIX_BPF_COLOR_YELLOW,
ROC_NIX_BPF_COLOR_RED};
@@ -707,16 +741,30 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
}
if (!dscp_table) {
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
nix_dscp_tbl[i] = ROC_NIX_BPF_COLOR_GREEN;
} else {
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
nix_dscp_tbl[i] = color_map[dscp_table[i]];
}
- table.count = ROC_NIX_BPF_PRE_COLOR_MAX;
- table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
+
+ switch (dev->proto) {
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
+ table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
+ table.mode = ROC_NIX_BPF_PC_MODE_DSCP_INNER;
+ break;
+ default:
+ rc = -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "Invalid input color protocol");
+ goto exit;
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
table.color[i] = nix_dscp_tbl[i];
rc = roc_nix_bpf_pre_color_tbl_setup(nix, mtr->bpf_id,
@@ -727,13 +775,138 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
goto exit;
}
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
dev->precolor_tbl[i] = nix_dscp_tbl[i];
exit:
return rc;
}
+static int
+cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ enum rte_color *vlan_table,
+ struct rte_mtr_error *error)
+{
+ enum roc_nix_bpf_color nix_vlan_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN];
+ enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
+ ROC_NIX_BPF_COLOR_YELLOW,
+ ROC_NIX_BPF_COLOR_RED};
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct roc_nix_bpf_precolor table;
+ struct roc_nix *nix = &dev->nix;
+ struct cnxk_meter_node *mtr;
+ int rc, i;
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ if (!vlan_table) {
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ nix_vlan_tbl[i] = ROC_NIX_BPF_COLOR_GREEN;
+ } else {
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ nix_vlan_tbl[i] = color_map[vlan_table[i]];
+ }
+
+ table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
+
+ switch (dev->proto) {
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
+ table.mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
+ table.mode = ROC_NIX_BPF_PC_MODE_VLAN_INNER;
+ break;
+ default:
+ rc = -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "Invalid input color protocol");
+ goto exit;
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ table.color[i] = nix_vlan_tbl[i];
+
+ rc = roc_nix_bpf_pre_color_tbl_setup(nix, mtr->bpf_id,
+ lvl_map[mtr->level], &table);
+ if (rc) {
+ rte_mtr_error_set(error, rc, RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+ NULL, NULL);
+ goto exit;
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ dev->precolor_tbl[i] = nix_vlan_tbl[i];
+
+exit:
+ return rc;
+}
+
+static int
+cnxk_nix_mtr_in_proto_set(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ enum rte_mtr_color_in_protocol proto,
+ uint32_t priority, struct rte_mtr_error *error)
+{
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct cnxk_meter_node *mtr;
+
+ RTE_SET_USED(priority);
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ dev->proto = proto;
+ return 0;
+}
+
+static int
+cnxk_nix_mtr_in_proto_get(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ uint64_t *proto_mask, struct rte_mtr_error *error)
+{
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct cnxk_meter_node *mtr;
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ *proto_mask = dev->proto;
+ return 0;
+}
+
+static int
+cnxk_nix_mtr_in_proto_prio_get(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ enum rte_mtr_color_in_protocol proto,
+ uint32_t *priority, struct rte_mtr_error *error)
+{
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct cnxk_meter_node *mtr;
+
+ RTE_SET_USED(proto);
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ plt_info("Only single priority supported i.e. 0");
+ *priority = 0;
+ return 0;
+}
+
static int
cnxk_nix_mtr_stats_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
uint64_t stats_mask, struct rte_mtr_error *error)
@@ -870,6 +1043,10 @@ const struct rte_mtr_ops nix_mtr_ops = {
.meter_enable = cnxk_nix_mtr_enable,
.meter_disable = cnxk_nix_mtr_disable,
.meter_dscp_table_update = cnxk_nix_mtr_dscp_table_update,
+ .meter_vlan_table_update = cnxk_nix_mtr_vlan_table_update,
+ .in_proto_set = cnxk_nix_mtr_in_proto_set,
+ .in_proto_get = cnxk_nix_mtr_in_proto_get,
+ .in_proto_prio_get = cnxk_nix_mtr_in_proto_prio_get,
.stats_update = cnxk_nix_mtr_stats_update,
.stats_read = cnxk_nix_mtr_stats_read,
};
@@ -1041,6 +1218,9 @@ nix_mtr_level_update(struct rte_eth_dev *eth_dev, uint32_t id, uint32_t level)
static void
nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
{
+ enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
+ ROC_NIX_BPF_COLOR_YELLOW,
+ ROC_NIX_BPF_COLOR_RED};
enum roc_nix_bpf_algo alg_map[] = {
ROC_NIX_BPF_ALGO_NONE, ROC_NIX_BPF_ALGO_2697,
ROC_NIX_BPF_ALGO_2698, ROC_NIX_BPF_ALGO_4115};
@@ -1049,6 +1229,28 @@ nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
cfg->alg = alg_map[profile->profile.alg];
cfg->lmode = profile->profile.packet_mode;
+ cfg->icolor = color_map[mtr->params.default_input_color];
+
+ switch (RTE_MTR_COLOR_IN_PROTO_OUTER_IP) {
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
+ cfg->tnl_ena = false;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_DSCP_INNER;
+ cfg->tnl_ena = true;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
+ cfg->tnl_ena = false;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_VLAN_INNER;
+ cfg->tnl_ena = true;
+ break;
+ default:
+ break;
+ }
switch (cfg->alg) {
case ROC_NIX_BPF_ALGO_2697:
@@ -1090,23 +1292,52 @@ nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
}
static void
-nix_dscp_table_map(struct cnxk_meter_node *mtr,
- struct roc_nix_bpf_precolor *tbl)
+nix_precolor_table_map(struct cnxk_meter_node *mtr,
+ struct roc_nix_bpf_precolor *tbl,
+ enum rte_mtr_color_in_protocol proto)
{
enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
ROC_NIX_BPF_COLOR_YELLOW,
ROC_NIX_BPF_COLOR_RED};
int i;
- tbl->count = ROC_NIX_BPF_PRE_COLOR_MAX;
- tbl->mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
-
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
- tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
-
- if (mtr->params.dscp_table) {
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
- tbl->color[i] = color_map[mtr->params.dscp_table[i]];
+ switch (proto) {
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
+ case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
+ tbl->count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
+ tbl->mode = (RTE_MTR_COLOR_IN_PROTO_OUTER_IP ==
+ RTE_MTR_COLOR_IN_PROTO_OUTER_IP) ?
+ ROC_NIX_BPF_PC_MODE_DSCP_OUTER :
+ ROC_NIX_BPF_PC_MODE_DSCP_INNER;
+
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
+
+ if (mtr->params.dscp_table) {
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] =
+ color_map[mtr->params.dscp_table[i]];
+ }
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
+ case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
+ tbl->count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
+ tbl->mode = (RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN ==
+ RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN) ?
+ ROC_NIX_BPF_PC_MODE_VLAN_OUTER :
+ ROC_NIX_BPF_PC_MODE_VLAN_INNER;
+
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
+
+ if (mtr->params.vlan_table) {
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] =
+ color_map[mtr->params.vlan_table[i]];
+ }
+ break;
+ default:
+ break;
}
}
@@ -1245,7 +1476,8 @@ nix_mtr_configure(struct rte_eth_dev *eth_dev, uint32_t id)
memset(&tbl, 0,
sizeof(struct roc_nix_bpf_precolor));
- nix_dscp_table_map(mtr[i], &tbl);
+ nix_precolor_table_map(mtr[i], &tbl,
+ dev->proto);
rc = roc_nix_bpf_pre_color_tbl_setup(nix,
mtr[i]->bpf_id, lvl_map[mtr[i]->level],
&tbl);
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v3 2/2] net/cnxk: support ops to update precolor VLAN table
2022-06-16 11:54 ` [PATCH v3 2/2] net/cnxk: support ops to update precolor VLAN table skori
@ 2022-06-20 17:44 ` Jerin Jacob
2022-06-21 7:19 ` [EXT] " Sunil Kumar Kori
2022-06-21 7:35 ` [PATCH v4 1/2] common/cnxk: update precolor table setup for VLAN skori
1 sibling, 1 reply; 30+ messages in thread
From: Jerin Jacob @ 2022-06-20 17:44 UTC (permalink / raw)
To: Sunil Kumar Kori; +Cc: Nithin Dabilpuram, Kiran Kumar K, Satha Rao, dpdk-dev
On Thu, Jun 16, 2022 at 5:24 PM <skori@marvell.com> wrote:
>
> From: Sunil Kumar Kori <skori@marvell.com>
>
> Implement API to update VLAN table for pre-coloring for
> incoming packet per nixlf for CN10K platform.
>
> Depends-on: patch-23516 ("app/testpmd: support different input color method")
Actually, it does not depend on testpmd. You can remove this.
>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Build issues with clang
http://mails.dpdk.org/archives/test-report/2022-June/289909.html
https://patches.dpdk.org/project/dpdk/patch/20220616115402.772274-2-skori@marvell.com/
> ---
> v2..v3:
> - Fix dscp table runtime update error.
>
> v1..v2:
> - Aligned with latest input color spec.
>
> drivers/net/cnxk/cnxk_ethdev.c | 1 +
> drivers/net/cnxk/cnxk_ethdev.h | 3 +-
> drivers/net/cnxk/cnxk_ethdev_mtr.c | 284 ++++++++++++++++++++++++++---
> 3 files changed, 261 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
> index 09e57361d2..55945456c1 100644
> --- a/drivers/net/cnxk/cnxk_ethdev.c
> +++ b/drivers/net/cnxk/cnxk_ethdev.c
> @@ -1679,6 +1679,7 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
> dev->eth_dev = eth_dev;
> dev->configured = 0;
> dev->ptype_disable = 0;
> + dev->proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
>
> TAILQ_INIT(&dev->inb.list);
> TAILQ_INIT(&dev->outb.list);
> diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
> index e99230285c..feb24f2839 100644
> --- a/drivers/net/cnxk/cnxk_ethdev.h
> +++ b/drivers/net/cnxk/cnxk_ethdev.h
> @@ -412,7 +412,8 @@ struct cnxk_eth_dev {
> uint64_t clk_delta;
>
> /* Ingress policer */
> - enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
> + enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
> + enum rte_mtr_color_in_protocol proto;
> struct cnxk_mtr_profiles mtr_profiles;
> struct cnxk_mtr_policy mtr_policy;
> struct cnxk_mtr mtr;
> diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c
> index 02803bdf75..5405015436 100644
> --- a/drivers/net/cnxk/cnxk_ethdev_mtr.c
> +++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c
> @@ -48,7 +48,12 @@ static struct rte_mtr_capabilities mtr_capa = {
> RTE_MTR_STATS_N_PKTS_RED | RTE_MTR_STATS_N_PKTS_DROPPED |
> RTE_MTR_STATS_N_BYTES_GREEN |
> RTE_MTR_STATS_N_BYTES_YELLOW | RTE_MTR_STATS_N_BYTES_RED |
> - RTE_MTR_STATS_N_BYTES_DROPPED};
> + RTE_MTR_STATS_N_BYTES_DROPPED,
> + .input_color_proto_mask = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN |
> + RTE_MTR_COLOR_IN_PROTO_INNER_VLAN |
> + RTE_MTR_COLOR_IN_PROTO_OUTER_IP |
> + RTE_MTR_COLOR_IN_PROTO_INNER_IP,
> + .separate_input_color_table_per_port = true};
>
> static struct cnxk_meter_node *
> nix_mtr_find(struct cnxk_eth_dev *dev, uint32_t meter_id)
> @@ -470,6 +475,7 @@ cnxk_nix_mtr_create(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> struct cnxk_mtr_profile_node *profile;
> struct cnxk_mtr_policy_node *policy;
> struct cnxk_mtr *fm = &dev->mtr;
> + enum rte_color *table = NULL;
> struct cnxk_meter_node *mtr;
> int i;
>
> @@ -521,18 +527,40 @@ cnxk_nix_mtr_create(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> mtr->is_next = false;
> mtr->level = ROC_NIX_BPF_LEVEL_IDX_INVALID;
>
> + /* populate dscp table for input coloring */
> if (params->dscp_table) {
> - mtr->params.dscp_table =
> - plt_zmalloc(ROC_NIX_BPF_PRE_COLOR_MAX, ROC_ALIGN);
> - if (mtr->params.dscp_table == NULL) {
> + table = (enum rte_color *)plt_zmalloc(sizeof(enum rte_color) *
> + ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP, ROC_ALIGN);
> + if (table == NULL) {
> plt_free(mtr);
> return -rte_mtr_error_set(error, ENOMEM,
> RTE_MTR_ERROR_TYPE_UNSPECIFIED,
> NULL, "Memory alloc failed.");
> }
>
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> - mtr->params.dscp_table[i] = params->dscp_table[i];
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
> + table[i] = params->dscp_table[i];
> +
> + mtr->params.dscp_table = table;
> + }
> +
> +
> + /* populate vlan table for input coloring */
> + if (params->vlan_table) {
> + table = (enum rte_color *)plt_zmalloc(sizeof(enum rte_color) *
> + ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN, ROC_ALIGN);
> + if (table == NULL) {
> + plt_free(mtr->params.dscp_table);
> + plt_free(mtr);
> + return -rte_mtr_error_set(error, ENOMEM,
> + RTE_MTR_ERROR_TYPE_UNSPECIFIED,
> + NULL, "Memory alloc failed.");
> + }
> +
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
> + table[i] = params->vlan_table[i];
> +
> + mtr->params.vlan_table = table;
> }
>
> profile->ref_cnt++;
> @@ -619,7 +647,13 @@ cnxk_nix_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> mtr->policy->ref_cnt--;
> mtr->profile->ref_cnt--;
> TAILQ_REMOVE(fm, mtr, next);
> - plt_free(mtr->params.dscp_table);
> +
> + if (mtr->params.dscp_table)
> + plt_free(mtr->params.dscp_table);
> +
> + if (mtr->params.vlan_table)
> + plt_free(mtr->params.vlan_table);
> +
> plt_free(mtr);
>
> exit:
> @@ -689,7 +723,7 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> enum rte_color *dscp_table,
> struct rte_mtr_error *error)
> {
> - enum roc_nix_bpf_color nix_dscp_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
> + enum roc_nix_bpf_color nix_dscp_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
> enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
> ROC_NIX_BPF_COLOR_YELLOW,
> ROC_NIX_BPF_COLOR_RED};
> @@ -707,16 +741,30 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> }
>
> if (!dscp_table) {
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
> nix_dscp_tbl[i] = ROC_NIX_BPF_COLOR_GREEN;
> } else {
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
> nix_dscp_tbl[i] = color_map[dscp_table[i]];
> }
>
> - table.count = ROC_NIX_BPF_PRE_COLOR_MAX;
> - table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> + table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
> +
> + switch (dev->proto) {
> + case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
> + table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
> + break;
> + case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
> + table.mode = ROC_NIX_BPF_PC_MODE_DSCP_INNER;
> + break;
> + default:
> + rc = -rte_mtr_error_set(error, EINVAL,
> + RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
> + "Invalid input color protocol");
> + goto exit;
> + }
> +
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
> table.color[i] = nix_dscp_tbl[i];
>
> rc = roc_nix_bpf_pre_color_tbl_setup(nix, mtr->bpf_id,
> @@ -727,13 +775,138 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> goto exit;
> }
>
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
> dev->precolor_tbl[i] = nix_dscp_tbl[i];
>
> exit:
> return rc;
> }
>
> +static int
> +cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> + enum rte_color *vlan_table,
> + struct rte_mtr_error *error)
> +{
> + enum roc_nix_bpf_color nix_vlan_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN];
> + enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
> + ROC_NIX_BPF_COLOR_YELLOW,
> + ROC_NIX_BPF_COLOR_RED};
> + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
> + struct roc_nix_bpf_precolor table;
> + struct roc_nix *nix = &dev->nix;
> + struct cnxk_meter_node *mtr;
> + int rc, i;
> +
> + mtr = nix_mtr_find(dev, mtr_id);
> + if (mtr == NULL) {
> + return -rte_mtr_error_set(error, ENOENT,
> + RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
> + "Meter object not found");
> + }
> +
> + if (!vlan_table) {
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
> + nix_vlan_tbl[i] = ROC_NIX_BPF_COLOR_GREEN;
> + } else {
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
> + nix_vlan_tbl[i] = color_map[vlan_table[i]];
> + }
> +
> + table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
> +
> + switch (dev->proto) {
> + case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
> + table.mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
> + break;
> + case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
> + table.mode = ROC_NIX_BPF_PC_MODE_VLAN_INNER;
> + break;
> + default:
> + rc = -rte_mtr_error_set(error, EINVAL,
> + RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
> + "Invalid input color protocol");
> + goto exit;
> + }
> +
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
> + table.color[i] = nix_vlan_tbl[i];
> +
> + rc = roc_nix_bpf_pre_color_tbl_setup(nix, mtr->bpf_id,
> + lvl_map[mtr->level], &table);
> + if (rc) {
> + rte_mtr_error_set(error, rc, RTE_MTR_ERROR_TYPE_UNSPECIFIED,
> + NULL, NULL);
> + goto exit;
> + }
> +
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
> + dev->precolor_tbl[i] = nix_vlan_tbl[i];
> +
> +exit:
> + return rc;
> +}
> +
> +static int
> +cnxk_nix_mtr_in_proto_set(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> + enum rte_mtr_color_in_protocol proto,
> + uint32_t priority, struct rte_mtr_error *error)
> +{
> + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
> + struct cnxk_meter_node *mtr;
> +
> + RTE_SET_USED(priority);
> +
> + mtr = nix_mtr_find(dev, mtr_id);
> + if (mtr == NULL) {
> + return -rte_mtr_error_set(error, ENOENT,
> + RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
> + "Meter object not found");
> + }
> +
> + dev->proto = proto;
> + return 0;
> +}
> +
> +static int
> +cnxk_nix_mtr_in_proto_get(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> + uint64_t *proto_mask, struct rte_mtr_error *error)
> +{
> + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
> + struct cnxk_meter_node *mtr;
> +
> + mtr = nix_mtr_find(dev, mtr_id);
> + if (mtr == NULL) {
> + return -rte_mtr_error_set(error, ENOENT,
> + RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
> + "Meter object not found");
> + }
> +
> + *proto_mask = dev->proto;
> + return 0;
> +}
> +
> +static int
> +cnxk_nix_mtr_in_proto_prio_get(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> + enum rte_mtr_color_in_protocol proto,
> + uint32_t *priority, struct rte_mtr_error *error)
> +{
> + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
> + struct cnxk_meter_node *mtr;
> +
> + RTE_SET_USED(proto);
> +
> + mtr = nix_mtr_find(dev, mtr_id);
> + if (mtr == NULL) {
> + return -rte_mtr_error_set(error, ENOENT,
> + RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
> + "Meter object not found");
> + }
> +
> + plt_info("Only single priority supported i.e. 0");
> + *priority = 0;
> + return 0;
> +}
> +
> static int
> cnxk_nix_mtr_stats_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> uint64_t stats_mask, struct rte_mtr_error *error)
> @@ -870,6 +1043,10 @@ const struct rte_mtr_ops nix_mtr_ops = {
> .meter_enable = cnxk_nix_mtr_enable,
> .meter_disable = cnxk_nix_mtr_disable,
> .meter_dscp_table_update = cnxk_nix_mtr_dscp_table_update,
> + .meter_vlan_table_update = cnxk_nix_mtr_vlan_table_update,
> + .in_proto_set = cnxk_nix_mtr_in_proto_set,
> + .in_proto_get = cnxk_nix_mtr_in_proto_get,
> + .in_proto_prio_get = cnxk_nix_mtr_in_proto_prio_get,
> .stats_update = cnxk_nix_mtr_stats_update,
> .stats_read = cnxk_nix_mtr_stats_read,
> };
> @@ -1041,6 +1218,9 @@ nix_mtr_level_update(struct rte_eth_dev *eth_dev, uint32_t id, uint32_t level)
> static void
> nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
> {
> + enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
> + ROC_NIX_BPF_COLOR_YELLOW,
> + ROC_NIX_BPF_COLOR_RED};
> enum roc_nix_bpf_algo alg_map[] = {
> ROC_NIX_BPF_ALGO_NONE, ROC_NIX_BPF_ALGO_2697,
> ROC_NIX_BPF_ALGO_2698, ROC_NIX_BPF_ALGO_4115};
> @@ -1049,6 +1229,28 @@ nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
>
> cfg->alg = alg_map[profile->profile.alg];
> cfg->lmode = profile->profile.packet_mode;
> + cfg->icolor = color_map[mtr->params.default_input_color];
> +
> + switch (RTE_MTR_COLOR_IN_PROTO_OUTER_IP) {
> + case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
> + cfg->pc_mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
> + cfg->tnl_ena = false;
> + break;
> + case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
> + cfg->pc_mode = ROC_NIX_BPF_PC_MODE_DSCP_INNER;
> + cfg->tnl_ena = true;
> + break;
> + case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
> + cfg->pc_mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
> + cfg->tnl_ena = false;
> + break;
> + case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
> + cfg->pc_mode = ROC_NIX_BPF_PC_MODE_VLAN_INNER;
> + cfg->tnl_ena = true;
> + break;
> + default:
> + break;
> + }
>
> switch (cfg->alg) {
> case ROC_NIX_BPF_ALGO_2697:
> @@ -1090,23 +1292,52 @@ nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
> }
>
> static void
> -nix_dscp_table_map(struct cnxk_meter_node *mtr,
> - struct roc_nix_bpf_precolor *tbl)
> +nix_precolor_table_map(struct cnxk_meter_node *mtr,
> + struct roc_nix_bpf_precolor *tbl,
> + enum rte_mtr_color_in_protocol proto)
> {
> enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
> ROC_NIX_BPF_COLOR_YELLOW,
> ROC_NIX_BPF_COLOR_RED};
> int i;
>
> - tbl->count = ROC_NIX_BPF_PRE_COLOR_MAX;
> - tbl->mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
> -
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> - tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
> -
> - if (mtr->params.dscp_table) {
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> - tbl->color[i] = color_map[mtr->params.dscp_table[i]];
> + switch (proto) {
> + case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
> + case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
> + tbl->count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
> + tbl->mode = (RTE_MTR_COLOR_IN_PROTO_OUTER_IP ==
> + RTE_MTR_COLOR_IN_PROTO_OUTER_IP) ?
> + ROC_NIX_BPF_PC_MODE_DSCP_OUTER :
> + ROC_NIX_BPF_PC_MODE_DSCP_INNER;
> +
> + for (i = 0; i < tbl->count; i++)
> + tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
> +
> + if (mtr->params.dscp_table) {
> + for (i = 0; i < tbl->count; i++)
> + tbl->color[i] =
> + color_map[mtr->params.dscp_table[i]];
> + }
> + break;
> + case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
> + case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
> + tbl->count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
> + tbl->mode = (RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN ==
> + RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN) ?
> + ROC_NIX_BPF_PC_MODE_VLAN_OUTER :
> + ROC_NIX_BPF_PC_MODE_VLAN_INNER;
> +
> + for (i = 0; i < tbl->count; i++)
> + tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
> +
> + if (mtr->params.vlan_table) {
> + for (i = 0; i < tbl->count; i++)
> + tbl->color[i] =
> + color_map[mtr->params.vlan_table[i]];
> + }
> + break;
> + default:
> + break;
> }
> }
>
> @@ -1245,7 +1476,8 @@ nix_mtr_configure(struct rte_eth_dev *eth_dev, uint32_t id)
>
> memset(&tbl, 0,
> sizeof(struct roc_nix_bpf_precolor));
> - nix_dscp_table_map(mtr[i], &tbl);
> + nix_precolor_table_map(mtr[i], &tbl,
> + dev->proto);
> rc = roc_nix_bpf_pre_color_tbl_setup(nix,
> mtr[i]->bpf_id, lvl_map[mtr[i]->level],
> &tbl);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [EXT] Re: [PATCH v3 2/2] net/cnxk: support ops to update precolor VLAN table
2022-06-20 17:44 ` Jerin Jacob
@ 2022-06-21 7:19 ` Sunil Kumar Kori
0 siblings, 0 replies; 30+ messages in thread
From: Sunil Kumar Kori @ 2022-06-21 7:19 UTC (permalink / raw)
To: Jerin Jacob
Cc: Nithin Kumar Dabilpuram, Kiran Kumar Kokkilagadda,
Satha Koteswara Rao Kottidi, dpdk-dev
> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: Monday, June 20, 2022 11:14 PM
> To: Sunil Kumar Kori <skori@marvell.com>
> Cc: Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>; Kiran Kumar
> Kokkilagadda <kirankumark@marvell.com>; Satha Koteswara Rao Kottidi
> <skoteshwar@marvell.com>; dpdk-dev <dev@dpdk.org>
> Subject: [EXT] Re: [PATCH v3 2/2] net/cnxk: support ops to update precolor
> VLAN table
>
> External Email
>
> ----------------------------------------------------------------------
> On Thu, Jun 16, 2022 at 5:24 PM <skori@marvell.com> wrote:
> >
> > From: Sunil Kumar Kori <skori@marvell.com>
> >
> > Implement API to update VLAN table for pre-coloring for incoming
> > packet per nixlf for CN10K platform.
> >
> > Depends-on: patch-23516 ("app/testpmd: support different input color
> > method")
>
> Actually, it does not depend on testpmd. You can remove this.
>
Ack.
>
> >
> > Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
>
> Build issues with clang
> https://urldefense.proofpoint.com/v2/url?u=http-
> 3A__mails.dpdk.org_archives_test-2Dreport_2022-
> 2DJune_289909.html&d=DwIBaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=dXeXaA
> MkP5COgn1zxHMyaF1_d9IIuq6vHQO6NrIPjaE&m=nnqy_NateM77p8iH4wZg
> Qo6L5fn4uooaWcTssYSSokB_T7e76Q6X0frgAAOLcmDq&s=0aRLT69gIzdOBXJq
> jzM_MhnXYvWh_R7T0rhKz9-xAkI&e=
> https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__patches.dpdk.org_project_dpdk_patch_20220616115402.772274-2D2-
> 2Dskori-
> 40marvell.com_&d=DwIBaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=dXeXaAMkP5
> COgn1zxHMyaF1_d9IIuq6vHQO6NrIPjaE&m=nnqy_NateM77p8iH4wZgQo6L5f
> n4uooaWcTssYSSokB_T7e76Q6X0frgAAOLcmDq&s=1ILtkOaqc8Hdzfe_UyOR1
> HUClBh0EVz5BHzEe9iQfEk&e=
>
Ack.
> > ---
> > v2..v3:
> > - Fix dscp table runtime update error.
> >
> > v1..v2:
> > - Aligned with latest input color spec.
> >
> > drivers/net/cnxk/cnxk_ethdev.c | 1 +
> > drivers/net/cnxk/cnxk_ethdev.h | 3 +-
> > drivers/net/cnxk/cnxk_ethdev_mtr.c | 284
> > ++++++++++++++++++++++++++---
[snip]
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v4 1/2] common/cnxk: update precolor table setup for VLAN
2022-06-16 11:54 ` [PATCH v3 2/2] net/cnxk: support ops to update precolor VLAN table skori
2022-06-20 17:44 ` Jerin Jacob
@ 2022-06-21 7:35 ` skori
2022-06-21 7:35 ` [PATCH v4 2/2] net/cnxk: support ops to update precolor VLAN table skori
1 sibling, 1 reply; 30+ messages in thread
From: skori @ 2022-06-21 7:35 UTC (permalink / raw)
To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao; +Cc: dev
From: Sunil Kumar Kori <skori@marvell.com>
As per new spec in DPDK, VLAN priority is supported for
precoloring of input packet.
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v3..v4:
- Remove Depends On tag from commit message.
v2..v3:
- No changes.
v1..v2:
- Aligned with latest input color spec.
drivers/common/cnxk/roc_nix.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h
index aedde1c10f..98ff513cb7 100644
--- a/drivers/common/cnxk/roc_nix.h
+++ b/drivers/common/cnxk/roc_nix.h
@@ -42,6 +42,12 @@ enum roc_nix_bpf_level_flag {
ROC_NIX_BPF_LEVEL_F_TOP = BIT(2),
};
+enum roc_nix_bpf_precolor_tbl_size {
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_GEN = 16,
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN = 16,
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP = 64,
+};
+
enum roc_nix_bpf_pc_mode {
ROC_NIX_BPF_PC_MODE_VLAN_INNER,
ROC_NIX_BPF_PC_MODE_VLAN_OUTER,
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v4 2/2] net/cnxk: support ops to update precolor VLAN table
2022-06-21 7:35 ` [PATCH v4 1/2] common/cnxk: update precolor table setup for VLAN skori
@ 2022-06-21 7:35 ` skori
2022-08-22 12:33 ` Jerin Jacob
0 siblings, 1 reply; 30+ messages in thread
From: skori @ 2022-06-21 7:35 UTC (permalink / raw)
To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao; +Cc: dev
From: Sunil Kumar Kori <skori@marvell.com>
Implement API to update VLAN table for pre-coloring for
incoming packet per nixlf for CN10K platform.
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v3..v4:
- Remove Depends On tag from commit log.
- Rebase on top of dpdk-next-net/main.
- Fix clang build failures.
v2..v3:
- Fix dscp table runtime update error.
v1..v2:
- Aligned with latest input color spec.
drivers/net/cnxk/cnxk_ethdev.c | 1 +
drivers/net/cnxk/cnxk_ethdev.h | 3 +-
drivers/net/cnxk/cnxk_ethdev_mtr.c | 282 ++++++++++++++++++++++++++---
3 files changed, 259 insertions(+), 27 deletions(-)
diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index 09e57361d2..55945456c1 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -1679,6 +1679,7 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
dev->eth_dev = eth_dev;
dev->configured = 0;
dev->ptype_disable = 0;
+ dev->proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
TAILQ_INIT(&dev->inb.list);
TAILQ_INIT(&dev->outb.list);
diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
index e99230285c..feb24f2839 100644
--- a/drivers/net/cnxk/cnxk_ethdev.h
+++ b/drivers/net/cnxk/cnxk_ethdev.h
@@ -412,7 +412,8 @@ struct cnxk_eth_dev {
uint64_t clk_delta;
/* Ingress policer */
- enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
+ enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
+ enum rte_mtr_color_in_protocol proto;
struct cnxk_mtr_profiles mtr_profiles;
struct cnxk_mtr_policy mtr_policy;
struct cnxk_mtr mtr;
diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c
index 02803bdf75..be2cb7d628 100644
--- a/drivers/net/cnxk/cnxk_ethdev_mtr.c
+++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c
@@ -48,7 +48,12 @@ static struct rte_mtr_capabilities mtr_capa = {
RTE_MTR_STATS_N_PKTS_RED | RTE_MTR_STATS_N_PKTS_DROPPED |
RTE_MTR_STATS_N_BYTES_GREEN |
RTE_MTR_STATS_N_BYTES_YELLOW | RTE_MTR_STATS_N_BYTES_RED |
- RTE_MTR_STATS_N_BYTES_DROPPED};
+ RTE_MTR_STATS_N_BYTES_DROPPED,
+ .input_color_proto_mask = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN |
+ RTE_MTR_COLOR_IN_PROTO_INNER_VLAN |
+ RTE_MTR_COLOR_IN_PROTO_OUTER_IP |
+ RTE_MTR_COLOR_IN_PROTO_INNER_IP,
+ .separate_input_color_table_per_port = true};
static struct cnxk_meter_node *
nix_mtr_find(struct cnxk_eth_dev *dev, uint32_t meter_id)
@@ -470,6 +475,7 @@ cnxk_nix_mtr_create(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
struct cnxk_mtr_profile_node *profile;
struct cnxk_mtr_policy_node *policy;
struct cnxk_mtr *fm = &dev->mtr;
+ enum rte_color *table = NULL;
struct cnxk_meter_node *mtr;
int i;
@@ -521,18 +527,40 @@ cnxk_nix_mtr_create(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
mtr->is_next = false;
mtr->level = ROC_NIX_BPF_LEVEL_IDX_INVALID;
+ /* populate dscp table for input coloring */
if (params->dscp_table) {
- mtr->params.dscp_table =
- plt_zmalloc(ROC_NIX_BPF_PRE_COLOR_MAX, ROC_ALIGN);
- if (mtr->params.dscp_table == NULL) {
+ table = (enum rte_color *)plt_zmalloc(sizeof(enum rte_color) *
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP, ROC_ALIGN);
+ if (table == NULL) {
plt_free(mtr);
return -rte_mtr_error_set(error, ENOMEM,
RTE_MTR_ERROR_TYPE_UNSPECIFIED,
NULL, "Memory alloc failed.");
}
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
- mtr->params.dscp_table[i] = params->dscp_table[i];
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
+ table[i] = params->dscp_table[i];
+
+ mtr->params.dscp_table = table;
+ }
+
+
+ /* populate vlan table for input coloring */
+ if (params->vlan_table) {
+ table = (enum rte_color *)plt_zmalloc(sizeof(enum rte_color) *
+ ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN, ROC_ALIGN);
+ if (table == NULL) {
+ plt_free(mtr->params.dscp_table);
+ plt_free(mtr);
+ return -rte_mtr_error_set(error, ENOMEM,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Memory alloc failed.");
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ table[i] = params->vlan_table[i];
+
+ mtr->params.vlan_table = table;
}
profile->ref_cnt++;
@@ -619,7 +647,13 @@ cnxk_nix_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
mtr->policy->ref_cnt--;
mtr->profile->ref_cnt--;
TAILQ_REMOVE(fm, mtr, next);
- plt_free(mtr->params.dscp_table);
+
+ if (mtr->params.dscp_table)
+ plt_free(mtr->params.dscp_table);
+
+ if (mtr->params.vlan_table)
+ plt_free(mtr->params.vlan_table);
+
plt_free(mtr);
exit:
@@ -689,7 +723,7 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
enum rte_color *dscp_table,
struct rte_mtr_error *error)
{
- enum roc_nix_bpf_color nix_dscp_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
+ enum roc_nix_bpf_color nix_dscp_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
ROC_NIX_BPF_COLOR_YELLOW,
ROC_NIX_BPF_COLOR_RED};
@@ -707,16 +741,30 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
}
if (!dscp_table) {
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
nix_dscp_tbl[i] = ROC_NIX_BPF_COLOR_GREEN;
} else {
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
nix_dscp_tbl[i] = color_map[dscp_table[i]];
}
- table.count = ROC_NIX_BPF_PRE_COLOR_MAX;
- table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
+
+ switch (dev->proto) {
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
+ table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
+ table.mode = ROC_NIX_BPF_PC_MODE_DSCP_INNER;
+ break;
+ default:
+ rc = -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "Invalid input color protocol");
+ goto exit;
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
table.color[i] = nix_dscp_tbl[i];
rc = roc_nix_bpf_pre_color_tbl_setup(nix, mtr->bpf_id,
@@ -727,13 +775,138 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
goto exit;
}
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
dev->precolor_tbl[i] = nix_dscp_tbl[i];
exit:
return rc;
}
+static int
+cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ enum rte_color *vlan_table,
+ struct rte_mtr_error *error)
+{
+ enum roc_nix_bpf_color nix_vlan_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN];
+ enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
+ ROC_NIX_BPF_COLOR_YELLOW,
+ ROC_NIX_BPF_COLOR_RED};
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct roc_nix_bpf_precolor table;
+ struct roc_nix *nix = &dev->nix;
+ struct cnxk_meter_node *mtr;
+ int rc, i;
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ if (!vlan_table) {
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ nix_vlan_tbl[i] = ROC_NIX_BPF_COLOR_GREEN;
+ } else {
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ nix_vlan_tbl[i] = color_map[vlan_table[i]];
+ }
+
+ table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
+
+ switch (dev->proto) {
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
+ table.mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
+ table.mode = ROC_NIX_BPF_PC_MODE_VLAN_INNER;
+ break;
+ default:
+ rc = -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "Invalid input color protocol");
+ goto exit;
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ table.color[i] = nix_vlan_tbl[i];
+
+ rc = roc_nix_bpf_pre_color_tbl_setup(nix, mtr->bpf_id,
+ lvl_map[mtr->level], &table);
+ if (rc) {
+ rte_mtr_error_set(error, rc, RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+ NULL, NULL);
+ goto exit;
+ }
+
+ for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
+ dev->precolor_tbl[i] = nix_vlan_tbl[i];
+
+exit:
+ return rc;
+}
+
+static int
+cnxk_nix_mtr_in_proto_set(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ enum rte_mtr_color_in_protocol proto,
+ uint32_t priority, struct rte_mtr_error *error)
+{
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct cnxk_meter_node *mtr;
+
+ RTE_SET_USED(priority);
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ dev->proto = proto;
+ return 0;
+}
+
+static int
+cnxk_nix_mtr_in_proto_get(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ uint64_t *proto_mask, struct rte_mtr_error *error)
+{
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct cnxk_meter_node *mtr;
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ *proto_mask = dev->proto;
+ return 0;
+}
+
+static int
+cnxk_nix_mtr_in_proto_prio_get(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
+ enum rte_mtr_color_in_protocol proto,
+ uint32_t *priority, struct rte_mtr_error *error)
+{
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct cnxk_meter_node *mtr;
+
+ RTE_SET_USED(proto);
+
+ mtr = nix_mtr_find(dev, mtr_id);
+ if (mtr == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
+ "Meter object not found");
+ }
+
+ plt_info("Only single priority supported i.e. 0");
+ *priority = 0;
+ return 0;
+}
+
static int
cnxk_nix_mtr_stats_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
uint64_t stats_mask, struct rte_mtr_error *error)
@@ -870,6 +1043,10 @@ const struct rte_mtr_ops nix_mtr_ops = {
.meter_enable = cnxk_nix_mtr_enable,
.meter_disable = cnxk_nix_mtr_disable,
.meter_dscp_table_update = cnxk_nix_mtr_dscp_table_update,
+ .meter_vlan_table_update = cnxk_nix_mtr_vlan_table_update,
+ .in_proto_set = cnxk_nix_mtr_in_proto_set,
+ .in_proto_get = cnxk_nix_mtr_in_proto_get,
+ .in_proto_prio_get = cnxk_nix_mtr_in_proto_prio_get,
.stats_update = cnxk_nix_mtr_stats_update,
.stats_read = cnxk_nix_mtr_stats_read,
};
@@ -1041,6 +1218,9 @@ nix_mtr_level_update(struct rte_eth_dev *eth_dev, uint32_t id, uint32_t level)
static void
nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
{
+ enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
+ ROC_NIX_BPF_COLOR_YELLOW,
+ ROC_NIX_BPF_COLOR_RED};
enum roc_nix_bpf_algo alg_map[] = {
ROC_NIX_BPF_ALGO_NONE, ROC_NIX_BPF_ALGO_2697,
ROC_NIX_BPF_ALGO_2698, ROC_NIX_BPF_ALGO_4115};
@@ -1049,6 +1229,28 @@ nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
cfg->alg = alg_map[profile->profile.alg];
cfg->lmode = profile->profile.packet_mode;
+ cfg->icolor = color_map[mtr->params.default_input_color];
+
+ switch (RTE_MTR_COLOR_IN_PROTO_OUTER_IP) {
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
+ cfg->tnl_ena = false;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_DSCP_INNER;
+ cfg->tnl_ena = true;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
+ cfg->tnl_ena = false;
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
+ cfg->pc_mode = ROC_NIX_BPF_PC_MODE_VLAN_INNER;
+ cfg->tnl_ena = true;
+ break;
+ default:
+ break;
+ }
switch (cfg->alg) {
case ROC_NIX_BPF_ALGO_2697:
@@ -1090,23 +1292,50 @@ nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
}
static void
-nix_dscp_table_map(struct cnxk_meter_node *mtr,
- struct roc_nix_bpf_precolor *tbl)
+nix_precolor_table_map(struct cnxk_meter_node *mtr,
+ struct roc_nix_bpf_precolor *tbl,
+ enum rte_mtr_color_in_protocol proto)
{
enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
ROC_NIX_BPF_COLOR_YELLOW,
ROC_NIX_BPF_COLOR_RED};
int i;
- tbl->count = ROC_NIX_BPF_PRE_COLOR_MAX;
- tbl->mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
-
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
- tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
-
- if (mtr->params.dscp_table) {
- for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
- tbl->color[i] = color_map[mtr->params.dscp_table[i]];
+ switch (proto) {
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
+ case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
+ tbl->count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
+ tbl->mode = (proto == RTE_MTR_COLOR_IN_PROTO_OUTER_IP) ?
+ ROC_NIX_BPF_PC_MODE_DSCP_OUTER :
+ ROC_NIX_BPF_PC_MODE_DSCP_INNER;
+
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
+
+ if (mtr->params.dscp_table) {
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] =
+ color_map[mtr->params.dscp_table[i]];
+ }
+ break;
+ case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
+ case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
+ tbl->count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
+ tbl->mode = (proto == RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN) ?
+ ROC_NIX_BPF_PC_MODE_VLAN_OUTER :
+ ROC_NIX_BPF_PC_MODE_VLAN_INNER;
+
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
+
+ if (mtr->params.vlan_table) {
+ for (i = 0; i < tbl->count; i++)
+ tbl->color[i] =
+ color_map[mtr->params.vlan_table[i]];
+ }
+ break;
+ default:
+ break;
}
}
@@ -1245,7 +1474,8 @@ nix_mtr_configure(struct rte_eth_dev *eth_dev, uint32_t id)
memset(&tbl, 0,
sizeof(struct roc_nix_bpf_precolor));
- nix_dscp_table_map(mtr[i], &tbl);
+ nix_precolor_table_map(mtr[i], &tbl,
+ dev->proto);
rc = roc_nix_bpf_pre_color_tbl_setup(nix,
mtr[i]->bpf_id, lvl_map[mtr[i]->level],
&tbl);
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v4 1/1] app/testpmd: support different input color method
2022-06-14 10:05 ` [PATCH v4 " skori
@ 2022-06-23 11:05 ` Andrew Rybchenko
2022-06-23 12:54 ` [EXT] " Sunil Kumar Kori
2022-06-23 12:57 ` [PATCH v5 " skori
1 sibling, 1 reply; 30+ messages in thread
From: Andrew Rybchenko @ 2022-06-23 11:05 UTC (permalink / raw)
To: skori, Xiaoyun Li, Aman Singh, Yuying Zhang, Cristian Dumitrescu; +Cc: dev
On 6/14/22 13:05, skori@marvell.com wrote:
> From: Sunil Kumar Kori <skori@marvell.com>
>
> To enable input coloring, based on VLAN or DSCP, patch adds
> command line interface to configure the following:
>
> - configuring input coloring using VLAN or DSCP while creating
> meter i.e. during rte_mtr_create()
>
> - Update VLAN input coloring table at runtime.
>
> - configures protocol priorities.
>
> - retrieve protocol and priority information
>
> Depends-on: patch-22751 ("ethdev: mtr: support protocol based input color selection")
>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> ---
> v3..v4:
> - Replace strcmp with strcasecmp whereever is needed.
>
> v2..v3:
> - Rebased to branch ToT dpdk-next-net/main
> - Fix static keyword for newly added token parsing symbols
>
> v1..v2:
> - Rebased to branch dpdk-next-net
> - add CLIs for input coloring mechanism
>
> app/test-pmd/cmdline.c | 4 +
> app/test-pmd/cmdline_mtr.c | 552 ++++++++++++++++++++++++++++++++++++-
> app/test-pmd/cmdline_mtr.h | 4 +
> 3 files changed, 554 insertions(+), 6 deletions(-)
doc/guides/testpmd_app_ug/testpmd_funcs.rst update is missing.
Please, respin it quickly and I'll process it today.
^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [EXT] Re: [PATCH v4 1/1] app/testpmd: support different input color method
2022-06-23 11:05 ` Andrew Rybchenko
@ 2022-06-23 12:54 ` Sunil Kumar Kori
0 siblings, 0 replies; 30+ messages in thread
From: Sunil Kumar Kori @ 2022-06-23 12:54 UTC (permalink / raw)
To: Andrew Rybchenko, Xiaoyun Li, Aman Singh, Yuying Zhang,
Cristian Dumitrescu
Cc: dev
> -----Original Message-----
> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Sent: Thursday, June 23, 2022 4:36 PM
> To: Sunil Kumar Kori <skori@marvell.com>; Xiaoyun Li
> <xiaoyun.li@intel.com>; Aman Singh <aman.deep.singh@intel.com>; Yuying
> Zhang <yuying.zhang@intel.com>; Cristian Dumitrescu
> <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org
> Subject: [EXT] Re: [PATCH v4 1/1] app/testpmd: support different input color
> method
>
> External Email
>
> ----------------------------------------------------------------------
> On 6/14/22 13:05, skori@marvell.com wrote:
> > From: Sunil Kumar Kori <skori@marvell.com>
> >
> > To enable input coloring, based on VLAN or DSCP, patch adds command
> > line interface to configure the following:
> >
> > - configuring input coloring using VLAN or DSCP while creating
> > meter i.e. during rte_mtr_create()
> >
> > - Update VLAN input coloring table at runtime.
> >
> > - configures protocol priorities.
> >
> > - retrieve protocol and priority information
> >
> > Depends-on: patch-22751 ("ethdev: mtr: support protocol based input
> > color selection")
> >
> > Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> > Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> > ---
> > v3..v4:
> > - Replace strcmp with strcasecmp whereever is needed.
> >
> > v2..v3:
> > - Rebased to branch ToT dpdk-next-net/main
> > - Fix static keyword for newly added token parsing symbols
> >
> > v1..v2:
> > - Rebased to branch dpdk-next-net
> > - add CLIs for input coloring mechanism
> >
> > app/test-pmd/cmdline.c | 4 +
> > app/test-pmd/cmdline_mtr.c | 552
> ++++++++++++++++++++++++++++++++++++-
> > app/test-pmd/cmdline_mtr.h | 4 +
> > 3 files changed, 554 insertions(+), 6 deletions(-)
>
>
> doc/guides/testpmd_app_ug/testpmd_funcs.rst update is missing.
> Please, respin it quickly and I'll process it today.
Ack.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v5 1/1] app/testpmd: support different input color method
2022-06-14 10:05 ` [PATCH v4 " skori
2022-06-23 11:05 ` Andrew Rybchenko
@ 2022-06-23 12:57 ` skori
2022-06-23 13:07 ` Sunil Kumar Kori
2022-06-24 12:44 ` Andrew Rybchenko
1 sibling, 2 replies; 30+ messages in thread
From: skori @ 2022-06-23 12:57 UTC (permalink / raw)
To: Xiaoyun Li, Aman Singh, Yuying Zhang, Cristian Dumitrescu
Cc: dev, Sunil Kumar Kori
From: Sunil Kumar Kori <skori@marvell.com>
To enable input coloring, based on VLAN or DSCP, patch adds
command line interface to configure the following:
- configuring input coloring using VLAN or DSCP while creating
meter i.e. during rte_mtr_create()
- Update VLAN input coloring table at runtime.
- configures protocol priorities.
- retrieve protocol and priority information
Depends-on: patch-22751 ("ethdev: mtr: support protocol based input color selection")
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
v4..v5:
- Update testpmd user guide.
v3..v4:
- Replace strcmp with strcasecmp whereever is needed.
v2..v3:
- Rebased to branch ToT dpdk-next-net/main
- Fix static keyword for newly added token parsing symbols
v1..v2:
- Rebased to branch dpdk-next-net
- add CLIs for input coloring mechanism
app/test-pmd/cmdline.c | 4 +
app/test-pmd/cmdline_mtr.c | 552 +++++++++++++++++++-
app/test-pmd/cmdline_mtr.h | 4 +
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 35 +-
4 files changed, 587 insertions(+), 8 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 9a7fd5fc35..ded7dfe656 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -14345,6 +14345,10 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
+ (cmdline_parse_inst_t *)&cmd_set_port_meter_vlan_table,
+ (cmdline_parse_inst_t *)&cmd_set_port_meter_in_proto,
+ (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto,
+ (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto_prio,
(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
(cmdline_parse_inst_t *)&cmd_mcast_addr,
diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index 57050ec9af..b92e66cedb 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -14,6 +14,7 @@
#include "cmdline_mtr.h"
#define PARSE_DELIMITER " \f\n\r\t\v"
+#define MAX_VLAN_TABLE_ENTRIES 16
#define MAX_DSCP_TABLE_ENTRIES 64
/** Display Meter Error Message */
@@ -82,6 +83,122 @@ parse_uint(uint64_t *value, const char *str)
return 0;
}
+static int
+parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
+ enum rte_color **vlan_table)
+{
+ enum rte_color *vlan, *dscp;
+ char *token;
+ int i = 0;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for dscp table */
+ dscp = (enum rte_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (dscp == NULL)
+ return -1;
+
+ while (1) {
+ if (strcasecmp(token, "G") == 0)
+ dscp[i++] = RTE_COLOR_GREEN;
+ else if (strcasecmp(token, "Y") == 0)
+ dscp[i++] = RTE_COLOR_YELLOW;
+ else if (strcasecmp(token, "R") == 0)
+ dscp[i++] = RTE_COLOR_RED;
+ else {
+ free(dscp);
+ return -1;
+ }
+ if (i == MAX_DSCP_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(dscp);
+ return -1;
+ }
+ }
+
+ *dscp_table = dscp;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for vlan table */
+ vlan = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (vlan == NULL)
+ return -1;
+
+ i = 0;
+ while (1) {
+ if (strcasecmp(token, "G") == 0)
+ vlan[i++] = RTE_COLOR_GREEN;
+ else if (strcasecmp(token, "Y") == 0)
+ vlan[i++] = RTE_COLOR_YELLOW;
+ else if (strcasecmp(token, "R") == 0)
+ vlan[i++] = RTE_COLOR_RED;
+ else {
+ free(vlan);
+ return -1;
+ }
+ if (i == MAX_VLAN_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(vlan);
+ return -1;
+ }
+ }
+
+ *vlan_table = vlan;
+ return 0;
+}
+
+static int
+parse_vlan_table_entries(char *str, enum rte_color **vlan_table)
+{
+ char *token;
+ int i = 0;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ /* Allocate memory for vlan table */
+ *vlan_table = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
+ sizeof(enum rte_color));
+ if (*vlan_table == NULL)
+ return -1;
+
+ while (1) {
+ if (strcasecmp(token, "G") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_GREEN;
+ else if (strcasecmp(token, "Y") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_YELLOW;
+ else if (strcasecmp(token, "R") == 0)
+ (*vlan_table)[i++] = RTE_COLOR_RED;
+ else {
+ free(*vlan_table);
+ return -1;
+ }
+ if (i == MAX_VLAN_TABLE_ENTRIES)
+ break;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL) {
+ free(*vlan_table);
+ return -1;
+ }
+ }
+ return 0;
+}
+
static int
parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
{
@@ -124,9 +241,30 @@ parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
return 0;
}
+static int
+parse_default_input_color_str(char *str, uint64_t *def_inp_color)
+{
+ char *token;
+
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ if (token == NULL)
+ return 0;
+
+ if (strcasecmp(token, "G") == 0)
+ *def_inp_color = RTE_COLOR_GREEN;
+ else if (strcasecmp(token, "Y") == 0)
+ *def_inp_color = RTE_COLOR_YELLOW;
+ else if (strcasecmp(token, "R") == 0)
+ *def_inp_color = RTE_COLOR_RED;
+ else
+ return -1;
+
+ return 0;
+}
+
static int
parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
- enum rte_color **dscp_table)
+ enum rte_color **vlan_table, enum rte_color **dscp_table)
{
char *token;
uint64_t previous_mtr_color = 0;
@@ -147,8 +285,7 @@ parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
return 0;
}
- /* Parse dscp table entries */
- ret = parse_dscp_table_entries(c_str, dscp_table);
+ ret = parse_input_color_table_entries(c_str, dscp_table, vlan_table);
if (ret != 0)
return -1;
@@ -192,6 +329,43 @@ parse_multi_token_string(char *t_str, uint16_t *port_id,
return 0;
}
+static int
+parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
+ enum rte_color **vlan_table)
+{
+ uint64_t val;
+ char *token;
+ int ret;
+
+ /* First token: port id */
+ token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+ if (token == NULL)
+ return -1;
+
+ ret = parse_uint(&val, token);
+ if (ret != 0 || val > UINT16_MAX)
+ return -1;
+
+ *port_id = val;
+
+ /* Second token: meter id */
+ token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+ if (token == NULL)
+ return 0;
+
+ ret = parse_uint(&val, token);
+ if (ret != 0 || val > UINT32_MAX)
+ return -1;
+
+ *mtr_id = val;
+
+ ret = parse_vlan_table_entries(t_str, vlan_table);
+ if (ret != 0)
+ return -1;
+
+ return 0;
+}
+
/* *** Show Port Meter Capabilities *** */
struct cmd_show_port_meter_cap_result {
cmdline_fixed_string_t show;
@@ -277,6 +451,10 @@ static void cmd_show_port_meter_cap_parsed(void *parsed_result,
printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
cap.trtcm_rfc4115_packet_mode_supported);
printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
+ printf("cap.input_color_proto_mask 0x%" PRIx64 "\n",
+ cap.input_color_proto_mask);
+ printf("cap.separate_input_color_table_per_port %" PRId32 "\n",
+ cap.separate_input_color_table_per_port);
}
cmdline_parse_inst_t cmd_show_port_meter_cap = {
@@ -721,6 +899,7 @@ struct cmd_create_port_meter_result {
cmdline_fixed_string_t r_action;
uint64_t statistics_mask;
uint32_t shared;
+ cmdline_fixed_string_t default_input_color;
cmdline_multi_string_t meter_input_color;
};
@@ -754,6 +933,9 @@ static cmdline_parse_token_num_t cmd_create_port_meter_statistics_mask =
static cmdline_parse_token_num_t cmd_create_port_meter_shared =
TOKEN_NUM_INITIALIZER(struct cmd_create_port_meter_result,
shared, RTE_UINT32);
+static cmdline_parse_token_string_t cmd_create_port_meter_default_input_color =
+ TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
+ default_input_color, "R#Y#G#r#y#g");
static cmdline_parse_token_string_t cmd_create_port_meter_input_color =
TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
meter_input_color, TOKEN_STRING_MULTI);
@@ -769,7 +951,10 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
uint32_t shared = res->shared;
uint32_t use_prev_meter_color = 0;
uint16_t port_id = res->port_id;
+ uint64_t def_inp_color = 0;
enum rte_color *dscp_table = NULL;
+ enum rte_color *vlan_table = NULL;
+ char *def_color_str = res->default_input_color;
char *c_str = res->meter_input_color;
int ret;
@@ -780,8 +965,18 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
memset(¶ms, 0, sizeof(struct rte_mtr_params));
params.meter_profile_id = res->profile_id;
params.meter_policy_id = res->policy_id;
+
+ /* Parse meter default input color string params */
+ ret = parse_default_input_color_str(def_color_str, &def_inp_color);
+ if (ret) {
+ fprintf(stderr,
+ " Meter default input color is invalid\n");
+ return;
+ }
+
/* Parse meter input color string params */
- ret = parse_meter_color_str(c_str, &use_prev_meter_color, &dscp_table);
+ ret = parse_meter_color_str(c_str, &use_prev_meter_color, &vlan_table,
+ &dscp_table);
if (ret) {
fprintf(stderr,
" Meter input color params string parse error\n");
@@ -789,16 +984,20 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
}
params.use_prev_mtr_color = use_prev_meter_color;
+ params.vlan_table = vlan_table;
params.dscp_table = dscp_table;
+ params.default_input_color = def_inp_color;
if (strcmp(res->meter_enable, "yes") == 0)
params.meter_enable = 1;
else
params.meter_enable = 0;
+
params.stats_mask = res->statistics_mask;
ret = rte_mtr_create(port_id, mtr_id, ¶ms, shared, &error);
if (ret != 0) {
+ free(vlan_table);
free(dscp_table);
print_err_msg(&error);
return;
@@ -809,8 +1008,10 @@ cmdline_parse_inst_t cmd_create_port_meter = {
.f = cmd_create_port_meter_parsed,
.data = NULL,
.help_str = "create port meter <port_id> <mtr_id> <profile_id> <policy_id> "
- "<meter_enable>(yes|no) <stats_mask> <shared> <use_pre_meter_color> "
- "[<dscp_tbl_entry0> <dscp_tbl_entry1> ...<dscp_tbl_entry63>]",
+ "<meter_enable>(yes|no) <stats_mask> <shared> "
+ "<default_input_color>(g|y|r) <use_pre_meter_color> "
+ "[<dscp_tbl_entry0> <dscp_tbl_entry1> ...<dscp_tbl_entry63>] "
+ "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry15>]",
.tokens = {
(void *)&cmd_create_port_meter_create,
(void *)&cmd_create_port_meter_port,
@@ -822,6 +1023,7 @@ cmdline_parse_inst_t cmd_create_port_meter = {
(void *)&cmd_create_port_meter_meter_enable,
(void *)&cmd_create_port_meter_statistics_mask,
(void *)&cmd_create_port_meter_shared,
+ (void *)&cmd_create_port_meter_default_input_color,
(void *)&cmd_create_port_meter_input_color,
NULL,
},
@@ -1224,6 +1426,344 @@ cmdline_parse_inst_t cmd_set_port_meter_dscp_table = {
},
};
+/* *** Set Port Meter VLAN Table *** */
+struct cmd_set_port_meter_vlan_table_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t vlan_table;
+ cmdline_multi_string_t token_string;
+};
+
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_set =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, set, "set");
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, port, "port");
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result, meter, "meter");
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_vlan_table =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_vlan_table_result,
+ vlan_table, "vlan table");
+static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_token_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_port_meter_vlan_table_result,
+ token_string, TOKEN_STRING_MULTI);
+
+static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_vlan_table_result *res = parsed_result;
+ struct rte_mtr_error error;
+ enum rte_color *vlan_table = NULL;
+ char *t_str = res->token_string;
+ uint32_t mtr_id = 0;
+ uint16_t port_id;
+ int ret;
+
+ /* Parse string */
+ ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &vlan_table);
+ if (ret) {
+ fprintf(stderr, " Multi token string parse error\n");
+ return;
+ }
+
+ if (port_id_is_invalid(port_id, ENABLED_WARN))
+ goto free_table;
+
+ /* Update Meter VLAN Table*/
+ ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id,
+ vlan_table, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+
+free_table:
+ free(vlan_table);
+}
+
+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> "
+ "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry15>]",
+ .tokens = {
+ (void *)&cmd_set_port_meter_vlan_table_set,
+ (void *)&cmd_set_port_meter_vlan_table_port,
+ (void *)&cmd_set_port_meter_vlan_table_meter,
+ (void *)&cmd_set_port_meter_vlan_table_vlan_table,
+ (void *)&cmd_set_port_meter_vlan_table_token_string,
+ NULL,
+ },
+};
+
+/* *** Set Port Meter input protocol *** */
+struct cmd_set_port_meter_in_proto_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ cmdline_fixed_string_t proto;
+ uint32_t prio;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_set =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, set, "set");
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, port, "port");
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, meter, "meter");
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, protocol, "proto");
+
+static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_proto =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, proto,
+ "outer_vlan#inner_vlan#outer_ip#inner_ip");
+
+static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_prio =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, prio, RTE_UINT32);
+
+static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, port_id, RTE_UINT16);
+
+static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_set_port_meter_in_proto_result, mtr_id, RTE_UINT32);
+
+static void cmd_set_port_meter_in_proto_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_in_proto_result *res = parsed_result;
+ enum rte_mtr_color_in_protocol proto;
+ struct rte_mtr_error error;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ if (strcmp(res->proto, "outer_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
+ else if (strcmp(res->proto, "inner_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
+ else if (strcmp(res->proto, "outer_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
+ else if (strcmp(res->proto, "inner_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
+ else {
+ printf("Invalid protocol\n");
+ return;
+ }
+
+ /* Update Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_set(res->port_id, res->mtr_id,
+ proto, res->prio, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+}
+
+cmdline_parse_inst_t cmd_set_port_meter_in_proto = {
+ .f = cmd_set_port_meter_in_proto_parsed,
+ .data = NULL,
+ .help_str = "set port meter proto <port_id> <mtr_id> <proto> "
+ "<prio>",
+ .tokens = {
+ (void *)&cmd_set_port_meter_in_proto_set,
+ (void *)&cmd_set_port_meter_in_proto_port,
+ (void *)&cmd_set_port_meter_in_proto_meter,
+ (void *)&cmd_set_port_meter_in_proto_protocol,
+ (void *)&cmd_set_port_meter_in_proto_port_id,
+ (void *)&cmd_set_port_meter_in_proto_mtr_id,
+ (void *)&cmd_set_port_meter_in_proto_proto,
+ (void *)&cmd_set_port_meter_in_proto_prio,
+ NULL,
+ },
+};
+
+/* *** Get Port Meter input protocol *** */
+struct cmd_get_port_meter_in_proto_result {
+ cmdline_fixed_string_t get;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_get =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, get, "get");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, port, "port");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, meter, "meter");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, protocol, "proto");
+
+static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, port_id, RTE_UINT16);
+
+static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_result, mtr_id, RTE_UINT32);
+
+static void cmd_get_port_meter_in_proto_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_set_port_meter_in_proto_result *res = parsed_result;
+ struct rte_mtr_error error;
+ uint64_t proto_mask = 0;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ /* Update Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_get(res->port_id, res->mtr_id,
+ &proto_mask, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+
+ printf("Enabled protocols:\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN)
+ printf("\touter_vlan\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_VLAN)
+ printf("\tinner_vlan\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_IP)
+ printf("\touter_ip\n");
+ if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_IP)
+ printf("\tinner_ip\n");
+}
+
+cmdline_parse_inst_t cmd_get_port_meter_in_proto = {
+ .f = cmd_get_port_meter_in_proto_parsed,
+ .data = NULL,
+ .help_str = "get port meter proto <port_id> <mtr_id>",
+ .tokens = {
+ (void *)&cmd_get_port_meter_in_proto_get,
+ (void *)&cmd_get_port_meter_in_proto_port,
+ (void *)&cmd_get_port_meter_in_proto_meter,
+ (void *)&cmd_get_port_meter_in_proto_protocol,
+ (void *)&cmd_get_port_meter_in_proto_port_id,
+ (void *)&cmd_get_port_meter_in_proto_mtr_id,
+ NULL,
+ },
+};
+
+/* *** Get Port Meter input protocol priority *** */
+struct cmd_get_port_meter_in_proto_prio_result {
+ cmdline_fixed_string_t get;
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t meter;
+ cmdline_fixed_string_t protocol;
+ cmdline_fixed_string_t proto;
+ uint32_t mtr_id;
+ uint16_t port_id;
+};
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_get =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, get, "get");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_port =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, port, "port");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_meter =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, meter, "meter");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_protocol =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, protocol,
+ "proto_prio");
+
+static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_proto =
+ TOKEN_STRING_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, proto,
+ "outer_vlan#inner_vlan#outer_ip#inner_ip");
+
+static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_prio_port_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, port_id,
+ RTE_UINT16);
+
+static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_prio_mtr_id =
+ TOKEN_NUM_INITIALIZER(
+ struct cmd_get_port_meter_in_proto_prio_result, mtr_id,
+ RTE_UINT32);
+
+static void cmd_get_port_meter_in_proto_prio_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_get_port_meter_in_proto_prio_result *res = parsed_result;
+ enum rte_mtr_color_in_protocol proto;
+ struct rte_mtr_error error;
+ uint32_t prio = 0;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ if (strcmp(res->proto, "outer_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
+ else if (strcmp(res->proto, "inner_vlan") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
+ else if (strcmp(res->proto, "outer_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
+ else if (strcmp(res->proto, "inner_ip") == 0)
+ proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
+ else {
+ printf("Invalid protocol\n");
+ return;
+ }
+
+ /* Get Meter input proto and priority */
+ ret = rte_mtr_color_in_protocol_priority_get(res->port_id, res->mtr_id,
+ proto, &prio, &error);
+ if (ret != 0)
+ print_err_msg(&error);
+}
+
+cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio = {
+ .f = cmd_get_port_meter_in_proto_prio_parsed,
+ .data = NULL,
+ .help_str = "get port meter proto_prio <port_id> <mtr_id> <proto>",
+ .tokens = {
+ (void *)&cmd_get_port_meter_in_proto_prio_get,
+ (void *)&cmd_get_port_meter_in_proto_prio_port,
+ (void *)&cmd_get_port_meter_in_proto_prio_meter,
+ (void *)&cmd_get_port_meter_in_proto_prio_protocol,
+ (void *)&cmd_get_port_meter_in_proto_prio_port_id,
+ (void *)&cmd_get_port_meter_in_proto_prio_mtr_id,
+ (void *)&cmd_get_port_meter_in_proto_prio_proto,
+ NULL,
+ },
+};
+
/* *** Set Port Meter Stats Mask *** */
struct cmd_set_port_meter_stats_mask_result {
cmdline_fixed_string_t set;
diff --git a/app/test-pmd/cmdline_mtr.h b/app/test-pmd/cmdline_mtr.h
index 2415fc16c3..23eaa5bc03 100644
--- a/app/test-pmd/cmdline_mtr.h
+++ b/app/test-pmd/cmdline_mtr.h
@@ -19,6 +19,10 @@ extern cmdline_parse_inst_t cmd_del_port_meter;
extern cmdline_parse_inst_t cmd_del_port_meter_policy;
extern cmdline_parse_inst_t cmd_set_port_meter_profile;
extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;
+extern cmdline_parse_inst_t cmd_set_port_meter_vlan_table;
+extern cmdline_parse_inst_t cmd_set_port_meter_in_proto;
+extern cmdline_parse_inst_t cmd_get_port_meter_in_proto;
+extern cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio;
extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;
extern cmdline_parse_inst_t cmd_show_port_meter_stats;
void print_mtr_err_msg(struct rte_mtr_error *error);
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 0b7a53fdf1..4509a47ed4 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2527,9 +2527,10 @@ create port meter
Create new meter object for the ethernet device::
testpmd> create port meter (port_id) (mtr_id) (profile_id) \
- (policy_id) (meter_enable) (stats_mask) (shared) \
+ (policy_id) (meter_enable) (stats_mask) (shared) (default_input_color) \
(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\
- (dscp_tbl_entry63)]
+ (dscp_tbl_entry63)] [(vlan_tbl_entry0) (vlan_tbl_entry1) ... \
+ (vlan_tbl_entry15)]
where:
@@ -2542,12 +2543,17 @@ where:
meter object.
* ``shared``: When this parameter has a non-zero value, the meter object is
shared by multiple flows. Otherwise, meter object is used by single flow.
+* ``default_input_color``: Default input color for incoming packets.
+ If incoming packet misses DSCP or VLAN input color table then it will be used
+ as input color.
* ``use_pre_meter_color``: When this parameter has a non-zero value, the
input color for the current meter object is determined by the latest meter
object in the same flow. Otherwise, the current meter object uses the
*dscp_table* to determine the input color.
* ``dscp_tbl_entryx``: DSCP table entry x providing meter providing input
color, 0 <= x <= 63.
+* ``vlan_tbl_entryx``: VLAN table entry x providing meter input color,
+ 0 <= x <= 15.
enable port meter
~~~~~~~~~~~~~~~~~
@@ -2585,6 +2591,31 @@ 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)]
+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)]
+
+set port meter protocol
+~~~~~~~~~~~~~~~~~~~~~~~
+Set meter protocol and corresponding priority::
+
+ testpmd> set port meter proto (port_id) (mtr_id) (proto) (prio)
+
+get port meter protocol
+~~~~~~~~~~~~~~~~~~~~~~~
+Get meter protocol::
+
+ testpmd> get port meter proto (port_id) (mtr_id)
+
+get port meter protocol priority
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Get priority associated to meter protocol::
+
+ testpmd> get port meter proto_prio (port_id) (mtr_id) (proto)
+
set port meter stats mask
~~~~~~~~~~~~~~~~~~~~~~~~~
--
2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [PATCH v5 1/1] app/testpmd: support different input color method
2022-06-23 12:57 ` [PATCH v5 " skori
@ 2022-06-23 13:07 ` Sunil Kumar Kori
2022-06-24 12:44 ` Andrew Rybchenko
1 sibling, 0 replies; 30+ messages in thread
From: Sunil Kumar Kori @ 2022-06-23 13:07 UTC (permalink / raw)
To: Sunil Kumar Kori, Xiaoyun Li, Aman Singh, Yuying Zhang,
Cristian Dumitrescu, Andrew Rybchenko
Cc: dev
@Andrew Rybchenko
Please look into it. Updated user guide as suggested.
Regards
Sunil Kumar Kori
> -----Original Message-----
> From: skori@marvell.com <skori@marvell.com>
> Sent: Thursday, June 23, 2022 6:27 PM
> To: Xiaoyun Li <xiaoyun.li@intel.com>; Aman Singh
> <aman.deep.singh@intel.com>; Yuying Zhang <yuying.zhang@intel.com>;
> Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org; Sunil Kumar Kori <skori@marvell.com>
> Subject: [PATCH v5 1/1] app/testpmd: support different input color method
>
> From: Sunil Kumar Kori <skori@marvell.com>
>
> To enable input coloring, based on VLAN or DSCP, patch adds command line
> interface to configure the following:
>
> - configuring input coloring using VLAN or DSCP while creating
> meter i.e. during rte_mtr_create()
>
> - Update VLAN input coloring table at runtime.
>
> - configures protocol priorities.
>
> - retrieve protocol and priority information
>
> Depends-on: patch-22751 ("ethdev: mtr: support protocol based input color
> selection")
>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> ---
> v4..v5:
> - Update testpmd user guide.
>
> v3..v4:
> - Replace strcmp with strcasecmp whereever is needed.
>
> v2..v3:
> - Rebased to branch ToT dpdk-next-net/main
> - Fix static keyword for newly added token parsing symbols
>
> v1..v2:
> - Rebased to branch dpdk-next-net
> - add CLIs for input coloring mechanism
>
> app/test-pmd/cmdline.c | 4 +
> app/test-pmd/cmdline_mtr.c | 552 +++++++++++++++++++-
> app/test-pmd/cmdline_mtr.h | 4 +
> doc/guides/testpmd_app_ug/testpmd_funcs.rst | 35 +-
> 4 files changed, 587 insertions(+), 8 deletions(-)
>
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> 9a7fd5fc35..ded7dfe656 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -14345,6 +14345,10 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
> (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
> (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
> (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
> + (cmdline_parse_inst_t *)&cmd_set_port_meter_vlan_table,
> + (cmdline_parse_inst_t *)&cmd_set_port_meter_in_proto,
> + (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto,
> + (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto_prio,
> (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
> (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
> (cmdline_parse_inst_t *)&cmd_mcast_addr, diff --git a/app/test-
> pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c index
> 57050ec9af..b92e66cedb 100644
> --- a/app/test-pmd/cmdline_mtr.c
> +++ b/app/test-pmd/cmdline_mtr.c
> @@ -14,6 +14,7 @@
> #include "cmdline_mtr.h"
>
> #define PARSE_DELIMITER " \f\n\r\t\v"
> +#define MAX_VLAN_TABLE_ENTRIES 16
> #define MAX_DSCP_TABLE_ENTRIES 64
>
> /** Display Meter Error Message */
> @@ -82,6 +83,122 @@ parse_uint(uint64_t *value, const char *str)
> return 0;
> }
>
> +static int
> +parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
> + enum rte_color **vlan_table)
> +{
> + enum rte_color *vlan, *dscp;
> + char *token;
> + int i = 0;
> +
> + token = strtok_r(str, PARSE_DELIMITER, &str);
> + if (token == NULL)
> + return 0;
> +
> + /* Allocate memory for dscp table */
> + dscp = (enum rte_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
> + sizeof(enum rte_color));
> + if (dscp == NULL)
> + return -1;
> +
> + while (1) {
> + if (strcasecmp(token, "G") == 0)
> + dscp[i++] = RTE_COLOR_GREEN;
> + else if (strcasecmp(token, "Y") == 0)
> + dscp[i++] = RTE_COLOR_YELLOW;
> + else if (strcasecmp(token, "R") == 0)
> + dscp[i++] = RTE_COLOR_RED;
> + else {
> + free(dscp);
> + return -1;
> + }
> + if (i == MAX_DSCP_TABLE_ENTRIES)
> + break;
> +
> + token = strtok_r(str, PARSE_DELIMITER, &str);
> + if (token == NULL) {
> + free(dscp);
> + return -1;
> + }
> + }
> +
> + *dscp_table = dscp;
> +
> + token = strtok_r(str, PARSE_DELIMITER, &str);
> + if (token == NULL)
> + return 0;
> +
> + /* Allocate memory for vlan table */
> + vlan = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
> + sizeof(enum rte_color));
> + if (vlan == NULL)
> + return -1;
> +
> + i = 0;
> + while (1) {
> + if (strcasecmp(token, "G") == 0)
> + vlan[i++] = RTE_COLOR_GREEN;
> + else if (strcasecmp(token, "Y") == 0)
> + vlan[i++] = RTE_COLOR_YELLOW;
> + else if (strcasecmp(token, "R") == 0)
> + vlan[i++] = RTE_COLOR_RED;
> + else {
> + free(vlan);
> + return -1;
> + }
> + if (i == MAX_VLAN_TABLE_ENTRIES)
> + break;
> +
> + token = strtok_r(str, PARSE_DELIMITER, &str);
> + if (token == NULL) {
> + free(vlan);
> + return -1;
> + }
> + }
> +
> + *vlan_table = vlan;
> + return 0;
> +}
> +
> +static int
> +parse_vlan_table_entries(char *str, enum rte_color **vlan_table) {
> + char *token;
> + int i = 0;
> +
> + token = strtok_r(str, PARSE_DELIMITER, &str);
> + if (token == NULL)
> + return 0;
> +
> + /* Allocate memory for vlan table */
> + *vlan_table = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES
> *
> + sizeof(enum rte_color));
> + if (*vlan_table == NULL)
> + return -1;
> +
> + while (1) {
> + if (strcasecmp(token, "G") == 0)
> + (*vlan_table)[i++] = RTE_COLOR_GREEN;
> + else if (strcasecmp(token, "Y") == 0)
> + (*vlan_table)[i++] = RTE_COLOR_YELLOW;
> + else if (strcasecmp(token, "R") == 0)
> + (*vlan_table)[i++] = RTE_COLOR_RED;
> + else {
> + free(*vlan_table);
> + return -1;
> + }
> + if (i == MAX_VLAN_TABLE_ENTRIES)
> + break;
> +
> + token = strtok_r(str, PARSE_DELIMITER, &str);
> + if (token == NULL) {
> + free(*vlan_table);
> + return -1;
> + }
> + }
> + return 0;
> +}
> +
> static int
> parse_dscp_table_entries(char *str, enum rte_color **dscp_table) { @@ -
> 124,9 +241,30 @@ parse_dscp_table_entries(char *str, enum rte_color
> **dscp_table)
> return 0;
> }
>
> +static int
> +parse_default_input_color_str(char *str, uint64_t *def_inp_color) {
> + char *token;
> +
> + token = strtok_r(str, PARSE_DELIMITER, &str);
> + if (token == NULL)
> + return 0;
> +
> + if (strcasecmp(token, "G") == 0)
> + *def_inp_color = RTE_COLOR_GREEN;
> + else if (strcasecmp(token, "Y") == 0)
> + *def_inp_color = RTE_COLOR_YELLOW;
> + else if (strcasecmp(token, "R") == 0)
> + *def_inp_color = RTE_COLOR_RED;
> + else
> + return -1;
> +
> + return 0;
> +}
> +
> static int
> parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
> - enum rte_color **dscp_table)
> + enum rte_color **vlan_table, enum rte_color **dscp_table)
> {
> char *token;
> uint64_t previous_mtr_color = 0;
> @@ -147,8 +285,7 @@ parse_meter_color_str(char *c_str, uint32_t
> *use_prev_meter_color,
> return 0;
> }
>
> - /* Parse dscp table entries */
> - ret = parse_dscp_table_entries(c_str, dscp_table);
> + ret = parse_input_color_table_entries(c_str, dscp_table, vlan_table);
> if (ret != 0)
> return -1;
>
> @@ -192,6 +329,43 @@ parse_multi_token_string(char *t_str, uint16_t
> *port_id,
> return 0;
> }
>
> +static int
> +parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t
> *mtr_id,
> + enum rte_color **vlan_table)
> +{
> + uint64_t val;
> + char *token;
> + int ret;
> +
> + /* First token: port id */
> + token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
> + if (token == NULL)
> + return -1;
> +
> + ret = parse_uint(&val, token);
> + if (ret != 0 || val > UINT16_MAX)
> + return -1;
> +
> + *port_id = val;
> +
> + /* Second token: meter id */
> + token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
> + if (token == NULL)
> + return 0;
> +
> + ret = parse_uint(&val, token);
> + if (ret != 0 || val > UINT32_MAX)
> + return -1;
> +
> + *mtr_id = val;
> +
> + ret = parse_vlan_table_entries(t_str, vlan_table);
> + if (ret != 0)
> + return -1;
> +
> + return 0;
> +}
> +
> /* *** Show Port Meter Capabilities *** */ struct
> cmd_show_port_meter_cap_result {
> cmdline_fixed_string_t show;
> @@ -277,6 +451,10 @@ static void cmd_show_port_meter_cap_parsed(void
> *parsed_result,
> printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
> cap.trtcm_rfc4115_packet_mode_supported);
> printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
> + printf("cap.input_color_proto_mask 0x%" PRIx64 "\n",
> + cap.input_color_proto_mask);
> + printf("cap.separate_input_color_table_per_port %" PRId32 "\n",
> + cap.separate_input_color_table_per_port);
> }
>
> cmdline_parse_inst_t cmd_show_port_meter_cap = { @@ -721,6 +899,7
> @@ struct cmd_create_port_meter_result {
> cmdline_fixed_string_t r_action;
> uint64_t statistics_mask;
> uint32_t shared;
> + cmdline_fixed_string_t default_input_color;
> cmdline_multi_string_t meter_input_color; };
>
> @@ -754,6 +933,9 @@ static cmdline_parse_token_num_t
> cmd_create_port_meter_statistics_mask = static
> cmdline_parse_token_num_t cmd_create_port_meter_shared =
> TOKEN_NUM_INITIALIZER(struct cmd_create_port_meter_result,
> shared, RTE_UINT32);
> +static cmdline_parse_token_string_t
> cmd_create_port_meter_default_input_color =
> + TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
> + default_input_color, "R#Y#G#r#y#g");
> static cmdline_parse_token_string_t cmd_create_port_meter_input_color =
> TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
> meter_input_color, TOKEN_STRING_MULTI); @@ -769,7
> +951,10 @@ static void cmd_create_port_meter_parsed(void
> *parsed_result,
> uint32_t shared = res->shared;
> uint32_t use_prev_meter_color = 0;
> uint16_t port_id = res->port_id;
> + uint64_t def_inp_color = 0;
> enum rte_color *dscp_table = NULL;
> + enum rte_color *vlan_table = NULL;
> + char *def_color_str = res->default_input_color;
> char *c_str = res->meter_input_color;
> int ret;
>
> @@ -780,8 +965,18 @@ static void cmd_create_port_meter_parsed(void
> *parsed_result,
> memset(¶ms, 0, sizeof(struct rte_mtr_params));
> params.meter_profile_id = res->profile_id;
> params.meter_policy_id = res->policy_id;
> +
> + /* Parse meter default input color string params */
> + ret = parse_default_input_color_str(def_color_str, &def_inp_color);
> + if (ret) {
> + fprintf(stderr,
> + " Meter default input color is invalid\n");
> + return;
> + }
> +
> /* Parse meter input color string params */
> - ret = parse_meter_color_str(c_str, &use_prev_meter_color,
> &dscp_table);
> + ret = parse_meter_color_str(c_str, &use_prev_meter_color,
> &vlan_table,
> + &dscp_table);
> if (ret) {
> fprintf(stderr,
> " Meter input color params string parse error\n");
> @@ -789,16 +984,20 @@ static void cmd_create_port_meter_parsed(void
> *parsed_result,
> }
>
> params.use_prev_mtr_color = use_prev_meter_color;
> + params.vlan_table = vlan_table;
> params.dscp_table = dscp_table;
> + params.default_input_color = def_inp_color;
>
> if (strcmp(res->meter_enable, "yes") == 0)
> params.meter_enable = 1;
> else
> params.meter_enable = 0;
> +
> params.stats_mask = res->statistics_mask;
>
> ret = rte_mtr_create(port_id, mtr_id, ¶ms, shared, &error);
> if (ret != 0) {
> + free(vlan_table);
> free(dscp_table);
> print_err_msg(&error);
> return;
> @@ -809,8 +1008,10 @@ cmdline_parse_inst_t cmd_create_port_meter = {
> .f = cmd_create_port_meter_parsed,
> .data = NULL,
> .help_str = "create port meter <port_id> <mtr_id> <profile_id>
> <policy_id> "
> - "<meter_enable>(yes|no) <stats_mask> <shared>
> <use_pre_meter_color> "
> - "[<dscp_tbl_entry0> <dscp_tbl_entry1>
> ...<dscp_tbl_entry63>]",
> + "<meter_enable>(yes|no) <stats_mask> <shared> "
> + "<default_input_color>(g|y|r) <use_pre_meter_color> "
> + "[<dscp_tbl_entry0> <dscp_tbl_entry1>
> ...<dscp_tbl_entry63>] "
> + "[<vlan_tbl_entry0> <vlan_tbl_entry1> ...
> <vlan_tbl_entry15>]",
> .tokens = {
> (void *)&cmd_create_port_meter_create,
> (void *)&cmd_create_port_meter_port,
> @@ -822,6 +1023,7 @@ cmdline_parse_inst_t cmd_create_port_meter = {
> (void *)&cmd_create_port_meter_meter_enable,
> (void *)&cmd_create_port_meter_statistics_mask,
> (void *)&cmd_create_port_meter_shared,
> + (void *)&cmd_create_port_meter_default_input_color,
> (void *)&cmd_create_port_meter_input_color,
> NULL,
> },
> @@ -1224,6 +1426,344 @@ cmdline_parse_inst_t
> cmd_set_port_meter_dscp_table = {
> },
> };
>
> +/* *** Set Port Meter VLAN Table *** */ struct
> +cmd_set_port_meter_vlan_table_result {
> + cmdline_fixed_string_t set;
> + cmdline_fixed_string_t port;
> + cmdline_fixed_string_t meter;
> + cmdline_fixed_string_t vlan_table;
> + cmdline_multi_string_t token_string;
> +};
> +
> +static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_set =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_set_port_meter_vlan_table_result, set, "set");
> static
> +cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_port =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_set_port_meter_vlan_table_result, port, "port");
> static
> +cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_meter =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_set_port_meter_vlan_table_result, meter,
> "meter"); static
> +cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_vlan_table
> =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_set_port_meter_vlan_table_result,
> + vlan_table, "vlan table");
> +static cmdline_parse_token_string_t
> cmd_set_port_meter_vlan_table_token_string =
> + TOKEN_STRING_INITIALIZER(struct
> cmd_set_port_meter_vlan_table_result,
> + token_string, TOKEN_STRING_MULTI);
> +
> +static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
> + __rte_unused struct cmdline *cl,
> + __rte_unused void *data)
> +{
> + struct cmd_set_port_meter_vlan_table_result *res = parsed_result;
> + struct rte_mtr_error error;
> + enum rte_color *vlan_table = NULL;
> + char *t_str = res->token_string;
> + uint32_t mtr_id = 0;
> + uint16_t port_id;
> + int ret;
> +
> + /* Parse string */
> + ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id,
> &vlan_table);
> + if (ret) {
> + fprintf(stderr, " Multi token string parse error\n");
> + return;
> + }
> +
> + if (port_id_is_invalid(port_id, ENABLED_WARN))
> + goto free_table;
> +
> + /* Update Meter VLAN Table*/
> + ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id,
> + vlan_table, &error);
> + if (ret != 0)
> + print_err_msg(&error);
> +
> +free_table:
> + free(vlan_table);
> +}
> +
> +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> "
> + "[<vlan_tbl_entry0> <vlan_tbl_entry1> ...
> <vlan_tbl_entry15>]",
> + .tokens = {
> + (void *)&cmd_set_port_meter_vlan_table_set,
> + (void *)&cmd_set_port_meter_vlan_table_port,
> + (void *)&cmd_set_port_meter_vlan_table_meter,
> + (void *)&cmd_set_port_meter_vlan_table_vlan_table,
> + (void *)&cmd_set_port_meter_vlan_table_token_string,
> + NULL,
> + },
> +};
> +
> +/* *** Set Port Meter input protocol *** */ struct
> +cmd_set_port_meter_in_proto_result {
> + cmdline_fixed_string_t set;
> + cmdline_fixed_string_t port;
> + cmdline_fixed_string_t meter;
> + cmdline_fixed_string_t protocol;
> + cmdline_fixed_string_t proto;
> + uint32_t prio;
> + uint32_t mtr_id;
> + uint16_t port_id;
> +};
> +
> +static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_set =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_set_port_meter_in_proto_result, set, "set");
> +
> +static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_port =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_set_port_meter_in_proto_result, port, "port");
> +
> +static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_meter
> =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_set_port_meter_in_proto_result, meter,
> "meter");
> +
> +static cmdline_parse_token_string_t
> cmd_set_port_meter_in_proto_protocol =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_set_port_meter_in_proto_result, protocol,
> "proto");
> +
> +static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_proto
> =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_set_port_meter_in_proto_result, proto,
> + "outer_vlan#inner_vlan#outer_ip#inner_ip");
> +
> +static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_prio =
> + TOKEN_NUM_INITIALIZER(
> + struct cmd_set_port_meter_in_proto_result, prio,
> RTE_UINT32);
> +
> +static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_port_id
> =
> + TOKEN_NUM_INITIALIZER(
> + struct cmd_set_port_meter_in_proto_result, port_id,
> RTE_UINT16);
> +
> +static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_mtr_id
> =
> + TOKEN_NUM_INITIALIZER(
> + struct cmd_set_port_meter_in_proto_result, mtr_id,
> RTE_UINT32);
> +
> +static void cmd_set_port_meter_in_proto_parsed(void *parsed_result,
> + __rte_unused struct cmdline *cl,
> + __rte_unused void *data)
> +{
> + struct cmd_set_port_meter_in_proto_result *res = parsed_result;
> + enum rte_mtr_color_in_protocol proto;
> + struct rte_mtr_error error;
> + int ret;
> +
> + if (port_id_is_invalid(res->port_id, ENABLED_WARN))
> + return;
> +
> + if (strcmp(res->proto, "outer_vlan") == 0)
> + proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
> + else if (strcmp(res->proto, "inner_vlan") == 0)
> + proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
> + else if (strcmp(res->proto, "outer_ip") == 0)
> + proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
> + else if (strcmp(res->proto, "inner_ip") == 0)
> + proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
> + else {
> + printf("Invalid protocol\n");
> + return;
> + }
> +
> + /* Update Meter input proto and priority */
> + ret = rte_mtr_color_in_protocol_set(res->port_id, res->mtr_id,
> + proto, res->prio, &error);
> + if (ret != 0)
> + print_err_msg(&error);
> +}
> +
> +cmdline_parse_inst_t cmd_set_port_meter_in_proto = {
> + .f = cmd_set_port_meter_in_proto_parsed,
> + .data = NULL,
> + .help_str = "set port meter proto <port_id> <mtr_id> <proto> "
> + "<prio>",
> + .tokens = {
> + (void *)&cmd_set_port_meter_in_proto_set,
> + (void *)&cmd_set_port_meter_in_proto_port,
> + (void *)&cmd_set_port_meter_in_proto_meter,
> + (void *)&cmd_set_port_meter_in_proto_protocol,
> + (void *)&cmd_set_port_meter_in_proto_port_id,
> + (void *)&cmd_set_port_meter_in_proto_mtr_id,
> + (void *)&cmd_set_port_meter_in_proto_proto,
> + (void *)&cmd_set_port_meter_in_proto_prio,
> + NULL,
> + },
> +};
> +
> +/* *** Get Port Meter input protocol *** */ struct
> +cmd_get_port_meter_in_proto_result {
> + cmdline_fixed_string_t get;
> + cmdline_fixed_string_t port;
> + cmdline_fixed_string_t meter;
> + cmdline_fixed_string_t protocol;
> + uint32_t mtr_id;
> + uint16_t port_id;
> +};
> +
> +static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_get =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_result, get, "get");
> +
> +static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_port =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_result, port, "port");
> +
> +static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_meter
> =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_result, meter,
> "meter");
> +
> +static cmdline_parse_token_string_t
> cmd_get_port_meter_in_proto_protocol =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_result, protocol,
> "proto");
> +
> +static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_port_id
> =
> + TOKEN_NUM_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_result, port_id,
> RTE_UINT16);
> +
> +static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_mtr_id
> =
> + TOKEN_NUM_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_result, mtr_id,
> RTE_UINT32);
> +
> +static void cmd_get_port_meter_in_proto_parsed(void *parsed_result,
> + __rte_unused struct cmdline *cl,
> + __rte_unused void *data)
> +{
> + struct cmd_set_port_meter_in_proto_result *res = parsed_result;
> + struct rte_mtr_error error;
> + uint64_t proto_mask = 0;
> + int ret;
> +
> + if (port_id_is_invalid(res->port_id, ENABLED_WARN))
> + return;
> +
> + /* Update Meter input proto and priority */
> + ret = rte_mtr_color_in_protocol_get(res->port_id, res->mtr_id,
> + &proto_mask, &error);
> + if (ret != 0)
> + print_err_msg(&error);
> +
> + printf("Enabled protocols:\n");
> + if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN)
> + printf("\touter_vlan\n");
> + if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_VLAN)
> + printf("\tinner_vlan\n");
> + if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_IP)
> + printf("\touter_ip\n");
> + if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_IP)
> + printf("\tinner_ip\n");
> +}
> +
> +cmdline_parse_inst_t cmd_get_port_meter_in_proto = {
> + .f = cmd_get_port_meter_in_proto_parsed,
> + .data = NULL,
> + .help_str = "get port meter proto <port_id> <mtr_id>",
> + .tokens = {
> + (void *)&cmd_get_port_meter_in_proto_get,
> + (void *)&cmd_get_port_meter_in_proto_port,
> + (void *)&cmd_get_port_meter_in_proto_meter,
> + (void *)&cmd_get_port_meter_in_proto_protocol,
> + (void *)&cmd_get_port_meter_in_proto_port_id,
> + (void *)&cmd_get_port_meter_in_proto_mtr_id,
> + NULL,
> + },
> +};
> +
> +/* *** Get Port Meter input protocol priority *** */ struct
> +cmd_get_port_meter_in_proto_prio_result {
> + cmdline_fixed_string_t get;
> + cmdline_fixed_string_t port;
> + cmdline_fixed_string_t meter;
> + cmdline_fixed_string_t protocol;
> + cmdline_fixed_string_t proto;
> + uint32_t mtr_id;
> + uint16_t port_id;
> +};
> +
> +static cmdline_parse_token_string_t
> cmd_get_port_meter_in_proto_prio_get =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_prio_result, get, "get");
> +
> +static cmdline_parse_token_string_t
> cmd_get_port_meter_in_proto_prio_port =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_prio_result, port,
> "port");
> +
> +static cmdline_parse_token_string_t
> cmd_get_port_meter_in_proto_prio_meter =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_prio_result, meter,
> "meter");
> +
> +static cmdline_parse_token_string_t
> cmd_get_port_meter_in_proto_prio_protocol =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_prio_result, protocol,
> + "proto_prio");
> +
> +static cmdline_parse_token_string_t
> cmd_get_port_meter_in_proto_prio_proto =
> + TOKEN_STRING_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_prio_result, proto,
> + "outer_vlan#inner_vlan#outer_ip#inner_ip");
> +
> +static cmdline_parse_token_num_t
> cmd_get_port_meter_in_proto_prio_port_id =
> + TOKEN_NUM_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_prio_result, port_id,
> + RTE_UINT16);
> +
> +static cmdline_parse_token_num_t
> cmd_get_port_meter_in_proto_prio_mtr_id =
> + TOKEN_NUM_INITIALIZER(
> + struct cmd_get_port_meter_in_proto_prio_result, mtr_id,
> + RTE_UINT32);
> +
> +static void cmd_get_port_meter_in_proto_prio_parsed(void
> *parsed_result,
> + __rte_unused struct cmdline *cl,
> + __rte_unused void *data)
> +{
> + struct cmd_get_port_meter_in_proto_prio_result *res =
> parsed_result;
> + enum rte_mtr_color_in_protocol proto;
> + struct rte_mtr_error error;
> + uint32_t prio = 0;
> + int ret;
> +
> + if (port_id_is_invalid(res->port_id, ENABLED_WARN))
> + return;
> +
> + if (strcmp(res->proto, "outer_vlan") == 0)
> + proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
> + else if (strcmp(res->proto, "inner_vlan") == 0)
> + proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
> + else if (strcmp(res->proto, "outer_ip") == 0)
> + proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
> + else if (strcmp(res->proto, "inner_ip") == 0)
> + proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
> + else {
> + printf("Invalid protocol\n");
> + return;
> + }
> +
> + /* Get Meter input proto and priority */
> + ret = rte_mtr_color_in_protocol_priority_get(res->port_id, res-
> >mtr_id,
> + proto, &prio, &error);
> + if (ret != 0)
> + print_err_msg(&error);
> +}
> +
> +cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio = {
> + .f = cmd_get_port_meter_in_proto_prio_parsed,
> + .data = NULL,
> + .help_str = "get port meter proto_prio <port_id> <mtr_id> <proto>",
> + .tokens = {
> + (void *)&cmd_get_port_meter_in_proto_prio_get,
> + (void *)&cmd_get_port_meter_in_proto_prio_port,
> + (void *)&cmd_get_port_meter_in_proto_prio_meter,
> + (void *)&cmd_get_port_meter_in_proto_prio_protocol,
> + (void *)&cmd_get_port_meter_in_proto_prio_port_id,
> + (void *)&cmd_get_port_meter_in_proto_prio_mtr_id,
> + (void *)&cmd_get_port_meter_in_proto_prio_proto,
> + NULL,
> + },
> +};
> +
> /* *** Set Port Meter Stats Mask *** */ struct
> cmd_set_port_meter_stats_mask_result {
> cmdline_fixed_string_t set;
> diff --git a/app/test-pmd/cmdline_mtr.h b/app/test-pmd/cmdline_mtr.h
> index 2415fc16c3..23eaa5bc03 100644
> --- a/app/test-pmd/cmdline_mtr.h
> +++ b/app/test-pmd/cmdline_mtr.h
> @@ -19,6 +19,10 @@ extern cmdline_parse_inst_t cmd_del_port_meter;
> extern cmdline_parse_inst_t cmd_del_port_meter_policy; extern
> cmdline_parse_inst_t cmd_set_port_meter_profile; extern
> cmdline_parse_inst_t cmd_set_port_meter_dscp_table;
> +extern cmdline_parse_inst_t cmd_set_port_meter_vlan_table; extern
> +cmdline_parse_inst_t cmd_set_port_meter_in_proto; extern
> +cmdline_parse_inst_t cmd_get_port_meter_in_proto; extern
> +cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio;
> extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask; extern
> cmdline_parse_inst_t cmd_show_port_meter_stats; void
> print_mtr_err_msg(struct rte_mtr_error *error); diff --git
> a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index 0b7a53fdf1..4509a47ed4 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -2527,9 +2527,10 @@ create port meter Create new meter object for
> the ethernet device::
>
> testpmd> create port meter (port_id) (mtr_id) (profile_id) \
> - (policy_id) (meter_enable) (stats_mask) (shared) \
> + (policy_id) (meter_enable) (stats_mask) (shared)
> + (default_input_color) \
> (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\
> - (dscp_tbl_entry63)]
> + (dscp_tbl_entry63)] [(vlan_tbl_entry0) (vlan_tbl_entry1) ... \
> + (vlan_tbl_entry15)]
>
> where:
>
> @@ -2542,12 +2543,17 @@ where:
> meter object.
> * ``shared``: When this parameter has a non-zero value, the meter object is
> shared by multiple flows. Otherwise, meter object is used by single flow.
> +* ``default_input_color``: Default input color for incoming packets.
> + If incoming packet misses DSCP or VLAN input color table then it will
> +be used
> + as input color.
> * ``use_pre_meter_color``: When this parameter has a non-zero value, the
> input color for the current meter object is determined by the latest meter
> object in the same flow. Otherwise, the current meter object uses the
> *dscp_table* to determine the input color.
> * ``dscp_tbl_entryx``: DSCP table entry x providing meter providing input
> color, 0 <= x <= 63.
> +* ``vlan_tbl_entryx``: VLAN table entry x providing meter input color,
> + 0 <= x <= 15.
>
> enable port meter
> ~~~~~~~~~~~~~~~~~
> @@ -2585,6 +2591,31 @@ 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)]
>
> +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)]
> +
> +set port meter protocol
> +~~~~~~~~~~~~~~~~~~~~~~~
> +Set meter protocol and corresponding priority::
> +
> + testpmd> set port meter proto (port_id) (mtr_id) (proto) (prio)
> +
> +get port meter protocol
> +~~~~~~~~~~~~~~~~~~~~~~~
> +Get meter protocol::
> +
> + testpmd> get port meter proto (port_id) (mtr_id)
> +
> +get port meter protocol priority
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +Get priority associated to meter protocol::
> +
> + testpmd> get port meter proto_prio (port_id) (mtr_id) (proto)
> +
> set port meter stats mask
> ~~~~~~~~~~~~~~~~~~~~~~~~~
>
> --
> 2.25.1
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v5 1/1] app/testpmd: support different input color method
2022-06-23 12:57 ` [PATCH v5 " skori
2022-06-23 13:07 ` Sunil Kumar Kori
@ 2022-06-24 12:44 ` Andrew Rybchenko
1 sibling, 0 replies; 30+ messages in thread
From: Andrew Rybchenko @ 2022-06-24 12:44 UTC (permalink / raw)
To: skori, Xiaoyun Li, Aman Singh, Yuying Zhang, Cristian Dumitrescu; +Cc: dev
On 6/23/22 15:57, skori@marvell.com wrote:
> From: Sunil Kumar Kori <skori@marvell.com>
>
> To enable input coloring, based on VLAN or DSCP, patch adds
> command line interface to configure the following:
>
> - configuring input coloring using VLAN or DSCP while creating
> meter i.e. during rte_mtr_create()
>
> - Update VLAN input coloring table at runtime.
>
> - configures protocol priorities.
>
> - retrieve protocol and priority information
>
> Depends-on: patch-22751 ("ethdev: mtr: support protocol based input color selection")
>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> ---
> v4..v5:
> - Update testpmd user guide.
>
> v3..v4:
> - Replace strcmp with strcasecmp whereever is needed.
>
> v2..v3:
> - Rebased to branch ToT dpdk-next-net/main
> - Fix static keyword for newly added token parsing symbols
>
> v1..v2:
> - Rebased to branch dpdk-next-net
> - add CLIs for input coloring mechanism
>
> app/test-pmd/cmdline.c | 4 +
> app/test-pmd/cmdline_mtr.c | 552 +++++++++++++++++++-
> app/test-pmd/cmdline_mtr.h | 4 +
> doc/guides/testpmd_app_ug/testpmd_funcs.rst | 35 +-
> 4 files changed, 587 insertions(+), 8 deletions(-)
Applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v4 2/2] net/cnxk: support ops to update precolor VLAN table
2022-06-21 7:35 ` [PATCH v4 2/2] net/cnxk: support ops to update precolor VLAN table skori
@ 2022-08-22 12:33 ` Jerin Jacob
0 siblings, 0 replies; 30+ messages in thread
From: Jerin Jacob @ 2022-08-22 12:33 UTC (permalink / raw)
To: Sunil Kumar Kori; +Cc: Nithin Dabilpuram, Kiran Kumar K, Satha Rao, dpdk-dev
On Tue, Jun 21, 2022 at 1:05 PM <skori@marvell.com> wrote:
>
> From: Sunil Kumar Kori <skori@marvell.com>
>
> Implement API to update VLAN table for pre-coloring for
> incoming packet per nixlf for CN10K platform.
>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Squashed 1/2 and 2/2 and Updated the git commit as follows and applied
to dpdk-next-net-eventdev/for-main. Thanks
net/cnxk: support for ingress meter pre-color
Added support for ingress meter pre-coloring for incoming
packet for CN10K platform.
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> ---
> v3..v4:
> - Remove Depends On tag from commit log.
> - Rebase on top of dpdk-next-net/main.
> - Fix clang build failures.
>
> v2..v3:
> - Fix dscp table runtime update error.
>
> v1..v2:
> - Aligned with latest input color spec.
>
> drivers/net/cnxk/cnxk_ethdev.c | 1 +
> drivers/net/cnxk/cnxk_ethdev.h | 3 +-
> drivers/net/cnxk/cnxk_ethdev_mtr.c | 282 ++++++++++++++++++++++++++---
> 3 files changed, 259 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
> index 09e57361d2..55945456c1 100644
> --- a/drivers/net/cnxk/cnxk_ethdev.c
> +++ b/drivers/net/cnxk/cnxk_ethdev.c
> @@ -1679,6 +1679,7 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
> dev->eth_dev = eth_dev;
> dev->configured = 0;
> dev->ptype_disable = 0;
> + dev->proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
>
> TAILQ_INIT(&dev->inb.list);
> TAILQ_INIT(&dev->outb.list);
> diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
> index e99230285c..feb24f2839 100644
> --- a/drivers/net/cnxk/cnxk_ethdev.h
> +++ b/drivers/net/cnxk/cnxk_ethdev.h
> @@ -412,7 +412,8 @@ struct cnxk_eth_dev {
> uint64_t clk_delta;
>
> /* Ingress policer */
> - enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
> + enum roc_nix_bpf_color precolor_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
> + enum rte_mtr_color_in_protocol proto;
> struct cnxk_mtr_profiles mtr_profiles;
> struct cnxk_mtr_policy mtr_policy;
> struct cnxk_mtr mtr;
> diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c
> index 02803bdf75..be2cb7d628 100644
> --- a/drivers/net/cnxk/cnxk_ethdev_mtr.c
> +++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c
> @@ -48,7 +48,12 @@ static struct rte_mtr_capabilities mtr_capa = {
> RTE_MTR_STATS_N_PKTS_RED | RTE_MTR_STATS_N_PKTS_DROPPED |
> RTE_MTR_STATS_N_BYTES_GREEN |
> RTE_MTR_STATS_N_BYTES_YELLOW | RTE_MTR_STATS_N_BYTES_RED |
> - RTE_MTR_STATS_N_BYTES_DROPPED};
> + RTE_MTR_STATS_N_BYTES_DROPPED,
> + .input_color_proto_mask = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN |
> + RTE_MTR_COLOR_IN_PROTO_INNER_VLAN |
> + RTE_MTR_COLOR_IN_PROTO_OUTER_IP |
> + RTE_MTR_COLOR_IN_PROTO_INNER_IP,
> + .separate_input_color_table_per_port = true};
>
> static struct cnxk_meter_node *
> nix_mtr_find(struct cnxk_eth_dev *dev, uint32_t meter_id)
> @@ -470,6 +475,7 @@ cnxk_nix_mtr_create(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> struct cnxk_mtr_profile_node *profile;
> struct cnxk_mtr_policy_node *policy;
> struct cnxk_mtr *fm = &dev->mtr;
> + enum rte_color *table = NULL;
> struct cnxk_meter_node *mtr;
> int i;
>
> @@ -521,18 +527,40 @@ cnxk_nix_mtr_create(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> mtr->is_next = false;
> mtr->level = ROC_NIX_BPF_LEVEL_IDX_INVALID;
>
> + /* populate dscp table for input coloring */
> if (params->dscp_table) {
> - mtr->params.dscp_table =
> - plt_zmalloc(ROC_NIX_BPF_PRE_COLOR_MAX, ROC_ALIGN);
> - if (mtr->params.dscp_table == NULL) {
> + table = (enum rte_color *)plt_zmalloc(sizeof(enum rte_color) *
> + ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP, ROC_ALIGN);
> + if (table == NULL) {
> plt_free(mtr);
> return -rte_mtr_error_set(error, ENOMEM,
> RTE_MTR_ERROR_TYPE_UNSPECIFIED,
> NULL, "Memory alloc failed.");
> }
>
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> - mtr->params.dscp_table[i] = params->dscp_table[i];
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
> + table[i] = params->dscp_table[i];
> +
> + mtr->params.dscp_table = table;
> + }
> +
> +
> + /* populate vlan table for input coloring */
> + if (params->vlan_table) {
> + table = (enum rte_color *)plt_zmalloc(sizeof(enum rte_color) *
> + ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN, ROC_ALIGN);
> + if (table == NULL) {
> + plt_free(mtr->params.dscp_table);
> + plt_free(mtr);
> + return -rte_mtr_error_set(error, ENOMEM,
> + RTE_MTR_ERROR_TYPE_UNSPECIFIED,
> + NULL, "Memory alloc failed.");
> + }
> +
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
> + table[i] = params->vlan_table[i];
> +
> + mtr->params.vlan_table = table;
> }
>
> profile->ref_cnt++;
> @@ -619,7 +647,13 @@ cnxk_nix_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> mtr->policy->ref_cnt--;
> mtr->profile->ref_cnt--;
> TAILQ_REMOVE(fm, mtr, next);
> - plt_free(mtr->params.dscp_table);
> +
> + if (mtr->params.dscp_table)
> + plt_free(mtr->params.dscp_table);
> +
> + if (mtr->params.vlan_table)
> + plt_free(mtr->params.vlan_table);
> +
> plt_free(mtr);
>
> exit:
> @@ -689,7 +723,7 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> enum rte_color *dscp_table,
> struct rte_mtr_error *error)
> {
> - enum roc_nix_bpf_color nix_dscp_tbl[ROC_NIX_BPF_PRE_COLOR_MAX];
> + enum roc_nix_bpf_color nix_dscp_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP];
> enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
> ROC_NIX_BPF_COLOR_YELLOW,
> ROC_NIX_BPF_COLOR_RED};
> @@ -707,16 +741,30 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> }
>
> if (!dscp_table) {
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
> nix_dscp_tbl[i] = ROC_NIX_BPF_COLOR_GREEN;
> } else {
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
> nix_dscp_tbl[i] = color_map[dscp_table[i]];
> }
>
> - table.count = ROC_NIX_BPF_PRE_COLOR_MAX;
> - table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> + table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
> +
> + switch (dev->proto) {
> + case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
> + table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
> + break;
> + case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
> + table.mode = ROC_NIX_BPF_PC_MODE_DSCP_INNER;
> + break;
> + default:
> + rc = -rte_mtr_error_set(error, EINVAL,
> + RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
> + "Invalid input color protocol");
> + goto exit;
> + }
> +
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
> table.color[i] = nix_dscp_tbl[i];
>
> rc = roc_nix_bpf_pre_color_tbl_setup(nix, mtr->bpf_id,
> @@ -727,13 +775,138 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> goto exit;
> }
>
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
> dev->precolor_tbl[i] = nix_dscp_tbl[i];
>
> exit:
> return rc;
> }
>
> +static int
> +cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> + enum rte_color *vlan_table,
> + struct rte_mtr_error *error)
> +{
> + enum roc_nix_bpf_color nix_vlan_tbl[ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN];
> + enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
> + ROC_NIX_BPF_COLOR_YELLOW,
> + ROC_NIX_BPF_COLOR_RED};
> + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
> + struct roc_nix_bpf_precolor table;
> + struct roc_nix *nix = &dev->nix;
> + struct cnxk_meter_node *mtr;
> + int rc, i;
> +
> + mtr = nix_mtr_find(dev, mtr_id);
> + if (mtr == NULL) {
> + return -rte_mtr_error_set(error, ENOENT,
> + RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
> + "Meter object not found");
> + }
> +
> + if (!vlan_table) {
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
> + nix_vlan_tbl[i] = ROC_NIX_BPF_COLOR_GREEN;
> + } else {
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
> + nix_vlan_tbl[i] = color_map[vlan_table[i]];
> + }
> +
> + table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
> +
> + switch (dev->proto) {
> + case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
> + table.mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
> + break;
> + case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
> + table.mode = ROC_NIX_BPF_PC_MODE_VLAN_INNER;
> + break;
> + default:
> + rc = -rte_mtr_error_set(error, EINVAL,
> + RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
> + "Invalid input color protocol");
> + goto exit;
> + }
> +
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
> + table.color[i] = nix_vlan_tbl[i];
> +
> + rc = roc_nix_bpf_pre_color_tbl_setup(nix, mtr->bpf_id,
> + lvl_map[mtr->level], &table);
> + if (rc) {
> + rte_mtr_error_set(error, rc, RTE_MTR_ERROR_TYPE_UNSPECIFIED,
> + NULL, NULL);
> + goto exit;
> + }
> +
> + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
> + dev->precolor_tbl[i] = nix_vlan_tbl[i];
> +
> +exit:
> + return rc;
> +}
> +
> +static int
> +cnxk_nix_mtr_in_proto_set(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> + enum rte_mtr_color_in_protocol proto,
> + uint32_t priority, struct rte_mtr_error *error)
> +{
> + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
> + struct cnxk_meter_node *mtr;
> +
> + RTE_SET_USED(priority);
> +
> + mtr = nix_mtr_find(dev, mtr_id);
> + if (mtr == NULL) {
> + return -rte_mtr_error_set(error, ENOENT,
> + RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
> + "Meter object not found");
> + }
> +
> + dev->proto = proto;
> + return 0;
> +}
> +
> +static int
> +cnxk_nix_mtr_in_proto_get(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> + uint64_t *proto_mask, struct rte_mtr_error *error)
> +{
> + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
> + struct cnxk_meter_node *mtr;
> +
> + mtr = nix_mtr_find(dev, mtr_id);
> + if (mtr == NULL) {
> + return -rte_mtr_error_set(error, ENOENT,
> + RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
> + "Meter object not found");
> + }
> +
> + *proto_mask = dev->proto;
> + return 0;
> +}
> +
> +static int
> +cnxk_nix_mtr_in_proto_prio_get(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> + enum rte_mtr_color_in_protocol proto,
> + uint32_t *priority, struct rte_mtr_error *error)
> +{
> + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
> + struct cnxk_meter_node *mtr;
> +
> + RTE_SET_USED(proto);
> +
> + mtr = nix_mtr_find(dev, mtr_id);
> + if (mtr == NULL) {
> + return -rte_mtr_error_set(error, ENOENT,
> + RTE_MTR_ERROR_TYPE_MTR_ID, NULL,
> + "Meter object not found");
> + }
> +
> + plt_info("Only single priority supported i.e. 0");
> + *priority = 0;
> + return 0;
> +}
> +
> static int
> cnxk_nix_mtr_stats_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
> uint64_t stats_mask, struct rte_mtr_error *error)
> @@ -870,6 +1043,10 @@ const struct rte_mtr_ops nix_mtr_ops = {
> .meter_enable = cnxk_nix_mtr_enable,
> .meter_disable = cnxk_nix_mtr_disable,
> .meter_dscp_table_update = cnxk_nix_mtr_dscp_table_update,
> + .meter_vlan_table_update = cnxk_nix_mtr_vlan_table_update,
> + .in_proto_set = cnxk_nix_mtr_in_proto_set,
> + .in_proto_get = cnxk_nix_mtr_in_proto_get,
> + .in_proto_prio_get = cnxk_nix_mtr_in_proto_prio_get,
> .stats_update = cnxk_nix_mtr_stats_update,
> .stats_read = cnxk_nix_mtr_stats_read,
> };
> @@ -1041,6 +1218,9 @@ nix_mtr_level_update(struct rte_eth_dev *eth_dev, uint32_t id, uint32_t level)
> static void
> nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
> {
> + enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
> + ROC_NIX_BPF_COLOR_YELLOW,
> + ROC_NIX_BPF_COLOR_RED};
> enum roc_nix_bpf_algo alg_map[] = {
> ROC_NIX_BPF_ALGO_NONE, ROC_NIX_BPF_ALGO_2697,
> ROC_NIX_BPF_ALGO_2698, ROC_NIX_BPF_ALGO_4115};
> @@ -1049,6 +1229,28 @@ nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
>
> cfg->alg = alg_map[profile->profile.alg];
> cfg->lmode = profile->profile.packet_mode;
> + cfg->icolor = color_map[mtr->params.default_input_color];
> +
> + switch (RTE_MTR_COLOR_IN_PROTO_OUTER_IP) {
> + case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
> + cfg->pc_mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
> + cfg->tnl_ena = false;
> + break;
> + case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
> + cfg->pc_mode = ROC_NIX_BPF_PC_MODE_DSCP_INNER;
> + cfg->tnl_ena = true;
> + break;
> + case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
> + cfg->pc_mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
> + cfg->tnl_ena = false;
> + break;
> + case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
> + cfg->pc_mode = ROC_NIX_BPF_PC_MODE_VLAN_INNER;
> + cfg->tnl_ena = true;
> + break;
> + default:
> + break;
> + }
>
> switch (cfg->alg) {
> case ROC_NIX_BPF_ALGO_2697:
> @@ -1090,23 +1292,50 @@ nix_mtr_config_map(struct cnxk_meter_node *mtr, struct roc_nix_bpf_cfg *cfg)
> }
>
> static void
> -nix_dscp_table_map(struct cnxk_meter_node *mtr,
> - struct roc_nix_bpf_precolor *tbl)
> +nix_precolor_table_map(struct cnxk_meter_node *mtr,
> + struct roc_nix_bpf_precolor *tbl,
> + enum rte_mtr_color_in_protocol proto)
> {
> enum roc_nix_bpf_color color_map[] = {ROC_NIX_BPF_COLOR_GREEN,
> ROC_NIX_BPF_COLOR_YELLOW,
> ROC_NIX_BPF_COLOR_RED};
> int i;
>
> - tbl->count = ROC_NIX_BPF_PRE_COLOR_MAX;
> - tbl->mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
> -
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> - tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
> -
> - if (mtr->params.dscp_table) {
> - for (i = 0; i < ROC_NIX_BPF_PRE_COLOR_MAX; i++)
> - tbl->color[i] = color_map[mtr->params.dscp_table[i]];
> + switch (proto) {
> + case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
> + case RTE_MTR_COLOR_IN_PROTO_INNER_IP:
> + tbl->count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
> + tbl->mode = (proto == RTE_MTR_COLOR_IN_PROTO_OUTER_IP) ?
> + ROC_NIX_BPF_PC_MODE_DSCP_OUTER :
> + ROC_NIX_BPF_PC_MODE_DSCP_INNER;
> +
> + for (i = 0; i < tbl->count; i++)
> + tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
> +
> + if (mtr->params.dscp_table) {
> + for (i = 0; i < tbl->count; i++)
> + tbl->color[i] =
> + color_map[mtr->params.dscp_table[i]];
> + }
> + break;
> + case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
> + case RTE_MTR_COLOR_IN_PROTO_INNER_VLAN:
> + tbl->count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
> + tbl->mode = (proto == RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN) ?
> + ROC_NIX_BPF_PC_MODE_VLAN_OUTER :
> + ROC_NIX_BPF_PC_MODE_VLAN_INNER;
> +
> + for (i = 0; i < tbl->count; i++)
> + tbl->color[i] = ROC_NIX_BPF_COLOR_GREEN;
> +
> + if (mtr->params.vlan_table) {
> + for (i = 0; i < tbl->count; i++)
> + tbl->color[i] =
> + color_map[mtr->params.vlan_table[i]];
> + }
> + break;
> + default:
> + break;
> }
> }
>
> @@ -1245,7 +1474,8 @@ nix_mtr_configure(struct rte_eth_dev *eth_dev, uint32_t id)
>
> memset(&tbl, 0,
> sizeof(struct roc_nix_bpf_precolor));
> - nix_dscp_table_map(mtr[i], &tbl);
> + nix_precolor_table_map(mtr[i], &tbl,
> + dev->proto);
> rc = roc_nix_bpf_pre_color_tbl_setup(nix,
> mtr[i]->bpf_id, lvl_map[mtr[i]->level],
> &tbl);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2022-08-22 12:34 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 9:00 [PATCH v1 1/3] common/cnxk: update precolor table setup for VLAN skori
2022-03-01 9:00 ` [PATCH v1 2/3] net/cnxk: support ops to update precolor VLAN table skori
2022-06-16 9:48 ` [PATCH v2 1/2] common/cnxk: update precolor table setup for VLAN skori
2022-06-16 9:48 ` [PATCH v2 2/2] net/cnxk: support ops to update precolor VLAN table skori
2022-06-16 11:54 ` [PATCH v3 1/2] common/cnxk: update precolor table setup for VLAN skori
2022-06-16 11:54 ` [PATCH v3 2/2] net/cnxk: support ops to update precolor VLAN table skori
2022-06-20 17:44 ` Jerin Jacob
2022-06-21 7:19 ` [EXT] " Sunil Kumar Kori
2022-06-21 7:35 ` [PATCH v4 1/2] common/cnxk: update precolor table setup for VLAN skori
2022-06-21 7:35 ` [PATCH v4 2/2] net/cnxk: support ops to update precolor VLAN table skori
2022-08-22 12:33 ` Jerin Jacob
2022-03-01 9:00 ` [PATCH v1 3/3] app/testpmd: support different input color method skori
2022-05-20 22:09 ` Ferruh Yigit
2022-05-21 7:07 ` [EXT] " Sunil Kumar Kori
2022-05-23 8:43 ` Ferruh Yigit
2022-05-24 7:35 ` [PATCH v2 1/1] " skori
2022-05-25 12:36 ` Dumitrescu, Cristian
2022-05-25 14:32 ` Sunil Kumar Kori
2022-05-25 14:37 ` skori
2022-05-25 14:41 ` Dumitrescu, Cristian
2022-05-31 15:41 ` Andrew Rybchenko
2022-06-03 13:03 ` [EXT] " Sunil Kumar Kori
2022-06-03 13:06 ` [PATCH v3 " skori
2022-06-08 12:06 ` Andrew Rybchenko
2022-06-14 10:05 ` [PATCH v4 " skori
2022-06-23 11:05 ` Andrew Rybchenko
2022-06-23 12:54 ` [EXT] " Sunil Kumar Kori
2022-06-23 12:57 ` [PATCH v5 " skori
2022-06-23 13:07 ` Sunil Kumar Kori
2022-06-24 12:44 ` Andrew Rybchenko
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).