Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci/ixgbe Use atomic_{load,store}_relaxed() for even...
details: https://anonhg.NetBSD.org/src/rev/d5ab58cdfb53
branches: trunk
changeset: 359817:d5ab58cdfb53
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Tue Jan 25 01:56:22 2022 +0000
description:
Use atomic_{load,store}_relaxed() for event counters.
diffstat:
sys/dev/pci/ixgbe/ix_txrx.c | 46 ++--
sys/dev/pci/ixgbe/ixgbe.c | 416 ++++++++++++++++++--------------------
sys/dev/pci/ixgbe/ixgbe_mbx.c | 59 ++--
sys/dev/pci/ixgbe/ixgbe_netbsd.h | 31 ++-
sys/dev/pci/ixgbe/ixv.c | 128 ++++++------
5 files changed, 345 insertions(+), 335 deletions(-)
diffs (truncated from 1271 to 300 lines):
diff -r 2aff4130912f -r d5ab58cdfb53 sys/dev/pci/ixgbe/ix_txrx.c
--- a/sys/dev/pci/ixgbe/ix_txrx.c Mon Jan 24 22:59:49 2022 +0000
+++ b/sys/dev/pci/ixgbe/ix_txrx.c Tue Jan 25 01:56:22 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.94 2021/09/08 09:09:47 msaitoh Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.95 2022/01/25 01:56:22 msaitoh Exp $ */
/******************************************************************************
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.94 2021/09/08 09:09:47 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.95 2022/01/25 01:56:22 msaitoh Exp $");
#include "opt_inet.h"
#include "opt_inet6.h"
@@ -247,7 +247,7 @@
if (__predict_false(!pcq_put(txr->txr_interq, m))) {
m_freem(m);
- txr->pcq_drops.ev_count++;
+ IXGBE_EVC_ADD(&txr->pcq_drops, 1);
return ENOBUFS;
}
if (IXGBE_TX_TRYLOCK(txr)) {
@@ -475,7 +475,7 @@
/* Make certain there are enough descriptors */
if (txr->tx_avail < (map->dm_nsegs + 2)) {
txr->txr_no_space = true;
- txr->no_desc_avail.ev_count++;
+ IXGBE_EVC_ADD(&txr->no_desc_avail, 1);
ixgbe_dmamap_unload(txr->txtag, txbuf->map);
return EAGAIN;
}
@@ -546,7 +546,7 @@
* Advance the Transmit Descriptor Tail (Tdt), this tells the
* hardware that this frame is available to transmit.
*/
- ++txr->total_packets.ev_count;
+ IXGBE_EVC_ADD(&txr->total_packets, 1);
IXGBE_WRITE_REG(&adapter->hw, txr->tail, i);
net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
@@ -582,7 +582,7 @@
while ((m = pcq_get(txr->txr_interq)) != NULL) {
m_freem(m);
- txr->pcq_drops.ev_count++;
+ IXGBE_EVC_ADD(&txr->pcq_drops, 1);
}
}
@@ -839,7 +839,7 @@
int rv = ixgbe_tso_setup(txr, mp, cmd_type_len, olinfo_status);
if (rv != 0)
- ++adapter->tso_err.ev_count;
+ IXGBE_EVC_ADD(&adapter->tso_err, 1);
return rv;
}
@@ -1081,7 +1081,7 @@
*cmd_type_len |= IXGBE_ADVTXD_DCMD_TSE;
*olinfo_status |= IXGBE_TXD_POPTS_TXSM << 8;
*olinfo_status |= paylen << IXGBE_ADVTXD_PAYLEN_SHIFT;
- ++txr->tso_tx.ev_count;
+ IXGBE_EVC_ADD(&txr->tso_tx, 1);
return (0);
} /* ixgbe_tso_setup */
@@ -1353,7 +1353,7 @@
if (__predict_false(rxbuf->buf == NULL)) {
mp = ixgbe_getcl();
if (mp == NULL) {
- rxr->no_mbuf.ev_count++;
+ IXGBE_EVC_ADD(&rxr->no_mbuf, 1);
goto update;
}
mp->m_pkthdr.len = mp->m_len = rxr->mbuf_sz;
@@ -1536,7 +1536,7 @@
rxbuf->flags = 0;
rxbuf->buf = ixgbe_getcl();
if (rxbuf->buf == NULL) {
- rxr->no_mbuf.ev_count++;
+ IXGBE_EVC_ADD(&rxr->no_mbuf, 1);
error = ENOBUFS;
goto fail;
}
@@ -1569,11 +1569,11 @@
rxr->next_to_refresh = adapter->num_rx_desc - 1; /* Fully allocated */
rxr->lro_enabled = FALSE;
rxr->discard_multidesc = false;
- rxr->rx_copies.ev_count = 0;
+ IXGBE_EVC_STORE(&rxr->rx_copies, 0);
#if 0 /* NetBSD */
- rxr->rx_bytes.ev_count = 0;
+ IXGBE_EVC_STORE(&rxr->rx_bytes, 0);
#if 1 /* Fix inconsistency */
- rxr->rx_packets.ev_count = 0;
+ IXGBE_EVC_STORE(&rxr->rx_packets, 0);
#endif
#endif
rxr->vtag_strip = FALSE;
@@ -1904,7 +1904,7 @@
if (adapter->feat_en & IXGBE_FEATURE_VF)
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
#endif
- rxr->rx_discarded.ev_count++;
+ IXGBE_EVC_ADD(&rxr->rx_discarded, 1);
ixgbe_rx_discard(rxr, i);
discard_multidesc = false;
goto next_desc;
@@ -1920,14 +1920,14 @@
/* For short packet. See below. */
sendmp = m_gethdr(M_NOWAIT, MT_DATA);
if (__predict_false(sendmp == NULL)) {
- rxr->no_mbuf.ev_count++;
+ IXGBE_EVC_ADD(&rxr->no_mbuf, 1);
discard = true;
}
} else {
/* For long packet. */
newmp = ixgbe_getcl();
if (__predict_false(newmp == NULL)) {
- rxr->no_mbuf.ev_count++;
+ IXGBE_EVC_ADD(&rxr->no_mbuf, 1);
discard = true;
}
}
@@ -2031,7 +2031,7 @@
sendmp->m_data += ETHER_ALIGN;
memcpy(mtod(sendmp, void *),
mtod(mp, void *), len);
- rxr->rx_copies.ev_count++;
+ IXGBE_EVC_ADD(&rxr->rx_copies, 1);
rbuf->flags |= IXGBE_RX_COPY;
} else {
/* Non short packet */
@@ -2060,10 +2060,10 @@
} else { /* Sending this frame */
m_set_rcvif(sendmp, ifp);
++rxr->packets;
- rxr->rx_packets.ev_count++;
+ IXGBE_EVC_ADD(&rxr->rx_packets, 1);
/* capture data for AIM */
rxr->bytes += sendmp->m_pkthdr.len;
- rxr->rx_bytes.ev_count += sendmp->m_pkthdr.len;
+ IXGBE_EVC_ADD(&rxr->rx_bytes, sendmp->m_pkthdr.len);
/* Process vlan info */
if ((rxr->vtag_strip) && (staterr & IXGBE_RXD_STAT_VP))
vtag = le16toh(cur->wb.upper.vlan);
@@ -2204,23 +2204,23 @@
/* IPv4 checksum */
if (status & IXGBE_RXD_STAT_IPCS) {
- stats->ipcs.ev_count++;
+ IXGBE_EVC_ADD(&stats->ipcs, 1);
if (!(errors & IXGBE_RXD_ERR_IPE)) {
/* IP Checksum Good */
mp->m_pkthdr.csum_flags = M_CSUM_IPv4;
} else {
- stats->ipcs_bad.ev_count++;
+ IXGBE_EVC_ADD(&stats->ipcs_bad, 1);
mp->m_pkthdr.csum_flags = M_CSUM_IPv4|M_CSUM_IPv4_BAD;
}
}
/* TCP/UDP/SCTP checksum */
if (status & IXGBE_RXD_STAT_L4CS) {
- stats->l4cs.ev_count++;
+ IXGBE_EVC_ADD(&stats->l4cs, 1);
int type = M_CSUM_TCPv4|M_CSUM_TCPv6|M_CSUM_UDPv4|M_CSUM_UDPv6;
if (!(errors & IXGBE_RXD_ERR_TCPE)) {
mp->m_pkthdr.csum_flags |= type;
} else {
- stats->l4cs_bad.ev_count++;
+ IXGBE_EVC_ADD(&stats->l4cs_bad, 1);
mp->m_pkthdr.csum_flags |= type | M_CSUM_TCP_UDP_BAD;
}
}
diff -r 2aff4130912f -r d5ab58cdfb53 sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Mon Jan 24 22:59:49 2022 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Tue Jan 25 01:56:22 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.304 2022/01/18 04:35:49 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.305 2022/01/25 01:56:22 msaitoh Exp $ */
/******************************************************************************
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.304 2022/01/18 04:35:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.305 2022/01/25 01:56:22 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1627,35 +1627,27 @@
struct ifnet *ifp = adapter->ifp;
struct ixgbe_hw *hw = &adapter->hw;
struct ixgbe_hw_stats *stats = &adapter->stats.pf;
- u32 missed_rx = 0, bprc, lxon, lxoff;
+ u32 missed_rx = 0, bprc, lxontxc, lxofftxc;
u64 total, total_missed_rx = 0;
uint64_t crcerrs, illerrc, rlec, ruc, rfc, roc, rjc;
unsigned int queue_counters;
int i;
-#define READ_COPY_SET(hw, stats, regname, evname) \
- do { \
- (evname) = IXGBE_READ_REG((hw), regname); \
- (stats)->evname.ev_count += (evname); \
- } while (/*CONSTCOND*/0)
-
- READ_COPY_SET(hw, stats, IXGBE_CRCERRS, crcerrs);
- READ_COPY_SET(hw, stats, IXGBE_ILLERRC, illerrc);
-
- stats->errbc.ev_count += IXGBE_READ_REG(hw, IXGBE_ERRBC);
- stats->mspdc.ev_count += IXGBE_READ_REG(hw, IXGBE_MSPDC);
+ IXGBE_EVC_REGADD2(hw, stats, IXGBE_CRCERRS, crcerrs);
+ IXGBE_EVC_REGADD2(hw, stats, IXGBE_ILLERRC, illerrc);
+
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_ERRBC, errbc);
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_MSPDC, mspdc);
if (hw->mac.type >= ixgbe_mac_X550)
- stats->mbsdc.ev_count += IXGBE_READ_REG(hw, IXGBE_MBSDC);
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_MBSDC, mbsdc);
/* 16 registers exist */
queue_counters = uimin(__arraycount(stats->qprc), adapter->num_queues);
for (i = 0; i < queue_counters; i++) {
- stats->qprc[i].ev_count += IXGBE_READ_REG(hw, IXGBE_QPRC(i));
- stats->qptc[i].ev_count += IXGBE_READ_REG(hw, IXGBE_QPTC(i));
- if (hw->mac.type >= ixgbe_mac_82599EB) {
- stats->qprdc[i].ev_count
- += IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
- }
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_QPRC(i), qprc[i]);
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_QPTC(i), qptc[i]);
+ if (hw->mac.type >= ixgbe_mac_82599EB)
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_QPRDC(i), qprdc[i]);
}
/* 8 registers exist */
@@ -1665,120 +1657,108 @@
/* MPC */
mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
/* global total per queue */
- stats->mpc[i].ev_count += mp;
+ IXGBE_EVC_ADD(&stats->mpc[i], mp);
/* running comprehensive total for stats display */
total_missed_rx += mp;
if (hw->mac.type == ixgbe_mac_82598EB)
- stats->rnbc[i].ev_count
- += IXGBE_READ_REG(hw, IXGBE_RNBC(i));
-
- stats->pxontxc[i].ev_count
- += IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
- stats->pxofftxc[i].ev_count
- += IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_RNBC(i), rnbc[i]);
+
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_PXONTXC(i), pxontxc[i]);
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_PXOFFTXC(i), pxofftxc[i]);
if (hw->mac.type >= ixgbe_mac_82599EB) {
- stats->pxonrxc[i].ev_count
- += IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
- stats->pxoffrxc[i].ev_count
- += IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i));
- stats->pxon2offc[i].ev_count
- += IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_PXONRXCNT(i), pxonrxc[i]);
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_PXOFFRXCNT(i), pxoffrxc[i]);
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_PXON2OFFCNT(i),
+ pxon2offc[i]);
} else {
- stats->pxonrxc[i].ev_count
- += IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
- stats->pxoffrxc[i].ev_count
- += IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_PXONRXC(i), pxonrxc[i]);
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_PXOFFRXC(i), pxoffrxc[i]);
}
}
- stats->mpctotal.ev_count += total_missed_rx;
+ IXGBE_EVC_ADD(&stats->mpctotal, total_missed_rx);
/* Document says M[LR]FC are valid when link is up and 10Gbps */
if ((adapter->link_active == LINK_STATE_UP)
&& (adapter->link_speed == IXGBE_LINK_SPEED_10GB_FULL)) {
- stats->mlfc.ev_count += IXGBE_READ_REG(hw, IXGBE_MLFC);
- stats->mrfc.ev_count += IXGBE_READ_REG(hw, IXGBE_MRFC);
- }
- READ_COPY_SET(hw, stats, IXGBE_RLEC, rlec);
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_MLFC, mlfc);
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_MRFC, mrfc);
+ }
Home |
Main Index |
Thread Index |
Old Index