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 3CC44A0A03; Tue, 19 Jan 2021 09:20:57 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1E270140D21; Tue, 19 Jan 2021 09:20:57 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id B6AC1140CF7 for ; Tue, 19 Jan 2021 09:20:55 +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 4A5847F5B4; Tue, 19 Jan 2021 11:20:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 4A5847F5B4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1611044455; bh=JjTbpXFDnp1De0j1ra7l2z6zqavSlKh8TYX7zmDrkEY=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=fHc+kMc2W7bbF6YAUP5uyIIrIP9vAHjQdchbPXyD4Z98iTLwyHS/QN+X2a6n9c0AC x0Bz3s0IDCEa66fl+ddT6P0006VhW5xMROZKcTwgKTFr8Lr3bFUVh04oIi94D6caUl lEhfr++oiclcJ/yP2ElHh5B6qP/psmd4hzHG/lUo= To: Xueming Li Cc: dev@dpdk.org, Viacheslav Ovsiienko , Asaf Penso , Ajit Khaparde , Somnath Kotur , John Daley , Hyong Youb Kim , Beilei Xing , Jeff Guo , Haiyue Wang , Matan Azrad , Shahaf Shuler , Thomas Monjalon , Ferruh Yigit , Ray Kinsella , Neil Horman References: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> <1611040501-11666-7-git-send-email-xuemingl@nvidia.com> From: Andrew Rybchenko Organization: OKTET Labs Message-ID: <7309bfb0-63bb-e0c6-bd0d-2258cc94ad74@oktetlabs.ru> Date: Tue, 19 Jan 2021 11:20:55 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <1611040501-11666-7-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 v5 7/9] devarg: change representor ID to bitmap 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 1/19/21 10:14 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). > > SR-IOV and SubFunction are created on top of PF. PF index is introduced > because there might be multiple PFs in the bonding configuration and > only bonding device is probed. > > In eth representor comparator callback, ethdev was compared with devarg. > Since ethdev representor port didn't contain controller index and PF > index information, callback returned representor from other PF or > controller. > > This patch changes representor ID to bitmap so that the ethdev > representor comparer callback returns correct ethdev by comparing full > representor information including: controller index, PF index, > representor type, SF or VF index. > > Representor ID bitmap definition: > xxxx xxxx xxxx xxxx > |||| |LLL LLLL LLLL vf/sf id > |||| L 1:sf, 0:vf > ||LL pf id > LL controller(host) id What about PF representor case? I.e. representor for entire PF. Also it implies that controller ID 0 is the caller. I.e. special meaning. So, space for just 3 specific contoller left Similar for PF. In fact it is worse. E.g. PMD is bound to the second PF (PF number 1). If so, vf0 means the first VF of the PF itself, i.e. PF 1 VF 0. But, pf0vf0 should mean PF 1 VF 1. > > This approach keeps binary compatibility with all drivers, VF > representor id matches with simple id for non-bonding and non-multi-host > configurations. > > In the future, the representor ID field and each section should extend > to bigger width to support more devices. > > Signed-off-by: Xueming Li > Acked-by: Viacheslav Ovsiienko > Acked-by: Thomas Monjalon > diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c > index efe6149df5..994db96960 100644 > --- a/lib/librte_ethdev/rte_class_eth.c > +++ b/lib/librte_ethdev/rte_class_eth.c > @@ -66,8 +66,8 @@ eth_representor_cmp(const char *key __rte_unused, > int ret; > char *values; > const struct rte_eth_dev_data *data = opaque; > - struct rte_eth_devargs representors; > - uint16_t index; > + struct rte_eth_devargs eth_da; > + uint16_t index, c, p, f; > > if ((data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) > return -1; /* not a representor port */ > @@ -76,17 +76,39 @@ eth_representor_cmp(const char *key __rte_unused, > values = strdup(value); > if (values == NULL) > return -1; > - memset(&representors, 0, sizeof(representors)); > - ret = rte_eth_devargs_parse_representor_ports(values, &representors); > + memset(ð_da, 0, sizeof(eth_da)); > + ret = rte_eth_devargs_parse_representor_ports(values, ð_da); > free(values); > if (ret != 0) > return -1; /* invalid devargs value */ > > + /* Set default values. */ > + if (eth_da.nb_mh_controllers == 0) { > + eth_da.nb_mh_controllers = 1; > + eth_da.mh_controllers[0] = 0; > + } > + if (eth_da.nb_ports == 0) { > + eth_da.nb_ports = 1; > + eth_da.ports[0] = 0; > + } > + if (eth_da.nb_representor_ports == 0) { > + eth_da.nb_representor_ports = 1; > + eth_da.representor_ports[0] = 0; > + } > /* Return 0 if representor id is matching one of the values. */ > - for (index = 0; index < representors.nb_representor_ports; index++) > - if (data->representor_id == > - representors.representor_ports[index]) > - return 0; > + for (c = 0; c < eth_da.nb_mh_controllers; ++c) { > + for (p = 0; p < eth_da.nb_ports; ++p) { > + for (f = 0; f < eth_da.nb_representor_ports; ++f) { > + index = rte_eth_representor_id_encode( > + eth_da.mh_controllers[c], > + eth_da.ports[p], > + eth_da.type, > + eth_da.representor_ports[f]); > + if (data->representor_id == index) > + return 0; > + } > + } > + } > return -1; /* no match */ > } > > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c > index 91b3263338..2cac0ccfbd 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -5575,6 +5575,32 @@ rte_eth_devargs_parse(const char *dargs, struct rte_eth_devargs *eth_da) > return result; > } > > +uint16_t > +rte_eth_representor_id_encode(uint16_t controller, uint16_t pf, > + enum rte_eth_representor_type type, > + uint16_t representor_port) > +{ > + return (((controller & 3) << 14) | > + ((pf & 3) << 12) | > + (!!(type == RTE_ETH_REPRESENTOR_SF) << 11) | > + (representor_port & 0x7ff)); > +} > + > +uint16_t > +rte_eth_representor_id_parse(const uint16_t representor_id, > + uint16_t *controller, uint16_t *pf, > + enum rte_eth_representor_type *type) > +{ > + if (controller) Compare vs NULL in accordance with DPDK coding style guide > + *controller = (representor_id >> 14) & 3; > + if (pf) Compare vs NULL in accordance with DPDK coding style guide > + *pf = (representor_id >> 12) & 3; > + if (type) Compare vs NULL in accordance with DPDK coding style guide > + *type = ((representor_id >> 11) & 1) ? > + RTE_ETH_REPRESENTOR_SF : RTE_ETH_REPRESENTOR_VF; > + return representor_id & 0x7ff; > +} > + > static int > eth_dev_handle_port_list(const char *cmd __rte_unused, > const char *params __rte_unused, > diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h > index b01f118965..57253c8f90 100644 > --- a/lib/librte_ethdev/rte_ethdev_driver.h > +++ b/lib/librte_ethdev/rte_ethdev_driver.h > @@ -1218,6 +1218,59 @@ struct rte_eth_devargs { > enum rte_eth_representor_type type; /* type of representor */ > }; > > +#define RTE_NO_REPRESENTOR_ID UINT16_MAX /**< No representor ID. */ > + > +/** > + * PMD helper function to encode representor ID > + * > + * The compact format is used for device iterator that comparing > + * ethdev representor ID with target devargs. > + * > + * xxxx xxxx xxxx xxxx > + * |||| |LLL LLLL LLLL vf/sf id > + * |||| L 1:sf, 0:vf > + * ||LL pf id > + * LL controller(host) id > + * > + * @param controller > + * Controller ID. > + * @param pf > + * PF port ID. > + * @param type > + * Representor type. > + * @param representor_port > + * Representor port ID. > + * > + * @return > + * Encoded representor ID. > + */ > +__rte_internal > +uint16_t > +rte_eth_representor_id_encode(uint16_t controller, uint16_t pf, > + enum rte_eth_representor_type type, > + uint16_t representor_port); > + > +/** > + * PMD helper function to parse representor ID > + * > + * @param representor_id > + * Representor ID. > + * @param controller > + * Parsed controller ID. > + * @param pf > + * Parsed PF port ID. > + * @param type > + * Parsed representor type. > + * > + * @return > + * Parsed representor port ID. > + */ > +__rte_internal > +uint16_t > +rte_eth_representor_id_parse(const uint16_t representor_id, > + uint16_t *controller, uint16_t *pf, > + enum rte_eth_representor_type *type); > + > /** > * PMD helper function to parse ethdev arguments > * > diff --git a/lib/librte_ethdev/version.map b/lib/librte_ethdev/version.map > index d3f5410806..44edaed507 100644 > --- a/lib/librte_ethdev/version.map > +++ b/lib/librte_ethdev/version.map > @@ -257,6 +257,8 @@ INTERNAL { > rte_eth_dev_release_port; > rte_eth_dev_internal_reset; > rte_eth_devargs_parse; > + rte_eth_representor_id_encode; > + rte_eth_representor_id_parse; The place looks wrong. It must be sorted or added at bottom with the comment with version number. I'd prefer to have it simply alphanumberically sorted. > rte_eth_dma_zone_free; > rte_eth_dma_zone_reserve; > rte_eth_hairpin_queue_peer_bind; >