if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {
struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
- if (ptp && ptp->tx_tstamp_en && !skb_is_gso(skb) &&
- atomic_dec_if_positive(&ptp->tx_avail) >= 0) {
+ if (ptp && ptp->tx_tstamp_en && !skb_is_gso(skb)) {
+ if (!atomic_dec_if_positive(&ptp->tx_avail)) {
+ atomic64_inc(&ptp->stats.ts_err);
+ goto tx_no_ts;
+ }
if (!bnxt_ptp_parse(skb, &ptp->tx_seqid,
&ptp->tx_hdr_off)) {
if (vlan_tag_flags)
}
}
+tx_no_ts:
if (unlikely(skb->no_fcs))
lflags |= cpu_to_le32(TX_BD_FLAGS_NO_CRC);
return NETDEV_TX_OK;
tx_dma_error:
- if (BNXT_TX_PTP_IS_SET(lflags))
+ if (BNXT_TX_PTP_IS_SET(lflags)) {
+ atomic64_inc(&bp->ptp_cfg->stats.ts_err);
atomic_inc(&bp->ptp_cfg->tx_avail);
+ }
last_frag = i;
if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
if (BNXT_CHIP_P5(bp)) {
/* PTP worker takes ownership of the skb */
- if (!bnxt_get_tx_ts_p5(bp, skb))
+ if (!bnxt_get_tx_ts_p5(bp, skb)) {
skb = NULL;
- else
+ } else {
+ atomic64_inc(&bp->ptp_cfg->stats.ts_err);
atomic_inc(&bp->ptp_cfg->tx_avail);
+ }
}
}
*ranges = bnxt_rmon_ranges;
}
+static void bnxt_get_ptp_stats(struct net_device *dev,
+ struct ethtool_ts_stats *ts_stats)
+{
+ struct bnxt *bp = netdev_priv(dev);
+ struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
+
+ if (ptp) {
+ ts_stats->pkts = ptp->stats.ts_pkts;
+ ts_stats->lost = ptp->stats.ts_lost;
+ ts_stats->err = atomic64_read(&ptp->stats.ts_err);
+ }
+}
+
static void bnxt_get_link_ext_stats(struct net_device *dev,
struct ethtool_link_ext_stats *stats)
{
.get_eth_mac_stats = bnxt_get_eth_mac_stats,
.get_eth_ctrl_stats = bnxt_get_eth_ctrl_stats,
.get_rmon_stats = bnxt_get_rmon_stats,
+ .get_ts_stats = bnxt_get_ptp_stats,
};
spin_unlock_bh(&ptp->ptp_lock);
timestamp.hwtstamp = ns_to_ktime(ns);
skb_tstamp_tx(ptp->tx_skb, ×tamp);
+ ptp->stats.ts_pkts++;
} else {
if (!time_after_eq(jiffies, ptp->abs_txts_tmo)) {
ptp->txts_pending = true;
return;
}
+ ptp->stats.ts_lost++;
netdev_warn_once(bp->dev,
"TS query for TX timer failed rc = %x\n", rc);
}
rc = err;
goto out;
}
+
+ ptp->stats.ts_pkts = 0;
+ ptp->stats.ts_lost = 0;
+ atomic64_set(&ptp->stats.ts_err, 0);
+
if (BNXT_CHIP_P5(bp)) {
spin_lock_bh(&ptp->ptp_lock);
bnxt_refclk_read(bp, NULL, &ptp->current_time);
dev_kfree_skb_any(ptp->tx_skb);
ptp->tx_skb = NULL;
}
+
bnxt_unmap_ptp_regs(bp);
}
struct pps_pin pins[BNXT_MAX_TSIO_PINS];
};
+struct bnxt_ptp_stats {
+ u64 ts_pkts;
+ u64 ts_lost;
+ atomic64_t ts_err;
+};
+
struct bnxt_ptp_cfg {
struct ptp_clock_info ptp_info;
struct ptp_clock *ptp_clock;
u32 refclk_mapped_regs[2];
u32 txts_tmo;
unsigned long abs_txts_tmo;
+
+ struct bnxt_ptp_stats stats;
};
#if BITS_PER_LONG == 32