Skip to content

Commit 66b1708

Browse files
paravmellanoxdavem330
authored andcommitted
devlink: Use controller while building phys_port_name
Now that controller number attribute is available, use it when building phsy_port_name for external controller ports. An example devlink port and representor netdev name consist of controller annotation for external controller with controller number = 1, for a VF 1 of PF 0: $ devlink port show pci/0000:06:00.0/2 pci/0000:06:00.0/2: type eth netdev ens2f0c1pf0vf1 flavour pcivf controller 1 pfnum 0 vfnum 1 external true splittable false function: hw_addr 00:00:00:00:00:00 $ devlink port show pci/0000:06:00.0/2 -jp { "port": { "pci/0000:06:00.0/2": { "type": "eth", "netdev": "ens2f0c1pf0vf1", "flavour": "pcivf", "controller": 1, "pfnum": 0, "vfnum": 1, "external": true, "splittable": false, "function": { "hw_addr": "00:00:00:00:00:00" } } } } Controller number annotation is skipped for non external controllers to maintain backward compatibility. Signed-off-by: Parav Pandit <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3a2d958 commit 66b1708

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

net/core/devlink.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7793,9 +7793,23 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
77937793
WARN_ON(1);
77947794
return -EINVAL;
77957795
case DEVLINK_PORT_FLAVOUR_PCI_PF:
7796+
if (attrs->pci_pf.external) {
7797+
n = snprintf(name, len, "c%u", attrs->pci_pf.controller);
7798+
if (n >= len)
7799+
return -EINVAL;
7800+
len -= n;
7801+
name += n;
7802+
}
77967803
n = snprintf(name, len, "pf%u", attrs->pci_pf.pf);
77977804
break;
77987805
case DEVLINK_PORT_FLAVOUR_PCI_VF:
7806+
if (attrs->pci_vf.external) {
7807+
n = snprintf(name, len, "c%u", attrs->pci_vf.controller);
7808+
if (n >= len)
7809+
return -EINVAL;
7810+
len -= n;
7811+
name += n;
7812+
}
77997813
n = snprintf(name, len, "pf%uvf%u",
78007814
attrs->pci_vf.pf, attrs->pci_vf.vf);
78017815
break;

0 commit comments

Comments
 (0)