[PATCH net-next 5/8] nfp: switch to devlink_port_get_phys_port_name()

Jakub Kicinski
2019-02-26T18:25:06Z

Now that devlink understands all port flavours - switch
to the devlink_port_get_phys_port_name() helper.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
drivers/net/ethernet/netronome/nfp/nfp_port.c | 33 +------------------
1 file changed, 1 insertion(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.c b/drivers/net/ethernet/netronome/nfp/nfp_port.c
index 93c5bfc0510b..3e2ff8d35e8d 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_port.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c
@@ -117,44 +117,13 @@ struct nfp_eth_table_port *nfp_port_get_eth_port(struct nfp_port *port)
int
nfp_port_get_phys_port_name(struct net_device *netdev, char *name, size_t len)
{
- struct nfp_eth_table_port *eth_port;
struct nfp_port *port;
- int n;

port = nfp_port_from_netdev(netdev);
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:
- if (!port->pf_split)
- n = snprintf(name, len, "pf%d", port->pf_id);
- else
- n = snprintf(name, len, "pf%ds%d", port->pf_id,
- port->pf_split_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;
-
- return 0;
+ return devlink_port_get_phys_port_name(&port->dl_port, name, len);
}

/**
--
2.19.2