From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D4085A0575; Thu, 11 Mar 2021 14:14:59 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9745822A4C7; Thu, 11 Mar 2021 14:14:29 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 3259222A4C7 for ; Thu, 11 Mar 2021 14:14:28 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 11 Mar 2021 15:14:27 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 12BDDkZA023953; Thu, 11 Mar 2021 15:14:27 +0200 From: Xueming Li To: Andrew Rybchenko , Ferruh Yigit Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso , Thomas Monjalon , Ray Kinsella , Neil Horman Date: Thu, 11 Mar 2021 13:13:31 +0000 Message-Id: <1615468416-10115-9-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615468416-10115-1-git-send-email-xuemingl@nvidia.com> References: <1615468416-10115-1-git-send-email-xuemingl@nvidia.com> In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v9 08/10] ethdev: new API to get representor info X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The NIC can have multiple PCIe links and can be attached to multiple hosts, for example the same single NIC can be shared for multiple server units in the rack. On each PCIe link NIC can provide multiple PFs and VFs/SFs based on these ones. The full representor identifier consists of three indices - controller index, PF index, and VF or SF index (if any). This patch introduces a new API rte_eth_representor_info_get() to retrieve representor corresponding info mapping: - caller controller index and pf index. - supported representor ID ranges. - type, controller, pf and start vf/sf ID of each range. The API is useful to calculate representor from devargs to representor ID. New ethdev callback representor_info_get() is added to retrieve info from PMD driver, optional for PMD that doesn't support new devargs representor syntax. Signed-off-by: Xueming Li Acked-by: Andrew Rybchenko --- lib/librte_ethdev/ethdev_driver.h | 27 ++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 14 ++++++++ lib/librte_ethdev/rte_ethdev.h | 54 +++++++++++++++++++++++++++++++ lib/librte_ethdev/version.map | 3 ++ 4 files changed, 98 insertions(+) diff --git a/lib/librte_ethdev/ethdev_driver.h b/lib/librte_ethdev/ethdev_driver.h index 06ff35266f..067be38f33 100644 --- a/lib/librte_ethdev/ethdev_driver.h +++ b/lib/librte_ethdev/ethdev_driver.h @@ -783,6 +783,30 @@ typedef int (*eth_hairpin_queue_peer_unbind_t) typedef int (*eth_get_monitor_addr_t)(void *rxq, struct rte_power_monitor_cond *pmc); +/** + * @internal + * Get representor info to be able to calculate the unique representor ID. + * + * Caller should pass NULL as pointer of info to get number of entries, + * allocate info buffer according to returned entry number, then call + * again with buffer to get real info. + * + * To calculate the representor ID, caller should iterate each entry, + * match controller index, pf index, vf or sf start index and range, + * then calculate representor ID from offset to vf/sf start index. + * @see rte_eth_representor_id_get. + * + * @param dev + * Ethdev handle of port. + * @param [out] info + * Pointer to memory to save device representor info. + * @return + * Negative errno value on error, number of info entries otherwise. + */ + +typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev, + struct rte_eth_representor_info *info); + /** * @internal A structure containing the functions exported by an Ethernet driver. */ @@ -940,6 +964,9 @@ struct eth_dev_ops { eth_get_monitor_addr_t get_monitor_addr; /**< Get power monitoring condition for Rx queue. */ + + eth_representor_info_get_t representor_info_get; + /**< Get representor info. */ }; /** diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 60889a8663..3d4ec8ad5c 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -5816,6 +5816,20 @@ rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue, direction); } +int +rte_eth_representor_info_get(uint16_t port_id, + struct rte_eth_representor_info *info) +{ + 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->representor_info_get, -ENOTSUP); + return eth_err(port_id, (*dev->dev_ops->representor_info_get)(dev, + info)); +} + RTE_LOG_REGISTER(rte_eth_dev_logtype, lib.ethdev, INFO); RTE_INIT(ethdev_init_telemetry) diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 9cd519bf59..efda3137f7 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -4791,6 +4791,60 @@ __rte_experimental int rte_eth_dev_hairpin_capability_get(uint16_t port_id, struct rte_eth_hairpin_cap *cap); +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice. + * + * ethernet device representor ID range entry + */ +struct rte_eth_representor_range { + enum rte_eth_representor_type type; /**< Representor type */ + int controller; /**< Controller index */ + int pf; /**< Physical function index */ + __extension__ + union { + int vf; /**< VF start index */ + int sf; /**< SF start index */ + }; + uint32_t id_base; /**< Representor ID start index */ + uint32_t id_end; /**< Representor ID end index */ + char name[RTE_DEV_NAME_MAX_LEN]; /**< Representor name */ +}; + +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice. + * + * Ethernet device representor information + */ +struct rte_eth_representor_info { + uint16_t controller; /**< Controller ID of caller device. */ + uint16_t pf; /**< Physical function ID of caller device. */ + struct rte_eth_representor_range ranges[];/**< Representor ID range. */ +}; + +/** + * Retrieve the representor info of the device. + * + * Get device representor info to be able to calculate a unique + * representor ID. @see rte_eth_representor_id_get helper. + * + * @param port_id + * The port identifier of the device. + * @param info + * A pointer to a representor info structure. + * NULL to return number of range entries and allocate memory + * for next call to store detail. + * @return + * - (-ENOTSUP) if operation is not supported. + * - (-ENODEV) if *port_id* invalid. + * - (-EIO) if device is removed. + * - (>=0) number of representor range entries supported by device. + */ +__rte_experimental +int rte_eth_representor_info_get(uint16_t port_id, + struct rte_eth_representor_info *info); + #include /** diff --git a/lib/librte_ethdev/version.map b/lib/librte_ethdev/version.map index a124e1e370..bb6f7436c2 100644 --- a/lib/librte_ethdev/version.map +++ b/lib/librte_ethdev/version.map @@ -243,6 +243,9 @@ EXPERIMENTAL { # added in 21.02 rte_eth_get_monitor_addr; + + # added in 21.05 + rte_eth_representor_info_get; }; INTERNAL { -- 2.25.1