From: sfeldma@gmail.com
To: netdev@vger.kernel.org
Cc: jiri@resnulli.us, davem@davemloft.net, f.fainelli@gmail.com,
roopa@cumulusnetworks.com
Subject: [RFC PATCH net-next 2/2] rocker: register each switch as a switchdev
Date: Thu, 27 Aug 2015 00:16:46 -0700 [thread overview]
Message-ID: <1440659806-56582-3-git-send-email-sfeldma@gmail.com> (raw)
In-Reply-To: <1440659806-56582-1-git-send-email-sfeldma@gmail.com>
From: Scott Feldman <sfeldma@gmail.com>
Signed-off-by: Scott Feldman <sfeldma@gmail.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
next prev parent reply other threads:[~2015-08-27 7:14 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 7:16 [RFC PATCH net-next 0/2] Add new switchdev device class sfeldma
2015-08-27 7:16 ` [RFC PATCH net-next 1/2] switchdev: create " sfeldma
2015-08-27 7:16 ` sfeldma [this message]
2015-08-27 7:27 ` [RFC PATCH net-next 0/2] Add " Jiri Pirko
2015-08-27 7:43 ` John Fastabend
2015-08-27 7:51 ` Jiri Pirko
2015-08-27 8:14 ` John Fastabend
2015-08-27 8:17 ` Scott Feldman
2015-08-27 8:41 ` Jiri Pirko
2015-08-27 7:36 ` John Fastabend
2015-08-27 7:44 ` Jiri Pirko
2015-08-27 8:09 ` John Fastabend
2015-08-27 8:23 ` Scott Feldman
2015-08-27 7:45 ` Andrew Lunn
2015-08-27 8:42 ` Scott Feldman
2015-08-27 9:06 ` Andrew Lunn
2015-08-27 16:41 ` Scott Feldman
2015-08-28 11:52 ` Andrew Lunn
2015-08-27 13:54 ` John W. Linville
2015-08-27 23:25 ` David Miller
2015-08-28 2:13 ` Arad, Ronen
2015-08-28 16:55 ` Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440659806-56582-3-git-send-email-sfeldma@gmail.com \
--to=sfeldma@gmail.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=roopa@cumulusnetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).