blob: a35f54ebdce003509864280f437fa50bf7c371da [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Adaptec AAC series RAID controller driver
Alan Coxfa195af2008-10-27 15:16:36 +00003 * (c) Copyright 2001 Red Hat Inc.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux.
7 *
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -07008 * Copyright (c) 2000-2010 Adaptec, Inc.
9 * 2010 PMC-Sierra, Inc. (aacraid@pmc-sierra.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; see the file COPYING. If not, write to
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * Module Name:
26 * comminit.c
27 *
28 * Abstract: This supports the initialization of the host adapter commuication interface.
29 * This is a platform dependent module for the pci cyclone board.
30 *
31 */
32
33#include <linux/kernel.h>
34#include <linux/init.h>
35#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/pci.h>
37#include <linux/spinlock.h>
38#include <linux/slab.h>
39#include <linux/blkdev.h>
40#include <linux/completion.h>
41#include <linux/mm.h>
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -070042#include <scsi/scsi_host.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
44#include "aacraid.h"
45
Mark Haverkampbed30de2005-08-03 15:38:51 -070046struct aac_common aac_config = {
47 .irq_mod = 1
48};
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long commsize, unsigned long commalign)
51{
52 unsigned char *base;
53 unsigned long size, align;
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -070054 const unsigned long fibsize = 4096;
55 const unsigned long printfbufsiz = 256;
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -070056 unsigned long host_rrq_size = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 struct aac_init *init;
58 dma_addr_t phys;
Leubner, Achimd8e965072009-04-01 07:16:08 -070059 unsigned long aac_max_hostphysmempages;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -070061 if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE1)
62 host_rrq_size = (dev->scsi_host_ptr->can_queue
63 + AAC_NUM_MGT_FIB) * sizeof(u32);
64 size = fibsize + sizeof(struct aac_init) + commsize +
65 commalign + printfbufsiz + host_rrq_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67 base = pci_alloc_consistent(dev->pdev, size, &phys);
68
69 if(base == NULL)
70 {
71 printk(KERN_ERR "aacraid: unable to create mapping.\n");
72 return 0;
73 }
74 dev->comm_addr = (void *)base;
75 dev->comm_phys = phys;
76 dev->comm_size = size;
77
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -070078 if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE1) {
79 dev->host_rrq = (u32 *)(base + fibsize);
80 dev->host_rrq_pa = phys + fibsize;
81 memset(dev->host_rrq, 0, host_rrq_size);
82 }
83
84 dev->init = (struct aac_init *)(base + fibsize + host_rrq_size);
85 dev->init_pa = phys + fibsize + host_rrq_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
87 init = dev->init;
88
89 init->InitStructRevision = cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION);
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -070090 if (dev->max_fib_size != sizeof(struct hw_fib))
91 init->InitStructRevision = cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION_4);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 init->MiniPortRevision = cpu_to_le32(Sa_MINIPORT_REVISION);
93 init->fsrev = cpu_to_le32(dev->fsrev);
94
95 /*
96 * Adapter Fibs are the first thing allocated so that they
97 * start page aligned
98 */
99 dev->aif_base_va = (struct hw_fib *)base;
100
101 init->AdapterFibsVirtualAddress = 0;
102 init->AdapterFibsPhysicalAddress = cpu_to_le32((u32)phys);
103 init->AdapterFibsSize = cpu_to_le32(fibsize);
104 init->AdapterFibAlign = cpu_to_le32(sizeof(struct hw_fib));
Leubner, Achimd8e965072009-04-01 07:16:08 -0700105 /*
106 * number of 4k pages of host physical memory. The aacraid fw needs
107 * this number to be less than 4gb worth of pages. New firmware doesn't
108 * have any issues with the mapping system, but older Firmware did, and
109 * had *troubles* dealing with the math overloading past 32 bits, thus
110 * we must limit this field.
111 */
112 aac_max_hostphysmempages = dma_get_required_mask(&dev->pdev->dev) >> 12;
113 if (aac_max_hostphysmempages < AAC_MAX_HOSTPHYSMEMPAGES)
114 init->HostPhysMemPages = cpu_to_le32(aac_max_hostphysmempages);
115 else
116 init->HostPhysMemPages = cpu_to_le32(AAC_MAX_HOSTPHYSMEMPAGES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -0700118 init->InitFlags = 0;
Mark Haverkamp28713322007-01-23 14:59:20 -0800119 if (dev->comm_interface == AAC_COMM_MESSAGE) {
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -0700120 init->InitFlags |= cpu_to_le32(INITFLAGS_NEW_COMM_SUPPORTED);
Mark Haverkamp8e0c5eb2005-10-24 10:52:22 -0700121 dprintk((KERN_WARNING"aacraid: New Comm Interface enabled\n"));
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -0700122 } else if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE1) {
123 init->InitStructRevision = cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION_6);
124 init->InitFlags |= cpu_to_le32(INITFLAGS_NEW_COMM_TYPE1_SUPPORTED);
125 dprintk((KERN_WARNING
126 "aacraid: New Comm Interface type1 enabled\n"));
Mark Haverkamp8e0c5eb2005-10-24 10:52:22 -0700127 }
Mark Salyzyn655d7222008-04-30 16:03:42 -0400128 init->InitFlags |= cpu_to_le32(INITFLAGS_DRIVER_USES_UTC_TIME |
129 INITFLAGS_DRIVER_SUPPORTS_PM);
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -0700130 init->MaxIoCommands = cpu_to_le32(dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB);
131 init->MaxIoSize = cpu_to_le32(dev->scsi_host_ptr->max_sectors << 9);
132 init->MaxFibSize = cpu_to_le32(dev->max_fib_size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -0700134 init->MaxNumAif = cpu_to_le32(dev->max_num_aif);
135 init->HostRRQ_AddrHigh = (u32)((u64)dev->host_rrq_pa >> 32);
136 init->HostRRQ_AddrLow = (u32)(dev->host_rrq_pa & 0xffffffff);
137
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 /*
140 * Increment the base address by the amount already used
141 */
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -0700142 base = base + fibsize + host_rrq_size + sizeof(struct aac_init);
143 phys = (dma_addr_t)((ulong)phys + fibsize + host_rrq_size +
144 sizeof(struct aac_init));
145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 /*
147 * Align the beginning of Headers to commalign
148 */
Al Viro142956a2007-10-29 05:11:28 +0000149 align = (commalign - ((uintptr_t)(base) & (commalign - 1)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 base = base + align;
151 phys = phys + align;
152 /*
153 * Fill in addresses of the Comm Area Headers and Queues
154 */
155 *commaddr = base;
156 init->CommHeaderAddress = cpu_to_le32((u32)phys);
157 /*
158 * Increment the base address by the size of the CommArea
159 */
160 base = base + commsize;
161 phys = phys + commsize;
162 /*
163 * Place the Printf buffer area after the Fast I/O comm area.
164 */
165 dev->printfbuf = (void *)base;
166 init->printfbuf = cpu_to_le32(phys);
167 init->printfbufsiz = cpu_to_le32(printfbufsiz);
168 memset(base, 0, printfbufsiz);
169 return 1;
170}
171
172static void aac_queue_init(struct aac_dev * dev, struct aac_queue * q, u32 *mem, int qsize)
173{
174 q->numpending = 0;
175 q->dev = dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 init_waitqueue_head(&q->cmdready);
177 INIT_LIST_HEAD(&q->cmdq);
178 init_waitqueue_head(&q->qfull);
179 spin_lock_init(&q->lockdata);
180 q->lock = &q->lockdata;
Mark Haverkamp 56b58712005-04-27 06:05:51 -0700181 q->headers.producer = (__le32 *)mem;
182 q->headers.consumer = (__le32 *)(mem+1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 *(q->headers.producer) = cpu_to_le32(qsize);
184 *(q->headers.consumer) = cpu_to_le32(qsize);
185 q->entries = qsize;
186}
187
188/**
189 * aac_send_shutdown - shutdown an adapter
190 * @dev: Adapter to shutdown
191 *
192 * This routine will send a VM_CloseAll (shutdown) request to the adapter.
193 */
194
195int aac_send_shutdown(struct aac_dev * dev)
196{
197 struct fib * fibctx;
198 struct aac_close *cmd;
199 int status;
200
Mark Haverkampbfb35aa82006-02-01 09:30:55 -0800201 fibctx = aac_fib_alloc(dev);
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -0700202 if (!fibctx)
203 return -ENOMEM;
Mark Haverkampbfb35aa82006-02-01 09:30:55 -0800204 aac_fib_init(fibctx);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206 cmd = (struct aac_close *) fib_data(fibctx);
207
208 cmd->command = cpu_to_le32(VM_CloseAll);
209 cmd->cid = cpu_to_le32(0xffffffff);
210
Mark Haverkampbfb35aa82006-02-01 09:30:55 -0800211 status = aac_fib_send(ContainerCommand,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 fibctx,
213 sizeof(struct aac_close),
214 FsaNormal,
Mark Haverkamp92033442005-09-20 12:56:50 -0700215 -2 /* Timeout silently */, 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 NULL, NULL);
217
Mark Haverkamp90ee3462006-08-03 08:03:07 -0700218 if (status >= 0)
Mark Haverkampbfb35aa82006-02-01 09:30:55 -0800219 aac_fib_complete(fibctx);
Penchala Narasimha Reddy Chilakala, ERS-HCLTechcacb6dc2009-12-21 18:39:27 +0530220 /* FIB should be freed only after getting the response from the F/W */
221 if (status != -ERESTARTSYS)
222 aac_fib_free(fibctx);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 return status;
224}
225
226/**
227 * aac_comm_init - Initialise FSA data structures
228 * @dev: Adapter to initialise
229 *
230 * Initializes the data structures that are required for the FSA commuication
231 * interface to operate.
232 * Returns
233 * 1 - if we were able to init the commuication interface.
234 * 0 - If there were errors initing. This is a fatal error.
235 */
236
Adrian Bunk 48338692005-04-25 19:45:58 -0700237static int aac_comm_init(struct aac_dev * dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238{
239 unsigned long hdrsize = (sizeof(u32) * NUMBER_OF_COMM_QUEUES) * 2;
240 unsigned long queuesize = sizeof(struct aac_entry) * TOTAL_QUEUE_ENTRIES;
241 u32 *headers;
242 struct aac_entry * queues;
243 unsigned long size;
244 struct aac_queue_block * comm = dev->queues;
245 /*
246 * Now allocate and initialize the zone structures used as our
247 * pool of FIB context records. The size of the zone is based
248 * on the system memory size. We also initialize the mutex used
249 * to protect the zone.
250 */
251 spin_lock_init(&dev->fib_lock);
252
253 /*
André Goddard Rosaaf901ca2009-11-14 13:09:05 -0200254 * Allocate the physically contiguous space for the commuication
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 * queue headers.
256 */
257
258 size = hdrsize + queuesize;
259
260 if (!aac_alloc_comm(dev, (void * *)&headers, size, QUEUE_ALIGNMENT))
261 return -ENOMEM;
262
263 queues = (struct aac_entry *)(((ulong)headers) + hdrsize);
264
265 /* Adapter to Host normal priority Command queue */
266 comm->queue[HostNormCmdQueue].base = queues;
267 aac_queue_init(dev, &comm->queue[HostNormCmdQueue], headers, HOST_NORM_CMD_ENTRIES);
268 queues += HOST_NORM_CMD_ENTRIES;
269 headers += 2;
270
271 /* Adapter to Host high priority command queue */
272 comm->queue[HostHighCmdQueue].base = queues;
273 aac_queue_init(dev, &comm->queue[HostHighCmdQueue], headers, HOST_HIGH_CMD_ENTRIES);
274
275 queues += HOST_HIGH_CMD_ENTRIES;
276 headers +=2;
277
278 /* Host to adapter normal priority command queue */
279 comm->queue[AdapNormCmdQueue].base = queues;
280 aac_queue_init(dev, &comm->queue[AdapNormCmdQueue], headers, ADAP_NORM_CMD_ENTRIES);
281
282 queues += ADAP_NORM_CMD_ENTRIES;
283 headers += 2;
284
285 /* host to adapter high priority command queue */
286 comm->queue[AdapHighCmdQueue].base = queues;
287 aac_queue_init(dev, &comm->queue[AdapHighCmdQueue], headers, ADAP_HIGH_CMD_ENTRIES);
288
289 queues += ADAP_HIGH_CMD_ENTRIES;
290 headers += 2;
291
292 /* adapter to host normal priority response queue */
293 comm->queue[HostNormRespQueue].base = queues;
294 aac_queue_init(dev, &comm->queue[HostNormRespQueue], headers, HOST_NORM_RESP_ENTRIES);
295 queues += HOST_NORM_RESP_ENTRIES;
296 headers += 2;
297
298 /* adapter to host high priority response queue */
299 comm->queue[HostHighRespQueue].base = queues;
300 aac_queue_init(dev, &comm->queue[HostHighRespQueue], headers, HOST_HIGH_RESP_ENTRIES);
301
302 queues += HOST_HIGH_RESP_ENTRIES;
303 headers += 2;
304
305 /* host to adapter normal priority response queue */
306 comm->queue[AdapNormRespQueue].base = queues;
307 aac_queue_init(dev, &comm->queue[AdapNormRespQueue], headers, ADAP_NORM_RESP_ENTRIES);
308
309 queues += ADAP_NORM_RESP_ENTRIES;
310 headers += 2;
311
312 /* host to adapter high priority response queue */
313 comm->queue[AdapHighRespQueue].base = queues;
314 aac_queue_init(dev, &comm->queue[AdapHighRespQueue], headers, ADAP_HIGH_RESP_ENTRIES);
315
316 comm->queue[AdapNormCmdQueue].lock = comm->queue[HostNormRespQueue].lock;
317 comm->queue[AdapHighCmdQueue].lock = comm->queue[HostHighRespQueue].lock;
318 comm->queue[AdapNormRespQueue].lock = comm->queue[HostNormCmdQueue].lock;
319 comm->queue[AdapHighRespQueue].lock = comm->queue[HostHighCmdQueue].lock;
320
321 return 0;
322}
323
324struct aac_dev *aac_init_adapter(struct aac_dev *dev)
325{
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -0700326 u32 status[5];
327 struct Scsi_Host * host = dev->scsi_host_ptr;
Mahesh Rajashekhara11604612012-02-08 22:51:04 -0800328 extern int aac_sync_mode;
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -0700329
330 /*
331 * Check the preferred comm settings, defaults from template.
332 */
Penchala Narasimha Reddy Chilakala, ERS-HCLTechcacb6dc2009-12-21 18:39:27 +0530333 dev->management_fib_count = 0;
334 spin_lock_init(&dev->manage_lock);
Mahesh Rajashekhara11604612012-02-08 22:51:04 -0800335 spin_lock_init(&dev->sync_lock);
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -0700336 dev->max_fib_size = sizeof(struct hw_fib);
337 dev->sg_tablesize = host->sg_tablesize = (dev->max_fib_size
338 - sizeof(struct aac_fibhdr)
Mark Haverkamp63a70ee2005-09-20 12:57:04 -0700339 - sizeof(struct aac_write) + sizeof(struct sgentry))
340 / sizeof(struct sgentry);
Mark Haverkamp28713322007-01-23 14:59:20 -0800341 dev->comm_interface = AAC_COMM_PRODUCER;
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -0700342 dev->raw_io_interface = dev->raw_io_64 = 0;
343
Mark Haverkamp7a8cf292005-09-22 09:15:24 -0700344 if ((!aac_adapter_sync_cmd(dev, GET_ADAPTER_PROPERTIES,
345 0, 0, 0, 0, 0, 0, status+0, status+1, status+2, NULL, NULL)) &&
346 (status[0] == 0x00000001)) {
Salyzyn, Marka3940da2008-01-08 12:48:25 -0800347 if (status[1] & le32_to_cpu(AAC_OPT_NEW_COMM_64))
Mark Haverkamp7a8cf292005-09-22 09:15:24 -0700348 dev->raw_io_64 = 1;
Mahesh Rajashekhara11604612012-02-08 22:51:04 -0800349 dev->sync_mode = aac_sync_mode;
350 if (dev->a_ops.adapter_comm &&
351 (status[1] & le32_to_cpu(AAC_OPT_NEW_COMM))) {
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -0700352 dev->comm_interface = AAC_COMM_MESSAGE;
353 dev->raw_io_interface = 1;
Mahesh Rajashekhara11604612012-02-08 22:51:04 -0800354 if ((status[1] & le32_to_cpu(AAC_OPT_NEW_COMM_TYPE1))) {
355 /* driver supports TYPE1 (Tupelo) */
356 dev->comm_interface = AAC_COMM_MESSAGE_TYPE1;
357 } else if ((status[1] & le32_to_cpu(AAC_OPT_NEW_COMM_TYPE4)) ||
358 (status[1] & le32_to_cpu(AAC_OPT_NEW_COMM_TYPE3)) ||
359 (status[1] & le32_to_cpu(AAC_OPT_NEW_COMM_TYPE2))) {
360 /* driver doesn't support TYPE2 (Series7), TYPE3 and TYPE4 */
361 /* switch to sync. mode */
362 dev->comm_interface = AAC_COMM_MESSAGE_TYPE1;
363 dev->sync_mode = 1;
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -0700364 }
365 }
Mark Haverkamp28713322007-01-23 14:59:20 -0800366 if ((dev->comm_interface == AAC_COMM_MESSAGE) &&
367 (status[2] > dev->base_size)) {
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -0700368 aac_adapter_ioremap(dev, 0);
Mark Haverkamp8e0c5eb2005-10-24 10:52:22 -0700369 dev->base_size = status[2];
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -0700370 if (aac_adapter_ioremap(dev, status[2])) {
Mark Haverkamp8e0c5eb2005-10-24 10:52:22 -0700371 /* remap failed, go back ... */
Mark Haverkamp28713322007-01-23 14:59:20 -0800372 dev->comm_interface = AAC_COMM_PRODUCER;
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -0700373 if (aac_adapter_ioremap(dev, AAC_MIN_FOOTPRINT_SIZE)) {
Mark Haverkamp8e0c5eb2005-10-24 10:52:22 -0700374 printk(KERN_WARNING
375 "aacraid: unable to map adapter.\n");
376 return NULL;
377 }
378 }
379 }
Mark Haverkamp7a8cf292005-09-22 09:15:24 -0700380 }
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -0700381 if ((!aac_adapter_sync_cmd(dev, GET_COMM_PREFERRED_SETTINGS,
382 0, 0, 0, 0, 0, 0,
383 status+0, status+1, status+2, status+3, status+4))
384 && (status[0] == 0x00000001)) {
385 /*
386 * status[1] >> 16 maximum command size in KB
387 * status[1] & 0xFFFF maximum FIB size
388 * status[2] >> 16 maximum SG elements to driver
389 * status[2] & 0xFFFF maximum SG elements from driver
390 * status[3] & 0xFFFF maximum number FIBs outstanding
391 */
392 host->max_sectors = (status[1] >> 16) << 1;
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -0700393 /* Multiple of 32 for PMC */
394 dev->max_fib_size = status[1] & 0xFFE0;
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -0700395 host->sg_tablesize = status[2] >> 16;
396 dev->sg_tablesize = status[2] & 0xFFFF;
397 host->can_queue = (status[3] & 0xFFFF) - AAC_NUM_MGT_FIB;
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -0700398 dev->max_num_aif = status[4] & 0xFFFF;
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -0700399 /*
400 * NOTE:
401 * All these overrides are based on a fixed internal
402 * knowledge and understanding of existing adapters,
403 * acbsize should be set with caution.
404 */
405 if (acbsize == 512) {
406 host->max_sectors = AAC_MAX_32BIT_SGBCOUNT;
407 dev->max_fib_size = 512;
408 dev->sg_tablesize = host->sg_tablesize
409 = (512 - sizeof(struct aac_fibhdr)
Mark Haverkamp63a70ee2005-09-20 12:57:04 -0700410 - sizeof(struct aac_write) + sizeof(struct sgentry))
411 / sizeof(struct sgentry);
Mark Haverkamp 7c00ffa2005-05-16 18:28:42 -0700412 host->can_queue = AAC_NUM_IO_FIB;
413 } else if (acbsize == 2048) {
414 host->max_sectors = 512;
415 dev->max_fib_size = 2048;
416 host->sg_tablesize = 65;
417 dev->sg_tablesize = 81;
418 host->can_queue = 512 - AAC_NUM_MGT_FIB;
419 } else if (acbsize == 4096) {
420 host->max_sectors = 1024;
421 dev->max_fib_size = 4096;
422 host->sg_tablesize = 129;
423 dev->sg_tablesize = 166;
424 host->can_queue = 256 - AAC_NUM_MGT_FIB;
425 } else if (acbsize == 8192) {
426 host->max_sectors = 2048;
427 dev->max_fib_size = 8192;
428 host->sg_tablesize = 257;
429 dev->sg_tablesize = 337;
430 host->can_queue = 128 - AAC_NUM_MGT_FIB;
431 } else if (acbsize > 0) {
432 printk("Illegal acbsize=%d ignored\n", acbsize);
433 }
434 }
435 {
436
437 if (numacb > 0) {
438 if (numacb < host->can_queue)
439 host->can_queue = numacb;
440 else
441 printk("numacb=%d ignored\n", numacb);
442 }
443 }
444
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 /*
446 * Ok now init the communication subsystem
447 */
448
Salyzyn, Mark4dbc22d2007-04-16 11:21:50 -0400449 dev->queues = kzalloc(sizeof(struct aac_queue_block), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 if (dev->queues == NULL) {
451 printk(KERN_ERR "Error could not allocate comm region.\n");
452 return NULL;
453 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
455 if (aac_comm_init(dev)<0){
456 kfree(dev->queues);
457 return NULL;
458 }
459 /*
460 * Initialize the list of fibs
461 */
Mark Haverkampbfb35aa82006-02-01 09:30:55 -0800462 if (aac_fib_setup(dev) < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 kfree(dev->queues);
464 return NULL;
465 }
466
467 INIT_LIST_HEAD(&dev->fib_list);
Mahesh Rajashekhara11604612012-02-08 22:51:04 -0800468 INIT_LIST_HEAD(&dev->sync_fib_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
470 return dev;
471}
472
473