aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorHighPoint Linux Team <linux@highpoint-tech.com>2007-08-30 06:06:21 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:46:40 -0400
commitdb9b6e89ea8dc3f32dea1125c672de1a9710be7c (patch)
tree62532db0e64c087a13955cff928775d74f6a4bbd /drivers/scsi
parentff17a29d3cd9819a0977a07047e8f54e57dca7ce (diff)
[SCSI] hptiop: adding new firmware interface and more PCI device IDs
updated patch based on Jeff Garzik's comments. - check adapter firmware version and use appropriate interface accordingly - add new PCI device IDs and use PCI_VDEVICE macro - update driver version string - remove unused data structures - remove unnecessary typecasts Signed-off-by: HighPoint Linux Team <linux@highpoint-tech.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/hptiop.c63
-rw-r--r--drivers/scsi/hptiop.h229
2 files changed, 58 insertions, 234 deletions
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 0e579ca45814..8b384fa7f048 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * HighPoint RR3xxx controller driver for Linux 2 * HighPoint RR3xxx controller driver for Linux
3 * Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved. 3 * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ MODULE_DESCRIPTION("HighPoint RocketRAID 3xxx SATA Controller Driver");
42 42
43static char driver_name[] = "hptiop"; 43static char driver_name[] = "hptiop";
44static const char driver_name_long[] = "RocketRAID 3xxx SATA Controller driver"; 44static const char driver_name_long[] = "RocketRAID 3xxx SATA Controller driver";
45static const char driver_ver[] = "v1.0 (060426)"; 45static const char driver_ver[] = "v1.2 (070830)";
46 46
47static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag); 47static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag);
48static void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag); 48static void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag);
@@ -76,7 +76,7 @@ static int iop_wait_ready(struct hpt_iopmu __iomem *iop, u32 millisec)
76 76
77static void hptiop_request_callback(struct hptiop_hba *hba, u32 tag) 77static void hptiop_request_callback(struct hptiop_hba *hba, u32 tag)
78{ 78{
79 if ((tag & IOPMU_QUEUE_MASK_HOST_BITS) == IOPMU_QUEUE_ADDR_HOST_BIT) 79 if (tag & IOPMU_QUEUE_ADDR_HOST_BIT)
80 return hptiop_host_request_callback(hba, 80 return hptiop_host_request_callback(hba,
81 tag & ~IOPMU_QUEUE_ADDR_HOST_BIT); 81 tag & ~IOPMU_QUEUE_ADDR_HOST_BIT);
82 else 82 else
@@ -323,12 +323,22 @@ static inline void free_req(struct hptiop_hba *hba, struct hptiop_request *req)
323 hba->req_list = req; 323 hba->req_list = req;
324} 324}
325 325
326static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag) 326static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag)
327{ 327{
328 struct hpt_iop_request_scsi_command *req; 328 struct hpt_iop_request_scsi_command *req;
329 struct scsi_cmnd *scp; 329 struct scsi_cmnd *scp;
330 u32 tag;
331
332 if (hba->iopintf_v2) {
333 tag = _tag & ~ IOPMU_QUEUE_REQUEST_RESULT_BIT;
334 req = hba->reqs[tag].req_virt;
335 if (likely(_tag & IOPMU_QUEUE_REQUEST_RESULT_BIT))
336 req->header.result = IOP_RESULT_SUCCESS;
337 } else {
338 tag = _tag;
339 req = hba->reqs[tag].req_virt;
340 }
330 341
331 req = (struct hpt_iop_request_scsi_command *)hba->reqs[tag].req_virt;
332 dprintk("hptiop_host_request_callback: req=%p, type=%d, " 342 dprintk("hptiop_host_request_callback: req=%p, type=%d, "
333 "result=%d, context=0x%x tag=%d\n", 343 "result=%d, context=0x%x tag=%d\n",
334 req, req->header.type, req->header.result, 344 req, req->header.type, req->header.result,
@@ -497,7 +507,7 @@ static int hptiop_queuecommand(struct scsi_cmnd *scp,
497 goto cmd_done; 507 goto cmd_done;
498 } 508 }
499 509
500 req = (struct hpt_iop_request_scsi_command *)_req->req_virt; 510 req = _req->req_virt;
501 511
502 /* build S/G table */ 512 /* build S/G table */
503 sg_count = hptiop_buildsgl(scp, req->sg_list); 513 sg_count = hptiop_buildsgl(scp, req->sg_list);
@@ -521,8 +531,19 @@ static int hptiop_queuecommand(struct scsi_cmnd *scp,
521 531
522 memcpy(req->cdb, scp->cmnd, sizeof(req->cdb)); 532 memcpy(req->cdb, scp->cmnd, sizeof(req->cdb));
523 533
524 writel(IOPMU_QUEUE_ADDR_HOST_BIT | _req->req_shifted_phy, 534 if (hba->iopintf_v2) {
525 &hba->iop->inbound_queue); 535 u32 size_bits;
536 if (req->header.size < 256)
537 size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT;
538 else if (req->header.size < 512)
539 size_bits = IOPMU_QUEUE_ADDR_HOST_BIT;
540 else
541 size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT |
542 IOPMU_QUEUE_ADDR_HOST_BIT;
543 writel(_req->req_shifted_phy | size_bits, &hba->iop->inbound_queue);
544 } else
545 writel(_req->req_shifted_phy | IOPMU_QUEUE_ADDR_HOST_BIT,
546 &hba->iop->inbound_queue);
526 547
527 return 0; 548 return 0;
528 549
@@ -688,6 +709,7 @@ static int __devinit hptiop_probe(struct pci_dev *pcidev,
688 hba->pcidev = pcidev; 709 hba->pcidev = pcidev;
689 hba->host = host; 710 hba->host = host;
690 hba->initialized = 0; 711 hba->initialized = 0;
712 hba->iopintf_v2 = 0;
691 713
692 atomic_set(&hba->resetting, 0); 714 atomic_set(&hba->resetting, 0);
693 atomic_set(&hba->reset_count, 0); 715 atomic_set(&hba->reset_count, 0);
@@ -722,8 +744,13 @@ static int __devinit hptiop_probe(struct pci_dev *pcidev,
722 hba->max_request_size = le32_to_cpu(iop_config.request_size); 744 hba->max_request_size = le32_to_cpu(iop_config.request_size);
723 hba->max_sg_descriptors = le32_to_cpu(iop_config.max_sg_count); 745 hba->max_sg_descriptors = le32_to_cpu(iop_config.max_sg_count);
724 hba->firmware_version = le32_to_cpu(iop_config.firmware_version); 746 hba->firmware_version = le32_to_cpu(iop_config.firmware_version);
747 hba->interface_version = le32_to_cpu(iop_config.interface_version);
725 hba->sdram_size = le32_to_cpu(iop_config.sdram_size); 748 hba->sdram_size = le32_to_cpu(iop_config.sdram_size);
726 749
750 if (hba->firmware_version > 0x01020000 ||
751 hba->interface_version > 0x01020000)
752 hba->iopintf_v2 = 1;
753
727 host->max_sectors = le32_to_cpu(iop_config.data_transfer_length) >> 9; 754 host->max_sectors = le32_to_cpu(iop_config.data_transfer_length) >> 9;
728 host->max_id = le32_to_cpu(iop_config.max_devices); 755 host->max_id = le32_to_cpu(iop_config.max_devices);
729 host->sg_tablesize = le32_to_cpu(iop_config.max_sg_count); 756 host->sg_tablesize = le32_to_cpu(iop_config.max_sg_count);
@@ -731,8 +758,15 @@ static int __devinit hptiop_probe(struct pci_dev *pcidev,
731 host->cmd_per_lun = le32_to_cpu(iop_config.max_requests); 758 host->cmd_per_lun = le32_to_cpu(iop_config.max_requests);
732 host->max_cmd_len = 16; 759 host->max_cmd_len = 16;
733 760
734 set_config.vbus_id = cpu_to_le32(host->host_no); 761 req_size = sizeof(struct hpt_iop_request_scsi_command)
762 + sizeof(struct hpt_iopsg) * (hba->max_sg_descriptors - 1);
763 if ((req_size & 0x1f) != 0)
764 req_size = (req_size + 0x1f) & ~0x1f;
765
766 memset(&set_config, 0, sizeof(struct hpt_iop_request_set_config));
735 set_config.iop_id = cpu_to_le32(host->host_no); 767 set_config.iop_id = cpu_to_le32(host->host_no);
768 set_config.vbus_id = cpu_to_le16(host->host_no);
769 set_config.max_host_request_size = cpu_to_le16(req_size);
736 770
737 if (iop_set_config(hba, &set_config)) { 771 if (iop_set_config(hba, &set_config)) {
738 printk(KERN_ERR "scsi%d: set config failed\n", 772 printk(KERN_ERR "scsi%d: set config failed\n",
@@ -750,10 +784,6 @@ static int __devinit hptiop_probe(struct pci_dev *pcidev,
750 } 784 }
751 785
752 /* Allocate request mem */ 786 /* Allocate request mem */
753 req_size = sizeof(struct hpt_iop_request_scsi_command)
754 + sizeof(struct hpt_iopsg) * (hba->max_sg_descriptors - 1);
755 if ((req_size& 0x1f) != 0)
756 req_size = (req_size + 0x1f) & ~0x1f;
757 787
758 dprintk("req_size=%d, max_requests=%d\n", req_size, hba->max_requests); 788 dprintk("req_size=%d, max_requests=%d\n", req_size, hba->max_requests);
759 789
@@ -879,8 +909,10 @@ static void hptiop_remove(struct pci_dev *pcidev)
879} 909}
880 910
881static struct pci_device_id hptiop_id_table[] = { 911static struct pci_device_id hptiop_id_table[] = {
882 { PCI_DEVICE(0x1103, 0x3220) }, 912 { PCI_VDEVICE(TTI, 0x3220) },
883 { PCI_DEVICE(0x1103, 0x3320) }, 913 { PCI_VDEVICE(TTI, 0x3320) },
914 { PCI_VDEVICE(TTI, 0x3520) },
915 { PCI_VDEVICE(TTI, 0x4320) },
884 {}, 916 {},
885}; 917};
886 918
@@ -910,3 +942,4 @@ module_init(hptiop_module_init);
910module_exit(hptiop_module_exit); 942module_exit(hptiop_module_exit);
911 943
912MODULE_LICENSE("GPL"); 944MODULE_LICENSE("GPL");
945
diff --git a/drivers/scsi/hptiop.h b/drivers/scsi/hptiop.h
index f04f7e81d1ae..2a5e46e001cb 100644
--- a/drivers/scsi/hptiop.h
+++ b/drivers/scsi/hptiop.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * HighPoint RR3xxx controller driver for Linux 2 * HighPoint RR3xxx controller driver for Linux
3 * Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved. 3 * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License as published by
@@ -18,219 +18,6 @@
18#ifndef _HPTIOP_H_ 18#ifndef _HPTIOP_H_
19#define _HPTIOP_H_ 19#define _HPTIOP_H_
20 20
21/*
22 * logical device type.
23 * Identify array (logical device) and physical device.
24 */
25#define LDT_ARRAY 1
26#define LDT_DEVICE 2
27
28/*
29 * Array types
30 */
31#define AT_UNKNOWN 0
32#define AT_RAID0 1
33#define AT_RAID1 2
34#define AT_RAID5 3
35#define AT_RAID6 4
36#define AT_JBOD 7
37
38#define MAX_NAME_LENGTH 36
39#define MAX_ARRAYNAME_LEN 16
40
41#define MAX_ARRAY_MEMBERS_V1 8
42#define MAX_ARRAY_MEMBERS_V2 16
43
44/* keep definition for source code compatiblity */
45#define MAX_ARRAY_MEMBERS MAX_ARRAY_MEMBERS_V1
46
47/*
48 * array flags
49 */
50#define ARRAY_FLAG_DISABLED 0x00000001 /* The array is disabled */
51#define ARRAY_FLAG_NEEDBUILDING 0x00000002 /* need to be rebuilt */
52#define ARRAY_FLAG_REBUILDING 0x00000004 /* in rebuilding process */
53#define ARRAY_FLAG_BROKEN 0x00000008 /* broken but still working */
54#define ARRAY_FLAG_BOOTDISK 0x00000010 /* has a active partition */
55#define ARRAY_FLAG_BOOTMARK 0x00000040 /* array has boot mark set */
56#define ARRAY_FLAG_NEED_AUTOREBUILD 0x00000080 /* auto-rebuild should start */
57#define ARRAY_FLAG_VERIFYING 0x00000100 /* is being verified */
58#define ARRAY_FLAG_INITIALIZING 0x00000200 /* is being initialized */
59#define ARRAY_FLAG_TRANSFORMING 0x00000400 /* tranform in progress */
60#define ARRAY_FLAG_NEEDTRANSFORM 0x00000800 /* array need tranform */
61#define ARRAY_FLAG_NEEDINITIALIZING 0x00001000 /* initialization not done */
62#define ARRAY_FLAG_BROKEN_REDUNDANT 0x00002000 /* broken but redundant */
63
64/*
65 * device flags
66 */
67#define DEVICE_FLAG_DISABLED 0x00000001 /* device is disabled */
68#define DEVICE_FLAG_UNINITIALIZED 0x00010000 /* device is not initialized */
69#define DEVICE_FLAG_LEGACY 0x00020000 /* lagacy drive */
70#define DEVICE_FLAG_IS_SPARE 0x80000000 /* is a spare disk */
71
72/*
73 * ioctl codes
74 */
75#define HPT_CTL_CODE(x) (x+0xFF00)
76#define HPT_CTL_CODE_LINUX_TO_IOP(x) ((x)-0xff00)
77
78#define HPT_IOCTL_GET_CONTROLLER_INFO HPT_CTL_CODE(2)
79#define HPT_IOCTL_GET_CHANNEL_INFO HPT_CTL_CODE(3)
80#define HPT_IOCTL_GET_LOGICAL_DEVICES HPT_CTL_CODE(4)
81#define HPT_IOCTL_GET_DRIVER_CAPABILITIES HPT_CTL_CODE(19)
82#define HPT_IOCTL_GET_DEVICE_INFO_V3 HPT_CTL_CODE(46)
83#define HPT_IOCTL_GET_CONTROLLER_INFO_V2 HPT_CTL_CODE(47)
84
85/*
86 * Controller information.
87 */
88struct hpt_controller_info {
89 u8 chip_type; /* chip type */
90 u8 interrupt_level; /* IRQ level */
91 u8 num_buses; /* bus count */
92 u8 chip_flags;
93
94 u8 product_id[MAX_NAME_LENGTH];/* product name */
95 u8 vendor_id[MAX_NAME_LENGTH]; /* vendor name */
96}
97__attribute__((packed));
98
99/*
100 * Channel information.
101 */
102struct hpt_channel_info {
103 __le32 io_port; /* IDE Base Port Address */
104 __le32 control_port; /* IDE Control Port Address */
105 __le32 devices[2]; /* device connected to this channel */
106}
107__attribute__((packed));
108
109/*
110 * Array information.
111 */
112struct hpt_array_info_v3 {
113 u8 name[MAX_ARRAYNAME_LEN]; /* array name */
114 u8 description[64]; /* array description */
115 u8 create_manager[16]; /* who created it */
116 __le32 create_time; /* when created it */
117
118 u8 array_type; /* array type */
119 u8 block_size_shift; /* stripe size */
120 u8 ndisk; /* Number of ID in Members[] */
121 u8 reserved;
122
123 __le32 flags; /* working flags, see ARRAY_FLAG_XXX */
124 __le32 members[MAX_ARRAY_MEMBERS_V2]; /* member array/disks */
125
126 __le32 rebuilding_progress;
127 __le64 rebuilt_sectors; /* rebuilding point (LBA) for single member */
128
129 __le32 transform_source;
130 __le32 transform_target; /* destination device ID */
131 __le32 transforming_progress;
132 __le32 signature; /* persistent identification*/
133 __le16 critical_members; /* bit mask of critical members */
134 __le16 reserve2;
135 __le32 reserve;
136}
137__attribute__((packed));
138
139/*
140 * physical device information.
141 */
142#define MAX_PARENTS_PER_DISK 8
143
144struct hpt_device_info_v2 {
145 u8 ctlr_id; /* controller id */
146 u8 path_id; /* bus */
147 u8 target_id; /* id */
148 u8 device_mode_setting; /* Current Data Transfer mode: 0-4 PIO0-4 */
149 /* 5-7 MW DMA0-2, 8-13 UDMA0-5 */
150 u8 device_type; /* device type */
151 u8 usable_mode; /* highest usable mode */
152
153#ifdef __BIG_ENDIAN_BITFIELD
154 u8 NCQ_enabled: 1;
155 u8 NCQ_supported: 1;
156 u8 TCQ_enabled: 1;
157 u8 TCQ_supported: 1;
158 u8 write_cache_enabled: 1;
159 u8 write_cache_supported: 1;
160 u8 read_ahead_enabled: 1;
161 u8 read_ahead_supported: 1;
162 u8 reserved6: 6;
163 u8 spin_up_mode: 2;
164#else
165 u8 read_ahead_supported: 1;
166 u8 read_ahead_enabled: 1;
167 u8 write_cache_supported: 1;
168 u8 write_cache_enabled: 1;
169 u8 TCQ_supported: 1;
170 u8 TCQ_enabled: 1;
171 u8 NCQ_supported: 1;
172 u8 NCQ_enabled: 1;
173 u8 spin_up_mode: 2;
174 u8 reserved6: 6;
175#endif
176
177 __le32 flags; /* working flags, see DEVICE_FLAG_XXX */
178 u8 ident[150]; /* (partitial) Identify Data of this device */
179
180 __le64 total_free;
181 __le64 max_free;
182 __le64 bad_sectors;
183 __le32 parent_arrays[MAX_PARENTS_PER_DISK];
184}
185__attribute__((packed));
186
187/*
188 * Logical device information.
189 */
190#define INVALID_TARGET_ID 0xFF
191#define INVALID_BUS_ID 0xFF
192
193struct hpt_logical_device_info_v3 {
194 u8 type; /* LDT_ARRAY or LDT_DEVICE */
195 u8 cache_policy; /* refer to CACHE_POLICY_xxx */
196 u8 vbus_id; /* vbus sequence in vbus_list */
197 u8 target_id; /* OS target id. 0xFF is invalid */
198 /* OS name: DISK $VBusId_$TargetId */
199 __le64 capacity; /* array capacity */
200 __le32 parent_array; /* don't use this field for physical
201 device. use ParentArrays field in
202 hpt_device_info_v2 */
203 /* reserved statistic fields */
204 __le32 stat1;
205 __le32 stat2;
206 __le32 stat3;
207 __le32 stat4;
208
209 union {
210 struct hpt_array_info_v3 array;
211 struct hpt_device_info_v2 device;
212 } __attribute__((packed)) u;
213
214}
215__attribute__((packed));
216
217/*
218 * ioctl structure
219 */
220#define HPT_IOCTL_MAGIC 0xA1B2C3D4
221
222struct hpt_ioctl_u {
223 u32 magic; /* used to check if it's a valid ioctl packet */
224 u32 ioctl_code; /* operation control code */
225 void __user *inbuf; /* input data buffer */
226 u32 inbuf_size; /* size of input data buffer */
227 void __user *outbuf; /* output data buffer */
228 u32 outbuf_size; /* size of output data buffer */
229 void __user *bytes_returned; /* count of bytes returned */
230}
231__attribute__((packed));
232
233
234struct hpt_iopmu 21struct hpt_iopmu
235{ 22{
236 __le32 resrved0[4]; 23 __le32 resrved0[4];
@@ -252,6 +39,8 @@ struct hpt_iopmu
252#define IOPMU_QUEUE_EMPTY 0xffffffff 39#define IOPMU_QUEUE_EMPTY 0xffffffff
253#define IOPMU_QUEUE_MASK_HOST_BITS 0xf0000000 40#define IOPMU_QUEUE_MASK_HOST_BITS 0xf0000000
254#define IOPMU_QUEUE_ADDR_HOST_BIT 0x80000000 41#define IOPMU_QUEUE_ADDR_HOST_BIT 0x80000000
42#define IOPMU_QUEUE_REQUEST_SIZE_BIT 0x40000000
43#define IOPMU_QUEUE_REQUEST_RESULT_BIT 0x40000000
255 44
256#define IOPMU_OUTBOUND_INT_MSG0 1 45#define IOPMU_OUTBOUND_INT_MSG0 1
257#define IOPMU_OUTBOUND_INT_MSG1 2 46#define IOPMU_OUTBOUND_INT_MSG1 2
@@ -336,7 +125,8 @@ struct hpt_iop_request_set_config
336{ 125{
337 struct hpt_iop_request_header header; 126 struct hpt_iop_request_header header;
338 __le32 iop_id; 127 __le32 iop_id;
339 __le32 vbus_id; 128 __le16 vbus_id;
129 __le16 max_host_request_size;
340 __le32 reserve[6]; 130 __le32 reserve[6];
341}; 131};
342 132
@@ -412,9 +202,8 @@ struct hptiop_hba {
412 struct Scsi_Host * host; 202 struct Scsi_Host * host;
413 struct pci_dev * pcidev; 203 struct pci_dev * pcidev;
414 204
415 struct list_head link;
416
417 /* IOP config info */ 205 /* IOP config info */
206 u32 interface_version;
418 u32 firmware_version; 207 u32 firmware_version;
419 u32 sdram_size; 208 u32 sdram_size;
420 u32 max_devices; 209 u32 max_devices;
@@ -423,8 +212,10 @@ struct hptiop_hba {
423 u32 max_sg_descriptors; 212 u32 max_sg_descriptors;
424 213
425 u32 req_size; /* host-allocated request buffer size */ 214 u32 req_size; /* host-allocated request buffer size */
426 int initialized; 215
427 int msg_done; 216 int iopintf_v2: 1;
217 int initialized: 1;
218 int msg_done: 1;
428 219
429 struct hptiop_request * req_list; 220 struct hptiop_request * req_list;
430 struct hptiop_request reqs[HPTIOP_MAX_REQUESTS]; 221 struct hptiop_request reqs[HPTIOP_MAX_REQUESTS];