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 6A1EDA054F; Mon, 15 Feb 2021 09:50:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DDE131606ED; Mon, 15 Feb 2021 09:50:13 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 7508F40FDF for ; Mon, 15 Feb 2021 09:50:12 +0100 (CET) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 006CF7F504; Mon, 15 Feb 2021 11:50:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 006CF7F504 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1613379012; bh=+WEP3MRwJYV4SpoNHxjC7xkrf2l4DmPt+9+LGQoUPYA=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=vUk5Ss7Qb2+GX6e7wqbwJ8MyYQrCYX0MTDYfQ7DxtXxlMvqnxwYk09SGEW7IXQLE/ 6Qa4UQ8A2JefwajeVEoK2298f/rPwJToGaKh/C25YS5MfXB1HW8MYscDRCzsG27Uv+ 12+e/hPoUG6mrxr00ydn2epWMX99flVDcmDDTzrI= To: Xueming Li Cc: dev@dpdk.org, Viacheslav Ovsiienko , Asaf Penso , Thomas Monjalon , Ferruh Yigit , Ray Kinsella , Neil Horman References: <1613272907-22563-1-git-send-email-xuemingl@nvidia.com> <1613272907-22563-8-git-send-email-xuemingl@nvidia.com> From: Andrew Rybchenko Organization: OKTET Labs Message-ID: <355c5351-f454-cf1f-62ce-6cc9956f36fe@oktetlabs.ru> Date: Mon, 15 Feb 2021 11:50:11 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <1613272907-22563-8-git-send-email-xuemingl@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v6 7/9] 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" On 2/14/21 6:21 AM, Xueming Li wrote: > 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 convert 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 LGTM, except minor notes below. > --- > lib/librte_ethdev/ethdev_driver.h | 6 +++++ > lib/librte_ethdev/rte_ethdev.c | 14 ++++++++++ > lib/librte_ethdev/rte_ethdev.h | 43 +++++++++++++++++++++++++++++++ > lib/librte_ethdev/version.map | 3 +++ > 4 files changed, 66 insertions(+) > > diff --git a/lib/librte_ethdev/ethdev_driver.h b/lib/librte_ethdev/ethdev_driver.h > index 06ff35266f..abcbc3112d 100644 > --- a/lib/librte_ethdev/ethdev_driver.h > +++ b/lib/librte_ethdev/ethdev_driver.h > @@ -289,6 +289,10 @@ typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev, > char *fw_version, size_t fw_size); > /**< @internal Get firmware information of an Ethernet device. */ > > +typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev, > + struct rte_eth_representor_info *info); > +/**< @internal Get representor type and ID range. */ > + > typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt); > /**< @internal Force mbufs to be from TX ring. */ > > @@ -823,6 +827,8 @@ struct eth_dev_ops { > eth_burst_mode_get_t rx_burst_mode_get; /**< Get RX burst mode */ > eth_burst_mode_get_t tx_burst_mode_get; /**< Get TX burst mode */ > eth_fw_version_get_t fw_version_get; /**< Get firmware version. */ > + eth_representor_info_get_t representor_info_get; > + /**< Get representor info. */ Why is it added in the middle of the ops structure? > eth_dev_supported_ptypes_get_t dev_supported_ptypes_get; > /**< Get packet types supported and identified by device. */ > eth_dev_ptypes_set_t dev_ptypes_set; > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c > index fe9466a03e..07c6debb58 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -3265,6 +3265,20 @@ rte_eth_dev_fw_version_get(uint16_t port_id, char *fw_version, size_t fw_size) > fw_version, fw_size)); > } > > +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->fw_version_get, -ENOTSUP); I guess you mean to check representor_info_get here. > + return eth_err(port_id, (*dev->dev_ops->representor_info_get)(dev, > + info)); > +} > + > int > rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info) > { > diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h > index 9cd519bf59..35eb0a5721 100644 > --- a/lib/librte_ethdev/rte_ethdev.h > +++ b/lib/librte_ethdev/rte_ethdev.h > @@ -1581,6 +1581,30 @@ struct rte_eth_dev_info { > void *reserved_ptrs[2]; /**< Reserved for future fields */ > }; > > +/** > + * @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 { > + enum rte_eth_representor_type type; /**< Representor type */ > + int controller; /**< Controller ID, -1 to ignore */ > + int pf; /**< Physical function ID, -1 to ignore */ > + __extension__ > + union { > + int vf; /**< VF start index */ > + int sf; /**< SF start index */ > + }; > + uint16_t id_base; /**< Representor ID start index */ > + uint16_t id_end; /**< Representor ID end index */ > + char name[RTE_DEV_NAME_MAX_LEN]; /**< Representor name */ > + } ranges[]; /**< Representor ID range by type */ I'm pretty sure that you need separate type for the structure when you add support, since you need to allocate memory and calculate required size. > +}; > + > /** > * Ethernet device RX queue information structure. > * Used to retrieve information about configured queue. > @@ -3038,6 +3062,25 @@ int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr); > */ > int rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info); > > +/** > + * Retrieve the representor info of the device. > + * > + * @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); > + > /** > * Retrieve the firmware version of a device. > *