nfp: add .ndo_get_devlink
authorJakub Kicinski <jakub.kicinski@netronome.com>
Tue, 26 Feb 2019 03:34:04 +0000 (19:34 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 Feb 2019 16:49:05 +0000 (08:49 -0800)
Support getting devlink instance from a new NDO.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfp_app.h
drivers/net/ethernet/netronome/nfp/nfp_devlink.c
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
drivers/net/ethernet/netronome/nfp/nfp_net_repr.c

index d578d856a009f8d7608615a4bb185eee70be2fb9..f8d42271370509440439c483585c509e07616200 100644 (file)
@@ -433,4 +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);
+
 #endif
index db2da99f6aa7ca9d86918963e2e57c73ef69286a..e9eca99cf4937c6e0abbe18791ef772a6f40f31f 100644 (file)
@@ -376,3 +376,14 @@ void nfp_devlink_port_unregister(struct nfp_port *port)
 {
        devlink_port_unregister(&port->dl_port);
 }
+
+struct devlink *nfp_devlink_get_devlink(struct net_device *netdev)
+{
+       struct nfp_app *app;
+
+       app = nfp_app_from_netdev(netdev);
+       if (!app)
+               return NULL;
+
+       return priv_to_devlink(app->pf);
+}
index 776f6c07701b06b77ab39c0f06f6846f8111eb69..6d1b8816552ea5cc56505b3d4d396396e7894300 100644 (file)
@@ -3531,6 +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,
 };
 
 /**
index 62839807e21ee723573273605ed43d9dea740a82..d2c803bb4e562dd3805aaea86e689e5f682ce9ed 100644 (file)
@@ -273,6 +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,
 };
 
 void