Commit 5dc37bb9 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

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: default avatarJiri Pirko <jiri@mellanox.com>
Reviewed-by: default avatarMichal Kubecek <mkubecek@suse.cz>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 335bc0dd
......@@ -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
......@@ -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;
}
......@@ -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,
};
/**
......
......@@ -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
......
......@@ -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);
};
/**
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment