Commit ac124ff9 authored by Sathya Perla's avatar Sathya Perla Committed by David S. Miller

be2net: cleanup and refactor stats code

In preparation for 64-bit stats interface, the following cleanups help
streamline the code:
1) made some more rx/tx stats stored by driver 64 bit
2) made some HW stas (err/drop counters) stored in be_drv_stats 32 bit to
   keep the code simple as BE provides 32-bit counters only.
3) removed duplication of netdev stats in ethtool
4) removed some un-necessary stats and fixed some names
Signed-off-by: default avatarSathya Perla <sathya.perla@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1b4c8af8
......@@ -167,15 +167,13 @@ struct be_mcc_obj {
};
struct be_tx_stats {
u32 be_tx_reqs; /* number of TX requests initiated */
u32 be_tx_stops; /* number of times TX Q was stopped */
u32 be_tx_wrbs; /* number of tx WRBs used */
u32 be_tx_compl; /* number of tx completion entries processed */
ulong be_tx_jiffies;
u64 be_tx_bytes;
u64 be_tx_bytes_prev;
u64 be_tx_pkts;
u32 be_tx_rate;
u64 tx_bytes;
u64 tx_pkts;
u64 tx_reqs;
u64 tx_wrbs;
u64 tx_compl;
ulong tx_jiffies;
u32 tx_stops;
};
struct be_tx_obj {
......@@ -195,22 +193,19 @@ struct be_rx_page_info {
};
struct be_rx_stats {
u32 rx_post_fail;/* number of ethrx buffer alloc failures */
u32 rx_polls; /* number of times NAPI called poll function */
u32 rx_events; /* number of ucast rx completion events */
u32 rx_compl; /* number of rx completion entries processed */
ulong rx_dropped; /* number of skb allocation errors */
ulong rx_jiffies;
u64 rx_bytes;
u64 rx_bytes_prev;
u64 rx_pkts;
u32 rx_rate;
u64 rx_pkts_prev;
ulong rx_jiffies;
u32 rx_drops_no_skbs; /* skb allocation errors */
u32 rx_drops_no_frags; /* HW has no fetched frags */
u32 rx_post_fail; /* page post alloc failures */
u32 rx_polls; /* NAPI calls */
u32 rx_events;
u32 rx_compl;
u32 rx_mcast_pkts;
u32 rxcp_err; /* Num rx completion entries w/ err set. */
ulong rx_fps_jiffies; /* jiffies at last FPS calc */
u32 rx_frags;
u32 prev_rx_frags;
u32 rx_fps; /* Rx frags per second */
u32 rx_compl_err; /* completions with err set */
u32 rx_pps; /* pkts per second */
};
struct be_rx_compl_info {
......@@ -247,43 +242,40 @@ struct be_rx_obj {
struct be_drv_stats {
u8 be_on_die_temperature;
u64 be_tx_events;
u64 eth_red_drops;
u64 rx_drops_no_pbuf;
u64 rx_drops_no_txpb;
u64 rx_drops_no_erx_descr;
u64 rx_drops_no_tpre_descr;
u64 rx_drops_too_many_frags;
u64 rx_drops_invalid_ring;
u64 forwarded_packets;
u64 rx_drops_mtu;
u64 rx_crc_errors;
u64 rx_alignment_symbol_errors;
u64 rx_pause_frames;
u64 rx_priority_pause_frames;
u64 rx_control_frames;
u64 rx_in_range_errors;
u64 rx_out_range_errors;
u64 rx_frame_too_long;
u64 rx_address_match_errors;
u64 rx_dropped_too_small;
u64 rx_dropped_too_short;
u64 rx_dropped_header_too_small;
u64 rx_dropped_tcp_length;
u64 rx_dropped_runt;
u64 rx_ip_checksum_errs;
u64 rx_tcp_checksum_errs;
u64 rx_udp_checksum_errs;
u64 rx_switched_unicast_packets;
u64 rx_switched_multicast_packets;
u64 rx_switched_broadcast_packets;
u64 tx_pauseframes;
u64 tx_priority_pauseframes;
u64 tx_controlframes;
u64 rxpp_fifo_overflow_drop;
u64 rx_input_fifo_overflow_drop;
u64 pmem_fifo_overflow_drop;
u64 jabber_events;
u32 tx_events;
u32 eth_red_drops;
u32 rx_drops_no_pbuf;
u32 rx_drops_no_txpb;
u32 rx_drops_no_erx_descr;
u32 rx_drops_no_tpre_descr;
u32 rx_drops_too_many_frags;
u32 rx_drops_invalid_ring;
u32 forwarded_packets;
u32 rx_drops_mtu;
u32 rx_crc_errors;
u32 rx_alignment_symbol_errors;
u32 rx_pause_frames;
u32 rx_priority_pause_frames;
u32 rx_control_frames;
u32 rx_in_range_errors;
u32 rx_out_range_errors;
u32 rx_frame_too_long;
u32 rx_address_match_errors;
u32 rx_dropped_too_small;
u32 rx_dropped_too_short;
u32 rx_dropped_header_too_small;
u32 rx_dropped_tcp_length;
u32 rx_dropped_runt;
u32 rx_ip_checksum_errs;
u32 rx_tcp_checksum_errs;
u32 rx_udp_checksum_errs;
u32 tx_pauseframes;
u32 tx_priority_pauseframes;
u32 tx_controlframes;
u32 rxpp_fifo_overflow_drop;
u32 rx_input_fifo_overflow_drop;
u32 pmem_fifo_overflow_drop;
u32 jabber_events;
};
struct be_vf_cfg {
......
......@@ -82,26 +82,6 @@ static int be_mcc_compl_process(struct be_adapter *adapter,
if (((compl->tag0 == OPCODE_ETH_GET_STATISTICS) ||
(compl->tag0 == OPCODE_ETH_GET_PPORT_STATS)) &&
(compl->tag1 == CMD_SUBSYSTEM_ETH)) {
if (adapter->generation == BE_GEN3) {
if (lancer_chip(adapter)) {
struct lancer_cmd_resp_pport_stats
*resp = adapter->stats_cmd.va;
be_dws_le_to_cpu(&resp->pport_stats,
sizeof(resp->pport_stats));
} else {
struct be_cmd_resp_get_stats_v1 *resp =
adapter->stats_cmd.va;
be_dws_le_to_cpu(&resp->hw_stats,
sizeof(resp->hw_stats));
}
} else {
struct be_cmd_resp_get_stats_v0 *resp =
adapter->stats_cmd.va;
be_dws_le_to_cpu(&resp->hw_stats,
sizeof(resp->hw_stats));
}
be_parse_stats(adapter);
netdev_stats_update(adapter);
adapter->stats_cmd_sent = false;
......
......@@ -693,8 +693,7 @@ struct be_cmd_resp_get_stats_v0 {
struct be_hw_stats_v0 hw_stats;
};
#define make_64bit_val(hi_32, lo_32) (((u64)hi_32<<32) | lo_32)
struct lancer_cmd_pport_stats {
struct lancer_pport_stats {
u32 tx_packets_lo;
u32 tx_packets_hi;
u32 tx_unicast_packets_lo;
......@@ -871,16 +870,16 @@ struct lancer_cmd_req_pport_stats {
struct be_cmd_req_hdr hdr;
union {
struct pport_stats_params params;
u8 rsvd[sizeof(struct lancer_cmd_pport_stats)];
u8 rsvd[sizeof(struct lancer_pport_stats)];
} cmd_params;
};
struct lancer_cmd_resp_pport_stats {
struct be_cmd_resp_hdr hdr;
struct lancer_cmd_pport_stats pport_stats;
struct lancer_pport_stats pport_stats;
};
static inline struct lancer_cmd_pport_stats*
static inline struct lancer_pport_stats*
pport_stats_from_cmd(struct be_adapter *adapter)
{
struct lancer_cmd_resp_pport_stats *cmd = adapter->stats_cmd.va;
......@@ -1383,8 +1382,7 @@ struct be_cmd_resp_get_stats_v1 {
struct be_hw_stats_v1 hw_stats;
};
static inline void *
hw_stats_from_cmd(struct be_adapter *adapter)
static inline void *hw_stats_from_cmd(struct be_adapter *adapter)
{
if (adapter->generation == BE_GEN3) {
struct be_cmd_resp_get_stats_v1 *cmd = adapter->stats_cmd.va;
......@@ -1397,34 +1395,6 @@ hw_stats_from_cmd(struct be_adapter *adapter)
}
}
static inline void *be_port_rxf_stats_from_cmd(struct be_adapter *adapter)
{
if (adapter->generation == BE_GEN3) {
struct be_hw_stats_v1 *hw_stats = hw_stats_from_cmd(adapter);
struct be_rxf_stats_v1 *rxf_stats = &hw_stats->rxf;
return &rxf_stats->port[adapter->port_num];
} else {
struct be_hw_stats_v0 *hw_stats = hw_stats_from_cmd(adapter);
struct be_rxf_stats_v0 *rxf_stats = &hw_stats->rxf;
return &rxf_stats->port[adapter->port_num];
}
}
static inline void *be_rxf_stats_from_cmd(struct be_adapter *adapter)
{
if (adapter->generation == BE_GEN3) {
struct be_hw_stats_v1 *hw_stats = hw_stats_from_cmd(adapter);
return &hw_stats->rxf;
} else {
struct be_hw_stats_v0 *hw_stats = hw_stats_from_cmd(adapter);
return &hw_stats->rxf;
}
}
static inline void *be_erx_stats_from_cmd(struct be_adapter *adapter)
{
if (adapter->generation == BE_GEN3) {
......@@ -1438,19 +1408,6 @@ static inline void *be_erx_stats_from_cmd(struct be_adapter *adapter)
}
}
static inline void *be_pmem_stats_from_cmd(struct be_adapter *adapter)
{
if (adapter->generation == BE_GEN3) {
struct be_hw_stats_v1 *hw_stats = hw_stats_from_cmd(adapter);
return &hw_stats->pmem;
} else {
struct be_hw_stats_v0 *hw_stats = hw_stats_from_cmd(adapter);
return &hw_stats->pmem;
}
}
extern int be_pci_fnum_get(struct be_adapter *adapter);
extern int be_cmd_POST(struct be_adapter *adapter);
extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
......
......@@ -26,33 +26,18 @@ struct be_ethtool_stat {
int offset;
};
enum {NETSTAT, DRVSTAT_TX, DRVSTAT_RX, ERXSTAT,
DRVSTAT};
enum {DRVSTAT_TX, DRVSTAT_RX, DRVSTAT};
#define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \
offsetof(_struct, field)
#define NETSTAT_INFO(field) #field, NETSTAT,\
FIELDINFO(struct net_device_stats,\
field)
#define DRVSTAT_TX_INFO(field) #field, DRVSTAT_TX,\
FIELDINFO(struct be_tx_stats, field)
#define DRVSTAT_RX_INFO(field) #field, DRVSTAT_RX,\
FIELDINFO(struct be_rx_stats, field)
#define ERXSTAT_INFO(field) #field, ERXSTAT,\
FIELDINFO(struct be_erx_stats_v1, field)
#define DRVSTAT_INFO(field) #field, DRVSTAT,\
FIELDINFO(struct be_drv_stats, \
field)
FIELDINFO(struct be_drv_stats, field)
static const struct be_ethtool_stat et_stats[] = {
{NETSTAT_INFO(rx_packets)},
{NETSTAT_INFO(tx_packets)},
{NETSTAT_INFO(rx_bytes)},
{NETSTAT_INFO(tx_bytes)},
{NETSTAT_INFO(rx_errors)},
{NETSTAT_INFO(tx_errors)},
{NETSTAT_INFO(rx_dropped)},
{NETSTAT_INFO(tx_dropped)},
{DRVSTAT_INFO(be_tx_events)},
{DRVSTAT_INFO(tx_events)},
{DRVSTAT_INFO(rx_crc_errors)},
{DRVSTAT_INFO(rx_alignment_symbol_errors)},
{DRVSTAT_INFO(rx_pause_frames)},
......@@ -71,9 +56,6 @@ static const struct be_ethtool_stat et_stats[] = {
{DRVSTAT_INFO(rx_ip_checksum_errs)},
{DRVSTAT_INFO(rx_tcp_checksum_errs)},
{DRVSTAT_INFO(rx_udp_checksum_errs)},
{DRVSTAT_INFO(rx_switched_unicast_packets)},
{DRVSTAT_INFO(rx_switched_multicast_packets)},
{DRVSTAT_INFO(rx_switched_broadcast_packets)},
{DRVSTAT_INFO(tx_pauseframes)},
{DRVSTAT_INFO(tx_controlframes)},
{DRVSTAT_INFO(rx_priority_pause_frames)},
......@@ -96,24 +78,24 @@ static const struct be_ethtool_stat et_stats[] = {
static const struct be_ethtool_stat et_rx_stats[] = {
{DRVSTAT_RX_INFO(rx_bytes)},
{DRVSTAT_RX_INFO(rx_pkts)},
{DRVSTAT_RX_INFO(rx_rate)},
{DRVSTAT_RX_INFO(rx_polls)},
{DRVSTAT_RX_INFO(rx_events)},
{DRVSTAT_RX_INFO(rx_compl)},
{DRVSTAT_RX_INFO(rx_mcast_pkts)},
{DRVSTAT_RX_INFO(rx_post_fail)},
{DRVSTAT_RX_INFO(rx_dropped)},
{ERXSTAT_INFO(rx_drops_no_fragments)}
{DRVSTAT_RX_INFO(rx_drops_no_skbs)},
{DRVSTAT_RX_INFO(rx_drops_no_frags)}
};
#define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats))
/* Stats related to multi TX queues */
static const struct be_ethtool_stat et_tx_stats[] = {
{DRVSTAT_TX_INFO(be_tx_rate)},
{DRVSTAT_TX_INFO(be_tx_reqs)},
{DRVSTAT_TX_INFO(be_tx_wrbs)},
{DRVSTAT_TX_INFO(be_tx_stops)},
{DRVSTAT_TX_INFO(be_tx_compl)}
{DRVSTAT_TX_INFO(tx_bytes)},
{DRVSTAT_TX_INFO(tx_pkts)},
{DRVSTAT_TX_INFO(tx_reqs)},
{DRVSTAT_TX_INFO(tx_wrbs)},
{DRVSTAT_TX_INFO(tx_compl)},
{DRVSTAT_TX_INFO(tx_stops)}
};
#define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats))
......@@ -260,20 +242,11 @@ be_get_ethtool_stats(struct net_device *netdev,
struct be_adapter *adapter = netdev_priv(netdev);
struct be_rx_obj *rxo;
struct be_tx_obj *txo;
void *p = NULL;
void *p;
int i, j, base;
for (i = 0; i < ETHTOOL_STATS_NUM; i++) {
switch (et_stats[i].type) {
case NETSTAT:
p = &netdev->stats;
break;
case DRVSTAT:
p = &adapter->drv_stats;
break;
}
p = (u8 *)p + et_stats[i].offset;
p = (u8 *)&adapter->drv_stats + et_stats[i].offset;
data[i] = (et_stats[i].size == sizeof(u64)) ?
*(u64 *)p: *(u32 *)p;
}
......@@ -281,15 +254,7 @@ be_get_ethtool_stats(struct net_device *netdev,
base = ETHTOOL_STATS_NUM;
for_all_rx_queues(adapter, rxo, j) {
for (i = 0; i < ETHTOOL_RXSTATS_NUM; i++) {
switch (et_rx_stats[i].type) {
case DRVSTAT_RX:
p = (u8 *)&rxo->stats + et_rx_stats[i].offset;
break;
case ERXSTAT:
p = (u32 *)be_erx_stats_from_cmd(adapter) +
rxo->q.id;
break;
}
p = (u8 *)rx_stats(rxo) + et_rx_stats[i].offset;
data[base + j * ETHTOOL_RXSTATS_NUM + i] =
(et_rx_stats[i].size == sizeof(u64)) ?
*(u64 *)p: *(u32 *)p;
......@@ -299,7 +264,7 @@ be_get_ethtool_stats(struct net_device *netdev,
base = ETHTOOL_STATS_NUM + adapter->num_rx_qs * ETHTOOL_RXSTATS_NUM;
for_all_tx_queues(adapter, txo, j) {
for (i = 0; i < ETHTOOL_TXSTATS_NUM; i++) {
p = (u8 *)&txo->stats + et_tx_stats[i].offset;
p = (u8 *)tx_stats(txo) + et_tx_stats[i].offset;
data[base + j * ETHTOOL_TXSTATS_NUM + i] =
(et_tx_stats[i].size == sizeof(u64)) ?
*(u64 *)p: *(u32 *)p;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment