0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef __MTIP32XX_H__
0012 #define __MTIP32XX_H__
0013
0014 #include <linux/spinlock.h>
0015 #include <linux/rwsem.h>
0016 #include <linux/ata.h>
0017 #include <linux/interrupt.h>
0018
0019
0020 #define PCI_SUBSYSTEM_DEVICEID 0x2E
0021
0022
0023 #define PCIE_CONFIG_EXT_DEVICE_CONTROL_OFFSET 0x48
0024
0025
0026 #define MTIP_SEC_ERASE_MODE 0x2
0027
0028
0029 #define MTIP_MAX_RETRIES 2
0030
0031
0032 #define MTIP_NCQ_CMD_TIMEOUT_MS 15000
0033 #define MTIP_IOCTL_CMD_TIMEOUT_MS 5000
0034 #define MTIP_INT_CMD_TIMEOUT_MS 5000
0035 #define MTIP_QUIESCE_IO_TIMEOUT_MS (MTIP_NCQ_CMD_TIMEOUT_MS * \
0036 (MTIP_MAX_RETRIES + 1))
0037
0038
0039 #define MTIP_TIMEOUT_CHECK_PERIOD 500
0040
0041
0042 #define MTIP_FTL_REBUILD_OFFSET 142
0043 #define MTIP_FTL_REBUILD_MAGIC 0xED51
0044 #define MTIP_FTL_REBUILD_TIMEOUT_MS 2400000
0045
0046
0047 #define MTIP_MAX_UNALIGNED_SLOTS 2
0048
0049
0050 #define MTIP_TAG_BIT(tag) (tag & 0x1F)
0051
0052
0053
0054
0055
0056
0057 #define MTIP_TAG_INDEX(tag) (tag >> 5)
0058
0059
0060
0061
0062
0063 #define MTIP_MAX_SG 504
0064
0065
0066
0067
0068
0069 #define MTIP_MAX_SLOT_GROUPS 8
0070
0071
0072 #define MTIP_TAG_INTERNAL 0
0073
0074
0075 #define PCI_VENDOR_ID_MICRON 0x1344
0076 #define P320H_DEVICE_ID 0x5150
0077 #define P320M_DEVICE_ID 0x5151
0078 #define P320S_DEVICE_ID 0x5152
0079 #define P325M_DEVICE_ID 0x5153
0080 #define P420H_DEVICE_ID 0x5160
0081 #define P420M_DEVICE_ID 0x5161
0082 #define P425M_DEVICE_ID 0x5163
0083
0084
0085 #define MTIP_DRV_NAME "mtip32xx"
0086 #define MTIP_DRV_VERSION "1.3.1"
0087
0088
0089 #define MTIP_MAX_MINORS 16
0090
0091
0092 #define MTIP_MAX_COMMAND_SLOTS (MTIP_MAX_SLOT_GROUPS * 32)
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102 #define U32_PER_LONG (sizeof(long) / sizeof(u32))
0103 #define SLOTBITS_IN_LONGS ((MTIP_MAX_SLOT_GROUPS + \
0104 (U32_PER_LONG-1))/U32_PER_LONG)
0105
0106
0107 #define MTIP_ABAR 5
0108
0109 #ifdef DEBUG
0110 #define dbg_printk(format, arg...) \
0111 printk(pr_fmt(format), ##arg);
0112 #else
0113 #define dbg_printk(format, arg...)
0114 #endif
0115
0116 #define MTIP_DFS_MAX_BUF_SIZE 1024
0117
0118 enum {
0119
0120 MTIP_PF_IC_ACTIVE_BIT = 0,
0121 MTIP_PF_EH_ACTIVE_BIT = 1,
0122 MTIP_PF_SE_ACTIVE_BIT = 2,
0123 MTIP_PF_DM_ACTIVE_BIT = 3,
0124 MTIP_PF_TO_ACTIVE_BIT = 9,
0125 MTIP_PF_PAUSE_IO = ((1 << MTIP_PF_IC_ACTIVE_BIT) |
0126 (1 << MTIP_PF_EH_ACTIVE_BIT) |
0127 (1 << MTIP_PF_SE_ACTIVE_BIT) |
0128 (1 << MTIP_PF_DM_ACTIVE_BIT) |
0129 (1 << MTIP_PF_TO_ACTIVE_BIT)),
0130 MTIP_PF_HOST_CAP_64 = 10,
0131
0132 MTIP_PF_SVC_THD_ACTIVE_BIT = 4,
0133 MTIP_PF_ISSUE_CMDS_BIT = 5,
0134 MTIP_PF_REBUILD_BIT = 6,
0135 MTIP_PF_SVC_THD_STOP_BIT = 8,
0136
0137 MTIP_PF_SVC_THD_WORK = ((1 << MTIP_PF_EH_ACTIVE_BIT) |
0138 (1 << MTIP_PF_ISSUE_CMDS_BIT) |
0139 (1 << MTIP_PF_REBUILD_BIT) |
0140 (1 << MTIP_PF_SVC_THD_STOP_BIT) |
0141 (1 << MTIP_PF_TO_ACTIVE_BIT)),
0142
0143
0144 MTIP_DDF_SEC_LOCK_BIT = 0,
0145 MTIP_DDF_REMOVE_PENDING_BIT = 1,
0146 MTIP_DDF_OVER_TEMP_BIT = 2,
0147 MTIP_DDF_WRITE_PROTECT_BIT = 3,
0148 MTIP_DDF_CLEANUP_BIT = 5,
0149 MTIP_DDF_RESUME_BIT = 6,
0150 MTIP_DDF_INIT_DONE_BIT = 7,
0151 MTIP_DDF_REBUILD_FAILED_BIT = 8,
0152
0153 MTIP_DDF_STOP_IO = ((1 << MTIP_DDF_REMOVE_PENDING_BIT) |
0154 (1 << MTIP_DDF_SEC_LOCK_BIT) |
0155 (1 << MTIP_DDF_OVER_TEMP_BIT) |
0156 (1 << MTIP_DDF_WRITE_PROTECT_BIT) |
0157 (1 << MTIP_DDF_REBUILD_FAILED_BIT)),
0158
0159 };
0160
0161 struct smart_attr {
0162 u8 attr_id;
0163 __le16 flags;
0164 u8 cur;
0165 u8 worst;
0166 __le32 data;
0167 u8 res[3];
0168 } __packed;
0169
0170 struct mtip_work {
0171 struct work_struct work;
0172 void *port;
0173 int cpu_binding;
0174 u32 completed;
0175 } ____cacheline_aligned_in_smp;
0176
0177 #define DEFINE_HANDLER(group) \
0178 void mtip_workq_sdbf##group(struct work_struct *work) \
0179 { \
0180 struct mtip_work *w = (struct mtip_work *) work; \
0181 mtip_workq_sdbfx(w->port, group, w->completed); \
0182 }
0183
0184
0185 struct host_to_dev_fis {
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197 unsigned char type;
0198 unsigned char opts;
0199 unsigned char command;
0200 unsigned char features;
0201
0202 union {
0203 unsigned char lba_low;
0204 unsigned char sector;
0205 };
0206 union {
0207 unsigned char lba_mid;
0208 unsigned char cyl_low;
0209 };
0210 union {
0211 unsigned char lba_hi;
0212 unsigned char cyl_hi;
0213 };
0214 union {
0215 unsigned char device;
0216 unsigned char head;
0217 };
0218
0219 union {
0220 unsigned char lba_low_ex;
0221 unsigned char sector_ex;
0222 };
0223 union {
0224 unsigned char lba_mid_ex;
0225 unsigned char cyl_low_ex;
0226 };
0227 union {
0228 unsigned char lba_hi_ex;
0229 unsigned char cyl_hi_ex;
0230 };
0231 unsigned char features_ex;
0232
0233 unsigned char sect_count;
0234 unsigned char sect_cnt_ex;
0235 unsigned char res2;
0236 unsigned char control;
0237
0238 unsigned int res3;
0239 };
0240
0241
0242 struct mtip_cmd_hdr {
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252 __le32 opts;
0253
0254 union {
0255 __le32 byte_count;
0256 __le32 status;
0257 };
0258
0259
0260
0261
0262 __le32 ctba;
0263
0264
0265
0266
0267 __le32 ctbau;
0268
0269 u32 res[4];
0270 };
0271
0272
0273 struct mtip_cmd_sg {
0274
0275
0276
0277
0278
0279 __le32 dba;
0280
0281
0282
0283
0284 __le32 dba_upper;
0285
0286 __le32 reserved;
0287
0288
0289
0290
0291
0292
0293 __le32 info;
0294 };
0295 struct mtip_port;
0296
0297 struct mtip_int_cmd;
0298
0299
0300 struct mtip_cmd {
0301 void *command;
0302
0303 dma_addr_t command_dma;
0304
0305 int scatter_ents;
0306
0307 int unaligned;
0308
0309 union {
0310 struct scatterlist sg[MTIP_MAX_SG];
0311 struct mtip_int_cmd *icmd;
0312 };
0313
0314 int retries;
0315
0316 int direction;
0317 blk_status_t status;
0318 };
0319
0320
0321 struct mtip_port {
0322
0323 struct driver_data *dd;
0324
0325
0326
0327
0328 unsigned long identify_valid;
0329
0330 void __iomem *mmio;
0331
0332 void __iomem *s_active[MTIP_MAX_SLOT_GROUPS];
0333
0334 void __iomem *completed[MTIP_MAX_SLOT_GROUPS];
0335
0336 void __iomem *cmd_issue[MTIP_MAX_SLOT_GROUPS];
0337
0338
0339
0340
0341 void *command_list;
0342
0343
0344
0345
0346 dma_addr_t command_list_dma;
0347
0348
0349
0350
0351 void *rxfis;
0352
0353
0354
0355
0356 dma_addr_t rxfis_dma;
0357
0358
0359
0360 void *block1;
0361
0362
0363
0364 dma_addr_t block1_dma;
0365
0366
0367
0368
0369 u16 *identify;
0370
0371
0372
0373
0374 dma_addr_t identify_dma;
0375
0376
0377
0378
0379 u16 *sector_buffer;
0380
0381
0382
0383
0384 dma_addr_t sector_buffer_dma;
0385
0386 u16 *log_buf;
0387 dma_addr_t log_buf_dma;
0388
0389 u8 *smart_buf;
0390 dma_addr_t smart_buf_dma;
0391
0392
0393
0394
0395
0396 unsigned long cmds_to_issue[SLOTBITS_IN_LONGS];
0397
0398 wait_queue_head_t svc_wait;
0399
0400
0401
0402
0403 unsigned long flags;
0404
0405
0406
0407 unsigned long ic_pause_timer;
0408
0409
0410 atomic_t cmd_slot_unal;
0411
0412
0413 spinlock_t cmd_issue_lock[MTIP_MAX_SLOT_GROUPS];
0414 };
0415
0416
0417
0418
0419
0420
0421 struct driver_data {
0422 void __iomem *mmio;
0423
0424 int major;
0425
0426 int instance;
0427
0428 struct gendisk *disk;
0429
0430 struct pci_dev *pdev;
0431
0432 struct request_queue *queue;
0433
0434 struct blk_mq_tag_set tags;
0435
0436 struct mtip_port *port;
0437
0438 unsigned product_type;
0439
0440 unsigned slot_groups;
0441
0442 unsigned long index;
0443
0444 unsigned long dd_flag;
0445
0446 struct task_struct *mtip_svc_handler;
0447
0448 struct dentry *dfs_node;
0449
0450 bool sr;
0451
0452 int numa_node;
0453
0454 char workq_name[32];
0455
0456 struct workqueue_struct *isr_workq;
0457
0458 atomic_t irq_workers_active;
0459
0460 struct mtip_work work[MTIP_MAX_SLOT_GROUPS];
0461
0462 int isr_binding;
0463
0464 int unal_qdepth;
0465 };
0466
0467 #endif