| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2015 Linaro Ltd. |
|---|
| 3 | 4 | * Copyright (c) 2015 Hisilicon Limited. |
|---|
| 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; either version 2 of the License, or |
|---|
| 8 | | - * (at your option) any later version. |
|---|
| 9 | | - * |
|---|
| 10 | 5 | */ |
|---|
| 11 | 6 | |
|---|
| 12 | 7 | #ifndef _HISI_SAS_H_ |
|---|
| 13 | 8 | #define _HISI_SAS_H_ |
|---|
| 14 | 9 | |
|---|
| 15 | 10 | #include <linux/acpi.h> |
|---|
| 11 | +#include <linux/blk-mq.h> |
|---|
| 12 | +#include <linux/blk-mq-pci.h> |
|---|
| 16 | 13 | #include <linux/clk.h> |
|---|
| 14 | +#include <linux/debugfs.h> |
|---|
| 17 | 15 | #include <linux/dmapool.h> |
|---|
| 18 | 16 | #include <linux/iopoll.h> |
|---|
| 19 | 17 | #include <linux/lcm.h> |
|---|
| 18 | +#include <linux/libata.h> |
|---|
| 20 | 19 | #include <linux/mfd/syscon.h> |
|---|
| 21 | 20 | #include <linux/module.h> |
|---|
| 22 | 21 | #include <linux/of_address.h> |
|---|
| 23 | 22 | #include <linux/pci.h> |
|---|
| 24 | 23 | #include <linux/platform_device.h> |
|---|
| 24 | +#include <linux/pm_runtime.h> |
|---|
| 25 | 25 | #include <linux/property.h> |
|---|
| 26 | 26 | #include <linux/regmap.h> |
|---|
| 27 | +#include <linux/timer.h> |
|---|
| 27 | 28 | #include <scsi/sas_ata.h> |
|---|
| 28 | 29 | #include <scsi/libsas.h> |
|---|
| 29 | 30 | |
|---|
| 30 | 31 | #define HISI_SAS_MAX_PHYS 9 |
|---|
| 31 | 32 | #define HISI_SAS_MAX_QUEUES 32 |
|---|
| 32 | | -#define HISI_SAS_QUEUE_SLOTS 512 |
|---|
| 33 | +#define HISI_SAS_QUEUE_SLOTS 4096 |
|---|
| 33 | 34 | #define HISI_SAS_MAX_ITCT_ENTRIES 1024 |
|---|
| 34 | 35 | #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES |
|---|
| 35 | 36 | #define HISI_SAS_RESET_BIT 0 |
|---|
| 36 | 37 | #define HISI_SAS_REJECT_CMD_BIT 1 |
|---|
| 38 | +#define HISI_SAS_PM_BIT 2 |
|---|
| 39 | +#define HISI_SAS_MAX_COMMANDS (HISI_SAS_QUEUE_SLOTS) |
|---|
| 40 | +#define HISI_SAS_RESERVED_IPTT 96 |
|---|
| 41 | +#define HISI_SAS_UNRESERVED_IPTT \ |
|---|
| 42 | + (HISI_SAS_MAX_COMMANDS - HISI_SAS_RESERVED_IPTT) |
|---|
| 43 | + |
|---|
| 44 | +#define HISI_SAS_IOST_ITCT_CACHE_NUM 64 |
|---|
| 45 | +#define HISI_SAS_IOST_ITCT_CACHE_DW_SZ 10 |
|---|
| 37 | 46 | |
|---|
| 38 | 47 | #define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer)) |
|---|
| 39 | 48 | #define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table)) |
|---|
| 40 | 49 | |
|---|
| 41 | 50 | #define hisi_sas_status_buf_addr(buf) \ |
|---|
| 42 | | - (buf + offsetof(struct hisi_sas_slot_buf_table, status_buffer)) |
|---|
| 43 | | -#define hisi_sas_status_buf_addr_mem(slot) hisi_sas_status_buf_addr(slot->buf) |
|---|
| 51 | + ((buf) + offsetof(struct hisi_sas_slot_buf_table, status_buffer)) |
|---|
| 52 | +#define hisi_sas_status_buf_addr_mem(slot) hisi_sas_status_buf_addr((slot)->buf) |
|---|
| 44 | 53 | #define hisi_sas_status_buf_addr_dma(slot) \ |
|---|
| 45 | | - hisi_sas_status_buf_addr(slot->buf_dma) |
|---|
| 54 | + hisi_sas_status_buf_addr((slot)->buf_dma) |
|---|
| 46 | 55 | |
|---|
| 47 | 56 | #define hisi_sas_cmd_hdr_addr(buf) \ |
|---|
| 48 | | - (buf + offsetof(struct hisi_sas_slot_buf_table, command_header)) |
|---|
| 49 | | -#define hisi_sas_cmd_hdr_addr_mem(slot) hisi_sas_cmd_hdr_addr(slot->buf) |
|---|
| 50 | | -#define hisi_sas_cmd_hdr_addr_dma(slot) hisi_sas_cmd_hdr_addr(slot->buf_dma) |
|---|
| 57 | + ((buf) + offsetof(struct hisi_sas_slot_buf_table, command_header)) |
|---|
| 58 | +#define hisi_sas_cmd_hdr_addr_mem(slot) hisi_sas_cmd_hdr_addr((slot)->buf) |
|---|
| 59 | +#define hisi_sas_cmd_hdr_addr_dma(slot) hisi_sas_cmd_hdr_addr((slot)->buf_dma) |
|---|
| 51 | 60 | |
|---|
| 52 | 61 | #define hisi_sas_sge_addr(buf) \ |
|---|
| 53 | | - (buf + offsetof(struct hisi_sas_slot_buf_table, sge_page)) |
|---|
| 54 | | -#define hisi_sas_sge_addr_mem(slot) hisi_sas_sge_addr(slot->buf) |
|---|
| 55 | | -#define hisi_sas_sge_addr_dma(slot) hisi_sas_sge_addr(slot->buf_dma) |
|---|
| 62 | + ((buf) + offsetof(struct hisi_sas_slot_buf_table, sge_page)) |
|---|
| 63 | +#define hisi_sas_sge_addr_mem(slot) hisi_sas_sge_addr((slot)->buf) |
|---|
| 64 | +#define hisi_sas_sge_addr_dma(slot) hisi_sas_sge_addr((slot)->buf_dma) |
|---|
| 65 | + |
|---|
| 66 | +#define hisi_sas_sge_dif_addr(buf) \ |
|---|
| 67 | + ((buf) + offsetof(struct hisi_sas_slot_dif_buf_table, sge_dif_page)) |
|---|
| 68 | +#define hisi_sas_sge_dif_addr_mem(slot) hisi_sas_sge_dif_addr((slot)->buf) |
|---|
| 69 | +#define hisi_sas_sge_dif_addr_dma(slot) hisi_sas_sge_dif_addr((slot)->buf_dma) |
|---|
| 56 | 70 | |
|---|
| 57 | 71 | #define HISI_SAS_MAX_SSP_RESP_SZ (sizeof(struct ssp_frame_hdr) + 1024) |
|---|
| 58 | 72 | #define HISI_SAS_MAX_SMP_RESP_SZ 1028 |
|---|
| 59 | 73 | #define HISI_SAS_MAX_STP_RESP_SZ 28 |
|---|
| 60 | | - |
|---|
| 61 | | -#define DEV_IS_EXPANDER(type) \ |
|---|
| 62 | | - ((type == SAS_EDGE_EXPANDER_DEVICE) || \ |
|---|
| 63 | | - (type == SAS_FANOUT_EXPANDER_DEVICE)) |
|---|
| 64 | 74 | |
|---|
| 65 | 75 | #define HISI_SAS_SATA_PROTOCOL_NONDATA 0x1 |
|---|
| 66 | 76 | #define HISI_SAS_SATA_PROTOCOL_PIO 0x2 |
|---|
| 67 | 77 | #define HISI_SAS_SATA_PROTOCOL_DMA 0x4 |
|---|
| 68 | 78 | #define HISI_SAS_SATA_PROTOCOL_FPDMA 0x8 |
|---|
| 69 | 79 | #define HISI_SAS_SATA_PROTOCOL_ATAPI 0x10 |
|---|
| 80 | + |
|---|
| 81 | +#define HISI_SAS_DIF_PROT_MASK (SHOST_DIF_TYPE1_PROTECTION | \ |
|---|
| 82 | + SHOST_DIF_TYPE2_PROTECTION | \ |
|---|
| 83 | + SHOST_DIF_TYPE3_PROTECTION) |
|---|
| 84 | + |
|---|
| 85 | +#define HISI_SAS_DIX_PROT_MASK (SHOST_DIX_TYPE1_PROTECTION | \ |
|---|
| 86 | + SHOST_DIX_TYPE2_PROTECTION | \ |
|---|
| 87 | + SHOST_DIX_TYPE3_PROTECTION) |
|---|
| 88 | + |
|---|
| 89 | +#define HISI_SAS_PROT_MASK (HISI_SAS_DIF_PROT_MASK | HISI_SAS_DIX_PROT_MASK) |
|---|
| 90 | + |
|---|
| 91 | +#define HISI_SAS_WAIT_PHYUP_TIMEOUT 20 |
|---|
| 92 | +#define CLEAR_ITCT_TIMEOUT 20 |
|---|
| 70 | 93 | |
|---|
| 71 | 94 | struct hisi_hba; |
|---|
| 72 | 95 | |
|---|
| .. | .. |
|---|
| 76 | 99 | }; |
|---|
| 77 | 100 | |
|---|
| 78 | 101 | enum dev_status { |
|---|
| 102 | + HISI_SAS_DEV_INIT, |
|---|
| 79 | 103 | HISI_SAS_DEV_NORMAL, |
|---|
| 80 | | - HISI_SAS_DEV_EH, |
|---|
| 81 | 104 | }; |
|---|
| 82 | 105 | |
|---|
| 83 | 106 | enum { |
|---|
| .. | .. |
|---|
| 117 | 140 | |
|---|
| 118 | 141 | #define HISI_SAS_DECLARE_RST_WORK_ON_STACK(r) \ |
|---|
| 119 | 142 | DECLARE_COMPLETION_ONSTACK(c); \ |
|---|
| 120 | | - DECLARE_WORK(w, hisi_sas_sync_rst_work_handler); \ |
|---|
| 121 | 143 | struct hisi_sas_rst r = HISI_SAS_RST_WORK_INIT(r, c) |
|---|
| 122 | 144 | |
|---|
| 123 | 145 | enum hisi_sas_bit_err_type { |
|---|
| .. | .. |
|---|
| 138 | 160 | struct asd_sas_phy sas_phy; |
|---|
| 139 | 161 | struct sas_identify identify; |
|---|
| 140 | 162 | struct completion *reset_completion; |
|---|
| 163 | + struct timer_list timer; |
|---|
| 141 | 164 | spinlock_t lock; |
|---|
| 142 | 165 | u64 port_id; /* from hw */ |
|---|
| 143 | 166 | u64 frame_rcvd_size; |
|---|
| .. | .. |
|---|
| 146 | 169 | u8 in_reset; |
|---|
| 147 | 170 | u8 reserved[2]; |
|---|
| 148 | 171 | u32 phy_type; |
|---|
| 172 | + u32 code_violation_err_count; |
|---|
| 149 | 173 | enum sas_linkrate minimum_linkrate; |
|---|
| 150 | 174 | enum sas_linkrate maximum_linkrate; |
|---|
| 175 | + int enable; |
|---|
| 176 | + atomic_t down_cnt; |
|---|
| 151 | 177 | }; |
|---|
| 152 | 178 | |
|---|
| 153 | 179 | struct hisi_sas_port { |
|---|
| .. | .. |
|---|
| 158 | 184 | |
|---|
| 159 | 185 | struct hisi_sas_cq { |
|---|
| 160 | 186 | struct hisi_hba *hisi_hba; |
|---|
| 161 | | - struct tasklet_struct tasklet; |
|---|
| 187 | + const struct cpumask *irq_mask; |
|---|
| 162 | 188 | int rd_point; |
|---|
| 163 | 189 | int id; |
|---|
| 190 | + int irq_no; |
|---|
| 164 | 191 | }; |
|---|
| 165 | 192 | |
|---|
| 166 | 193 | struct hisi_sas_dq { |
|---|
| .. | .. |
|---|
| 178 | 205 | struct hisi_sas_dq *dq; |
|---|
| 179 | 206 | struct list_head list; |
|---|
| 180 | 207 | enum sas_device_type dev_type; |
|---|
| 208 | + enum dev_status dev_status; |
|---|
| 181 | 209 | int device_id; |
|---|
| 182 | 210 | int sata_idx; |
|---|
| 183 | | - u8 dev_status; |
|---|
| 211 | + spinlock_t lock; /* For protecting slots */ |
|---|
| 184 | 212 | }; |
|---|
| 185 | 213 | |
|---|
| 186 | 214 | struct hisi_sas_tmf_task { |
|---|
| .. | .. |
|---|
| 196 | 224 | struct sas_task *task; |
|---|
| 197 | 225 | struct hisi_sas_port *port; |
|---|
| 198 | 226 | u64 n_elem; |
|---|
| 227 | + u64 n_elem_dif; |
|---|
| 199 | 228 | int dlvry_queue; |
|---|
| 200 | 229 | int dlvry_queue_slot; |
|---|
| 201 | 230 | int cmplt_queue; |
|---|
| 202 | 231 | int cmplt_queue_slot; |
|---|
| 203 | 232 | int abort; |
|---|
| 204 | 233 | int ready; |
|---|
| 234 | + int device_id; |
|---|
| 205 | 235 | void *cmd_hdr; |
|---|
| 206 | 236 | dma_addr_t cmd_hdr_dma; |
|---|
| 207 | 237 | struct timer_list internal_abort_timer; |
|---|
| .. | .. |
|---|
| 210 | 240 | /* Do not reorder/change members after here */ |
|---|
| 211 | 241 | void *buf; |
|---|
| 212 | 242 | dma_addr_t buf_dma; |
|---|
| 213 | | - int idx; |
|---|
| 243 | + u16 idx; |
|---|
| 244 | +}; |
|---|
| 245 | + |
|---|
| 246 | +#define HISI_SAS_DEBUGFS_REG(x) {#x, x} |
|---|
| 247 | + |
|---|
| 248 | +struct hisi_sas_debugfs_reg_lu { |
|---|
| 249 | + char *name; |
|---|
| 250 | + int off; |
|---|
| 251 | +}; |
|---|
| 252 | + |
|---|
| 253 | +struct hisi_sas_debugfs_reg { |
|---|
| 254 | + const struct hisi_sas_debugfs_reg_lu *lu; |
|---|
| 255 | + int count; |
|---|
| 256 | + int base_off; |
|---|
| 257 | + union { |
|---|
| 258 | + u32 (*read_global_reg)(struct hisi_hba *hisi_hba, u32 off); |
|---|
| 259 | + u32 (*read_port_reg)(struct hisi_hba *hisi_hba, int port, |
|---|
| 260 | + u32 off); |
|---|
| 261 | + }; |
|---|
| 262 | +}; |
|---|
| 263 | + |
|---|
| 264 | +struct hisi_sas_iost_itct_cache { |
|---|
| 265 | + u32 data[HISI_SAS_IOST_ITCT_CACHE_DW_SZ]; |
|---|
| 266 | +}; |
|---|
| 267 | + |
|---|
| 268 | +enum hisi_sas_debugfs_reg_array_member { |
|---|
| 269 | + DEBUGFS_GLOBAL = 0, |
|---|
| 270 | + DEBUGFS_AXI, |
|---|
| 271 | + DEBUGFS_RAS, |
|---|
| 272 | + DEBUGFS_REGS_NUM |
|---|
| 273 | +}; |
|---|
| 274 | + |
|---|
| 275 | +enum hisi_sas_debugfs_cache_type { |
|---|
| 276 | + HISI_SAS_ITCT_CACHE, |
|---|
| 277 | + HISI_SAS_IOST_CACHE, |
|---|
| 278 | +}; |
|---|
| 279 | + |
|---|
| 280 | +enum hisi_sas_debugfs_bist_ffe_cfg { |
|---|
| 281 | + FFE_SAS_1_5_GBPS, |
|---|
| 282 | + FFE_SAS_3_0_GBPS, |
|---|
| 283 | + FFE_SAS_6_0_GBPS, |
|---|
| 284 | + FFE_SAS_12_0_GBPS, |
|---|
| 285 | + FFE_RESV, |
|---|
| 286 | + FFE_SATA_1_5_GBPS, |
|---|
| 287 | + FFE_SATA_3_0_GBPS, |
|---|
| 288 | + FFE_SATA_6_0_GBPS, |
|---|
| 289 | + FFE_CFG_MAX |
|---|
| 290 | +}; |
|---|
| 291 | + |
|---|
| 292 | +enum hisi_sas_debugfs_bist_fixed_code { |
|---|
| 293 | + FIXED_CODE, |
|---|
| 294 | + FIXED_CODE_1, |
|---|
| 295 | + FIXED_CODE_MAX |
|---|
| 296 | +}; |
|---|
| 297 | + |
|---|
| 298 | +enum { |
|---|
| 299 | + HISI_SAS_BIST_CODE_MODE_PRBS7, |
|---|
| 300 | + HISI_SAS_BIST_CODE_MODE_PRBS23, |
|---|
| 301 | + HISI_SAS_BIST_CODE_MODE_PRBS31, |
|---|
| 302 | + HISI_SAS_BIST_CODE_MODE_JTPAT, |
|---|
| 303 | + HISI_SAS_BIST_CODE_MODE_CJTPAT, |
|---|
| 304 | + HISI_SAS_BIST_CODE_MODE_SCRAMBED_0, |
|---|
| 305 | + HISI_SAS_BIST_CODE_MODE_TRAIN, |
|---|
| 306 | + HISI_SAS_BIST_CODE_MODE_TRAIN_DONE, |
|---|
| 307 | + HISI_SAS_BIST_CODE_MODE_HFTP, |
|---|
| 308 | + HISI_SAS_BIST_CODE_MODE_MFTP, |
|---|
| 309 | + HISI_SAS_BIST_CODE_MODE_LFTP, |
|---|
| 310 | + HISI_SAS_BIST_CODE_MODE_FIXED_DATA, |
|---|
| 214 | 311 | }; |
|---|
| 215 | 312 | |
|---|
| 216 | 313 | struct hisi_sas_hw { |
|---|
| 217 | 314 | int (*hw_init)(struct hisi_hba *hisi_hba); |
|---|
| 218 | 315 | void (*setup_itct)(struct hisi_hba *hisi_hba, |
|---|
| 219 | 316 | struct hisi_sas_device *device); |
|---|
| 220 | | - int (*slot_index_alloc)(struct hisi_hba *hisi_hba, int *slot_idx, |
|---|
| 317 | + int (*slot_index_alloc)(struct hisi_hba *hisi_hba, |
|---|
| 221 | 318 | struct domain_device *device); |
|---|
| 222 | 319 | struct hisi_sas_device *(*alloc_dev)(struct domain_device *device); |
|---|
| 223 | 320 | void (*sl_notify_ssp)(struct hisi_hba *hisi_hba, int phy_no); |
|---|
| 224 | | - int (*get_free_slot)(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq); |
|---|
| 225 | 321 | void (*start_delivery)(struct hisi_sas_dq *dq); |
|---|
| 226 | 322 | void (*prep_ssp)(struct hisi_hba *hisi_hba, |
|---|
| 227 | 323 | struct hisi_sas_slot *slot); |
|---|
| .. | .. |
|---|
| 232 | 328 | void (*prep_abort)(struct hisi_hba *hisi_hba, |
|---|
| 233 | 329 | struct hisi_sas_slot *slot, |
|---|
| 234 | 330 | int device_id, int abort_flag, int tag_to_abort); |
|---|
| 235 | | - int (*slot_complete)(struct hisi_hba *hisi_hba, |
|---|
| 236 | | - struct hisi_sas_slot *slot); |
|---|
| 237 | 331 | void (*phys_init)(struct hisi_hba *hisi_hba); |
|---|
| 238 | 332 | void (*phy_start)(struct hisi_hba *hisi_hba, int phy_no); |
|---|
| 239 | 333 | void (*phy_disable)(struct hisi_hba *hisi_hba, int phy_no); |
|---|
| .. | .. |
|---|
| 242 | 336 | void (*phy_set_linkrate)(struct hisi_hba *hisi_hba, int phy_no, |
|---|
| 243 | 337 | struct sas_phy_linkrates *linkrates); |
|---|
| 244 | 338 | enum sas_linkrate (*phy_get_max_linkrate)(void); |
|---|
| 245 | | - void (*clear_itct)(struct hisi_hba *hisi_hba, |
|---|
| 246 | | - struct hisi_sas_device *dev); |
|---|
| 339 | + int (*clear_itct)(struct hisi_hba *hisi_hba, |
|---|
| 340 | + struct hisi_sas_device *dev); |
|---|
| 247 | 341 | void (*free_device)(struct hisi_sas_device *sas_dev); |
|---|
| 248 | 342 | int (*get_wideport_bitmap)(struct hisi_hba *hisi_hba, int port_id); |
|---|
| 249 | 343 | void (*dereg_device)(struct hisi_hba *hisi_hba, |
|---|
| .. | .. |
|---|
| 254 | 348 | u8 reg_index, u8 reg_count, u8 *write_data); |
|---|
| 255 | 349 | void (*wait_cmds_complete_timeout)(struct hisi_hba *hisi_hba, |
|---|
| 256 | 350 | int delay_ms, int timeout_ms); |
|---|
| 257 | | - int max_command_entries; |
|---|
| 351 | + void (*snapshot_prepare)(struct hisi_hba *hisi_hba); |
|---|
| 352 | + void (*snapshot_restore)(struct hisi_hba *hisi_hba); |
|---|
| 353 | + int (*set_bist)(struct hisi_hba *hisi_hba, bool enable); |
|---|
| 354 | + void (*read_iost_itct_cache)(struct hisi_hba *hisi_hba, |
|---|
| 355 | + enum hisi_sas_debugfs_cache_type type, |
|---|
| 356 | + u32 *cache); |
|---|
| 258 | 357 | int complete_hdr_size; |
|---|
| 259 | 358 | struct scsi_host_template *sht; |
|---|
| 359 | + |
|---|
| 360 | + const struct hisi_sas_debugfs_reg *debugfs_reg_array[DEBUGFS_REGS_NUM]; |
|---|
| 361 | + const struct hisi_sas_debugfs_reg *debugfs_reg_port; |
|---|
| 362 | +}; |
|---|
| 363 | + |
|---|
| 364 | +#define HISI_SAS_MAX_DEBUGFS_DUMP (50) |
|---|
| 365 | + |
|---|
| 366 | +struct hisi_sas_debugfs_cq { |
|---|
| 367 | + struct hisi_sas_cq *cq; |
|---|
| 368 | + void *complete_hdr; |
|---|
| 369 | +}; |
|---|
| 370 | + |
|---|
| 371 | +struct hisi_sas_debugfs_dq { |
|---|
| 372 | + struct hisi_sas_dq *dq; |
|---|
| 373 | + struct hisi_sas_cmd_hdr *hdr; |
|---|
| 374 | +}; |
|---|
| 375 | + |
|---|
| 376 | +struct hisi_sas_debugfs_regs { |
|---|
| 377 | + struct hisi_hba *hisi_hba; |
|---|
| 378 | + u32 *data; |
|---|
| 379 | +}; |
|---|
| 380 | + |
|---|
| 381 | +struct hisi_sas_debugfs_port { |
|---|
| 382 | + struct hisi_sas_phy *phy; |
|---|
| 383 | + u32 *data; |
|---|
| 384 | +}; |
|---|
| 385 | + |
|---|
| 386 | +struct hisi_sas_debugfs_iost { |
|---|
| 387 | + struct hisi_sas_iost *iost; |
|---|
| 388 | +}; |
|---|
| 389 | + |
|---|
| 390 | +struct hisi_sas_debugfs_itct { |
|---|
| 391 | + struct hisi_sas_itct *itct; |
|---|
| 392 | +}; |
|---|
| 393 | + |
|---|
| 394 | +struct hisi_sas_debugfs_iost_cache { |
|---|
| 395 | + struct hisi_sas_iost_itct_cache *cache; |
|---|
| 396 | +}; |
|---|
| 397 | + |
|---|
| 398 | +struct hisi_sas_debugfs_itct_cache { |
|---|
| 399 | + struct hisi_sas_iost_itct_cache *cache; |
|---|
| 260 | 400 | }; |
|---|
| 261 | 401 | |
|---|
| 262 | 402 | struct hisi_hba { |
|---|
| .. | .. |
|---|
| 266 | 406 | struct platform_device *platform_dev; |
|---|
| 267 | 407 | struct pci_dev *pci_dev; |
|---|
| 268 | 408 | struct device *dev; |
|---|
| 409 | + |
|---|
| 410 | + int prot_mask; |
|---|
| 269 | 411 | |
|---|
| 270 | 412 | void __iomem *regs; |
|---|
| 271 | 413 | void __iomem *sgpio_regs; |
|---|
| .. | .. |
|---|
| 320 | 462 | const struct hisi_sas_hw *hw; /* Low level hw interface */ |
|---|
| 321 | 463 | unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)]; |
|---|
| 322 | 464 | struct work_struct rst_work; |
|---|
| 465 | + struct work_struct debugfs_work; |
|---|
| 323 | 466 | u32 phy_state; |
|---|
| 467 | + u32 intr_coal_ticks; /* Time of interrupt coalesce in us */ |
|---|
| 468 | + u32 intr_coal_count; /* Interrupt count to coalesce */ |
|---|
| 469 | + |
|---|
| 470 | + int cq_nvecs; |
|---|
| 471 | + |
|---|
| 472 | + /* bist */ |
|---|
| 473 | + enum sas_linkrate debugfs_bist_linkrate; |
|---|
| 474 | + int debugfs_bist_code_mode; |
|---|
| 475 | + int debugfs_bist_phy_no; |
|---|
| 476 | + int debugfs_bist_mode; |
|---|
| 477 | + u32 debugfs_bist_cnt; |
|---|
| 478 | + int debugfs_bist_enable; |
|---|
| 479 | + u32 debugfs_bist_ffe[HISI_SAS_MAX_PHYS][FFE_CFG_MAX]; |
|---|
| 480 | + u32 debugfs_bist_fixed_code[FIXED_CODE_MAX]; |
|---|
| 481 | + |
|---|
| 482 | + /* debugfs memories */ |
|---|
| 483 | + /* Put Global AXI and RAS Register into register array */ |
|---|
| 484 | + struct hisi_sas_debugfs_regs debugfs_regs[HISI_SAS_MAX_DEBUGFS_DUMP][DEBUGFS_REGS_NUM]; |
|---|
| 485 | + struct hisi_sas_debugfs_port debugfs_port_reg[HISI_SAS_MAX_DEBUGFS_DUMP][HISI_SAS_MAX_PHYS]; |
|---|
| 486 | + struct hisi_sas_debugfs_cq debugfs_cq[HISI_SAS_MAX_DEBUGFS_DUMP][HISI_SAS_MAX_QUEUES]; |
|---|
| 487 | + struct hisi_sas_debugfs_dq debugfs_dq[HISI_SAS_MAX_DEBUGFS_DUMP][HISI_SAS_MAX_QUEUES]; |
|---|
| 488 | + struct hisi_sas_debugfs_iost debugfs_iost[HISI_SAS_MAX_DEBUGFS_DUMP]; |
|---|
| 489 | + struct hisi_sas_debugfs_itct debugfs_itct[HISI_SAS_MAX_DEBUGFS_DUMP]; |
|---|
| 490 | + struct hisi_sas_debugfs_iost_cache debugfs_iost_cache[HISI_SAS_MAX_DEBUGFS_DUMP]; |
|---|
| 491 | + struct hisi_sas_debugfs_itct_cache debugfs_itct_cache[HISI_SAS_MAX_DEBUGFS_DUMP]; |
|---|
| 492 | + |
|---|
| 493 | + u64 debugfs_timestamp[HISI_SAS_MAX_DEBUGFS_DUMP]; |
|---|
| 494 | + int debugfs_dump_index; |
|---|
| 495 | + struct dentry *debugfs_dir; |
|---|
| 496 | + struct dentry *debugfs_dump_dentry; |
|---|
| 497 | + struct dentry *debugfs_bist_dentry; |
|---|
| 324 | 498 | }; |
|---|
| 325 | 499 | |
|---|
| 326 | 500 | /* Generic HW DMA host memory structures */ |
|---|
| .. | .. |
|---|
| 414 | 588 | u8 atapi_cdb[ATAPI_CDB_LEN]; |
|---|
| 415 | 589 | }; |
|---|
| 416 | 590 | |
|---|
| 417 | | -#define HISI_SAS_SGE_PAGE_CNT SG_CHUNK_SIZE |
|---|
| 591 | +#define HISI_SAS_SGE_PAGE_CNT (124) |
|---|
| 418 | 592 | struct hisi_sas_sge_page { |
|---|
| 419 | 593 | struct hisi_sas_sge sge[HISI_SAS_SGE_PAGE_CNT]; |
|---|
| 594 | +} __aligned(16); |
|---|
| 595 | + |
|---|
| 596 | +#define HISI_SAS_SGE_DIF_PAGE_CNT HISI_SAS_SGE_PAGE_CNT |
|---|
| 597 | +struct hisi_sas_sge_dif_page { |
|---|
| 598 | + struct hisi_sas_sge sge[HISI_SAS_SGE_DIF_PAGE_CNT]; |
|---|
| 420 | 599 | } __aligned(16); |
|---|
| 421 | 600 | |
|---|
| 422 | 601 | struct hisi_sas_command_table_ssp { |
|---|
| .. | .. |
|---|
| 449 | 628 | struct hisi_sas_sge_page sge_page; |
|---|
| 450 | 629 | }; |
|---|
| 451 | 630 | |
|---|
| 631 | +struct hisi_sas_slot_dif_buf_table { |
|---|
| 632 | + struct hisi_sas_slot_buf_table slot_buf; |
|---|
| 633 | + struct hisi_sas_sge_dif_page sge_dif_page; |
|---|
| 634 | +}; |
|---|
| 635 | + |
|---|
| 452 | 636 | extern struct scsi_transport_template *hisi_sas_stt; |
|---|
| 637 | + |
|---|
| 638 | +extern bool hisi_sas_debugfs_enable; |
|---|
| 639 | +extern u32 hisi_sas_debugfs_dump_count; |
|---|
| 640 | +extern struct dentry *hisi_sas_debugfs_dir; |
|---|
| 641 | + |
|---|
| 453 | 642 | extern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba); |
|---|
| 454 | | -extern int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost); |
|---|
| 643 | +extern int hisi_sas_alloc(struct hisi_hba *hisi_hba); |
|---|
| 455 | 644 | extern void hisi_sas_free(struct hisi_hba *hisi_hba); |
|---|
| 456 | 645 | extern u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis, |
|---|
| 457 | 646 | int direction); |
|---|
| 458 | 647 | extern struct hisi_sas_port *to_hisi_sas_port(struct asd_sas_port *sas_port); |
|---|
| 459 | 648 | extern void hisi_sas_sata_done(struct sas_task *task, |
|---|
| 460 | 649 | struct hisi_sas_slot *slot); |
|---|
| 461 | | -extern int hisi_sas_get_ncq_tag(struct sas_task *task, u32 *tag); |
|---|
| 462 | 650 | extern int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba); |
|---|
| 463 | 651 | extern int hisi_sas_probe(struct platform_device *pdev, |
|---|
| 464 | 652 | const struct hisi_sas_hw *ops); |
|---|
| .. | .. |
|---|
| 467 | 655 | extern int hisi_sas_slave_configure(struct scsi_device *sdev); |
|---|
| 468 | 656 | extern int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time); |
|---|
| 469 | 657 | extern void hisi_sas_scan_start(struct Scsi_Host *shost); |
|---|
| 470 | | -extern struct device_attribute *host_attrs[]; |
|---|
| 471 | 658 | extern int hisi_sas_host_reset(struct Scsi_Host *shost, int reset_type); |
|---|
| 659 | +extern void hisi_sas_phy_enable(struct hisi_hba *hisi_hba, int phy_no, |
|---|
| 660 | + int enable); |
|---|
| 472 | 661 | extern void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy); |
|---|
| 473 | 662 | extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, |
|---|
| 474 | 663 | struct sas_task *task, |
|---|
| .. | .. |
|---|
| 476 | 665 | extern void hisi_sas_init_mem(struct hisi_hba *hisi_hba); |
|---|
| 477 | 666 | extern void hisi_sas_rst_work_handler(struct work_struct *work); |
|---|
| 478 | 667 | extern void hisi_sas_sync_rst_work_handler(struct work_struct *work); |
|---|
| 479 | | -extern void hisi_sas_kill_tasklets(struct hisi_hba *hisi_hba); |
|---|
| 668 | +extern void hisi_sas_sync_irqs(struct hisi_hba *hisi_hba); |
|---|
| 669 | +extern void hisi_sas_phy_oob_ready(struct hisi_hba *hisi_hba, int phy_no); |
|---|
| 480 | 670 | extern bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, |
|---|
| 481 | 671 | enum hisi_sas_phy_event event); |
|---|
| 482 | 672 | extern void hisi_sas_release_tasks(struct hisi_hba *hisi_hba); |
|---|
| 483 | 673 | extern u8 hisi_sas_get_prog_phy_linkrate_mask(enum sas_linkrate max); |
|---|
| 484 | 674 | extern void hisi_sas_controller_reset_prepare(struct hisi_hba *hisi_hba); |
|---|
| 485 | 675 | extern void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba); |
|---|
| 676 | +extern void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba); |
|---|
| 677 | +extern void hisi_sas_debugfs_exit(struct hisi_hba *hisi_hba); |
|---|
| 678 | +extern void hisi_sas_debugfs_work_handler(struct work_struct *work); |
|---|
| 486 | 679 | #endif |
|---|