[PATCH 1/2] app/testpmd: assign share group dynamically

Stephen Hemminger stephen at networkplumber.org
Wed Mar 25 17:45:20 CET 2026


On Tue, 24 Mar 2026 13:37:08 +0100
Dariusz Sosnowski <dsosnowski at nvidia.com> wrote:

> +static uint16_t
> +assign_share_group(struct rte_eth_dev_info *dev_info)
> +{
> +	unsigned int first_free = RTE_DIM(share_group_slots);
> +	bool found = false;
> +	unsigned int i;
> +
> +	for (i = 0; i < RTE_DIM(share_group_slots); i++) {
> +		if (share_group_slots[i].share_group > 0) {
> +			if (dev_info->switch_info.domain_id == share_group_slots[i].domain_id &&
> +			    dev_info->switch_info.rx_domain == share_group_slots[i].rx_domain) {
> +				found = true;
> +				break;
> +			}
> +		} else if (first_free == RTE_DIM(share_group_slots)) {
> +			first_free = i;
> +		}
> +	}
> +
> +	if (found)
> +		return share_group_slots[i].share_group;

Please use a short circuit return, that would be simpler and code would be shorter.
Same thing below, avoid unnecessary bools.

	
	for (i = 0; i < RTE_DIM(share_group_slots); i++) {
		if (share_group_slots[i].share_group > 0) {
			if (dev_info->switch_info.domain_id == share_group_slots[i].domain_id &&
			    dev_info->switch_info.rx_domain == share_group_slots[i].rx_domain)
			    		return share_group_slots[i].share_group;
		} else  if (first_free == RTE_DIM(share_group_slots)) {
			first_free = i;
		}
	}



More information about the dev mailing list