From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id E4460968 for ; Mon, 19 Jun 2017 07:43:26 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP; 18 Jun 2017 22:43:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,359,1493708400"; d="scan'208";a="1184169588" Received: from dpdk26.sh.intel.com ([10.239.129.102]) by fmsmga002.fm.intel.com with ESMTP; 18 Jun 2017 22:43:25 -0700 From: Wenzhuo Lu To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, jasvinder.singh@intel.com, jingjing.wu@intel.com, Wenzhuo Lu Date: Mon, 19 Jun 2017 13:43:38 +0800 Message-Id: <1497851036-96016-3-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1497851036-96016-1-git-send-email-wenzhuo.lu@intel.com> References: <1495873075-49542-1-git-send-email-wenzhuo.lu@intel.com> <1497851036-96016-1-git-send-email-wenzhuo.lu@intel.com> Subject: [dpdk-dev] [PATCH v2 02/20] net/i40e: support getting TM capability X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jun 2017 05:43:27 -0000 Add the support of the Traffic Management API, rte_tm_capabilities_get. Signed-off-by: Wenzhuo Lu --- drivers/net/i40e/i40e_tm.c | 82 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/drivers/net/i40e/i40e_tm.c b/drivers/net/i40e/i40e_tm.c index 2f4c866..86a2f74 100644 --- a/drivers/net/i40e/i40e_tm.c +++ b/drivers/net/i40e/i40e_tm.c @@ -34,8 +34,12 @@ #include "base/i40e_prototype.h" #include "i40e_ethdev.h" +static int i40e_tm_capabilities_get(struct rte_eth_dev *dev, + struct rte_tm_capabilities *cap, + struct rte_tm_error *error); + const struct rte_tm_ops i40e_tm_ops = { - NULL, + .capabilities_get = i40e_tm_capabilities_get, }; int @@ -49,3 +53,79 @@ return 0; } + +static inline uint16_t +i40e_tc_nb_get(struct rte_eth_dev *dev) +{ + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct i40e_vsi *main_vsi = pf->main_vsi; + uint16_t sum = 0; + int i; + + for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { + if (main_vsi->enabled_tc & BIT_ULL(i)) + sum++; + } + + return sum; +} + +static int +i40e_tm_capabilities_get(struct rte_eth_dev *dev, + struct rte_tm_capabilities *cap, + struct rte_tm_error *error) +{ + uint16_t tc_nb = 0; + + if (!cap || !error) + return -EINVAL; + + error->type = RTE_TM_ERROR_TYPE_NONE; + + /* set all the parameters to 0 first. */ + memset(cap, 0, sizeof(struct rte_tm_capabilities)); + + /* only support port + TCs */ + tc_nb = i40e_tc_nb_get(dev); + cap->n_nodes_max = tc_nb + 1; + cap->n_levels_max = 2; + cap->non_leaf_nodes_identical = 0; + cap->leaf_nodes_identical = 0; + cap->shaper_n_max = cap->n_nodes_max; + cap->shaper_private_n_max = cap->n_nodes_max; + cap->shaper_private_dual_rate_n_max = 0; + cap->shaper_private_rate_min = 0; + /* 40Gbps -> 5GBps */ + cap->shaper_private_rate_max = 5000000000ull; + cap->shaper_shared_n_max = 0; + cap->shaper_shared_n_nodes_per_shaper_max = 0; + cap->shaper_shared_n_shapers_per_node_max = 0; + cap->shaper_shared_dual_rate_n_max = 0; + cap->shaper_shared_rate_min = 0; + cap->shaper_shared_rate_max = 0; + cap->sched_n_children_max = tc_nb; + cap->sched_sp_n_priorities_max = 0; + cap->sched_wfq_n_children_per_group_max = 0; + cap->sched_wfq_n_groups_max = 0; + cap->sched_wfq_weight_max = 0; + cap->cman_head_drop_supported = 0; + cap->dynamic_update_mask = 0; + + /** + * not supported parameters are 0, below, + * shaper_pkt_length_adjust_min + * shaper_pkt_length_adjust_max + * cman_wred_context_n_max + * cman_wred_context_private_n_max + * cman_wred_context_shared_n_max + * cman_wred_context_shared_n_nodes_per_context_max + * cman_wred_context_shared_n_contexts_per_node_max + * mark_vlan_dei_supported + * mark_ip_ecn_tcp_supported + * mark_ip_ecn_sctp_supported + * mark_ip_dscp_supported + * stats_mask + */ + + return 0; +} -- 1.9.3