DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wenzhuo Lu <wenzhuo.lu@intel.com>
To: dev@dpdk.org
Cc: cristian.dumitrescu@intel.com, jasvinder.singh@intel.com,
	jingjing.wu@intel.com, Wenzhuo Lu <wenzhuo.lu@intel.com>
Subject: [dpdk-dev] [PATCH v2 13/20] net/ixgbe: support adding TM shaper profile
Date: Mon, 19 Jun 2017 13:43:49 +0800	[thread overview]
Message-ID: <1497851036-96016-14-git-send-email-wenzhuo.lu@intel.com> (raw)
In-Reply-To: <1497851036-96016-1-git-send-email-wenzhuo.lu@intel.com>

Add the support of the Traffic Management API,
rte_tm_shaper_profile_add.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c |   6 +++
 drivers/net/ixgbe/ixgbe_ethdev.h |  21 ++++++++
 drivers/net/ixgbe/ixgbe_tm.c     | 111 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 138 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ab70c1c..26eaece 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1360,6 +1360,9 @@ struct rte_ixgbe_xstats_name_off {
 	/* initialize bandwidth configuration info */
 	memset(bw_conf, 0, sizeof(struct ixgbe_bw_conf));
 
+	/* initialize Traffic Manager configuration */
+	ixgbe_tm_conf_init(eth_dev);
+
 	return 0;
 }
 
@@ -1413,6 +1416,9 @@ struct rte_ixgbe_xstats_name_off {
 	/* clear all the filters list */
 	ixgbe_filterlist_flush();
 
+	/* Remove all Traffic Manager configuration */
+	ixgbe_tm_conf_uninit(eth_dev);
+
 	return 0;
 }
 
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 7e99fd3..b647702 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -435,6 +435,21 @@ struct ixgbe_bw_conf {
 	uint8_t tc_num; /* Number of TCs. */
 };
 
+/* Struct to store Traffic Manager shaper profile. */
+struct ixgbe_tm_shaper_profile {
+	TAILQ_ENTRY(ixgbe_tm_shaper_profile) node;
+	uint32_t shaper_profile_id;
+	uint32_t reference_count;
+	struct rte_tm_shaper_params profile;
+};
+
+TAILQ_HEAD(ixgbe_shaper_profile_list, ixgbe_tm_shaper_profile);
+
+/* The configuration of Traffic Manager */
+struct ixgbe_tm_conf {
+	struct ixgbe_shaper_profile_list shaper_profile_list;
+};
+
 /*
  * Structure to store private data for each driver instance (for each port).
  */
@@ -463,6 +478,7 @@ struct ixgbe_adapter {
 	struct rte_timecounter      systime_tc;
 	struct rte_timecounter      rx_tstamp_tc;
 	struct rte_timecounter      tx_tstamp_tc;
+	struct ixgbe_tm_conf        tm_conf;
 };
 
 #define IXGBE_DEV_TO_PCI(eth_dev) \
@@ -513,6 +529,9 @@ struct ixgbe_adapter {
 #define IXGBE_DEV_PRIVATE_TO_BW_CONF(adapter) \
 	(&((struct ixgbe_adapter *)adapter)->bw_conf)
 
+#define IXGBE_DEV_PRIVATE_TO_TM_CONF(adapter) \
+	(&((struct ixgbe_adapter *)adapter)->tm_conf)
+
 /*
  * RX/TX function prototypes
  */
@@ -673,6 +692,8 @@ int ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
 			    uint16_t tx_rate, uint64_t q_msk);
 bool is_ixgbe_supported(struct rte_eth_dev *dev);
 int ixgbe_tm_ops_get(struct rte_eth_dev *dev, void *ops);
+void ixgbe_tm_conf_init(struct rte_eth_dev *dev);
+void ixgbe_tm_conf_uninit(struct rte_eth_dev *dev);
 
 static inline int
 ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,
diff --git a/drivers/net/ixgbe/ixgbe_tm.c b/drivers/net/ixgbe/ixgbe_tm.c
index 77066b7..89e795a 100644
--- a/drivers/net/ixgbe/ixgbe_tm.c
+++ b/drivers/net/ixgbe/ixgbe_tm.c
@@ -31,14 +31,21 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <rte_malloc.h>
+
 #include "ixgbe_ethdev.h"
 
 static int ixgbe_tm_capabilities_get(struct rte_eth_dev *dev,
 				     struct rte_tm_capabilities *cap,
 				     struct rte_tm_error *error);
+static int ixgbe_shaper_profile_add(struct rte_eth_dev *dev,
+				    uint32_t shaper_profile_id,
+				    struct rte_tm_shaper_params *profile,
+				    struct rte_tm_error *error);
 
 const struct rte_tm_ops ixgbe_tm_ops = {
 	.capabilities_get = ixgbe_tm_capabilities_get,
+	.shaper_profile_add = ixgbe_shaper_profile_add,
 };
 
 int
@@ -53,6 +60,32 @@ static int ixgbe_tm_capabilities_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+void
+ixgbe_tm_conf_init(struct rte_eth_dev *dev)
+{
+	struct ixgbe_tm_conf *tm_conf =
+		IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
+
+	/* initialize shaper profile list */
+	TAILQ_INIT(&tm_conf->shaper_profile_list);
+}
+
+void
+ixgbe_tm_conf_uninit(struct rte_eth_dev *dev)
+{
+	struct ixgbe_tm_conf *tm_conf =
+		IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
+	struct ixgbe_tm_shaper_profile *shaper_profile;
+
+	/* Remove all shaper profiles */
+	while ((shaper_profile =
+	       TAILQ_FIRST(&tm_conf->shaper_profile_list))) {
+		TAILQ_REMOVE(&tm_conf->shaper_profile_list,
+			     shaper_profile, node);
+		rte_free(shaper_profile);
+	}
+}
+
 static inline uint8_t
 ixgbe_tc_nb_get(struct rte_eth_dev *dev)
 {
@@ -136,3 +169,81 @@ static int ixgbe_tm_capabilities_get(struct rte_eth_dev *dev,
 
 	return 0;
 }
+
+static inline struct ixgbe_tm_shaper_profile *
+ixgbe_shaper_profile_search(struct rte_eth_dev *dev,
+			    uint32_t shaper_profile_id)
+{
+	struct ixgbe_tm_conf *tm_conf =
+		IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
+	struct ixgbe_shaper_profile_list *shaper_profile_list =
+		&tm_conf->shaper_profile_list;
+	struct ixgbe_tm_shaper_profile *shaper_profile;
+
+	TAILQ_FOREACH(shaper_profile, shaper_profile_list, node) {
+		if (shaper_profile_id == shaper_profile->shaper_profile_id)
+			return shaper_profile;
+	}
+
+	return NULL;
+}
+
+static int
+ixgbe_shaper_profile_add(struct rte_eth_dev *dev,
+			 uint32_t shaper_profile_id,
+			 struct rte_tm_shaper_params *profile,
+			 struct rte_tm_error *error)
+{
+	struct ixgbe_tm_conf *tm_conf =
+		IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
+	struct ixgbe_tm_shaper_profile *shaper_profile;
+
+	if (!profile || !error)
+		return -EINVAL;
+
+	/* min rate not supported */
+	if (profile->committed.rate) {
+		error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE;
+		error->message = "committed rate not supported";
+		return -EINVAL;
+	}
+	/* min bucket size not supported */
+	if (profile->committed.size) {
+		error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE;
+		error->message = "committed bucket size not supported";
+		return -EINVAL;
+	}
+	/* max bucket size not supported */
+	if (profile->peak.size) {
+		error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE;
+		error->message = "peak bucket size not supported";
+		return -EINVAL;
+	}
+	/* length adjustment not supported */
+	if (profile->pkt_length_adjust) {
+		error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN;
+		error->message = "packet length adjustment not supported";
+		return -EINVAL;
+	}
+
+	shaper_profile = ixgbe_shaper_profile_search(dev, shaper_profile_id);
+
+	if (shaper_profile) {
+		error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID;
+		error->message = "profile ID exist";
+		return -EINVAL;
+	}
+
+	shaper_profile = rte_zmalloc("ixgbe_tm_shaper_profile",
+				     sizeof(struct ixgbe_tm_shaper_profile),
+				     0);
+	if (!shaper_profile)
+		return -ENOMEM;
+	shaper_profile->shaper_profile_id = shaper_profile_id;
+	(void)rte_memcpy(&shaper_profile->profile, profile,
+			 sizeof(struct rte_tm_shaper_params));
+	TAILQ_INSERT_TAIL(&tm_conf->shaper_profile_list,
+			  shaper_profile, node);
+
+	return 0;
+}
-- 
1.9.3

  parent reply	other threads:[~2017-06-19  5:43 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-27  8:17 [dpdk-dev] [PATCH 00/20] traffic manager on i40e and ixgbe Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 01/20] net/i40e: support getting TM ops Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 02/20] net/i40e: support getting TM capability Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 03/20] net/i40e: support adding TM shaper profile Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 04/20] net/i40e: support deleting " Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 05/20] net/i40e: support adding TM node Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 06/20] net/i40e: support deleting " Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 07/20] net/i40e: support getting TM node type Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 08/20] net/i40e: support getting TM level capability Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 09/20] net/i40e: support getting TM node capability Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 10/20] net/i40e: support committing TM hierarchy Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 11/20] net/ixgbe: support getting TM ops Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 12/20] net/ixgbe: support getting TM capability Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 13/20] net/ixgbe: support adding TM shaper profile Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 14/20] net/ixgbe: support deleting " Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 15/20] net/ixgbe: support adding TM node Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 16/20] net/ixgbe: support deleting " Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 17/20] net/ixgbe: support getting TM node type Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 18/20] net/ixgbe: support getting TM level capability Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 19/20] net/ixgbe: support getting TM node capability Wenzhuo Lu
2017-05-27  8:17 ` [dpdk-dev] [PATCH 20/20] net/ixgbe: support committing TM hierarchy Wenzhuo Lu
2017-06-08 11:19 ` [dpdk-dev] [PATCH 00/20] traffic manager on i40e and ixgbe Ferruh Yigit
2017-06-08 12:52   ` Thomas Monjalon
2017-06-19  5:43 ` [dpdk-dev] [PATCH v2 " Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 01/20] net/i40e: support getting TM ops Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 02/20] net/i40e: support getting TM capability Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 03/20] net/i40e: support adding TM shaper profile Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 04/20] net/i40e: support deleting " Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 05/20] net/i40e: support adding TM node Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 06/20] net/i40e: support deleting " Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 07/20] net/i40e: support getting TM node type Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 08/20] net/i40e: support getting TM level capability Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 09/20] net/i40e: support getting TM node capability Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 10/20] net/i40e: support committing TM hierarchy Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 11/20] net/ixgbe: support getting TM ops Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 12/20] net/ixgbe: support getting TM capability Wenzhuo Lu
2017-06-19  5:43   ` Wenzhuo Lu [this message]
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 14/20] net/ixgbe: support deleting TM shaper profile Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 15/20] net/ixgbe: support adding TM node Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 16/20] net/ixgbe: support deleting " Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 17/20] net/ixgbe: support getting TM node type Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 18/20] net/ixgbe: support getting TM level capability Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 19/20] net/ixgbe: support getting TM node capability Wenzhuo Lu
2017-06-19  5:43   ` [dpdk-dev] [PATCH v2 20/20] net/ixgbe: support committing TM hierarchy Wenzhuo Lu
2017-06-29  4:23 ` [dpdk-dev] [PATCH v3 00/20] traffic manager on i40e and ixgbe Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 01/20] net/i40e: support getting TM ops Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 02/20] net/i40e: support getting TM capability Wenzhuo Lu
2017-07-09 19:31     ` Thomas Monjalon
2017-07-10 11:17       ` Dumitrescu, Cristian
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 03/20] net/i40e: support adding TM shaper profile Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 04/20] net/i40e: support deleting " Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 05/20] net/i40e: support adding TM node Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 06/20] net/i40e: support deleting " Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 07/20] net/i40e: support getting TM node type Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 08/20] net/i40e: support getting TM level capability Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 09/20] net/i40e: support getting TM node capability Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 10/20] net/i40e: support committing TM hierarchy Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 11/20] net/ixgbe: support getting TM ops Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 12/20] net/ixgbe: support getting TM capability Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 13/20] net/ixgbe: support adding TM shaper profile Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 14/20] net/ixgbe: support deleting " Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 15/20] net/ixgbe: support adding TM node Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 16/20] net/ixgbe: support deleting " Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 17/20] net/ixgbe: support getting TM node type Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 18/20] net/ixgbe: support getting TM level capability Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 19/20] net/ixgbe: support getting TM node capability Wenzhuo Lu
2017-06-29  4:23   ` [dpdk-dev] [PATCH v3 20/20] net/ixgbe: support committing TM hierarchy Wenzhuo Lu
2017-07-04 15:11   ` [dpdk-dev] [PATCH v3 00/20] traffic manager on i40e and ixgbe Dumitrescu, Cristian

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1497851036-96016-14-git-send-email-wenzhuo.lu@intel.com \
    --to=wenzhuo.lu@intel.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=jasvinder.singh@intel.com \
    --cc=jingjing.wu@intel.com \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).