Skip to content

Commit 3019632

Browse files
author
Shruti Parab
committed
bnxt_en: improve TX timestamping FIFO configuration
JIRA: https://issues.redhat.com/browse/RHEL-76565 commit 8f7ae5a Author: Vadim Fedorenko <vadim.fedorenko@linux.dev> Date: Thu Apr 24 05:55:47 2025 -0700 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 <michael.chan@broadcom.com> Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com> Signed-off-by: Vadim Fedorenko <vadfed@meta.com> Link: https://patch.msgid.link/20250424125547.460632-1-vadfed@meta.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Shruti Parab <shruti.parab@broadcom.com>
1 parent 08226d0 commit 3019632

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

34023402
bnxt_free_one_tx_ring_skbs(bp, txr, i);
34033403
}
3404+
3405+
if (bp->ptp_cfg && !(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP))
3406+
bnxt_ptp_free_txts_skbs(bp->ptp_cfg);
34043407
}
34053408

34063409
static void bnxt_free_one_rx_ring(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
@@ -12664,8 +12667,6 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
1266412667
/* VF-reps may need to be re-opened after the PF is re-opened */
1266512668
if (BNXT_PF(bp))
1266612669
bnxt_vf_reps_open(bp);
12667-
if (bp->ptp_cfg && !(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP))
12668-
WRITE_ONCE(bp->ptp_cfg->tx_avail, BNXT_MAX_TX_TS);
1266912670
bnxt_ptp_init_rtc(bp, true);
1267012671
bnxt_ptp_cfg_tstamp_filters(bp);
1267112672
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)