summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/marvell/prestera/prestera_main.c
diff options
context:
space:
mode:
authorVadym Kochan <vadym.kochan@plvision.eu>2020-09-16 19:30:59 +0300
committerDavid S. Miller <davem@davemloft.net>2020-09-17 16:35:47 -0700
commit34dd1710f5a3c9a7dc78e1ff6de69a19d407db25 (patch)
tree3d8a91010e777d1c6dd16cc1e5b70f3a2b48ca00 /drivers/net/ethernet/marvell/prestera/prestera_main.c
parent4c2703dfd7fabb0824b3bc345f9fa47e33248c14 (diff)
downloadlwn-34dd1710f5a3c9a7dc78e1ff6de69a19d407db25.tar.gz
lwn-34dd1710f5a3c9a7dc78e1ff6de69a19d407db25.zip
net: marvell: prestera: Add basic devlink support
Add very basic support for devlink interface: - driver name - fw version - devlink ports Signed-off-by: Vadym Kochan <vadym.kochan@plvision.eu> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/marvell/prestera/prestera_main.c')
-rw-r--r--drivers/net/ethernet/marvell/prestera/prestera_main.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
index eb695e2ebda3..47cd2bc367bf 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
@@ -12,6 +12,7 @@
#include "prestera.h"
#include "prestera_hw.h"
#include "prestera_rxtx.h"
+#include "prestera_devlink.h"
#define PRESTERA_MTU_DEFAULT 1536
@@ -186,6 +187,7 @@ static const struct net_device_ops prestera_netdev_ops = {
.ndo_change_mtu = prestera_port_change_mtu,
.ndo_get_stats64 = prestera_port_get_stats64,
.ndo_set_mac_address = prestera_port_set_mac_address,
+ .ndo_get_devlink_port = prestera_devlink_get_port,
};
static int prestera_port_autoneg_set(struct prestera_port *port, bool enable,
@@ -250,9 +252,13 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id)
&port->fp_id);
if (err) {
dev_err(prestera_dev(sw), "Failed to get port(%u) info\n", id);
- goto err_port_init;
+ goto err_port_info_get;
}
+ err = prestera_devlink_port_register(port);
+ if (err)
+ goto err_dl_port_register;
+
dev->features |= NETIF_F_NETNS_LOCAL;
dev->netdev_ops = &prestera_netdev_ops;
@@ -313,11 +319,16 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id)
if (err)
goto err_register_netdev;
+ prestera_devlink_port_set(port);
+
return 0;
err_register_netdev:
prestera_port_list_del(port);
err_port_init:
+ prestera_devlink_port_unregister(port);
+err_dl_port_register:
+err_port_info_get:
free_netdev(dev);
return err;
}
@@ -327,8 +338,10 @@ static void prestera_port_destroy(struct prestera_port *port)
struct net_device *dev = port->dev;
cancel_delayed_work_sync(&port->cached_hw_stats.caching_dw);
+ prestera_devlink_port_clear(port);
unregister_netdev(dev);
prestera_port_list_del(port);
+ prestera_devlink_port_unregister(port);
free_netdev(dev);
}
@@ -446,6 +459,10 @@ static int prestera_switch_init(struct prestera_switch *sw)
if (err)
goto err_handlers_register;
+ err = prestera_devlink_register(sw);
+ if (err)
+ goto err_dl_register;
+
err = prestera_create_ports(sw);
if (err)
goto err_ports_create;
@@ -453,6 +470,8 @@ static int prestera_switch_init(struct prestera_switch *sw)
return 0;
err_ports_create:
+ prestera_devlink_unregister(sw);
+err_dl_register:
prestera_event_handlers_unregister(sw);
err_handlers_register:
prestera_rxtx_switch_fini(sw);
@@ -464,6 +483,7 @@ err_handlers_register:
static void prestera_switch_fini(struct prestera_switch *sw)
{
prestera_destroy_ports(sw);
+ prestera_devlink_unregister(sw);
prestera_event_handlers_unregister(sw);
prestera_rxtx_switch_fini(sw);
prestera_hw_switch_fini(sw);
@@ -474,7 +494,7 @@ int prestera_device_register(struct prestera_device *dev)
struct prestera_switch *sw;
int err;
- sw = kzalloc(sizeof(*sw), GFP_KERNEL);
+ sw = prestera_devlink_alloc();
if (!sw)
return -ENOMEM;
@@ -483,7 +503,7 @@ int prestera_device_register(struct prestera_device *dev)
err = prestera_switch_init(sw);
if (err) {
- kfree(sw);
+ prestera_devlink_free(sw);
return err;
}
@@ -496,7 +516,7 @@ void prestera_device_unregister(struct prestera_device *dev)
struct prestera_switch *sw = dev->priv;
prestera_switch_fini(sw);
- kfree(sw);
+ prestera_devlink_free(sw);
}
EXPORT_SYMBOL(prestera_device_unregister);