return err;
}
-static int mlx5_esw_adj_vport_create(struct mlx5_eswitch *esw, u16 vhca_id)
+static int mlx5_esw_adj_vport_create(struct mlx5_eswitch *esw, u16 vhca_id,
+ const void *rid_info_reg)
{
struct mlx5_vport *vport;
u16 vport_num;
vport->adjacent = true;
vport->vhca_id = vhca_id;
+ vport->adj_info.parent_pci_devfn =
+ MLX5_GET(function_vhca_rid_info_reg, rid_info_reg,
+ parent_pci_device_function);
+ vport->adj_info.function_id =
+ MLX5_GET(function_vhca_rid_info_reg, rid_info_reg, function_id);
+
mlx5_fs_vport_egress_acl_ns_add(esw->dev->priv.steering, vport->index);
mlx5_fs_vport_ingress_acl_ns_add(esw->dev->priv.steering, vport->index);
err = mlx5_esw_offloads_rep_add(esw, vport);
esw_debug(esw->dev, "Delegated vhca functions count %d\n", count);
for (i = 0; i < count; i++) {
- void *rid_info, *rid_info_reg;
+ const void *rid_info, *rid_info_reg;
u16 vhca_id;
rid_info = MLX5_ADDR_OF(query_delegated_vhca_out, out,
vhca_id = MLX5_GET(function_vhca_rid_info_reg, rid_info_reg,
vhca_id);
- esw_debug(esw->dev, "Delegating vhca_id 0x%x rid info:\n",
- vhca_id);
+ esw_debug(esw->dev, "Delegating vhca_id 0x%x\n", vhca_id);
- err = mlx5_esw_adj_vport_create(esw, vhca_id);
+ err = mlx5_esw_adj_vport_create(esw, vhca_id, rid_info_reg);
if (err) {
esw_warn(esw->dev,
"Failed to init adjacent vhca 0x%x, err %d\n",
{
struct mlx5_core_dev *dev = esw->dev;
struct netdev_phys_item_id ppid = {};
+ struct mlx5_vport *vport;
u32 controller_num = 0;
bool external;
u16 pfnum;
dl_port->attrs.switch_id.id_len = ppid.id_len;
devlink_port_attrs_pci_pf_set(dl_port, controller_num, pfnum, external);
} else if (mlx5_eswitch_is_vf_vport(esw, vport_num)) {
+ u16 func_id = vport_num - 1;
+
+ vport = mlx5_eswitch_get_vport(esw, vport_num);
memcpy(dl_port->attrs.switch_id.id, ppid.id, ppid.id_len);
dl_port->attrs.switch_id.id_len = ppid.id_len;
+ if (vport->adjacent) {
+ func_id = vport->adj_info.function_id;
+ pfnum = vport->adj_info.parent_pci_devfn;
+ }
+
devlink_port_attrs_pci_vf_set(dl_port, controller_num, pfnum,
- vport_num - 1, external);
+ func_id, external);
} else if (mlx5_core_is_ec_vf_vport(esw->dev, vport_num)) {
u16 base_vport = mlx5_core_ec_vf_vport_base(dev);