Skip to content

Commit ff89ac7

Browse files
HoratiuVulturdavem330
authored andcommitted
net: lan966x: Don't read RX timestamp if not needed
Whenever a frame was received to the CPU, the HW is timestamping the frame. In the IFH(Inter Frame Header) it is found the nanosecond part of the timestamps the SW is required to read from HW the second part. But reading the second part it seems to be a expensive operations, so so change this such to read the second part only when rx filter is enabled. Doing this change gives the RX a performance boost of ~70mbit. before: [ 5] 0.00-10.01 sec 546 MBytes 457 Mbits/sec 0 sender now: [ 5] 0.00-10.01 sec 652 MBytes 530 Mbits/sec 0 sender Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 105a201 commit ff89ac7

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx,
517517
if (likely(!(skb->dev->features & NETIF_F_RXFCS)))
518518
skb_trim(skb, skb->len - ETH_FCS_LEN);
519519

520-
lan966x_ptp_rxtstamp(lan966x, skb, timestamp);
520+
lan966x_ptp_rxtstamp(lan966x, skb, src_port, timestamp);
521521
skb->protocol = eth_type_trans(skb, skb->dev);
522522

523523
if (lan966x->bridge_mask & BIT(src_port)) {

drivers/net/ethernet/microchip/lan966x/lan966x_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ static irqreturn_t lan966x_xtr_irq_handler(int irq, void *args)
668668
*buf = val;
669669
}
670670

671-
lan966x_ptp_rxtstamp(lan966x, skb, timestamp);
671+
lan966x_ptp_rxtstamp(lan966x, skb, src_port, timestamp);
672672
skb->protocol = eth_type_trans(skb, dev);
673673

674674
if (lan966x->bridge_mask & BIT(src_port)) {

drivers/net/ethernet/microchip/lan966x/lan966x_main.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ struct lan966x_port {
407407
struct phy *serdes;
408408
struct fwnode_handle *fwnode;
409409

410-
u8 ptp_cmd;
410+
u8 ptp_tx_cmd;
411+
bool ptp_rx_cmd;
411412
u16 ts_id;
412413
struct sk_buff_head tx_skbs;
413414

@@ -527,7 +528,7 @@ void lan966x_ptp_deinit(struct lan966x *lan966x);
527528
int lan966x_ptp_hwtstamp_set(struct lan966x_port *port, struct ifreq *ifr);
528529
int lan966x_ptp_hwtstamp_get(struct lan966x_port *port, struct ifreq *ifr);
529530
void lan966x_ptp_rxtstamp(struct lan966x *lan966x, struct sk_buff *skb,
530-
u64 timestamp);
531+
u64 src_port, u64 timestamp);
531532
int lan966x_ptp_txtstamp_request(struct lan966x_port *port,
532533
struct sk_buff *skb);
533534
void lan966x_ptp_txtstamp_release(struct lan966x_port *port,

drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,21 @@ int lan966x_ptp_hwtstamp_set(struct lan966x_port *port, struct ifreq *ifr)
272272

273273
switch (cfg.tx_type) {
274274
case HWTSTAMP_TX_ON:
275-
port->ptp_cmd = IFH_REW_OP_TWO_STEP_PTP;
275+
port->ptp_tx_cmd = IFH_REW_OP_TWO_STEP_PTP;
276276
break;
277277
case HWTSTAMP_TX_ONESTEP_SYNC:
278-
port->ptp_cmd = IFH_REW_OP_ONE_STEP_PTP;
278+
port->ptp_tx_cmd = IFH_REW_OP_ONE_STEP_PTP;
279279
break;
280280
case HWTSTAMP_TX_OFF:
281-
port->ptp_cmd = IFH_REW_OP_NOOP;
281+
port->ptp_tx_cmd = IFH_REW_OP_NOOP;
282282
break;
283283
default:
284284
return -ERANGE;
285285
}
286286

287287
switch (cfg.rx_filter) {
288288
case HWTSTAMP_FILTER_NONE:
289+
port->ptp_rx_cmd = false;
289290
break;
290291
case HWTSTAMP_FILTER_ALL:
291292
case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
@@ -301,6 +302,7 @@ int lan966x_ptp_hwtstamp_set(struct lan966x_port *port, struct ifreq *ifr)
301302
case HWTSTAMP_FILTER_PTP_V2_SYNC:
302303
case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
303304
case HWTSTAMP_FILTER_NTP_ALL:
305+
port->ptp_rx_cmd = true;
304306
cfg.rx_filter = HWTSTAMP_FILTER_ALL;
305307
break;
306308
default:
@@ -332,7 +334,7 @@ static int lan966x_ptp_classify(struct lan966x_port *port, struct sk_buff *skb)
332334
u8 msgtype;
333335
int type;
334336

335-
if (port->ptp_cmd == IFH_REW_OP_NOOP)
337+
if (port->ptp_tx_cmd == IFH_REW_OP_NOOP)
336338
return IFH_REW_OP_NOOP;
337339

338340
type = ptp_classify_raw(skb);
@@ -343,7 +345,7 @@ static int lan966x_ptp_classify(struct lan966x_port *port, struct sk_buff *skb)
343345
if (!header)
344346
return IFH_REW_OP_NOOP;
345347

346-
if (port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP)
348+
if (port->ptp_tx_cmd == IFH_REW_OP_TWO_STEP_PTP)
347349
return IFH_REW_OP_TWO_STEP_PTP;
348350

349351
/* If it is sync and run 1 step then set the correct operation,
@@ -1009,9 +1011,6 @@ static int lan966x_ptp_phc_init(struct lan966x *lan966x,
10091011
phc->index = index;
10101012
phc->lan966x = lan966x;
10111013

1012-
/* PTP Rx stamping is always enabled. */
1013-
phc->hwtstamp_config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
1014-
10151014
return 0;
10161015
}
10171016

@@ -1088,14 +1087,15 @@ void lan966x_ptp_deinit(struct lan966x *lan966x)
10881087
}
10891088

10901089
void lan966x_ptp_rxtstamp(struct lan966x *lan966x, struct sk_buff *skb,
1091-
u64 timestamp)
1090+
u64 src_port, u64 timestamp)
10921091
{
10931092
struct skb_shared_hwtstamps *shhwtstamps;
10941093
struct lan966x_phc *phc;
10951094
struct timespec64 ts;
10961095
u64 full_ts_in_ns;
10971096

1098-
if (!lan966x->ptp)
1097+
if (!lan966x->ptp ||
1098+
!lan966x->ports[src_port]->ptp_rx_cmd)
10991099
return;
11001100

11011101
phc = &lan966x->phc[LAN966X_PHC_PORT];

0 commit comments

Comments
 (0)