[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1440659806-56582-3-git-send-email-sfeldma@gmail.com>
Date: Thu, 27 Aug 2015 00:16:46 -0700
From: sfeldma@...il.com
To: netdev@...r.kernel.org
Cc: jiri@...nulli.us, davem@...emloft.net, f.fainelli@...il.com,
roopa@...ulusnetworks.com
Subject: [RFC PATCH net-next 2/2] rocker: register each switch as a switchdev
From: Scott Feldman <sfeldma@...il.com>
Signed-off-by: Scott Feldman <sfeldma@...il.com>
---
drivers/net/ethernet/rocker/rocker.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
index a7cb74a..9555ae4 100644
--- a/drivers/net/ethernet/rocker/rocker.c
+++ b/drivers/net/ethernet/rocker/rocker.c
@@ -233,6 +233,7 @@ struct rocker {
struct pci_dev *pdev;
u8 __iomem *hw_addr;
struct msix_entry *msix_entries;
+ struct switchdev switchdev;
unsigned int port_count;
struct rocker_port **ports;
struct {
@@ -5090,6 +5091,19 @@ static void rocker_msix_fini(const struct rocker *rocker)
kfree(rocker->msix_entries);
}
+static int rocker_probe_register_switchdev(struct rocker *rocker)
+{
+ char name[sizeof(rocker->hw.id) * 2 + 1];
+
+ sprintf(name, "%*phN", (int)sizeof(rocker->hw.id), &rocker->hw.id);
+ return register_switchdev(&rocker->switchdev, name);
+}
+
+static void rocker_probe_unregister_switchdev(struct rocker *rocker)
+{
+ unregister_switchdev(&rocker->switchdev);
+}
+
static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct rocker *rocker;
@@ -5194,11 +5208,19 @@ static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto err_probe_ports;
}
+ err = rocker_probe_register_switchdev(rocker);
+ if (err) {
+ dev_err(&pdev->dev, "cannot register switchdev\n");
+ goto err_register_switchdev;
+ }
+
dev_info(&pdev->dev, "Rocker switch with id %*phN\n",
(int)sizeof(rocker->hw.id), &rocker->hw.id);
return 0;
+err_register_switchdev:
+ rocker_remove_ports(rocker);
err_probe_ports:
rocker_free_tbls(rocker);
err_init_tbls:
@@ -5227,6 +5249,7 @@ static void rocker_remove(struct pci_dev *pdev)
{
struct rocker *rocker = pci_get_drvdata(pdev);
+ rocker_probe_unregister_switchdev(rocker);
rocker_free_tbls(rocker);
rocker_write32(rocker, CONTROL, ROCKER_CONTROL_RESET);
rocker_remove_ports(rocker);
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists