nfp: wire get_phys_port_name on representors

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>
This commit is contained in:
Jakub Kicinski 2017-06-27 00:50:24 -07:00 committed by David S. Miller
parent 39ae7eb69d
commit 168c478e10
2 changed files with 24 additions and 7 deletions

View 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)

View 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;
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);
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 (n >= len)
return -EINVAL;