-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.c
658 lines (543 loc) · 19.1 KB
/
init.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
/*
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2012
* The ACX100 Open Source Project <acx100-devel@lists.sourceforge.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "acx_debug.h"
#include "acx.h"
#include "usb.h"
#include "merge.h"
#include "mem.h"
#include "pci.h"
#include "cmd.h"
#include "ie.h"
#include "init.h"
#include "cardsetting.h"
#include "tx.h"
#define ACX111_PERCENT(percent) ((percent)/5)
/* Probably a number of acx's intermediate buffers for USB transfers,
* not to be confused with number of descriptors in tx/rx rings
* (which are not directly accessible to host in USB devices)
*/
#define USB_RX_CNT 10
#define USB_TX_CNT 10
static int acx_init_max_template_generic(acx_device_t *adev, unsigned int len,
unsigned int cmdarg)
{
int res;
union {
acx_template_nullframe_t null;
acx_template_beacon_t b;
acx_template_tim_t tim;
acx_template_probereq_t preq;
acx_template_proberesp_t presp;
} templ;
memset(&templ, 0, len);
templ.null.size = cpu_to_le16(len - 2);
res = acx_issue_cmd(adev, cmdarg, &templ, len);
return res;
}
static int acx_init_max_null_data_template(acx_device_t *adev)
{
/* OW hh version:
* issue_cmd(cmd:cmd,buflen:26,timeout:50ms,type:0x0018)
* mac80211 version: issue_cmd: begin:
* (cmd:cmd,buflen:32,timeout:50ms,type:0x001E)
*
* diff with hh is struct ieee80211_hdr included in
* acx_template_nullframe_t, which is bigger, thus size if
* bigger
*/
return acx_init_max_template_generic(adev,
sizeof(acx_template_nullframe_t), ACX1xx_CMD_CONFIG_NULL_DATA);
}
static int acx_init_max_beacon_template(acx_device_t *adev)
{
return acx_init_max_template_generic(adev,
sizeof(acx_template_beacon_t),
ACX1xx_CMD_CONFIG_BEACON);
}
static int acx_init_max_tim_template(acx_device_t *adev)
{
return acx_init_max_template_generic(adev,
sizeof(acx_template_tim_t),
ACX1xx_CMD_CONFIG_TIM);
}
static int acx_init_max_probe_response_template(acx_device_t *adev)
{
return acx_init_max_template_generic(adev,
sizeof(acx_template_proberesp_t),
ACX1xx_CMD_CONFIG_PROBE_RESPONSE);
}
static int acx_init_max_probe_request_template(acx_device_t *adev)
{
return acx_init_max_template_generic(adev,
sizeof(acx_template_probereq_t),
ACX1xx_CMD_CONFIG_PROBE_REQUEST);
}
/*
* acx_s_init_packet_templates()
*
* NOTE: order is very important here, to have a correct memory
* layout! init templates: max Probe Request (station mode), max NULL
* data, max Beacon, max TIM, max Probe Response.
*/
static int acx_init_packet_templates(acx_device_t *adev)
{
acx_ie_memmap_t mm; /* ACX100 only */
int result = NOT_OK;
log(L_DEBUG | L_INIT, "initializing max packet templates\n");
if (OK != acx_init_max_probe_request_template(adev))
goto failed;
if (OK != acx_init_max_null_data_template(adev))
goto failed;
if (OK != acx_init_max_beacon_template(adev))
goto failed;
if (OK != acx_init_max_tim_template(adev))
goto failed;
if (OK != acx_init_max_probe_response_template(adev))
goto failed;
if (IS_ACX111(adev)) {
/* ACX111 doesn't need the memory map magic below, and
* the other templates will be set later (acx_start) */
result = OK;
goto success;
}
/* ACX100 will have its TIM template set,
* and we also need to update the memory map */
if (OK != acx_set_tim_template(adev, NULL, 0))
goto failed_acx100;
log(L_DEBUG, "sizeof(memmap) = %d bytes\n", (int)sizeof(mm));
if (OK != acx_interrogate(adev, &mm, ACX1xx_IE_MEMORY_MAP))
goto failed_acx100;
mm.QueueStart = cpu_to_le32(le32_to_cpu(mm.PacketTemplateEnd) + 4);
if (OK != acx_configure(adev, &mm, ACX1xx_IE_MEMORY_MAP))
goto failed_acx100;
result = OK;
goto success;
failed_acx100:
log(L_DEBUG | L_INIT,
/* "cb=0x%X\n" */
"acx: ACXMemoryMap:\n"
"acx: .CodeStart=0x%X\n"
"acx: .CodeEnd=0x%X\n"
"acx: .WEPCacheStart=0x%X\n"
"acx: .WEPCacheEnd=0x%X\n"
"acx: .PacketTemplateStart=0x%X\n"
"acx: .PacketTemplateEnd=0x%X\n",
/* len, */
le32_to_cpu(mm.CodeStart),
le32_to_cpu(mm.CodeEnd),
le32_to_cpu(mm.WEPCacheStart),
le32_to_cpu(mm.WEPCacheEnd),
le32_to_cpu(mm.PacketTemplateStart),
le32_to_cpu(mm.PacketTemplateEnd));
failed:
pr_info("%s: FAILED\n", wiphy_name(adev->hw->wiphy));
success:
return result;
}
/*
* acx111_s_create_dma_regions
*
* Note that this fn messes heavily with hardware, but we cannot
* lock it (we need to sleep). Not a problem since IRQs can't happen
*/
static int acx111_create_dma_regions(acx_device_t *adev)
{
int i;
struct acx111_ie_memoryconfig memconf;
struct acx111_ie_queueconfig queueconf;
u32 rx_queue_start;
u32 tx_queue_start[ACX111_NUM_HW_TX_QUEUES];
adev->num_hw_tx_queues = ACX111_NUM_HW_TX_QUEUES;
/* Calculate memory positions and queue sizes */
/* Set up our host descriptor pool + data pool */
if (IS_PCI(adev) || IS_MEM(adev)) {
if (OK != acx_create_hostdesc_queues(adev, ACX111_NUM_HW_TX_QUEUES))
goto fail;
}
memset(&memconf, 0, sizeof(memconf));
/* the number of STAs (STA contexts) to support
** NB: was set to 1 and everything seemed to work nevertheless... */
memconf.no_of_stations = 1; //cpu_to_le16(ARRAY_SIZE(adev->sta_list));
/* specify the memory block size. Default is 256 */
memconf.memory_block_size = cpu_to_le16(adev->memblocksize);
/* let's use 50%/50% for tx/rx (specify percentage, units of 5%) */
memconf.tx_rx_memory_block_allocation = ACX111_PERCENT(50);
/* set the count of our queues
** NB: struct acx111_ie_memoryconfig shall be modified
** if we ever will switch to more than one rx and/or tx queue */
memconf.count_rx_queues = 1;
memconf.count_tx_queues = ACX111_NUM_HW_TX_QUEUES;
/* 0 == Busmaster Indirect Memory Organization, which is what
* we want (using linked host descs with their allocated mem).
* 2 == Generic Bus Slave */
/* done by memset: memconf.options = 0; */
/* let's use 25% for fragmentations and 75% for frame transfers
* (specified in units of 5%) */
memconf.fragmentation = ACX111_PERCENT(75);
/* Rx descriptor queue config */
memconf.rx_queue1_count_descs = RX_CNT;
memconf.rx_queue1_type = 7; /* must be set to 7 */
/* done by memset: memconf.rx_queue1_prio = 0; low prio */
if (IS_PCI(adev)) {
#if defined(CONFIG_ACX_MAC80211_PCI)
memconf.rx_queue1_host_rx_start =
cpu2acx(adev->hw_rx_queue.hostdescinfo.phy);
#endif
}
else if (IS_MEM(adev)) {
#if defined(CONFIG_ACX_MAC80211_MEM)
memconf.rx_queue1_host_rx_start =
cpu2acx(adev->hw_rx_queue.hostdescinfo.phy);
#endif
}
/* Tx descriptor queue config */
for (i = 0; i < ACX111_NUM_HW_TX_QUEUES; i++) {
memconf.tx_queue[i].count_descs = TX_CNT;
// TODO check if prio if up- or downwards
/* done by memset: memconf.tx_queue1_attributes = 0; lowest priority */
memconf.tx_queue[i].attributes = ACX111_NUM_HW_TX_QUEUES - 1 - i;
}
if (OK != acx_configure(adev, &memconf, ACX111_IE_MEMORY_CONFIG_OPTIONS))
goto fail;
memset(&queueconf, 0, sizeof(queueconf));
acx_interrogate(adev, &queueconf, ACX111_IE_QUEUE_CONFIG);
rx_queue_start = le32_to_cpu(queueconf.rx1_queue_address);
for (i=0; i<ACX111_NUM_HW_TX_QUEUES; i++)
tx_queue_start[i] = le32_to_cpu(queueconf.tx_queue[i].address);
log(L_INIT,
"Queue head: len=%u, tx_memory_block_address=%X, rx_memory_block_address=%X\n",
le16_to_cpu(queueconf.len),
le32_to_cpu(queueconf.tx_memory_block_address),
le32_to_cpu(queueconf.rx_memory_block_address));
log(L_INIT, "Queue head: rx_queue_start=%X\n", rx_queue_start);
for (i=0; i<ACX111_NUM_HW_TX_QUEUES; i++)
log(L_INIT, "Queue head: tx_queue_start[%d]=%X\n", i, tx_queue_start[i]);
acx_create_desc_queues(adev, rx_queue_start, tx_queue_start,
ACX111_NUM_HW_TX_QUEUES);
return OK;
fail:
if (IS_PCI(adev) || IS_MEM(adev))
acx_free_desc_queues(adev);
return NOT_OK;
}
/*
* acx100_s_init_wep
*
* FIXME: this should probably be moved into the new card settings
* management, but since we're also modifying the memory map layout
* here due to the WEP key space we want, we should take care...
*/
static int acx100_init_wep(acx_device_t * adev)
{
/* acx100_ie_wep_options_t options;
* ie_dot11WEPDefaultKeyID_t dk;
*/
acx_ie_memmap_t pt;
int res = NOT_OK;
if (OK != acx_interrogate(adev, &pt, ACX1xx_IE_MEMORY_MAP))
goto fail;
log(L_DEBUG, "CodeEnd:%X\n", pt.CodeEnd);
pt.WEPCacheStart = cpu_to_le32(le32_to_cpu(pt.CodeEnd) + 0x4);
pt.WEPCacheEnd = cpu_to_le32(le32_to_cpu(pt.CodeEnd) + 0x4);
if (OK != acx_configure(adev, &pt, ACX1xx_IE_MEMORY_MAP))
goto fail;
/* OW: This disables WEP by not configuring the WEP cache and leaving
* WEPCacheStart=WEPCacheEnd.
*
* When doing the crypto by mac80211 it is required, that the acx is
* not doing any WEP crypto himself. Otherwise TX "WEP key not found"
* errors occure.
*
* By disabling WEP using WEPCacheStart=WEPCacheStart the acx not
* trying any own crypto anymore. All crypto (including WEP) is pushed
* to mac80211 for the moment.
*
*/
#if 0
/* let's choose maximum setting: 4 default keys, plus 10 other keys: */
options.NumKeys = cpu_to_le16(DOT11_MAX_DEFAULT_WEP_KEYS + 10);
options.WEPOption = 0x00;
log(L_ASSOC, "writing WEP options\n");
acx_configure(adev, &options, ACX100_IE_WEP_OPTIONS);
acx100_set_wepkey(adev);
if (adev->wep_keys[adev->wep_current_index].size != 0) {
log(L_ASSOC, "setting active default WEP key number: %d\n",
adev->wep_current_index);
dk.KeyID = adev->wep_current_index;
acx_configure(adev, &dk,
ACX1xx_IE_DOT11_WEP_DEFAULT_KEY_SET); /* 0x1010 */
}
/* FIXME!!! wep_key_struct is filled nowhere! But adev
* is initialized to 0, and we don't REALLY need those keys either */
/* for (i = 0; i < 10; i++) {
if (adev->wep_key_struct[i].len != 0) {
MAC_COPY(wep_mgmt.MacAddr, adev->wep_key_struct[i].addr);
wep_mgmt.KeySize = cpu_to_le16(adev->wep_key_struct[i].len);
memcpy(&wep_mgmt.Key, adev->wep_key_struct[i].key, le16_to_cpu(wep_mgmt.KeySize));
wep_mgmt.Action = cpu_to_le16(1);
log(L_ASSOC, "writing WEP key %d (len %d)\n", i, le16_to_cpu(wep_mgmt.KeySize));
if (OK == acx_s_issue_cmd(adev, ACX1xx_CMD_WEP_MGMT, &wep_mgmt, sizeof(wep_mgmt))) {
adev->wep_key_struct[i].index = i;
}
}
}
*/
/* now retrieve the updated WEPCacheEnd pointer... */
if (OK != acx_interrogate(adev, &pt, ACX1xx_IE_MEMORY_MAP)) {
pr_info("%s: ACX1xx_IE_MEMORY_MAP read #2 FAILED\n",
wiphy_name(adev->hw->wiphy));
goto fail;
}
#endif
/* ...and tell it to start allocating templates at that location */
/* (no endianness conversion needed) */
pt.PacketTemplateStart = pt.WEPCacheEnd;
if (OK != acx_configure(adev, &pt, ACX1xx_IE_MEMORY_MAP)) {
pr_info("%s: ACX1xx_IE_MEMORY_MAP write #2 FAILED\n",
wiphy_name(adev->hw->wiphy));
goto fail;
}
res = OK;
fail:
return res;
}
static int acx100_init_memory_pools(acx_device_t *adev,
const acx_ie_memmap_t *mmt)
{
acx100_ie_memblocksize_t MemoryBlockSize;
acx100_ie_memconfigoption_t MemoryConfigOption;
int TotalMemoryBlocks;
int RxBlockNum;
int TotalRxBlockSize;
int TxBlockNum;
int TotalTxBlockSize;
/* Let's see if we can follow this:
first we select our memory block size (which I think is
completely arbitrary) */
MemoryBlockSize.size = cpu_to_le16(adev->memblocksize);
/* Then we alert the card to our decision of block size */
if (OK != acx_configure(adev, &MemoryBlockSize, ACX100_IE_BLOCK_SIZE))
goto bad;
/* We figure out how many total blocks we can create, using
the block size we chose, and the beginning and ending
memory pointers, i.e.: end-start/size */
TotalMemoryBlocks =
(le32_to_cpu(mmt->PoolEnd) -
le32_to_cpu(mmt->PoolStart)) / adev->memblocksize;
log(L_ANY, "TotalMemoryBlocks=%u (%u bytes)\n",
TotalMemoryBlocks, TotalMemoryBlocks * adev->memblocksize);
/* MemoryConfigOption.DMA_config bitmask:
access to ACX memory is to be done:
0x00080000 using PCI conf space?!
0x00040000 using IO instructions?
0x00000000 using memory access instructions
0x00020000 using local memory block linked list (else what?)
0x00010000 using host indirect descriptors (else host must access ACX memory?)
*/
if (IS_PCI(adev)) {
#if defined(CONFIG_ACX_MAC80211_PCI)
MemoryConfigOption.DMA_config = cpu_to_le32(0x30000);
/* Declare start of the Rx host pool */
MemoryConfigOption.pRxHostDesc =
cpu2acx(adev->hw_rx_queue.hostdescinfo.phy);
log(L_DEBUG, "pRxHostDesc 0x%08X, rxhostdesc_startphy 0x%lX\n",
acx2cpu(MemoryConfigOption.pRxHostDesc),
(long)adev->hw_rx_queue.hostdescinfo.phy);
#endif
}
else if(IS_MEM(adev)) {
/*
* ACX ignores DMA_config for generic slave mode.
*/
#if defined(CONFIG_ACX_MAC80211_MEM)
MemoryConfigOption.DMA_config = 0;
/* Declare start of the Rx host pool */
MemoryConfigOption.pRxHostDesc = cpu2acx(0);
log(L_DEBUG, "pRxHostDesc 0x%08X, rxhostdesc_startphy 0x%lX\n",
acx2cpu(MemoryConfigOption.pRxHostDesc),
(long)adev->hw_rx_queue.hostdescinfo.phy);
#endif
}
else
MemoryConfigOption.DMA_config = cpu_to_le32(0x20000);
/* 50% of the allotment of memory blocks go to tx descriptors */
TxBlockNum = TotalMemoryBlocks / 2;
MemoryConfigOption.TxBlockNum = cpu_to_le16(TxBlockNum);
/* and 50% go to the rx descriptors */
RxBlockNum = TotalMemoryBlocks - TxBlockNum;
MemoryConfigOption.RxBlockNum = cpu_to_le16(RxBlockNum);
/* size of the tx and rx descriptor queues */
TotalTxBlockSize = TxBlockNum * adev->memblocksize;
TotalRxBlockSize = RxBlockNum * adev->memblocksize;
log(L_DEBUG, "TxBlockNum %u RxBlockNum %u TotalTxBlockSize %u "
"TotalTxBlockSize %u\n", TxBlockNum, RxBlockNum,
TotalTxBlockSize, TotalRxBlockSize);
/* align the tx descriptor queue to an alignment of 0x20 (32 bytes) */
MemoryConfigOption.rx_mem =
cpu_to_le32((le32_to_cpu(mmt->PoolStart) + 0x1f) & ~0x1f);
/* align the rx descriptor queue to units of 0x20
* and offset it by the tx descriptor queue */
MemoryConfigOption.tx_mem =
cpu_to_le32((le32_to_cpu(mmt->PoolStart) + TotalRxBlockSize +
0x1f) & ~0x1f);
log(L_DEBUG, "rx_mem %08X rx_mem %08X\n", MemoryConfigOption.tx_mem,
MemoryConfigOption.rx_mem);
/* alert the device to our decision */
if (OK !=
acx_configure(adev, &MemoryConfigOption,
ACX100_IE_MEMORY_CONFIG_OPTIONS))
goto bad;
/* and tell the device to kick it into gear */
if (OK != acx_issue_cmd(adev, ACX100_CMD_INIT_MEMORY, NULL, 0))
goto bad;
#ifdef CONFIG_ACX_MAC80211_MEM
/*
* slave memory interface has to manage the transmit pools for the ACX,
* so it needs to know what we chose here.
*/
adev->acx_txbuf_start = MemoryConfigOption.tx_mem;
adev->acx_txbuf_numblocks = MemoryConfigOption.TxBlockNum;
#endif
return OK;
bad:
return NOT_OK;
}
/*
* acx100_s_create_dma_regions
*
* Note that this fn messes up heavily with hardware, but we cannot
* lock it (we need to sleep). Not a problem since IRQs can't happen
*/
/* OLD CODE? - let's rewrite it! */
static int acx100_create_dma_regions(acx_device_t * adev)
{
acx100_ie_queueconfig_t queueconf;
acx_ie_memmap_t memmap;
int res = NOT_OK;
u32 tx_queue_start, rx_queue_start;
adev->num_hw_tx_queues = ACX100_NUM_HW_TX_QUEUES;
/* read out the acx100 physical start address for the queues */
if (OK != acx_interrogate(adev, &memmap, ACX1xx_IE_MEMORY_MAP))
goto fail;
tx_queue_start = le32_to_cpu(memmap.QueueStart);
rx_queue_start = tx_queue_start + TX_CNT * sizeof(txacxdesc_t);
log(L_DEBUG, "Initializing Queue Indicator\n");
memset(&queueconf, 0, sizeof(queueconf));
/* Not needed for PCI, so we can avoid setting them altogether */
if (IS_USB(adev)) {
queueconf.NumTxDesc = USB_TX_CNT;
queueconf.NumRxDesc = USB_RX_CNT;
}
/* calculate size of queues */
queueconf.AreaSize = cpu_to_le32(TX_CNT * sizeof(txacxdesc_t) +
RX_CNT * sizeof(rxacxdesc_t) + 8);
queueconf.NumTxQueues = 1; /* number of tx queues */
/* sets the beginning of the tx descriptor queue */
queueconf.TxQueueStart = memmap.QueueStart;
/* done by memset: queueconf.TxQueuePri = 0; */
queueconf.RxQueueStart = cpu_to_le32(rx_queue_start);
queueconf.QueueOptions = 1; /* auto reset descriptor */
/* sets the end of the rx descriptor queue */
queueconf.QueueEnd =
cpu_to_le32(rx_queue_start + RX_CNT * sizeof(rxacxdesc_t)
);
/* sets the beginning of the next queue */
queueconf.HostQueueEnd =
cpu_to_le32(le32_to_cpu(queueconf.QueueEnd) + 8);
if (OK != acx_configure(adev, &queueconf, ACX100_IE_QUEUE_CONFIG))
goto fail;
if (IS_PCI(adev)) {
/* sets the beginning of the rx descriptor queue,
* after the tx descrs */
if (OK != acx_create_hostdesc_queues(adev, ACX100_NUM_HW_TX_QUEUES))
goto fail;
acx_create_desc_queues(adev, rx_queue_start, &tx_queue_start,
ACX100_NUM_HW_TX_QUEUES);
}
#ifdef CONFIG_ACX_MAC80211_MEM
else if (IS_MEM(adev)) {
/* sets the beginning of the rx descriptor queue,
* after the tx descrs */
adev->acx_queue_indicator = (queueindicator_t *)
(uintptr_t)le32_to_cpu (queueconf.QueueEnd);
if (OK != acx_create_hostdesc_queues(adev, ACX100_NUM_HW_TX_QUEUES))
goto fail;
acx_create_desc_queues(adev, rx_queue_start, &tx_queue_start,
ACX100_NUM_HW_TX_QUEUES);
}
#endif
if (OK != acx_interrogate(adev, &memmap, ACX1xx_IE_MEMORY_MAP))
goto fail;
memmap.PoolStart = cpu_to_le32((le32_to_cpu(memmap.QueueEnd) + 4 +
0x1f) & ~0x1f);
if (OK != acx_configure(adev, &memmap, ACX1xx_IE_MEMORY_MAP))
goto fail;
if (OK != acx100_init_memory_pools(adev, &memmap))
goto fail;
res = OK;
goto end;
fail:
acx_mwait(1000); /* ? */
if (IS_PCI(adev) || IS_MEM(adev))
acx_free_desc_queues(adev);
end:
return res;
}
int acx_init_mac(acx_device_t * adev)
{
int result = NOT_OK;
if (IS_PCI(adev) || IS_MEM(adev) ) {
adev->memblocksize = 256; /* 256 is default */
/* try to load radio for both ACX100 and ACX111, since both
* chips have at least some firmware versions making use of an
* external radio module */
acx_upload_radio(adev);
}
else {
adev->memblocksize = 128;
}
if (IS_ACX111(adev)) {
/* for ACX111, the order is different from ACX100
1. init packet templates
2. create station context and create dma regions
3. init wep default keys
*/
if (OK != acx_init_packet_templates(adev))
goto fail;
if (OK != acx111_create_dma_regions(adev)) {
pr_info("%s: acx111_create_dma_regions FAILED\n",
wiphy_name(adev->hw->wiphy));
goto fail;
}
} else {
if (OK != acx100_init_wep(adev))
goto fail;
if (OK != acx_init_packet_templates(adev))
goto fail;
if (OK != acx100_create_dma_regions(adev)) {
pr_info("%s: acx100_create_dma_regions FAILED\n",
wiphy_name(adev->hw->wiphy));
goto fail;
}
}
result = OK;
fail:
if (result)
pr_info("init_mac() FAILED\n");
return result;
}