controller_num = mlx5_esw_get_hpf_host_number(dev) + 1;
if (vport_num == MLX5_VPORT_HOST_PF) {
+ if (external)
+ pfnum = mlx5_esw_get_hpf_pf_num(dev);
memcpy(dl_port->attrs.switch_id.id, ppid.id, ppid.id_len);
dl_port->attrs.switch_id.id_len = ppid.id_len;
devlink_port_attrs_pci_pf_set(dl_port, controller_num, pfnum, external);
if (vport->adjacent) {
func_id = vport->adj_info.function_id;
pfnum = vport->adj_info.parent_pci_devfn;
+ } else if (external) {
+ pfnum = mlx5_esw_get_hpf_pf_num(dev);
}
devlink_port_attrs_pci_vf_set(dl_port, controller_num, pfnum,
entry, pci_total_vfs),
.host_number = MLX5_GET(network_function_params,
entry, host_number),
+ .pf_num = MLX5_GET(network_function_params, entry,
+ pci_device_function),
};
}
return -EINVAL;
*host_number = esw->esw_funcs.spfs[spf_idx].host_number;
-
return 0;
}
return esw->esw_funcs.hpf_host_number;
}
+u16 mlx5_esw_get_hpf_pf_num(struct mlx5_core_dev *dev)
+{
+ struct mlx5_eswitch *esw = dev->priv.eswitch;
+
+ if (mlx5_core_is_ecpf_esw_manager(dev) &&
+ MLX5_CAP_GEN(dev, query_host_net_function_v1))
+ return esw->esw_funcs.hpf_pf_num;
+
+ return PCI_FUNC(dev->pdev->devfn);
+}
+
bool mlx5_esw_has_spf_sfs(struct mlx5_core_dev *dev)
{
struct mlx5_eswitch *esw = dev->priv.eswitch;
return esw->esw_funcs.has_spf_sfs;
}
-static int mlx5_esw_hpf_host_number_init(struct mlx5_eswitch *esw)
+static int mlx5_esw_hpf_info_init(struct mlx5_eswitch *esw)
{
struct mlx5_esw_pf_info host_pf_info;
const u32 *query_host_out;
/* Mark non local controller with non zero controller number. */
host_pf_info = mlx5_esw_get_host_pf_info(esw->dev, query_host_out);
esw->esw_funcs.hpf_host_number = host_pf_info.host_number;
+ esw->esw_funcs.hpf_pf_num = host_pf_info.pf_num;
kvfree(query_host_out);
return 0;
}
esw_funcs->spfs[esw_funcs->num_spfs].vhca_id = vhca_id;
esw_funcs->spfs[esw_funcs->num_spfs].host_number =
MLX5_GET(network_function_params, entry, host_number);
+ esw_funcs->spfs[esw_funcs->num_spfs].pf_num =
+ MLX5_GET(network_function_params, entry,
+ pci_device_function);
esw_funcs->num_spfs++;
entry += MLX5_UN_SZ_BYTES(net_function_params);
xa_init(&esw->vports);
- err = mlx5_esw_hpf_host_number_init(esw);
+ err = mlx5_esw_hpf_info_init(esw);
if (err)
goto err;
u16 num_of_vfs;
u16 total_vfs;
u16 host_number;
+ u16 pf_num;
};
#ifdef CONFIG_MLX5_ESWITCH
u16 vport_num;
u16 vhca_id;
u16 host_number;
+ u16 pf_num;
};
struct mlx5_esw_functions {
u16 num_vfs;
u16 num_ec_vfs;
u16 hpf_host_number;
+ u16 hpf_pf_num;
bool has_spf_sfs;
struct mlx5_esw_spf *spfs;
int num_spfs;
int mlx5_esw_spf_get_host_number(struct mlx5_core_dev *dev, int spf_idx,
u16 *host_number);
u16 mlx5_esw_get_hpf_host_number(struct mlx5_core_dev *dev);
+u16 mlx5_esw_get_hpf_pf_num(struct mlx5_core_dev *dev);
bool mlx5_esw_has_spf_sfs(struct mlx5_core_dev *dev);
int mlx5_esw_vport_vhca_id_map(struct mlx5_eswitch *esw,