]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
nfp: wire get_phys_port_name on representors
authorJakub Kicinski <jakub.kicinski@netronome.com>
Tue, 27 Jun 2017 07:50:24 +0000 (00:50 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 27 Jun 2017 19:48:49 +0000 (15:48 -0400)
Make nfp_port_get_phys_port_name() support new port types and
wire it up to representors' struct net_device_ops.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
drivers/net/ethernet/netronome/nfp/nfp_port.c

index 7bfdef2af1a937074196810de891a7173ca80b86..046b89eb4cf2f396af65f1d56c936796f9b694e8 100644 (file)
@@ -256,6 +256,7 @@ const struct net_device_ops nfp_repr_netdev_ops = {
        .ndo_get_stats64        = nfp_repr_get_stats64,
        .ndo_has_offload_stats  = nfp_repr_has_offload_stats,
        .ndo_get_offload_stats  = nfp_repr_get_offload_stats,
+       .ndo_get_phys_port_name = nfp_port_get_phys_port_name,
 };
 
 static void nfp_repr_clean(struct nfp_repr *repr)
index 0be6c7e0b1c1ab9b7d53cf0922ec43616782692b..0b44952945d884128e9d0d9026796be671cb9be0 100644 (file)
@@ -106,15 +106,31 @@ nfp_port_get_phys_port_name(struct net_device *netdev, char *name, size_t len)
        int n;
 
        port = nfp_port_from_netdev(netdev);
-       eth_port = __nfp_port_get_eth_port(port);
-       if (!eth_port)
+       if (!port)
+               return -EOPNOTSUPP;
+
+       switch (port->type) {
+       case NFP_PORT_PHYS_PORT:
+               eth_port = __nfp_port_get_eth_port(port);
+               if (!eth_port)
+                       return -EOPNOTSUPP;
+
+               if (!eth_port->is_split)
+                       n = snprintf(name, len, "p%d", eth_port->label_port);
+               else
+                       n = snprintf(name, len, "p%ds%d", eth_port->label_port,
+                                    eth_port->label_subport);
+               break;
+       case NFP_PORT_PF_PORT:
+               n = snprintf(name, len, "pf%d", port->pf_id);
+               break;
+       case NFP_PORT_VF_PORT:
+               n = snprintf(name, len, "pf%dvf%d", port->pf_id, port->vf_id);
+               break;
+       default:
                return -EOPNOTSUPP;
+       }
 
-       if (!eth_port->is_split)
-               n = snprintf(name, len, "p%d", eth_port->label_port);
-       else
-               n = snprintf(name, len, "p%ds%d", eth_port->label_port,
-                            eth_port->label_subport);
        if (n >= len)
                return -EINVAL;