[dpdk-dev] [dpdk-stable] [PATCH v3] ethdev: fix data type for port id

wangyunjian wangyunjian at huawei.com
Wed Nov 4 02:57:44 CET 2020


> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas at monjalon.net]
> Sent: Wednesday, November 4, 2020 2:44 AM
> To: wangyunjian <wangyunjian at huawei.com>
> Cc: dev at dpdk.org; ferruh.yigit at intel.com; andrew.rybchenko at oktetlabs.ru;
> Lilijun (Jerry) <jerry.lilijun at huawei.com>; xudingke <xudingke at huawei.com>;
> stable at dpdk.org
> Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v3] ethdev: fix data type for port id
> 
> 02/11/2020 10:18, wangyunjian:
> > From: Yunjian Wang <wangyunjian at huawei.com>
> >
> > The ethdev port id is 16 bits now. This patch fixes the data type of
> > the variable for 'pid', which changing from uint32_t to uint16_t.
> >
> > RTE_MAX_ETHPORTS is the maximum number of ports, which customized by
> > the user. To avoid 16-bit unsigned integer overflow, the valid value
> > of RTE_MAX_ETHPORTS should be set from 0 to UINT16_MAX, and it is
> > safer to cut one more port from space.
> >
> > So we use RTE_BUILD_BUG_ON() to ensure that RTE_MAX_ETHPORTS is less
> > to UINT16_MAX.
> >
> > Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
> > Cc: stable at dpdk.org
> >
> > Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
> > ---
> > v3:
> >    fix code styles suggested by Thomas Monjalon and Andrew Rybchenko
> 
> I don't understand why you add the compile check in several place.
> We should just find one good place for checking RTE_MAX_ETHPORTS at
> compilation time.
> 
> I suggest rte_eth_find_next() or rte_eth_dev_allocate().
> Or maybe rte_eth_dev_is_valid_port().
> 
> Please choose only one.
> 
OK, I will add the compile check in function rte_eth_dev_allocate().

Thanks
Yunjian



More information about the dev mailing list