diff options
author | Vishvambar Panth S <vishvambarpanth.s@microchip.com> | 2023-10-20 21:58:01 +0300 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2023-10-24 10:16:08 +0300 |
commit | 169e0a5e43208fc5a6c5bc6476348cbd7203ae8a (patch) | |
tree | 6957594c12ef744e0db2947b265ef2fe2e6458ce /drivers/net/ethernet/microchip/lan743x_main.c | |
parent | efb3e0e1649f944c032095e3f0533a235a7477d3 (diff) | |
download | linux-169e0a5e43208fc5a6c5bc6476348cbd7203ae8a.tar.xz |
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 <vishvambarpanth.s@microchip.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20231020185801.25649-1-vishvambarpanth.s@microchip.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'drivers/net/ethernet/microchip/lan743x_main.c')
-rw-r--r-- | drivers/net/ethernet/microchip/lan743x_main.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index f940895b14e8..45e209a7d083 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1870,6 +1870,50 @@ static int lan743x_tx_get_avail_desc(struct lan743x_tx *tx) return last_head - last_tail - 1; } +static void lan743x_rx_cfg_b_tstamp_config(struct lan743x_adapter *adapter, + int rx_ts_config) +{ + int channel_number; + int index; + u32 data; + + for (index = 0; index < LAN743X_USED_RX_CHANNELS; index++) { + channel_number = adapter->rx[index].channel_number; + data = lan743x_csr_read(adapter, RX_CFG_B(channel_number)); + data &= RX_CFG_B_TS_MASK_; + data |= rx_ts_config; + lan743x_csr_write(adapter, RX_CFG_B(channel_number), + data); + } +} + +int lan743x_rx_set_tstamp_mode(struct lan743x_adapter *adapter, + int rx_filter) +{ + u32 data; + + switch (rx_filter) { + case HWTSTAMP_FILTER_PTP_V2_EVENT: + lan743x_rx_cfg_b_tstamp_config(adapter, + RX_CFG_B_TS_DESCR_EN_); + data = lan743x_csr_read(adapter, PTP_RX_TS_CFG); + data |= PTP_RX_TS_CFG_EVENT_MSGS_; + lan743x_csr_write(adapter, PTP_RX_TS_CFG, data); + break; + case HWTSTAMP_FILTER_NONE: + lan743x_rx_cfg_b_tstamp_config(adapter, + RX_CFG_B_TS_NONE_); + break; + case HWTSTAMP_FILTER_ALL: + lan743x_rx_cfg_b_tstamp_config(adapter, + RX_CFG_B_TS_ALL_RX_); + break; + default: + return -ERANGE; + } + return 0; +} + void lan743x_tx_set_timestamping_mode(struct lan743x_tx *tx, bool enable_timestamping, bool enable_onestep_sync) @@ -2944,7 +2988,6 @@ 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_; if (!(adapter->csr.flags & LAN743X_CSR_FLAG_IS_A0)) data |= RX_CFG_B_RDMABL_512_; |