- if (switch_info->representor && dpdk_dev->devargs) {
- switch (eth_da->type) {
- case RTE_ETH_REPRESENTOR_SF:
- if (switch_info->name_type !=
- MLX5_PHYS_PORT_NAME_TYPE_PFSF) {
- rte_errno = EBUSY;
- return NULL;
- }
- break;
- case RTE_ETH_REPRESENTOR_VF:
- /* Allows HPF representor index -1 as exception. */
- if (!(spawn->info.port_name == -1 &&
- switch_info->name_type ==
- MLX5_PHYS_PORT_NAME_TYPE_PFHPF) &&
- switch_info->name_type !=
- MLX5_PHYS_PORT_NAME_TYPE_PFVF) {
- rte_errno = EBUSY;
- return NULL;
- }
- break;
- case RTE_ETH_REPRESENTOR_NONE:
- rte_errno = EBUSY;
- return NULL;
- break;
- default:
- rte_errno = ENOTSUP;
- DRV_LOG(ERR, "unsupported representor type: %s",
- dpdk_dev->devargs->args);
- return NULL;
- }
- /* Check controller ID: */
- for (i = 0; i < eth_da->nb_mh_controllers; ++i)
- if (eth_da->mh_controllers[i] ==
- (uint16_t)switch_info->ctrl_num)
- break;
- if (eth_da->nb_mh_controllers &&
- i == eth_da->nb_mh_controllers) {
- rte_errno = EBUSY;
- return NULL;
- }
- /* Check SF/VF ID: */
- for (i = 0; i < eth_da->nb_representor_ports; ++i)
- if (eth_da->representor_ports[i] ==
- (uint16_t)switch_info->port_name)
- break;
- if (eth_da->type != RTE_ETH_REPRESENTOR_PF &&
- i == eth_da->nb_representor_ports) {
- rte_errno = EBUSY;
- return NULL;
- }
- /* Check PF ID. Check after repr port to avoid warning flood. */
- if (spawn->pf_bond >= 0) {
- for (i = 0; i < eth_da->nb_ports; ++i)
- if (eth_da->ports[i] ==
- (uint16_t)switch_info->pf_num)
- break;
- if (eth_da->nb_ports && i == eth_da->nb_ports) {
- /* For backward compatibility, bonding
- * representor syntax supported with limitation,
- * device iterator won't find it:
- * <PF1_BDF>,representor=#
- */
- if (switch_info->pf_num > 0 &&
- eth_da->ports[0] == 0) {
- DRV_LOG(WARNING, "Representor on Bonding PF should use pf#vf# format: %s",
- dpdk_dev->devargs->args);
- } else {
- rte_errno = EBUSY;
- return NULL;
- }
- }
- } else if (eth_da->nb_ports > 1 || eth_da->ports[0]) {
- rte_errno = EINVAL;
- DRV_LOG(ERR, "PF id not supported by non-bond device: %s",
- dpdk_dev->devargs->args);
- return NULL;
- }
- }