From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 2D8E82B88 for ; Fri, 24 Feb 2017 17:28:16 +0100 (CET) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2017 08:28:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,201,1484035200"; d="scan'208";a="68698642" Received: from silpixa00382659.ir.intel.com ([10.237.223.208]) by orsmga005.jf.intel.com with ESMTP; 24 Feb 2017 08:28:14 -0800 From: Cristian Dumitrescu To: dev@dpdk.org Cc: thomas.monjalon@6wind.com, jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com Date: Fri, 24 Feb 2017 16:28:11 +0000 Message-Id: <1487953692-107094-2-git-send-email-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1487953692-107094-1-git-send-email-cristian.dumitrescu@intel.com> References: <1487953692-107094-1-git-send-email-cristian.dumitrescu@intel.com> Subject: [dpdk-dev] [PATCH v2 1/2] ethdev: add capability control 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: Fri, 24 Feb 2017 16:28:17 -0000 The rte_flow feature breaks the current monolithic approach for ethdev and introduces the new generic 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. At the same time, 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); Unfortunately, the rte_flow opportunistically uses the rte_eth_dev_filter_ctrl() API function, which is applicable just to RX-side filters as opposed to introducing a mechanism that could be used by any capability in a generic way. This is the gap that addressed by the current patch. This mechanism is intended to be used to introduce new capabilities into ethdev in a modular plugin-like approach, such as hierarchical scheduler. Over time, if agreed, it can also be used for exposing the existing Ethernet device capabilities in a modular way, such as: xstats, filters, multicast, mirroring, tunnels, time stamping, eeprom, bypass, etc. 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 Signed-off-by: Cristian Dumitrescu Acked-by: Keith Wiles Acked-by: Jerin Jacob Acked-by: Hemant Agrawal --- lib/librte_ether/rte_ethdev.c | 13 +++++++++++++ lib/librte_ether/rte_ethdev.h | 29 +++++++++++++++++++++++++++++ lib/librte_ether/rte_ether_version.map | 7 +++++++ 3 files changed, 49 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index eb0a94a..674bbae 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -2802,6 +2802,19 @@ 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_capability_ops_get(uint8_t port_id, enum rte_eth_capability cap, + void *arg) +{ + 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->cap_ops_get, -ENOTSUP); + return (*dev->dev_ops->cap_ops_get)(dev, cap, arg); +} + 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 97f3e2d..e56d160 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1073,6 +1073,12 @@ TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback); * structure associated with an Ethernet device. */ +enum rte_eth_capability { + RTE_ETH_CAPABILITY_FLOW = 0, /**< Flow */ + RTE_ETH_CAPABILITY_SCHED, /**< Hierarchical Scheduler */ + RTE_ETH_CAPABILITY_MAX +}; + typedef int (*eth_dev_configure_t)(struct rte_eth_dev *dev); /**< @internal Ethernet device configuration. */ @@ -1427,6 +1433,10 @@ 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_capability_ops_get_t)(struct rte_eth_dev *dev, + enum rte_eth_capability cap, void *arg); +/**< @internal Take capability 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 */ @@ -1548,6 +1558,8 @@ struct eth_dev_ops { eth_timesync_adjust_time timesync_adjust_time; /** Adjust the device clock. */ eth_timesync_read_time timesync_read_time; /** Get the device clock time. */ eth_timesync_write_time timesync_write_time; /** Set the device clock time. */ + + eth_capability_ops_get_t cap_ops_get; /**< capability control. */ }; /** @@ -3890,6 +3902,23 @@ 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 capability operations on an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param cap + * The capability of the Ethernet device + * @param arg + * A pointer to arguments defined specifically for the operation. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support. + * - (-ENODEV) if *port_id* invalid. + */ +int rte_eth_dev_capability_ops_get(uint8_t port_id, + enum rte_eth_capability cap, void *arg); + +/** * 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 c6c9d0d..637317c 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -154,3 +154,10 @@ DPDK_17.02 { rte_flow_validate; } DPDK_16.11; + +DPDK_17.05 { + global: + + rte_eth_dev_capability_ops_get; + +} DPDK_17.02; -- 2.5.0