net: replace ndo_get_devlink with ndo_get_devlink_port

Follow-up patch is going to need a devlink port instance according to
a netdev. Devlink port instance should be always available when devlink
is used. So change the recently introduced ndo_get_devlink to
ndo_get_devlink_port. With that, adjust the wrapper for the only
user to get devlink pointer.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jiri Pirko 2019-03-28 13:56:36 +01:00 committed by David S. Miller
parent 335bc0dde0
commit 5dc37bb9b0
6 changed files with 23 additions and 13 deletions

View File

@ -433,6 +433,6 @@ int nfp_app_nic_vnic_alloc(struct nfp_app *app, struct nfp_net *nn,
int nfp_app_nic_vnic_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
struct nfp_net *nn, unsigned int id);
struct devlink *nfp_devlink_get_devlink(struct net_device *netdev);
struct devlink_port *nfp_devlink_get_devlink_port(struct net_device *netdev);
#endif

View File

@ -386,13 +386,13 @@ void nfp_devlink_port_type_clear(struct nfp_port *port)
devlink_port_type_clear(&port->dl_port);
}
struct devlink *nfp_devlink_get_devlink(struct net_device *netdev)
struct devlink_port *nfp_devlink_get_devlink_port(struct net_device *netdev)
{
struct nfp_app *app;
struct nfp_port *port;
app = nfp_app_from_netdev(netdev);
if (!app)
port = nfp_port_from_netdev(netdev);
if (!port)
return NULL;
return priv_to_devlink(app->pf);
return &port->dl_port;
}

View File

@ -3531,7 +3531,7 @@ const struct net_device_ops nfp_net_netdev_ops = {
.ndo_udp_tunnel_del = nfp_net_del_vxlan_port,
.ndo_bpf = nfp_net_xdp,
.ndo_get_port_parent_id = nfp_port_get_port_parent_id,
.ndo_get_devlink = nfp_devlink_get_devlink,
.ndo_get_devlink_port = nfp_devlink_get_devlink_port,
};
/**

View File

@ -273,7 +273,7 @@ const struct net_device_ops nfp_repr_netdev_ops = {
.ndo_set_features = nfp_port_set_features,
.ndo_set_mac_address = eth_mac_addr,
.ndo_get_port_parent_id = nfp_port_get_port_parent_id,
.ndo_get_devlink = nfp_devlink_get_devlink,
.ndo_get_devlink_port = nfp_devlink_get_devlink_port,
};
void

View File

@ -1250,8 +1250,8 @@ struct devlink;
* that got dropped are freed/returned via xdp_return_frame().
* Returns negative number, means general error invoking ndo, meaning
* no frames were xmit'ed and core-caller will free all frames.
* struct devlink *(*ndo_get_devlink)(struct net_device *dev);
* Get devlink instance associated with a given netdev.
* struct devlink_port *(*ndo_get_devlink_port)(struct net_device *dev);
* Get devlink port instance associated with a given netdev.
* Called with a reference on the netdevice and devlink locks only,
* rtnl_lock is not held.
*/
@ -1451,7 +1451,7 @@ struct net_device_ops {
u32 flags);
int (*ndo_xsk_async_xmit)(struct net_device *dev,
u32 queue_id);
struct devlink * (*ndo_get_devlink)(struct net_device *dev);
struct devlink_port * (*ndo_get_devlink_port)(struct net_device *dev);
};
/**

View File

@ -547,10 +547,20 @@ static inline struct devlink *priv_to_devlink(void *priv)
return container_of(priv, struct devlink, priv);
}
static inline struct devlink_port *
netdev_to_devlink_port(struct net_device *dev)
{
if (dev->netdev_ops->ndo_get_devlink_port)
return dev->netdev_ops->ndo_get_devlink_port(dev);
return NULL;
}
static inline struct devlink *netdev_to_devlink(struct net_device *dev)
{
if (dev->netdev_ops->ndo_get_devlink)
return dev->netdev_ops->ndo_get_devlink(dev);
struct devlink_port *devlink_port = netdev_to_devlink_port(dev);
if (devlink_port)
return devlink_port->devlink;
return NULL;
}