netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: jiri@resnulli.us, jhs@mojatatu.com, davem@davemloft.net,
	xiyou.wangcong@gmail.com, andrew@lunn.ch,
	vivien.didelot@savoirfairelinux.com,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: [RFC net-next 6/8] net: dsa: Expose dsa_slave_dev_check and dsa_slave_dev_port_num
Date: Wed, 30 Aug 2017 17:18:50 -0700	[thread overview]
Message-ID: <1504138732-65383-7-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1504138732-65383-1-git-send-email-f.fainelli@gmail.com>

Expose two helper functions:
* one to verify if a net_device is a DSA slave network device
* one to obtain the physical port number associated with a DSA slave
  network device

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 include/net/dsa.h | 15 +++++++++++++++
 net/dsa/slave.c   | 12 +++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index b10e8da3f8d7..649bd06f9fe4 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -459,6 +459,21 @@ static inline bool netdev_uses_dsa(struct net_device *dev)
 	return false;
 }
 
+#if IS_ENABLED(CONFIG_NET_DSA)
+bool dsa_slave_dev_check(struct net_device *dev);
+unsigned int dsa_slave_dev_port_num(struct net_device *dev);
+#else
+static inline bool dsa_slave_dev_check(struct net_device *dev)
+{
+	return false;
+}
+
+static inline dsa_slave_dev_port_num(struct net_device *dev)
+{
+	return DSA_MAX_PORTS;
+}
+#endif
+
 struct dsa_switch *dsa_switch_alloc(struct device *dev, size_t n);
 void dsa_unregister_switch(struct dsa_switch *ds);
 int dsa_register_switch(struct dsa_switch *ds);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index bfd7173a3c6a..302ae3326e3a 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -25,8 +25,6 @@
 
 #include "dsa_priv.h"
 
-static bool dsa_slave_dev_check(struct net_device *dev);
-
 /* slave mii_bus handling ***************************************************/
 static int dsa_slave_phy_read(struct mii_bus *bus, int addr, int reg)
 {
@@ -1346,10 +1344,18 @@ void dsa_slave_destroy(struct net_device *slave_dev)
 	free_netdev(slave_dev);
 }
 
-static bool dsa_slave_dev_check(struct net_device *dev)
+bool dsa_slave_dev_check(struct net_device *dev)
 {
 	return dev->netdev_ops == &dsa_slave_netdev_ops;
 }
+EXPORT_SYMBOL_GPL(dsa_slave_dev_check);
+
+unsigned int dsa_slave_dev_port_num(struct net_device *dev)
+{
+	struct dsa_slave_priv *p = netdev_priv(dev);
+	return p->dp->index;
+}
+EXPORT_SYMBOL_GPL(dsa_slave_dev_port_num);
 
 static int dsa_slave_changeupper(struct net_device *dev,
 				 struct netdev_notifier_changeupper_info *info)
-- 
1.9.1

  parent reply	other threads:[~2017-08-31  0:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-31  0:18 [RFC net-next 0/8] net: dsa: Multi-queue awareness Florian Fainelli
2017-08-31  0:18 ` [RFC net-next 1/8] net: dsa: Allow switch drivers to indicate number of RX/TX queues Florian Fainelli
2017-08-31 23:44   ` Andrew Lunn
2017-09-01  4:00     ` Florian Fainelli
2017-08-31  0:18 ` [RFC net-next 2/8] net: dsa: tag_brcm: Set output queue from skb queue mapping Florian Fainelli
2017-08-31  0:18 ` [RFC net-next 3/8] net: dsa: bcm_sf2: Advertise number of egress queues Florian Fainelli
2017-08-31  0:18 ` [RFC net-next 4/8] net: dsa: bcm_sf2: Configure IMP port TC2QOS mapping Florian Fainelli
2017-08-31  0:18 ` [RFC net-next 5/8] net: dsa: bcm_sf2: Fix number of CFP entries for BCM7278 Florian Fainelli
2017-08-31  0:18 ` Florian Fainelli [this message]
2017-08-31  0:18 ` [RFC net-next 7/8] net: dsa: tag_brcm: Indicate to master netdevice port + queue Florian Fainelli
2017-08-31  0:18 ` [RFC net-next 8/8] net: systemport: Establish DSA network device queue mapping Florian Fainelli
2017-09-01  0:05 ` [RFC net-next 0/8] net: dsa: Multi-queue awareness Andrew Lunn
2017-09-01  4:10   ` Florian Fainelli
2017-09-01 13:29     ` Andrew Lunn
2017-09-01 16:46       ` Florian Fainelli
2017-09-01 17:55         ` Andrew Lunn
2017-09-01 18:27           ` Florian Fainelli
2017-09-01 18:50             ` Andrew Lunn
2017-09-01 19:21               ` Florian Fainelli
2017-09-01 19:44                 ` Andrew Lunn

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=1504138732-65383-7-git-send-email-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@savoirfairelinux.com \
    --cc=xiyou.wangcong@gmail.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).