netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: raspl@linux.vnet.ibm.com
To: bhutchings@solarflare.com
Cc: davem@davemloft.net, blaschka@linux.vnet.ibm.com,
	netdev@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH ethtool 1/3] ethtool: Add callback to indicate adjacent switch port attributes
Date: Mon, 09 Dec 2013 07:31:55 +0100	[thread overview]
Message-ID: <20131209063312.413393059@linux.vnet.ibm.com> (raw)
In-Reply-To: 20131209063154.508075549@linux.vnet.ibm.com

[-- Attachment #1: ethtool_add_query_swport_settings.patch --]
[-- Type: text/plain, Size: 4644 bytes --]

Switches supporting LLDP can communicate port attributes to connected devices.
Device drivers capable of accessing this information from the devices can use
the new callback get_switch_port_attrs() to report supported and enabled
settings in the card's adjacent switch port for display in ethtool.
Implementors have to use the respective SUPPORTED_SP_* and ENABLED_SP_* defines
to indicate the current settings.

Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>

---
 include/linux/ethtool.h      |    3 +++
 include/uapi/linux/ethtool.h |   35 +++++++++++++++++++++++++++++++++++
 net/core/ethtool.c           |   22 ++++++++++++++++++++++
 3 files changed, 60 insertions(+)

--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -177,6 +177,7 @@ static inline u32 ethtool_rxfh_indir_def
  * @get_module_eeprom: Get the eeprom information from the plug-in module
  * @get_eee: Get Energy-Efficient (EEE) supported and status.
  * @set_eee: Set EEE status (enable/disable) as well as LPI timers.
+ * @get_switch_port_attrs: Get adjacent switch port attributes.
  *
  * All operations are optional (i.e. the function pointer may be set
  * to %NULL) and callers must take this into account.  Callers must
@@ -245,6 +246,8 @@ struct ethtool_ops {
 				     struct ethtool_eeprom *, u8 *);
 	int	(*get_eee)(struct net_device *, struct ethtool_eee *);
 	int	(*set_eee)(struct net_device *, struct ethtool_eee *);
+	int     (*get_switch_port_attrs)(struct net_device *,
+					 struct ethtool_swport_attrs *);
 
 
 };
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -136,6 +136,22 @@ struct ethtool_eeprom {
 };
 
 /**
+ * struct ethtool_swport_attrs - query adjacent switch port attributes
+ * @cmd: ETHTOOL_GPORT
+ * @port_rc: Use GPORT_RC_* as appropriate.
+ * @supported: Forwarding modes and capabilities supported by the switch port,
+ *	see SUPPORTED_SP_* flags.
+ * @enabled: Forwarding modes and capabilities currently activated at the
+ *	adjacent switch port, see ENABLED_SP_* flags.
+ */
+struct ethtool_swport_attrs {
+	__u32	cmd;
+	__u32	port_rc;
+	__u32	supported;
+	__u32	enabled;
+};
+
+/**
  * struct ethtool_eee - Energy Efficient Ethernet information
  * @cmd: ETHTOOL_{G,S}EEE
  * @supported: Mask of %SUPPORTED_* flags for the speed/duplex combinations
@@ -900,6 +916,7 @@ enum ethtool_sfeatures_retval_bits {
 #define ETHTOOL_GMODULEEEPROM	0x00000043 /* Get plug-in module eeprom */
 #define ETHTOOL_GEEE		0x00000044 /* Get EEE settings */
 #define ETHTOOL_SEEE		0x00000045 /* Set EEE settings */
+#define ETHTOOL_GPORT		0x00000046 /* Get switch port attributes */
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET
@@ -1067,6 +1084,24 @@ enum ethtool_sfeatures_retval_bits {
 #define ETH_MODULE_SFF_8472		0x2
 #define ETH_MODULE_SFF_8472_LEN		512
 
+/* Bad return codes for switch ports */
+#define GPORT_RC_LLDP_UNSUP	1	/* switch port doesn't support */
+					/* required LLDP EVB TLV       */
+
+/* Indicates what features the adjacent switch port supports. */
+#define SUPPORTED_SP_FWD_802_1	(1 << 0)
+#define SUPPORTED_SP_FWD_RR	(1 << 1)
+#define SUPPORTED_SP_CAP_RTE	(1 << 9)
+#define SUPPORTED_SP_CAP_ECP	(1 << 10)
+#define SUPPORTED_SP_CAP_VDP	(1 << 11)
+
+/* Indicates what features the adjacent switch port has enabled. */
+#define ENABLED_SP_FWD_802_1	(1 << 0)
+#define ENABLED_SP_FWD_RR	(1 << 1)
+#define ENABLED_SP_CAP_RTE	(1 << 9)
+#define ENABLED_SP_CAP_ECP	(1 << 10)
+#define ENABLED_SP_CAP_VDP	(1 << 11)
+
 /* Reset flags */
 /* The reset() operation must clear the flags for the components which
  * were actually reset.  On successful return, the flags indicate the
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1446,6 +1446,25 @@ static int ethtool_get_module_eeprom(str
 				      modinfo.eeprom_len);
 }
 
+static int ethtool_get_switch_port_attrs(struct net_device *dev,
+							void __user *useraddr)
+{
+	struct ethtool_swport_attrs attrs = { ETHTOOL_GPORT };
+	int rc;
+
+	if (!dev->ethtool_ops->get_switch_port_attrs)
+		return -EOPNOTSUPP;
+
+	rc = dev->ethtool_ops->get_switch_port_attrs(dev, &attrs);
+	if (rc)
+		return rc;
+
+	if (copy_to_user(useraddr, &attrs, sizeof(attrs)))
+		return -EFAULT;
+
+	return 0;
+}
+
 /* The main entry point in this file.  Called from net/core/dev_ioctl.c */
 
 int dev_ethtool(struct net *net, struct ifreq *ifr)
@@ -1675,6 +1694,9 @@ int dev_ethtool(struct net *net, struct
 	case ETHTOOL_GMODULEEEPROM:
 		rc = ethtool_get_module_eeprom(dev, useraddr);
 		break;
+	case ETHTOOL_GPORT:
+		rc = ethtool_get_switch_port_attrs(dev, useraddr);
+		break;
 	default:
 		rc = -EOPNOTSUPP;
 	}

  reply	other threads:[~2013-12-12  8:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-09  6:31 [PATCH ethtool 0/3] Display adjacent switch port's attributes raspl
2013-12-09  6:31 ` raspl [this message]
2013-12-09  6:31 ` [PATCH ethtool 2/3] ethtool: Add option -q to display adjacent switch ports attributes raspl
2013-12-09  6:31 ` [PATCH ethtool 3/3] qeth: Display adjacent switch port attributes in ethtool raspl
2013-12-12  9:24 ` [PATCH ethtool 0/3] Display adjacent switch port's attributes Stefan Raspl
  -- strict thread matches above, loose matches on Subject: below --
2013-12-09  8:11 raspl
2013-12-09  8:11 ` [PATCH ethtool 1/3] ethtool: Add callback to indicate adjacent switch port attributes raspl

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=20131209063312.413393059@linux.vnet.ibm.com \
    --to=raspl@linux.vnet.ibm.com \
    --cc=bhutchings@solarflare.com \
    --cc=blaschka@linux.vnet.ibm.com \
    --cc=davem@davemloft.net \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).