WARN_ON(!list_empty(&cnt->users)); /* We'd like to synchronize_rcu() here, but unfortunately we aren't *removingtheelementfromthehashtable(it'snotclearthat'sa *safethingtodoinanrhashtable_free_and_destroyfree_fn),so *threadscouldstillbeobtainingnewpointersto*cntiftheycan *raceagainstthisfunctionatall.
*/
flush_work(&cnt->work);
EFX_WARN_ON_PARANOID(spin_is_locked(&cnt->lock));
kfree(cnt);
}
list_for_each_entry(act, &cnt->users, count_user) {
encap = act->encap_md; if (!encap) continue; if (!encap->neigh) /* can't happen */ continue; if (time_after_eq(encap->neigh->used, touched)) continue;
encap->neigh->used = touched; /* We have passed traffic using this ARP entry, so *indicatetotheARPcachethatit'sstillactive
*/ if (encap->neigh->dst_ip)
n = neigh_lookup(&arp_tbl, &encap->neigh->dst_ip,
encap->neigh->egdev); else #if IS_ENABLED(CONFIG_IPV6)
n = neigh_lookup(ipv6_stub->nd_tbl,
&encap->neigh->dst_ip6,
encap->neigh->egdev); #else
n = NULL; #endif if (!n) continue;
rcu_read_lock(); /* Protect against deletion of 'cnt' */
cnt = efx_tc_flower_find_counter_by_fw_id(efx, counter_type, counter_idx); if (!cnt) { /* This can legitimately happen when a counter is removed, *withupdatesforthecounterstillin-flight;howeverthis *shouldbeaninfrequentoccurrence.
*/ if (net_ratelimit())
netif_dbg(efx, drv, efx->net_dev, "Got update for unwanted MAE counter %u type %u\n",
counter_idx, counter_type); goto out;
}
spin_lock_bh(&cnt->lock); if ((s32)mark - (s32)cnt->gen < 0) { /* This counter update packet is from before the counter was *allocated;thusitmustbeforapreviouscounterwith *thesameIDthathassincebeenfreed,anditshouldbe *ignored.
*/
} else { /* Update latest seen generation count. This ensures that *evenalong-livedcounterwon'tstartgettingignoredif *thegenerationcountwrapsaround,unlessitsomehow *managestogo1<<31generationswithoutanupdate.
*/
cnt->gen = mark; /* update counter values */
cnt->packets += packets;
cnt->bytes += bytes;
cnt->touched = jiffies;
}
spin_unlock_bh(&cnt->lock);
schedule_work(&cnt->work);
out:
rcu_read_unlock();
}
ident = TCV2_HDR_BYTE(data, IDENTIFIER); switch (ident) { case ERF_SC_PACKETISER_HEADER_IDENTIFIER_AR:
type = EFX_TC_COUNTER_TYPE_AR; break; case ERF_SC_PACKETISER_HEADER_IDENTIFIER_CT:
type = EFX_TC_COUNTER_TYPE_CT; break; case ERF_SC_PACKETISER_HEADER_IDENTIFIER_OR:
type = EFX_TC_COUNTER_TYPE_OR; break; default: if (net_ratelimit())
netif_err(efx, drv, efx->net_dev, "ignored v2 MAE counter packet (bad identifier %u" "), counters may be inaccurate\n", ident); return EFX_TC_COUNTER_TYPE_MAX;
}
header_offset = TCV2_HDR_BYTE(data, HEADER_OFFSET); /* mae_counter_format.h implies that this offset is fixed, since it *carriesonwithSOP-basedLBNsforthefieldsinthisheader
*/ if (header_offset != ERF_SC_PACKETISER_HEADER_HEADER_OFFSET_DEFAULT) { if (net_ratelimit())
netif_err(efx, drv, efx->net_dev, "choked on v2 MAE counter packet (bad header_offset %u" "), counters may be inaccurate\n", header_offset); return EFX_TC_COUNTER_TYPE_MAX;
}
payload_offset = TCV2_HDR_BYTE(data, PAYLOAD_OFFSET);
n_counters = le16_to_cpu(TCV2_HDR_WORD(data, COUNT));
for (i = 0; i < n_counters; i++) { constvoid *counter_idx_p, *packet_count_p, *byte_count_p;
u64 packet_count, byte_count;
u32 counter_idx;
/* 24-bit field with 32-bit alignment */
counter_idx_p = TCV2_PKT_PTR(data, payload_offset, i, COUNTER_INDEX);
BUILD_BUG_ON(ERF_SC_PACKETISER_PAYLOAD_COUNTER_INDEX_WIDTH != 24);
BUILD_BUG_ON(ERF_SC_PACKETISER_PAYLOAD_COUNTER_INDEX_LBN & 31);
counter_idx = le32_to_cpu(*(const __le32 *)counter_idx_p) & 0xffffff; /* 48-bit field with 16-bit alignment */
packet_count_p = TCV2_PKT_PTR(data, payload_offset, i, PACKET_COUNT);
BUILD_BUG_ON(ERF_SC_PACKETISER_PAYLOAD_PACKET_COUNT_WIDTH != 48);
BUILD_BUG_ON(ERF_SC_PACKETISER_PAYLOAD_PACKET_COUNT_LBN & 15);
packet_count = efx_tc_read48((const __le16 *)packet_count_p); /* 48-bit field with 16-bit alignment */
byte_count_p = TCV2_PKT_PTR(data, payload_offset, i, BYTE_COUNT);
BUILD_BUG_ON(ERF_SC_PACKETISER_PAYLOAD_BYTE_COUNT_WIDTH != 48);
BUILD_BUG_ON(ERF_SC_PACKETISER_PAYLOAD_BYTE_COUNT_LBN & 15);
byte_count = efx_tc_read48((const __le16 *)byte_count_p);
if (type == EFX_TC_COUNTER_TYPE_CT) { /* CT counters are 1-bit saturating counters to update *thelastusetimeinCTstats.AreceivedCTcounter *shouldhavepacketcounterto0andonlyLSBbiton *inbytecounter.
*/ if (packet_count || byte_count != 1)
netdev_warn_once(efx->net_dev, "CT counter with inconsistent state (%llu, %llu)\n",
packet_count, byte_count); /* Do not increment the driver's byte counter */
byte_count = 0;
}
/* We always swallow the packet, whether successful or not, since it's not *anetworkpacketandshouldn'teverbeforwardedtothestack. *@markisthegenerationcountforcounterallocations.
*/ staticbool efx_tc_rx(struct efx_rx_queue *rx_queue, u32 mark)
{ struct efx_channel *channel = efx_rx_queue_channel(rx_queue); struct efx_rx_buffer *rx_buf = efx_rx_buffer(rx_queue,
channel->rx_pkt_index); const u8 *data = efx_rx_buf_va(rx_buf); struct efx_nic *efx = rx_queue->efx; enum efx_tc_counter_type type;
u8 version;
/* version is always first byte of packet */
version = *data; switch (version) { case1:
type = EFX_TC_COUNTER_TYPE_AR;
efx_tc_rx_version_1(efx, data, mark); break; case ERF_SC_PACKETISER_HEADER_VERSION_VALUE: // 2
type = efx_tc_rx_version_2(efx, data, mark); break; default: if (net_ratelimit())
netif_err(efx, drv, efx->net_dev, "choked on MAE counter packet (bad version %u" "); counters may be inaccurate\n",
version); goto out;
}
if (type < EFX_TC_COUNTER_TYPE_MAX) { /* Update seen_gen unconditionally, to avoid a missed wakeup if *weracewithefx_mae_stop_counters().
*/
efx->tc->seen_gen[type] = mark; if (efx->tc->flush_counters &&
(s32)(efx->tc->flush_gen[type] - mark) <= 0)
wake_up(&efx->tc->flush_wq);
}
out:
efx_free_rx_buffers(rx_queue, rx_buf, 1);
channel->rx_pkt_n_frags = 0; returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.