lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230731125418.75140-1-vishvambarpanth.s@microchip.com>
Date:   Mon, 31 Jul 2023 18:24:18 +0530
From:   Vishvambar Panth S <vishvambarpanth.s@...rochip.com>
To:     <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC:     <bryan.whitehead@...rochip.com>, <UNGLinuxDriver@...rochip.com>,
        <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
        <pabeni@...hat.com>, <richardcochran@...il.com>,
        Vishvambar Panth S <vishvambarpanth.s@...rochip.com>
Subject: [PATCH net-next] net: lan743x: skip timestamping for non-PTP packets

Currently all the RX packets are timestamped and the timestamp is appended
to the RX packet for processing, this reduces RX throughput. This can be
optimized by timestamping packets only when the PTP messages are received.
The RX PTP Configuration register [PTP_RX_TS_CFG] specifies what are the
PTP message types to be timestamped. The PTP_RX_TS_CFG_MSG_EN_ configures
Sync, Delay_Req, Pdelay_Req, Pdelay_Resp Message types to be timestamped.
The RX_CFG_B_TS_ALL_RX_ bit enables storing the timestamp for all RX
frames, now this is cleared as only PTP packets will be timestamped. The
RX_CFG_B_TS_DESCR_EN_ enables storing the timestamp in an extension
descriptor. When PTP messages are received the timestamp will be stored
in an extension descriptor of the RX packet.

Test setup:  x86 PC with LAN7430 ---> x86 PC with i210 as partner

Before:

Connecting to host 192.168.10.3, port 5201
Reverse mode, remote host 192.168.10.3 is sending
[  5] local 192.168.10.10 port 54072 connected to 192.168.10.3 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  97.7 MBytes   819 Mbits/sec
[  5]   1.00-2.00   sec  97.6 MBytes   819 Mbits/sec
[  5]   2.00-3.00   sec  97.7 MBytes   819 Mbits/sec
[  5]   3.00-4.00   sec  97.7 MBytes   819 Mbits/sec
[  5]   4.00-5.00   sec  97.7 MBytes   820 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-5.05   sec   490 MBytes   814 Mbits/sec    0   sender
[  5]   0.00-5.00   sec   488 MBytes   819 Mbits/sec        receiver

iperf Done.

After:

Connecting to host 192.168.10.3, port 5201
Reverse mode, remote host 192.168.10.3 is sending
[  5] local 192.168.10.10 port 42438 connected to 192.168.10.3 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec   112 MBytes   941 Mbits/sec
[  5]   1.00-2.00   sec   112 MBytes   941 Mbits/sec
[  5]   2.00-3.00   sec   112 MBytes   941 Mbits/sec
[  5]   3.00-4.00   sec   112 MBytes   941 Mbits/sec
[  5]   4.00-5.00   sec   112 MBytes   941 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-5.04   sec   563 MBytes   936 Mbits/sec    0   sender
[  5]   0.00-5.00   sec   561 MBytes   941 Mbits/sec        receiver

iperf Done.

Signed-off-by: Vishvambar Panth S <vishvambarpanth.s@...rochip.com>
---
 drivers/net/ethernet/microchip/lan743x_ethtool.c |  4 +++-
 drivers/net/ethernet/microchip/lan743x_main.c    |  2 +-
 drivers/net/ethernet/microchip/lan743x_main.h    |  5 ++++-
 drivers/net/ethernet/microchip/lan743x_ptp.c     | 11 +++++++++++
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_ethtool.c b/drivers/net/ethernet/microchip/lan743x_ethtool.c
index 2db5949b4c7e..01cb2e4cce82 100644
--- a/drivers/net/ethernet/microchip/lan743x_ethtool.c
+++ b/drivers/net/ethernet/microchip/lan743x_ethtool.c
@@ -1047,7 +1047,9 @@ 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_PTP_V2_EVENT) |
+			      BIT(HWTSTAMP_FILTER_PTP_V2_SYNC) |
+			      BIT(HWTSTAMP_FILTER_PTP_V2_DELAY_REQ);
 	return 0;
 }
 
diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index a36f6369f132..154f714f5b92 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -2938,7 +2938,7 @@ static int lan743x_rx_open(struct lan743x_rx *rx)
 		data |= RX_CFG_B_RX_PAD_2_;
 	data &= ~RX_CFG_B_RX_RING_LEN_MASK_;
 	data |= ((rx->ring_size) & RX_CFG_B_RX_RING_LEN_MASK_);
-	data |= RX_CFG_B_TS_ALL_RX_;
+	data |= RX_CFG_B_TS_DESCR_EN_;
 	if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0))
 		data |= RX_CFG_B_RDMABL_512_;
 
diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h
index 52609fc13ad9..e1b01a899002 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.h
+++ b/drivers/net/ethernet/microchip/lan743x_main.h
@@ -522,6 +522,9 @@
 	(((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)
+/* Config for Sync, Delay_Req, Pdelay_Req, Pdelay_Resp Message types */
+#define PTP_RX_TS_CFG_MSG_EN_			(0x000F)
 
 #define PTP_TX_MOD				(0x0AA4)
 #define PTP_TX_MOD_TX_PTP_SYNC_TS_INSERT_	(0x10000000)
@@ -656,7 +659,7 @@
 #define RX_CFG_A_RX_HP_WB_EN_			BIT(5)
 
 #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_RX_PAD_MASK_			(0x03000000)
 #define RX_CFG_B_RX_PAD_0_			(0x00000000)
 #define RX_CFG_B_RX_PAD_2_			(0x02000000)
diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.c b/drivers/net/ethernet/microchip/lan743x_ptp.c
index 39e1066ecd5f..74204f5bf8b0 100644
--- a/drivers/net/ethernet/microchip/lan743x_ptp.c
+++ b/drivers/net/ethernet/microchip/lan743x_ptp.c
@@ -1636,9 +1636,14 @@ static bool lan743x_ptp_is_enabled(struct lan743x_adapter *adapter)
 static void lan743x_ptp_enable(struct lan743x_adapter *adapter)
 {
 	struct lan743x_ptp *ptp = &adapter->ptp;
+	u32 data;
 
 	mutex_lock(&ptp->command_lock);
 
+	data = lan743x_csr_read(adapter, PTP_RX_TS_CFG);
+	data |= PTP_RX_TS_CFG_MSG_EN_;
+	lan743x_csr_write(adapter, PTP_RX_TS_CFG, data);
+
 	if (lan743x_ptp_is_enabled(adapter)) {
 		netif_warn(adapter, drv, adapter->netdev,
 			   "PTP already enabled\n");
@@ -1652,6 +1657,7 @@ static void lan743x_ptp_enable(struct lan743x_adapter *adapter)
 static void lan743x_ptp_disable(struct lan743x_adapter *adapter)
 {
 	struct lan743x_ptp *ptp = &adapter->ptp;
+	u32 data;
 
 	mutex_lock(&ptp->command_lock);
 	if (!lan743x_ptp_is_enabled(adapter)) {
@@ -1659,6 +1665,11 @@ static void lan743x_ptp_disable(struct lan743x_adapter *adapter)
 			   "PTP already disabled\n");
 		goto done;
 	}
+
+	data = lan743x_csr_read(adapter, PTP_RX_TS_CFG);
+	data &= ~PTP_RX_TS_CFG_MSG_EN_;
+	lan743x_csr_write(adapter, PTP_RX_TS_CFG, data);
+
 	lan743x_csr_write(adapter, PTP_CMD_CTL, PTP_CMD_CTL_PTP_DISABLE_);
 	lan743x_ptp_wait_till_cmd_done(adapter, PTP_CMD_CTL_PTP_ENABLE_);
 done:
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ