All of lore.kernel.org
 help / color / mirror / Atom feed
From: Po Liu <po.liu@nxp.com>
To: "rmk+kernel@armlinux.org.uk" <rmk+kernel@armlinux.org.uk>,
	"linville@tuxdriver.com" <linville@tuxdriver.com>,
	"netdev-owner@vger.kernel.org" <netdev-owner@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "vinicius.gomes@intel.com" <vinicius.gomes@intel.com>,
	"simon.horman@netronome.com" <simon.horman@netronome.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Xiaoliang Yang <xiaoliang.yang_1@nxp.com>,
	Roy Zang <roy.zang@nxp.com>, Mingkai Hu <mingkai.hu@nxp.com>,
	Jerry Huang <jerry.huang@nxp.com>, Leo Li <leoyang.li@nxp.com>,
	Po Liu <po.liu@nxp.com>
Subject: [v1,ethtool] ethtool: add setting frame preemption of traffic classes
Date: Wed, 27 Nov 2019 09:58:52 +0000	[thread overview]
Message-ID: <20191127094448.6206-1-Po.Liu@nxp.com> (raw)

IEEE Std 802.1Qbu standard defined the frame preemption of port
trffic classes. User can set a value to hardware. The value will
be translated to a binary, each bit represent a traffic class.
Bit "1" means preemptable traffic class. Bit "0" means express
traffic class.  MSB represent high number traffic class.

ethtool -k devname

This command would show if the tx-preemption feature is available.
If hareware set preemption feature. The property would be a fixed
value 'on' if hardware support the frame preemption. Feature would
show a fixed value 'off' if hardware don't support the frame preemption.

ethtool devname

This command would show include an item 'preemption'. A following
value '0' means all traffic classes are 'express'. A value none zero
means traffic classes preemption capabilities. The value will be
translated to a binary, each bit represent a traffic class. Bit '1'
means preemptable traffic class. Bit '0' means express traffic class.
MSB represent high number traffic class.

ethtool -s devname preemption N

This command would set which traffic classes are frame preemptable.
The value will be translated to a binary, each bit represent a
traffic class. Bit '1' means preemptable traffic class. Bit '0'
means express traffic class. MSB represent high number traffic class.

Signed-off-by: Po Liu <Po.Liu@nxp.com>
---
 ethtool-copy.h |  6 +++++-
 ethtool.8.in   |  8 ++++++++
 ethtool.c      | 18 ++++++++++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/ethtool-copy.h b/ethtool-copy.h
index 9afd2e6..e04bdf3 100644
--- a/ethtool-copy.h
+++ b/ethtool-copy.h
@@ -1662,6 +1662,9 @@ static __inline__ int ethtool_validate_duplex(__u8 duplex)
 #define AUTONEG_DISABLE		0x00
 #define AUTONEG_ENABLE		0x01
 
+/* Disable preemtion. */
+#define PREEMPTION_DISABLE	0x0
+
 /* MDI or MDI-X status/control - if MDI/MDI_X/AUTO is set then
  * the driver is required to renegotiate link
  */
@@ -1878,7 +1881,8 @@ struct ethtool_link_settings {
 	__s8	link_mode_masks_nwords;
 	__u8	transceiver;
 	__u8	reserved1[3];
-	__u32	reserved[7];
+	__u32	preemption;
+	__u32	reserved[6];
 	__u32	link_mode_masks[0];
 	/* layout of link_mode_masks fields:
 	 * __u32 map_supported[link_mode_masks_nwords];
diff --git a/ethtool.8.in b/ethtool.8.in
index 062695a..7d612b2 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -236,6 +236,7 @@ ethtool \- query or control network driver and hardware settings
 .B2 autoneg on off
 .BN advertise
 .BN phyad
+.BN preemption
 .B2 xcvr internal external
 .RB [ wol \ \*(WO]
 .RB [ sopass \ \*(MA]
@@ -703,6 +704,13 @@ lB	l	lB.
 .BI phyad \ N
 PHY address.
 .TP
+.BI preemption \ N
+Set preemptable traffic classes by bits.
+.B A
+value will be translated to a binary, each bit represent a traffic class.
+Bit "1" means preemptable traffic class. Bit "0" means express traffic class.
+MSB represent high number traffic class.
+.TP
 .A2 xcvr internal external
 Selects transceiver type. Currently only internal and external can be
 specified, in the future further types might be added.
diff --git a/ethtool.c b/ethtool.c
index acf183d..d5240f8 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -928,6 +928,12 @@ dump_link_usettings(const struct ethtool_link_usettings *link_usettings)
 		}
 	}
 
+	if (link_usettings->base.preemption == PREEMPTION_DISABLE)
+		fprintf(stdout, "	Preemption: 0x0 (off)\n");
+	else
+		fprintf(stdout, "	Preemption: 0x%x\n",
+			link_usettings->base.preemption);
+
 	return 0;
 }
 
@@ -2869,6 +2875,7 @@ static int do_sset(struct cmd_context *ctx)
 	int port_wanted = -1;
 	int mdix_wanted = -1;
 	int autoneg_wanted = -1;
+	int preemption_wanted = -1;
 	int phyad_wanted = -1;
 	int xcvr_wanted = -1;
 	u32 *full_advertising_wanted = NULL;
@@ -2957,6 +2964,12 @@ static int do_sset(struct cmd_context *ctx)
 			} else {
 				exit_bad_args();
 			}
+		} else if (!strcmp(argp[i], "preemption")) {
+			gset_changed = 1;
+			i += 1;
+			if (i >= argc)
+				exit_bad_args();
+			preemption_wanted = get_u32(argp[i], 16);
 		} else if (!strcmp(argp[i], "advertise")) {
 			gset_changed = 1;
 			i += 1;
@@ -3094,6 +3107,9 @@ static int do_sset(struct cmd_context *ctx)
 			}
 			if (autoneg_wanted != -1)
 				link_usettings->base.autoneg = autoneg_wanted;
+			if (preemption_wanted != -1)
+				link_usettings->base.preemption
+					= preemption_wanted;
 			if (phyad_wanted != -1)
 				link_usettings->base.phy_address = phyad_wanted;
 			if (xcvr_wanted != -1)
@@ -3186,6 +3202,8 @@ static int do_sset(struct cmd_context *ctx)
 				fprintf(stderr, "  not setting transceiver\n");
 			if (mdix_wanted != -1)
 				fprintf(stderr, "  not setting mdix\n");
+			if (preemption_wanted != -1)
+				fprintf(stderr, "  not setting preemption\n");
 		}
 	}
 
-- 
2.17.1


             reply	other threads:[~2019-11-27  9:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27  9:58 Po Liu [this message]
2019-12-03 16:27 ` [v1,ethtool] ethtool: add setting frame preemption of traffic classes Ivan Khoronzhuk
2019-12-03 17:42   ` Murali Karicheri
2019-12-04  8:14     ` [EXT] " Po Liu
2019-12-04 16:59       ` Murali Karicheri

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=20191127094448.6206-1-Po.Liu@nxp.com \
    --to=po.liu@nxp.com \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=jerry.huang@nxp.com \
    --cc=leoyang.li@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=mingkai.hu@nxp.com \
    --cc=netdev-owner@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=roy.zang@nxp.com \
    --cc=simon.horman@netronome.com \
    --cc=vinicius.gomes@intel.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=xiaoliang.yang_1@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.