From: Tomasz Duszynski <tdu@semihalf.com>
To: dev@dpdk.org
Cc: mw@semihalf.com, dima@marvell.com, nsamsono@marvell.com,
jck@semihalf.com, jianbo.liu@arm.com,
Tomasz Duszynski <tdu@semihalf.com>
Subject: [dpdk-dev] [PATCH v3 2/8] net/mrvl: add ingress policer support
Date: Thu, 15 Mar 2018 08:51:58 +0100 [thread overview]
Message-ID: <1521100324-26558-3-git-send-email-tdu@semihalf.com> (raw)
In-Reply-To: <1521100324-26558-1-git-send-email-tdu@semihalf.com>
Add ingress policer support.
Signed-off-by: Natalie Samsonov <nsamsono@marvell.com>
Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
---
drivers/net/mrvl/mrvl_ethdev.c | 6 ++
drivers/net/mrvl/mrvl_ethdev.h | 1 +
drivers/net/mrvl/mrvl_qos.c | 160 +++++++++++++++++++++++++++++++++++++++--
drivers/net/mrvl/mrvl_qos.h | 3 +
4 files changed, 166 insertions(+), 4 deletions(-)
diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c
index e313768..d1faa3d 100644
--- a/drivers/net/mrvl/mrvl_ethdev.c
+++ b/drivers/net/mrvl/mrvl_ethdev.c
@@ -661,6 +661,12 @@ mrvl_dev_stop(struct rte_eth_dev *dev)
if (priv->ppio)
pp2_ppio_deinit(priv->ppio);
priv->ppio = NULL;
+
+ /* policer must be released after ppio deinitialization */
+ if (priv->policer) {
+ pp2_cls_plcr_deinit(priv->policer);
+ priv->policer = NULL;
+ }
}
/**
diff --git a/drivers/net/mrvl/mrvl_ethdev.h b/drivers/net/mrvl/mrvl_ethdev.h
index aee853a..2cc229e 100644
--- a/drivers/net/mrvl/mrvl_ethdev.h
+++ b/drivers/net/mrvl/mrvl_ethdev.h
@@ -85,6 +85,7 @@ struct mrvl_priv {
struct pp2_cls_qos_tbl_params qos_tbl_params;
struct pp2_cls_tbl *qos_tbl;
uint16_t nb_rx_queues;
+ struct pp2_cls_plcr *policer;
};
#endif /* _MRVL_ETHDEV_H_ */
diff --git a/drivers/net/mrvl/mrvl_qos.c b/drivers/net/mrvl/mrvl_qos.c
index d206dc6..0205157 100644
--- a/drivers/net/mrvl/mrvl_qos.c
+++ b/drivers/net/mrvl/mrvl_qos.c
@@ -43,6 +43,22 @@
#define MRVL_TOK_VLAN_IP "vlan/ip"
#define MRVL_TOK_WEIGHT "weight"
+/* policer specific configuration tokens */
+#define MRVL_TOK_PLCR_ENABLE "policer_enable"
+#define MRVL_TOK_PLCR_UNIT "token_unit"
+#define MRVL_TOK_PLCR_UNIT_BYTES "bytes"
+#define MRVL_TOK_PLCR_UNIT_PACKETS "packets"
+#define MRVL_TOK_PLCR_COLOR "color_mode"
+#define MRVL_TOK_PLCR_COLOR_BLIND "blind"
+#define MRVL_TOK_PLCR_COLOR_AWARE "aware"
+#define MRVL_TOK_PLCR_CIR "cir"
+#define MRVL_TOK_PLCR_CBS "cbs"
+#define MRVL_TOK_PLCR_EBS "ebs"
+#define MRVL_TOK_PLCR_DEFAULT_COLOR "default_color"
+#define MRVL_TOK_PLCR_DEFAULT_COLOR_GREEN "green"
+#define MRVL_TOK_PLCR_DEFAULT_COLOR_YELLOW "yellow"
+#define MRVL_TOK_PLCR_DEFAULT_COLOR_RED "red"
+
/** Number of tokens in range a-b = 2. */
#define MAX_RNG_TOKENS 2
@@ -296,6 +312,25 @@ parse_tc_cfg(struct rte_cfgfile *file, int port, int tc,
}
cfg->port[port].tc[tc].dscps = n;
}
+
+ entry = rte_cfgfile_get_entry(file, sec_name,
+ MRVL_TOK_PLCR_DEFAULT_COLOR);
+ if (entry) {
+ if (!strncmp(entry, MRVL_TOK_PLCR_DEFAULT_COLOR_GREEN,
+ sizeof(MRVL_TOK_PLCR_DEFAULT_COLOR_GREEN))) {
+ cfg->port[port].tc[tc].color = PP2_PPIO_COLOR_GREEN;
+ } else if (!strncmp(entry, MRVL_TOK_PLCR_DEFAULT_COLOR_YELLOW,
+ sizeof(MRVL_TOK_PLCR_DEFAULT_COLOR_YELLOW))) {
+ cfg->port[port].tc[tc].color = PP2_PPIO_COLOR_YELLOW;
+ } else if (!strncmp(entry, MRVL_TOK_PLCR_DEFAULT_COLOR_RED,
+ sizeof(MRVL_TOK_PLCR_DEFAULT_COLOR_RED))) {
+ cfg->port[port].tc[tc].color = PP2_PPIO_COLOR_RED;
+ } else {
+ RTE_LOG(ERR, PMD, "Error while parsing: %s\n", entry);
+ return -1;
+ }
+ }
+
return 0;
}
@@ -368,6 +403,88 @@ mrvl_get_qoscfg(const char *key __rte_unused, const char *path,
}
entry = rte_cfgfile_get_entry(file, sec_name,
+ MRVL_TOK_PLCR_ENABLE);
+ if (entry) {
+ if (get_val_securely(entry, &val) < 0)
+ return -1;
+ (*cfg)->port[n].policer_enable = val;
+ }
+
+ if ((*cfg)->port[n].policer_enable) {
+ enum pp2_cls_plcr_token_unit unit;
+
+ /* Read policer token unit */
+ entry = rte_cfgfile_get_entry(file, sec_name,
+ MRVL_TOK_PLCR_UNIT);
+ if (entry) {
+ if (!strncmp(entry, MRVL_TOK_PLCR_UNIT_BYTES,
+ sizeof(MRVL_TOK_PLCR_UNIT_BYTES))) {
+ unit = PP2_CLS_PLCR_BYTES_TOKEN_UNIT;
+ } else if (!strncmp(entry,
+ MRVL_TOK_PLCR_UNIT_PACKETS,
+ sizeof(MRVL_TOK_PLCR_UNIT_PACKETS))) {
+ unit = PP2_CLS_PLCR_PACKETS_TOKEN_UNIT;
+ } else {
+ RTE_LOG(ERR, PMD, "Unknown token: %s\n",
+ entry);
+ return -1;
+ }
+ (*cfg)->port[n].policer_params.token_unit =
+ unit;
+ }
+
+ /* Read policer color mode */
+ entry = rte_cfgfile_get_entry(file, sec_name,
+ MRVL_TOK_PLCR_COLOR);
+ if (entry) {
+ enum pp2_cls_plcr_color_mode mode;
+
+ if (!strncmp(entry, MRVL_TOK_PLCR_COLOR_BLIND,
+ sizeof(MRVL_TOK_PLCR_COLOR_BLIND))) {
+ mode = PP2_CLS_PLCR_COLOR_BLIND_MODE;
+ } else if (!strncmp(entry,
+ MRVL_TOK_PLCR_COLOR_AWARE,
+ sizeof(MRVL_TOK_PLCR_COLOR_AWARE))) {
+ mode = PP2_CLS_PLCR_COLOR_AWARE_MODE;
+ } else {
+ RTE_LOG(ERR, PMD,
+ "Error in parsing: %s\n",
+ entry);
+ return -1;
+ }
+ (*cfg)->port[n].policer_params.color_mode =
+ mode;
+ }
+
+ /* Read policer cir */
+ entry = rte_cfgfile_get_entry(file, sec_name,
+ MRVL_TOK_PLCR_CIR);
+ if (entry) {
+ if (get_val_securely(entry, &val) < 0)
+ return -1;
+ (*cfg)->port[n].policer_params.cir = val;
+ }
+
+ /* Read policer cbs */
+ entry = rte_cfgfile_get_entry(file, sec_name,
+ MRVL_TOK_PLCR_CBS);
+ if (entry) {
+ if (get_val_securely(entry, &val) < 0)
+ return -1;
+ (*cfg)->port[n].policer_params.cbs = val;
+ }
+
+ /* Read policer ebs */
+ entry = rte_cfgfile_get_entry(file, sec_name,
+ MRVL_TOK_PLCR_EBS);
+ if (entry) {
+ if (get_val_securely(entry, &val) < 0)
+ return -1;
+ (*cfg)->port[n].policer_params.ebs = val;
+ }
+ }
+
+ entry = rte_cfgfile_get_entry(file, sec_name,
MRVL_TOK_MAPPING_PRIORITY);
if (entry) {
if (!strncmp(entry, MRVL_TOK_VLAN_IP,
@@ -422,16 +539,18 @@ mrvl_get_qoscfg(const char *key __rte_unused, const char *path,
* @param param TC parameters entry.
* @param inqs Number of MUSDK in-queues in this TC.
* @param bpool Bpool for this TC.
+ * @param color Default color for this TC.
* @returns 0 in case of success, exits otherwise.
*/
static int
setup_tc(struct pp2_ppio_tc_params *param, uint8_t inqs,
- struct pp2_bpool *bpool)
+ struct pp2_bpool *bpool, enum pp2_ppio_color color)
{
struct pp2_ppio_inq_params *inq_params;
param->pkt_offset = MRVL_PKT_OFFS;
param->pools[0] = bpool;
+ param->default_color = color;
inq_params = rte_zmalloc_socket("inq_params",
inqs * sizeof(*inq_params),
@@ -451,6 +570,33 @@ setup_tc(struct pp2_ppio_tc_params *param, uint8_t inqs,
}
/**
+ * Setup ingress policer.
+ *
+ * @param priv Port's private data.
+ * @param params Pointer to the policer's configuration.
+ * @returns 0 in case of success, negative values otherwise.
+ */
+static int
+setup_policer(struct mrvl_priv *priv, struct pp2_cls_plcr_params *params)
+{
+ char match[16];
+ int ret;
+
+ sprintf(match, "policer-%d:%d\n", priv->pp_id, priv->ppio_id);
+ params->match = match;
+
+ ret = pp2_cls_plcr_init(params, &priv->policer);
+ if (ret) {
+ RTE_LOG(ERR, PMD, "Failed to setup %s\n", match);
+ return -1;
+ }
+
+ priv->ppio_params.inqs_params.plcr = priv->policer;
+
+ return 0;
+}
+
+/**
* Configure RX Queues in a given port.
*
* Sets up RX queues, their Traffic Classes and DPDK rxq->(TC,inq) mapping.
@@ -468,10 +614,13 @@ mrvl_configure_rxqs(struct mrvl_priv *priv, uint16_t portid,
if (mrvl_qos_cfg == NULL ||
mrvl_qos_cfg->port[portid].use_global_defaults) {
- /* No port configuration, use default: 1 TC, no QoS. */
+ /*
+ * No port configuration, use default: 1 TC, no QoS,
+ * TC color set to green.
+ */
priv->ppio_params.inqs_params.num_tcs = 1;
setup_tc(&priv->ppio_params.inqs_params.tcs_params[0],
- max_queues, priv->bpool);
+ max_queues, priv->bpool, PP2_PPIO_COLOR_GREEN);
/* Direct mapping of queues i.e. 0->0, 1->1 etc. */
for (i = 0; i < max_queues; ++i) {
@@ -569,11 +718,14 @@ mrvl_configure_rxqs(struct mrvl_priv *priv, uint16_t portid,
break;
setup_tc(&priv->ppio_params.inqs_params.tcs_params[i],
port_cfg->tc[i].inqs,
- priv->bpool);
+ priv->bpool, port_cfg->tc[i].color);
}
priv->ppio_params.inqs_params.num_tcs = i;
+ if (port_cfg->policer_enable)
+ return setup_policer(priv, &port_cfg->policer_params);
+
return 0;
}
diff --git a/drivers/net/mrvl/mrvl_qos.h b/drivers/net/mrvl/mrvl_qos.h
index d2b6c83..bcf5bd3 100644
--- a/drivers/net/mrvl/mrvl_qos.h
+++ b/drivers/net/mrvl/mrvl_qos.h
@@ -27,6 +27,7 @@ struct mrvl_qos_cfg {
uint8_t inqs;
uint8_t dscps;
uint8_t pcps;
+ enum pp2_ppio_color color;
} tc[MRVL_PP2_TC_MAX];
struct {
uint8_t weight;
@@ -36,6 +37,8 @@ struct mrvl_qos_cfg {
uint16_t outqs;
uint8_t default_tc;
uint8_t use_global_defaults;
+ struct pp2_cls_plcr_params policer_params;
+ uint8_t policer_enable;
} port[RTE_MAX_ETHPORTS];
};
--
2.7.4
next prev parent reply other threads:[~2018-03-15 7:52 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-21 14:14 [dpdk-dev] [PATCH 0/8] net/mrvl: add new features to PMD Tomasz Duszynski
2018-02-21 14:14 ` [dpdk-dev] [PATCH 1/8] net/mrvl: fix crash when port is closed without starting Tomasz Duszynski
2018-02-21 14:14 ` [dpdk-dev] [PATCH 2/8] net/mrvl: add ingress policer support Tomasz Duszynski
2018-02-21 14:14 ` [dpdk-dev] [PATCH 3/8] net/mrvl: add egress scheduler/rate limiter support Tomasz Duszynski
2018-02-21 14:14 ` [dpdk-dev] [PATCH 4/8] net/mrvl: document policer/scheduler/rate limiter usage Tomasz Duszynski
2018-02-21 14:14 ` [dpdk-dev] [PATCH 5/8] net/mrvl: add classifier support Tomasz Duszynski
2018-03-07 11:07 ` Ferruh Yigit
2018-03-07 11:16 ` Tomasz Duszynski
2018-03-07 11:24 ` Ferruh Yigit
2018-03-08 13:23 ` Tomasz Duszynski
2018-02-21 14:14 ` [dpdk-dev] [PATCH 6/8] net/mrvl: add extended statistics Tomasz Duszynski
2018-02-21 14:14 ` [dpdk-dev] [PATCH 7/8] net/mrvl: add Rx flow control Tomasz Duszynski
2018-02-21 14:14 ` [dpdk-dev] [PATCH 8/8] net/mrvl: add Tx queue start/stop Tomasz Duszynski
2018-03-12 8:42 ` [dpdk-dev] [PATCH v2 0/8] net/mrvl: add new features to PMD Tomasz Duszynski
2018-03-12 8:42 ` [dpdk-dev] [PATCH v2 1/8] net/mrvl: fix crash when port is closed without starting Tomasz Duszynski
2018-03-12 8:42 ` [dpdk-dev] [PATCH v2 2/8] net/mrvl: add ingress policer support Tomasz Duszynski
2018-03-12 8:42 ` [dpdk-dev] [PATCH v2 3/8] net/mrvl: add egress scheduler/rate limiter support Tomasz Duszynski
2018-03-12 8:42 ` [dpdk-dev] [PATCH v2 4/8] net/mrvl: document policer/scheduler/rate limiter usage Tomasz Duszynski
2018-03-12 8:42 ` [dpdk-dev] [PATCH v2 5/8] net/mrvl: add classifier support Tomasz Duszynski
2018-03-12 8:42 ` [dpdk-dev] [PATCH v2 6/8] net/mrvl: add extended statistics Tomasz Duszynski
2018-03-14 17:21 ` Ferruh Yigit
2018-03-15 7:09 ` Tomasz Duszynski
2018-03-12 8:42 ` [dpdk-dev] [PATCH v2 7/8] net/mrvl: add Rx flow control Tomasz Duszynski
2018-03-12 8:42 ` [dpdk-dev] [PATCH v2 8/8] net/mrvl: add Tx queue start/stop Tomasz Duszynski
2018-03-15 7:51 ` [dpdk-dev] [PATCH v3 0/8] net/mrvl: add new features to PMD Tomasz Duszynski
2018-03-15 7:51 ` [dpdk-dev] [PATCH v3 1/8] net/mrvl: fix crash when port is closed without starting Tomasz Duszynski
2018-03-15 7:51 ` Tomasz Duszynski [this message]
2018-03-15 7:51 ` [dpdk-dev] [PATCH v3 3/8] net/mrvl: add egress scheduler/rate limiter support Tomasz Duszynski
2018-03-15 7:52 ` [dpdk-dev] [PATCH v3 4/8] net/mrvl: document policer/scheduler/rate limiter usage Tomasz Duszynski
2018-03-15 7:52 ` [dpdk-dev] [PATCH v3 5/8] net/mrvl: add classifier support Tomasz Duszynski
2018-03-15 7:52 ` [dpdk-dev] [PATCH v3 6/8] net/mrvl: add extended statistics Tomasz Duszynski
2018-03-15 7:52 ` [dpdk-dev] [PATCH v3 7/8] net/mrvl: add Rx flow control Tomasz Duszynski
2018-03-15 7:52 ` [dpdk-dev] [PATCH v3 8/8] net/mrvl: add Tx queue start/stop Tomasz Duszynski
2018-03-15 15:09 ` [dpdk-dev] [PATCH v3 0/8] net/mrvl: add new features to PMD Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1521100324-26558-3-git-send-email-tdu@semihalf.com \
--to=tdu@semihalf.com \
--cc=dev@dpdk.org \
--cc=dima@marvell.com \
--cc=jck@semihalf.com \
--cc=jianbo.liu@arm.com \
--cc=mw@semihalf.com \
--cc=nsamsono@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).