Skip to contentSkip to conversation

net: microchip: lan743x: improve throughput with rx timestamp config

PATCH Superseded Vishvambar Panth S 2 participants 2 messages Oct 17, 2023

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: microchip: lan743x: improve throughput with rx timestamp config

Currently all RX frames are timestamped which results in a performance penalty when timestamping is not needed. The default is now being changed to not timestamp any Rx frames (HWTSTAMP_FILTER_NONE), but support has been added to allow changing the desired RX timestamping mode (HWTSTAMP_FILTER_ALL - which was the previous setting and HWTSTAMP_FILTER_PTP_V2_EVENT are now supported) using SIOCSHWTSTAMP. All settings were tested using the hwstamp_ctl application. It is also noted that ptp4l, when started, preconfigures the device to timestamp using HWTSTAMP_FILTER_PTP_V2_EVENT, so this driver continues to work properly "out of the box".

Test setup: x64 PC with LAN7430 ---> x64 PC as partner

iperf3 with - Timestamp all incoming packets:
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr

[  5]   0.00-5.05   sec   517 MBytes   859 Mbits/sec    0    sender
[  5]   0.00-5.00   sec   515 MBytes   864 Mbits/sec         receiver

iperf Done.

iperf3 with - Timestamp only PTP packets:
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr

[  5]   0.00-5.04   sec   563 MBytes   937 Mbits/sec    0    sender
[  5]   0.00-5.00   sec   561 MBytes   941 Mbits/sec         receiver

---
Change Log:
v1->v2
* As per community comments, dropped netif_warn
* dropped HWTSTAMP_FILTER_PTP_V2_DELAY_REQ & SYNC cases.
* replaced two separate decision points with mask & setting

 .../net/ethernet/microchip/lan743x_ethtool.c  |  3 +-
 drivers/net/ethernet/microchip/lan743x_main.c | 45 ++++++++++++++++++-
 drivers/net/ethernet/microchip/lan743x_main.h |  8 ++++
 drivers/net/ethernet/microchip/lan743x_ptp.c  |  9 ++++
 4 files changed, 63 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/lan743x_ethtool.c +2 -1
index 2db5949b4c7e..6961cfc55fb9 100644
@@ -1047,7 +1047,8 @@ static int lan743x_ethtool_get_ts_info(struct net_device *netdev,
 			    BIT(HWTSTAMP_TX_ON) |
 			    BIT(HWTSTAMP_TX_ONESTEP_SYNC);
 	ts_info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) |
-			      BIT(HWTSTAMP_FILTER_ALL);
+			      BIT(HWTSTAMP_FILTER_ALL) |
+			      BIT(HWTSTAMP_FILTER_PTP_V2_EVENT);
 	return 0;
 }
 
drivers/net/ethernet/microchip/lan743x_main.c +44 -1

57 lines not on this page · raw message

drivers/net/ethernet/microchip/lan743x_main.h +8 -0
index 52609fc13ad9..b648461787d2 100644
@@ -522,6 +522,8 @@
 	(((u32)(rx_latency)) & 0x0000FFFF)
 #define PTP_CAP_INFO				(0x0A60)
 #define PTP_CAP_INFO_TX_TS_CNT_GET_(reg_val)	(((reg_val) & 0x00000070) >> 4)
+#define PTP_RX_TS_CFG				(0x0A68)
+#define PTP_RX_TS_CFG_EVENT_MSGS_               GENMASK(3, 0)
 
 #define PTP_TX_MOD				(0x0AA4)
 #define PTP_TX_MOD_TX_PTP_SYNC_TS_INSERT_	(0x10000000)
@@ -657,6 +659,9 @@
 
 #define RX_CFG_B(channel)			(0xC44 + ((channel) << 6))
 #define RX_CFG_B_TS_ALL_RX_			BIT(29)
+#define RX_CFG_B_TS_DESCR_EN_			BIT(28)
+#define RX_CFG_B_TS_NONE_			0
+#define RX_CFG_B_TS_MASK_			(0xCFFFFFFF)
 #define RX_CFG_B_RX_PAD_MASK_			(0x03000000)
 #define RX_CFG_B_RX_PAD_0_			(0x00000000)
 #define RX_CFG_B_RX_PAD_2_			(0x02000000)
@@ -991,6 +996,9 @@ struct lan743x_rx {
 	struct sk_buff *skb_head, *skb_tail;
 };
 
+int lan743x_rx_set_tstamp_mode(struct lan743x_adapter *adapter,
+			       int rx_filter);
+
 /* SGMII Link Speed Duplex status */
 enum lan743x_sgmii_lsd {
 	POWER_DOWN = 0,
drivers/net/ethernet/microchip/lan743x_ptp.c +9 -0
index 39e1066ecd5f..2f04bc77a118 100644
@@ -1493,6 +1493,10 @@ int lan743x_ptp_open(struct lan743x_adapter *adapter)
 	temp = lan743x_csr_read(adapter, PTP_TX_MOD2);
 	temp |= PTP_TX_MOD2_TX_PTP_CLR_UDPV4_CHKSUM_;
 	lan743x_csr_write(adapter, PTP_TX_MOD2, temp);
+
+	/* Default Timestamping */
+	lan743x_rx_set_tstamp_mode(adapter, HWTSTAMP_FILTER_NONE);
+
 	lan743x_ptp_enable(adapter);
 	lan743x_csr_write(adapter, INT_EN_SET, INT_BIT_1588_);
 	lan743x_csr_write(adapter, PTP_INT_EN_SET,
@@ -1653,6 +1657,9 @@ static void lan743x_ptp_disable(struct lan743x_adapter *adapter)
 {
 	struct lan743x_ptp *ptp = &adapter->ptp;
 
+	/* Disable Timestamping */
+	lan743x_rx_set_tstamp_mode(adapter, HWTSTAMP_FILTER_NONE);
+
 	mutex_lock(&ptp->command_lock);
 	if (!lan743x_ptp_is_enabled(adapter)) {
 		netif_warn(adapter, drv, adapter->netdev,
@@ -1785,6 +1792,8 @@ int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
 		break;
 	}
 
+	ret = lan743x_rx_set_tstamp_mode(adapter, config.rx_filter);
+
 	if (!ret)
 		return copy_to_user(ifr->ifr_data, &config,
 			sizeof(config)) ? -EFAULT : 0;
Signature · 1 line
2.25.1
#1 lore raw
kernel test robot noticed the following build warnings:

Hi Vishvambar,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Vishvambar-Panth-S/net-microchip-lan743x-improve-throughput-with-rx-timestamp-config/20231017-180453
base:   net-next/main
patch link:    https://lore.kernel.org/r/20231017180542.30613-1-vishvambarpanth.s%40microchip.com
patch subject: [PATCH v2 net-next] net: microchip: lan743x: improve throughput with rx timestamp config
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20231017/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231017/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/microchip/lan743x_main.c:1873:6: warning: no previous prototype for 'lan743x_rx_cfg_b_tstamp_config' [-Wmissing-prototypes]
    1873 | void lan743x_rx_cfg_b_tstamp_config(struct lan743x_adapter *adapter,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/lan743x_rx_cfg_b_tstamp_config +1873 drivers/net/ethernet/microchip/lan743x_main.c

1872

> 1873	void lan743x_rx_cfg_b_tstamp_config(struct lan743x_adapter *adapter,

1874 int rx_ts_config)
1875 {
1876 int channel_number;
1877 int index;
1878 u32 data;
1879
1880 for (index = 0; index < LAN743X_USED_RX_CHANNELS; index++) {
1881 channel_number = adapter->rx[index].channel_number;
1882 data = lan743x_csr_read(adapter, RX_CFG_B(channel_number));
1883 data &= RX_CFG_B_TS_MASK_;
1884 data |= rx_ts_config;
1885 lan743x_csr_write(adapter, RX_CFG_B(channel_number),
1886 data);
1887 }
1888 }
1889

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki