> -----Original Message-----
> From: Xueming Li <[email protected]>
> Sent: Tuesday, January 19, 2021 15:15
> Cc: [email protected]; Viacheslav Ovsiienko <[email protected]>;
> [email protected]; Asaf Penso
> <[email protected]>; Ajit Khaparde <[email protected]>; Somnath Kotur
> <[email protected]>; Daley, John <[email protected]>; Hyong Youb
> Kim <[email protected]>;
> Xing, Beilei <[email protected]>; Guo, Jia <[email protected]>; Wang,
> Haiyue
> <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler
> <[email protected]>; Thomas
> Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>;
> Andrew Rybchenko
> <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman
> <[email protected]>
> Subject: [PATCH v5 7/9] devarg: change representor ID to bitmap
>
> The NIC can have multiple PCIe links and can be attached to multiple
> hosts, for example the same single NIC can be shared for multiple server
> units in the rack. On each PCIe link NIC can provide multiple PFs and
> VFs/SFs based on these ones. The full representor identifier consists of
> three indices - controller index, PF index, and VF or SF index (if any).
>
> SR-IOV and SubFunction are created on top of PF. PF index is introduced
> because there might be multiple PFs in the bonding configuration and
> only bonding device is probed.
>
> In eth representor comparator callback, ethdev was compared with devarg.
> Since ethdev representor port didn't contain controller index and PF
> index information, callback returned representor from other PF or
> controller.
>
> This patch changes representor ID to bitmap so that the ethdev
> representor comparer callback returns correct ethdev by comparing full
> representor information including: controller index, PF index,
> representor type, SF or VF index.
>
> Representor ID bitmap definition:
> xxxx xxxx xxxx xxxx
> |||| |LLL LLLL LLLL vf/sf id
> |||| L 1:sf, 0:vf
> ||LL pf id
> LL controller(host) id
>
> This approach keeps binary compatibility with all drivers, VF
> representor id matches with simple id for non-bonding and non-multi-host
> configurations.
>
> In the future, the representor ID field and each section should extend
> to bigger width to support more devices.
>
> Signed-off-by: Xueming Li <[email protected]>
> Acked-by: Viacheslav Ovsiienko <[email protected]>
> Acked-by: Thomas Monjalon <[email protected]>
> ---
> drivers/net/bnxt/bnxt_reps.c | 3 +-
> drivers/net/enic/enic_vf_representor.c | 3 +-
> drivers/net/i40e/i40e_vf_representor.c | 3 +-
> drivers/net/ixgbe/ixgbe_vf_representor.c | 3 +-
> drivers/net/mlx5/linux/mlx5_os.c | 4 +-
> lib/librte_ethdev/rte_class_eth.c | 38 +++++++++++++----
> lib/librte_ethdev/rte_ethdev.c | 26 ++++++++++++
> lib/librte_ethdev/rte_ethdev_driver.h | 53 ++++++++++++++++++++++++
> lib/librte_ethdev/version.map | 2 +
> 9 files changed, 122 insertions(+), 13 deletions(-)
>
> +uint16_t
> +rte_eth_representor_id_encode(uint16_t controller, uint16_t pf,
> + enum rte_eth_representor_type type,
> + uint16_t representor_port)
> +{
> + return (((controller & 3) << 14) |
> + ((pf & 3) << 12) |
> + (!!(type == RTE_ETH_REPRESENTOR_SF) << 11) |
> + (representor_port & 0x7ff));
> +}
> +
> +uint16_t
> +rte_eth_representor_id_parse(const uint16_t representor_id,
> + uint16_t *controller, uint16_t *pf,
> + enum rte_eth_representor_type *type)
> +{
> + if (controller)
> + *controller = (representor_id >> 14) & 3;
> + if (pf)
> + *pf = (representor_id >> 12) & 3;
> + if (type)
> + *type = ((representor_id >> 11) & 1) ?
> + RTE_ETH_REPRESENTOR_SF : RTE_ETH_REPRESENTOR_VF;
> + return representor_id & 0x7ff;
> +}
> +
Rename 'parse' to 'decode' ? Since not parse from string. ;-)
The these two functions are pair style.
rte_eth_representor_id_encode / rte_eth_representor_id_decode ?
> 2.25.1