From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 42D263DC for ; Mon, 12 Jun 2017 15:35:44 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jun 2017 06:35:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,333,1493708400"; d="scan'208";a="97100538" Received: from silpixa00382658.ir.intel.com ([10.237.223.29]) by orsmga004.jf.intel.com with ESMTP; 12 Jun 2017 06:35:42 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: thomas@monjalon.net, jerin.jacob@caviumnetworks.com, balasubramanian.manoharan@cavium.com, hemant.agrawal@nxp.com, shreyansh.jain@nxp.com, jasvinder.singh@intel.com, wenzhuo.lu@intel.com Date: Mon, 12 Jun 2017 14:35:38 +0100 Message-Id: <1497274539-187029-2-git-send-email-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497274539-187029-1-git-send-email-cristian.dumitrescu@intel.com> References: <1497027075-31738-3-git-send-email-cristian.dumitrescu@intel.com> <1497274539-187029-1-git-send-email-cristian.dumitrescu@intel.com> Subject: [dpdk-dev] [PATCH v6 1/2] ethdev: add traffic management ops get API 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, 12 Jun 2017 13:35:46 -0000 The rte_flow feature breaks the monolithic approach for ethdev by introducing the new rte_flow API to ethdev using a plugin-like approach. Basically, the rte_flow API is still logically part of ethdev: - It extends the ethdev functionality: rte_flow is a new feature/ capability of ethdev; - all its functions work on an Ethernet device: the first parameter of the rte_flow functions is Ethernet device port ID. Also, the rte_flow API is a sort of capability plugin for ethdev: - the rte_flow API functions have their own name space: they are called rte_flow_operationXYZ() as opposed to rte_eth_dev_flow_operationXYZ()); - the rte_flow API functions are placed in separate files in the same librte_ether folder as opposed to rte_ethdev.[hc]. The way it works is by using the existing ethdev API function rte_eth_dev_filter_ctrl() to query the current Ethernet device port ID for the support of the rte_flow capability and return the pointer to the rte_flow operations when supported and NULL otherwise: struct rte_flow_ops *eth_flow_ops; int rte = rte_eth_dev_filter_ctrl(eth_port_id, RTE_ETH_FILTER_GENERIC, RTE_ETH_FILTER_GET, ð_flow_ops); This patch reuses the same approach for ethdev Traffic Management API. Signed-off-by: Cristian Dumitrescu Acked-by: Keith Wiles Acked-by: Jerin Jacob Acked-by: Hemant Agrawal --- Changes in v4: - Followed up on suggestion from Thomas: Replaced generic capability ethdev API function with traffic management specific function rte_eth_dev_tm_ops_get() Changes in v3: - Followed up on suggestion from Jerin: renamed capability from Hierarchical Scheduler (sched) to Traffic Manager (tm) Changes in v2: - Followed up on suggestion from Jerin and Hemant: renamed capability_control() to capability_ops_get() - Added ACK from Keith, Jerin and Hemant lib/librte_ether/rte_ethdev.c | 12 ++++++++++++ lib/librte_ether/rte_ethdev.h | 20 ++++++++++++++++++++ lib/librte_ether/rte_ether_version.map | 6 ++++++ 3 files changed, 38 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 64aefdd..7d2c7e1 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3020,6 +3020,18 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type, return (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op, arg); } +int +rte_eth_dev_tm_ops_get(uint8_t port_id, void *ops) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tm_ops_get, -ENOTSUP); + return (*dev->dev_ops->tm_ops_get)(dev, ops); +} + void * rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id, rte_rx_callback_fn fn, void *user_param) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 2784ad1..78beb60 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1441,6 +1441,9 @@ typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev, void *arg); /**< @internal Take operations to assigned filter type on an Ethernet device */ +typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops); +/**< @internal Get Traffic Management (TM) operations on an Ethernet device */ + typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev, struct rte_eth_dcb_info *dcb_info); /**< @internal Get dcb information on an Ethernet device */ @@ -1573,6 +1576,9 @@ struct eth_dev_ops { /**< Get extended device statistic values by ID. */ eth_xstats_get_names_by_id_t xstats_get_names_by_id; /**< Get name of extended device statistics by ID. */ + + eth_tm_ops_get_t tm_ops_get; + /**< Get Traffic Management (TM) operations. */ }; /** @@ -4105,6 +4111,20 @@ int rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type, enum rte_filter_op filter_op, void *arg); /** + * Take Traffic Management (TM) operations on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param ops + * Pointer to TM operations. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support. + * - (-ENODEV) if *port_id* invalid. + */ +int rte_eth_dev_tm_ops_get(uint8_t port_id, void *ops); + +/** * Get DCB information on an Ethernet device. * * @param port_id diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index d6726bb..2788e7b 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -156,3 +156,9 @@ DPDK_17.05 { rte_eth_xstats_get_names_by_id; } DPDK_17.02; + +DPDK_17.08 { + global: + + rte_eth_dev_tm_ops_get; +} DPDK_17.05; -- 2.7.4