1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef _PMCRAID_H
22#define _PMCRAID_H
23
24#include <linux/version.h>
25#include <linux/types.h>
26#include <linux/completion.h>
27#include <linux/list.h>
28#include <scsi/scsi.h>
29#include <scsi/scsi_cmnd.h>
30#include <linux/cdev.h>
31#include <net/netlink.h>
32#include <net/genetlink.h>
33#include <linux/connector.h>
34
35
36
37
38
39
40#define PMCRAID_DRIVER_NAME "PMC MaxRAID"
41#define PMCRAID_DEVFILE "pmcsas"
42#define PMCRAID_DRIVER_VERSION "1.0.2"
43#define PMCRAID_DRIVER_DATE __DATE__
44
45
46#define PMCRAID_MAX_ADAPTERS 1024
47
48
49#define PMC_BIT8(n) (1 << (7-n))
50#define PMC_BIT16(n) (1 << (15-n))
51#define PMC_BIT32(n) (1 << (31-n))
52
53
54#define PCI_VENDOR_ID_PMC 0x11F8
55#define PCI_DEVICE_ID_PMC_MAXRAID 0x5220
56
57
58
59
60
61
62
63#define PMCRAID_MAX_CMD 1024
64#define PMCRAID_MAX_IO_CMD 1020
65#define PMCRAID_MAX_HCAM_CMD 2
66#define PMCRAID_MAX_INTERNAL_CMD 2
67
68
69
70
71
72#define PMCRAID_IOADLS_INTERNAL 27
73#define PMCRAID_IOADLS_EXTERNAL 37
74#define PMCRAID_MAX_IOADLS PMCRAID_IOADLS_INTERNAL
75
76
77
78
79
80
81#define HRRQ_ENTRY_SIZE sizeof(__le32)
82#define PMCRAID_IOARCB_ALIGNMENT 32
83#define PMCRAID_IOADL_ALIGNMENT 16
84#define PMCRAID_IOASA_ALIGNMENT 4
85#define PMCRAID_NUM_MSIX_VECTORS 1
86
87
88#define PMCRAID_VENDOR_ID_LEN 8
89#define PMCRAID_PRODUCT_ID_LEN 16
90#define PMCRAID_SERIAL_NUM_LEN 8
91#define PMCRAID_LUN_LEN 8
92#define PMCRAID_MAX_CDB_LEN 16
93#define PMCRAID_DEVICE_ID_LEN 8
94#define PMCRAID_SENSE_DATA_LEN 256
95#define PMCRAID_ADD_CMD_PARAM_LEN 48
96
97#define PMCRAID_MAX_BUS_TO_SCAN 1
98#define PMCRAID_MAX_NUM_TARGETS_PER_BUS 256
99#define PMCRAID_MAX_NUM_LUNS_PER_TARGET 8
100
101
102#define PMCRAID_IOA_BUS_ID 0xfe
103#define PMCRAID_IOA_TARGET_ID 0xff
104#define PMCRAID_IOA_LUN_ID 0xff
105#define PMCRAID_VSET_BUS_ID 0x1
106#define PMCRAID_VSET_LUN_ID 0x0
107#define PMCRAID_PHYS_BUS_ID 0x0
108#define PMCRAID_VIRTUAL_ENCL_BUS_ID 0x8
109#define PMCRAID_MAX_VSET_TARGETS 240
110#define PMCRAID_MAX_VSET_LUNS_PER_TARGET 8
111
112#define PMCRAID_IOA_MAX_SECTORS 32767
113#define PMCRAID_VSET_MAX_SECTORS 512
114#define PMCRAID_MAX_CMD_PER_LUN 254
115
116
117#define PMCRAID_MAX_NUM_OF_VSETS 240
118
119
120#define PMCRAID_MAX_NUM_OF_PHY_DEVS 256
121
122
123#define PMCRAID_MAX_NUM_OF_DEVS \
124 (PMCRAID_MAX_NUM_OF_VSETS + PMCRAID_MAX_NUM_OF_PHY_DEVS + 2)
125
126#define PMCRAID_MAX_RESOURCES PMCRAID_MAX_NUM_OF_DEVS
127
128
129#define PMCRAID_QUERY_RESOURCE_STATE 0xC2
130#define PMCRAID_RESET_DEVICE 0xC3
131
132#define ENABLE_RESET_MODIFIER 0x80
133#define RESET_DEVICE_LUN 0x40
134#define RESET_DEVICE_TARGET 0x20
135#define RESET_DEVICE_BUS 0x10
136
137#define PMCRAID_IDENTIFY_HRRQ 0xC4
138#define PMCRAID_QUERY_IOA_CONFIG 0xC5
139#define PMCRAID_QUERY_CMD_STATUS 0xCB
140#define PMCRAID_ABORT_CMD 0xC7
141
142
143
144
145#define PMCRAID_CANCEL_ALL_REQUESTS 0xCE
146#define PMCRAID_SYNC_COMPLETE_AFTER_CANCEL PMC_BIT8(0)
147
148
149#define PMCRAID_HOST_CONTROLLED_ASYNC 0xCF
150#define PMCRAID_HCAM_CODE_CONFIG_CHANGE 0x01
151#define PMCRAID_HCAM_CODE_LOG_DATA 0x02
152
153
154#define PMCRAID_IOA_SHUTDOWN 0xF7
155#define PMCRAID_SHUTDOWN_NORMAL 0x00
156#define PMCRAID_SHUTDOWN_PREPARE_FOR_NORMAL 0x40
157#define PMCRAID_SHUTDOWN_NONE 0x100
158#define PMCRAID_SHUTDOWN_ABBREV 0x80
159
160
161
162
163#define PMCRAID_SET_SUPPORTED_DEVICES 0xFB
164#define ALL_DEVICES_SUPPORTED PMC_BIT8(0)
165
166
167#define PMCRAID_WR_BUF_DOWNLOAD_AND_SAVE 0x05
168
169
170#define PMCRAID_IOASC_SENSE_MASK 0xFFFFFF00
171#define PMCRAID_IOASC_SENSE_KEY(ioasc) ((ioasc) >> 24)
172#define PMCRAID_IOASC_SENSE_CODE(ioasc) (((ioasc) & 0x00ff0000) >> 16)
173#define PMCRAID_IOASC_SENSE_QUAL(ioasc) (((ioasc) & 0x0000ff00) >> 8)
174#define PMCRAID_IOASC_SENSE_STATUS(ioasc) ((ioasc) & 0x000000ff)
175
176#define PMCRAID_IOASC_GOOD_COMPLETION 0x00000000
177#define PMCRAID_IOASC_NR_INIT_CMD_REQUIRED 0x02040200
178#define PMCRAID_IOASC_NR_IOA_RESET_REQUIRED 0x02048000
179#define PMCRAID_IOASC_NR_SYNC_REQUIRED 0x023F0000
180#define PMCRAID_IOASC_ME_READ_ERROR_NO_REALLOC 0x03110C00
181#define PMCRAID_IOASC_HW_CANNOT_COMMUNICATE 0x04050000
182#define PMCRAID_IOASC_HW_DEVICE_TIMEOUT 0x04080100
183#define PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR 0x04448500
184#define PMCRAID_IOASC_HW_IOA_RESET_REQUIRED 0x04448600
185#define PMCRAID_IOASC_IR_INVALID_RESOURCE_HANDLE 0x05250000
186#define PMCRAID_IOASC_AC_TERMINATED_BY_HOST 0x0B5A0000
187#define PMCRAID_IOASC_UA_BUS_WAS_RESET 0x06290000
188#define PMCRAID_IOASC_UA_BUS_WAS_RESET_BY_OTHER 0x06298000
189
190
191#define PMCRAID_IOASC_IOA_WAS_RESET 0x10000001
192#define PMCRAID_IOASC_PCI_ACCESS_ERROR 0x10000002
193
194
195
196
197#define PMCRAID_PCI_DEASSERT_TIMEOUT 2000
198#define PMCRAID_BIST_TIMEOUT 2000
199#define PMCRAID_AENWAIT_TIMEOUT 5000
200#define PMCRAID_TRANSOP_TIMEOUT 60000
201
202#define PMCRAID_RESET_TIMEOUT (2 * HZ)
203#define PMCRAID_CHECK_FOR_RESET_TIMEOUT ((HZ / 10))
204#define PMCRAID_VSET_IO_TIMEOUT (60 * HZ)
205#define PMCRAID_INTERNAL_TIMEOUT (60 * HZ)
206#define PMCRAID_SHUTDOWN_TIMEOUT (150 * HZ)
207#define PMCRAID_RESET_BUS_TIMEOUT (60 * HZ)
208#define PMCRAID_RESET_HOST_TIMEOUT (150 * HZ)
209#define PMCRAID_REQUEST_SENSE_TIMEOUT (30 * HZ)
210#define PMCRAID_SET_SUP_DEV_TIMEOUT (2 * 60 * HZ)
211
212
213struct pmcraid_ioadl_desc {
214 __le64 address;
215 __le32 data_len;
216 __u8 reserved[3];
217 __u8 flags;
218} __attribute__((packed, aligned(PMCRAID_IOADL_ALIGNMENT)));
219
220
221#define IOADL_FLAGS_CHAINED PMC_BIT8(0)
222#define IOADL_FLAGS_LAST_DESC PMC_BIT8(1)
223#define IOADL_FLAGS_READ_LAST PMC_BIT8(1)
224#define IOADL_FLAGS_WRITE_LAST PMC_BIT8(1)
225
226
227
228
229
230
231
232struct pmcraid_ioarcb_add_data {
233 union {
234 struct pmcraid_ioadl_desc ioadl[PMCRAID_IOADLS_INTERNAL];
235 __u8 add_cmd_params[PMCRAID_ADD_CMD_PARAM_LEN];
236 } u;
237};
238
239
240
241
242struct pmcraid_ioarcb {
243 __le64 ioarcb_bus_addr;
244 __le32 resource_handle;
245 __le32 response_handle;
246 __le64 ioadl_bus_addr;
247 __le32 ioadl_length;
248 __le32 data_transfer_length;
249 __le64 ioasa_bus_addr;
250 __le16 ioasa_len;
251 __le16 cmd_timeout;
252 __le16 add_cmd_param_offset;
253 __le16 add_cmd_param_length;
254 __le32 reserved1[2];
255 __le32 reserved2;
256 __u8 request_type;
257 __u8 request_flags0;
258 __u8 request_flags1;
259 __u8 hrrq_id;
260 __u8 cdb[PMCRAID_MAX_CDB_LEN];
261 struct pmcraid_ioarcb_add_data add_data;
262} __attribute__((packed, aligned(PMCRAID_IOARCB_ALIGNMENT)));
263
264
265#define PMCRAID_IOA_RES_HANDLE 0xffffffff
266#define PMCRAID_INVALID_RES_HANDLE 0
267
268
269#define REQ_TYPE_SCSI 0x00
270#define REQ_TYPE_IOACMD 0x01
271#define REQ_TYPE_HCAM 0x02
272
273
274#define TRANSFER_DIR_WRITE PMC_BIT8(0)
275#define INHIBIT_UL_CHECK PMC_BIT8(2)
276#define SYNC_OVERRIDE PMC_BIT8(3)
277#define SYNC_COMPLETE PMC_BIT8(4)
278#define NO_LINK_DESCS PMC_BIT8(5)
279
280
281#define DELAY_AFTER_RESET PMC_BIT8(0)
282#define TASK_TAG_SIMPLE 0x10
283#define TASK_TAG_ORDERED 0x20
284#define TASK_TAG_QUEUE_HEAD 0x30
285
286
287#define HRRQ_TOGGLE_BIT 0x01
288#define HRRQ_RESPONSE_BIT 0x02
289
290
291struct pmcraid_ioasa_vset {
292 __le32 failing_lba_hi;
293 __le32 failing_lba_lo;
294 __le32 reserved;
295} __attribute__((packed, aligned(4)));
296
297struct pmcraid_ioasa {
298 __le32 ioasc;
299 __le16 returned_status_length;
300 __le16 available_status_length;
301 __le32 residual_data_length;
302 __le32 ilid;
303 __le32 fd_ioasc;
304 __le32 fd_res_address;
305 __le32 fd_res_handle;
306 __le32 reserved;
307
308
309 union {
310 struct pmcraid_ioasa_vset vset;
311 } u;
312
313
314 __le16 auto_sense_length;
315 __le16 error_data_length;
316 __u8 sense_data[PMCRAID_SENSE_DATA_LEN];
317} __attribute__((packed, aligned(4)));
318
319#define PMCRAID_DRIVER_ILID 0xffffffff
320
321
322struct pmcraid_config_table_entry {
323 __u8 resource_type;
324 __u8 bus_protocol;
325 __le16 array_id;
326 __u8 common_flags0;
327 __u8 common_flags1;
328 __u8 unique_flags0;
329 __u8 unique_flags1;
330 __le32 resource_handle;
331 __le32 resource_address;
332 __u8 device_id[PMCRAID_DEVICE_ID_LEN];
333 __u8 lun[PMCRAID_LUN_LEN];
334} __attribute__((packed, aligned(4)));
335
336
337#define RES_TYPE_AF_DASD 0x00
338#define RES_TYPE_GSCSI 0x01
339#define RES_TYPE_VSET 0x02
340#define RES_TYPE_IOA_FP 0xFF
341
342#define RES_IS_IOA(res) ((res).resource_type == RES_TYPE_IOA_FP)
343#define RES_IS_GSCSI(res) ((res).resource_type == RES_TYPE_GSCSI)
344#define RES_IS_VSET(res) ((res).resource_type == RES_TYPE_VSET)
345#define RES_IS_AFDASD(res) ((res).resource_type == RES_TYPE_AF_DASD)
346
347
348#define RES_TYPE_VENCLOSURE 0x8
349
350
351#define MULTIPATH_RESOURCE PMC_BIT32(0)
352
353
354#define IMPORT_MODE_MANUAL PMC_BIT8(0)
355
356
357#define RES_HANDLE_IOA 0xFFFFFFFF
358#define RES_HANDLE_NONE 0x00000000
359
360
361#define RES_ADDRESS_IOAFP 0xFEFFFFFF
362#define RES_ADDRESS_INVALID 0xFFFFFFFF
363
364
365#define RES_BUS(res_addr) (le32_to_cpu(res_addr) & 0xFF)
366#define RES_TARGET(res_addr) ((le32_to_cpu(res_addr) >> 16) & 0xFF)
367#define RES_LUN(res_addr) 0x0
368
369
370struct pmcraid_config_table {
371 __le16 num_entries;
372 __u8 table_format;
373 __u8 reserved1;
374 __u8 flags;
375 __u8 reserved2[11];
376 struct pmcraid_config_table_entry entries[PMCRAID_MAX_RESOURCES];
377} __attribute__((packed, aligned(4)));
378
379
380#define MICROCODE_UPDATE_REQUIRED PMC_BIT32(0)
381
382
383
384
385#define PMCRAID_HOSTRCB_LDNSIZE 4056
386
387
388struct pmcraid_hostrcb_error {
389 __le32 fd_ioasc;
390 __le32 fd_ra;
391 __le32 fd_rh;
392 __le32 prc;
393 union {
394 __u8 data[PMCRAID_HOSTRCB_LDNSIZE];
395 } u;
396} __attribute__ ((packed, aligned(4)));
397
398struct pmcraid_hcam_hdr {
399 __u8 op_code;
400 __u8 notification_type;
401 __u8 notification_lost;
402 __u8 flags;
403 __u8 overlay_id;
404 __u8 reserved1[3];
405 __le32 ilid;
406 __le32 timestamp1;
407 __le32 timestamp2;
408 __le32 data_len;
409} __attribute__((packed, aligned(4)));
410
411#define PMCRAID_AEN_GROUP 0x3
412
413struct pmcraid_hcam_ccn {
414 struct pmcraid_hcam_hdr header;
415 struct pmcraid_config_table_entry cfg_entry;
416} __attribute__((packed, aligned(4)));
417
418struct pmcraid_hcam_ldn {
419 struct pmcraid_hcam_hdr header;
420 struct pmcraid_hostrcb_error error_log;
421} __attribute__((packed, aligned(4)));
422
423
424#define HOSTRCB_TYPE_CCN 0xE1
425#define HOSTRCB_TYPE_LDN 0xE2
426
427
428#define NOTIFICATION_TYPE_ENTRY_CHANGED 0x0
429#define NOTIFICATION_TYPE_ENTRY_NEW 0x1
430#define NOTIFICATION_TYPE_ENTRY_DELETED 0x2
431#define NOTIFICATION_TYPE_ERROR_LOG 0x10
432#define NOTIFICATION_TYPE_INFORMATION_LOG 0x11
433
434#define HOSTRCB_NOTIFICATIONS_LOST PMC_BIT8(0)
435
436
437#define HOSTRCB_INTERNAL_OP_ERROR PMC_BIT8(0)
438#define HOSTRCB_ERROR_RESPONSE_SENT PMC_BIT8(1)
439
440
441#define HOSTRCB_OVERLAY_ID_08 0x08
442#define HOSTRCB_OVERLAY_ID_09 0x09
443#define HOSTRCB_OVERLAY_ID_11 0x11
444#define HOSTRCB_OVERLAY_ID_12 0x12
445#define HOSTRCB_OVERLAY_ID_13 0x13
446#define HOSTRCB_OVERLAY_ID_14 0x14
447#define HOSTRCB_OVERLAY_ID_16 0x16
448#define HOSTRCB_OVERLAY_ID_17 0x17
449#define HOSTRCB_OVERLAY_ID_20 0x20
450#define HOSTRCB_OVERLAY_ID_FF 0xFF
451
452
453struct pmcraid_chip_details {
454
455 unsigned long ioastatus;
456 unsigned long ioarrin;
457 unsigned long mailbox;
458 unsigned long global_intr_mask;
459 unsigned long ioa_host_intr;
460 unsigned long ioa_host_intr_clr;
461 unsigned long ioa_host_mask;
462 unsigned long ioa_host_mask_clr;
463 unsigned long host_ioa_intr;
464 unsigned long host_ioa_intr_clr;
465
466
467 unsigned long transop_timeout;
468};
469
470
471#define INTRS_TRANSITION_TO_OPERATIONAL PMC_BIT32(0)
472#define INTRS_IOARCB_TRANSFER_FAILED PMC_BIT32(3)
473#define INTRS_IOA_UNIT_CHECK PMC_BIT32(4)
474#define INTRS_NO_HRRQ_FOR_CMD_RESPONSE PMC_BIT32(5)
475#define INTRS_CRITICAL_OP_IN_PROGRESS PMC_BIT32(6)
476#define INTRS_IO_DEBUG_ACK PMC_BIT32(7)
477#define INTRS_IOARRIN_LOST PMC_BIT32(27)
478#define INTRS_SYSTEM_BUS_MMIO_ERROR PMC_BIT32(28)
479#define INTRS_IOA_PROCESSOR_ERROR PMC_BIT32(29)
480#define INTRS_HRRQ_VALID PMC_BIT32(30)
481#define INTRS_OPERATIONAL_STATUS PMC_BIT32(0)
482
483
484#define DOORBELL_RUNTIME_RESET PMC_BIT32(1)
485#define DOORBELL_IOA_RESET_ALERT PMC_BIT32(7)
486#define DOORBELL_IOA_DEBUG_ALERT PMC_BIT32(9)
487#define DOORBELL_ENABLE_DESTRUCTIVE_DIAGS PMC_BIT32(8)
488#define DOORBELL_IOA_START_BIST PMC_BIT32(23)
489#define DOORBELL_RESET_IOA PMC_BIT32(31)
490
491
492#define GLOBAL_INTERRUPT_MASK 0x4ULL
493
494#define PMCRAID_ERROR_INTERRUPTS (INTRS_IOARCB_TRANSFER_FAILED | \
495 INTRS_IOA_UNIT_CHECK | \
496 INTRS_NO_HRRQ_FOR_CMD_RESPONSE | \
497 INTRS_IOARRIN_LOST | \
498 INTRS_SYSTEM_BUS_MMIO_ERROR | \
499 INTRS_IOA_PROCESSOR_ERROR)
500
501#define PMCRAID_PCI_INTERRUPTS (PMCRAID_ERROR_INTERRUPTS | \
502 INTRS_HRRQ_VALID | \
503 INTRS_CRITICAL_OP_IN_PROGRESS |\
504 INTRS_TRANSITION_TO_OPERATIONAL)
505
506
507
508
509
510struct pmcraid_control_block {
511 struct pmcraid_ioarcb ioarcb;
512 struct pmcraid_ioadl_desc ioadl[PMCRAID_IOADLS_EXTERNAL + 3];
513 struct pmcraid_ioasa ioasa;
514} __attribute__ ((packed, aligned(PMCRAID_IOARCB_ALIGNMENT)));
515
516
517
518struct pmcraid_sglist {
519 u32 order;
520 u32 num_sg;
521 u32 num_dma_sg;
522 u32 buffer_len;
523 struct scatterlist scatterlist[1];
524};
525
526
527struct pmcraid_cmd {
528
529
530 struct pmcraid_control_block *ioa_cb;
531 dma_addr_t ioa_cb_bus_addr;
532
533
534
535
536 dma_addr_t sense_buffer_dma;
537 dma_addr_t dma_handle;
538 u8 *sense_buffer;
539
540
541 struct scsi_cmnd *scsi_cmd;
542
543 struct list_head free_list;
544 struct completion wait_for_completion;
545 struct timer_list timer;
546 u32 timeout;
547 u32 index;
548 u8 completion_req;
549 u8 release;
550
551 void (*cmd_done) (struct pmcraid_cmd *);
552 struct pmcraid_instance *drv_inst;
553
554 struct pmcraid_sglist *sglist;
555
556
557 union {
558 unsigned long time_left;
559 struct pmcraid_resource_entry *res;
560 } u;
561};
562
563
564
565
566struct pmcraid_interrupts {
567 void __iomem *ioa_host_interrupt_reg;
568 void __iomem *ioa_host_interrupt_clr_reg;
569 void __iomem *ioa_host_interrupt_mask_reg;
570 void __iomem *ioa_host_interrupt_mask_clr_reg;
571 void __iomem *global_interrupt_mask_reg;
572 void __iomem *host_ioa_interrupt_reg;
573 void __iomem *host_ioa_interrupt_clr_reg;
574};
575
576
577struct pmcraid_isr_param {
578 u8 hrrq_id;
579 u16 vector;
580 struct pmcraid_instance *drv_inst;
581};
582
583
584struct pmcraid_aen_msg {
585 u32 hostno;
586 u32 length;
587 u8 reserved[8];
588 u8 data[0];
589};
590
591struct pmcraid_hostrcb {
592 struct pmcraid_instance *drv_inst;
593 struct pmcraid_aen_msg *msg;
594 struct pmcraid_hcam_hdr *hcam;
595 struct pmcraid_cmd *cmd;
596 dma_addr_t baddr;
597 atomic_t ignore;
598};
599
600#define PMCRAID_AEN_HDR_SIZE sizeof(struct pmcraid_aen_msg)
601
602
603
604
605
606
607struct pmcraid_instance {
608
609
610
611 struct pmcraid_resource_entry *res_entries;
612
613 struct list_head free_res_q;
614 struct list_head used_res_q;
615 spinlock_t resource_lock;
616
617 void __iomem *mapped_dma_addr;
618 void __iomem *ioa_status;
619 void __iomem *mailbox;
620 void __iomem *ioarrin;
621
622 struct pmcraid_interrupts int_regs;
623 struct pmcraid_chip_details *chip_cfg;
624
625
626 struct pmcraid_hostrcb ldn;
627 struct pmcraid_hostrcb ccn;
628
629
630
631 dma_addr_t hrrq_start_bus_addr[PMCRAID_NUM_MSIX_VECTORS];
632
633
634 __be32 *hrrq_start[PMCRAID_NUM_MSIX_VECTORS];
635
636
637 __be32 *hrrq_end[PMCRAID_NUM_MSIX_VECTORS];
638
639
640 __be32 *hrrq_curr[PMCRAID_NUM_MSIX_VECTORS];
641
642
643 spinlock_t hrrq_lock[PMCRAID_NUM_MSIX_VECTORS];
644
645
646 u8 host_toggle_bit[PMCRAID_NUM_MSIX_VECTORS];
647
648
649 u8 ioa_reset_attempts;
650#define PMCRAID_RESET_ATTEMPTS 3
651
652
653 wait_queue_head_t reset_wait_q;
654 struct pmcraid_cmd *reset_cmd;
655
656
657 struct fasync_struct *aen_queue;
658 struct mutex aen_queue_lock;
659 struct cdev cdev;
660
661 struct Scsi_Host *host;
662 struct pci_dev *pdev;
663
664 u8 current_log_level;
665
666 u8 num_hrrq;
667 dev_t dev;
668
669
670 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
671
672
673 struct pmcraid_config_table *cfg_table;
674 dma_addr_t cfg_table_bus_addr;
675
676
677 struct kmem_cache *cmd_cachep;
678 struct pci_pool *control_pool;
679 char cmd_pool_name[64];
680 char ctl_pool_name[64];
681
682 struct pmcraid_cmd *cmd_list[PMCRAID_MAX_CMD];
683
684 struct list_head free_cmd_pool;
685 struct list_head pending_cmd_pool;
686 spinlock_t free_pool_lock;
687 spinlock_t pending_pool_lock;
688
689
690 atomic_t outstanding_cmds;
691
692
693 atomic_t expose_resources;
694
695
696 struct tasklet_struct isr_tasklet[PMCRAID_NUM_MSIX_VECTORS];
697
698
699 struct work_struct worker_q;
700
701
702 u32 ioa_state:4;
703#define IOA_STATE_OPERATIONAL 0x0
704#define IOA_STATE_UNKNOWN 0x1
705#define IOA_STATE_DEAD 0x2
706#define IOA_STATE_IN_SOFT_RESET 0x3
707#define IOA_STATE_IN_HARD_RESET 0x4
708#define IOA_STATE_IN_RESET_ALERT 0x5
709#define IOA_STATE_IN_BRINGDOWN 0x6
710#define IOA_STATE_IN_BRINGUP 0x7
711
712 u32 ioa_reset_in_progress:1;
713 u32 ioa_hard_reset:1;
714 u32 ioa_unit_check:1;
715 u32 ioa_bringdown:1;
716 u32 force_ioa_reset:1;
717 u32 reinit_cfg_table:1;
718 u32 ioa_shutdown_type:2;
719#define SHUTDOWN_NONE 0x0
720#define SHUTDOWN_NORMAL 0x1
721#define SHUTDOWN_ABBREV 0x2
722
723};
724
725
726struct pmcraid_resource_entry {
727 struct list_head queue;
728 struct pmcraid_config_table_entry cfg_entry;
729 struct scsi_device *scsi_dev;
730 atomic_t read_failures;
731 atomic_t write_failures;
732
733
734 u8 change_detected;
735#define RES_CHANGE_ADD 0x1
736#define RES_CHANGE_DEL 0x2
737
738 u8 reset_progress;
739
740
741
742
743
744
745
746 u8 sync_reqd;
747
748
749
750
751
752 u8 target;
753};
754
755
756struct pmcraid_ioasc_error {
757 u32 ioasc_code;
758 u8 log_level;
759 char *error_string;
760};
761
762
763#define IOASC_LOG_LEVEL_NONE 0x0
764#define IOASC_LOG_LEVEL_MUST 0x1
765#define IOASC_LOG_LEVEL_HARD 0x2
766
767
768
769
770static struct pmcraid_ioasc_error pmcraid_ioasc_error_table[] = {
771 {0x01180600, IOASC_LOG_LEVEL_MUST,
772 "Recovered Error, soft media error, sector reassignment suggested"},
773 {0x015D0000, IOASC_LOG_LEVEL_MUST,
774 "Recovered Error, failure prediction thresold exceeded"},
775 {0x015D9200, IOASC_LOG_LEVEL_MUST,
776 "Recovered Error, soft Cache Card Battery error thresold"},
777 {0x015D9200, IOASC_LOG_LEVEL_MUST,
778 "Recovered Error, soft Cache Card Battery error thresold"},
779 {0x02048000, IOASC_LOG_LEVEL_MUST,
780 "Not Ready, IOA Reset Required"},
781 {0x02408500, IOASC_LOG_LEVEL_MUST,
782 "Not Ready, IOA microcode download required"},
783 {0x03110B00, IOASC_LOG_LEVEL_MUST,
784 "Medium Error, data unreadable, reassignment suggested"},
785 {0x03110C00, IOASC_LOG_LEVEL_MUST,
786 "Medium Error, data unreadable do not reassign"},
787 {0x03310000, IOASC_LOG_LEVEL_MUST,
788 "Medium Error, media corrupted"},
789 {0x04050000, IOASC_LOG_LEVEL_MUST,
790 "Hardware Error, IOA can't communicate with device"},
791 {0x04080000, IOASC_LOG_LEVEL_MUST,
792 "Hardware Error, device bus error"},
793 {0x04080000, IOASC_LOG_LEVEL_MUST,
794 "Hardware Error, device bus is not functioning"},
795 {0x04118000, IOASC_LOG_LEVEL_MUST,
796 "Hardware Error, IOA reserved area data check"},
797 {0x04118100, IOASC_LOG_LEVEL_MUST,
798 "Hardware Error, IOA reserved area invalid data pattern"},
799 {0x04118200, IOASC_LOG_LEVEL_MUST,
800 "Hardware Error, IOA reserved area LRC error"},
801 {0x04320000, IOASC_LOG_LEVEL_MUST,
802 "Hardware Error, reassignment space exhausted"},
803 {0x04330000, IOASC_LOG_LEVEL_MUST,
804 "Hardware Error, data transfer underlength error"},
805 {0x04330000, IOASC_LOG_LEVEL_MUST,
806 "Hardware Error, data transfer overlength error"},
807 {0x04418000, IOASC_LOG_LEVEL_MUST,
808 "Hardware Error, PCI bus error"},
809 {0x04440000, IOASC_LOG_LEVEL_MUST,
810 "Hardware Error, device error"},
811 {0x04448300, IOASC_LOG_LEVEL_MUST,
812 "Hardware Error, undefined device response"},
813 {0x04448400, IOASC_LOG_LEVEL_MUST,
814 "Hardware Error, IOA microcode error"},
815 {0x04448600, IOASC_LOG_LEVEL_MUST,
816 "Hardware Error, IOA reset required"},
817 {0x04449200, IOASC_LOG_LEVEL_MUST,
818 "Hardware Error, hard Cache Fearuee Card Battery error"},
819 {0x0444A000, IOASC_LOG_LEVEL_MUST,
820 "Hardware Error, failed device altered"},
821 {0x0444A200, IOASC_LOG_LEVEL_MUST,
822 "Hardware Error, data check after reassignment"},
823 {0x0444A300, IOASC_LOG_LEVEL_MUST,
824 "Hardware Error, LRC error after reassignment"},
825 {0x044A0000, IOASC_LOG_LEVEL_MUST,
826 "Hardware Error, device bus error (msg/cmd phase)"},
827 {0x04670400, IOASC_LOG_LEVEL_MUST,
828 "Hardware Error, new device can't be used"},
829 {0x04678000, IOASC_LOG_LEVEL_MUST,
830 "Hardware Error, invalid multiadapter configuration"},
831 {0x04678100, IOASC_LOG_LEVEL_MUST,
832 "Hardware Error, incorrect connection between enclosures"},
833 {0x04678200, IOASC_LOG_LEVEL_MUST,
834 "Hardware Error, connections exceed IOA design limits"},
835 {0x04678300, IOASC_LOG_LEVEL_MUST,
836 "Hardware Error, incorrect multipath connection"},
837 {0x04679000, IOASC_LOG_LEVEL_MUST,
838 "Hardware Error, command to LUN failed"},
839 {0x064C8000, IOASC_LOG_LEVEL_HARD,
840 "Unit Attention, cache exists for missing/failed device"},
841 {0x06670100, IOASC_LOG_LEVEL_HARD,
842 "Unit Attention, incompatible exposed mode device"},
843 {0x06670600, IOASC_LOG_LEVEL_HARD,
844 "Unit Attention, attachment of logical unit failed"},
845 {0x06678000, IOASC_LOG_LEVEL_MUST,
846 "Unit Attention, cables exceed connective design limit"},
847 {0x06678300, IOASC_LOG_LEVEL_MUST,
848 "Unit Attention, incomplete multipath connection between" \
849 "IOA and enclosure"},
850 {0x06678400, IOASC_LOG_LEVEL_MUST,
851 "Unit Attention, incomplete multipath connection between" \
852 "device and enclosure"},
853 {0x06678500, IOASC_LOG_LEVEL_MUST,
854 "Unit Attention, incomplete multipath connection between" \
855 "IOA and remote IOA"},
856 {0x06678600, IOASC_LOG_LEVEL_HARD,
857 "Unit Attention, missing remote IOA"},
858 {0x06679100, IOASC_LOG_LEVEL_HARD,
859 "Unit Attention, enclosure doesn't support required multipath" \
860 "function"},
861 {0x06698200, IOASC_LOG_LEVEL_HARD,
862 "Unit Attention, corrupt array parity detected on device"},
863 {0x066B0200, IOASC_LOG_LEVEL_MUST,
864 "Unit Attention, array exposed"},
865 {0x066B8200, IOASC_LOG_LEVEL_HARD,
866 "Unit Attention, exposed array is still protected"},
867 {0x066B9200, IOASC_LOG_LEVEL_MUST,
868 "Unit Attention, Multipath redundancy level got worse"},
869 {0x07270000, IOASC_LOG_LEVEL_HARD,
870 "Data Protect, device is read/write protected by IOA"},
871 {0x07278000, IOASC_LOG_LEVEL_HARD,
872 "Data Protect, IOA doesn't support device attribute"},
873 {0x07278100, IOASC_LOG_LEVEL_HARD,
874 "Data Protect, NVRAM mirroring prohibited"},
875 {0x07278400, IOASC_LOG_LEVEL_MUST,
876 "Data Protect, array is short 2 or more devices"},
877 {0x07278600, IOASC_LOG_LEVEL_MUST,
878 "Data Protect, exposed array is short a required device"},
879 {0x07278700, IOASC_LOG_LEVEL_MUST,
880 "Data Protect, array members not at required addresses"},
881 {0x07278800, IOASC_LOG_LEVEL_MUST,
882 "Data Protect, exposed mode device resource address conflict"},
883 {0x07278900, IOASC_LOG_LEVEL_MUST,
884 "Data Protect, incorrect resource address of exposed mode device"},
885 {0x07278A00, IOASC_LOG_LEVEL_MUST,
886 "Data Protect, Array is missing a device and parity is out of sync"},
887 {0x07278B00, IOASC_LOG_LEVEL_MUST,
888 "Data Protect, maximum number of arrays already exist"},
889 {0x07278C00, IOASC_LOG_LEVEL_HARD,
890 "Data Protect, cannot locate cache data for device"},
891 {0x07278D00, IOASC_LOG_LEVEL_HARD,
892 "Data Protect, cache data exits for a changed device"},
893 {0x07279100, IOASC_LOG_LEVEL_MUST,
894 "Data Protect, detection of a device requiring format"},
895 {0x07279200, IOASC_LOG_LEVEL_MUST,
896 "Data Protect, IOA exceeds maximum number of devices"},
897 {0x07279600, IOASC_LOG_LEVEL_MUST,
898 "Data Protect, missing array, volume set is not functional"},
899 {0x07279700, IOASC_LOG_LEVEL_MUST,
900 "Data Protect, single device for a volume set"},
901 {0x07279800, IOASC_LOG_LEVEL_MUST,
902 "Data Protect, missing multiple devices for a volume set"},
903 {0x07279900, IOASC_LOG_LEVEL_HARD,
904 "Data Protect, maximum number of volument sets already exists"},
905 {0x07279A00, IOASC_LOG_LEVEL_MUST,
906 "Data Protect, other volume set problem"},
907};
908
909
910#define pmcraid_err(...) \
911 printk(KERN_ERR "MaxRAID: "__VA_ARGS__)
912
913#define pmcraid_info(...) \
914 if (pmcraid_debug_log) \
915 printk(KERN_INFO "MaxRAID: "__VA_ARGS__)
916
917
918#define SCSI_READ_CMD 0x1
919#define SCSI_WRITE_CMD 0x2
920#define SCSI_CMD_TYPE(opcode) \
921({ u8 op = opcode; u8 __type = 0;\
922 if (op == READ_6 || op == READ_10 || op == READ_12 || op == READ_16)\
923 __type = SCSI_READ_CMD;\
924 else if (op == WRITE_6 || op == WRITE_10 || op == WRITE_12 || \
925 op == WRITE_16)\
926 __type = SCSI_WRITE_CMD;\
927 __type;\
928})
929
930#define IS_SCSI_READ_WRITE(opcode) \
931({ u8 __type = SCSI_CMD_TYPE(opcode); \
932 (__type == SCSI_READ_CMD || __type == SCSI_WRITE_CMD) ? 1 : 0;\
933})
934
935
936
937
938
939
940
941
942
943
944struct pmcraid_ioctl_header {
945 u8 signature[8];
946 u32 reserved;
947 u32 buffer_length;
948};
949
950#define PMCRAID_IOCTL_SIGNATURE "PMCRAID"
951
952
953
954
955
956
957
958
959struct pmcraid_event_details {
960 struct pmcraid_hcam_ccn rcb_ccn;
961 struct pmcraid_hcam_ldn rcb_ldn;
962};
963
964
965
966
967
968struct pmcraid_driver_ioctl_buffer {
969 struct pmcraid_ioctl_header ioctl_header;
970 struct pmcraid_event_details event_details;
971};
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987struct pmcraid_passthrough_ioctl_buffer {
988 struct pmcraid_ioctl_header ioctl_header;
989 struct pmcraid_ioarcb ioarcb;
990 struct pmcraid_ioasa ioasa;
991 u8 request_buffer[1];
992} __attribute__ ((packed));
993
994
995
996
997
998
999#define PMCRAID_DRIVER_IOCTL 'D'
1000#define PMCRAID_PASSTHROUGH_IOCTL 'F'
1001
1002#define DRV_IOCTL(n, size) \
1003 _IOC(_IOC_READ|_IOC_WRITE, PMCRAID_DRIVER_IOCTL, (n), (size))
1004
1005#define FMW_IOCTL(n, size) \
1006 _IOC(_IOC_READ|_IOC_WRITE, PMCRAID_PASSTHROUGH_IOCTL, (n), (size))
1007
1008
1009
1010
1011
1012
1013#define _ARGSIZE(arg) (sizeof(struct pmcraid_ioctl_header) + sizeof(arg))
1014
1015
1016
1017#define PMCRAID_IOCTL_RESET_ADAPTER \
1018 DRV_IOCTL(5, sizeof(struct pmcraid_ioctl_header))
1019
1020
1021#define PMCRAID_IOCTL_PASSTHROUGH_COMMAND \
1022 FMW_IOCTL(1, sizeof(struct pmcraid_passthrough_ioctl_buffer))
1023
1024#define PMCRAID_IOCTL_DOWNLOAD_MICROCODE \
1025 FMW_IOCTL(2, sizeof(struct pmcraid_passthrough_ioctl_buffer))
1026
1027
1028#endif
1029