Skip to content

Commit 169e0a5

Browse files
Vishvambar Panth SPaolo Abeni
authored andcommitted
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 Signed-off-by: Vishvambar Panth S <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent efb3e0e commit 169e0a5

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

drivers/net/ethernet/microchip/lan743x_ethtool.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,8 @@ static int lan743x_ethtool_get_ts_info(struct net_device *netdev,
10471047
BIT(HWTSTAMP_TX_ON) |
10481048
BIT(HWTSTAMP_TX_ONESTEP_SYNC);
10491049
ts_info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) |
1050-
BIT(HWTSTAMP_FILTER_ALL);
1050+
BIT(HWTSTAMP_FILTER_ALL) |
1051+
BIT(HWTSTAMP_FILTER_PTP_V2_EVENT);
10511052
return 0;
10521053
}
10531054

drivers/net/ethernet/microchip/lan743x_main.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1870,6 +1870,50 @@ static int lan743x_tx_get_avail_desc(struct lan743x_tx *tx)
18701870
return last_head - last_tail - 1;
18711871
}
18721872

1873+
static 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+
1890+
int lan743x_rx_set_tstamp_mode(struct lan743x_adapter *adapter,
1891+
int rx_filter)
1892+
{
1893+
u32 data;
1894+
1895+
switch (rx_filter) {
1896+
case HWTSTAMP_FILTER_PTP_V2_EVENT:
1897+
lan743x_rx_cfg_b_tstamp_config(adapter,
1898+
RX_CFG_B_TS_DESCR_EN_);
1899+
data = lan743x_csr_read(adapter, PTP_RX_TS_CFG);
1900+
data |= PTP_RX_TS_CFG_EVENT_MSGS_;
1901+
lan743x_csr_write(adapter, PTP_RX_TS_CFG, data);
1902+
break;
1903+
case HWTSTAMP_FILTER_NONE:
1904+
lan743x_rx_cfg_b_tstamp_config(adapter,
1905+
RX_CFG_B_TS_NONE_);
1906+
break;
1907+
case HWTSTAMP_FILTER_ALL:
1908+
lan743x_rx_cfg_b_tstamp_config(adapter,
1909+
RX_CFG_B_TS_ALL_RX_);
1910+
break;
1911+
default:
1912+
return -ERANGE;
1913+
}
1914+
return 0;
1915+
}
1916+
18731917
void lan743x_tx_set_timestamping_mode(struct lan743x_tx *tx,
18741918
bool enable_timestamping,
18751919
bool enable_onestep_sync)
@@ -2944,7 +2988,6 @@ static int lan743x_rx_open(struct lan743x_rx *rx)
29442988
data |= RX_CFG_B_RX_PAD_2_;
29452989
data &= ~RX_CFG_B_RX_RING_LEN_MASK_;
29462990
data |= ((rx->ring_size) & RX_CFG_B_RX_RING_LEN_MASK_);
2947-
data |= RX_CFG_B_TS_ALL_RX_;
29482991
if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0))
29492992
data |= RX_CFG_B_RDMABL_512_;
29502993

drivers/net/ethernet/microchip/lan743x_main.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,8 @@
522522
(((u32)(rx_latency)) & 0x0000FFFF)
523523
#define PTP_CAP_INFO (0x0A60)
524524
#define PTP_CAP_INFO_TX_TS_CNT_GET_(reg_val) (((reg_val) & 0x00000070) >> 4)
525+
#define PTP_RX_TS_CFG (0x0A68)
526+
#define PTP_RX_TS_CFG_EVENT_MSGS_ GENMASK(3, 0)
525527

526528
#define PTP_TX_MOD (0x0AA4)
527529
#define PTP_TX_MOD_TX_PTP_SYNC_TS_INSERT_ (0x10000000)
@@ -657,6 +659,9 @@
657659

658660
#define RX_CFG_B(channel) (0xC44 + ((channel) << 6))
659661
#define RX_CFG_B_TS_ALL_RX_ BIT(29)
662+
#define RX_CFG_B_TS_DESCR_EN_ BIT(28)
663+
#define RX_CFG_B_TS_NONE_ 0
664+
#define RX_CFG_B_TS_MASK_ (0xCFFFFFFF)
660665
#define RX_CFG_B_RX_PAD_MASK_ (0x03000000)
661666
#define RX_CFG_B_RX_PAD_0_ (0x00000000)
662667
#define RX_CFG_B_RX_PAD_2_ (0x02000000)
@@ -991,6 +996,9 @@ struct lan743x_rx {
991996
struct sk_buff *skb_head, *skb_tail;
992997
};
993998

999+
int lan743x_rx_set_tstamp_mode(struct lan743x_adapter *adapter,
1000+
int rx_filter);
1001+
9941002
/* SGMII Link Speed Duplex status */
9951003
enum lan743x_sgmii_lsd {
9961004
POWER_DOWN = 0,

drivers/net/ethernet/microchip/lan743x_ptp.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,10 @@ int lan743x_ptp_open(struct lan743x_adapter *adapter)
14931493
temp = lan743x_csr_read(adapter, PTP_TX_MOD2);
14941494
temp |= PTP_TX_MOD2_TX_PTP_CLR_UDPV4_CHKSUM_;
14951495
lan743x_csr_write(adapter, PTP_TX_MOD2, temp);
1496+
1497+
/* Default Timestamping */
1498+
lan743x_rx_set_tstamp_mode(adapter, HWTSTAMP_FILTER_NONE);
1499+
14961500
lan743x_ptp_enable(adapter);
14971501
lan743x_csr_write(adapter, INT_EN_SET, INT_BIT_1588_);
14981502
lan743x_csr_write(adapter, PTP_INT_EN_SET,
@@ -1653,6 +1657,9 @@ static void lan743x_ptp_disable(struct lan743x_adapter *adapter)
16531657
{
16541658
struct lan743x_ptp *ptp = &adapter->ptp;
16551659

1660+
/* Disable Timestamping */
1661+
lan743x_rx_set_tstamp_mode(adapter, HWTSTAMP_FILTER_NONE);
1662+
16561663
mutex_lock(&ptp->command_lock);
16571664
if (!lan743x_ptp_is_enabled(adapter)) {
16581665
netif_warn(adapter, drv, adapter->netdev,
@@ -1785,6 +1792,8 @@ int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
17851792
break;
17861793
}
17871794

1795+
ret = lan743x_rx_set_tstamp_mode(adapter, config.rx_filter);
1796+
17881797
if (!ret)
17891798
return copy_to_user(ifr->ifr_data, &config,
17901799
sizeof(config)) ? -EFAULT : 0;

0 commit comments

Comments
 (0)