Added support for displaying HW port stats using sysctl.

This provides port stats (updated once per second) in
dev.bnxt.X.port_stats for PFs.  VFs do not have access to the port stats.

Submitted by:	Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>
Reviewed by:	shurd, sbruno
Approved by:	sbruno (mentor)
Sponsored by:	Broadcom Limited
Differential Revision:	https://reviews.freebsd.org/D11914
This commit is contained in:
Stephen Hurd 2017-09-08 18:03:34 +00:00
parent 3e0ca40a54
commit 47516844a3
6 changed files with 540 additions and 1 deletions

View file

@ -558,6 +558,7 @@ struct bnxt_softc {
uint8_t max_tc;
struct bnxt_cos_queue q_info[BNXT_MAX_QUEUE];
uint64_t admin_ticks;
struct iflib_dma_info hw_rx_port_stats;
struct iflib_dma_info hw_tx_port_stats;
struct rx_port_stats *rx_port_stats;

View file

@ -819,6 +819,25 @@ fail:
return rc;
}
int
bnxt_hwrm_port_qstats(struct bnxt_softc *softc)
{
struct hwrm_port_qstats_input req = {0};
int rc = 0;
bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_QSTATS);
req.port_id = htole16(softc->pf.port_id);
req.rx_stat_host_addr = htole64(softc->hw_rx_port_stats.idi_paddr);
req.tx_stat_host_addr = htole64(softc->hw_tx_port_stats.idi_paddr);
BNXT_HWRM_LOCK(softc);
rc = _hwrm_send_message(softc, &req, sizeof(req));
BNXT_HWRM_UNLOCK(softc);
return rc;
}
int
bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt_softc *softc,
struct bnxt_vnic_info *vnic)

View file

@ -52,6 +52,7 @@ int bnxt_hwrm_vnic_ctx_alloc(struct bnxt_softc *softc, uint16_t *ctx_id);
int bnxt_hwrm_vnic_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic);
int bnxt_hwrm_stat_ctx_alloc(struct bnxt_softc *softc, struct bnxt_cp_ring *cpr,
uint64_t paddr);
int bnxt_hwrm_port_qstats(struct bnxt_softc *softc);
int bnxt_hwrm_ring_grp_alloc(struct bnxt_softc *softc,
struct bnxt_grp_info *grp);
int bnxt_hwrm_vnic_alloc(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic);

View file

@ -163,6 +163,456 @@ bnxt_create_tx_sysctls(struct bnxt_softc *softc, int txr)
return 0;
}
int
bnxt_create_port_stats_sysctls(struct bnxt_softc *softc)
{
struct sysctl_oid *oid;
char name[32];
char desc[64];
sprintf(name, "port_stats");
sprintf(desc, "Port Stats");
oid = SYSCTL_ADD_NODE(&softc->hw_stats,
SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name, CTLFLAG_RD, 0,
desc);
if (!oid)
return ENOMEM;
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_64b_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_64b_frames, "Transmitted 64b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_65b_127b_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_65b_127b_frames,
"Transmitted 65b 127b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_128b_255b_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_128b_255b_frames,
"Transmitted 128b 255b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_256b_511b_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_256b_511b_frames,
"Transmitted 256b 511b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_512b_1023b_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_512b_1023b_frames,
"Transmitted 512b 1023b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_1024b_1518_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_1024b_1518_frames,
"Transmitted 1024b 1518 frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_good_vlan_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_good_vlan_frames,
"Transmitted good vlan frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_1519b_2047_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_1519b_2047_frames,
"Transmitted 1519b 2047 frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_2048b_4095b_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_2048b_4095b_frames,
"Transmitted 2048b 4095b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_4096b_9216b_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_4096b_9216b_frames,
"Transmitted 4096b 9216b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_9217b_16383b_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_9217b_16383b_frames,
"Transmitted 9217b 16383b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_good_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_good_frames, "Transmitted good frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_total_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_total_frames, "Transmitted total frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_ucast_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_ucast_frames, "Transmitted ucast frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_mcast_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_mcast_frames, "Transmitted mcast frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_bcast_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_bcast_frames, "Transmitted bcast frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_pause_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_pause_frames, "Transmitted pause frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_pfc_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_pfc_frames, "Transmitted pfc frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_jabber_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_jabber_frames, "Transmitted jabber frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_fcs_err_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_fcs_err_frames,
"Transmitted fcs err frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_control_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_control_frames,
"Transmitted control frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_oversz_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_oversz_frames, "Transmitted oversz frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_single_dfrl_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_single_dfrl_frames,
"Transmitted single dfrl frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_multi_dfrl_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_multi_dfrl_frames,
"Transmitted multi dfrl frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_single_coll_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_single_coll_frames,
"Transmitted single coll frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_multi_coll_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_multi_coll_frames,
"Transmitted multi coll frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_late_coll_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_late_coll_frames,
"Transmitted late coll frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_excessive_coll_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_excessive_coll_frames,
"Transmitted excessive coll frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_frag_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_frag_frames, "Transmitted frag frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_err", CTLFLAG_RD,
&softc->tx_port_stats->tx_err, "Transmitted err");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_tagged_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_tagged_frames, "Transmitted tagged frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_dbl_tagged_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_dbl_tagged_frames,
"Transmitted dbl tagged frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_runt_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_runt_frames, "Transmitted runt frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_fifo_underruns", CTLFLAG_RD,
&softc->tx_port_stats->tx_fifo_underruns,
"Transmitted fifo underruns");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_pfc_ena_frames_pri0", CTLFLAG_RD,
&softc->tx_port_stats->tx_pfc_ena_frames_pri0,
"Transmitted pfc ena frames pri0");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_pfc_ena_frames_pri1", CTLFLAG_RD,
&softc->tx_port_stats->tx_pfc_ena_frames_pri1,
"Transmitted pfc ena frames pri1");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_pfc_ena_frames_pri2", CTLFLAG_RD,
&softc->tx_port_stats->tx_pfc_ena_frames_pri2,
"Transmitted pfc ena frames pri2");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_pfc_ena_frames_pri3", CTLFLAG_RD,
&softc->tx_port_stats->tx_pfc_ena_frames_pri3,
"Transmitted pfc ena frames pri3");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_pfc_ena_frames_pri4", CTLFLAG_RD,
&softc->tx_port_stats->tx_pfc_ena_frames_pri4,
"Transmitted pfc ena frames pri4");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_pfc_ena_frames_pri5", CTLFLAG_RD,
&softc->tx_port_stats->tx_pfc_ena_frames_pri5,
"Transmitted pfc ena frames pri5");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_pfc_ena_frames_pri6", CTLFLAG_RD,
&softc->tx_port_stats->tx_pfc_ena_frames_pri6,
"Transmitted pfc ena frames pri6");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_pfc_ena_frames_pri7", CTLFLAG_RD,
&softc->tx_port_stats->tx_pfc_ena_frames_pri7,
"Transmitted pfc ena frames pri7");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_eee_lpi_events", CTLFLAG_RD,
&softc->tx_port_stats->tx_eee_lpi_events,
"Transmitted eee lpi events");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_eee_lpi_duration", CTLFLAG_RD,
&softc->tx_port_stats->tx_eee_lpi_duration,
"Transmitted eee lpi duration");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_llfc_logical_msgs", CTLFLAG_RD,
&softc->tx_port_stats->tx_llfc_logical_msgs,
"Transmitted llfc logical msgs");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_hcfc_msgs", CTLFLAG_RD,
&softc->tx_port_stats->tx_hcfc_msgs, "Transmitted hcfc msgs");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_total_collisions", CTLFLAG_RD,
&softc->tx_port_stats->tx_total_collisions,
"Transmitted total collisions");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_bytes", CTLFLAG_RD,
&softc->tx_port_stats->tx_bytes, "Transmitted bytes");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_xthol_frames", CTLFLAG_RD,
&softc->tx_port_stats->tx_xthol_frames, "Transmitted xthol frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_stat_discard", CTLFLAG_RD,
&softc->tx_port_stats->tx_stat_discard, "Transmitted stat discard");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"tx_stat_error", CTLFLAG_RD,
&softc->tx_port_stats->tx_stat_error, "Transmitted stat error");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_64b_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_64b_frames, "Received 64b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_65b_127b_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_65b_127b_frames, "Received 65b 127b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_128b_255b_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_128b_255b_frames,
"Received 128b 255b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_256b_511b_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_256b_511b_frames,
"Received 256b 511b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_512b_1023b_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_512b_1023b_frames,
"Received 512b 1023b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_1024b_1518_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_1024b_1518_frames,
"Received 1024b 1518 frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_good_vlan_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_good_vlan_frames,
"Received good vlan frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_1519b_2047b_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_1519b_2047b_frames,
"Received 1519b 2047b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_2048b_4095b_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_2048b_4095b_frames,
"Received 2048b 4095b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_4096b_9216b_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_4096b_9216b_frames,
"Received 4096b 9216b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_9217b_16383b_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_9217b_16383b_frames,
"Received 9217b 16383b frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_total_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_total_frames, "Received total frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_ucast_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_ucast_frames, "Received ucast frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_mcast_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_mcast_frames, "Received mcast frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_bcast_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_bcast_frames, "Received bcast frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_fcs_err_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_fcs_err_frames, "Received fcs err frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_ctrl_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_ctrl_frames, "Received ctrl frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pause_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_pause_frames, "Received pause frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_frames, "Received pfc frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_unsupported_opcode_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_unsupported_opcode_frames,
"Received unsupported opcode frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_unsupported_da_pausepfc_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_unsupported_da_pausepfc_frames,
"Received unsupported da pausepfc frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_wrong_sa_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_wrong_sa_frames,
"Received wrong sa frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_align_err_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_align_err_frames,
"Received align err frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_oor_len_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_oor_len_frames,
"Received oor len frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_code_err_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_code_err_frames,
"Received code err frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_false_carrier_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_false_carrier_frames,
"Received false carrier frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_ovrsz_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_ovrsz_frames,
"Received ovrsz frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_jbr_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_jbr_frames,
"Received jbr frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_mtu_err_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_mtu_err_frames,
"Received mtu err frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_match_crc_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_match_crc_frames,
"Received match crc frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_promiscuous_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_promiscuous_frames,
"Received promiscuous frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_tagged_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_tagged_frames,
"Received tagged frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_double_tagged_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_double_tagged_frames,
"Received double tagged frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_trunc_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_trunc_frames,
"Received trunc frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_good_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_good_frames,
"Received good frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_xon2xoff_frames_pri0", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri0,
"Received pfc xon2xoff frames pri0");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_xon2xoff_frames_pri1", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri1,
"Received pfc xon2xoff frames pri1");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_xon2xoff_frames_pri2", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri2,
"Received pfc xon2xoff frames pri2");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_xon2xoff_frames_pri3", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri3,
"Received pfc xon2xoff frames pri3");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_xon2xoff_frames_pri4", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri4,
"Received pfc xon2xoff frames pri4");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_xon2xoff_frames_pri5", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri5,
"Received pfc xon2xoff frames pri5");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_xon2xoff_frames_pri6", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri6,
"Received pfc xon2xoff frames pri6");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_xon2xoff_frames_pri7", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri7,
"Received pfc xon2xoff frames pri7");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_ena_frames_pri0", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_ena_frames_pri0,
"Received pfc ena frames pri0");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_ena_frames_pri1", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_ena_frames_pri1,
"Received pfc ena frames pri1");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_ena_frames_pri2", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_ena_frames_pri2,
"Received pfc ena frames pri2");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_ena_frames_pri3", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_ena_frames_pri3,
"Received pfc ena frames pri3");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_ena_frames_pri4", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_ena_frames_pri4,
"Received pfc ena frames pri4");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_ena_frames_pri5", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_ena_frames_pri5,
"Received pfc ena frames pri5");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_ena_frames_pri6", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_ena_frames_pri6,
"Received pfc ena frames pri6");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_pfc_ena_frames_pri7", CTLFLAG_RD,
&softc->rx_port_stats->rx_pfc_ena_frames_pri7,
"Received pfc ena frames pri7");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_sch_crc_err_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_sch_crc_err_frames,
"Received sch crc err frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_undrsz_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_undrsz_frames, "Received undrsz frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_frag_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_frag_frames, "Received frag frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_eee_lpi_events", CTLFLAG_RD,
&softc->rx_port_stats->rx_eee_lpi_events, "Received eee lpi events");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_eee_lpi_duration", CTLFLAG_RD,
&softc->rx_port_stats->rx_eee_lpi_duration,
"Received eee lpi duration");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_llfc_physical_msgs", CTLFLAG_RD,
&softc->rx_port_stats->rx_llfc_physical_msgs,
"Received llfc physical msgs");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_llfc_logical_msgs", CTLFLAG_RD,
&softc->rx_port_stats->rx_llfc_logical_msgs,
"Received llfc logical msgs");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_llfc_msgs_with_crc_err", CTLFLAG_RD,
&softc->rx_port_stats->rx_llfc_msgs_with_crc_err,
"Received llfc msgs with crc err");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_hcfc_msgs", CTLFLAG_RD,
&softc->rx_port_stats->rx_hcfc_msgs, "Received hcfc msgs");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_hcfc_msgs_with_crc_err", CTLFLAG_RD,
&softc->rx_port_stats->rx_hcfc_msgs_with_crc_err,
"Received hcfc msgs with crc err");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_bytes", CTLFLAG_RD,
&softc->rx_port_stats->rx_bytes, "Received bytes");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_runt_bytes", CTLFLAG_RD,
&softc->rx_port_stats->rx_runt_bytes, "Received runt bytes");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_runt_frames", CTLFLAG_RD,
&softc->rx_port_stats->rx_runt_frames, "Received runt frames");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_stat_discard", CTLFLAG_RD,
&softc->rx_port_stats->rx_stat_discard, "Received stat discard");
SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
"rx_stat_err", CTLFLAG_RD,
&softc->rx_port_stats->rx_stat_err, "Received stat err");
return 0;
}
int
bnxt_create_rx_sysctls(struct bnxt_softc *softc, int rxr)
{

View file

@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
int bnxt_init_sysctl_ctx(struct bnxt_softc *softc);
int bnxt_free_sysctl_ctx(struct bnxt_softc *softc);
int bnxt_create_port_stats_sysctls(struct bnxt_softc *softc);
int bnxt_create_tx_sysctls(struct bnxt_softc *softc, int txr);
int bnxt_create_rx_sysctls(struct bnxt_softc *softc, int rxr);
int bnxt_create_ver_sysctls(struct bnxt_softc *softc);

View file

@ -176,6 +176,7 @@ static int bnxt_media_change(if_ctx_t ctx);
static int bnxt_promisc_set(if_ctx_t ctx, int flags);
static uint64_t bnxt_get_counter(if_ctx_t, ift_counter);
static void bnxt_update_admin_status(if_ctx_t ctx);
static void bnxt_if_timer(if_ctx_t ctx, uint16_t qid);
/* Interrupt enable / disable */
static void bnxt_intr_enable(if_ctx_t ctx);
@ -260,6 +261,7 @@ static device_method_t bnxt_iflib_methods[] = {
DEVMETHOD(ifdi_promisc_set, bnxt_promisc_set),
DEVMETHOD(ifdi_get_counter, bnxt_get_counter),
DEVMETHOD(ifdi_update_admin_status, bnxt_update_admin_status),
DEVMETHOD(ifdi_timer, bnxt_if_timer),
DEVMETHOD(ifdi_intr_enable, bnxt_intr_enable),
DEVMETHOD(ifdi_tx_queue_intr_enable, bnxt_tx_queue_intr_enable),
@ -424,6 +426,8 @@ bnxt_queues_free(if_ctx_t ctx)
// Free RX queues
iflib_dma_free(&softc->rx_stats);
iflib_dma_free(&softc->hw_tx_port_stats);
iflib_dma_free(&softc->hw_rx_port_stats);
free(softc->grp_info, M_DEVBUF);
free(softc->ag_rings, M_DEVBUF);
free(softc->rx_rings, M_DEVBUF);
@ -480,6 +484,33 @@ bnxt_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
bus_dmamap_sync(softc->rx_stats.idi_tag, softc->rx_stats.idi_map,
BUS_DMASYNC_PREREAD);
/*
* Additional 512 bytes for future expansion.
* To prevent corruption when loaded with newer firmwares with added counters.
* This can be deleted when there will be no further additions of counters.
*/
#define BNXT_PORT_STAT_PADDING 512
rc = iflib_dma_alloc(ctx, sizeof(struct rx_port_stats) + BNXT_PORT_STAT_PADDING,
&softc->hw_rx_port_stats, 0);
if (rc)
goto hw_port_rx_stats_alloc_fail;
bus_dmamap_sync(softc->hw_rx_port_stats.idi_tag,
softc->hw_rx_port_stats.idi_map, BUS_DMASYNC_PREREAD);
rc = iflib_dma_alloc(ctx, sizeof(struct tx_port_stats) + BNXT_PORT_STAT_PADDING,
&softc->hw_tx_port_stats, 0);
if (rc)
goto hw_port_tx_stats_alloc_fail;
bus_dmamap_sync(softc->hw_tx_port_stats.idi_tag,
softc->hw_tx_port_stats.idi_map, BUS_DMASYNC_PREREAD);
softc->rx_port_stats = (void *) softc->hw_rx_port_stats.idi_vaddr;
softc->tx_port_stats = (void *) softc->hw_tx_port_stats.idi_vaddr;
for (i = 0; i < nrxqsets; i++) {
/* Allocation the completion ring */
softc->rx_cp_rings[i].stats_ctx_id = HWRM_NA_SIGNATURE;
@ -538,6 +569,13 @@ bnxt_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
bnxt_create_rx_sysctls(softc, i);
}
/*
* When SR-IOV is enabled, avoid each VF sending PORT_QSTATS
* HWRM every sec with which firmware timeouts can happen
*/
if (BNXT_PF(softc))
bnxt_create_port_stats_sysctls(softc);
/* And finally, the VNIC */
softc->vnic_info.id = (uint16_t)HWRM_NA_SIGNATURE;
softc->vnic_info.flow_id = (uint16_t)HWRM_NA_SIGNATURE;
@ -586,6 +624,10 @@ tpa_alloc_fail:
mc_list_alloc_fail:
for (i = i - 1; i >= 0; i--)
free(softc->rx_rings[i].tpa_start, M_DEVBUF);
iflib_dma_free(&softc->hw_tx_port_stats);
hw_port_tx_stats_alloc_fail:
iflib_dma_free(&softc->hw_rx_port_stats);
hw_port_rx_stats_alloc_fail:
iflib_dma_free(&softc->rx_stats);
hw_stats_alloc_fail:
free(softc->grp_info, M_DEVBUF);
@ -1467,7 +1509,32 @@ bnxt_get_counter(if_ctx_t ctx, ift_counter cnt)
static void
bnxt_update_admin_status(if_ctx_t ctx)
{
/* TODO: do we need to do anything here? */
struct bnxt_softc *softc = iflib_get_softc(ctx);
/*
* When SR-IOV is enabled, avoid each VF sending this HWRM
* request every sec with which firmware timeouts can happen
*/
if (BNXT_PF(softc)) {
bnxt_hwrm_port_qstats(softc);
}
return;
}
static void
bnxt_if_timer(if_ctx_t ctx, uint16_t qid)
{
struct bnxt_softc *softc = iflib_get_softc(ctx);
uint64_t ticks_now = ticks;
/* Schedule bnxt_update_admin_status() once per sec */
if (ticks_now - softc->admin_ticks >= hz) {
softc->admin_ticks = ticks_now;
iflib_admin_intr_deferred(ctx);
}
return;
}