1718cf2ccSPedro F. Giffuni /*- 24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 435291c22SDavid C Somayajulu * Copyright (c) 2013-2016 Qlogic Corporation 5f10a77bbSDavid C Somayajulu * All rights reserved. 6f10a77bbSDavid C Somayajulu * 7f10a77bbSDavid C Somayajulu * Redistribution and use in source and binary forms, with or without 8f10a77bbSDavid C Somayajulu * modification, are permitted provided that the following conditions 9f10a77bbSDavid C Somayajulu * are met: 10f10a77bbSDavid C Somayajulu * 11f10a77bbSDavid C Somayajulu * 1. Redistributions of source code must retain the above copyright 12f10a77bbSDavid C Somayajulu * notice, this list of conditions and the following disclaimer. 13f10a77bbSDavid C Somayajulu * 2. Redistributions in binary form must reproduce the above copyright 14f10a77bbSDavid C Somayajulu * notice, this list of conditions and the following disclaimer in the 15f10a77bbSDavid C Somayajulu * documentation and/or other materials provided with the distribution. 16f10a77bbSDavid C Somayajulu * 17f10a77bbSDavid C Somayajulu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18f10a77bbSDavid C Somayajulu * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19f10a77bbSDavid C Somayajulu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20f10a77bbSDavid C Somayajulu * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21f10a77bbSDavid C Somayajulu * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22f10a77bbSDavid C Somayajulu * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23f10a77bbSDavid C Somayajulu * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24f10a77bbSDavid C Somayajulu * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25f10a77bbSDavid C Somayajulu * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26f10a77bbSDavid C Somayajulu * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27f10a77bbSDavid C Somayajulu * POSSIBILITY OF SUCH DAMAGE. 28f10a77bbSDavid C Somayajulu */ 29f10a77bbSDavid C Somayajulu /* 30f10a77bbSDavid C Somayajulu * File: ql_ioctl.h 31f10a77bbSDavid C Somayajulu * Author : David C Somayajulu, Qlogic Corporation, Aliso Viejo, CA 92656. 32f10a77bbSDavid C Somayajulu */ 33f10a77bbSDavid C Somayajulu 34f10a77bbSDavid C Somayajulu #ifndef _QL_IOCTL_H_ 35f10a77bbSDavid C Somayajulu #define _QL_IOCTL_H_ 36f10a77bbSDavid C Somayajulu 37f10a77bbSDavid C Somayajulu #include <sys/ioccom.h> 38f10a77bbSDavid C Somayajulu 39f10a77bbSDavid C Somayajulu struct qla_reg_val { 40f10a77bbSDavid C Somayajulu uint16_t rd; 41f10a77bbSDavid C Somayajulu uint16_t direct; 42f10a77bbSDavid C Somayajulu uint32_t reg; 43f10a77bbSDavid C Somayajulu uint32_t val; 44f10a77bbSDavid C Somayajulu }; 45f10a77bbSDavid C Somayajulu typedef struct qla_reg_val qla_reg_val_t; 46f10a77bbSDavid C Somayajulu 47f10a77bbSDavid C Somayajulu struct qla_rd_flash { 48f10a77bbSDavid C Somayajulu uint32_t off; 49f10a77bbSDavid C Somayajulu uint32_t data; 50f10a77bbSDavid C Somayajulu }; 51f10a77bbSDavid C Somayajulu typedef struct qla_rd_flash qla_rd_flash_t; 52f10a77bbSDavid C Somayajulu 53f10a77bbSDavid C Somayajulu struct qla_wr_flash { 54f10a77bbSDavid C Somayajulu uint32_t off; 55f10a77bbSDavid C Somayajulu uint32_t size; 56f10a77bbSDavid C Somayajulu void *buffer; 57f10a77bbSDavid C Somayajulu uint32_t pattern; 58f10a77bbSDavid C Somayajulu }; 59f10a77bbSDavid C Somayajulu typedef struct qla_wr_flash qla_wr_flash_t; 60f10a77bbSDavid C Somayajulu 61f10a77bbSDavid C Somayajulu struct qla_erase_flash { 62f10a77bbSDavid C Somayajulu uint32_t off; 63f10a77bbSDavid C Somayajulu uint32_t size; 64f10a77bbSDavid C Somayajulu }; 65f10a77bbSDavid C Somayajulu typedef struct qla_erase_flash qla_erase_flash_t; 66f10a77bbSDavid C Somayajulu 67f10a77bbSDavid C Somayajulu struct qla_rd_pci_ids { 68f10a77bbSDavid C Somayajulu uint16_t ven_id; 69f10a77bbSDavid C Somayajulu uint16_t dev_id; 70f10a77bbSDavid C Somayajulu uint16_t subsys_ven_id; 71f10a77bbSDavid C Somayajulu uint16_t subsys_dev_id; 72f10a77bbSDavid C Somayajulu uint8_t rev_id; 73f10a77bbSDavid C Somayajulu }; 74f10a77bbSDavid C Somayajulu typedef struct qla_rd_pci_ids qla_rd_pci_ids_t; 75f10a77bbSDavid C Somayajulu 76b65c0c07SDavid C Somayajulu #define NUM_LOG_ENTRY_PARAMS 5 77b65c0c07SDavid C Somayajulu #define NUM_LOG_ENTRIES 512 78b65c0c07SDavid C Somayajulu 79b65c0c07SDavid C Somayajulu struct qla_sp_log_entry { 80b65c0c07SDavid C Somayajulu uint32_t fmtstr_idx; 81b65c0c07SDavid C Somayajulu uint32_t num_params; 82b65c0c07SDavid C Somayajulu uint64_t usec_ts; 83b65c0c07SDavid C Somayajulu uint32_t params[NUM_LOG_ENTRY_PARAMS]; 84b65c0c07SDavid C Somayajulu }; 85b65c0c07SDavid C Somayajulu typedef struct qla_sp_log_entry qla_sp_log_entry_t; 86b65c0c07SDavid C Somayajulu 87f10a77bbSDavid C Somayajulu /* 88f10a77bbSDavid C Somayajulu * structure encapsulating the value to read/write from/to offchip (MS) memory 89f10a77bbSDavid C Somayajulu */ 90f10a77bbSDavid C Somayajulu struct qla_offchip_mem_val { 91f10a77bbSDavid C Somayajulu uint16_t rd; 92f10a77bbSDavid C Somayajulu uint64_t off; 93f10a77bbSDavid C Somayajulu uint32_t data_lo; 94f10a77bbSDavid C Somayajulu uint32_t data_hi; 95f10a77bbSDavid C Somayajulu uint32_t data_ulo; 96f10a77bbSDavid C Somayajulu uint32_t data_uhi; 97f10a77bbSDavid C Somayajulu }; 98f10a77bbSDavid C Somayajulu typedef struct qla_offchip_mem_val qla_offchip_mem_val_t; 99f10a77bbSDavid C Somayajulu 100f10a77bbSDavid C Somayajulu struct qla_rd_fw_dump { 101f10a77bbSDavid C Somayajulu uint16_t pci_func; 102b65c0c07SDavid C Somayajulu uint16_t saved; 103b65c0c07SDavid C Somayajulu uint64_t usec_ts; 1046a62bec0SDavid C Somayajulu uint32_t minidump_size; 1056a62bec0SDavid C Somayajulu void *minidump; 106f10a77bbSDavid C Somayajulu }; 107f10a77bbSDavid C Somayajulu typedef struct qla_rd_fw_dump qla_rd_fw_dump_t; 108f10a77bbSDavid C Somayajulu 109ab142b3fSDavid C Somayajulu struct qla_drvr_state_tx { 110ab142b3fSDavid C Somayajulu uint64_t base_p_addr; 111ab142b3fSDavid C Somayajulu uint64_t cons_p_addr; 112ab142b3fSDavid C Somayajulu uint32_t tx_prod_reg; 113ab142b3fSDavid C Somayajulu uint32_t tx_cntxt_id; 114ab142b3fSDavid C Somayajulu uint32_t txr_free; 115ab142b3fSDavid C Somayajulu uint32_t txr_next; 116ab142b3fSDavid C Somayajulu uint32_t txr_comp; 117ab142b3fSDavid C Somayajulu }; 118ab142b3fSDavid C Somayajulu typedef struct qla_drvr_state_tx qla_drvr_state_tx_t; 119ab142b3fSDavid C Somayajulu 120ab142b3fSDavid C Somayajulu struct qla_drvr_state_sds { 121ab142b3fSDavid C Somayajulu uint32_t sdsr_next; /* next entry in SDS ring to process */ 122ab142b3fSDavid C Somayajulu uint32_t sds_consumer; 123ab142b3fSDavid C Somayajulu }; 124ab142b3fSDavid C Somayajulu typedef struct qla_drvr_state_sds qla_drvr_state_sds_t; 125ab142b3fSDavid C Somayajulu 126ab142b3fSDavid C Somayajulu struct qla_drvr_state_rx { 127ab142b3fSDavid C Somayajulu uint32_t prod_std; 128ab142b3fSDavid C Somayajulu uint32_t rx_next; /* next standard rcv ring to arm fw */; 129ab142b3fSDavid C Somayajulu }; 130ab142b3fSDavid C Somayajulu typedef struct qla_drvr_state_rx qla_drvr_state_rx_t; 131ab142b3fSDavid C Somayajulu 132ab142b3fSDavid C Somayajulu struct qla_drvr_state_hdr { 133ab142b3fSDavid C Somayajulu uint32_t drvr_version_major; 134ab142b3fSDavid C Somayajulu uint32_t drvr_version_minor; 135ab142b3fSDavid C Somayajulu uint32_t drvr_version_build; 136ab142b3fSDavid C Somayajulu 137ab142b3fSDavid C Somayajulu uint8_t mac_addr[ETHER_ADDR_LEN]; 138b65c0c07SDavid C Somayajulu uint16_t saved; 139b65c0c07SDavid C Somayajulu uint64_t usec_ts; 140ab142b3fSDavid C Somayajulu uint16_t link_speed; 141ab142b3fSDavid C Somayajulu uint16_t cable_length; 142ab142b3fSDavid C Somayajulu uint32_t cable_oui; 143ab142b3fSDavid C Somayajulu uint8_t link_up; 144ab142b3fSDavid C Somayajulu uint8_t module_type; 145ab142b3fSDavid C Somayajulu uint8_t link_faults; 146ab142b3fSDavid C Somayajulu uint32_t rcv_intr_coalesce; 147ab142b3fSDavid C Somayajulu uint32_t xmt_intr_coalesce; 148ab142b3fSDavid C Somayajulu 149ab142b3fSDavid C Somayajulu uint32_t tx_state_offset;/* size = sizeof (qla_drvr_state_tx_t) * num_tx_rings */ 150ab142b3fSDavid C Somayajulu uint32_t rx_state_offset;/* size = sizeof (qla_drvr_state_rx_t) * num_rx_rings */ 151ab142b3fSDavid C Somayajulu uint32_t sds_state_offset;/* size = sizeof (qla_drvr_state_sds_t) * num_sds_rings */ 152ab142b3fSDavid C Somayajulu 153ab142b3fSDavid C Somayajulu uint32_t num_tx_rings; /* number of tx rings */ 154ab142b3fSDavid C Somayajulu uint32_t txr_size; /* size of each tx ring in bytes */ 155ab142b3fSDavid C Somayajulu uint32_t txr_entries; /* number of descriptors in each tx ring */ 156ab142b3fSDavid C Somayajulu uint32_t txr_offset; /* start of tx ring [0 - #rings] content */ 157ab142b3fSDavid C Somayajulu 158ab142b3fSDavid C Somayajulu uint32_t num_rx_rings; /* number of rx rings */ 159ab142b3fSDavid C Somayajulu uint32_t rxr_size; /* size of each rx ring in bytes */ 160ab142b3fSDavid C Somayajulu uint32_t rxr_entries; /* number of descriptors in each rx ring */ 161ab142b3fSDavid C Somayajulu uint32_t rxr_offset; /* start of rx ring [0 - #rings] content */ 162ab142b3fSDavid C Somayajulu 163ab142b3fSDavid C Somayajulu uint32_t num_sds_rings; /* number of sds rings */ 164ab142b3fSDavid C Somayajulu uint32_t sds_ring_size; /* size of each sds ring in bytes */ 165ab142b3fSDavid C Somayajulu uint32_t sds_entries; /* number of descriptors in each sds ring */ 166ab142b3fSDavid C Somayajulu uint32_t sds_offset; /* start of sds ring [0 - #rings] content */ 167ab142b3fSDavid C Somayajulu }; 168ab142b3fSDavid C Somayajulu 169ab142b3fSDavid C Somayajulu typedef struct qla_drvr_state_hdr qla_drvr_state_hdr_t; 170ab142b3fSDavid C Somayajulu 171ab142b3fSDavid C Somayajulu struct qla_driver_state { 172ab142b3fSDavid C Somayajulu uint32_t size; 173ab142b3fSDavid C Somayajulu void *buffer; 174ab142b3fSDavid C Somayajulu }; 175ab142b3fSDavid C Somayajulu typedef struct qla_driver_state qla_driver_state_t; 176ab142b3fSDavid C Somayajulu 177b65c0c07SDavid C Somayajulu struct qla_sp_log { 178b65c0c07SDavid C Somayajulu uint32_t next_idx; /* index of next entry in slowpath trace log */ 179b65c0c07SDavid C Somayajulu uint32_t num_entries; /* number of entries in slowpath trace log */ 180b65c0c07SDavid C Somayajulu void *buffer; 181b65c0c07SDavid C Somayajulu }; 182b65c0c07SDavid C Somayajulu typedef struct qla_sp_log qla_sp_log_t; 183b65c0c07SDavid C Somayajulu 184f10a77bbSDavid C Somayajulu /* 185f10a77bbSDavid C Somayajulu * Read/Write Register 186f10a77bbSDavid C Somayajulu */ 187f10a77bbSDavid C Somayajulu #define QLA_RDWR_REG _IOWR('q', 1, qla_reg_val_t) 188f10a77bbSDavid C Somayajulu 189f10a77bbSDavid C Somayajulu /* 190f10a77bbSDavid C Somayajulu * Read Flash 191f10a77bbSDavid C Somayajulu */ 192f10a77bbSDavid C Somayajulu #define QLA_RD_FLASH _IOWR('q', 2, qla_rd_flash_t) 193f10a77bbSDavid C Somayajulu 194f10a77bbSDavid C Somayajulu /* 195f10a77bbSDavid C Somayajulu * Write Flash 196f10a77bbSDavid C Somayajulu */ 197f10a77bbSDavid C Somayajulu #define QLA_WR_FLASH _IOWR('q', 3, qla_wr_flash_t) 198f10a77bbSDavid C Somayajulu 199f10a77bbSDavid C Somayajulu /* 200f10a77bbSDavid C Somayajulu * Read Offchip (MS) Memory 201f10a77bbSDavid C Somayajulu */ 202f10a77bbSDavid C Somayajulu #define QLA_RDWR_MS_MEM _IOWR('q', 4, qla_offchip_mem_val_t) 203f10a77bbSDavid C Somayajulu 204f10a77bbSDavid C Somayajulu /* 205f10a77bbSDavid C Somayajulu * Erase Flash 206f10a77bbSDavid C Somayajulu */ 207f10a77bbSDavid C Somayajulu #define QLA_ERASE_FLASH _IOWR('q', 5, qla_erase_flash_t) 208f10a77bbSDavid C Somayajulu 209f10a77bbSDavid C Somayajulu /* 210f10a77bbSDavid C Somayajulu * Read PCI IDs 211f10a77bbSDavid C Somayajulu */ 212f10a77bbSDavid C Somayajulu #define QLA_RD_PCI_IDS _IOWR('q', 6, qla_rd_pci_ids_t) 213f10a77bbSDavid C Somayajulu 214f10a77bbSDavid C Somayajulu /* 215f10a77bbSDavid C Somayajulu * Read Minidump Template Size 216f10a77bbSDavid C Somayajulu */ 217f10a77bbSDavid C Somayajulu #define QLA_RD_FW_DUMP_SIZE _IOWR('q', 7, qla_rd_fw_dump_t) 218f10a77bbSDavid C Somayajulu 219f10a77bbSDavid C Somayajulu /* 220f10a77bbSDavid C Somayajulu * Read Minidump Template 221f10a77bbSDavid C Somayajulu */ 222f10a77bbSDavid C Somayajulu #define QLA_RD_FW_DUMP _IOWR('q', 8, qla_rd_fw_dump_t) 223f10a77bbSDavid C Somayajulu 224ab142b3fSDavid C Somayajulu /* 225ab142b3fSDavid C Somayajulu * Read Driver State 226ab142b3fSDavid C Somayajulu */ 227ab142b3fSDavid C Somayajulu #define QLA_RD_DRVR_STATE _IOWR('q', 9, qla_driver_state_t) 228ab142b3fSDavid C Somayajulu 229b65c0c07SDavid C Somayajulu /* 230b65c0c07SDavid C Somayajulu * Read Slowpath Log 231b65c0c07SDavid C Somayajulu */ 232b65c0c07SDavid C Somayajulu #define QLA_RD_SLOWPATH_LOG _IOWR('q', 10, qla_sp_log_t) 233b65c0c07SDavid C Somayajulu 234b65c0c07SDavid C Somayajulu /* 235b65c0c07SDavid C Somayajulu * Format Strings For Slowpath Trace Logs 236b65c0c07SDavid C Somayajulu */ 237b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_0 \ 238b65c0c07SDavid C Somayajulu "qla_mbx_cmd [%ld]: enter no_pause = %d [0x%08x 0x%08x 0x%08x 0x%08x]\n" 239b65c0c07SDavid C Somayajulu 240b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_1 \ 241b65c0c07SDavid C Somayajulu "qla_mbx_cmd [%ld]: offline = 0x%08x qla_initiate_recovery = 0x%08x exit1\n" 242b65c0c07SDavid C Somayajulu 243b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_2 \ 244b65c0c07SDavid C Somayajulu "qla_mbx_cmd [%ld]: qla_initiate_recovery = 0x%08x exit2\n" 245b65c0c07SDavid C Somayajulu 246b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_3 \ 247b65c0c07SDavid C Somayajulu "qla_mbx_cmd [%ld]: timeout exit3 [host_mbx_cntrl = 0x%08x]\n" 248b65c0c07SDavid C Somayajulu 249b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_4 \ 250b65c0c07SDavid C Somayajulu "qla_mbx_cmd [%ld]: qla_initiate_recovery = 0x%08x exit4\n" 251b65c0c07SDavid C Somayajulu 252b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_5 \ 253b65c0c07SDavid C Somayajulu "qla_mbx_cmd [%ld]: timeout exit5 [fw_mbx_cntrl = 0x%08x]\n" 254b65c0c07SDavid C Somayajulu 255b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_6 \ 256b65c0c07SDavid C Somayajulu "qla_mbx_cmd [%ld]: qla_initiate_recovery = 0x%08x exit6\n" 257b65c0c07SDavid C Somayajulu 258b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_7 \ 259b65c0c07SDavid C Somayajulu "qla_mbx_cmd [%ld]: exit [0x%08x 0x%08x 0x%08x 0x%08x 0x%08x]\n" 260b65c0c07SDavid C Somayajulu 261b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_8 \ 262b65c0c07SDavid C Somayajulu "qla_ioctl [%ld]: SIOCSIFADDR if_drv_flags = 0x%08x [0x%08x] ipv4 = 0x%08x\n" 263b65c0c07SDavid C Somayajulu 264b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_9 \ 265b65c0c07SDavid C Somayajulu "qla_ioctl [%ld]: SIOCSIFMTU if_drv_flags = 0x%08x [0x%08x] max_frame_size = 0x%08x if_mtu = 0x%08x\n" 266b65c0c07SDavid C Somayajulu 267b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_10 \ 26854ab3b4aSJustin Hibbits 269b65c0c07SDavid C Somayajulu 270b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_11 \ 27154ab3b4aSJustin Hibbits 272b65c0c07SDavid C Somayajulu 273b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_12 \ 274b65c0c07SDavid C Somayajulu "qla_set_multi [%ld]: if_drv_flags = 0x%08x [0x%08x] add_multi = 0x%08x mcnt = 0x%08x\n" 275b65c0c07SDavid C Somayajulu 276b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_13 \ 277b65c0c07SDavid C Somayajulu "qla_stop [%ld]: \n" 278b65c0c07SDavid C Somayajulu 279b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_14 \ 280b65c0c07SDavid C Somayajulu "qla_init_locked [%ld]: \n" 281b65c0c07SDavid C Somayajulu 282f10a77bbSDavid C Somayajulu #endif /* #ifndef _QL_IOCTL_H_ */ 283