Accumulate out of RX buffers into a 64-bit value and subtract out of

RX buffers from number of received packets.

Differential Revision:	https://reviews.freebsd.org/D4178
Submitted by:	Drew Gallatin <gallatin@freebsd.org>
Sponsored by:	Mellanox Technologies
MFC after:	3 days
This commit is contained in:
Hans Petter Selasky 2015-11-19 10:23:10 +00:00
parent 36c1007d35
commit ee09079968
2 changed files with 23 additions and 13 deletions

View file

@ -141,6 +141,7 @@ typedef void (mlx5e_cq_comp_t)(struct mlx5_core_cq *);
m(+1, u64 rx_broadcast_bytes, "rx_broadcast_bytes", "Received broadcast bytes") \
m(+1, u64 tx_broadcast_packets, "tx_broadcast_packets", "Transmitted broadcast packets") \
m(+1, u64 tx_broadcast_bytes, "tx_broadcast_bytes", "Transmitted broadcast bytes") \
m(+1, u64 rx_out_of_buffer, "rx_out_of_buffer", "Receive out of buffer, no recv wqes events") \
/* SW counters */ \
m(+1, u64 tso_packets, "tso_packets", "Transmitted TSO packets") \
m(+1, u64 tso_bytes, "tso_bytes", "Transmitted TSO bytes") \
@ -161,6 +162,7 @@ struct mlx5e_vport_stats {
struct sysctl_ctx_list ctx;
u64 arg [0];
MLX5E_VPORT_STATS(MLX5E_STATS_VAR)
u32 rx_out_of_buffer_prev;
};
#define MLX5E_PPORT_IEEE802_3_STATS(m) \
@ -265,17 +267,13 @@ struct mlx5e_vport_stats {
m(+1, u64 rs_corrected_symbols_lane3, "rs_corrected_symbols_lane3", \
"FEC corrected symbol counter lane 3") \
#define MLX5E_PPORT_Q_CONTERS(m) \
m(+1, u64 out_of_rx_buffer, "out_of_rx_buffer", "out of rx buffers aka no recv wqes events")
/*
* Make sure to update mlx5e_update_pport_counters()
* when adding a new MLX5E_PPORT_STATS block
*/
#define MLX5E_PPORT_STATS(m) \
MLX5E_PPORT_IEEE802_3_STATS(m) \
MLX5E_PPORT_RFC2819_STATS(m) \
MLX5E_PPORT_Q_CONTERS(m)
MLX5E_PPORT_RFC2819_STATS(m)
#define MLX5E_PORT_STATS_DEBUG(m) \
MLX5E_PPORT_RFC2819_STATS_DEBUG(m) \

View file

@ -378,7 +378,7 @@ mlx5e_update_stats_work(struct work_struct *work)
u64 sw_lro_flushed = 0;
u64 rx_csum_none = 0;
u64 rx_wqe_err = 0;
u32 out_of_rx_buffer = 0;
u32 rx_out_of_buffer = 0;
int i;
int j;
@ -440,6 +440,16 @@ mlx5e_update_stats_work(struct work_struct *work)
memset(out, 0, outlen);
/* get number of out-of-buffer drops first */
if (mlx5_vport_query_out_of_rx_buffer(mdev, priv->counter_set_id,
&rx_out_of_buffer))
goto free_out;
/* accumulate difference into a 64-bit counter */
s->rx_out_of_buffer += (u64)(u32)(rx_out_of_buffer - s->rx_out_of_buffer_prev);
s->rx_out_of_buffer_prev = rx_out_of_buffer;
/* get port statistics */
if (mlx5_cmd_exec(mdev, in, sizeof(in), out, outlen))
goto free_out;
@ -485,7 +495,8 @@ mlx5e_update_stats_work(struct work_struct *work)
s->rx_packets =
s->rx_unicast_packets +
s->rx_multicast_packets +
s->rx_broadcast_packets;
s->rx_broadcast_packets -
s->rx_out_of_buffer;
s->rx_bytes =
s->rx_unicast_bytes +
s->rx_multicast_bytes +
@ -503,10 +514,14 @@ mlx5e_update_stats_work(struct work_struct *work)
s->tx_csum_offload = s->tx_packets - tx_offload_none;
s->rx_csum_good = s->rx_packets - s->rx_csum_none;
/* Update per port counters */
mlx5e_update_pport_counters(priv);
#if (__FreeBSD_version < 1100000)
/* no get_counters interface in fbsd 10 */
ifp->if_ipackets = s->rx_packets;
ifp->if_ierrors = s->rx_error_packets;
ifp->if_iqdrops = s->rx_out_of_buffer;
ifp->if_opackets = s->tx_packets;
ifp->if_oerrors = s->tx_error_packets;
ifp->if_snd.ifq_drops = s->tx_queue_dropped;
@ -514,12 +529,6 @@ mlx5e_update_stats_work(struct work_struct *work)
ifp->if_obytes = s->tx_bytes;
#endif
mlx5_vport_query_out_of_rx_buffer(mdev, priv->counter_set_id,
&out_of_rx_buffer);
/* Update per port counters */
mlx5e_update_pport_counters(priv);
priv->stats.pport.out_of_rx_buffer = (u64)out_of_rx_buffer;
free_out:
kvfree(out);
PRIV_UNLOCK(priv);
@ -2178,6 +2187,9 @@ mlx5e_get_counter(struct ifnet *ifp, ift_counter cnt)
case IFCOUNTER_IERRORS:
retval = priv->stats.vport.rx_error_packets;
break;
case IFCOUNTER_IQDROPS:
retval = priv->stats.vport.rx_out_of_buffer;
break;
case IFCOUNTER_OPACKETS:
retval = priv->stats.vport.tx_packets;
break;