[dpdk-dev] [PATCH v3 3/3] app/testpmd: add CL for ptype mapping configure

Zhang, Qi Z qi.z.zhang at intel.com
Wed Mar 22 02:24:42 CET 2017



> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Tuesday, March 21, 2017 11:54 PM
> To: Zhang, Qi Z <qi.z.zhang at intel.com>; Wu, Jingjing <jingjing.wu at intel.com>;
> Zhang, Helin <helin.zhang at intel.com>
> Cc: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v3 3/3] app/testpmd: add CL for ptype mapping
> configure
> 
> On 3/17/2017 10:45 AM, Qi Zhang wrote:
> > Add below command line to configure ptype mapping.
> > ptype mapping get <port_id> <valid_only>.
> > ptype mapping replace <port_id> <target> <mask> <pkt_type>.
> > ptype mapping reset <port_id>.
> > ptype mapping update <port_id> <hw_ptype> <sw_ptype>.
> >
> > Signed-off-by: Qi Zhang <qi.z.zhang at intel.com>
> 
> <...>
> 
> > +static void
> > +cmd_ptype_mapping_get_parsed(
> > +	void *parsed_result,
> > +	__attribute__((unused)) struct cmdline *cl,
> > +	__attribute__((unused)) void *data)
> > +{
> > +	struct cmd_ptype_mapping_get_result *res = parsed_result;
> > +	int ret = -ENOTSUP;
> > +#ifdef RTE_LIBRTE_I40E_PMD
> > +	int max_ptype_num = 256;
> > +	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
> > +	uint16_t count;
> > +	int i;
> > +#endif
> > +
> > +	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
> > +		return;
> > +
> > +#ifdef RTE_LIBRTE_I40E_PMD
> > +	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
> > +					mapping,
> > +					max_ptype_num,
> > +					&count,
> > +					res->valid_only);
> > +#endif
> > +
> > +	switch (ret) {
> > +	case 0:
> > +		break;
> > +	case -ENODEV:
> > +		printf("invalid port_id %d\n", res->port_id);
> > +		break;
> > +	case -ENOTSUP:
> > +		printf("function not implemented\n");
> > +		break;
> > +	default:
> > +		printf("programming error: (%s)\n", strerror(-ret));
> > +	}
> > +
> > +#ifdef RTE_LIBRTE_I40E_PMD
> > +	if (!ret) {
> > +		for (i = 0; i < count; i++)
> > +			printf("%3d\t0x%08x\n",
> > +				mapping[i].hw_ptype, mapping[i].sw_ptype);
> > +	}
> > +#endif
> 
> Why this #ifdef exists?
> I thinks only wrapping the API with #ifdef should be enough, like other
> commands in this patch?

struct rte_pmd_i40e_ptype_mapping defined in rte_pmd_i40e.h
and it will only be included when is RTE_LIBRTE_I40E_PMD is enabled in cmdline.c
so I can't remove it


More information about the dev mailing list