Skip to content

Commit c13e268

Browse files
Michael Chankuba-moo
authored andcommitted
bnxt_en: Fix HWTSTAMP_FILTER_ALL packet timestamp logic
When the chip is configured to timestamp all receive packets, the timestamp in the RX completion is only valid if the metadata present flag is not set for packets received on the wire. In addition, internal loopback packets will never have a valid timestamp and the timestamp field will always be zero. We must exclude any 0 value in the timestamp field because there is no way to determine if it is a loopback packet or not. Add a new function bnxt_rx_ts_valid() to check for all timestamp valid conditions. Fixes: 66ed81d ("bnxt_en: Enable packet timestamping for all RX packets") Reviewed-by: Andy Gospodarek <[email protected]> Reviewed-by: Pavan Chebbi <[email protected]> Signed-off-by: Michael Chan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent bd6781c commit c13e268

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,6 +1759,21 @@ static void bnxt_deliver_skb(struct bnxt *bp, struct bnxt_napi *bnapi,
17591759
napi_gro_receive(&bnapi->napi, skb);
17601760
}
17611761

1762+
static bool bnxt_rx_ts_valid(struct bnxt *bp, u32 flags,
1763+
struct rx_cmp_ext *rxcmp1, u32 *cmpl_ts)
1764+
{
1765+
u32 ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp);
1766+
1767+
if (BNXT_PTP_RX_TS_VALID(flags))
1768+
goto ts_valid;
1769+
if (!bp->ptp_all_rx_tstamp || !ts || !BNXT_ALL_RX_TS_VALID(flags))
1770+
return false;
1771+
1772+
ts_valid:
1773+
*cmpl_ts = ts;
1774+
return true;
1775+
}
1776+
17621777
/* returns the following:
17631778
* 1 - 1 packet successfully received
17641779
* 0 - successful TPA_START, packet not completed yet
@@ -1784,6 +1799,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
17841799
struct sk_buff *skb;
17851800
struct xdp_buff xdp;
17861801
u32 flags, misc;
1802+
u32 cmpl_ts;
17871803
void *data;
17881804
int rc = 0;
17891805

@@ -2006,10 +2022,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
20062022
}
20072023
}
20082024

2009-
if (unlikely((flags & RX_CMP_FLAGS_ITYPES_MASK) ==
2010-
RX_CMP_FLAGS_ITYPE_PTP_W_TS) || bp->ptp_all_rx_tstamp) {
2025+
if (bnxt_rx_ts_valid(bp, flags, rxcmp1, &cmpl_ts)) {
20112026
if (bp->flags & BNXT_FLAG_CHIP_P5) {
2012-
u32 cmpl_ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp);
20132027
u64 ns, ts;
20142028

20152029
if (!bnxt_get_rx_ts_p5(bp, &ts, cmpl_ts)) {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ struct rx_cmp {
161161
#define RX_CMP_FLAGS_ERROR (1 << 6)
162162
#define RX_CMP_FLAGS_PLACEMENT (7 << 7)
163163
#define RX_CMP_FLAGS_RSS_VALID (1 << 10)
164-
#define RX_CMP_FLAGS_UNUSED (1 << 11)
164+
#define RX_CMP_FLAGS_PKT_METADATA_PRESENT (1 << 11)
165165
#define RX_CMP_FLAGS_ITYPES_SHIFT 12
166166
#define RX_CMP_FLAGS_ITYPES_MASK 0xf000
167167
#define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12)
@@ -188,6 +188,12 @@ struct rx_cmp {
188188
__le32 rx_cmp_rss_hash;
189189
};
190190

191+
#define BNXT_PTP_RX_TS_VALID(flags) \
192+
(((flags) & RX_CMP_FLAGS_ITYPES_MASK) == RX_CMP_FLAGS_ITYPE_PTP_W_TS)
193+
194+
#define BNXT_ALL_RX_TS_VALID(flags) \
195+
!((flags) & RX_CMP_FLAGS_PKT_METADATA_PRESENT)
196+
191197
#define RX_CMP_HASH_VALID(rxcmp) \
192198
((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID))
193199

0 commit comments

Comments
 (0)