Skip to content

Commit 8f7ae5a

Browse files
vvfedorenkokuba-moo
authored andcommitted
bnxt_en: improve TX timestamping FIFO configuration
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]>
1 parent 8548c84 commit 8f7ae5a

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
@@ -3414,6 +3414,9 @@ static void bnxt_free_tx_skbs(struct bnxt *bp)
34143414

34153415
bnxt_free_one_tx_ring_skbs(bp, txr, i);
34163416
}
3417+
3418+
if (bp->ptp_cfg && !(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP))
3419+
bnxt_ptp_free_txts_skbs(bp->ptp_cfg);
34173420
}
34183421

34193422
static void bnxt_free_one_rx_ring(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
@@ -12797,8 +12800,6 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
1279712800
/* VF-reps may need to be re-opened after the PF is re-opened */
1279812801
if (BNXT_PF(bp))
1279912802
bnxt_vf_reps_open(bp);
12800-
if (bp->ptp_cfg && !(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP))
12801-
WRITE_ONCE(bp->ptp_cfg->tx_avail, BNXT_MAX_TX_TS);
1280212803
bnxt_ptp_init_rtc(bp, true);
1280312804
bnxt_ptp_cfg_tstamp_filters(bp);
1280412805
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
@@ -794,6 +794,27 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info)
794794
return HZ;
795795
}
796796

797+
void bnxt_ptp_free_txts_skbs(struct bnxt_ptp_cfg *ptp)
798+
{
799+
struct bnxt_ptp_tx_req *txts_req;
800+
u16 cons = ptp->txts_cons;
801+
802+
/* make sure ptp aux worker finished with
803+
* possible BNXT_STATE_OPEN set
804+
*/
805+
ptp_cancel_worker_sync(ptp->ptp_clock);
806+
807+
ptp->tx_avail = BNXT_MAX_TX_TS;
808+
while (cons != ptp->txts_prod) {
809+
txts_req = &ptp->txts_req[cons];
810+
if (!IS_ERR_OR_NULL(txts_req->tx_skb))
811+
dev_kfree_skb_any(txts_req->tx_skb);
812+
cons = NEXT_TXTS(cons);
813+
}
814+
ptp->txts_cons = cons;
815+
ptp_schedule_worker(ptp->ptp_clock, 0);
816+
}
817+
797818
int bnxt_ptp_get_txts_prod(struct bnxt_ptp_cfg *ptp, u16 *prod)
798819
{
799820
spin_lock_bh(&ptp->ptp_tx_lock);
@@ -1105,7 +1126,6 @@ int bnxt_ptp_init(struct bnxt *bp)
11051126
void bnxt_ptp_clear(struct bnxt *bp)
11061127
{
11071128
struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
1108-
int i;
11091129

11101130
if (!ptp)
11111131
return;
@@ -1117,12 +1137,5 @@ void bnxt_ptp_clear(struct bnxt *bp)
11171137
kfree(ptp->ptp_info.pin_config);
11181138
ptp->ptp_info.pin_config = NULL;
11191139

1120-
for (i = 0; i < BNXT_MAX_TX_TS; i++) {
1121-
if (ptp->txts_req[i].tx_skb) {
1122-
dev_kfree_skb_any(ptp->txts_req[i].tx_skb);
1123-
ptp->txts_req[i].tx_skb = NULL;
1124-
}
1125-
}
1126-
11271140
bnxt_unmap_ptp_regs(bp);
11281141
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ int bnxt_ptp_cfg_tstamp_filters(struct bnxt *bp);
162162
void bnxt_ptp_reapply_pps(struct bnxt *bp);
163163
int bnxt_hwtstamp_set(struct net_device *dev, struct ifreq *ifr);
164164
int bnxt_hwtstamp_get(struct net_device *dev, struct ifreq *ifr);
165+
void bnxt_ptp_free_txts_skbs(struct bnxt_ptp_cfg *ptp);
165166
int bnxt_ptp_get_txts_prod(struct bnxt_ptp_cfg *ptp, u16 *prod);
166167
void bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb, u16 prod);
167168
int bnxt_get_rx_ts_p5(struct bnxt *bp, u64 *ts, u32 pkt_ts);

0 commit comments

Comments
 (0)