[dpdk-stable] [dpdk-dev] [PATCH v2] ethdev: fix data type for port id
Thomas Monjalon
thomas at monjalon.net
Tue Oct 27 15:29:29 CET 2020
27/10/2020 14:41, wangyunjian:
> From: Yunjian Wang <wangyunjian at huawei.com>
>
> The ethdev port id should be 16 bits now. This patch fixes the data
> type of the variable for 'pid', changing from uint32_t to uint16_t.
>
> We also need use RTE_BUILD_BUG_ON() to ensure that RTE_MAX_ETHPORTS
> is less or equal to UINT16_MAX.
Actually the need is to check that we have room for an increment
after RTE_MAX_ETHPORTS, meaning RTE_MAX_ETHPORTS < UINT16_MAX.
> Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
> Cc: stable at dpdk.org
>
> Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
> ---
> v2:
> add RTE_BUILD_BUG_ON() check for RTE_MAX_ETHPORTS validity
> ---
> rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id)
> {
> - uint32_t pid;
> + uint16_t pid;
>
> if (name == NULL) {
> RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n");
> @@ -4292,6 +4292,8 @@ RTE_INIT(eth_dev_init_cb_lists)
> {
> int i;
>
> + RTE_BUILD_BUG_ON(RTE_MAX_ETHPORTS > UINT16_MAX);
As explained above, should check >=
This check is global for ethdev.
Please could you move it somewhere else?
More information about the stable
mailing list