Skip to contentSkip to conversation

net/mvpp2: add new features

PATCH Superseded Tomasz Duszynski 5 participants 48 messages Sep 4, 2018 – Sep 25, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover net/mvpp2: add new features

This patch series introduces fixes and adds support for traffic metering and traffic manager.

Natalie Samsonov (2):
net/mvpp2: initialize ppio only once net/mvpp2: update MTU and MRU related calculations

Tomasz Duszynski (5):
net/mvpp2: move common code
net/mvpp2: add metering support
net/mvpp2: change default policer configuration
net/mvpp2: add init and deinit to flow
net/mvpp2: add traffic manager support

Yuval Caduri (1):
net/mvpp2: detach tx_qos from rx cls/qos config

 doc/guides/nics/mvpp2.rst       |   31 +-
 drivers/net/mvpp2/Makefile      |    2 +
 drivers/net/mvpp2/meson.build   |    4 +-
 drivers/net/mvpp2/mrvl_ethdev.c |  188 ++++++--
 drivers/net/mvpp2/mrvl_ethdev.h |  122 ++++-
 drivers/net/mvpp2/mrvl_flow.c   |  129 +++--
 drivers/net/mvpp2/mrvl_flow.h   |   15 +
 drivers/net/mvpp2/mrvl_mtr.c    |  512 ++++++++++++++++++++
 drivers/net/mvpp2/mrvl_mtr.h    |   15 +
 drivers/net/mvpp2/mrvl_qos.c    |  244 +++++-----
 drivers/net/mvpp2/mrvl_qos.h    |    2 +-
 drivers/net/mvpp2/mrvl_tm.c     | 1009 +++++++++++++++++++++++++++++++++++++++
 drivers/net/mvpp2/mrvl_tm.h     |   15 +
 13 files changed, 2064 insertions(+), 224 deletions(-)
 create mode 100644 drivers/net/mvpp2/mrvl_flow.h
 create mode 100644 drivers/net/mvpp2/mrvl_mtr.c
 create mode 100644 drivers/net/mvpp2/mrvl_mtr.h
 create mode 100644 drivers/net/mvpp2/mrvl_tm.c
 create mode 100644 drivers/net/mvpp2/mrvl_tm.h

--
2.7.4

#1 lore raw

PATCH 1/8 net/mvpp2: initialize ppio only once

From: Natalie Samsonov <[email protected]>

This changes stop/start/configure behavior due to issue in MUSDK library itself. From now on, ppio can be reconfigured only after interface is closed.

---
 drivers/net/mvpp2/mrvl_ethdev.c | 53 +++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 21 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +32 -21
index 6824445..f022cad 100644
@@ -304,6 +304,11 @@ mrvl_dev_configure(struct rte_eth_dev *dev)
 	struct mrvl_priv *priv = dev->data->dev_private;
 	int ret;
 
+	if (priv->ppio) {
+		MRVL_LOG(INFO, "Device reconfiguration is not supported");
+		return -EINVAL;
+	}
+
 	if (dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_NONE &&
 	    dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_RSS) {
 		MRVL_LOG(INFO, "Unsupported rx multi queue mode %d",
@@ -525,6 +530,9 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 	char match[MRVL_MATCH_LEN];
 	int ret = 0, i, def_init_size;
 
+	if (priv->ppio)
+		return mrvl_dev_set_link_up(dev);
+
 	snprintf(match, sizeof(match), "ppio-%d:%d",
 		 priv->pp_id, priv->ppio_id);
 	priv->ppio_params.match = match;
@@ -749,28 +757,7 @@ mrvl_flush_bpool(struct rte_eth_dev *dev)
 static void
 mrvl_dev_stop(struct rte_eth_dev *dev)
 {
-	struct mrvl_priv *priv = dev->data->dev_private;
-
 	mrvl_dev_set_link_down(dev);
-	mrvl_flush_rx_queues(dev);
-	mrvl_flush_tx_shadow_queues(dev);
-	if (priv->cls_tbl) {
-		pp2_cls_tbl_deinit(priv->cls_tbl);
-		priv->cls_tbl = NULL;
-	}
-	if (priv->qos_tbl) {
-		pp2_cls_qos_tbl_deinit(priv->qos_tbl);
-		priv->qos_tbl = NULL;
-	}
-	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;
-	}
 }
 
 /**
@@ -785,6 +772,9 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 	struct mrvl_priv *priv = dev->data->dev_private;
 	size_t i;
 
+	mrvl_flush_rx_queues(dev);
+	mrvl_flush_tx_shadow_queues(dev);
+
 	for (i = 0; i < priv->ppio_params.inqs_params.num_tcs; ++i) {
 		struct pp2_ppio_tc_params *tc_params =
 			&priv->ppio_params.inqs_params.tcs_params[i];
@@ -795,7 +785,28 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 		}
 	}
 
+	if (priv->cls_tbl) {
+		pp2_cls_tbl_deinit(priv->cls_tbl);
+		priv->cls_tbl = NULL;
+	}
+
+	if (priv->qos_tbl) {
+		pp2_cls_qos_tbl_deinit(priv->qos_tbl);
+		priv->qos_tbl = NULL;
+	}
+
 	mrvl_flush_bpool(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;
+	}
 }
 
 /**
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/8 net/mvpp2: move common code

In reply to Tomasz Duszynski

Cleanup sources by moving common code to the pmd
header file.

---
 drivers/net/mvpp2/mrvl_ethdev.c |  9 ---------
 drivers/net/mvpp2/mrvl_ethdev.h | 11 +++++++++++
 drivers/net/mvpp2/mrvl_flow.c   |  5 -----
 drivers/net/mvpp2/mrvl_qos.c    |  9 ---------
 4 files changed, 11 insertions(+), 23 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +0 -9
index f022cad..adb07d0 100644
@@ -10,15 +10,6 @@
 #include <rte_malloc.h>
 #include <rte_bus_vdev.h>
 
-/* Unluckily, container_of is defined by both DPDK and MUSDK,
- * we'll declare only one version.
- *
- * Note that it is not used in this PMD anyway.
- */
-#ifdef container_of
-#undef container_of
-#endif
-
 #include <fcntl.h>
 #include <linux/ethtool.h>
 #include <linux/sockios.h>
drivers/net/mvpp2/mrvl_ethdev.h +11 -0
index 3726f78..2204be2 100644
@@ -10,12 +10,23 @@
 #include <rte_spinlock.h>
 #include <rte_flow_driver.h>
 
+/*
+ * container_of is defined by both DPDK and MUSDK,
+ * we'll declare only one version.
+ *
+ * Note that it is not used in this PMD anyway.
+ */
+#ifdef container_of
+#undef container_of
+#endif
+
 #include <env/mv_autogen_comp_flags.h>
 #include <drivers/mv_pp2.h>
 #include <drivers/mv_pp2_bpool.h>
 #include <drivers/mv_pp2_cls.h>
 #include <drivers/mv_pp2_hif.h>
 #include <drivers/mv_pp2_ppio.h>
+#include "env/mv_common.h" /* for BIT() */
 
 /** Maximum number of rx queues per port */
 #define MRVL_PP2_RXQ_MAX 32
drivers/net/mvpp2/mrvl_flow.c +0 -5
index 13295e6..db750f4 100644
@@ -11,13 +11,8 @@
 
 #include <arpa/inet.h>
 
-#ifdef container_of
-#undef container_of
-#endif
-
 #include "mrvl_ethdev.h"
 #include "mrvl_qos.h"
-#include "env/mv_common.h" /* for BIT() */
 
 /** Number of rules in the classifier table. */
 #define MRVL_CLS_MAX_NUM_RULES 20
drivers/net/mvpp2/mrvl_qos.c +0 -9
index 71856c1..eeb46f8 100644
@@ -15,15 +15,6 @@
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
-/* Unluckily, container_of is defined by both DPDK and MUSDK,
- * we'll declare only one version.
- *
- * Note that it is not used in this PMD anyway.
- */
-#ifdef container_of
-#undef container_of
-#endif
-
 #include "mrvl_qos.h"
 
 /* Parsing tokens. Defined conveniently, so that any correction is easy. */
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/8 net/mvpp2: add metering support

In reply to Tomasz Duszynski

Add support for configuring plcr via DPDK generic metering API.

---
 drivers/net/mvpp2/Makefile      |   1 +
 drivers/net/mvpp2/meson.build   |   3 +-
 drivers/net/mvpp2/mrvl_ethdev.c |  24 ++
 drivers/net/mvpp2/mrvl_ethdev.h |  71 ++++++
 drivers/net/mvpp2/mrvl_flow.c   |  91 +++----
 drivers/net/mvpp2/mrvl_mtr.c    | 512 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mvpp2/mrvl_mtr.h    |  15 ++
 7 files changed, 673 insertions(+), 44 deletions(-)
 create mode 100644 drivers/net/mvpp2/mrvl_mtr.c
 create mode 100644 drivers/net/mvpp2/mrvl_mtr.h
drivers/net/mvpp2/Makefile +1 -0
index 211d398..4848d65 100644
@@ -39,5 +39,6 @@ LDLIBS += -lrte_bus_vdev -lrte_common_mvep
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_qos.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_flow.c
+SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_mtr.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/mvpp2/meson.build +2 -1
index 3620659..f475511 100644
@@ -19,7 +19,8 @@ endif
 sources = files(
 	'mrvl_ethdev.c',
 	'mrvl_flow.c',
-	'mrvl_qos.c'
+	'mrvl_qos.c',
+	'mrvl_mtr.c'
 )
 
 deps += ['cfgfile', 'common_mvep']
drivers/net/mvpp2/mrvl_ethdev.c +24 -0
index adb07d0..a4951d3 100644
@@ -23,6 +23,7 @@
 #include <rte_mvep_common.h>
 #include "mrvl_ethdev.h"
 #include "mrvl_qos.h"
+#include "mrvl_mtr.h"
 
 /* bitmask with reserved hifs */
 #define MRVL_MUSDK_HIFS_RESERVED 0x0F
@@ -627,6 +628,8 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 			goto out;
 	}
 
+	mrvl_mtr_init(dev);
+
 	return 0;
 out:
 	MRVL_LOG(ERR, "Failed to start device");
@@ -765,6 +768,7 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 
 	mrvl_flush_rx_queues(dev);
 	mrvl_flush_tx_shadow_queues(dev);
+	mrvl_mtr_deinit(dev);
 
 	for (i = 0; i < priv->ppio_params.inqs_params.num_tcs; ++i) {
 		struct pp2_ppio_tc_params *tc_params =
@@ -1868,6 +1872,25 @@ mrvl_eth_filter_ctrl(struct rte_eth_dev *dev __rte_unused,
 	}
 }
 
+/**
+ * DPDK callback to get rte_mtr callbacks.
+ *
+ * @param dev
+ *   Pointer to the device structure.
+ * @param ops
+ *   Pointer to pass the mtr ops.
+ *
+ * @return
+ *   Always 0.
+ */
+static int
+mrvl_mtr_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops)
+{
+	*(const void **)ops = &mrvl_mtr_ops;
+
+	return 0;
+}
+
 static const struct eth_dev_ops mrvl_ops = {
 	.dev_configure = mrvl_dev_configure,
 	.dev_start = mrvl_dev_start,
@@ -1905,6 +1928,7 @@ static const struct eth_dev_ops mrvl_ops = {
 	.rss_hash_update = mrvl_rss_hash_update,
 	.rss_hash_conf_get = mrvl_rss_hash_conf_get,
 	.filter_ctrl = mrvl_eth_filter_ctrl,
+	.mtr_ops_get = mrvl_mtr_ops_get,
 };
 
 /**
drivers/net/mvpp2/mrvl_ethdev.h +71 -0

94 lines not on this page · raw message

drivers/net/mvpp2/mrvl_flow.c +48 -43

119 lines not on this page · raw message

drivers/net/mvpp2/mrvl_mtr.c new file +512 -0

512 lines not on this page · raw message

drivers/net/mvpp2/mrvl_mtr.h new file +15 -0
new file mode 100644
index 0000000..302a20f
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Marvell International Ltd.
+ * Copyright(c) 2018 Semihalf.
+ * All rights reserved.
+ */
+
+#ifndef _MRVL_MTR_H_
+#define _MRVL_MTR_H_
+
+#include "mrvl_ethdev.h"
+
+void mrvl_mtr_init(struct rte_eth_dev *dev);
+void mrvl_mtr_deinit(struct rte_eth_dev *dev);
+
+#endif /* _MRVL_MTR_H_ */
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/8 net/mvpp2: change default policer configuration

In reply to Tomasz Duszynski

Change QoS configuration file syntax for port's default policer setup.

Since default policer configuration is performed before any other policer configuration we can pick a default id.

This simplifies default policer configuration since user no longer has to choose ids from range [0, PP2_CLS_PLCR_NUM].

Explicitly document values for rate_limit_enable field.

---
 doc/guides/nics/mvpp2.rst       |  31 ++++---
 drivers/net/mvpp2/mrvl_ethdev.c |   6 +-
 drivers/net/mvpp2/mrvl_ethdev.h |   2 +-
 drivers/net/mvpp2/mrvl_qos.c    | 198 ++++++++++++++++++++++------------------
 drivers/net/mvpp2/mrvl_qos.h    |   2 +-
 5 files changed, 134 insertions(+), 105 deletions(-)
doc/guides/nics/mvpp2.rst +19 -12
index 0408752..a452c8a 100644
@@ -152,20 +152,23 @@ Configuration syntax
 
 .. code-block:: console
 
-   [port <portnum> default]
-   default_tc = <default_tc>
-   mapping_priority = <mapping_priority>
-   policer_enable = <policer_enable>
+   [policer <policer_id>]
    token_unit = <token_unit>
    color = <color_mode>
    cir = <cir>
    ebs = <ebs>
    cbs = <cbs>
 
+   [port <portnum> default]
+   default_tc = <default_tc>
+   mapping_priority = <mapping_priority>
+
    rate_limit_enable = <rate_limit_enable>
    rate_limit = <rate_limit>
    burst_size = <burst_size>
 
+   default_policer = <policer_id>
+
    [port <portnum> tc <traffic_class>]
    rxq = <rx_queue_list>
    pcp = <pcp_list>
@@ -201,7 +204,9 @@ Where:
 
 - ``<dscp_list>``: List of DSCP values to handle in particular TC (e.g. 0-12 32-48 63).
 
-- ``<policer_enable>``: Enable ingress policer.
+- ``<default_policer>``: Id of the policer configuration section to be used as default.
+
+- ``<policer_id>``: Id of the policer configuration section (0..31).
 
 - ``<token_unit>``: Policer token unit (`bytes` or `packets`).
 
@@ -215,7 +220,7 @@ Where:
 
 - ``<default_color>``: Default color for specific tc.
 
-- ``<rate_limit_enable>``: Enables per port or per txq rate limiting.
+- ``<rate_limit_enable>``: Enables per port or per txq rate limiting (`0`/`1` to disable/enable).
 
 - ``<rate_limit>``: Committed information rate, in kilo bits per second.
 
@@ -234,6 +239,13 @@ Configuration file example
 
 .. code-block:: console
 
+   [policer 0]
+   token_unit = bytes
+   color = blind
+   cir = 100000
+   ebs = 64
+   cbs = 64
+
    [port 0 default]
    default_tc = 0
    mapping_priority = ip
@@ -265,12 +277,7 @@ Configuration file example
    default_tc = 0
    mapping_priority = vlan/ip
 
-   policer_enable = 1
-   token_unit = bytes
-   color = blind
-   cir = 100000
-   ebs = 64
-   cbs = 64
+   default_policer = 0
 
    [port 1 tc 0]
    rxq = 0
drivers/net/mvpp2/mrvl_ethdev.c +3 -3
index a4951d3..1464385 100644
@@ -798,9 +798,9 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 	}
 
 	/* policer must be released after ppio deinitialization */
-	if (priv->policer) {
-		pp2_cls_plcr_deinit(priv->policer);
-		priv->policer = NULL;
+	if (priv->default_policer) {
+		pp2_cls_plcr_deinit(priv->default_policer);
+		priv->default_policer = NULL;
 	}
 }
 
drivers/net/mvpp2/mrvl_ethdev.h +1 -1
index ecb8fdc..de423a9 100644
@@ -168,7 +168,7 @@ struct mrvl_priv {
 	uint32_t cls_tbl_pattern;
 	LIST_HEAD(mrvl_flows, rte_flow) flows;
 
-	struct pp2_cls_plcr *policer;
+	struct pp2_cls_plcr *default_policer;
 
 	LIST_HEAD(profiles, mrvl_mtr_profile) profiles;
 	LIST_HEAD(mtrs, mrvl_mtr) mtrs;
drivers/net/mvpp2/mrvl_qos.c +110 -88

253 lines not on this page · raw message

drivers/net/mvpp2/mrvl_qos.h +1 -1
index fa9ddec..f03e773 100644
@@ -43,7 +43,7 @@ struct mrvl_qos_cfg {
 		uint8_t default_tc;
 		uint8_t use_global_defaults;
 		struct pp2_cls_plcr_params policer_params;
-		uint8_t policer_enable;
+		uint8_t setup_policer;
 	} port[RTE_MAX_ETHPORTS];
 };
 
Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/8 net/mvpp2: add init and deinit to flow

In reply to Tomasz Duszynski

Add init and deinit functionality to flow implementation.

Init puts structures used by flow in a sane sate.
Deinit deallocates all resources used by flow.

---
 drivers/net/mvpp2/mrvl_ethdev.c |  3 +++
 drivers/net/mvpp2/mrvl_flow.c   | 33 ++++++++++++++++++++++++++++++++-
 drivers/net/mvpp2/mrvl_flow.h   | 15 +++++++++++++++
 3 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/mvpp2/mrvl_flow.h
drivers/net/mvpp2/mrvl_ethdev.c +3 -0
index 1464385..5e3a106 100644
@@ -23,6 +23,7 @@
 #include <rte_mvep_common.h>
 #include "mrvl_ethdev.h"
 #include "mrvl_qos.h"
+#include "mrvl_flow.h"
 #include "mrvl_mtr.h"
 
 /* bitmask with reserved hifs */
@@ -628,6 +629,7 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 			goto out;
 	}
 
+	mrvl_flow_init(dev);
 	mrvl_mtr_init(dev);
 
 	return 0;
@@ -768,6 +770,7 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 
 	mrvl_flush_rx_queues(dev);
 	mrvl_flush_tx_shadow_queues(dev);
+	mrvl_flow_deinit(dev);
 	mrvl_mtr_deinit(dev);
 
 	for (i = 0; i < priv->ppio_params.inqs_params.num_tcs; ++i) {
drivers/net/mvpp2/mrvl_flow.c +32 -1
index e6953e4..065b1aa 100644
@@ -11,7 +11,7 @@
 
 #include <arpa/inet.h>
 
-#include "mrvl_ethdev.h"
+#include "mrvl_flow.h"
 #include "mrvl_qos.h"
 
 /** Number of rules in the classifier table. */
@@ -2790,3 +2790,34 @@ const struct rte_flow_ops mrvl_flow_ops = {
 	.flush = mrvl_flow_flush,
 	.isolate = mrvl_flow_isolate
 };
+
+/**
+ * Initialize flow resources.
+ *
+ * @param dev Pointer to the device.
+ */
+void
+mrvl_flow_init(struct rte_eth_dev *dev)
+{
+	struct mrvl_priv *priv = dev->data->dev_private;
+
+	LIST_INIT(&priv->flows);
+}
+
+/**
+ * Cleanup flow resources.
+ *
+ * @param dev Pointer to the device.
+ */
+void
+mrvl_flow_deinit(struct rte_eth_dev *dev)
+{
+	struct mrvl_priv *priv = dev->data->dev_private;
+
+	mrvl_flow_flush(dev, NULL);
+
+	if (priv->cls_tbl) {
+		pp2_cls_tbl_deinit(priv->cls_tbl);
+		priv->cls_tbl = NULL;
+	}
+}
drivers/net/mvpp2/mrvl_flow.h new file +15 -0
new file mode 100644
index 0000000..f63747c
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Marvell International Ltd.
+ * Copyright(c) 2018 Semihalf.
+ * All rights reserved.
+ */
+
+#ifndef _MRVL_FLOW_H_
+#define _MRVL_FLOW_H_
+
+#include "mrvl_ethdev.h"
+
+void mrvl_flow_init(struct rte_eth_dev *dev);
+void mrvl_flow_deinit(struct rte_eth_dev *dev);
+
+#endif /* _MRVL_FLOW_H_ */
Signature · 1 line
2.7.4
#6 lore raw

PATCH 6/8 net/mvpp2: add traffic manager support

In reply to Tomasz Duszynski

Add traffic manager support.

---
 drivers/net/mvpp2/Makefile      |    1 +
 drivers/net/mvpp2/meson.build   |    3 +-
 drivers/net/mvpp2/mrvl_ethdev.c |   26 +
 drivers/net/mvpp2/mrvl_ethdev.h |   31 ++
 drivers/net/mvpp2/mrvl_tm.c     | 1009 +++++++++++++++++++++++++++++++++++++++
 drivers/net/mvpp2/mrvl_tm.h     |   15 +
 6 files changed, 1084 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/mvpp2/mrvl_tm.c
 create mode 100644 drivers/net/mvpp2/mrvl_tm.h
drivers/net/mvpp2/Makefile +1 -0
index 4848d65..661d2cd 100644
@@ -40,5 +40,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_qos.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_flow.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_mtr.c
+SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_tm.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/mvpp2/meson.build +2 -1
index f475511..70ef2d6 100644
@@ -20,7 +20,8 @@ sources = files(
 	'mrvl_ethdev.c',
 	'mrvl_flow.c',
 	'mrvl_qos.c',
-	'mrvl_mtr.c'
+	'mrvl_mtr.c',
+	'mrvl_tm.c'
 )
 
 deps += ['cfgfile', 'common_mvep']
drivers/net/mvpp2/mrvl_ethdev.c +26 -0
index 5e3a106..a1dc6b1 100644
@@ -25,6 +25,7 @@
 #include "mrvl_qos.h"
 #include "mrvl_flow.h"
 #include "mrvl_mtr.h"
+#include "mrvl_tm.h"
 
 /* bitmask with reserved hifs */
 #define MRVL_MUSDK_HIFS_RESERVED 0x0F
@@ -340,6 +341,10 @@ mrvl_dev_configure(struct rte_eth_dev *dev)
 	priv->ppio_params.maintain_stats = 1;
 	priv->nb_rx_queues = dev->data->nb_rx_queues;
 
+	ret = mrvl_tm_init(dev);
+	if (ret < 0)
+		return ret;
+
 	if (dev->data->nb_rx_queues == 1 &&
 	    dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_RSS) {
 		MRVL_LOG(WARNING, "Disabling hash for 1 rx queue");
@@ -794,6 +799,7 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 	}
 
 	mrvl_flush_bpool(dev);
+	mrvl_tm_deinit(dev);
 
 	if (priv->ppio) {
 		pp2_ppio_deinit(priv->ppio);
@@ -1894,6 +1900,25 @@ mrvl_mtr_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops)
 	return 0;
 }
 
+/**
+ * DPDK callback to get rte_tm callbacks.
+ *
+ * @param dev
+ *   Pointer to the device structure.
+ * @param ops
+ *   Pointer to pass the tm ops.
+ *
+ * @return
+ *   Always 0.
+ */
+static int
+mrvl_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops)
+{
+	*(const void **)ops = &mrvl_tm_ops;
+
+	return 0;
+}
+
 static const struct eth_dev_ops mrvl_ops = {
 	.dev_configure = mrvl_dev_configure,
 	.dev_start = mrvl_dev_start,
@@ -1932,6 +1957,7 @@ static const struct eth_dev_ops mrvl_ops = {
 	.rss_hash_conf_get = mrvl_rss_hash_conf_get,
 	.filter_ctrl = mrvl_eth_filter_ctrl,
 	.mtr_ops_get = mrvl_mtr_ops_get,
+	.tm_ops_get = mrvl_tm_ops_get,
 };
 
 /**
drivers/net/mvpp2/mrvl_ethdev.h +31 -0
index de423a9..984f31e 100644
@@ -10,6 +10,7 @@
 #include <rte_spinlock.h>
 #include <rte_flow_driver.h>
 #include <rte_mtr_driver.h>
+#include <rte_tm_driver.h>
 
 /*
  * container_of is defined by both DPDK and MUSDK,
@@ -134,6 +135,29 @@ struct mrvl_mtr {
 	struct pp2_cls_plcr *plcr;
 };
 
+struct mrvl_tm_shaper_profile {
+	LIST_ENTRY(mrvl_tm_shaper_profile) next;
+	uint32_t id;
+	int refcnt;
+	struct rte_tm_shaper_params params;
+};
+
+enum {
+	MRVL_NODE_PORT,
+	MRVL_NODE_QUEUE,
+};
+
+struct mrvl_tm_node {
+	LIST_ENTRY(mrvl_tm_node) next;
+	uint32_t id;
+	uint32_t type;
+	int refcnt;
+	struct mrvl_tm_node *parent;
+	struct mrvl_tm_shaper_profile *profile;
+	uint8_t weight;
+	uint64_t stats_mask;
+};
+
 struct mrvl_priv {
 	/* Hot fields, used in fast path. */
 	struct pp2_bpool *bpool;  /**< BPool pointer */
@@ -173,6 +197,10 @@ struct mrvl_priv {
 	LIST_HEAD(profiles, mrvl_mtr_profile) profiles;
 	LIST_HEAD(mtrs, mrvl_mtr) mtrs;
 	uint32_t used_plcrs;
+
+	LIST_HEAD(shaper_profiles, mrvl_tm_shaper_profile) shaper_profiles;
+	LIST_HEAD(nodes, mrvl_tm_node) nodes;
+	uint64_t rate_max;
 };
 
 /** Flow operations forward declaration. */
@@ -181,6 +209,9 @@ extern const struct rte_flow_ops mrvl_flow_ops;
 /** Meter operations forward declaration. */
 extern const struct rte_mtr_ops mrvl_mtr_ops;
 
+/** Traffic manager operations forward declaration. */
+extern const struct rte_tm_ops mrvl_tm_ops;
+
 /** Current log type. */
 extern int mrvl_logtype;
 
drivers/net/mvpp2/mrvl_tm.c new file +1009 -0

1,009 lines not on this page · raw message

drivers/net/mvpp2/mrvl_tm.h new file +15 -0
new file mode 100644
index 0000000..9d81ede
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Marvell International Ltd.
+ * Copyright(c) 2018 Semihalf.
+ * All rights reserved.
+ */
+
+#ifndef _MRVL_TM_H_
+#define _MRVL_TM_H_
+
+#include "mrvl_ethdev.h"
+
+int mrvl_tm_init(struct rte_eth_dev *dev);
+void mrvl_tm_deinit(struct rte_eth_dev *dev);
+
+#endif /* _MRVL_TM_H_ */
Signature · 1 line
2.7.4
#7 lore raw

PATCH 7/8 net/mvpp2: detach tx_qos from rx cls/qos config

In reply to Tomasz Duszynski

From: Yuval Caduri <[email protected]>

Functional change:
Open receive cls/qos related features, only if the config file contains an rx_related configuration entry. This allows to configure tx_related entries, w/o unintentionally opening rx cls/qos.

Code:
'use_global_defaults' is by default set to '1'.
Only if an rx_related entry was configured, it is updated to '0'. rx cls/qos is performed only if 'use_global_defaults' is '0'. Default TC configuration is now only mandatory when 'use_global_defaults' is '0'.

---
 drivers/net/mvpp2/mrvl_ethdev.c |  3 ++-
 drivers/net/mvpp2/mrvl_qos.c    | 41 +++++++++++++++++++++++------------------
 2 files changed, 25 insertions(+), 19 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +2 -1
index a1dc6b1..5643e7d 100644
@@ -602,7 +602,8 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 	}
 
 	/* For default QoS config, don't start classifier. */
-	if (mrvl_qos_cfg) {
+	if (mrvl_qos_cfg  &&
+	    mrvl_qos_cfg->port[dev->data->port_id].use_global_defaults == 0) {
 		ret = mrvl_start_qos_mapping(priv);
 		if (ret) {
 			MRVL_LOG(ERR, "Failed to setup QoS mapping");
drivers/net/mvpp2/mrvl_qos.c +23 -18

89 lines not on this page · raw message

Signature · 1 line
2.7.4
#8 lore raw

PATCH 8/8 net/mvpp2: update MTU and MRU related calculations

In reply to Tomasz Duszynski

From: Natalie Samsonov <[email protected]>

This commit updates MTU and MRU related calculations.

---
 drivers/net/mvpp2/mrvl_ethdev.c | 70 +++++++++++++++++++++++++++++++----------
 drivers/net/mvpp2/mrvl_ethdev.h |  7 +++++
 2 files changed, 61 insertions(+), 16 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +54 -16
index 5643e7d..035ee81 100644
@@ -325,7 +325,7 @@ mrvl_dev_configure(struct rte_eth_dev *dev)
 
 	if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME)
 		dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
-				 ETHER_HDR_LEN - ETHER_CRC_LEN;
+				 MRVL_PP2_ETH_HDRS_LEN;
 
 	ret = mrvl_configure_rxqs(priv, dev->data->port_id,
 				  dev->data->nb_rx_queues);
@@ -375,21 +375,55 @@ static int
 mrvl_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 {
 	struct mrvl_priv *priv = dev->data->dev_private;
-	/* extra MV_MH_SIZE bytes are required for Marvell tag */
-	uint16_t mru = mtu + MV_MH_SIZE + ETHER_HDR_LEN + ETHER_CRC_LEN;
+	uint16_t mru;
+	uint16_t mbuf_data_size = 0; /* SW buffer size */
 	int ret;
 
-	if (mtu < ETHER_MIN_MTU || mru > MRVL_PKT_SIZE_MAX)
+	mru = MRVL_PP2_MTU_TO_MRU(mtu);
+	/*
+	 * min_rx_buf_size is equal to mbuf data size
+	 * if pmd didn't set it differently
+	 */
+	mbuf_data_size = dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM;
+	/* Prevent PMD from:
+	 * - setting mru greater than the mbuf size resulting in
+	 * hw and sw buffer size mismatch
+	 * - setting mtu that requires the support of scattered packets
+	 * when this feature has not been enabled/supported so far
+	 * (TODO check scattered_rx flag here once scattered RX is supported).
+	 */
+	if (mru + MRVL_PKT_OFFS > mbuf_data_size) {
+		mru = mbuf_data_size - MRVL_PKT_OFFS;
+		mtu = MRVL_PP2_MRU_TO_MTU(mru);
+		MRVL_LOG(WARNING, "MTU too big, max MTU possible limitted "
+			"by current mbuf size: %u. Set MTU to %u, MRU to %u",
+			mbuf_data_size, mtu, mru);
+	}
+
+	if (mtu < ETHER_MIN_MTU || mru > MRVL_PKT_SIZE_MAX) {
+		MRVL_LOG(ERR, "Invalid MTU [%u] or MRU [%u]", mtu, mru);
 		return -EINVAL;
+	}
+
+	dev->data->mtu = mtu;
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = mru - MV_MH_SIZE;
 
 	if (!priv->ppio)
 		return 0;
 
 	ret = pp2_ppio_set_mru(priv->ppio, mru);
-	if (ret)
+	if (ret) {
+		MRVL_LOG(ERR, "Failed to change MRU");
 		return ret;
+	}
+
+	ret = pp2_ppio_set_mtu(priv->ppio, mtu);
+	if (ret) {
+		MRVL_LOG(ERR, "Failed to change MTU");
+		return ret;
+	}
 
-	return pp2_ppio_set_mtu(priv->ppio, mtu);
+	return 0;
 }
 
 /**
@@ -600,6 +634,9 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 		}
 		priv->vlan_flushed = 1;
 	}
+	ret = mrvl_mtu_set(dev, dev->data->mtu);
+	if (ret)
+		MRVL_LOG(ERR, "Failed to set MTU to %d", dev->data->mtu);
 
 	/* For default QoS config, don't start classifier. */
 	if (mrvl_qos_cfg  &&
@@ -1552,8 +1589,8 @@ mrvl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 {
 	struct mrvl_priv *priv = dev->data->dev_private;
 	struct mrvl_rxq *rxq;
-	uint32_t min_size,
-		 max_rx_pkt_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
+	uint32_t frame_size, buf_size = rte_pktmbuf_data_room_size(mp);
+	uint32_t max_rx_pkt_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
 	int ret, tc, inq;
 	uint64_t offloads;
 
@@ -1568,15 +1605,16 @@ mrvl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 		return -EFAULT;
 	}
 
-	min_size = rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM -
-		   MRVL_PKT_EFFEC_OFFS;
-	if (min_size < max_rx_pkt_len) {
-		MRVL_LOG(ERR,
-			"Mbuf size must be increased to %u bytes to hold up to %u bytes of data.",
-			max_rx_pkt_len + RTE_PKTMBUF_HEADROOM +
-			MRVL_PKT_EFFEC_OFFS,
+	frame_size = buf_size - RTE_PKTMBUF_HEADROOM - MRVL_PKT_EFFEC_OFFS;
+	if (frame_size < max_rx_pkt_len) {
+		MRVL_LOG(WARNING,
+			"Mbuf size must be increased to %u bytes to hold up "
+			"to %u bytes of data.",
+			buf_size + max_rx_pkt_len - frame_size,
 			max_rx_pkt_len);
-		return -EINVAL;
+		dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+		MRVL_LOG(INFO, "Setting max rx pkt len to %u",
+			dev->data->dev_conf.rxmode.max_rx_pkt_len);
 	}
 
 	if (dev->data->rx_queues[idx]) {
drivers/net/mvpp2/mrvl_ethdev.h +7 -0
index 984f31e..f0ae983 100644
@@ -72,6 +72,13 @@
 /** Minimum number of sent buffers to release from shadow queue to BM */
 #define MRVL_PP2_BUF_RELEASE_BURST_SIZE	64
 
+#define MRVL_PP2_VLAN_TAG_LEN		4
+#define MRVL_PP2_ETH_HDRS_LEN		(ETHER_HDR_LEN + ETHER_CRC_LEN + \
+					(2 * MRVL_PP2_VLAN_TAG_LEN))
+#define MRVL_PP2_HDRS_LEN		(MV_MH_SIZE + MRVL_PP2_ETH_HDRS_LEN)
+#define MRVL_PP2_MTU_TO_MRU(mtu)	((mtu) + MRVL_PP2_HDRS_LEN)
+#define MRVL_PP2_MRU_TO_MTU(mru)	((mru) - MRVL_PP2_HDRS_LEN)
+
 /** Maximum length of a match string */
 #define MRVL_MATCH_LEN 16
 
Signature · 1 line
2.7.4
#9 lore raw

v2 cover net/mvpp2: add new features

In reply to Tomasz Duszynski

This patch series introduces fixes and adds support for traffic metering, traffic manager and Tx S/G. Additionally it aligns with for MUSDK 18.09.

Changes since v2:
* Align with MUSDK 18.09 library
* Add support for Tx Gather.
* Add documentation related to MTR and TM.
* Align documentation with MUSDK 18.09

Natalie Samsonov (4):
net/mvpp2: initialize ppio only once net/mvpp2: update MTU and MRU related calculations net/mvpp2: align documentation with MUSDK 18.09 net/mvpp2: document MTR and TM usage

Tomasz Duszynski (6):
net/mvpp2: move common code
net/mvpp2: add metering support
net/mvpp2: change default policer configuration
net/mvpp2: add init and deinit to flow
net/mvpp2: add traffic manager support
net/mvpp2: align with MUSDK 18.09

Yuval Caduri (1):
net/mvpp2: detach tx_qos from rx cls/qos config

Zyta Szpak (1):
net/mvpp2: add Tx S/G support

 doc/guides/nics/img/mvpp2_tm.png |  Bin 0 -> 5355 bytes
 doc/guides/nics/mvpp2.rst        |  433 +++++++++++++---
 drivers/net/mvpp2/Makefile       |    2 +
 drivers/net/mvpp2/meson.build    |    4 +-
 drivers/net/mvpp2/mrvl_ethdev.c  |  427 +++++++++++++---
 drivers/net/mvpp2/mrvl_ethdev.h  |  123 ++++-
 drivers/net/mvpp2/mrvl_flow.c    |  132 +++--
 drivers/net/mvpp2/mrvl_flow.h    |   15 +
 drivers/net/mvpp2/mrvl_mtr.c     |  512 +++++++++++++++++++
 drivers/net/mvpp2/mrvl_mtr.h     |   15 +
 drivers/net/mvpp2/mrvl_qos.c     |  246 +++++-----
 drivers/net/mvpp2/mrvl_qos.h     |    2 +-
 drivers/net/mvpp2/mrvl_tm.c      | 1009 ++++++++++++++++++++++++++++++++++++++
 drivers/net/mvpp2/mrvl_tm.h      |   15 +
 14 files changed, 2624 insertions(+), 311 deletions(-)
 create mode 100644 doc/guides/nics/img/mvpp2_tm.png
 create mode 100644 drivers/net/mvpp2/mrvl_flow.h
 create mode 100644 drivers/net/mvpp2/mrvl_mtr.c
 create mode 100644 drivers/net/mvpp2/mrvl_mtr.h
 create mode 100644 drivers/net/mvpp2/mrvl_tm.c
 create mode 100644 drivers/net/mvpp2/mrvl_tm.h

--
2.7.4

#10 lore raw

PATCH v2 1/12 net/mvpp2: initialize ppio only once

From: Natalie Samsonov <[email protected]>

This changes stop/start/configure behavior due to issue in MUSDK library itself. From now on, ppio can be reconfigured only after interface is closed.

---
 drivers/net/mvpp2/mrvl_ethdev.c | 53 +++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 21 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +32 -21
index 6824445..f022cad 100644
@@ -304,6 +304,11 @@ mrvl_dev_configure(struct rte_eth_dev *dev)
 	struct mrvl_priv *priv = dev->data->dev_private;
 	int ret;
 
+	if (priv->ppio) {
+		MRVL_LOG(INFO, "Device reconfiguration is not supported");
+		return -EINVAL;
+	}
+
 	if (dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_NONE &&
 	    dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_RSS) {
 		MRVL_LOG(INFO, "Unsupported rx multi queue mode %d",
@@ -525,6 +530,9 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 	char match[MRVL_MATCH_LEN];
 	int ret = 0, i, def_init_size;
 
+	if (priv->ppio)
+		return mrvl_dev_set_link_up(dev);
+
 	snprintf(match, sizeof(match), "ppio-%d:%d",
 		 priv->pp_id, priv->ppio_id);
 	priv->ppio_params.match = match;
@@ -749,28 +757,7 @@ mrvl_flush_bpool(struct rte_eth_dev *dev)
 static void
 mrvl_dev_stop(struct rte_eth_dev *dev)
 {
-	struct mrvl_priv *priv = dev->data->dev_private;
-
 	mrvl_dev_set_link_down(dev);
-	mrvl_flush_rx_queues(dev);
-	mrvl_flush_tx_shadow_queues(dev);
-	if (priv->cls_tbl) {
-		pp2_cls_tbl_deinit(priv->cls_tbl);
-		priv->cls_tbl = NULL;
-	}
-	if (priv->qos_tbl) {
-		pp2_cls_qos_tbl_deinit(priv->qos_tbl);
-		priv->qos_tbl = NULL;
-	}
-	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;
-	}
 }
 
 /**
@@ -785,6 +772,9 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 	struct mrvl_priv *priv = dev->data->dev_private;
 	size_t i;
 
+	mrvl_flush_rx_queues(dev);
+	mrvl_flush_tx_shadow_queues(dev);
+
 	for (i = 0; i < priv->ppio_params.inqs_params.num_tcs; ++i) {
 		struct pp2_ppio_tc_params *tc_params =
 			&priv->ppio_params.inqs_params.tcs_params[i];
@@ -795,7 +785,28 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 		}
 	}
 
+	if (priv->cls_tbl) {
+		pp2_cls_tbl_deinit(priv->cls_tbl);
+		priv->cls_tbl = NULL;
+	}
+
+	if (priv->qos_tbl) {
+		pp2_cls_qos_tbl_deinit(priv->qos_tbl);
+		priv->qos_tbl = NULL;
+	}
+
 	mrvl_flush_bpool(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;
+	}
 }
 
 /**
Signature · 1 line
2.7.4
#11 lore raw

PATCH v2 2/12 net/mvpp2: move common code

In reply to Tomasz Duszynski

Cleanup sources by moving common code to the pmd
header file.

---
 drivers/net/mvpp2/mrvl_ethdev.c |  9 ---------
 drivers/net/mvpp2/mrvl_ethdev.h | 11 +++++++++++
 drivers/net/mvpp2/mrvl_flow.c   |  5 -----
 drivers/net/mvpp2/mrvl_qos.c    |  9 ---------
 4 files changed, 11 insertions(+), 23 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +0 -9
index f022cad..adb07d0 100644
@@ -10,15 +10,6 @@
 #include <rte_malloc.h>
 #include <rte_bus_vdev.h>
 
-/* Unluckily, container_of is defined by both DPDK and MUSDK,
- * we'll declare only one version.
- *
- * Note that it is not used in this PMD anyway.
- */
-#ifdef container_of
-#undef container_of
-#endif
-
 #include <fcntl.h>
 #include <linux/ethtool.h>
 #include <linux/sockios.h>
drivers/net/mvpp2/mrvl_ethdev.h +11 -0
index 3726f78..2204be2 100644
@@ -10,12 +10,23 @@
 #include <rte_spinlock.h>
 #include <rte_flow_driver.h>
 
+/*
+ * container_of is defined by both DPDK and MUSDK,
+ * we'll declare only one version.
+ *
+ * Note that it is not used in this PMD anyway.
+ */
+#ifdef container_of
+#undef container_of
+#endif
+
 #include <env/mv_autogen_comp_flags.h>
 #include <drivers/mv_pp2.h>
 #include <drivers/mv_pp2_bpool.h>
 #include <drivers/mv_pp2_cls.h>
 #include <drivers/mv_pp2_hif.h>
 #include <drivers/mv_pp2_ppio.h>
+#include "env/mv_common.h" /* for BIT() */
 
 /** Maximum number of rx queues per port */
 #define MRVL_PP2_RXQ_MAX 32
drivers/net/mvpp2/mrvl_flow.c +0 -5
index 13295e6..db750f4 100644
@@ -11,13 +11,8 @@
 
 #include <arpa/inet.h>
 
-#ifdef container_of
-#undef container_of
-#endif
-
 #include "mrvl_ethdev.h"
 #include "mrvl_qos.h"
-#include "env/mv_common.h" /* for BIT() */
 
 /** Number of rules in the classifier table. */
 #define MRVL_CLS_MAX_NUM_RULES 20
drivers/net/mvpp2/mrvl_qos.c +0 -9
index 71856c1..eeb46f8 100644
@@ -15,15 +15,6 @@
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
-/* Unluckily, container_of is defined by both DPDK and MUSDK,
- * we'll declare only one version.
- *
- * Note that it is not used in this PMD anyway.
- */
-#ifdef container_of
-#undef container_of
-#endif
-
 #include "mrvl_qos.h"
 
 /* Parsing tokens. Defined conveniently, so that any correction is easy. */
Signature · 1 line
2.7.4
#12 lore raw

PATCH v2 3/12 net/mvpp2: add metering support

In reply to Tomasz Duszynski

Add support for configuring plcr via DPDK generic metering API.

---
 drivers/net/mvpp2/Makefile      |   1 +
 drivers/net/mvpp2/meson.build   |   3 +-
 drivers/net/mvpp2/mrvl_ethdev.c |  24 ++
 drivers/net/mvpp2/mrvl_ethdev.h |  71 ++++++
 drivers/net/mvpp2/mrvl_flow.c   |  91 +++----
 drivers/net/mvpp2/mrvl_mtr.c    | 512 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mvpp2/mrvl_mtr.h    |  15 ++
 7 files changed, 673 insertions(+), 44 deletions(-)
 create mode 100644 drivers/net/mvpp2/mrvl_mtr.c
 create mode 100644 drivers/net/mvpp2/mrvl_mtr.h
drivers/net/mvpp2/Makefile +1 -0
index 211d398..4848d65 100644
@@ -39,5 +39,6 @@ LDLIBS += -lrte_bus_vdev -lrte_common_mvep
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_qos.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_flow.c
+SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_mtr.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/mvpp2/meson.build +2 -1
index 3620659..f475511 100644
@@ -19,7 +19,8 @@ endif
 sources = files(
 	'mrvl_ethdev.c',
 	'mrvl_flow.c',
-	'mrvl_qos.c'
+	'mrvl_qos.c',
+	'mrvl_mtr.c'
 )
 
 deps += ['cfgfile', 'common_mvep']
drivers/net/mvpp2/mrvl_ethdev.c +24 -0
index adb07d0..a4951d3 100644
@@ -23,6 +23,7 @@
 #include <rte_mvep_common.h>
 #include "mrvl_ethdev.h"
 #include "mrvl_qos.h"
+#include "mrvl_mtr.h"
 
 /* bitmask with reserved hifs */
 #define MRVL_MUSDK_HIFS_RESERVED 0x0F
@@ -627,6 +628,8 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 			goto out;
 	}
 
+	mrvl_mtr_init(dev);
+
 	return 0;
 out:
 	MRVL_LOG(ERR, "Failed to start device");
@@ -765,6 +768,7 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 
 	mrvl_flush_rx_queues(dev);
 	mrvl_flush_tx_shadow_queues(dev);
+	mrvl_mtr_deinit(dev);
 
 	for (i = 0; i < priv->ppio_params.inqs_params.num_tcs; ++i) {
 		struct pp2_ppio_tc_params *tc_params =
@@ -1868,6 +1872,25 @@ mrvl_eth_filter_ctrl(struct rte_eth_dev *dev __rte_unused,
 	}
 }
 
+/**
+ * DPDK callback to get rte_mtr callbacks.
+ *
+ * @param dev
+ *   Pointer to the device structure.
+ * @param ops
+ *   Pointer to pass the mtr ops.
+ *
+ * @return
+ *   Always 0.
+ */
+static int
+mrvl_mtr_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops)
+{
+	*(const void **)ops = &mrvl_mtr_ops;
+
+	return 0;
+}
+
 static const struct eth_dev_ops mrvl_ops = {
 	.dev_configure = mrvl_dev_configure,
 	.dev_start = mrvl_dev_start,
@@ -1905,6 +1928,7 @@ static const struct eth_dev_ops mrvl_ops = {
 	.rss_hash_update = mrvl_rss_hash_update,
 	.rss_hash_conf_get = mrvl_rss_hash_conf_get,
 	.filter_ctrl = mrvl_eth_filter_ctrl,
+	.mtr_ops_get = mrvl_mtr_ops_get,
 };
 
 /**
drivers/net/mvpp2/mrvl_ethdev.h +71 -0

94 lines not on this page · raw message

drivers/net/mvpp2/mrvl_flow.c +48 -43

119 lines not on this page · raw message

drivers/net/mvpp2/mrvl_mtr.c new file +512 -0

512 lines not on this page · raw message

drivers/net/mvpp2/mrvl_mtr.h new file +15 -0
new file mode 100644
index 0000000..302a20f
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Marvell International Ltd.
+ * Copyright(c) 2018 Semihalf.
+ * All rights reserved.
+ */
+
+#ifndef _MRVL_MTR_H_
+#define _MRVL_MTR_H_
+
+#include "mrvl_ethdev.h"
+
+void mrvl_mtr_init(struct rte_eth_dev *dev);
+void mrvl_mtr_deinit(struct rte_eth_dev *dev);
+
+#endif /* _MRVL_MTR_H_ */
Signature · 1 line
2.7.4
#13 lore raw

PATCH v2 4/12 net/mvpp2: change default policer configuration

In reply to Tomasz Duszynski

Change QoS configuration file syntax for port's default policer setup.

Since default policer configuration is performed before any other policer configuration we can pick a default id.

This simplifies default policer configuration since user no longer has to choose ids from range [0, PP2_CLS_PLCR_NUM].

Explicitly document values for rate_limit_enable field.

---
 doc/guides/nics/mvpp2.rst       |  31 ++++---
 drivers/net/mvpp2/mrvl_ethdev.c |   6 +-
 drivers/net/mvpp2/mrvl_ethdev.h |   2 +-
 drivers/net/mvpp2/mrvl_qos.c    | 198 ++++++++++++++++++++++------------------
 drivers/net/mvpp2/mrvl_qos.h    |   2 +-
 5 files changed, 134 insertions(+), 105 deletions(-)
doc/guides/nics/mvpp2.rst +19 -12
index 0408752..a452c8a 100644
@@ -152,20 +152,23 @@ Configuration syntax
 
 .. code-block:: console
 
-   [port <portnum> default]
-   default_tc = <default_tc>
-   mapping_priority = <mapping_priority>
-   policer_enable = <policer_enable>
+   [policer <policer_id>]
    token_unit = <token_unit>
    color = <color_mode>
    cir = <cir>
    ebs = <ebs>
    cbs = <cbs>
 
+   [port <portnum> default]
+   default_tc = <default_tc>
+   mapping_priority = <mapping_priority>
+
    rate_limit_enable = <rate_limit_enable>
    rate_limit = <rate_limit>
    burst_size = <burst_size>
 
+   default_policer = <policer_id>
+
    [port <portnum> tc <traffic_class>]
    rxq = <rx_queue_list>
    pcp = <pcp_list>
@@ -201,7 +204,9 @@ Where:
 
 - ``<dscp_list>``: List of DSCP values to handle in particular TC (e.g. 0-12 32-48 63).
 
-- ``<policer_enable>``: Enable ingress policer.
+- ``<default_policer>``: Id of the policer configuration section to be used as default.
+
+- ``<policer_id>``: Id of the policer configuration section (0..31).
 
 - ``<token_unit>``: Policer token unit (`bytes` or `packets`).
 
@@ -215,7 +220,7 @@ Where:
 
 - ``<default_color>``: Default color for specific tc.
 
-- ``<rate_limit_enable>``: Enables per port or per txq rate limiting.
+- ``<rate_limit_enable>``: Enables per port or per txq rate limiting (`0`/`1` to disable/enable).
 
 - ``<rate_limit>``: Committed information rate, in kilo bits per second.
 
@@ -234,6 +239,13 @@ Configuration file example
 
 .. code-block:: console
 
+   [policer 0]
+   token_unit = bytes
+   color = blind
+   cir = 100000
+   ebs = 64
+   cbs = 64
+
    [port 0 default]
    default_tc = 0
    mapping_priority = ip
@@ -265,12 +277,7 @@ Configuration file example
    default_tc = 0
    mapping_priority = vlan/ip
 
-   policer_enable = 1
-   token_unit = bytes
-   color = blind
-   cir = 100000
-   ebs = 64
-   cbs = 64
+   default_policer = 0
 
    [port 1 tc 0]
    rxq = 0
drivers/net/mvpp2/mrvl_ethdev.c +3 -3
index a4951d3..1464385 100644
@@ -798,9 +798,9 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 	}
 
 	/* policer must be released after ppio deinitialization */
-	if (priv->policer) {
-		pp2_cls_plcr_deinit(priv->policer);
-		priv->policer = NULL;
+	if (priv->default_policer) {
+		pp2_cls_plcr_deinit(priv->default_policer);
+		priv->default_policer = NULL;
 	}
 }
 
drivers/net/mvpp2/mrvl_ethdev.h +1 -1
index ecb8fdc..de423a9 100644
@@ -168,7 +168,7 @@ struct mrvl_priv {
 	uint32_t cls_tbl_pattern;
 	LIST_HEAD(mrvl_flows, rte_flow) flows;
 
-	struct pp2_cls_plcr *policer;
+	struct pp2_cls_plcr *default_policer;
 
 	LIST_HEAD(profiles, mrvl_mtr_profile) profiles;
 	LIST_HEAD(mtrs, mrvl_mtr) mtrs;
drivers/net/mvpp2/mrvl_qos.c +110 -88

253 lines not on this page · raw message

drivers/net/mvpp2/mrvl_qos.h +1 -1
index fa9ddec..f03e773 100644
@@ -43,7 +43,7 @@ struct mrvl_qos_cfg {
 		uint8_t default_tc;
 		uint8_t use_global_defaults;
 		struct pp2_cls_plcr_params policer_params;
-		uint8_t policer_enable;
+		uint8_t setup_policer;
 	} port[RTE_MAX_ETHPORTS];
 };
 
Signature · 1 line
2.7.4
#14 lore raw

PATCH v2 5/12 net/mvpp2: add init and deinit to flow

In reply to Tomasz Duszynski

Add init and deinit functionality to flow implementation.

Init puts structures used by flow in a sane sate.
Deinit deallocates all resources used by flow.

---
 drivers/net/mvpp2/mrvl_ethdev.c |  3 +++
 drivers/net/mvpp2/mrvl_flow.c   | 33 ++++++++++++++++++++++++++++++++-
 drivers/net/mvpp2/mrvl_flow.h   | 15 +++++++++++++++
 3 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/mvpp2/mrvl_flow.h
drivers/net/mvpp2/mrvl_ethdev.c +3 -0
index 1464385..5e3a106 100644
@@ -23,6 +23,7 @@
 #include <rte_mvep_common.h>
 #include "mrvl_ethdev.h"
 #include "mrvl_qos.h"
+#include "mrvl_flow.h"
 #include "mrvl_mtr.h"
 
 /* bitmask with reserved hifs */
@@ -628,6 +629,7 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 			goto out;
 	}
 
+	mrvl_flow_init(dev);
 	mrvl_mtr_init(dev);
 
 	return 0;
@@ -768,6 +770,7 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 
 	mrvl_flush_rx_queues(dev);
 	mrvl_flush_tx_shadow_queues(dev);
+	mrvl_flow_deinit(dev);
 	mrvl_mtr_deinit(dev);
 
 	for (i = 0; i < priv->ppio_params.inqs_params.num_tcs; ++i) {
drivers/net/mvpp2/mrvl_flow.c +32 -1
index e6953e4..065b1aa 100644
@@ -11,7 +11,7 @@
 
 #include <arpa/inet.h>
 
-#include "mrvl_ethdev.h"
+#include "mrvl_flow.h"
 #include "mrvl_qos.h"
 
 /** Number of rules in the classifier table. */
@@ -2790,3 +2790,34 @@ const struct rte_flow_ops mrvl_flow_ops = {
 	.flush = mrvl_flow_flush,
 	.isolate = mrvl_flow_isolate
 };
+
+/**
+ * Initialize flow resources.
+ *
+ * @param dev Pointer to the device.
+ */
+void
+mrvl_flow_init(struct rte_eth_dev *dev)
+{
+	struct mrvl_priv *priv = dev->data->dev_private;
+
+	LIST_INIT(&priv->flows);
+}
+
+/**
+ * Cleanup flow resources.
+ *
+ * @param dev Pointer to the device.
+ */
+void
+mrvl_flow_deinit(struct rte_eth_dev *dev)
+{
+	struct mrvl_priv *priv = dev->data->dev_private;
+
+	mrvl_flow_flush(dev, NULL);
+
+	if (priv->cls_tbl) {
+		pp2_cls_tbl_deinit(priv->cls_tbl);
+		priv->cls_tbl = NULL;
+	}
+}
drivers/net/mvpp2/mrvl_flow.h new file +15 -0
new file mode 100644
index 0000000..f63747c
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Marvell International Ltd.
+ * Copyright(c) 2018 Semihalf.
+ * All rights reserved.
+ */
+
+#ifndef _MRVL_FLOW_H_
+#define _MRVL_FLOW_H_
+
+#include "mrvl_ethdev.h"
+
+void mrvl_flow_init(struct rte_eth_dev *dev);
+void mrvl_flow_deinit(struct rte_eth_dev *dev);
+
+#endif /* _MRVL_FLOW_H_ */
Signature · 1 line
2.7.4
#15 lore raw

PATCH v2 6/12 net/mvpp2: add traffic manager support

In reply to Tomasz Duszynski

Add traffic manager support.

---
 drivers/net/mvpp2/Makefile      |    1 +
 drivers/net/mvpp2/meson.build   |    3 +-
 drivers/net/mvpp2/mrvl_ethdev.c |   26 +
 drivers/net/mvpp2/mrvl_ethdev.h |   31 ++
 drivers/net/mvpp2/mrvl_tm.c     | 1009 +++++++++++++++++++++++++++++++++++++++
 drivers/net/mvpp2/mrvl_tm.h     |   15 +
 6 files changed, 1084 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/mvpp2/mrvl_tm.c
 create mode 100644 drivers/net/mvpp2/mrvl_tm.h
drivers/net/mvpp2/Makefile +1 -0
index 4848d65..661d2cd 100644
@@ -40,5 +40,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_qos.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_flow.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_mtr.c
+SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_tm.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/mvpp2/meson.build +2 -1
index f475511..70ef2d6 100644
@@ -20,7 +20,8 @@ sources = files(
 	'mrvl_ethdev.c',
 	'mrvl_flow.c',
 	'mrvl_qos.c',
-	'mrvl_mtr.c'
+	'mrvl_mtr.c',
+	'mrvl_tm.c'
 )
 
 deps += ['cfgfile', 'common_mvep']
drivers/net/mvpp2/mrvl_ethdev.c +26 -0
index 5e3a106..a1dc6b1 100644
@@ -25,6 +25,7 @@
 #include "mrvl_qos.h"
 #include "mrvl_flow.h"
 #include "mrvl_mtr.h"
+#include "mrvl_tm.h"
 
 /* bitmask with reserved hifs */
 #define MRVL_MUSDK_HIFS_RESERVED 0x0F
@@ -340,6 +341,10 @@ mrvl_dev_configure(struct rte_eth_dev *dev)
 	priv->ppio_params.maintain_stats = 1;
 	priv->nb_rx_queues = dev->data->nb_rx_queues;
 
+	ret = mrvl_tm_init(dev);
+	if (ret < 0)
+		return ret;
+
 	if (dev->data->nb_rx_queues == 1 &&
 	    dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_RSS) {
 		MRVL_LOG(WARNING, "Disabling hash for 1 rx queue");
@@ -794,6 +799,7 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 	}
 
 	mrvl_flush_bpool(dev);
+	mrvl_tm_deinit(dev);
 
 	if (priv->ppio) {
 		pp2_ppio_deinit(priv->ppio);
@@ -1894,6 +1900,25 @@ mrvl_mtr_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops)
 	return 0;
 }
 
+/**
+ * DPDK callback to get rte_tm callbacks.
+ *
+ * @param dev
+ *   Pointer to the device structure.
+ * @param ops
+ *   Pointer to pass the tm ops.
+ *
+ * @return
+ *   Always 0.
+ */
+static int
+mrvl_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops)
+{
+	*(const void **)ops = &mrvl_tm_ops;
+
+	return 0;
+}
+
 static const struct eth_dev_ops mrvl_ops = {
 	.dev_configure = mrvl_dev_configure,
 	.dev_start = mrvl_dev_start,
@@ -1932,6 +1957,7 @@ static const struct eth_dev_ops mrvl_ops = {
 	.rss_hash_conf_get = mrvl_rss_hash_conf_get,
 	.filter_ctrl = mrvl_eth_filter_ctrl,
 	.mtr_ops_get = mrvl_mtr_ops_get,
+	.tm_ops_get = mrvl_tm_ops_get,
 };
 
 /**
drivers/net/mvpp2/mrvl_ethdev.h +31 -0
index de423a9..984f31e 100644
@@ -10,6 +10,7 @@
 #include <rte_spinlock.h>
 #include <rte_flow_driver.h>
 #include <rte_mtr_driver.h>
+#include <rte_tm_driver.h>
 
 /*
  * container_of is defined by both DPDK and MUSDK,
@@ -134,6 +135,29 @@ struct mrvl_mtr {
 	struct pp2_cls_plcr *plcr;
 };
 
+struct mrvl_tm_shaper_profile {
+	LIST_ENTRY(mrvl_tm_shaper_profile) next;
+	uint32_t id;
+	int refcnt;
+	struct rte_tm_shaper_params params;
+};
+
+enum {
+	MRVL_NODE_PORT,
+	MRVL_NODE_QUEUE,
+};
+
+struct mrvl_tm_node {
+	LIST_ENTRY(mrvl_tm_node) next;
+	uint32_t id;
+	uint32_t type;
+	int refcnt;
+	struct mrvl_tm_node *parent;
+	struct mrvl_tm_shaper_profile *profile;
+	uint8_t weight;
+	uint64_t stats_mask;
+};
+
 struct mrvl_priv {
 	/* Hot fields, used in fast path. */
 	struct pp2_bpool *bpool;  /**< BPool pointer */
@@ -173,6 +197,10 @@ struct mrvl_priv {
 	LIST_HEAD(profiles, mrvl_mtr_profile) profiles;
 	LIST_HEAD(mtrs, mrvl_mtr) mtrs;
 	uint32_t used_plcrs;
+
+	LIST_HEAD(shaper_profiles, mrvl_tm_shaper_profile) shaper_profiles;
+	LIST_HEAD(nodes, mrvl_tm_node) nodes;
+	uint64_t rate_max;
 };
 
 /** Flow operations forward declaration. */
@@ -181,6 +209,9 @@ extern const struct rte_flow_ops mrvl_flow_ops;
 /** Meter operations forward declaration. */
 extern const struct rte_mtr_ops mrvl_mtr_ops;
 
+/** Traffic manager operations forward declaration. */
+extern const struct rte_tm_ops mrvl_tm_ops;
+
 /** Current log type. */
 extern int mrvl_logtype;
 
drivers/net/mvpp2/mrvl_tm.c new file +1009 -0

1,009 lines not on this page · raw message

drivers/net/mvpp2/mrvl_tm.h new file +15 -0
new file mode 100644
index 0000000..9d81ede
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Marvell International Ltd.
+ * Copyright(c) 2018 Semihalf.
+ * All rights reserved.
+ */
+
+#ifndef _MRVL_TM_H_
+#define _MRVL_TM_H_
+
+#include "mrvl_ethdev.h"
+
+int mrvl_tm_init(struct rte_eth_dev *dev);
+void mrvl_tm_deinit(struct rte_eth_dev *dev);
+
+#endif /* _MRVL_TM_H_ */
Signature · 1 line
2.7.4
#16 lore raw

PATCH v2 7/12 net/mvpp2: detach tx_qos from rx cls/qos config

In reply to Tomasz Duszynski

From: Yuval Caduri <[email protected]>

Functional change:
Open receive cls/qos related features, only if the config file contains an rx_related configuration entry. This allows to configure tx_related entries, w/o unintentionally opening rx cls/qos.

Code:
'use_global_defaults' is by default set to '1'.
Only if an rx_related entry was configured, it is updated to '0'. rx cls/qos is performed only if 'use_global_defaults' is '0'. Default TC configuration is now only mandatory when 'use_global_defaults' is '0'.

---
 drivers/net/mvpp2/mrvl_ethdev.c |  3 ++-
 drivers/net/mvpp2/mrvl_qos.c    | 41 +++++++++++++++++++++++------------------
 2 files changed, 25 insertions(+), 19 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +2 -1
index a1dc6b1..5643e7d 100644
@@ -602,7 +602,8 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 	}
 
 	/* For default QoS config, don't start classifier. */
-	if (mrvl_qos_cfg) {
+	if (mrvl_qos_cfg  &&
+	    mrvl_qos_cfg->port[dev->data->port_id].use_global_defaults == 0) {
 		ret = mrvl_start_qos_mapping(priv);
 		if (ret) {
 			MRVL_LOG(ERR, "Failed to setup QoS mapping");
drivers/net/mvpp2/mrvl_qos.c +23 -18

89 lines not on this page · raw message

Signature · 1 line
2.7.4
#17 lore raw

PATCH v2 8/12 net/mvpp2: update MTU and MRU related calculations

In reply to Tomasz Duszynski

From: Natalie Samsonov <[email protected]>

This commit updates MTU and MRU related calculations.

---
 drivers/net/mvpp2/mrvl_ethdev.c | 70 +++++++++++++++++++++++++++++++----------
 drivers/net/mvpp2/mrvl_ethdev.h |  7 +++++
 2 files changed, 61 insertions(+), 16 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +54 -16
index 5643e7d..035ee81 100644
@@ -325,7 +325,7 @@ mrvl_dev_configure(struct rte_eth_dev *dev)
 
 	if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME)
 		dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
-				 ETHER_HDR_LEN - ETHER_CRC_LEN;
+				 MRVL_PP2_ETH_HDRS_LEN;
 
 	ret = mrvl_configure_rxqs(priv, dev->data->port_id,
 				  dev->data->nb_rx_queues);
@@ -375,21 +375,55 @@ static int
 mrvl_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 {
 	struct mrvl_priv *priv = dev->data->dev_private;
-	/* extra MV_MH_SIZE bytes are required for Marvell tag */
-	uint16_t mru = mtu + MV_MH_SIZE + ETHER_HDR_LEN + ETHER_CRC_LEN;
+	uint16_t mru;
+	uint16_t mbuf_data_size = 0; /* SW buffer size */
 	int ret;
 
-	if (mtu < ETHER_MIN_MTU || mru > MRVL_PKT_SIZE_MAX)
+	mru = MRVL_PP2_MTU_TO_MRU(mtu);
+	/*
+	 * min_rx_buf_size is equal to mbuf data size
+	 * if pmd didn't set it differently
+	 */
+	mbuf_data_size = dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM;
+	/* Prevent PMD from:
+	 * - setting mru greater than the mbuf size resulting in
+	 * hw and sw buffer size mismatch
+	 * - setting mtu that requires the support of scattered packets
+	 * when this feature has not been enabled/supported so far
+	 * (TODO check scattered_rx flag here once scattered RX is supported).
+	 */
+	if (mru + MRVL_PKT_OFFS > mbuf_data_size) {
+		mru = mbuf_data_size - MRVL_PKT_OFFS;
+		mtu = MRVL_PP2_MRU_TO_MTU(mru);
+		MRVL_LOG(WARNING, "MTU too big, max MTU possible limitted "
+			"by current mbuf size: %u. Set MTU to %u, MRU to %u",
+			mbuf_data_size, mtu, mru);
+	}
+
+	if (mtu < ETHER_MIN_MTU || mru > MRVL_PKT_SIZE_MAX) {
+		MRVL_LOG(ERR, "Invalid MTU [%u] or MRU [%u]", mtu, mru);
 		return -EINVAL;
+	}
+
+	dev->data->mtu = mtu;
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = mru - MV_MH_SIZE;
 
 	if (!priv->ppio)
 		return 0;
 
 	ret = pp2_ppio_set_mru(priv->ppio, mru);
-	if (ret)
+	if (ret) {
+		MRVL_LOG(ERR, "Failed to change MRU");
 		return ret;
+	}
+
+	ret = pp2_ppio_set_mtu(priv->ppio, mtu);
+	if (ret) {
+		MRVL_LOG(ERR, "Failed to change MTU");
+		return ret;
+	}
 
-	return pp2_ppio_set_mtu(priv->ppio, mtu);
+	return 0;
 }
 
 /**
@@ -600,6 +634,9 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 		}
 		priv->vlan_flushed = 1;
 	}
+	ret = mrvl_mtu_set(dev, dev->data->mtu);
+	if (ret)
+		MRVL_LOG(ERR, "Failed to set MTU to %d", dev->data->mtu);
 
 	/* For default QoS config, don't start classifier. */
 	if (mrvl_qos_cfg  &&
@@ -1552,8 +1589,8 @@ mrvl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 {
 	struct mrvl_priv *priv = dev->data->dev_private;
 	struct mrvl_rxq *rxq;
-	uint32_t min_size,
-		 max_rx_pkt_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
+	uint32_t frame_size, buf_size = rte_pktmbuf_data_room_size(mp);
+	uint32_t max_rx_pkt_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
 	int ret, tc, inq;
 	uint64_t offloads;
 
@@ -1568,15 +1605,16 @@ mrvl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 		return -EFAULT;
 	}
 
-	min_size = rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM -
-		   MRVL_PKT_EFFEC_OFFS;
-	if (min_size < max_rx_pkt_len) {
-		MRVL_LOG(ERR,
-			"Mbuf size must be increased to %u bytes to hold up to %u bytes of data.",
-			max_rx_pkt_len + RTE_PKTMBUF_HEADROOM +
-			MRVL_PKT_EFFEC_OFFS,
+	frame_size = buf_size - RTE_PKTMBUF_HEADROOM - MRVL_PKT_EFFEC_OFFS;
+	if (frame_size < max_rx_pkt_len) {
+		MRVL_LOG(WARNING,
+			"Mbuf size must be increased to %u bytes to hold up "
+			"to %u bytes of data.",
+			buf_size + max_rx_pkt_len - frame_size,
 			max_rx_pkt_len);
-		return -EINVAL;
+		dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+		MRVL_LOG(INFO, "Setting max rx pkt len to %u",
+			dev->data->dev_conf.rxmode.max_rx_pkt_len);
 	}
 
 	if (dev->data->rx_queues[idx]) {
drivers/net/mvpp2/mrvl_ethdev.h +7 -0
index 984f31e..f0ae983 100644
@@ -72,6 +72,13 @@
 /** Minimum number of sent buffers to release from shadow queue to BM */
 #define MRVL_PP2_BUF_RELEASE_BURST_SIZE	64
 
+#define MRVL_PP2_VLAN_TAG_LEN		4
+#define MRVL_PP2_ETH_HDRS_LEN		(ETHER_HDR_LEN + ETHER_CRC_LEN + \
+					(2 * MRVL_PP2_VLAN_TAG_LEN))
+#define MRVL_PP2_HDRS_LEN		(MV_MH_SIZE + MRVL_PP2_ETH_HDRS_LEN)
+#define MRVL_PP2_MTU_TO_MRU(mtu)	((mtu) + MRVL_PP2_HDRS_LEN)
+#define MRVL_PP2_MRU_TO_MTU(mru)	((mru) - MRVL_PP2_HDRS_LEN)
+
 /** Maximum length of a match string */
 #define MRVL_MATCH_LEN 16
 
Signature · 1 line
2.7.4
#18 lore raw

PATCH v2 9/12 net/mvpp2: align with MUSDK 18.09

In reply to Tomasz Duszynski

This patch introduces necessary changes required by MUSDK 18.09 library.

* As of MUSDK 18.09, pp2_cookie_t is no longer available. Now RX descriptor cookie is defined as plain u64 so existing cast is no longer valid.

* MUSDK 18.09 increased number of available bpools (buffer hw pools) by introducing dma regions support. Update mvpp2 driver accordingly.

* replace MV_NET_IP4_F_TOS with MV_NET_IP4_F_DSCP

Before this patch, API allowed to configure a classification rule according to IPv4 TOS, which was not supported in classifier. This patch fixes this by using proper field.

* use 48 bit address mask

We cannot get pointers exceeding 48 bits thus using 48 bit mask for extracting higher IOVA address bits is enough.

---
 drivers/net/mvpp2/mrvl_ethdev.c | 10 ++++------
 drivers/net/mvpp2/mrvl_flow.c   |  3 ++-
 drivers/net/mvpp2/mrvl_qos.c    |  2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +4 -6
index 035ee81..899a9e4 100644
@@ -54,9 +54,7 @@
 #define MRVL_ARP_LENGTH 28
 
 #define MRVL_COOKIE_ADDR_INVALID ~0ULL
-
-#define MRVL_COOKIE_HIGH_ADDR_SHIFT	(sizeof(pp2_cookie_t) * 8)
-#define MRVL_COOKIE_HIGH_ADDR_MASK	(~0ULL << MRVL_COOKIE_HIGH_ADDR_SHIFT)
+#define MRVL_COOKIE_HIGH_ADDR_MASK 0xffffff0000000000
 
 /** Port Rx offload capabilities */
 #define MRVL_RX_OFFLOADS (DEV_RX_OFFLOAD_VLAN_FILTER | \
@@ -1544,7 +1542,7 @@ mrvl_fill_bpool(struct mrvl_rxq *rxq, int num)
 
 		entries[i].buff.addr =
 			rte_mbuf_data_iova_default(mbufs[i]);
-		entries[i].buff.cookie = (pp2_cookie_t)(uint64_t)mbufs[i];
+		entries[i].buff.cookie = (uint64_t)mbufs[i];
 		entries[i].bpool = bpool;
 	}
 
@@ -2180,7 +2178,7 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		if (unlikely(status != PP2_DESC_ERR_OK)) {
 			struct pp2_buff_inf binf = {
 				.addr = rte_mbuf_data_iova_default(mbuf),
-				.cookie = (pp2_cookie_t)(uint64_t)mbuf,
+				.cookie = (uint64_t)mbuf,
 			};
 
 			pp2_bpool_put_buff(hif, bpool, &binf);
@@ -2441,7 +2439,7 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 			rte_mbuf_prefetch_part2(pref_pkt_hdr);
 		}
 
-		sq->ent[sq->head].buff.cookie = (pp2_cookie_t)(uint64_t)mbuf;
+		sq->ent[sq->head].buff.cookie = (uint64_t)mbuf;
 		sq->ent[sq->head].buff.addr =
 			rte_mbuf_data_iova_default(mbuf);
 		sq->ent[sq->head].bpool =
drivers/net/mvpp2/mrvl_flow.c +2 -1
index 065b1aa..ffd1dab 100644
@@ -2437,7 +2437,8 @@ mrvl_create_cls_table(struct rte_eth_dev *dev, struct rte_flow *first_flow)
 
 	if (first_flow->pattern & F_IP4_TOS) {
 		key->proto_field[key->num_fields].proto = MV_NET_PROTO_IP4;
-		key->proto_field[key->num_fields].field.ipv4 = MV_NET_IP4_F_TOS;
+		key->proto_field[key->num_fields].field.ipv4 =
+							MV_NET_IP4_F_DSCP;
 		key->key_size += 1;
 		key->num_fields += 1;
 	}
drivers/net/mvpp2/mrvl_qos.c +1 -1
index 5d80c3e..7fd9703 100644
@@ -654,7 +654,7 @@ setup_tc(struct pp2_ppio_tc_params *param, uint8_t inqs,
 	struct pp2_ppio_inq_params *inq_params;
 
 	param->pkt_offset = MRVL_PKT_OFFS;
-	param->pools[0] = bpool;
+	param->pools[0][0] = bpool;
 	param->default_color = color;
 
 	inq_params = rte_zmalloc_socket("inq_params",
Signature · 1 line
2.7.4
#19 lore raw

PATCH v2 10/12 net/mvpp2: align documentation with MUSDK 18.09

In reply to Tomasz Duszynski

From: Natalie Samsonov <[email protected]>

Update documentation to align with MUSDK 18.09.

---
 doc/guides/nics/mvpp2.rst | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
doc/guides/nics/mvpp2.rst +12 -14
index a452c8a..3b3f8c6 100644
@@ -74,6 +74,7 @@ Features of the MVPP2 PMD are:
 - QoS
 - RX flow control
 - TX queue start/stop
+- Scattered TX frames
 
 
 Limitations
@@ -96,19 +97,19 @@ Prerequisites
 
   .. code-block:: console
 
-     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.52-armada-17.10
+     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.120-armada-18.09
 
 - Out of tree `mvpp2x_sysfs` kernel module sources
 
   .. code-block:: console
 
-     git clone https://github.com/MarvellEmbeddedProcessors/mvpp2x-marvell.git -b mvpp2x-armada-17.10
+     git clone https://github.com/MarvellEmbeddedProcessors/mvpp2x-marvell.git -b mvpp2x-armada-18.09
 
 - MUSDK (Marvell User-Space SDK) sources
 
   .. code-block:: console
 
-     git clone https://github.com/MarvellEmbeddedProcessors/musdk-marvell.git -b musdk-armada-17.10
+     git clone https://github.com/MarvellEmbeddedProcessors/musdk-marvell.git -b musdk-armada-18.09
 
   MUSDK is a light-weight library that provides direct access to Marvell's
   PPv2 (Packet Processor v2). Alternatively prebuilt MUSDK library can be
@@ -119,12 +120,6 @@ Prerequisites
   To get better understanding of the library one can consult documentation
   available in the ``doc`` top level directory of the MUSDK sources.
 
-  MUSDK must be configured with the following features:
-
-  .. code-block:: console
-
-     --enable-bpool-dma=64
-
 - DPDK environment
 
   Follow the DPDK :ref:`Getting Started Guide for Linux <linux_gsg>` to setup
@@ -140,6 +135,9 @@ The following options can be modified in the ``config`` file.
 
     Toggle compilation of the librte mvpp2 driver.
 
+    .. Note::
+
+       When MVPP2 PMD is enabled ``CONFIG_RTE_LIBRTE_MVNETA_PMD`` must be disabled
 
 QoS Configuration
 -----------------
@@ -314,7 +312,7 @@ Driver needs precompiled MUSDK library during compilation.
 
    export CROSS_COMPILE=<toolchain>/bin/aarch64-linux-gnu-
    ./bootstrap
-   ./configure --host=aarch64-linux-gnu --enable-bpool-dma=64
+   ./configure --host=aarch64-linux-gnu
    make install
 
 MUSDK will be installed to `usr/local` under current directory.
@@ -328,7 +326,8 @@ the path to the MUSDK installation directory needs to be exported.
    export LIBMUSDK_PATH=<musdk>/usr/local
    export CROSS=aarch64-linux-gnu-
    make config T=arm64-armv8a-linuxapp-gcc
-   sed -ri 's,(MVPP2_PMD=)n,\1y,' build/.config
+   sed -i "s/MVNETA_PMD=y/MVNETA_PMD=n/" build/.config
+   sed -i "s/MVPP2_PMD=n/MVPP2_PMD=y/" build/.config
    make
 
 Flow API
@@ -500,15 +499,14 @@ Usage Example
 -------------
 
 MVPP2 PMD requires extra out of tree kernel modules to function properly.
-`musdk_uio` and `mv_pp_uio` sources are part of the MUSDK. Please consult
+`musdk_cma` sources are part of the MUSDK. Please consult
 ``doc/musdk_get_started.txt`` for the detailed build instructions.
 For `mvpp2x_sysfs` please consult ``Documentation/pp22_sysfs.txt`` for the
 detailed build instructions.
 
 .. code-block:: console
 
-   insmod musdk_uio.ko
-   insmod mv_pp_uio.ko
+   insmod musdk_cma.ko
    insmod mvpp2x_sysfs.ko
 
 Additionally interfaces used by DPDK application need to be put up:
Signature · 1 line
2.7.4
#29 lore raw

PATCH v2 11/12 net/mvpp2: document MTR and TM usage

In reply to Tomasz Duszynski

From: Natalie Samsonov <[email protected]>

Document MTR (metering) and TM (traffic management) usage plus do some small updates here and there.

---
 doc/guides/nics/img/mvpp2_tm.png | Bin 0 -> 5355 bytes
 doc/guides/nics/mvpp2.rst        | 386 +++++++++++++++++++++++++++++++++------
 2 files changed, 335 insertions(+), 51 deletions(-)
 create mode 100644 doc/guides/nics/img/mvpp2_tm.png
doc/guides/nics/img/mvpp2_tm.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..3c709bab43950c39578a6726ab570008bc722e2f
GIT binary patch
doc/guides/nics/mvpp2.rst +335 -51

436 lines not on this page · raw message

Signature · 1 line
2.7.4
#31 lore raw

PATCH v2 12/12 net/mvpp2: add Tx S/G support

In reply to Tomasz Duszynski

From: Zyta Szpak <[email protected]>

The patch introduces scatter/gather support on transmit path. A separate Tx callback is added and set if the application requests multisegment Tx offload. Multiple descriptors are sent per one packet.

---
 drivers/net/mvpp2/mrvl_ethdev.c | 231 ++++++++++++++++++++++++++++++++++++----
 drivers/net/mvpp2/mrvl_ethdev.h |   1 +
 2 files changed, 212 insertions(+), 20 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +211 -20
index 899a9e4..56b190e 100644
@@ -65,7 +65,8 @@
 /** Port Tx offloads capabilities */
 #define MRVL_TX_OFFLOADS (DEV_TX_OFFLOAD_IPV4_CKSUM | \
 			  DEV_TX_OFFLOAD_UDP_CKSUM | \
-			  DEV_TX_OFFLOAD_TCP_CKSUM)
+			  DEV_TX_OFFLOAD_TCP_CKSUM | \
+			  DEV_TX_OFFLOAD_MULTI_SEGS)
 
 static const char * const valid_args[] = {
 	MRVL_IFACE_NAME_ARG,
@@ -105,7 +106,9 @@ struct mrvl_shadow_txq {
 	int head;           /* write index - used when sending buffers */
 	int tail;           /* read index - used when releasing buffers */
 	u16 size;           /* queue occupied size */
-	u16 num_to_release; /* number of buffers sent, that can be released */
+	u16 num_to_release; /* number of descriptors sent, that can be
+			     * released
+			     */
 	struct buff_release_entry ent[MRVL_PP2_TX_SHADOWQ_SIZE]; /* q entries */
 };
 
@@ -137,6 +140,12 @@ static inline void mrvl_free_sent_buffers(struct pp2_ppio *ppio,
 			struct pp2_hif *hif, unsigned int core_id,
 			struct mrvl_shadow_txq *sq, int qid, int force);
 
+static uint16_t mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts);
+static uint16_t mrvl_tx_sg_pkt_burst(void *txq,	struct rte_mbuf **tx_pkts,
+				     uint16_t nb_pkts);
+
+
 #define MRVL_XSTATS_TBL_ENTRY(name) { \
 	#name, offsetof(struct pp2_ppio_statistics, name),	\
 	sizeof(((struct pp2_ppio_statistics *)0)->name)		\
@@ -163,6 +172,31 @@ static struct {
 	MRVL_XSTATS_TBL_ENTRY(tx_errors)
 };
 
+static inline void
+mrvl_fill_shadowq(struct mrvl_shadow_txq *sq, struct rte_mbuf *buf)
+{
+	sq->ent[sq->head].buff.cookie = (uint64_t)buf;
+	sq->ent[sq->head].buff.addr = buf ?
+		rte_mbuf_data_iova_default(buf) : 0;
+
+	sq->ent[sq->head].bpool =
+		(unlikely(!buf || buf->port >= RTE_MAX_ETHPORTS ||
+		 buf->refcnt > 1)) ? NULL :
+		 mrvl_port_to_bpool_lookup[buf->port];
+
+	sq->head = (sq->head + 1) & MRVL_PP2_TX_SHADOWQ_MASK;
+	sq->size++;
+}
+
+static inline void
+mrvl_fill_desc(struct pp2_ppio_desc *desc, struct rte_mbuf *buf)
+{
+	pp2_ppio_outq_desc_reset(desc);
+	pp2_ppio_outq_desc_set_phys_addr(desc, rte_pktmbuf_iova(buf));
+	pp2_ppio_outq_desc_set_pkt_offset(desc, 0);
+	pp2_ppio_outq_desc_set_pkt_len(desc, rte_pktmbuf_data_len(buf));
+}
+
 static inline int
 mrvl_get_bpool_size(int pp2_id, int pool_id)
 {
@@ -242,6 +276,27 @@ mrvl_get_hif(struct mrvl_priv *priv, int core_id)
 }
 
 /**
+ * Set tx burst function according to offload flag
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ */
+static void
+mrvl_set_tx_function(struct rte_eth_dev *dev)
+{
+	struct mrvl_priv *priv = dev->data->dev_private;
+
+	/* Use a simple Tx queue (no offloads, no multi segs) if possible */
+	if (priv->multiseg) {
+		RTE_LOG(INFO, PMD, "Using multi-segment tx callback\n");
+		dev->tx_pkt_burst = mrvl_tx_sg_pkt_burst;
+	} else {
+		RTE_LOG(INFO, PMD, "Using single-segment tx callback\n");
+		dev->tx_pkt_burst = mrvl_tx_pkt_burst;
+	}
+}
+
+/**
  * Configure rss based on dpdk rss configuration.
  *
  * @param priv
@@ -325,6 +380,9 @@ mrvl_dev_configure(struct rte_eth_dev *dev)
 		dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
 				 MRVL_PP2_ETH_HDRS_LEN;
 
+	if (dev->data->dev_conf.txmode.offloads & DEV_TX_OFFLOAD_MULTI_SEGS)
+		priv->multiseg = 1;
+
 	ret = mrvl_configure_rxqs(priv, dev->data->port_id,
 				  dev->data->nb_rx_queues);
 	if (ret < 0)
@@ -672,6 +730,7 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 
 	mrvl_flow_init(dev);
 	mrvl_mtr_init(dev);
+	mrvl_set_tx_function(dev);
 
 	return 0;
 out:
@@ -2439,22 +2498,8 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 			rte_mbuf_prefetch_part2(pref_pkt_hdr);
 		}
 
-		sq->ent[sq->head].buff.cookie = (uint64_t)mbuf;
-		sq->ent[sq->head].buff.addr =
-			rte_mbuf_data_iova_default(mbuf);
-		sq->ent[sq->head].bpool =
-			(unlikely(mbuf->port >= RTE_MAX_ETHPORTS ||
-			 mbuf->refcnt > 1)) ? NULL :
-			 mrvl_port_to_bpool_lookup[mbuf->port];
-		sq->head = (sq->head + 1) & MRVL_PP2_TX_SHADOWQ_MASK;
-		sq->size++;
-
-		pp2_ppio_outq_desc_reset(&descs[i]);
-		pp2_ppio_outq_desc_set_phys_addr(&descs[i],
-						 rte_pktmbuf_iova(mbuf));
-		pp2_ppio_outq_desc_set_pkt_offset(&descs[i], 0);
-		pp2_ppio_outq_desc_set_pkt_len(&descs[i],
-					       rte_pktmbuf_pkt_len(mbuf));
+		mrvl_fill_shadowq(sq, mbuf);
+		mrvl_fill_desc(&descs[i], mbuf);
 
 		bytes_sent += rte_pktmbuf_pkt_len(mbuf);
 		/*
@@ -2492,6 +2537,152 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	return nb_pkts;
 }
 
+/** DPDK callback for S/G transmit.
+ *
+ * @param txq
+ *   Generic pointer transmit queue.
+ * @param tx_pkts
+ *   Packets to transmit.
+ * @param nb_pkts
+ *   Number of packets in array.
+ *
+ * @return
+ *   Number of packets successfully transmitted.
+ */
+static uint16_t
+mrvl_tx_sg_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,
+		     uint16_t nb_pkts)
+{
+	struct mrvl_txq *q = txq;
+	struct mrvl_shadow_txq *sq;
+	struct pp2_hif *hif;
+	struct pp2_ppio_desc descs[nb_pkts * PP2_PPIO_DESC_NUM_FRAGS];
+	struct pp2_ppio_sg_pkts pkts;
+	uint8_t frags[nb_pkts];
+	unsigned int core_id = rte_lcore_id();
+	int i, j, ret, bytes_sent = 0;
+	int tail, tail_first;
+	uint16_t num, sq_free_size;
+	uint16_t nb_segs, total_descs = 0;
+	uint64_t addr;
+
+	hif = mrvl_get_hif(q->priv, core_id);
+	sq = &q->shadow_txqs[core_id];
+	pkts.frags = frags;
+	pkts.num = 0;
+
+	if (unlikely(!q->priv->ppio || !hif))
+		return 0;
+
+	if (sq->size)
+		mrvl_free_sent_buffers(q->priv->ppio, hif, core_id,
+				       sq, q->queue_id, 0);
+
+	/* Save shadow queue free size */
+	sq_free_size = MRVL_PP2_TX_SHADOWQ_SIZE - sq->size - 1;
+
+	tail = 0;
+	for (i = 0; i < nb_pkts; i++) {
+		struct rte_mbuf *mbuf = tx_pkts[i];
+		struct rte_mbuf *seg = NULL;
+		int gen_l3_cksum, gen_l4_cksum;
+		enum pp2_outq_l3_type l3_type;
+		enum pp2_outq_l4_type l4_type;
+
+		nb_segs = mbuf->nb_segs;
+		tail_first = tail;
+		total_descs += nb_segs;
+
+		/*
+		 * Check if total_descs does not exceed
+		 * shadow queue free size
+		 */
+		if (unlikely(total_descs > sq_free_size)) {
+			total_descs -= nb_segs;
+			RTE_LOG(DEBUG, PMD,
+				"No room in shadow queue for %d packets! "
+				"%d packets will be sent.\n",
+				nb_pkts, i);
+			break;
+		}
+
+		/* Check if nb_segs does not exceed the max nb of desc per
+		 * fragmented packet
+		 */
+		if (nb_segs > PP2_PPIO_DESC_NUM_FRAGS) {
+			total_descs -= nb_segs;
+			RTE_LOG(ERR, PMD,
+				"Too many segments. Packet won't be sent.\n");
+			break;
+		}
+
+		if (likely(nb_pkts - i > MRVL_MUSDK_PREFETCH_SHIFT)) {
+			struct rte_mbuf *pref_pkt_hdr;
+
+			pref_pkt_hdr = tx_pkts[i + MRVL_MUSDK_PREFETCH_SHIFT];
+			rte_mbuf_prefetch_part1(pref_pkt_hdr);
+			rte_mbuf_prefetch_part2(pref_pkt_hdr);
+		}
+
+		pkts.frags[pkts.num] = nb_segs;
+		pkts.num++;
+
+		seg = mbuf;
+		for (j = 0; j < nb_segs - 1; j++) {
+			/* For the subsequent segments, set shadow queue
+			 * buffer to NULL
+			 */
+			mrvl_fill_shadowq(sq, NULL);
+			mrvl_fill_desc(&descs[tail], seg);
+
+			tail++;
+			seg = seg->next;
+		}
+		/* Put first mbuf info in last shadow queue entry */
+		mrvl_fill_shadowq(sq, mbuf);
+		/* Update descriptor with last segment */
+		mrvl_fill_desc(&descs[tail++], seg);
+
+		bytes_sent += rte_pktmbuf_pkt_len(mbuf);
+		/* In case unsupported ol_flags were passed
+		 * do not update descriptor offload information
+		 */
+		ret = mrvl_prepare_proto_info(mbuf->ol_flags, mbuf->packet_type,
+					      &l3_type, &l4_type, &gen_l3_cksum,
+					      &gen_l4_cksum);
+		if (unlikely(ret))
+			continue;
+
+		pp2_ppio_outq_desc_set_proto_info(&descs[tail_first], l3_type,
+						  l4_type, mbuf->l2_len,
+						  mbuf->l2_len + mbuf->l3_len,
+						  gen_l3_cksum, gen_l4_cksum);
+	}
+
+	num = total_descs;
+	pp2_ppio_send_sg(q->priv->ppio, hif, q->queue_id, descs,
+			 &total_descs, &pkts);
+	/* number of packets that were not sent */
+	if (unlikely(num > total_descs)) {
+		for (i = total_descs; i < num; i++) {
+			sq->head = (MRVL_PP2_TX_SHADOWQ_SIZE + sq->head - 1) &
+				MRVL_PP2_TX_SHADOWQ_MASK;
+
+			addr = sq->ent[sq->head].buff.cookie;
+			if (addr)
+				bytes_sent -=
+					rte_pktmbuf_pkt_len((struct rte_mbuf *)
+						(cookie_addr_high | addr));
+		}
+		sq->size -= num - total_descs;
+		nb_pkts = pkts.num;
+	}
+
+	q->bytes_sent += bytes_sent;
+
+	return nb_pkts;
+}
+
 /**
  * Initialize packet processor.
  *
@@ -2620,11 +2811,11 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name)
 	memcpy(eth_dev->data->mac_addrs[0].addr_bytes,
 	       req.ifr_addr.sa_data, ETHER_ADDR_LEN);
 
-	eth_dev->rx_pkt_burst = mrvl_rx_pkt_burst;
-	eth_dev->tx_pkt_burst = mrvl_tx_pkt_burst;
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
 	eth_dev->data->dev_private = priv;
 	eth_dev->device = &vdev->device;
+	eth_dev->rx_pkt_burst = mrvl_rx_pkt_burst;
+	mrvl_set_tx_function(eth_dev);
 	eth_dev->dev_ops = &mrvl_ops;
 
 	rte_eth_dev_probing_finish(eth_dev);
drivers/net/mvpp2/mrvl_ethdev.h +1 -0
index f0ae983..0120b9e 100644
@@ -188,6 +188,7 @@ struct mrvl_priv {
 	uint8_t uc_mc_flushed;
 	uint8_t vlan_flushed;
 	uint8_t isolated;
+	uint8_t multiseg;
 
 	struct pp2_ppio_params ppio_params;
 	struct pp2_cls_qos_tbl_params qos_tbl_params;
Signature · 1 line
2.7.4
#20 lore raw

Re: [PATCH v2 10/12] net/mvpp2: align documentation with MUSDK 18.09

In reply to Tomasz Duszynski
Quoted 22 lines · Tomasz Duszynski

From: Natalie Samsonov <[email protected]>

Update documentation to align with MUSDK 18.09.

---
 doc/guides/nics/mvpp2.rst | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
doc/guides/nics/mvpp2.rst +1 -0
index a452c8a..3b3f8c6 100644
@@ -74,6 +74,7 @@ Features of the MVPP2 PMD are:
 - QoS
 - RX flow control
 - TX queue start/stop
+- Scattered TX frames
 
 
 Limitations

doc/guides/nics/mvpp2.rst Prerequisites · line 100

Quoted 5 lines
doc/guides/nics/mvpp2.rst +1 -1
@@ -96,19 +97,19 @@ Prerequisites
 
   .. code-block:: console
 
-     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.52-armada-17.10
+     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.120-armada-18.09

There is a strict dependency to MUSDK 18.09, dpdk18.11 won't compile with older versions. It is hard to trace this dependency, what do you think having a matrix in DPDK documentation showing which DPDK version supports which MUSDK?

#32 lore raw
In reply to Tomasz Duszynski
Quoted 23 lines · Tomasz Duszynski

This patch series introduces fixes and adds support for traffic metering, traffic manager and Tx S/G. Additionally it aligns with for MUSDK 18.09.

Changes since v2:
* Align with MUSDK 18.09 library
* Add support for Tx Gather.
* Add documentation related to MTR and TM.
* Align documentation with MUSDK 18.09

Natalie Samsonov (4):
net/mvpp2: initialize ppio only once net/mvpp2: update MTU and MRU related calculations net/mvpp2: align documentation with MUSDK 18.09 net/mvpp2: document MTR and TM usage

Tomasz Duszynski (6):
net/mvpp2: move common code
net/mvpp2: add metering support
net/mvpp2: change default policer configuration
net/mvpp2: add init and deinit to flow
net/mvpp2: add traffic manager support
net/mvpp2: align with MUSDK 18.09

Quoted 5 lines

Yuval Caduri (1):
net/mvpp2: detach tx_qos from rx cls/qos config

Zyta Szpak (1):
net/mvpp2: add Tx S/G support

Series applied to dpdk-next-net/master, thanks.

#21 lore raw

Re: [PATCH v2 10/12] net/mvpp2: align documentation with MUSDK 18.09

In reply to Ferruh Yigit

19/09/2018 19:15, Ferruh Yigit:

Quoted 10 lines · Tomasz Duszynski

doc/guides/nics/mvpp2.rst Prerequisites · line 100

Quoted 5 lines

From: Natalie Samsonov <[email protected]>

doc/guides/nics/mvpp2.rst +1 -1
-     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.52-armada-17.10
+     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.120-armada-18.09

There is a strict dependency to MUSDK 18.09, dpdk18.11 won't compile with older versions. It is hard to trace this dependency, what do you think having a matrix in DPDK documentation showing which DPDK version supports which MUSDK?

It does not compile even with MUSDK 18.09.

With MUSDK 18.09, the error is:

	drivers/crypto/mvsam/rte_mrvl_pmd.c:867:26: error: 'SAM_HW_RING_NUM' undeclared

The explanation is in MUSDK:
commit 9bf8b3ca4ddfa00619c0023dfb08ae1601054fce

Author: Dmitri Epshtein <[email protected]>
Date:   Mon Nov 20 10:38:31 2017 +0200

sam: remove SAM_HW_RING_NUM from APIs

Use function:
u32 sam_get_num_cios(u32 inst);

As a consequence, next-net cannot be pulled!

#30 lore raw

Re: [PATCH v2 11/12] net/mvpp2: document MTR and TM usage

In reply to Tomasz Duszynski

04/09/2018 15:49, Tomasz Duszynski:

doc/guides/nics/img/mvpp2_tm.png

Quoted 14 lines

From: Natalie Samsonov <[email protected]>

Document MTR (metering) and TM (traffic management) usage plus do some small updates here and there.

---
 doc/guides/nics/img/mvpp2_tm.png | Bin 0 -> 5355 bytes
 doc/guides/nics/mvpp2.rst        | 386 +++++++++++++++++++++++++++++++++------
 2 files changed, 335 insertions(+), 51 deletions(-)
 create mode 100644 doc/guides/nics/img/mvpp2_tm.png
doc/guides/nics/img/mvpp2_tm.png new file +0 -0
new file mode 100644

Sorry, it is forbidden to add new binary file.
As an Open Source project, everything must be open including the source of the figures. Please could you provide a SVG version?

#22 lore raw

Re: [PATCH v2 10/12] net/mvpp2: align documentation with MUSDK 18.09

In reply to Thomas Monjalon
Quoted 12 lines · Thomas Monjalon

19/09/2018 19:15, Ferruh Yigit:

Quoted 10 lines · Tomasz Duszynski

doc/guides/nics/mvpp2.rst Prerequisites · line 100

Quoted 5 lines

From: Natalie Samsonov <[email protected]>

doc/guides/nics/mvpp2.rst +1 -1
-     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.52-armada-17.10
+     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.120-armada-18.09

There is a strict dependency to MUSDK 18.09, dpdk18.11 won't compile with older versions. It is hard to trace this dependency, what do you think having a matrix in DPDK documentation showing which DPDK version supports which MUSDK?

Quoted 4 lines

It does not compile even with MUSDK 18.09.

With MUSDK 18.09, the error is:

	drivers/crypto/mvsam/rte_mrvl_pmd.c:867:26: error: 'SAM_HW_RING_NUM' undeclared

I confirm same error. I wasn't building with crypto PMD enabled so not caught it.

Quoted 6 lines

The explanation is in MUSDK:
commit 9bf8b3ca4ddfa00619c0023dfb08ae1601054fce

Author: Dmitri Epshtein <[email protected]>
Date:   Mon Nov 20 10:38:31 2017 +0200
Quoted 6 lines

sam: remove SAM_HW_RING_NUM from APIs

Use function:
u32 sam_get_num_cios(u32 inst);

As a consequence, next-net cannot be pulled!

Got it, should I drop the patchset from tree?

#23 lore raw

Re: [PATCH v2 10/12] net/mvpp2: align documentation with MUSDK 18.09

Hi Ferruh,

pon., 24 wrz 2018 o 13:38 Ferruh Yigit <[email protected]> napisał(a):

Quoted 27 lines · Thomas Monjalon
Quoted 12 lines

19/09/2018 19:15, Ferruh Yigit:

Quoted 10 lines · Tomasz Duszynski

doc/guides/nics/mvpp2.rst Prerequisites · line 100

Quoted 5 lines

From: Natalie Samsonov <[email protected]>

doc/guides/nics/mvpp2.rst +1 -1
-     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.52-armada-17.10
+     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.120-armada-18.09

There is a strict dependency to MUSDK 18.09, dpdk18.11 won't compile with older versions. It is hard to trace this dependency, what do you think having a matrix in DPDK documentation showing which DPDK version supports which MUSDK?

Quoted 4 lines

It does not compile even with MUSDK 18.09.

With MUSDK 18.09, the error is:

      drivers/crypto/mvsam/rte_mrvl_pmd.c:867:26: error: 'SAM_HW_RING_NUM' undeclared

I confirm same error. I wasn't building with crypto PMD enabled so not caught it.

Quoted 6 lines

The explanation is in MUSDK:
commit 9bf8b3ca4ddfa00619c0023dfb08ae1601054fce

Author: Dmitri Epshtein <[email protected]>
Date:   Mon Nov 20 10:38:31 2017 +0200
Quoted 8 lines
Quoted 6 lines

sam: remove SAM_HW_RING_NUM from APIs

Use function:
u32 sam_get_num_cios(u32 inst);

As a consequence, next-net cannot be pulled!

Got it, should I drop the patchset from tree?

We're checking the error and will provide fix asap. Please let know if this should be another version of the entire patchset or fix on top. Sorry for the problems.

Best regards,
Marcin

#24 lore raw

Re: [PATCH v2 10/12] net/mvpp2: align documentation with MUSDK 18.09

Quoted 35 lines · Marcin Wojtas

Hi Ferruh,

pon., 24 wrz 2018 o 13:38 Ferruh Yigit <[email protected]> napisał(a):

Quoted 32 lines · Thomas Monjalon
Quoted 12 lines

19/09/2018 19:15, Ferruh Yigit:

Quoted 10 lines · Tomasz Duszynski

doc/guides/nics/mvpp2.rst Prerequisites · line 100

Quoted 5 lines

From: Natalie Samsonov <[email protected]>

doc/guides/nics/mvpp2.rst +1 -1
-     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.52-armada-17.10
+     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.120-armada-18.09

There is a strict dependency to MUSDK 18.09, dpdk18.11 won't compile with older versions. It is hard to trace this dependency, what do you think having a matrix in DPDK documentation showing which DPDK version supports which MUSDK?

Quoted 4 lines

It does not compile even with MUSDK 18.09.

With MUSDK 18.09, the error is:

      drivers/crypto/mvsam/rte_mrvl_pmd.c:867:26: error: 'SAM_HW_RING_NUM' undeclared

I confirm same error. I wasn't building with crypto PMD enabled so not caught it.

Quoted 11 lines

The explanation is in MUSDK:
commit 9bf8b3ca4ddfa00619c0023dfb08ae1601054fce

Author: Dmitri Epshtein <[email protected]>
Date:   Mon Nov 20 10:38:31 2017 +0200

sam: remove SAM_HW_RING_NUM from APIs

Use function:
u32 sam_get_num_cios(u32 inst);

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

As a consequence, next-net cannot be pulled!

Got it, should I drop the patchset from tree?

We're checking the error and will provide fix asap. Please let know if this should be another version of the entire patchset or fix on top.

There is another comment from Thomas (mvpp2_tm.png).

Both "fix on top" and "new version" is OK for me, pick whichever easy for you. For "fix on top", I will squash fixes to original commits, so fixes should be separate patches with a information which commit it targets.

But overall build should not be broken, it should be clear in which commit dependency changed to 18.09. Let call the commit that switch happens X, all commits before X should compile successfully with 17.10, commit X and all following commits should be compile successfully with 18.09.

Quoted 5 lines

Sorry for the problems.

Best regards,
Marcin

#25 lore raw

Re: [PATCH v2 10/12] net/mvpp2: align documentation with MUSDK 18.09

In reply to Ferruh Yigit

24/09/2018 13:36, Ferruh Yigit:

Quoted 4 lines · Thomas Monjalon
Quoted 1 line

As a consequence, next-net cannot be pulled!

Got it, should I drop the patchset from tree?

Yes I think it's better to re-consider this patchset later.

#26 lore raw

Re: [PATCH v2 10/12] net/mvpp2: align documentation with MUSDK 18.09

pon., 24 wrz 2018 o 14:44 Thomas Monjalon <[email protected]> napisał(a):

Quoted 10 lines

24/09/2018 13:36, Ferruh Yigit:

Quoted 4 lines · Thomas Monjalon
Quoted 1 line

As a consequence, next-net cannot be pulled!

Got it, should I drop the patchset from tree?

Yes I think it's better to re-consider this patchset later.

Ok, complete, new version of it will be re-sent to the lists.

Best regards,
Marcin

#27 lore raw

Re: [PATCH v2 10/12] net/mvpp2: align documentation with MUSDK 18.09

Quoted 6 lines · Marcin Wojtas

pon., 24 wrz 2018 o 14:44 Thomas Monjalon <[email protected]> napisał(a):

Quoted 5 lines

24/09/2018 13:36, Ferruh Yigit:

Quoted 3 lines · Thomas Monjalon
Quoted 1 line

As a consequence, next-net cannot be pulled!

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Got it, should I drop the patchset from tree?

Yes I think it's better to re-consider this patchset later.

Ok, complete, new version of it will be re-sent to the lists.

OK, patch will be dropped from the next-net for now.

Quoted 4 lines

Best regards,
Marcin

#28 lore raw

Re: [PATCH v2 10/12] net/mvpp2: align documentation with MUSDK 18.09

Quoted 9 lines · Ferruh Yigit
Quoted 8 lines · Marcin Wojtas

pon., 24 wrz 2018 o 14:44 Thomas Monjalon <[email protected]> napisał(a):

Quoted 7 lines

24/09/2018 13:36, Ferruh Yigit:

Quoted 4 lines · Thomas Monjalon
Quoted 1 line

As a consequence, next-net cannot be pulled!

Got it, should I drop the patchset from tree?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Yes I think it's better to re-consider this patchset later.

Ok, complete, new version of it will be re-sent to the lists.

OK, patch will be dropped from the next-net for now.

I will provide the new patchset shortly with following patch:
http://patches.dpdk.org/patch/44255/
already "squashed"/applied. This is the patch for updating mvsam to MUSDK 18.09 which solves the problem you experience but I guess it goes to next-crypto. That way I hope there would be no problem with merging next-crypto and next-net will be able to compile.

Best regards
Andrzej

#33 lore raw

v3 cover net/mvpp2: add new features

In reply to Tomasz Duszynski

This patch series introduces fixes and adds support for traffic metering, traffic manager and Tx S/G. Additionally it aligns with for MUSDK 18.09.

Changes in v3:
* change the format of image referred in doc (png -> svg)
* "cherry-pick" http://patches.dpdk.org/patch/44255/ to be part of this patch set so that next-net can compile with new MUSDK also when mvsam is enabled

Changes since v2:
* Align with MUSDK 18.09 library
* Add support for Tx Gather.
* Add documentation related to MTR and TM.
* Align documentation with MUSDK 18.09

Dmitri Epshtein (1):
crypto/mvsam: get number of CIOs dynamically

Natalie Samsonov (4):
net/mvpp2: initialize ppio only once net/mvpp2: update MTU and MRU related calculations net/mvpp2: align documentation with MUSDK 18.09 net/mvpp2: document MTR and TM usage

Tomasz Duszynski (6):
net/mvpp2: move common code
net/mvpp2: add metering support
net/mvpp2: change default policer configuration
net/mvpp2: add init and deinit to flow
net/mvpp2: add traffic manager support
net/mvpp2: align with MUSDK 18.09

Yuval Caduri (1):
net/mvpp2: detach Tx QoS from Rx cls/QoS config

Zyta Szpak (1):
net/mvpp2: add Tx scatter/gather support

 doc/guides/nics/img/mvpp2_tm.svg    |   71 +++
 doc/guides/nics/mvpp2.rst           |  433 ++++++++++++---
 drivers/crypto/mvsam/rte_mrvl_pmd.c |    2 +-
 drivers/net/mvpp2/Makefile          |    2 +
 drivers/net/mvpp2/meson.build       |    4 +-
 drivers/net/mvpp2/mrvl_ethdev.c     |  427 ++++++++++++---
 drivers/net/mvpp2/mrvl_ethdev.h     |  123 ++++-
 drivers/net/mvpp2/mrvl_flow.c       |  132 +++--
 drivers/net/mvpp2/mrvl_flow.h       |   15 +
 drivers/net/mvpp2/mrvl_mtr.c        |  512 ++++++++++++++++++
 drivers/net/mvpp2/mrvl_mtr.h        |   15 +
 drivers/net/mvpp2/mrvl_qos.c        |  246 +++++----
 drivers/net/mvpp2/mrvl_qos.h        |    2 +-
 drivers/net/mvpp2/mrvl_tm.c         | 1009 +++++++++++++++++++++++++++++++++++
 drivers/net/mvpp2/mrvl_tm.h         |   15 +
 15 files changed, 2696 insertions(+), 312 deletions(-)
 create mode 100644 doc/guides/nics/img/mvpp2_tm.svg
 create mode 100644 drivers/net/mvpp2/mrvl_flow.h
 create mode 100644 drivers/net/mvpp2/mrvl_mtr.c
 create mode 100644 drivers/net/mvpp2/mrvl_mtr.h
 create mode 100644 drivers/net/mvpp2/mrvl_tm.c
 create mode 100644 drivers/net/mvpp2/mrvl_tm.h
Signature · 1 line
2.7.4
#34 lore raw

PATCH v3 1/13 net/mvpp2: initialize ppio only once

From: Natalie Samsonov <[email protected]>

This changes stop/start/configure behavior due to issue in MUSDK library itself. From now on, ppio can be reconfigured only after interface is closed.

---
 drivers/net/mvpp2/mrvl_ethdev.c | 53 +++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 21 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +32 -21
index fa4af49..dca3ccc 100644
@@ -303,6 +303,11 @@ mrvl_dev_configure(struct rte_eth_dev *dev)
 	struct mrvl_priv *priv = dev->data->dev_private;
 	int ret;
 
+	if (priv->ppio) {
+		MRVL_LOG(INFO, "Device reconfiguration is not supported");
+		return -EINVAL;
+	}
+
 	if (dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_NONE &&
 	    dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_RSS) {
 		MRVL_LOG(INFO, "Unsupported rx multi queue mode %d",
@@ -516,6 +521,9 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 	char match[MRVL_MATCH_LEN];
 	int ret = 0, i, def_init_size;
 
+	if (priv->ppio)
+		return mrvl_dev_set_link_up(dev);
+
 	snprintf(match, sizeof(match), "ppio-%d:%d",
 		 priv->pp_id, priv->ppio_id);
 	priv->ppio_params.match = match;
@@ -740,28 +748,7 @@ mrvl_flush_bpool(struct rte_eth_dev *dev)
 static void
 mrvl_dev_stop(struct rte_eth_dev *dev)
 {
-	struct mrvl_priv *priv = dev->data->dev_private;
-
 	mrvl_dev_set_link_down(dev);
-	mrvl_flush_rx_queues(dev);
-	mrvl_flush_tx_shadow_queues(dev);
-	if (priv->cls_tbl) {
-		pp2_cls_tbl_deinit(priv->cls_tbl);
-		priv->cls_tbl = NULL;
-	}
-	if (priv->qos_tbl) {
-		pp2_cls_qos_tbl_deinit(priv->qos_tbl);
-		priv->qos_tbl = NULL;
-	}
-	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;
-	}
 }
 
 /**
@@ -776,6 +763,9 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 	struct mrvl_priv *priv = dev->data->dev_private;
 	size_t i;
 
+	mrvl_flush_rx_queues(dev);
+	mrvl_flush_tx_shadow_queues(dev);
+
 	for (i = 0; i < priv->ppio_params.inqs_params.num_tcs; ++i) {
 		struct pp2_ppio_tc_params *tc_params =
 			&priv->ppio_params.inqs_params.tcs_params[i];
@@ -786,7 +776,28 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 		}
 	}
 
+	if (priv->cls_tbl) {
+		pp2_cls_tbl_deinit(priv->cls_tbl);
+		priv->cls_tbl = NULL;
+	}
+
+	if (priv->qos_tbl) {
+		pp2_cls_qos_tbl_deinit(priv->qos_tbl);
+		priv->qos_tbl = NULL;
+	}
+
 	mrvl_flush_bpool(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;
+	}
 }
 
 /**
Signature · 1 line
2.7.4
#35 lore raw

PATCH v3 2/13 net/mvpp2: move common code

In reply to Andrzej Ostruszka

From: Tomasz Duszynski <[email protected]>

Cleanup sources by moving common code to the pmd
header file.

---
 drivers/net/mvpp2/mrvl_ethdev.c |  9 ---------
 drivers/net/mvpp2/mrvl_ethdev.h | 11 +++++++++++
 drivers/net/mvpp2/mrvl_flow.c   |  5 -----
 drivers/net/mvpp2/mrvl_qos.c    |  9 ---------
 4 files changed, 11 insertions(+), 23 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +0 -9
index dca3ccc..c8c8548 100644
@@ -10,15 +10,6 @@
 #include <rte_malloc.h>
 #include <rte_bus_vdev.h>
 
-/* Unluckily, container_of is defined by both DPDK and MUSDK,
- * we'll declare only one version.
- *
- * Note that it is not used in this PMD anyway.
- */
-#ifdef container_of
-#undef container_of
-#endif
-
 #include <fcntl.h>
 #include <linux/ethtool.h>
 #include <linux/sockios.h>
drivers/net/mvpp2/mrvl_ethdev.h +11 -0
index 3726f78..2204be2 100644
@@ -10,12 +10,23 @@
 #include <rte_spinlock.h>
 #include <rte_flow_driver.h>
 
+/*
+ * container_of is defined by both DPDK and MUSDK,
+ * we'll declare only one version.
+ *
+ * Note that it is not used in this PMD anyway.
+ */
+#ifdef container_of
+#undef container_of
+#endif
+
 #include <env/mv_autogen_comp_flags.h>
 #include <drivers/mv_pp2.h>
 #include <drivers/mv_pp2_bpool.h>
 #include <drivers/mv_pp2_cls.h>
 #include <drivers/mv_pp2_hif.h>
 #include <drivers/mv_pp2_ppio.h>
+#include "env/mv_common.h" /* for BIT() */
 
 /** Maximum number of rx queues per port */
 #define MRVL_PP2_RXQ_MAX 32
drivers/net/mvpp2/mrvl_flow.c +0 -5
index 13295e6..db750f4 100644
@@ -11,13 +11,8 @@
 
 #include <arpa/inet.h>
 
-#ifdef container_of
-#undef container_of
-#endif
-
 #include "mrvl_ethdev.h"
 #include "mrvl_qos.h"
-#include "env/mv_common.h" /* for BIT() */
 
 /** Number of rules in the classifier table. */
 #define MRVL_CLS_MAX_NUM_RULES 20
drivers/net/mvpp2/mrvl_qos.c +0 -9
index 71856c1..eeb46f8 100644
@@ -15,15 +15,6 @@
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
-/* Unluckily, container_of is defined by both DPDK and MUSDK,
- * we'll declare only one version.
- *
- * Note that it is not used in this PMD anyway.
- */
-#ifdef container_of
-#undef container_of
-#endif
-
 #include "mrvl_qos.h"
 
 /* Parsing tokens. Defined conveniently, so that any correction is easy. */
Signature · 1 line
2.7.4
#36 lore raw

PATCH v3 3/13 net/mvpp2: add metering support

In reply to Andrzej Ostruszka

From: Tomasz Duszynski <[email protected]>

Add support for configuring plcr via DPDK generic metering API.

---
 drivers/net/mvpp2/Makefile      |   1 +
 drivers/net/mvpp2/meson.build   |   3 +-
 drivers/net/mvpp2/mrvl_ethdev.c |  24 ++
 drivers/net/mvpp2/mrvl_ethdev.h |  71 ++++++
 drivers/net/mvpp2/mrvl_flow.c   |  91 +++----
 drivers/net/mvpp2/mrvl_mtr.c    | 512 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/mvpp2/mrvl_mtr.h    |  15 ++
 7 files changed, 673 insertions(+), 44 deletions(-)
 create mode 100644 drivers/net/mvpp2/mrvl_mtr.c
 create mode 100644 drivers/net/mvpp2/mrvl_mtr.h
drivers/net/mvpp2/Makefile +1 -0
index 211d398..4848d65 100644
@@ -39,5 +39,6 @@ LDLIBS += -lrte_bus_vdev -lrte_common_mvep
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_qos.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_flow.c
+SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_mtr.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/mvpp2/meson.build +2 -1
index 3620659..f475511 100644
@@ -19,7 +19,8 @@ endif
 sources = files(
 	'mrvl_ethdev.c',
 	'mrvl_flow.c',
-	'mrvl_qos.c'
+	'mrvl_qos.c',
+	'mrvl_mtr.c'
 )
 
 deps += ['cfgfile', 'common_mvep']
drivers/net/mvpp2/mrvl_ethdev.c +24 -0
index c8c8548..a6cc550 100644
@@ -23,6 +23,7 @@
 #include <rte_mvep_common.h>
 #include "mrvl_ethdev.h"
 #include "mrvl_qos.h"
+#include "mrvl_mtr.h"
 
 /* bitmask with reserved hifs */
 #define MRVL_MUSDK_HIFS_RESERVED 0x0F
@@ -618,6 +619,8 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 			goto out;
 	}
 
+	mrvl_mtr_init(dev);
+
 	return 0;
 out:
 	MRVL_LOG(ERR, "Failed to start device");
@@ -756,6 +759,7 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 
 	mrvl_flush_rx_queues(dev);
 	mrvl_flush_tx_shadow_queues(dev);
+	mrvl_mtr_deinit(dev);
 
 	for (i = 0; i < priv->ppio_params.inqs_params.num_tcs; ++i) {
 		struct pp2_ppio_tc_params *tc_params =
@@ -1858,6 +1862,25 @@ mrvl_eth_filter_ctrl(struct rte_eth_dev *dev __rte_unused,
 	}
 }
 
+/**
+ * DPDK callback to get rte_mtr callbacks.
+ *
+ * @param dev
+ *   Pointer to the device structure.
+ * @param ops
+ *   Pointer to pass the mtr ops.
+ *
+ * @return
+ *   Always 0.
+ */
+static int
+mrvl_mtr_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops)
+{
+	*(const void **)ops = &mrvl_mtr_ops;
+
+	return 0;
+}
+
 static const struct eth_dev_ops mrvl_ops = {
 	.dev_configure = mrvl_dev_configure,
 	.dev_start = mrvl_dev_start,
@@ -1895,6 +1918,7 @@ static const struct eth_dev_ops mrvl_ops = {
 	.rss_hash_update = mrvl_rss_hash_update,
 	.rss_hash_conf_get = mrvl_rss_hash_conf_get,
 	.filter_ctrl = mrvl_eth_filter_ctrl,
+	.mtr_ops_get = mrvl_mtr_ops_get,
 };
 
 /**
drivers/net/mvpp2/mrvl_ethdev.h +71 -0

94 lines not on this page · raw message

drivers/net/mvpp2/mrvl_flow.c +48 -43

119 lines not on this page · raw message

drivers/net/mvpp2/mrvl_mtr.c new file +512 -0

512 lines not on this page · raw message

drivers/net/mvpp2/mrvl_mtr.h new file +15 -0
new file mode 100644
index 0000000..302a20f
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Marvell International Ltd.
+ * Copyright(c) 2018 Semihalf.
+ * All rights reserved.
+ */
+
+#ifndef _MRVL_MTR_H_
+#define _MRVL_MTR_H_
+
+#include "mrvl_ethdev.h"
+
+void mrvl_mtr_init(struct rte_eth_dev *dev);
+void mrvl_mtr_deinit(struct rte_eth_dev *dev);
+
+#endif /* _MRVL_MTR_H_ */
Signature · 1 line
2.7.4
#37 lore raw

PATCH v3 4/13 net/mvpp2: change default policer configuration

In reply to Andrzej Ostruszka

From: Tomasz Duszynski <[email protected]>

Change QoS configuration file syntax for port's default policer setup.

Since default policer configuration is performed before any other policer configuration we can pick a default id.

This simplifies default policer configuration since user no longer has to choose ids from range [0, PP2_CLS_PLCR_NUM].

Explicitly document values for rate_limit_enable field.

---
 doc/guides/nics/mvpp2.rst       |  31 ++++---
 drivers/net/mvpp2/mrvl_ethdev.c |   6 +-
 drivers/net/mvpp2/mrvl_ethdev.h |   2 +-
 drivers/net/mvpp2/mrvl_qos.c    | 198 ++++++++++++++++++++++------------------
 drivers/net/mvpp2/mrvl_qos.h    |   2 +-
 5 files changed, 134 insertions(+), 105 deletions(-)
doc/guides/nics/mvpp2.rst +19 -12
index 0408752..a452c8a 100644
@@ -152,20 +152,23 @@ Configuration syntax
 
 .. code-block:: console
 
-   [port <portnum> default]
-   default_tc = <default_tc>
-   mapping_priority = <mapping_priority>
-   policer_enable = <policer_enable>
+   [policer <policer_id>]
    token_unit = <token_unit>
    color = <color_mode>
    cir = <cir>
    ebs = <ebs>
    cbs = <cbs>
 
+   [port <portnum> default]
+   default_tc = <default_tc>
+   mapping_priority = <mapping_priority>
+
    rate_limit_enable = <rate_limit_enable>
    rate_limit = <rate_limit>
    burst_size = <burst_size>
 
+   default_policer = <policer_id>
+
    [port <portnum> tc <traffic_class>]
    rxq = <rx_queue_list>
    pcp = <pcp_list>
@@ -201,7 +204,9 @@ Where:
 
 - ``<dscp_list>``: List of DSCP values to handle in particular TC (e.g. 0-12 32-48 63).
 
-- ``<policer_enable>``: Enable ingress policer.
+- ``<default_policer>``: Id of the policer configuration section to be used as default.
+
+- ``<policer_id>``: Id of the policer configuration section (0..31).
 
 - ``<token_unit>``: Policer token unit (`bytes` or `packets`).
 
@@ -215,7 +220,7 @@ Where:
 
 - ``<default_color>``: Default color for specific tc.
 
-- ``<rate_limit_enable>``: Enables per port or per txq rate limiting.
+- ``<rate_limit_enable>``: Enables per port or per txq rate limiting (`0`/`1` to disable/enable).
 
 - ``<rate_limit>``: Committed information rate, in kilo bits per second.
 
@@ -234,6 +239,13 @@ Configuration file example
 
 .. code-block:: console
 
+   [policer 0]
+   token_unit = bytes
+   color = blind
+   cir = 100000
+   ebs = 64
+   cbs = 64
+
    [port 0 default]
    default_tc = 0
    mapping_priority = ip
@@ -265,12 +277,7 @@ Configuration file example
    default_tc = 0
    mapping_priority = vlan/ip
 
-   policer_enable = 1
-   token_unit = bytes
-   color = blind
-   cir = 100000
-   ebs = 64
-   cbs = 64
+   default_policer = 0
 
    [port 1 tc 0]
    rxq = 0
drivers/net/mvpp2/mrvl_ethdev.c +3 -3
index a6cc550..0571635 100644
@@ -789,9 +789,9 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 	}
 
 	/* policer must be released after ppio deinitialization */
-	if (priv->policer) {
-		pp2_cls_plcr_deinit(priv->policer);
-		priv->policer = NULL;
+	if (priv->default_policer) {
+		pp2_cls_plcr_deinit(priv->default_policer);
+		priv->default_policer = NULL;
 	}
 }
 
drivers/net/mvpp2/mrvl_ethdev.h +1 -1
index ecb8fdc..de423a9 100644
@@ -168,7 +168,7 @@ struct mrvl_priv {
 	uint32_t cls_tbl_pattern;
 	LIST_HEAD(mrvl_flows, rte_flow) flows;
 
-	struct pp2_cls_plcr *policer;
+	struct pp2_cls_plcr *default_policer;
 
 	LIST_HEAD(profiles, mrvl_mtr_profile) profiles;
 	LIST_HEAD(mtrs, mrvl_mtr) mtrs;
drivers/net/mvpp2/mrvl_qos.c +110 -88

253 lines not on this page · raw message

drivers/net/mvpp2/mrvl_qos.h +1 -1
index fa9ddec..f03e773 100644
@@ -43,7 +43,7 @@ struct mrvl_qos_cfg {
 		uint8_t default_tc;
 		uint8_t use_global_defaults;
 		struct pp2_cls_plcr_params policer_params;
-		uint8_t policer_enable;
+		uint8_t setup_policer;
 	} port[RTE_MAX_ETHPORTS];
 };
 
Signature · 1 line
2.7.4
#38 lore raw

PATCH v3 5/13 net/mvpp2: add init and deinit to flow

In reply to Andrzej Ostruszka

From: Tomasz Duszynski <[email protected]>

Add init and deinit functionality to flow implementation.

Init puts structures used by flow in a sane sate.
Deinit deallocates all resources used by flow.

---
 drivers/net/mvpp2/mrvl_ethdev.c |  3 +++
 drivers/net/mvpp2/mrvl_flow.c   | 33 ++++++++++++++++++++++++++++++++-
 drivers/net/mvpp2/mrvl_flow.h   | 15 +++++++++++++++
 3 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/mvpp2/mrvl_flow.h
drivers/net/mvpp2/mrvl_ethdev.c +3 -0
index 0571635..461f297 100644
@@ -23,6 +23,7 @@
 #include <rte_mvep_common.h>
 #include "mrvl_ethdev.h"
 #include "mrvl_qos.h"
+#include "mrvl_flow.h"
 #include "mrvl_mtr.h"
 
 /* bitmask with reserved hifs */
@@ -619,6 +620,7 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 			goto out;
 	}
 
+	mrvl_flow_init(dev);
 	mrvl_mtr_init(dev);
 
 	return 0;
@@ -759,6 +761,7 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 
 	mrvl_flush_rx_queues(dev);
 	mrvl_flush_tx_shadow_queues(dev);
+	mrvl_flow_deinit(dev);
 	mrvl_mtr_deinit(dev);
 
 	for (i = 0; i < priv->ppio_params.inqs_params.num_tcs; ++i) {
drivers/net/mvpp2/mrvl_flow.c +32 -1
index e6953e4..065b1aa 100644
@@ -11,7 +11,7 @@
 
 #include <arpa/inet.h>
 
-#include "mrvl_ethdev.h"
+#include "mrvl_flow.h"
 #include "mrvl_qos.h"
 
 /** Number of rules in the classifier table. */
@@ -2790,3 +2790,34 @@ const struct rte_flow_ops mrvl_flow_ops = {
 	.flush = mrvl_flow_flush,
 	.isolate = mrvl_flow_isolate
 };
+
+/**
+ * Initialize flow resources.
+ *
+ * @param dev Pointer to the device.
+ */
+void
+mrvl_flow_init(struct rte_eth_dev *dev)
+{
+	struct mrvl_priv *priv = dev->data->dev_private;
+
+	LIST_INIT(&priv->flows);
+}
+
+/**
+ * Cleanup flow resources.
+ *
+ * @param dev Pointer to the device.
+ */
+void
+mrvl_flow_deinit(struct rte_eth_dev *dev)
+{
+	struct mrvl_priv *priv = dev->data->dev_private;
+
+	mrvl_flow_flush(dev, NULL);
+
+	if (priv->cls_tbl) {
+		pp2_cls_tbl_deinit(priv->cls_tbl);
+		priv->cls_tbl = NULL;
+	}
+}
drivers/net/mvpp2/mrvl_flow.h new file +15 -0
new file mode 100644
index 0000000..f63747c
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Marvell International Ltd.
+ * Copyright(c) 2018 Semihalf.
+ * All rights reserved.
+ */
+
+#ifndef _MRVL_FLOW_H_
+#define _MRVL_FLOW_H_
+
+#include "mrvl_ethdev.h"
+
+void mrvl_flow_init(struct rte_eth_dev *dev);
+void mrvl_flow_deinit(struct rte_eth_dev *dev);
+
+#endif /* _MRVL_FLOW_H_ */
Signature · 1 line
2.7.4
#39 lore raw

PATCH v3 6/13 net/mvpp2: add traffic manager support

In reply to Andrzej Ostruszka

From: Tomasz Duszynski <[email protected]>

Add traffic manager support.

---
 drivers/net/mvpp2/Makefile      |    1 +
 drivers/net/mvpp2/meson.build   |    3 +-
 drivers/net/mvpp2/mrvl_ethdev.c |   26 +
 drivers/net/mvpp2/mrvl_ethdev.h |   31 ++
 drivers/net/mvpp2/mrvl_tm.c     | 1009 +++++++++++++++++++++++++++++++++++++++
 drivers/net/mvpp2/mrvl_tm.h     |   15 +
 6 files changed, 1084 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/mvpp2/mrvl_tm.c
 create mode 100644 drivers/net/mvpp2/mrvl_tm.h
drivers/net/mvpp2/Makefile +1 -0
index 4848d65..661d2cd 100644
@@ -40,5 +40,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_qos.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_flow.c
 SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_mtr.c
+SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_tm.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/mvpp2/meson.build +2 -1
index f475511..70ef2d6 100644
@@ -20,7 +20,8 @@ sources = files(
 	'mrvl_ethdev.c',
 	'mrvl_flow.c',
 	'mrvl_qos.c',
-	'mrvl_mtr.c'
+	'mrvl_mtr.c',
+	'mrvl_tm.c'
 )
 
 deps += ['cfgfile', 'common_mvep']
drivers/net/mvpp2/mrvl_ethdev.c +26 -0
index 461f297..4d1e84a 100644
@@ -25,6 +25,7 @@
 #include "mrvl_qos.h"
 #include "mrvl_flow.h"
 #include "mrvl_mtr.h"
+#include "mrvl_tm.h"
 
 /* bitmask with reserved hifs */
 #define MRVL_MUSDK_HIFS_RESERVED 0x0F
@@ -331,6 +332,10 @@ mrvl_dev_configure(struct rte_eth_dev *dev)
 	priv->ppio_params.maintain_stats = 1;
 	priv->nb_rx_queues = dev->data->nb_rx_queues;
 
+	ret = mrvl_tm_init(dev);
+	if (ret < 0)
+		return ret;
+
 	if (dev->data->nb_rx_queues == 1 &&
 	    dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_RSS) {
 		MRVL_LOG(WARNING, "Disabling hash for 1 rx queue");
@@ -785,6 +790,7 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 	}
 
 	mrvl_flush_bpool(dev);
+	mrvl_tm_deinit(dev);
 
 	if (priv->ppio) {
 		pp2_ppio_deinit(priv->ppio);
@@ -1884,6 +1890,25 @@ mrvl_mtr_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops)
 	return 0;
 }
 
+/**
+ * DPDK callback to get rte_tm callbacks.
+ *
+ * @param dev
+ *   Pointer to the device structure.
+ * @param ops
+ *   Pointer to pass the tm ops.
+ *
+ * @return
+ *   Always 0.
+ */
+static int
+mrvl_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops)
+{
+	*(const void **)ops = &mrvl_tm_ops;
+
+	return 0;
+}
+
 static const struct eth_dev_ops mrvl_ops = {
 	.dev_configure = mrvl_dev_configure,
 	.dev_start = mrvl_dev_start,
@@ -1922,6 +1947,7 @@ static const struct eth_dev_ops mrvl_ops = {
 	.rss_hash_conf_get = mrvl_rss_hash_conf_get,
 	.filter_ctrl = mrvl_eth_filter_ctrl,
 	.mtr_ops_get = mrvl_mtr_ops_get,
+	.tm_ops_get = mrvl_tm_ops_get,
 };
 
 /**
drivers/net/mvpp2/mrvl_ethdev.h +31 -0
index de423a9..984f31e 100644
@@ -10,6 +10,7 @@
 #include <rte_spinlock.h>
 #include <rte_flow_driver.h>
 #include <rte_mtr_driver.h>
+#include <rte_tm_driver.h>
 
 /*
  * container_of is defined by both DPDK and MUSDK,
@@ -134,6 +135,29 @@ struct mrvl_mtr {
 	struct pp2_cls_plcr *plcr;
 };
 
+struct mrvl_tm_shaper_profile {
+	LIST_ENTRY(mrvl_tm_shaper_profile) next;
+	uint32_t id;
+	int refcnt;
+	struct rte_tm_shaper_params params;
+};
+
+enum {
+	MRVL_NODE_PORT,
+	MRVL_NODE_QUEUE,
+};
+
+struct mrvl_tm_node {
+	LIST_ENTRY(mrvl_tm_node) next;
+	uint32_t id;
+	uint32_t type;
+	int refcnt;
+	struct mrvl_tm_node *parent;
+	struct mrvl_tm_shaper_profile *profile;
+	uint8_t weight;
+	uint64_t stats_mask;
+};
+
 struct mrvl_priv {
 	/* Hot fields, used in fast path. */
 	struct pp2_bpool *bpool;  /**< BPool pointer */
@@ -173,6 +197,10 @@ struct mrvl_priv {
 	LIST_HEAD(profiles, mrvl_mtr_profile) profiles;
 	LIST_HEAD(mtrs, mrvl_mtr) mtrs;
 	uint32_t used_plcrs;
+
+	LIST_HEAD(shaper_profiles, mrvl_tm_shaper_profile) shaper_profiles;
+	LIST_HEAD(nodes, mrvl_tm_node) nodes;
+	uint64_t rate_max;
 };
 
 /** Flow operations forward declaration. */
@@ -181,6 +209,9 @@ extern const struct rte_flow_ops mrvl_flow_ops;
 /** Meter operations forward declaration. */
 extern const struct rte_mtr_ops mrvl_mtr_ops;
 
+/** Traffic manager operations forward declaration. */
+extern const struct rte_tm_ops mrvl_tm_ops;
+
 /** Current log type. */
 extern int mrvl_logtype;
 
drivers/net/mvpp2/mrvl_tm.c new file +1009 -0

1,009 lines not on this page · raw message

drivers/net/mvpp2/mrvl_tm.h new file +15 -0
new file mode 100644
index 0000000..9d81ede
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Marvell International Ltd.
+ * Copyright(c) 2018 Semihalf.
+ * All rights reserved.
+ */
+
+#ifndef _MRVL_TM_H_
+#define _MRVL_TM_H_
+
+#include "mrvl_ethdev.h"
+
+int mrvl_tm_init(struct rte_eth_dev *dev);
+void mrvl_tm_deinit(struct rte_eth_dev *dev);
+
+#endif /* _MRVL_TM_H_ */
Signature · 1 line
2.7.4
#40 lore raw

PATCH v3 7/13 net/mvpp2: detach Tx QoS from Rx cls/QoS config

In reply to Andrzej Ostruszka

From: Yuval Caduri <[email protected]>

Functional change:
Open receive cls/qos related features, only if the config file contains an rx_related configuration entry. This allows to configure tx_related entries, w/o unintentionally opening rx cls/qos.

Code:
'use_global_defaults' is by default set to '1'.
Only if an rx_related entry was configured, it is updated to '0'. rx cls/qos is performed only if 'use_global_defaults' is '0'. Default TC configuration is now only mandatory when 'use_global_defaults' is '0'.

---
 drivers/net/mvpp2/mrvl_ethdev.c |  3 ++-
 drivers/net/mvpp2/mrvl_qos.c    | 41 +++++++++++++++++++++++------------------
 2 files changed, 25 insertions(+), 19 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +2 -1
index 4d1e84a..64c6f0f 100644
@@ -593,7 +593,8 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 	}
 
 	/* For default QoS config, don't start classifier. */
-	if (mrvl_qos_cfg) {
+	if (mrvl_qos_cfg  &&
+	    mrvl_qos_cfg->port[dev->data->port_id].use_global_defaults == 0) {
 		ret = mrvl_start_qos_mapping(priv);
 		if (ret) {
 			MRVL_LOG(ERR, "Failed to setup QoS mapping");
drivers/net/mvpp2/mrvl_qos.c +23 -18

89 lines not on this page · raw message

Signature · 1 line
2.7.4
#41 lore raw

PATCH v3 8/13 net/mvpp2: update MTU and MRU related calculations

In reply to Andrzej Ostruszka

From: Natalie Samsonov <[email protected]>

This commit updates MTU and MRU related calculations.

---
 drivers/net/mvpp2/mrvl_ethdev.c | 70 +++++++++++++++++++++++++++++++----------
 drivers/net/mvpp2/mrvl_ethdev.h |  7 +++++
 2 files changed, 61 insertions(+), 16 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +54 -16
index 64c6f0f..24bd0a5 100644
@@ -316,7 +316,7 @@ mrvl_dev_configure(struct rte_eth_dev *dev)
 
 	if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME)
 		dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
-				 ETHER_HDR_LEN - ETHER_CRC_LEN;
+				 MRVL_PP2_ETH_HDRS_LEN;
 
 	ret = mrvl_configure_rxqs(priv, dev->data->port_id,
 				  dev->data->nb_rx_queues);
@@ -366,21 +366,55 @@ static int
 mrvl_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 {
 	struct mrvl_priv *priv = dev->data->dev_private;
-	/* extra MV_MH_SIZE bytes are required for Marvell tag */
-	uint16_t mru = mtu + MV_MH_SIZE + ETHER_HDR_LEN + ETHER_CRC_LEN;
+	uint16_t mru;
+	uint16_t mbuf_data_size = 0; /* SW buffer size */
 	int ret;
 
-	if (mtu < ETHER_MIN_MTU || mru > MRVL_PKT_SIZE_MAX)
+	mru = MRVL_PP2_MTU_TO_MRU(mtu);
+	/*
+	 * min_rx_buf_size is equal to mbuf data size
+	 * if pmd didn't set it differently
+	 */
+	mbuf_data_size = dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM;
+	/* Prevent PMD from:
+	 * - setting mru greater than the mbuf size resulting in
+	 * hw and sw buffer size mismatch
+	 * - setting mtu that requires the support of scattered packets
+	 * when this feature has not been enabled/supported so far
+	 * (TODO check scattered_rx flag here once scattered RX is supported).
+	 */
+	if (mru + MRVL_PKT_OFFS > mbuf_data_size) {
+		mru = mbuf_data_size - MRVL_PKT_OFFS;
+		mtu = MRVL_PP2_MRU_TO_MTU(mru);
+		MRVL_LOG(WARNING, "MTU too big, max MTU possible limitted "
+			"by current mbuf size: %u. Set MTU to %u, MRU to %u",
+			mbuf_data_size, mtu, mru);
+	}
+
+	if (mtu < ETHER_MIN_MTU || mru > MRVL_PKT_SIZE_MAX) {
+		MRVL_LOG(ERR, "Invalid MTU [%u] or MRU [%u]", mtu, mru);
 		return -EINVAL;
+	}
+
+	dev->data->mtu = mtu;
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = mru - MV_MH_SIZE;
 
 	if (!priv->ppio)
 		return 0;
 
 	ret = pp2_ppio_set_mru(priv->ppio, mru);
-	if (ret)
+	if (ret) {
+		MRVL_LOG(ERR, "Failed to change MRU");
 		return ret;
+	}
+
+	ret = pp2_ppio_set_mtu(priv->ppio, mtu);
+	if (ret) {
+		MRVL_LOG(ERR, "Failed to change MTU");
+		return ret;
+	}
 
-	return pp2_ppio_set_mtu(priv->ppio, mtu);
+	return 0;
 }
 
 /**
@@ -591,6 +625,9 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 		}
 		priv->vlan_flushed = 1;
 	}
+	ret = mrvl_mtu_set(dev, dev->data->mtu);
+	if (ret)
+		MRVL_LOG(ERR, "Failed to set MTU to %d", dev->data->mtu);
 
 	/* For default QoS config, don't start classifier. */
 	if (mrvl_qos_cfg  &&
@@ -1542,8 +1579,8 @@ mrvl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 {
 	struct mrvl_priv *priv = dev->data->dev_private;
 	struct mrvl_rxq *rxq;
-	uint32_t min_size,
-		 max_rx_pkt_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
+	uint32_t frame_size, buf_size = rte_pktmbuf_data_room_size(mp);
+	uint32_t max_rx_pkt_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
 	int ret, tc, inq;
 	uint64_t offloads;
 
@@ -1558,15 +1595,16 @@ mrvl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 		return -EFAULT;
 	}
 
-	min_size = rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM -
-		   MRVL_PKT_EFFEC_OFFS;
-	if (min_size < max_rx_pkt_len) {
-		MRVL_LOG(ERR,
-			"Mbuf size must be increased to %u bytes to hold up to %u bytes of data.",
-			max_rx_pkt_len + RTE_PKTMBUF_HEADROOM +
-			MRVL_PKT_EFFEC_OFFS,
+	frame_size = buf_size - RTE_PKTMBUF_HEADROOM - MRVL_PKT_EFFEC_OFFS;
+	if (frame_size < max_rx_pkt_len) {
+		MRVL_LOG(WARNING,
+			"Mbuf size must be increased to %u bytes to hold up "
+			"to %u bytes of data.",
+			buf_size + max_rx_pkt_len - frame_size,
 			max_rx_pkt_len);
-		return -EINVAL;
+		dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+		MRVL_LOG(INFO, "Setting max rx pkt len to %u",
+			dev->data->dev_conf.rxmode.max_rx_pkt_len);
 	}
 
 	if (dev->data->rx_queues[idx]) {
drivers/net/mvpp2/mrvl_ethdev.h +7 -0
index 984f31e..f0ae983 100644
@@ -72,6 +72,13 @@
 /** Minimum number of sent buffers to release from shadow queue to BM */
 #define MRVL_PP2_BUF_RELEASE_BURST_SIZE	64
 
+#define MRVL_PP2_VLAN_TAG_LEN		4
+#define MRVL_PP2_ETH_HDRS_LEN		(ETHER_HDR_LEN + ETHER_CRC_LEN + \
+					(2 * MRVL_PP2_VLAN_TAG_LEN))
+#define MRVL_PP2_HDRS_LEN		(MV_MH_SIZE + MRVL_PP2_ETH_HDRS_LEN)
+#define MRVL_PP2_MTU_TO_MRU(mtu)	((mtu) + MRVL_PP2_HDRS_LEN)
+#define MRVL_PP2_MRU_TO_MTU(mru)	((mru) - MRVL_PP2_HDRS_LEN)
+
 /** Maximum length of a match string */
 #define MRVL_MATCH_LEN 16
 
Signature · 1 line
2.7.4
#42 lore raw

PATCH v3 9/13 net/mvpp2: align with MUSDK 18.09

In reply to Andrzej Ostruszka

From: Tomasz Duszynski <[email protected]>

This patch introduces necessary changes required by MUSDK 18.09 library.

* As of MUSDK 18.09, pp2_cookie_t is no longer available. Now RX descriptor cookie is defined as plain u64 so existing cast is no longer valid.

* MUSDK 18.09 increased number of available bpools (buffer hw pools) by introducing dma regions support. Update mvpp2 driver accordingly.

* replace MV_NET_IP4_F_TOS with MV_NET_IP4_F_DSCP

Before this patch, API allowed to configure a classification rule according to IPv4 TOS, which was not supported in classifier. This patch fixes this by using proper field.

* use 48 bit address mask

We cannot get pointers exceeding 48 bits thus using 48 bit mask for extracting higher IOVA address bits is enough.

---
 drivers/net/mvpp2/mrvl_ethdev.c | 10 ++++------
 drivers/net/mvpp2/mrvl_flow.c   |  3 ++-
 drivers/net/mvpp2/mrvl_qos.c    |  2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +4 -6
index 24bd0a5..26497ef 100644
@@ -54,9 +54,7 @@
 #define MRVL_ARP_LENGTH 28
 
 #define MRVL_COOKIE_ADDR_INVALID ~0ULL
-
-#define MRVL_COOKIE_HIGH_ADDR_SHIFT	(sizeof(pp2_cookie_t) * 8)
-#define MRVL_COOKIE_HIGH_ADDR_MASK	(~0ULL << MRVL_COOKIE_HIGH_ADDR_SHIFT)
+#define MRVL_COOKIE_HIGH_ADDR_MASK 0xffffff0000000000
 
 /** Port Rx offload capabilities */
 #define MRVL_RX_OFFLOADS (DEV_RX_OFFLOAD_VLAN_FILTER | \
@@ -1534,7 +1532,7 @@ mrvl_fill_bpool(struct mrvl_rxq *rxq, int num)
 
 		entries[i].buff.addr =
 			rte_mbuf_data_iova_default(mbufs[i]);
-		entries[i].buff.cookie = (pp2_cookie_t)(uint64_t)mbufs[i];
+		entries[i].buff.cookie = (uint64_t)mbufs[i];
 		entries[i].bpool = bpool;
 	}
 
@@ -2170,7 +2168,7 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		if (unlikely(status != PP2_DESC_ERR_OK)) {
 			struct pp2_buff_inf binf = {
 				.addr = rte_mbuf_data_iova_default(mbuf),
-				.cookie = (pp2_cookie_t)(uint64_t)mbuf,
+				.cookie = (uint64_t)mbuf,
 			};
 
 			pp2_bpool_put_buff(hif, bpool, &binf);
@@ -2431,7 +2429,7 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 			rte_mbuf_prefetch_part2(pref_pkt_hdr);
 		}
 
-		sq->ent[sq->head].buff.cookie = (pp2_cookie_t)(uint64_t)mbuf;
+		sq->ent[sq->head].buff.cookie = (uint64_t)mbuf;
 		sq->ent[sq->head].buff.addr =
 			rte_mbuf_data_iova_default(mbuf);
 		sq->ent[sq->head].bpool =
drivers/net/mvpp2/mrvl_flow.c +2 -1
index 065b1aa..ffd1dab 100644
@@ -2437,7 +2437,8 @@ mrvl_create_cls_table(struct rte_eth_dev *dev, struct rte_flow *first_flow)
 
 	if (first_flow->pattern & F_IP4_TOS) {
 		key->proto_field[key->num_fields].proto = MV_NET_PROTO_IP4;
-		key->proto_field[key->num_fields].field.ipv4 = MV_NET_IP4_F_TOS;
+		key->proto_field[key->num_fields].field.ipv4 =
+							MV_NET_IP4_F_DSCP;
 		key->key_size += 1;
 		key->num_fields += 1;
 	}
drivers/net/mvpp2/mrvl_qos.c +1 -1
index 5d80c3e..7fd9703 100644
@@ -654,7 +654,7 @@ setup_tc(struct pp2_ppio_tc_params *param, uint8_t inqs,
 	struct pp2_ppio_inq_params *inq_params;
 
 	param->pkt_offset = MRVL_PKT_OFFS;
-	param->pools[0] = bpool;
+	param->pools[0][0] = bpool;
 	param->default_color = color;
 
 	inq_params = rte_zmalloc_socket("inq_params",
Signature · 1 line
2.7.4
#43 lore raw

PATCH v3 10/13 crypto/mvsam: get number of CIOs dynamically

In reply to Andrzej Ostruszka

From: Dmitri Epshtein <[email protected]>

MUSDK 18.09 introduced API for getting CIOs number dynamically. Use that instead of predefined constant.

---
 drivers/crypto/mvsam/rte_mrvl_pmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/mvsam/rte_mrvl_pmd.c +1 -1
index 73eff75..6d54c06 100644
@@ -864,7 +864,7 @@ cryptodev_mrvl_crypto_init(struct rte_vdev_device *vdev)
 			.private_data_size =
 				sizeof(struct mrvl_crypto_private),
 			.max_nb_queue_pairs =
-				sam_get_num_inst() * SAM_HW_RING_NUM,
+				sam_get_num_inst() * sam_get_num_cios(0),
 			.socket_id = rte_socket_id()
 		},
 		.max_nb_sessions = MRVL_PMD_DEFAULT_MAX_NB_SESSIONS
Signature · 1 line
2.7.4
#44 lore raw

PATCH v3 11/13 net/mvpp2: align documentation with MUSDK 18.09

In reply to Andrzej Ostruszka

From: Natalie Samsonov <[email protected]>

Update documentation to align with MUSDK 18.09.

---
 doc/guides/nics/mvpp2.rst | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
doc/guides/nics/mvpp2.rst +12 -14
index a452c8a..3b3f8c6 100644
@@ -74,6 +74,7 @@ Features of the MVPP2 PMD are:
 - QoS
 - RX flow control
 - TX queue start/stop
+- Scattered TX frames
 
 
 Limitations
@@ -96,19 +97,19 @@ Prerequisites
 
   .. code-block:: console
 
-     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.52-armada-17.10
+     git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.120-armada-18.09
 
 - Out of tree `mvpp2x_sysfs` kernel module sources
 
   .. code-block:: console
 
-     git clone https://github.com/MarvellEmbeddedProcessors/mvpp2x-marvell.git -b mvpp2x-armada-17.10
+     git clone https://github.com/MarvellEmbeddedProcessors/mvpp2x-marvell.git -b mvpp2x-armada-18.09
 
 - MUSDK (Marvell User-Space SDK) sources
 
   .. code-block:: console
 
-     git clone https://github.com/MarvellEmbeddedProcessors/musdk-marvell.git -b musdk-armada-17.10
+     git clone https://github.com/MarvellEmbeddedProcessors/musdk-marvell.git -b musdk-armada-18.09
 
   MUSDK is a light-weight library that provides direct access to Marvell's
   PPv2 (Packet Processor v2). Alternatively prebuilt MUSDK library can be
@@ -119,12 +120,6 @@ Prerequisites
   To get better understanding of the library one can consult documentation
   available in the ``doc`` top level directory of the MUSDK sources.
 
-  MUSDK must be configured with the following features:
-
-  .. code-block:: console
-
-     --enable-bpool-dma=64
-
 - DPDK environment
 
   Follow the DPDK :ref:`Getting Started Guide for Linux <linux_gsg>` to setup
@@ -140,6 +135,9 @@ The following options can be modified in the ``config`` file.
 
     Toggle compilation of the librte mvpp2 driver.
 
+    .. Note::
+
+       When MVPP2 PMD is enabled ``CONFIG_RTE_LIBRTE_MVNETA_PMD`` must be disabled
 
 QoS Configuration
 -----------------
@@ -314,7 +312,7 @@ Driver needs precompiled MUSDK library during compilation.
 
    export CROSS_COMPILE=<toolchain>/bin/aarch64-linux-gnu-
    ./bootstrap
-   ./configure --host=aarch64-linux-gnu --enable-bpool-dma=64
+   ./configure --host=aarch64-linux-gnu
    make install
 
 MUSDK will be installed to `usr/local` under current directory.
@@ -328,7 +326,8 @@ the path to the MUSDK installation directory needs to be exported.
    export LIBMUSDK_PATH=<musdk>/usr/local
    export CROSS=aarch64-linux-gnu-
    make config T=arm64-armv8a-linuxapp-gcc
-   sed -ri 's,(MVPP2_PMD=)n,\1y,' build/.config
+   sed -i "s/MVNETA_PMD=y/MVNETA_PMD=n/" build/.config
+   sed -i "s/MVPP2_PMD=n/MVPP2_PMD=y/" build/.config
    make
 
 Flow API
@@ -500,15 +499,14 @@ Usage Example
 -------------
 
 MVPP2 PMD requires extra out of tree kernel modules to function properly.
-`musdk_uio` and `mv_pp_uio` sources are part of the MUSDK. Please consult
+`musdk_cma` sources are part of the MUSDK. Please consult
 ``doc/musdk_get_started.txt`` for the detailed build instructions.
 For `mvpp2x_sysfs` please consult ``Documentation/pp22_sysfs.txt`` for the
 detailed build instructions.
 
 .. code-block:: console
 
-   insmod musdk_uio.ko
-   insmod mv_pp_uio.ko
+   insmod musdk_cma.ko
    insmod mvpp2x_sysfs.ko
 
 Additionally interfaces used by DPDK application need to be put up:
Signature · 1 line
2.7.4
#45 lore raw

PATCH v3 12/13 net/mvpp2: document MTR and TM usage

In reply to Andrzej Ostruszka

From: Natalie Samsonov <[email protected]>

Document MTR (metering) and TM (traffic management) usage plus do some small updates here and there.

---
 doc/guides/nics/img/mvpp2_tm.svg |  71 +++++++
 doc/guides/nics/mvpp2.rst        | 386 +++++++++++++++++++++++++++++++++------
 2 files changed, 406 insertions(+), 51 deletions(-)
 create mode 100644 doc/guides/nics/img/mvpp2_tm.svg
doc/guides/nics/img/mvpp2_tm.svg new file +71 -0
new file mode 100644
index 0000000..4aa9272
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/PR-SVG-20010719/DTD/svg10.dtd">
+<svg width="16cm" height="4cm" viewBox="-1 -1 309 75" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+  <g>
+    <polyline style="fill: none; fill-opacity:0; stroke-width: 1; stroke: #000000" points="159.661,12.6759 141.655,12.6759 141.655,35.5606 88.1561,35.5606 88.1561,44.9245 "/>
+    <polygon style="fill: #000000" points="88.1561,49.4245 85.1561,43.4245 88.1561,44.9245 91.1561,43.4245 "/>
+    <polygon style="fill: none; fill-opacity:0; stroke-width: 1; stroke: #000000" points="88.1561,49.4245 85.1561,43.4245 88.1561,44.9245 91.1561,43.4245 "/>
+  </g>
+  <g>
+    <polyline style="fill: none; fill-opacity:0; stroke-width: 1; stroke: #000000" points="159.661,12.6759 176.28,12.6759 176.28,35.5606 281.681,35.5606 281.681,44.9245 "/>
+    <polygon style="fill: #000000" points="281.681,49.4245 278.681,43.4245 281.681,44.9245 284.681,43.4245 "/>
+    <polygon style="fill: none; fill-opacity:0; stroke-width: 1; stroke: #000000" points="281.681,49.4245 278.681,43.4245 281.681,44.9245 284.681,43.4245 "/>
+  </g>
+  <g>
+    <rect style="fill: #ffffff" x="126.066" y="0.98102" width="67.1901" height="23.3899"/>
+    <rect style="fill: none; fill-opacity:0; stroke-width: 2; stroke: #000000" x="126.066" y="0.98102" width="67.1901" height="23.3899"/>
+  </g>
+  <text font-size="12.7998" style="fill: #000000;text-anchor:middle;font-family:sans-serif;font-style:normal;font-weight:normal" x="159.661" y="17.1259">
+    <tspan x="159.661" y="17.1259">Port N</tspan>
+  </text>
+  <text font-size="12.7998" style="fill: #000000;text-anchor:start;font-family:sans-serif;font-style:normal;font-weight:normal" x="304.581" y="68.168">
+    <tspan x="304.581" y="68.168"></tspan>
+  </text>
+  <g>
+    <rect style="fill: #ffffff" x="62.5504" y="51.5478" width="51.2114" height="22.0925"/>
+    <rect style="fill: none; fill-opacity:0; stroke-width: 2; stroke: #000000" x="62.5504" y="51.5478" width="51.2114" height="22.0925"/>
+  </g>
+  <text font-size="12.7998" style="fill: #000000;text-anchor:middle;font-family:sans-serif;font-style:normal;font-weight:normal" x="88.1561" y="67.044">
+    <tspan x="88.1561" y="67.044">Txq 0</tspan>
+  </text>
+  <g>
+    <rect style="fill: #ffffff" x="134.1" y="51.355" width="51.1213" height="22.478"/>
+    <rect style="fill: none; fill-opacity:0; stroke-width: 2; stroke: #000000" x="134.1" y="51.355" width="51.1213" height="22.478"/>
+  </g>
+  <text font-size="12.7998" style="fill: #000000;text-anchor:middle;font-family:sans-serif;font-style:normal;font-weight:normal" x="159.661" y="67.044">
+    <tspan x="159.661" y="67.044">Txq 1</tspan>
+  </text>
+  <g>
+    <rect style="fill: #ffffff" x="256.416" y="51.5478" width="50.5306" height="22.0925"/>
+    <rect style="fill: none; fill-opacity:0; stroke-width: 2; stroke: #000000" x="256.416" y="51.5478" width="50.5306" height="22.0925"/>
+  </g>
+  <text font-size="12.7998" style="fill: #000000;text-anchor:middle;font-family:sans-serif;font-style:normal;font-weight:normal" x="281.681" y="67.044">
+    <tspan x="281.681" y="67.044">Txq M</tspan>
+  </text>
+  <text font-size="12.7998" style="fill: #000000;text-anchor:start;font-family:sans-serif;font-style:normal;font-weight:normal" x="101.822" y="67.044">
+    <tspan x="101.822" y="67.044"></tspan>
+  </text>
+  <text font-size="12.7998" style="fill: #000000;text-anchor:start;font-family:sans-serif;font-style:normal;font-weight:normal" x="-0.537645" y="17.1259">
+    <tspan x="-0.537645" y="17.1259">Level 0:</tspan>
+  </text>
+  <text font-size="12.7998" style="fill: #000000;text-anchor:start;font-family:sans-serif;font-style:normal;font-weight:normal" x="-0.746688" y="67.044">
+    <tspan x="-0.746688" y="67.044">Level 1:</tspan>
+  </text>
+  <g>
+    <ellipse style="fill: #000000" cx="207.645" cy="62.594" rx="0.425344" ry="0.425344"/>
+    <ellipse style="fill: none; fill-opacity:0; stroke-width: 2; stroke: #000000" cx="207.645" cy="62.594" rx="0.425344" ry="0.425344"/>
+  </g>
+  <g>
+    <ellipse style="fill: #000000" cx="219.525" cy="62.594" rx="0.425344" ry="0.425344"/>
+    <ellipse style="fill: none; fill-opacity:0; stroke-width: 2; stroke: #000000" cx="219.525" cy="62.594" rx="0.425344" ry="0.425344"/>
+  </g>
+  <g>
+    <ellipse style="fill: #000000" cx="231.405" cy="62.594" rx="0.425345" ry="0.425345"/>
+    <ellipse style="fill: none; fill-opacity:0; stroke-width: 2; stroke: #000000" cx="231.405" cy="62.594" rx="0.425345" ry="0.425345"/>
+  </g>
+  <g>
+    <line style="fill: none; fill-opacity:0; stroke-width: 1; stroke: #000000" x1="159.661" y1="24.3709" x2="159.661" y2="45.737"/>
+    <polygon style="fill: #000000" points="159.661,50.237 156.661,44.237 159.661,45.737 162.661,44.237 "/>
+    <polygon style="fill: none; fill-opacity:0; stroke-width: 1; stroke: #000000" points="159.661,50.237 156.661,44.237 159.661,45.737 162.661,44.237 "/>
+  </g>
+</svg>
doc/guides/nics/mvpp2.rst +335 -51

436 lines not on this page · raw message

Signature · 1 line
2.7.4
#46 lore raw

PATCH v3 13/13 net/mvpp2: add Tx scatter/gather support

In reply to Andrzej Ostruszka

From: Zyta Szpak <[email protected]>

The patch introduces scatter/gather support on transmit path. A separate Tx callback is added and set if the application requests multisegment Tx offload. Multiple descriptors are sent per one packet.

---
 drivers/net/mvpp2/mrvl_ethdev.c | 231 ++++++++++++++++++++++++++++++++++++----
 drivers/net/mvpp2/mrvl_ethdev.h |   1 +
 2 files changed, 212 insertions(+), 20 deletions(-)
drivers/net/mvpp2/mrvl_ethdev.c +211 -20
index 26497ef..0682c63 100644
@@ -64,7 +64,8 @@
 /** Port Tx offloads capabilities */
 #define MRVL_TX_OFFLOADS (DEV_TX_OFFLOAD_IPV4_CKSUM | \
 			  DEV_TX_OFFLOAD_UDP_CKSUM | \
-			  DEV_TX_OFFLOAD_TCP_CKSUM)
+			  DEV_TX_OFFLOAD_TCP_CKSUM | \
+			  DEV_TX_OFFLOAD_MULTI_SEGS)
 
 static const char * const valid_args[] = {
 	MRVL_IFACE_NAME_ARG,
@@ -104,7 +105,9 @@ struct mrvl_shadow_txq {
 	int head;           /* write index - used when sending buffers */
 	int tail;           /* read index - used when releasing buffers */
 	u16 size;           /* queue occupied size */
-	u16 num_to_release; /* number of buffers sent, that can be released */
+	u16 num_to_release; /* number of descriptors sent, that can be
+			     * released
+			     */
 	struct buff_release_entry ent[MRVL_PP2_TX_SHADOWQ_SIZE]; /* q entries */
 };
 
@@ -136,6 +139,12 @@ static inline void mrvl_free_sent_buffers(struct pp2_ppio *ppio,
 			struct pp2_hif *hif, unsigned int core_id,
 			struct mrvl_shadow_txq *sq, int qid, int force);
 
+static uint16_t mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts);
+static uint16_t mrvl_tx_sg_pkt_burst(void *txq,	struct rte_mbuf **tx_pkts,
+				     uint16_t nb_pkts);
+
+
 #define MRVL_XSTATS_TBL_ENTRY(name) { \
 	#name, offsetof(struct pp2_ppio_statistics, name),	\
 	sizeof(((struct pp2_ppio_statistics *)0)->name)		\
@@ -162,6 +171,31 @@ static struct {
 	MRVL_XSTATS_TBL_ENTRY(tx_errors)
 };
 
+static inline void
+mrvl_fill_shadowq(struct mrvl_shadow_txq *sq, struct rte_mbuf *buf)
+{
+	sq->ent[sq->head].buff.cookie = (uint64_t)buf;
+	sq->ent[sq->head].buff.addr = buf ?
+		rte_mbuf_data_iova_default(buf) : 0;
+
+	sq->ent[sq->head].bpool =
+		(unlikely(!buf || buf->port >= RTE_MAX_ETHPORTS ||
+		 buf->refcnt > 1)) ? NULL :
+		 mrvl_port_to_bpool_lookup[buf->port];
+
+	sq->head = (sq->head + 1) & MRVL_PP2_TX_SHADOWQ_MASK;
+	sq->size++;
+}
+
+static inline void
+mrvl_fill_desc(struct pp2_ppio_desc *desc, struct rte_mbuf *buf)
+{
+	pp2_ppio_outq_desc_reset(desc);
+	pp2_ppio_outq_desc_set_phys_addr(desc, rte_pktmbuf_iova(buf));
+	pp2_ppio_outq_desc_set_pkt_offset(desc, 0);
+	pp2_ppio_outq_desc_set_pkt_len(desc, rte_pktmbuf_data_len(buf));
+}
+
 static inline int
 mrvl_get_bpool_size(int pp2_id, int pool_id)
 {
@@ -241,6 +275,27 @@ mrvl_get_hif(struct mrvl_priv *priv, int core_id)
 }
 
 /**
+ * Set tx burst function according to offload flag
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ */
+static void
+mrvl_set_tx_function(struct rte_eth_dev *dev)
+{
+	struct mrvl_priv *priv = dev->data->dev_private;
+
+	/* Use a simple Tx queue (no offloads, no multi segs) if possible */
+	if (priv->multiseg) {
+		RTE_LOG(INFO, PMD, "Using multi-segment tx callback\n");
+		dev->tx_pkt_burst = mrvl_tx_sg_pkt_burst;
+	} else {
+		RTE_LOG(INFO, PMD, "Using single-segment tx callback\n");
+		dev->tx_pkt_burst = mrvl_tx_pkt_burst;
+	}
+}
+
+/**
  * Configure rss based on dpdk rss configuration.
  *
  * @param priv
@@ -316,6 +371,9 @@ mrvl_dev_configure(struct rte_eth_dev *dev)
 		dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
 				 MRVL_PP2_ETH_HDRS_LEN;
 
+	if (dev->data->dev_conf.txmode.offloads & DEV_TX_OFFLOAD_MULTI_SEGS)
+		priv->multiseg = 1;
+
 	ret = mrvl_configure_rxqs(priv, dev->data->port_id,
 				  dev->data->nb_rx_queues);
 	if (ret < 0)
@@ -663,6 +721,7 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 
 	mrvl_flow_init(dev);
 	mrvl_mtr_init(dev);
+	mrvl_set_tx_function(dev);
 
 	return 0;
 out:
@@ -2429,22 +2488,8 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 			rte_mbuf_prefetch_part2(pref_pkt_hdr);
 		}
 
-		sq->ent[sq->head].buff.cookie = (uint64_t)mbuf;
-		sq->ent[sq->head].buff.addr =
-			rte_mbuf_data_iova_default(mbuf);
-		sq->ent[sq->head].bpool =
-			(unlikely(mbuf->port >= RTE_MAX_ETHPORTS ||
-			 mbuf->refcnt > 1)) ? NULL :
-			 mrvl_port_to_bpool_lookup[mbuf->port];
-		sq->head = (sq->head + 1) & MRVL_PP2_TX_SHADOWQ_MASK;
-		sq->size++;
-
-		pp2_ppio_outq_desc_reset(&descs[i]);
-		pp2_ppio_outq_desc_set_phys_addr(&descs[i],
-						 rte_pktmbuf_iova(mbuf));
-		pp2_ppio_outq_desc_set_pkt_offset(&descs[i], 0);
-		pp2_ppio_outq_desc_set_pkt_len(&descs[i],
-					       rte_pktmbuf_pkt_len(mbuf));
+		mrvl_fill_shadowq(sq, mbuf);
+		mrvl_fill_desc(&descs[i], mbuf);
 
 		bytes_sent += rte_pktmbuf_pkt_len(mbuf);
 		/*
@@ -2482,6 +2527,152 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	return nb_pkts;
 }
 
+/** DPDK callback for S/G transmit.
+ *
+ * @param txq
+ *   Generic pointer transmit queue.
+ * @param tx_pkts
+ *   Packets to transmit.
+ * @param nb_pkts
+ *   Number of packets in array.
+ *
+ * @return
+ *   Number of packets successfully transmitted.
+ */
+static uint16_t
+mrvl_tx_sg_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,
+		     uint16_t nb_pkts)
+{
+	struct mrvl_txq *q = txq;
+	struct mrvl_shadow_txq *sq;
+	struct pp2_hif *hif;
+	struct pp2_ppio_desc descs[nb_pkts * PP2_PPIO_DESC_NUM_FRAGS];
+	struct pp2_ppio_sg_pkts pkts;
+	uint8_t frags[nb_pkts];
+	unsigned int core_id = rte_lcore_id();
+	int i, j, ret, bytes_sent = 0;
+	int tail, tail_first;
+	uint16_t num, sq_free_size;
+	uint16_t nb_segs, total_descs = 0;
+	uint64_t addr;
+
+	hif = mrvl_get_hif(q->priv, core_id);
+	sq = &q->shadow_txqs[core_id];
+	pkts.frags = frags;
+	pkts.num = 0;
+
+	if (unlikely(!q->priv->ppio || !hif))
+		return 0;
+
+	if (sq->size)
+		mrvl_free_sent_buffers(q->priv->ppio, hif, core_id,
+				       sq, q->queue_id, 0);
+
+	/* Save shadow queue free size */
+	sq_free_size = MRVL_PP2_TX_SHADOWQ_SIZE - sq->size - 1;
+
+	tail = 0;
+	for (i = 0; i < nb_pkts; i++) {
+		struct rte_mbuf *mbuf = tx_pkts[i];
+		struct rte_mbuf *seg = NULL;
+		int gen_l3_cksum, gen_l4_cksum;
+		enum pp2_outq_l3_type l3_type;
+		enum pp2_outq_l4_type l4_type;
+
+		nb_segs = mbuf->nb_segs;
+		tail_first = tail;
+		total_descs += nb_segs;
+
+		/*
+		 * Check if total_descs does not exceed
+		 * shadow queue free size
+		 */
+		if (unlikely(total_descs > sq_free_size)) {
+			total_descs -= nb_segs;
+			RTE_LOG(DEBUG, PMD,
+				"No room in shadow queue for %d packets! "
+				"%d packets will be sent.\n",
+				nb_pkts, i);
+			break;
+		}
+
+		/* Check if nb_segs does not exceed the max nb of desc per
+		 * fragmented packet
+		 */
+		if (nb_segs > PP2_PPIO_DESC_NUM_FRAGS) {
+			total_descs -= nb_segs;
+			RTE_LOG(ERR, PMD,
+				"Too many segments. Packet won't be sent.\n");
+			break;
+		}
+
+		if (likely(nb_pkts - i > MRVL_MUSDK_PREFETCH_SHIFT)) {
+			struct rte_mbuf *pref_pkt_hdr;
+
+			pref_pkt_hdr = tx_pkts[i + MRVL_MUSDK_PREFETCH_SHIFT];
+			rte_mbuf_prefetch_part1(pref_pkt_hdr);
+			rte_mbuf_prefetch_part2(pref_pkt_hdr);
+		}
+
+		pkts.frags[pkts.num] = nb_segs;
+		pkts.num++;
+
+		seg = mbuf;
+		for (j = 0; j < nb_segs - 1; j++) {
+			/* For the subsequent segments, set shadow queue
+			 * buffer to NULL
+			 */
+			mrvl_fill_shadowq(sq, NULL);
+			mrvl_fill_desc(&descs[tail], seg);
+
+			tail++;
+			seg = seg->next;
+		}
+		/* Put first mbuf info in last shadow queue entry */
+		mrvl_fill_shadowq(sq, mbuf);
+		/* Update descriptor with last segment */
+		mrvl_fill_desc(&descs[tail++], seg);
+
+		bytes_sent += rte_pktmbuf_pkt_len(mbuf);
+		/* In case unsupported ol_flags were passed
+		 * do not update descriptor offload information
+		 */
+		ret = mrvl_prepare_proto_info(mbuf->ol_flags, mbuf->packet_type,
+					      &l3_type, &l4_type, &gen_l3_cksum,
+					      &gen_l4_cksum);
+		if (unlikely(ret))
+			continue;
+
+		pp2_ppio_outq_desc_set_proto_info(&descs[tail_first], l3_type,
+						  l4_type, mbuf->l2_len,
+						  mbuf->l2_len + mbuf->l3_len,
+						  gen_l3_cksum, gen_l4_cksum);
+	}
+
+	num = total_descs;
+	pp2_ppio_send_sg(q->priv->ppio, hif, q->queue_id, descs,
+			 &total_descs, &pkts);
+	/* number of packets that were not sent */
+	if (unlikely(num > total_descs)) {
+		for (i = total_descs; i < num; i++) {
+			sq->head = (MRVL_PP2_TX_SHADOWQ_SIZE + sq->head - 1) &
+				MRVL_PP2_TX_SHADOWQ_MASK;
+
+			addr = sq->ent[sq->head].buff.cookie;
+			if (addr)
+				bytes_sent -=
+					rte_pktmbuf_pkt_len((struct rte_mbuf *)
+						(cookie_addr_high | addr));
+		}
+		sq->size -= num - total_descs;
+		nb_pkts = pkts.num;
+	}
+
+	q->bytes_sent += bytes_sent;
+
+	return nb_pkts;
+}
+
 /**
  * Initialize packet processor.
  *
@@ -2610,11 +2801,11 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name)
 	memcpy(eth_dev->data->mac_addrs[0].addr_bytes,
 	       req.ifr_addr.sa_data, ETHER_ADDR_LEN);
 
-	eth_dev->rx_pkt_burst = mrvl_rx_pkt_burst;
-	eth_dev->tx_pkt_burst = mrvl_tx_pkt_burst;
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
 	eth_dev->data->dev_private = priv;
 	eth_dev->device = &vdev->device;
+	eth_dev->rx_pkt_burst = mrvl_rx_pkt_burst;
+	mrvl_set_tx_function(eth_dev);
 	eth_dev->dev_ops = &mrvl_ops;
 
 	rte_eth_dev_probing_finish(eth_dev);
drivers/net/mvpp2/mrvl_ethdev.h +1 -0
index f0ae983..0120b9e 100644
@@ -188,6 +188,7 @@ struct mrvl_priv {
 	uint8_t uc_mc_flushed;
 	uint8_t vlan_flushed;
 	uint8_t isolated;
+	uint8_t multiseg;
 
 	struct pp2_ppio_params ppio_params;
 	struct pp2_cls_qos_tbl_params qos_tbl_params;
Signature · 1 line
2.7.4
#47 lore raw
In reply to Andrzej Ostruszka
Quoted 32 lines · Andrzej Ostruszka

This patch series introduces fixes and adds support for traffic metering, traffic manager and Tx S/G. Additionally it aligns with for MUSDK 18.09.

Changes in v3:
* change the format of image referred in doc (png -> svg)
* "cherry-pick" http://patches.dpdk.org/patch/44255/ to be part of this patch set so that next-net can compile with new MUSDK also when mvsam is enabled

Changes since v2:
* Align with MUSDK 18.09 library
* Add support for Tx Gather.
* Add documentation related to MTR and TM.
* Align documentation with MUSDK 18.09

Dmitri Epshtein (1):
crypto/mvsam: get number of CIOs dynamically

Natalie Samsonov (4):
net/mvpp2: initialize ppio only once net/mvpp2: update MTU and MRU related calculations net/mvpp2: align documentation with MUSDK 18.09 net/mvpp2: document MTR and TM usage

Tomasz Duszynski (6):
net/mvpp2: move common code
net/mvpp2: add metering support
net/mvpp2: change default policer configuration
net/mvpp2: add init and deinit to flow
net/mvpp2: add traffic manager support
net/mvpp2: align with MUSDK 18.09

Quoted 5 lines

Yuval Caduri (1):
net/mvpp2: detach Tx QoS from Rx cls/QoS config

Zyta Szpak (1):
net/mvpp2: add Tx scatter/gather support

Series applied to dpdk-next-net/master (again), thanks.

patch 10/13 (crypto one) squashed into 9/13 (align with MUSDK 18.09)