/* * Broadcom NetXtreme-C/E network driver. * * Copyright (c) 2022 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 "bnxt.h" #include #include #include #include #include #include #include #include #define DRIVER_NAME "if_bnxt" #define IOW_BNXT_MGMT_OPCODE_GET_DEV_INFO _IOC(IOC_IN, 0, 0, 0) #define IOW_BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM _IOC(IOC_IN, 0, 1, 0) #define IOW_BNXT_MGMT_OPCODE_DCB_OPS _IOC(IOC_IN, 0, 2, 0) #define IOW_BNXT_MGMT_OPCODE_DRV_DUMP _IOC(IOC_IN, 0, 3, 0) #define IOW_BNXT_MGMT_OPCODE_CRASH_DUMP _IOC(IOC_IN, 0, 4, 0) #define IO_BNXT_MGMT_OPCODE_GET_DEV_INFO _IO(0, 0) #define IO_BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM _IO(0, 1) #define IO_BNXT_MGMT_OPCODE_DCB_OPS _IO(0, 2) #define IO_BNXT_MGMT_OPCODE_DRV_DUMP _IO(0, 3) #define IO_BNXT_MGMT_OPCODE_CRASH_DUMP _IO(0, 4) #define BNXT_MGMT_MAX_HWRM_REQ_LENGTH HWRM_MAX_REQ_LEN #define BNXT_MGMT_MAX_HWRM_RESP_LENGTH (512) struct bnxt_nic_info { #define BNXT_MAX_STR 64 char dev_name[BNXT_MAX_STR]; char driver_version[BNXT_MAX_STR]; char driver_name[BNXT_MAX_STR]; char device_serial_number[64]; uint32_t mtu; uint8_t mac[ETHER_ADDR_LEN]; uint32_t pci_link_speed; uint32_t pci_link_width; uint32_t rsvd[4]; } __packed; struct bnxt_pci_info { uint16_t domain_no; uint16_t bus_no; uint16_t device_no; uint16_t function_no; uint16_t vendor_id; uint16_t device_id; uint16_t sub_system_vendor_id; uint16_t sub_system_device_id; uint16_t revision; uint32_t chip_rev_id; uint32_t rsvd[2]; } __packed; struct bnxt_dev_info { struct bnxt_nic_info nic_info; struct bnxt_pci_info pci_info; } __packed; struct dma_info { uint64_t data; uint32_t length; uint16_t offset; uint8_t read_or_write; uint8_t unused; }; struct bnxt_mgmt_fw_msg { uint64_t usr_req; uint64_t usr_resp; uint32_t len_req; uint32_t len_resp; uint32_t timeout; uint32_t num_dma_indications; struct dma_info dma[0]; }; struct bnxt_mgmt_generic_msg { uint8_t key; #define BNXT_LFC_KEY_DOMAIN_NO 1 uint8_t reserved[3]; uint32_t value; }; enum bnxt_mgmt_req_type { BNXT_MGMT_NVM_GET_VAR_REQ = 1, BNXT_MGMT_NVM_SET_VAR_REQ, BNXT_MGMT_NVM_FLUSH_REQ, BNXT_MGMT_GENERIC_HWRM_REQ, }; struct bnxt_mgmt_req_hdr { uint32_t ver; uint32_t domain; uint32_t bus; uint32_t devfn; enum bnxt_mgmt_req_type req_type; }; struct bnxt_mgmt_req { struct bnxt_mgmt_req_hdr hdr; union { uint64_t hreq; } req; }; struct bnxt_mgmt_app_tlv { uint32_t num_app; struct bnxt_dcb_app app[128]; } __attribute__ ((__packed__)); struct bnxt_mgmt_dcb { struct bnxt_mgmt_req_hdr hdr; #define BNXT_MGMT_DCB_GET_ETS 0x1 #define BNXT_MGMT_DCB_SET_ETS 0x2 #define BNXT_MGMT_DCB_GET_PFC 0x3 #define BNXT_MGMT_DCB_SET_PFC 0x4 #define BNXT_MGMT_DCB_SET_APP 0x5 #define BNXT_MGMT_DCB_DEL_APP 0x6 #define BNXT_MGMT_DCB_LIST_APP 0x7 #define BNXT_MGMT_DCB_MAX BNXT_MGMT_DCB_LIST_APP uint32_t op; union { struct bnxt_ieee_ets ets; struct bnxt_ieee_pfc pfc; struct bnxt_mgmt_app_tlv app_tlv; } req; } __attribute__ ((__packed__)); struct bnxt_mgmt_drv_dump { struct bnxt_mgmt_req_hdr hdr; #define BNXT_MGMT_GET_DRV_DUMP_SIZE 0x1 #define BNXT_MGMT_GET_DRV_DUMP 0x2 #define BNXT_MGMT_DRV_DUMP_MAX BNXT_MGMT_GET_DRV_DUMP uint32_t op; void *buf; uint32_t buf_size; } __attribute__ ((__packed__)); struct bnxt_mgmt_crash_dump { struct bnxt_mgmt_req_hdr hdr; #define BNXT_MGMT_SET_DUMP_FLAG 0x1 #define BNXT_MGMT_GET_DUMP_FLAG 0x2 #define BNXT_MGMT_GET_DUMP_DATA 0x3 #define BNXT_MGMT_CRASH_DUMP_MAX BNXT_MGMT_GET_DUMP_DATA uint32_t op; union { struct { uint32_t dump_flag; } set_flag; struct { uint32_t dump_flag; uint32_t dump_len; uint32_t version; } get_flag; struct { uint32_t dump_flag; uint32_t dump_len; void *dump_buffer; size_t buffer_size; } get_data; } req; } __attribute__ ((__packed__)); struct bnxt_driver_segment_record { uint32_t max_entries; uint32_t entry_size; uint32_t offset; uint8_t wrapped:1; uint8_t reserved[3]; }; #define DRV_COREDUMP_COMP_ID 0xD #define DRV_SRT_TRACE_SEG_ID 1 #define DRV_SRT2_TRACE_SEG_ID 2 #define DRV_CRT_TRACE_SEG_ID 3 #define DRV_CRT2_TRACE_SEG_ID 4 #define DRV_RIGP0_TRACE_SEG_ID 5 #define DRV_LOG_HWRM_L2_TRACE_SEG_ID 6 #define DRV_LOG_HWRM_ROCE_TRACE_SEG_ID 7 void bnxt_get_ctx_coredump(struct bnxt_softc *, void *);