From: <skori@marvell.com>
To: Nithin Dabilpuram <ndabilpuram@marvell.com>,
Kiran Kumar K <kirankumark@marvell.com>,
Sunil Kumar Kori <skori@marvell.com>,
Satha Rao <skoteshwar@marvell.com>
Cc: <dev@dpdk.org>
Subject: [PATCH v1 2/3] net/cnxk: support ops to update precolor VLAN table
Date: Tue, 1 Mar 2022 14:30:54 +0530 [thread overview]
Message-ID: <20220301090056.1042866-2-skori@marvell.com> (raw)
In-Reply-To: <20220301090056.1042866-1-skori@marvell.com>
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
next prev parent reply other threads:[~2022-03-01 9:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-01 9:00 [PATCH v1 1/3] common/cnxk: update precolor table setup for VLAN skori
2022-03-01 9:00 ` skori [this message]
2022-06-16 9:48 ` [PATCH v2 1/2] " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220301090056.1042866-2-skori@marvell.com \
--to=skori@marvell.com \
--cc=dev@dpdk.org \
--cc=kirankumark@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=skoteshwar@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).