Index: sys/dev/bnxt/bnxt.h =================================================================== --- sys/dev/bnxt/bnxt.h +++ sys/dev/bnxt/bnxt.h @@ -550,8 +550,9 @@ uint8_t max_tc; struct bnxt_cos_queue q_info[BNXT_MAX_QUEUE]; - struct iflib_dma_info hw_rx_port_stats; - struct iflib_dma_info hw_tx_port_stats; + struct callout timer; + struct iflib_dma_info hw_port_stats; + uint32_t hw_port_stats_size; struct rx_port_stats *rx_port_stats; struct tx_port_stats *tx_port_stats; Index: sys/dev/bnxt/bnxt_hwrm.h =================================================================== --- sys/dev/bnxt/bnxt_hwrm.h +++ sys/dev/bnxt/bnxt_hwrm.h @@ -51,6 +51,7 @@ 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); Index: sys/dev/bnxt/bnxt_hwrm.c =================================================================== --- sys/dev/bnxt/bnxt_hwrm.c +++ sys/dev/bnxt/bnxt_hwrm.c @@ -795,6 +795,26 @@ } 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_port_stats.idi_paddr); + req.tx_stat_host_addr = htole64((uint8_t *) req.rx_stat_host_addr + + sizeof(struct rx_port_stats) + 512); + + 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) { Index: sys/dev/bnxt/bnxt_sysctl.h =================================================================== --- sys/dev/bnxt/bnxt_sysctl.h +++ sys/dev/bnxt/bnxt_sysctl.h @@ -33,6 +33,7 @@ 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); Index: sys/dev/bnxt/bnxt_sysctl.c =================================================================== --- sys/dev/bnxt/bnxt_sysctl.c +++ sys/dev/bnxt/bnxt_sysctl.c @@ -164,6 +164,456 @@ } 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) { struct sysctl_oid *oid; Index: sys/dev/bnxt/if_bnxt.c =================================================================== --- sys/dev/bnxt/if_bnxt.c +++ sys/dev/bnxt/if_bnxt.c @@ -424,6 +424,7 @@ // Free RX queues iflib_dma_free(&softc->rx_stats); + iflib_dma_free(&softc->hw_port_stats); free(softc->grp_info, M_DEVBUF); free(softc->ag_rings, M_DEVBUF); free(softc->rx_rings, M_DEVBUF); @@ -480,6 +481,20 @@ bus_dmamap_sync(softc->rx_stats.idi_tag, softc->rx_stats.idi_map, BUS_DMASYNC_PREREAD); + softc->hw_port_stats_size = sizeof(struct rx_port_stats) + + sizeof(struct tx_port_stats) + 1024; + + rc = iflib_dma_alloc(ctx, softc->hw_port_stats_size, + &softc->hw_port_stats, 0); + if (rc) + goto hw_port_stats_alloc_fail; + + bus_dmamap_sync(softc->hw_port_stats.idi_tag, softc->hw_port_stats.idi_map, + BUS_DMASYNC_PREREAD); + + softc->rx_port_stats = (void *) softc->hw_port_stats.idi_vaddr; + softc->tx_port_stats = (void *) ((uint8_t *) ((softc->rx_port_stats + 1)) + 512); + for (i = 0; i < nrxqsets; i++) { /* Allocation the completion ring */ softc->rx_cp_rings[i].stats_ctx_id = HWRM_NA_SIGNATURE; @@ -538,6 +553,8 @@ bnxt_create_rx_sysctls(softc, i); } + 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 +603,8 @@ 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_port_stats); +hw_port_stats_alloc_fail: iflib_dma_free(&softc->rx_stats); hw_stats_alloc_fail: free(softc->grp_info, M_DEVBUF); @@ -599,6 +618,16 @@ return rc; } +static void +bnxt_local_timer(void *arg) +{ + struct bnxt_softc *softc = arg; + + bnxt_hwrm_port_qstats(softc); + + callout_reset(&softc->timer, hz, bnxt_local_timer, softc); +} + /* Device setup and teardown */ static int bnxt_attach_pre(if_ctx_t ctx) @@ -812,6 +841,11 @@ SLIST_INIT(&softc->vnic_info.vlan_tags); softc->vnic_info.vlan_tag_list.idi_vaddr = NULL; + callout_init(&softc->timer, CALLOUT_MPSAFE); + rc = callout_reset(&softc->timer, 2 * hz, bnxt_local_timer, softc); + if (rc) + goto failed; + return (rc); failed: @@ -866,6 +900,7 @@ struct bnxt_vlan_tag *tmp; int i; + callout_drain(&softc->timer); bnxt_wol_config(ctx); bnxt_do_disable_intr(&softc->def_cp_ring); bnxt_free_sysctl_ctx(softc);