[PATCH v2 07/12] net/cpfl: create port representor

Liu, Mingxia mingxia.liu at intel.com
Tue Sep 5 10:30:34 CEST 2023



> -----Original Message-----
> From: Xing, Beilei <beilei.xing at intel.com>
> Sent: Wednesday, August 16, 2023 11:06 PM
> To: Wu, Jingjing <jingjing.wu at intel.com>
> Cc: dev at dpdk.org; Liu, Mingxia <mingxia.liu at intel.com>; Xing, Beilei
> <beilei.xing at intel.com>; Zhang, Qi Z <qi.z.zhang at intel.com>
> Subject: [PATCH v2 07/12] net/cpfl: create port representor
> 
> From: Beilei Xing <beilei.xing at intel.com>
> 
> Track representor request in a whitelist.
> Representor will only be created for active vport.
> 
> Signed-off-by: Jingjing Wu <jingjing.wu at intel.com>
> Signed-off-by: Qi Zhang <qi.z.zhang at intel.com>
> Signed-off-by: Beilei Xing <beilei.xing at intel.com>
> ---
>  drivers/net/cpfl/cpfl_ethdev.c      | 107 ++++---
>  drivers/net/cpfl/cpfl_ethdev.h      |  34 +++
>  drivers/net/cpfl/cpfl_representor.c | 448 ++++++++++++++++++++++++++++
> drivers/net/cpfl/cpfl_representor.h |  26 ++
>  drivers/net/cpfl/meson.build        |   1 +
>  5 files changed, 573 insertions(+), 43 deletions(-)  create mode 100644
> drivers/net/cpfl/cpfl_representor.c
>  create mode 100644 drivers/net/cpfl/cpfl_representor.h
> 
> +static int
> +cpfl_repr_init(struct rte_eth_dev *eth_dev, void *init_param) {
> +	struct cpfl_repr *repr = CPFL_DEV_TO_REPR(eth_dev);
> +	struct cpfl_repr_param *param = init_param;
> +	struct cpfl_adapter_ext *adapter = param->adapter;
> +
> +	repr->repr_id = param->repr_id;
> +	repr->vport_info = param->vport_info;
> +	repr->itf.type = CPFL_ITF_TYPE_REPRESENTOR;
> +	repr->itf.adapter = adapter;
> +	repr->itf.data = eth_dev->data;
> +
> +	eth_dev->dev_ops = &cpfl_repr_dev_ops;
> +
> +	eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
> +	/* bit[15:14] type
> +	 * bit[13] xeon/acc
> +	 * bit[12] apf/cpf
> +	 * bit[11:0] vf
> +	 */
> +	eth_dev->data->representor_id =
> +		(uint16_t)(repr->repr_id.type << 14 |
> +			   repr->repr_id.host_id << 13 |
> +			   repr->repr_id.pf_id << 12 |
> +			   repr->repr_id.vf_id);
> +
[Liu, Mingxia]  how about use the macro variable ?
#define CPFL_REPRESENTOR_ID(type, host_id, pf_id, vf_id)\
  ((((type) & 0x3) << 14) + (((host_id) & 0x1) << 13) + (((pf_id) & 0x1) << 12) + ((vf_id) & 0xfff))

> +
> +static bool
> +match_repr_with_vport(const struct cpfl_repr_id *repr_id,
> +		      struct cpchnl2_vport_info *info) {
> +	int func_id;
> +
> +	if (repr_id->type == RTE_ETH_REPRESENTOR_PF &&
> +	    info->func_type == 0) {
> +		func_id = cpfl_func_id_get(repr_id->host_id, repr_id->pf_id);
> +		if (func_id < 0)
> +			return false;
> +		else
> +			return true;
> +	} else if (repr_id->type == RTE_ETH_REPRESENTOR_VF &&
> +		   info->func_type == 1) {
[Liu, Mingxia] For good readability, func_type value 0 and 1 are better to be replaced by macro variables.




More information about the dev mailing list