diff --git a/sys/dev/bnxt/bnxt_en/bnxt.h b/sys/dev/bnxt/bnxt_en/bnxt.h index ab60ddf74672..d6fe2ce8ddb1 100644 --- a/sys/dev/bnxt/bnxt_en/bnxt.h +++ b/sys/dev/bnxt/bnxt_en/bnxt.h @@ -1,1114 +1,1137 @@ /*- * Broadcom NetXtreme-C/E network driver. * * Copyright (c) 2016 Broadcom, All Rights Reserved. * The term Broadcom refers to Broadcom Limited and/or its subsidiaries * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef _BNXT_H #define _BNXT_H #include #include #include #include #include #include #include #include #include #include #include #include "hsi_struct_def.h" #include "bnxt_dcb.h" #include "bnxt_auxbus_compat.h" #define DFLT_HWRM_CMD_TIMEOUT 500 /* PCI IDs */ #define BROADCOM_VENDOR_ID 0x14E4 #define BCM57301 0x16c8 #define BCM57302 0x16c9 #define BCM57304 0x16ca #define BCM57311 0x16ce #define BCM57312 0x16cf #define BCM57314 0x16df #define BCM57402 0x16d0 #define BCM57402_NPAR 0x16d4 #define BCM57404 0x16d1 #define BCM57404_NPAR 0x16e7 #define BCM57406 0x16d2 #define BCM57406_NPAR 0x16e8 #define BCM57407 0x16d5 #define BCM57407_NPAR 0x16ea #define BCM57407_SFP 0x16e9 #define BCM57412 0x16d6 #define BCM57412_NPAR1 0x16de #define BCM57412_NPAR2 0x16eb #define BCM57414 0x16d7 #define BCM57414_NPAR1 0x16ec #define BCM57414_NPAR2 0x16ed #define BCM57416 0x16d8 #define BCM57416_NPAR1 0x16ee #define BCM57416_NPAR2 0x16ef #define BCM57416_SFP 0x16e3 #define BCM57417 0x16d9 #define BCM57417_NPAR1 0x16c0 #define BCM57417_NPAR2 0x16cc #define BCM57417_SFP 0x16e2 #define BCM57454 0x1614 #define BCM58700 0x16cd #define BCM57508 0x1750 #define BCM57504 0x1751 #define BCM57502 0x1752 #define NETXTREME_C_VF1 0x16cb #define NETXTREME_C_VF2 0x16e1 #define NETXTREME_C_VF3 0x16e5 #define NETXTREME_E_VF1 0x16c1 #define NETXTREME_E_VF2 0x16d3 #define NETXTREME_E_VF3 0x16dc #define EVENT_DATA1_RESET_NOTIFY_FATAL(data1) \ (((data1) & \ HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK) ==\ HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL) #define BNXT_EVENT_ERROR_REPORT_TYPE(data1) \ (((data1) & \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_MASK) >> \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_SFT) #define BNXT_EVENT_INVALID_SIGNAL_DATA(data2) \ (((data2) & \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA2_PIN_ID_MASK) >> \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA2_PIN_ID_SFT) #define BNXT_EVENT_DBR_EPOCH(data) \ (((data) & HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_DATA1_EPOCH_MASK) >> \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_DATA1_EPOCH_SFT) #define BNXT_EVENT_THERMAL_THRESHOLD_TEMP(data2) \ (((data2) & \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_THRESHOLD_TEMP_MASK) >> \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_THRESHOLD_TEMP_SFT) #define EVENT_DATA2_NVM_ERR_ADDR(data2) \ (((data2) & \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA2_ERR_ADDR_MASK) >> \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA2_ERR_ADDR_SFT) #define EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING(data1) \ (((data1) & \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR) == \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR_INCREASING) #define EVENT_DATA1_NVM_ERR_TYPE_WRITE(data1) \ (((data1) & \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_MASK) == \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_WRITE) #define EVENT_DATA1_NVM_ERR_TYPE_ERASE(data1) \ (((data1) & \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_MASK) == \ HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_ERASE) #define EVENT_DATA1_THERMAL_THRESHOLD_TYPE(data1) \ ((data1) & HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_MASK) #define BNXT_EVENT_THERMAL_CURRENT_TEMP(data2) \ ((data2) & HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_CURRENT_TEMP_MASK) #define INVALID_STATS_CTX_ID -1 /* Maximum numbers of RX and TX descriptors. iflib requires this to be a power * of two. The hardware has no particular limitation. */ #define BNXT_MAX_RXD ((INT32_MAX >> 1) + 1) #define BNXT_MAX_TXD ((INT32_MAX >> 1) + 1) #define CSUM_OFFLOAD (CSUM_IP_TSO|CSUM_IP6_TSO|CSUM_IP| \ CSUM_IP_UDP|CSUM_IP_TCP|CSUM_IP_SCTP| \ CSUM_IP6_UDP|CSUM_IP6_TCP|CSUM_IP6_SCTP) #define BNXT_MAX_MTU 9600 #define BNXT_RSS_HASH_TYPE_TCPV4 0 #define BNXT_RSS_HASH_TYPE_UDPV4 1 #define BNXT_RSS_HASH_TYPE_IPV4 2 #define BNXT_RSS_HASH_TYPE_TCPV6 3 #define BNXT_RSS_HASH_TYPE_UDPV6 4 #define BNXT_RSS_HASH_TYPE_IPV6 5 #define BNXT_GET_RSS_PROFILE_ID(rss_hash_type) ((rss_hash_type >> 1) & 0x1F) #define BNXT_NO_MORE_WOL_FILTERS 0xFFFF #define bnxt_wol_supported(softc) (!((softc)->flags & BNXT_FLAG_VF) && \ ((softc)->flags & BNXT_FLAG_WOL_CAP )) /* 64-bit doorbell */ #define DBR_INDEX_MASK 0x0000000000ffffffULL #define DBR_PI_LO_MASK 0xff000000UL #define DBR_PI_LO_SFT 24 #define DBR_XID_MASK 0x000fffff00000000ULL #define DBR_XID_SFT 32 #define DBR_PI_HI_MASK 0xf0000000000000ULL #define DBR_PI_HI_SFT 52 #define DBR_PATH_L2 (0x1ULL << 56) #define DBR_VALID (0x1ULL << 58) #define DBR_TYPE_SQ (0x0ULL << 60) #define DBR_TYPE_RQ (0x1ULL << 60) #define DBR_TYPE_SRQ (0x2ULL << 60) #define DBR_TYPE_SRQ_ARM (0x3ULL << 60) #define DBR_TYPE_CQ (0x4ULL << 60) #define DBR_TYPE_CQ_ARMSE (0x5ULL << 60) #define DBR_TYPE_CQ_ARMALL (0x6ULL << 60) #define DBR_TYPE_CQ_ARMENA (0x7ULL << 60) #define DBR_TYPE_SRQ_ARMENA (0x8ULL << 60) #define DBR_TYPE_CQ_CUTOFF_ACK (0x9ULL << 60) #define DBR_TYPE_NQ (0xaULL << 60) #define DBR_TYPE_NQ_ARM (0xbULL << 60) #define DBR_TYPE_PUSH_START (0xcULL << 60) #define DBR_TYPE_PUSH_END (0xdULL << 60) #define DBR_TYPE_NULL (0xfULL << 60) #define BNXT_MAX_L2_QUEUES 128 #define BNXT_ROCE_IRQ_COUNT 9 #define BNXT_MAX_NUM_QUEUES (BNXT_MAX_L2_QUEUES + BNXT_ROCE_IRQ_COUNT) /* Completion related defines */ #define CMP_VALID(cmp, v_bit) \ ((!!(((struct cmpl_base *)(cmp))->info3_v & htole32(CMPL_BASE_V))) == !!(v_bit) ) /* Chip class phase 5 */ #define BNXT_CHIP_P5(sc) ((sc->flags & BNXT_FLAG_CHIP_P5)) #define DB_PF_OFFSET_P5 0x10000 #define DB_VF_OFFSET_P5 0x4000 #define NQ_VALID(cmp, v_bit) \ ((!!(((nq_cn_t *)(cmp))->v & htole32(NQ_CN_V))) == !!(v_bit) ) #ifndef DIV_ROUND_UP #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) #endif #ifndef roundup #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) #endif #define NEXT_CP_CONS_V(ring, cons, v_bit) do { \ if (__predict_false(++(cons) == (ring)->ring_size)) \ ((cons) = 0, (v_bit) = !v_bit); \ } while (0) #define RING_NEXT(ring, idx) (__predict_false(idx + 1 == (ring)->ring_size) ? \ 0 : idx + 1) #define CMPL_PREFETCH_NEXT(cpr, idx) \ __builtin_prefetch(&((struct cmpl_base *)(cpr)->ring.vaddr)[((idx) +\ (CACHE_LINE_SIZE / sizeof(struct cmpl_base))) & \ ((cpr)->ring.ring_size - 1)]) /* Lock macros */ #define BNXT_HWRM_LOCK_INIT(_softc, _name) \ mtx_init(&(_softc)->hwrm_lock, _name, "BNXT HWRM Lock", MTX_DEF) #define BNXT_HWRM_LOCK(_softc) mtx_lock(&(_softc)->hwrm_lock) #define BNXT_HWRM_UNLOCK(_softc) mtx_unlock(&(_softc)->hwrm_lock) #define BNXT_HWRM_LOCK_DESTROY(_softc) mtx_destroy(&(_softc)->hwrm_lock) #define BNXT_HWRM_LOCK_ASSERT(_softc) mtx_assert(&(_softc)->hwrm_lock, \ MA_OWNED) #define BNXT_IS_FLOW_CTRL_CHANGED(link_info) \ ((link_info->last_flow_ctrl.tx != link_info->flow_ctrl.tx) || \ (link_info->last_flow_ctrl.rx != link_info->flow_ctrl.rx) || \ (link_info->last_flow_ctrl.autoneg != link_info->flow_ctrl.autoneg)) /* Chip info */ #define BNXT_TSO_SIZE UINT16_MAX #define min_t(type, x, y) ({ \ type __min1 = (x); \ type __min2 = (y); \ __min1 < __min2 ? __min1 : __min2; }) #define max_t(type, x, y) ({ \ type __max1 = (x); \ type __max2 = (y); \ __max1 > __max2 ? __max1 : __max2; }) #define clamp_t(type, _x, min, max) min_t(type, max_t(type, _x, min), max) #define BNXT_IFMEDIA_ADD(supported, fw_speed, ifm_speed) do { \ if ((supported) & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_ ## fw_speed) \ ifmedia_add(softc->media, IFM_ETHER | (ifm_speed), 0, NULL); \ } while(0) #define BNXT_MIN_FRAME_SIZE 52 /* Frames must be padded to this size for some A0 chips */ +#define BNXT_RX_STATS_EXT_OFFSET(counter) \ + (offsetof(struct rx_port_stats_ext, counter) / 8) + +#define BNXT_RX_STATS_EXT_NUM_LEGACY \ + BNXT_RX_STATS_EXT_OFFSET(rx_fec_corrected_blocks) + +#define BNXT_TX_STATS_EXT_OFFSET(counter) \ + (offsetof(struct tx_port_stats_ext, counter) / 8) + extern const char bnxt_driver_version[]; typedef void (*bnxt_doorbell_tx)(void *, uint16_t idx); typedef void (*bnxt_doorbell_rx)(void *, uint16_t idx); typedef void (*bnxt_doorbell_rx_cq)(void *, bool); typedef void (*bnxt_doorbell_tx_cq)(void *, bool); typedef void (*bnxt_doorbell_nq)(void *, bool); typedef struct bnxt_doorbell_ops { bnxt_doorbell_tx bnxt_db_tx; bnxt_doorbell_rx bnxt_db_rx; bnxt_doorbell_rx_cq bnxt_db_rx_cq; bnxt_doorbell_tx_cq bnxt_db_tx_cq; bnxt_doorbell_nq bnxt_db_nq; } bnxt_dooorbell_ops_t; /* NVRAM access */ enum bnxt_nvm_directory_type { BNX_DIR_TYPE_UNUSED = 0, BNX_DIR_TYPE_PKG_LOG = 1, BNX_DIR_TYPE_UPDATE = 2, BNX_DIR_TYPE_CHIMP_PATCH = 3, BNX_DIR_TYPE_BOOTCODE = 4, BNX_DIR_TYPE_VPD = 5, BNX_DIR_TYPE_EXP_ROM_MBA = 6, BNX_DIR_TYPE_AVS = 7, BNX_DIR_TYPE_PCIE = 8, BNX_DIR_TYPE_PORT_MACRO = 9, BNX_DIR_TYPE_APE_FW = 10, BNX_DIR_TYPE_APE_PATCH = 11, BNX_DIR_TYPE_KONG_FW = 12, BNX_DIR_TYPE_KONG_PATCH = 13, BNX_DIR_TYPE_BONO_FW = 14, BNX_DIR_TYPE_BONO_PATCH = 15, BNX_DIR_TYPE_TANG_FW = 16, BNX_DIR_TYPE_TANG_PATCH = 17, BNX_DIR_TYPE_BOOTCODE_2 = 18, BNX_DIR_TYPE_CCM = 19, BNX_DIR_TYPE_PCI_CFG = 20, BNX_DIR_TYPE_TSCF_UCODE = 21, BNX_DIR_TYPE_ISCSI_BOOT = 22, BNX_DIR_TYPE_ISCSI_BOOT_IPV6 = 24, BNX_DIR_TYPE_ISCSI_BOOT_IPV4N6 = 25, BNX_DIR_TYPE_ISCSI_BOOT_CFG6 = 26, BNX_DIR_TYPE_EXT_PHY = 27, BNX_DIR_TYPE_SHARED_CFG = 40, BNX_DIR_TYPE_PORT_CFG = 41, BNX_DIR_TYPE_FUNC_CFG = 42, BNX_DIR_TYPE_MGMT_CFG = 48, BNX_DIR_TYPE_MGMT_DATA = 49, BNX_DIR_TYPE_MGMT_WEB_DATA = 50, BNX_DIR_TYPE_MGMT_WEB_META = 51, BNX_DIR_TYPE_MGMT_EVENT_LOG = 52, BNX_DIR_TYPE_MGMT_AUDIT_LOG = 53 }; enum bnxnvm_pkglog_field_index { BNX_PKG_LOG_FIELD_IDX_INSTALLED_TIMESTAMP = 0, BNX_PKG_LOG_FIELD_IDX_PKG_DESCRIPTION = 1, BNX_PKG_LOG_FIELD_IDX_PKG_VERSION = 2, BNX_PKG_LOG_FIELD_IDX_PKG_TIMESTAMP = 3, BNX_PKG_LOG_FIELD_IDX_PKG_CHECKSUM = 4, BNX_PKG_LOG_FIELD_IDX_INSTALLED_ITEMS = 5, BNX_PKG_LOG_FIELD_IDX_INSTALLED_MASK = 6 }; #define BNX_DIR_ORDINAL_FIRST 0 #define BNX_DIR_EXT_NONE 0 struct bnxt_bar_info { struct resource *res; bus_space_tag_t tag; bus_space_handle_t handle; bus_size_t size; int rid; }; struct bnxt_flow_ctrl { bool rx; bool tx; bool autoneg; }; struct bnxt_link_info { uint8_t media_type; uint8_t transceiver; uint8_t phy_addr; uint8_t phy_link_status; uint8_t wire_speed; uint8_t loop_back; uint8_t link_up; uint8_t last_link_up; uint8_t duplex; uint8_t last_duplex; uint8_t last_phy_type; struct bnxt_flow_ctrl flow_ctrl; struct bnxt_flow_ctrl last_flow_ctrl; uint8_t duplex_setting; uint8_t auto_mode; #define PHY_VER_LEN 3 uint8_t phy_ver[PHY_VER_LEN]; uint8_t phy_type; #define BNXT_PHY_STATE_ENABLED 0 #define BNXT_PHY_STATE_DISABLED 1 uint8_t phy_state; uint16_t link_speed; uint16_t support_speeds; uint16_t support_pam4_speeds; uint16_t auto_link_speeds; uint16_t auto_pam4_link_speeds; uint16_t force_link_speed; uint16_t force_pam4_link_speed; bool force_pam4_speed_set_by_user; uint16_t advertising; uint16_t advertising_pam4; uint32_t preemphasis; uint16_t support_auto_speeds; uint16_t support_force_speeds; uint16_t support_pam4_auto_speeds; uint16_t support_pam4_force_speeds; #define BNXT_SIG_MODE_NRZ HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_NRZ #define BNXT_SIG_MODE_PAM4 HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_PAM4 uint8_t req_signal_mode; uint8_t active_fec_sig_mode; uint8_t sig_mode; /* copy of requested setting */ uint8_t autoneg; #define BNXT_AUTONEG_SPEED 1 #define BNXT_AUTONEG_FLOW_CTRL 2 uint8_t req_duplex; uint16_t req_link_speed; uint8_t module_status; struct hwrm_port_phy_qcfg_output phy_qcfg_resp; }; enum bnxt_phy_type { BNXT_MEDIA_CR = 0, BNXT_MEDIA_LR, BNXT_MEDIA_SR, BNXT_MEDIA_KR, BNXT_MEDIA_END }; enum bnxt_cp_type { BNXT_DEFAULT, BNXT_TX, BNXT_RX, BNXT_SHARED }; struct bnxt_queue_info { uint8_t queue_id; uint8_t queue_profile; }; struct bnxt_func_info { uint32_t fw_fid; uint8_t mac_addr[ETHER_ADDR_LEN]; uint16_t max_rsscos_ctxs; uint16_t max_cp_rings; uint16_t max_tx_rings; uint16_t max_rx_rings; uint16_t max_hw_ring_grps; uint16_t max_irqs; uint16_t max_l2_ctxs; uint16_t max_vnics; uint16_t max_stat_ctxs; }; struct bnxt_pf_info { #define BNXT_FIRST_PF_FID 1 #define BNXT_FIRST_VF_FID 128 uint8_t port_id; uint32_t first_vf_id; uint16_t active_vfs; uint16_t max_vfs; uint32_t max_encap_records; uint32_t max_decap_records; uint32_t max_tx_em_flows; uint32_t max_tx_wm_flows; uint32_t max_rx_em_flows; uint32_t max_rx_wm_flows; unsigned long *vf_event_bmap; uint16_t hwrm_cmd_req_pages; void *hwrm_cmd_req_addr[4]; bus_addr_t hwrm_cmd_req_dma_addr[4]; }; struct bnxt_vf_info { uint16_t fw_fid; uint8_t mac_addr[ETHER_ADDR_LEN]; uint16_t max_rsscos_ctxs; uint16_t max_cp_rings; uint16_t max_tx_rings; uint16_t max_rx_rings; uint16_t max_hw_ring_grps; uint16_t max_l2_ctxs; uint16_t max_irqs; uint16_t max_vnics; uint16_t max_stat_ctxs; uint32_t vlan; #define BNXT_VF_QOS 0x1 #define BNXT_VF_SPOOFCHK 0x2 #define BNXT_VF_LINK_FORCED 0x4 #define BNXT_VF_LINK_UP 0x8 uint32_t flags; uint32_t func_flags; /* func cfg flags */ uint32_t min_tx_rate; uint32_t max_tx_rate; void *hwrm_cmd_req_addr; bus_addr_t hwrm_cmd_req_dma_addr; }; #define BNXT_PF(softc) (!((softc)->flags & BNXT_FLAG_VF)) #define BNXT_VF(softc) ((softc)->flags & BNXT_FLAG_VF) struct bnxt_vlan_tag { SLIST_ENTRY(bnxt_vlan_tag) next; uint64_t filter_id; uint16_t tag; }; struct bnxt_vnic_info { uint16_t id; uint16_t def_ring_grp; uint16_t cos_rule; uint16_t lb_rule; uint16_t mru; uint32_t rx_mask; struct iflib_dma_info mc_list; int mc_list_count; #define BNXT_MAX_MC_ADDRS 16 uint32_t flags; #define BNXT_VNIC_FLAG_DEFAULT 0x01 #define BNXT_VNIC_FLAG_BD_STALL 0x02 #define BNXT_VNIC_FLAG_VLAN_STRIP 0x04 uint64_t filter_id; uint16_t rss_id; uint32_t rss_hash_type; uint8_t rss_hash_key[HW_HASH_KEY_SIZE]; struct iflib_dma_info rss_hash_key_tbl; struct iflib_dma_info rss_grp_tbl; SLIST_HEAD(vlan_head, bnxt_vlan_tag) vlan_tags; struct iflib_dma_info vlan_tag_list; }; struct bnxt_grp_info { uint16_t stats_ctx; uint16_t grp_id; uint16_t rx_ring_id; uint16_t cp_ring_id; uint16_t ag_ring_id; }; struct bnxt_ring { uint64_t paddr; vm_offset_t doorbell; caddr_t vaddr; struct bnxt_softc *softc; uint32_t ring_size; /* Must be a power of two */ uint16_t id; /* Logical ID */ uint16_t phys_id; uint16_t idx; struct bnxt_full_tpa_start *tpa_start; }; struct bnxt_cp_ring { struct bnxt_ring ring; struct if_irq irq; uint32_t cons; bool v_bit; /* Value of valid bit */ struct ctx_hw_stats *stats; uint32_t stats_ctx_id; uint32_t last_idx; /* Used by RX rings only * set to the last read pidx */ uint64_t int_count; }; struct bnxt_full_tpa_start { struct rx_tpa_start_cmpl low; struct rx_tpa_start_cmpl_hi high; }; /* All the version information for the part */ #define BNXT_VERSTR_SIZE (3*3+2+1) /* ie: "255.255.255\0" */ #define BNXT_NAME_SIZE 17 #define FW_VER_STR_LEN 32 #define BC_HWRM_STR_LEN 21 struct bnxt_ver_info { uint8_t hwrm_if_major; uint8_t hwrm_if_minor; uint8_t hwrm_if_update; char hwrm_if_ver[BNXT_VERSTR_SIZE]; char driver_hwrm_if_ver[BNXT_VERSTR_SIZE]; char mgmt_fw_ver[FW_VER_STR_LEN]; char netctrl_fw_ver[FW_VER_STR_LEN]; char roce_fw_ver[FW_VER_STR_LEN]; char fw_ver_str[FW_VER_STR_LEN]; char phy_ver[BNXT_VERSTR_SIZE]; char pkg_ver[64]; char hwrm_fw_name[BNXT_NAME_SIZE]; char mgmt_fw_name[BNXT_NAME_SIZE]; char netctrl_fw_name[BNXT_NAME_SIZE]; char roce_fw_name[BNXT_NAME_SIZE]; char phy_vendor[BNXT_NAME_SIZE]; char phy_partnumber[BNXT_NAME_SIZE]; uint16_t chip_num; uint8_t chip_rev; uint8_t chip_metal; uint8_t chip_bond_id; uint8_t chip_type; uint8_t hwrm_min_major; uint8_t hwrm_min_minor; uint8_t hwrm_min_update; uint64_t fw_ver_code; #define BNXT_FW_VER_CODE(maj, min, bld, rsv) \ ((uint64_t)(maj) << 48 | (uint64_t)(min) << 32 | (uint64_t)(bld) << 16 | (rsv)) #define BNXT_FW_MAJ(softc) ((softc)->ver_info->fw_ver_code >> 48) #define BNXT_FW_MIN(softc) (((softc)->ver_info->fw_ver_code >> 32) & 0xffff) #define BNXT_FW_BLD(softc) (((softc)->ver_info->fw_ver_code >> 16) & 0xffff) #define BNXT_FW_RSV(softc) (((softc)->ver_info->fw_ver_code) & 0xffff) struct sysctl_ctx_list ver_ctx; struct sysctl_oid *ver_oid; }; struct bnxt_nvram_info { uint16_t mfg_id; uint16_t device_id; uint32_t sector_size; uint32_t size; uint32_t reserved_size; uint32_t available_size; struct sysctl_ctx_list nvm_ctx; struct sysctl_oid *nvm_oid; }; struct bnxt_func_qcfg { uint16_t alloc_completion_rings; uint16_t alloc_tx_rings; uint16_t alloc_rx_rings; uint16_t alloc_vnics; }; struct bnxt_hw_lro { uint16_t enable; uint16_t is_mode_gro; uint16_t max_agg_segs; uint16_t max_aggs; uint32_t min_agg_len; }; /* The hardware supports certain page sizes. Use the supported page sizes * to allocate the rings. */ #if (PAGE_SHIFT < 12) #define BNXT_PAGE_SHIFT 12 #elif (PAGE_SHIFT <= 13) #define BNXT_PAGE_SHIFT PAGE_SHIFT #elif (PAGE_SHIFT < 16) #define BNXT_PAGE_SHIFT 13 #else #define BNXT_PAGE_SHIFT 16 #endif #define BNXT_PAGE_SIZE (1 << BNXT_PAGE_SHIFT) #define MAX_CTX_PAGES (BNXT_PAGE_SIZE / 8) #define MAX_CTX_TOTAL_PAGES (MAX_CTX_PAGES * MAX_CTX_PAGES) struct bnxt_ring_mem_info { int nr_pages; int page_size; uint16_t flags; #define BNXT_RMEM_VALID_PTE_FLAG 1 #define BNXT_RMEM_RING_PTE_FLAG 2 #define BNXT_RMEM_USE_FULL_PAGE_FLAG 4 uint16_t depth; struct bnxt_ctx_mem_type *ctx_mem; struct iflib_dma_info *pg_arr; struct iflib_dma_info pg_tbl; int vmem_size; void **vmem; }; struct bnxt_ctx_pg_info { uint32_t entries; uint32_t nr_pages; struct iflib_dma_info ctx_arr[MAX_CTX_PAGES]; struct bnxt_ring_mem_info ring_mem; struct bnxt_ctx_pg_info **ctx_pg_tbl; }; #define BNXT_MAX_TQM_SP_RINGS 1 #define BNXT_MAX_TQM_FP_LEGACY_RINGS 8 #define BNXT_MAX_TQM_FP_RINGS 9 #define BNXT_MAX_TQM_LEGACY_RINGS \ (BNXT_MAX_TQM_SP_RINGS + BNXT_MAX_TQM_FP_LEGACY_RINGS) #define BNXT_MAX_TQM_RINGS \ (BNXT_MAX_TQM_SP_RINGS + BNXT_MAX_TQM_FP_RINGS) #define BNXT_BACKING_STORE_CFG_LEGACY_LEN 256 #define BNXT_BACKING_STORE_CFG_LEN \ sizeof(struct hwrm_func_backing_store_cfg_input) #define BNXT_SET_CTX_PAGE_ATTR(attr) \ do { \ if (BNXT_PAGE_SIZE == 0x2000) \ attr = HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_SRQ_PG_SIZE_PG_8K; \ else if (BNXT_PAGE_SIZE == 0x10000) \ attr = HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_QPC_PG_SIZE_PG_64K; \ else \ attr = HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_QPC_PG_SIZE_PG_4K; \ } while (0) struct bnxt_ctx_mem_type { u16 type; u16 entry_size; u32 flags; #define BNXT_CTX_MEM_TYPE_VALID HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_FLAGS_TYPE_VALID u32 instance_bmap; u8 init_value; u8 entry_multiple; u16 init_offset; #define BNXT_CTX_INIT_INVALID_OFFSET 0xffff u32 max_entries; u32 min_entries; u8 split_entry_cnt; #define BNXT_MAX_SPLIT_ENTRY 4 union { struct { u32 qp_l2_entries; u32 qp_qp1_entries; }; u32 srq_l2_entries; u32 cq_l2_entries; u32 vnic_entries; struct { u32 mrav_av_entries; u32 mrav_num_entries_units; }; u32 split[BNXT_MAX_SPLIT_ENTRY]; }; struct bnxt_ctx_pg_info *pg_info; }; #define BNXT_CTX_QP HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_QP #define BNXT_CTX_SRQ HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SRQ #define BNXT_CTX_CQ HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_CQ #define BNXT_CTX_VNIC HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_VNIC #define BNXT_CTX_STAT HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_STAT #define BNXT_CTX_STQM HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SP_TQM_RING #define BNXT_CTX_FTQM HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_FP_TQM_RING #define BNXT_CTX_MRAV HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_MRAV #define BNXT_CTX_TIM HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_TIM #define BNXT_CTX_TKC HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_TKC #define BNXT_CTX_RKC HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_RKC #define BNXT_CTX_MTQM HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_MP_TQM_RING #define BNXT_CTX_SQDBS HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SQ_DB_SHADOW #define BNXT_CTX_RQDBS HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_RQ_DB_SHADOW #define BNXT_CTX_SRQDBS HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SRQ_DB_SHADOW #define BNXT_CTX_CQDBS HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_CQ_DB_SHADOW #define BNXT_CTX_QTKC HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_QUIC_TKC #define BNXT_CTX_QRKC HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_QUIC_RKC #define BNXT_CTX_MAX (BNXT_CTX_QRKC + 1) struct bnxt_ctx_mem_info { u8 tqm_fp_rings_count; u32 flags; #define BNXT_CTX_FLAG_INITED 0x01 struct bnxt_ctx_mem_type ctx_arr[BNXT_CTX_MAX]; }; struct bnxt_hw_resc { uint16_t min_rsscos_ctxs; uint16_t max_rsscos_ctxs; uint16_t min_cp_rings; uint16_t max_cp_rings; uint16_t resv_cp_rings; uint16_t min_tx_rings; uint16_t max_tx_rings; uint16_t resv_tx_rings; uint16_t max_tx_sch_inputs; uint16_t min_rx_rings; uint16_t max_rx_rings; uint16_t resv_rx_rings; uint16_t min_hw_ring_grps; uint16_t max_hw_ring_grps; uint16_t resv_hw_ring_grps; uint16_t min_l2_ctxs; uint16_t max_l2_ctxs; uint16_t min_vnics; uint16_t max_vnics; uint16_t resv_vnics; uint16_t min_stat_ctxs; uint16_t max_stat_ctxs; uint16_t resv_stat_ctxs; uint16_t max_nqs; uint16_t max_irqs; uint16_t resv_irqs; }; enum bnxt_type_ets { BNXT_TYPE_ETS_TSA = 0, BNXT_TYPE_ETS_PRI2TC, BNXT_TYPE_ETS_TCBW, BNXT_TYPE_ETS_MAX }; static const char *const BNXT_ETS_TYPE_STR[] = { "tsa", "pri2tc", "tcbw", }; static const char *const BNXT_ETS_HELP_STR[] = { "X is 1 (strict), 0 (ets)", "TC values for pri 0 to 7", "TC BW values for pri 0 to 7, Sum should be 100", }; #define BNXT_HWRM_MAX_REQ_LEN (softc->hwrm_max_req_len) struct bnxt_softc_list { SLIST_ENTRY(bnxt_softc_list) next; struct bnxt_softc *softc; }; #ifndef BIT_ULL #define BIT_ULL(nr) (1ULL << (nr)) #endif struct bnxt_aux_dev { struct auxiliary_device aux_dev; struct bnxt_en_dev *edev; int id; }; struct bnxt_msix_tbl { uint32_t entry; uint32_t vector; }; struct bnxt_softc { device_t dev; if_ctx_t ctx; if_softc_ctx_t scctx; if_shared_ctx_t sctx; if_t ifp; uint32_t domain; uint32_t bus; uint32_t slot; uint32_t function; uint32_t dev_fn; struct ifmedia *media; struct bnxt_ctx_mem_info *ctx_mem; struct bnxt_hw_resc hw_resc; struct bnxt_softc_list list; struct bnxt_bar_info hwrm_bar; struct bnxt_bar_info doorbell_bar; struct bnxt_link_info link_info; #define BNXT_FLAG_VF 0x0001 #define BNXT_FLAG_NPAR 0x0002 #define BNXT_FLAG_WOL_CAP 0x0004 #define BNXT_FLAG_SHORT_CMD 0x0008 #define BNXT_FLAG_FW_CAP_NEW_RM 0x0010 #define BNXT_FLAG_CHIP_P5 0x0020 #define BNXT_FLAG_TPA 0x0040 #define BNXT_FLAG_FW_CAP_EXT_STATS 0x0080 #define BNXT_FLAG_MULTI_HOST 0x0100 #define BNXT_FLAG_MULTI_ROOT 0x0200 #define BNXT_FLAG_ROCEV1_CAP 0x0400 #define BNXT_FLAG_ROCEV2_CAP 0x0800 #define BNXT_FLAG_ROCE_CAP (BNXT_FLAG_ROCEV1_CAP | BNXT_FLAG_ROCEV2_CAP) uint32_t flags; #define BNXT_STATE_LINK_CHANGE (0) #define BNXT_STATE_MAX (BNXT_STATE_LINK_CHANGE + 1) bitstr_t *state_bv; uint32_t total_irqs; struct bnxt_msix_tbl *irq_tbl; struct bnxt_func_info func; struct bnxt_func_qcfg fn_qcfg; struct bnxt_pf_info pf; struct bnxt_vf_info vf; uint16_t hwrm_cmd_seq; uint32_t hwrm_cmd_timeo; /* milliseconds */ struct iflib_dma_info hwrm_cmd_resp; struct iflib_dma_info hwrm_short_cmd_req_addr; /* Interrupt info for HWRM */ struct if_irq irq; struct mtx hwrm_lock; uint16_t hwrm_max_req_len; uint16_t hwrm_max_ext_req_len; uint32_t hwrm_spec_code; #define BNXT_MAX_QUEUE 8 uint8_t max_tc; uint8_t max_lltc; struct bnxt_queue_info tx_q_info[BNXT_MAX_QUEUE]; struct bnxt_queue_info rx_q_info[BNXT_MAX_QUEUE]; uint8_t tc_to_qidx[BNXT_MAX_QUEUE]; uint8_t tx_q_ids[BNXT_MAX_QUEUE]; uint8_t rx_q_ids[BNXT_MAX_QUEUE]; uint8_t tx_max_q; uint8_t rx_max_q; uint8_t is_asym_q; struct bnxt_ieee_ets *ieee_ets; struct bnxt_ieee_pfc *ieee_pfc; uint8_t dcbx_cap; uint8_t default_pri; uint8_t max_dscp_value; 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; struct tx_port_stats *tx_port_stats; struct iflib_dma_info hw_tx_port_stats_ext; struct iflib_dma_info hw_rx_port_stats_ext; struct tx_port_stats_ext *tx_port_stats_ext; struct rx_port_stats_ext *rx_port_stats_ext; + uint16_t fw_rx_stats_ext_size; + uint16_t fw_tx_stats_ext_size; + uint16_t hw_ring_stats_size; + + uint8_t tx_pri2cos_idx[8]; + uint8_t rx_pri2cos_idx[8]; + bool pri2cos_valid; + + uint64_t tx_bytes_pri[8]; + uint64_t tx_packets_pri[8]; + uint64_t rx_bytes_pri[8]; + uint64_t rx_packets_pri[8]; + + uint8_t port_count; int num_cp_rings; struct bnxt_cp_ring *nq_rings; struct bnxt_ring *tx_rings; struct bnxt_cp_ring *tx_cp_rings; struct iflib_dma_info tx_stats[BNXT_MAX_NUM_QUEUES]; int ntxqsets; struct bnxt_vnic_info vnic_info; struct bnxt_ring *ag_rings; struct bnxt_ring *rx_rings; struct bnxt_cp_ring *rx_cp_rings; struct bnxt_grp_info *grp_info; struct iflib_dma_info rx_stats[BNXT_MAX_NUM_QUEUES]; int nrxqsets; uint16_t rx_buf_size; struct bnxt_cp_ring def_cp_ring; struct bnxt_cp_ring def_nq_ring; struct iflib_dma_info def_cp_ring_mem; struct iflib_dma_info def_nq_ring_mem; struct grouptask def_cp_task; int db_size; int legacy_db_size; struct bnxt_doorbell_ops db_ops; struct sysctl_ctx_list hw_stats; struct sysctl_oid *hw_stats_oid; struct sysctl_ctx_list hw_lro_ctx; struct sysctl_oid *hw_lro_oid; struct sysctl_ctx_list flow_ctrl_ctx; struct sysctl_oid *flow_ctrl_oid; struct sysctl_ctx_list dcb_ctx; struct sysctl_oid *dcb_oid; struct bnxt_ver_info *ver_info; struct bnxt_nvram_info *nvm_info; bool wol; bool is_dev_init; struct bnxt_hw_lro hw_lro; uint8_t wol_filter_id; uint16_t rx_coal_usecs; uint16_t rx_coal_usecs_irq; uint16_t rx_coal_frames; uint16_t rx_coal_frames_irq; uint16_t tx_coal_usecs; uint16_t tx_coal_usecs_irq; uint16_t tx_coal_frames; uint16_t tx_coal_frames_irq; #define BNXT_USEC_TO_COAL_TIMER(x) ((x) * 25 / 2) #define BNXT_DEF_STATS_COAL_TICKS 1000000 #define BNXT_MIN_STATS_COAL_TICKS 250000 #define BNXT_MAX_STATS_COAL_TICKS 1000000 uint64_t fw_cap; #define BNXT_FW_CAP_SHORT_CMD BIT_ULL(0) #define BNXT_FW_CAP_LLDP_AGENT BIT_ULL(1) #define BNXT_FW_CAP_DCBX_AGENT BIT_ULL(2) #define BNXT_FW_CAP_NEW_RM BIT_ULL(3) #define BNXT_FW_CAP_IF_CHANGE BIT_ULL(4) #define BNXT_FW_CAP_LINK_ADMIN BIT_ULL(5) #define BNXT_FW_CAP_VF_RES_MIN_GUARANTEED BIT_ULL(6) #define BNXT_FW_CAP_KONG_MB_CHNL BIT_ULL(7) #define BNXT_FW_CAP_ADMIN_MTU BIT_ULL(8) #define BNXT_FW_CAP_ADMIN_PF BIT_ULL(9) #define BNXT_FW_CAP_OVS_64BIT_HANDLE BIT_ULL(10) #define BNXT_FW_CAP_TRUSTED_VF BIT_ULL(11) #define BNXT_FW_CAP_VF_VNIC_NOTIFY BIT_ULL(12) #define BNXT_FW_CAP_ERROR_RECOVERY BIT_ULL(13) #define BNXT_FW_CAP_PKG_VER BIT_ULL(14) #define BNXT_FW_CAP_CFA_ADV_FLOW BIT_ULL(15) #define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2 BIT_ULL(16) #define BNXT_FW_CAP_PCIE_STATS_SUPPORTED BIT_ULL(17) #define BNXT_FW_CAP_EXT_STATS_SUPPORTED BIT_ULL(18) #define BNXT_FW_CAP_SECURE_MODE BIT_ULL(19) #define BNXT_FW_CAP_ERR_RECOVER_RELOAD BIT_ULL(20) #define BNXT_FW_CAP_HOT_RESET BIT_ULL(21) #define BNXT_FW_CAP_CRASHDUMP BIT_ULL(23) #define BNXT_FW_CAP_VLAN_RX_STRIP BIT_ULL(24) #define BNXT_FW_CAP_VLAN_TX_INSERT BIT_ULL(25) #define BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED BIT_ULL(26) #define BNXT_FW_CAP_CFA_EEM BIT_ULL(27) #define BNXT_FW_CAP_DBG_QCAPS BIT_ULL(29) #define BNXT_FW_CAP_RING_MONITOR BIT_ULL(30) #define BNXT_FW_CAP_ECN_STATS BIT_ULL(31) #define BNXT_FW_CAP_TRUFLOW BIT_ULL(32) #define BNXT_FW_CAP_VF_CFG_FOR_PF BIT_ULL(33) #define BNXT_FW_CAP_PTP_PPS BIT_ULL(34) #define BNXT_FW_CAP_HOT_RESET_IF BIT_ULL(35) #define BNXT_FW_CAP_LIVEPATCH BIT_ULL(36) #define BNXT_FW_CAP_NPAR_1_2 BIT_ULL(37) #define BNXT_FW_CAP_RSS_HASH_TYPE_DELTA BIT_ULL(38) #define BNXT_FW_CAP_PTP_RTC BIT_ULL(39) #define BNXT_FW_CAP_TRUFLOW_EN BIT_ULL(40) #define BNXT_TRUFLOW_EN(bp) ((bp)->fw_cap & BNXT_FW_CAP_TRUFLOW_EN) #define BNXT_FW_CAP_RX_ALL_PKT_TS BIT_ULL(41) #define BNXT_FW_CAP_BACKING_STORE_V2 BIT_ULL(42) #define BNXT_FW_CAP_DBR_SUPPORTED BIT_ULL(43) #define BNXT_FW_CAP_GENERIC_STATS BIT_ULL(44) #define BNXT_FW_CAP_DBR_PACING_SUPPORTED BIT_ULL(45) #define BNXT_FW_CAP_PTP_PTM BIT_ULL(46) #define BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO BIT_ULL(47) #define BNXT_FW_CAP_ENABLE_RDMA_SRIOV BIT_ULL(48) #define BNXT_FW_CAP_RSS_TCAM BIT_ULL(49) uint32_t lpi_tmr_lo; uint32_t lpi_tmr_hi; /* copied from flags and flags2 in hwrm_port_phy_qcaps_output */ uint16_t phy_flags; #define BNXT_PHY_FL_EEE_CAP HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_EEE_SUPPORTED #define BNXT_PHY_FL_EXT_LPBK HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_EXTERNAL_LPBK_SUPPORTED #define BNXT_PHY_FL_AN_PHY_LPBK HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_AUTONEG_LPBK_SUPPORTED #define BNXT_PHY_FL_SHARED_PORT_CFG HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_SHARED_PHY_CFG_SUPPORTED #define BNXT_PHY_FL_PORT_STATS_NO_RESET HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_CUMULATIVE_COUNTERS_ON_RESET #define BNXT_PHY_FL_NO_PHY_LPBK HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_LOCAL_LPBK_NOT_SUPPORTED #define BNXT_PHY_FL_FW_MANAGED_LKDN HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_FW_MANAGED_LINK_DOWN #define BNXT_PHY_FL_NO_FCS HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_NO_FCS #define BNXT_PHY_FL_NO_PAUSE (HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS2_PAUSE_UNSUPPORTED << 8) #define BNXT_PHY_FL_NO_PFC (HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS2_PFC_UNSUPPORTED << 8) #define BNXT_PHY_FL_BANK_SEL (HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS2_BANK_ADDR_SUPPORTED << 8) struct bnxt_aux_dev *aux_dev; struct net_device *net_dev; struct mtx en_ops_lock; uint8_t port_partition_type; struct bnxt_en_dev *edev; unsigned long state; #define BNXT_STATE_OPEN 0 #define BNXT_STATE_IN_SP_TASK 1 #define BNXT_STATE_READ_STATS 2 #define BNXT_STATE_FW_RESET_DET 3 #define BNXT_STATE_IN_FW_RESET 4 #define BNXT_STATE_ABORT_ERR 5 #define BNXT_STATE_FW_FATAL_COND 6 #define BNXT_STATE_DRV_REGISTERED 7 #define BNXT_STATE_PCI_CHANNEL_IO_FROZEN 8 #define BNXT_STATE_NAPI_DISABLED 9 #define BNXT_STATE_L2_FILTER_RETRY 10 #define BNXT_STATE_FW_ACTIVATE 11 #define BNXT_STATE_RECOVER 12 #define BNXT_STATE_FW_NON_FATAL_COND 13 #define BNXT_STATE_FW_ACTIVATE_RESET 14 #define BNXT_STATE_HALF_OPEN 15 #define BNXT_NO_FW_ACCESS(bp) \ test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) struct pci_dev *pdev; int fw_reset_state; }; struct bnxt_filter_info { STAILQ_ENTRY(bnxt_filter_info) next; uint64_t fw_l2_filter_id; #define INVALID_MAC_INDEX ((uint16_t)-1) uint16_t mac_index; /* Filter Characteristics */ uint32_t flags; uint32_t enables; uint8_t l2_addr[ETHER_ADDR_LEN]; uint8_t l2_addr_mask[ETHER_ADDR_LEN]; uint16_t l2_ovlan; uint16_t l2_ovlan_mask; uint16_t l2_ivlan; uint16_t l2_ivlan_mask; uint8_t t_l2_addr[ETHER_ADDR_LEN]; uint8_t t_l2_addr_mask[ETHER_ADDR_LEN]; uint16_t t_l2_ovlan; uint16_t t_l2_ovlan_mask; uint16_t t_l2_ivlan; uint16_t t_l2_ivlan_mask; uint8_t tunnel_type; uint16_t mirror_vnic_id; uint32_t vni; uint8_t pri_hint; uint64_t l2_filter_id_hint; }; #define I2C_DEV_ADDR_A0 0xa0 #define BNXT_MAX_PHY_I2C_RESP_SIZE 64 /* Function declarations */ void bnxt_report_link(struct bnxt_softc *softc); bool bnxt_check_hwrm_version(struct bnxt_softc *softc); struct bnxt_softc *bnxt_find_dev(uint32_t domain, uint32_t bus, uint32_t dev_fn, char *name); int bnxt_read_sfp_module_eeprom_info(struct bnxt_softc *bp, uint16_t i2c_addr, uint16_t page_number, uint8_t bank, bool bank_sel_en, uint16_t start_addr, uint16_t data_length, uint8_t *buf); void bnxt_dcb_init(struct bnxt_softc *softc); void bnxt_dcb_free(struct bnxt_softc *softc); uint8_t bnxt_dcb_setdcbx(struct bnxt_softc *softc, uint8_t mode); uint8_t bnxt_dcb_getdcbx(struct bnxt_softc *softc); int bnxt_dcb_ieee_getets(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets); int bnxt_dcb_ieee_setets(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets); uint8_t get_phy_type(struct bnxt_softc *softc); int bnxt_dcb_ieee_getpfc(struct bnxt_softc *softc, struct bnxt_ieee_pfc *pfc); int bnxt_dcb_ieee_setpfc(struct bnxt_softc *softc, struct bnxt_ieee_pfc *pfc); int bnxt_dcb_ieee_setapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app); int bnxt_dcb_ieee_delapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app); int bnxt_dcb_ieee_listapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app, int *num_inputs); #endif /* _BNXT_H */ diff --git a/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c index 07834aeca363..677869484ace 100644 --- a/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c +++ b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c @@ -1,2916 +1,3065 @@ /*- * Broadcom NetXtreme-C/E network driver. * * Copyright (c) 2016 Broadcom, All Rights Reserved. * The term Broadcom refers to Broadcom Limited and/or its subsidiaries * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include "bnxt.h" #include "bnxt_hwrm.h" #include "hsi_struct_def.h" static int bnxt_hwrm_err_map(uint16_t err); static inline int _is_valid_ether_addr(uint8_t *); static inline void get_random_ether_addr(uint8_t *); static void bnxt_hwrm_set_link_common(struct bnxt_softc *softc, struct hwrm_port_phy_cfg_input *req); static void bnxt_hwrm_set_pause_common(struct bnxt_softc *softc, struct hwrm_port_phy_cfg_input *req); static void bnxt_hwrm_set_eee(struct bnxt_softc *softc, struct hwrm_port_phy_cfg_input *req); /* NVRam stuff has a five minute timeout */ #define BNXT_NVM_TIMEO (5 * 60 * 1000) +#define BNXT_RX_STATS_PRI_ENTRY(counter, n) \ + BNXT_RX_STATS_EXT_OFFSET(counter##_cos0) + +#define BNXT_TX_STATS_PRI_ENTRY(counter, n) \ + BNXT_TX_STATS_EXT_OFFSET(counter##_cos0) + +#define BNXT_RX_STATS_PRI_ENTRIES(counter) \ + BNXT_RX_STATS_PRI_ENTRY(counter, 0), \ + BNXT_RX_STATS_PRI_ENTRY(counter, 1), \ + BNXT_RX_STATS_PRI_ENTRY(counter, 2), \ + BNXT_RX_STATS_PRI_ENTRY(counter, 3), \ + BNXT_RX_STATS_PRI_ENTRY(counter, 4), \ + BNXT_RX_STATS_PRI_ENTRY(counter, 5), \ + BNXT_RX_STATS_PRI_ENTRY(counter, 6), \ + BNXT_RX_STATS_PRI_ENTRY(counter, 7) + +#define BNXT_TX_STATS_PRI_ENTRIES(counter) \ + BNXT_TX_STATS_PRI_ENTRY(counter, 0), \ + BNXT_TX_STATS_PRI_ENTRY(counter, 1), \ + BNXT_TX_STATS_PRI_ENTRY(counter, 2), \ + BNXT_TX_STATS_PRI_ENTRY(counter, 3), \ + BNXT_TX_STATS_PRI_ENTRY(counter, 4), \ + BNXT_TX_STATS_PRI_ENTRY(counter, 5), \ + BNXT_TX_STATS_PRI_ENTRY(counter, 6), \ + BNXT_TX_STATS_PRI_ENTRY(counter, 7) + + +long bnxt_rx_bytes_pri_arr_base_off[] = {BNXT_RX_STATS_PRI_ENTRIES(rx_bytes)}; +long bnxt_rx_pkts_pri_arr_base_off[] = {BNXT_RX_STATS_PRI_ENTRIES(rx_packets)}; +long bnxt_tx_bytes_pri_arr_base_off[] = {BNXT_TX_STATS_PRI_ENTRIES(tx_bytes)}; +long bnxt_tx_pkts_pri_arr_base_off[] = {BNXT_TX_STATS_PRI_ENTRIES(tx_packets)}; + static int bnxt_hwrm_err_map(uint16_t err) { int rc; switch (err) { case HWRM_ERR_CODE_SUCCESS: return 0; case HWRM_ERR_CODE_INVALID_PARAMS: case HWRM_ERR_CODE_INVALID_FLAGS: case HWRM_ERR_CODE_INVALID_ENABLES: return EINVAL; case HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED: return EACCES; case HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR: return ENOMEM; case HWRM_ERR_CODE_CMD_NOT_SUPPORTED: return ENOSYS; case HWRM_ERR_CODE_FAIL: return EIO; case HWRM_ERR_CODE_HWRM_ERROR: case HWRM_ERR_CODE_UNKNOWN_ERR: default: return EDOOFUS; } return rc; } int bnxt_alloc_hwrm_dma_mem(struct bnxt_softc *softc) { int rc; rc = iflib_dma_alloc(softc->ctx, PAGE_SIZE, &softc->hwrm_cmd_resp, BUS_DMA_NOWAIT); return rc; } void bnxt_free_hwrm_dma_mem(struct bnxt_softc *softc) { if (softc->hwrm_cmd_resp.idi_vaddr) iflib_dma_free(&softc->hwrm_cmd_resp); softc->hwrm_cmd_resp.idi_vaddr = NULL; return; } void bnxt_hwrm_cmd_hdr_init(struct bnxt_softc *softc, void *request, uint16_t req_type) { struct input *req = request; req->req_type = htole16(req_type); req->cmpl_ring = 0xffff; req->target_id = 0xffff; req->resp_addr = htole64(softc->hwrm_cmd_resp.idi_paddr); } int _hwrm_send_message(struct bnxt_softc *softc, void *msg, uint32_t msg_len) { struct input *req = msg; struct hwrm_err_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; uint32_t *data = msg; int i; uint8_t *valid; uint16_t err; uint16_t max_req_len = BNXT_HWRM_MAX_REQ_LEN; struct hwrm_short_input short_input = {0}; /* TODO: DMASYNC in here. */ req->seq_id = htole16(softc->hwrm_cmd_seq++); memset(resp, 0, PAGE_SIZE); if (BNXT_NO_FW_ACCESS(softc) && (req->req_type != HWRM_FUNC_RESET && req->req_type != HWRM_VER_GET)) return -EINVAL; if ((softc->flags & BNXT_FLAG_SHORT_CMD) || msg_len > BNXT_HWRM_MAX_REQ_LEN) { void *short_cmd_req = softc->hwrm_short_cmd_req_addr.idi_vaddr; uint16_t max_msg_len; /* Set boundary for maximum extended request length for short * cmd format. If passed up from device use the max supported * internal req length. */ max_msg_len = softc->hwrm_max_ext_req_len; memcpy(short_cmd_req, req, msg_len); if (msg_len < max_msg_len) memset((uint8_t *) short_cmd_req + msg_len, 0, max_msg_len - msg_len); short_input.req_type = req->req_type; short_input.signature = htole16(HWRM_SHORT_INPUT_SIGNATURE_SHORT_CMD); short_input.size = htole16(msg_len); short_input.req_addr = htole64(softc->hwrm_short_cmd_req_addr.idi_paddr); data = (uint32_t *)&short_input; msg_len = sizeof(short_input); /* Sync memory write before updating doorbell */ wmb(); max_req_len = BNXT_HWRM_SHORT_REQ_LEN; } /* Write request msg to hwrm channel */ for (i = 0; i < msg_len; i += 4) { bus_space_write_4(softc->hwrm_bar.tag, softc->hwrm_bar.handle, i, *data); data++; } /* Clear to the end of the request buffer */ for (i = msg_len; i < max_req_len; i += 4) bus_space_write_4(softc->hwrm_bar.tag, softc->hwrm_bar.handle, i, 0); /* Ring channel doorbell */ bus_space_write_4(softc->hwrm_bar.tag, softc->hwrm_bar.handle, 0x100, htole32(1)); /* Check if response len is updated */ for (i = 0; i < softc->hwrm_cmd_timeo; i++) { if (resp->resp_len && resp->resp_len <= 4096) break; DELAY(1000); } if (i >= softc->hwrm_cmd_timeo) { device_printf(softc->dev, "Timeout sending %s: (timeout: %u) seq: %d\n", GET_HWRM_REQ_TYPE(req->req_type), softc->hwrm_cmd_timeo, le16toh(req->seq_id)); return ETIMEDOUT; } /* Last byte of resp contains the valid key */ valid = (uint8_t *)resp + resp->resp_len - 1; for (i = 0; i < softc->hwrm_cmd_timeo; i++) { if (*valid == HWRM_RESP_VALID_KEY) break; DELAY(1000); } if (i >= softc->hwrm_cmd_timeo) { device_printf(softc->dev, "Timeout sending %s: " "(timeout: %u) msg {0x%x 0x%x} len:%d v: %d\n", GET_HWRM_REQ_TYPE(req->req_type), softc->hwrm_cmd_timeo, le16toh(req->req_type), le16toh(req->seq_id), msg_len, *valid); return ETIMEDOUT; } err = le16toh(resp->error_code); if (err) { /* HWRM_ERR_CODE_FAIL is a "normal" error, don't log */ if (err != HWRM_ERR_CODE_FAIL) { device_printf(softc->dev, "%s command returned %s error.\n", GET_HWRM_REQ_TYPE(req->req_type), GET_HWRM_ERROR_CODE(err)); } return bnxt_hwrm_err_map(err); } return 0; } int hwrm_send_message(struct bnxt_softc *softc, void *msg, uint32_t msg_len) { int rc; BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, msg, msg_len); BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_queue_qportcfg(struct bnxt_softc *softc, uint32_t path_dir) { int rc = 0; struct hwrm_queue_qportcfg_input req = {0}; struct hwrm_queue_qportcfg_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; uint8_t max_tc, max_lltc, *max_q; uint8_t queue_profile, queue_id; struct bnxt_queue_info *q_info; uint8_t i, j, *qptr, *q_ids; bool no_rdma; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_QPORTCFG); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto qportcfg_exit; if (!resp->max_configurable_queues) { rc = -EINVAL; goto qportcfg_exit; } if (resp->queue_cfg_info & HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_CFG_INFO_ASYM_CFG) { softc->is_asym_q = true; /* bnxt_init_cosq_names(softc, path_dir); */ } else { softc->is_asym_q = false; /* bnxt_free_stats_cosqnames_mem(softc); */ } max_tc = min_t(uint8_t, resp->max_configurable_queues, BNXT_MAX_QUEUE); max_lltc = resp->max_configurable_lossless_queues; /* * No RDMA support yet. * no_rdma = !(softc->flags & BNXT_FLAG_ROCE_CAP); */ no_rdma = true; qptr = &resp->queue_id0; if (path_dir == HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX) { q_info = softc->tx_q_info; q_ids = softc->tx_q_ids; max_q = &softc->tx_max_q; } else { q_info = softc->rx_q_info; q_ids = softc->rx_q_ids; max_q = &softc->rx_max_q; } for (i = 0, j = 0; i < max_tc; i++) { queue_id = *qptr; qptr++; queue_profile = *qptr; qptr++; q_info[j].queue_id = queue_id; q_info[j].queue_profile = queue_profile; q_ids[i] = queue_id; softc->tc_to_qidx[j] = j; if (!BNXT_CNPQ(q_info[j].queue_profile) || (no_rdma && BNXT_PF(softc))) j++; } *max_q = max_tc; max_tc = max_t(uint8_t, j, 1); softc->max_tc = softc->max_tc ? min(softc->max_tc, max_tc) : max_tc; softc->max_lltc = softc->max_lltc ? min(softc->max_lltc, max_lltc) : max_lltc; if (softc->max_lltc > softc->max_tc) softc->max_lltc = softc->max_tc; qportcfg_exit: BNXT_HWRM_UNLOCK(softc); return rc; } static int bnxt_alloc_all_ctx_pg_info(struct bnxt_softc *softc) { struct bnxt_ctx_mem_info *ctx = softc->ctx_mem; u16 type; for (type = 0; type < BNXT_CTX_MAX; type++) { struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type]; int n = 1; if (!ctxm->max_entries || ctxm->pg_info) continue; if (ctxm->instance_bmap) n = hweight32(ctxm->instance_bmap); ctxm->pg_info = kcalloc(n, sizeof(*ctxm->pg_info), GFP_KERNEL); if (!ctxm->pg_info) return -ENOMEM; } return 0; } static void bnxt_init_ctx_initializer(struct bnxt_ctx_mem_type *ctxm, u8 init_val, u8 init_offset, bool init_mask_set) { ctxm->init_value = init_val; ctxm->init_offset = BNXT_CTX_INIT_INVALID_OFFSET; if (init_mask_set) ctxm->init_offset = init_offset * 4; else ctxm->init_value = 0; } int bnxt_hwrm_func_backing_store_qcaps(struct bnxt_softc *softc) { struct hwrm_func_backing_store_qcaps_input req = {0}; struct hwrm_func_backing_store_qcaps_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc; if (softc->hwrm_spec_code < 0x10902 || softc->ctx_mem) return 0; if (BNXT_VF(softc)) return 0; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_BACKING_STORE_QCAPS); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (!rc) { struct bnxt_ctx_mem_type *ctxm; struct bnxt_ctx_mem_info *ctx; u8 init_val, init_idx = 0; u16 init_mask; ctx = softc->ctx_mem; if (!ctx) { ctx = malloc(sizeof(*ctx), M_DEVBUF, M_NOWAIT | M_ZERO); if (!ctx) { rc = -ENOMEM; goto ctx_err; } softc->ctx_mem = ctx; } init_val = resp->ctx_kind_initializer; init_mask = le16_to_cpu(resp->ctx_init_mask); ctxm = &ctx->ctx_arr[BNXT_CTX_QP]; ctxm->max_entries = le32_to_cpu(resp->qp_max_entries); ctxm->qp_qp1_entries = le16_to_cpu(resp->qp_min_qp1_entries); ctxm->qp_l2_entries = le16_to_cpu(resp->qp_max_l2_entries); ctxm->entry_size = le16_to_cpu(resp->qp_entry_size); bnxt_init_ctx_initializer(ctxm, init_val, resp->qp_init_offset, (init_mask & (1 << init_idx++)) != 0); ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ]; ctxm->srq_l2_entries = le16_to_cpu(resp->srq_max_l2_entries); ctxm->max_entries = le32_to_cpu(resp->srq_max_entries); ctxm->entry_size = le16_to_cpu(resp->srq_entry_size); bnxt_init_ctx_initializer(ctxm, init_val, resp->srq_init_offset, (init_mask & (1 << init_idx++)) != 0); ctxm = &ctx->ctx_arr[BNXT_CTX_CQ]; ctxm->cq_l2_entries = le16_to_cpu(resp->cq_max_l2_entries); ctxm->max_entries = le32_to_cpu(resp->cq_max_entries); ctxm->entry_size = le16_to_cpu(resp->cq_entry_size); bnxt_init_ctx_initializer(ctxm, init_val, resp->cq_init_offset, (init_mask & (1 << init_idx++)) != 0); ctxm = &ctx->ctx_arr[BNXT_CTX_VNIC]; ctxm->vnic_entries = le32_to_cpu(resp->vnic_max_vnic_entries); ctxm->max_entries = ctxm->vnic_entries + le16_to_cpu(resp->vnic_max_ring_table_entries); ctxm->entry_size = le16_to_cpu(resp->vnic_entry_size); bnxt_init_ctx_initializer(ctxm, init_val, resp->vnic_init_offset, (init_mask & (1 << init_idx++)) != 0); ctxm = &ctx->ctx_arr[BNXT_CTX_STAT]; ctxm->max_entries = le32_to_cpu(resp->stat_max_entries); ctxm->entry_size = le16_to_cpu(resp->stat_entry_size); bnxt_init_ctx_initializer(ctxm, init_val, resp->stat_init_offset, (init_mask & (1 << init_idx++)) != 0); ctxm = &ctx->ctx_arr[BNXT_CTX_STQM]; ctxm->entry_size = le16_to_cpu(resp->tqm_entry_size); ctxm->min_entries = le32_to_cpu(resp->tqm_min_entries_per_ring); ctxm->max_entries = le32_to_cpu(resp->tqm_max_entries_per_ring); ctxm->entry_multiple = resp->tqm_entries_multiple; if (!ctxm->entry_multiple) ctxm->entry_multiple = 1; memcpy(&ctx->ctx_arr[BNXT_CTX_FTQM], ctxm, sizeof(*ctxm)); ctxm = &ctx->ctx_arr[BNXT_CTX_MRAV]; ctxm->max_entries = le32_to_cpu(resp->mrav_max_entries); ctxm->entry_size = le16_to_cpu(resp->mrav_entry_size); ctxm->mrav_num_entries_units = le16_to_cpu(resp->mrav_num_entries_units); bnxt_init_ctx_initializer(ctxm, init_val, resp->mrav_init_offset, (init_mask & (1 << init_idx++)) != 0); ctxm = &ctx->ctx_arr[BNXT_CTX_TIM]; ctxm->entry_size = le16_to_cpu(resp->tim_entry_size); ctxm->max_entries = le32_to_cpu(resp->tim_max_entries); ctx->tqm_fp_rings_count = resp->tqm_fp_rings_count; if (!ctx->tqm_fp_rings_count) ctx->tqm_fp_rings_count = softc->tx_max_q; else if (ctx->tqm_fp_rings_count > BNXT_MAX_TQM_FP_LEGACY_RINGS) ctx->tqm_fp_rings_count = BNXT_MAX_TQM_FP_LEGACY_RINGS; if (ctx->tqm_fp_rings_count == BNXT_MAX_TQM_FP_LEGACY_RINGS && softc->hwrm_max_ext_req_len >= BNXT_BACKING_STORE_CFG_LEN) { ctx->tqm_fp_rings_count += resp->tqm_fp_rings_count_ext; if (ctx->tqm_fp_rings_count > BNXT_MAX_TQM_FP_RINGS) ctx->tqm_fp_rings_count = BNXT_MAX_TQM_FP_RINGS; } ctxm = &ctx->ctx_arr[BNXT_CTX_FTQM]; memcpy(ctxm, &ctx->ctx_arr[BNXT_CTX_STQM], sizeof(*ctxm)); ctxm->instance_bmap = (1 << ctx->tqm_fp_rings_count) - 1; rc = bnxt_alloc_all_ctx_pg_info(softc); } else { rc = 0; } ctx_err: BNXT_HWRM_UNLOCK(softc); return rc; } #define HWRM_FUNC_BACKING_STORE_CFG_INPUT_DFLT_ENABLES \ (HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_QP | \ HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_SRQ | \ HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_CQ | \ HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_VNIC | \ HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_STAT) static void bnxt_hwrm_set_pg_attr(struct bnxt_ring_mem_info *rmem, uint8_t *pg_attr, uint64_t *pg_dir) { uint8_t pg_size = 0; if (BNXT_PAGE_SHIFT == 13) pg_size = 1 << 4; else if (BNXT_PAGE_SIZE == 16) pg_size = 2 << 4; *pg_attr = pg_size; if (rmem->depth >= 1) { if (rmem->depth == 2) *pg_attr |= HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_LVL_2; else *pg_attr |= HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_LVL_1; *pg_dir = htole64(rmem->pg_tbl.idi_paddr); } else { *pg_dir = htole64(rmem->pg_arr[0].idi_paddr); } } int bnxt_hwrm_func_backing_store_cfg(struct bnxt_softc *softc, uint32_t enables) { struct hwrm_func_backing_store_cfg_input req = {0}; struct bnxt_ctx_mem_info *ctx = softc->ctx_mem; struct bnxt_ctx_pg_info *ctx_pg; struct bnxt_ctx_mem_type *ctxm; u32 req_len = sizeof(req); __le32 *num_entries; u32 ena, flags = 0; __le64 *pg_dir; u8 *pg_attr; int i; if (!ctx) return 0; if (req_len > softc->hwrm_max_ext_req_len) req_len = BNXT_BACKING_STORE_CFG_LEGACY_LEN; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_BACKING_STORE_CFG); req.enables = htole32(enables); if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_QP) { ctxm = &ctx->ctx_arr[BNXT_CTX_QP]; ctx_pg = ctxm->pg_info; req.qp_num_entries = cpu_to_le32(ctx_pg->entries); req.qp_num_qp1_entries = cpu_to_le16(ctxm->qp_qp1_entries); req.qp_num_l2_entries = cpu_to_le16(ctxm->qp_l2_entries); req.qp_entry_size = cpu_to_le16(ctxm->entry_size); bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, &req.qpc_pg_size_qpc_lvl, &req.qpc_page_dir); } if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_SRQ) { ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ]; ctx_pg = ctxm->pg_info; req.srq_num_entries = cpu_to_le32(ctx_pg->entries); req.srq_num_l2_entries = cpu_to_le16(ctxm->srq_l2_entries); req.srq_entry_size = cpu_to_le16(ctxm->entry_size); bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, &req.srq_pg_size_srq_lvl, &req.srq_page_dir); } if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_CQ) { ctxm = &ctx->ctx_arr[BNXT_CTX_CQ]; ctx_pg = ctxm->pg_info; req.cq_num_entries = cpu_to_le32(ctx_pg->entries); req.cq_num_l2_entries = cpu_to_le16(ctxm->cq_l2_entries); req.cq_entry_size = cpu_to_le16(ctxm->entry_size); bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, &req.cq_pg_size_cq_lvl, &req.cq_page_dir); } if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_MRAV) { ctxm = &ctx->ctx_arr[BNXT_CTX_MRAV]; ctx_pg = ctxm->pg_info; req.mrav_num_entries = cpu_to_le32(ctx_pg->entries); if (ctxm->mrav_num_entries_units) flags |= HWRM_FUNC_BACKING_STORE_CFG_INPUT_FLAGS_MRAV_RESERVATION_SPLIT; req.mrav_entry_size = cpu_to_le16(ctxm->entry_size); bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, &req.mrav_pg_size_mrav_lvl, &req.mrav_page_dir); } if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TIM) { ctxm = &ctx->ctx_arr[BNXT_CTX_TIM]; ctx_pg = ctxm->pg_info; req.tim_num_entries = cpu_to_le32(ctx_pg->entries); req.tim_entry_size = cpu_to_le16(ctxm->entry_size); bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, &req.tim_pg_size_tim_lvl, &req.tim_page_dir); } if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_VNIC) { ctxm = &ctx->ctx_arr[BNXT_CTX_VNIC]; ctx_pg = ctxm->pg_info; req.vnic_num_vnic_entries = cpu_to_le16(ctxm->vnic_entries); req.vnic_num_ring_table_entries = cpu_to_le16(ctxm->max_entries - ctxm->vnic_entries); req.vnic_entry_size = cpu_to_le16(ctxm->entry_size); bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, &req.vnic_pg_size_vnic_lvl, &req.vnic_page_dir); } if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_STAT) { ctxm = &ctx->ctx_arr[BNXT_CTX_STAT]; ctx_pg = ctxm->pg_info; req.stat_num_entries = cpu_to_le32(ctxm->max_entries); req.stat_entry_size = cpu_to_le16(ctxm->entry_size); bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, &req.stat_pg_size_stat_lvl, &req.stat_page_dir); } ctxm = &ctx->ctx_arr[BNXT_CTX_STQM]; for (i = 0, num_entries = &req.tqm_sp_num_entries, pg_attr = &req.tqm_sp_pg_size_tqm_sp_lvl, pg_dir = &req.tqm_sp_page_dir, ena = HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_SP, ctx_pg = ctxm->pg_info; i < BNXT_MAX_TQM_LEGACY_RINGS; ctx_pg = &ctx->ctx_arr[BNXT_CTX_FTQM].pg_info[i], i++, num_entries++, pg_attr++, pg_dir++, ena <<= 1) { if (!(enables & ena)) continue; req.tqm_entry_size = cpu_to_le16(ctxm->entry_size); *num_entries = cpu_to_le32(ctx_pg->entries); bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir); } if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING8) { pg_attr = &req.tqm_ring8_pg_size_tqm_ring_lvl; pg_dir = &req.tqm_ring8_page_dir; ctx_pg = &ctx->ctx_arr[BNXT_CTX_FTQM].pg_info[8]; req.tqm_ring8_num_entries = cpu_to_le32(ctx_pg->entries); bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir); } req.flags = cpu_to_le32(flags); return hwrm_send_message(softc, &req, sizeof(req)); } int bnxt_hwrm_func_resc_qcaps(struct bnxt_softc *softc, bool all) { struct hwrm_func_resource_qcaps_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; struct hwrm_func_resource_qcaps_input req = {0}; struct bnxt_hw_resc *hw_resc = &softc->hw_resc; int rc; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_RESOURCE_QCAPS); req.fid = htole16(0xffff); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) { rc = -EIO; goto hwrm_func_resc_qcaps_exit; } hw_resc->max_tx_sch_inputs = le16toh(resp->max_tx_scheduler_inputs); if (!all) goto hwrm_func_resc_qcaps_exit; hw_resc->min_rsscos_ctxs = le16toh(resp->min_rsscos_ctx); hw_resc->max_rsscos_ctxs = le16toh(resp->max_rsscos_ctx); hw_resc->min_cp_rings = le16toh(resp->min_cmpl_rings); hw_resc->max_cp_rings = le16toh(resp->max_cmpl_rings); hw_resc->min_tx_rings = le16toh(resp->min_tx_rings); hw_resc->max_tx_rings = le16toh(resp->max_tx_rings); hw_resc->min_rx_rings = le16toh(resp->min_rx_rings); hw_resc->max_rx_rings = le16toh(resp->max_rx_rings); hw_resc->min_hw_ring_grps = le16toh(resp->min_hw_ring_grps); hw_resc->max_hw_ring_grps = le16toh(resp->max_hw_ring_grps); hw_resc->min_l2_ctxs = le16toh(resp->min_l2_ctxs); hw_resc->max_l2_ctxs = le16toh(resp->max_l2_ctxs); hw_resc->min_vnics = le16toh(resp->min_vnics); hw_resc->max_vnics = le16toh(resp->max_vnics); hw_resc->min_stat_ctxs = le16toh(resp->min_stat_ctx); hw_resc->max_stat_ctxs = le16toh(resp->max_stat_ctx); if (BNXT_CHIP_P5(softc)) { hw_resc->max_nqs = le16toh(resp->max_msix); hw_resc->max_hw_ring_grps = hw_resc->max_rx_rings; } hwrm_func_resc_qcaps_exit: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt_softc *softc, struct bnxt_ctx_mem_type *ctxm, bool last) { struct hwrm_func_backing_store_cfg_v2_input req = {0}; u32 instance_bmap = ctxm->instance_bmap; int i, j, rc = 0, n = 1; __le32 *p; if (!(ctxm->flags & BNXT_CTX_MEM_TYPE_VALID) || !ctxm->pg_info) return 0; if (instance_bmap) n = hweight32(ctxm->instance_bmap); else instance_bmap = 1; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_BACKING_STORE_CFG_V2); req.type = cpu_to_le16(ctxm->type); req.entry_size = cpu_to_le16(ctxm->entry_size); for (i = 0, p = &req.split_entry_0; i < ctxm->split_entry_cnt; i++) p[i] = cpu_to_le32(ctxm->split[i]); for (i = 0, j = 0; j < n && !rc; i++) { struct bnxt_ctx_pg_info *ctx_pg; if (!(instance_bmap & (1 << i))) continue; req.instance = cpu_to_le16(i); ctx_pg = &ctxm->pg_info[j++]; if (!ctx_pg->entries) continue; req.num_entries = cpu_to_le32(ctx_pg->entries); bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, &req.page_size_pbl_level, &req.page_dir); if (last && j == (n - 1)) req.flags = cpu_to_le32(HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_FLAGS_BS_CFG_ALL_DONE); rc = hwrm_send_message(softc, &req, sizeof(req)); } return rc; } int bnxt_hwrm_passthrough(struct bnxt_softc *softc, void *req, uint32_t req_len, void *resp, uint32_t resp_len, uint32_t app_timeout) { int rc = 0; void *output = (void *)softc->hwrm_cmd_resp.idi_vaddr; struct input *input = req; uint32_t old_timeo; input->resp_addr = htole64(softc->hwrm_cmd_resp.idi_paddr); BNXT_HWRM_LOCK(softc); old_timeo = softc->hwrm_cmd_timeo; if (input->req_type == HWRM_NVM_INSTALL_UPDATE) softc->hwrm_cmd_timeo = BNXT_NVM_TIMEO; else softc->hwrm_cmd_timeo = max(app_timeout, softc->hwrm_cmd_timeo); rc = _hwrm_send_message(softc, req, req_len); softc->hwrm_cmd_timeo = old_timeo; if (rc) { device_printf(softc->dev, "%s: %s command failed with rc: 0x%x\n", __FUNCTION__, GET_HWRM_REQ_TYPE(input->req_type), rc); goto fail; } memcpy(resp, output, resp_len); fail: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_ver_get(struct bnxt_softc *softc) { struct hwrm_ver_get_input req = {0}; struct hwrm_ver_get_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc; const char nastr[] = ""; const char naver[] = ""; uint32_t dev_caps_cfg; uint16_t fw_maj, fw_min, fw_bld, fw_rsv, len; softc->hwrm_max_req_len = HWRM_MAX_REQ_LEN; softc->hwrm_cmd_timeo = 1000; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VER_GET); req.hwrm_intf_maj = HWRM_VERSION_MAJOR; req.hwrm_intf_min = HWRM_VERSION_MINOR; req.hwrm_intf_upd = HWRM_VERSION_UPDATE; BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; snprintf(softc->ver_info->hwrm_if_ver, BNXT_VERSTR_SIZE, "%d.%d.%d", resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, resp->hwrm_intf_upd_8b); softc->ver_info->hwrm_if_major = resp->hwrm_intf_maj_8b; softc->ver_info->hwrm_if_minor = resp->hwrm_intf_min_8b; softc->ver_info->hwrm_if_update = resp->hwrm_intf_upd_8b; strlcpy(softc->ver_info->driver_hwrm_if_ver, HWRM_VERSION_STR, BNXT_VERSTR_SIZE); strlcpy(softc->ver_info->hwrm_fw_name, resp->hwrm_fw_name, BNXT_NAME_SIZE); softc->hwrm_spec_code = resp->hwrm_intf_maj_8b << 16 | resp->hwrm_intf_min_8b << 8 | resp->hwrm_intf_upd_8b; if (resp->hwrm_intf_maj_8b < 1) { device_printf(softc->dev, "HWRM interface %d.%d.%d is older " "than 1.0.0.\n", resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, resp->hwrm_intf_upd_8b); device_printf(softc->dev, "Please update firmware with HWRM " "interface 1.0.0 or newer.\n"); } if (resp->mgmt_fw_major == 0 && resp->mgmt_fw_minor == 0 && resp->mgmt_fw_build == 0) { strlcpy(softc->ver_info->mgmt_fw_ver, naver, BNXT_VERSTR_SIZE); strlcpy(softc->ver_info->mgmt_fw_name, nastr, BNXT_NAME_SIZE); } else { snprintf(softc->ver_info->mgmt_fw_ver, FW_VER_STR_LEN, "%d.%d.%d.%d", resp->mgmt_fw_major, resp->mgmt_fw_minor, resp->mgmt_fw_build, resp->mgmt_fw_patch); strlcpy(softc->ver_info->mgmt_fw_name, resp->mgmt_fw_name, BNXT_NAME_SIZE); } if (resp->netctrl_fw_major == 0 && resp->netctrl_fw_minor == 0 && resp->netctrl_fw_build == 0) { strlcpy(softc->ver_info->netctrl_fw_ver, naver, BNXT_VERSTR_SIZE); strlcpy(softc->ver_info->netctrl_fw_name, nastr, BNXT_NAME_SIZE); } else { snprintf(softc->ver_info->netctrl_fw_ver, FW_VER_STR_LEN, "%d.%d.%d.%d", resp->netctrl_fw_major, resp->netctrl_fw_minor, resp->netctrl_fw_build, resp->netctrl_fw_patch); strlcpy(softc->ver_info->netctrl_fw_name, resp->netctrl_fw_name, BNXT_NAME_SIZE); } if (resp->roce_fw_major == 0 && resp->roce_fw_minor == 0 && resp->roce_fw_build == 0) { strlcpy(softc->ver_info->roce_fw_ver, naver, BNXT_VERSTR_SIZE); strlcpy(softc->ver_info->roce_fw_name, nastr, BNXT_NAME_SIZE); } else { snprintf(softc->ver_info->roce_fw_ver, BNXT_VERSTR_SIZE, "%d.%d.%d.%d", resp->roce_fw_major, resp->roce_fw_minor, resp->roce_fw_build, resp->roce_fw_patch); strlcpy(softc->ver_info->roce_fw_name, resp->roce_fw_name, BNXT_NAME_SIZE); } fw_maj = le32toh(resp->hwrm_fw_major); if (softc->hwrm_spec_code > 0x10803 && fw_maj) { fw_min = le16toh(resp->hwrm_fw_minor); fw_bld = le16toh(resp->hwrm_fw_build); fw_rsv = le16toh(resp->hwrm_fw_patch); len = FW_VER_STR_LEN; } else { fw_maj = resp->hwrm_fw_maj_8b; fw_min = resp->hwrm_fw_min_8b; fw_bld = resp->hwrm_fw_bld_8b; fw_rsv = resp->hwrm_fw_rsvd_8b; len = BC_HWRM_STR_LEN; } softc->ver_info->fw_ver_code = BNXT_FW_VER_CODE(fw_maj, fw_min, fw_bld, fw_rsv); snprintf (softc->ver_info->fw_ver_str, len, "%d.%d.%d.%d", fw_maj, fw_min, fw_bld, fw_rsv); if (strlen(resp->active_pkg_name)) { int fw_ver_len = strlen (softc->ver_info->fw_ver_str); snprintf(softc->ver_info->fw_ver_str + fw_ver_len, FW_VER_STR_LEN - fw_ver_len - 1, "/pkg %s", resp->active_pkg_name); softc->fw_cap |= BNXT_FW_CAP_PKG_VER; } softc->ver_info->chip_num = le16toh(resp->chip_num); softc->ver_info->chip_rev = resp->chip_rev; softc->ver_info->chip_metal = resp->chip_metal; softc->ver_info->chip_bond_id = resp->chip_bond_id; softc->ver_info->chip_type = resp->chip_platform_type; if (resp->hwrm_intf_maj_8b >= 1) { softc->hwrm_max_req_len = le16toh(resp->max_req_win_len); softc->hwrm_max_ext_req_len = le16toh(resp->max_ext_req_len); } softc->hwrm_cmd_timeo = le16toh(resp->def_req_timeout); if (!softc->hwrm_cmd_timeo) softc->hwrm_cmd_timeo = DFLT_HWRM_CMD_TIMEOUT; dev_caps_cfg = le32toh(resp->dev_caps_cfg); if ((dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) && (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_REQUIRED)) softc->flags |= BNXT_FLAG_SHORT_CMD; if ((dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) && (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_REQUIRED)) softc->fw_cap |= BNXT_FW_CAP_SHORT_CMD; if (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_KONG_MB_CHNL_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_KONG_MB_CHNL; if (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_FLOW_HANDLE_64BIT_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_OVS_64BIT_HANDLE; if (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_TRUSTED_VF_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_TRUSTED_VF; if (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_ADV_FLOW_MGNT_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_CFA_ADV_FLOW; if (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_EEM_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_CFA_EEM; if (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_TRUFLOW_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_TRUFLOW_EN; fail: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_func_drv_rgtr(struct bnxt_softc *softc) { struct hwrm_func_drv_rgtr_input req = {0}; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_DRV_RGTR); req.enables = htole32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER | HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_OS_TYPE); req.os_type = htole16(HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_FREEBSD); req.ver_maj = HWRM_VERSION_MAJOR; req.ver_min = HWRM_VERSION_MINOR; req.ver_upd = HWRM_VERSION_UPDATE; return hwrm_send_message(softc, &req, sizeof(req)); } int bnxt_hwrm_func_drv_unrgtr(struct bnxt_softc *softc, bool shutdown) { struct hwrm_func_drv_unrgtr_input req = {0}; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_DRV_UNRGTR); if (shutdown == true) req.flags |= HWRM_FUNC_DRV_UNRGTR_INPUT_FLAGS_PREPARE_FOR_SHUTDOWN; return hwrm_send_message(softc, &req, sizeof(req)); } static inline int _is_valid_ether_addr(uint8_t *addr) { char zero_addr[6] = { 0, 0, 0, 0, 0, 0 }; if ((addr[0] & 1) || (!bcmp(addr, zero_addr, ETHER_ADDR_LEN))) return (FALSE); return (TRUE); } static inline void get_random_ether_addr(uint8_t *addr) { uint8_t temp[ETHER_ADDR_LEN]; arc4rand(&temp, sizeof(temp), 0); temp[0] &= 0xFE; temp[0] |= 0x02; bcopy(temp, addr, sizeof(temp)); } int bnxt_hwrm_func_qcaps(struct bnxt_softc *softc) { int rc = 0; struct hwrm_func_qcaps_input req = {0}; struct hwrm_func_qcaps_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; struct bnxt_func_info *func = &softc->func; uint32_t flags, flags_ext, flags_ext2; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_QCAPS); req.fid = htole16(0xffff); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; flags = htole32(resp->flags); if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_WOL_MAGICPKT_SUPPORTED) softc->flags |= BNXT_FLAG_WOL_CAP; if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED) softc->flags |= BNXT_FLAG_FW_CAP_EXT_STATS; /* Enable RoCE only on Thor devices */ if (BNXT_CHIP_P5(softc)) { if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ROCE_V1_SUPPORTED) softc->flags |= BNXT_FLAG_ROCEV1_CAP; if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ROCE_V2_SUPPORTED) softc->flags |= BNXT_FLAG_ROCEV2_CAP; } if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_LINK_ADMIN_STATUS_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_LINK_ADMIN; if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ADMIN_PF_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_ADMIN_PF; if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_HOT_RESET_CAPABLE) softc->fw_cap |= BNXT_FW_CAP_HOT_RESET; if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERROR_RECOVERY_CAPABLE) softc->fw_cap |= BNXT_FW_CAP_ERROR_RECOVERY; if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PCIE_STATS_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_PCIE_STATS_SUPPORTED; if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_EXT_STATS_SUPPORTED; if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD) softc->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD; if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_NOTIFY_VF_DEF_VNIC_CHNG_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_VF_VNIC_NOTIFY; if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_CRASHDUMP_CMD_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_CRASHDUMP; if (!(flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_VLAN_ACCELERATION_TX_DISABLED)) softc->fw_cap |= BNXT_FW_CAP_VLAN_TX_INSERT; if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_DBG_QCAPS_CMD_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_DBG_QCAPS; flags_ext = htole32(resp->flags_ext); if (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_EXT_HW_STATS_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED; if (BNXT_PF(softc) && (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_ECN_STATS_SUPPORTED)) softc->fw_cap |= BNXT_FW_CAP_ECN_STATS; if (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PTP_PPS_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_PTP_PPS; if (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PTP_PTM_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_PTP_PTM; if (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PTP_64BIT_RTC_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_PTP_RTC; if (BNXT_PF(softc) && (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_HOT_RESET_IF_SUPPORT)) softc->fw_cap |= BNXT_FW_CAP_HOT_RESET_IF; if (BNXT_PF(softc) && (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_FW_LIVEPATCH_SUPPORTED)) softc->fw_cap |= BNXT_FW_CAP_LIVEPATCH; if (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_NPAR_1_2_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_NPAR_1_2; if (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_BS_V2_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_BACKING_STORE_V2; if (BNXT_PF(softc) && (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_VF_CFG_ASYNC_FOR_PF_SUPPORTED)) softc->fw_cap |= BNXT_FW_CAP_VF_CFG_FOR_PF; flags_ext2 = htole32(resp->flags_ext2); if (flags_ext2 & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_RX_ALL_PKTS_TIMESTAMPS_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_RX_ALL_PKT_TS; if (flags_ext2 & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_SW_DBR_DROP_RECOVERY_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_DBR_SUPPORTED; if (flags_ext2 & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_DBR_PACING_EXT_SUPPORTED || flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_DBR_PACING_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_DBR_PACING_SUPPORTED; if (flags_ext2 & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_GENERIC_STATS_SUPPORTED) softc->fw_cap |= BNXT_FW_CAP_GENERIC_STATS; func->fw_fid = le16toh(resp->fid); memcpy(func->mac_addr, resp->mac_address, ETHER_ADDR_LEN); func->max_rsscos_ctxs = le16toh(resp->max_rsscos_ctx); func->max_cp_rings = le16toh(resp->max_cmpl_rings); func->max_tx_rings = le16toh(resp->max_tx_rings); func->max_rx_rings = le16toh(resp->max_rx_rings); func->max_hw_ring_grps = le32toh(resp->max_hw_ring_grps); if (!func->max_hw_ring_grps) func->max_hw_ring_grps = func->max_tx_rings; func->max_l2_ctxs = le16toh(resp->max_l2_ctxs); func->max_vnics = le16toh(resp->max_vnics); func->max_stat_ctxs = le16toh(resp->max_stat_ctx); if (BNXT_PF(softc)) { struct bnxt_pf_info *pf = &softc->pf; pf->port_id = le16toh(resp->port_id); pf->first_vf_id = le16toh(resp->first_vf_id); pf->max_vfs = le16toh(resp->max_vfs); pf->max_encap_records = le32toh(resp->max_encap_records); pf->max_decap_records = le32toh(resp->max_decap_records); pf->max_tx_em_flows = le32toh(resp->max_tx_em_flows); pf->max_tx_wm_flows = le32toh(resp->max_tx_wm_flows); pf->max_rx_em_flows = le32toh(resp->max_rx_em_flows); pf->max_rx_wm_flows = le32toh(resp->max_rx_wm_flows); } if (!_is_valid_ether_addr(func->mac_addr)) { device_printf(softc->dev, "Invalid ethernet address, generating random locally administered address\n"); get_random_ether_addr(func->mac_addr); } fail: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_func_qcfg(struct bnxt_softc *softc) { struct hwrm_func_qcfg_input req = {0}; struct hwrm_func_qcfg_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; struct bnxt_func_qcfg *fn_qcfg = &softc->fn_qcfg; uint32_t min_db_offset = 0; uint16_t flags; int rc; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_QCFG); req.fid = htole16(0xffff); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto end; fn_qcfg->alloc_completion_rings = le16toh(resp->alloc_cmpl_rings); fn_qcfg->alloc_tx_rings = le16toh(resp->alloc_tx_rings); fn_qcfg->alloc_rx_rings = le16toh(resp->alloc_rx_rings); fn_qcfg->alloc_vnics = le16toh(resp->alloc_vnics); switch (resp->port_partition_type) { case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_0: case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_2: case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_5: case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR2_0: softc->port_partition_type = resp->port_partition_type; break; } flags = le16toh(resp->flags); if (flags & (HWRM_FUNC_QCFG_OUTPUT_FLAGS_FW_DCBX_AGENT_ENABLED | HWRM_FUNC_QCFG_OUTPUT_FLAGS_FW_LLDP_AGENT_ENABLED)) { softc->fw_cap |= BNXT_FW_CAP_LLDP_AGENT; if (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_FW_DCBX_AGENT_ENABLED) softc->fw_cap |= BNXT_FW_CAP_DCBX_AGENT; } if (BNXT_PF(softc) && (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_HOST)) softc->flags |= BNXT_FLAG_MULTI_HOST; if (BNXT_PF(softc) && (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_ROOT)) softc->flags |= BNXT_FLAG_MULTI_ROOT; if (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_SECURE_MODE_ENABLED) softc->fw_cap |= BNXT_FW_CAP_SECURE_MODE; if (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_RING_MONITOR_ENABLED) softc->fw_cap |= BNXT_FW_CAP_RING_MONITOR; if (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_ENABLE_RDMA_SRIOV) softc->fw_cap |= BNXT_FW_CAP_ENABLE_RDMA_SRIOV; if (softc->db_size) goto end; softc->legacy_db_size = le16_to_cpu(resp->legacy_l2_db_size_kb) * 1024; if (BNXT_CHIP_P5(softc)) { if (BNXT_PF(softc)) min_db_offset = DB_PF_OFFSET_P5; else min_db_offset = DB_VF_OFFSET_P5; } softc->db_size = roundup2(le16_to_cpu(resp->l2_doorbell_bar_size_kb) * 1024, PAGE_SIZE); if (!softc->db_size || softc->db_size > pci_resource_len(softc->pdev, 2) || softc->db_size <= min_db_offset) softc->db_size = pci_resource_len(softc->pdev, 2); end: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_func_reset(struct bnxt_softc *softc) { struct hwrm_func_reset_input req = {0}; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_RESET); req.enables = 0; return hwrm_send_message(softc, &req, sizeof(req)); } static void bnxt_hwrm_set_link_common(struct bnxt_softc *softc, struct hwrm_port_phy_cfg_input *req) { struct bnxt_link_info *link_info = &softc->link_info; uint8_t autoneg = softc->link_info.autoneg; uint16_t fw_link_speed = softc->link_info.req_link_speed; if (autoneg & BNXT_AUTONEG_SPEED) { uint8_t phy_type = get_phy_type(softc); if (phy_type == HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASET || phy_type == HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET || phy_type == HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE) { req->auto_mode |= htole32(HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK); if (link_info->advertising) { req->enables |= htole32(HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED_MASK); req->auto_link_speed_mask = htole16(link_info->advertising); } } else { req->auto_mode |= HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ALL_SPEEDS; } req->enables |= htole32(HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE); req->flags |= htole32(HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESTART_AUTONEG); } else { req->flags |= htole32(HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE); if (link_info->force_pam4_speed_set_by_user) { req->force_pam4_link_speed = htole16(fw_link_speed); req->enables |= htole32(HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAM4_LINK_SPEED); link_info->force_pam4_speed_set_by_user = false; } else { req->force_link_speed = htole16(fw_link_speed); } } /* tell chimp that the setting takes effect immediately */ req->flags |= htole32(HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESET_PHY); } static void bnxt_hwrm_set_pause_common(struct bnxt_softc *softc, struct hwrm_port_phy_cfg_input *req) { struct bnxt_link_info *link_info = &softc->link_info; if (link_info->flow_ctrl.autoneg) { req->auto_pause = HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_AUTONEG_PAUSE; if (link_info->flow_ctrl.rx) req->auto_pause |= HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_RX; if (link_info->flow_ctrl.tx) req->auto_pause |= HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_TX; req->enables |= htole32(HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_PAUSE); } else { if (link_info->flow_ctrl.rx) req->force_pause |= HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_RX; if (link_info->flow_ctrl.tx) req->force_pause |= HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_TX; req->enables |= htole32(HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAUSE); req->auto_pause = req->force_pause; req->enables |= htole32(HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_PAUSE); } } /* JFV this needs interface connection */ static void bnxt_hwrm_set_eee(struct bnxt_softc *softc, struct hwrm_port_phy_cfg_input *req) { /* struct ethtool_eee *eee = &softc->eee; */ bool eee_enabled = false; if (eee_enabled) { #if 0 uint16_t eee_speeds; uint32_t flags = HWRM_PORT_PHY_CFG_INPUT_FLAGS_EEE_ENABLE; if (eee->tx_lpi_enabled) flags |= HWRM_PORT_PHY_CFG_INPUT_FLAGS_EEE_TX_LPI; req->flags |= htole32(flags); eee_speeds = bnxt_get_fw_auto_link_speeds(eee->advertised); req->eee_link_speed_mask = htole16(eee_speeds); req->tx_lpi_timer = htole32(eee->tx_lpi_timer); #endif } else { req->flags |= htole32(HWRM_PORT_PHY_CFG_INPUT_FLAGS_EEE_DISABLE); } } int bnxt_hwrm_set_link_setting(struct bnxt_softc *softc, bool set_pause, bool set_eee, bool set_link) { struct hwrm_port_phy_cfg_input req = {0}; int rc; if (softc->flags & BNXT_FLAG_NPAR) return ENOTSUP; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_PHY_CFG); if (set_pause) { bnxt_hwrm_set_pause_common(softc, &req); if (softc->link_info.flow_ctrl.autoneg) set_link = true; } if (set_link) bnxt_hwrm_set_link_common(softc, &req); if (set_eee) bnxt_hwrm_set_eee(softc, &req); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (!rc) { if (set_pause) { /* since changing of 'force pause' setting doesn't * trigger any link change event, the driver needs to * update the current pause result upon successfully i * return of the phy_cfg command */ if (!softc->link_info.flow_ctrl.autoneg) bnxt_report_link(softc); } } BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_vnic_set_hds(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic) { struct hwrm_vnic_plcmodes_cfg_input req = {0}; if (!BNXT_CHIP_P5(softc)) return 0; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VNIC_PLCMODES_CFG); req.flags = htole32(HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_JUMBO_PLACEMENT); req.vnic_id = htole16(vnic->id); return hwrm_send_message(softc, &req, sizeof(req)); } int bnxt_hwrm_vnic_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic) { struct hwrm_vnic_cfg_input req = {0}; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VNIC_CFG); if (vnic->flags & BNXT_VNIC_FLAG_DEFAULT) req.flags |= htole32(HWRM_VNIC_CFG_INPUT_FLAGS_DEFAULT); if (vnic->flags & BNXT_VNIC_FLAG_BD_STALL) req.flags |= htole32(HWRM_VNIC_CFG_INPUT_FLAGS_BD_STALL_MODE); if (vnic->flags & BNXT_VNIC_FLAG_VLAN_STRIP) req.flags |= htole32(HWRM_VNIC_CFG_INPUT_FLAGS_VLAN_STRIP_MODE); if (BNXT_CHIP_P5 (softc)) { req.default_rx_ring_id = htole16(softc->rx_rings[0].phys_id); req.default_cmpl_ring_id = htole16(softc->rx_cp_rings[0].ring.phys_id); req.enables |= htole32(HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_RX_RING_ID | HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_CMPL_RING_ID); req.vnic_id = htole16(vnic->id); } else { req.enables = htole32(HWRM_VNIC_CFG_INPUT_ENABLES_DFLT_RING_GRP | HWRM_VNIC_CFG_INPUT_ENABLES_RSS_RULE); req.vnic_id = htole16(vnic->id); req.dflt_ring_grp = htole16(vnic->def_ring_grp); } req.rss_rule = htole16(vnic->rss_id); req.cos_rule = htole16(vnic->cos_rule); req.lb_rule = htole16(vnic->lb_rule); req.enables |= htole32(HWRM_VNIC_CFG_INPUT_ENABLES_MRU); req.mru = htole16(vnic->mru); return hwrm_send_message(softc, &req, sizeof(req)); } int bnxt_hwrm_vnic_free(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic) { struct hwrm_vnic_free_input req = {0}; int rc = 0; if (vnic->id == (uint16_t)HWRM_NA_SIGNATURE) return rc; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VNIC_FREE); req.vnic_id = htole32(vnic->id); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; fail: BNXT_HWRM_UNLOCK(softc); return (rc); } int bnxt_hwrm_vnic_alloc(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic) { struct hwrm_vnic_alloc_input req = {0}; struct hwrm_vnic_alloc_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc; if (vnic->id != (uint16_t)HWRM_NA_SIGNATURE) { device_printf(softc->dev, "Attempt to re-allocate vnic %04x\n", vnic->id); return EDOOFUS; } bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VNIC_ALLOC); if (vnic->flags & BNXT_VNIC_FLAG_DEFAULT) req.flags = htole32(HWRM_VNIC_ALLOC_INPUT_FLAGS_DEFAULT); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; vnic->id = le32toh(resp->vnic_id); fail: BNXT_HWRM_UNLOCK(softc); return (rc); } int bnxt_hwrm_vnic_ctx_free(struct bnxt_softc *softc, uint16_t ctx_id) { struct hwrm_vnic_rss_cos_lb_ctx_free_input req = {0}; int rc = 0; if (ctx_id == (uint16_t)HWRM_NA_SIGNATURE) return rc; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VNIC_RSS_COS_LB_CTX_FREE); req.rss_cos_lb_ctx_id = htole16(ctx_id); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; fail: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_vnic_ctx_alloc(struct bnxt_softc *softc, uint16_t *ctx_id) { struct hwrm_vnic_rss_cos_lb_ctx_alloc_input req = {0}; struct hwrm_vnic_rss_cos_lb_ctx_alloc_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc; if (*ctx_id != (uint16_t)HWRM_NA_SIGNATURE) { device_printf(softc->dev, "Attempt to re-allocate vnic ctx %04x\n", *ctx_id); return EDOOFUS; } bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VNIC_RSS_COS_LB_CTX_ALLOC); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; *ctx_id = le32toh(resp->rss_cos_lb_ctx_id); fail: BNXT_HWRM_UNLOCK(softc); return (rc); } int bnxt_hwrm_ring_grp_alloc(struct bnxt_softc *softc, struct bnxt_grp_info *grp) { struct hwrm_ring_grp_alloc_input req = {0}; struct hwrm_ring_grp_alloc_output *resp; int rc = 0; if (grp->grp_id != (uint16_t)HWRM_NA_SIGNATURE) { device_printf(softc->dev, "Attempt to re-allocate ring group %04x\n", grp->grp_id); return EDOOFUS; } if (BNXT_CHIP_P5 (softc)) return 0; resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_RING_GRP_ALLOC); req.cr = htole16(grp->cp_ring_id); req.rr = htole16(grp->rx_ring_id); req.ar = htole16(grp->ag_ring_id); req.sc = htole16(grp->stats_ctx); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; grp->grp_id = le32toh(resp->ring_group_id); fail: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_ring_grp_free(struct bnxt_softc *softc, struct bnxt_grp_info *grp) { struct hwrm_ring_grp_free_input req = {0}; int rc = 0; if (grp->grp_id == (uint16_t)HWRM_NA_SIGNATURE) return 0; if (BNXT_CHIP_P5 (softc)) return 0; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_RING_GRP_FREE); req.ring_group_id = htole32(grp->grp_id); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; fail: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_ring_free(struct bnxt_softc *softc, uint32_t ring_type, struct bnxt_ring *ring, int cmpl_ring_id) { struct hwrm_ring_free_input req = {0}; struct hwrm_ring_free_output *resp; int rc = 0; uint16_t error_code; if (ring->phys_id == (uint16_t)HWRM_NA_SIGNATURE) return 0; resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_RING_FREE); req.cmpl_ring = htole16(cmpl_ring_id); req.ring_type = ring_type; req.ring_id = htole16(ring->phys_id); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); error_code = le16toh(resp->error_code); if (rc || error_code) { device_printf(softc->dev, "hwrm_ring_free type %d failed. " "rc:%x err:%x\n", ring_type, rc, error_code); if (!rc) rc = -EIO; } BNXT_HWRM_UNLOCK(softc); return rc; } /* * Ring allocation message to the firmware */ int bnxt_hwrm_ring_alloc(struct bnxt_softc *softc, uint8_t type, struct bnxt_ring *ring) { struct hwrm_ring_alloc_input req = {0}; struct hwrm_ring_alloc_output *resp; uint16_t idx = ring->idx; struct bnxt_cp_ring *cp_ring; int rc; if (ring->phys_id != (uint16_t)HWRM_NA_SIGNATURE) { device_printf(softc->dev, "Attempt to re-allocate ring %04x\n", ring->phys_id); return EDOOFUS; } resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_RING_ALLOC); req.enables = htole32(0); req.fbo = htole32(0); req.ring_type = type; req.page_tbl_addr = htole64(ring->paddr); req.logical_id = htole16(ring->id); req.length = htole32(ring->ring_size); switch (type) { case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX: cp_ring = &softc->tx_cp_rings[idx]; req.cmpl_ring_id = htole16(cp_ring->ring.phys_id); /* queue_id - what CoS queue the TX ring is associated with */ req.queue_id = htole16(softc->tx_q_info[0].queue_id); req.stat_ctx_id = htole32(cp_ring->stats_ctx_id); req.enables |= htole32( HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID); break; case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX: if (!BNXT_CHIP_P5(softc)) break; cp_ring = &softc->rx_cp_rings[idx]; req.stat_ctx_id = htole32(cp_ring->stats_ctx_id); req.rx_buf_size = htole16(softc->rx_buf_size); req.enables |= htole32( HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID | HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID); break; case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG: if (!BNXT_CHIP_P5(softc)) { req.ring_type = HWRM_RING_ALLOC_INPUT_RING_TYPE_RX; break; } cp_ring = &softc->rx_cp_rings[idx]; req.rx_ring_id = htole16(softc->rx_rings[idx].phys_id); req.stat_ctx_id = htole32(cp_ring->stats_ctx_id); req.rx_buf_size = htole16(softc->rx_buf_size); req.enables |= htole32( HWRM_RING_ALLOC_INPUT_ENABLES_RX_RING_ID_VALID | HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID | HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID); break; case HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL: if (!BNXT_CHIP_P5(softc)) { req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX; break; } req.cq_handle = htole64(ring->id); req.nq_ring_id = htole16(softc->nq_rings[idx].ring.phys_id); req.enables |= htole32( HWRM_RING_ALLOC_INPUT_ENABLES_NQ_RING_ID_VALID); break; case HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ: req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX; break; default: device_printf(softc->dev, "hwrm alloc invalid ring type %d\n", type); return -1; } BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; ring->phys_id = le16toh(resp->ring_id); fail: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_stat_ctx_free(struct bnxt_softc *softc, struct bnxt_cp_ring *cpr) { struct hwrm_stat_ctx_free_input req = {0}; int rc = 0; if (cpr->stats_ctx_id == HWRM_NA_SIGNATURE) return rc; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_STAT_CTX_FREE); req.stat_ctx_id = htole16(cpr->stats_ctx_id); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; fail: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_stat_ctx_alloc(struct bnxt_softc *softc, struct bnxt_cp_ring *cpr, uint64_t paddr) { struct hwrm_stat_ctx_alloc_input req = {0}; struct hwrm_stat_ctx_alloc_output *resp; int rc = 0; if (cpr->stats_ctx_id != HWRM_NA_SIGNATURE) { device_printf(softc->dev, "Attempt to re-allocate stats ctx %08x\n", cpr->stats_ctx_id); return EDOOFUS; } resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_STAT_CTX_ALLOC); req.update_period_ms = htole32(1000); req.stats_dma_addr = htole64(paddr); if (BNXT_CHIP_P5(softc)) req.stats_dma_length = htole16(sizeof(struct ctx_hw_stats_ext) - 8); else req.stats_dma_length = htole16(sizeof(struct ctx_hw_stats)); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; cpr->stats_ctx_id = le32toh(resp->stat_ctx_id); fail: BNXT_HWRM_UNLOCK(softc); 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; } +static int bnxt_hwrm_pri2cos_idx(struct bnxt_softc *softc, uint32_t path_dir) +{ + struct hwrm_queue_pri2cos_qcfg_input req = {0}; + struct hwrm_queue_pri2cos_qcfg_output *resp; + uint8_t *pri2cos_idx, *q_ids, max_q; + int rc, i, j; + uint8_t *pri2cos; -void + bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_PRI2COS_QCFG); + resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; + + req.flags = htole32(HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_IVLAN | + path_dir); + rc = hwrm_send_message(softc, &req, sizeof(req)); + + if (rc) + return rc; + + if (path_dir == HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_TX) { + pri2cos_idx = softc->tx_pri2cos_idx; + q_ids = softc->tx_q_ids; + max_q = softc->tx_max_q; + } else { + pri2cos_idx = softc->rx_pri2cos_idx; + q_ids = softc->rx_q_ids; + max_q = softc->rx_max_q; + } + + pri2cos = &resp->pri0_cos_queue_id; + + for (i = 0; i < BNXT_MAX_QUEUE; i++) { + uint8_t queue_id = pri2cos[i]; + uint8_t queue_idx; + + /* Per port queue IDs start from 0, 10, 20, etc */ + queue_idx = queue_id % 10; + if (queue_idx > BNXT_MAX_QUEUE) { + softc->pri2cos_valid = false; + rc = -EINVAL; + return rc; + } + + for (j = 0; j < max_q; j++) { + if (q_ids[j] == queue_id) + pri2cos_idx[i] = queue_idx; + } + } + + softc->pri2cos_valid = true; + + return rc; +} + +int bnxt_hwrm_port_qstats_ext(struct bnxt_softc *softc) { struct hwrm_port_qstats_ext_input req = {0}; + struct hwrm_port_qstats_ext_output *resp; + int rc = 0, i; + uint32_t tx_stat_size; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_QSTATS_EXT); + resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; + tx_stat_size = sizeof(struct tx_port_stats_ext); req.port_id = htole16(softc->pf.port_id); - req.tx_stat_size = htole16(sizeof(struct tx_port_stats_ext)); + req.tx_stat_size = htole16(tx_stat_size); req.rx_stat_size = htole16(sizeof(struct rx_port_stats_ext)); req.rx_stat_host_addr = htole64(softc->hw_rx_port_stats_ext.idi_paddr); req.tx_stat_host_addr = htole64(softc->hw_tx_port_stats_ext.idi_paddr); - BNXT_HWRM_LOCK(softc); - _hwrm_send_message(softc, &req, sizeof(req)); - BNXT_HWRM_UNLOCK(softc); + rc = hwrm_send_message(softc, &req, sizeof(req)); - return; + if (!rc) { + softc->fw_rx_stats_ext_size = + le16toh(resp->rx_stat_size) / 8; + if (BNXT_FW_MAJ(softc) < 220 && + softc->fw_rx_stats_ext_size > BNXT_RX_STATS_EXT_NUM_LEGACY) + softc->fw_rx_stats_ext_size = BNXT_RX_STATS_EXT_NUM_LEGACY; + + softc->fw_tx_stats_ext_size = tx_stat_size ? + le16toh(resp->tx_stat_size) / 8 : 0; + } else { + softc->fw_rx_stats_ext_size = 0; + softc->fw_tx_stats_ext_size = 0; + } + + if (softc->fw_tx_stats_ext_size <= + offsetof(struct tx_port_stats_ext, pfc_pri0_tx_duration_us) / 8) { + softc->pri2cos_valid = false; + return rc; + } + + rc = bnxt_hwrm_pri2cos_idx(softc, HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_TX); + if (rc) + return rc; + + if (softc->is_asym_q) { + rc = bnxt_hwrm_pri2cos_idx(softc, HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_RX); + if (rc) + return rc; + } else { + memcpy(softc->rx_pri2cos_idx, softc->tx_pri2cos_idx, sizeof(softc->rx_pri2cos_idx)); + } + + u64 *rx_port_stats_ext = (u64 *)softc->hw_rx_port_stats_ext.idi_vaddr; + u64 *tx_port_stats_ext = (u64 *)softc->hw_tx_port_stats_ext.idi_vaddr; + + if (softc->pri2cos_valid) { + for (i = 0; i < 8; i++) { + long n = bnxt_rx_bytes_pri_arr_base_off[i] + + softc->rx_pri2cos_idx[i]; + + softc->rx_bytes_pri[i] = *(rx_port_stats_ext + n); + } + for (i = 0; i < 8; i++) { + long n = bnxt_rx_pkts_pri_arr_base_off[i] + + softc->rx_pri2cos_idx[i]; + + softc->rx_packets_pri[i] = *(rx_port_stats_ext + n); + } + for (i = 0; i < 8; i++) { + long n = bnxt_tx_bytes_pri_arr_base_off[i] + + softc->tx_pri2cos_idx[i]; + + softc->tx_bytes_pri[i] = *(tx_port_stats_ext + n); + } + for (i = 0; i < 8; i++) { + long n = bnxt_tx_pkts_pri_arr_base_off[i] + + softc->tx_pri2cos_idx[i]; + + softc->tx_packets_pri[i] = *(tx_port_stats_ext + n); + } + } + + return rc; } int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic) { struct hwrm_cfa_l2_set_rx_mask_input req = {0}; uint32_t mask = vnic->rx_mask; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_CFA_L2_SET_RX_MASK); req.vnic_id = htole32(vnic->id); req.mask = htole32(mask); req.mc_tbl_addr = htole64(vnic->mc_list.idi_paddr); req.num_mc_entries = htole32(vnic->mc_list_count); return hwrm_send_message(softc, &req, sizeof(req)); } int bnxt_hwrm_l2_filter_free(struct bnxt_softc *softc, uint64_t filter_id) { struct hwrm_cfa_l2_filter_free_input req = {0}; int rc = 0; if (filter_id == -1) return rc; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_CFA_L2_FILTER_FREE); req.l2_filter_id = htole64(filter_id); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; fail: BNXT_HWRM_UNLOCK(softc); return (rc); } int bnxt_hwrm_free_filter(struct bnxt_softc *softc) { struct bnxt_vnic_info *vnic = &softc->vnic_info; struct bnxt_vlan_tag *tag; int rc = 0; rc = bnxt_hwrm_l2_filter_free(softc, softc->vnic_info.filter_id); if (rc) goto end; SLIST_FOREACH(tag, &vnic->vlan_tags, next) { rc = bnxt_hwrm_l2_filter_free(softc, tag->filter_id); if (rc) goto end; tag->filter_id = -1; } end: return rc; } int bnxt_hwrm_l2_filter_alloc(struct bnxt_softc *softc, uint16_t vlan_tag, uint64_t *filter_id) { struct hwrm_cfa_l2_filter_alloc_input req = {0}; struct hwrm_cfa_l2_filter_alloc_output *resp; struct bnxt_vnic_info *vnic = &softc->vnic_info; uint32_t enables = 0; int rc = 0; if (*filter_id != -1) { device_printf(softc->dev, "Attempt to re-allocate l2 ctx " "filter (fid: 0x%jx)\n", (uintmax_t)*filter_id); return EDOOFUS; } resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_CFA_L2_FILTER_ALLOC); req.flags = htole32(HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX); enables = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR | HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK | HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_DST_ID; if (vlan_tag != 0xffff) { enables |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN | HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN_MASK | HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_NUM_VLANS; req.l2_ivlan_mask = 0xffff; req.l2_ivlan = vlan_tag; req.num_vlans = 1; } req.enables = htole32(enables); req.dst_id = htole16(vnic->id); memcpy(req.l2_addr, if_getlladdr(iflib_get_ifp(softc->ctx)), ETHER_ADDR_LEN); memset(&req.l2_addr_mask, 0xff, sizeof(req.l2_addr_mask)); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto fail; *filter_id = le64toh(resp->l2_filter_id); fail: BNXT_HWRM_UNLOCK(softc); return (rc); } int bnxt_hwrm_set_filter(struct bnxt_softc *softc) { struct bnxt_vnic_info *vnic = &softc->vnic_info; struct bnxt_vlan_tag *tag; int rc = 0; rc = bnxt_hwrm_l2_filter_alloc(softc, 0xffff, &vnic->filter_id); if (rc) goto end; SLIST_FOREACH(tag, &vnic->vlan_tags, next) { rc = bnxt_hwrm_l2_filter_alloc(softc, tag->tag, &tag->filter_id); if (rc) goto end; } end: return rc; } int bnxt_hwrm_rss_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic, uint32_t hash_type) { struct hwrm_vnic_rss_cfg_input req = {0}; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VNIC_RSS_CFG); req.hash_type = htole32(hash_type); req.ring_grp_tbl_addr = htole64(vnic->rss_grp_tbl.idi_paddr); req.hash_key_tbl_addr = htole64(vnic->rss_hash_key_tbl.idi_paddr); req.rss_ctx_idx = htole16(vnic->rss_id); req.hash_mode_flags = HWRM_FUNC_SPD_CFG_INPUT_HASH_MODE_FLAGS_DEFAULT; if (BNXT_CHIP_P5(softc)) { req.vnic_id = htole16(vnic->id); req.ring_table_pair_index = 0x0; } return hwrm_send_message(softc, &req, sizeof(req)); } int bnxt_hwrm_reserve_pf_rings(struct bnxt_softc *softc) { struct hwrm_func_cfg_input req = {0}; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_CFG); req.fid = htole16(0xffff); req.enables |= htole32(HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS); req.enables |= htole32(HWRM_FUNC_CFG_INPUT_ENABLES_NUM_CMPL_RINGS); req.enables |= htole32(HWRM_FUNC_CFG_INPUT_ENABLES_NUM_TX_RINGS); req.enables |= htole32(HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RX_RINGS); req.enables |= htole32(HWRM_FUNC_CFG_INPUT_ENABLES_NUM_VNICS); req.enables |= htole32(HWRM_FUNC_CFG_INPUT_ENABLES_NUM_MSIX); req.enables |= htole32(HWRM_FUNC_CFG_INPUT_ENABLES_NUM_STAT_CTXS); req.num_msix = htole16(BNXT_MAX_NUM_QUEUES); req.num_rsscos_ctxs = htole16(0x8); req.num_cmpl_rings = htole16(BNXT_MAX_NUM_QUEUES * 2); req.num_tx_rings = htole16(BNXT_MAX_NUM_QUEUES); req.num_rx_rings = htole16(BNXT_MAX_NUM_QUEUES); req.num_vnics = htole16(BNXT_MAX_NUM_QUEUES); req.num_stat_ctxs = htole16(BNXT_MAX_NUM_QUEUES * 2); return hwrm_send_message(softc, &req, sizeof(req)); } int bnxt_cfg_async_cr(struct bnxt_softc *softc) { int rc = 0; struct hwrm_func_cfg_input req = {0}; if (!BNXT_PF(softc)) return 0; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_CFG); req.fid = htole16(0xffff); req.enables = htole32(HWRM_FUNC_CFG_INPUT_ENABLES_ASYNC_EVENT_CR); if (BNXT_CHIP_P5(softc)) req.async_event_cr = htole16(softc->nq_rings[0].ring.phys_id); else req.async_event_cr = htole16(softc->def_cp_ring.ring.phys_id); rc = hwrm_send_message(softc, &req, sizeof(req)); return rc; } void bnxt_validate_hw_lro_settings(struct bnxt_softc *softc) { softc->hw_lro.enable = min(softc->hw_lro.enable, 1); softc->hw_lro.is_mode_gro = min(softc->hw_lro.is_mode_gro, 1); softc->hw_lro.max_agg_segs = min(softc->hw_lro.max_agg_segs, HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_MAX); softc->hw_lro.max_aggs = min(softc->hw_lro.max_aggs, HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_MAX); softc->hw_lro.min_agg_len = min(softc->hw_lro.min_agg_len, BNXT_MAX_MTU); } int bnxt_hwrm_vnic_tpa_cfg(struct bnxt_softc *softc) { struct hwrm_vnic_tpa_cfg_input req = {0}; uint32_t flags; if (softc->vnic_info.id == (uint16_t) HWRM_NA_SIGNATURE) { return 0; } if (!(softc->flags & BNXT_FLAG_TPA)) return 0; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VNIC_TPA_CFG); if (softc->hw_lro.enable) { flags = HWRM_VNIC_TPA_CFG_INPUT_FLAGS_TPA | HWRM_VNIC_TPA_CFG_INPUT_FLAGS_ENCAP_TPA | HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_ECN | HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_SAME_GRE_SEQ; if (softc->hw_lro.is_mode_gro) flags |= HWRM_VNIC_TPA_CFG_INPUT_FLAGS_GRO; else flags |= HWRM_VNIC_TPA_CFG_INPUT_FLAGS_RSC_WND_UPDATE; req.flags = htole32(flags); req.enables = htole32(HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGG_SEGS | HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGGS | HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MIN_AGG_LEN); req.max_agg_segs = htole16(softc->hw_lro.max_agg_segs); req.max_aggs = htole16(softc->hw_lro.max_aggs); req.min_agg_len = htole32(softc->hw_lro.min_agg_len); } req.vnic_id = htole16(softc->vnic_info.id); return hwrm_send_message(softc, &req, sizeof(req)); } int bnxt_hwrm_nvm_find_dir_entry(struct bnxt_softc *softc, uint16_t type, uint16_t *ordinal, uint16_t ext, uint16_t *index, bool use_index, uint8_t search_opt, uint32_t *data_length, uint32_t *item_length, uint32_t *fw_ver) { struct hwrm_nvm_find_dir_entry_input req = {0}; struct hwrm_nvm_find_dir_entry_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc = 0; uint32_t old_timeo; MPASS(ordinal); bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_NVM_FIND_DIR_ENTRY); if (use_index) { req.enables = htole32( HWRM_NVM_FIND_DIR_ENTRY_INPUT_ENABLES_DIR_IDX_VALID); req.dir_idx = htole16(*index); } req.dir_type = htole16(type); req.dir_ordinal = htole16(*ordinal); req.dir_ext = htole16(ext); req.opt_ordinal = search_opt; BNXT_HWRM_LOCK(softc); old_timeo = softc->hwrm_cmd_timeo; softc->hwrm_cmd_timeo = BNXT_NVM_TIMEO; rc = _hwrm_send_message(softc, &req, sizeof(req)); softc->hwrm_cmd_timeo = old_timeo; if (rc) goto exit; if (item_length) *item_length = le32toh(resp->dir_item_length); if (data_length) *data_length = le32toh(resp->dir_data_length); if (fw_ver) *fw_ver = le32toh(resp->fw_ver); *ordinal = le16toh(resp->dir_ordinal); if (index) *index = le16toh(resp->dir_idx); exit: BNXT_HWRM_UNLOCK(softc); return (rc); } int bnxt_hwrm_nvm_read(struct bnxt_softc *softc, uint16_t index, uint32_t offset, uint32_t length, struct iflib_dma_info *data) { struct hwrm_nvm_read_input req = {0}; int rc; uint32_t old_timeo; if (length > data->idi_size) { rc = EINVAL; goto exit; } bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_NVM_READ); req.host_dest_addr = htole64(data->idi_paddr); req.dir_idx = htole16(index); req.offset = htole32(offset); req.len = htole32(length); BNXT_HWRM_LOCK(softc); old_timeo = softc->hwrm_cmd_timeo; softc->hwrm_cmd_timeo = BNXT_NVM_TIMEO; rc = _hwrm_send_message(softc, &req, sizeof(req)); softc->hwrm_cmd_timeo = old_timeo; BNXT_HWRM_UNLOCK(softc); if (rc) goto exit; bus_dmamap_sync(data->idi_tag, data->idi_map, BUS_DMASYNC_POSTREAD); goto exit; exit: return rc; } int bnxt_hwrm_nvm_modify(struct bnxt_softc *softc, uint16_t index, uint32_t offset, void *data, bool cpyin, uint32_t length) { struct hwrm_nvm_modify_input req = {0}; struct iflib_dma_info dma_data; int rc; uint32_t old_timeo; if (length == 0 || !data) return EINVAL; rc = iflib_dma_alloc(softc->ctx, length, &dma_data, BUS_DMA_NOWAIT); if (rc) return ENOMEM; if (cpyin) { rc = copyin(data, dma_data.idi_vaddr, length); if (rc) goto exit; } else memcpy(dma_data.idi_vaddr, data, length); bus_dmamap_sync(dma_data.idi_tag, dma_data.idi_map, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_NVM_MODIFY); req.host_src_addr = htole64(dma_data.idi_paddr); req.dir_idx = htole16(index); req.offset = htole32(offset); req.len = htole32(length); BNXT_HWRM_LOCK(softc); old_timeo = softc->hwrm_cmd_timeo; softc->hwrm_cmd_timeo = BNXT_NVM_TIMEO; rc = _hwrm_send_message(softc, &req, sizeof(req)); softc->hwrm_cmd_timeo = old_timeo; BNXT_HWRM_UNLOCK(softc); exit: iflib_dma_free(&dma_data); return rc; } int bnxt_hwrm_fw_reset(struct bnxt_softc *softc, uint8_t processor, uint8_t *selfreset) { struct hwrm_fw_reset_input req = {0}; struct hwrm_fw_reset_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc; MPASS(selfreset); bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FW_RESET); req.embedded_proc_type = processor; req.selfrst_status = *selfreset; BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto exit; *selfreset = resp->selfrst_status; exit: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_fw_qstatus(struct bnxt_softc *softc, uint8_t type, uint8_t *selfreset) { struct hwrm_fw_qstatus_input req = {0}; struct hwrm_fw_qstatus_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc; MPASS(selfreset); bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FW_QSTATUS); req.embedded_proc_type = type; BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto exit; *selfreset = resp->selfrst_status; exit: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_nvm_write(struct bnxt_softc *softc, void *data, bool cpyin, uint16_t type, uint16_t ordinal, uint16_t ext, uint16_t attr, uint16_t option, uint32_t data_length, bool keep, uint32_t *item_length, uint16_t *index) { struct hwrm_nvm_write_input req = {0}; struct hwrm_nvm_write_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; struct iflib_dma_info dma_data; int rc; uint32_t old_timeo; if (data_length) { rc = iflib_dma_alloc(softc->ctx, data_length, &dma_data, BUS_DMA_NOWAIT); if (rc) return ENOMEM; if (cpyin) { rc = copyin(data, dma_data.idi_vaddr, data_length); if (rc) goto early_exit; } else memcpy(dma_data.idi_vaddr, data, data_length); bus_dmamap_sync(dma_data.idi_tag, dma_data.idi_map, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); } else dma_data.idi_paddr = 0; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_NVM_WRITE); req.host_src_addr = htole64(dma_data.idi_paddr); req.dir_type = htole16(type); req.dir_ordinal = htole16(ordinal); req.dir_ext = htole16(ext); req.dir_attr = htole16(attr); req.dir_data_length = htole32(data_length); req.option = htole16(option); if (keep) { req.flags = htole16(HWRM_NVM_WRITE_INPUT_FLAGS_KEEP_ORIG_ACTIVE_IMG); } if (item_length) req.dir_item_length = htole32(*item_length); BNXT_HWRM_LOCK(softc); old_timeo = softc->hwrm_cmd_timeo; softc->hwrm_cmd_timeo = BNXT_NVM_TIMEO; rc = _hwrm_send_message(softc, &req, sizeof(req)); softc->hwrm_cmd_timeo = old_timeo; if (rc) goto exit; if (item_length) *item_length = le32toh(resp->dir_item_length); if (index) *index = le16toh(resp->dir_idx); exit: BNXT_HWRM_UNLOCK(softc); early_exit: if (data_length) iflib_dma_free(&dma_data); return rc; } int bnxt_hwrm_nvm_erase_dir_entry(struct bnxt_softc *softc, uint16_t index) { struct hwrm_nvm_erase_dir_entry_input req = {0}; uint32_t old_timeo; int rc; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_NVM_ERASE_DIR_ENTRY); req.dir_idx = htole16(index); BNXT_HWRM_LOCK(softc); old_timeo = softc->hwrm_cmd_timeo; softc->hwrm_cmd_timeo = BNXT_NVM_TIMEO; rc = _hwrm_send_message(softc, &req, sizeof(req)); softc->hwrm_cmd_timeo = old_timeo; BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_nvm_get_dir_info(struct bnxt_softc *softc, uint32_t *entries, uint32_t *entry_length) { struct hwrm_nvm_get_dir_info_input req = {0}; struct hwrm_nvm_get_dir_info_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc; uint32_t old_timeo; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_NVM_GET_DIR_INFO); BNXT_HWRM_LOCK(softc); old_timeo = softc->hwrm_cmd_timeo; softc->hwrm_cmd_timeo = BNXT_NVM_TIMEO; rc = _hwrm_send_message(softc, &req, sizeof(req)); softc->hwrm_cmd_timeo = old_timeo; if (rc) goto exit; if (entries) *entries = le32toh(resp->entries); if (entry_length) *entry_length = le32toh(resp->entry_length); exit: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_nvm_get_dir_entries(struct bnxt_softc *softc, uint32_t *entries, uint32_t *entry_length, struct iflib_dma_info *dma_data) { struct hwrm_nvm_get_dir_entries_input req = {0}; uint32_t ent; uint32_t ent_len; int rc; uint32_t old_timeo; if (!entries) entries = &ent; if (!entry_length) entry_length = &ent_len; rc = bnxt_hwrm_nvm_get_dir_info(softc, entries, entry_length); if (rc) goto exit; if (*entries * *entry_length > dma_data->idi_size) { rc = EINVAL; goto exit; } /* * TODO: There's a race condition here that could blow up DMA memory... * we need to allocate the max size, not the currently in use * size. The command should totally have a max size here. */ bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_NVM_GET_DIR_ENTRIES); req.host_dest_addr = htole64(dma_data->idi_paddr); BNXT_HWRM_LOCK(softc); old_timeo = softc->hwrm_cmd_timeo; softc->hwrm_cmd_timeo = BNXT_NVM_TIMEO; rc = _hwrm_send_message(softc, &req, sizeof(req)); softc->hwrm_cmd_timeo = old_timeo; BNXT_HWRM_UNLOCK(softc); if (rc) goto exit; bus_dmamap_sync(dma_data->idi_tag, dma_data->idi_map, BUS_DMASYNC_POSTWRITE); exit: return rc; } int bnxt_hwrm_nvm_get_dev_info(struct bnxt_softc *softc, uint16_t *mfg_id, uint16_t *device_id, uint32_t *sector_size, uint32_t *nvram_size, uint32_t *reserved_size, uint32_t *available_size) { struct hwrm_nvm_get_dev_info_input req = {0}; struct hwrm_nvm_get_dev_info_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc; uint32_t old_timeo; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_NVM_GET_DEV_INFO); BNXT_HWRM_LOCK(softc); old_timeo = softc->hwrm_cmd_timeo; softc->hwrm_cmd_timeo = BNXT_NVM_TIMEO; rc = _hwrm_send_message(softc, &req, sizeof(req)); softc->hwrm_cmd_timeo = old_timeo; if (rc) goto exit; if (mfg_id) *mfg_id = le16toh(resp->manufacturer_id); if (device_id) *device_id = le16toh(resp->device_id); if (sector_size) *sector_size = le32toh(resp->sector_size); if (nvram_size) *nvram_size = le32toh(resp->nvram_size); if (reserved_size) *reserved_size = le32toh(resp->reserved_size); if (available_size) *available_size = le32toh(resp->available_size); exit: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_nvm_install_update(struct bnxt_softc *softc, uint32_t install_type, uint64_t *installed_items, uint8_t *result, uint8_t *problem_item, uint8_t *reset_required) { struct hwrm_nvm_install_update_input req = {0}; struct hwrm_nvm_install_update_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc; uint32_t old_timeo; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_NVM_INSTALL_UPDATE); req.install_type = htole32(install_type); BNXT_HWRM_LOCK(softc); old_timeo = softc->hwrm_cmd_timeo; softc->hwrm_cmd_timeo = BNXT_NVM_TIMEO; rc = _hwrm_send_message(softc, &req, sizeof(req)); softc->hwrm_cmd_timeo = old_timeo; if (rc) goto exit; if (installed_items) *installed_items = le32toh(resp->installed_items); if (result) *result = resp->result; if (problem_item) *problem_item = resp->problem_item; if (reset_required) *reset_required = resp->reset_required; exit: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_nvm_verify_update(struct bnxt_softc *softc, uint16_t type, uint16_t ordinal, uint16_t ext) { struct hwrm_nvm_verify_update_input req = {0}; uint32_t old_timeo; int rc; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_NVM_VERIFY_UPDATE); req.dir_type = htole16(type); req.dir_ordinal = htole16(ordinal); req.dir_ext = htole16(ext); BNXT_HWRM_LOCK(softc); old_timeo = softc->hwrm_cmd_timeo; softc->hwrm_cmd_timeo = BNXT_NVM_TIMEO; rc = _hwrm_send_message(softc, &req, sizeof(req)); softc->hwrm_cmd_timeo = old_timeo; BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_fw_get_time(struct bnxt_softc *softc, uint16_t *year, uint8_t *month, uint8_t *day, uint8_t *hour, uint8_t *minute, uint8_t *second, uint16_t *millisecond, uint16_t *zone) { struct hwrm_fw_get_time_input req = {0}; struct hwrm_fw_get_time_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FW_GET_TIME); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto exit; if (year) *year = le16toh(resp->year); if (month) *month = resp->month; if (day) *day = resp->day; if (hour) *hour = resp->hour; if (minute) *minute = resp->minute; if (second) *second = resp->second; if (millisecond) *millisecond = le16toh(resp->millisecond); if (zone) *zone = le16toh(resp->zone); exit: BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_fw_set_time(struct bnxt_softc *softc, uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond, uint16_t zone) { struct hwrm_fw_set_time_input req = {0}; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FW_SET_TIME); req.year = htole16(year); req.month = month; req.day = day; req.hour = hour; req.minute = minute; req.second = second; req.millisecond = htole16(millisecond); req.zone = htole16(zone); return hwrm_send_message(softc, &req, sizeof(req)); } int bnxt_read_sfp_module_eeprom_info(struct bnxt_softc *softc, uint16_t i2c_addr, uint16_t page_number, uint8_t bank,bool bank_sel_en, uint16_t start_addr, uint16_t data_length, uint8_t *buf) { struct hwrm_port_phy_i2c_read_output *output = (void *)softc->hwrm_cmd_resp.idi_vaddr; struct hwrm_port_phy_i2c_read_input req = {0}; int rc = 0, byte_offset = 0; BNXT_HWRM_LOCK(softc); bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_PHY_I2C_READ); req.i2c_slave_addr = i2c_addr; req.page_number = htole16(page_number); req.port_id = htole16(softc->pf.port_id); do { uint16_t xfer_size; xfer_size = min_t(uint16_t, data_length, BNXT_MAX_PHY_I2C_RESP_SIZE); data_length -= xfer_size; req.page_offset = htole16(start_addr + byte_offset); req.data_length = xfer_size; req.bank_number = bank; req.enables = htole32((start_addr + byte_offset ? HWRM_PORT_PHY_I2C_READ_INPUT_ENABLES_PAGE_OFFSET : 0) | (bank_sel_en ? HWRM_PORT_PHY_I2C_READ_INPUT_ENABLES_BANK_NUMBER : 0)); rc = hwrm_send_message(softc, &req, sizeof(req)); if (!rc) memcpy(buf + byte_offset, output->data, xfer_size); byte_offset += xfer_size; } while (!rc && data_length > 0); BNXT_HWRM_UNLOCK(softc); return rc; } int bnxt_hwrm_port_phy_qcfg(struct bnxt_softc *softc) { struct bnxt_link_info *link_info = &softc->link_info; struct hwrm_port_phy_qcfg_input req = {0}; struct hwrm_port_phy_qcfg_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc = 0; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_PHY_QCFG); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto exit; memcpy(&link_info->phy_qcfg_resp, resp, sizeof(*resp)); link_info->phy_link_status = resp->link; link_info->duplex = resp->duplex_cfg; link_info->auto_mode = resp->auto_mode; /* * When AUTO_PAUSE_AUTONEG_PAUSE bit is set to 1, * the advertisement of pause is enabled. * 1. When the auto_mode is not set to none and this flag is set to 1, * then the auto_pause bits on this port are being advertised and * autoneg pause results are being interpreted. * 2. When the auto_mode is not set to none and this flag is set to 0, * the pause is forced as indicated in force_pause, and also * advertised as auto_pause bits, but the autoneg results are not * interpreted since the pause configuration is being forced. * 3. When the auto_mode is set to none and this flag is set to 1, * auto_pause bits should be ignored and should be set to 0. */ link_info->flow_ctrl.autoneg = false; link_info->flow_ctrl.tx = false; link_info->flow_ctrl.rx = false; if ((resp->auto_mode) && (resp->auto_pause & BNXT_AUTO_PAUSE_AUTONEG_PAUSE)) { link_info->flow_ctrl.autoneg = true; } if (link_info->flow_ctrl.autoneg) { if (resp->auto_pause & BNXT_PAUSE_TX) link_info->flow_ctrl.tx = true; if (resp->auto_pause & BNXT_PAUSE_RX) link_info->flow_ctrl.rx = true; } else { if (resp->force_pause & BNXT_PAUSE_TX) link_info->flow_ctrl.tx = true; if (resp->force_pause & BNXT_PAUSE_RX) link_info->flow_ctrl.rx = true; } link_info->duplex_setting = resp->duplex_cfg; if (link_info->phy_link_status == HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK) link_info->link_speed = le16toh(resp->link_speed); else link_info->link_speed = 0; link_info->force_link_speed = le16toh(resp->force_link_speed); link_info->auto_link_speeds = le16toh(resp->auto_link_speed); link_info->support_speeds = le16toh(resp->support_speeds); link_info->auto_link_speeds = le16toh(resp->auto_link_speed_mask); link_info->preemphasis = le32toh(resp->preemphasis); link_info->phy_ver[0] = resp->phy_maj; link_info->phy_ver[1] = resp->phy_min; link_info->phy_ver[2] = resp->phy_bld; snprintf(softc->ver_info->phy_ver, sizeof(softc->ver_info->phy_ver), "%d.%d.%d", link_info->phy_ver[0], link_info->phy_ver[1], link_info->phy_ver[2]); strlcpy(softc->ver_info->phy_vendor, resp->phy_vendor_name, BNXT_NAME_SIZE); strlcpy(softc->ver_info->phy_partnumber, resp->phy_vendor_partnumber, BNXT_NAME_SIZE); link_info->media_type = resp->media_type; link_info->phy_type = resp->phy_type; link_info->transceiver = resp->xcvr_pkg_type; link_info->phy_addr = resp->eee_config_phy_addr & HWRM_PORT_PHY_QCFG_OUTPUT_PHY_ADDR_MASK; link_info->module_status = resp->module_status; link_info->support_pam4_speeds = le16toh(resp->support_pam4_speeds); link_info->auto_pam4_link_speeds = le16toh(resp->auto_pam4_link_speed_mask); link_info->force_pam4_link_speed = le16toh(resp->force_pam4_link_speed); if (softc->hwrm_spec_code >= 0x10504) link_info->active_fec_sig_mode = resp->active_fec_signal_mode; exit: BNXT_HWRM_UNLOCK(softc); return rc; } static bool bnxt_phy_qcaps_no_speed(struct hwrm_port_phy_qcaps_output *resp) { if (!resp->supported_speeds_auto_mode && !resp->supported_speeds_force_mode && !resp->supported_pam4_speeds_auto_mode && !resp->supported_pam4_speeds_force_mode) return true; return false; } int bnxt_hwrm_phy_qcaps(struct bnxt_softc *softc) { struct bnxt_link_info *link_info = &softc->link_info; struct hwrm_port_phy_qcaps_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; struct hwrm_port_phy_qcaps_input req = {}; int rc; if (softc->hwrm_spec_code < 0x10201) return 0; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_PHY_QCAPS); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); if (rc) goto exit; softc->phy_flags = resp->flags | (resp->flags2 << 8); if (resp->flags & HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_EEE_SUPPORTED) { softc->lpi_tmr_lo = le32toh(resp->tx_lpi_timer_low) & HWRM_PORT_PHY_QCAPS_OUTPUT_TX_LPI_TIMER_LOW_MASK; softc->lpi_tmr_hi = le32toh(resp->valid_tx_lpi_timer_high) & HWRM_PORT_PHY_QCAPS_OUTPUT_TX_LPI_TIMER_HIGH_MASK; } if (softc->hwrm_spec_code >= 0x10a01) { if (bnxt_phy_qcaps_no_speed(resp)) { link_info->phy_state = BNXT_PHY_STATE_DISABLED; device_printf(softc->dev, "Ethernet link disabled\n"); } else if (link_info->phy_state == BNXT_PHY_STATE_DISABLED) { link_info->phy_state = BNXT_PHY_STATE_ENABLED; device_printf(softc->dev, "Ethernet link enabled\n"); /* Phy re-enabled, reprobe the speeds */ link_info->support_auto_speeds = 0; link_info->support_pam4_auto_speeds = 0; } } if (resp->supported_speeds_auto_mode) link_info->support_auto_speeds = le16toh(resp->supported_speeds_auto_mode); if (resp->supported_speeds_force_mode) link_info->support_force_speeds = le16toh(resp->supported_speeds_force_mode); if (resp->supported_pam4_speeds_auto_mode) link_info->support_pam4_auto_speeds = le16toh(resp->supported_pam4_speeds_auto_mode); if (resp->supported_pam4_speeds_force_mode) link_info->support_pam4_force_speeds = le16toh(resp->supported_pam4_speeds_force_mode); exit: BNXT_HWRM_UNLOCK(softc); return rc; } uint16_t bnxt_hwrm_get_wol_fltrs(struct bnxt_softc *softc, uint16_t handle) { struct hwrm_wol_filter_qcfg_input req = {0}; struct hwrm_wol_filter_qcfg_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; uint16_t next_handle = 0; int rc; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_WOL_FILTER_QCFG); req.port_id = htole16(softc->pf.port_id); req.handle = htole16(handle); rc = hwrm_send_message(softc, &req, sizeof(req)); if (!rc) { next_handle = le16toh(resp->next_handle); if (next_handle != 0) { if (resp->wol_type == HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_MAGICPKT) { softc->wol = 1; softc->wol_filter_id = resp->wol_filter_id; } } } return next_handle; } int bnxt_hwrm_alloc_wol_fltr(struct bnxt_softc *softc) { struct hwrm_wol_filter_alloc_input req = {0}; struct hwrm_wol_filter_alloc_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_WOL_FILTER_ALLOC); req.port_id = htole16(softc->pf.port_id); req.wol_type = HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_MAGICPKT; req.enables = htole32(HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_MAC_ADDRESS); memcpy(req.mac_address, softc->func.mac_addr, ETHER_ADDR_LEN); rc = hwrm_send_message(softc, &req, sizeof(req)); if (!rc) softc->wol_filter_id = resp->wol_filter_id; return rc; } int bnxt_hwrm_free_wol_fltr(struct bnxt_softc *softc) { struct hwrm_wol_filter_free_input req = {0}; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_WOL_FILTER_FREE); req.port_id = htole16(softc->pf.port_id); req.enables = htole32(HWRM_WOL_FILTER_FREE_INPUT_ENABLES_WOL_FILTER_ID); req.wol_filter_id = softc->wol_filter_id; return hwrm_send_message(softc, &req, sizeof(req)); } static void bnxt_hwrm_set_coal_params(struct bnxt_softc *softc, uint32_t max_frames, uint32_t buf_tmrs, uint16_t flags, struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req) { req->flags = htole16(flags); req->num_cmpl_dma_aggr = htole16((uint16_t)max_frames); req->num_cmpl_dma_aggr_during_int = htole16(max_frames >> 16); req->cmpl_aggr_dma_tmr = htole16((uint16_t)buf_tmrs); req->cmpl_aggr_dma_tmr_during_int = htole16(buf_tmrs >> 16); /* Minimum time between 2 interrupts set to buf_tmr x 2 */ req->int_lat_tmr_min = htole16((uint16_t)buf_tmrs * 2); req->int_lat_tmr_max = htole16((uint16_t)buf_tmrs * 4); req->num_cmpl_aggr_int = htole16((uint16_t)max_frames * 4); } int bnxt_hwrm_set_coal(struct bnxt_softc *softc) { int i, rc = 0; struct hwrm_ring_cmpl_ring_cfg_aggint_params_input req_rx = {0}, req_tx = {0}, *req; uint16_t max_buf, max_buf_irq; uint16_t buf_tmr, buf_tmr_irq; uint32_t flags; bnxt_hwrm_cmd_hdr_init(softc, &req_rx, HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS); bnxt_hwrm_cmd_hdr_init(softc, &req_tx, HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS); /* Each rx completion (2 records) should be DMAed immediately. * DMA 1/4 of the completion buffers at a time. */ max_buf = min_t(uint16_t, softc->rx_coal_frames / 4, 2); /* max_buf must not be zero */ max_buf = clamp_t(uint16_t, max_buf, 1, 63); max_buf_irq = clamp_t(uint16_t, softc->rx_coal_frames_irq, 1, 63); buf_tmr = BNXT_USEC_TO_COAL_TIMER(softc->rx_coal_usecs); /* buf timer set to 1/4 of interrupt timer */ buf_tmr = max_t(uint16_t, buf_tmr / 4, 1); buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(softc->rx_coal_usecs_irq); buf_tmr_irq = max_t(uint16_t, buf_tmr_irq, 1); flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET; /* RING_IDLE generates more IRQs for lower latency. Enable it only * if coal_usecs is less than 25 us. */ if (softc->rx_coal_usecs < 25) flags |= HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_RING_IDLE; bnxt_hwrm_set_coal_params(softc, max_buf_irq << 16 | max_buf, buf_tmr_irq << 16 | buf_tmr, flags, &req_rx); /* max_buf must not be zero */ max_buf = clamp_t(uint16_t, softc->tx_coal_frames, 1, 63); max_buf_irq = clamp_t(uint16_t, softc->tx_coal_frames_irq, 1, 63); buf_tmr = BNXT_USEC_TO_COAL_TIMER(softc->tx_coal_usecs); /* buf timer set to 1/4 of interrupt timer */ buf_tmr = max_t(uint16_t, buf_tmr / 4, 1); buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(softc->tx_coal_usecs_irq); buf_tmr_irq = max_t(uint16_t, buf_tmr_irq, 1); flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET; bnxt_hwrm_set_coal_params(softc, max_buf_irq << 16 | max_buf, buf_tmr_irq << 16 | buf_tmr, flags, &req_tx); for (i = 0; i < softc->nrxqsets; i++) { req = &req_rx; req->ring_id = htole16(softc->grp_info[i].cp_ring_id); rc = hwrm_send_message(softc, req, sizeof(*req)); if (rc) break; } return rc; } int bnxt_hwrm_func_rgtr_async_events(struct bnxt_softc *softc, unsigned long *bmap, int bmap_size) { struct hwrm_func_drv_rgtr_input req = {0}; struct hwrm_func_drv_rgtr_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; bitstr_t *async_events_bmap; uint32_t *events; int i, rc = 0; #define BNXT_MAX_NUM_ASYNC_EVENTS 256 async_events_bmap = bit_alloc(BNXT_MAX_NUM_ASYNC_EVENTS, M_DEVBUF, M_WAITOK|M_ZERO); events = (uint32_t *)async_events_bmap; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_DRV_RGTR); req.enables = htole32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD); memset(async_events_bmap, 0, sizeof(BNXT_MAX_NUM_ASYNC_EVENTS / 8)); bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE); bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD); bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED); bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_CFG_CHANGE); bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE); if (bmap && bmap_size) { for (i = 0; i < bmap_size; i++) { if (bit_test(bmap, i)) bit_set(async_events_bmap, i); } } for (i = 0; i < 8; i++) req.async_event_fwd[i] |= htole32(events[i]); free(async_events_bmap, M_DEVBUF); rc = hwrm_send_message(softc, &req, sizeof(req)); if (!rc) { if (resp->flags & le32toh(HWRM_FUNC_DRV_RGTR_OUTPUT_FLAGS_IF_CHANGE_SUPPORTED)) softc->fw_cap |= BNXT_FW_CAP_IF_CHANGE; } return rc; } void bnxt_hwrm_ring_info_get(struct bnxt_softc *softc, uint8_t ring_type, uint32_t ring_id, uint32_t *prod, uint32_t *cons) { hwrm_dbg_ring_info_get_input_t req = {0}; hwrm_dbg_ring_info_get_output_t *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; int rc = 0; *prod = *cons = 0xffffffff; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_DBG_RING_INFO_GET); req.ring_type = le32toh(ring_type); req.fw_ring_id = le32toh(ring_id); rc = hwrm_send_message(softc, &req, sizeof(req)); if (!rc) { *prod = resp->producer_index; *cons = resp->consumer_index; } return; } diff --git a/sys/dev/bnxt/bnxt_en/bnxt_hwrm.h b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.h index 35a974fe3438..766556f9904c 100644 --- a/sys/dev/bnxt/bnxt_en/bnxt_hwrm.h +++ b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.h @@ -1,142 +1,142 @@ /*- * Broadcom NetXtreme-C/E network driver. * * Copyright (c) 2016 Broadcom, All Rights Reserved. * The term Broadcom refers to Broadcom Limited and/or its subsidiaries * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef _BNXT_HWRM_H #define _BNXT_HWRM_H #define BNXT_PAUSE_TX (HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX) #define BNXT_PAUSE_RX (HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX) #define BNXT_AUTO_PAUSE_AUTONEG_PAUSE \ (HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAUSE_AUTONEG_PAUSE) #define BNXT_HWRM_SHORT_REQ_LEN sizeof(struct hwrm_short_input) #define BNXT_BACKING_STORE_CFG_LEGACY_LEN 256 /* HWRM Function Prototypes */ int hwrm_send_message(struct bnxt_softc *softc, void *msg, uint32_t msg_len); int bnxt_alloc_hwrm_dma_mem(struct bnxt_softc *softc); void bnxt_free_hwrm_dma_mem(struct bnxt_softc *softc); int bnxt_hwrm_ring_alloc(struct bnxt_softc *softc, uint8_t type, struct bnxt_ring *ring); int bnxt_hwrm_ring_free(struct bnxt_softc *softc, uint32_t type, struct bnxt_ring *ring, int cmpl_ring_id); int bnxt_hwrm_ver_get(struct bnxt_softc *softc); int bnxt_hwrm_queue_qportcfg(struct bnxt_softc *softc, uint32_t path_dir); int bnxt_hwrm_func_drv_rgtr(struct bnxt_softc *softc); int bnxt_hwrm_func_drv_unrgtr(struct bnxt_softc *softc, bool shutdown); int bnxt_hwrm_func_qcaps(struct bnxt_softc *softc); int bnxt_hwrm_func_qcfg(struct bnxt_softc *softc); int bnxt_hwrm_func_reset(struct bnxt_softc *softc); int bnxt_hwrm_set_link_setting(struct bnxt_softc *softc, bool set_pause, bool set_eee, bool set_link); int bnxt_hwrm_set_pause(struct bnxt_softc *softc); int bnxt_hwrm_vnic_ctx_alloc(struct bnxt_softc *softc, uint16_t *ctx_id); int bnxt_hwrm_vnic_ctx_free(struct bnxt_softc *softc, uint16_t ctx_id); int bnxt_hwrm_vnic_set_hds(struct bnxt_softc *sc, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_alloc(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_free(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_stat_ctx_free(struct bnxt_softc *softc, struct bnxt_cp_ring *cpr); int bnxt_hwrm_port_qstats(struct bnxt_softc *softc); -void bnxt_hwrm_port_qstats_ext(struct bnxt_softc *softc); +int bnxt_hwrm_port_qstats_ext(struct bnxt_softc *softc); int bnxt_hwrm_ring_grp_alloc(struct bnxt_softc *softc, struct bnxt_grp_info *grp); int bnxt_hwrm_ring_grp_free(struct bnxt_softc *softc, struct bnxt_grp_info *gr); int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic); int bnxt_hwrm_set_filter(struct bnxt_softc *softc); int bnxt_hwrm_free_filter(struct bnxt_softc *softc); int bnxt_hwrm_l2_filter_alloc(struct bnxt_softc *softc, uint16_t vlan_tag, uint64_t *filter_id); int bnxt_hwrm_l2_filter_free(struct bnxt_softc *softc, uint64_t filter_id); int bnxt_hwrm_rss_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic, uint32_t hash_type); int bnxt_cfg_async_cr(struct bnxt_softc *softc); int bnxt_hwrm_vnic_tpa_cfg(struct bnxt_softc *softc); void bnxt_validate_hw_lro_settings(struct bnxt_softc *softc); int bnxt_hwrm_nvm_find_dir_entry(struct bnxt_softc *softc, uint16_t type, uint16_t *ordinal, uint16_t ext, uint16_t *index, bool use_index, uint8_t search_opt, uint32_t *data_length, uint32_t *item_length, uint32_t *fw_ver); int bnxt_hwrm_nvm_read(struct bnxt_softc *softc, uint16_t index, uint32_t offset, uint32_t length, struct iflib_dma_info *data); int bnxt_hwrm_nvm_modify(struct bnxt_softc *softc, uint16_t index, uint32_t offset, void *data, bool cpyin, uint32_t length); int bnxt_hwrm_fw_reset(struct bnxt_softc *softc, uint8_t processor, uint8_t *selfreset); int bnxt_hwrm_fw_qstatus(struct bnxt_softc *softc, uint8_t type, uint8_t *selfreset); int bnxt_hwrm_nvm_write(struct bnxt_softc *softc, void *data, bool cpyin, uint16_t type, uint16_t ordinal, uint16_t ext, uint16_t attr, uint16_t option, uint32_t data_length, bool keep, uint32_t *item_length, uint16_t *index); int bnxt_hwrm_nvm_erase_dir_entry(struct bnxt_softc *softc, uint16_t index); int bnxt_hwrm_nvm_get_dir_info(struct bnxt_softc *softc, uint32_t *entries, uint32_t *entry_length); int bnxt_hwrm_nvm_get_dir_entries(struct bnxt_softc *softc, uint32_t *entries, uint32_t *entry_length, struct iflib_dma_info *dma_data); int bnxt_hwrm_nvm_get_dev_info(struct bnxt_softc *softc, uint16_t *mfg_id, uint16_t *device_id, uint32_t *sector_size, uint32_t *nvram_size, uint32_t *reserved_size, uint32_t *available_size); int bnxt_hwrm_nvm_install_update(struct bnxt_softc *softc, uint32_t install_type, uint64_t *installed_items, uint8_t *result, uint8_t *problem_item, uint8_t *reset_required); int bnxt_hwrm_nvm_verify_update(struct bnxt_softc *softc, uint16_t type, uint16_t ordinal, uint16_t ext); int bnxt_hwrm_fw_get_time(struct bnxt_softc *softc, uint16_t *year, uint8_t *month, uint8_t *day, uint8_t *hour, uint8_t *minute, uint8_t *second, uint16_t *millisecond, uint16_t *zone); int bnxt_hwrm_fw_set_time(struct bnxt_softc *softc, uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond, uint16_t zone); int bnxt_hwrm_port_phy_qcfg(struct bnxt_softc *softc); int bnxt_hwrm_phy_qcaps(struct bnxt_softc *softc); uint16_t bnxt_hwrm_get_wol_fltrs(struct bnxt_softc *softc, uint16_t handle); int bnxt_hwrm_alloc_wol_fltr(struct bnxt_softc *softc); int bnxt_hwrm_free_wol_fltr(struct bnxt_softc *softc); int bnxt_hwrm_set_coal(struct bnxt_softc *softc); int bnxt_hwrm_func_rgtr_async_events(struct bnxt_softc *softc, unsigned long *bmap, int bmap_size); int bnxt_hwrm_func_backing_store_qcaps(struct bnxt_softc *softc); int bnxt_hwrm_func_backing_store_cfg(struct bnxt_softc *softc, uint32_t); int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt_softc *softc, struct bnxt_ctx_mem_type *ctxm, bool last); int bnxt_hwrm_func_resc_qcaps(struct bnxt_softc *softc, bool all); int bnxt_hwrm_reserve_pf_rings (struct bnxt_softc *softc); void bnxt_hwrm_ring_info_get(struct bnxt_softc *softc, uint8_t ring_type, uint32_t ring_id, uint32_t *prod, uint32_t *); int bnxt_hwrm_passthrough(struct bnxt_softc *softc, void *req, uint32_t req_len, void *resp, uint32_t resp_len, uint32_t timeout); int _hwrm_send_message(struct bnxt_softc *, void *, uint32_t); int hwrm_send_message(struct bnxt_softc *, void *, uint32_t); void bnxt_hwrm_cmd_hdr_init(struct bnxt_softc *, void *, uint16_t); #endif diff --git a/sys/dev/bnxt/bnxt_en/bnxt_sysctl.c b/sys/dev/bnxt/bnxt_en/bnxt_sysctl.c index e00cb225fd49..fdc54ab34511 100644 --- a/sys/dev/bnxt/bnxt_en/bnxt_sysctl.c +++ b/sys/dev/bnxt/bnxt_en/bnxt_sysctl.c @@ -1,2016 +1,2114 @@ /*- * Broadcom NetXtreme-C/E network driver. * * Copyright (c) 2016 Broadcom, All Rights Reserved. * The term Broadcom refers to Broadcom Limited and/or its subsidiaries * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include "bnxt.h" #include "bnxt_hwrm.h" #include "bnxt_sysctl.h" /* * We want to create: * dev.bnxt.0.hwstats.txq0 * dev.bnxt.0.hwstats.txq0.txmbufs * dev.bnxt.0.hwstats.rxq0 * dev.bnxt.0.hwstats.txq0.rxmbufs * so the hwstats ctx list needs to be created in attach_post and populated * during init. * * Then, it needs to be cleaned up in stop. */ int bnxt_init_sysctl_ctx(struct bnxt_softc *softc) { struct sysctl_ctx_list *ctx; sysctl_ctx_init(&softc->hw_stats); ctx = device_get_sysctl_ctx(softc->dev); softc->hw_stats_oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO, "hwstats", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "hardware statistics"); if (!softc->hw_stats_oid) { sysctl_ctx_free(&softc->hw_stats); return ENOMEM; } sysctl_ctx_init(&softc->ver_info->ver_ctx); ctx = device_get_sysctl_ctx(softc->dev); softc->ver_info->ver_oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO, "ver", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "hardware/firmware version information"); if (!softc->ver_info->ver_oid) { sysctl_ctx_free(&softc->ver_info->ver_ctx); return ENOMEM; } if (BNXT_PF(softc)) { sysctl_ctx_init(&softc->nvm_info->nvm_ctx); ctx = device_get_sysctl_ctx(softc->dev); softc->nvm_info->nvm_oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO, "nvram", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "nvram information"); if (!softc->nvm_info->nvm_oid) { sysctl_ctx_free(&softc->nvm_info->nvm_ctx); return ENOMEM; } } sysctl_ctx_init(&softc->hw_lro_ctx); ctx = device_get_sysctl_ctx(softc->dev); softc->hw_lro_oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO, "hw_lro", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "hardware lro"); if (!softc->hw_lro_oid) { sysctl_ctx_free(&softc->hw_lro_ctx); return ENOMEM; } sysctl_ctx_init(&softc->flow_ctrl_ctx); ctx = device_get_sysctl_ctx(softc->dev); softc->flow_ctrl_oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO, "fc", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "flow ctrl"); if (!softc->flow_ctrl_oid) { sysctl_ctx_free(&softc->flow_ctrl_ctx); return ENOMEM; } sysctl_ctx_init(&softc->dcb_ctx); ctx = device_get_sysctl_ctx(softc->dev); softc->dcb_oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO, "dcb", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "dcb"); if (!softc->dcb_oid) { sysctl_ctx_free(&softc->dcb_ctx); return ENOMEM; } return 0; } int bnxt_free_sysctl_ctx(struct bnxt_softc *softc) { int orc; int rc = 0; if (softc->hw_stats_oid != NULL) { orc = sysctl_ctx_free(&softc->hw_stats); if (orc) rc = orc; else softc->hw_stats_oid = NULL; } if (softc->ver_info->ver_oid != NULL) { orc = sysctl_ctx_free(&softc->ver_info->ver_ctx); if (orc) rc = orc; else softc->ver_info->ver_oid = NULL; } if (BNXT_PF(softc) && softc->nvm_info->nvm_oid != NULL) { orc = sysctl_ctx_free(&softc->nvm_info->nvm_ctx); if (orc) rc = orc; else softc->nvm_info->nvm_oid = NULL; } if (softc->hw_lro_oid != NULL) { orc = sysctl_ctx_free(&softc->hw_lro_ctx); if (orc) rc = orc; else softc->hw_lro_oid = NULL; } if (softc->flow_ctrl_oid != NULL) { orc = sysctl_ctx_free(&softc->flow_ctrl_ctx); if (orc) rc = orc; else softc->flow_ctrl_oid = NULL; } if (softc->dcb_oid != NULL) { orc = sysctl_ctx_free(&softc->dcb_ctx); if (orc) rc = orc; else softc->dcb_oid = NULL; } return rc; } int bnxt_create_tx_sysctls(struct bnxt_softc *softc, int txr) { struct sysctl_oid *oid; struct ctx_hw_stats *tx_stats = (void *)softc->tx_stats[txr].idi_vaddr; char name[32]; char desc[64]; sprintf(name, "txq%d", txr); sprintf(desc, "transmit queue %d", txr); oid = SYSCTL_ADD_NODE(&softc->hw_stats, SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, desc); if (!oid) return ENOMEM; SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "ucast_pkts", CTLFLAG_RD, &tx_stats->tx_ucast_pkts, "unicast packets sent"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "mcast_pkts", CTLFLAG_RD, &tx_stats->tx_mcast_pkts, "multicast packets sent"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "bcast_pkts", CTLFLAG_RD, &tx_stats->tx_bcast_pkts, "broadcast packets sent"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "discard_pkts", CTLFLAG_RD, &tx_stats->tx_discard_pkts, "discarded transmit packets"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "error_pkts", CTLFLAG_RD, &tx_stats->tx_error_pkts, "Error transmit packets"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "ucast_bytes", CTLFLAG_RD, &tx_stats->tx_ucast_bytes, "unicast bytes sent"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "mcast_bytes", CTLFLAG_RD, &tx_stats->tx_mcast_bytes, "multicast bytes sent"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "bcast_bytes", CTLFLAG_RD, &tx_stats->tx_bcast_bytes, "broadcast bytes sent"); 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 | CTLFLAG_MPSAFE, 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_1518b_frames", CTLFLAG_RD, &softc->tx_port_stats->tx_1024b_1518b_frames, "Transmitted 1024b 1518b 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_2047b_frames", CTLFLAG_RD, &softc->tx_port_stats->tx_1519b_2047b_frames, "Transmitted 1519b 2047b 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_err", CTLFLAG_RD, &softc->tx_port_stats->tx_err, "Transmitted err"); 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_1518b_frames", CTLFLAG_RD, &softc->rx_port_stats->rx_1024b_1518b_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_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_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_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_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_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_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"); if (BNXT_CHIP_P5(softc) && (softc->flags & BNXT_FLAG_FW_CAP_EXT_STATS)) { SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_bytes_cos0", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_bytes_cos0, "Transmitted bytes count cos0"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_packets_cos0", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_packets_cos0, "Transmitted packets count cos0"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_bytes_cos1", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_bytes_cos1, "Transmitted bytes count cos1"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_packets_cos1", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_packets_cos1, "Transmitted packets count cos1"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_bytes_cos2", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_bytes_cos2, "Transmitted bytes count cos2"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_packets_cos2", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_packets_cos2, "Transmitted packets count cos2"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_bytes_cos3", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_bytes_cos3, "Transmitted bytes count cos3"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_packets_cos3", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_packets_cos3, "Transmitted packets count cos3"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_bytes_cos4", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_bytes_cos4, "Transmitted bytes count cos4"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_packets_cos4", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_packets_cos4, "Transmitted packets count cos4"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_bytes_cos5", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_bytes_cos5, "Transmitted bytes count cos5"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_packets_cos5", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_packets_cos5, "Transmitted packets count cos5"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_bytes_cos6", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_bytes_cos6, "Transmitted bytes count cos6"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_packets_cos6", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_packets_cos6, "Transmitted packets count cos6"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_bytes_cos7", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_bytes_cos7, "Transmitted bytes count cos7"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tx_packets_cos7", CTLFLAG_RD, &softc->tx_port_stats_ext->tx_packets_cos7, "Transmitted packets count cos7"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_bytes_pri0", CTLFLAG_RD, + &softc->tx_bytes_pri[0], "Transmitted bytes count pri0"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_packets_pri0", CTLFLAG_RD, + &softc->tx_packets_pri[0], "Transmitted packets count pri0"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_bytes_pri1", CTLFLAG_RD, + &softc->tx_bytes_pri[1], "Transmitted bytes count pri1"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_packets_pri1", CTLFLAG_RD, + &softc->tx_packets_pri[1], "Transmitted packets count pri1"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_bytes_pri2", CTLFLAG_RD, + &softc->tx_bytes_pri[2], "Transmitted bytes count pri2"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_packets_pri2", CTLFLAG_RD, + &softc->tx_packets_pri[2], "Transmitted packets count pri2"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_bytes_pri3", CTLFLAG_RD, + &softc->tx_bytes_pri[3], "Transmitted bytes count pri3"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_packets_pri3", CTLFLAG_RD, + &softc->tx_packets_pri[3], "Transmitted packets count pri3"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_bytes_pri4", CTLFLAG_RD, + &softc->tx_bytes_pri[4], "Transmitted bytes count pri4"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_packets_pri4", CTLFLAG_RD, + &softc->tx_packets_pri[4], "Transmitted packets count pri4"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_bytes_pri5", CTLFLAG_RD, + &softc->tx_bytes_pri[5], "Transmitted bytes count pri5"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_packets_pri5", CTLFLAG_RD, + &softc->tx_packets_pri[5], "Transmitted packets count pri5"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_bytes_pri6", CTLFLAG_RD, + &softc->tx_bytes_pri[6], "Transmitted bytes count pri6"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_packets_pri6", CTLFLAG_RD, + &softc->tx_packets_pri[6], "Transmitted packets count pri6"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_bytes_pri7", CTLFLAG_RD, + &softc->tx_bytes_pri[7], "Transmitted bytes count pri7"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_packets_pri7", CTLFLAG_RD, + &softc->tx_packets_pri[7], "Transmitted packets count pri7"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri0_tx_duration_us", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri0_tx_duration_us, "Time duration between" "XON to XOFF and XOFF to XON for pri0"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri0_tx_transitions", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri0_tx_transitions, "Num times transition" "between XON to XOFF and XOFF to XON for pri0"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri1_tx_duration_us", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri1_tx_duration_us, "Time duration between" "XON to XOFF and XOFF to XON for pri1"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri1_tx_transitions", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri1_tx_transitions, "Num times transition" "between XON to XOFF and XOFF to XON for pri1"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri2_tx_duration_us", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri2_tx_duration_us, "Time duration between" "XON to XOFF and XOFF to XON for pri2"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri2_tx_transitions", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri2_tx_transitions, "Num times transition" "between XON to XOFF and XOFF to XON for pri2"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri3_tx_duration_us", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri3_tx_duration_us, "Time duration between" "XON to XOFF and XOFF to XON for pri3"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri3_tx_transitions", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri3_tx_transitions, "Num times transition" "between XON to XOFF and XOFF to XON for pri3"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri4_tx_duration_us", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri4_tx_duration_us, "Time duration between" "XON to XOFF and XOFF to XON for pri4"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri4_tx_transitions", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri4_tx_transitions, "Num times transition" "between XON to XOFF and XOFF to XON for pri4"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri5_tx_duration_us", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri5_tx_duration_us, "Time duration between" "XON to XOFF and XOFF to XON for pri5"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri5_tx_transitions", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri5_tx_transitions, "Num times transition" "between XON to XOFF and XOFF to XON for pri5"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri6_tx_duration_us", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri6_tx_duration_us, "Time duration between" "XON to XOFF and XOFF to XON for pri6"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri6_tx_transitions", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri6_tx_transitions, "Num times transition" "between XON to XOFF and XOFF to XON for pri6"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri7_tx_duration_us", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri7_tx_duration_us, "Time duration between" "XON to XOFF and XOFF to XON for pri7"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri7_tx_transitions", CTLFLAG_RD, &softc->tx_port_stats_ext->pfc_pri7_tx_transitions, "Num times transition" "between XON to XOFF and XOFF to XON for pri7"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "link_down_events", CTLFLAG_RD, &softc->rx_port_stats_ext->link_down_events, "Num times link states down"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "continuous_pause_events", CTLFLAG_RD, &softc->rx_port_stats_ext->continuous_pause_events, "Num times pause events"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "resume_pause_events", CTLFLAG_RD, &softc->rx_port_stats_ext->resume_pause_events, "Num times pause events" "resumes"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "continuous_roce_pause_events", CTLFLAG_RD, &softc->rx_port_stats_ext->continuous_roce_pause_events, "Num times roce" "pause events"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "resume_roce_pause_events", CTLFLAG_RD, &softc->rx_port_stats_ext->resume_roce_pause_events, "Num times roce pause" "events resumes"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_bytes_cos0", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_bytes_cos0, "Received bytes count cos0"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_packets_cos0", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_packets_cos0, "Received packets count cos0"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_bytes_cos1", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_bytes_cos1, "Received bytes count cos1"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_packets_cos1", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_packets_cos1, "Received packets count cos1"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_bytes_cos2", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_bytes_cos2, "Received bytes count cos2"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_packets_cos2", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_packets_cos2, "Received packets count cos2"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_bytes_cos3", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_bytes_cos3, "Received bytes count cos3"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_packets_cos3", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_packets_cos3, "Received packets count cos3"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_bytes_cos4", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_bytes_cos4, "Received bytes count cos4"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_packets_cos4", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_packets_cos4, "Received packets count cos4"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_bytes_cos5", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_bytes_cos5, "Received bytes count cos5"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_packets_cos5", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_packets_cos5, "Received packets count cos5"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_bytes_cos6", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_bytes_cos6, "Received bytes count cos6"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_packets_cos6", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_packets_cos6, "Received packets count cos6"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_bytes_cos7", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_bytes_cos7, "Received bytes count cos7"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_packets_cos7", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_packets_cos7, "Received packets count cos7"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_bytes_pri0", CTLFLAG_RD, + &softc->rx_bytes_pri[0], "Received bytes count pri0"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_packets_pri0", CTLFLAG_RD, + &softc->rx_packets_pri[0], "Received packets count pri0"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_bytes_pri1", CTLFLAG_RD, + &softc->rx_bytes_pri[1], "Received bytes count pri1"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_packets_pri1", CTLFLAG_RD, + &softc->rx_packets_pri[1], "Received packets count pri1"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_bytes_pri2", CTLFLAG_RD, + &softc->rx_bytes_pri[2], "Received bytes count pri2"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_packets_pri2", CTLFLAG_RD, + &softc->rx_packets_pri[2], "Received packets count pri2"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_bytes_pri3", CTLFLAG_RD, + &softc->rx_bytes_pri[3], "Received bytes count pri3"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_packets_pri3", CTLFLAG_RD, + &softc->rx_packets_pri[3], "Received packets count pri3"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_bytes_pri4", CTLFLAG_RD, + &softc->rx_bytes_pri[4], "Received bytes count pri4"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_packets_pri4", CTLFLAG_RD, + &softc->rx_packets_pri[4], "Received packets count pri4"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_bytes_pri5", CTLFLAG_RD, + &softc->rx_bytes_pri[5], "Received bytes count pri5"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_packets_pri5", CTLFLAG_RD, + &softc->rx_packets_pri[5], "Received packets count pri5"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_bytes_pri6", CTLFLAG_RD, + &softc->rx_bytes_pri[6], "Received bytes count pri6"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_packets_pri6", CTLFLAG_RD, + &softc->rx_packets_pri[6], "Received packets count pri6"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_bytes_pri7", CTLFLAG_RD, + &softc->rx_bytes_pri[7], "Received bytes count pri7"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_packets_pri7", CTLFLAG_RD, + &softc->rx_packets_pri[7], "Received packets count pri7"); + SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri0_rx_duration_us", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri0_rx_duration_us, "Time duration in receiving" "between XON to XOFF and XOFF to XON for pri0"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri0_rx_transitions", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri0_rx_transitions, "Num times rx transition" "between XON to XOFF and XOFF to XON for pri0"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri1_rx_duration_us", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri1_rx_duration_us, "Time duration in receiving" "between XON to XOFF and XOFF to XON for pri1"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri1_rx_transitions", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri1_rx_transitions, "Num times rx transition" "between XON to XOFF and XOFF to XON for pri1"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri2_rx_duration_us", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri2_rx_duration_us, "Time duration in receiving" "between XON to XOFF and XOFF to XON for pri2"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri2_rx_transitions", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri2_rx_transitions, "Num times rx transition" "between XON to XOFF and XOFF to XON for pri2"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri3_rx_duration_us", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri3_rx_duration_us, "Time duration in receiving" "between XON to XOFF and XOFF to XON for pri3"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri3_rx_transitions", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri3_rx_transitions, "Num times rx transition" "between XON to XOFF and XOFF to XON for pri3"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri4_rx_duration_us", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri4_rx_duration_us, "Time duration in receiving" "between XON to XOFF and XOFF to XON for pri4"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri4_rx_transitions", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri4_rx_transitions, "Num times rx transition" "between XON to XOFF and XOFF to XON for pri4"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri5_rx_duration_us", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri5_rx_duration_us, "Time duration in receiving" "between XON to XOFF and XOFF to XON for pri5"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri5_rx_transitions", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri5_rx_transitions, "Num times rx transition" "between XON to XOFF and XOFF to XON for pri5"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri6_rx_duration_us", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri6_rx_duration_us, "Time duration in receiving" "between XON to XOFF and XOFF to XON for pri6"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri6_rx_transitions", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri6_rx_transitions, "Num times rx transition" "between XON to XOFF and XOFF to XON for pri6"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri7_rx_duration_us", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri7_rx_duration_us, "Time duration in receiving" "between XON to XOFF and XOFF to XON for pri7"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc_pri7_rx_transitions", CTLFLAG_RD, &softc->rx_port_stats_ext->pfc_pri7_rx_transitions, "Num times rx transition" "between XON to XOFF and XOFF to XON for pri7"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_bits", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_bits, "total number of received bits"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_buffer_passed_threshold", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_buffer_passed_threshold, "num of events port" "buffer" "was over 85%"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_pcs_symbol_err", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_pcs_symbol_err, "num of symbol errors wasn't" "corrected by FEC"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_corrected_bits", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_corrected_bits, "num of bits corrected by FEC"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_bytes_cos0", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_bytes_cos0, "num of rx discard bytes" "count on cos0"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_packets_cos0", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_packets_cos0, "num of rx discard packets" "count on cos0"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_bytes_cos1", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_bytes_cos1, "num of rx discard bytes" "count on cos1"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_packets_cos1", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_packets_cos1, "num of rx discard packets" "count on cos1"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_bytes_cos2", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_bytes_cos2, "num of rx discard bytes" "count on cos2"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_packets_cos2", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_packets_cos2, "num of rx discard packets" "count on cos2"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_bytes_cos3", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_bytes_cos3, "num of rx discard bytes" "count on cos3"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_packets_cos3", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_packets_cos3, "num of rx discard packets" "count on cos3"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_bytes_cos4", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_bytes_cos4, "num of rx discard bytes" "count on cos4"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_packets_cos4", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_packets_cos4, "num of rx discard packets" "count on cos4"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_bytes_cos5", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_bytes_cos5, "num of rx discard bytes" "count on cos5"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_packets_cos5", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_packets_cos5, "num of rx discard packets" "count on cos5"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_bytes_cos6", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_bytes_cos6, "num of rx discard bytes" "count on cos6"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_packets_cos6", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_packets_cos6, "num of rx discard packets" "count on cos6"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_bytes_cos7", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_bytes_cos7, "num of rx discard bytes" "count on cos7"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rx_discard_packets_cos7", CTLFLAG_RD, &softc->rx_port_stats_ext->rx_discard_packets_cos7, "num of rx discard packets" "count on cos7"); } return 0; } int bnxt_create_rx_sysctls(struct bnxt_softc *softc, int rxr) { struct sysctl_oid *oid; struct ctx_hw_stats *rx_stats = (void *)softc->rx_stats[rxr].idi_vaddr; char name[32]; char desc[64]; sprintf(name, "rxq%d", rxr); sprintf(desc, "receive queue %d", rxr); oid = SYSCTL_ADD_NODE(&softc->hw_stats, SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, desc); if (!oid) return ENOMEM; if (BNXT_CHIP_P5(softc)) SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "nq_num_ints", CTLFLAG_RD, &softc->nq_rings[rxr].int_count, "Num Interrupts"); else SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "rq_num_ints", CTLFLAG_RD, &softc->rx_cp_rings[rxr].int_count, "Num Interrupts"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "ucast_pkts", CTLFLAG_RD, &rx_stats->rx_ucast_pkts, "unicast packets received"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "mcast_pkts", CTLFLAG_RD, &rx_stats->rx_mcast_pkts, "multicast packets received"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "bcast_pkts", CTLFLAG_RD, &rx_stats->rx_bcast_pkts, "broadcast packets received"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "discard_pkts", CTLFLAG_RD, &rx_stats->rx_discard_pkts, "discarded receive packets"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "error_pkts", CTLFLAG_RD, &rx_stats->rx_error_pkts, "Error receive packets"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "ucast_bytes", CTLFLAG_RD, &rx_stats->rx_ucast_bytes, "unicast bytes received"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "mcast_bytes", CTLFLAG_RD, &rx_stats->rx_mcast_bytes, "multicast bytes received"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "bcast_bytes", CTLFLAG_RD, &rx_stats->rx_bcast_bytes, "broadcast bytes received"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tpa_pkts", CTLFLAG_RD, &rx_stats->tpa_pkts, "TPA packets"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tpa_bytes", CTLFLAG_RD, &rx_stats->tpa_bytes, "TPA bytes"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tpa_events", CTLFLAG_RD, &rx_stats->tpa_events, "TPA events"); SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, "tpa_aborts", CTLFLAG_RD, &rx_stats->tpa_aborts, "TPA aborts"); return 0; } static char *bnxt_chip_type[] = { "ASIC", "FPGA", "Palladium", "Unknown" }; #define MAX_CHIP_TYPE 3 static char *bnxt_parse_pkglog(int desired_field, uint8_t *data, size_t datalen) { char *retval = NULL; char *p; char *value; int field = 0; if (datalen < 1) return NULL; /* null-terminate the log data (removing last '\n'): */ data[datalen - 1] = 0; for (p = data; *p != 0; p++) { field = 0; retval = NULL; while (*p != 0 && *p != '\n') { value = p; while (*p != 0 && *p != '\t' && *p != '\n') p++; if (field == desired_field) retval = value; if (*p != '\t') break; *p = 0; field++; p++; } if (*p == 0) break; *p = 0; } return retval; } static int bnxt_package_ver_sysctl(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; struct iflib_dma_info dma_data; char *pkglog = NULL; char *p; char unk[] = ""; char *buf = unk; int rc; uint16_t ordinal = BNX_DIR_ORDINAL_FIRST; uint16_t index; uint32_t data_len; rc = bnxt_hwrm_nvm_find_dir_entry(softc, BNX_DIR_TYPE_PKG_LOG, &ordinal, BNX_DIR_EXT_NONE, &index, false, HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_EQ, &data_len, NULL, NULL); dma_data.idi_vaddr = NULL; if (rc == 0 && data_len) { rc = iflib_dma_alloc(softc->ctx, data_len, &dma_data, BUS_DMA_NOWAIT); if (rc == 0) { rc = bnxt_hwrm_nvm_read(softc, index, 0, data_len, &dma_data); if (rc == 0) { pkglog = dma_data.idi_vaddr; p = bnxt_parse_pkglog(BNX_PKG_LOG_FIELD_IDX_PKG_VERSION, pkglog, data_len); if (p && *p != 0 && isdigit(*p)) buf = p; } } else dma_data.idi_vaddr = NULL; } rc = sysctl_handle_string(oidp, buf, 0, req); if (dma_data.idi_vaddr) iflib_dma_free(&dma_data); return rc; } static int bnxt_hwrm_min_ver_sysctl(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; char buf[16]; uint8_t newver[3]; int rc; sprintf(buf, "%hhu.%hhu.%hhu", softc->ver_info->hwrm_min_major, softc->ver_info->hwrm_min_minor, softc->ver_info->hwrm_min_update); rc = sysctl_handle_string(oidp, buf, sizeof(buf), req); if (rc || req->newptr == NULL) return rc; if (sscanf(buf, "%hhu.%hhu.%hhu%*c", &newver[0], &newver[1], &newver[2]) != 3) return EINVAL; softc->ver_info->hwrm_min_major = newver[0]; softc->ver_info->hwrm_min_minor = newver[1]; softc->ver_info->hwrm_min_update = newver[2]; bnxt_check_hwrm_version(softc); return rc; } int bnxt_create_ver_sysctls(struct bnxt_softc *softc) { struct bnxt_ver_info *vi = softc->ver_info; struct sysctl_oid *oid = vi->ver_oid; if (!oid) return ENOMEM; SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "hwrm_if", CTLFLAG_RD, vi->hwrm_if_ver, 0, "HWRM interface version"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "driver_hwrm_if", CTLFLAG_RD, vi->driver_hwrm_if_ver, 0, "HWRM firmware version"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "mgmt_fw", CTLFLAG_RD, vi->mgmt_fw_ver, 0, "management firmware version"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "netctrl_fw", CTLFLAG_RD, vi->netctrl_fw_ver, 0, "network control firmware version"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "roce_fw", CTLFLAG_RD, vi->roce_fw_ver, 0, "RoCE firmware version"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "fw_ver", CTLFLAG_RD, vi->fw_ver_str, 0, "Firmware version"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "phy", CTLFLAG_RD, vi->phy_ver, 0, "PHY version"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "hwrm_fw_name", CTLFLAG_RD, vi->hwrm_fw_name, 0, "HWRM firmware name"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "mgmt_fw_name", CTLFLAG_RD, vi->mgmt_fw_name, 0, "management firmware name"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "netctrl_fw_name", CTLFLAG_RD, vi->netctrl_fw_name, 0, "network control firmware name"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "roce_fw_name", CTLFLAG_RD, vi->roce_fw_name, 0, "RoCE firmware name"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "phy_vendor", CTLFLAG_RD, vi->phy_vendor, 0, "PHY vendor name"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "phy_partnumber", CTLFLAG_RD, vi->phy_partnumber, 0, "PHY vendor part number"); SYSCTL_ADD_U16(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "chip_num", CTLFLAG_RD, &vi->chip_num, 0, "chip number"); SYSCTL_ADD_U8(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "chip_rev", CTLFLAG_RD, &vi->chip_rev, 0, "chip revision"); SYSCTL_ADD_U8(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "chip_metal", CTLFLAG_RD, &vi->chip_metal, 0, "chip metal number"); SYSCTL_ADD_U8(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "chip_bond_id", CTLFLAG_RD, &vi->chip_bond_id, 0, "chip bond id"); SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "chip_type", CTLFLAG_RD, vi->chip_type > MAX_CHIP_TYPE ? bnxt_chip_type[MAX_CHIP_TYPE] : bnxt_chip_type[vi->chip_type], 0, "RoCE firmware name"); SYSCTL_ADD_PROC(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "package_ver", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, bnxt_package_ver_sysctl, "A", "currently installed package version"); SYSCTL_ADD_PROC(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "hwrm_min_ver", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_hwrm_min_ver_sysctl, "A", "minimum hwrm API vesion to support"); return 0; } int bnxt_create_nvram_sysctls(struct bnxt_nvram_info *ni) { struct sysctl_oid *oid = ni->nvm_oid; if (!oid) return ENOMEM; SYSCTL_ADD_U16(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "mfg_id", CTLFLAG_RD, &ni->mfg_id, 0, "manufacturer id"); SYSCTL_ADD_U16(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "device_id", CTLFLAG_RD, &ni->device_id, 0, "device id"); SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "sector_size", CTLFLAG_RD, &ni->sector_size, 0, "sector size"); SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "size", CTLFLAG_RD, &ni->size, 0, "nvram total size"); SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "reserved_size", CTLFLAG_RD, &ni->reserved_size, 0, "total reserved space"); SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "available_size", CTLFLAG_RD, &ni->available_size, 0, "total available space"); return 0; } static int bnxt_rss_key_sysctl(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; char buf[HW_HASH_KEY_SIZE*2+1] = {0}; char *p; int i; int rc; for (p = buf, i=0; ivnic_info.rss_hash_key[i]); rc = sysctl_handle_string(oidp, buf, sizeof(buf), req); if (rc || req->newptr == NULL) return rc; if (strspn(buf, "0123456789abcdefABCDEF") != (HW_HASH_KEY_SIZE * 2)) return EINVAL; for (p = buf, i=0; ivnic_info.rss_hash_key[i]) != 1) return EINVAL; p += 2; } if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING) bnxt_hwrm_rss_cfg(softc, &softc->vnic_info, softc->vnic_info.rss_hash_type); return rc; } static const char *bnxt_hash_types[] = {"ipv4", "tcp_ipv4", "udp_ipv4", "ipv6", "tcp_ipv6", "udp_ipv6", NULL}; static int bnxt_get_rss_type_str_bit(char *str) { int i; for (i=0; bnxt_hash_types[i]; i++) if (strcmp(bnxt_hash_types[i], str) == 0) return i; return -1; } static int bnxt_rss_type_sysctl(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; char buf[256] = {0}; char *p; char *next; int rc; int type; int bit; for (type = softc->vnic_info.rss_hash_type; type; type &= ~(1<= sizeof(bnxt_hash_types) / sizeof(const char *)) continue; if (type != softc->vnic_info.rss_hash_type) strcat(buf, ","); strcat(buf, bnxt_hash_types[bit]); } rc = sysctl_handle_string(oidp, buf, sizeof(buf), req); if (rc || req->newptr == NULL) return rc; for (type = 0, next = buf, p = strsep(&next, " ,"); p; p = strsep(&next, " ,")) { bit = bnxt_get_rss_type_str_bit(p); if (bit == -1) return EINVAL; type |= 1<vnic_info.rss_hash_type) { softc->vnic_info.rss_hash_type = type; if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING) bnxt_hwrm_rss_cfg(softc, &softc->vnic_info, softc->vnic_info.rss_hash_type); } return rc; } static int bnxt_rx_stall_sysctl(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; int rc; int val; if (softc == NULL) return EBUSY; val = (bool)(softc->vnic_info.flags & BNXT_VNIC_FLAG_BD_STALL); rc = sysctl_handle_int(oidp, &val, 0, req); if (rc || !req->newptr) return rc; if (val) softc->vnic_info.flags |= BNXT_VNIC_FLAG_BD_STALL; else softc->vnic_info.flags &= ~BNXT_VNIC_FLAG_BD_STALL; if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING) rc = bnxt_hwrm_vnic_cfg(softc, &softc->vnic_info); return rc; } static int bnxt_vlan_strip_sysctl(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; int rc; int val; if (softc == NULL) return EBUSY; val = (bool)(softc->vnic_info.flags & BNXT_VNIC_FLAG_VLAN_STRIP); rc = sysctl_handle_int(oidp, &val, 0, req); if (rc || !req->newptr) return rc; if (val) softc->vnic_info.flags |= BNXT_VNIC_FLAG_VLAN_STRIP; else softc->vnic_info.flags &= ~BNXT_VNIC_FLAG_VLAN_STRIP; if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING) rc = bnxt_hwrm_vnic_cfg(softc, &softc->vnic_info); return rc; } static int bnxt_set_coal_rx_usecs(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; int rc; int val; if (softc == NULL) return EBUSY; val = softc->rx_coal_usecs; rc = sysctl_handle_int(oidp, &val, 0, req); if (rc || !req->newptr) return rc; softc->rx_coal_usecs = val; rc = bnxt_hwrm_set_coal(softc); return rc; } static int bnxt_set_coal_rx_frames(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; int rc; int val; if (softc == NULL) return EBUSY; val = softc->rx_coal_frames; rc = sysctl_handle_int(oidp, &val, 0, req); if (rc || !req->newptr) return rc; softc->rx_coal_frames = val; rc = bnxt_hwrm_set_coal(softc); return rc; } static int bnxt_set_coal_rx_usecs_irq(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; int rc; int val; if (softc == NULL) return EBUSY; val = softc->rx_coal_usecs_irq; rc = sysctl_handle_int(oidp, &val, 0, req); if (rc || !req->newptr) return rc; softc->rx_coal_usecs_irq = val; rc = bnxt_hwrm_set_coal(softc); return rc; } static int bnxt_set_coal_rx_frames_irq(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; int rc; int val; if (softc == NULL) return EBUSY; val = softc->rx_coal_frames_irq; rc = sysctl_handle_int(oidp, &val, 0, req); if (rc || !req->newptr) return rc; softc->rx_coal_frames_irq = val; rc = bnxt_hwrm_set_coal(softc); return rc; } static int bnxt_set_coal_tx_usecs(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; int rc; int val; if (softc == NULL) return EBUSY; val = softc->tx_coal_usecs; rc = sysctl_handle_int(oidp, &val, 0, req); if (rc || !req->newptr) return rc; softc->tx_coal_usecs = val; rc = bnxt_hwrm_set_coal(softc); return rc; } static int bnxt_set_coal_tx_frames(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; int rc; int val; if (softc == NULL) return EBUSY; val = softc->tx_coal_frames; rc = sysctl_handle_int(oidp, &val, 0, req); if (rc || !req->newptr) return rc; softc->tx_coal_frames = val; rc = bnxt_hwrm_set_coal(softc); return rc; } static int bnxt_set_coal_tx_usecs_irq(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; int rc; int val; if (softc == NULL) return EBUSY; val = softc->tx_coal_usecs_irq; rc = sysctl_handle_int(oidp, &val, 0, req); if (rc || !req->newptr) return rc; softc->tx_coal_usecs_irq = val; rc = bnxt_hwrm_set_coal(softc); return rc; } static int bnxt_set_coal_tx_frames_irq(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; int rc; int val; if (softc == NULL) return EBUSY; val = softc->tx_coal_frames_irq; rc = sysctl_handle_int(oidp, &val, 0, req); if (rc || !req->newptr) return rc; softc->tx_coal_frames_irq = val; rc = bnxt_hwrm_set_coal(softc); return rc; } int bnxt_create_config_sysctls_pre(struct bnxt_softc *softc) { struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(softc->dev); struct sysctl_oid_list *children; children = SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rss_key", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_rss_key_sysctl, "A", "RSS key"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rss_type", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_rss_type_sysctl, "A", "RSS type bits"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rx_stall", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_rx_stall_sysctl, "I", "buffer rx packets in hardware until the host posts new buffers"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "vlan_strip", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_vlan_strip_sysctl, "I", "strip VLAN tag in the RX path"); SYSCTL_ADD_CONST_STRING(ctx, children, OID_AUTO, "if_name", CTLFLAG_RD, if_name(iflib_get_ifp(softc->ctx)), "interface name"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_usecs", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_set_coal_rx_usecs, "I", "interrupt coalescing Rx Usecs"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_frames", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_set_coal_rx_frames, "I", "interrupt coalescing Rx Frames"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_usecs_irq", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_set_coal_rx_usecs_irq, "I", "interrupt coalescing Rx Usecs IRQ"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_frames_irq", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_set_coal_rx_frames_irq, "I", "interrupt coalescing Rx Frames IRQ"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_usecs", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_set_coal_tx_usecs, "I", "interrupt coalescing Tx Usces"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_frames", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_set_coal_tx_frames, "I", "interrupt coalescing Tx Frames"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_usecs_irq", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_set_coal_tx_usecs_irq, "I", "interrupt coalescing Tx Usecs IRQ"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_frames_irq", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_set_coal_tx_frames_irq, "I", "interrupt coalescing Tx Frames IRQ"); SYSCTL_ADD_U32(ctx, children, OID_AUTO, "flags", CTLFLAG_RD, &softc->flags, 0, "flags"); SYSCTL_ADD_U64(ctx, children, OID_AUTO, "fw_cap", CTLFLAG_RD, &softc->fw_cap, 0, "FW caps"); return 0; } #define BNXT_HW_LRO_FN(fn_name, arg) \ static int \ fn_name(SYSCTL_HANDLER_ARGS) { \ struct bnxt_softc *softc = arg1; \ int rc; \ int val; \ \ if (softc == NULL) \ return EBUSY; \ \ val = softc->hw_lro.arg; \ rc = sysctl_handle_int(oidp, &val, 0, req); \ if (rc || !req->newptr) \ return rc; \ \ if ((if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)) \ return EBUSY; \ \ if (!(softc->flags & BNXT_FLAG_TPA)) \ return EINVAL; \ \ softc->hw_lro.arg = val; \ bnxt_validate_hw_lro_settings(softc); \ rc = bnxt_hwrm_vnic_tpa_cfg(softc); \ \ return rc; \ } BNXT_HW_LRO_FN(bnxt_hw_lro_enable_disable, enable) BNXT_HW_LRO_FN(bnxt_hw_lro_set_mode, is_mode_gro) BNXT_HW_LRO_FN(bnxt_hw_lro_set_max_agg_segs, max_agg_segs) BNXT_HW_LRO_FN(bnxt_hw_lro_set_max_aggs, max_aggs) BNXT_HW_LRO_FN(bnxt_hw_lro_set_min_agg_len, min_agg_len) #define BNXT_FLOW_CTRL_FN(fn_name, arg) \ static int \ fn_name(SYSCTL_HANDLER_ARGS) { \ struct bnxt_softc *softc = arg1; \ int rc; \ int val; \ \ if (softc == NULL) \ return EBUSY; \ \ val = softc->link_info.flow_ctrl.arg; \ rc = sysctl_handle_int(oidp, &val, 0, req); \ if (rc || !req->newptr) \ return rc; \ \ if (val) \ val = 1; \ \ if (softc->link_info.flow_ctrl.arg != val) { \ softc->link_info.flow_ctrl.arg = val; \ rc = bnxt_hwrm_set_link_setting(softc, true, false, false);\ rc = bnxt_hwrm_port_phy_qcfg(softc); \ } \ \ return rc; \ } BNXT_FLOW_CTRL_FN(bnxt_flow_ctrl_tx, tx) BNXT_FLOW_CTRL_FN(bnxt_flow_ctrl_rx, rx) BNXT_FLOW_CTRL_FN(bnxt_flow_ctrl_autoneg, autoneg) int bnxt_create_pause_fc_sysctls(struct bnxt_softc *softc) { struct sysctl_oid *oid = softc->flow_ctrl_oid; if (!oid) return ENOMEM; SYSCTL_ADD_PROC(&softc->flow_ctrl_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "tx", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_flow_ctrl_tx, "A", "Enable or Disable Tx Flow Ctrl: 0 / 1"); SYSCTL_ADD_PROC(&softc->flow_ctrl_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "rx", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_flow_ctrl_rx, "A", "Enable or Disable Tx Flow Ctrl: 0 / 1"); SYSCTL_ADD_PROC(&softc->flow_ctrl_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "autoneg", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_flow_ctrl_autoneg, "A", "Enable or Disable Autoneg Flow Ctrl: 0 / 1"); return 0; } int bnxt_create_hw_lro_sysctls(struct bnxt_softc *softc) { struct sysctl_oid *oid = softc->hw_lro_oid; if (!oid) return ENOMEM; SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "enable", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_hw_lro_enable_disable, "A", "Enable or Disable HW LRO: 0 / 1"); SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "gro_mode", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_hw_lro_set_mode, "A", "Set mode: 1 = GRO mode, 0 = RSC mode"); SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "max_agg_segs", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_hw_lro_set_max_agg_segs, "A", "Set Max Agg Seg Value (unit is Log2): " "0 (= 1 seg) / 1 (= 2 segs) / ... / 31 (= 2^31 segs)"); SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "max_aggs", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_hw_lro_set_max_aggs, "A", "Set Max Aggs Value (unit is Log2): " "0 (= 1 agg) / 1 (= 2 aggs) / ... / 7 (= 2^7 segs)"); SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "min_agg_len", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, bnxt_hw_lro_set_min_agg_len, "A", "Min Agg Len: 1 to 9000"); return 0; } static int bnxt_dcb_dcbx_cap(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; int val; int rc; if (softc == NULL) return EBUSY; val = bnxt_dcb_getdcbx(softc); rc = sysctl_handle_int(oidp, &val, 0, req); if (rc || !req->newptr) return rc; bnxt_dcb_setdcbx(softc, val); return rc; } static char bnxt_ets_tsa_to_str(struct bnxt_softc *softc, uint32_t tc) { switch (softc->ieee_ets->tc_tsa[tc]) { case BNXT_IEEE_8021QAZ_TSA_STRICT: return 's'; case BNXT_IEEE_8021QAZ_TSA_ETS: return 'e'; default: return 'X'; } } static uint32_t bnxt_ets_str_to_tsa(char tsa_str) { switch (tsa_str) { case 's': return BNXT_IEEE_8021QAZ_TSA_STRICT; case 'e': return BNXT_IEEE_8021QAZ_TSA_ETS; default: return -1; } } static int bnxt_ets_get_val(struct bnxt_softc *softc, uint32_t type, uint32_t tc) { switch (type) { case BNXT_TYPE_ETS_TSA: if (softc->ieee_ets) return softc->ieee_ets->tc_tsa[tc]; break; case BNXT_TYPE_ETS_PRI2TC: if (softc->ieee_ets) return softc->ieee_ets->prio_tc[tc]; break; case BNXT_TYPE_ETS_TCBW: if (softc->ieee_ets) return softc->ieee_ets->tc_tx_bw[tc]; break; default: break; } return -1; } static void bnxt_pfc_get_string(struct bnxt_softc *softc, char *buf, struct bnxt_ieee_pfc *pfc) { uint32_t i; bool found = false; for (i = 0; i < BNXT_IEEE_8021QAZ_MAX_TCS; i++) { if (pfc->pfc_en & (1 << i)) { if (found) buf += sprintf(buf, ", "); buf += sprintf(buf, "%d", i); found = true; } } if (!found) buf += sprintf(buf, "none"); } static char *bnxt_get_tlv_selector_str(uint8_t selector) { switch (selector) { case BNXT_IEEE_8021QAZ_APP_SEL_ETHERTYPE: return "Ethertype"; case BNXT_IEEE_8021QAZ_APP_SEL_DGRAM: return "UDP or DCCP"; case BNXT_IEEE_8021QAZ_APP_SEL_DSCP: return "DSCP"; default: return "Unknown"; } } static void bnxt_app_tlv_get_string(struct bnxt_softc *softc, char *buf, struct bnxt_dcb_app *app, int num) { uint32_t i; if (!num) { buf += sprintf(buf, " None"); return; } buf += sprintf(buf, "\n"); for (i = 0; i < num; i++) { buf += sprintf(buf, "\tAPP#%0d:\tpri: %d,\tSel: %d,\t%s: %d\n", i, app[i].priority, app[i].selector, bnxt_get_tlv_selector_str(app[i].selector), app[i].protocol); } } static void bnxt_ets_get_string(struct bnxt_softc *softc, char *buf) { uint32_t type, i; type = BNXT_TYPE_ETS_TSA; for (type = 0; type < BNXT_TYPE_ETS_MAX; type++) { for (i = 0; i < BNXT_IEEE_8021QAZ_MAX_TCS; i++) { if (i == 0) buf += sprintf(buf, "%s:", BNXT_ETS_TYPE_STR[type]); if (!softc->ieee_ets) buf += sprintf(buf, "x"); else if (type == BNXT_TYPE_ETS_TSA) buf += sprintf(buf, "%c", bnxt_ets_tsa_to_str(softc, i)); else buf += sprintf(buf, "%d", bnxt_ets_get_val(softc, type, i)); if (i != BNXT_IEEE_8021QAZ_MAX_TCS - 1) buf += sprintf(buf, ","); } if (type != BNXT_TYPE_ETS_MAX - 1) buf += sprintf(buf, "#"); } } static int bnxt_dcb_list_app(SYSCTL_HANDLER_ARGS) { struct bnxt_dcb_app app[128] = {0}; struct bnxt_softc *softc = arg1; int rc, num_inputs = 0; char *buf; if (softc == NULL) return EBUSY; #define BNXT_APP_TLV_STR_LEN 4096 buf = malloc(BNXT_APP_TLV_STR_LEN, M_DEVBUF, M_NOWAIT | M_ZERO); if (!buf) return ENOMEM; bnxt_dcb_ieee_listapp(softc, app, &num_inputs); bnxt_app_tlv_get_string(softc, buf, app, num_inputs); rc = sysctl_handle_string(oidp, buf, BNXT_APP_TLV_STR_LEN, req); if (rc || req->newptr == NULL) goto end; end: free(buf, M_DEVBUF); return rc; } static int bnxt_dcb_del_app(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; struct bnxt_dcb_app app = {0}; char buf[256] = {0}; int rc, num_inputs; if (softc == NULL) return EBUSY; rc = sysctl_handle_string(oidp, buf, sizeof(buf), req); if (rc || req->newptr == NULL) return rc; num_inputs = sscanf(buf, "%hhu,%hhu,%hd", &app.priority, &app.selector, &app.protocol); if (num_inputs != 3) { device_printf(softc->dev, "Invalid app tlv syntax, inputs = %d\n", num_inputs); return EINVAL; } bnxt_dcb_ieee_delapp(softc, &app); return rc; } static int bnxt_dcb_set_app(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; struct bnxt_dcb_app app = {0}; char buf[256] = {0}; int rc, num_inputs; if (softc == NULL) return EBUSY; rc = sysctl_handle_string(oidp, buf, sizeof(buf), req); if (rc || req->newptr == NULL) return rc; num_inputs = sscanf(buf, "%hhu,%hhu,%hd", &app.priority, &app.selector, &app.protocol); if (num_inputs != 3) { device_printf(softc->dev, "Invalid app tlv syntax, inputs = %d\n", num_inputs); return EINVAL; } bnxt_dcb_ieee_setapp(softc, &app); return rc; } static int bnxt_dcb_pfc(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; struct bnxt_ieee_pfc pfc = {0}; int rc, i, num_inputs; char buf[256] = {0}; int pri_mask = 0; char pri[8]; if (softc == NULL) return EBUSY; rc = bnxt_dcb_ieee_getpfc(softc, &pfc); if (!rc) bnxt_pfc_get_string(softc, buf, &pfc); else sprintf(buf, "## getpfc failed with error %d ##", rc); rc = sysctl_handle_string(oidp, buf, sizeof(buf), req); if (rc || req->newptr == NULL) return rc; /* Check for 'none' string first */ if (sscanf(buf, "%s", buf) == 1) { if (strncmp(buf, "none", 8) == 0) { goto configure; } } num_inputs = sscanf(buf, "%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu", &pri[0], &pri[1], &pri[2], &pri[3], &pri[4], &pri[5], &pri[6], &pri[7]); if (num_inputs < 1 || num_inputs > 8) { device_printf(softc->dev, "Invalid pfc syntax, inputs = %d\n", num_inputs); return EINVAL; } for (i = 0; i < num_inputs; i++) { if (pri[i] > 7 || pri[i] < 0) { device_printf(softc->dev, "Invalid priority %d. Valid priorties are " "from 0 to 7 and string \"none\".\n", pri[i]); return EINVAL; } pri_mask |= (1 << pri[i]) & 0xFF; } configure: pfc.pfc_en = pri_mask; rc = bnxt_dcb_ieee_setpfc(softc, &pfc); if (rc) device_printf(softc->dev, "setpfc failed with status %d\n", rc); return rc; } static int bnxt_dcb_ets(SYSCTL_HANDLER_ARGS) { struct bnxt_softc *softc = arg1; struct bnxt_ieee_ets ets = {0}; int rc = 0, i, num_inputs; char buf[256] = {0}; char tsa[8]; if (softc == NULL) return EBUSY; rc = bnxt_dcb_ieee_getets(softc, &ets); if (!rc) bnxt_ets_get_string(softc, buf); else sprintf(buf, "## getets failed with error %d ##", rc); rc = sysctl_handle_string(oidp, buf, sizeof(buf), req); if (rc || req->newptr == NULL) return rc; num_inputs = sscanf(buf, "tsa:%c,%c,%c,%c,%c,%c,%c,%c#" "pri2tc:%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu#" "tcbw:%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu", &tsa[0], &tsa[1], &tsa[2], &tsa[3], &tsa[4], &tsa[5], &tsa[6], &tsa[7], &ets.prio_tc[0], &ets.prio_tc[1], &ets.prio_tc[2], &ets.prio_tc[3], &ets.prio_tc[4], &ets.prio_tc[5], &ets.prio_tc[6], &ets.prio_tc[7], &ets.tc_tx_bw[0], &ets.tc_tx_bw[1], &ets.tc_tx_bw[2], &ets.tc_tx_bw[3], &ets.tc_tx_bw[4], &ets.tc_tx_bw[5], &ets.tc_tx_bw[6], &ets.tc_tx_bw[7]); if (num_inputs != 24) return EINVAL; for ( i= 0; i < 8; i++) ets.tc_tsa[i] = bnxt_ets_str_to_tsa(tsa[i]); rc = bnxt_dcb_ieee_setets(softc, &ets); return rc; } int bnxt_create_dcb_sysctls(struct bnxt_softc *softc) { struct sysctl_oid *oid = softc->dcb_oid; if (!oid) return ENOMEM; SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "dcbx_cap", CTLTYPE_INT | CTLFLAG_RWTUN, softc, 0, bnxt_dcb_dcbx_cap, "A", "Enable or Disable LRO: 0 / 1"); SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "ets", CTLTYPE_STRING | CTLFLAG_RWTUN, softc, 0, bnxt_dcb_ets, "A", "Enhanced Transmission Selection (ETS)"); SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc", CTLTYPE_STRING | CTLFLAG_RWTUN, softc, 0, bnxt_dcb_pfc, "A", "Enhanced Transmission Selection (ETS)"); SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "set_apptlv", CTLTYPE_STRING | CTLFLAG_WR, softc, 0, bnxt_dcb_set_app, "A", "Set App TLV"); SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "del_apptlv", CTLTYPE_STRING | CTLFLAG_WR, softc, 0, bnxt_dcb_del_app, "A", "Delete App TLV"); SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "list_apptlv", CTLTYPE_STRING | CTLFLAG_RD, softc, 0, bnxt_dcb_list_app, "A", "List all App TLVs"); return 0; } int bnxt_create_config_sysctls_post(struct bnxt_softc *softc) { /* Nothing for now, meant for future expansion */ return 0; }