Skip to content

Commit 4911412

Browse files
vvfedorenkogregkh
authored andcommitted
bnxt_en: improve TX timestamping FIFO configuration
[ Upstream commit 8f7ae5a ] Reconfiguration of netdev may trigger close/open procedure which can break FIFO status by adjusting the amount of empty slots for TX timestamps. But it is not really needed because timestamps for the packets sent over the wire still can be retrieved. On the other side, during netdev close procedure any skbs waiting for TX timestamps can be leaked because there is no cleaning procedure called. Free skbs waiting for TX timestamps when closing netdev. Fixes: 8aa2a79 ("bnxt_en: Increase the max total outstanding PTP TX packets to 4") Reviewed-by: Michael Chan <[email protected]> Reviewed-by: Pavan Chebbi <[email protected]> Signed-off-by: Vadim Fedorenko <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent ddc1e64 commit 4911412

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,6 +3320,9 @@ static void bnxt_free_tx_skbs(struct bnxt *bp)
33203320
}
33213321
netdev_tx_reset_queue(netdev_get_tx_queue(bp->dev, i));
33223322
}
3323+
3324+
if (bp->ptp_cfg && !(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP))
3325+
bnxt_ptp_free_txts_skbs(bp->ptp_cfg);
33233326
}
33243327

33253328
static void bnxt_free_one_rx_ring(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
@@ -12249,8 +12252,6 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
1224912252
/* VF-reps may need to be re-opened after the PF is re-opened */
1225012253
if (BNXT_PF(bp))
1225112254
bnxt_vf_reps_open(bp);
12252-
if (bp->ptp_cfg && !(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP))
12253-
WRITE_ONCE(bp->ptp_cfg->tx_avail, BNXT_MAX_TX_TS);
1225412255
bnxt_ptp_init_rtc(bp, true);
1225512256
bnxt_ptp_cfg_tstamp_filters(bp);
1225612257
if (BNXT_SUPPORTS_MULTI_RSS_CTX(bp))

drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,27 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info)
777777
return HZ;
778778
}
779779

780+
void bnxt_ptp_free_txts_skbs(struct bnxt_ptp_cfg *ptp)
781+
{
782+
struct bnxt_ptp_tx_req *txts_req;
783+
u16 cons = ptp->txts_cons;
784+
785+
/* make sure ptp aux worker finished with
786+
* possible BNXT_STATE_OPEN set
787+
*/
788+
ptp_cancel_worker_sync(ptp->ptp_clock);
789+
790+
ptp->tx_avail = BNXT_MAX_TX_TS;
791+
while (cons != ptp->txts_prod) {
792+
txts_req = &ptp->txts_req[cons];
793+
if (!IS_ERR_OR_NULL(txts_req->tx_skb))
794+
dev_kfree_skb_any(txts_req->tx_skb);
795+
cons = NEXT_TXTS(cons);
796+
}
797+
ptp->txts_cons = cons;
798+
ptp_schedule_worker(ptp->ptp_clock, 0);
799+
}
800+
780801
int bnxt_ptp_get_txts_prod(struct bnxt_ptp_cfg *ptp, u16 *prod)
781802
{
782803
spin_lock_bh(&ptp->ptp_tx_lock);
@@ -1095,7 +1116,6 @@ int bnxt_ptp_init(struct bnxt *bp)
10951116
void bnxt_ptp_clear(struct bnxt *bp)
10961117
{
10971118
struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
1098-
int i;
10991119

11001120
if (!ptp)
11011121
return;
@@ -1107,12 +1127,5 @@ void bnxt_ptp_clear(struct bnxt *bp)
11071127
kfree(ptp->ptp_info.pin_config);
11081128
ptp->ptp_info.pin_config = NULL;
11091129

1110-
for (i = 0; i < BNXT_MAX_TX_TS; i++) {
1111-
if (ptp->txts_req[i].tx_skb) {
1112-
dev_kfree_skb_any(ptp->txts_req[i].tx_skb);
1113-
ptp->txts_req[i].tx_skb = NULL;
1114-
}
1115-
}
1116-
11171130
bnxt_unmap_ptp_regs(bp);
11181131
}

drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ int bnxt_ptp_cfg_tstamp_filters(struct bnxt *bp);
174174
void bnxt_ptp_reapply_pps(struct bnxt *bp);
175175
int bnxt_hwtstamp_set(struct net_device *dev, struct ifreq *ifr);
176176
int bnxt_hwtstamp_get(struct net_device *dev, struct ifreq *ifr);
177+
void bnxt_ptp_free_txts_skbs(struct bnxt_ptp_cfg *ptp);
177178
int bnxt_ptp_get_txts_prod(struct bnxt_ptp_cfg *ptp, u16 *prod);
178179
void bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb, u16 prod);
179180
int bnxt_get_rx_ts_p5(struct bnxt *bp, u64 *ts, u32 pkt_ts);

0 commit comments

Comments
 (0)