Skip to contentSkip to conversation

Display adjacent switch port's attributes

PATCH New Stefan Raspl 1 participant 2 messages Dec 11, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Display adjacent switch port's attributes

This patch adds a new option to ethtool to display the adjacent switch port's attributes, as perceived by the NIC, e.g. through respective LLDP message exchanges.

Best regards,
Stefan Raspl

Stefan Raspl (1):
ethtool: Add option '-q' to display adjacent switch port's attributes

 ethtool-copy.h | 35 ++++++++++++++++++++++++++++++
 ethtool.8.in   |  6 ++++++
 ethtool.c      | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 109 insertions(+)
Signature · 1 line
1.8.3.4
#1 lore raw

PATCH 1/1 ethtool: Add option '-q' to display adjacent switch port's attributes

Add new option '-q|--query-switch-port' to display information on the adjacent switch port's settings as perceived by the respective NIC. In the output,
- unsupported attributes are indicated as such ('unsupported'),
- supported but disabled attributes display 'no', and
- enabled attributes display 'yes'.
Attributes supported by this patch are
- forwarding modes:
standard (802.1) and reflective relay (RR) aka hairpin
- edge virtual bridging (EVB) related capabilities:
edge control protocol (ECP), VSI discovery and configuration protocol (VDP), and retransmission timer exponent (RTE).

---
 ethtool-copy.h | 35 ++++++++++++++++++++++++++++++
 ethtool.8.in   |  6 ++++++
 ethtool.c      | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 109 insertions(+)
ethtool-copy.h +35 -0
index b5515c2..7028bf6 100644
@@ -348,6 +348,22 @@ struct ethtool_pauseparam {
 	__u32	tx_pause;
 };
 
+/**
+ * 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;
+};
+
 #define ETH_GSTRING_LEN		32
 enum ethtool_stringset {
 	ETH_SS_TEST		= 0,
@@ -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
ethtool.8.in +6 -0
index f587ec8..ffc0225 100644
@@ -214,6 +214,9 @@ ethtool \- query or control network driver and hardware settings
 .B ethtool \-P|\-\-show\-permaddr
 .I devname
 .HP
+.B ethtool \-q|\-\-query-switch-port
+.I devname
+.HP
 .B ethtool \-r|\-\-negotiate
 .I devname
 .HP
@@ -483,6 +486,9 @@ Length of time to perform phys-id, in seconds.
 .B \-P \-\-show\-permaddr
 Queries the specified network device for permanent hardware address.
 .TP
+.B \-q \-\-query-switch-port
+Queries the specified Ethernet device for adjacent switch port's attributes.
+.TP
 .B \-r \-\-negotiate
 Restarts auto-negotiation on the specified Ethernet device, if
 auto-negotiation is enabled.
ethtool.c +68 -0

86 lines not on this page · raw message

Signature · 1 line
1.8.3.4