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 52B6E2BF1 for ; Fri, 20 Apr 2018 15:23:01 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Apr 2018 06:22:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,301,1520924400"; d="scan'208";a="47749475" Received: from irsmsx108.ger.corp.intel.com ([163.33.3.3]) by fmsmga004.fm.intel.com with ESMTP; 20 Apr 2018 06:22:57 -0700 Received: from irsmsx111.ger.corp.intel.com (10.108.20.4) by IRSMSX108.ger.corp.intel.com (163.33.3.3) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 20 Apr 2018 14:22:57 +0100 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.164]) by irsmsx111.ger.corp.intel.com ([169.254.2.167]) with mapi id 14.03.0319.002; Fri, 20 Apr 2018 14:22:57 +0100 From: "Ananyev, Konstantin" To: "Doherty, Declan" , "dev@dpdk.org" CC: Adrien Mazarguil , "Yigit, Ferruh" , Thomas Monjalon , "Shahaf Shuler" , "Doherty, Declan" Thread-Topic: [dpdk-dev] [PATCH v7 7/9] ethdev: add switch domain allocator Thread-Index: AQHT1YUysAi1WmVSUUeL0cC72mUDB6QJqM6g Date: Fri, 20 Apr 2018 13:22:56 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258AE918C53@IRSMSX102.ger.corp.intel.com> References: <20180328135433.20203-1-declan.doherty@intel.com> <20180416130605.6509-1-declan.doherty@intel.com> <20180416130605.6509-8-declan.doherty@intel.com> In-Reply-To: <20180416130605.6509-8-declan.doherty@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTc2ZmUyMTQtMWVhOC00ZWQ1LWEzNGItYzY3YTcxZDFkZDJiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Im13UHVhdkFYOHBZR2plQmtWclhvWk4xcDZXaUI2QTR0c1hTMGlGa2NxME09In0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v7 7/9] ethdev: add switch domain allocator 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, 20 Apr 2018 13:23:01 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Declan Doherty > Sent: Monday, April 16, 2018 2:06 PM > To: dev@dpdk.org > Cc: Adrien Mazarguil ; Yigit, Ferruh ; Thomas Monjalon ; > Shahaf Shuler ; Doherty, Declan > Subject: [dpdk-dev] [PATCH v7 7/9] ethdev: add switch domain allocator >=20 > Signed-off-by: Declan Doherty > --- > lib/librte_ether/rte_ethdev.c | 53 +++++++++++++++++++++++++++= ++++++ > lib/librte_ether/rte_ethdev_driver.h | 39 ++++++++++++++++++++++++ > lib/librte_ether/rte_ethdev_version.map | 3 ++ > 3 files changed, 95 insertions(+) >=20 > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.= c > index a082b211c..d1f95161f 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -4300,6 +4300,59 @@ rte_eth_devargs_parse_ports(char *str, void *data) > ð_da->nb_ports, RTE_MAX_ETHPORTS); > } >=20 > +/** > + * A set of values to describe the possible states of a switch domain. > + */ > +enum rte_eth_switch_domain_state { > + RTE_ETH_SWITCH_DOMAIN_UNUSED =3D 0, > + RTE_ETH_SWITCH_DOMAIN_ALLOCATED > +}; > + > +/** > + * Array of switch domains available for allocation. Array is sized to > + * RTE_MAX_ETHPORTS elements as there cannot be more active switch domai= ns than > + * ethdev ports in a single process. > + */ > +struct rte_eth_dev_switch { > + enum rte_eth_switch_domain_state state; > +} rte_eth_switch_domains[RTE_MAX_ETHPORTS]; Probably already discussed before, but if we can't have more than one swit= ch_id per port, while we can't use port_id as switch_id? > + > +int __rte_experimental > +rte_eth_switch_domain_alloc(uint16_t *domain_id) > +{ > + unsigned int i; > + > + *domain_id =3D RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID; > + > + for (i =3D RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID + 1; > + i < RTE_MAX_ETHPORTS; i++) { > + if (rte_eth_switch_domains[i].state =3D=3D > + RTE_ETH_SWITCH_DOMAIN_UNUSED) { > + rte_eth_switch_domains[i].state =3D > + RTE_ETH_SWITCH_DOMAIN_ALLOCATED; > + *domain_id =3D i; > + return 0; > + } > + } So all we need for state is just one status bit (occupied/free)? Wouldn't bitmap do then? > + > + return -ENOSPC; > +} > + > +int __rte_experimental > +rte_eth_switch_domain_free(uint16_t domain_id) > +{ > + if (domain_id =3D=3D RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID || > + domain_id >=3D RTE_MAX_ETHPORTS) > + return -EINVAL; > + > + if (rte_eth_switch_domains[domain_id].state !=3D > + RTE_ETH_SWITCH_DOMAIN_ALLOCATED) > + return -EINVAL; > + > + rte_eth_switch_domains[domain_id].state =3D RTE_ETH_SWITCH_DOMAIN_UNUSE= D; > + > + return 0; > +} >=20 > static int > rte_eth_devargs_parse_representor_ports(char *str, void *data) > diff --git a/lib/librte_ether/rte_ethdev_driver.h b/lib/librte_ether/rte_= ethdev_driver.h > index 3bce5747d..c22fcbde1 100644 > --- a/lib/librte_ether/rte_ethdev_driver.h > +++ b/lib/librte_ether/rte_ethdev_driver.h > @@ -188,6 +188,45 @@ rte_eth_linkstatus_get(const struct rte_eth_dev *dev= , > #endif > } >=20 > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * Allocate an unique switch domain identifier. > + * > + * A pool of switch domain identifiers which can be allocated on request= . This > + * will enabled devices which support the concept of switch domains to r= equest > + * a switch domain id which is guaranteed to be unique from other device= s > + * running in the same process. > + * > + * @param domain_id > + * switch domain identifier parameter to pass back to application > + * > + * @return > + * Negative errno value on error, 0 on success. > + */ > +int __rte_experimental > +rte_eth_switch_domain_alloc(uint16_t *domain_id); > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * Free switch domain. > + * > + * Return a switch domain identifier to the pool of free identifiers aft= er it is > + * no longer in use by device. > + * > + * @param domain_id > + * switch domain identifier to free > + * > + * @return > + * Negative errno value on error, 0 on success. > + */ > +int __rte_experimental > +rte_eth_switch_domain_free(uint16_t domain_id); > + > + >=20 > /** Generic Ethernet device arguments */ > struct rte_eth_devargs { > diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/r= te_ethdev_version.map > index 62ecbdb8a..6601ef106 100644 > --- a/lib/librte_ether/rte_ethdev_version.map > +++ b/lib/librte_ether/rte_ethdev_version.map > @@ -236,5 +236,8 @@ EXPERIMENTAL { > rt_eth_devargs_parse; > rte_eth_dev_create; > rte_eth_dev_destroy; > + rte_eth_switch_domain_alloc; > + rte_eth_switch_domain_free; > + rte_eth_switch_domains; >=20 > } DPDK_18.05; > -- > 2.14.3