Commit 11d55be0 authored by Kory Maincent's avatar Kory Maincent Committed by David S. Miller
Browse files

net: ethtool: Add a command to expose current time stamping layer



Time stamping on network packets may happen either in the MAC or in
the PHY, but not both.  In preparation for making the choice
selectable, expose both the current layers via ethtool.

In accordance with the kernel implementation as it stands, the current
layer will always read as "phy" when a PHY time stamping device is
present. Future patches will allow changing the current layer
administratively.

Signed-off-by: default avatarKory Maincent <kory.maincent@bootlin.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent acec05fb
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -225,6 +225,7 @@ Userspace to kernel:
  ``ETHTOOL_MSG_RSS_GET``               get RSS settings
  ``ETHTOOL_MSG_MM_GET``                get MAC merge layer state
  ``ETHTOOL_MSG_MM_SET``                set MAC merge layer parameters
  ``ETHTOOL_MSG_TS_GET``                get current timestamping
  ===================================== =================================

Kernel to userspace:
@@ -268,6 +269,7 @@ Kernel to userspace:
  ``ETHTOOL_MSG_PSE_GET_REPLY``            PSE parameters
  ``ETHTOOL_MSG_RSS_GET_REPLY``            RSS settings
  ``ETHTOOL_MSG_MM_GET_REPLY``             MAC merge layer status
  ``ETHTOOL_MSG_TS_GET_REPLY``             current timestamping
  ======================================== =================================

``GET`` requests are sent by userspace applications to retrieve device
@@ -1994,6 +1996,26 @@ The attributes are propagated to the driver through the following structure:
.. kernel-doc:: include/linux/ethtool.h
    :identifiers: ethtool_mm_cfg

TS_GET
======

Gets current timestamping.

Request contents:

  =================================  ======  ====================
  ``ETHTOOL_A_TS_HEADER``            nested  request header
  =================================  ======  ====================

Kernel response contents:

  =======================  ======  ==============================
  ``ETHTOOL_A_TS_HEADER``  nested  reply header
  ``ETHTOOL_A_TS_LAYER``   u32     current timestamping
  =======================  ======  ==============================

This command get the current timestamp layer.

Request translation
===================

@@ -2100,4 +2122,5 @@ are netlink only.
  n/a                                 ``ETHTOOL_MSG_PLCA_GET_STATUS``
  n/a                                 ``ETHTOOL_MSG_MM_GET``
  n/a                                 ``ETHTOOL_MSG_MM_SET``
  n/a                                 ``ETHTOOL_MSG_TS_GET``
  =================================== =====================================
+14 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ enum {
	ETHTOOL_MSG_PLCA_GET_STATUS,
	ETHTOOL_MSG_MM_GET,
	ETHTOOL_MSG_MM_SET,
	ETHTOOL_MSG_TS_GET,

	/* add new constants above here */
	__ETHTOOL_MSG_USER_CNT,
@@ -109,6 +110,7 @@ enum {
	ETHTOOL_MSG_PLCA_NTF,
	ETHTOOL_MSG_MM_GET_REPLY,
	ETHTOOL_MSG_MM_NTF,
	ETHTOOL_MSG_TS_GET_REPLY,

	/* add new constants above here */
	__ETHTOOL_MSG_KERNEL_CNT,
@@ -975,6 +977,18 @@ enum {
	ETHTOOL_A_MM_MAX = (__ETHTOOL_A_MM_CNT - 1)
};

/* TS LAYER */

enum {
	ETHTOOL_A_TS_UNSPEC,
	ETHTOOL_A_TS_HEADER,			/* nest - _A_HEADER_* */
	ETHTOOL_A_TS_LAYER,			/* u32 */

	/* add new constants above here */
	__ETHTOOL_A_TS_CNT,
	ETHTOOL_A_TS_MAX = (__ETHTOOL_A_TS_CNT - 1)
};

/* generic netlink info */
#define ETHTOOL_GENL_NAME "ethtool"
#define ETHTOOL_GENL_VERSION 1
+10 −0
Original line number Diff line number Diff line
@@ -13,6 +13,16 @@
#include <linux/types.h>
#include <linux/socket.h>   /* for SO_TIMESTAMPING */

/* Layer of the TIMESTAMPING provider */
enum timestamping_layer {
	NO_TIMESTAMPING,
	SOFTWARE_TIMESTAMPING,
	MAC_TIMESTAMPING,
	PHY_TIMESTAMPING,

	__TIMESTAMPING_COUNT,
};

/* SO_TIMESTAMPING flags */
enum {
	SOF_TIMESTAMPING_TX_HARDWARE = (1<<0),
+1 −1
Original line number Diff line number Diff line
@@ -8,4 +8,4 @@ ethtool_nl-y := netlink.o bitset.o strset.o linkinfo.o linkmodes.o rss.o \
		   linkstate.o debug.o wol.o features.o privflags.o rings.o \
		   channels.o coalesce.o pause.o eee.o tsinfo.o cabletest.o \
		   tunnels.o fec.o eeprom.o stats.o phc_vclocks.o mm.o \
		   module.o pse-pd.o plca.o mm.o
		   module.o pse-pd.o plca.o mm.o ts.o
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ extern const char wol_mode_names[][ETH_GSTRING_LEN];
extern const char sof_timestamping_names[][ETH_GSTRING_LEN];
extern const char ts_tx_type_names[][ETH_GSTRING_LEN];
extern const char ts_rx_filter_names[][ETH_GSTRING_LEN];
extern const char ts_layer_names[][ETH_GSTRING_LEN];
extern const char udp_tunnel_type_names[][ETH_GSTRING_LEN];

int __ethtool_get_link(struct net_device *dev);
Loading