1 /* Broadcom NetXtreme-C/E network driver. 2 * 3 * Copyright (c) 2018 Broadcom Inc 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation. 8 */ 9 10 #ifndef BNXT_COREDUMP_H 11 #define BNXT_COREDUMP_H 12 13 #include <linux/utsname.h> 14 #include <linux/time.h> 15 #include <linux/rtc.h> 16 17 struct bnxt_coredump_segment_hdr { 18 __u8 signature[4]; 19 __le32 component_id; 20 __le32 segment_id; 21 __le32 flags; 22 __u8 low_version; 23 __u8 high_version; 24 __le16 function_id; 25 __le32 offset; 26 __le32 length; 27 __le32 status; 28 __le32 duration; 29 __le32 data_offset; 30 __le32 instance; 31 __le32 rsvd[5]; 32 }; 33 34 struct bnxt_coredump_record { 35 __u8 signature[4]; 36 __le32 flags; 37 __u8 low_version; 38 __u8 high_version; 39 __u8 asic_state; 40 __u8 rsvd0[5]; 41 char system_name[32]; 42 __le16 year; 43 __le16 month; 44 __le16 day; 45 __le16 hour; 46 __le16 minute; 47 __le16 second; 48 __le16 utc_bias; 49 __le16 rsvd1; 50 char commandline[256]; 51 __le32 total_segments; 52 __le32 os_ver_major; 53 __le32 os_ver_minor; 54 __le32 rsvd2; 55 char os_name[32]; 56 __le16 end_year; 57 __le16 end_month; 58 __le16 end_day; 59 __le16 end_hour; 60 __le16 end_minute; 61 __le16 end_second; 62 __le16 end_utc_bias; 63 __le32 asic_id1; 64 __le32 asic_id2; 65 __le32 coredump_status; 66 __u8 ioctl_low_version; 67 __u8 ioctl_high_version; 68 __le16 rsvd3[313]; 69 }; 70 71 struct bnxt_driver_segment_record { 72 __le32 max_entries; 73 __le32 entry_size; 74 __le32 offset; 75 __u8 wrapped:1; 76 __u8 unused[3]; 77 }; 78 79 #define BNXT_VER_GET_COMP_ID 2 80 #define BNXT_DRV_COMP_ID 0xd 81 82 #define BNXT_CTX_MEM_SEG_ID_START 0x200 83 84 #define BNXT_CTX_MEM_SEG_QP (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_QP) 85 #define BNXT_CTX_MEM_SEG_SRQ (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_SRQ) 86 #define BNXT_CTX_MEM_SEG_CQ (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_CQ) 87 #define BNXT_CTX_MEM_SEG_VNIC (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_VNIC) 88 #define BNXT_CTX_MEM_SEG_STAT (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_STAT) 89 #define BNXT_CTX_MEM_SEG_STQM (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_STQM) 90 #define BNXT_CTX_MEM_SEG_FTQM (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_FTQM) 91 #define BNXT_CTX_MEM_SEG_MRAV (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_MRAV) 92 #define BNXT_CTX_MEM_SEG_TIM (BNXT_CTX_MEM_SEG_ID_START + BNXT_CTX_TIM) 93 94 #define BNXT_CTX_MEM_SEG_SRT 0x1 95 #define BNXT_CTX_MEM_SEG_SRT2 0x2 96 #define BNXT_CTX_MEM_SEG_CRT 0x3 97 #define BNXT_CTX_MEM_SEG_CRT2 0x4 98 #define BNXT_CTX_MEM_SEG_RIGP0 0x5 99 #define BNXT_CTX_MEM_SEG_L2HWRM 0x6 100 #define BNXT_CTX_MEM_SEG_REHWRM 0x7 101 #define BNXT_CTX_MEM_SEG_CA0 0x8 102 #define BNXT_CTX_MEM_SEG_CA1 0x9 103 #define BNXT_CTX_MEM_SEG_CA2 0xa 104 #define BNXT_CTX_MEM_SEG_RIGP1 0xb 105 106 #define BNXT_CRASH_DUMP_LEN (8 << 20) 107 108 #define COREDUMP_LIST_BUF_LEN 2048 109 #define COREDUMP_RETRIEVE_BUF_LEN 4096 110 111 #define BNXT_SEG_HDR_LEN sizeof(struct bnxt_coredump_segment_hdr) 112 #define BNXT_SEG_RCD_LEN sizeof(struct bnxt_driver_segment_record) 113 114 struct bnxt_coredump { 115 void *data; 116 int data_size; 117 u16 total_segs; 118 }; 119 120 #define BNXT_COREDUMP_BUF_LEN(len) ((len) - sizeof(struct bnxt_coredump_record)) 121 122 struct bnxt_hwrm_dbg_dma_info { 123 void *dest_buf; 124 int dest_buf_size; 125 u16 dma_len; 126 u16 seq_off; 127 u16 data_len_off; 128 u16 segs; 129 u32 seg_start; 130 u32 buf_len; 131 }; 132 133 struct hwrm_dbg_cmn_input { 134 __le16 req_type; 135 __le16 cmpl_ring; 136 __le16 seq_id; 137 __le16 target_id; 138 __le64 resp_addr; 139 __le64 host_dest_addr; 140 __le32 host_buf_len; 141 }; 142 143 struct hwrm_dbg_cmn_output { 144 __le16 error_code; 145 __le16 req_type; 146 __le16 seq_id; 147 __le16 resp_len; 148 u8 flags; 149 #define HWRM_DBG_CMN_FLAGS_MORE 1 150 }; 151 152 #define BNXT_DBG_FL_CR_DUMP_SIZE_SOC \ 153 DBG_QCFG_REQ_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_SOC_DDR 154 #define BNXT_DBG_FL_CR_DUMP_SIZE_HOST \ 155 DBG_QCFG_REQ_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_HOST_DDR 156 #define BNXT_DBG_CR_DUMP_MDM_CFG_DDR \ 157 DBG_CRASHDUMP_MEDIUM_CFG_REQ_TYPE_DDR 158 159 void bnxt_fill_coredump_seg_hdr(struct bnxt *bp, 160 struct bnxt_coredump_segment_hdr *seg_hdr, 161 struct coredump_segment_record *seg_rec, 162 u32 seg_len, int status, u32 duration, 163 u32 instance, u32 comp_id, u32 seg_id); 164 int bnxt_get_coredump(struct bnxt *bp, u16 dump_type, void *buf, u32 *dump_len); 165 int bnxt_hwrm_get_dump_len(struct bnxt *bp, u16 dump_type, u32 *dump_len); 166 u32 bnxt_get_coredump_length(struct bnxt *bp, u16 dump_type); 167 168 #endif 169