Merge branch 'bjorn-start-stop-2.6.32' into release
[deliverable/linux.git] / drivers / staging / wlan-ng / prism2fw.c
CommitLineData
76e3e7c4
KR
1/* from src/prism2/download/prism2dl.c
2*
3* utility for downloading prism2 images moved into kernelspace
4*
5* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6* --------------------------------------------------------------------
7*
8* linux-wlan
9*
10* The contents of this file are subject to the Mozilla Public
11* License Version 1.1 (the "License"); you may not use this file
12* except in compliance with the License. You may obtain a copy of
13* the License at http://www.mozilla.org/MPL/
14*
15* Software distributed under the License is distributed on an "AS
16* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17* implied. See the License for the specific language governing
18* rights and limitations under the License.
19*
20* Alternatively, the contents of this file may be used under the
21* terms of the GNU Public License version 2 (the "GPL"), in which
22* case the provisions of the GPL are applicable instead of the
23* above. If you wish to allow the use of your version of this file
24* only under the terms of the GPL and not to allow others to use
25* your version of this file under the MPL, indicate your decision
26* by deleting the provisions above and replace them with the notice
27* and other provisions required by the GPL. If you do not delete
28* the provisions above, a recipient may use your version of this
29* file under either the MPL or the GPL.
30*
31* --------------------------------------------------------------------
32*
33* Inquiries regarding the linux-wlan Open Source project can be
34* made directly to:
35*
36* AbsoluteValue Systems Inc.
37* info@linux-wlan.com
38* http://www.linux-wlan.com
39*
40* --------------------------------------------------------------------
41*
42* Portions of the development of this software were funded by
43* Intersil Corporation as part of PRISM(R) chipset product development.
44*
45* --------------------------------------------------------------------
46*/
47
48/*================================================================*/
49/* System Includes */
d8950599 50#include <linux/ihex.h>
76e3e7c4 51
76e3e7c4
KR
52/*================================================================*/
53/* Local Constants */
54
d8950599 55#define PRISM2_USB_FWFILE "prism2_ru.fw"
76e3e7c4
KR
56
57#define S3DATA_MAX 5000
58#define S3PLUG_MAX 200
59#define S3CRC_MAX 200
60#define S3INFO_MAX 50
76e3e7c4
KR
61
62#define S3ADDR_PLUG (0xff000000UL)
63#define S3ADDR_CRC (0xff100000UL)
64#define S3ADDR_INFO (0xff200000UL)
d8950599 65#define S3ADDR_START (0xff400000UL)
76e3e7c4
KR
66
67#define CHUNKS_MAX 100
68
69#define WRITESIZE_MAX 4096
70
76e3e7c4
KR
71/*================================================================*/
72/* Local Types */
73
75f49e07
MT
74typedef struct s3datarec {
75 u32 len;
76 u32 addr;
77 u8 checksum;
78 u8 *data;
76e3e7c4
KR
79} s3datarec_t;
80
75f49e07
MT
81typedef struct s3plugrec {
82 u32 itemcode;
83 u32 addr;
84 u32 len;
76e3e7c4
KR
85} s3plugrec_t;
86
75f49e07
MT
87typedef struct s3crcrec {
88 u32 addr;
89 u32 len;
90 unsigned int dowrite;
76e3e7c4
KR
91} s3crcrec_t;
92
75f49e07
MT
93typedef struct s3inforec {
94 u16 len;
95 u16 type;
76e3e7c4 96 union {
75f49e07
MT
97 hfa384x_compident_t version;
98 hfa384x_caplevel_t compat;
99 u16 buildseq;
100 hfa384x_compident_t platform;
101 } info;
76e3e7c4
KR
102} s3inforec_t;
103
75f49e07
MT
104typedef struct pda {
105 u8 buf[HFA384x_PDA_LEN_MAX];
106 hfa384x_pdrec_t *rec[HFA384x_PDA_RECS_MAX];
107 unsigned int nrec;
76e3e7c4
KR
108} pda_t;
109
75f49e07
MT
110typedef struct imgchunk {
111 u32 addr; /* start address */
112 u32 len; /* in bytes */
113 u16 crc; /* CRC value (if it falls at a chunk boundary) */
114 u8 *data;
76e3e7c4
KR
115} imgchunk_t;
116
117/*================================================================*/
118/* Local Static Definitions */
119
76e3e7c4
KR
120/*----------------------------------------------------------------*/
121/* s-record image processing */
122
123/* Data records */
297f06ce 124unsigned int ns3data;
75f49e07 125s3datarec_t s3data[S3DATA_MAX];
76e3e7c4
KR
126
127/* Plug records */
297f06ce 128unsigned int ns3plug;
75f49e07 129s3plugrec_t s3plug[S3PLUG_MAX];
76e3e7c4
KR
130
131/* CRC records */
297f06ce 132unsigned int ns3crc;
75f49e07 133s3crcrec_t s3crc[S3CRC_MAX];
76e3e7c4
KR
134
135/* Info records */
297f06ce 136unsigned int ns3info;
75f49e07 137s3inforec_t s3info[S3INFO_MAX];
76e3e7c4
KR
138
139/* S7 record (there _better_ be only one) */
75f49e07 140u32 startaddr;
76e3e7c4
KR
141
142/* Load image chunks */
75f49e07
MT
143unsigned int nfchunks;
144imgchunk_t fchunk[CHUNKS_MAX];
76e3e7c4
KR
145
146/* Note that for the following pdrec_t arrays, the len and code */
147/* fields are stored in HOST byte order. The mkpdrlist() function */
148/* does the conversion. */
149/*----------------------------------------------------------------*/
150/* PDA, built from [card|newfile]+[addfile1+addfile2...] */
151
75f49e07 152pda_t pda;
76e3e7c4 153hfa384x_compident_t nicid;
75f49e07
MT
154hfa384x_caplevel_t rfid;
155hfa384x_caplevel_t macid;
156hfa384x_caplevel_t priid;
76e3e7c4
KR
157
158/*================================================================*/
159/* Local Function Declarations */
160
d8950599
KR
161int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev);
162int read_fwfile(const struct ihex_binrec *rfptr);
297f06ce
MT
163int mkimage(imgchunk_t *clist, unsigned int *ccnt);
164int read_cardpda(pda_t *pda, wlandevice_t *wlandev);
165int mkpdrlist(pda_t *pda);
297f06ce
MT
166int plugimage(imgchunk_t *fchunk, unsigned int nfchunks,
167 s3plugrec_t *s3plug, unsigned int ns3plug, pda_t * pda);
168int crcimage(imgchunk_t *fchunk, unsigned int nfchunks,
169 s3crcrec_t *s3crc, unsigned int ns3crc);
170int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk,
75f49e07 171 unsigned int nfchunks);
297f06ce 172void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks);
75f49e07
MT
173void free_srecs(void);
174
175int validate_identity(void);
76e3e7c4
KR
176
177/*================================================================*/
178/* Function Definitions */
179
76e3e7c4
KR
180/*----------------------------------------------------------------
181* prism2_fwtry
182*
183* Try and get firmware into memory
184*
185* Arguments:
186* udev usb device structure
187* wlandev wlan device structure
188*
189* Returns:
190* 0 - success
191* ~0 - failure
192----------------------------------------------------------------*/
297f06ce 193int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev)
76e3e7c4
KR
194{
195 const struct firmware *fw_entry = NULL;
196
75f49e07
MT
197 printk(KERN_INFO "prism2_usb: Checking for firmware %s\n",
198 PRISM2_USB_FWFILE);
d8950599 199 if (request_ihex_firmware(&fw_entry, PRISM2_USB_FWFILE, &udev->dev) != 0) {
76e3e7c4
KR
200 printk(KERN_INFO
201 "prism2_usb: Firmware not available, but not essential\n");
202 printk(KERN_INFO
203 "prism2_usb: can continue to use card anyway.\n");
204 return 1;
205 }
206
75f49e07
MT
207 printk(KERN_INFO "prism2_usb: %s will be processed, size %d\n",
208 PRISM2_USB_FWFILE, fw_entry->size);
d8950599 209 prism2_fwapply((const struct ihex_binrec *)fw_entry->data, wlandev);
76e3e7c4
KR
210
211 release_firmware(fw_entry);
212 return 0;
213}
214
76e3e7c4
KR
215/*----------------------------------------------------------------
216* prism2_fwapply
217*
218* Apply the firmware loaded into memory
219*
220* Arguments:
221* rfptr firmware image in kernel memory
76e3e7c4
KR
222* wlandev device
223*
224* Returns:
225* 0 - success
226* ~0 - failure
227----------------------------------------------------------------*/
d8950599 228int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev)
76e3e7c4 229{
75f49e07 230 signed int result = 0;
76e3e7c4
KR
231 p80211msg_dot11req_mibget_t getmsg;
232 p80211itemd_t *item;
75f49e07 233 u32 *data;
76e3e7c4
KR
234
235 /* Initialize the data structures */
236 ns3data = 0;
237 memset(s3data, 0, sizeof(s3data));
238 ns3plug = 0;
239 memset(s3plug, 0, sizeof(s3plug));
240 ns3crc = 0;
241 memset(s3crc, 0, sizeof(s3crc));
242 ns3info = 0;
243 memset(s3info, 0, sizeof(s3info));
244 startaddr = 0;
245
246 nfchunks = 0;
75f49e07
MT
247 memset(fchunk, 0, sizeof(fchunk));
248 memset(&nicid, 0, sizeof(nicid));
249 memset(&rfid, 0, sizeof(rfid));
250 memset(&macid, 0, sizeof(macid));
251 memset(&priid, 0, sizeof(priid));
76e3e7c4
KR
252
253 /* clear the pda and add an initial END record */
254 memset(&pda, 0, sizeof(pda));
75f49e07
MT
255 pda.rec[0] = (hfa384x_pdrec_t *) pda.buf;
256 pda.rec[0]->len = cpu_to_le16(2); /* len in words *//* len in words */
76e3e7c4
KR
257 pda.rec[0]->code = cpu_to_le16(HFA384x_PDR_END_OF_PDA);
258 pda.nrec = 1;
259
76e3e7c4
KR
260 /*-----------------------------------------------------*/
261 /* Put card into fwload state */
262 prism2sta_ifstate(wlandev, P80211ENUM_ifstate_fwload);
263
264 /* Build the PDA we're going to use. */
265 if (read_cardpda(&pda, wlandev)) {
266 printk(KERN_ERR "load_cardpda failed, exiting.\n");
75f49e07 267 return (1);
76e3e7c4
KR
268 }
269
270 /* read the card's PRI-SUP */
271 memset(&getmsg, 0, sizeof(getmsg));
272 getmsg.msgcode = DIDmsg_dot11req_mibget;
273 getmsg.msglen = sizeof(getmsg);
274 strcpy(getmsg.devname, wlandev->name);
275
276 getmsg.mibattribute.did = DIDmsg_dot11req_mibget_mibattribute;
277 getmsg.mibattribute.status = P80211ENUM_msgitem_status_data_ok;
278 getmsg.resultcode.did = DIDmsg_dot11req_mibget_resultcode;
279 getmsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
280
281 item = (p80211itemd_t *) getmsg.mibattribute.data;
282 item->did = DIDmib_p2_p2NIC_p2PRISupRange;
283 item->status = P80211ENUM_msgitem_status_no_value;
284
75f49e07 285 data = (u32 *) item->data;
76e3e7c4
KR
286
287 /* DIDmsg_dot11req_mibget */
288 prism2mgmt_mibset_mibget(wlandev, &getmsg);
289 if (getmsg.resultcode.data != P80211ENUM_resultcode_success) {
290 printk(KERN_ERR "Couldn't fetch PRI-SUP info\n");
291 }
292
293 /* Already in host order */
294 priid.role = *data++;
295 priid.id = *data++;
296 priid.variant = *data++;
297 priid.bottom = *data++;
298 priid.top = *data++;
299
76e3e7c4 300 /* Read the S3 file */
d8950599 301 result = read_fwfile(rfptr);
75f49e07 302 if (result) {
76e3e7c4 303 printk(KERN_ERR "Failed to read the data exiting.\n");
75f49e07 304 return (1);
76e3e7c4 305 }
76e3e7c4
KR
306
307 result = validate_identity();
308
75f49e07 309 if (result) {
76e3e7c4 310 printk(KERN_ERR "Incompatible firmware image.\n");
75f49e07 311 return (1);
76e3e7c4
KR
312 }
313
314 if (startaddr == 0x00000000) {
315 printk(KERN_ERR "Can't RAM download a Flash image!\n");
75f49e07 316 return (1);
76e3e7c4
KR
317 }
318
319 /* Make the image chunks */
320 result = mkimage(fchunk, &nfchunks);
321
322 /* Do any plugging */
75f49e07
MT
323 result = plugimage(fchunk, nfchunks, s3plug, ns3plug, &pda);
324 if (result) {
76e3e7c4 325 printk(KERN_ERR "Failed to plug data.\n");
75f49e07 326 return (1);
76e3e7c4
KR
327 }
328
329 /* Insert any CRCs */
75f49e07 330 if (crcimage(fchunk, nfchunks, s3crc, ns3crc)) {
76e3e7c4 331 printk(KERN_ERR "Failed to insert all CRCs\n");
75f49e07 332 return (1);
76e3e7c4
KR
333 }
334
335 /* Write the image */
336 result = writeimage(wlandev, fchunk, nfchunks);
75f49e07 337 if (result) {
76e3e7c4 338 printk(KERN_ERR "Failed to ramwrite image data.\n");
75f49e07 339 return (1);
76e3e7c4
KR
340 }
341
342 /* clear any allocated memory */
343 free_chunks(fchunk, &nfchunks);
344 free_srecs();
345
346 printk(KERN_INFO "prism2_usb: firmware loading finished.\n");
347
348 return result;
349}
350
76e3e7c4
KR
351/*----------------------------------------------------------------
352* crcimage
353*
354* Adds a CRC16 in the two bytes prior to each block identified by
355* an S3 CRC record. Currently, we don't actually do a CRC we just
356* insert the value 0xC0DE in hfa384x order.
357*
358* Arguments:
359* fchunk Array of image chunks
360* nfchunks Number of image chunks
361* s3crc Array of crc records
362* ns3crc Number of crc records
363*
364* Returns:
365* 0 success
366* ~0 failure
367----------------------------------------------------------------*/
297f06ce 368int crcimage(imgchunk_t *fchunk, unsigned int nfchunks, s3crcrec_t *s3crc,
76e3e7c4
KR
369 unsigned int ns3crc)
370{
75f49e07
MT
371 int result = 0;
372 int i;
373 int c;
374 u32 crcstart;
375 u32 crcend;
376 u32 cstart = 0;
377 u32 cend;
378 u8 *dest;
379 u32 chunkoff;
380
381 for (i = 0; i < ns3crc; i++) {
382 if (!s3crc[i].dowrite)
383 continue;
76e3e7c4 384 crcstart = s3crc[i].addr;
75f49e07 385 crcend = s3crc[i].addr + s3crc[i].len;
76e3e7c4 386 /* Find chunk */
75f49e07 387 for (c = 0; c < nfchunks; c++) {
76e3e7c4 388 cstart = fchunk[c].addr;
75f49e07 389 cend = fchunk[c].addr + fchunk[c].len;
76e3e7c4
KR
390 /* the line below does an address & len match search */
391 /* unfortunately, I've found that the len fields of */
392 /* some crc records don't match with the length of */
393 /* the actual data, so we're not checking right */
394 /* now */
75f49e07 395 /* if ( crcstart-2 >= cstart && crcend <= cend ) break; */
76e3e7c4
KR
396
397 /* note the -2 below, it's to make sure the chunk has */
398 /* space for the CRC value */
75f49e07
MT
399 if (crcstart - 2 >= cstart && crcstart < cend)
400 break;
76e3e7c4 401 }
75f49e07 402 if (c >= nfchunks) {
76e3e7c4 403 printk(KERN_ERR
75f49e07
MT
404 "Failed to find chunk for "
405 "crcrec[%d], addr=0x%06x len=%d , "
406 "aborting crc.\n",
407 i, s3crc[i].addr, s3crc[i].len);
76e3e7c4
KR
408 return 1;
409 }
410
411 /* Insert crc */
75f49e07 412 pr_debug("Adding crc @ 0x%06x\n", s3crc[i].addr - 2);
76e3e7c4
KR
413 chunkoff = crcstart - cstart - 2;
414 dest = fchunk[c].data + chunkoff;
75f49e07
MT
415 *dest = 0xde;
416 *(dest + 1) = 0xc0;
76e3e7c4
KR
417
418 }
419 return result;
420}
421
76e3e7c4
KR
422/*----------------------------------------------------------------
423* free_chunks
424*
425* Clears the chunklist data structures in preparation for a new file.
426*
427* Arguments:
428* none
429*
430* Returns:
431* nothing
432----------------------------------------------------------------*/
297f06ce 433void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks)
76e3e7c4
KR
434{
435 int i;
75f49e07
MT
436 for (i = 0; i < *nfchunks; i++) {
437 if (fchunk[i].data != NULL) {
76e3e7c4
KR
438 kfree(fchunk[i].data);
439 }
440 }
441 *nfchunks = 0;
75f49e07 442 memset(fchunk, 0, sizeof(fchunk));
76e3e7c4
KR
443
444}
445
76e3e7c4
KR
446/*----------------------------------------------------------------
447* free_srecs
448*
449* Clears the srec data structures in preparation for a new file.
450*
451* Arguments:
452* none
453*
454* Returns:
455* nothing
456----------------------------------------------------------------*/
457void free_srecs(void)
458{
76e3e7c4
KR
459 ns3data = 0;
460 memset(s3data, 0, sizeof(s3data));
461 ns3plug = 0;
462 memset(s3plug, 0, sizeof(s3plug));
463 ns3crc = 0;
464 memset(s3crc, 0, sizeof(s3crc));
465 ns3info = 0;
466 memset(s3info, 0, sizeof(s3info));
467 startaddr = 0;
468}
469
76e3e7c4
KR
470/*----------------------------------------------------------------
471* mkimage
472*
473* Scans the currently loaded set of S records for data residing
474* in contiguous memory regions. Each contiguous region is then
475* made into a 'chunk'. This function assumes that we're building
476* a new chunk list. Assumes the s3data items are in sorted order.
477*
478* Arguments: none
479*
480* Returns:
481* 0 - success
482* ~0 - failure (probably an errno)
483----------------------------------------------------------------*/
297f06ce 484int mkimage(imgchunk_t *clist, unsigned int *ccnt)
76e3e7c4 485{
75f49e07
MT
486 int result = 0;
487 int i;
488 int j;
489 int currchunk = 0;
490 u32 nextaddr = 0;
491 u32 s3start;
492 u32 s3end;
493 u32 cstart = 0;
494 u32 cend;
495 u32 coffset;
76e3e7c4
KR
496
497 /* There may already be data in the chunklist */
498 *ccnt = 0;
499
500 /* Establish the location and size of each chunk */
75f49e07
MT
501 for (i = 0; i < ns3data; i++) {
502 if (s3data[i].addr == nextaddr) {
76e3e7c4
KR
503 /* existing chunk, grow it */
504 clist[currchunk].len += s3data[i].len;
505 nextaddr += s3data[i].len;
506 } else {
507 /* New chunk */
508 (*ccnt)++;
509 currchunk = *ccnt - 1;
510 clist[currchunk].addr = s3data[i].addr;
511 clist[currchunk].len = s3data[i].len;
512 nextaddr = s3data[i].addr + s3data[i].len;
513 /* Expand the chunk if there is a CRC record at */
514 /* their beginning bound */
75f49e07
MT
515 for (j = 0; j < ns3crc; j++) {
516 if (s3crc[j].dowrite &&
517 s3crc[j].addr == clist[currchunk].addr) {
76e3e7c4
KR
518 clist[currchunk].addr -= 2;
519 clist[currchunk].len += 2;
520 }
521 }
522 }
523 }
524
525 /* We're currently assuming there aren't any overlapping chunks */
526 /* if this proves false, we'll need to add code to coalesce. */
527
528 /* Allocate buffer space for chunks */
75f49e07 529 for (i = 0; i < *ccnt; i++) {
76e3e7c4 530 clist[i].data = kmalloc(clist[i].len, GFP_KERNEL);
75f49e07
MT
531 if (clist[i].data == NULL) {
532 printk(KERN_ERR
533 "failed to allocate image space, exitting.\n");
534 return (1);
76e3e7c4
KR
535 }
536 memset(clist[i].data, 0, clist[i].len);
76e3e7c4 537 pr_debug("chunk[%d]: addr=0x%06x len=%d\n",
75f49e07 538 i, clist[i].addr, clist[i].len);
76e3e7c4
KR
539 }
540
541 /* Copy srec data to chunks */
75f49e07 542 for (i = 0; i < ns3data; i++) {
76e3e7c4 543 s3start = s3data[i].addr;
75f49e07
MT
544 s3end = s3start + s3data[i].len - 1;
545 for (j = 0; j < *ccnt; j++) {
76e3e7c4
KR
546 cstart = clist[j].addr;
547 cend = cstart + clist[j].len - 1;
75f49e07 548 if (s3start >= cstart && s3end <= cend) {
76e3e7c4
KR
549 break;
550 }
551 }
75f49e07 552 if (((unsigned int)j) >= (*ccnt)) {
76e3e7c4 553 printk(KERN_ERR
75f49e07
MT
554 "s3rec(a=0x%06x,l=%d), no chunk match, exiting.\n",
555 s3start, s3data[i].len);
556 return (1);
76e3e7c4
KR
557 }
558 coffset = s3start - cstart;
75f49e07 559 memcpy(clist[j].data + coffset, s3data[i].data, s3data[i].len);
76e3e7c4
KR
560 }
561
562 return result;
563}
564
565/*----------------------------------------------------------------
566* mkpdrlist
567*
568* Reads a raw PDA and builds an array of pdrec_t structures.
569*
570* Arguments:
571* pda buffer containing raw PDA bytes
572* pdrec ptr to an array of pdrec_t's. Will be filled on exit.
573* nrec ptr to a variable that will contain the count of PDRs
574*
575* Returns:
576* 0 - success
577* ~0 - failure (probably an errno)
578----------------------------------------------------------------*/
297f06ce 579int mkpdrlist(pda_t *pda)
76e3e7c4 580{
75f49e07
MT
581 int result = 0;
582 u16 *pda16 = (u16 *) pda->buf;
583 int curroff; /* in 'words' */
76e3e7c4
KR
584
585 pda->nrec = 0;
586 curroff = 0;
75f49e07
MT
587 while (curroff < (HFA384x_PDA_LEN_MAX / 2) &&
588 le16_to_cpu(pda16[curroff + 1]) != HFA384x_PDR_END_OF_PDA) {
589 pda->rec[pda->nrec] = (hfa384x_pdrec_t *) & (pda16[curroff]);
76e3e7c4 590
75f49e07 591 if (le16_to_cpu(pda->rec[pda->nrec]->code) == HFA384x_PDR_NICID) {
76e3e7c4
KR
592 memcpy(&nicid, &pda->rec[pda->nrec]->data.nicid,
593 sizeof(nicid));
594 nicid.id = le16_to_cpu(nicid.id);
595 nicid.variant = le16_to_cpu(nicid.variant);
596 nicid.major = le16_to_cpu(nicid.major);
597 nicid.minor = le16_to_cpu(nicid.minor);
598 }
599 if (le16_to_cpu(pda->rec[pda->nrec]->code) ==
75f49e07 600 HFA384x_PDR_MFISUPRANGE) {
76e3e7c4
KR
601 memcpy(&rfid, &pda->rec[pda->nrec]->data.mfisuprange,
602 sizeof(rfid));
603 rfid.id = le16_to_cpu(rfid.id);
604 rfid.variant = le16_to_cpu(rfid.variant);
605 rfid.bottom = le16_to_cpu(rfid.bottom);
606 rfid.top = le16_to_cpu(rfid.top);
607 }
608 if (le16_to_cpu(pda->rec[pda->nrec]->code) ==
75f49e07 609 HFA384x_PDR_CFISUPRANGE) {
76e3e7c4
KR
610 memcpy(&macid, &pda->rec[pda->nrec]->data.cfisuprange,
611 sizeof(macid));
612 macid.id = le16_to_cpu(macid.id);
613 macid.variant = le16_to_cpu(macid.variant);
614 macid.bottom = le16_to_cpu(macid.bottom);
615 macid.top = le16_to_cpu(macid.top);
616 }
617
618 (pda->nrec)++;
619 curroff += le16_to_cpu(pda16[curroff]) + 1;
620
621 }
75f49e07 622 if (curroff >= (HFA384x_PDA_LEN_MAX / 2)) {
76e3e7c4 623 printk(KERN_ERR
75f49e07
MT
624 "no end record found or invalid lengths in "
625 "PDR data, exiting. %x %d\n", curroff, pda->nrec);
626 return (1);
76e3e7c4 627 }
75f49e07
MT
628 if (le16_to_cpu(pda16[curroff + 1]) == HFA384x_PDR_END_OF_PDA) {
629 pda->rec[pda->nrec] = (hfa384x_pdrec_t *) & (pda16[curroff]);
76e3e7c4
KR
630 (pda->nrec)++;
631 }
632 return result;
633}
634
76e3e7c4
KR
635/*----------------------------------------------------------------
636* plugimage
637*
638* Plugs the given image using the given plug records from the given
639* PDA and filename.
640*
641* Arguments:
642* fchunk Array of image chunks
643* nfchunks Number of image chunks
644* s3plug Array of plug records
645* ns3plug Number of plug records
646* pda Current pda data
647*
648* Returns:
649* 0 success
650* ~0 failure
651----------------------------------------------------------------*/
297f06ce
MT
652int plugimage(imgchunk_t *fchunk, unsigned int nfchunks,
653 s3plugrec_t *s3plug, unsigned int ns3plug, pda_t * pda)
76e3e7c4 654{
75f49e07
MT
655 int result = 0;
656 int i; /* plug index */
657 int j; /* index of PDR or -1 if fname plug */
658 int c; /* chunk index */
659 u32 pstart;
660 u32 pend;
661 u32 cstart = 0;
662 u32 cend;
663 u32 chunkoff;
664 u8 *dest;
76e3e7c4
KR
665
666 /* for each plug record */
75f49e07 667 for (i = 0; i < ns3plug; i++) {
76e3e7c4 668 pstart = s3plug[i].addr;
75f49e07 669 pend = s3plug[i].addr + s3plug[i].len;
76e3e7c4 670 /* find the matching PDR (or filename) */
75f49e07
MT
671 if (s3plug[i].itemcode != 0xffffffffUL) { /* not filename */
672 for (j = 0; j < pda->nrec; j++) {
673 if (s3plug[i].itemcode ==
674 le16_to_cpu(pda->rec[j]->code))
675 break;
76e3e7c4
KR
676 }
677 } else {
678 j = -1;
679 }
75f49e07 680 if (j >= pda->nrec && j != -1) { /* if no matching PDR, fail */
76e3e7c4 681 printk(KERN_WARNING
75f49e07
MT
682 "warning: Failed to find PDR for "
683 "plugrec 0x%04x.\n", s3plug[i].itemcode);
684 continue; /* and move on to the next PDR */
76e3e7c4
KR
685#if 0
686 /* MSM: They swear that unless it's the MAC address,
687 * the serial number, or the TX calibration records,
688 * then there's reasonable defaults in the f/w
689 * image. Therefore, missing PDRs in the card
690 * should only be a warning, not fatal.
691 * TODO: add fatals for the PDRs mentioned above.
692 */
693 result = 1;
694 continue;
695#endif
696 }
697
698 /* Validate plug len against PDR len */
75f49e07 699 if (j != -1 && s3plug[i].len < le16_to_cpu(pda->rec[j]->len)) {
76e3e7c4 700 printk(KERN_ERR
75f49e07
MT
701 "error: Plug vs. PDR len mismatch for "
702 "plugrec 0x%04x, abort plugging.\n",
703 s3plug[i].itemcode);
76e3e7c4
KR
704 result = 1;
705 continue;
706 }
707
708 /* Validate plug address against chunk data and identify chunk */
75f49e07 709 for (c = 0; c < nfchunks; c++) {
76e3e7c4 710 cstart = fchunk[c].addr;
75f49e07
MT
711 cend = fchunk[c].addr + fchunk[c].len;
712 if (pstart >= cstart && pend <= cend)
713 break;
76e3e7c4 714 }
75f49e07 715 if (c >= nfchunks) {
76e3e7c4 716 printk(KERN_ERR
75f49e07
MT
717 "error: Failed to find image chunk for "
718 "plugrec 0x%04x.\n", s3plug[i].itemcode);
76e3e7c4
KR
719 result = 1;
720 continue;
721 }
722
723 /* Plug data */
724 chunkoff = pstart - cstart;
725 dest = fchunk[c].data + chunkoff;
726 pr_debug("Plugging item 0x%04x @ 0x%06x, len=%d, "
75f49e07
MT
727 "cnum=%d coff=0x%06x\n",
728 s3plug[i].itemcode, pstart, s3plug[i].len,
729 c, chunkoff);
76e3e7c4 730
75f49e07 731 if (j == -1) { /* plug the filename */
76e3e7c4
KR
732 memset(dest, 0, s3plug[i].len);
733 strncpy(dest, PRISM2_USB_FWFILE, s3plug[i].len - 1);
75f49e07
MT
734 } else { /* plug a PDR */
735 memcpy(dest, &(pda->rec[j]->data), s3plug[i].len);
76e3e7c4
KR
736 }
737 }
738 return result;
739
740}
741
76e3e7c4
KR
742/*----------------------------------------------------------------
743* read_cardpda
744*
745* Sends the command for the driver to read the pda from the card
746* named in the device variable. Upon success, the card pda is
747* stored in the "cardpda" variables. Note that the pda structure
748* is considered 'well formed' after this function. That means
749* that the nrecs is valid, the rec array has been set up, and there's
750* a valid PDAEND record in the raw PDA data.
751*
752* Arguments:
753* pda pda structure
754* wlandev device
755*
756* Returns:
757* 0 - success
758* ~0 - failure (probably an errno)
759----------------------------------------------------------------*/
297f06ce 760int read_cardpda(pda_t *pda, wlandevice_t *wlandev)
76e3e7c4 761{
75f49e07
MT
762 int result = 0;
763 p80211msg_p2req_readpda_t msg;
76e3e7c4
KR
764
765 /* set up the msg */
766 msg.msgcode = DIDmsg_p2req_readpda;
767 msg.msglen = sizeof(msg);
768 strcpy(msg.devname, wlandev->name);
769 msg.pda.did = DIDmsg_p2req_readpda_pda;
770 msg.pda.len = HFA384x_PDA_LEN_MAX;
771 msg.pda.status = P80211ENUM_msgitem_status_no_value;
772 msg.resultcode.did = DIDmsg_p2req_readpda_resultcode;
773 msg.resultcode.len = sizeof(u32);
774 msg.resultcode.status = P80211ENUM_msgitem_status_no_value;
775
75f49e07 776 if (prism2mgmt_readpda(wlandev, &msg) != 0) {
76e3e7c4
KR
777 /* prism2mgmt_readpda prints an errno if appropriate */
778 result = -1;
75f49e07 779 } else if (msg.resultcode.data == P80211ENUM_resultcode_success) {
76e3e7c4
KR
780 memcpy(pda->buf, msg.pda.data, HFA384x_PDA_LEN_MAX);
781 result = mkpdrlist(pda);
782 } else {
783 /* resultcode must've been something other than success */
784 result = -1;
785 }
786
787 return result;
788}
789
76e3e7c4 790/*----------------------------------------------------------------
d8950599 791* read_fwfile
76e3e7c4 792*
d8950599
KR
793* Reads the given fw file which should have been compiled from an srec
794* file. Each record in the fw file will either be a plain data record,
795* a start address record, or other records used for plugging.
76e3e7c4 796*
d8950599
KR
797* Note that data records are expected to be sorted into
798* ascending address order in the fw file.
76e3e7c4 799*
d8950599
KR
800* Note also that the start address record, originally an S7 record in
801* the srec file, is expected in the fw file to be like a data record but
802* with a certain address to make it identiable.
76e3e7c4 803*
d8950599 804* Here's the SREC format that the fw should have come from:
76e3e7c4
KR
805* S[37]nnaaaaaaaaddd...dddcc
806*
807* nn - number of bytes starting with the address field
808* aaaaaaaa - address in readable (or big endian) format
809* dd....dd - 0-245 data bytes (two chars per byte)
810* cc - checksum
811*
812* The S7 record's (there should be only one) address value gets
d8950599
KR
813* converted to an S3 record with address of 0xff400000, with the
814* start address being stored as a 4 byte data word. That address is
815* the start execution address used for RAM downloads.
76e3e7c4
KR
816*
817* The S3 records have a collection of subformats indicated by the
818* value of aaaaaaaa:
819* 0xff000000 - Plug record, data field format:
820* xxxxxxxxaaaaaaaassssssss
821* x - PDR code number (little endian)
822* a - Address in load image to plug (little endian)
823* s - Length of plug data area (little endian)
824*
825* 0xff100000 - CRC16 generation record, data field format:
826* aaaaaaaassssssssbbbbbbbb
827* a - Start address for CRC calculation (little endian)
828* s - Length of data to calculate over (little endian)
829* b - Boolean, true=write crc, false=don't write
830*
831* 0xff200000 - Info record, data field format:
832* ssssttttdd..dd
833* s - Size in words (little endian)
834* t - Info type (little endian), see #defines and
835* s3inforec_t for details about types.
836* d - (s - 1) little endian words giving the contents of
837* the given info type.
838*
d8950599
KR
839* 0xff400000 - Start address record, data field format:
840* aaaaaaaa
841* a - Address in load image to plug (little endian)
842*
76e3e7c4 843* Arguments:
d8950599 844* record firmware image (ihex record structure) in kernel memory
76e3e7c4
KR
845*
846* Returns:
847* 0 - success
848* ~0 - failure (probably an errno)
849----------------------------------------------------------------*/
d8950599 850int read_fwfile(const struct ihex_binrec *record)
76e3e7c4 851{
d8950599
KR
852 int i;
853 int rcnt = 0;
854 u16 *tmpinfo;
855 u16 *ptr16;
856 u32 *ptr32, len, addr;
76e3e7c4 857
d8950599 858 pr_debug("Reading fw file ...\n");
76e3e7c4 859
d8950599
KR
860 while (record) {
861
862 rcnt++;
863
864 len = be16_to_cpu(record->len);
865 addr = be32_to_cpu(record->addr);
866
867 /* Point into data for different word lengths */
868 ptr32 = (u32 *) record->data;
869 ptr16 = (u16 *) record->data;
870
871 /* parse what was an S3 srec and put it in the right array */
872 switch(addr) {
873 case S3ADDR_START:
874 startaddr = *ptr32;
875 pr_debug(" S7 start addr, record=%d "
876 " addr=0x%08x\n",
877 rcnt,
878 startaddr);
879 break;
880 case S3ADDR_PLUG:
881 s3plug[ns3plug].itemcode = *ptr32;
882 s3plug[ns3plug].addr = *(ptr32 + 1);
883 s3plug[ns3plug].len = *(ptr32 + 2);
884
885 pr_debug(" S3 plugrec, record=%d "
886 "itemcode=0x%08x addr=0x%08x len=%d\n",
887 rcnt,
888 s3plug[ns3plug].itemcode,
889 s3plug[ns3plug].addr,
890 s3plug[ns3plug].len);
891
892 ns3plug++;
893 if ( ns3plug == S3PLUG_MAX ) {
894 printk(KERN_ERR "S3 plugrec limit reached - aborting\n");
895 return 1;
76e3e7c4 896 }
d8950599
KR
897 break;
898 case S3ADDR_CRC:
899 s3crc[ns3crc].addr = *ptr32;
900 s3crc[ns3crc].len = *(ptr32 + 1);
901 s3crc[ns3crc].dowrite = *(ptr32 + 2);
902
903 pr_debug(" S3 crcrec, record=%d "
904 "addr=0x%08x len=%d write=0x%08x\n",
905 rcnt,
906 s3crc[ns3crc].addr,
907 s3crc[ns3crc].len,
908 s3crc[ns3crc].dowrite);
909 ns3crc++;
910 if ( ns3crc == S3CRC_MAX ) {
911 printk(KERN_ERR "S3 crcrec limit reached - aborting\n");
912 return 1;
913 }
914 break;
915 case S3ADDR_INFO:
916 s3info[ns3info].len = *ptr16;
917 s3info[ns3info].type = *(ptr16 + 1);
918
919 pr_debug(" S3 inforec, record=%d "
920 "len=0x%04x type=0x%04x\n",
921 rcnt,
922 s3info[ns3info].len,
923 s3info[ns3info].type);
924 if ( ((s3info[ns3info].len - 1) * sizeof(u16)) > sizeof(s3info[ns3info].info) ) {
925 printk(KERN_ERR " S3 inforec length too long - aborting\n");
926 return 1;
927 }
928
929 tmpinfo = (u16*)&(s3info[ns3info].info.version);
930 pr_debug(" info=");
931 for (i = 0; i < s3info[ns3info].len - 1; i++) {
932 tmpinfo[i] = *(ptr16 + 2 + i);
933 pr_debug("%04x ", tmpinfo[i]);
934 }
935 pr_debug("\n");
936
937 ns3info++;
938 if ( ns3info == S3INFO_MAX ) {
939 printk(KERN_ERR "S3 inforec limit reached - aborting\n");
940 return 1;
941 }
942 break;
943 default: /* Data record */
944 s3data[ns3data].addr = addr;
945 s3data[ns3data].len = len;
946 s3data[ns3data].data = (uint8_t *) record->data;
947 ns3data++;
948 if ( ns3data == S3DATA_MAX ) {
949 printk(KERN_ERR "S3 datarec limit reached - aborting\n");
950 return 1;
951 }
952 break;
76e3e7c4 953 }
d8950599 954 record = ihex_next_binrec(record);
76e3e7c4 955 }
d8950599 956 return 0;
76e3e7c4
KR
957}
958
76e3e7c4
KR
959/*----------------------------------------------------------------
960* writeimage
961*
962* Takes the chunks, builds p80211 messages and sends them down
963* to the driver for writing to the card.
964*
965* Arguments:
966* wlandev device
967* fchunk Array of image chunks
968* nfchunks Number of image chunks
969*
970* Returns:
971* 0 success
972* ~0 failure
973----------------------------------------------------------------*/
297f06ce 974int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk,
75f49e07 975 unsigned int nfchunks)
76e3e7c4 976{
75f49e07
MT
977 int result = 0;
978 p80211msg_p2req_ramdl_state_t rstatemsg;
979 p80211msg_p2req_ramdl_write_t rwritemsg;
980 p80211msg_t *msgp;
981 u32 resultcode;
982 int i;
983 int j;
984 unsigned int nwrites;
985 u32 curroff;
986 u32 currlen;
987 u32 currdaddr;
76e3e7c4
KR
988
989 /* Initialize the messages */
990 memset(&rstatemsg, 0, sizeof(rstatemsg));
991 strcpy(rstatemsg.devname, wlandev->name);
75f49e07
MT
992 rstatemsg.msgcode = DIDmsg_p2req_ramdl_state;
993 rstatemsg.msglen = sizeof(rstatemsg);
994 rstatemsg.enable.did = DIDmsg_p2req_ramdl_state_enable;
995 rstatemsg.exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr;
996 rstatemsg.resultcode.did = DIDmsg_p2req_ramdl_state_resultcode;
997 rstatemsg.enable.status = P80211ENUM_msgitem_status_data_ok;
998 rstatemsg.exeaddr.status = P80211ENUM_msgitem_status_data_ok;
999 rstatemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
1000 rstatemsg.enable.len = sizeof(u32);
1001 rstatemsg.exeaddr.len = sizeof(u32);
1002 rstatemsg.resultcode.len = sizeof(u32);
76e3e7c4
KR
1003
1004 memset(&rwritemsg, 0, sizeof(rwritemsg));
1005 strcpy(rwritemsg.devname, wlandev->name);
75f49e07
MT
1006 rwritemsg.msgcode = DIDmsg_p2req_ramdl_write;
1007 rwritemsg.msglen = sizeof(rwritemsg);
1008 rwritemsg.addr.did = DIDmsg_p2req_ramdl_write_addr;
1009 rwritemsg.len.did = DIDmsg_p2req_ramdl_write_len;
1010 rwritemsg.data.did = DIDmsg_p2req_ramdl_write_data;
1011 rwritemsg.resultcode.did = DIDmsg_p2req_ramdl_write_resultcode;
1012 rwritemsg.addr.status = P80211ENUM_msgitem_status_data_ok;
1013 rwritemsg.len.status = P80211ENUM_msgitem_status_data_ok;
1014 rwritemsg.data.status = P80211ENUM_msgitem_status_data_ok;
1015 rwritemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
1016 rwritemsg.addr.len = sizeof(u32);
1017 rwritemsg.len.len = sizeof(u32);
1018 rwritemsg.data.len = WRITESIZE_MAX;
1019 rwritemsg.resultcode.len = sizeof(u32);
76e3e7c4
KR
1020
1021 /* Send xxx_state(enable) */
1022 pr_debug("Sending dl_state(enable) message.\n");
1023 rstatemsg.enable.data = P80211ENUM_truth_true;
1024 rstatemsg.exeaddr.data = startaddr;
1025
75f49e07 1026 msgp = (p80211msg_t *) & rstatemsg;
76e3e7c4 1027 result = prism2mgmt_ramdl_state(wlandev, msgp);
75f49e07 1028 if (result) {
76e3e7c4 1029 printk(KERN_ERR
75f49e07
MT
1030 "writeimage state enable failed w/ result=%d, "
1031 "aborting download\n", result);
76e3e7c4
KR
1032 return result;
1033 }
1034 resultcode = rstatemsg.resultcode.data;
75f49e07 1035 if (resultcode != P80211ENUM_resultcode_success) {
76e3e7c4 1036 printk(KERN_ERR
75f49e07
MT
1037 "writeimage()->xxxdl_state msg indicates failure, "
1038 "w/ resultcode=%d, aborting download.\n", resultcode);
76e3e7c4
KR
1039 return 1;
1040 }
1041
1042 /* Now, loop through the data chunks and send WRITESIZE_MAX data */
75f49e07 1043 for (i = 0; i < nfchunks; i++) {
76e3e7c4
KR
1044 nwrites = fchunk[i].len / WRITESIZE_MAX;
1045 nwrites += (fchunk[i].len % WRITESIZE_MAX) ? 1 : 0;
1046 curroff = 0;
75f49e07 1047 for (j = 0; j < nwrites; j++) {
76e3e7c4 1048 currlen =
75f49e07
MT
1049 (fchunk[i].len - (WRITESIZE_MAX * j)) >
1050 WRITESIZE_MAX ? WRITESIZE_MAX : (fchunk[i].len -
1051 (WRITESIZE_MAX *
1052 j));
76e3e7c4
KR
1053 curroff = j * WRITESIZE_MAX;
1054 currdaddr = fchunk[i].addr + curroff;
1055 /* Setup the message */
1056 rwritemsg.addr.data = currdaddr;
1057 rwritemsg.len.data = currlen;
1058 memcpy(rwritemsg.data.data,
75f49e07 1059 fchunk[i].data + curroff, currlen);
76e3e7c4
KR
1060
1061 /* Send flashdl_write(pda) */
75f49e07
MT
1062 pr_debug
1063 ("Sending xxxdl_write message addr=%06x len=%d.\n",
1064 currdaddr, currlen);
76e3e7c4 1065
75f49e07 1066 msgp = (p80211msg_t *) & rwritemsg;
76e3e7c4
KR
1067 result = prism2mgmt_ramdl_write(wlandev, msgp);
1068
1069 /* Check the results */
75f49e07 1070 if (result) {
76e3e7c4 1071 printk(KERN_ERR
75f49e07
MT
1072 "writeimage chunk write failed w/ result=%d, "
1073 "aborting download\n", result);
76e3e7c4
KR
1074 return result;
1075 }
1076 resultcode = rstatemsg.resultcode.data;
75f49e07 1077 if (resultcode != P80211ENUM_resultcode_success) {
76e3e7c4 1078 printk(KERN_ERR
75f49e07
MT
1079 "writeimage()->xxxdl_write msg indicates failure, "
1080 "w/ resultcode=%d, aborting download.\n",
1081 resultcode);
76e3e7c4
KR
1082 return 1;
1083 }
1084
1085 }
1086 }
1087
1088 /* Send xxx_state(disable) */
1089 pr_debug("Sending dl_state(disable) message.\n");
1090 rstatemsg.enable.data = P80211ENUM_truth_false;
1091 rstatemsg.exeaddr.data = 0;
1092
75f49e07 1093 msgp = (p80211msg_t *) & rstatemsg;
76e3e7c4 1094 result = prism2mgmt_ramdl_state(wlandev, msgp);
75f49e07 1095 if (result) {
76e3e7c4 1096 printk(KERN_ERR
75f49e07
MT
1097 "writeimage state disable failed w/ result=%d, "
1098 "aborting download\n", result);
76e3e7c4
KR
1099 return result;
1100 }
1101 resultcode = rstatemsg.resultcode.data;
75f49e07 1102 if (resultcode != P80211ENUM_resultcode_success) {
76e3e7c4 1103 printk(KERN_ERR
75f49e07
MT
1104 "writeimage()->xxxdl_state msg indicates failure, "
1105 "w/ resultcode=%d, aborting download.\n", resultcode);
76e3e7c4
KR
1106 return 1;
1107 }
1108 return result;
1109}
1110
76e3e7c4
KR
1111int validate_identity(void)
1112{
1113 int i;
1114 int result = 1;
d8950599 1115 int trump = 0;
76e3e7c4
KR
1116
1117 pr_debug("NIC ID: %#x v%d.%d.%d\n",
75f49e07 1118 nicid.id, nicid.major, nicid.minor, nicid.variant);
76e3e7c4 1119 pr_debug("MFI ID: %#x v%d %d->%d\n",
75f49e07 1120 rfid.id, rfid.variant, rfid.bottom, rfid.top);
76e3e7c4 1121 pr_debug("CFI ID: %#x v%d %d->%d\n",
75f49e07 1122 macid.id, macid.variant, macid.bottom, macid.top);
76e3e7c4 1123 pr_debug("PRI ID: %#x v%d %d->%d\n",
75f49e07 1124 priid.id, priid.variant, priid.bottom, priid.top);
76e3e7c4 1125
75f49e07 1126 for (i = 0; i < ns3info; i++) {
76e3e7c4
KR
1127 switch (s3info[i].type) {
1128 case 1:
1129 pr_debug("Version: ID %#x %d.%d.%d\n",
75f49e07
MT
1130 s3info[i].info.version.id,
1131 s3info[i].info.version.major,
1132 s3info[i].info.version.minor,
1133 s3info[i].info.version.variant);
76e3e7c4
KR
1134 break;
1135 case 2:
1136 pr_debug("Compat: Role %#x Id %#x v%d %d->%d\n",
75f49e07
MT
1137 s3info[i].info.compat.role,
1138 s3info[i].info.compat.id,
1139 s3info[i].info.compat.variant,
1140 s3info[i].info.compat.bottom,
1141 s3info[i].info.compat.top);
76e3e7c4
KR
1142
1143 /* MAC compat range */
1144 if ((s3info[i].info.compat.role == 1) &&
1145 (s3info[i].info.compat.id == 2)) {
1146 if (s3info[i].info.compat.variant !=
1147 macid.variant) {
1148 result = 2;
1149 }
1150 }
1151
1152 /* PRI compat range */
1153 if ((s3info[i].info.compat.role == 1) &&
1154 (s3info[i].info.compat.id == 3)) {
75f49e07
MT
1155 if ((s3info[i].info.compat.bottom > priid.top)
1156 || (s3info[i].info.compat.top <
1157 priid.bottom)) {
76e3e7c4
KR
1158 result = 3;
1159 }
1160 }
1161 /* SEC compat range */
1162 if ((s3info[i].info.compat.role == 1) &&
1163 (s3info[i].info.compat.id == 4)) {
1164
1165 }
1166
1167 break;
1168 case 3:
75f49e07 1169 pr_debug("Seq: %#x\n", s3info[i].info.buildseq);
76e3e7c4 1170
75f49e07 1171 break;
76e3e7c4
KR
1172 case 4:
1173 pr_debug("Platform: ID %#x %d.%d.%d\n",
75f49e07
MT
1174 s3info[i].info.version.id,
1175 s3info[i].info.version.major,
1176 s3info[i].info.version.minor,
1177 s3info[i].info.version.variant);
76e3e7c4
KR
1178
1179 if (nicid.id != s3info[i].info.version.id)
1180 continue;
1181 if (nicid.major != s3info[i].info.version.major)
1182 continue;
1183 if (nicid.minor != s3info[i].info.version.minor)
1184 continue;
1185 if ((nicid.variant != s3info[i].info.version.variant) &&
1186 (nicid.id != 0x8008))
1187 continue;
1188
d8950599 1189 trump = 1;
76e3e7c4
KR
1190 break;
1191 case 0x8001:
1192 pr_debug("name inforec len %d\n", s3info[i].len);
1193
1194 break;
1195 default:
1196 pr_debug("Unknown inforec type %d\n", s3info[i].type);
1197 }
1198 }
1199 // walk through
1200
d8950599 1201 if (trump && (result != 2)) result = 0;
76e3e7c4
KR
1202 return result;
1203}
This page took 0.107811 seconds and 5 git commands to generate.