[dpdk-dev] [PATCH V16 3/3] app/testpmd: add FEC command

Ferruh Yigit ferruh.yigit at intel.com
Thu Oct 8 17:57:37 CEST 2020


On 10/8/2020 11:02 AM, Min Hu (Connor) wrote:
> This commit adds testpmd capability to query and config FEC
> function of device. This includes:
> - show FEC capabilities, example:
> 	testpmd> show port 0 fec capabilities
> - show FEC mode, example:
> 	testpmd> show port 0 fec_mode
> - config FEC mode, example:
> 	testpmd> set port <port_id> fec_mode auto|off|rs|baser
> 
> 	where:
> 
> 	auto|off|rs|baser are four kinds of FEC mode which dev
> 	support according to MAC link speed.
> 
> Signed-off-by: Min Hu (Connor) <humin29 at huawei.com>
> Reviewed-by: Wei Hu (Xavier) <xavier.huwei at huawei.com>
> Reviewed-by: Chengwen Feng <fengchengwen at huawei.com>
> Reviewed-by: Chengchang Tang <tangchengchang at huawei.com>

<...>

> +static const struct {
> +	uint32_t speed;
> +	const char *name;
> +} eth_speed_name[] = {
> +	{
> +		.speed = ETH_SPEED_NUM_10G,
> +		.name = "Speed 10G",
> +	},
> +	{
> +		.speed = ETH_SPEED_NUM_25G,
> +		.name = "Speed 25G",
> +	},
> +	{
> +		.speed = ETH_SPEED_NUM_40G,
> +		.name = "Speed 40G",
> +	},
> +	{
> +		.speed = ETH_SPEED_NUM_50G,
> +		.name = "Speed 50G",
> +	},
> +	{
> +		.speed = ETH_SPEED_NUM_100G,
> +		.name = "Speed 100G",
> +	},
> +	{
> +		.speed = ETH_SPEED_NUM_200G,
> +		.name = "Speed 200G",
> +	},
> +};
> +
>   static void
>   print_ethaddr(const char *name, struct rte_ether_addr *eth_addr)
>   {
> @@ -2969,6 +3021,45 @@ set_tx_pkt_split(const char *name)
>   	printf("unknown value: \"%s\"\n", name);
>   }
>   
> +int
> +parse_fec_mode(const char *name, uint32_t *mode)
> +{
> +	uint8_t i;
> +
> +	for (i = 0; i < RTE_DIM(fec_mode_name); i++) {
> +		if (strcmp(fec_mode_name[i].name, name) == 0) {
> +			*mode = RTE_ETH_FEC_MODE_TO_CAPA(fec_mode_name[i].mode);
> +			return 0;
> +		}
> +	}
> +	return -1;
> +}
> +
> +void
> +show_fec_capability(unsigned int num, struct rte_eth_fec_capa *speed_fec_capa)
> +{
> +	unsigned int i, j, k;
> +
> +	printf("FEC capabilities:\n");
> +
> +	for (i = 0; i < num; i++) {
> +		for (j = 0; j < RTE_DIM(eth_speed_name); j++) {
> +			if (eth_speed_name[j].speed ==
> +						speed_fec_capa[i].speed) {
> +				printf("%s : ", eth_speed_name[j].name);
> +				break;
> +			}
> +		}
> +
> +		for (k = RTE_ETH_FEC_AUTO; k < RTE_DIM(fec_mode_name); k++) {
> +			if (RTE_ETH_FEC_MODE_TO_CAPA(k) &
> +						speed_fec_capa[i].capa)
> +				printf("%s ", fec_mode_name[k].name);
> +		}
> +		printf("\n");
> +	}
> +}

Hi Connor,

Sorry for catching this late, but there is a new 'rte_eth_link_speed_to_str()' 
API in the ethdev, which may enable removing above global 'eth_speed_name' array 
[1].

I will proceed with this patchset, but can you please send an increamental patch 
to use the 'rte_eth_link_speed_to_str()'?
If it comes before the next-net pulled I can squash it, if not it can stay as 
individual patch.

Thanks,
ferruh


[1]
     printf("%s : ", rte_eth_link_speed_to_str(speed_fec_capa[i].speed));



More information about the dev mailing list