diff options
| author | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-07-24 23:00:45 +0100 |
|---|---|---|
| committer | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-07-24 23:00:45 +0100 |
| commit | 3cc1f8a1eb2986db05de6dd25c0869921dc41136 (patch) | |
| tree | 0645a44275cea5928b9f2d52b591a9d09969032c /bcm4329/dhdutil | |
| parent | 6863a0b90384a0fcb2d6280923e942242293f1c0 (diff) | |
| parent | 82f1cb8a08a90ff145e0a4eebede9c6a1ba2be95 (diff) | |
| download | android_hardware_broadcom_wlan-stable/cm-10.2.tar.gz android_hardware_broadcom_wlan-stable/cm-10.2.tar.bz2 android_hardware_broadcom_wlan-stable/cm-10.2.zip | |
Merge tag 'android-4.3_r2.1' into cm-10.2cm-10.2.1cm-10.2.0cm-10.2-M1stable/cm-10.2cm-10.2
Android 4.3 release 2.1
Conflicts:
bcm4329/Android.mk
bcmdhd/config/config-bcm.mk
Change-Id: Ib265fc14466dc52c40db6e2b457dbba84992fb2f
Diffstat (limited to 'bcm4329/dhdutil')
34 files changed, 0 insertions, 13582 deletions
diff --git a/bcm4329/dhdutil/Android.mk b/bcm4329/dhdutil/Android.mk deleted file mode 100644 index bc4c27b..0000000 --- a/bcm4329/dhdutil/Android.mk +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (C) 2008-2011 Broadcom Corporation -# -# $Id: Android.mk,v 2.6 2009-05-07 18:25:15 hharte Exp $ -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION -# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_SRC_FILES := \ - dhdu.c \ - dhdu_linux.c \ - bcmutils.c \ - miniopt.c - -LOCAL_MODULE := dhdutil -LOCAL_CFLAGS := -DSDTEST -DTARGETENV_android -Dlinux -DLINUX -mabi=aapcs-linux -LOCAL_C_INCLUDES +=$(LOCAL_PATH)/include - -LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) -LOCAL_MODULE_TAGS := debug - -include $(BUILD_EXECUTABLE) diff --git a/bcm4329/dhdutil/MODULE_LICENSE_BSD b/bcm4329/dhdutil/MODULE_LICENSE_BSD deleted file mode 100644 index e69de29..0000000 --- a/bcm4329/dhdutil/MODULE_LICENSE_BSD +++ /dev/null diff --git a/bcm4329/dhdutil/NOTICE b/bcm4329/dhdutil/NOTICE deleted file mode 100644 index 6b0eb47..0000000 --- a/bcm4329/dhdutil/NOTICE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (C) 1999-2011, Broadcom Corporation - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION -OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/bcm4329/dhdutil/bcmutils.c b/bcm4329/dhdutil/bcmutils.c deleted file mode 100644 index 65ca89d..0000000 --- a/bcm4329/dhdutil/bcmutils.c +++ /dev/null @@ -1,1962 +0,0 @@ -/* - * Driver O/S-independent utility routines - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: bcmutils.c,v 1.277.2.18 2011-01-26 02:32:08 Exp $ - */ - -#include <typedefs.h> -#include <bcmdefs.h> -#include <stdarg.h> - -#ifdef BCMDRIVER - -#include <osl.h> -#include <bcmutils.h> -#include <siutils.h> - -#else /* !BCMDRIVER */ - -#include <stdio.h> -#include <string.h> -#include <bcmutils.h> - -#if defined(BCMEXTSUP) -#include <bcm_osl.h> -#endif - - -#endif /* !BCMDRIVER */ - -#include <bcmendian.h> -#include <bcmdevs.h> -#include <proto/ethernet.h> -#include <proto/vlan.h> -#include <proto/bcmip.h> -#include <proto/802.1d.h> -#include <proto/802.11.h> - -void *_bcmutils_dummy_fn = NULL; - -#ifdef BCMDRIVER - - - -/* copy a pkt buffer chain into a buffer */ -uint -pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf) -{ - uint n, ret = 0; - - if (len < 0) - len = 4096; /* "infinite" */ - - /* skip 'offset' bytes */ - for (; p && offset; p = PKTNEXT(osh, p)) { - if (offset < (uint)PKTLEN(osh, p)) - break; - offset -= PKTLEN(osh, p); - } - - if (!p) - return 0; - - /* copy the data */ - for (; p && len; p = PKTNEXT(osh, p)) { - n = MIN((uint)PKTLEN(osh, p) - offset, (uint)len); - bcopy(PKTDATA(osh, p) + offset, buf, n); - buf += n; - len -= n; - ret += n; - offset = 0; - } - - return ret; -} - -/* copy a buffer into a pkt buffer chain */ -uint -pktfrombuf(osl_t *osh, void *p, uint offset, int len, uchar *buf) -{ - uint n, ret = 0; - - /* skip 'offset' bytes */ - for (; p && offset; p = PKTNEXT(osh, p)) { - if (offset < (uint)PKTLEN(osh, p)) - break; - offset -= PKTLEN(osh, p); - } - - if (!p) - return 0; - - /* copy the data */ - for (; p && len; p = PKTNEXT(osh, p)) { - n = MIN((uint)PKTLEN(osh, p) - offset, (uint)len); - bcopy(buf, PKTDATA(osh, p) + offset, n); - buf += n; - len -= n; - ret += n; - offset = 0; - } - - return ret; -} - - - -/* return total length of buffer chain */ -uint BCMFASTPATH -pkttotlen(osl_t *osh, void *p) -{ - uint total; - - total = 0; - for (; p; p = PKTNEXT(osh, p)) - total += PKTLEN(osh, p); - return (total); -} - -/* return the last buffer of chained pkt */ -void * -pktlast(osl_t *osh, void *p) -{ - for (; PKTNEXT(osh, p); p = PKTNEXT(osh, p)) - ; - - return (p); -} - -/* count segments of a chained packet */ -uint BCMFASTPATH -pktsegcnt(osl_t *osh, void *p) -{ - uint cnt; - - for (cnt = 0; p; p = PKTNEXT(osh, p)) - cnt++; - - return cnt; -} - - -/* - * osl multiple-precedence packet queue - * hi_prec is always >= the number of the highest non-empty precedence - */ -void * BCMFASTPATH -pktq_penq(struct pktq *pq, int prec, void *p) -{ - struct pktq_prec *q; - - ASSERT(prec >= 0 && prec < pq->num_prec); - ASSERT(PKTLINK(p) == NULL); /* queueing chains not allowed */ - - ASSERT(!pktq_full(pq)); - ASSERT(!pktq_pfull(pq, prec)); - - q = &pq->q[prec]; - - if (q->head) - PKTSETLINK(q->tail, p); - else - q->head = p; - - q->tail = p; - q->len++; - - pq->len++; - - if (pq->hi_prec < prec) - pq->hi_prec = (uint8)prec; - - return p; -} - -void * BCMFASTPATH -pktq_penq_head(struct pktq *pq, int prec, void *p) -{ - struct pktq_prec *q; - - ASSERT(prec >= 0 && prec < pq->num_prec); - ASSERT(PKTLINK(p) == NULL); /* queueing chains not allowed */ - - ASSERT(!pktq_full(pq)); - ASSERT(!pktq_pfull(pq, prec)); - - q = &pq->q[prec]; - - if (q->head == NULL) - q->tail = p; - - PKTSETLINK(p, q->head); - q->head = p; - q->len++; - - pq->len++; - - if (pq->hi_prec < prec) - pq->hi_prec = (uint8)prec; - - return p; -} - -void * BCMFASTPATH -pktq_pdeq(struct pktq *pq, int prec) -{ - struct pktq_prec *q; - void *p; - - ASSERT(prec >= 0 && prec < pq->num_prec); - - q = &pq->q[prec]; - - if ((p = q->head) == NULL) - return NULL; - - if ((q->head = PKTLINK(p)) == NULL) - q->tail = NULL; - - q->len--; - - pq->len--; - - PKTSETLINK(p, NULL); - - return p; -} - -void * BCMFASTPATH -pktq_pdeq_tail(struct pktq *pq, int prec) -{ - struct pktq_prec *q; - void *p, *prev; - - ASSERT(prec >= 0 && prec < pq->num_prec); - - q = &pq->q[prec]; - - if ((p = q->head) == NULL) - return NULL; - - for (prev = NULL; p != q->tail; p = PKTLINK(p)) - prev = p; - - if (prev) - PKTSETLINK(prev, NULL); - else - q->head = NULL; - - q->tail = prev; - q->len--; - - pq->len--; - - return p; -} - -void -pktq_pflush(osl_t *osh, struct pktq *pq, int prec, bool dir, ifpkt_cb_t fn, int arg) -{ - struct pktq_prec *q; - void *p, *prev = NULL; - - q = &pq->q[prec]; - p = q->head; - while (p) { - if (fn == NULL || (*fn)(p, arg)) { - bool head = (p == q->head); - if (head) - q->head = PKTLINK(p); - else - PKTSETLINK(prev, PKTLINK(p)); - PKTSETLINK(p, NULL); - PKTFREE(osh, p, dir); - q->len--; - pq->len--; - p = (head ? q->head : PKTLINK(prev)); - } else { - prev = p; - p = PKTLINK(p); - } - } - - if (q->head == NULL) { - ASSERT(q->len == 0); - q->tail = NULL; - } -} - -bool BCMFASTPATH -pktq_pdel(struct pktq *pq, void *pktbuf, int prec) -{ - struct pktq_prec *q; - void *p; - - ASSERT(prec >= 0 && prec < pq->num_prec); - - if (!pktbuf) - return FALSE; - - q = &pq->q[prec]; - - if (q->head == pktbuf) { - if ((q->head = PKTLINK(pktbuf)) == NULL) - q->tail = NULL; - } else { - for (p = q->head; p && PKTLINK(p) != pktbuf; p = PKTLINK(p)) - ; - if (p == NULL) - return FALSE; - - PKTSETLINK(p, PKTLINK(pktbuf)); - if (q->tail == pktbuf) - q->tail = p; - } - - q->len--; - pq->len--; - PKTSETLINK(pktbuf, NULL); - return TRUE; -} - -void -pktq_init(struct pktq *pq, int num_prec, int max_len) -{ - int prec; - - ASSERT(num_prec > 0 && num_prec <= PKTQ_MAX_PREC); - - /* pq is variable size; only zero out what's requested */ - bzero(pq, OFFSETOF(struct pktq, q) + (sizeof(struct pktq_prec) * num_prec)); - - pq->num_prec = (uint16)num_prec; - - pq->max = (uint16)max_len; - - for (prec = 0; prec < num_prec; prec++) - pq->q[prec].max = pq->max; -} - -void * BCMFASTPATH -pktq_deq(struct pktq *pq, int *prec_out) -{ - struct pktq_prec *q; - void *p; - int prec; - - if (pq->len == 0) - return NULL; - - while ((prec = pq->hi_prec) > 0 && pq->q[prec].head == NULL) - pq->hi_prec--; - - q = &pq->q[prec]; - - if ((p = q->head) == NULL) - return NULL; - - if ((q->head = PKTLINK(p)) == NULL) - q->tail = NULL; - - q->len--; - - pq->len--; - - if (prec_out) - *prec_out = prec; - - PKTSETLINK(p, NULL); - - return p; -} - -void * BCMFASTPATH -pktq_deq_tail(struct pktq *pq, int *prec_out) -{ - struct pktq_prec *q; - void *p, *prev; - int prec; - - if (pq->len == 0) - return NULL; - - for (prec = 0; prec < pq->hi_prec; prec++) - if (pq->q[prec].head) - break; - - q = &pq->q[prec]; - - if ((p = q->head) == NULL) - return NULL; - - for (prev = NULL; p != q->tail; p = PKTLINK(p)) - prev = p; - - if (prev) - PKTSETLINK(prev, NULL); - else - q->head = NULL; - - q->tail = prev; - q->len--; - - pq->len--; - - if (prec_out) - *prec_out = prec; - - PKTSETLINK(p, NULL); - - return p; -} - -void * -pktq_peek(struct pktq *pq, int *prec_out) -{ - int prec; - - if (pq->len == 0) - return NULL; - - while ((prec = pq->hi_prec) > 0 && pq->q[prec].head == NULL) - pq->hi_prec--; - - if (prec_out) - *prec_out = prec; - - return (pq->q[prec].head); -} - -void * -pktq_peek_tail(struct pktq *pq, int *prec_out) -{ - int prec; - - if (pq->len == 0) - return NULL; - - for (prec = 0; prec < pq->hi_prec; prec++) - if (pq->q[prec].head) - break; - - if (prec_out) - *prec_out = prec; - - return (pq->q[prec].tail); -} - -void -pktq_flush(osl_t *osh, struct pktq *pq, bool dir, ifpkt_cb_t fn, int arg) -{ - int prec; - for (prec = 0; prec < pq->num_prec; prec++) - pktq_pflush(osh, pq, prec, dir, fn, arg); - if (fn == NULL) - ASSERT(pq->len == 0); -} - -/* Return sum of lengths of a specific set of precedences */ -int -pktq_mlen(struct pktq *pq, uint prec_bmp) -{ - int prec, len; - - len = 0; - - for (prec = 0; prec <= pq->hi_prec; prec++) - if (prec_bmp & (1 << prec)) - len += pq->q[prec].len; - - return len; -} - -/* Priority dequeue from a specific set of precedences */ -void * BCMFASTPATH -pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out) -{ - struct pktq_prec *q; - void *p; - int prec; - - if (pq->len == 0) - return NULL; - - while ((prec = pq->hi_prec) > 0 && pq->q[prec].head == NULL) - pq->hi_prec--; - - while ((prec_bmp & (1 << prec)) == 0 || pq->q[prec].head == NULL) - if (prec-- == 0) - return NULL; - - q = &pq->q[prec]; - - if ((p = q->head) == NULL) - return NULL; - - if ((q->head = PKTLINK(p)) == NULL) - q->tail = NULL; - - q->len--; - - if (prec_out) - *prec_out = prec; - - pq->len--; - - PKTSETLINK(p, NULL); - - return p; -} - -#endif /* BCMDRIVER */ - -const unsigned char bcm_ctype[] = { - - _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 0-7 */ - _BCM_C, _BCM_C|_BCM_S, _BCM_C|_BCM_S, _BCM_C|_BCM_S, _BCM_C|_BCM_S, _BCM_C|_BCM_S, _BCM_C, - _BCM_C, /* 8-15 */ - _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 16-23 */ - _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 24-31 */ - _BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 32-39 */ - _BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 40-47 */ - _BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D, /* 48-55 */ - _BCM_D,_BCM_D,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 56-63 */ - _BCM_P, _BCM_U|_BCM_X, _BCM_U|_BCM_X, _BCM_U|_BCM_X, _BCM_U|_BCM_X, _BCM_U|_BCM_X, - _BCM_U|_BCM_X, _BCM_U, /* 64-71 */ - _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 72-79 */ - _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 80-87 */ - _BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 88-95 */ - _BCM_P, _BCM_L|_BCM_X, _BCM_L|_BCM_X, _BCM_L|_BCM_X, _BCM_L|_BCM_X, _BCM_L|_BCM_X, - _BCM_L|_BCM_X, _BCM_L, /* 96-103 */ - _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 104-111 */ - _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 112-119 */ - _BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_C, /* 120-127 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 128-143 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 144-159 */ - _BCM_S|_BCM_SP, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, - _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, /* 160-175 */ - _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, - _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, /* 176-191 */ - _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, - _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, /* 192-207 */ - _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_P, _BCM_U, _BCM_U, _BCM_U, - _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_L, /* 208-223 */ - _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, - _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, /* 224-239 */ - _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_P, _BCM_L, _BCM_L, _BCM_L, - _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L /* 240-255 */ -}; - -ulong -bcm_strtoul(char *cp, char **endp, uint base) -{ - ulong result, last_result = 0, value; - bool minus; - - minus = FALSE; - - while (bcm_isspace(*cp)) - cp++; - - if (cp[0] == '+') - cp++; - else if (cp[0] == '-') { - minus = TRUE; - cp++; - } - - if (base == 0) { - if (cp[0] == '0') { - if ((cp[1] == 'x') || (cp[1] == 'X')) { - base = 16; - cp = &cp[2]; - } else { - base = 8; - cp = &cp[1]; - } - } else - base = 10; - } else if (base == 16 && (cp[0] == '0') && ((cp[1] == 'x') || (cp[1] == 'X'))) { - cp = &cp[2]; - } - - result = 0; - - while (bcm_isxdigit(*cp) && - (value = bcm_isdigit(*cp) ? *cp-'0' : bcm_toupper(*cp)-'A'+10) < base) - { - result = result*base + value; - /* Detected overflow */ - if (result < last_result && !minus) - return (ulong)-1; - last_result = result; - cp++; - } - - if (minus) - result = (ulong)(-(long)result); - - if (endp) - *endp = (char *)cp; - - return (result); -} - -int -bcm_atoi(char *s) -{ - return (int)bcm_strtoul(s, NULL, 10); -} - -/* return pointer to location of substring 'needle' in 'haystack' */ -char* -bcmstrstr(char *haystack, char *needle) -{ - int len, nlen; - int i; - - if ((haystack == NULL) || (needle == NULL)) - return (haystack); - - nlen = strlen(needle); - len = strlen(haystack) - nlen + 1; - - for (i = 0; i < len; i++) - if (memcmp(needle, &haystack[i], nlen) == 0) - return (&haystack[i]); - return (NULL); -} - -char* -bcmstrcat(char *dest, const char *src) -{ - char *p; - - p = dest + strlen(dest); - - while ((*p++ = *src++) != '\0') - ; - - return (dest); -} - -char* -bcmstrncat(char *dest, const char *src, uint size) -{ - char *endp; - char *p; - - p = dest + strlen(dest); - endp = p + size; - - while (p != endp && (*p++ = *src++) != '\0') - ; - - return (dest); -} - - -/**************************************************************************** -* Function: bcmstrtok -* -* Purpose: -* Tokenizes a string. This function is conceptually similiar to ANSI C strtok(), -* but allows strToken() to be used by different strings or callers at the same -* time. Each call modifies '*string' by substituting a NULL character for the -* first delimiter that is encountered, and updates 'string' to point to the char -* after the delimiter. Leading delimiters are skipped. -* -* Parameters: -* string (mod) Ptr to string ptr, updated by token. -* delimiters (in) Set of delimiter characters. -* tokdelim (out) Character that delimits the returned token. (May -* be set to NULL if token delimiter is not required). -* -* Returns: Pointer to the next token found. NULL when no more tokens are found. -***************************************************************************** -*/ -char * -bcmstrtok(char **string, const char *delimiters, char *tokdelim) -{ - unsigned char *str; - unsigned long map[8]; - int count; - char *nextoken; - - if (tokdelim != NULL) { - /* Prime the token delimiter */ - *tokdelim = '\0'; - } - - /* Clear control map */ - for (count = 0; count < 8; count++) { - map[count] = 0; - } - - /* Set bits in delimiter table */ - do { - map[*delimiters >> 5] |= (1 << (*delimiters & 31)); - } - while (*delimiters++); - - str = (unsigned char*)*string; - - /* Find beginning of token (skip over leading delimiters). Note that - * there is no token iff this loop sets str to point to the terminal - * null (*str == '\0') - */ - while (((map[*str >> 5] & (1 << (*str & 31))) && *str) || (*str == ' ')) { - str++; - } - - nextoken = (char*)str; - - /* Find the end of the token. If it is not the end of the string, - * put a null there. - */ - for (; *str; str++) { - if (map[*str >> 5] & (1 << (*str & 31))) { - if (tokdelim != NULL) { - *tokdelim = *str; - } - - *str++ = '\0'; - break; - } - } - - *string = (char*)str; - - /* Determine if a token has been found. */ - if (nextoken == (char *) str) { - return NULL; - } - else { - return nextoken; - } -} - - -#define xToLower(C) \ - ((C >= 'A' && C <= 'Z') ? (char)((int)C - (int)'A' + (int)'a') : C) - - -/**************************************************************************** -* Function: bcmstricmp -* -* Purpose: Compare to strings case insensitively. -* -* Parameters: s1 (in) First string to compare. -* s2 (in) Second string to compare. -* -* Returns: Return 0 if the two strings are equal, -1 if t1 < t2 and 1 if -* t1 > t2, when ignoring case sensitivity. -***************************************************************************** -*/ -int -bcmstricmp(const char *s1, const char *s2) -{ - char dc, sc; - - while (*s2 && *s1) { - dc = xToLower(*s1); - sc = xToLower(*s2); - if (dc < sc) return -1; - if (dc > sc) return 1; - s1++; - s2++; - } - - if (*s1 && !*s2) return 1; - if (!*s1 && *s2) return -1; - return 0; -} - - -/**************************************************************************** -* Function: bcmstrnicmp -* -* Purpose: Compare to strings case insensitively, upto a max of 'cnt' -* characters. -* -* Parameters: s1 (in) First string to compare. -* s2 (in) Second string to compare. -* cnt (in) Max characters to compare. -* -* Returns: Return 0 if the two strings are equal, -1 if t1 < t2 and 1 if -* t1 > t2, when ignoring case sensitivity. -***************************************************************************** -*/ -int -bcmstrnicmp(const char* s1, const char* s2, int cnt) -{ - char dc, sc; - - while (*s2 && *s1 && cnt) { - dc = xToLower(*s1); - sc = xToLower(*s2); - if (dc < sc) return -1; - if (dc > sc) return 1; - s1++; - s2++; - cnt--; - } - - if (!cnt) return 0; - if (*s1 && !*s2) return 1; - if (!*s1 && *s2) return -1; - return 0; -} - -/* parse a xx:xx:xx:xx:xx:xx format ethernet address */ -int -bcm_ether_atoe(char *p, struct ether_addr *ea) -{ - int i = 0; - - for (;;) { - ea->octet[i++] = (char) bcm_strtoul(p, &p, 16); - if (!*p++ || i == 6) - break; - } - - return (i == 6); -} - - -#if defined(CONFIG_USBRNDIS_RETAIL) || defined(NDIS_MINIPORT_DRIVER) -/* registry routine buffer preparation utility functions: - * parameter order is like strncpy, but returns count - * of bytes copied. Minimum bytes copied is null char(1)/wchar(2) - */ -ulong -wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen) -{ - ulong copyct = 1; - ushort i; - - if (abuflen == 0) - return 0; - - /* wbuflen is in bytes */ - wbuflen /= sizeof(ushort); - - for (i = 0; i < wbuflen; ++i) { - if (--abuflen == 0) - break; - *abuf++ = (char) *wbuf++; - ++copyct; - } - *abuf = '\0'; - - return copyct; -} -#endif /* CONFIG_USBRNDIS_RETAIL || NDIS_MINIPORT_DRIVER */ - -char * -bcm_ether_ntoa(const struct ether_addr *ea, char *buf) -{ - static const char template[] = "%02x:%02x:%02x:%02x:%02x:%02x"; - snprintf(buf, 18, template, - ea->octet[0]&0xff, ea->octet[1]&0xff, ea->octet[2]&0xff, - ea->octet[3]&0xff, ea->octet[4]&0xff, ea->octet[5]&0xff); - return (buf); -} - -char * -bcm_ip_ntoa(struct ipv4_addr *ia, char *buf) -{ - snprintf(buf, 16, "%d.%d.%d.%d", - ia->addr[0], ia->addr[1], ia->addr[2], ia->addr[3]); - return (buf); -} - -#ifdef BCMDRIVER - -void -bcm_mdelay(uint ms) -{ - uint i; - - for (i = 0; i < ms; i++) { - OSL_DELAY(1000); - } -} - - - - - -#if defined(DHD_DEBUG) -/* pretty hex print a pkt buffer chain */ -void -prpkt(const char *msg, osl_t *osh, void *p0) -{ - void *p; - - if (msg && (msg[0] != '\0')) - printf("%s:\n", msg); - - for (p = p0; p; p = PKTNEXT(osh, p)) - prhex(NULL, PKTDATA(osh, p), PKTLEN(osh, p)); -} -#endif - -/* Takes an Ethernet frame and sets out-of-bound PKTPRIO. - * Also updates the inplace vlan tag if requested. - * For debugging, it returns an indication of what it did. - */ -uint BCMFASTPATH -pktsetprio(void *pkt, bool update_vtag) -{ - struct ether_header *eh; - struct ethervlan_header *evh; - uint8 *pktdata; - int priority = 0; - int rc = 0; - - pktdata = (uint8 *) PKTDATA(NULL, pkt); - ASSERT(ISALIGNED((uintptr)pktdata, sizeof(uint16))); - - eh = (struct ether_header *) pktdata; - - if (ntoh16(eh->ether_type) == ETHER_TYPE_8021Q) { - uint16 vlan_tag; - int vlan_prio, dscp_prio = 0; - - evh = (struct ethervlan_header *)eh; - - vlan_tag = ntoh16(evh->vlan_tag); - vlan_prio = (int) (vlan_tag >> VLAN_PRI_SHIFT) & VLAN_PRI_MASK; - - if (ntoh16(evh->ether_type) == ETHER_TYPE_IP) { - uint8 *ip_body = pktdata + sizeof(struct ethervlan_header); - uint8 tos_tc = IP_TOS46(ip_body); - dscp_prio = (int)(tos_tc >> IPV4_TOS_PREC_SHIFT); - } - - /* DSCP priority gets precedence over 802.1P (vlan tag) */ - if (dscp_prio != 0) { - priority = dscp_prio; - rc |= PKTPRIO_VDSCP; - } else { - priority = vlan_prio; - rc |= PKTPRIO_VLAN; - } - /* - * If the DSCP priority is not the same as the VLAN priority, - * then overwrite the priority field in the vlan tag, with the - * DSCP priority value. This is required for Linux APs because - * the VLAN driver on Linux, overwrites the skb->priority field - * with the priority value in the vlan tag - */ - if (update_vtag && (priority != vlan_prio)) { - vlan_tag &= ~(VLAN_PRI_MASK << VLAN_PRI_SHIFT); - vlan_tag |= (uint16)priority << VLAN_PRI_SHIFT; - evh->vlan_tag = hton16(vlan_tag); - rc |= PKTPRIO_UPD; - } - } else if (ntoh16(eh->ether_type) == ETHER_TYPE_IP) { - uint8 *ip_body = pktdata + sizeof(struct ether_header); - uint8 tos_tc = IP_TOS46(ip_body); - priority = (int)(tos_tc >> IPV4_TOS_PREC_SHIFT); - rc |= PKTPRIO_DSCP; - } - - ASSERT(priority >= 0 && priority <= MAXPRIO); - PKTSETPRIO(pkt, priority); - return (rc | priority); -} - -#ifndef BCM_BOOTLOADER - -static char bcm_undeferrstr[32]; -static const char *bcmerrorstrtable[] = BCMERRSTRINGTABLE; - -/* Convert the error codes into related error strings */ -const char * -bcmerrorstr(int bcmerror) -{ - /* check if someone added a bcmerror code but forgot to add errorstring */ - ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(bcmerrorstrtable) - 1)); - - if (bcmerror > 0 || bcmerror < BCME_LAST) { - snprintf(bcm_undeferrstr, sizeof(bcm_undeferrstr), "Undefined error %d", bcmerror); - return bcm_undeferrstr; - } - - ASSERT(strlen(bcmerrorstrtable[-bcmerror]) < BCME_STRLEN); - - return bcmerrorstrtable[-bcmerror]; -} - -#endif /* !BCM_BOOTLOADER */ - - - -/* iovar table lookup */ -const bcm_iovar_t* -bcm_iovar_lookup(const bcm_iovar_t *table, const char *name) -{ - const bcm_iovar_t *vi; - const char *lookup_name; - - /* skip any ':' delimited option prefixes */ - lookup_name = strrchr(name, ':'); - if (lookup_name != NULL) - lookup_name++; - else - lookup_name = name; - - ASSERT(table != NULL); - - for (vi = table; vi->name; vi++) { - if (!strcmp(vi->name, lookup_name)) - return vi; - } - /* ran to end of table */ - - return NULL; /* var name not found */ -} - -int -bcm_iovar_lencheck(const bcm_iovar_t *vi, void *arg, int len, bool set) -{ - int bcmerror = 0; - - /* length check on io buf */ - switch (vi->type) { - case IOVT_BOOL: - case IOVT_INT8: - case IOVT_INT16: - case IOVT_INT32: - case IOVT_UINT8: - case IOVT_UINT16: - case IOVT_UINT32: - /* all integers are int32 sized args at the ioctl interface */ - if (len < (int)sizeof(int)) { - bcmerror = BCME_BUFTOOSHORT; - } - break; - - case IOVT_BUFFER: - /* buffer must meet minimum length requirement */ - if (len < vi->minlen) { - bcmerror = BCME_BUFTOOSHORT; - } - break; - - case IOVT_VOID: - if (!set) { - /* Cannot return nil... */ - bcmerror = BCME_UNSUPPORTED; - } else if (len) { - /* Set is an action w/o parameters */ - bcmerror = BCME_BUFTOOLONG; - } - break; - - default: - /* unknown type for length check in iovar info */ - ASSERT(0); - bcmerror = BCME_UNSUPPORTED; - } - - return bcmerror; -} - -#endif /* BCMDRIVER */ - - -/******************************************************************************* - * crc8 - * - * Computes a crc8 over the input data using the polynomial: - * - * x^8 + x^7 +x^6 + x^4 + x^2 + 1 - * - * The caller provides the initial value (either CRC8_INIT_VALUE - * or the previous returned value) to allow for processing of - * discontiguous blocks of data. When generating the CRC the - * caller is responsible for complementing the final return value - * and inserting it into the byte stream. When checking, a final - * return value of CRC8_GOOD_VALUE indicates a valid CRC. - * - * Reference: Dallas Semiconductor Application Note 27 - * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms", - * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd., - * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt - * - * **************************************************************************** - */ - -static const uint8 crc8_table[256] = { - 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B, - 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21, - 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF, - 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5, - 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14, - 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E, - 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80, - 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA, - 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95, - 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF, - 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01, - 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B, - 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA, - 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0, - 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E, - 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34, - 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0, - 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A, - 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54, - 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E, - 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF, - 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5, - 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B, - 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61, - 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E, - 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74, - 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA, - 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0, - 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41, - 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B, - 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5, - 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F -}; - -#define CRC_INNER_LOOP(n, c, x) \ - (c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff] - -uint8 -hndcrc8( - uint8 *pdata, /* pointer to array of data to process */ - uint nbytes, /* number of input data bytes to process */ - uint8 crc /* either CRC8_INIT_VALUE or previous return value */ -) -{ - /* hard code the crc loop instead of using CRC_INNER_LOOP macro - * to avoid the undefined and unnecessary (uint8 >> 8) operation. - */ - while (nbytes-- > 0) - crc = crc8_table[(crc ^ *pdata++) & 0xff]; - - return crc; -} - -/******************************************************************************* - * crc16 - * - * Computes a crc16 over the input data using the polynomial: - * - * x^16 + x^12 +x^5 + 1 - * - * The caller provides the initial value (either CRC16_INIT_VALUE - * or the previous returned value) to allow for processing of - * discontiguous blocks of data. When generating the CRC the - * caller is responsible for complementing the final return value - * and inserting it into the byte stream. When checking, a final - * return value of CRC16_GOOD_VALUE indicates a valid CRC. - * - * Reference: Dallas Semiconductor Application Note 27 - * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms", - * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd., - * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt - * - * **************************************************************************** - */ - -static const uint16 crc16_table[256] = { - 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, - 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7, - 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E, - 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876, - 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD, - 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5, - 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C, - 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974, - 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB, - 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3, - 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A, - 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72, - 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9, - 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1, - 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738, - 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70, - 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7, - 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF, - 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036, - 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E, - 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5, - 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD, - 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134, - 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C, - 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3, - 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB, - 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232, - 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A, - 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1, - 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9, - 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330, - 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78 -}; - -uint16 -hndcrc16( - uint8 *pdata, /* pointer to array of data to process */ - uint nbytes, /* number of input data bytes to process */ - uint16 crc /* either CRC16_INIT_VALUE or previous return value */ -) -{ - while (nbytes-- > 0) - CRC_INNER_LOOP(16, crc, *pdata++); - return crc; -} - -static const uint32 crc32_table[256] = { - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, - 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, - 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, - 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, - 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, - 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, - 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, - 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, - 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, - 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, - 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, - 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, - 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, - 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, - 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, - 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, - 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, - 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, - 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, - 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, - 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, - 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, - 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, - 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, - 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, - 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, - 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, - 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, - 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, - 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, - 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, - 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, - 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -}; - -/* - * crc input is CRC32_INIT_VALUE for a fresh start, or previous return value if - * accumulating over multiple pieces. - */ -uint32 -hndcrc32(uint8 *pdata, uint nbytes, uint32 crc) -{ - uint8 *pend; -#ifdef __mips__ - uint8 tmp[4]; - ulong *tptr = (ulong *)tmp; - - /* in case the beginning of the buffer isn't aligned */ - pend = (uint8 *)((uint)(pdata + 3) & 0xfffffffc); - nbytes -= (pend - pdata); - while (pdata < pend) - CRC_INNER_LOOP(32, crc, *pdata++); - - /* handle bulk of data as 32-bit words */ - pend = pdata + (nbytes & 0xfffffffc); - while (pdata < pend) { - *tptr = *(ulong *)pdata; - pdata += sizeof(ulong *); - CRC_INNER_LOOP(32, crc, tmp[0]); - CRC_INNER_LOOP(32, crc, tmp[1]); - CRC_INNER_LOOP(32, crc, tmp[2]); - CRC_INNER_LOOP(32, crc, tmp[3]); - } - - /* 1-3 bytes at end of buffer */ - pend = pdata + (nbytes & 0x03); - while (pdata < pend) - CRC_INNER_LOOP(32, crc, *pdata++); -#else - pend = pdata + nbytes; - while (pdata < pend) - CRC_INNER_LOOP(32, crc, *pdata++); -#endif /* __mips__ */ - - return crc; -} - -#ifdef notdef -#define CLEN 1499 /* CRC Length */ -#define CBUFSIZ (CLEN+4) -#define CNBUFS 5 /* # of bufs */ - -void -testcrc32(void) -{ - uint j, k, l; - uint8 *buf; - uint len[CNBUFS]; - uint32 crcr; - uint32 crc32tv[CNBUFS] = - {0xd2cb1faa, 0xd385c8fa, 0xf5b4f3f3, 0x55789e20, 0x00343110}; - - ASSERT((buf = MALLOC(CBUFSIZ*CNBUFS)) != NULL); - - /* step through all possible alignments */ - for (l = 0; l <= 4; l++) { - for (j = 0; j < CNBUFS; j++) { - len[j] = CLEN; - for (k = 0; k < len[j]; k++) - *(buf + j*CBUFSIZ + (k+l)) = (j+k) & 0xff; - } - - for (j = 0; j < CNBUFS; j++) { - crcr = crc32(buf + j*CBUFSIZ + l, len[j], CRC32_INIT_VALUE); - ASSERT(crcr == crc32tv[j]); - } - } - - MFREE(buf, CBUFSIZ*CNBUFS); - return; -} -#endif /* notdef */ - -/* - * Advance from the current 1-byte tag/1-byte length/variable-length value - * triple, to the next, returning a pointer to the next. - * If the current or next TLV is invalid (does not fit in given buffer length), - * NULL is returned. - * *buflen is not modified if the TLV elt parameter is invalid, or is decremented - * by the TLV parameter's length if it is valid. - */ -bcm_tlv_t * -bcm_next_tlv(bcm_tlv_t *elt, int *buflen) -{ - int len; - - /* validate current elt */ - if (!bcm_valid_tlv(elt, *buflen)) - return NULL; - - /* advance to next elt */ - len = elt->len; - elt = (bcm_tlv_t*)(elt->data + len); - *buflen -= (2 + len); - - /* validate next elt */ - if (!bcm_valid_tlv(elt, *buflen)) - return NULL; - - return elt; -} - -/* - * Traverse a string of 1-byte tag/1-byte length/variable-length value - * triples, returning a pointer to the substring whose first element - * matches tag - */ -bcm_tlv_t * -bcm_parse_tlvs(void *buf, int buflen, uint key) -{ - bcm_tlv_t *elt; - int totlen; - - elt = (bcm_tlv_t*)buf; - totlen = buflen; - - /* find tagged parameter */ - while (totlen >= 2) { - int len = elt->len; - - /* validate remaining totlen */ - if ((elt->id == key) && (totlen >= (len + 2))) - return (elt); - - elt = (bcm_tlv_t*)((uint8*)elt + (len + 2)); - totlen -= (len + 2); - } - - return NULL; -} - -/* - * Traverse a string of 1-byte tag/1-byte length/variable-length value - * triples, returning a pointer to the substring whose first element - * matches tag. Stop parsing when we see an element whose ID is greater - * than the target key. - */ -bcm_tlv_t * -bcm_parse_ordered_tlvs(void *buf, int buflen, uint key) -{ - bcm_tlv_t *elt; - int totlen; - - elt = (bcm_tlv_t*)buf; - totlen = buflen; - - /* find tagged parameter */ - while (totlen >= 2) { - uint id = elt->id; - int len = elt->len; - - /* Punt if we start seeing IDs > than target key */ - if (id > key) - return (NULL); - - /* validate remaining totlen */ - if ((id == key) && (totlen >= (len + 2))) - return (elt); - - elt = (bcm_tlv_t*)((uint8*)elt + (len + 2)); - totlen -= (len + 2); - } - return NULL; -} - -#if defined(WLMSG_PRHDRS) || defined(WLMSG_PRPKT) || defined(WLMSG_ASSOC) || \ - defined(DHD_DEBUG) -int -bcm_format_flags(const bcm_bit_desc_t *bd, uint32 flags, char* buf, int len) -{ - int i; - char* p = buf; - char hexstr[16]; - int slen = 0, nlen = 0; - uint32 bit; - const char* name; - - if (len < 2 || !buf) - return 0; - - buf[0] = '\0'; - - for (i = 0; flags != 0; i++) { - bit = bd[i].bit; - name = bd[i].name; - if (bit == 0 && flags != 0) { - /* print any unnamed bits */ - snprintf(hexstr, 16, "0x%X", flags); - name = hexstr; - flags = 0; /* exit loop */ - } else if ((flags & bit) == 0) - continue; - flags &= ~bit; - nlen = strlen(name); - slen += nlen; - /* count btwn flag space */ - if (flags != 0) - slen += 1; - /* need NULL char as well */ - if (len <= slen) - break; - /* copy NULL char but don't count it */ - strncpy(p, name, nlen + 1); - p += nlen; - /* copy btwn flag space and NULL char */ - if (flags != 0) - p += snprintf(p, 2, " "); - len -= slen; - } - - /* indicate the str was too short */ - if (flags != 0) { - if (len < 2) - p -= 2 - len; /* overwrite last char */ - p += snprintf(p, 2, ">"); - } - - return (int)(p - buf); -} -#endif - -#if defined(WLMSG_PRHDRS) || defined(WLMSG_PRPKT) || defined(WLMSG_ASSOC) || \ - defined(DHD_DEBUG) || defined(WLMEDIA_PEAKRATE) -/* print bytes formatted as hex to a string. return the resulting string length */ -int -bcm_format_hex(char *str, const void *bytes, int len) -{ - int i; - char *p = str; - const uint8 *src = (const uint8*)bytes; - - for (i = 0; i < len; i++) { - p += snprintf(p, 3, "%02X", *src); - src++; - } - return (int)(p - str); -} -#endif - -/* pretty hex print a contiguous buffer */ -void -prhex(const char *msg, uchar *buf, uint nbytes) -{ - char line[128], *p; - int len = sizeof(line); - int nchar; - uint i; - - if (msg && (msg[0] != '\0')) - printf("%s:\n", msg); - - p = line; - for (i = 0; i < nbytes; i++) { - if (i % 16 == 0) { - nchar = snprintf(p, len, " %04d: ", i); /* line prefix */ - p += nchar; - len -= nchar; - } - if (len > 0) { - nchar = snprintf(p, len, "%02x ", buf[i]); - p += nchar; - len -= nchar; - } - - if (i % 16 == 15) { - printf("%s\n", line); /* flush line */ - p = line; - len = sizeof(line); - } - } - - /* flush last partial line */ - if (p != line) - printf("%s\n", line); -} - -static const char *crypto_algo_names[] = { - "NONE", - "WEP1", - "TKIP", - "WEP128", - "AES_CCM", - "AES_OCB_MSDU", - "AES_OCB_MPDU", - "NALG" - "UNDEF", - "UNDEF", - "UNDEF", - "UNDEF" -}; - -const char * -bcm_crypto_algo_name(uint algo) -{ - return (algo < ARRAYSIZE(crypto_algo_names)) ? crypto_algo_names[algo] : "ERR"; -} - - -char * -bcm_chipname(uint chipid, char *buf, uint len) -{ - const char *fmt; - - fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ? "%d" : "%x"; - snprintf(buf, len, fmt, chipid); - return buf; -} - -/* Produce a human-readable string for boardrev */ -char * -bcm_brev_str(uint32 brev, char *buf) -{ - if (brev < 0x100) - snprintf(buf, 8, "%d.%d", (brev & 0xf0) >> 4, brev & 0xf); - else - snprintf(buf, 8, "%c%03x", ((brev & 0xf000) == 0x1000) ? 'P' : 'A', brev & 0xfff); - - return (buf); -} - -#define BUFSIZE_TODUMP_ATONCE 512 /* Buffer size */ - -/* dump large strings to console */ -void -printbig(char *buf) -{ - uint len, max_len; - char c; - - len = strlen(buf); - - max_len = BUFSIZE_TODUMP_ATONCE; - - while (len > max_len) { - c = buf[max_len]; - buf[max_len] = '\0'; - printf("%s", buf); - buf[max_len] = c; - - buf += max_len; - len -= max_len; - } - /* print the remaining string */ - printf("%s\n", buf); - return; -} - -/* routine to dump fields in a fileddesc structure */ -uint -bcmdumpfields(bcmutl_rdreg_rtn read_rtn, void *arg0, uint arg1, struct fielddesc *fielddesc_array, - char *buf, uint32 bufsize) -{ - uint filled_len; - int len; - struct fielddesc *cur_ptr; - - filled_len = 0; - cur_ptr = fielddesc_array; - - while (bufsize > 1) { - if (cur_ptr->nameandfmt == NULL) - break; - len = snprintf(buf, bufsize, cur_ptr->nameandfmt, - read_rtn(arg0, arg1, cur_ptr->offset)); - /* check for snprintf overflow or error */ - if (len < 0 || (uint32)len >= bufsize) - len = bufsize - 1; - buf += len; - bufsize -= len; - filled_len += len; - cur_ptr++; - } - return filled_len; -} - -uint -bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint buflen) -{ - uint len; - - len = strlen(name) + 1; - - if ((len + datalen) > buflen) - return 0; - - strncpy(buf, name, buflen); - - /* append data onto the end of the name string */ - memcpy(&buf[len], data, datalen); - len += datalen; - - return len; -} - -/* Quarter dBm units to mW - * Table starts at QDBM_OFFSET, so the first entry is mW for qdBm=153 - * Table is offset so the last entry is largest mW value that fits in - * a uint16. - */ - -#define QDBM_OFFSET 153 /* Offset for first entry */ -#define QDBM_TABLE_LEN 40 /* Table size */ - -/* Smallest mW value that will round up to the first table entry, QDBM_OFFSET. - * Value is ( mW(QDBM_OFFSET - 1) + mW(QDBM_OFFSET) ) / 2 - */ -#define QDBM_TABLE_LOW_BOUND 6493 /* Low bound */ - -/* Largest mW value that will round down to the last table entry, - * QDBM_OFFSET + QDBM_TABLE_LEN-1. - * Value is ( mW(QDBM_OFFSET + QDBM_TABLE_LEN - 1) + mW(QDBM_OFFSET + QDBM_TABLE_LEN) ) / 2. - */ -#define QDBM_TABLE_HIGH_BOUND 64938 /* High bound */ - -static const uint16 nqdBm_to_mW_map[QDBM_TABLE_LEN] = { -/* qdBm: +0 +1 +2 +3 +4 +5 +6 +7 */ -/* 153: */ 6683, 7079, 7499, 7943, 8414, 8913, 9441, 10000, -/* 161: */ 10593, 11220, 11885, 12589, 13335, 14125, 14962, 15849, -/* 169: */ 16788, 17783, 18836, 19953, 21135, 22387, 23714, 25119, -/* 177: */ 26607, 28184, 29854, 31623, 33497, 35481, 37584, 39811, -/* 185: */ 42170, 44668, 47315, 50119, 53088, 56234, 59566, 63096 -}; - -uint16 -bcm_qdbm_to_mw(uint8 qdbm) -{ - uint factor = 1; - int idx = qdbm - QDBM_OFFSET; - - if (idx >= QDBM_TABLE_LEN) { - /* clamp to max uint16 mW value */ - return 0xFFFF; - } - - /* scale the qdBm index up to the range of the table 0-40 - * where an offset of 40 qdBm equals a factor of 10 mW. - */ - while (idx < 0) { - idx += 40; - factor *= 10; - } - - /* return the mW value scaled down to the correct factor of 10, - * adding in factor/2 to get proper rounding. - */ - return ((nqdBm_to_mW_map[idx] + factor/2) / factor); -} - -uint8 -bcm_mw_to_qdbm(uint16 mw) -{ - uint8 qdbm; - int offset; - uint mw_uint = mw; - uint boundary; - - /* handle boundary case */ - if (mw_uint <= 1) - return 0; - - offset = QDBM_OFFSET; - - /* move mw into the range of the table */ - while (mw_uint < QDBM_TABLE_LOW_BOUND) { - mw_uint *= 10; - offset -= 40; - } - - for (qdbm = 0; qdbm < QDBM_TABLE_LEN-1; qdbm++) { - boundary = nqdBm_to_mW_map[qdbm] + (nqdBm_to_mW_map[qdbm+1] - - nqdBm_to_mW_map[qdbm])/2; - if (mw_uint < boundary) - break; - } - - qdbm += (uint8)offset; - - return (qdbm); -} - - -uint -bcm_bitcount(uint8 *bitmap, uint length) -{ - uint bitcount = 0, i; - uint8 tmp; - for (i = 0; i < length; i++) { - tmp = bitmap[i]; - while (tmp) { - bitcount++; - tmp &= (tmp - 1); - } - } - return bitcount; -} - -#ifdef BCMDRIVER - -/* Initialization of bcmstrbuf structure */ -void -bcm_binit(struct bcmstrbuf *b, char *buf, uint size) -{ - b->origsize = b->size = size; - b->origbuf = b->buf = buf; -} - -/* Buffer sprintf wrapper to guard against buffer overflow */ -int -bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...) -{ - va_list ap; - int r; - - va_start(ap, fmt); - r = vsnprintf(b->buf, b->size, fmt, ap); - - /* Non Ansi C99 compliant returns -1, - * Ansi compliant return r >= b->size, - * bcmstdlib returns 0, handle all - */ - if ((r == -1) || (r >= (int)b->size) || (r == 0)) { - b->size = 0; - } else { - b->size -= r; - b->buf += r; - } - - va_end(ap); - - return r; -} - -void -bcm_inc_bytes(uchar *num, int num_bytes, uint8 amount) -{ - int i; - - for (i = 0; i < num_bytes; i++) { - num[i] += amount; - if (num[i] >= amount) - break; - amount = 1; - } -} - -int -bcm_cmp_bytes(uchar *arg1, uchar *arg2, uint8 nbytes) -{ - int i; - - for (i = nbytes - 1; i >= 0; i--) { - if (arg1[i] != arg2[i]) - return (arg1[i] - arg2[i]); - } - return 0; -} - -void -bcm_print_bytes(char *name, const uchar *data, int len) -{ - int i; - int per_line = 0; - - printf("%s: %d \n", name ? name : "", len); - for (i = 0; i < len; i++) { - printf("%02x ", *data++); - per_line++; - if (per_line == 16) { - per_line = 0; - printf("\n"); - } - } - printf("\n"); -} -#if defined(WLTINYDUMP) || defined(WLMSG_INFORM) || defined(WLMSG_ASSOC) || \ - defined(WLMSG_PRPKT) || defined(WLMSG_WSEC) -#define SSID_FMT_BUF_LEN ((4 * DOT11_MAX_SSID_LEN) + 1) - -int -bcm_format_ssid(char* buf, const uchar ssid[], uint ssid_len) -{ - uint i, c; - char *p = buf; - char *endp = buf + SSID_FMT_BUF_LEN; - - if (ssid_len > DOT11_MAX_SSID_LEN) ssid_len = DOT11_MAX_SSID_LEN; - - for (i = 0; i < ssid_len; i++) { - c = (uint)ssid[i]; - if (c == '\\') { - *p++ = '\\'; - *p++ = '\\'; - } else if (bcm_isprint((uchar)c)) { - *p++ = (char)c; - } else { - p += snprintf(p, (endp - p), "\\x%02X", c); - } - } - *p = '\0'; - ASSERT(p < endp); - - return (int)(p - buf); -} -#endif - -#endif /* BCMDRIVER */ - -/* - * ProcessVars:Takes a buffer of "<var>=<value>\n" lines read from a file and ending in a NUL. - * also accepts nvram files which are already in the format of <var1>=<value>\0\<var2>=<value2>\0 - * Removes carriage returns, empty lines, comment lines, and converts newlines to NULs. - * Shortens buffer as needed and pads with NULs. End of buffer is marked by two NULs. -*/ - -unsigned int -process_nvram_vars(char *varbuf, unsigned int len) -{ - char *dp; - bool findNewline; - int column; - unsigned int buf_len, n; - unsigned int pad = 0; - - dp = varbuf; - - findNewline = FALSE; - column = 0; - - for (n = 0; n < len; n++) { - if (varbuf[n] == '\r') - continue; - if (findNewline && varbuf[n] != '\n') - continue; - findNewline = FALSE; - if (varbuf[n] == '#') { - findNewline = TRUE; - continue; - } - if (varbuf[n] == '\n') { - if (column == 0) - continue; - *dp++ = 0; - column = 0; - continue; - } - *dp++ = varbuf[n]; - column++; - } - buf_len = (unsigned int)(dp - varbuf); - if (buf_len % 4) { - pad = 4 - buf_len % 4; - if (pad && (buf_len + pad <= len)) { - buf_len += pad; - } - } - - while (dp < varbuf + n) - *dp++ = 0; - - return buf_len; -} diff --git a/bcm4329/dhdutil/dhdu.c b/bcm4329/dhdutil/dhdu.c deleted file mode 100644 index c20cef0..0000000 --- a/bcm4329/dhdutil/dhdu.c +++ /dev/null @@ -1,2693 +0,0 @@ -/* - * Common code for DHD command-line utility - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: dhdu.c,v 1.88.2.19 2011-01-19 23:47:10 Exp $ - */ - -/* For backwards compatibility, the absence of the define 'BWL_NO_FILESYSTEM_SUPPORT' - * implies that a filesystem is supported. - */ -#if !defined(BWL_NO_FILESYSTEM_SUPPORT) -#define BWL_FILESYSTEM_SUPPORT -#endif - -#define PROP_TXSTATUS - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <assert.h> - -#include <typedefs.h> -#include <epivers.h> -#include <proto/ethernet.h> -#include <dhdioctl.h> -#include <sdiovar.h> -#include <bcmutils.h> -#include <bcmendian.h> -#include "dhdu.h" -#include "miniopt.h" -#include <proto/bcmip.h> -#define IPV4_ADDR_LEN 4 -#include <proto/bt_amp_hci.h> - -#include <errno.h> - -#include <trxhdr.h> - -#define stricmp strcasecmp -#define strnicmp strncasecmp - - -static cmd_func_t dhd_var_void; -static cmd_func_t dhd_varint, dhd_varstr; -static cmd_func_t dhd_var_getandprintstr, dhd_var_getint, dhd_var_get; -static cmd_func_t dhd_var_setint; - -static cmd_func_t dhd_version, dhd_list, dhd_msglevel; - -#ifdef SDTEST -static cmd_func_t dhd_pktgen; -#endif -static cmd_func_t dhd_sprom; -static cmd_func_t dhd_sdreg; -static cmd_func_t dhd_sd_msglevel, dhd_sd_blocksize, dhd_sd_mode, dhd_sd_reg; -static cmd_func_t dhd_dma_mode; -static cmd_func_t dhd_membytes, dhd_download, dhd_dldn, - dhd_upload, dhd_vars, dhd_idleclock, dhd_idletime; -static cmd_func_t dhd_logstamp; - -#ifdef PROP_TXSTATUS -static cmd_func_t dhd_proptxstatusenable; -static cmd_func_t dhd_proptxstatusmode; -#endif -static int dhd_var_getbuf(void *dhd, char *iovar, void *param, int param_len, void **bufptr); -static int dhd_var_setbuf(void *dhd, char *iovar, void *param, int param_len); - -static uint dhd_iovar_mkbuf(char *name, char *data, uint datalen, - char *buf, uint buflen, int *perr); -static int dhd_iovar_getint(void *dhd, char *name, int *var); -static int dhd_iovar_setint(void *dhd, char *name, int var); - -#if defined(BWL_FILESYSTEM_SUPPORT) -static int file_size(char *fname); -static int read_vars(char *fname, char *buf, int buf_maxlen); -#endif - -static cmd_func_t wl_HCI_cmd; -static cmd_func_t wl_HCI_ACL_data; - -/* dword align allocation */ -static union { - char bufdata[DHD_IOCTL_MAXLEN]; - uint32 alignme; -} bufstruct_dhd; -static char *buf = (char*) &bufstruct_dhd.bufdata; - -/* integer output format, default to signed integer */ -static uint8 int_fmt; - -typedef struct { - uint value; - char *string; -} dbg_msg_t; - -static int dhd_do_msglevel(void *dhd, cmd_t *cmd, char **argv, dbg_msg_t *dbg_msg); - -/* Actual command table */ -cmd_t dhd_cmds[] = { - { "cmds", dhd_list, -1, -1, - "generate a short list of available commands"}, - { "version", dhd_version, DHD_GET_VAR, -1, - "get version information" }, - { "msglevel", dhd_msglevel, DHD_GET_VAR, DHD_SET_VAR, - "get/set message bits" }, - { "bcmerrorstr", dhd_var_getandprintstr, DHD_GET_VAR, -1, - "errorstring"}, - { "wdtick", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "watchdog tick time (ms units)"}, - { "intr", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "use interrupts on the bus"}, - { "pollrate", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "number of ticks between bus polls (0 means no polling)"}, - { "idletime", dhd_idletime, DHD_GET_VAR, DHD_SET_VAR, - "number of ticks for activity timeout (-1: immediate, 0: never)"}, - { "idleclock", dhd_idleclock, DHD_GET_VAR, DHD_SET_VAR, - "idleclock active | stopped | <N>\n" - "\tactive (0) - do not request any change to the SD clock\n" - "\tstopped (-1) - request SD clock be stopped on activity timeout\n" - "\t<N> (other) - an sd_divisor value to request on activity timeout\n"}, - { "sd1idle", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "change mode to SD1 when turning off clock at idle"}, - { "forceeven", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "force SD tx/rx buffers to be even"}, - { "readahead", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "enable readahead feature (look for next frame len in headers)"}, - { "sdrxchain", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "enable packet chains to SDIO stack for glom receive"}, - { "alignctl", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "align control frames"}, - { "sdalign", dhd_varint, DHD_GET_VAR, -1, - "display the (compiled in) alignment target for sd requests"}, - { "txbound", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "get/set maximum number of tx frames per scheduling"}, - { "rxbound", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "get/set maximum number of rx frames per scheduling"}, - { "txminmax", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "get/set maximum number of tx frames per scheduling while rx frames outstanding"}, - { "dconpoll", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "g/set dongle console polling interval (ms)"}, - { "dump", dhd_varstr, DHD_GET_VAR, -1, - "dump information"}, - { "cons", dhd_varstr, -1, DHD_SET_VAR, - "send string to device console (sd only)"}, - { "clearcounts", dhd_var_void, -1, DHD_SET_VAR, - "reset the bus stats shown in the dhd dump"}, - { "logdump", dhd_varstr, DHD_GET_VAR, -1, - "dump the timestamp logging buffer"}, - { "logcal", dhd_varint, -1, DHD_SET_VAR, - "logcal <n> -- log around an osl_delay of <n> usecs"}, - { "logstamp", dhd_logstamp, -1, DHD_SET_VAR, - "logstamp [<n1>] [<n2>] -- add a message to the log"}, - { "memsize", dhd_varint, DHD_GET_VAR, -1, - "display size of onchip SOCRAM"}, - { "membytes", dhd_membytes, DHD_GET_VAR, DHD_SET_VAR, - "membytes [-h | -r | -i] <address> <length> [<bytes>]\n" - "\tread or write data in the dongle ram\n" - "\t-h <bytes> is a sequence of hex digits, else a char string\n" - "\t-r output as a raw write rather than hexdump display\n"}, - { "download", dhd_download, -1, DHD_SET_VAR, - "download [-a <address>] [--noreset] [--norun] <binfile> [<varsfile>]\n" - "\tdownload file to specified dongle ram address and start CPU\n" - "\toptional vars file will replace vars parsed from the CIS\n" - "\t--noreset do not reset SOCRAM core before download\n" - "\t--norun do not start dongle CPU after download\n" - "\tdefault <address> is 0\n"}, - { "dldn", dhd_dldn, -1, DHD_SET_VAR, - "download <binfile>\n" - "\tdownload file to specified dongle ram address 0\n"}, - { "vars", dhd_vars, DHD_GET_VAR, DHD_SET_VAR, - "vars [<file>]\n" - "\toverride SPROM vars with <file> (before download)\n"}, - { "upload", dhd_upload, -1, -1, - "upload [-a <address> ] <file> [<size>]\n" - "\tupload dongle RAM content into a file\n" - "\tdefault <address> is 0, default <size> is RAM size"}, - { "srdump", dhd_sprom, DHD_GET_VAR, -1, - "display SPROM content" }, - { "srwrite", dhd_sprom, -1, DHD_SET_VAR, - "write data or file content to SPROM\n" - "\tsrwrite <word-offset> <word-value> ...\n" - "\tsrwrite [-c] <srom-file-path>\n" - "\t -c means write regardless of crc"}, - { "sleep", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "enter/exit simulated host sleep (bus powerdown w/OOB wakeup)"}, -#ifdef SDTEST - { "extloop", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "external loopback: convert all tx data to echo test frames"}, - { "pktgen", dhd_pktgen, DHD_GET_VAR, DHD_SET_VAR, - "configure/report pktgen status (SDIO)\n" - "\t-f N frequency: send/recv a burst every N ticks\n" - "\t-c N count: send/recv N packets each burst\n" - "\t-t N total: stop after a total of N packets\n" - "\t-p N print: display counts on console every N bursts\n" - "\t-m N min: set minimum length of packet data\n" - "\t-M N Max: set maximum length of packet data\n" - "\t-l N len: set fixed length of packet data\n" - "\t-s N stop after N tx failures\n" - "\t-d dir test direction/type:\n" - "\t send -- send packets discarded by dongle\n" - "\t echo -- send packets to be echoed by dongle\n" - "\t burst -- request bursts (of size <-c>) from dongle\n" - "\t one every <-f> ticks, until <-t> total requests\n" - "\t recv -- request dongle enter continuous send mode,\n" - "\t read up to <-c> pkts every <-f> ticks until <-t>\n" - "\t total reads\n"}, -#endif /* SDTEST */ - { "dngl_isolation", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "g/set dongle isolation, so the dev could be disabled with out effecting the dongle state"}, - { "sdreg", dhd_sdreg, DHD_GET_VAR, DHD_SET_VAR, - "g/set sdpcmdev core register (f1) across SDIO (CMD53)"}, - { "sbreg", dhd_sdreg, DHD_GET_VAR, DHD_SET_VAR, - "g/set any backplane core register (f1) across SDIO (CMD53)"}, - { "sd_cis", dhd_var_getandprintstr, DHD_GET_VAR, -1, - "dump sdio CIS"}, - { "sd_devreg", dhd_sd_reg, DHD_GET_VAR, DHD_SET_VAR, - "g/set device register across SDIO bus (CMD52)"}, - { "sd_hostreg", dhd_sd_reg, DHD_GET_VAR, DHD_SET_VAR, - "g/set local controller register"}, - { "sd_blocksize", dhd_sd_blocksize, DHD_GET_VAR, DHD_SET_VAR, - "g/set block size for a function"}, - { "sd_blockmode", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "g/set blockmode"}, - { "sd_ints", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "g/set client ints"}, - { "sd_dma", dhd_dma_mode, DHD_GET_VAR, DHD_SET_VAR, - "g/set dma usage: [PIO | SDMA | ADMA1 | ADMA2]"}, - { "sd_yieldcpu", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "allow blocking (yield of CPU) on data xfer"}, - { "sd_minyield", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "minimum xfer size to allow CPU yield"}, - { "sd_forcerb", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "force readback when changing local interrupt settings"}, - { "sd_numints", dhd_varint, DHD_GET_VAR, -1, - "number of device interrupts"}, - { "sd_numlocalints", dhd_varint, DHD_GET_VAR, -1, - "number of non-device interrupts"}, - { "sd_divisor", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "set the divisor for SDIO clock generation"}, - { "sd_power", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "set the SD Card slot power"}, - { "sd_clock", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "turn on/off the SD Clock"}, - { "sd_crc", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "turn on/off CRC checking in SPI mode"}, - { "sd_mode", dhd_sd_mode, DHD_GET_VAR, DHD_SET_VAR, - "g/set SDIO bus mode (spi, sd1, sd4)"}, - { "sd_highspeed", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "set the high-speed clocking mode"}, - { "sd_msglevel", dhd_sd_msglevel, DHD_GET_VAR, DHD_SET_VAR, - "g/set debug message level"}, - { "sd_hciregs", dhd_varstr, DHD_GET_VAR, -1, - "display host-controller interrupt registers"}, - { "sdiod_drive", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "SDIO Device drive strength in milliamps. (0=tri-state, 1-12mA)"}, - { "devreset", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "Move device into or out of reset state (1/reset, or 0/operational)"}, - { "ioctl_timeout", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "IOCTL response timeout (milliseconds)."}, - { "HCI_cmd", wl_HCI_cmd, -1, DHD_SET_VAR, - "carries HCI commands to the driver\n" - "\tusage: dhd HCI_cmd <command> <args>\n" }, - { "HCI_ACL_data", wl_HCI_ACL_data, -1, DHD_SET_VAR, - "carries HCI ACL data packet to the driver\n" - "\tusage: dhd HCI_ACL_data <logical link handle> <data>\n" }, -#ifdef PROP_TXSTATUS - { "proptx", dhd_proptxstatusenable, DHD_GET_VAR, DHD_SET_VAR, - "enable/disable the proptxtstatus feature\n" - "0 - disabled\n" - "1 - enabled\n"}, - { "ptxmode", dhd_proptxstatusmode, DHD_GET_VAR, DHD_SET_VAR, - "set the proptxtstatus operation mode:\n" - "0 - Unsupported\n" - "1 - Use implied credit from a packet status\n" - "2 - Use explicit credit\n" }, -#endif - { "sd_uhsimode", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "g/set UHSI Mode"}, -#ifdef WLMEDIA_HTSF - { "pktdlystatsz", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "Specify the size of the delay statistics buffer\n" - "0 - disable"}, -#endif - { "hsicsleep", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "sleep/wake HSIC bus"}, - { "changemtu", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "change the size of the mtu during runtime <1500-1752> Bytes\n"}, - { "hsicautosleep", dhd_varint, DHD_GET_VAR, DHD_SET_VAR, - "Enable/Disable HSIC bus automatic sleep/resume feature"}, - { NULL, NULL, 0, 0, NULL } -}; - -cmd_t dhd_varcmd = {"var", dhd_varint, -1, -1, "unrecognized name, type -h for help"}; -char *dhdu_av0; - -#if defined(BWL_FILESYSTEM_SUPPORT) -static int -file_size(char *fname) -{ - FILE *fp; - long size = -1; - - /* Can't use stat() because of Win CE */ - - if ((fp = fopen(fname, "rb")) == NULL || - fseek(fp, 0, SEEK_END) < 0 || - (size = ftell(fp)) < 0) - fprintf(stderr, "Could not determine size of %s: %s\n", - fname, strerror(errno)); - - if (fp != NULL) - fclose(fp); - - return (int)size; -} -#endif /* BWL_FILESYSTEM_SUPPORT */ - - -/* parse/validate the command line arguments */ -/* -* pargv is updated upon return if the first argument is an option. - * It remains intact otherwise. - */ -int -dhd_option(char ***pargv, char **pifname, int *phelp) -{ - char *ifname = NULL; - int help = FALSE; - int status = CMD_OPT; - char **argv = *pargv; - - int_fmt = INT_FMT_DEC; - - while (*argv) { - /* select different adapter */ - if (!strcmp(*argv, "-a") || !strcmp(*argv, "-i")) { - char *opt = *argv++; - ifname = *argv; - if (!ifname) { - fprintf(stderr, - "error: expected interface name after option %s\n", opt); - status = CMD_ERR; - break; - } - } - - /* integer output format */ - else if (!strcmp(*argv, "-d")) - int_fmt = INT_FMT_DEC; - else if (!strcmp(*argv, "-u")) - int_fmt = INT_FMT_UINT; - else if (!strcmp(*argv, "-x")) - int_fmt = INT_FMT_HEX; - - /* command usage */ - else if (!strcmp(*argv, "-h")) - help = TRUE; - - /* done with generic options */ - else { - status = CMD_DHD; - break; - } - - /* consume the argument */ - argv ++; - break; - } - - *phelp = help; - *pifname = ifname; - *pargv = argv; - - return status; -} - -void -dhd_cmd_usage(cmd_t *cmd) -{ - if (strlen(cmd->name) >= 8) - fprintf(stderr, "%s\n\t%s\n\n", cmd->name, cmd->help); - else - fprintf(stderr, "%s\t%s\n\n", cmd->name, cmd->help); -} - -/* Dump out short list of commands */ -static int -dhd_list(void *dhd, cmd_t *garb, char **argv) -{ - cmd_t *cmd; - int nrows, i, len; - char *buf; - int letter, col, row, pad; - - UNUSED_PARAMETER(dhd); - UNUSED_PARAMETER(garb); - UNUSED_PARAMETER(argv); - - for (cmd = dhd_cmds, nrows = 0; cmd->name; cmd++) - nrows++; - - nrows /= 4; - nrows++; - - len = nrows * 80 + 2; - buf = malloc(len); - if (buf == NULL) { - fprintf(stderr, "Failed to allocate buffer of %d bytes\n", len); - return COMMAND_ERROR; - } - for (i = 0; i < len; i++) - *(buf+i) = 0; - - row = col = 0; - for (letter = 'a'; letter < 'z'; letter++) { - for (cmd = dhd_cmds; cmd->name; cmd++) { - if (cmd->name[0] == letter || cmd->name[0] == letter - 0x20) { - strcat(buf+row*80, cmd->name); - pad = 18 * (col + 1) - strlen(buf+row*80); - if (pad < 1) - pad = 1; - for (; pad; pad--) - strcat(buf+row*80, " "); - row++; - if (row == nrows) { - col++; row = 0; - } - } - } - } - for (row = 0; row < nrows; row++) - printf("%s\n", buf+row*80); - - printf("\n"); - free(buf); - return (0); -} - -void -dhd_cmds_usage(cmd_t *port_cmds) -{ - cmd_t *port_cmd; - cmd_t *cmd; - - /* print usage of port commands */ - for (port_cmd = port_cmds; port_cmd && port_cmd->name; port_cmd++) - /* Check for wc_cmd */ - dhd_cmd_usage(port_cmd); - - /* print usage of common commands without port counterparts */ - for (cmd = dhd_cmds; cmd->name; cmd++) { - /* search if port counterpart exists */ - for (port_cmd = port_cmds; port_cmd && port_cmd->name; port_cmd++) - if (!strcmp(port_cmd->name, cmd->name)) - break; - if (!port_cmd || !port_cmd->name) - dhd_cmd_usage(cmd); - } -} - -void -dhd_usage(cmd_t *port_cmds) -{ - fprintf(stderr, - "Usage: %s [-a|i <adapter>] [-h] [-d|u|x] <command> [arguments]\n", - dhdu_av0); - - fprintf(stderr, "\n"); - fprintf(stderr, " -h this message\n"); - fprintf(stderr, " -a, -i adapter name or number\n"); - fprintf(stderr, " -d display values as signed integer\n"); - fprintf(stderr, " -u display values as unsigned integer\n"); - fprintf(stderr, " -x display values as hexdecimal\n"); - fprintf(stderr, "\n"); - - dhd_cmds_usage(port_cmds); -} - -int -dhd_check(void *dhd) -{ - int ret; - int val; - - if ((ret = dhd_get(dhd, DHD_GET_MAGIC, &val, sizeof(int)) < 0)) - return ret; - if (val != DHD_IOCTL_MAGIC) - return -1; - if ((ret = dhd_get(dhd, DHD_GET_VERSION, &val, sizeof(int)) < 0)) - return ret; - if (val > DHD_IOCTL_VERSION) { - fprintf(stderr, "Version mismatch, please upgrade\n"); - return -1; - } - return 0; -} - -void -dhd_printint(int val) -{ - switch (int_fmt) { - case INT_FMT_UINT: - printf("%u\n", val); - break; - case INT_FMT_HEX: - printf("0x%x\n", val); - break; - case INT_FMT_DEC: - default: - printf("%d\n", val); - break; - } -} - -/* pretty hex print a contiguous buffer (tweaked from wlu) */ -void -dhd_hexdump(uchar *buf, uint nbytes, uint saddr) -{ - char line[256]; - char* p; - uint i; - - if (nbytes == 0) { - printf("\n"); - return; - } - - p = line; - for (i = 0; i < nbytes; i++) { - if (i % 16 == 0) { - p += sprintf(p, "%08x: ", saddr + i); /* line prefix */ - } - p += sprintf(p, "%02x ", buf[i]); - if (i % 16 == 15) { - uint j; - p += sprintf(p, " "); - for (j = i-15; j <= i; j++) - p += sprintf(p, "%c", - ((buf[j] >= 0x20 && buf[j] <= 0x7f) ? buf[j] : '.')); - printf("%s\n", line); /* flush line */ - p = line; - } - } - - /* flush last partial line */ - if (p != line) - printf("%s\n", line); -} - - -#ifdef SDTEST -static int -dhd_pktgen(void *dhd, cmd_t *cmd, char **argv) -{ - int ret = 0; - void *ptr = NULL; - dhd_pktgen_t pktgen; - char *str; - - UNUSED_PARAMETER(dhd); - UNUSED_PARAMETER(cmd); - - /* Get current settings */ - if ((ret = dhd_var_getbuf(dhd, "pktgen", NULL, 0, &ptr)) != 0) - return ret; - memcpy(&pktgen, ptr, sizeof(pktgen)); - - if (pktgen.version != DHD_PKTGEN_VERSION) { - fprintf(stderr, "pktgen version mismatch (module %d app %d)\n", - pktgen.version, DHD_PKTGEN_VERSION); - return COMMAND_ERROR; - } - - /* Presence of args implies a set, else a get */ - if (*++argv) { - miniopt_t opts; - int opt_err; - - /* Initialize option parser */ - miniopt_init(&opts, "pktgen", "", FALSE); - - while ((opt_err = miniopt(&opts, argv)) != -1) { - if (opt_err == 1) { - fprintf(stderr, "pktgen options error\n"); - ret = -1; - goto exit; - } - argv += opts.consumed; - - if (!opts.good_int && opts.opt != 'd') { - fprintf(stderr, "invalid integer %s\n", opts.valstr); - ret = -1; - goto exit; - } - - switch (opts.opt) { - case 'f': - pktgen.freq = opts.uval; - break; - case 'c': - pktgen.count = opts.uval; - break; - case 'p': - pktgen.print = opts.uval; - break; - case 't': - pktgen.total = opts.uval; - break; - case 's': - pktgen.stop = opts.uval; - break; - case 'm': - pktgen.minlen = opts.uval; - break; - case 'M': - pktgen.maxlen = opts.uval; - break; - case 'l': case 'L': - pktgen.minlen = pktgen.maxlen = opts.uval; - break; - case 'd': - if (!strcmp(opts.valstr, "send")) - pktgen.mode = DHD_PKTGEN_SEND; - else if (!strcmp(opts.valstr, "echo")) - pktgen.mode = DHD_PKTGEN_ECHO; - else if (!strcmp(opts.valstr, "burst")) - pktgen.mode = DHD_PKTGEN_RXBURST; - else if (!strcmp(opts.valstr, "recv")) - pktgen.mode = DHD_PKTGEN_RECV; - else { - fprintf(stderr, "unrecognized dir mode %s\n", - opts.valstr); - return USAGE_ERROR; - } - break; - - default: - fprintf(stderr, "option parsing error (key %s valstr %s)\n", - opts.key, opts.valstr); - ret = USAGE_ERROR; - goto exit; - } - } - - if (pktgen.maxlen < pktgen.minlen) { - fprintf(stderr, "min/max error (%d/%d)\n", pktgen.minlen, pktgen.maxlen); - ret = -1; - goto exit; - } - - /* Set the new values */ - ret = dhd_var_setbuf(dhd, "pktgen", &pktgen, sizeof(pktgen)); - } else { - printf("Counts: %d send attempts, %d received, %d tx failures\n", - pktgen.numsent, pktgen.numrcvd, pktgen.numfail); - } - - /* Show configuration in either case */ - switch (pktgen.mode) { - case DHD_PKTGEN_ECHO: str = "echo"; break; - case DHD_PKTGEN_SEND: str = "send"; break; - case DHD_PKTGEN_RECV: str = "recv"; break; - case DHD_PKTGEN_RXBURST: str = "burst"; break; - default: str = "UNKNOWN"; break; - } - - printf("Config: mode %s %d pkts (len %d-%d) each %d ticks\n", - str, pktgen.count, pktgen.minlen, pktgen.maxlen, pktgen.freq); - - /* Second config line for optional items */ - str = " "; - if (pktgen.total) { - printf("%slimit %d", str, pktgen.total); - str = ", "; - } - if (pktgen.print) { - printf("%sprint every %d ticks", str, (pktgen.freq * pktgen.print)); - str = ", "; - } - if (pktgen.stop) { - printf("%sstop after %d tx failures", str, pktgen.stop); - str = ", "; - } - if (str[0] == ',') - printf("\n"); - -exit: - return ret; -} -#endif /* SDTEST */ - -static dbg_msg_t dhd_sd_msgs[] = { - {SDH_ERROR_VAL, "error"}, - {SDH_TRACE_VAL, "trace"}, - {SDH_INFO_VAL, "info"}, - {SDH_DATA_VAL, "data"}, - {SDH_CTRL_VAL, "control"}, - {SDH_LOG_VAL, "log"}, - {SDH_DMA_VAL, "dma"}, - {0, NULL} -}; - -static int -dhd_sd_msglevel(void *dhd, cmd_t *cmd, char **argv) -{ - return dhd_do_msglevel(dhd, cmd, argv, dhd_sd_msgs); -} - -static int -dhd_sd_blocksize(void *dhd, cmd_t *cmd, char **argv) -{ - int ret; - int argc; - char *endptr = NULL; - void *ptr = NULL; - int func, size; - - /* arg count */ - for (argc = 0; argv[argc]; argc++); - argc--; - - if (argc < 1 || argc > 2) { - printf("required args: function [size] (size 0 means max)\n"); - return USAGE_ERROR; - } - - func = strtol(argv[1], &endptr, 0); - if (*endptr != '\0') { - printf("Invalid function: %s\n", argv[1]); - return USAGE_ERROR; - } - - if (argc > 1) { - size = strtol(argv[2], &endptr, 0); - if (*endptr != '\0') { - printf("Invalid size: %s\n", argv[1]); - return USAGE_ERROR; - } - } - - if (argc == 1) { - if ((ret = dhd_var_getbuf(dhd, cmd->name, &func, sizeof(func), &ptr)) >= 0) - printf("Function %d block size: %d\n", func, *(int*)ptr); - } else { - printf("Setting function %d block size to %d\n", func, size); - size &= 0x0000ffff; size |= (func << 16); - ret = dhd_var_setbuf(dhd, cmd->name, &size, sizeof(size)); - } - - return (ret); -} - -static int -dhd_sd_mode(void *wl, cmd_t *cmd, char **argv) -{ - int ret; - int argc; - int sdmode; - - /* arg count */ - for (argc = 0; argv[argc]; argc++); - argc--; - - if (argv[1]) { - if (!strcmp(argv[1], "spi")) { - strcpy(argv[1], "0"); - } else if (!strcmp(argv[1], "sd1")) { - strcpy(argv[1], "1"); - } else if (!strcmp(argv[1], "sd4")) { - strcpy(argv[1], "2"); - } else { - return USAGE_ERROR; - } - - ret = dhd_var_setint(wl, cmd, argv); - - } else { - if ((ret = dhd_var_get(wl, cmd, argv))) { - return (ret); - } else { - sdmode = *(int32*)buf; - - printf("SD Mode is: %s\n", - sdmode == 0 ? "SPI" - : sdmode == 1 ? "SD1" - : sdmode == 2 ? "SD4" : "Unknown"); - } - } - - return (ret); -} - -static int -dhd_dma_mode(void *wl, cmd_t *cmd, char **argv) -{ - int ret; - int argc; - int dmamode; - - /* arg count */ - for (argc = 0; argv[argc]; argc++); - argc--; - - if (argv[1]) { - if (!stricmp(argv[1], "pio")) { - strcpy(argv[1], "0"); - } else if (!strcmp(argv[1], "0")) { - } else if (!stricmp(argv[1], "dma")) { - strcpy(argv[1], "1"); - } else if (!stricmp(argv[1], "sdma")) { - strcpy(argv[1], "1"); - } else if (!strcmp(argv[1], "1")) { - } else if (!stricmp(argv[1], "adma1")) { - strcpy(argv[1], "2"); - } else if (!stricmp(argv[1], "adma")) { - strcpy(argv[1], "3"); - } else if (!stricmp(argv[1], "adma2")) { - strcpy(argv[1], "3"); - } else { - return USAGE_ERROR; - } - - ret = dhd_var_setint(wl, cmd, argv); - - } else { - if ((ret = dhd_var_get(wl, cmd, argv))) { - return (ret); - } else { - dmamode = *(int32*)buf; - - printf("DMA Mode is: %s\n", - dmamode == 0 ? "PIO" - : dmamode == 1 ? "SDMA" - : dmamode == 2 ? "ADMA1" - : dmamode == 3 ? "ADMA2" - : "Unknown"); - } - } - - return (ret); -} - - -static int -dhd_sdreg(void *dhd, cmd_t *cmd, char **argv) -{ - int ret; - sdreg_t sdreg; - uint argc; - char *ptr = NULL; - - UNUSED_PARAMETER(cmd); - - bzero(&sdreg, sizeof(sdreg)); - - /* arg count */ - for (argc = 0; argv[argc]; argc++); - argc--; - - /* required args: offset (will default size) */ - if (argc < 1) { - printf("required args: offset[/size] [value]\n"); - return USAGE_ERROR; - } - - sdreg.offset = strtoul(argv[1], &ptr, 0); - if (*ptr && *ptr != '/') { - printf("Bad arg: %s\n", argv[1]); - return USAGE_ERROR; - } - - /* read optional /size */ - if (*ptr == '/') { - sdreg.func = strtol((ptr+1), &ptr, 0); - if (*ptr || ((sdreg.func != 2) && sdreg.func != 4)) { - printf("Bad size option?\n"); - return USAGE_ERROR; - } - } - else { - sdreg.func = 4; - printf("Defaulting to register size 4\n"); - } - - if (argc > 1) { - sdreg.value = strtoul(argv[2], &ptr, 0); - if (*ptr) { - printf("Bad value: %s\n", argv[2]); - return USAGE_ERROR; - } - } - - if (argc <= 1) { - ret = dhd_var_getbuf(dhd, argv[0], &sdreg, sizeof(sdreg), (void**)&ptr); - if (ret >= 0) - printf("0x%0*x\n", (2 * sdreg.func), *(int *)ptr); - } else { - ret = dhd_var_setbuf(dhd, argv[0], &sdreg, sizeof(sdreg)); - } - - return (ret); -} - -static int -dhd_membytes(void *dhd, cmd_t *cmd, char **argv) -{ - int ret = -1; - uint argc; - char *ptr; - int params[2]; - uint addr; - uint len; - int align; - - int rawout, hexin; - - miniopt_t opts; - int opt_err; - - /* Parse command-line options */ - miniopt_init(&opts, "membytes", "rh", FALSE); - - rawout = hexin = 0; - - argv++; - while ((opt_err = miniopt(&opts, argv)) != -1) { - if (opt_err == 1) { - fprintf(stderr, "membytes options error\n"); - ret = -1; - goto exit; - } - - if (opts.positional) - break; - - argv += opts.consumed; - - if (opts.opt == 'h') { - hexin = 1; - } else if (opts.opt == 'r') { - rawout = 1; - } else { - fprintf(stderr, "membytes command error\n"); - ret = -1; - goto exit; - } - } - - /* arg count */ - for (argc = 0; argv[argc]; argc++); - - /* required args: address size [<bytes>]] */ - if (argc < 2) { - fprintf(stderr, "required args: address size [<bytes>]\n"); - return USAGE_ERROR; - } - if (argc < 3 && hexin) { - fprintf(stderr, "missing <bytes> arg implies by -h\n"); - return USAGE_ERROR; - } - if ((argc > 2) && (rawout)) { - fprintf(stderr, "can't have input <bytes> arg with -r or -i\n"); - return USAGE_ERROR; - } - - /* read address */ - addr = strtoul(argv[0], &ptr, 0); - if (*ptr) { - fprintf(stderr, "Bad arg: %s\n", argv[0]); - return USAGE_ERROR; - } - - /* read size */ - len = strtoul(argv[1], &ptr, 0); - if (*ptr) { - fprintf(stderr, "Bad value: %s\n", argv[1]); - return USAGE_ERROR; - } - - align = addr & 0x03; - if (align && argc > 2) { - fprintf(stderr, "Can only write starting at long-aligned addresses.\n"); - return USAGE_ERROR; - } - - /* get can just use utility function, set must copy custom buffer */ - if (argc == 2) { - uint chunk = DHD_IOCTL_MAXLEN; - for (addr -= align, len += align; len; addr += chunk, len -= chunk, align = 0) { - chunk = MIN(chunk, len); - params[0] = addr; params[1] = ROUNDUP(chunk, 4); - ret = dhd_var_getbuf(dhd, "membytes", - params, (2 * sizeof(int)), (void**)&ptr); - if (ret < 0) - goto exit; - - if (rawout) { - fwrite(ptr + align, sizeof(char), chunk - align, stdout); - } else { - dhd_hexdump((uchar*)ptr + align, chunk - align, addr + align); - } - } - } else { - uint patlen = strlen(argv[2]); - uint chunk, maxchunk; - char *sptr; - - if (hexin) { - char *inptr, *outptr; - if (patlen & 1) { - fprintf(stderr, "Hex (-h) must consist of whole bytes\n"); - ret = USAGE_ERROR; - goto exit; - } - - for (inptr = outptr = argv[2]; patlen; patlen -= 2) { - int n1, n2; - - n1 = (int)((unsigned char)*inptr++); - n2 = (int)((unsigned char)*inptr++); - if (!isxdigit(n1) || !isxdigit(n2)) { - fprintf(stderr, "invalid hex digit %c\n", - (isxdigit(n1) ? n2 : n1)); - ret = USAGE_ERROR; - goto exit; - } - n1 = isdigit(n1) ? (n1 - '0') - : ((islower(n1) ? (toupper(n1)) : n1) - 'A' + 10); - n2 = isdigit(n2) ? (n2 - '0') - : ((islower(n2) ? (toupper(n2)) : n2) - 'A' + 10); - *outptr++ = (n1 * 16) + n2; - } - - patlen = outptr - argv[2]; - } - - sptr = argv[2]; - maxchunk = DHD_IOCTL_MAXLEN - (strlen(cmd->name) + 1 + (2 * sizeof(int))); - - while (len) { - chunk = (len > maxchunk) ? (maxchunk & ~0x3) : len; - - /* build the iovar command */ - memset(buf, 0, DHD_IOCTL_MAXLEN); - strcpy(buf, cmd->name); - ptr = buf + strlen(buf) + 1; - params[0] = addr; params[1] = chunk; - memcpy(ptr, params, (2 * sizeof(int))); - ptr += (2 * sizeof(int)); - addr += chunk; len -= chunk; - - while (chunk--) { - *ptr++ = *sptr++; - if (sptr >= (argv[2] + patlen)) - sptr = argv[2]; - } - - ret = dhd_set(dhd, DHD_SET_VAR, &buf[0], (ptr - buf)); - if (ret < 0) - goto exit; - } - } - -exit: - return ret; -} - -static int -dhd_idletime(void *dhd, cmd_t *cmd, char **argv) -{ - int32 idletime; - char *endptr = NULL; - int err = 0; - - if (argv[1]) { - if (!strcmp(argv[1], "never")) { - idletime = 0; - } else if (!strcmp(argv[1], "immediate") || !strcmp(argv[1], "immed")) { - idletime = DHD_IDLE_IMMEDIATE; - } else { - idletime = strtol(argv[1], &endptr, 0); - if (*endptr != '\0') { - fprintf(stderr, "invalid number %s\n", argv[1]); - err = -1; - } - } - if ((idletime < 0) && (idletime != DHD_IDLE_IMMEDIATE)) { - fprintf(stderr, "invalid value %s\n", argv[1]); - err = -1; - } - - if (!err) { - strcpy(buf, "idletime"); - endptr = buf + strlen(buf) + 1; - memcpy(endptr, &idletime, sizeof(uint32)); - endptr += sizeof(uint32); - err = dhd_set(dhd, DHD_SET_VAR, &buf[0], (endptr - buf)); - } - } else { - if ((err = dhd_var_get(dhd, cmd, argv))) { - return err; - } else { - idletime = *(int32*)buf; - - if (idletime == 0) { - printf("0 (never)\n"); - } else if (idletime == DHD_IDLE_IMMEDIATE) { - printf("-1 (immediate)\n"); - } else if (idletime > 0) { - printf("%d\n", idletime); - } else printf("%d (invalid)\n", idletime); - } - } - return err; -} - -static int -dhd_idleclock(void *dhd, cmd_t *cmd, char **argv) -{ - int32 idleclock; - char *endptr = NULL; - int err = 0; - - if (argv[1]) { - if (!strcmp(argv[1], "active")) { - idleclock = DHD_IDLE_ACTIVE; - } else if (!strcmp(argv[1], "stopped")) { - idleclock = DHD_IDLE_STOP; - } else { - idleclock = strtol(argv[1], &endptr, 0); - if (*endptr != '\0') { - fprintf(stderr, "invalid number %s\n", argv[1]); - err = USAGE_ERROR; - } - } - - if (!err) { - strcpy(buf, "idleclock"); - endptr = buf + strlen(buf) + 1; - memcpy(endptr, &idleclock, sizeof(int32)); - endptr += sizeof(int32); - err = dhd_set(dhd, DHD_SET_VAR, &buf[0], (endptr - buf)); - } - } else { - if ((err = dhd_var_get(dhd, cmd, argv))) { - return err; - } else { - idleclock = *(int32*)buf; - - if (idleclock == DHD_IDLE_ACTIVE) - printf("Idleclock %d (active)\n", idleclock); - else if (idleclock == DHD_IDLE_STOP) - printf("Idleclock %d (stopped)\n", idleclock); - else - printf("Idleclock divisor %d\n", idleclock); - } - } - return err; -} - -/* Word count for a 4kb SPROM */ -#define SPROM_WORDS 256 - -static int -dhd_sprom(void *dhd, cmd_t *cmd, char **argv) -{ -#if !defined(BWL_FILESYSTEM_SUPPORT) - return (-1); -#else - int ret, i; - uint argc; - char *endptr; - char *bufp, *countptr; - uint16 *wordptr; - uint offset, words, bytes; - bool nocrc = FALSE; - - char *fname; - FILE *fp; - - UNUSED_PARAMETER(cmd); - - /* arg count */ - for (argc = 0; argv[argc]; argc++); - argc--; - - /* init buffer */ - bufp = buf; - memset(bufp, 0, DHD_IOCTL_MAXLEN); - strcpy(bufp, "sprom"); - bufp += strlen("sprom") + 1; - - if (strcmp(argv[0], "srdump") == 0) { - if (argc) { - fprintf(stderr, "Command srdump doesn't take args\n"); - return USAGE_ERROR; - } - offset = 0; - words = SPROM_WORDS; - bytes = 2 * words; - - memcpy(bufp, &offset, sizeof(int)); - bufp += sizeof(int); - memcpy(bufp, &bytes, sizeof(int)); - bufp += sizeof(int); - - if (!ISALIGNED((uintptr)bufp, sizeof(uint16))) { - fprintf(stderr, "Internal error: unaligned word buffer\n"); - return COMMAND_ERROR; - } - } else { - if (strcmp(argv[0], "srwrite") != 0) { - fprintf(stderr, "Unimplemented sprom command: %s\n", argv[0]); - return USAGE_ERROR; - } - - if (argc == 0) { - return USAGE_ERROR; - } else if ((argc == 1) || - ((argc == 2) && ((nocrc = !strcmp(argv[1], "-c"))))) { - - fname = nocrc ? argv[2] : argv[1]; - - /* determine and validate file size */ - if ((ret = file_size(fname)) < 0) - return COMMAND_ERROR; - - bytes = ret; - offset = 0; - words = bytes / 2; - - if (bytes != 2 * SPROM_WORDS) { - fprintf(stderr, "Bad file size\n"); - return COMMAND_ERROR; - } - - memcpy(bufp, &offset, sizeof(int)); - bufp += sizeof(int); - memcpy(bufp, &bytes, sizeof(int)); - bufp += sizeof(int); - - if (!ISALIGNED((uintptr)bufp, sizeof(uint16))) { - fprintf(stderr, "Internal error: unaligned word buffer\n"); - return COMMAND_ERROR; - } - - if ((fp = fopen(fname, "rb")) == NULL) { - fprintf(stderr, "Could not open %s: %s\n", - fname, strerror(errno)); - return COMMAND_ERROR; - } - - if (fread((uint16*)bufp, sizeof(uint16), words, fp) != words) { - fprintf(stderr, "Could not read %d bytes from %s\n", - words * 2, fname); - fclose(fp); - return COMMAND_ERROR; - } - - fclose(fp); - - if (!nocrc && - hndcrc8((uint8*)bufp, bytes, CRC8_INIT_VALUE) != CRC8_GOOD_VALUE) { - fprintf(stderr, "CRC check failed: 0x%02x, should be 0x%02x.\n", - ((uint8*)bufp)[bytes-1], - ~hndcrc8((uint8*)bufp, bytes - 1, CRC8_INIT_VALUE) & 0xff); - return COMMAND_ERROR; - } - - ltoh16_buf(bufp, bytes); - } else { - offset = strtoul(*++argv, &endptr, 0) * 2; - if (*endptr != '\0') { - fprintf(stderr, "offset %s is not an integer\n", *argv); - return USAGE_ERROR; - } - - memcpy(bufp, &offset, sizeof(int)); - bufp += sizeof(int); - countptr = bufp; - bufp += sizeof(int); - - if (!ISALIGNED((uintptr)bufp, sizeof(uint16))) { - fprintf(stderr, "Internal error: unaligned word buffer\n"); - return COMMAND_ERROR; - } - - for (words = 0, wordptr = (uint16*)bufp; *++argv; words++) { - *wordptr++ = (uint16)strtoul(*argv, &endptr, 0); - if (*endptr != '\0') { - fprintf(stderr, "value %s is not an integer\n", *argv); - return USAGE_ERROR; - } - if (words > SPROM_WORDS) { - fprintf(stderr, "max of %d words\n", SPROM_WORDS); - return USAGE_ERROR; - } - } - - bytes = 2 * words; - memcpy(countptr, &bytes, sizeof(int)); - } - } - - if (argc) { - ret = dhd_set(dhd, DHD_SET_VAR, buf, - (strlen("sprom") + 1) + (2 * sizeof(int)) + bytes); - return (ret); - } else { - ret = dhd_get(dhd, DHD_GET_VAR, buf, - (strlen("sprom") + 1) + (2 * sizeof(int)) + bytes); - if (ret < 0) { - return ret; - } - - for (i = 0; i < (int)words; i++) { - if ((i % 8) == 0) - printf("\n srom[%03d]: ", i); - printf("0x%04x ", ((uint16*)buf)[i]); - } - printf("\n"); - } - - return 0; -#endif /* BWL_FILESYSTEM_SUPPORT */ -} - -/* - * read_vars: reads an environment variables file into a buffer, - * reformatting them and returning the length (-1 on error). - * - * The input text file consists of lines of the form "<var>=<value>\n". - * CRs are ignored, as are blank lines and comments beginning with '#'. - * - * The output buffer consists of blocks of the form "<var>=<value>\0" - * (the newlines have been replaced by NULs) - * - * Todo: allow quoted variable names and quoted values. -*/ - -#if defined(BWL_FILESYSTEM_SUPPORT) -static int -read_vars(char *fname, char *buf, int buf_maxlen) -{ - FILE *fp; - int buf_len, slen; - char line[256], *s, *e; - int line_no = 0; - - if ((fp = fopen(fname, "rb")) == NULL) { - fprintf(stderr, "Cannot open NVRAM file %s: %s\n", - fname, strerror(errno)); - exit(1); - } - - buf_len = 0; - - while (fgets(line, sizeof(line), fp) != NULL) { - bool found_eq = FALSE; - - /* Ensure line length is limited */ - line[sizeof(line) - 1] = 0; - - /* Skip any initial white space */ - for (s = line; *s == ' ' || *s == '\t'; s++) - ; - - /* Determine end of string */ - for (e = s; *e != 0 && *e != '#' && *e != '\r' && *e != '\n'; e++) - if (*e == '=') - found_eq = TRUE; - - /* Strip any white space from end of string */ - while (e > s && (e[-1] == ' ' || e[-1] == '\t')) - e--; - - slen = e - s; - - /* Skip lines that end up blank */ - if (slen == 0) - continue; - - if (!found_eq) { - fprintf(stderr, "Invalid line %d in NVRAM file %s\n", line_no, fname); - fclose(fp); - return -1; - } - - if (buf_len + slen + 1 > buf_maxlen) { - fprintf(stderr, "NVRAM file %s too long\n", fname); - fclose(fp); - return -1; - } - - memcpy(buf + buf_len, s, slen); - buf_len += slen; - buf[buf_len++] = 0; - } - - fclose(fp); - - return buf_len; -} -#endif /* BWL_FILESYSTEM_SUPPORT */ - -static int -dhd_vars(void *dhd, cmd_t *cmd, char **argv) -{ - int ret; - uint argc; - char *bufp; - - UNUSED_PARAMETER(cmd); - - /* arg count */ - for (argc = 0; argv[argc]; argc++); - argc--; - - switch (argc) { - case 0: /* get */ - { - if ((ret = dhd_var_getbuf(dhd, "vars", NULL, 0, (void**)&bufp))) - break; - while (*bufp) { - printf("%s\n", bufp); - bufp += strlen(bufp) + 1; - } - } - break; - -#if defined(BWL_FILESYSTEM_SUPPORT) - case 1: /* set */ - { - char *vname; - uint nvram_len; - - vname = argv[1]; - - bufp = buf; - strcpy(bufp, "vars"); - bufp += strlen("vars") + 1; - - if ((ret = read_vars(vname, bufp, - DHD_IOCTL_MAXLEN - (strlen("vars") + 3))) < 0) { - ret = -1; - break; - } - - nvram_len = ret; - bufp += nvram_len; - *bufp++ = 0; - - ret = dhd_set(dhd, DHD_SET_VAR, buf, bufp - buf); - } - break; -#endif /* BWL_FILESYSTEM_SUPPORT */ - - default: - ret = -1; - break; - } - - return ret; -} - -#define MEMBLOCK 2048 - -/* Check that strlen("membytes")+1 + 2*sizeof(int32) + MEMBLOCK <= DHD_IOCTL_MAXLEN */ -#if (MEMBLOCK + 17 > DHD_IOCTL_MAXLEN) -#error MEMBLOCK/DHD_IOCTL_MAXLEN sizing -#endif - - -#if defined(BWL_FILESYSTEM_SUPPORT) -static int -dhd_load_file_bytes(void *dhd, cmd_t *cmd, FILE *fp, int fsize, int start) -{ - int tot_len = 0; - uint read_len; - char *bufp; - uint len; - uint8 memblock[MEMBLOCK]; - int ret; - - UNUSED_PARAMETER(cmd); - - while (tot_len < fsize) { - read_len = fsize - tot_len; - if (read_len >= MEMBLOCK) - read_len = MEMBLOCK; - len = fread(memblock, sizeof(uint8), read_len, fp); - if ((len < read_len) && !feof(fp)) { - fprintf(stderr, "%s: error reading file\n", __FUNCTION__); - return -1; - - } - - bufp = buf; - memset(bufp, 0, DHD_IOCTL_MAXLEN); - strcpy(bufp, "membytes"); - bufp += strlen("membytes") + 1; - memcpy(bufp, &start, sizeof(int)); - bufp += sizeof(int); - memcpy(bufp, &len, sizeof(int)); - bufp += sizeof(int); - memcpy(bufp, memblock, len); - - ret = dhd_set(dhd, DHD_SET_VAR, &buf[0], (bufp - buf + len)); - - if (ret) { - fprintf(stderr, "%s: error %d on writing %d membytes at 0x%08x\n", - __FUNCTION__, ret, len, start); - return -1; - } - start += len; - tot_len += len; - } - return 0; -} -#endif /* BWL_FILESYSTEM_SUPPORT */ - -#ifdef PROP_TXSTATUS -static int -dhd_proptxstatusenable(void *dhd, cmd_t *cmd, char **argv) -{ - int flag = 0xdead; - - if (argv[1]) { - flag = atoi(argv[1]); - dhd_iovar_setint(dhd, cmd->name, flag); - } - else { - dhd_iovar_getint(dhd, cmd->name, &flag); - printf("proptxstatus: %d\n", flag); - } - return 0; -} - -static int -dhd_proptxstatusmode(void *dhd, cmd_t *cmd, char **argv) -{ - int mode = 0xdead; - - if (argv[1]) { - mode = atoi(argv[1]); - dhd_iovar_setint(dhd, cmd->name, mode); - } - else { - dhd_iovar_getint(dhd, cmd->name, &mode); - printf("proptxstatusmode: %d\n", mode); - } - return 0; -} -#endif /* PROP_TXSTATUS */ - -static int -dhd_download(void *dhd, cmd_t *cmd, char **argv) -{ -#if !defined(BWL_FILESYSTEM_SUPPORT) - return (-1); -#else - bool reset = TRUE; - bool run = TRUE; - char *fname = NULL; - char *vname = NULL; - uint32 start = 0; - int ret = 0; - int fsize; - FILE *fp = NULL; - uint32 memsize; - char *memszargs[] = { "memsize", NULL }; - char *bufp; - miniopt_t opts; - int opt_err; - uint nvram_len; - struct trx_header trx_hdr; - bool trx_file = FALSE; - bool overlays = FALSE; - - UNUSED_PARAMETER(cmd); - - /* Parse command-line options */ - miniopt_init(&opts, "download", "", TRUE); - - argv++; - while ((opt_err = miniopt(&opts, argv)) != -1) { - if (opt_err == 1) { - fprintf(stderr, "download options error\n"); - ret = -1; - goto exit; - } - argv += opts.consumed; - - if (opts.opt == 'a') { - if (!opts.good_int) { - fprintf(stderr, "invalid address %s\n", opts.valstr); - ret = -1; - goto exit; - } - start = (uint32)opts.uval; - } else if (opts.positional) { - if (fname && vname) { - fprintf(stderr, "extra positional arg, %s\n", - opts.valstr); - ret = -1; - goto exit; - } - if (fname) - vname = opts.valstr; - else - fname = opts.valstr; - } else if (!opts.opt) { - if (!strcmp(opts.key, "noreset")) { - reset = FALSE; - } else if (!strcmp(opts.key, "norun")) { - run = FALSE; - } else { - fprintf(stderr, "unrecognized option %s\n", opts.valstr); - ret = -1; - goto exit; - } - } else { - fprintf(stderr, "unrecognized option %c\n", opts.opt); - ret = -1; - goto exit; - } - } - - /* validate arguments */ - if (!fname) { - fprintf(stderr, "filename required\n"); - ret = -1; - goto exit; - } - - /* validate file size compared to memory size */ - if ((fsize = file_size(fname)) < 0) { - ret = -1; - goto exit; - } - /* read the file and push blocks down to memory */ - if ((fp = fopen(fname, "rb")) == NULL) { - fprintf(stderr, "%s: unable to open %s: %s\n", - __FUNCTION__, fname, strerror(errno)); - ret = -1; - goto exit; - } - /* Verify the file is a regular bin file or trx file */ - { - uint32 tmp_len; - uint32 trx_hdr_len = sizeof(struct trx_header); - tmp_len = fread(&trx_hdr, sizeof(uint8), trx_hdr_len, fp); - if (tmp_len == trx_hdr_len) { - if (trx_hdr.magic == TRX_MAGIC) { - trx_file = TRUE; - if (trx_hdr.flag_version & TRX_OVERLAYS) { - fprintf(stderr, "Image contains overlays but overlays " - "not supported by this command\n"); - ret = BCME_UNSUPPORTED; - goto exit; - } else { - } - } - else - fseek(fp, 0, SEEK_SET); - } - else - fseek(fp, 0, SEEK_SET); - } - - if ((ret = dhd_var_get(dhd, NULL, memszargs))) { - fprintf(stderr, "%s: error obtaining memsize\n", __FUNCTION__); - goto exit; - } - - memsize = *(uint32*)buf; - -#ifdef PART_OF_RAM_AS_ROMSIM - /* only useful for cases where you want to sim some RAM as ROM */ - if (memsize && ((uint32)fsize > memsize)) { - fprintf(stderr, "%s: file %s too large (%d > %d)\n", - __FUNCTION__, fname, fsize, memsize); - ret = -1; - goto exit; - } -#endif /* PART_OF_RAM_AS_ROMSIM */ - - /* do the download reset if not suppressed */ - if (reset) { - if ((ret = dhd_iovar_setint(dhd, "download", TRUE))) { - fprintf(stderr, "%s: failed to put dongle in download mode\n", - __FUNCTION__); - goto exit; - } - } - - if (trx_file) - fsize = trx_hdr.offsets[0]; - - /* Load the ram image */ - if (dhd_load_file_bytes(dhd, cmd, fp, fsize, start)) { - fprintf(stderr, "%s: error loading the ramimage at addr 0x%x\n", - __FUNCTION__, start); - ret = -1; - goto exit; - } - - if (trx_file) { - if (overlays) { - } else { - } - } - - fclose(fp); - fp = NULL; - - /* download the vars file if specified */ - if (vname) { - bufp = buf; - strcpy(bufp, "vars"); - bufp += strlen("vars") + 1; - - if ((ret = read_vars(vname, bufp, - DHD_IOCTL_MAXLEN - (strlen("vars") + 3))) < 0) { - ret = -1; - goto exit; - } - - nvram_len = ret; - bufp += nvram_len; - *bufp++ = 0; - - ret = dhd_set(dhd, DHD_SET_VAR, buf, (bufp - buf)); - if (ret) { - fprintf(stderr, "%s: error %d on delivering vars\n", - __FUNCTION__, ret); - goto exit; - } - } - - /* start running the downloaded code if not suppressed */ - if (run) { - if ((ret = dhd_iovar_setint(dhd, "download", FALSE))) { - fprintf(stderr, "%s: failed to take dongle out of download mode\n", - __FUNCTION__); - goto exit; - } - } - -exit: - if (fp) - fclose(fp); - - - return ret; -#endif /* BWL_FILESYSTEM_SUPPORT */ -} - -static int -dhd_dldn(void *dhd, cmd_t *cmd, char **argv) -{ -#if !defined(BWL_FILESYSTEM_SUPPORT) - return (-1); -#else - char *fname = NULL; - uint32 start = 0; - int ret = 0; - int fsize; - int fd = 0; - - FILE *fp = NULL; - uint32 memsize; - - uint len; - uint8 memblock[MEMBLOCK]; - - miniopt_t opts; - int opt_err; - - UNUSED_PARAMETER(cmd); - - /* Parse command-line options */ - miniopt_init(&opts, "download", "", TRUE); - argv++; - - while ((opt_err = miniopt(&opts, argv)) != -1) { - if (opt_err == 1) { - fprintf(stderr, "download options error\n"); - ret = -1; - goto exit; - } - argv += opts.consumed; - - if (opts.positional) { - if (fname) { - fprintf(stderr, "extra positional arg, %s\n", - opts.valstr); - ret = -1; - goto exit; - } - if (!fname) - fname = opts.valstr; - } else { - fprintf(stderr, "unrecognized option %c\n", opts.opt); - ret = -1; - goto exit; - } - } - - fd = dhd_set(dhd, DHD_DLDN_ST, NULL, 0); - if (fd < 0) { - ret = -1; - goto exit; - } - - /* validate arguments */ - if (!fname) { - fprintf(stderr, "filename required\n"); - ret = -1; - goto exit; - } - - /* validate file size compared to memory size */ - if ((fsize = file_size(fname)) < 0) { - ret = -1; - goto exit; - } - - memsize = 393216; - - if (memsize && ((uint32)fsize > memsize)) { - fprintf(stderr, "%s: file %s too large (%d > %d)\n", - __FUNCTION__, fname, fsize, memsize); - ret = -1; - goto exit; - } - - /* read the file and push blocks down to memory */ - if ((fp = fopen(fname, "rb")) == NULL) { - fprintf(stderr, "%s: unable to open %s: %s\n", - __FUNCTION__, fname, strerror(errno)); - ret = -1; - goto exit; - } - - while ((len = fread(memblock, sizeof(uint8), MEMBLOCK, fp))) { - if (len < MEMBLOCK && !feof(fp)) { - fprintf(stderr, "%s: error reading file %s\n", __FUNCTION__, fname); - ret = -1; - goto exit; - } - - ret = dhd_set(dhd, DHD_DLDN_WRITE, memblock, len); - if (ret) { - fprintf(stderr, "%s: error %d on writing %d membytes at 0x%08x\n", - __FUNCTION__, ret, len, start); - goto exit; - } - - start += len; - } - - if (!feof(fp)) { - fprintf(stderr, "%s: error reading file %s\n", __FUNCTION__, fname); - ret = -1; - goto exit; - } - fclose(fp); - fp = NULL; - -exit: - if (fp) - fclose(fp); - - if (fd) - dhd_set(dhd, DHD_DLDN_END, NULL, 0); - - return ret; -#endif /* BWL_FILESYSTEM_SUPPORT */ -} - -static int -dhd_upload(void *dhd, cmd_t *cmd, char **argv) -{ -#if !defined(BWL_FILESYSTEM_SUPPORT) - return (-1); -#else - char *fname = NULL; - uint32 start = 0; - uint32 size = 0; - int ret = 0; - - FILE *fp; - uint32 memsize; - char *memszargs[] = { "memsize", NULL }; - - uint len; - - miniopt_t opts; - int opt_err; - - UNUSED_PARAMETER(cmd); - UNUSED_PARAMETER(argv); - - /* Parse command-line options */ - miniopt_init(&opts, "upload", "", TRUE); - - argv++; - while ((opt_err = miniopt(&opts, argv)) != -1) { - if (opt_err == 1) { - fprintf(stderr, "upload options error\n"); - ret = -1; - goto exit; - } - argv += opts.consumed; - - if (opts.opt == 'a') { - if (!opts.good_int) { - fprintf(stderr, "invalid address %s\n", opts.valstr); - ret = -1; - goto exit; - } - start = (uint32)opts.uval; - } else if (opts.positional) { - if (!fname) { - fname = opts.valstr; - } else if (opts.good_int) { - size = (uint32)opts.uval; - } else { - fprintf(stderr, "upload options error\n"); - ret = -1; - goto exit; - } - } else if (!opts.opt) { - fprintf(stderr, "unrecognized option %s\n", opts.valstr); - ret = -1; - goto exit; - } else { - fprintf(stderr, "unrecognized option %c\n", opts.opt); - ret = -1; - goto exit; - } - } - - /* validate arguments */ - if (!fname) { - fprintf(stderr, "filename required\n"); - ret = -1; - goto exit; - } - - if ((ret = dhd_var_get(dhd, NULL, memszargs))) { - fprintf(stderr, "%s: error obtaining memsize\n", __FUNCTION__); - goto exit; - } - memsize = *(uint32*)buf; - - if (!memsize) - memsize = start + size; - - if (start + size > memsize) { - fprintf(stderr, "%s: %d bytes at 0x%x exceeds ramsize 0x%x\n", - __FUNCTION__, size, start, memsize); - ret = -1; - goto exit; - } - - if ((fp = fopen(fname, "wb")) == NULL) { - fprintf(stderr, "%s: Could not open %s: %s\n", - __FUNCTION__, fname, strerror(errno)); - ret = -1; - goto exit; - } - - /* default size to full RAM */ - if (!size) - size = memsize - start; - - /* read memory and write to file */ - while (size) { - char *ptr; - int params[2]; - - len = MIN(MEMBLOCK, size); - - params[0] = start; - params[1] = len; - ret = dhd_var_getbuf(dhd, "membytes", params, 2 * sizeof(int), (void**)&ptr); - if (ret) { - fprintf(stderr, "%s: failed reading %d membytes from 0x%08x\n", - __FUNCTION__, len, start); - break; - } - - if (fwrite(ptr, sizeof(*ptr), len, fp) != len) { - fprintf(stderr, "%s: error writing to file %s\n", __FUNCTION__, fname); - ret = -1; - break; - } - - start += len; - size -= len; - } - - fclose(fp); -exit: - return ret; -#endif /* BWL_FILESYSTEM_SUPPORT */ -} - -static int -dhd_logstamp(void *dhd, cmd_t *cmd, char **argv) -{ - int ret; - char *endptr = NULL; - uint argc; - int valn[2] = {0, 0}; - - /* arg count */ - for (argc = 0; argv[argc]; argc++); - argc--; argv++; - - if (argc > 2) - return USAGE_ERROR; - - if (argc) { - valn[0] = strtol(argv[0], &endptr, 0); - if (*endptr != '\0') { - printf("bad val1: %s\n", argv[0]); - return USAGE_ERROR; - } - } - - if (argc > 1) { - valn[1] = strtol(argv[1], &endptr, 0); - if (*endptr != '\0') { - printf("bad val2: %s\n", argv[1]); - return USAGE_ERROR; - } - } - - ret = dhd_var_setbuf(dhd, cmd->name, valn, argc * sizeof(int)); - - return (ret); -} - -static int -dhd_sd_reg(void *dhd, cmd_t *cmd, char **argv) -{ - int ret; - sdreg_t sdreg; - char *endptr = NULL; - uint argc; - void *ptr = NULL; - - bzero(&sdreg, sizeof(sdreg)); - - /* arg count */ - for (argc = 0; argv[argc]; argc++); - argc--; - - /* hostreg: offset [value]; devreg: func offset [value] */ - if (!strcmp(cmd->name, "sd_hostreg")) { - argv++; - if (argc < 1) { - printf("required args: offset [value]\n"); - return USAGE_ERROR; - } - - } else if (!strcmp(cmd->name, "sd_devreg")) { - argv++; - if (argc < 2) { - printf("required args: func offset [value]\n"); - return USAGE_ERROR; - } - - sdreg.func = strtoul(*argv++, &endptr, 0); - if (*endptr != '\0') { - printf("Invalid function number\n"); - return USAGE_ERROR; - } - } else { - return USAGE_ERROR; - } - - sdreg.offset = strtoul(*argv++, &endptr, 0); - if (*endptr != '\0') { - printf("Invalid offset value\n"); - return USAGE_ERROR; - } - - /* third arg: value */ - if (*argv) { - sdreg.value = strtoul(*argv, &endptr, 0); - if (*endptr != '\0') { - printf("Invalid value\n"); - return USAGE_ERROR; - } - } - - /* no third arg means get, otherwise set */ - if (!*argv) { - if ((ret = dhd_var_getbuf(dhd, cmd->name, &sdreg, sizeof(sdreg), &ptr)) >= 0) - printf("0x%x\n", *(int *)ptr); - } else { - ret = dhd_var_setbuf(dhd, cmd->name, &sdreg, sizeof(sdreg)); - } - - return (ret); -} - -static dbg_msg_t dhd_msgs[] = { - {DHD_ERROR_VAL, "error"}, - {DHD_ERROR_VAL, "err"}, - {DHD_TRACE_VAL, "trace"}, - {DHD_INFO_VAL, "inform"}, - {DHD_INFO_VAL, "info"}, - {DHD_INFO_VAL, "inf"}, - {DHD_DATA_VAL, "data"}, - {DHD_CTL_VAL, "ctl"}, - {DHD_TIMER_VAL, "timer"}, - {DHD_HDRS_VAL, "hdrs"}, - {DHD_BYTES_VAL, "bytes"}, - {DHD_INTR_VAL, "intr"}, - {DHD_LOG_VAL, "log"}, - {DHD_GLOM_VAL, "glom"}, - {DHD_EVENT_VAL, "event"}, - {DHD_BTA_VAL, "bta"}, - {0, NULL} -}; - -static int -dhd_msglevel(void *dhd, cmd_t *cmd, char **argv) -{ - return dhd_do_msglevel(dhd, cmd, argv, dhd_msgs); -} - -static int -dhd_do_msglevel(void *dhd, cmd_t *cmd, char **argv, dbg_msg_t *dbg_msg) -{ - int ret, i; - uint val, last_val = 0, msglevel = 0, msglevel_add = 0, msglevel_del = 0; - char *endptr = NULL; - - if ((ret = dhd_iovar_getint(dhd, cmd->name, (int*)&msglevel)) < 0) - return (ret); - - if (!*++argv) { - printf("0x%x ", msglevel); - for (i = 0; (val = dbg_msg[i].value); i++) { - if ((msglevel & val) && (val != last_val)) - printf(" %s", dbg_msg[i].string); - last_val = val; - } - printf("\n"); - return (0); - } - - while (*argv) { - char *s = *argv; - if (*s == '+' || *s == '-') - s++; - else - msglevel_del = ~0; /* make the whole list absolute */ - val = strtoul(s, &endptr, 0); - /* not a plain integer if not all the string was parsed by strtoul */ - if (*endptr != '\0') { - for (i = 0; (val = dbg_msg[i].value); i++) - if (stricmp(dbg_msg[i].string, s) == 0) - break; - if (!val) - goto usage; - } - if (**argv == '-') - msglevel_del |= val; - else - msglevel_add |= val; - ++argv; - } - - msglevel &= ~msglevel_del; - msglevel |= msglevel_add; - - return (dhd_iovar_setint(dhd, cmd->name, msglevel)); - -usage: - fprintf(stderr, "msg values may be a list of numbers or names from the following set.\n"); - fprintf(stderr, "Use a + or - prefix to make an incremental change."); - - for (i = 0; (val = dbg_msg[i].value); i++) { - if (val != last_val) - fprintf(stderr, "\n0x%04x %s", val, dbg_msg[i].string); - else - fprintf(stderr, ", %s", dbg_msg[i].string); - last_val = val; - } - fprintf(stderr, "\n"); - - return 0; -} - -static char * -ver2str(unsigned int vms, unsigned int vls) -{ - static char verstr[100]; - unsigned int maj, year, month, day, build; - - maj = (vms >> 16) & 0xFFFF; - if (maj > 1000) { - /* it is probably a date... */ - year = (vms >> 16) & 0xFFFF; - month = vms & 0xFFFF; - day = (vls >> 16) & 0xFFFF; - build = vls & 0xFFFF; - sprintf(verstr, "%d/%d/%d build %d", - month, day, year, build); - } else { - /* it is a tagged release. */ - sprintf(verstr, "%d.%d RC%d.%d", - (vms>>16)&0xFFFF, vms&0xFFFF, - (vls>>16)&0xFFFF, vls&0xFFFF); - } - return verstr; -} - -static int -dhd_version(void *dhd, cmd_t *cmd, char **argv) -{ - int ret; - char *ptr; - - UNUSED_PARAMETER(cmd); - UNUSED_PARAMETER(argv); - - /* Display the application version info */ - printf("%s: %s\n", dhdu_av0, - ver2str((EPI_MAJOR_VERSION << 16)| EPI_MINOR_VERSION, - (EPI_RC_NUMBER << 16) | EPI_INCREMENTAL_NUMBER)); - - if ((ret = dhd_var_getbuf(dhd, cmd->name, NULL, 0, (void**)&ptr)) < 0) - return ret; - - /* Display the returned string */ - printf("%s\n", ptr); - - return 0; -} - -static int -dhd_var_setint(void *dhd, cmd_t *cmd, char **argv) -{ - int32 val; - int len; - char *varname; - char *endptr = NULL; - char *p; - - if (cmd->set == -1) { - printf("set not defined for %s\n", cmd->name); - return COMMAND_ERROR; - } - - if (!*argv) { - printf("set: missing arguments\n"); - return USAGE_ERROR; - } - - varname = *argv++; - - if (!*argv) { - printf("set: missing value argument for set of \"%s\"\n", varname); - return USAGE_ERROR; - } - - val = strtol(*argv, &endptr, 0); - if (*endptr != '\0') { - /* not all the value string was parsed by strtol */ - printf("set: error parsing value \"%s\" as an integer for set of \"%s\"\n", - *argv, varname); - return USAGE_ERROR; - } - - strcpy(buf, varname); - p = buf; - while (*p != '\0') { - *p = tolower(*p); - p++; - } - - /* skip the NUL */ - p++; - - memcpy(p, &val, sizeof(uint)); - len = (p - buf) + sizeof(uint); - - return (dhd_set(dhd, DHD_SET_VAR, &buf[0], len)); -} - -static int -dhd_var_get(void *dhd, cmd_t *cmd, char **argv) -{ - char *varname; - char *p; - - UNUSED_PARAMETER(cmd); - - if (!*argv) { - printf("get: missing arguments\n"); - return USAGE_ERROR; - } - - varname = *argv++; - - if (*argv) { - printf("get: error, extra arg \"%s\"\n", *argv); - return USAGE_ERROR; - } - - strcpy(buf, varname); - p = buf; - while (*p != '\0') { - *p = tolower(*p); - p++; - } - return (dhd_get(dhd, DHD_GET_VAR, &buf[0], DHD_IOCTL_MAXLEN)); -} - -static int -dhd_var_getint(void *dhd, cmd_t *cmd, char **argv) -{ - int err; - int32 val; - if (cmd->get == -1) { - printf("get not defined for %s\n", cmd->name); - return COMMAND_ERROR; - } - - if ((err = dhd_var_get(dhd, cmd, argv))) - return (err); - - val = *(int32*)buf; - - if (val < 10) - printf("%d\n", val); - else - printf("%d (0x%x)\n", val, val); - - return (0); -} - -static int -dhd_var_getandprintstr(void *dhd, cmd_t *cmd, char **argv) -{ - int err; - - if ((err = dhd_var_get(dhd, cmd, argv))) - return (err); - - printf("%s\n", buf); - return (0); -} - - -void -dhd_printlasterror(void *dhd) -{ - char *cmd[2] = {"bcmerrorstr"}; - - if (dhd_var_get(dhd, NULL, cmd) != 0) { - fprintf(stderr, "%s: \nError getting the last error\n", dhdu_av0); - } else { - fprintf(stderr, "%s: %s\n", dhdu_av0, buf); - } -} - -static int -dhd_varint(void *dhd, cmd_t *cmd, char *argv[]) -{ - if (argv[1]) - return (dhd_var_setint(dhd, cmd, argv)); - else - return (dhd_var_getint(dhd, cmd, argv)); -} - -static int -dhd_var_getbuf(void *dhd, char *iovar, void *param, int param_len, void **bufptr) -{ - int len; - - memset(buf, 0, DHD_IOCTL_MAXLEN); - strcpy(buf, iovar); - - /* include the NUL */ - len = strlen(iovar) + 1; - - if (param_len) - memcpy(&buf[len], param, param_len); - - *bufptr = buf; - - return dhd_get(dhd, DHD_GET_VAR, &buf[0], DHD_IOCTL_MAXLEN); -} - -static int -dhd_var_setbuf(void *dhd, char *iovar, void *param, int param_len) -{ - int len; - - memset(buf, 0, DHD_IOCTL_MAXLEN); - strcpy(buf, iovar); - - /* include the NUL */ - len = strlen(iovar) + 1; - - if (param_len) - memcpy(&buf[len], param, param_len); - - len += param_len; - - return dhd_set(dhd, DHD_SET_VAR, &buf[0], len); -} - -static int -dhd_var_void(void *dhd, cmd_t *cmd, char **argv) -{ - UNUSED_PARAMETER(argv); - - if (cmd->set < 0) - return USAGE_ERROR; - - return dhd_var_setbuf(dhd, cmd->name, NULL, 0); -} - -/* - * format an iovar buffer - */ -static uint -dhd_iovar_mkbuf(char *name, char *data, uint datalen, char *buf, uint buflen, int *perr) -{ - uint len; - - len = strlen(name) + 1; - - /* check for overflow */ - if ((len + datalen) > buflen) { - *perr = BCME_BUFTOOSHORT; - return 0; - } - - strcpy(buf, name); - - /* append data onto the end of the name string */ - if (datalen > 0) - memcpy(&buf[len], data, datalen); - - len += datalen; - - *perr = 0; - return len; -} - -static int -dhd_iovar_getint(void *dhd, char *name, int *var) -{ - char ibuf[DHD_IOCTL_SMLEN]; - int error; - - dhd_iovar_mkbuf(name, NULL, 0, ibuf, sizeof(ibuf), &error); - if (error) - return error; - - if ((error = dhd_get(dhd, DHD_GET_VAR, &ibuf, sizeof(ibuf))) < 0) - return error; - - memcpy(var, ibuf, sizeof(int)); - - return 0; -} - -static int -dhd_iovar_setint(void *dhd, char *name, int var) -{ - int len; - char ibuf[DHD_IOCTL_SMLEN]; - int error; - - len = dhd_iovar_mkbuf(name, (char *)&var, sizeof(var), ibuf, sizeof(ibuf), &error); - if (error) - return error; - - if ((error = dhd_set(dhd, DHD_SET_VAR, &ibuf, len)) < 0) - return error; - - return 0; -} - -static int -dhd_varstr(void *dhd, cmd_t *cmd, char **argv) -{ - int error; - char *str; - - if (!*++argv) { - void *ptr; - - if ((error = dhd_var_getbuf(dhd, cmd->name, NULL, 0, &ptr)) < 0) - return (error); - - str = (char *)ptr; - printf("%s\n", str); - return (0); - } else { - str = *argv; - /* iovar buffer length includes NUL */ - return dhd_var_setbuf(dhd, cmd->name, str, strlen(str) + 1); - } -} - - - -#define MATCH_OP(op, opstr) (strlen(op) == strlen(opstr) && strncmp(op, opstr, strlen(op)) == 0) - -static int -wl_HCI_cmd(void *wl, cmd_t *cmd, char **argv) -{ - union { - char buf[HCI_CMD_PREAMBLE_SIZE + HCI_CMD_DATA_SIZE]; - uint32 alignme; - } cbuf; - amp_hci_cmd_t *cpkt = (amp_hci_cmd_t *)&cbuf.buf[0]; - - char *op; - uint8 plen; - - UNUSED_PARAMETER(cmd); - - if (!*++argv) - return USAGE_ERROR; - - /* recognize and encode operations */ - op = *argv++; - if (MATCH_OP(op, "Read_Link_Quality")) { - cpkt->opcode = HCI_Read_Link_Quality; - } else if (MATCH_OP(op, "Read_Local_AMP_Info")) { - cpkt->opcode = HCI_Read_Local_AMP_Info; - } else if (MATCH_OP(op, "Read_Local_AMP_ASSOC")) { - cpkt->opcode = HCI_Read_Local_AMP_ASSOC; - } else if (MATCH_OP(op, "Write_Remote_AMP_ASSOC")) { - cpkt->opcode = HCI_Write_Remote_AMP_ASSOC; - } else if (MATCH_OP(op, "Create_Physical_Link")) { - cpkt->opcode = HCI_Create_Physical_Link; - } else if (MATCH_OP(op, "Accept_Physical_Link_Request")) { - cpkt->opcode = HCI_Accept_Physical_Link_Request; - } else if (MATCH_OP(op, "Disconnect_Physical_Link")) { - cpkt->opcode = HCI_Disconnect_Physical_Link; - } else if (MATCH_OP(op, "Create_Logical_Link")) { - cpkt->opcode = HCI_Create_Logical_Link; - } else if (MATCH_OP(op, "Accept_Logical_Link")) { - cpkt->opcode = HCI_Accept_Logical_Link; - } else if (MATCH_OP(op, "Disconnect_Logical_Link")) { - cpkt->opcode = HCI_Disconnect_Logical_Link; - } else if (MATCH_OP(op, "Logical_Link_Cancel")) { - cpkt->opcode = HCI_Logical_Link_Cancel; - } else if (MATCH_OP(op, "Short_Range_Mode")) { - cpkt->opcode = HCI_Short_Range_Mode; - } else if (MATCH_OP(op, "Read_Connection_Accept_Timeout")) { - cpkt->opcode = HCI_Read_Connection_Accept_Timeout; - } else if (MATCH_OP(op, "Write_Connection_Accept_Timeout")) { - cpkt->opcode = HCI_Write_Connection_Accept_Timeout; - } else if (MATCH_OP(op, "Read_Link_Supervision_Timeout")) { - cpkt->opcode = HCI_Read_Link_Supervision_Timeout; - } else if (MATCH_OP(op, "Write_Link_Supervision_Timeout")) { - cpkt->opcode = HCI_Write_Link_Supervision_Timeout; - } else if (MATCH_OP(op, "Reset")) { - cpkt->opcode = HCI_Reset; - } else if (MATCH_OP(op, "Enhanced_Flush")) { - cpkt->opcode = HCI_Enhanced_Flush; - } else if (MATCH_OP(op, "Read_Best_Effort_Flush_Timeout")) { - cpkt->opcode = HCI_Read_Best_Effort_Flush_Timeout; - } else if (MATCH_OP(op, "Write_Best_Effort_Flush_Timeout")) { - cpkt->opcode = HCI_Write_Best_Effort_Flush_Timeout; - } else if (MATCH_OP(op, "Read_Logical_Link_Accept_Timeout")) { - cpkt->opcode = HCI_Read_Logical_Link_Accept_Timeout; - } else if (MATCH_OP(op, "Write_Logical_Link_Accept_Timeout")) { - cpkt->opcode = HCI_Write_Logical_Link_Accept_Timeout; - } else if (MATCH_OP(op, "Read_Buffer_Size")) { - cpkt->opcode = HCI_Read_Buffer_Size; - } else if (MATCH_OP(op, "Read_Data_Block_Size")) { - cpkt->opcode = HCI_Read_Data_Block_Size; - } else if (MATCH_OP(op, "Set_Event_Mask_Page_2")) { - cpkt->opcode = HCI_Set_Event_Mask_Page_2; - } else if (MATCH_OP(op, "Flow_Spec_Modify")) { - cpkt->opcode = HCI_Flow_Spec_Modify; - } else if (MATCH_OP(op, "Read_Local_Version_Info")) { - cpkt->opcode = HCI_Read_Local_Version_Info; - } else if (MATCH_OP(op, "Read_Local_Supported_Commands")) { - cpkt->opcode = HCI_Read_Local_Supported_Commands; - } else if (MATCH_OP(op, "Read_Failed_Contact_Counter")) { - cpkt->opcode = HCI_Read_Failed_Contact_Counter; - } else if (MATCH_OP(op, "Reset_Failed_Contact_Counter")) { - cpkt->opcode = HCI_Reset_Failed_Contact_Counter; - } else { - printf("unsupported HCI command: %s\n", op); - return (-1); - } - - plen = 0; - while (*argv && (plen < HCI_CMD_DATA_SIZE)) { - cpkt->parms[plen++] = (uint8)strtol(*argv++, NULL, 0); - } - cpkt->plen = plen; - - return dhd_var_setbuf(wl, cmd->name, cpkt, HCI_CMD_PREAMBLE_SIZE + plen); -} - -static int -wl_HCI_ACL_data(void *wl, cmd_t *cmd, char **argv) -{ - /* Align struct. Also declare static so that large array isn't allocated - * from the stack. - */ - static union { - uint8 buf[HCI_ACL_DATA_PREAMBLE_SIZE + 2048]; - uint32 alignme; - } g_hci_dbuf; - - amp_hci_ACL_data_t *dpkt = (amp_hci_ACL_data_t *)&g_hci_dbuf.buf[0]; - uint16 dlen; - - if (!*++argv) - return USAGE_ERROR; - - /* get logical link handle */ - dpkt->handle = (HCI_ACL_DATA_BC_FLAGS | HCI_ACL_DATA_PB_FLAGS); - dpkt->handle |= (uint16)strtol(*argv++, NULL, 0); - - /* get data */ - dlen = 0; - while (*argv && (dlen < 2048)) { - dpkt->data[dlen++] = (uint8)strtol(*argv++, NULL, 0); - } - dpkt->dlen = dlen; - - return dhd_var_setbuf(wl, cmd->name, dpkt, HCI_ACL_DATA_PREAMBLE_SIZE + dlen); -} - -/* These two utility functions are used by dhdu_linux.c - * The code is taken from wlu.c. - */ -int -dhd_atoip(const char *a, struct ipv4_addr *n) -{ - char *c; - int i = 0; - - for (;;) { - n->addr[i++] = (uint8)strtoul(a, &c, 0); - if (*c++ != '.' || i == IPV4_ADDR_LEN) - break; - a = c; - } - return (i == IPV4_ADDR_LEN); -} - -int -dhd_ether_atoe(const char *a, struct ether_addr *n) -{ - char *c; - int i = 0; - - memset(n, 0, ETHER_ADDR_LEN); - for (;;) { - n->octet[i++] = (uint8)strtoul(a, &c, 16); - if (!*c++ || i == ETHER_ADDR_LEN) - break; - a = c; - } - return (i == ETHER_ADDR_LEN); -} diff --git a/bcm4329/dhdutil/dhdu.h b/bcm4329/dhdutil/dhdu.h deleted file mode 100644 index 84d7e1f..0000000 --- a/bcm4329/dhdutil/dhdu.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Definitions for DHD command-line utility - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: dhdu.h,v 1.7 2009-05-22 19:23:29 Exp $ - */ - -#ifndef _dhdu_h_ -#define _dhdu_h_ - -#include "dhdu_cmd.h" - -extern char *dhdu_av0; - -/* parse common option */ -extern int dhd_option(char ***pargv, char **pifname, int *phelp); -extern void dhd_cmd_init(void); - -/* print usage */ -extern void dhd_cmd_usage(cmd_t *cmd); -extern void dhd_usage(cmd_t *port_cmds); -extern void dhd_cmds_usage(cmd_t *port_cmds); - -/* print helpers */ -extern void dhd_printlasterror(void *dhd); -extern void dhd_printint(int val); - -/* check driver version */ -extern int dhd_check(void *dhd); - -/* utility functions */ -struct ipv4_addr; -int dhd_ether_atoe(const char *a, struct ether_addr *n); -int dhd_atoip(const char *a, struct ipv4_addr *n); -/* useful macros */ -#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) - -#define USAGE_ERROR -1 /* Error code for Usage */ -#define IOCTL_ERROR -2 /* Error code for ioctl failure */ -#define COMMAND_ERROR -3 /* Error code for general command failure */ - -/* integer output format */ -#define INT_FMT_DEC 0 /* signed integer */ -#define INT_FMT_UINT 1 /* unsigned integer */ -#define INT_FMT_HEX 2 /* hexdecimal */ - -/* command line argument usage */ -#define CMD_ERR -1 /* Error for command */ -#define CMD_OPT 0 /* a command line option */ -#define CMD_DHD 1 /* the start of a dhd command */ - -#endif /* _dhdu_h_ */ diff --git a/bcm4329/dhdutil/dhdu_cmd.h b/bcm4329/dhdutil/dhdu_cmd.h deleted file mode 100644 index 571f8b9..0000000 --- a/bcm4329/dhdutil/dhdu_cmd.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Command structure for dhd command line utility. - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: dhdu_cmd.h,v 1.6 2008-06-05 00:36:42 Exp $ - */ - -#ifndef _dhdu_cmd_h_ -#define _dhdu_cmd_h_ - -typedef struct cmd cmd_t; -typedef int (cmd_func_t)(void *dhd, cmd_t *cmd, char **argv); - -/* generic command line argument handler */ -struct cmd { - char *name; - cmd_func_t *func; - int get; - int set; - char *help; -}; - -/* list of command line arguments */ -extern cmd_t dhd_cmds[]; -extern cmd_t dhd_varcmd; - -/* Special set cmds to do download via dev node interface if present */ -#define DHD_DLDN_ST 0x400 -#define DHD_DLDN_WRITE (DHD_DLDN_ST + 1) -#define DHD_DLDN_END (DHD_DLDN_ST + 2) - -/* per-port ioctl handlers */ -extern int dhd_get(void *dhd, int cmd, void *buf, int len); -extern int dhd_set(void *dhd, int cmd, void *buf, int len); - -#endif /* _dhdu_cmd_h_ */ diff --git a/bcm4329/dhdutil/dhdu_common.h b/bcm4329/dhdutil/dhdu_common.h deleted file mode 100644 index d1a70f0..0000000 --- a/bcm4329/dhdutil/dhdu_common.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Common code for dhd command line utility. - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: dhdu_common.h,v 1.4.34.1 2011-02-05 00:43:28 Exp $ - */ - -/* Common header file for dhdu_linux.c and dhdu_ndis.c */ - -#ifndef _dhdu_common_h -#define _dhdu_common_h - -/* DHD utility function declarations */ -extern int dhd_check(void *dhd); -extern int dhd_atoip(const char *a, struct ipv4_addr *n); -extern int dhd_option(char ***pargv, char **pifname, int *phelp); -void dhd_usage(cmd_t *port_cmds); - -static int process_args(struct ifreq* ifr, char **argv); - - -#define dtoh32(i) i -#define dtoh16(i) i - -#endif /* _dhdu_common_h_ */ diff --git a/bcm4329/dhdutil/dhdu_linux.c b/bcm4329/dhdutil/dhdu_linux.c deleted file mode 100644 index 4e58020..0000000 --- a/bcm4329/dhdutil/dhdu_linux.c +++ /dev/null @@ -1,442 +0,0 @@ -/* - * Linux port of dhd command line utility. - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: dhdu_linux.c,v 1.16.2.2 2010-12-16 08:12:11 Exp $ - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <ctype.h> -#include <string.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/socket.h> -#include <proto/ethernet.h> -#include <proto/bcmip.h> -#include <arpa/inet.h> -#include <sys/ioctl.h> -#include <net/if.h> -#include <fcntl.h> -#include <sys/ioctl.h> -#include <unistd.h> - -#ifndef TARGETENV_android -#include <error.h> -typedef u_int64_t u64; -typedef u_int32_t u32; -typedef u_int16_t u16; -typedef u_int8_t u8; -#endif /* TARGETENV_android */ -#include <linux/sockios.h> -#include <linux/types.h> -#include <linux/ethtool.h> - -#include <typedefs.h> -#include <signal.h> -#include <dhdioctl.h> -#include <wlioctl.h> -#include <bcmcdc.h> -#include <bcmutils.h> -#include "dhdu.h" -#include <netdb.h> -#include <dhdioctl.h> -#include "dhdu_common.h" - -extern int wl_get(void *wl, int cmd, void *buf, int len); -extern int wl_set(void *wl, int cmd, void *buf, int len); - -char *av0; -/* Search the dhd_cmds table for a matching command name. - * Return the matching command or NULL if no match found. - */ -static cmd_t * -dhd_find_cmd(char* name) -{ - cmd_t *cmd = NULL; - /* search the dhd_cmds for a matching name */ - for (cmd = dhd_cmds; cmd->name && strcmp(cmd->name, name); cmd++); - if (cmd->name == NULL) - cmd = NULL; - return cmd; -} - -static void -syserr(char *s) -{ - fprintf(stderr, "%s: ", dhdu_av0); - perror(s); - exit(errno); -} - -/* This function is called by ioctl_setinformation_fe or ioctl_queryinformation_fe - * for executing remote commands or local commands - */ -static int -dhd_ioctl(void *dhd, int cmd, void *buf, int len, bool set) -{ - struct ifreq *ifr = (struct ifreq *)dhd; - dhd_ioctl_t ioc; - int ret = 0; - int s; - /* By default try to execute wl commands */ - int driver_magic = DHD_IOCTL_MAGIC; - int get_magic = DHD_GET_MAGIC; - - /* open socket to kernel */ - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - syserr("socket"); - - /* do it */ - ioc.cmd = cmd; - ioc.buf = buf; - ioc.len = len; - ioc.set = set; - ioc.driver = driver_magic; - ifr->ifr_data = (caddr_t) &ioc; - - if ((ret = ioctl(s, SIOCDEVPRIVATE, ifr)) < 0) { - if (cmd != get_magic) { - ret = IOCTL_ERROR; - } - } - - /* cleanup */ - close(s); - return ret; -} - -/* This function is called in wlu_pipe.c remote_wifi_ser_init() to execute - * the initial set of wl commands for wifi transport (e.g slow_timer, fast_timer etc) - */ -int wl_ioctl(void *wl, int cmd, void *buf, int len, bool set) -{ - return dhd_ioctl(wl, cmd, buf, len, set); /* Call actual wl_ioctl here: Shubhro */ -} - -/* Search if dhd adapter or wl adapter is present - * This is called by dhd_find to check if it supports wl or dhd - * The reason for checking wl adapter is that we can still send remote dhd commands over - * wifi transport. - */ -static int -dhd_get_dev_type(char *name, void *buf, char *type) -{ - int s; - int ret; - struct ifreq ifr; - struct ethtool_drvinfo info; - - /* open socket to kernel */ - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - syserr("socket"); - - /* get device type */ - memset(&info, 0, sizeof(info)); - info.cmd = ETHTOOL_GDRVINFO; - strcpy(info.driver, "?"); - strcat(info.driver, type); - ifr.ifr_data = (caddr_t)&info; - strncpy(ifr.ifr_name, name, IFNAMSIZ); - if ((ret = ioctl(s, SIOCETHTOOL, &ifr)) < 0) { - - /* print a good diagnostic if not superuser */ - if (errno == EPERM) - syserr("dhd_get_dev_type"); - - *(char *)buf = '\0'; - } - else - strcpy(buf, info.driver); - - close(s); - return ret; -} - -/* dhd_get/dhd_set is called by several functions in dhdu.c. This used to call dhd_ioctl - * directly. However now we need to execute the dhd commands remotely. - * So we make use of wl pipes to execute this. - * wl_get or wl_set functions also check if it is a local command hence they in turn - * call dhd_ioctl if required. Name wl_get/wl_set is retained because these functions are - * also called by wlu_pipe.c wlu_client_shared.c - */ -int -dhd_get(void *dhd, int cmd, void *buf, int len) -{ - return wl_get(dhd, cmd, buf, len); -} - -/* - * To use /dev/node interface: - * 1. mknod /dev/hnd0 c 248 0 - * 2. chmod 777 /dev/hnd0 - */ -#define NODE "/dev/hnd0" - -int -dhd_set(void *dhd, int cmd, void *buf, int len) -{ - static int dnode = -1; - - switch (cmd) { - case DHD_DLDN_ST: - if (dnode == -1) - dnode = open(NODE, O_RDWR); - else - fprintf(stderr, "devnode already opened!\n"); - - return dnode; - break; - case DHD_DLDN_WRITE: - if (dnode > 0) - return write(dnode, buf, len); - break; - case DHD_DLDN_END: - if (dnode > 0) - return close(dnode); - break; - default: - return wl_set(dhd, cmd, buf, len); - - } - - return -1; -} - -/* Verify the wl adapter found. - * This is called by dhd_find to check if it supports wl - * The reason for checking wl adapter is that we can still send remote dhd commands over - * wifi transport. The function is copied from wlu.c. - */ -int -wl_check(void *wl) -{ - int ret; - int val = 0; - - if (!dhd_check (wl)) - return 0; - - /* - * If dhd_check() fails then go for a regular wl driver verification - */ - if ((ret = wl_get(wl, WLC_GET_MAGIC, &val, sizeof(int))) < 0) - return ret; - if (val != WLC_IOCTL_MAGIC) - return BCME_ERROR; - if ((ret = wl_get(wl, WLC_GET_VERSION, &val, sizeof(int))) < 0) - return ret; - if (val > WLC_IOCTL_VERSION) { - fprintf(stderr, "Version mismatch, please upgrade\n"); - return BCME_ERROR; - } - return 0; -} -/* Search and verify the request type of adapter (wl or dhd) - * This is called by main before executing local dhd commands - * or sending remote dhd commands over wifi transport - */ -void -dhd_find(struct ifreq *ifr, char *type) -{ - char proc_net_dev[] = "/proc/net/dev"; - FILE *fp; - static char buf[400]; - char *c, *name; - char dev_type[32]; - - ifr->ifr_name[0] = '\0'; - /* eat first two lines */ - if (!(fp = fopen(proc_net_dev, "r")) || - !fgets(buf, sizeof(buf), fp) || - !fgets(buf, sizeof(buf), fp)) - return; - - while (fgets(buf, sizeof(buf), fp)) { - c = buf; - while (isspace(*c)) - c++; - if (!(name = strsep(&c, ":"))) - continue; - strncpy(ifr->ifr_name, name, IFNAMSIZ); - if (dhd_get_dev_type(name, dev_type, type) >= 0 && - !strncmp(dev_type, type, strlen(dev_type) - 1)) - { - if (!wl_check((void*)ifr)) - break; - } - ifr->ifr_name[0] = '\0'; - } - - fclose(fp); -} -/* This function is called by wl_get to execute either local dhd command - * or send a dhd command over wl transport - */ -static int -ioctl_queryinformation_fe(void *wl, int cmd, void* input_buf, int *input_len) -{ - return dhd_ioctl(wl, cmd, input_buf, *input_len, FALSE); -} - -/* This function is called by wl_set to execute either local dhd command - * or send a dhd command over wl transport - */ -static int -ioctl_setinformation_fe(void *wl, int cmd, void* buf, int *len) -{ - return dhd_ioctl(wl, cmd, buf, *len, TRUE); -} - -/* The function is replica of wl_get in wlu_linux.c. Optimize when we have some - * common code between wlu_linux.c and dhdu_linux.c - */ -int -wl_get(void *wl, int cmd, void *buf, int len) -{ - int error = BCME_OK; - error = (int)ioctl_queryinformation_fe(wl, cmd, buf, &len); - - if (error != 0) - return IOCTL_ERROR; - - return error; -} - -/* The function is replica of wl_set in wlu_linux.c. Optimize when we have some - * common code between wlu_linux.c and dhdu_linux.c - */ -int -wl_set(void *wl, int cmd, void *buf, int len) -{ - int error = BCME_OK; - - error = (int)ioctl_setinformation_fe(wl, cmd, buf, &len); - - if (error != 0) { - return IOCTL_ERROR; - } - return error; -} -/* Main client function - * The code is mostly from wlu_linux.c. This function takes care of executing remote dhd commands - * along with the local dhd commands now. - */ -int -main(int argc, char **argv) -{ - struct ifreq ifr; - char *ifname = NULL; - int err = 0; - int help = 0; - int status = CMD_DHD; - UNUSED_PARAMETER(argc); - - av0 = dhdu_av0 = argv[0]; - memset(&ifr, 0, sizeof(ifr)); - argv++; - - if ((status = dhd_option(&argv, &ifname, &help)) == CMD_OPT) { - if (ifname) - strncpy(ifr.ifr_name, ifname, IFNAMSIZ); - } - - err = process_args(&ifr, argv); - - return err; -} -/* - * Function called for 'local' execution and for 'remote' non-interactive session - * (shell cmd, wl cmd) .The code is mostly from wlu_linux.c. This code can be - * common to wlu_linux.c and dhdu_linux.c - */ -static int -process_args(struct ifreq* ifr, char **argv) -{ - char *ifname = NULL; - int help = 0; - int status = 0; - int err = BCME_OK; - cmd_t *cmd = NULL; - while (*argv) { - if ((status = dhd_option(&argv, &ifname, &help)) == CMD_OPT) { - if (help) - break; - if (ifname) - strncpy(ifr->ifr_name, ifname, IFNAMSIZ); - continue; - } - /* parse error */ - else if (status == CMD_ERR) - break; - - /* use default interface */ - if (!ifr->ifr_name[0]) - dhd_find(ifr, "dhd"); - /* validate the interface */ - if (!ifr->ifr_name[0] || dhd_check((void *)ifr)) { - if (strcmp("dldn", *argv) != 0) { - fprintf(stderr, "%s: dhd driver adapter not found\n", av0); - exit(BCME_ERROR); - } - } - - /* search for command */ - cmd = dhd_find_cmd(*argv); - /* if not found, use default set_var and get_var commands */ - if (!cmd) { - cmd = &dhd_varcmd; - } - - /* do command */ - err = (*cmd->func)((void *) ifr, cmd, argv); - break; - } /* while loop end */ - - /* provide for help on a particular command */ - if (help && *argv) { - cmd = dhd_find_cmd(*argv); - if (cmd) { - dhd_cmd_usage(cmd); - } else { - printf("%s: Unrecognized command \"%s\", type -h for help\n", - av0, *argv); - } - } else if (!cmd) - dhd_usage(NULL); - else if (err == USAGE_ERROR) - dhd_cmd_usage(cmd); - else if (err == IOCTL_ERROR) - dhd_printlasterror((void *) ifr); - - return err; -} - -int -rwl_shell_createproc(void *wl) -{ - UNUSED_PARAMETER(wl); - return fork(); -} - -void -rwl_shell_killproc(int pid) -{ - kill(pid, SIGKILL); -} - diff --git a/bcm4329/dhdutil/include/bcmcdc.h b/bcm4329/dhdutil/include/bcmcdc.h deleted file mode 100644 index f5fc452..0000000 --- a/bcm4329/dhdutil/include/bcmcdc.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * CDC network driver ioctl/indication encoding - * Broadcom 802.11abg Networking Device Driver - * - * Definitions subject to change without notice. - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: bcmcdc.h,v 13.25.10.3 2010-12-22 23:47:26 Exp $ - */ - -#ifndef _bcmcdc_h_ -#define _bcmcdc_h_ -#include <proto/ethernet.h> - -typedef struct cdc_ioctl { - uint32 cmd; - uint32 len; - uint32 flags; - uint32 status; -} cdc_ioctl_t; - - -#define CDC_MAX_MSG_SIZE ETHER_MAX_LEN - - -#define CDCL_IOC_OUTLEN_MASK 0x0000FFFF -#define CDCL_IOC_OUTLEN_SHIFT 0 -#define CDCL_IOC_INLEN_MASK 0xFFFF0000 -#define CDCL_IOC_INLEN_SHIFT 16 - - -#define CDCF_IOC_ERROR 0x01 -#define CDCF_IOC_SET 0x02 -#define CDCF_IOC_OVL_IDX_MASK 0x3c -#define CDCF_IOC_OVL_RSV 0x40 -#define CDCF_IOC_OVL 0x80 -#define CDCF_IOC_ACTION_MASK 0xfe -#define CDCF_IOC_ACTION_SHIFT 1 -#define CDCF_IOC_IF_MASK 0xF000 -#define CDCF_IOC_IF_SHIFT 12 -#define CDCF_IOC_ID_MASK 0xFFFF0000 -#define CDCF_IOC_ID_SHIFT 16 - -#define CDC_IOC_IF_IDX(flags) (((flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT) -#define CDC_IOC_ID(flags) (((flags) & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT) - -#define CDC_GET_IF_IDX(hdr) \ - ((int)((((hdr)->flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT)) -#define CDC_SET_IF_IDX(hdr, idx) \ - ((hdr)->flags = (((hdr)->flags & ~CDCF_IOC_IF_MASK) | ((idx) << CDCF_IOC_IF_SHIFT))) - - - -#define BDC_HEADER_LEN 4 - -#define BDC_PROTO_VER_1 1 -#define BDC_PROTO_VER 2 - -#define BDC_FLAG_VER_MASK 0xf0 -#define BDC_FLAG_VER_SHIFT 4 - -#define BDC_FLAG__UNUSED 0x03 -#define BDC_FLAG_SUM_GOOD 0x04 -#define BDC_FLAG_SUM_NEEDED 0x08 - -#define BDC_PRIORITY_MASK 0x7 - -#define BDC_FLAG2_FC_FLAG 0x10 - -#define BDC_PRIORITY_FC_SHIFT 4 - -#define BDC_FLAG2_IF_MASK 0x0f -#define BDC_FLAG2_IF_SHIFT 0 -#define BDC_FLAG2_PAD_MASK 0xf0 -#define BDC_FLAG_PAD_MASK 0x03 -#define BDC_FLAG2_PAD_SHIFT 2 -#define BDC_FLAG_PAD_SHIFT 0 -#define BDC_FLAG2_PAD_IDX 0x3c -#define BDC_FLAG_PAD_IDX 0x03 -#define BDC_GET_PAD_LEN(hdr) \ - ((int)(((((hdr)->flags2) & BDC_FLAG2_PAD_MASK) >> BDC_FLAG2_PAD_SHIFT) | \ - ((((hdr)->flags) & BDC_FLAG_PAD_MASK) >> BDC_FLAG_PAD_SHIFT))) -#define BDC_SET_PAD_LEN(hdr, idx) \ - ((hdr)->flags2 = (((hdr)->flags2 & ~BDC_FLAG2_PAD_MASK) | \ - (((idx) & BDC_FLAG2_PAD_IDX) << BDC_FLAG2_PAD_SHIFT))); \ - ((hdr)->flags = (((hdr)->flags & ~BDC_FLAG_PAD_MASK) | \ - (((idx) & BDC_FLAG_PAD_IDX) << BDC_FLAG_PAD_SHIFT))) - -#define BDC_GET_IF_IDX(hdr) \ - ((int)((((hdr)->flags2) & BDC_FLAG2_IF_MASK) >> BDC_FLAG2_IF_SHIFT)) -#define BDC_SET_IF_IDX(hdr, idx) \ - ((hdr)->flags2 = (((hdr)->flags2 & ~BDC_FLAG2_IF_MASK) | ((idx) << BDC_FLAG2_IF_SHIFT))) - -struct bdc_header { - uint8 flags; - uint8 priority; - uint8 flags2; - uint8 dataOffset; -}; - -#endif diff --git a/bcm4329/dhdutil/include/bcmdefs.h b/bcm4329/dhdutil/include/bcmdefs.h deleted file mode 100644 index c8c68b4..0000000 --- a/bcm4329/dhdutil/include/bcmdefs.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Misc system wide definitions - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: bcmdefs.h,v 13.68.2.8 2011-01-08 04:04:19 Exp $ - */ - -#ifndef _bcmdefs_h_ -#define _bcmdefs_h_ - - - -#define bcmreclaimed 0 -#define _data _data -#define _fn _fn -#define _data _data -#define _fn _fn -#define _fn _fn -#define CONST const -#define BCMFASTPATH - - - - -#define _data _data -#define _fn _fn -#define _fn _fn -#define STATIC static - - -#define SI_BUS 0 -#define PCI_BUS 1 -#define PCMCIA_BUS 2 -#define SDIO_BUS 3 -#define JTAG_BUS 4 -#define USB_BUS 5 -#define SPI_BUS 6 -#define RPC_BUS 7 - - -#ifdef BCMBUSTYPE -#define BUSTYPE(bus) (BCMBUSTYPE) -#else -#define BUSTYPE(bus) (bus) -#endif - - -#ifdef BCMCHIPTYPE -#define CHIPTYPE(bus) (BCMCHIPTYPE) -#else -#define CHIPTYPE(bus) (bus) -#endif - - - -#if defined(BCMSPROMBUS) -#define SPROMBUS (BCMSPROMBUS) -#elif defined(SI_PCMCIA_SROM) -#define SPROMBUS (PCMCIA_BUS) -#else -#define SPROMBUS (PCI_BUS) -#endif - - -#ifdef BCMCHIPID -#define CHIPID(chip) (BCMCHIPID) -#else -#define CHIPID(chip) (chip) -#endif - -#ifdef BCMCHIPREV -#define CHIPREV(rev) (BCMCHIPREV) -#else -#define CHIPREV(rev) (rev) -#endif - - -#define DMADDR_MASK_32 0x0 -#define DMADDR_MASK_30 0xc0000000 -#define DMADDR_MASK_0 0xffffffff - -#define DMADDRWIDTH_30 30 -#define DMADDRWIDTH_32 32 -#define DMADDRWIDTH_63 63 -#define DMADDRWIDTH_64 64 - -#ifdef BCMDMA64OSL -typedef struct { - uint32 loaddr; - uint32 hiaddr; -} dma64addr_t; - -typedef dma64addr_t dmaaddr_t; -#define PHYSADDRHI(_pa) ((_pa).hiaddr) -#define PHYSADDRHISET(_pa, _val) \ - do { \ - (_pa).hiaddr = (_val); \ - } while (0) -#define PHYSADDRLO(_pa) ((_pa).loaddr) -#define PHYSADDRLOSET(_pa, _val) \ - do { \ - (_pa).loaddr = (_val); \ - } while (0) - -#else -typedef unsigned long dmaaddr_t; -#define PHYSADDRHI(_pa) (0) -#define PHYSADDRHISET(_pa, _val) -#define PHYSADDRLO(_pa) ((_pa)) -#define PHYSADDRLOSET(_pa, _val) \ - do { \ - (_pa) = (_val); \ - } while (0) -#endif - - -typedef struct { - dmaaddr_t addr; - uint32 length; -} hnddma_seg_t; - -#define MAX_DMA_SEGS 4 - - -typedef struct { - void *oshdmah; - uint origsize; - uint nsegs; - hnddma_seg_t segs[MAX_DMA_SEGS]; -} hnddma_seg_map_t; - - - - -#if defined(BCM_RPC_NOCOPY) || defined(BCM_RCP_TXNOCOPY) - -#define BCMEXTRAHDROOM 220 -#else -#define BCMEXTRAHDROOM 172 -#endif - - -#define BCMDONGLEHDRSZ 12 -#define BCMDONGLEPADSZ 16 - -#define BCMDONGLEOVERHEAD (BCMDONGLEHDRSZ + BCMDONGLEPADSZ) - - -#if defined(BCMASSERT_LOG) -#define BCMASSERT_SUPPORT -#endif - - -#define BITFIELD_MASK(width) \ - (((unsigned)1 << (width)) - 1) -#define GFIELD(val, field) \ - (((val) >> field ## _S) & field ## _M) -#define SFIELD(val, field, bits) \ - (((val) & (~(field ## _M << field ## _S))) | \ - ((unsigned)(bits) << field ## _S)) - - -#ifdef BCMSMALL -#undef BCMSPACE -#define bcmspace FALSE -#else -#define BCMSPACE -#define bcmspace TRUE -#endif - - -#define MAXSZ_NVRAM_VARS 4096 - -#define LOCATOR_EXTERN static - -#endif diff --git a/bcm4329/dhdutil/include/bcmdevs.h b/bcm4329/dhdutil/include/bcmdevs.h deleted file mode 100644 index 85a4559..0000000 --- a/bcm4329/dhdutil/include/bcmdevs.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Broadcom device-specific manifest constants. - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: bcmdevs.h,v 13.285.2.39 2011-02-04 05:03:16 Exp $ - */ - - -#ifndef _BCMDEVS_H -#define _BCMDEVS_H - - -#define VENDOR_EPIGRAM 0xfeda -#define VENDOR_BROADCOM 0x14e4 -#define VENDOR_SI_IMAGE 0x1095 -#define VENDOR_TI 0x104c -#define VENDOR_RICOH 0x1180 -#define VENDOR_JMICRON 0x197b - - - -#define VENDOR_BROADCOM_PCMCIA 0x02d0 - - -#define VENDOR_BROADCOM_SDIO 0x00BF - - -#define BCM_DNGL_VID 0x0a5c -#define BCM_DNGL_BL_PID_4328 0xbd12 -#define BCM_DNGL_BL_PID_4322 0xbd13 -#define BCM_DNGL_BL_PID_4319 0xbd16 -#define BCM_DNGL_BL_PID_43236 0xbd17 -#define BCM_DNGL_BL_PID_4332 0xbd18 -#define BCM_DNGL_BL_PID_4330 0xbd19 -#define BCM_DNGL_BL_PID_43239 0xbd1b -#define BCM_DNGL_BDC_PID 0x0bdc -#define BCM_DNGL_JTAG_PID 0x4a44 -#define BCM4325_D11DUAL_ID 0x431b -#define BCM4325_D11G_ID 0x431c -#define BCM4325_D11A_ID 0x431d -#define BCM4321_D11N_ID 0x4328 -#define BCM4321_D11N2G_ID 0x4329 -#define BCM4321_D11N5G_ID 0x432a -#define BCM4322_D11N_ID 0x432b -#define BCM4322_D11N2G_ID 0x432c -#define BCM4322_D11N5G_ID 0x432d -#define BCM4329_D11N_ID 0x432e -#define BCM4329_D11N2G_ID 0x432f -#define BCM4329_D11N5G_ID 0x4330 -#define BCM4315_D11DUAL_ID 0x4334 -#define BCM4315_D11G_ID 0x4335 -#define BCM4315_D11A_ID 0x4336 -#define BCM4319_D11N_ID 0x4337 -#define BCM4319_D11N2G_ID 0x4338 -#define BCM4319_D11N5G_ID 0x4339 -#define BCM43231_D11N2G_ID 0x4340 -#define BCM43221_D11N2G_ID 0x4341 -#define BCM43222_D11N_ID 0x4350 -#define BCM43222_D11N2G_ID 0x4351 -#define BCM43222_D11N5G_ID 0x4352 -#define BCM43224_D11N_ID 0x4353 -#define BCM43224_D11N_ID_VEN1 0x0576 -#define BCM43226_D11N_ID 0x4354 -#define BCM43236_D11N_ID 0x4346 -#define BCM43236_D11N2G_ID 0x4347 -#define BCM43236_D11N5G_ID 0x4348 -#define BCM43225_D11N2G_ID 0x4357 -#define BCM43421_D11N_ID 0xA99D -#define BCM4313_D11N2G_ID 0x4727 -#define BCM4330_D11N_ID 0x4360 -#define BCM4330_D11N2G_ID 0x4361 -#define BCM4330_D11N5G_ID 0x4362 -#define BCM4336_D11N_ID 0x4343 -#define BCM6362_D11N_ID 0x435f -#define BCM4331_D11N_ID 0x4331 -#define BCM4331_D11N2G_ID 0x4332 -#define BCM4331_D11N5G_ID 0x4333 -#define BCM43237_D11N_ID 0x4355 -#define BCM43237_D11N5G_ID 0x4356 -#define BCM43227_D11N2G_ID 0x4358 -#define BCM43228_D11N_ID 0x4359 -#define BCM43228_D11N5G_ID 0x435a -#define BCM43362_D11N_ID 0x4363 -#define BCM43239_D11N_ID 0x4370 - - -#define SDIOH_FPGA_ID 0x43f2 -#define SPIH_FPGA_ID 0x43f5 -#define BCM4710_DEVICE_ID 0x4710 -#define BCM27XX_SDIOH_ID 0x2702 -#define PCIXX21_FLASHMEDIA0_ID 0x8033 -#define PCIXX21_SDIOH0_ID 0x8034 -#define PCIXX21_FLASHMEDIA_ID 0x803b -#define PCIXX21_SDIOH_ID 0x803c -#define R5C822_SDIOH_ID 0x0822 -#define JMICRON_SDIOH_ID 0x2381 - - -#define BCM4306_CHIP_ID 0x4306 -#define BCM4311_CHIP_ID 0x4311 -#define BCM43111_CHIP_ID 43111 -#define BCM43112_CHIP_ID 43112 -#define BCM4312_CHIP_ID 0x4312 -#define BCM4313_CHIP_ID 0x4313 -#define BCM4315_CHIP_ID 0x4315 -#define BCM4318_CHIP_ID 0x4318 -#define BCM4319_CHIP_ID 0x4319 -#define BCM4320_CHIP_ID 0x4320 -#define BCM4321_CHIP_ID 0x4321 -#define BCM4322_CHIP_ID 0x4322 -#define BCM43221_CHIP_ID 43221 -#define BCM43222_CHIP_ID 43222 -#define BCM43224_CHIP_ID 43224 -#define BCM43225_CHIP_ID 43225 -#define BCM43227_CHIP_ID 43227 -#define BCM43228_CHIP_ID 43228 -#define BCM43226_CHIP_ID 43226 -#define BCM43231_CHIP_ID 43231 -#define BCM43234_CHIP_ID 43234 -#define BCM43235_CHIP_ID 43235 -#define BCM43236_CHIP_ID 43236 -#define BCM43237_CHIP_ID 43237 -#define BCM43238_CHIP_ID 43238 -#define BCM43239_CHIP_ID 43239 -#define BCM43420_CHIP_ID 43420 -#define BCM43421_CHIP_ID 43421 -#define BCM43428_CHIP_ID 43428 -#define BCM43431_CHIP_ID 43431 -#define BCM4325_CHIP_ID 0x4325 -#define BCM4328_CHIP_ID 0x4328 -#define BCM4329_CHIP_ID 0x4329 -#define BCM4331_CHIP_ID 0x4331 -#define BCM4336_CHIP_ID 0x4336 -#define BCM43362_CHIP_ID 43362 -#define BCM4330_CHIP_ID 0x4330 -#define BCM4402_CHIP_ID 0x4402 -#define BCM4704_CHIP_ID 0x4704 -#define BCM4710_CHIP_ID 0x4710 -#define BCM4712_CHIP_ID 0x4712 -#define BCM4785_CHIP_ID 0x4785 -#define BCM5350_CHIP_ID 0x5350 -#define BCM5352_CHIP_ID 0x5352 -#define BCM5354_CHIP_ID 0x5354 -#define BCM5365_CHIP_ID 0x5365 - - -#define BCM4303_PKG_ID 2 -#define BCM4309_PKG_ID 1 -#define BCM4712LARGE_PKG_ID 0 -#define BCM4712SMALL_PKG_ID 1 -#define BCM4712MID_PKG_ID 2 -#define BCM4328USBD11G_PKG_ID 2 -#define BCM4328USBDUAL_PKG_ID 3 -#define BCM4328SDIOD11G_PKG_ID 4 -#define BCM4328SDIODUAL_PKG_ID 5 -#define BCM4329_289PIN_PKG_ID 0 -#define BCM4329_182PIN_PKG_ID 1 -#define BCM5354E_PKG_ID 1 -#define HDLSIM5350_PKG_ID 1 -#define HDLSIM_PKG_ID 14 -#define HWSIM_PKG_ID 15 - -#endif diff --git a/bcm4329/dhdutil/include/bcmendian.h b/bcm4329/dhdutil/include/bcmendian.h deleted file mode 100644 index e8f0a87..0000000 --- a/bcm4329/dhdutil/include/bcmendian.h +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Byte order utilities - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: bcmendian.h,v 1.36 2009-11-09 05:29:43 Exp $ - * - * This file by default provides proper behavior on little-endian architectures. - * On big-endian architectures, IL_BIGENDIAN should be defined. - */ - - -#ifndef _BCMENDIAN_H_ -#define _BCMENDIAN_H_ - -#include <typedefs.h> - - -#define BCMSWAP16(val) \ - ((uint16)((((uint16)(val) & (uint16)0x00ffU) << 8) | \ - (((uint16)(val) & (uint16)0xff00U) >> 8))) - - -#define BCMSWAP32(val) \ - ((uint32)((((uint32)(val) & (uint32)0x000000ffU) << 24) | \ - (((uint32)(val) & (uint32)0x0000ff00U) << 8) | \ - (((uint32)(val) & (uint32)0x00ff0000U) >> 8) | \ - (((uint32)(val) & (uint32)0xff000000U) >> 24))) - - -#define BCMSWAP32BY16(val) \ - ((uint32)((((uint32)(val) & (uint32)0x0000ffffU) << 16) | \ - (((uint32)(val) & (uint32)0xffff0000U) >> 16))) - - -#ifndef hton16 -#define HTON16(i) BCMSWAP16(i) -#define hton16(i) bcmswap16(i) -#define HTON32(i) BCMSWAP32(i) -#define hton32(i) bcmswap32(i) -#define NTOH16(i) BCMSWAP16(i) -#define ntoh16(i) bcmswap16(i) -#define NTOH32(i) BCMSWAP32(i) -#define ntoh32(i) bcmswap32(i) -#define LTOH16(i) (i) -#define ltoh16(i) (i) -#define LTOH32(i) (i) -#define ltoh32(i) (i) -#define HTOL16(i) (i) -#define htol16(i) (i) -#define HTOL32(i) (i) -#define htol32(i) (i) -#endif - -#define ltoh16_buf(buf, i) -#define htol16_buf(buf, i) - - -#define load32_ua(a) ltoh32_ua(a) -#define store32_ua(a, v) htol32_ua_store(v, a) -#define load16_ua(a) ltoh16_ua(a) -#define store16_ua(a, v) htol16_ua_store(v, a) - -#define _LTOH16_UA(cp) ((cp)[0] | ((cp)[1] << 8)) -#define _LTOH32_UA(cp) ((cp)[0] | ((cp)[1] << 8) | ((cp)[2] << 16) | ((cp)[3] << 24)) -#define _NTOH16_UA(cp) (((cp)[0] << 8) | (cp)[1]) -#define _NTOH32_UA(cp) (((cp)[0] << 24) | ((cp)[1] << 16) | ((cp)[2] << 8) | (cp)[3]) - -#define ltoh_ua(ptr) \ - (sizeof(*(ptr)) == sizeof(uint8) ? *(const uint8 *)(ptr) : \ - sizeof(*(ptr)) == sizeof(uint16) ? _LTOH16_UA((const uint8 *)(ptr)) : \ - sizeof(*(ptr)) == sizeof(uint32) ? _LTOH32_UA((const uint8 *)(ptr)) : \ - *(uint8 *)0) - -#define ntoh_ua(ptr) \ - (sizeof(*(ptr)) == sizeof(uint8) ? *(const uint8 *)(ptr) : \ - sizeof(*(ptr)) == sizeof(uint16) ? _NTOH16_UA((const uint8 *)(ptr)) : \ - sizeof(*(ptr)) == sizeof(uint32) ? _NTOH32_UA((const uint8 *)(ptr)) : \ - *(uint8 *)0) - -#ifdef __GNUC__ - - - -#define bcmswap16(val) ({ \ - uint16 _val = (val); \ - BCMSWAP16(_val); \ -}) - -#define bcmswap32(val) ({ \ - uint32 _val = (val); \ - BCMSWAP32(_val); \ -}) - -#define bcmswap32by16(val) ({ \ - uint32 _val = (val); \ - BCMSWAP32BY16(_val); \ -}) - -#define bcmswap16_buf(buf, len) ({ \ - uint16 *_buf = (uint16 *)(buf); \ - uint _wds = (len) / 2; \ - while (_wds--) { \ - *_buf = bcmswap16(*_buf); \ - _buf++; \ - } \ -}) - -#define htol16_ua_store(val, bytes) ({ \ - uint16 _val = (val); \ - uint8 *_bytes = (uint8 *)(bytes); \ - _bytes[0] = _val & 0xff; \ - _bytes[1] = _val >> 8; \ -}) - -#define htol32_ua_store(val, bytes) ({ \ - uint32 _val = (val); \ - uint8 *_bytes = (uint8 *)(bytes); \ - _bytes[0] = _val & 0xff; \ - _bytes[1] = (_val >> 8) & 0xff; \ - _bytes[2] = (_val >> 16) & 0xff; \ - _bytes[3] = _val >> 24; \ -}) - -#define hton16_ua_store(val, bytes) ({ \ - uint16 _val = (val); \ - uint8 *_bytes = (uint8 *)(bytes); \ - _bytes[0] = _val >> 8; \ - _bytes[1] = _val & 0xff; \ -}) - -#define hton32_ua_store(val, bytes) ({ \ - uint32 _val = (val); \ - uint8 *_bytes = (uint8 *)(bytes); \ - _bytes[0] = _val >> 24; \ - _bytes[1] = (_val >> 16) & 0xff; \ - _bytes[2] = (_val >> 8) & 0xff; \ - _bytes[3] = _val & 0xff; \ -}) - -#define ltoh16_ua(bytes) ({ \ - const uint8 *_bytes = (const uint8 *)(bytes); \ - _LTOH16_UA(_bytes); \ -}) - -#define ltoh32_ua(bytes) ({ \ - const uint8 *_bytes = (const uint8 *)(bytes); \ - _LTOH32_UA(_bytes); \ -}) - -#define ntoh16_ua(bytes) ({ \ - const uint8 *_bytes = (const uint8 *)(bytes); \ - _NTOH16_UA(_bytes); \ -}) - -#define ntoh32_ua(bytes) ({ \ - const uint8 *_bytes = (const uint8 *)(bytes); \ - _NTOH32_UA(_bytes); \ -}) - -#else - - -static INLINE uint16 -bcmswap16(uint16 val) -{ - return BCMSWAP16(val); -} - -static INLINE uint32 -bcmswap32(uint32 val) -{ - return BCMSWAP32(val); -} - -static INLINE uint32 -bcmswap32by16(uint32 val) -{ - return BCMSWAP32BY16(val); -} - - - - -static INLINE void -bcmswap16_buf(uint16 *buf, uint len) -{ - len = len / 2; - - while (len--) { - *buf = bcmswap16(*buf); - buf++; - } -} - - -static INLINE void -htol16_ua_store(uint16 val, uint8 *bytes) -{ - bytes[0] = val & 0xff; - bytes[1] = val >> 8; -} - - -static INLINE void -htol32_ua_store(uint32 val, uint8 *bytes) -{ - bytes[0] = val & 0xff; - bytes[1] = (val >> 8) & 0xff; - bytes[2] = (val >> 16) & 0xff; - bytes[3] = val >> 24; -} - - -static INLINE void -hton16_ua_store(uint16 val, uint8 *bytes) -{ - bytes[0] = val >> 8; - bytes[1] = val & 0xff; -} - - -static INLINE void -hton32_ua_store(uint32 val, uint8 *bytes) -{ - bytes[0] = val >> 24; - bytes[1] = (val >> 16) & 0xff; - bytes[2] = (val >> 8) & 0xff; - bytes[3] = val & 0xff; -} - - -static INLINE uint16 -ltoh16_ua(const void *bytes) -{ - return _LTOH16_UA((const uint8 *)bytes); -} - - -static INLINE uint32 -ltoh32_ua(const void *bytes) -{ - return _LTOH32_UA((const uint8 *)bytes); -} - - -static INLINE uint16 -ntoh16_ua(const void *bytes) -{ - return _NTOH16_UA((const uint8 *)bytes); -} - - -static INLINE uint32 -ntoh32_ua(const void *bytes) -{ - return _NTOH32_UA((const uint8 *)bytes); -} - -#endif -#endif diff --git a/bcm4329/dhdutil/include/bcmutils.h b/bcm4329/dhdutil/include/bcmutils.h deleted file mode 100644 index 3b823a1..0000000 --- a/bcm4329/dhdutil/include/bcmutils.h +++ /dev/null @@ -1,702 +0,0 @@ -/* - * Misc useful os-independent macros and functions. - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: bcmutils.h,v 13.236.2.16 2011-01-26 00:45:06 Exp $ - */ - - -#ifndef _bcmutils_h_ -#define _bcmutils_h_ - -#include <stddef.h> - -#define bcm_strcpy_s(dst, noOfElements, src) strcpy((dst), (src)) -#define bcm_strncpy_s(dst, noOfElements, src, count) strncpy((dst), (src), (count)) -#define bcm_strcat_s(dst, noOfElements, src) strcat((dst), (src)) - -#ifdef __cplusplus -extern "C" { -#endif - - -#define _BCM_U 0x01 -#define _BCM_L 0x02 -#define _BCM_D 0x04 -#define _BCM_C 0x08 -#define _BCM_P 0x10 -#define _BCM_S 0x20 -#define _BCM_X 0x40 -#define _BCM_SP 0x80 - -extern const unsigned char bcm_ctype[]; -#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)]) - -#define bcm_isalnum(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0) -#define bcm_isalpha(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0) -#define bcm_iscntrl(c) ((bcm_ismask(c)&(_BCM_C)) != 0) -#define bcm_isdigit(c) ((bcm_ismask(c)&(_BCM_D)) != 0) -#define bcm_isgraph(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0) -#define bcm_islower(c) ((bcm_ismask(c)&(_BCM_L)) != 0) -#define bcm_isprint(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0) -#define bcm_ispunct(c) ((bcm_ismask(c)&(_BCM_P)) != 0) -#define bcm_isspace(c) ((bcm_ismask(c)&(_BCM_S)) != 0) -#define bcm_isupper(c) ((bcm_ismask(c)&(_BCM_U)) != 0) -#define bcm_isxdigit(c) ((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0) -#define bcm_tolower(c) (bcm_isupper((c)) ? ((c) + 'a' - 'A') : (c)) -#define bcm_toupper(c) (bcm_islower((c)) ? ((c) + 'A' - 'a') : (c)) - - - -struct bcmstrbuf { - char *buf; - unsigned int size; - char *origbuf; - unsigned int origsize; -}; - - -#ifdef BCMDRIVER -#include <osl.h> - -#define GPIO_PIN_NOTDEFINED 0x20 - - -#define SPINWAIT(exp, us) { \ - uint countdown = (us) + 9; \ - while ((exp) && (countdown >= 10)) {\ - OSL_DELAY(10); \ - countdown -= 10; \ - } \ -} - - -#ifndef PKTQ_LEN_DEFAULT -#define PKTQ_LEN_DEFAULT 128 -#endif -#ifndef PKTQ_MAX_PREC -#define PKTQ_MAX_PREC 16 -#endif - -typedef struct pktq_prec { - void *head; - void *tail; - uint16 len; - uint16 max; -} pktq_prec_t; - - - -struct pktq { - uint16 num_prec; - uint16 hi_prec; - uint16 max; - uint16 len; - - struct pktq_prec q[PKTQ_MAX_PREC]; -}; - - -struct spktq { - uint16 num_prec; - uint16 hi_prec; - uint16 max; - uint16 len; - - struct pktq_prec q[1]; -}; - -#define PKTQ_PREC_ITER(pq, prec) for (prec = (pq)->num_prec - 1; prec >= 0; prec--) - - -typedef bool (*ifpkt_cb_t)(void*, int); - -#ifdef BCMPKTPOOL -#define POOL_ENAB(pool) ((pool) && (pool)->inited) -#if defined(BCM4329C0) -#define SHARED_POOL (pktpool_shared_ptr) -#else -#define SHARED_POOL (pktpool_shared) -#endif -#else -#define POOL_ENAB(bus) 0 -#define SHARED_POOL ((struct pktpool *)NULL) -#endif - -#define PKTPOOL_LEN_MAX 40 -#define PKTPOOL_CB_MAX 3 - -struct pktpool; -typedef void (*pktpool_cb_t)(struct pktpool *pool, void *arg); -typedef struct { - pktpool_cb_t cb; - void *arg; -} pktpool_cbinfo_t; - -#ifdef BCMDBG_POOL - -#define POOL_IDLE 0 -#define POOL_RXFILL 1 -#define POOL_RXDH 2 -#define POOL_RXD11 3 -#define POOL_TXDH 4 -#define POOL_TXD11 5 -#define POOL_AMPDU 6 -#define POOL_TXENQ 7 - -typedef struct { - void *p; - uint32 cycles; - uint32 dur; -} pktpool_dbg_t; - -typedef struct { - uint8 txdh; - uint8 txd11; - uint8 enq; - uint8 rxdh; - uint8 rxd11; - uint8 rxfill; - uint8 idle; -} pktpool_stats_t; -#endif - -typedef struct pktpool { - bool inited; - uint16 r; - uint16 w; - uint16 len; - uint16 maxlen; - uint16 plen; - bool istx; - bool empty; - uint8 cbtoggle; - uint8 cbcnt; - uint8 ecbcnt; - bool emptycb_disable; - pktpool_cbinfo_t cbs[PKTPOOL_CB_MAX]; - pktpool_cbinfo_t ecbs[PKTPOOL_CB_MAX]; - void *q[PKTPOOL_LEN_MAX + 1]; - -#ifdef BCMDBG_POOL - uint8 dbg_cbcnt; - pktpool_cbinfo_t dbg_cbs[PKTPOOL_CB_MAX]; - uint16 dbg_qlen; - pktpool_dbg_t dbg_q[PKTPOOL_LEN_MAX + 1]; -#endif -} pktpool_t; - -#if defined(BCM4329C0) -extern pktpool_t *pktpool_shared_ptr; -#else -extern pktpool_t *pktpool_shared; -#endif - -extern int pktpool_init(osl_t *osh, pktpool_t *pktp, int *pktplen, int plen, bool istx); -extern int pktpool_deinit(osl_t *osh, pktpool_t *pktp); -extern int pktpool_fill(osl_t *osh, pktpool_t *pktp, bool minimal); -extern void* pktpool_get(pktpool_t *pktp); -extern void pktpool_free(pktpool_t *pktp, void *p); -extern int pktpool_add(pktpool_t *pktp, void *p); -extern uint16 pktpool_avail(pktpool_t *pktp); -extern int pktpool_avail_register(pktpool_t *pktp, pktpool_cb_t cb, void *arg); -extern int pktpool_empty_register(pktpool_t *pktp, pktpool_cb_t cb, void *arg); -extern int pktpool_setmaxlen(pktpool_t *pktp, uint16 maxlen); -extern void pktpool_emptycb_disable(pktpool_t *pktp, bool disable); - -#define POOLPTR(pp) ((pktpool_t *)(pp)) -#define pktpool_len(pp) (POOLPTR(pp)->len - 1) -#define pktpool_plen(pp) (POOLPTR(pp)->plen) -#define pktpool_maxlen(pp) (POOLPTR(pp)->maxlen) - -#ifdef BCMDBG_POOL -extern int pktpool_dbg_register(pktpool_t *pktp, pktpool_cb_t cb, void *arg); -extern int pktpool_start_trigger(pktpool_t *pktp, void *p); -extern int pktpool_dbg_dump(pktpool_t *pktp); -extern int pktpool_dbg_notify(pktpool_t *pktp); -extern int pktpool_stats_dump(pktpool_t *pktp, pktpool_stats_t *stats); -#endif - - - -struct ether_addr; - -extern int ether_isbcast(const void *ea); -extern int ether_isnulladdr(const void *ea); - - - -#define pktq_psetmax(pq, prec, _max) ((pq)->q[prec].max = (_max)) -#define pktq_plen(pq, prec) ((pq)->q[prec].len) -#define pktq_pavail(pq, prec) ((pq)->q[prec].max - (pq)->q[prec].len) -#define pktq_pfull(pq, prec) ((pq)->q[prec].len >= (pq)->q[prec].max) -#define pktq_pempty(pq, prec) ((pq)->q[prec].len == 0) - -#define pktq_ppeek(pq, prec) ((pq)->q[prec].head) -#define pktq_ppeek_tail(pq, prec) ((pq)->q[prec].tail) - -extern void *pktq_penq(struct pktq *pq, int prec, void *p); -extern void *pktq_penq_head(struct pktq *pq, int prec, void *p); -extern void *pktq_pdeq(struct pktq *pq, int prec); -extern void *pktq_pdeq_tail(struct pktq *pq, int prec); - -extern void pktq_pflush(osl_t *osh, struct pktq *pq, int prec, bool dir, - ifpkt_cb_t fn, int arg); - -extern bool pktq_pdel(struct pktq *pq, void *p, int prec); - - - -extern int pktq_mlen(struct pktq *pq, uint prec_bmp); -extern void *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out); - - - -#define pktq_len(pq) ((int)(pq)->len) -#define pktq_max(pq) ((int)(pq)->max) -#define pktq_avail(pq) ((int)((pq)->max - (pq)->len)) -#define pktq_full(pq) ((pq)->len >= (pq)->max) -#define pktq_empty(pq) ((pq)->len == 0) - - -#define pktenq(pq, p) pktq_penq(((struct pktq *)pq), 0, (p)) -#define pktenq_head(pq, p) pktq_penq_head(((struct pktq *)pq), 0, (p)) -#define pktdeq(pq) pktq_pdeq(((struct pktq *)pq), 0) -#define pktdeq_tail(pq) pktq_pdeq_tail(((struct pktq *)pq), 0) -#define pktqinit(pq, len) pktq_init(((struct pktq *)pq), 1, len) - -extern void pktq_init(struct pktq *pq, int num_prec, int max_len); - -extern void *pktq_deq(struct pktq *pq, int *prec_out); -extern void *pktq_deq_tail(struct pktq *pq, int *prec_out); -extern void *pktq_peek(struct pktq *pq, int *prec_out); -extern void *pktq_peek_tail(struct pktq *pq, int *prec_out); -extern void pktq_flush(osl_t *osh, struct pktq *pq, bool dir, ifpkt_cb_t fn, int arg); - - - -extern uint pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf); -extern uint pktfrombuf(osl_t *osh, void *p, uint offset, int len, uchar *buf); -extern uint pkttotlen(osl_t *osh, void *p); -extern void *pktlast(osl_t *osh, void *p); -extern uint pktsegcnt(osl_t *osh, void *p); - - -extern uint pktsetprio(void *pkt, bool update_vtag); -#define PKTPRIO_VDSCP 0x100 -#define PKTPRIO_VLAN 0x200 -#define PKTPRIO_UPD 0x400 -#define PKTPRIO_DSCP 0x800 - - -extern int bcm_atoi(char *s); -extern ulong bcm_strtoul(char *cp, char **endp, uint base); -extern char *bcmstrstr(char *haystack, char *needle); -extern char *bcmstrcat(char *dest, const char *src); -extern char *bcmstrncat(char *dest, const char *src, uint size); -extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen); -char* bcmstrtok(char **string, const char *delimiters, char *tokdelim); -int bcmstricmp(const char *s1, const char *s2); -int bcmstrnicmp(const char* s1, const char* s2, int cnt); - - - -extern char *bcm_ether_ntoa(const struct ether_addr *ea, char *buf); -extern int bcm_ether_atoe(char *p, struct ether_addr *ea); - - -struct ipv4_addr; -extern char *bcm_ip_ntoa(struct ipv4_addr *ia, char *buf); - - -extern void bcm_mdelay(uint ms); - -extern char *getvar(char *vars, const char *name); -extern int getintvar(char *vars, const char *name); -extern int getintvararray(char *vars, const char *name, int index); -extern int getintvararraysize(char *vars, const char *name); -extern uint getgpiopin(char *vars, char *pin_name, uint def_pin); -#define bcm_perf_enable() -#define bcmstats(fmt) -#define bcmlog(fmt, a1, a2) -#define bcmdumplog(buf, size) *buf = '\0' -#define bcmdumplogent(buf, idx) -1 - -#define bcmtslog(tstamp, fmt, a1, a2) -#define bcmprinttslogs() -#define bcmprinttstamp(us) - -extern char *bcm_nvram_vars(uint *length); -extern int bcm_nvram_cache(void *sih); - - - - -typedef struct bcm_iovar { - const char *name; - uint16 varid; - uint16 flags; - uint16 type; - uint16 minlen; -} bcm_iovar_t; - - - - -#define IOV_GET 0 -#define IOV_SET 1 - - -#define IOV_GVAL(id) ((id)*2) -#define IOV_SVAL(id) (((id)*2)+IOV_SET) -#define IOV_ISSET(actionid) ((actionid & IOV_SET) == IOV_SET) -#define IOV_ID(actionid) (actionid >> 1) - - - -extern const bcm_iovar_t *bcm_iovar_lookup(const bcm_iovar_t *table, const char *name); -extern int bcm_iovar_lencheck(const bcm_iovar_t *table, void *arg, int len, bool set); -#if defined(WLTINYDUMP) || defined(WLMSG_INFORM) || defined(WLMSG_ASSOC) || \ - defined(WLMSG_PRPKT) || defined(WLMSG_WSEC) -extern int bcm_format_ssid(char* buf, const uchar ssid[], uint ssid_len); -#endif -#endif - - -#define IOVT_VOID 0 -#define IOVT_BOOL 1 -#define IOVT_INT8 2 -#define IOVT_UINT8 3 -#define IOVT_INT16 4 -#define IOVT_UINT16 5 -#define IOVT_INT32 6 -#define IOVT_UINT32 7 -#define IOVT_BUFFER 8 -#define BCM_IOVT_VALID(type) (((unsigned int)(type)) <= IOVT_BUFFER) - - -#define BCM_IOV_TYPE_INIT { \ - "void", \ - "bool", \ - "int8", \ - "uint8", \ - "int16", \ - "uint16", \ - "int32", \ - "uint32", \ - "buffer", \ - "" } - -#define BCM_IOVT_IS_INT(type) (\ - (type == IOVT_BOOL) || \ - (type == IOVT_INT8) || \ - (type == IOVT_UINT8) || \ - (type == IOVT_INT16) || \ - (type == IOVT_UINT16) || \ - (type == IOVT_INT32) || \ - (type == IOVT_UINT32)) - - - -#define BCME_STRLEN 64 -#define VALID_BCMERROR(e) ((e <= 0) && (e >= BCME_LAST)) - - - - -#define BCME_OK 0 -#define BCME_ERROR -1 -#define BCME_BADARG -2 -#define BCME_BADOPTION -3 -#define BCME_NOTUP -4 -#define BCME_NOTDOWN -5 -#define BCME_NOTAP -6 -#define BCME_NOTSTA -7 -#define BCME_BADKEYIDX -8 -#define BCME_RADIOOFF -9 -#define BCME_NOTBANDLOCKED -10 -#define BCME_NOCLK -11 -#define BCME_BADRATESET -12 -#define BCME_BADBAND -13 -#define BCME_BUFTOOSHORT -14 -#define BCME_BUFTOOLONG -15 -#define BCME_BUSY -16 -#define BCME_NOTASSOCIATED -17 -#define BCME_BADSSIDLEN -18 -#define BCME_OUTOFRANGECHAN -19 -#define BCME_BADCHAN -20 -#define BCME_BADADDR -21 -#define BCME_NORESOURCE -22 -#define BCME_UNSUPPORTED -23 -#define BCME_BADLEN -24 -#define BCME_NOTREADY -25 -#define BCME_EPERM -26 -#define BCME_NOMEM -27 -#define BCME_ASSOCIATED -28 -#define BCME_RANGE -29 -#define BCME_NOTFOUND -30 -#define BCME_WME_NOT_ENABLED -31 -#define BCME_TSPEC_NOTFOUND -32 -#define BCME_ACM_NOTSUPPORTED -33 -#define BCME_NOT_WME_ASSOCIATION -34 -#define BCME_SDIO_ERROR -35 -#define BCME_DONGLE_DOWN -36 -#define BCME_VERSION -37 -#define BCME_TXFAIL -38 -#define BCME_RXFAIL -39 -#define BCME_NODEVICE -40 -#define BCME_NMODE_DISABLED -41 -#define BCME_NONRESIDENT -42 -#define BCME_LAST BCME_NONRESIDENT - - -#define BCMERRSTRINGTABLE { \ - "OK", \ - "Undefined error", \ - "Bad Argument", \ - "Bad Option", \ - "Not up", \ - "Not down", \ - "Not AP", \ - "Not STA", \ - "Bad Key Index", \ - "Radio Off", \ - "Not band locked", \ - "No clock", \ - "Bad Rate valueset", \ - "Bad Band", \ - "Buffer too short", \ - "Buffer too long", \ - "Busy", \ - "Not Associated", \ - "Bad SSID len", \ - "Out of Range Channel", \ - "Bad Channel", \ - "Bad Address", \ - "Not Enough Resources", \ - "Unsupported", \ - "Bad length", \ - "Not Ready", \ - "Not Permitted", \ - "No Memory", \ - "Associated", \ - "Not In Range", \ - "Not Found", \ - "WME Not Enabled", \ - "TSPEC Not Found", \ - "ACM Not Supported", \ - "Not WME Association", \ - "SDIO Bus Error", \ - "Dongle Not Accessible", \ - "Incorrect version", \ - "TX Failure", \ - "RX Failure", \ - "Device Not Present", \ - "NMODE Disabled", \ - "Nonresident overlay access", \ -} - -#ifndef ABS -#define ABS(a) (((a) < 0)?-(a):(a)) -#endif - -#ifndef MIN -#define MIN(a, b) (((a) < (b))?(a):(b)) -#endif - -#ifndef MAX -#define MAX(a, b) (((a) > (b))?(a):(b)) -#endif - -#define CEIL(x, y) (((x) + ((y)-1)) / (y)) -#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y)) -#define ISALIGNED(a, x) (((uintptr)(a) & ((x)-1)) == 0) -#define ALIGN_ADDR(addr, boundary) (void *)(((uintptr)(addr) + (boundary) - 1) \ - & ~((boundary) - 1)) -#define ISPOWEROF2(x) ((((x)-1)&(x)) == 0) -#define VALID_MASK(mask) !((mask) & ((mask) + 1)) -#ifndef OFFSETOF -#define OFFSETOF(type, member) ((uint)offsetof(type, member)) -#endif -#ifndef ARRAYSIZE -#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) -#endif - - -extern void *_bcmutils_dummy_fn; -#define REFERENCE_FUNCTION(f) (_bcmutils_dummy_fn = (void *)(f)) - - -#ifndef setbit -#ifndef NBBY -#define NBBY 8 -#endif -#define setbit(a, i) (((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY)) -#define clrbit(a, i) (((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) -#define isset(a, i) (((const uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) -#define isclr(a, i) ((((const uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) -#endif - -#define NBITS(type) (sizeof(type) * 8) -#define NBITVAL(nbits) (1 << (nbits)) -#define MAXBITVAL(nbits) ((1 << (nbits)) - 1) -#define NBITMASK(nbits) MAXBITVAL(nbits) -#define MAXNBVAL(nbyte) MAXBITVAL((nbyte) * 8) - - -#define MUX(pred, true, false) ((pred) ? (true) : (false)) - - -#define MODDEC(x, bound) MUX((x) == 0, (bound) - 1, (x) - 1) -#define MODINC(x, bound) MUX((x) == (bound) - 1, 0, (x) + 1) - - -#define MODDEC_POW2(x, bound) (((x) - 1) & ((bound) - 1)) -#define MODINC_POW2(x, bound) (((x) + 1) & ((bound) - 1)) - - -#define MODADD(x, y, bound) \ - MUX((x) + (y) >= (bound), (x) + (y) - (bound), (x) + (y)) -#define MODSUB(x, y, bound) \ - MUX(((int)(x)) - ((int)(y)) < 0, (x) - (y) + (bound), (x) - (y)) - - -#define MODADD_POW2(x, y, bound) (((x) + (y)) & ((bound) - 1)) -#define MODSUB_POW2(x, y, bound) (((x) - (y)) & ((bound) - 1)) - - -#define CRC8_INIT_VALUE 0xff -#define CRC8_GOOD_VALUE 0x9f -#define CRC16_INIT_VALUE 0xffff -#define CRC16_GOOD_VALUE 0xf0b8 -#define CRC32_INIT_VALUE 0xffffffff -#define CRC32_GOOD_VALUE 0xdebb20e3 - - -typedef struct bcm_bit_desc { - uint32 bit; - const char* name; -} bcm_bit_desc_t; - - -typedef struct bcm_tlv { - uint8 id; - uint8 len; - uint8 data[1]; -} bcm_tlv_t; - - -#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (int)(buflen) >= (int)(2 + (elt)->len)) - - -#define ETHER_ADDR_STR_LEN 18 - - - -static INLINE void -xor_128bit_block(const uint8 *src1, const uint8 *src2, uint8 *dst) -{ - if ( -#ifdef __i386__ - 1 || -#endif - (((uintptr)src1 | (uintptr)src2 | (uintptr)dst) & 3) == 0) { - - - ((uint32 *)dst)[0] = ((const uint32 *)src1)[0] ^ ((const uint32 *)src2)[0]; - ((uint32 *)dst)[1] = ((const uint32 *)src1)[1] ^ ((const uint32 *)src2)[1]; - ((uint32 *)dst)[2] = ((const uint32 *)src1)[2] ^ ((const uint32 *)src2)[2]; - ((uint32 *)dst)[3] = ((const uint32 *)src1)[3] ^ ((const uint32 *)src2)[3]; - } else { - - int k; - for (k = 0; k < 16; k++) - dst[k] = src1[k] ^ src2[k]; - } -} - - - -extern uint8 hndcrc8(uint8 *p, uint nbytes, uint8 crc); -extern uint16 hndcrc16(uint8 *p, uint nbytes, uint16 crc); -extern uint32 hndcrc32(uint8 *p, uint nbytes, uint32 crc); - -#if defined(DHD_DEBUG) || defined(WLMSG_PRHDRS) || defined(WLMSG_PRPKT) || \ - defined(WLMSG_ASSOC) -extern int bcm_format_flags(const bcm_bit_desc_t *bd, uint32 flags, char* buf, int len); -#endif - -#if defined(DHD_DEBUG) || defined(WLMSG_PRHDRS) || defined(WLMSG_PRPKT) || \ - defined(WLMSG_ASSOC) || defined(WLMEDIA_PEAKRATE) -extern int bcm_format_hex(char *str, const void *bytes, int len); -#endif - -extern const char *bcm_crypto_algo_name(uint algo); -extern char *bcm_chipname(uint chipid, char *buf, uint len); -extern char *bcm_brev_str(uint32 brev, char *buf); -extern void printbig(char *buf); -extern void prhex(const char *msg, uchar *buf, uint len); - - -extern bcm_tlv_t *bcm_next_tlv(bcm_tlv_t *elt, int *buflen); -extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key); -extern bcm_tlv_t *bcm_parse_ordered_tlvs(void *buf, int buflen, uint key); - - -extern const char *bcmerrorstr(int bcmerror); - - -typedef uint32 mbool; -#define mboolset(mb, bit) ((mb) |= (bit)) -#define mboolclr(mb, bit) ((mb) &= ~(bit)) -#define mboolisset(mb, bit) (((mb) & (bit)) != 0) -#define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val))) - - -extern uint16 bcm_qdbm_to_mw(uint8 qdbm); -extern uint8 bcm_mw_to_qdbm(uint16 mw); - - -struct fielddesc { - const char *nameandfmt; - uint32 offset; - uint32 len; -}; - -extern void bcm_binit(struct bcmstrbuf *b, char *buf, uint size); -extern int bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...); -extern void bcm_inc_bytes(uchar *num, int num_bytes, uint8 amount); -extern int bcm_cmp_bytes(uchar *arg1, uchar *arg2, uint8 nbytes); -extern void bcm_print_bytes(char *name, const uchar *cdata, int len); - -typedef uint32 (*bcmutl_rdreg_rtn)(void *arg0, uint arg1, uint32 offset); -extern uint bcmdumpfields(bcmutl_rdreg_rtn func_ptr, void *arg0, uint arg1, struct fielddesc *str, - char *buf, uint32 bufsize); - -extern uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint len); -extern uint bcm_bitcount(uint8 *bitmap, uint bytelength); - - - -#define SSID_FMT_BUF_LEN ((4 * DOT11_MAX_SSID_LEN) + 1) - -unsigned int process_nvram_vars(char *varbuf, unsigned int len); - -#ifdef __cplusplus - } -#endif - -#endif diff --git a/bcm4329/dhdutil/include/bcmwifi.h b/bcm4329/dhdutil/include/bcmwifi.h deleted file mode 100644 index 4b0a237..0000000 --- a/bcm4329/dhdutil/include/bcmwifi.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Misc utility routines for WL and Apps - * This header file housing the define and function prototype use by - * both the wl driver, tools & Apps. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * software in any way with any other Broadcom software provided under a license - * other than the GPL, without Broadcom's express prior written consent. - * - * $Id: bcmwifi.h,v 1.29.6.3 2010-08-03 17:47:04 Exp $ - */ - - -#ifndef _bcmwifi_h_ -#define _bcmwifi_h_ - - - -typedef uint16 chanspec_t; - - -#define CH_UPPER_SB 0x01 -#define CH_LOWER_SB 0x02 -#define CH_EWA_VALID 0x04 -#define CH_20MHZ_APART 4 -#define CH_10MHZ_APART 2 -#define CH_5MHZ_APART 1 -#define CH_MAX_2G_CHANNEL 14 -#define WLC_MAX_2G_CHANNEL CH_MAX_2G_CHANNEL -#define MAXCHANNEL 224 - -#define WL_CHANSPEC_CHAN_MASK 0x00ff -#define WL_CHANSPEC_CHAN_SHIFT 0 - -#define WL_CHANSPEC_CTL_SB_MASK 0x0300 -#define WL_CHANSPEC_CTL_SB_SHIFT 8 -#define WL_CHANSPEC_CTL_SB_LOWER 0x0100 -#define WL_CHANSPEC_CTL_SB_UPPER 0x0200 -#define WL_CHANSPEC_CTL_SB_NONE 0x0300 - -#define WL_CHANSPEC_BW_MASK 0x0C00 -#define WL_CHANSPEC_BW_SHIFT 10 -#define WL_CHANSPEC_BW_10 0x0400 -#define WL_CHANSPEC_BW_20 0x0800 -#define WL_CHANSPEC_BW_40 0x0C00 - -#define WL_CHANSPEC_BAND_MASK 0xf000 -#define WL_CHANSPEC_BAND_SHIFT 12 -#define WL_CHANSPEC_BAND_5G 0x1000 -#define WL_CHANSPEC_BAND_2G 0x2000 -#define INVCHANSPEC 255 - - -#define WF_CHAN_FACTOR_2_4_G 4814 -#define WF_CHAN_FACTOR_5_G 10000 -#define WF_CHAN_FACTOR_4_G 8000 - - -#define LOWER_20_SB(channel) (((channel) > CH_10MHZ_APART) ? ((channel) - CH_10MHZ_APART) : 0) -#define UPPER_20_SB(channel) (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \ - ((channel) + CH_10MHZ_APART) : 0) -#define CHSPEC_WLCBANDUNIT(chspec) (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX) -#define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \ - WL_CHANSPEC_CTL_SB_NONE | (((channel) <= CH_MAX_2G_CHANNEL) ? \ - WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G)) -#define NEXT_20MHZ_CHAN(channel) (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \ - ((channel) + CH_20MHZ_APART) : 0) -#define CH40MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \ - ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \ - ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \ - WL_CHANSPEC_BAND_5G)) -#define CHSPEC_CHANNEL(chspec) ((uint8)((chspec) & WL_CHANSPEC_CHAN_MASK)) -#define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK) - - -#define CHSPEC_CTL_SB(chspec) (chspec & WL_CHANSPEC_CTL_SB_MASK) -#define CHSPEC_BW(chspec) (chspec & WL_CHANSPEC_BW_MASK) - -#ifdef WL11N_20MHZONLY - -#define CHSPEC_IS10(chspec) 0 -#define CHSPEC_IS20(chspec) 1 -#ifndef CHSPEC_IS40 -#define CHSPEC_IS40(chspec) 0 -#endif - -#else - -#define CHSPEC_IS10(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10) -#define CHSPEC_IS20(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20) -#ifndef CHSPEC_IS40 -#define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40) -#endif - -#endif - -#define CHSPEC_IS20_UNCOND(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20) - -#define CHSPEC_IS5G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G) -#define CHSPEC_IS2G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G) -#define CHSPEC_SB_NONE(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE) -#define CHSPEC_SB_UPPER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER) -#define CHSPEC_SB_LOWER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER) -#define CHSPEC_CTL_CHAN(chspec) ((CHSPEC_SB_LOWER(chspec)) ? \ - (LOWER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \ - (UPPER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK)))) -#define CHSPEC2WLC_BAND(chspec) (CHSPEC_IS5G(chspec) ? WLC_BAND_5G : WLC_BAND_2G) - -#define CHANSPEC_STR_LEN 8 - - -#define WLC_MAXRATE 108 -#define WLC_RATE_1M 2 -#define WLC_RATE_2M 4 -#define WLC_RATE_5M5 11 -#define WLC_RATE_11M 22 -#define WLC_RATE_6M 12 -#define WLC_RATE_9M 18 -#define WLC_RATE_12M 24 -#define WLC_RATE_18M 36 -#define WLC_RATE_24M 48 -#define WLC_RATE_36M 72 -#define WLC_RATE_48M 96 -#define WLC_RATE_54M 108 - -#define WLC_2G_25MHZ_OFFSET 5 - - -extern char * wf_chspec_ntoa(chanspec_t chspec, char *buf); - - -extern chanspec_t wf_chspec_aton(char *a); - - -extern bool wf_chspec_malformed(chanspec_t chanspec); - - -extern uint8 wf_chspec_ctlchan(chanspec_t chspec); - - -extern chanspec_t wf_chspec_ctlchspec(chanspec_t chspec); - - -extern int wf_mhz2channel(uint freq, uint start_factor); - - -extern int wf_channel2mhz(uint channel, uint start_factor); - -#endif diff --git a/bcm4329/dhdutil/include/dhdioctl.h b/bcm4329/dhdutil/include/dhdioctl.h deleted file mode 100644 index 54a7f5c..0000000 --- a/bcm4329/dhdutil/include/dhdioctl.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Definitions for ioctls to access DHD iovars. - * Based on wlioctl.h (for Broadcom 802.11abg driver). - * (Moves towards generic ioctls for BCM drivers/iovars.) - * - * Definitions subject to change without notice. - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: dhdioctl.h,v 13.11.10.1 2010-12-22 23:47:26 Exp $ - */ - -#ifndef _dhdioctl_h_ -#define _dhdioctl_h_ - -#include <typedefs.h> - - -/* require default structure packing */ -#define BWL_DEFAULT_PACKING -#include <packed_section_start.h> - - -/* Linux network driver ioctl encoding */ -typedef struct dhd_ioctl { - uint cmd; /* common ioctl definition */ - void *buf; /* pointer to user buffer */ - uint len; /* length of user buffer */ - bool set; /* get or set request (optional) */ - uint used; /* bytes read or written (optional) */ - uint needed; /* bytes needed (optional) */ - uint driver; /* to identify target driver */ -} dhd_ioctl_t; - -/* Underlying BUS definition */ -enum { - BUS_TYPE_USB = 0, /* for USB dongles */ - BUS_TYPE_SDIO /* for SDIO dongles */ -}; - -/* per-driver magic numbers */ -#define DHD_IOCTL_MAGIC 0x00444944 - -/* bump this number if you change the ioctl interface */ -#define DHD_IOCTL_VERSION 1 - -#define DHD_IOCTL_MAXLEN 8192 /* max length ioctl buffer required */ -#define DHD_IOCTL_SMLEN 256 /* "small" length ioctl buffer required */ - -/* common ioctl definitions */ -#define DHD_GET_MAGIC 0 -#define DHD_GET_VERSION 1 -#define DHD_GET_VAR 2 -#define DHD_SET_VAR 3 - -/* message levels */ -#define DHD_ERROR_VAL 0x0001 -#define DHD_TRACE_VAL 0x0002 -#define DHD_INFO_VAL 0x0004 -#define DHD_DATA_VAL 0x0008 -#define DHD_CTL_VAL 0x0010 -#define DHD_TIMER_VAL 0x0020 -#define DHD_HDRS_VAL 0x0040 -#define DHD_BYTES_VAL 0x0080 -#define DHD_INTR_VAL 0x0100 -#define DHD_LOG_VAL 0x0200 -#define DHD_GLOM_VAL 0x0400 -#define DHD_EVENT_VAL 0x0800 -#define DHD_BTA_VAL 0x1000 -#define DHD_ISCAN_VAL 0x2000 - -#ifdef SDTEST -/* For pktgen iovar */ -typedef struct dhd_pktgen { - uint version; /* To allow structure change tracking */ - uint freq; /* Max ticks between tx/rx attempts */ - uint count; /* Test packets to send/rcv each attempt */ - uint print; /* Print counts every <print> attempts */ - uint total; /* Total packets (or bursts) */ - uint minlen; /* Minimum length of packets to send */ - uint maxlen; /* Maximum length of packets to send */ - uint numsent; /* Count of test packets sent */ - uint numrcvd; /* Count of test packets received */ - uint numfail; /* Count of test send failures */ - uint mode; /* Test mode (type of test packets) */ - uint stop; /* Stop after this many tx failures */ -} dhd_pktgen_t; - -/* Version in case structure changes */ -#define DHD_PKTGEN_VERSION 2 - -/* Type of test packets to use */ -#define DHD_PKTGEN_ECHO 1 /* Send echo requests */ -#define DHD_PKTGEN_SEND 2 /* Send discard packets */ -#define DHD_PKTGEN_RXBURST 3 /* Request dongle send N packets */ -#define DHD_PKTGEN_RECV 4 /* Continuous rx from continuous tx dongle */ -#endif /* SDTEST */ - -/* Enter idle immediately (no timeout) */ -#define DHD_IDLE_IMMEDIATE (-1) - -/* Values for idleclock iovar: other values are the sd_divisor to use when idle */ -#define DHD_IDLE_ACTIVE 0 /* Do not request any SD clock change when idle */ -#define DHD_IDLE_STOP (-1) /* Request SD clock be stopped (and use SD1 mode) */ - - -/* require default structure packing */ -#include <packed_section_end.h> - -#endif /* _dhdioctl_h_ */ diff --git a/bcm4329/dhdutil/include/epivers.h b/bcm4329/dhdutil/include/epivers.h deleted file mode 100644 index 72b2470..0000000 --- a/bcm4329/dhdutil/include/epivers.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: epivers.h.in,v 13.32.4.1 2010-09-17 00:39:18 Exp $ - * -*/ - - -#ifndef _epivers_h_ -#define _epivers_h_ - -#define EPI_MAJOR_VERSION 5 - -#define EPI_MINOR_VERSION 90 - -#define EPI_RC_NUMBER 125 - -#define EPI_INCREMENTAL_NUMBER 14 - -#define EPI_BUILD_NUMBER 0 - -#define EPI_VERSION 5, 90, 125, 14 - -#define EPI_VERSION_NUM 0x055a7d0e - -#define EPI_VERSION_DEV 5.90.125 - - -#define EPI_VERSION_STR "5.90.125.14" - -#endif diff --git a/bcm4329/dhdutil/include/miniopt.h b/bcm4329/dhdutil/include/miniopt.h deleted file mode 100644 index f3d9ce8..0000000 --- a/bcm4329/dhdutil/include/miniopt.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Command line options parser. - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: miniopt.h,v 1.3 2009-01-15 00:06:54 Exp $ - */ - - -#ifndef MINI_OPT_H -#define MINI_OPT_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* ---- Include Files ---------------------------------------------------- */ -/* ---- Constants and Types ---------------------------------------------- */ - -#define MINIOPT_MAXKEY 128 /* Max options */ -typedef struct miniopt { - - /* These are persistent after miniopt_init() */ - const char* name; /* name for prompt in error strings */ - const char* flags; /* option chars that take no args */ - bool longflags; /* long options may be flags */ - bool opt_end; /* at end of options (passed a "--") */ - - /* These are per-call to miniopt() */ - - int consumed; /* number of argv entries cosumed in - * the most recent call to miniopt() - */ - bool positional; - bool good_int; /* 'val' member is the result of a sucessful - * strtol conversion of the option value - */ - char opt; - char key[MINIOPT_MAXKEY]; - char* valstr; /* positional param, or value for the option, - * or null if the option had - * no accompanying value - */ - uint uval; /* strtol translation of valstr */ - int val; /* strtol translation of valstr */ -} miniopt_t; - -void miniopt_init(miniopt_t *t, const char* name, const char* flags, bool longflags); -int miniopt(miniopt_t *t, char **argv); - - -/* ---- Variable Externs ------------------------------------------------- */ -/* ---- Function Prototypes ---------------------------------------------- */ - - -#ifdef __cplusplus - } -#endif - -#endif /* MINI_OPT_H */ diff --git a/bcm4329/dhdutil/include/packed_section_end.h b/bcm4329/dhdutil/include/packed_section_end.h deleted file mode 100644 index 5644a93..0000000 --- a/bcm4329/dhdutil/include/packed_section_end.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Declare directives for structure packing. No padding will be provided - * between the members of packed structures, and therefore, there is no - * guarantee that structure members will be aligned. - * - * Declaring packed structures is compiler specific. In order to handle all - * cases, packed structures should be delared as: - * - * #include <packed_section_start.h> - * - * typedef BWL_PRE_PACKED_STRUCT struct foobar_t { - * some_struct_members; - * } BWL_POST_PACKED_STRUCT foobar_t; - * - * #include <packed_section_end.h> - * - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: packed_section_end.h,v 1.4 2008-12-09 23:43:22 Exp $ - */ - - - - -#ifdef BWL_PACKED_SECTION - #undef BWL_PACKED_SECTION -#else - #error "BWL_PACKED_SECTION is NOT defined!" -#endif - - - - - -#undef BWL_PRE_PACKED_STRUCT -#undef BWL_POST_PACKED_STRUCT diff --git a/bcm4329/dhdutil/include/packed_section_start.h b/bcm4329/dhdutil/include/packed_section_start.h deleted file mode 100644 index 6196aae..0000000 --- a/bcm4329/dhdutil/include/packed_section_start.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Declare directives for structure packing. No padding will be provided - * between the members of packed structures, and therefore, there is no - * guarantee that structure members will be aligned. - * - * Declaring packed structures is compiler specific. In order to handle all - * cases, packed structures should be delared as: - * - * #include <packed_section_start.h> - * - * typedef BWL_PRE_PACKED_STRUCT struct foobar_t { - * some_struct_members; - * } BWL_POST_PACKED_STRUCT foobar_t; - * - * #include <packed_section_end.h> - * - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: packed_section_start.h,v 1.4.124.1 2010-09-17 00:47:03 Exp $ - */ - - - - -#ifdef BWL_PACKED_SECTION - #error "BWL_PACKED_SECTION is already defined!" -#else - #define BWL_PACKED_SECTION -#endif - - - - - -#if defined(__GNUC__) - #define BWL_PRE_PACKED_STRUCT - #define BWL_POST_PACKED_STRUCT __attribute__ ((packed)) -#elif defined(__CC_ARM) - #define BWL_PRE_PACKED_STRUCT __packed - #define BWL_POST_PACKED_STRUCT -#else - #error "Unknown compiler!" -#endif diff --git a/bcm4329/dhdutil/include/proto/802.11.h b/bcm4329/dhdutil/include/proto/802.11.h deleted file mode 100644 index c74fe5f..0000000 --- a/bcm4329/dhdutil/include/proto/802.11.h +++ /dev/null @@ -1,1725 +0,0 @@ -/* - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Fundamental types and constants relating to 802.11 - * - * $Id: 802.11.h,v 9.260.2.6 2010-12-15 21:41:14 Exp $ - */ - - -#ifndef _802_11_H_ -#define _802_11_H_ - -#ifndef _TYPEDEFS_H_ -#include <typedefs.h> -#endif - -#ifndef _NET_ETHERNET_H_ -#include <proto/ethernet.h> -#endif - -#include <proto/wpa.h> - - -#include <packed_section_start.h> - - -#define DOT11_TU_TO_US 1024 - - -#define DOT11_A3_HDR_LEN 24 -#define DOT11_A4_HDR_LEN 30 -#define DOT11_MAC_HDR_LEN DOT11_A3_HDR_LEN -#define DOT11_FCS_LEN 4 -#define DOT11_ICV_LEN 4 -#define DOT11_ICV_AES_LEN 8 -#define DOT11_QOS_LEN 2 -#define DOT11_HTC_LEN 4 - -#define DOT11_KEY_INDEX_SHIFT 6 -#define DOT11_IV_LEN 4 -#define DOT11_IV_TKIP_LEN 8 -#define DOT11_IV_AES_OCB_LEN 4 -#define DOT11_IV_AES_CCM_LEN 8 -#define DOT11_IV_MAX_LEN 8 - - -#define DOT11_MAX_MPDU_BODY_LEN 2304 - -#define DOT11_MAX_MPDU_LEN (DOT11_A4_HDR_LEN + \ - DOT11_QOS_LEN + \ - DOT11_IV_AES_CCM_LEN + \ - DOT11_MAX_MPDU_BODY_LEN + \ - DOT11_ICV_LEN + \ - DOT11_FCS_LEN) - -#define DOT11_MAX_SSID_LEN 32 - - -#define DOT11_DEFAULT_RTS_LEN 2347 -#define DOT11_MAX_RTS_LEN 2347 - - -#define DOT11_MIN_FRAG_LEN 256 -#define DOT11_MAX_FRAG_LEN 2346 -#define DOT11_DEFAULT_FRAG_LEN 2346 - - -#define DOT11_MIN_BEACON_PERIOD 1 -#define DOT11_MAX_BEACON_PERIOD 0xFFFF - - -#define DOT11_MIN_DTIM_PERIOD 1 -#define DOT11_MAX_DTIM_PERIOD 0xFF - - -#define DOT11_LLC_SNAP_HDR_LEN 8 -#define DOT11_OUI_LEN 3 -BWL_PRE_PACKED_STRUCT struct dot11_llc_snap_header { - uint8 dsap; - uint8 ssap; - uint8 ctl; - uint8 oui[DOT11_OUI_LEN]; - uint16 type; -} BWL_POST_PACKED_STRUCT; - - -#define RFC1042_HDR_LEN (ETHER_HDR_LEN + DOT11_LLC_SNAP_HDR_LEN) - - - -BWL_PRE_PACKED_STRUCT struct dot11_header { - uint16 fc; - uint16 durid; - struct ether_addr a1; - struct ether_addr a2; - struct ether_addr a3; - uint16 seq; - struct ether_addr a4; -} BWL_POST_PACKED_STRUCT; - - - -BWL_PRE_PACKED_STRUCT struct dot11_rts_frame { - uint16 fc; - uint16 durid; - struct ether_addr ra; - struct ether_addr ta; -} BWL_POST_PACKED_STRUCT; -#define DOT11_RTS_LEN 16 - -BWL_PRE_PACKED_STRUCT struct dot11_cts_frame { - uint16 fc; - uint16 durid; - struct ether_addr ra; -} BWL_POST_PACKED_STRUCT; -#define DOT11_CTS_LEN 10 - -BWL_PRE_PACKED_STRUCT struct dot11_ack_frame { - uint16 fc; - uint16 durid; - struct ether_addr ra; -} BWL_POST_PACKED_STRUCT; -#define DOT11_ACK_LEN 10 - -BWL_PRE_PACKED_STRUCT struct dot11_ps_poll_frame { - uint16 fc; - uint16 durid; - struct ether_addr bssid; - struct ether_addr ta; -} BWL_POST_PACKED_STRUCT; -#define DOT11_PS_POLL_LEN 16 - -BWL_PRE_PACKED_STRUCT struct dot11_cf_end_frame { - uint16 fc; - uint16 durid; - struct ether_addr ra; - struct ether_addr bssid; -} BWL_POST_PACKED_STRUCT; -#define DOT11_CS_END_LEN 16 - - -BWL_PRE_PACKED_STRUCT struct dot11_action_wifi_vendor_specific { - uint8 category; - uint8 OUI[3]; - uint8 type; - uint8 subtype; - uint8 data[1040]; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_action_wifi_vendor_specific dot11_action_wifi_vendor_specific_t; - - -BWL_PRE_PACKED_STRUCT struct dot11_action_vs_frmhdr { - uint8 category; - uint8 OUI[3]; - uint8 type; - uint8 subtype; - uint8 data[1]; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_action_vs_frmhdr dot11_action_vs_frmhdr_t; -#define DOT11_ACTION_VS_HDR_LEN 6 - -#define BCM_ACTION_OUI_BYTE0 0x00 -#define BCM_ACTION_OUI_BYTE1 0x90 -#define BCM_ACTION_OUI_BYTE2 0x4c - - -#define DOT11_BA_CTL_POLICY_NORMAL 0x0000 -#define DOT11_BA_CTL_POLICY_NOACK 0x0001 -#define DOT11_BA_CTL_POLICY_MASK 0x0001 - -#define DOT11_BA_CTL_MTID 0x0002 -#define DOT11_BA_CTL_COMPRESSED 0x0004 - -#define DOT11_BA_CTL_NUMMSDU_MASK 0x0FC0 -#define DOT11_BA_CTL_NUMMSDU_SHIFT 6 - -#define DOT11_BA_CTL_TID_MASK 0xF000 -#define DOT11_BA_CTL_TID_SHIFT 12 - - -BWL_PRE_PACKED_STRUCT struct dot11_ctl_header { - uint16 fc; - uint16 durid; - struct ether_addr ra; - struct ether_addr ta; -} BWL_POST_PACKED_STRUCT; -#define DOT11_CTL_HDR_LEN 16 - - -BWL_PRE_PACKED_STRUCT struct dot11_bar { - uint16 bar_control; - uint16 seqnum; -} BWL_POST_PACKED_STRUCT; -#define DOT11_BAR_LEN 4 - -#define DOT11_BA_BITMAP_LEN 128 -#define DOT11_BA_CMP_BITMAP_LEN 8 - -BWL_PRE_PACKED_STRUCT struct dot11_ba { - uint16 ba_control; - uint16 seqnum; - uint8 bitmap[DOT11_BA_BITMAP_LEN]; -} BWL_POST_PACKED_STRUCT; -#define DOT11_BA_LEN 4 - - -BWL_PRE_PACKED_STRUCT struct dot11_management_header { - uint16 fc; - uint16 durid; - struct ether_addr da; - struct ether_addr sa; - struct ether_addr bssid; - uint16 seq; -} BWL_POST_PACKED_STRUCT; -#define DOT11_MGMT_HDR_LEN 24 - - - -BWL_PRE_PACKED_STRUCT struct dot11_bcn_prb { - uint32 timestamp[2]; - uint16 beacon_interval; - uint16 capability; -} BWL_POST_PACKED_STRUCT; -#define DOT11_BCN_PRB_LEN 12 -#define DOT11_BCN_PRB_FIXED_LEN 12 - -BWL_PRE_PACKED_STRUCT struct dot11_auth { - uint16 alg; - uint16 seq; - uint16 status; -} BWL_POST_PACKED_STRUCT; -#define DOT11_AUTH_FIXED_LEN 6 - -BWL_PRE_PACKED_STRUCT struct dot11_assoc_req { - uint16 capability; - uint16 listen; -} BWL_POST_PACKED_STRUCT; -#define DOT11_ASSOC_REQ_FIXED_LEN 4 - -BWL_PRE_PACKED_STRUCT struct dot11_reassoc_req { - uint16 capability; - uint16 listen; - struct ether_addr ap; -} BWL_POST_PACKED_STRUCT; -#define DOT11_REASSOC_REQ_FIXED_LEN 10 - -BWL_PRE_PACKED_STRUCT struct dot11_assoc_resp { - uint16 capability; - uint16 status; - uint16 aid; -} BWL_POST_PACKED_STRUCT; -#define DOT11_ASSOC_RESP_FIXED_LEN 6 - -BWL_PRE_PACKED_STRUCT struct dot11_action_measure { - uint8 category; - uint8 action; - uint8 token; - uint8 data[1]; -} BWL_POST_PACKED_STRUCT; -#define DOT11_ACTION_MEASURE_LEN 3 - -BWL_PRE_PACKED_STRUCT struct dot11_action_ht_ch_width { - uint8 category; - uint8 action; - uint8 ch_width; -} BWL_POST_PACKED_STRUCT; - -BWL_PRE_PACKED_STRUCT struct dot11_action_ht_mimops { - uint8 category; - uint8 action; - uint8 control; -} BWL_POST_PACKED_STRUCT; - -#define SM_PWRSAVE_ENABLE 1 -#define SM_PWRSAVE_MODE 2 - - -BWL_PRE_PACKED_STRUCT struct dot11_power_cnst { - uint8 id; - uint8 len; - uint8 power; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_power_cnst dot11_power_cnst_t; - -BWL_PRE_PACKED_STRUCT struct dot11_power_cap { - uint8 min; - uint8 max; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_power_cap dot11_power_cap_t; - -BWL_PRE_PACKED_STRUCT struct dot11_tpc_rep { - uint8 id; - uint8 len; - uint8 tx_pwr; - uint8 margin; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_tpc_rep dot11_tpc_rep_t; -#define DOT11_MNG_IE_TPC_REPORT_LEN 2 - -BWL_PRE_PACKED_STRUCT struct dot11_supp_channels { - uint8 id; - uint8 len; - uint8 first_channel; - uint8 num_channels; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_supp_channels dot11_supp_channels_t; - - -BWL_PRE_PACKED_STRUCT struct dot11_extch { - uint8 id; - uint8 len; - uint8 extch; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_extch dot11_extch_ie_t; - -BWL_PRE_PACKED_STRUCT struct dot11_brcm_extch { - uint8 id; - uint8 len; - uint8 oui[3]; - uint8 type; - uint8 extch; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_brcm_extch dot11_brcm_extch_ie_t; - -#define BRCM_EXTCH_IE_LEN 5 -#define BRCM_EXTCH_IE_TYPE 53 -#define DOT11_EXTCH_IE_LEN 1 -#define DOT11_EXT_CH_MASK 0x03 -#define DOT11_EXT_CH_UPPER 0x01 -#define DOT11_EXT_CH_LOWER 0x03 -#define DOT11_EXT_CH_NONE 0x00 - -BWL_PRE_PACKED_STRUCT struct dot11_action_frmhdr { - uint8 category; - uint8 action; - uint8 data[1]; -} BWL_POST_PACKED_STRUCT; -#define DOT11_ACTION_FRMHDR_LEN 2 - - -BWL_PRE_PACKED_STRUCT struct dot11_channel_switch { - uint8 id; - uint8 len; - uint8 mode; - uint8 channel; - uint8 count; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_channel_switch dot11_chan_switch_ie_t; - -#define DOT11_SWITCH_IE_LEN 3 - -#define DOT11_CSA_MODE_ADVISORY 0 -#define DOT11_CSA_MODE_NO_TX 1 - -BWL_PRE_PACKED_STRUCT struct dot11_action_switch_channel { - uint8 category; - uint8 action; - dot11_chan_switch_ie_t chan_switch_ie; - dot11_brcm_extch_ie_t extch_ie; -} BWL_POST_PACKED_STRUCT; - -BWL_PRE_PACKED_STRUCT struct dot11_csa_body { - uint8 mode; - uint8 reg; - uint8 channel; - uint8 count; -} BWL_POST_PACKED_STRUCT; - - -BWL_PRE_PACKED_STRUCT struct dot11_ext_csa { - uint8 id; - uint8 len; - struct dot11_csa_body b; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_ext_csa dot11_ext_csa_ie_t; -#define DOT11_EXT_CSA_IE_LEN 4 - -BWL_PRE_PACKED_STRUCT struct dot11_action_ext_csa { - uint8 category; - uint8 action; - dot11_ext_csa_ie_t chan_switch_ie; -} BWL_POST_PACKED_STRUCT; - -BWL_PRE_PACKED_STRUCT struct dot11y_action_ext_csa { - uint8 category; - uint8 action; - struct dot11_csa_body b; -} BWL_POST_PACKED_STRUCT; - -BWL_PRE_PACKED_STRUCT struct dot11_obss_coex { - uint8 id; - uint8 len; - uint8 info; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_obss_coex dot11_obss_coex_t; -#define DOT11_OBSS_COEXINFO_LEN 1 - -#define DOT11_OBSS_COEX_INFO_REQ 0x01 -#define DOT11_OBSS_COEX_40MHZ_INTOLERANT 0x02 -#define DOT11_OBSS_COEX_20MHZ_WIDTH_REQ 0x04 - -BWL_PRE_PACKED_STRUCT struct dot11_obss_chanlist { - uint8 id; - uint8 len; - uint8 regclass; - uint8 chanlist[1]; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_obss_chanlist dot11_obss_chanlist_t; -#define DOT11_OBSS_CHANLIST_FIXED_LEN 1 - -BWL_PRE_PACKED_STRUCT struct dot11_extcap_ie { - uint8 id; - uint8 len; - uint8 cap; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_extcap_ie dot11_extcap_ie_t; -#define DOT11_EXTCAP_LEN 1 - - - -#define DOT11_MEASURE_TYPE_BASIC 0 -#define DOT11_MEASURE_TYPE_CCA 1 -#define DOT11_MEASURE_TYPE_RPI 2 -#define DOT11_MEASURE_TYPE_CHLOAD 3 -#define DOT11_MEASURE_TYPE_NOISE 4 -#define DOT11_MEASURE_TYPE_BEACON 5 -#define DOT11_MEASURE_TYPE_FRAME 6 -#define DOT11_MEASURE_TYPE_STATS 7 -#define DOT11_MEASURE_TYPE_LCI 8 -#define DOT11_MEASURE_TYPE_TXSTREAM 9 -#define DOT11_MEASURE_TYPE_PAUSE 255 - - -#define DOT11_MEASURE_MODE_PARALLEL (1<<0) -#define DOT11_MEASURE_MODE_ENABLE (1<<1) -#define DOT11_MEASURE_MODE_REQUEST (1<<2) -#define DOT11_MEASURE_MODE_REPORT (1<<3) -#define DOT11_MEASURE_MODE_DUR (1<<4) - -#define DOT11_MEASURE_MODE_LATE (1<<0) -#define DOT11_MEASURE_MODE_INCAPABLE (1<<1) -#define DOT11_MEASURE_MODE_REFUSED (1<<2) - -#define DOT11_MEASURE_BASIC_MAP_BSS ((uint8)(1<<0)) -#define DOT11_MEASURE_BASIC_MAP_OFDM ((uint8)(1<<1)) -#define DOT11_MEASURE_BASIC_MAP_UKNOWN ((uint8)(1<<2)) -#define DOT11_MEASURE_BASIC_MAP_RADAR ((uint8)(1<<3)) -#define DOT11_MEASURE_BASIC_MAP_UNMEAS ((uint8)(1<<4)) - -BWL_PRE_PACKED_STRUCT struct dot11_meas_req { - uint8 id; - uint8 len; - uint8 token; - uint8 mode; - uint8 type; - uint8 channel; - uint8 start_time[8]; - uint16 duration; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_meas_req dot11_meas_req_t; -#define DOT11_MNG_IE_MREQ_LEN 14 - -#define DOT11_MNG_IE_MREQ_FIXED_LEN 3 - -BWL_PRE_PACKED_STRUCT struct dot11_meas_rep { - uint8 id; - uint8 len; - uint8 token; - uint8 mode; - uint8 type; - BWL_PRE_PACKED_STRUCT union - { - BWL_PRE_PACKED_STRUCT struct { - uint8 channel; - uint8 start_time[8]; - uint16 duration; - uint8 map; - } BWL_POST_PACKED_STRUCT basic; - uint8 data[1]; - } BWL_POST_PACKED_STRUCT rep; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_meas_rep dot11_meas_rep_t; - - -#define DOT11_MNG_IE_MREP_FIXED_LEN 3 - -BWL_PRE_PACKED_STRUCT struct dot11_meas_rep_basic { - uint8 channel; - uint8 start_time[8]; - uint16 duration; - uint8 map; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_meas_rep_basic dot11_meas_rep_basic_t; -#define DOT11_MEASURE_BASIC_REP_LEN 12 - -BWL_PRE_PACKED_STRUCT struct dot11_quiet { - uint8 id; - uint8 len; - uint8 count; - uint8 period; - uint16 duration; - uint16 offset; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_quiet dot11_quiet_t; - -BWL_PRE_PACKED_STRUCT struct chan_map_tuple { - uint8 channel; - uint8 map; -} BWL_POST_PACKED_STRUCT; -typedef struct chan_map_tuple chan_map_tuple_t; - -BWL_PRE_PACKED_STRUCT struct dot11_ibss_dfs { - uint8 id; - uint8 len; - uint8 eaddr[ETHER_ADDR_LEN]; - uint8 interval; - chan_map_tuple_t map[1]; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_ibss_dfs dot11_ibss_dfs_t; - - -#define WME_OUI "\x00\x50\xf2" -#define WME_OUI_LEN 3 -#define WME_OUI_TYPE 2 -#define WME_VER 1 -#define WME_TYPE 2 -#define WME_SUBTYPE_IE 0 -#define WME_SUBTYPE_PARAM_IE 1 -#define WME_SUBTYPE_TSPEC 2 - - -#define AC_BE 0 -#define AC_BK 1 -#define AC_VI 2 -#define AC_VO 3 -#define AC_COUNT 4 - -typedef uint8 ac_bitmap_t; - -#define AC_BITMAP_NONE 0x0 -#define AC_BITMAP_ALL 0xf -#define AC_BITMAP_TST(ab, ac) (((ab) & (1 << (ac))) != 0) -#define AC_BITMAP_SET(ab, ac) (((ab) |= (1 << (ac)))) -#define AC_BITMAP_RESET(ab, ac) (((ab) &= ~(1 << (ac)))) - - -BWL_PRE_PACKED_STRUCT struct wme_ie { - uint8 oui[3]; - uint8 type; - uint8 subtype; - uint8 version; - uint8 qosinfo; -} BWL_POST_PACKED_STRUCT; -typedef struct wme_ie wme_ie_t; -#define WME_IE_LEN 7 - -BWL_PRE_PACKED_STRUCT struct edcf_acparam { - uint8 ACI; - uint8 ECW; - uint16 TXOP; -} BWL_POST_PACKED_STRUCT; -typedef struct edcf_acparam edcf_acparam_t; - - -BWL_PRE_PACKED_STRUCT struct wme_param_ie { - uint8 oui[3]; - uint8 type; - uint8 subtype; - uint8 version; - uint8 qosinfo; - uint8 rsvd; - edcf_acparam_t acparam[AC_COUNT]; -} BWL_POST_PACKED_STRUCT; -typedef struct wme_param_ie wme_param_ie_t; -#define WME_PARAM_IE_LEN 24 - - -#define WME_QI_AP_APSD_MASK 0x80 -#define WME_QI_AP_APSD_SHIFT 7 -#define WME_QI_AP_COUNT_MASK 0x0f -#define WME_QI_AP_COUNT_SHIFT 0 - - -#define WME_QI_STA_MAXSPLEN_MASK 0x60 -#define WME_QI_STA_MAXSPLEN_SHIFT 5 -#define WME_QI_STA_APSD_ALL_MASK 0xf -#define WME_QI_STA_APSD_ALL_SHIFT 0 -#define WME_QI_STA_APSD_BE_MASK 0x8 -#define WME_QI_STA_APSD_BE_SHIFT 3 -#define WME_QI_STA_APSD_BK_MASK 0x4 -#define WME_QI_STA_APSD_BK_SHIFT 2 -#define WME_QI_STA_APSD_VI_MASK 0x2 -#define WME_QI_STA_APSD_VI_SHIFT 1 -#define WME_QI_STA_APSD_VO_MASK 0x1 -#define WME_QI_STA_APSD_VO_SHIFT 0 - - -#define EDCF_AIFSN_MIN 1 -#define EDCF_AIFSN_MAX 15 -#define EDCF_AIFSN_MASK 0x0f -#define EDCF_ACM_MASK 0x10 -#define EDCF_ACI_MASK 0x60 -#define EDCF_ACI_SHIFT 5 -#define EDCF_AIFSN_SHIFT 12 - - -#define EDCF_ECW_MIN 0 -#define EDCF_ECW_MAX 15 -#define EDCF_ECW2CW(exp) ((1 << (exp)) - 1) -#define EDCF_ECWMIN_MASK 0x0f -#define EDCF_ECWMAX_MASK 0xf0 -#define EDCF_ECWMAX_SHIFT 4 - - -#define EDCF_TXOP_MIN 0 -#define EDCF_TXOP_MAX 65535 -#define EDCF_TXOP2USEC(txop) ((txop) << 5) - - -#define NON_EDCF_AC_BE_ACI_STA 0x02 - - -#define EDCF_AC_BE_ACI_STA 0x03 -#define EDCF_AC_BE_ECW_STA 0xA4 -#define EDCF_AC_BE_TXOP_STA 0x0000 -#define EDCF_AC_BK_ACI_STA 0x27 -#define EDCF_AC_BK_ECW_STA 0xA4 -#define EDCF_AC_BK_TXOP_STA 0x0000 -#define EDCF_AC_VI_ACI_STA 0x42 -#define EDCF_AC_VI_ECW_STA 0x43 -#define EDCF_AC_VI_TXOP_STA 0x005e -#define EDCF_AC_VO_ACI_STA 0x62 -#define EDCF_AC_VO_ECW_STA 0x32 -#define EDCF_AC_VO_TXOP_STA 0x002f - - -#define EDCF_AC_BE_ACI_AP 0x03 -#define EDCF_AC_BE_ECW_AP 0x64 -#define EDCF_AC_BE_TXOP_AP 0x0000 -#define EDCF_AC_BK_ACI_AP 0x27 -#define EDCF_AC_BK_ECW_AP 0xA4 -#define EDCF_AC_BK_TXOP_AP 0x0000 -#define EDCF_AC_VI_ACI_AP 0x41 -#define EDCF_AC_VI_ECW_AP 0x43 -#define EDCF_AC_VI_TXOP_AP 0x005e -#define EDCF_AC_VO_ACI_AP 0x61 -#define EDCF_AC_VO_ECW_AP 0x32 -#define EDCF_AC_VO_TXOP_AP 0x002f - - -BWL_PRE_PACKED_STRUCT struct edca_param_ie { - uint8 qosinfo; - uint8 rsvd; - edcf_acparam_t acparam[AC_COUNT]; -} BWL_POST_PACKED_STRUCT; -typedef struct edca_param_ie edca_param_ie_t; -#define EDCA_PARAM_IE_LEN 18 - - -BWL_PRE_PACKED_STRUCT struct qos_cap_ie { - uint8 qosinfo; -} BWL_POST_PACKED_STRUCT; -typedef struct qos_cap_ie qos_cap_ie_t; - -BWL_PRE_PACKED_STRUCT struct dot11_qbss_load_ie { - uint8 id; - uint8 length; - uint16 station_count; - uint8 channel_utilization; - uint16 aac; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_qbss_load_ie dot11_qbss_load_ie_t; - - -#define FIXED_MSDU_SIZE 0x8000 -#define MSDU_SIZE_MASK 0x7fff - - - -#define INTEGER_SHIFT 13 -#define FRACTION_MASK 0x1FFF - - -BWL_PRE_PACKED_STRUCT struct dot11_management_notification { - uint8 category; - uint8 action; - uint8 token; - uint8 status; - uint8 data[1]; -} BWL_POST_PACKED_STRUCT; -#define DOT11_MGMT_NOTIFICATION_LEN 4 - - -#define WME_ADDTS_REQUEST 0 -#define WME_ADDTS_RESPONSE 1 -#define WME_DELTS_REQUEST 2 - - -#define WME_ADMISSION_ACCEPTED 0 -#define WME_INVALID_PARAMETERS 1 -#define WME_ADMISSION_REFUSED 3 - - -#define BCN_PRB_SSID(body) ((char*)(body) + DOT11_BCN_PRB_LEN) - - -#define DOT11_OPEN_SYSTEM 0 -#define DOT11_SHARED_KEY 1 -#define DOT11_OPEN_SHARED 2 -#define DOT11_FAST_BSS 3 -#define DOT11_CHALLENGE_LEN 128 - - -#define FC_PVER_MASK 0x3 -#define FC_PVER_SHIFT 0 -#define FC_TYPE_MASK 0xC -#define FC_TYPE_SHIFT 2 -#define FC_SUBTYPE_MASK 0xF0 -#define FC_SUBTYPE_SHIFT 4 -#define FC_TODS 0x100 -#define FC_TODS_SHIFT 8 -#define FC_FROMDS 0x200 -#define FC_FROMDS_SHIFT 9 -#define FC_MOREFRAG 0x400 -#define FC_MOREFRAG_SHIFT 10 -#define FC_RETRY 0x800 -#define FC_RETRY_SHIFT 11 -#define FC_PM 0x1000 -#define FC_PM_SHIFT 12 -#define FC_MOREDATA 0x2000 -#define FC_MOREDATA_SHIFT 13 -#define FC_WEP 0x4000 -#define FC_WEP_SHIFT 14 -#define FC_ORDER 0x8000 -#define FC_ORDER_SHIFT 15 - - -#define SEQNUM_SHIFT 4 -#define SEQNUM_MAX 0x1000 -#define FRAGNUM_MASK 0xF - - - - -#define FC_TYPE_MNG 0 -#define FC_TYPE_CTL 1 -#define FC_TYPE_DATA 2 - - -#define FC_SUBTYPE_ASSOC_REQ 0 -#define FC_SUBTYPE_ASSOC_RESP 1 -#define FC_SUBTYPE_REASSOC_REQ 2 -#define FC_SUBTYPE_REASSOC_RESP 3 -#define FC_SUBTYPE_PROBE_REQ 4 -#define FC_SUBTYPE_PROBE_RESP 5 -#define FC_SUBTYPE_BEACON 8 -#define FC_SUBTYPE_ATIM 9 -#define FC_SUBTYPE_DISASSOC 10 -#define FC_SUBTYPE_AUTH 11 -#define FC_SUBTYPE_DEAUTH 12 -#define FC_SUBTYPE_ACTION 13 -#define FC_SUBTYPE_ACTION_NOACK 14 - - -#define FC_SUBTYPE_CTL_WRAPPER 7 -#define FC_SUBTYPE_BLOCKACK_REQ 8 -#define FC_SUBTYPE_BLOCKACK 9 -#define FC_SUBTYPE_PS_POLL 10 -#define FC_SUBTYPE_RTS 11 -#define FC_SUBTYPE_CTS 12 -#define FC_SUBTYPE_ACK 13 -#define FC_SUBTYPE_CF_END 14 -#define FC_SUBTYPE_CF_END_ACK 15 - - -#define FC_SUBTYPE_DATA 0 -#define FC_SUBTYPE_DATA_CF_ACK 1 -#define FC_SUBTYPE_DATA_CF_POLL 2 -#define FC_SUBTYPE_DATA_CF_ACK_POLL 3 -#define FC_SUBTYPE_NULL 4 -#define FC_SUBTYPE_CF_ACK 5 -#define FC_SUBTYPE_CF_POLL 6 -#define FC_SUBTYPE_CF_ACK_POLL 7 -#define FC_SUBTYPE_QOS_DATA 8 -#define FC_SUBTYPE_QOS_DATA_CF_ACK 9 -#define FC_SUBTYPE_QOS_DATA_CF_POLL 10 -#define FC_SUBTYPE_QOS_DATA_CF_ACK_POLL 11 -#define FC_SUBTYPE_QOS_NULL 12 -#define FC_SUBTYPE_QOS_CF_POLL 14 -#define FC_SUBTYPE_QOS_CF_ACK_POLL 15 - - -#define FC_SUBTYPE_ANY_QOS(s) (((s) & 8) != 0) -#define FC_SUBTYPE_ANY_NULL(s) (((s) & 4) != 0) -#define FC_SUBTYPE_ANY_CF_POLL(s) (((s) & 2) != 0) -#define FC_SUBTYPE_ANY_CF_ACK(s) (((s) & 1) != 0) - - -#define FC_KIND_MASK (FC_TYPE_MASK | FC_SUBTYPE_MASK) - -#define FC_KIND(t, s) (((t) << FC_TYPE_SHIFT) | ((s) << FC_SUBTYPE_SHIFT)) - -#define FC_SUBTYPE(fc) (((fc) & FC_SUBTYPE_MASK) >> FC_SUBTYPE_SHIFT) -#define FC_TYPE(fc) (((fc) & FC_TYPE_MASK) >> FC_TYPE_SHIFT) - -#define FC_ASSOC_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_REQ) -#define FC_ASSOC_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_RESP) -#define FC_REASSOC_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_REQ) -#define FC_REASSOC_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_RESP) -#define FC_PROBE_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_REQ) -#define FC_PROBE_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_RESP) -#define FC_BEACON FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_BEACON) -#define FC_DISASSOC FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DISASSOC) -#define FC_AUTH FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_AUTH) -#define FC_DEAUTH FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DEAUTH) -#define FC_ACTION FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ACTION) -#define FC_ACTION_NOACK FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ACTION_NOACK) - -#define FC_CTL_WRAPPER FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CTL_WRAPPER) -#define FC_BLOCKACK_REQ FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_BLOCKACK_REQ) -#define FC_BLOCKACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_BLOCKACK) -#define FC_PS_POLL FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_PS_POLL) -#define FC_RTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_RTS) -#define FC_CTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CTS) -#define FC_ACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_ACK) -#define FC_CF_END FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END) -#define FC_CF_END_ACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END_ACK) - -#define FC_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA) -#define FC_NULL_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_NULL) -#define FC_DATA_CF_ACK FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA_CF_ACK) -#define FC_QOS_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_DATA) -#define FC_QOS_NULL FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_NULL) - - - - -#define QOS_PRIO_SHIFT 0 -#define QOS_PRIO_MASK 0x0007 -#define QOS_PRIO(qos) (((qos) & QOS_PRIO_MASK) >> QOS_PRIO_SHIFT) - - -#define QOS_TID_SHIFT 0 -#define QOS_TID_MASK 0x000f -#define QOS_TID(qos) (((qos) & QOS_TID_MASK) >> QOS_TID_SHIFT) - - -#define QOS_EOSP_SHIFT 4 -#define QOS_EOSP_MASK 0x0010 -#define QOS_EOSP(qos) (((qos) & QOS_EOSP_MASK) >> QOS_EOSP_SHIFT) - - -#define QOS_ACK_NORMAL_ACK 0 -#define QOS_ACK_NO_ACK 1 -#define QOS_ACK_NO_EXP_ACK 2 -#define QOS_ACK_BLOCK_ACK 3 -#define QOS_ACK_SHIFT 5 -#define QOS_ACK_MASK 0x0060 -#define QOS_ACK(qos) (((qos) & QOS_ACK_MASK) >> QOS_ACK_SHIFT) - - -#define QOS_AMSDU_SHIFT 7 -#define QOS_AMSDU_MASK 0x0080 - - - - - - -#define DOT11_MNG_AUTH_ALGO_LEN 2 -#define DOT11_MNG_AUTH_SEQ_LEN 2 -#define DOT11_MNG_BEACON_INT_LEN 2 -#define DOT11_MNG_CAP_LEN 2 -#define DOT11_MNG_AP_ADDR_LEN 6 -#define DOT11_MNG_LISTEN_INT_LEN 2 -#define DOT11_MNG_REASON_LEN 2 -#define DOT11_MNG_AID_LEN 2 -#define DOT11_MNG_STATUS_LEN 2 -#define DOT11_MNG_TIMESTAMP_LEN 8 - - -#define DOT11_AID_MASK 0x3fff - - -#define DOT11_RC_RESERVED 0 -#define DOT11_RC_UNSPECIFIED 1 -#define DOT11_RC_AUTH_INVAL 2 -#define DOT11_RC_DEAUTH_LEAVING 3 -#define DOT11_RC_INACTIVITY 4 -#define DOT11_RC_BUSY 5 -#define DOT11_RC_INVAL_CLASS_2 6 -#define DOT11_RC_INVAL_CLASS_3 7 -#define DOT11_RC_DISASSOC_LEAVING 8 -#define DOT11_RC_NOT_AUTH 9 -#define DOT11_RC_BAD_PC 10 -#define DOT11_RC_BAD_CHANNELS 11 - - - -#define DOT11_RC_UNSPECIFIED_QOS 32 -#define DOT11_RC_INSUFFCIENT_BW 33 -#define DOT11_RC_EXCESSIVE_FRAMES 34 -#define DOT11_RC_TX_OUTSIDE_TXOP 35 -#define DOT11_RC_LEAVING_QBSS 36 -#define DOT11_RC_BAD_MECHANISM 37 -#define DOT11_RC_SETUP_NEEDED 38 -#define DOT11_RC_TIMEOUT 39 - -#define DOT11_RC_MAX 23 - - -#define DOT11_SC_SUCCESS 0 -#define DOT11_SC_FAILURE 1 -#define DOT11_SC_CAP_MISMATCH 10 -#define DOT11_SC_REASSOC_FAIL 11 -#define DOT11_SC_ASSOC_FAIL 12 -#define DOT11_SC_AUTH_MISMATCH 13 -#define DOT11_SC_AUTH_SEQ 14 -#define DOT11_SC_AUTH_CHALLENGE_FAIL 15 -#define DOT11_SC_AUTH_TIMEOUT 16 -#define DOT11_SC_ASSOC_BUSY_FAIL 17 -#define DOT11_SC_ASSOC_RATE_MISMATCH 18 -#define DOT11_SC_ASSOC_SHORT_REQUIRED 19 -#define DOT11_SC_ASSOC_PBCC_REQUIRED 20 -#define DOT11_SC_ASSOC_AGILITY_REQUIRED 21 -#define DOT11_SC_ASSOC_SPECTRUM_REQUIRED 22 -#define DOT11_SC_ASSOC_BAD_POWER_CAP 23 -#define DOT11_SC_ASSOC_BAD_SUP_CHANNELS 24 -#define DOT11_SC_ASSOC_SHORTSLOT_REQUIRED 25 -#define DOT11_SC_ASSOC_ERPBCC_REQUIRED 26 -#define DOT11_SC_ASSOC_DSSOFDM_REQUIRED 27 - -#define DOT11_SC_DECLINED 37 -#define DOT11_SC_INVALID_PARAMS 38 -#define DOT11_SC_INVALID_AKMP 43 -#define DOT11_SC_INVALID_MDID 54 -#define DOT11_SC_INVALID_FTIE 55 - - -#define DOT11_MNG_DS_PARAM_LEN 1 -#define DOT11_MNG_IBSS_PARAM_LEN 2 - - -#define DOT11_MNG_TIM_FIXED_LEN 3 -#define DOT11_MNG_TIM_DTIM_COUNT 0 -#define DOT11_MNG_TIM_DTIM_PERIOD 1 -#define DOT11_MNG_TIM_BITMAP_CTL 2 -#define DOT11_MNG_TIM_PVB 3 - - -#define TLV_TAG_OFF 0 -#define TLV_LEN_OFF 1 -#define TLV_HDR_LEN 2 -#define TLV_BODY_OFF 2 - - -#define DOT11_MNG_SSID_ID 0 -#define DOT11_MNG_RATES_ID 1 -#define DOT11_MNG_FH_PARMS_ID 2 -#define DOT11_MNG_DS_PARMS_ID 3 -#define DOT11_MNG_CF_PARMS_ID 4 -#define DOT11_MNG_TIM_ID 5 -#define DOT11_MNG_IBSS_PARMS_ID 6 -#define DOT11_MNG_COUNTRY_ID 7 -#define DOT11_MNG_HOPPING_PARMS_ID 8 -#define DOT11_MNG_HOPPING_TABLE_ID 9 -#define DOT11_MNG_REQUEST_ID 10 -#define DOT11_MNG_QBSS_LOAD_ID 11 -#define DOT11_MNG_EDCA_PARAM_ID 12 -#define DOT11_MNG_CHALLENGE_ID 16 -#define DOT11_MNG_PWR_CONSTRAINT_ID 32 -#define DOT11_MNG_PWR_CAP_ID 33 -#define DOT11_MNG_TPC_REQUEST_ID 34 -#define DOT11_MNG_TPC_REPORT_ID 35 -#define DOT11_MNG_SUPP_CHANNELS_ID 36 -#define DOT11_MNG_CHANNEL_SWITCH_ID 37 -#define DOT11_MNG_MEASURE_REQUEST_ID 38 -#define DOT11_MNG_MEASURE_REPORT_ID 39 -#define DOT11_MNG_QUIET_ID 40 -#define DOT11_MNG_IBSS_DFS_ID 41 -#define DOT11_MNG_ERP_ID 42 -#define DOT11_MNG_TS_DELAY_ID 43 -#define DOT11_MNG_HT_CAP 45 -#define DOT11_MNG_QOS_CAP_ID 46 -#define DOT11_MNG_NONERP_ID 47 -#define DOT11_MNG_RSN_ID 48 -#define DOT11_MNG_EXT_RATES_ID 50 -#define DOT11_MNG_AP_CHREP_ID 51 -#define DOT11_MNG_NBR_REP_ID 52 -#define DOT11_MNG_MDIE_ID 54 -#define DOT11_MNG_FTIE_ID 55 -#define DOT11_MNG_FT_TI_ID 56 -#define DOT11_MNG_REGCLASS_ID 59 -#define DOT11_MNG_EXT_CSA_ID 60 -#define DOT11_MNG_HT_ADD 61 -#define DOT11_MNG_EXT_CHANNEL_OFFSET 62 - - -#define DOT11_MNG_RRM_CAP_ID 70 -#define DOT11_MNG_HT_BSS_COEXINFO_ID 72 -#define DOT11_MNG_HT_BSS_CHANNEL_REPORT_ID 73 -#define DOT11_MNG_HT_OBSS_ID 74 -#define DOT11_MNG_EXT_CAP 127 -#define DOT11_MNG_WPA_ID 221 -#define DOT11_MNG_PROPR_ID 221 - -#define DOT11_MNG_VS_ID 221 - - -#define DOT11_RATE_BASIC 0x80 -#define DOT11_RATE_MASK 0x7F - - -#define DOT11_MNG_ERP_LEN 1 -#define DOT11_MNG_NONERP_PRESENT 0x01 -#define DOT11_MNG_USE_PROTECTION 0x02 -#define DOT11_MNG_BARKER_PREAMBLE 0x04 - -#define DOT11_MGN_TS_DELAY_LEN 4 -#define TS_DELAY_FIELD_SIZE 4 - - -#define DOT11_CAP_ESS 0x0001 -#define DOT11_CAP_IBSS 0x0002 -#define DOT11_CAP_POLLABLE 0x0004 -#define DOT11_CAP_POLL_RQ 0x0008 -#define DOT11_CAP_PRIVACY 0x0010 -#define DOT11_CAP_SHORT 0x0020 -#define DOT11_CAP_PBCC 0x0040 -#define DOT11_CAP_AGILITY 0x0080 -#define DOT11_CAP_SPECTRUM 0x0100 -#define DOT11_CAP_SHORTSLOT 0x0400 -#define DOT11_CAP_RRM 0x1000 -#define DOT11_CAP_CCK_OFDM 0x2000 - - -#define DOT11_OBSS_COEX_MNG_SUPPORT 0x01 - - -#define DOT11_ACTION_HDR_LEN 2 -#define DOT11_ACTION_CAT_OFF 0 -#define DOT11_ACTION_ACT_OFF 1 - - -#define DOT11_ACTION_CAT_ERR_MASK 0x80 -#define DOT11_ACTION_CAT_MASK 0x7F -#define DOT11_ACTION_CAT_SPECT_MNG 0 -#define DOT11_ACTION_CAT_QOS 1 -#define DOT11_ACTION_CAT_DLS 2 -#define DOT11_ACTION_CAT_BLOCKACK 3 -#define DOT11_ACTION_CAT_PUBLIC 4 -#define DOT11_ACTION_CAT_RRM 5 -#define DOT11_ACTION_CAT_FBT 6 -#define DOT11_ACTION_CAT_HT 7 -#define DOT11_ACTION_CAT_BSSMGMT 10 -#define DOT11_ACTION_NOTIFICATION 17 -#define DOT11_ACTION_CAT_VS 127 - - -#define DOT11_SM_ACTION_M_REQ 0 -#define DOT11_SM_ACTION_M_REP 1 -#define DOT11_SM_ACTION_TPC_REQ 2 -#define DOT11_SM_ACTION_TPC_REP 3 -#define DOT11_SM_ACTION_CHANNEL_SWITCH 4 -#define DOT11_SM_ACTION_EXT_CSA 5 - - -#define DOT11_ACTION_ID_HT_CH_WIDTH 0 -#define DOT11_ACTION_ID_HT_MIMO_PS 1 - - -#define DOT11_PUB_ACTION_BSS_COEX_MNG 0 -#define DOT11_PUB_ACTION_CHANNEL_SWITCH 4 - - -#define DOT11_BA_ACTION_ADDBA_REQ 0 -#define DOT11_BA_ACTION_ADDBA_RESP 1 -#define DOT11_BA_ACTION_DELBA 2 - - -#define DOT11_ADDBA_PARAM_AMSDU_SUP 0x0001 -#define DOT11_ADDBA_PARAM_POLICY_MASK 0x0002 -#define DOT11_ADDBA_PARAM_POLICY_SHIFT 1 -#define DOT11_ADDBA_PARAM_TID_MASK 0x003c -#define DOT11_ADDBA_PARAM_TID_SHIFT 2 -#define DOT11_ADDBA_PARAM_BSIZE_MASK 0xffc0 -#define DOT11_ADDBA_PARAM_BSIZE_SHIFT 6 - -#define DOT11_ADDBA_POLICY_DELAYED 0 -#define DOT11_ADDBA_POLICY_IMMEDIATE 1 - -BWL_PRE_PACKED_STRUCT struct dot11_addba_req { - uint8 category; - uint8 action; - uint8 token; - uint16 addba_param_set; - uint16 timeout; - uint16 start_seqnum; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_addba_req dot11_addba_req_t; -#define DOT11_ADDBA_REQ_LEN 9 - -BWL_PRE_PACKED_STRUCT struct dot11_addba_resp { - uint8 category; - uint8 action; - uint8 token; - uint16 status; - uint16 addba_param_set; - uint16 timeout; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_addba_resp dot11_addba_resp_t; -#define DOT11_ADDBA_RESP_LEN 9 - - -#define DOT11_DELBA_PARAM_INIT_MASK 0x0800 -#define DOT11_DELBA_PARAM_INIT_SHIFT 11 -#define DOT11_DELBA_PARAM_TID_MASK 0xf000 -#define DOT11_DELBA_PARAM_TID_SHIFT 12 - -BWL_PRE_PACKED_STRUCT struct dot11_delba { - uint8 category; - uint8 action; - uint16 delba_param_set; - uint16 reason; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_delba dot11_delba_t; -#define DOT11_DELBA_LEN 6 - - - - - -#define DOT11_RRM_CAP_LEN 5 -BWL_PRE_PACKED_STRUCT struct dot11_rrm_cap_ie { - uint8 cap[DOT11_RRM_CAP_LEN]; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_rrm_cap_ie dot11_rrm_cap_ie_t; - - -#define DOT11_RRM_CAP_LINK 0 -#define DOT11_RRM_CAP_NEIGHBOR_REPORT 1 -#define DOT11_RRM_CAP_PARALLEL 2 -#define DOT11_RRM_CAP_REPEATED 3 -#define DOT11_RRM_CAP_BCN_PASSIVE 4 -#define DOT11_RRM_CAP_BCN_ACTIVE 5 -#define DOT11_RRM_CAP_BCN_TABLE 6 -#define DOT11_RRM_CAP_BCN_REP_COND 7 -#define DOT11_RRM_CAP_AP_CHANREP 16 - - -#define DOT11_RM_ACTION_RM_REQ 0 -#define DOT11_RM_ACTION_RM_REP 1 -#define DOT11_RM_ACTION_LM_REQ 2 -#define DOT11_RM_ACTION_LM_REP 3 -#define DOT11_RM_ACTION_NR_REQ 4 -#define DOT11_RM_ACTION_NR_REP 5 - - -BWL_PRE_PACKED_STRUCT struct dot11_rm_action { - uint8 category; - uint8 action; - uint8 token; - uint8 data[1]; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_rm_action dot11_rm_action_t; -#define DOT11_RM_ACTION_LEN 3 - -BWL_PRE_PACKED_STRUCT struct dot11_rmreq { - uint8 category; - uint8 action; - uint8 token; - uint16 reps; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_rmreq dot11_rmreq_t; -#define DOT11_RMREQ_LEN 5 - -BWL_PRE_PACKED_STRUCT struct dot11_rm_ie { - uint8 id; - uint8 len; - uint8 token; - uint8 mode; - uint8 type; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_rm_ie dot11_rm_ie_t; -#define DOT11_RM_IE_LEN 5 - - -#define DOT11_RMREQ_MODE_PARALLEL 1 -#define DOT11_RMREQ_MODE_ENABLE 2 -#define DOT11_RMREQ_MODE_REQUEST 4 -#define DOT11_RMREQ_MODE_REPORT 8 -#define DOT11_RMREQ_MODE_DURMAND 0x10 - - -#define DOT11_RMREP_MODE_LATE 1 -#define DOT11_RMREP_MODE_INCAPABLE 2 -#define DOT11_RMREP_MODE_REFUSED 4 - -BWL_PRE_PACKED_STRUCT struct dot11_rmreq_bcn { - uint8 id; - uint8 len; - uint8 token; - uint8 mode; - uint8 type; - uint8 reg; - uint8 channel; - uint16 interval; - uint16 duration; - uint8 bcn_mode; - struct ether_addr bssid; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_rmreq_bcn dot11_rmreq_bcn_t; -#define DOT11_RMREQ_BCN_LEN 18 - -BWL_PRE_PACKED_STRUCT struct dot11_rmrep_bcn { - uint8 reg; - uint8 channel; - uint32 starttime[2]; - uint16 duration; - uint8 frame_info; - uint8 rcpi; - uint8 rsni; - struct ether_addr bssid; - uint8 antenna_id; - uint32 parent_tsf; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_rmrep_bcn dot11_rmrep_bcn_t; -#define DOT11_RMREP_BCN_LEN 26 - - -#define DOT11_RMREQ_BCN_PASSIVE 0 -#define DOT11_RMREQ_BCN_ACTIVE 1 -#define DOT11_RMREQ_BCN_TABLE 2 - - -#define DOT11_RMREQ_BCN_SSID_ID 0 -#define DOT11_RMREQ_BCN_REPINFO_ID 1 -#define DOT11_RMREQ_BCN_REPDET_ID 2 -#define DOT11_RMREQ_BCN_REQUEST_ID 10 -#define DOT11_RMREQ_BCN_APCHREP_ID 51 - - -#define DOT11_RMREQ_BCN_REPDET_FIXED 0 -#define DOT11_RMREQ_BCN_REPDET_REQUEST 1 -#define DOT11_RMREQ_BCN_REPDET_ALL 2 - - -#define DOT11_RMREP_BCN_FRM_BODY 1 - - -BWL_PRE_PACKED_STRUCT struct dot11_rmrep_nbr { - struct ether_addr bssid; - uint32 bssid_info; - uint8 reg; - uint8 channel; - uint8 phytype; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_rmrep_nbr dot11_rmrep_nbr_t; -#define DOT11_RMREP_NBR_LEN 13 - - -#define DOT11_BSSTYPE_INFRASTRUCTURE 0 -#define DOT11_BSSTYPE_INDEPENDENT 1 -#define DOT11_BSSTYPE_ANY 2 -#define DOT11_SCANTYPE_ACTIVE 0 -#define DOT11_SCANTYPE_PASSIVE 1 - - -BWL_PRE_PACKED_STRUCT struct dot11_lmreq { - uint8 category; - uint8 action; - uint8 token; - uint8 txpwr; - uint8 maxtxpwr; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_lmreq dot11_lmreq_t; -#define DOT11_LMREQ_LEN 5 - -BWL_PRE_PACKED_STRUCT struct dot11_lmrep { - uint8 category; - uint8 action; - uint8 token; - dot11_tpc_rep_t tpc; - uint8 rxant; - uint8 txant; - uint8 rcpi; - uint8 rsni; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_lmrep dot11_lmrep_t; -#define DOT11_LMREP_LEN 11 - - -#define PREN_PREAMBLE 24 -#define PREN_MM_EXT 12 -#define PREN_PREAMBLE_EXT 4 - - -#define RIFS_11N_TIME 2 - - - -#define HT_SIG1_MCS_MASK 0x00007F -#define HT_SIG1_CBW 0x000080 -#define HT_SIG1_HT_LENGTH 0xFFFF00 - - -#define HT_SIG2_SMOOTHING 0x000001 -#define HT_SIG2_NOT_SOUNDING 0x000002 -#define HT_SIG2_RESERVED 0x000004 -#define HT_SIG2_AGGREGATION 0x000008 -#define HT_SIG2_STBC_MASK 0x000030 -#define HT_SIG2_STBC_SHIFT 4 -#define HT_SIG2_FEC_CODING 0x000040 -#define HT_SIG2_SHORT_GI 0x000080 -#define HT_SIG2_ESS_MASK 0x000300 -#define HT_SIG2_ESS_SHIFT 8 -#define HT_SIG2_CRC 0x03FC00 -#define HT_SIG2_TAIL 0x1C0000 - - -#define APHY_SLOT_TIME 9 -#define APHY_SIFS_TIME 16 -#define APHY_DIFS_TIME (APHY_SIFS_TIME + (2 * APHY_SLOT_TIME)) -#define APHY_PREAMBLE_TIME 16 -#define APHY_SIGNAL_TIME 4 -#define APHY_SYMBOL_TIME 4 -#define APHY_SERVICE_NBITS 16 -#define APHY_TAIL_NBITS 6 -#define APHY_CWMIN 15 - - -#define BPHY_SLOT_TIME 20 -#define BPHY_SIFS_TIME 10 -#define BPHY_DIFS_TIME 50 -#define BPHY_PLCP_TIME 192 -#define BPHY_PLCP_SHORT_TIME 96 -#define BPHY_CWMIN 31 - - -#define DOT11_OFDM_SIGNAL_EXTENSION 6 - -#define PHY_CWMAX 1023 - -#define DOT11_MAXNUMFRAGS 16 - - -typedef struct d11cnt { - uint32 txfrag; - uint32 txmulti; - uint32 txfail; - uint32 txretry; - uint32 txretrie; - uint32 rxdup; - uint32 txrts; - uint32 txnocts; - uint32 txnoack; - uint32 rxfrag; - uint32 rxmulti; - uint32 rxcrc; - uint32 txfrmsnt; - uint32 rxundec; -} d11cnt_t; - - -#define BRCM_PROP_OUI "\x00\x90\x4C" - - - -#define BRCM_OUI "\x00\x10\x18" - - -BWL_PRE_PACKED_STRUCT struct brcm_ie { - uint8 id; - uint8 len; - uint8 oui[3]; - uint8 ver; - uint8 assoc; - uint8 flags; - uint8 flags1; - uint16 amsdu_mtu_pref; -} BWL_POST_PACKED_STRUCT; -typedef struct brcm_ie brcm_ie_t; -#define BRCM_IE_LEN 11 -#define BRCM_IE_VER 2 -#define BRCM_IE_LEGACY_AES_VER 1 - - -#ifdef WLAFTERBURNER -#define BRF_ABCAP 0x1 -#define BRF_ABRQRD 0x2 -#define BRF_ABCOUNTER_MASK 0xf0 -#define BRF_ABCOUNTER_SHIFT 4 -#endif -#define BRF_LZWDS 0x4 -#define BRF_BLOCKACK 0x8 - - -#define BRF1_AMSDU 0x1 -#define BRF1_WMEPS 0x4 -#define BRF1_PSOFIX 0x8 -#define BRF1_RX_LARGE_AGG 0x10 -#define BRF1_SOFTAP 0x40 - -#ifdef WLAFTERBURNER -#define AB_WDS_TIMEOUT_MAX 15 -#define AB_WDS_TIMEOUT_MIN 1 -#endif - -#define AB_GUARDCOUNT 10 - - -BWL_PRE_PACKED_STRUCT struct vndr_ie { - uchar id; - uchar len; - uchar oui [3]; - uchar data [1]; -} BWL_POST_PACKED_STRUCT; -typedef struct vndr_ie vndr_ie_t; - -#define VNDR_IE_HDR_LEN 2 -#define VNDR_IE_MIN_LEN 3 -#define VNDR_IE_MAX_LEN 256 - - -#define MCSSET_LEN 16 -#define MAX_MCS_NUM (128) - -BWL_PRE_PACKED_STRUCT struct ht_cap_ie { - uint16 cap; - uint8 params; - uint8 supp_mcs[MCSSET_LEN]; - uint16 ext_htcap; - uint32 txbf_cap; - uint8 as_cap; -} BWL_POST_PACKED_STRUCT; -typedef struct ht_cap_ie ht_cap_ie_t; - - - -BWL_PRE_PACKED_STRUCT struct ht_prop_cap_ie { - uint8 id; - uint8 len; - uint8 oui[3]; - uint8 type; - ht_cap_ie_t cap_ie; -} BWL_POST_PACKED_STRUCT; -typedef struct ht_prop_cap_ie ht_prop_cap_ie_t; - -#define HT_PROP_IE_OVERHEAD 4 -#define HT_CAP_IE_LEN 26 -#define HT_CAP_IE_TYPE 51 - -#define HT_CAP_LDPC_CODING 0x0001 -#define HT_CAP_40MHZ 0x0002 -#define HT_CAP_MIMO_PS_MASK 0x000C -#define HT_CAP_MIMO_PS_SHIFT 0x0002 -#define HT_CAP_MIMO_PS_OFF 0x0003 -#define HT_CAP_MIMO_PS_RTS 0x0001 -#define HT_CAP_MIMO_PS_ON 0x0000 -#define HT_CAP_GF 0x0010 -#define HT_CAP_SHORT_GI_20 0x0020 -#define HT_CAP_SHORT_GI_40 0x0040 -#define HT_CAP_TX_STBC 0x0080 -#define HT_CAP_RX_STBC_MASK 0x0300 -#define HT_CAP_RX_STBC_SHIFT 8 -#define HT_CAP_DELAYED_BA 0x0400 -#define HT_CAP_MAX_AMSDU 0x0800 -#define HT_CAP_DSSS_CCK 0x1000 -#define HT_CAP_PSMP 0x2000 -#define HT_CAP_40MHZ_INTOLERANT 0x4000 -#define HT_CAP_LSIG_TXOP 0x8000 - -#define HT_CAP_RX_STBC_NO 0x0 -#define HT_CAP_RX_STBC_ONE_STREAM 0x1 -#define HT_CAP_RX_STBC_TWO_STREAM 0x2 -#define HT_CAP_RX_STBC_THREE_STREAM 0x3 - -#define HT_MAX_AMSDU 7935 -#define HT_MIN_AMSDU 3835 - -#define HT_PARAMS_RX_FACTOR_MASK 0x03 -#define HT_PARAMS_DENSITY_MASK 0x1C -#define HT_PARAMS_DENSITY_SHIFT 2 - - -#define AMPDU_MAX_MPDU_DENSITY 7 -#define AMPDU_RX_FACTOR_8K 0 -#define AMPDU_RX_FACTOR_16K 1 -#define AMPDU_RX_FACTOR_32K 2 -#define AMPDU_RX_FACTOR_64K 3 -#define AMPDU_RX_FACTOR_BASE 8*1024 - -#define AMPDU_DELIMITER_LEN 4 -#define AMPDU_DELIMITER_LEN_MAX 63 - -BWL_PRE_PACKED_STRUCT struct ht_add_ie { - uint8 ctl_ch; - uint8 byte1; - uint16 opmode; - uint16 misc_bits; - uint8 basic_mcs[MCSSET_LEN]; -} BWL_POST_PACKED_STRUCT; -typedef struct ht_add_ie ht_add_ie_t; - - - -BWL_PRE_PACKED_STRUCT struct ht_prop_add_ie { - uint8 id; - uint8 len; - uint8 oui[3]; - uint8 type; - ht_add_ie_t add_ie; -} BWL_POST_PACKED_STRUCT; -typedef struct ht_prop_add_ie ht_prop_add_ie_t; - -#define HT_ADD_IE_LEN 22 -#define HT_ADD_IE_TYPE 52 - - -#define HT_BW_ANY 0x04 -#define HT_RIFS_PERMITTED 0x08 - - -#define HT_OPMODE_MASK 0x0003 -#define HT_OPMODE_SHIFT 0 -#define HT_OPMODE_PURE 0x0000 -#define HT_OPMODE_OPTIONAL 0x0001 -#define HT_OPMODE_HT20IN40 0x0002 -#define HT_OPMODE_MIXED 0x0003 -#define HT_OPMODE_NONGF 0x0004 -#define DOT11N_TXBURST 0x0008 -#define DOT11N_OBSS_NONHT 0x0010 - - -#define HT_BASIC_STBC_MCS 0x007f -#define HT_DUAL_STBC_PROT 0x0080 -#define HT_SECOND_BCN 0x0100 -#define HT_LSIG_TXOP 0x0200 -#define HT_PCO_ACTIVE 0x0400 -#define HT_PCO_PHASE 0x0800 - - -#define DOT11N_2G_TXBURST_LIMIT 6160 -#define DOT11N_5G_TXBURST_LIMIT 3080 - - -#define GET_HT_OPMODE(add_ie) ((ltoh16_ua(&add_ie->opmode) & HT_OPMODE_MASK) \ - >> HT_OPMODE_SHIFT) -#define HT_MIXEDMODE_PRESENT(add_ie) ((ltoh16_ua(&add_ie->opmode) & HT_OPMODE_MASK) \ - == HT_OPMODE_MIXED) -#define HT_HT20_PRESENT(add_ie) ((ltoh16_ua(&add_ie->opmode) & HT_OPMODE_MASK) \ - == HT_OPMODE_HT20IN40) -#define HT_OPTIONAL_PRESENT(add_ie) ((ltoh16_ua(&add_ie->opmode) & HT_OPMODE_MASK) \ - == HT_OPMODE_OPTIONAL) -#define HT_USE_PROTECTION(add_ie) (HT_HT20_PRESENT((add_ie)) || \ - HT_MIXEDMODE_PRESENT((add_ie))) -#define HT_NONGF_PRESENT(add_ie) ((ltoh16_ua(&add_ie->opmode) & HT_OPMODE_NONGF) \ - == HT_OPMODE_NONGF) -#define DOT11N_TXBURST_PRESENT(add_ie) ((ltoh16_ua(&add_ie->opmode) & DOT11N_TXBURST) \ - == DOT11N_TXBURST) -#define DOT11N_OBSS_NONHT_PRESENT(add_ie) ((ltoh16_ua(&add_ie->opmode) & DOT11N_OBSS_NONHT) \ - == DOT11N_OBSS_NONHT) - -BWL_PRE_PACKED_STRUCT struct obss_params { - uint16 passive_dwell; - uint16 active_dwell; - uint16 bss_widthscan_interval; - uint16 passive_total; - uint16 active_total; - uint16 chanwidth_transition_dly; - uint16 activity_threshold; -} BWL_POST_PACKED_STRUCT; -typedef struct obss_params obss_params_t; - -BWL_PRE_PACKED_STRUCT struct dot11_obss_ie { - uint8 id; - uint8 len; - obss_params_t obss_params; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_obss_ie dot11_obss_ie_t; -#define DOT11_OBSS_SCAN_IE_LEN sizeof(obss_params_t) - - -#define HT_CTRL_LA_TRQ 0x00000002 -#define HT_CTRL_LA_MAI 0x0000003C -#define HT_CTRL_LA_MAI_SHIFT 2 -#define HT_CTRL_LA_MAI_MRQ 0x00000004 -#define HT_CTRL_LA_MAI_MSI 0x00000038 -#define HT_CTRL_LA_MFSI 0x000001C0 -#define HT_CTRL_LA_MFSI_SHIFT 6 -#define HT_CTRL_LA_MFB_ASELC 0x0000FE00 -#define HT_CTRL_LA_MFB_ASELC_SH 9 -#define HT_CTRL_LA_ASELC_CMD 0x00000C00 -#define HT_CTRL_LA_ASELC_DATA 0x0000F000 -#define HT_CTRL_CAL_POS 0x00030000 -#define HT_CTRL_CAL_SEQ 0x000C0000 -#define HT_CTRL_CSI_STEERING 0x00C00000 -#define HT_CTRL_CSI_STEER_SHIFT 22 -#define HT_CTRL_CSI_STEER_NFB 0 -#define HT_CTRL_CSI_STEER_CSI 1 -#define HT_CTRL_CSI_STEER_NCOM 2 -#define HT_CTRL_CSI_STEER_COM 3 -#define HT_CTRL_NDP_ANNOUNCE 0x01000000 -#define HT_CTRL_AC_CONSTRAINT 0x40000000 -#define HT_CTRL_RDG_MOREPPDU 0x80000000 - -#define HT_OPMODE_OPTIONAL 0x0001 -#define HT_OPMODE_HT20IN40 0x0002 -#define HT_OPMODE_MIXED 0x0003 -#define HT_OPMODE_NONGF 0x0004 -#define DOT11N_TXBURST 0x0008 -#define DOT11N_OBSS_NONHT 0x0010 - - - -#define WPA_OUI "\x00\x50\xF2" -#define WPA_OUI_LEN 3 -#define WPA_OUI_TYPE 1 -#define WPA_VERSION 1 -#define WPA2_OUI "\x00\x0F\xAC" -#define WPA2_OUI_LEN 3 -#define WPA2_VERSION 1 -#define WPA2_VERSION_LEN 2 - - -#define WPS_OUI "\x00\x50\xF2" -#define WPS_OUI_LEN 3 -#define WPS_OUI_TYPE 4 - - -#define WFA_OUI "\x50\x6F\x9A" -#define WFA_OUI_LEN 3 - -#define WFA_OUI_TYPE_WPA 1 -#define WFA_OUI_TYPE_WPS 4 -#define WFA_OUI_TYPE_TPC 8 -#define WFA_OUI_TYPE_P2P 9 - - -#define RSN_AKM_NONE 0 -#define RSN_AKM_UNSPECIFIED 1 -#define RSN_AKM_PSK 2 -#define RSN_AKM_FBT_1X 3 -#define RSN_AKM_FBT_PSK 4 - - -#define DOT11_MAX_DEFAULT_KEYS 4 -#define DOT11_MAX_KEY_SIZE 32 -#define DOT11_MAX_IV_SIZE 16 -#define DOT11_EXT_IV_FLAG (1<<5) -#define DOT11_WPA_KEY_RSC_LEN 8 - -#define WEP1_KEY_SIZE 5 -#define WEP1_KEY_HEX_SIZE 10 -#define WEP128_KEY_SIZE 13 -#define WEP128_KEY_HEX_SIZE 26 -#define TKIP_MIC_SIZE 8 -#define TKIP_EOM_SIZE 7 -#define TKIP_EOM_FLAG 0x5a -#define TKIP_KEY_SIZE 32 -#define TKIP_MIC_AUTH_TX 16 -#define TKIP_MIC_AUTH_RX 24 -#define TKIP_MIC_SUP_RX TKIP_MIC_AUTH_TX -#define TKIP_MIC_SUP_TX TKIP_MIC_AUTH_RX -#define AES_KEY_SIZE 16 -#define AES_MIC_SIZE 8 - - -#define WCN_OUI "\x00\x50\xf2" -#define WCN_TYPE 4 - - - - - -BWL_PRE_PACKED_STRUCT struct dot11_mdid_ie { - uint8 id; - uint8 len; - uint16 mdid; - uint8 cap; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_mdid_ie dot11_mdid_ie_t; - -#define FBT_MDID_CAP_OVERDS 0x01 -#define FBT_MDID_CAP_RRP 0x02 - - -BWL_PRE_PACKED_STRUCT struct dot11_ft_ie { - uint8 id; - uint8 len; - uint16 mic_control; - uint8 mic[16]; - uint8 anonce[32]; - uint8 snonce[32]; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_ft_ie dot11_ft_ie_t; - - -BWL_PRE_PACKED_STRUCT struct dot11_gtk_ie { - uint8 id; - uint8 len; - uint16 key_info; - uint8 key_len; - uint8 rsc[8]; - uint8 data[1]; -} BWL_POST_PACKED_STRUCT; -typedef struct dot11_gtk_ie dot11_gtk_ie_t; - - - -#include <packed_section_end.h> - -#endif diff --git a/bcm4329/dhdutil/include/proto/802.1d.h b/bcm4329/dhdutil/include/proto/802.1d.h deleted file mode 100644 index dbf3a1c..0000000 --- a/bcm4329/dhdutil/include/proto/802.1d.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Fundamental types and constants relating to 802.1D - * - * $Id: 802.1d.h,v 9.3 2007-04-10 21:33:06 Exp $ - */ - - -#ifndef _802_1_D_ -#define _802_1_D_ - - -#define PRIO_8021D_NONE 2 -#define PRIO_8021D_BK 1 -#define PRIO_8021D_BE 0 -#define PRIO_8021D_EE 3 -#define PRIO_8021D_CL 4 -#define PRIO_8021D_VI 5 -#define PRIO_8021D_VO 6 -#define PRIO_8021D_NC 7 -#define MAXPRIO 7 -#define NUMPRIO (MAXPRIO + 1) - -#define ALLPRIO -1 - - -#define PRIO2PREC(prio) \ - (((prio) == PRIO_8021D_NONE || (prio) == PRIO_8021D_BE) ? ((prio^2)) : (prio)) - -#endif diff --git a/bcm4329/dhdutil/include/proto/bcmeth.h b/bcm4329/dhdutil/include/proto/bcmeth.h deleted file mode 100644 index 06ca18f..0000000 --- a/bcm4329/dhdutil/include/proto/bcmeth.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Broadcom Ethernettype protocol definitions - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: bcmeth.h,v 9.12 2009-12-29 19:57:18 Exp $ - */ - - - - -#ifndef _BCMETH_H_ -#define _BCMETH_H_ - -#ifndef _TYPEDEFS_H_ -#include <typedefs.h> -#endif - - -#include <packed_section_start.h> - - - - - - - -#define BCMILCP_SUBTYPE_RATE 1 -#define BCMILCP_SUBTYPE_LINK 2 -#define BCMILCP_SUBTYPE_CSA 3 -#define BCMILCP_SUBTYPE_LARQ 4 -#define BCMILCP_SUBTYPE_VENDOR 5 -#define BCMILCP_SUBTYPE_FLH 17 - -#define BCMILCP_SUBTYPE_VENDOR_LONG 32769 -#define BCMILCP_SUBTYPE_CERT 32770 -#define BCMILCP_SUBTYPE_SES 32771 - - -#define BCMILCP_BCM_SUBTYPE_RESERVED 0 -#define BCMILCP_BCM_SUBTYPE_EVENT 1 -#define BCMILCP_BCM_SUBTYPE_SES 2 - - -#define BCMILCP_BCM_SUBTYPE_DPT 4 - -#define BCMILCP_BCM_SUBTYPEHDR_MINLENGTH 8 -#define BCMILCP_BCM_SUBTYPEHDR_VERSION 0 - - -typedef BWL_PRE_PACKED_STRUCT struct bcmeth_hdr -{ - uint16 subtype; - uint16 length; - uint8 version; - uint8 oui[3]; - - uint16 usr_subtype; -} BWL_POST_PACKED_STRUCT bcmeth_hdr_t; - - - -#include <packed_section_end.h> - -#endif diff --git a/bcm4329/dhdutil/include/proto/bcmevent.h b/bcm4329/dhdutil/include/proto/bcmevent.h deleted file mode 100644 index 966daa0..0000000 --- a/bcm4329/dhdutil/include/proto/bcmevent.h +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Broadcom Event protocol definitions - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Dependencies: proto/bcmeth.h - * - * $Id: bcmevent.h,v 9.64.2.9 2011-02-01 06:24:21 Exp $ - * - */ - - - - -#ifndef _BCMEVENT_H_ -#define _BCMEVENT_H_ - -#ifndef _TYPEDEFS_H_ -#include <typedefs.h> -#endif - - -#include <packed_section_start.h> - -#define BCM_EVENT_MSG_VERSION 2 -#define BCM_MSG_IFNAME_MAX 16 - - -#define WLC_EVENT_MSG_LINK 0x01 -#define WLC_EVENT_MSG_FLUSHTXQ 0x02 -#define WLC_EVENT_MSG_GROUP 0x04 -#define WLC_EVENT_MSG_UNKBSS 0x08 -#define WLC_EVENT_MSG_UNKIF 0x10 - - - - -typedef BWL_PRE_PACKED_STRUCT struct -{ - uint16 version; - uint16 flags; - uint32 event_type; - uint32 status; - uint32 reason; - uint32 auth_type; - uint32 datalen; - struct ether_addr addr; - char ifname[BCM_MSG_IFNAME_MAX]; -} BWL_POST_PACKED_STRUCT wl_event_msg_v1_t; - - -typedef BWL_PRE_PACKED_STRUCT struct -{ - uint16 version; - uint16 flags; - uint32 event_type; - uint32 status; - uint32 reason; - uint32 auth_type; - uint32 datalen; - struct ether_addr addr; - char ifname[BCM_MSG_IFNAME_MAX]; - uint8 ifidx; - uint8 bsscfgidx; -} BWL_POST_PACKED_STRUCT wl_event_msg_t; - - -typedef BWL_PRE_PACKED_STRUCT struct bcm_event { - struct ether_header eth; - bcmeth_hdr_t bcm_hdr; - wl_event_msg_t event; - -} BWL_POST_PACKED_STRUCT bcm_event_t; - -#define BCM_MSG_LEN (sizeof(bcm_event_t) - sizeof(bcmeth_hdr_t) - sizeof(struct ether_header)) - - -#define WLC_E_SET_SSID 0 -#define WLC_E_JOIN 1 -#define WLC_E_START 2 -#define WLC_E_AUTH 3 -#define WLC_E_AUTH_IND 4 -#define WLC_E_DEAUTH 5 -#define WLC_E_DEAUTH_IND 6 -#define WLC_E_ASSOC 7 -#define WLC_E_ASSOC_IND 8 -#define WLC_E_REASSOC 9 -#define WLC_E_REASSOC_IND 10 -#define WLC_E_DISASSOC 11 -#define WLC_E_DISASSOC_IND 12 -#define WLC_E_QUIET_START 13 -#define WLC_E_QUIET_END 14 -#define WLC_E_BEACON_RX 15 -#define WLC_E_LINK 16 -#define WLC_E_MIC_ERROR 17 -#define WLC_E_NDIS_LINK 18 -#define WLC_E_ROAM 19 -#define WLC_E_TXFAIL 20 -#define WLC_E_PMKID_CACHE 21 -#define WLC_E_RETROGRADE_TSF 22 -#define WLC_E_PRUNE 23 -#define WLC_E_AUTOAUTH 24 -#define WLC_E_EAPOL_MSG 25 -#define WLC_E_SCAN_COMPLETE 26 -#define WLC_E_ADDTS_IND 27 -#define WLC_E_DELTS_IND 28 -#define WLC_E_BCNSENT_IND 29 -#define WLC_E_BCNRX_MSG 30 -#define WLC_E_BCNLOST_MSG 31 -#define WLC_E_ROAM_PREP 32 -#define WLC_E_PFN_NET_FOUND 33 -#define WLC_E_PFN_NET_LOST 34 -#define WLC_E_RESET_COMPLETE 35 -#define WLC_E_JOIN_START 36 -#define WLC_E_ROAM_START 37 -#define WLC_E_ASSOC_START 38 -#define WLC_E_IBSS_ASSOC 39 -#define WLC_E_RADIO 40 -#define WLC_E_PSM_WATCHDOG 41 -#define WLC_E_PROBREQ_MSG 44 -#define WLC_E_SCAN_CONFIRM_IND 45 -#define WLC_E_PSK_SUP 46 -#define WLC_E_COUNTRY_CODE_CHANGED 47 -#define WLC_E_EXCEEDED_MEDIUM_TIME 48 -#define WLC_E_ICV_ERROR 49 -#define WLC_E_UNICAST_DECODE_ERROR 50 -#define WLC_E_MULTICAST_DECODE_ERROR 51 -#define WLC_E_TRACE 52 -#define WLC_E_BTA_HCI_EVENT 53 -#define WLC_E_IF 54 -#ifdef WLP2P -#define WLC_E_P2P_DISC_LISTEN_COMPLETE 55 -#endif -#define WLC_E_RSSI 56 -#define WLC_E_PFN_SCAN_COMPLETE 57 -#define WLC_E_EXTLOG_MSG 58 -#define WLC_E_ACTION_FRAME 59 -#define WLC_E_ACTION_FRAME_COMPLETE 60 -#define WLC_E_PRE_ASSOC_IND 61 -#define WLC_E_PRE_REASSOC_IND 62 -#define WLC_E_CHANNEL_ADOPTED 63 -#define WLC_E_AP_STARTED 64 -#define WLC_E_DFS_AP_STOP 65 -#define WLC_E_DFS_AP_RESUME 66 -#define WLC_E_WAI_STA_EVENT 67 -#define WLC_E_WAI_MSG 68 -#define WLC_E_ESCAN_RESULT 69 -#define WLC_E_ACTION_FRAME_OFF_CHAN_COMPLETE 70 -#if defined(WLP2P) -#define WLC_E_PROBRESP_MSG 71 -#define WLC_E_P2P_PROBREQ_MSG 72 -#endif -#define WLC_E_DCS_REQUEST 73 - -#define WLC_E_FIFO_CREDIT_MAP 74 - -#define WLC_E_ACTION_FRAME_RX 75 -#define WLC_E_WAKE_EVENT 76 -#define WLC_E_RM_COMPLETE 77 -#define WLC_E_HTSFSYNC 78 -#define WLC_E_OVERLAY_REQ 79 -#define WLC_E_CSA_COMPLETE_IND 80 -#define WLC_E_EXCESS_PM_WAKE_EVENT 81 -#define WLC_E_PFN_SCAN_NONE 82 -#define WLC_E_PFN_SCAN_ALLGONE 83 -#define WLC_E_LAST 84 - - -typedef struct { - uint event; - const char *name; -} bcmevent_name_t; - -extern const bcmevent_name_t bcmevent_names[]; -extern const int bcmevent_names_size; - - -#define WLC_E_STATUS_SUCCESS 0 -#define WLC_E_STATUS_FAIL 1 -#define WLC_E_STATUS_TIMEOUT 2 -#define WLC_E_STATUS_NO_NETWORKS 3 -#define WLC_E_STATUS_ABORT 4 -#define WLC_E_STATUS_NO_ACK 5 -#define WLC_E_STATUS_UNSOLICITED 6 -#define WLC_E_STATUS_ATTEMPT 7 -#define WLC_E_STATUS_PARTIAL 8 -#define WLC_E_STATUS_NEWSCAN 9 -#define WLC_E_STATUS_NEWASSOC 10 -#define WLC_E_STATUS_11HQUIET 11 -#define WLC_E_STATUS_SUPPRESS 12 -#define WLC_E_STATUS_NOCHANS 13 -#define WLC_E_STATUS_CS_ABORT 15 -#define WLC_E_STATUS_ERROR 16 - - -#define WLC_E_REASON_INITIAL_ASSOC 0 -#define WLC_E_REASON_LOW_RSSI 1 -#define WLC_E_REASON_DEAUTH 2 -#define WLC_E_REASON_DISASSOC 3 -#define WLC_E_REASON_BCNS_LOST 4 -#define WLC_E_REASON_MINTXRATE 9 -#define WLC_E_REASON_TXFAIL 10 - - -#define WLC_E_REASON_FAST_ROAM_FAILED 5 -#define WLC_E_REASON_DIRECTED_ROAM 6 -#define WLC_E_REASON_TSPEC_REJECTED 7 -#define WLC_E_REASON_BETTER_AP 8 - - -#define WLC_E_PRUNE_ENCR_MISMATCH 1 -#define WLC_E_PRUNE_BCAST_BSSID 2 -#define WLC_E_PRUNE_MAC_DENY 3 -#define WLC_E_PRUNE_MAC_NA 4 -#define WLC_E_PRUNE_REG_PASSV 5 -#define WLC_E_PRUNE_SPCT_MGMT 6 -#define WLC_E_PRUNE_RADAR 7 -#define WLC_E_RSN_MISMATCH 8 -#define WLC_E_PRUNE_NO_COMMON_RATES 9 -#define WLC_E_PRUNE_BASIC_RATES 10 -#define WLC_E_PRUNE_CIPHER_NA 12 -#define WLC_E_PRUNE_KNOWN_STA 13 -#define WLC_E_PRUNE_WDS_PEER 15 -#define WLC_E_PRUNE_QBSS_LOAD 16 -#define WLC_E_PRUNE_HOME_AP 17 - - -#define WLC_E_SUP_OTHER 0 -#define WLC_E_SUP_DECRYPT_KEY_DATA 1 -#define WLC_E_SUP_BAD_UCAST_WEP128 2 -#define WLC_E_SUP_BAD_UCAST_WEP40 3 -#define WLC_E_SUP_UNSUP_KEY_LEN 4 -#define WLC_E_SUP_PW_KEY_CIPHER 5 -#define WLC_E_SUP_MSG3_TOO_MANY_IE 6 -#define WLC_E_SUP_MSG3_IE_MISMATCH 7 -#define WLC_E_SUP_NO_INSTALL_FLAG 8 -#define WLC_E_SUP_MSG3_NO_GTK 9 -#define WLC_E_SUP_GRP_KEY_CIPHER 10 -#define WLC_E_SUP_GRP_MSG1_NO_GTK 11 -#define WLC_E_SUP_GTK_DECRYPT_FAIL 12 -#define WLC_E_SUP_SEND_FAIL 13 -#define WLC_E_SUP_DEAUTH 14 -#define WLC_E_SUP_WPA_PSK_TMO 15 - - - -typedef BWL_PRE_PACKED_STRUCT struct wl_event_rx_frame_data { - uint16 version; - uint16 channel; - int32 rssi; - uint32 mactime; - uint32 rate; -} BWL_POST_PACKED_STRUCT wl_event_rx_frame_data_t; - -#define BCM_RX_FRAME_DATA_VERSION 1 - - -typedef struct wl_event_data_if { - uint8 ifidx; - uint8 opcode; - uint8 reserved; - uint8 bssidx; - uint8 role; -} wl_event_data_if_t; - - -#define WLC_E_IF_ADD 1 -#define WLC_E_IF_DEL 2 -#define WLC_E_IF_CHANGE 3 - - -#define WLC_E_IF_ROLE_STA 0 -#define WLC_E_IF_ROLE_AP 1 -#define WLC_E_IF_ROLE_WDS 2 -#define WLC_E_IF_ROLE_P2P_GO 3 -#define WLC_E_IF_ROLE_P2P_CLIENT 4 -#define WLC_E_IF_ROLE_BTA_CREATOR 5 -#define WLC_E_IF_ROLE_BTA_ACCEPTOR 6 - - -#define WLC_E_LINK_BCN_LOSS 1 -#define WLC_E_LINK_DISASSOC 2 -#define WLC_E_LINK_ASSOC_REC 3 -#define WLC_E_LINK_BSSCFG_DIS 4 - - -#define WLC_E_OVL_DOWNLOAD 0 -#define WLC_E_OVL_UPDATE_IND 1 - - -#include <packed_section_end.h> - -#endif diff --git a/bcm4329/dhdutil/include/proto/bcmip.h b/bcm4329/dhdutil/include/proto/bcmip.h deleted file mode 100644 index af4e8cb..0000000 --- a/bcm4329/dhdutil/include/proto/bcmip.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Fundamental constants relating to IP Protocol - * - * $Id: bcmip.h,v 9.19 2009-11-10 20:08:33 Exp $ - */ - - -#ifndef _bcmip_h_ -#define _bcmip_h_ - -#ifndef _TYPEDEFS_H_ -#include <typedefs.h> -#endif - - -#include <packed_section_start.h> - - - -#define IP_VER_OFFSET 0x0 -#define IP_VER_MASK 0xf0 -#define IP_VER_SHIFT 4 -#define IP_VER_4 4 -#define IP_VER_6 6 - -#define IP_VER(ip_body) \ - ((((uint8 *)(ip_body))[IP_VER_OFFSET] & IP_VER_MASK) >> IP_VER_SHIFT) - -#define IP_PROT_ICMP 0x1 -#define IP_PROT_TCP 0x6 -#define IP_PROT_UDP 0x11 - - -#define IPV4_VER_HL_OFFSET 0 -#define IPV4_TOS_OFFSET 1 -#define IPV4_PKTLEN_OFFSET 2 -#define IPV4_PKTFLAG_OFFSET 6 -#define IPV4_PROT_OFFSET 9 -#define IPV4_CHKSUM_OFFSET 10 -#define IPV4_SRC_IP_OFFSET 12 -#define IPV4_DEST_IP_OFFSET 16 -#define IPV4_OPTIONS_OFFSET 20 - - -#define IPV4_VER_MASK 0xf0 -#define IPV4_VER_SHIFT 4 - -#define IPV4_HLEN_MASK 0x0f -#define IPV4_HLEN(ipv4_body) (4 * (((uint8 *)(ipv4_body))[IPV4_VER_HL_OFFSET] & IPV4_HLEN_MASK)) - -#define IPV4_ADDR_LEN 4 - -#define IPV4_ADDR_NULL(a) ((((uint8 *)(a))[0] | ((uint8 *)(a))[1] | \ - ((uint8 *)(a))[2] | ((uint8 *)(a))[3]) == 0) - -#define IPV4_ADDR_BCAST(a) ((((uint8 *)(a))[0] & ((uint8 *)(a))[1] & \ - ((uint8 *)(a))[2] & ((uint8 *)(a))[3]) == 0xff) - -#define IPV4_TOS_DSCP_MASK 0xfc -#define IPV4_TOS_DSCP_SHIFT 2 - -#define IPV4_TOS(ipv4_body) (((uint8 *)(ipv4_body))[IPV4_TOS_OFFSET]) - -#define IPV4_TOS_PREC_MASK 0xe0 -#define IPV4_TOS_PREC_SHIFT 5 - -#define IPV4_TOS_LOWDELAY 0x10 -#define IPV4_TOS_THROUGHPUT 0x8 -#define IPV4_TOS_RELIABILITY 0x4 - -#define IPV4_PROT(ipv4_body) (((uint8 *)(ipv4_body))[IPV4_PROT_OFFSET]) - -#define IPV4_FRAG_RESV 0x8000 -#define IPV4_FRAG_DONT 0x4000 -#define IPV4_FRAG_MORE 0x2000 -#define IPV4_FRAG_OFFSET_MASK 0x1fff - -#define IPV4_ADDR_STR_LEN 16 - - -BWL_PRE_PACKED_STRUCT struct ipv4_addr { - uint8 addr[IPV4_ADDR_LEN]; -} BWL_POST_PACKED_STRUCT; - -BWL_PRE_PACKED_STRUCT struct ipv4_hdr { - uint8 version_ihl; - uint8 tos; - uint16 tot_len; - uint16 id; - uint16 frag; - uint8 ttl; - uint8 prot; - uint16 hdr_chksum; - uint8 src_ip[IPV4_ADDR_LEN]; - uint8 dst_ip[IPV4_ADDR_LEN]; -} BWL_POST_PACKED_STRUCT; - - -#define IPV6_PAYLOAD_LEN_OFFSET 4 -#define IPV6_NEXT_HDR_OFFSET 6 -#define IPV6_HOP_LIMIT_OFFSET 7 -#define IPV6_SRC_IP_OFFSET 8 -#define IPV6_DEST_IP_OFFSET 24 - - -#define IPV6_TRAFFIC_CLASS(ipv6_body) \ - (((((uint8 *)(ipv6_body))[0] & 0x0f) << 4) | \ - ((((uint8 *)(ipv6_body))[1] & 0xf0) >> 4)) - -#define IPV6_FLOW_LABEL(ipv6_body) \ - (((((uint8 *)(ipv6_body))[1] & 0x0f) << 16) | \ - (((uint8 *)(ipv6_body))[2] << 8) | \ - (((uint8 *)(ipv6_body))[3])) - -#define IPV6_PAYLOAD_LEN(ipv6_body) \ - ((((uint8 *)(ipv6_body))[IPV6_PAYLOAD_LEN_OFFSET + 0] << 8) | \ - ((uint8 *)(ipv6_body))[IPV6_PAYLOAD_LEN_OFFSET + 1]) - -#define IPV6_NEXT_HDR(ipv6_body) \ - (((uint8 *)(ipv6_body))[IPV6_NEXT_HDR_OFFSET]) - -#define IPV6_PROT(ipv6_body) IPV6_NEXT_HDR(ipv6_body) - -#define IPV6_ADDR_LEN 16 - - -#define IP_TOS46(ip_body) \ - (IP_VER(ip_body) == IP_VER_4 ? IPV4_TOS(ip_body) : \ - IP_VER(ip_body) == IP_VER_6 ? IPV6_TRAFFIC_CLASS(ip_body) : 0) - - -#include <packed_section_end.h> - -#endif diff --git a/bcm4329/dhdutil/include/proto/bt_amp_hci.h b/bcm4329/dhdutil/include/proto/bt_amp_hci.h deleted file mode 100644 index 2ef2dd8..0000000 --- a/bcm4329/dhdutil/include/proto/bt_amp_hci.h +++ /dev/null @@ -1,436 +0,0 @@ -/* - * BT-AMP (BlueTooth Alternate Mac and Phy) HCI (Host/Controller Interface) - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: bt_amp_hci.h,v 9.14.8.2 2010-09-10 18:37:47 Exp $ -*/ - -#ifndef _bt_amp_hci_h -#define _bt_amp_hci_h - -/* This marks the start of a packed structure section. */ -#include <packed_section_start.h> - - -/* AMP HCI CMD packet format */ -typedef BWL_PRE_PACKED_STRUCT struct amp_hci_cmd { - uint16 opcode; - uint8 plen; - uint8 parms[1]; -} BWL_POST_PACKED_STRUCT amp_hci_cmd_t; - -#define HCI_CMD_PREAMBLE_SIZE OFFSETOF(amp_hci_cmd_t, parms) -#define HCI_CMD_DATA_SIZE 255 - -/* AMP HCI CMD opcode layout */ -#define HCI_CMD_OPCODE(ogf, ocf) ((((ogf) & 0x3F) << 10) | ((ocf) & 0x03FF)) -#define HCI_CMD_OGF(opcode) ((uint8)(((opcode) >> 10) & 0x3F)) -#define HCI_CMD_OCF(opcode) ((opcode) & 0x03FF) - -/* AMP HCI command opcodes */ -#define HCI_Read_Failed_Contact_Counter HCI_CMD_OPCODE(0x05, 0x0001) -#define HCI_Reset_Failed_Contact_Counter HCI_CMD_OPCODE(0x05, 0x0002) -#define HCI_Read_Link_Quality HCI_CMD_OPCODE(0x05, 0x0003) -#define HCI_Read_Local_AMP_Info HCI_CMD_OPCODE(0x05, 0x0009) -#define HCI_Read_Local_AMP_ASSOC HCI_CMD_OPCODE(0x05, 0x000A) -#define HCI_Write_Remote_AMP_ASSOC HCI_CMD_OPCODE(0x05, 0x000B) -#define HCI_Create_Physical_Link HCI_CMD_OPCODE(0x01, 0x0035) -#define HCI_Accept_Physical_Link_Request HCI_CMD_OPCODE(0x01, 0x0036) -#define HCI_Disconnect_Physical_Link HCI_CMD_OPCODE(0x01, 0x0037) -#define HCI_Create_Logical_Link HCI_CMD_OPCODE(0x01, 0x0038) -#define HCI_Accept_Logical_Link HCI_CMD_OPCODE(0x01, 0x0039) -#define HCI_Disconnect_Logical_Link HCI_CMD_OPCODE(0x01, 0x003A) -#define HCI_Logical_Link_Cancel HCI_CMD_OPCODE(0x01, 0x003B) -#define HCI_Flow_Spec_Modify HCI_CMD_OPCODE(0x01, 0x003C) -#define HCI_Write_Flow_Control_Mode HCI_CMD_OPCODE(0x01, 0x0067) -#define HCI_Read_Best_Effort_Flush_Timeout HCI_CMD_OPCODE(0x01, 0x0069) -#define HCI_Write_Best_Effort_Flush_Timeout HCI_CMD_OPCODE(0x01, 0x006A) -#define HCI_Short_Range_Mode HCI_CMD_OPCODE(0x01, 0x006B) -#define HCI_Reset HCI_CMD_OPCODE(0x03, 0x0003) -#define HCI_Read_Connection_Accept_Timeout HCI_CMD_OPCODE(0x03, 0x0015) -#define HCI_Write_Connection_Accept_Timeout HCI_CMD_OPCODE(0x03, 0x0016) -#define HCI_Read_Link_Supervision_Timeout HCI_CMD_OPCODE(0x03, 0x0036) -#define HCI_Write_Link_Supervision_Timeout HCI_CMD_OPCODE(0x03, 0x0037) -#define HCI_Enhanced_Flush HCI_CMD_OPCODE(0x03, 0x005F) -#define HCI_Read_Logical_Link_Accept_Timeout HCI_CMD_OPCODE(0x03, 0x0061) -#define HCI_Write_Logical_Link_Accept_Timeout HCI_CMD_OPCODE(0x03, 0x0062) -#define HCI_Set_Event_Mask_Page_2 HCI_CMD_OPCODE(0x03, 0x0063) -#define HCI_Read_Location_Data_Command HCI_CMD_OPCODE(0x03, 0x0064) -#define HCI_Write_Location_Data_Command HCI_CMD_OPCODE(0x03, 0x0065) -#define HCI_Read_Local_Version_Info HCI_CMD_OPCODE(0x04, 0x0001) -#define HCI_Read_Local_Supported_Commands HCI_CMD_OPCODE(0x04, 0x0002) -#define HCI_Read_Buffer_Size HCI_CMD_OPCODE(0x04, 0x0005) -#define HCI_Read_Data_Block_Size HCI_CMD_OPCODE(0x04, 0x000A) - -/* AMP HCI command parameters */ -typedef BWL_PRE_PACKED_STRUCT struct read_local_cmd_parms { - uint8 plh; - uint8 offset[2]; /* length so far */ - uint8 max_remote[2]; -} BWL_POST_PACKED_STRUCT read_local_cmd_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct write_remote_cmd_parms { - uint8 plh; - uint8 offset[2]; - uint8 len[2]; - uint8 frag[1]; -} BWL_POST_PACKED_STRUCT write_remote_cmd_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct phy_link_cmd_parms { - uint8 plh; - uint8 key_length; - uint8 key_type; - uint8 key[1]; -} BWL_POST_PACKED_STRUCT phy_link_cmd_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct dis_phy_link_cmd_parms { - uint8 plh; - uint8 reason; -} BWL_POST_PACKED_STRUCT dis_phy_link_cmd_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct log_link_cmd_parms { - uint8 plh; - uint8 txflow[16]; - uint8 rxflow[16]; -} BWL_POST_PACKED_STRUCT log_link_cmd_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct ext_flow_spec { - uint8 id; - uint8 service_type; - uint8 max_sdu[2]; - uint8 sdu_ia_time[4]; - uint8 access_latency[4]; - uint8 flush_timeout[4]; -} BWL_POST_PACKED_STRUCT ext_flow_spec_t; - -typedef BWL_PRE_PACKED_STRUCT struct log_link_cancel_cmd_parms { - uint8 plh; - uint8 tx_fs_ID; -} BWL_POST_PACKED_STRUCT log_link_cancel_cmd_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct flow_spec_mod_cmd_parms { - uint8 llh[2]; - uint8 txflow[16]; - uint8 rxflow[16]; -} BWL_POST_PACKED_STRUCT flow_spec_mod_cmd_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct plh_pad { - uint8 plh; - uint8 pad; -} BWL_POST_PACKED_STRUCT plh_pad_t; - -typedef BWL_PRE_PACKED_STRUCT union hci_handle { - uint16 bredr; - plh_pad_t amp; -} BWL_POST_PACKED_STRUCT hci_handle_t; - -typedef BWL_PRE_PACKED_STRUCT struct ls_to_cmd_parms { - hci_handle_t handle; - uint8 timeout[2]; -} BWL_POST_PACKED_STRUCT ls_to_cmd_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct befto_cmd_parms { - uint8 llh[2]; - uint8 befto[4]; -} BWL_POST_PACKED_STRUCT befto_cmd_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct srm_cmd_parms { - uint8 plh; - uint8 srm; -} BWL_POST_PACKED_STRUCT srm_cmd_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct ld_cmd_parms { - uint8 ld_aware; - uint8 ld[2]; - uint8 ld_opts; - uint8 l_opts; -} BWL_POST_PACKED_STRUCT ld_cmd_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct eflush_cmd_parms { - uint8 llh[2]; - uint8 packet_type; -} BWL_POST_PACKED_STRUCT eflush_cmd_parms_t; - -/* Generic AMP extended flow spec service types */ -#define EFS_SVCTYPE_NO_TRAFFIC 0 -#define EFS_SVCTYPE_BEST_EFFORT 1 -#define EFS_SVCTYPE_GUARANTEED 2 - -/* AMP HCI event packet format */ -typedef BWL_PRE_PACKED_STRUCT struct amp_hci_event { - uint8 ecode; - uint8 plen; - uint8 parms[1]; -} BWL_POST_PACKED_STRUCT amp_hci_event_t; - -#define HCI_EVT_PREAMBLE_SIZE OFFSETOF(amp_hci_event_t, parms) - -/* AMP HCI event codes */ -#define HCI_Command_Complete 0x0E -#define HCI_Command_Status 0x0F -#define HCI_Flush_Occurred 0x11 -#define HCI_Enhanced_Flush_Complete 0x39 -#define HCI_Physical_Link_Complete 0x40 -#define HCI_Channel_Select 0x41 -#define HCI_Disconnect_Physical_Link_Complete 0x42 -#define HCI_Logical_Link_Complete 0x45 -#define HCI_Disconnect_Logical_Link_Complete 0x46 -#define HCI_Flow_Spec_Modify_Complete 0x47 -#define HCI_Number_of_Completed_Data_Blocks 0x48 -#define HCI_Short_Range_Mode_Change_Complete 0x4C -#define HCI_Status_Change_Event 0x4D -#define HCI_Vendor_Specific 0xFF - -/* AMP HCI event mask bit positions */ -#define HCI_Physical_Link_Complete_Event_Mask 0x0001 -#define HCI_Channel_Select_Event_Mask 0x0002 -#define HCI_Disconnect_Physical_Link_Complete_Event_Mask 0x0004 -#define HCI_Logical_Link_Complete_Event_Mask 0x0020 -#define HCI_Disconnect_Logical_Link_Complete_Event_Mask 0x0040 -#define HCI_Flow_Spec_Modify_Complete_Event_Mask 0x0080 -#define HCI_Number_of_Completed_Data_Blocks_Event_Mask 0x0100 -#define HCI_Short_Range_Mode_Change_Complete_Event_Mask 0x1000 -#define HCI_Status_Change_Event_Mask 0x2000 -#define HCI_All_Event_Mask 0x31e7 - -/* AMP HCI event parameters */ -typedef BWL_PRE_PACKED_STRUCT struct cmd_status_parms { - uint8 status; - uint8 cmdpkts; - uint16 opcode; -} BWL_POST_PACKED_STRUCT cmd_status_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct cmd_complete_parms { - uint8 cmdpkts; - uint16 opcode; - uint8 parms[1]; -} BWL_POST_PACKED_STRUCT cmd_complete_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct flush_occurred_evt_parms { - uint16 handle; -} BWL_POST_PACKED_STRUCT flush_occurred_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct write_remote_evt_parms { - uint8 status; - uint8 plh; -} BWL_POST_PACKED_STRUCT write_remote_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct read_local_evt_parms { - uint8 status; - uint8 plh; - uint16 len; - uint8 frag[1]; -} BWL_POST_PACKED_STRUCT read_local_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct read_local_info_evt_parms { - uint8 status; - uint8 AMP_status; - uint32 bandwidth; - uint32 gbandwidth; - uint32 latency; - uint32 PDU_size; - uint8 ctrl_type; - uint16 PAL_cap; - uint16 AMP_ASSOC_len; - uint32 max_flush_timeout; - uint32 be_flush_timeout; -} BWL_POST_PACKED_STRUCT read_local_info_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct log_link_evt_parms { - uint8 status; - uint16 llh; - uint8 plh; - uint8 tx_fs_ID; -} BWL_POST_PACKED_STRUCT log_link_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct disc_log_link_evt_parms { - uint8 status; - uint16 llh; - uint8 reason; -} BWL_POST_PACKED_STRUCT disc_log_link_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct log_link_cancel_evt_parms { - uint8 status; - uint8 plh; - uint8 tx_fs_ID; -} BWL_POST_PACKED_STRUCT log_link_cancel_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct flow_spec_mod_evt_parms { - uint8 status; - uint16 llh; -} BWL_POST_PACKED_STRUCT flow_spec_mod_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct phy_link_evt_parms { - uint8 status; - uint8 plh; -} BWL_POST_PACKED_STRUCT phy_link_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct dis_phy_link_evt_parms { - uint8 status; - uint8 plh; - uint8 reason; -} BWL_POST_PACKED_STRUCT dis_phy_link_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct read_ls_to_evt_parms { - uint8 status; - hci_handle_t handle; - uint16 timeout; -} BWL_POST_PACKED_STRUCT read_ls_to_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct read_lla_ca_to_evt_parms { - uint8 status; - uint16 timeout; -} BWL_POST_PACKED_STRUCT read_lla_ca_to_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct read_data_block_size_evt_parms { - uint8 status; - uint16 ACL_pkt_len; - uint16 data_block_len; - uint16 data_block_num; -} BWL_POST_PACKED_STRUCT read_data_block_size_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct data_blocks { - uint16 handle; - uint16 pkts; - uint16 blocks; -} BWL_POST_PACKED_STRUCT data_blocks_t; - -typedef BWL_PRE_PACKED_STRUCT struct num_completed_data_blocks_evt_parms { - uint16 num_blocks; - uint8 num_handles; - data_blocks_t completed[1]; -} BWL_POST_PACKED_STRUCT num_completed_data_blocks_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct befto_evt_parms { - uint8 status; - uint32 befto; -} BWL_POST_PACKED_STRUCT befto_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct srm_evt_parms { - uint8 status; - uint8 plh; - uint8 srm; -} BWL_POST_PACKED_STRUCT srm_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct contact_counter_evt_parms { - uint8 status; - uint8 llh[2]; - uint16 counter; -} BWL_POST_PACKED_STRUCT contact_counter_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct contact_counter_reset_evt_parms { - uint8 status; - uint8 llh[2]; -} BWL_POST_PACKED_STRUCT contact_counter_reset_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct read_linkq_evt_parms { - uint8 status; - hci_handle_t handle; - uint8 link_quality; -} BWL_POST_PACKED_STRUCT read_linkq_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct ld_evt_parms { - uint8 status; - uint8 ld_aware; - uint8 ld[2]; - uint8 ld_opts; - uint8 l_opts; -} BWL_POST_PACKED_STRUCT ld_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct eflush_complete_evt_parms { - uint16 handle; -} BWL_POST_PACKED_STRUCT eflush_complete_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct vendor_specific_evt_parms { - uint8 len; - uint8 parms[1]; -} BWL_POST_PACKED_STRUCT vendor_specific_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct local_version_info_evt_parms { - uint8 status; - uint8 hci_version; - uint16 hci_revision; - uint8 pal_version; - uint16 mfg_name; - uint16 pal_subversion; -} BWL_POST_PACKED_STRUCT local_version_info_evt_parms_t; - -#define MAX_SUPPORTED_CMD_BYTE 64 -typedef BWL_PRE_PACKED_STRUCT struct local_supported_cmd_evt_parms { - uint8 status; - uint8 cmd[MAX_SUPPORTED_CMD_BYTE]; -} BWL_POST_PACKED_STRUCT local_supported_cmd_evt_parms_t; - -typedef BWL_PRE_PACKED_STRUCT struct status_change_evt_parms { - uint8 status; - uint8 amp_status; -} BWL_POST_PACKED_STRUCT status_change_evt_parms_t; - -/* AMP HCI error codes */ -#define HCI_SUCCESS 0x00 -#define HCI_ERR_ILLEGAL_COMMAND 0x01 -#define HCI_ERR_NO_CONNECTION 0x02 -#define HCI_ERR_MEMORY_FULL 0x07 -#define HCI_ERR_CONNECTION_TIMEOUT 0x08 -#define HCI_ERR_MAX_NUM_OF_CONNECTIONS 0x09 -#define HCI_ERR_CONNECTION_EXISTS 0x0B -#define HCI_ERR_CONNECTION_DISALLOWED 0x0C -#define HCI_ERR_CONNECTION_ACCEPT_TIMEOUT 0x10 -#define HCI_ERR_UNSUPPORTED_VALUE 0x11 -#define HCI_ERR_ILLEGAL_PARAMETER_FMT 0x12 -#define HCI_ERR_CONN_TERM_BY_LOCAL_HOST 0x16 -#define HCI_ERR_UNSPECIFIED 0x1F -#define HCI_ERR_UNIT_KEY_USED 0x26 -#define HCI_ERR_QOS_REJECTED 0x2D -#define HCI_ERR_PARAM_OUT_OF_RANGE 0x30 -#define HCI_ERR_NO_SUITABLE_CHANNEL 0x39 -#define HCI_ERR_CHANNEL_MOVE 0xFF - -/* AMP HCI ACL Data packet format */ -typedef BWL_PRE_PACKED_STRUCT struct amp_hci_ACL_data { - uint16 handle; /* 12-bit connection handle + 2-bit PB and 2-bit BC flags */ - uint16 dlen; /* data total length */ - uint8 data[1]; -} BWL_POST_PACKED_STRUCT amp_hci_ACL_data_t; - -#define HCI_ACL_DATA_PREAMBLE_SIZE OFFSETOF(amp_hci_ACL_data_t, data) - -#define HCI_ACL_DATA_BC_FLAGS (0x0 << 14) -#define HCI_ACL_DATA_PB_FLAGS (0x3 << 12) - -#define HCI_ACL_DATA_HANDLE(handle) ((handle) & 0x0fff) -#define HCI_ACL_DATA_FLAGS(handle) ((handle) >> 12) - -/* AMP Activity Report packet formats */ -typedef BWL_PRE_PACKED_STRUCT struct amp_hci_activity_report { - uint8 ScheduleKnown; - uint8 NumReports; - uint8 data[1]; -} BWL_POST_PACKED_STRUCT amp_hci_activity_report_t; - -typedef BWL_PRE_PACKED_STRUCT struct amp_hci_activity_report_triple { - uint32 StartTime; - uint32 Duration; - uint32 Periodicity; -} BWL_POST_PACKED_STRUCT amp_hci_activity_report_triple_t; - -#define HCI_AR_SCHEDULE_KNOWN 0x01 - - -/* This marks the end of a packed structure section. */ -#include <packed_section_end.h> - -#endif /* _bt_amp_hci_h_ */ diff --git a/bcm4329/dhdutil/include/proto/ethernet.h b/bcm4329/dhdutil/include/proto/ethernet.h deleted file mode 100644 index d18231f..0000000 --- a/bcm4329/dhdutil/include/proto/ethernet.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * From FreeBSD 2.2.7: Fundamental constants relating to ethernet. - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: ethernet.h,v 9.56 2009-10-15 22:54:58 Exp $ - */ - - -#ifndef _NET_ETHERNET_H_ -#define _NET_ETHERNET_H_ - -#ifndef _TYPEDEFS_H_ -#include "typedefs.h" -#endif - - -#include <packed_section_start.h> - - - -#define ETHER_ADDR_LEN 6 - - -#define ETHER_TYPE_LEN 2 - - -#define ETHER_CRC_LEN 4 - - -#define ETHER_HDR_LEN (ETHER_ADDR_LEN * 2 + ETHER_TYPE_LEN) - - -#define ETHER_MIN_LEN 64 - - -#define ETHER_MIN_DATA 46 - - -#define ETHER_MAX_LEN 1518 - - -#define ETHER_MAX_DATA 1500 - - -#define ETHER_TYPE_MIN 0x0600 -#define ETHER_TYPE_IP 0x0800 -#define ETHER_TYPE_ARP 0x0806 -#define ETHER_TYPE_8021Q 0x8100 -#define ETHER_TYPE_BRCM 0x886c -#define ETHER_TYPE_802_1X 0x888e -#define ETHER_TYPE_802_1X_PREAUTH 0x88c7 -#define ETHER_TYPE_WAI 0x88b4 - - - -#define ETHER_BRCM_SUBTYPE_LEN 4 -#define ETHER_BRCM_CRAM 1 - - -#define ETHER_DEST_OFFSET (0 * ETHER_ADDR_LEN) -#define ETHER_SRC_OFFSET (1 * ETHER_ADDR_LEN) -#define ETHER_TYPE_OFFSET (2 * ETHER_ADDR_LEN) - - -#define ETHER_IS_VALID_LEN(foo) \ - ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) - -#define ETHER_FILL_MCAST_ADDR_FROM_IP(ea, mgrp_ip) { \ - ((uint8 *)ea)[0] = 0x01; \ - ((uint8 *)ea)[1] = 0x00; \ - ((uint8 *)ea)[2] = 0x5e; \ - ((uint8 *)ea)[3] = ((mgrp_ip) >> 16) & 0x7f; \ - ((uint8 *)ea)[4] = ((mgrp_ip) >> 8) & 0xff; \ - ((uint8 *)ea)[5] = ((mgrp_ip) >> 0) & 0xff; \ -} - -#ifndef __INCif_etherh - -BWL_PRE_PACKED_STRUCT struct ether_header { - uint8 ether_dhost[ETHER_ADDR_LEN]; - uint8 ether_shost[ETHER_ADDR_LEN]; - uint16 ether_type; -} BWL_POST_PACKED_STRUCT; - - -BWL_PRE_PACKED_STRUCT struct ether_addr { - uint8 octet[ETHER_ADDR_LEN]; -} BWL_POST_PACKED_STRUCT; -#endif - - -#define ETHER_SET_LOCALADDR(ea) (((uint8 *)(ea))[0] = (((uint8 *)(ea))[0] | 2)) -#define ETHER_IS_LOCALADDR(ea) (((uint8 *)(ea))[0] & 2) -#define ETHER_CLR_LOCALADDR(ea) (((uint8 *)(ea))[0] = (((uint8 *)(ea))[0] & 0xd)) -#define ETHER_TOGGLE_LOCALADDR(ea) (((uint8 *)(ea))[0] = (((uint8 *)(ea))[0] ^ 2)) - - -#define ETHER_SET_UNICAST(ea) (((uint8 *)(ea))[0] = (((uint8 *)(ea))[0] & ~1)) - - -#define ETHER_ISMULTI(ea) (((const uint8 *)(ea))[0] & 1) - - - -#define ether_cmp(a, b) (!(((short*)a)[0] == ((short*)b)[0]) | \ - !(((short*)a)[1] == ((short*)b)[1]) | \ - !(((short*)a)[2] == ((short*)b)[2])) - - -#define ether_copy(s, d) { \ - ((short*)d)[0] = ((short*)s)[0]; \ - ((short*)d)[1] = ((short*)s)[1]; \ - ((short*)d)[2] = ((short*)s)[2]; } - - -static const struct ether_addr ether_bcast = {{255, 255, 255, 255, 255, 255}}; -static const struct ether_addr ether_null = {{0, 0, 0, 0, 0, 0}}; - -#define ETHER_ISBCAST(ea) ((((uint8 *)(ea))[0] & \ - ((uint8 *)(ea))[1] & \ - ((uint8 *)(ea))[2] & \ - ((uint8 *)(ea))[3] & \ - ((uint8 *)(ea))[4] & \ - ((uint8 *)(ea))[5]) == 0xff) -#define ETHER_ISNULLADDR(ea) ((((uint8 *)(ea))[0] | \ - ((uint8 *)(ea))[1] | \ - ((uint8 *)(ea))[2] | \ - ((uint8 *)(ea))[3] | \ - ((uint8 *)(ea))[4] | \ - ((uint8 *)(ea))[5]) == 0) - - -#define ETHER_MOVE_HDR(d, s) \ -do { \ - struct ether_header t; \ - t = *(struct ether_header *)(s); \ - *(struct ether_header *)(d) = t; \ -} while (0) - - -#include <packed_section_end.h> - -#endif diff --git a/bcm4329/dhdutil/include/proto/vlan.h b/bcm4329/dhdutil/include/proto/vlan.h deleted file mode 100644 index 6cba7fb..0000000 --- a/bcm4329/dhdutil/include/proto/vlan.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 802.1Q VLAN protocol definitions - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: vlan.h,v 9.7 2009-03-13 01:11:50 Exp $ - */ - - -#ifndef _vlan_h_ -#define _vlan_h_ - -#ifndef _TYPEDEFS_H_ -#include <typedefs.h> -#endif - - -#include <packed_section_start.h> - -#define VLAN_VID_MASK 0xfff -#define VLAN_CFI_SHIFT 12 -#define VLAN_PRI_SHIFT 13 - -#define VLAN_PRI_MASK 7 - -#define VLAN_TAG_LEN 4 -#define VLAN_TAG_OFFSET (2 * ETHER_ADDR_LEN) - -#define VLAN_TPID 0x8100 - -struct ethervlan_header { - uint8 ether_dhost[ETHER_ADDR_LEN]; - uint8 ether_shost[ETHER_ADDR_LEN]; - uint16 vlan_type; - uint16 vlan_tag; - uint16 ether_type; -}; - -#define ETHERVLAN_HDR_LEN (ETHER_HDR_LEN + VLAN_TAG_LEN) - - - -#include <packed_section_end.h> - -#define ETHERVLAN_MOVE_HDR(d, s) \ -do { \ - struct ethervlan_header t; \ - t = *(struct ethervlan_header *)(s); \ - *(struct ethervlan_header *)(d) = t; \ -} while (0) - -#endif diff --git a/bcm4329/dhdutil/include/proto/wpa.h b/bcm4329/dhdutil/include/proto/wpa.h deleted file mode 100644 index 99a246f..0000000 --- a/bcm4329/dhdutil/include/proto/wpa.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Fundamental types and constants relating to WPA - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: wpa.h,v 1.19 2009-07-13 08:29:58 Exp $ - */ - - -#ifndef _proto_wpa_h_ -#define _proto_wpa_h_ - -#include <typedefs.h> -#include <proto/ethernet.h> - - - -#include <packed_section_start.h> - - - - -#define DOT11_RC_INVALID_WPA_IE 13 -#define DOT11_RC_MIC_FAILURE 14 -#define DOT11_RC_4WH_TIMEOUT 15 -#define DOT11_RC_GTK_UPDATE_TIMEOUT 16 -#define DOT11_RC_WPA_IE_MISMATCH 17 -#define DOT11_RC_INVALID_MC_CIPHER 18 -#define DOT11_RC_INVALID_UC_CIPHER 19 -#define DOT11_RC_INVALID_AKMP 20 -#define DOT11_RC_BAD_WPA_VERSION 21 -#define DOT11_RC_INVALID_WPA_CAP 22 -#define DOT11_RC_8021X_AUTH_FAIL 23 - -#define WPA2_PMKID_LEN 16 - - -typedef BWL_PRE_PACKED_STRUCT struct -{ - uint8 tag; - uint8 length; - uint8 oui[3]; - uint8 oui_type; - BWL_PRE_PACKED_STRUCT struct { - uint8 low; - uint8 high; - } BWL_POST_PACKED_STRUCT version; -} BWL_POST_PACKED_STRUCT wpa_ie_fixed_t; -#define WPA_IE_OUITYPE_LEN 4 -#define WPA_IE_FIXED_LEN 8 -#define WPA_IE_TAG_FIXED_LEN 6 - -typedef BWL_PRE_PACKED_STRUCT struct { - uint8 tag; - uint8 length; - BWL_PRE_PACKED_STRUCT struct { - uint8 low; - uint8 high; - } BWL_POST_PACKED_STRUCT version; -} BWL_POST_PACKED_STRUCT wpa_rsn_ie_fixed_t; -#define WPA_RSN_IE_FIXED_LEN 4 -#define WPA_RSN_IE_TAG_FIXED_LEN 2 -typedef uint8 wpa_pmkid_t[WPA2_PMKID_LEN]; - - -typedef BWL_PRE_PACKED_STRUCT struct -{ - uint8 oui[3]; - uint8 type; -} BWL_POST_PACKED_STRUCT wpa_suite_t, wpa_suite_mcast_t; -#define WPA_SUITE_LEN 4 - - -typedef BWL_PRE_PACKED_STRUCT struct -{ - BWL_PRE_PACKED_STRUCT struct { - uint8 low; - uint8 high; - } BWL_POST_PACKED_STRUCT count; - wpa_suite_t list[1]; -} BWL_POST_PACKED_STRUCT wpa_suite_ucast_t, wpa_suite_auth_key_mgmt_t; -#define WPA_IE_SUITE_COUNT_LEN 2 -typedef BWL_PRE_PACKED_STRUCT struct -{ - BWL_PRE_PACKED_STRUCT struct { - uint8 low; - uint8 high; - } BWL_POST_PACKED_STRUCT count; - wpa_pmkid_t list[1]; -} BWL_POST_PACKED_STRUCT wpa_pmkid_list_t; - - -#define WPA_CIPHER_NONE 0 -#define WPA_CIPHER_WEP_40 1 -#define WPA_CIPHER_TKIP 2 -#define WPA_CIPHER_AES_OCB 3 -#define WPA_CIPHER_AES_CCM 4 -#define WPA_CIPHER_WEP_104 5 - - -#define IS_WPA_CIPHER(cipher) ((cipher) == WPA_CIPHER_NONE || \ - (cipher) == WPA_CIPHER_WEP_40 || \ - (cipher) == WPA_CIPHER_WEP_104 || \ - (cipher) == WPA_CIPHER_TKIP || \ - (cipher) == WPA_CIPHER_AES_OCB || \ - (cipher) == WPA_CIPHER_AES_CCM) - - -#define WPA_TKIP_CM_DETECT 60 -#define WPA_TKIP_CM_BLOCK 60 - - -#define RSN_CAP_LEN 2 - - -#define RSN_CAP_PREAUTH 0x0001 -#define RSN_CAP_NOPAIRWISE 0x0002 -#define RSN_CAP_PTK_REPLAY_CNTR_MASK 0x000C -#define RSN_CAP_PTK_REPLAY_CNTR_SHIFT 2 -#define RSN_CAP_GTK_REPLAY_CNTR_MASK 0x0030 -#define RSN_CAP_GTK_REPLAY_CNTR_SHIFT 4 -#define RSN_CAP_1_REPLAY_CNTR 0 -#define RSN_CAP_2_REPLAY_CNTRS 1 -#define RSN_CAP_4_REPLAY_CNTRS 2 -#define RSN_CAP_16_REPLAY_CNTRS 3 - - -#define WPA_CAP_4_REPLAY_CNTRS RSN_CAP_4_REPLAY_CNTRS -#define WPA_CAP_16_REPLAY_CNTRS RSN_CAP_16_REPLAY_CNTRS -#define WPA_CAP_REPLAY_CNTR_SHIFT RSN_CAP_PTK_REPLAY_CNTR_SHIFT -#define WPA_CAP_REPLAY_CNTR_MASK RSN_CAP_PTK_REPLAY_CNTR_MASK - - -#define WPA_CAP_LEN RSN_CAP_LEN - -#define WPA_CAP_WPA2_PREAUTH RSN_CAP_PREAUTH - - - -#include <packed_section_end.h> - -#endif diff --git a/bcm4329/dhdutil/include/sdiovar.h b/bcm4329/dhdutil/include/sdiovar.h deleted file mode 100644 index e8ce8f2..0000000 --- a/bcm4329/dhdutil/include/sdiovar.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Structure used by apps whose drivers access SDIO drivers. - * Pulled out separately so dhdu and wlu can both use it. - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: sdiovar.h,v 13.9 2009-12-08 22:30:15 Exp $ - */ - -#ifndef _sdiovar_h_ -#define _sdiovar_h_ - -#include <typedefs.h> - -/* require default structure packing */ -#define BWL_DEFAULT_PACKING -#include <packed_section_start.h> - -typedef struct sdreg { - int func; - int offset; - int value; -} sdreg_t; - -/* Common msglevel constants */ -#define SDH_ERROR_VAL 0x0001 /* Error */ -#define SDH_TRACE_VAL 0x0002 /* Trace */ -#define SDH_INFO_VAL 0x0004 /* Info */ -#define SDH_DEBUG_VAL 0x0008 /* Debug */ -#define SDH_DATA_VAL 0x0010 /* Data */ -#define SDH_CTRL_VAL 0x0020 /* Control Regs */ -#define SDH_LOG_VAL 0x0040 /* Enable bcmlog */ -#define SDH_DMA_VAL 0x0080 /* DMA */ - -#define NUM_PREV_TRANSACTIONS 16 - - -#include <packed_section_end.h> - -#endif /* _sdiovar_h_ */ diff --git a/bcm4329/dhdutil/include/trxhdr.h b/bcm4329/dhdutil/include/trxhdr.h deleted file mode 100644 index bad2e71..0000000 --- a/bcm4329/dhdutil/include/trxhdr.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * TRX image file header format. - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: trxhdr.h,v 13.15.108.2 2010-11-15 17:57:30 Exp $ - */ - -#ifndef _TRX_HDR_H_ -#define _TRX_HDR_H_ - -#include <typedefs.h> - -#define TRX_MAGIC 0x30524448 /* "HDR0" */ -#define TRX_VERSION 1 /* Version 1 */ -#define TRX_MAX_LEN 0x3B0000 /* Max length */ -#define TRX_NO_HEADER 1 /* Do not write TRX header */ -#define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */ -#define TRX_OVERLAYS 0x4 /* Contains an overlay header after the trx header */ -#define TRX_MAX_OFFSET 3 /* Max number of individual files */ -#define TRX_UNCOMP_IMAGE 0x20 /* Trx contains uncompressed rtecdc.bin image */ - -struct trx_header { - uint32 magic; /* "HDR0" */ - uint32 len; /* Length of file including header */ - uint32 crc32; /* 32-bit CRC from flag_version to end of file */ - uint32 flag_version; /* 0:15 flags, 16:31 version */ - uint32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */ -}; - -/* Compatibility */ -typedef struct trx_header TRXHDR, *PTRXHDR; - -#endif /* _TRX_HDR_H_ */ diff --git a/bcm4329/dhdutil/include/typedefs.h b/bcm4329/dhdutil/include/typedefs.h deleted file mode 100644 index 027f982..0000000 --- a/bcm4329/dhdutil/include/typedefs.h +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: typedefs.h,v 1.103.2.1 2010-05-11 18:19:28 Exp $ - */ - - -#ifndef _TYPEDEFS_H_ -#define _TYPEDEFS_H_ - -#ifdef SITE_TYPEDEFS - - - -#include "site_typedefs.h" - -#else - - - -#ifdef __cplusplus - -#define TYPEDEF_BOOL -#ifndef FALSE -#define FALSE false -#endif -#ifndef TRUE -#define TRUE true -#endif - -#else - - -#endif - -#if defined(__x86_64__) -#define TYPEDEF_UINTPTR -typedef unsigned long long int uintptr; -#endif - - - - - -#if defined(_NEED_SIZE_T_) -typedef long unsigned int size_t; -#endif - - - - - -#if defined(__sparc__) -#define TYPEDEF_ULONG -#endif - - - -#if !defined(LINUX_HYBRID) || defined(LINUX_PORT) -#define TYPEDEF_UINT -#ifndef TARGETENV_android -#define TYPEDEF_USHORT -#define TYPEDEF_ULONG -#endif -#ifdef __KERNEL__ -#include <linux/version.h> -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)) -#define TYPEDEF_BOOL -#endif - -#if (LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 18)) -#include <linux/compiler.h> -#ifdef noinline_for_stack -#define TYPEDEF_BOOL -#endif -#endif -#endif -#endif - - - - - -#if defined(__GNUC__) && defined(__STRICT_ANSI__) -#define TYPEDEF_INT64 -#define TYPEDEF_UINT64 -#endif - - -#if defined(__ICL) - -#define TYPEDEF_INT64 - -#if defined(__STDC__) -#define TYPEDEF_UINT64 -#endif - -#endif - -#if !defined(__DJGPP__) - - -#if defined(__KERNEL__) - - -#if !defined(LINUX_HYBRID) || defined(LINUX_PORT) -#include <linux/types.h> -#endif - -#else - - -#include <sys/types.h> - -#endif - -#endif - - - - -#define USE_TYPEDEF_DEFAULTS - -#endif - - - - -#ifdef USE_TYPEDEF_DEFAULTS -#undef USE_TYPEDEF_DEFAULTS - -#ifndef TYPEDEF_BOOL -typedef unsigned char bool; -#endif - - - -#ifndef TYPEDEF_UCHAR -typedef unsigned char uchar; -#endif - -#ifndef TYPEDEF_USHORT -typedef unsigned short ushort; -#endif - -#ifndef TYPEDEF_UINT -typedef unsigned int uint; -#endif - -#ifndef TYPEDEF_ULONG -typedef unsigned long ulong; -#endif - - - -#ifndef TYPEDEF_UINT8 -typedef unsigned char uint8; -#endif - -#ifndef TYPEDEF_UINT16 -typedef unsigned short uint16; -#endif - -#ifndef TYPEDEF_UINT32 -typedef unsigned int uint32; -#endif - -#ifndef TYPEDEF_UINT64 -typedef unsigned long long uint64; -#endif - -#ifndef TYPEDEF_UINTPTR -typedef unsigned int uintptr; -#endif - -#ifndef TYPEDEF_INT8 -typedef signed char int8; -#endif - -#ifndef TYPEDEF_INT16 -typedef signed short int16; -#endif - -#ifndef TYPEDEF_INT32 -typedef signed int int32; -#endif - -#ifndef TYPEDEF_INT64 -typedef signed long long int64; -#endif - - - -#ifndef TYPEDEF_FLOAT32 -typedef float float32; -#endif - -#ifndef TYPEDEF_FLOAT64 -typedef double float64; -#endif - - - -#ifndef TYPEDEF_FLOAT_T - -#if defined(FLOAT32) -typedef float32 float_t; -#else -typedef float64 float_t; -#endif - -#endif - - - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef OFF -#define OFF 0 -#endif - -#ifndef ON -#define ON 1 -#endif - -#define AUTO (-1) - - - -#ifndef PTRSZ -#define PTRSZ sizeof(char*) -#endif - - - -#if defined(__GNUC__) - #define BWL_COMPILER_GNU -#elif defined(__CC_ARM) && __CC_ARM - #define BWL_COMPILER_ARMCC -#else - #error "Unknown compiler!" -#endif - - -#ifndef INLINE - #if defined(BWL_COMPILER_MICROSOFT) - #define INLINE __inline - #elif defined(BWL_COMPILER_GNU) - #define INLINE __inline__ - #elif defined(BWL_COMPILER_ARMCC) - #define INLINE __inline - #else - #define INLINE - #endif -#endif - -#undef TYPEDEF_BOOL -#undef TYPEDEF_UCHAR -#undef TYPEDEF_USHORT -#undef TYPEDEF_UINT -#undef TYPEDEF_ULONG -#undef TYPEDEF_UINT8 -#undef TYPEDEF_UINT16 -#undef TYPEDEF_UINT32 -#undef TYPEDEF_UINT64 -#undef TYPEDEF_UINTPTR -#undef TYPEDEF_INT8 -#undef TYPEDEF_INT16 -#undef TYPEDEF_INT32 -#undef TYPEDEF_INT64 -#undef TYPEDEF_FLOAT32 -#undef TYPEDEF_FLOAT64 -#undef TYPEDEF_FLOAT_T - -#endif - - -#define UNUSED_PARAMETER(x) (void)(x) - - -#include <bcmdefs.h> -#endif diff --git a/bcm4329/dhdutil/include/wlioctl.h b/bcm4329/dhdutil/include/wlioctl.h deleted file mode 100644 index 2e2d4d8..0000000 --- a/bcm4329/dhdutil/include/wlioctl.h +++ /dev/null @@ -1,2664 +0,0 @@ -/* - * Custom OID/ioctl definitions for - * Broadcom 802.11abg Networking Device Driver - * - * Definitions subject to change without notice. - * - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: wlioctl.h,v 1.767.2.38 2011-02-01 23:04:28 Exp $ - */ - - -#ifndef _wlioctl_h_ -#define _wlioctl_h_ - -#include <typedefs.h> -#include <proto/ethernet.h> -#include <proto/bcmeth.h> -#include <proto/bcmevent.h> -#include <proto/802.11.h> -#include <bcmwifi.h> - -#include <bcmcdc.h> - -#ifndef INTF_NAME_SIZ -#define INTF_NAME_SIZ 16 -#endif - - -typedef struct remote_ioctl { - cdc_ioctl_t msg; - uint data_len; - char intf_name[INTF_NAME_SIZ]; -} rem_ioctl_t; -#define REMOTE_SIZE sizeof(rem_ioctl_t) - -#define ACTION_FRAME_SIZE 1040 - -typedef struct wl_action_frame { - struct ether_addr da; - uint16 len; - uint32 packetId; - uint8 data[ACTION_FRAME_SIZE]; -} wl_action_frame_t; - -#define WL_WIFI_ACTION_FRAME_SIZE sizeof(struct wl_action_frame) - -typedef struct wl_af_params { - uint32 channel; - int32 dwell_time; - struct ether_addr BSSID; - wl_action_frame_t action_frame; -} wl_af_params_t; - -#define WL_WIFI_AF_PARAMS_SIZE sizeof(struct wl_af_params) - - -#define BWL_DEFAULT_PACKING -#include <packed_section_start.h> - - - - - -#define LEGACY2_WL_BSS_INFO_VERSION 108 - - -typedef struct wl_bss_info_108 { - uint32 version; - uint32 length; - struct ether_addr BSSID; - uint16 beacon_period; - uint16 capability; - uint8 SSID_len; - uint8 SSID[32]; - struct { - uint count; - uint8 rates[16]; - } rateset; - chanspec_t chanspec; - uint16 atim_window; - uint8 dtim_period; - int16 RSSI; - int8 phy_noise; - - uint8 n_cap; - uint32 nbss_cap; - uint8 ctl_ch; - uint32 reserved32[1]; - uint8 flags; - uint8 reserved[3]; - uint8 basic_mcs[MCSSET_LEN]; - - uint16 ie_offset; - uint32 ie_length; - - -} wl_bss_info_108_t; - -#define WL_BSS_INFO_VERSION 109 - - -typedef struct wl_bss_info { - uint32 version; - uint32 length; - struct ether_addr BSSID; - uint16 beacon_period; - uint16 capability; - uint8 SSID_len; - uint8 SSID[32]; - struct { - uint count; - uint8 rates[16]; - } rateset; - chanspec_t chanspec; - uint16 atim_window; - uint8 dtim_period; - int16 RSSI; - int8 phy_noise; - - uint8 n_cap; - uint32 nbss_cap; - uint8 ctl_ch; - uint32 reserved32[1]; - uint8 flags; - uint8 reserved[3]; - uint8 basic_mcs[MCSSET_LEN]; - - uint16 ie_offset; - uint32 ie_length; - int16 SNR; - - -} wl_bss_info_t; - -typedef struct wl_bsscfg { - uint32 wsec; - uint32 WPA_auth; - uint32 wsec_index; - uint32 associated; - uint32 BSS; - uint32 phytest_on; - struct ether_addr prev_BSSID; - struct ether_addr BSSID; -} wl_bsscfg_t; - -typedef struct wl_bss_config { - uint32 atim_window; - uint32 beacon_period; - uint32 chanspec; -} wl_bss_config_t; - - -typedef struct wlc_ssid { - uint32 SSID_len; - uchar SSID[32]; -} wlc_ssid_t; - - -#define WL_BSSTYPE_INFRA 1 -#define WL_BSSTYPE_INDEP 0 -#define WL_BSSTYPE_ANY 2 - - -#define WL_SCANFLAGS_PASSIVE 0x01 -#define WL_SCANFLAGS_RESERVED 0x02 -#define WL_SCANFLAGS_PROHIBITED 0x04 - -typedef struct wl_scan_params { - wlc_ssid_t ssid; - struct ether_addr bssid; - int8 bss_type; - uint8 scan_type; - int32 nprobes; - int32 active_time; - int32 passive_time; - int32 home_time; - int32 channel_num; - uint16 channel_list[1]; -} wl_scan_params_t; - - -#define WL_SCAN_PARAMS_FIXED_SIZE 64 - - -#define WL_SCAN_PARAMS_COUNT_MASK 0x0000ffff -#define WL_SCAN_PARAMS_NSSID_SHIFT 16 - -#define WL_SCAN_ACTION_START 1 -#define WL_SCAN_ACTION_CONTINUE 2 -#define WL_SCAN_ACTION_ABORT 3 - -#define ISCAN_REQ_VERSION 1 - - -typedef struct wl_iscan_params { - uint32 version; - uint16 action; - uint16 scan_duration; - wl_scan_params_t params; -} wl_iscan_params_t; - - -#define WL_ISCAN_PARAMS_FIXED_SIZE (OFFSETOF(wl_iscan_params_t, params) + sizeof(wlc_ssid_t)) - -typedef struct wl_scan_results { - uint32 buflen; - uint32 version; - uint32 count; - wl_bss_info_t bss_info[1]; -} wl_scan_results_t; - - -#define WL_SCAN_RESULTS_FIXED_SIZE (sizeof(wl_scan_results_t) - sizeof(wl_bss_info_t)) - - -#define WL_SCAN_RESULTS_SUCCESS 0 -#define WL_SCAN_RESULTS_PARTIAL 1 -#define WL_SCAN_RESULTS_PENDING 2 -#define WL_SCAN_RESULTS_ABORTED 3 -#define WL_SCAN_RESULTS_NO_MEM 4 - - -#define DNGL_RXCTXT_SIZE 45 - -#if defined(SIMPLE_ISCAN) -#define ISCAN_RETRY_CNT 5 -#define ISCAN_STATE_IDLE 0 -#define ISCAN_STATE_SCANING 1 -#define ISCAN_STATE_PENDING 2 - - -#define WLC_IW_ISCAN_MAXLEN 2048 -typedef struct iscan_buf { - struct iscan_buf * next; - char iscan_buf[WLC_IW_ISCAN_MAXLEN]; -} iscan_buf_t; -#endif - -#define ESCAN_REQ_VERSION 1 - -typedef struct wl_escan_params { - uint32 version; - uint16 action; - uint16 sync_id; - wl_scan_params_t params; -} wl_escan_params_t; - -#define WL_ESCAN_PARAMS_FIXED_SIZE (OFFSETOF(wl_escan_params_t, params) + sizeof(wlc_ssid_t)) - -typedef struct wl_escan_result { - uint32 buflen; - uint32 version; - uint16 sync_id; - uint16 bss_count; - wl_bss_info_t bss_info[1]; -} wl_escan_result_t; - -#define WL_ESCAN_RESULTS_FIXED_SIZE (sizeof(wl_escan_result_t) - sizeof(wl_bss_info_t)) - - -typedef struct wl_iscan_results { - uint32 status; - wl_scan_results_t results; -} wl_iscan_results_t; - - -#define WL_ISCAN_RESULTS_FIXED_SIZE \ - (WL_SCAN_RESULTS_FIXED_SIZE + OFFSETOF(wl_iscan_results_t, results)) - -typedef struct wl_probe_params { - wlc_ssid_t ssid; - struct ether_addr bssid; - struct ether_addr mac; -} wl_probe_params_t; - -#define WL_NUMRATES 16 -typedef struct wl_rateset { - uint32 count; - uint8 rates[WL_NUMRATES]; -} wl_rateset_t; - -typedef struct wl_rateset_args { - uint32 count; - uint8 rates[WL_NUMRATES]; - uint8 mcs[MCSSET_LEN]; -} wl_rateset_args_t; - - -typedef struct wl_uint32_list { - - uint32 count; - - uint32 element[1]; -} wl_uint32_list_t; - - -typedef struct wl_assoc_params { - struct ether_addr bssid; - uint16 bssid_cnt; - int32 chanspec_num; - chanspec_t chanspec_list[1]; -} wl_assoc_params_t; -#define WL_ASSOC_PARAMS_FIXED_SIZE (sizeof(wl_assoc_params_t) - sizeof(chanspec_t)) - - -typedef wl_assoc_params_t wl_reassoc_params_t; -#define WL_REASSOC_PARAMS_FIXED_SIZE WL_ASSOC_PARAMS_FIXED_SIZE - - -typedef wl_assoc_params_t wl_join_assoc_params_t; -#define WL_JOIN_ASSOC_PARAMS_FIXED_SIZE WL_ASSOC_PARAMS_FIXED_SIZE - - -typedef struct wl_join_params { - wlc_ssid_t ssid; - wl_assoc_params_t params; -} wl_join_params_t; -#define WL_JOIN_PARAMS_FIXED_SIZE (sizeof(wl_join_params_t) - sizeof(chanspec_t)) - - -typedef struct wl_join_scan_params { - uint8 scan_type; - int32 nprobes; - int32 active_time; - int32 passive_time; - int32 home_time; -} wl_join_scan_params_t; - - -typedef struct wl_extjoin_params { - wlc_ssid_t ssid; - wl_join_scan_params_t scan; - wl_join_assoc_params_t assoc; -} wl_extjoin_params_t; -#define WL_EXTJOIN_PARAMS_FIXED_SIZE (sizeof(wl_extjoin_params_t) - sizeof(chanspec_t)) - -typedef struct { - uint32 num; - chanspec_t list[1]; -} chanspec_list_t; - - -#define NRATE_MCS_INUSE 0x00000080 -#define NRATE_RATE_MASK 0x0000007f -#define NRATE_STF_MASK 0x0000ff00 -#define NRATE_STF_SHIFT 8 -#define NRATE_OVERRIDE 0x80000000 -#define NRATE_OVERRIDE_MCS_ONLY 0x40000000 -#define NRATE_SGI_MASK 0x00800000 -#define NRATE_SGI_SHIFT 23 -#define NRATE_LDPC_CODING 0x00400000 -#define NRATE_LDPC_SHIFT 22 - -#define NRATE_STF_SISO 0 -#define NRATE_STF_CDD 1 -#define NRATE_STF_STBC 2 -#define NRATE_STF_SDM 3 - -#define ANTENNA_NUM_1 1 -#define ANTENNA_NUM_2 2 -#define ANTENNA_NUM_3 3 -#define ANTENNA_NUM_4 4 - -#define ANT_SELCFG_AUTO 0x80 -#define ANT_SELCFG_MASK 0x33 -#define ANT_SELCFG_MAX 4 -#define ANT_SELCFG_TX_UNICAST 0 -#define ANT_SELCFG_RX_UNICAST 1 -#define ANT_SELCFG_TX_DEF 2 -#define ANT_SELCFG_RX_DEF 3 - -#define MAX_STREAMS_SUPPORTED 4 - -typedef struct { - uint8 ant_config[ANT_SELCFG_MAX]; - uint8 num_antcfg; -} wlc_antselcfg_t; - -#define HIGHEST_SINGLE_STREAM_MCS 7 - -#define MAX_CCA_CHANNELS 38 -#define MAX_CCA_SECS 60 - -#define IBSS_MED 15 -#define IBSS_HI 25 -#define OBSS_MED 12 -#define OBSS_HI 25 -#define INTERFER_MED 5 -#define INTERFER_HI 10 - -#define CCA_FLAG_2G_ONLY 0x01 -#define CCA_FLAG_5G_ONLY 0x02 -#define CCA_FLAG_IGNORE_DURATION 0x04 -#define CCA_FLAGS_PREFER_1_6_11 0x10 -#define CCA_FLAG_IGNORE_INTERFER 0x20 - -#define CCA_ERRNO_BAND 1 -#define CCA_ERRNO_DURATION 2 -#define CCA_ERRNO_PREF_CHAN 3 -#define CCA_ERRNO_INTERFER 4 -#define CCA_ERRNO_TOO_FEW 5 - -typedef struct { - uint32 duration; - uint32 congest_ibss; - - uint32 congest_obss; - uint32 interference; - uint32 timestamp; -} cca_congest_t; - -typedef struct { - chanspec_t chanspec; - uint8 num_secs; - cca_congest_t secs[1]; -} cca_congest_channel_req_t; - -#define WLC_CNTRY_BUF_SZ 4 - -typedef struct wl_country { - char country_abbrev[WLC_CNTRY_BUF_SZ]; - int32 rev; - char ccode[WLC_CNTRY_BUF_SZ]; -} wl_country_t; - -typedef struct wl_channels_in_country { - uint32 buflen; - uint32 band; - char country_abbrev[WLC_CNTRY_BUF_SZ]; - uint32 count; - uint32 channel[1]; -} wl_channels_in_country_t; - -typedef struct wl_country_list { - uint32 buflen; - uint32 band_set; - uint32 band; - uint32 count; - char country_abbrev[1]; -} wl_country_list_t; - -#define WL_NUM_RPI_BINS 8 -#define WL_RM_TYPE_BASIC 1 -#define WL_RM_TYPE_CCA 2 -#define WL_RM_TYPE_RPI 3 - -#define WL_RM_FLAG_PARALLEL (1<<0) - -#define WL_RM_FLAG_LATE (1<<1) -#define WL_RM_FLAG_INCAPABLE (1<<2) -#define WL_RM_FLAG_REFUSED (1<<3) - -typedef struct wl_rm_req_elt { - int8 type; - int8 flags; - chanspec_t chanspec; - uint32 token; - uint32 tsf_h; - uint32 tsf_l; - uint32 dur; -} wl_rm_req_elt_t; - -typedef struct wl_rm_req { - uint32 token; - uint32 count; - void *cb; - void *cb_arg; - wl_rm_req_elt_t req[1]; -} wl_rm_req_t; -#define WL_RM_REQ_FIXED_LEN OFFSETOF(wl_rm_req_t, req) - -typedef struct wl_rm_rep_elt { - int8 type; - int8 flags; - chanspec_t chanspec; - uint32 token; - uint32 tsf_h; - uint32 tsf_l; - uint32 dur; - uint32 len; - uint8 data[1]; -} wl_rm_rep_elt_t; -#define WL_RM_REP_ELT_FIXED_LEN 24 - -#define WL_RPI_REP_BIN_NUM 8 -typedef struct wl_rm_rpi_rep { - uint8 rpi[WL_RPI_REP_BIN_NUM]; - int8 rpi_max[WL_RPI_REP_BIN_NUM]; -} wl_rm_rpi_rep_t; - -typedef struct wl_rm_rep { - uint32 token; - uint32 len; - wl_rm_rep_elt_t rep[1]; -} wl_rm_rep_t; -#define WL_RM_REP_FIXED_LEN 8 - - -typedef enum sup_auth_status { - - WLC_SUP_DISCONNECTED = 0, - WLC_SUP_CONNECTING, - WLC_SUP_IDREQUIRED, - WLC_SUP_AUTHENTICATING, - WLC_SUP_AUTHENTICATED, - WLC_SUP_KEYXCHANGE, - WLC_SUP_KEYED, - WLC_SUP_TIMEOUT, - WLC_SUP_LAST_BASIC_STATE, - - - - WLC_SUP_KEYXCHANGE_WAIT_M1 = WLC_SUP_AUTHENTICATED, - - WLC_SUP_KEYXCHANGE_PREP_M2 = WLC_SUP_KEYXCHANGE, - - WLC_SUP_KEYXCHANGE_WAIT_M3 = WLC_SUP_LAST_BASIC_STATE, - WLC_SUP_KEYXCHANGE_PREP_M4, - WLC_SUP_KEYXCHANGE_WAIT_G1, - WLC_SUP_KEYXCHANGE_PREP_G2 -} sup_auth_status_t; - - -#define CRYPTO_ALGO_OFF 0 -#define CRYPTO_ALGO_WEP1 1 -#define CRYPTO_ALGO_TKIP 2 -#define CRYPTO_ALGO_WEP128 3 -#define CRYPTO_ALGO_AES_CCM 4 -#define CRYPTO_ALGO_AES_OCB_MSDU 5 -#define CRYPTO_ALGO_AES_OCB_MPDU 6 -#define CRYPTO_ALGO_NALG 7 - -#define WSEC_GEN_MIC_ERROR 0x0001 -#define WSEC_GEN_REPLAY 0x0002 -#define WSEC_GEN_ICV_ERROR 0x0004 - -#define WL_SOFT_KEY (1 << 0) -#define WL_PRIMARY_KEY (1 << 1) -#define WL_KF_RES_4 (1 << 4) -#define WL_KF_RES_5 (1 << 5) -#define WL_IBSS_PEER_GROUP_KEY (1 << 6) - -typedef struct wl_wsec_key { - uint32 index; - uint32 len; - uint8 data[DOT11_MAX_KEY_SIZE]; - uint32 pad_1[18]; - uint32 algo; - uint32 flags; - uint32 pad_2[2]; - int pad_3; - int iv_initialized; - int pad_4; - - struct { - uint32 hi; - uint16 lo; - } rxiv; - uint32 pad_5[2]; - struct ether_addr ea; -} wl_wsec_key_t; - -#define WSEC_MIN_PSK_LEN 8 -#define WSEC_MAX_PSK_LEN 64 - - -#define WSEC_PASSPHRASE (1<<0) - - -typedef struct { - ushort key_len; - ushort flags; - uint8 key[WSEC_MAX_PSK_LEN]; -} wsec_pmk_t; - - -#define WEP_ENABLED 0x0001 -#define TKIP_ENABLED 0x0002 -#define AES_ENABLED 0x0004 -#define WSEC_SWFLAG 0x0008 -#define SES_OW_ENABLED 0x0040 - - -#define WPA_AUTH_DISABLED 0x0000 -#define WPA_AUTH_NONE 0x0001 -#define WPA_AUTH_UNSPECIFIED 0x0002 -#define WPA_AUTH_PSK 0x0004 - -#define WPA2_AUTH_UNSPECIFIED 0x0040 -#define WPA2_AUTH_PSK 0x0080 -#define BRCM_AUTH_PSK 0x0100 -#define BRCM_AUTH_DPT 0x0200 - - -#define MAXPMKID 16 - -typedef struct _pmkid { - struct ether_addr BSSID; - uint8 PMKID[WPA2_PMKID_LEN]; -} pmkid_t; - -typedef struct _pmkid_list { - uint32 npmkid; - pmkid_t pmkid[1]; -} pmkid_list_t; - -typedef struct _pmkid_cand { - struct ether_addr BSSID; - uint8 preauth; -} pmkid_cand_t; - -typedef struct _pmkid_cand_list { - uint32 npmkid_cand; - pmkid_cand_t pmkid_cand[1]; -} pmkid_cand_list_t; - - - - -#define WLC_TXFILTER_OVERRIDE_DISABLED 0 -#define WLC_TXFILTER_OVERRIDE_ENABLED 1 - - -typedef struct { - uint32 val; - struct ether_addr ea; -} scb_val_t; - - -typedef struct { - uint32 code; - scb_val_t ioctl_args; -} authops_t; - - -typedef struct channel_info { - int hw_channel; - int target_channel; - int scan_channel; -} channel_info_t; - - -struct maclist { - uint count; - struct ether_addr ea[1]; -}; - - -typedef struct get_pktcnt { - uint rx_good_pkt; - uint rx_bad_pkt; - uint tx_good_pkt; - uint tx_bad_pkt; - uint rx_ocast_good_pkt; -} get_pktcnt_t; - -#define WL_IOCTL_ACTION_GET 0x0 -#define WL_IOCTL_ACTION_SET 0x1 -#define WL_IOCTL_ACTION_OVL_IDX_MASK 0x1e -#define WL_IOCTL_ACTION_OVL_RSV 0x20 -#define WL_IOCTL_ACTION_OVL 0x40 -#define WL_IOCTL_ACTION_MASK 0x7e -#define WL_IOCTL_ACTION_OVL_SHIFT 1 - - -typedef struct wl_ioctl { - uint cmd; - void *buf; - uint len; - uint8 set; - uint used; - uint needed; -} wl_ioctl_t; - - -#define ioctl_subtype set -#define ioctl_pid used -#define ioctl_status needed - - -typedef struct wlc_rev_info { - uint vendorid; - uint deviceid; - uint radiorev; - uint chiprev; - uint corerev; - uint boardid; - uint boardvendor; - uint boardrev; - uint driverrev; - uint ucoderev; - uint bus; - uint chipnum; - uint phytype; - uint phyrev; - uint anarev; - uint chippkg; -} wlc_rev_info_t; - -#define WL_REV_INFO_LEGACY_LENGTH 48 - -#define WL_BRAND_MAX 10 -typedef struct wl_instance_info { - uint instance; - char brand[WL_BRAND_MAX]; -} wl_instance_info_t; - - -typedef struct wl_txfifo_sz { - uint16 magic; - uint16 fifo; - uint16 size; -} wl_txfifo_sz_t; - -#define WL_TXFIFO_SZ_MAGIC 0xa5a5 - - - -#define WLC_IOV_NAME_LEN 30 -typedef struct wlc_iov_trx_s { - uint8 module; - uint8 type; - char name[WLC_IOV_NAME_LEN]; -} wlc_iov_trx_t; - - -#define WLC_IOCTL_MAGIC 0x14e46c77 - - -#define WLC_IOCTL_VERSION 1 - -#define WLC_IOCTL_MAXLEN 8192 -#define WLC_IOCTL_SMLEN 256 -#define WLC_IOCTL_MEDLEN 1536 -#ifdef WLC_HIGH_ONLY -#define WLC_SAMPLECOLLECT_MAXLEN 1024 -#else -#define WLC_SAMPLECOLLECT_MAXLEN 10240 -#endif - - -#define WLC_GET_MAGIC 0 -#define WLC_GET_VERSION 1 -#define WLC_UP 2 -#define WLC_DOWN 3 -#define WLC_GET_LOOP 4 -#define WLC_SET_LOOP 5 -#define WLC_DUMP 6 -#define WLC_GET_MSGLEVEL 7 -#define WLC_SET_MSGLEVEL 8 -#define WLC_GET_PROMISC 9 -#define WLC_SET_PROMISC 10 -#define WLC_OVERLAY_IOCTL 11 -#define WLC_GET_RATE 12 - -#define WLC_GET_INSTANCE 14 - - - - -#define WLC_GET_INFRA 19 -#define WLC_SET_INFRA 20 -#define WLC_GET_AUTH 21 -#define WLC_SET_AUTH 22 -#define WLC_GET_BSSID 23 -#define WLC_SET_BSSID 24 -#define WLC_GET_SSID 25 -#define WLC_SET_SSID 26 -#define WLC_RESTART 27 - -#define WLC_GET_CHANNEL 29 -#define WLC_SET_CHANNEL 30 -#define WLC_GET_SRL 31 -#define WLC_SET_SRL 32 -#define WLC_GET_LRL 33 -#define WLC_SET_LRL 34 -#define WLC_GET_PLCPHDR 35 -#define WLC_SET_PLCPHDR 36 -#define WLC_GET_RADIO 37 -#define WLC_SET_RADIO 38 -#define WLC_GET_PHYTYPE 39 -#define WLC_DUMP_RATE 40 -#define WLC_SET_RATE_PARAMS 41 -#define WLC_GET_FIXRATE 42 -#define WLC_SET_FIXRATE 43 - - -#define WLC_GET_KEY 44 -#define WLC_SET_KEY 45 -#define WLC_GET_REGULATORY 46 -#define WLC_SET_REGULATORY 47 -#define WLC_GET_PASSIVE_SCAN 48 -#define WLC_SET_PASSIVE_SCAN 49 -#define WLC_SCAN 50 -#define WLC_SCAN_RESULTS 51 -#define WLC_DISASSOC 52 -#define WLC_REASSOC 53 -#define WLC_GET_ROAM_TRIGGER 54 -#define WLC_SET_ROAM_TRIGGER 55 -#define WLC_GET_ROAM_DELTA 56 -#define WLC_SET_ROAM_DELTA 57 -#define WLC_GET_ROAM_SCAN_PERIOD 58 -#define WLC_SET_ROAM_SCAN_PERIOD 59 -#define WLC_EVM 60 -#define WLC_GET_TXANT 61 -#define WLC_SET_TXANT 62 -#define WLC_GET_ANTDIV 63 -#define WLC_SET_ANTDIV 64 - - -#define WLC_GET_CLOSED 67 -#define WLC_SET_CLOSED 68 -#define WLC_GET_MACLIST 69 -#define WLC_SET_MACLIST 70 -#define WLC_GET_RATESET 71 -#define WLC_SET_RATESET 72 - -#define WLC_LONGTRAIN 74 -#define WLC_GET_BCNPRD 75 -#define WLC_SET_BCNPRD 76 -#define WLC_GET_DTIMPRD 77 -#define WLC_SET_DTIMPRD 78 -#define WLC_GET_SROM 79 -#define WLC_SET_SROM 80 -#define WLC_GET_WEP_RESTRICT 81 -#define WLC_SET_WEP_RESTRICT 82 -#define WLC_GET_COUNTRY 83 -#define WLC_SET_COUNTRY 84 -#define WLC_GET_PM 85 -#define WLC_SET_PM 86 -#define WLC_GET_WAKE 87 -#define WLC_SET_WAKE 88 - -#define WLC_GET_FORCELINK 90 -#define WLC_SET_FORCELINK 91 -#define WLC_FREQ_ACCURACY 92 -#define WLC_CARRIER_SUPPRESS 93 -#define WLC_GET_PHYREG 94 -#define WLC_SET_PHYREG 95 -#define WLC_GET_RADIOREG 96 -#define WLC_SET_RADIOREG 97 -#define WLC_GET_REVINFO 98 -#define WLC_GET_UCANTDIV 99 -#define WLC_SET_UCANTDIV 100 -#define WLC_R_REG 101 -#define WLC_W_REG 102 - - -#define WLC_GET_MACMODE 105 -#define WLC_SET_MACMODE 106 -#define WLC_GET_MONITOR 107 -#define WLC_SET_MONITOR 108 -#define WLC_GET_GMODE 109 -#define WLC_SET_GMODE 110 -#define WLC_GET_LEGACY_ERP 111 -#define WLC_SET_LEGACY_ERP 112 -#define WLC_GET_RX_ANT 113 -#define WLC_GET_CURR_RATESET 114 -#define WLC_GET_SCANSUPPRESS 115 -#define WLC_SET_SCANSUPPRESS 116 -#define WLC_GET_AP 117 -#define WLC_SET_AP 118 -#define WLC_GET_EAP_RESTRICT 119 -#define WLC_SET_EAP_RESTRICT 120 -#define WLC_SCB_AUTHORIZE 121 -#define WLC_SCB_DEAUTHORIZE 122 -#define WLC_GET_WDSLIST 123 -#define WLC_SET_WDSLIST 124 -#define WLC_GET_ATIM 125 -#define WLC_SET_ATIM 126 -#define WLC_GET_RSSI 127 -#define WLC_GET_PHYANTDIV 128 -#define WLC_SET_PHYANTDIV 129 -#define WLC_AP_RX_ONLY 130 -#define WLC_GET_TX_PATH_PWR 131 -#define WLC_SET_TX_PATH_PWR 132 -#define WLC_GET_WSEC 133 -#define WLC_SET_WSEC 134 -#define WLC_GET_PHY_NOISE 135 -#define WLC_GET_BSS_INFO 136 -#define WLC_GET_PKTCNTS 137 -#define WLC_GET_LAZYWDS 138 -#define WLC_SET_LAZYWDS 139 -#define WLC_GET_BANDLIST 140 -#define WLC_GET_BAND 141 -#define WLC_SET_BAND 142 -#define WLC_SCB_DEAUTHENTICATE 143 -#define WLC_GET_SHORTSLOT 144 -#define WLC_GET_SHORTSLOT_OVERRIDE 145 -#define WLC_SET_SHORTSLOT_OVERRIDE 146 -#define WLC_GET_SHORTSLOT_RESTRICT 147 -#define WLC_SET_SHORTSLOT_RESTRICT 148 -#define WLC_GET_GMODE_PROTECTION 149 -#define WLC_GET_GMODE_PROTECTION_OVERRIDE 150 -#define WLC_SET_GMODE_PROTECTION_OVERRIDE 151 -#define WLC_UPGRADE 152 - - -#define WLC_GET_IGNORE_BCNS 155 -#define WLC_SET_IGNORE_BCNS 156 -#define WLC_GET_SCB_TIMEOUT 157 -#define WLC_SET_SCB_TIMEOUT 158 -#define WLC_GET_ASSOCLIST 159 -#define WLC_GET_CLK 160 -#define WLC_SET_CLK 161 -#define WLC_GET_UP 162 -#define WLC_OUT 163 -#define WLC_GET_WPA_AUTH 164 -#define WLC_SET_WPA_AUTH 165 -#define WLC_GET_UCFLAGS 166 -#define WLC_SET_UCFLAGS 167 -#define WLC_GET_PWRIDX 168 -#define WLC_SET_PWRIDX 169 -#define WLC_GET_TSSI 170 -#define WLC_GET_SUP_RATESET_OVERRIDE 171 -#define WLC_SET_SUP_RATESET_OVERRIDE 172 - - - - - -#define WLC_GET_PROTECTION_CONTROL 178 -#define WLC_SET_PROTECTION_CONTROL 179 -#define WLC_GET_PHYLIST 180 -#define WLC_ENCRYPT_STRENGTH 181 -#define WLC_DECRYPT_STATUS 182 -#define WLC_GET_KEY_SEQ 183 -#define WLC_GET_SCAN_CHANNEL_TIME 184 -#define WLC_SET_SCAN_CHANNEL_TIME 185 -#define WLC_GET_SCAN_UNASSOC_TIME 186 -#define WLC_SET_SCAN_UNASSOC_TIME 187 -#define WLC_GET_SCAN_HOME_TIME 188 -#define WLC_SET_SCAN_HOME_TIME 189 -#define WLC_GET_SCAN_NPROBES 190 -#define WLC_SET_SCAN_NPROBES 191 -#define WLC_GET_PRB_RESP_TIMEOUT 192 -#define WLC_SET_PRB_RESP_TIMEOUT 193 -#define WLC_GET_ATTEN 194 -#define WLC_SET_ATTEN 195 -#define WLC_GET_SHMEM 196 -#define WLC_SET_SHMEM 197 - - -#define WLC_SET_WSEC_TEST 200 -#define WLC_SCB_DEAUTHENTICATE_FOR_REASON 201 -#define WLC_TKIP_COUNTERMEASURES 202 -#define WLC_GET_PIOMODE 203 -#define WLC_SET_PIOMODE 204 -#define WLC_SET_ASSOC_PREFER 205 -#define WLC_GET_ASSOC_PREFER 206 -#define WLC_SET_ROAM_PREFER 207 -#define WLC_GET_ROAM_PREFER 208 -#define WLC_SET_LED 209 -#define WLC_GET_LED 210 -#define WLC_GET_INTERFERENCE_MODE 211 -#define WLC_SET_INTERFERENCE_MODE 212 -#define WLC_GET_CHANNEL_QA 213 -#define WLC_START_CHANNEL_QA 214 -#define WLC_GET_CHANNEL_SEL 215 -#define WLC_START_CHANNEL_SEL 216 -#define WLC_GET_VALID_CHANNELS 217 -#define WLC_GET_FAKEFRAG 218 -#define WLC_SET_FAKEFRAG 219 -#define WLC_GET_PWROUT_PERCENTAGE 220 -#define WLC_SET_PWROUT_PERCENTAGE 221 -#define WLC_SET_BAD_FRAME_PREEMPT 222 -#define WLC_GET_BAD_FRAME_PREEMPT 223 -#define WLC_SET_LEAP_LIST 224 -#define WLC_GET_LEAP_LIST 225 -#define WLC_GET_CWMIN 226 -#define WLC_SET_CWMIN 227 -#define WLC_GET_CWMAX 228 -#define WLC_SET_CWMAX 229 -#define WLC_GET_WET 230 -#define WLC_SET_WET 231 -#define WLC_GET_PUB 232 - - -#define WLC_GET_KEY_PRIMARY 235 -#define WLC_SET_KEY_PRIMARY 236 - -#define WLC_GET_ACI_ARGS 238 -#define WLC_SET_ACI_ARGS 239 -#define WLC_UNSET_CALLBACK 240 -#define WLC_SET_CALLBACK 241 -#define WLC_GET_RADAR 242 -#define WLC_SET_RADAR 243 -#define WLC_SET_SPECT_MANAGMENT 244 -#define WLC_GET_SPECT_MANAGMENT 245 -#define WLC_WDS_GET_REMOTE_HWADDR 246 -#define WLC_WDS_GET_WPA_SUP 247 -#define WLC_SET_CS_SCAN_TIMER 248 -#define WLC_GET_CS_SCAN_TIMER 249 -#define WLC_MEASURE_REQUEST 250 -#define WLC_INIT 251 -#define WLC_SEND_QUIET 252 -#define WLC_KEEPALIVE 253 -#define WLC_SEND_PWR_CONSTRAINT 254 -#define WLC_UPGRADE_STATUS 255 -#define WLC_CURRENT_PWR 256 -#define WLC_GET_SCAN_PASSIVE_TIME 257 -#define WLC_SET_SCAN_PASSIVE_TIME 258 -#define WLC_LEGACY_LINK_BEHAVIOR 259 -#define WLC_GET_CHANNELS_IN_COUNTRY 260 -#define WLC_GET_COUNTRY_LIST 261 -#define WLC_GET_VAR 262 -#define WLC_SET_VAR 263 -#define WLC_NVRAM_GET 264 -#define WLC_NVRAM_SET 265 -#define WLC_NVRAM_DUMP 266 -#define WLC_REBOOT 267 -#define WLC_SET_WSEC_PMK 268 -#define WLC_GET_AUTH_MODE 269 -#define WLC_SET_AUTH_MODE 270 -#define WLC_GET_WAKEENTRY 271 -#define WLC_SET_WAKEENTRY 272 -#define WLC_NDCONFIG_ITEM 273 -#define WLC_NVOTPW 274 -#define WLC_OTPW 275 -#define WLC_IOV_BLOCK_GET 276 -#define WLC_IOV_MODULES_GET 277 -#define WLC_SOFT_RESET 278 -#define WLC_GET_ALLOW_MODE 279 -#define WLC_SET_ALLOW_MODE 280 -#define WLC_GET_DESIRED_BSSID 281 -#define WLC_SET_DESIRED_BSSID 282 -#define WLC_DISASSOC_MYAP 283 -#define WLC_GET_NBANDS 284 -#define WLC_GET_BANDSTATES 285 -#define WLC_GET_WLC_BSS_INFO 286 -#define WLC_GET_ASSOC_INFO 287 -#define WLC_GET_OID_PHY 288 -#define WLC_SET_OID_PHY 289 -#define WLC_SET_ASSOC_TIME 290 -#define WLC_GET_DESIRED_SSID 291 -#define WLC_GET_CHANSPEC 292 -#define WLC_GET_ASSOC_STATE 293 -#define WLC_SET_PHY_STATE 294 -#define WLC_GET_SCAN_PENDING 295 -#define WLC_GET_SCANREQ_PENDING 296 -#define WLC_GET_PREV_ROAM_REASON 297 -#define WLC_SET_PREV_ROAM_REASON 298 -#define WLC_GET_BANDSTATES_PI 299 -#define WLC_GET_PHY_STATE 300 -#define WLC_GET_BSS_WPA_RSN 301 -#define WLC_GET_BSS_WPA2_RSN 302 -#define WLC_GET_BSS_BCN_TS 303 -#define WLC_GET_INT_DISASSOC 304 -#define WLC_SET_NUM_PEERS 305 -#define WLC_GET_NUM_BSS 306 -#define WLC_NPHY_SAMPLE_COLLECT 307 -#define WLC_UM_PRIV 308 -#define WLC_GET_CMD 309 - -#define WLC_SET_INTERFERENCE_OVERRIDE_MODE 311 -#define WLC_GET_INTERFERENCE_OVERRIDE_MODE 312 -#define WLC_GET_WAI_RESTRICT 313 -#define WLC_SET_WAI_RESTRICT 314 -#define WLC_SET_WAI_REKEY 315 -#define WLC_SET_PEAKRATE 316 -#define WLC_GET_PEAKRATE 317 -#define WLC_LAST 318 - -#ifndef EPICTRL_COOKIE -#define EPICTRL_COOKIE 0xABADCEDE -#endif - - -#define CMN_IOCTL_OFF 0x180 - - - - -#define WL_OID_BASE 0xFFE41420 - - -#define OID_WL_GETINSTANCE (WL_OID_BASE + WLC_GET_INSTANCE) -#define OID_WL_GET_FORCELINK (WL_OID_BASE + WLC_GET_FORCELINK) -#define OID_WL_SET_FORCELINK (WL_OID_BASE + WLC_SET_FORCELINK) -#define OID_WL_ENCRYPT_STRENGTH (WL_OID_BASE + WLC_ENCRYPT_STRENGTH) -#define OID_WL_DECRYPT_STATUS (WL_OID_BASE + WLC_DECRYPT_STATUS) -#define OID_LEGACY_LINK_BEHAVIOR (WL_OID_BASE + WLC_LEGACY_LINK_BEHAVIOR) -#define OID_WL_NDCONFIG_ITEM (WL_OID_BASE + WLC_NDCONFIG_ITEM) - - -#define OID_STA_CHANSPEC (WL_OID_BASE + WLC_GET_CHANSPEC) -#define OID_STA_NBANDS (WL_OID_BASE + WLC_GET_NBANDS) -#define OID_STA_GET_PHY (WL_OID_BASE + WLC_GET_OID_PHY) -#define OID_STA_SET_PHY (WL_OID_BASE + WLC_SET_OID_PHY) -#define OID_STA_ASSOC_TIME (WL_OID_BASE + WLC_SET_ASSOC_TIME) -#define OID_STA_DESIRED_SSID (WL_OID_BASE + WLC_GET_DESIRED_SSID) -#define OID_STA_SET_PHY_STATE (WL_OID_BASE + WLC_SET_PHY_STATE) -#define OID_STA_SCAN_PENDING (WL_OID_BASE + WLC_GET_SCAN_PENDING) -#define OID_STA_SCANREQ_PENDING (WL_OID_BASE + WLC_GET_SCANREQ_PENDING) -#define OID_STA_GET_ROAM_REASON (WL_OID_BASE + WLC_GET_PREV_ROAM_REASON) -#define OID_STA_SET_ROAM_REASON (WL_OID_BASE + WLC_SET_PREV_ROAM_REASON) -#define OID_STA_GET_PHY_STATE (WL_OID_BASE + WLC_GET_PHY_STATE) -#define OID_STA_INT_DISASSOC (WL_OID_BASE + WLC_GET_INT_DISASSOC) -#define OID_STA_SET_NUM_PEERS (WL_OID_BASE + WLC_SET_NUM_PEERS) -#define OID_STA_GET_NUM_BSS (WL_OID_BASE + WLC_GET_NUM_BSS) - -#define WL_DECRYPT_STATUS_SUCCESS 1 -#define WL_DECRYPT_STATUS_FAILURE 2 -#define WL_DECRYPT_STATUS_UNKNOWN 3 - - -#define WLC_UPGRADE_SUCCESS 0 -#define WLC_UPGRADE_PENDING 1 - -#ifdef CONFIG_USBRNDIS_RETAIL - -typedef struct { - char *name; - void *param; -} ndconfig_item_t; -#endif - - - -#define WL_AUTH_OPEN_SYSTEM 0 -#define WL_AUTH_SHARED_KEY 1 -#define WL_AUTH_OPEN_SHARED 2 - - -#define WL_RADIO_SW_DISABLE (1<<0) -#define WL_RADIO_HW_DISABLE (1<<1) -#define WL_RADIO_MPC_DISABLE (1<<2) -#define WL_RADIO_COUNTRY_DISABLE (1<<3) - -#define WL_SPURAVOID_OFF 0 -#define WL_SPURAVOID_ON1 1 -#define WL_SPURAVOID_ON2 2 - - -#define WL_TXPWR_OVERRIDE (1U<<31) -#define WL_TXPWR_NEG (1U<<30) - -#define WL_PHY_PAVARS_LEN 6 - -#define WL_PHY_PAVARS2_NUM 3 -#define WL_PHY_PAVAR_VER 1 -typedef struct wl_pavars2 { - uint16 ver; - uint16 len; - uint16 inuse; - uint16 phy_type; - uint16 bandrange; - uint16 chain; - uint16 inpa[WL_PHY_PAVARS2_NUM]; -} wl_pavars2_t; - -typedef struct wl_po { - uint16 phy_type; - uint16 band; - uint16 cckpo; - uint32 ofdmpo; - uint16 mcspo[8]; -} wl_po_t; - - -#define WLC_TXPWR_MAX (127) - - -#define WL_DIAG_INTERRUPT 1 -#define WL_DIAG_LOOPBACK 2 -#define WL_DIAG_MEMORY 3 -#define WL_DIAG_LED 4 -#define WL_DIAG_REG 5 -#define WL_DIAG_SROM 6 -#define WL_DIAG_DMA 7 - -#define WL_DIAGERR_SUCCESS 0 -#define WL_DIAGERR_FAIL_TO_RUN 1 -#define WL_DIAGERR_NOT_SUPPORTED 2 -#define WL_DIAGERR_INTERRUPT_FAIL 3 -#define WL_DIAGERR_LOOPBACK_FAIL 4 -#define WL_DIAGERR_SROM_FAIL 5 -#define WL_DIAGERR_SROM_BADCRC 6 -#define WL_DIAGERR_REG_FAIL 7 -#define WL_DIAGERR_MEMORY_FAIL 8 -#define WL_DIAGERR_NOMEM 9 -#define WL_DIAGERR_DMA_FAIL 10 - -#define WL_DIAGERR_MEMORY_TIMEOUT 11 -#define WL_DIAGERR_MEMORY_BADPATTERN 12 - - -#define WLC_BAND_AUTO 0 -#define WLC_BAND_5G 1 -#define WLC_BAND_2G 2 -#define WLC_BAND_ALL 3 - - -#define WL_CHAN_FREQ_RANGE_2G 0 -#define WL_CHAN_FREQ_RANGE_5GL 1 -#define WL_CHAN_FREQ_RANGE_5GM 2 -#define WL_CHAN_FREQ_RANGE_5GH 3 - -#define WL_CHAN_FREQ_RANGE_5GLL_VER2 4 -#define WL_CHAN_FREQ_RANGE_5GLH_VER2 5 -#define WL_CHAN_FREQ_RANGE_5GML_VER2 6 -#define WL_CHAN_FREQ_RANGE_5GMH_VER2 7 -#define WL_CHAN_FREQ_RANGE_5GH_VER2 8 - - -#define WLC_PHY_TYPE_A 0 -#define WLC_PHY_TYPE_B 1 -#define WLC_PHY_TYPE_G 2 -#define WLC_PHY_TYPE_N 4 -#define WLC_PHY_TYPE_LP 5 -#define WLC_PHY_TYPE_SSN 6 -#define WLC_PHY_TYPE_HT 7 -#define WLC_PHY_TYPE_LCN 8 -#define WLC_PHY_TYPE_NULL 0xf - - -#define WLC_MACMODE_DISABLED 0 -#define WLC_MACMODE_DENY 1 -#define WLC_MACMODE_ALLOW 2 - - -#define GMODE_LEGACY_B 0 -#define GMODE_AUTO 1 -#define GMODE_ONLY 2 -#define GMODE_B_DEFERRED 3 -#define GMODE_PERFORMANCE 4 -#define GMODE_LRS 5 -#define GMODE_MAX 6 - - -#define WLC_PLCP_AUTO -1 -#define WLC_PLCP_SHORT 0 -#define WLC_PLCP_LONG 1 - - -#define WLC_PROTECTION_AUTO -1 -#define WLC_PROTECTION_OFF 0 -#define WLC_PROTECTION_ON 1 -#define WLC_PROTECTION_MMHDR_ONLY 2 -#define WLC_PROTECTION_CTS_ONLY 3 - - -#define WLC_PROTECTION_CTL_OFF 0 -#define WLC_PROTECTION_CTL_LOCAL 1 -#define WLC_PROTECTION_CTL_OVERLAP 2 - - -#define WLC_N_PROTECTION_OFF 0 -#define WLC_N_PROTECTION_OPTIONAL 1 -#define WLC_N_PROTECTION_20IN40 2 -#define WLC_N_PROTECTION_MIXEDMODE 3 - - -#define WLC_N_PREAMBLE_MIXEDMODE 0 -#define WLC_N_PREAMBLE_GF 1 -#define WLC_N_PREAMBLE_GF_BRCM 2 - - -#define WLC_N_BW_20ALL 0 -#define WLC_N_BW_40ALL 1 -#define WLC_N_BW_20IN2G_40IN5G 2 - - -#define WLC_N_TXRX_CHAIN0 0 -#define WLC_N_TXRX_CHAIN1 1 - - -#define WLC_N_SGI_20 0x01 -#define WLC_N_SGI_40 0x02 - - -#define PM_OFF 0 -#define PM_MAX 1 -#define PM_FAST 2 - -#define LISTEN_INTERVAL 20 - -#define INTERFERE_OVRRIDE_OFF -1 -#define INTERFERE_NONE 0 -#define NON_WLAN 1 -#define WLAN_MANUAL 2 -#define WLAN_AUTO 3 -#define WLAN_AUTO_W_NOISE 4 -#define AUTO_ACTIVE (1 << 7) - -typedef struct wl_aci_args { - int enter_aci_thresh; - int exit_aci_thresh; - int usec_spin; - int glitch_delay; - uint16 nphy_adcpwr_enter_thresh; - uint16 nphy_adcpwr_exit_thresh; - uint16 nphy_repeat_ctr; - uint16 nphy_num_samples; - uint16 nphy_undetect_window_sz; - uint16 nphy_b_energy_lo_aci; - uint16 nphy_b_energy_md_aci; - uint16 nphy_b_energy_hi_aci; - uint16 nphy_noise_noassoc_glitch_th_up; - uint16 nphy_noise_noassoc_glitch_th_dn; - uint16 nphy_noise_assoc_glitch_th_up; - uint16 nphy_noise_assoc_glitch_th_dn; - uint16 nphy_noise_assoc_aci_glitch_th_up; - uint16 nphy_noise_assoc_aci_glitch_th_dn; - uint16 nphy_noise_assoc_enter_th; - uint16 nphy_noise_noassoc_enter_th; - uint16 nphy_noise_assoc_rx_glitch_badplcp_enter_th; - uint16 nphy_noise_noassoc_crsidx_incr; - uint16 nphy_noise_assoc_crsidx_incr; - uint16 nphy_noise_crsidx_decr; -} wl_aci_args_t; - -#define TRIGGER_NOW 0 -#define TRIGGER_CRS 0x01 -#define TRIGGER_CRSDEASSERT 0x02 -#define TRIGGER_GOODFCS 0x04 -#define TRIGGER_BADFCS 0x08 -#define TRIGGER_BADPLCP 0x10 -#define TRIGGER_CRSGLITCH 0x20 -#define WL_ACI_ARGS_LEGACY_LENGTH 16 -#define WL_SAMPLECOLLECT_T_VERSION 1 -typedef struct wl_samplecollect_args { - - uint8 coll_us; - int cores; - - uint16 version; - uint16 length; - uint8 trigger; - uint16 timeout; - uint16 mode; - uint32 pre_dur; - uint32 post_dur; - uint8 gpio_sel; - bool downsamp; - bool be_deaf; - bool agc; - bool filter; -} wl_samplecollect_args_t; - -#define WL_SAMPLEDATA_HEADER_TYPE 1 -#define WL_SAMPLEDATA_HEADER_SIZE 80 -#define WL_SAMPLEDATA_TYPE 2 -#define WL_SAMPLEDATA_SEQ 0xff -#define WL_SAMPLEDATA_MORE_DATA 0x100 -#define WL_SAMPLEDATA_T_VERSION 1 - -#define WL_SAMPLEDATA_T_VERSION_SPEC_AN 2 - -typedef struct wl_sampledata { - uint16 version; - uint16 size; - uint16 tag; - uint16 length; - uint32 flag; -} wl_sampledata_t; - - - -#define WL_ERROR_VAL 0x00000001 -#define WL_TRACE_VAL 0x00000002 -#define WL_PRHDRS_VAL 0x00000004 -#define WL_PRPKT_VAL 0x00000008 -#define WL_INFORM_VAL 0x00000010 -#define WL_TMP_VAL 0x00000020 -#define WL_OID_VAL 0x00000040 -#define WL_RATE_VAL 0x00000080 -#define WL_ASSOC_VAL 0x00000100 -#define WL_PRUSR_VAL 0x00000200 -#define WL_PS_VAL 0x00000400 -#define WL_TXPWR_VAL 0x00000800 -#define WL_PORT_VAL 0x00001000 -#define WL_DUAL_VAL 0x00002000 -#define WL_WSEC_VAL 0x00004000 -#define WL_WSEC_DUMP_VAL 0x00008000 -#define WL_LOG_VAL 0x00010000 -#define WL_NRSSI_VAL 0x00020000 -#define WL_LOFT_VAL 0x00040000 -#define WL_REGULATORY_VAL 0x00080000 -#define WL_PHYCAL_VAL 0x00100000 -#define WL_RADAR_VAL 0x00200000 -#define WL_MPC_VAL 0x00400000 -#define WL_APSTA_VAL 0x00800000 -#define WL_DFS_VAL 0x01000000 -#define WL_BA_VAL 0x02000000 -#define WL_ACI_VAL 0x04000000 -#define WL_MBSS_VAL 0x04000000 -#define WL_CAC_VAL 0x08000000 -#define WL_AMSDU_VAL 0x10000000 -#define WL_AMPDU_VAL 0x20000000 -#define WL_FFPLD_VAL 0x40000000 - - -#define WL_DPT_VAL 0x00000001 -#define WL_SCAN_VAL 0x00000002 -#define WL_WOWL_VAL 0x00000004 -#define WL_COEX_VAL 0x00000008 -#define WL_RTDC_VAL 0x00000010 -#define WL_PROTO_VAL 0x00000020 -#define WL_BTA_VAL 0x00000040 -#define WL_CHANINT_VAL 0x00000080 -#define WL_THERMAL_VAL 0x00000100 -#define WL_P2P_VAL 0x00000200 -#define WL_TXRX_VAL 0x00000400 -#define WL_MCHAN_VAL 0x00000800 - - -#define WL_LED_NUMGPIO 16 - - -#define WL_LED_OFF 0 -#define WL_LED_ON 1 -#define WL_LED_ACTIVITY 2 -#define WL_LED_RADIO 3 -#define WL_LED_ARADIO 4 -#define WL_LED_BRADIO 5 -#define WL_LED_BGMODE 6 -#define WL_LED_WI1 7 -#define WL_LED_WI2 8 -#define WL_LED_WI3 9 -#define WL_LED_ASSOC 10 -#define WL_LED_INACTIVE 11 -#define WL_LED_ASSOCACT 12 -#define WL_LED_WI4 13 -#define WL_LED_WI5 14 -#define WL_LED_BLINKSLOW 15 -#define WL_LED_BLINKMED 16 -#define WL_LED_BLINKFAST 17 -#define WL_LED_BLINKCUSTOM 18 -#define WL_LED_BLINKPERIODIC 19 -#define WL_LED_ASSOC_WITH_SEC 20 - -#define WL_LED_START_OFF 21 -#define WL_LED_NUMBEHAVIOR 22 - - -#define WL_LED_BEH_MASK 0x7f -#define WL_LED_AL_MASK 0x80 - - -#define WL_NUMCHANNELS 64 -#define WL_NUMCHANSPECS 100 - - -#define WL_WDS_WPA_ROLE_AUTH 0 -#define WL_WDS_WPA_ROLE_SUP 1 -#define WL_WDS_WPA_ROLE_AUTO 255 - - -#define WL_EVENTING_MASK_LEN 16 - - - - -#define WL_JOIN_PREF_RSSI 1 -#define WL_JOIN_PREF_WPA 2 -#define WL_JOIN_PREF_BAND 3 -#define WL_JOIN_PREF_RSSI_DELTA 4 - - -#define WLJP_BAND_ASSOC_PREF 255 - - -#define WL_WPA_ACP_MCS_ANY "\x00\x00\x00\x00" - -struct tsinfo_arg { - uint8 octets[3]; -}; - -#define NFIFO 6 - -#define WL_CNT_T_VERSION 6 - -typedef struct { - uint16 version; - uint16 length; - - - uint32 txframe; - uint32 txbyte; - uint32 txretrans; - uint32 txerror; - uint32 txctl; - uint32 txprshort; - uint32 txserr; - uint32 txnobuf; - uint32 txnoassoc; - uint32 txrunt; - uint32 txchit; - uint32 txcmiss; - - - uint32 txuflo; - uint32 txphyerr; - uint32 txphycrs; - - - uint32 rxframe; - uint32 rxbyte; - uint32 rxerror; - uint32 rxctl; - uint32 rxnobuf; - uint32 rxnondata; - uint32 rxbadds; - uint32 rxbadcm; - uint32 rxfragerr; - uint32 rxrunt; - uint32 rxgiant; - uint32 rxnoscb; - uint32 rxbadproto; - uint32 rxbadsrcmac; - uint32 rxbadda; - uint32 rxfilter; - - - uint32 rxoflo; - uint32 rxuflo[NFIFO]; - - uint32 d11cnt_txrts_off; - uint32 d11cnt_rxcrc_off; - uint32 d11cnt_txnocts_off; - - - uint32 dmade; - uint32 dmada; - uint32 dmape; - uint32 reset; - uint32 tbtt; - uint32 txdmawar; - uint32 pkt_callback_reg_fail; - - - uint32 txallfrm; - uint32 txrtsfrm; - uint32 txctsfrm; - uint32 txackfrm; - uint32 txdnlfrm; - uint32 txbcnfrm; - uint32 txfunfl[8]; - uint32 txtplunfl; - uint32 txphyerror; - uint32 rxfrmtoolong; - uint32 rxfrmtooshrt; - uint32 rxinvmachdr; - uint32 rxbadfcs; - uint32 rxbadplcp; - uint32 rxcrsglitch; - uint32 rxstrt; - uint32 rxdfrmucastmbss; - uint32 rxmfrmucastmbss; - uint32 rxcfrmucast; - uint32 rxrtsucast; - uint32 rxctsucast; - uint32 rxackucast; - uint32 rxdfrmocast; - uint32 rxmfrmocast; - uint32 rxcfrmocast; - uint32 rxrtsocast; - uint32 rxctsocast; - uint32 rxdfrmmcast; - uint32 rxmfrmmcast; - uint32 rxcfrmmcast; - uint32 rxbeaconmbss; - uint32 rxdfrmucastobss; - uint32 rxbeaconobss; - uint32 rxrsptmout; - uint32 bcntxcancl; - uint32 rxf0ovfl; - uint32 rxf1ovfl; - uint32 rxf2ovfl; - uint32 txsfovfl; - uint32 pmqovfl; - uint32 rxcgprqfrm; - uint32 rxcgprsqovfl; - uint32 txcgprsfail; - uint32 txcgprssuc; - uint32 prs_timeout; - uint32 rxnack; - uint32 frmscons; - uint32 txnack; - uint32 txglitch_nack; - uint32 txburst; - - - uint32 txfrag; - uint32 txmulti; - uint32 txfail; - uint32 txretry; - uint32 txretrie; - uint32 rxdup; - uint32 txrts; - uint32 txnocts; - uint32 txnoack; - uint32 rxfrag; - uint32 rxmulti; - uint32 rxcrc; - uint32 txfrmsnt; - uint32 rxundec; - - - uint32 tkipmicfaill; - uint32 tkipcntrmsr; - uint32 tkipreplay; - uint32 ccmpfmterr; - uint32 ccmpreplay; - uint32 ccmpundec; - uint32 fourwayfail; - uint32 wepundec; - uint32 wepicverr; - uint32 decsuccess; - uint32 tkipicverr; - uint32 wepexcluded; - - uint32 rxundec_mcst; - - - uint32 tkipmicfaill_mcst; - uint32 tkipcntrmsr_mcst; - uint32 tkipreplay_mcst; - uint32 ccmpfmterr_mcst; - uint32 ccmpreplay_mcst; - uint32 ccmpundec_mcst; - uint32 fourwayfail_mcst; - uint32 wepundec_mcst; - uint32 wepicverr_mcst; - uint32 decsuccess_mcst; - uint32 tkipicverr_mcst; - uint32 wepexcluded_mcst; - - uint32 txchanrej; - uint32 txexptime; - uint32 psmwds; - uint32 phywatchdog; - - - uint32 prq_entries_handled; - uint32 prq_undirected_entries; - uint32 prq_bad_entries; - uint32 atim_suppress_count; - uint32 bcn_template_not_ready; - uint32 bcn_template_not_ready_done; - uint32 late_tbtt_dpc; - - - uint32 rx1mbps; - uint32 rx2mbps; - uint32 rx5mbps5; - uint32 rx6mbps; - uint32 rx9mbps; - uint32 rx11mbps; - uint32 rx12mbps; - uint32 rx18mbps; - uint32 rx24mbps; - uint32 rx36mbps; - uint32 rx48mbps; - uint32 rx54mbps; - uint32 rx108mbps; - uint32 rx162mbps; - uint32 rx216mbps; - uint32 rx270mbps; - uint32 rx324mbps; - uint32 rx378mbps; - uint32 rx432mbps; - uint32 rx486mbps; - uint32 rx540mbps; - - - uint32 pktengrxducast; - uint32 pktengrxdmcast; - - uint32 rfdisable; - uint32 bphy_rxcrsglitch; - - uint32 txmpdu_sgi; - uint32 rxmpdu_sgi; - uint32 txmpdu_stbc; - uint32 rxmpdu_stbc; -} wl_cnt_t; - - -#define WL_WME_CNT_VERSION 1 - -typedef struct { - uint32 packets; - uint32 bytes; -} wl_traffic_stats_t; - -typedef struct { - uint16 version; - uint16 length; - - wl_traffic_stats_t tx[AC_COUNT]; - wl_traffic_stats_t tx_failed[AC_COUNT]; - wl_traffic_stats_t rx[AC_COUNT]; - wl_traffic_stats_t rx_failed[AC_COUNT]; - - wl_traffic_stats_t forward[AC_COUNT]; - - wl_traffic_stats_t tx_expired[AC_COUNT]; - -} wl_wme_cnt_t; - -struct wl_msglevel2 { - uint32 low; - uint32 high; -}; - - - -#define WLC_ROAM_TRIGGER_DEFAULT 0 -#define WLC_ROAM_TRIGGER_BANDWIDTH 1 -#define WLC_ROAM_TRIGGER_DISTANCE 2 -#define WLC_ROAM_TRIGGER_AUTO 3 -#define WLC_ROAM_TRIGGER_MAX_VALUE 3 - - -#define WPA_AUTH_PFN_ANY 0xffffffff - -enum { - PFN_LIST_ORDER, - PFN_RSSI -}; - -enum { - DISABLE, - ENABLE -}; - -enum { - OFF_ADAPT, - SMART_ADAPT, - STRICT_ADAPT -}; - -#define SORT_CRITERIA_BIT 0 -#define AUTO_NET_SWITCH_BIT 1 -#define ENABLE_BKGRD_SCAN_BIT 2 -#define IMMEDIATE_SCAN_BIT 3 -#define AUTO_CONNECT_BIT 4 -#define ENABLE_BD_SCAN_BIT 5 -#define ENABLE_ADAPTSCAN_BIT 6 - -#define SORT_CRITERIA_MASK 0x01 -#define AUTO_NET_SWITCH_MASK 0x02 -#define ENABLE_BKGRD_SCAN_MASK 0x04 -#define IMMEDIATE_SCAN_MASK 0x08 -#define AUTO_CONNECT_MASK 0x10 -#define ENABLE_BD_SCAN_MASK 0x20 -#define ENABLE_ADAPTSCAN_MASK 0xc0 - -#define PFN_VERSION 2 -#define PFN_SCANRESULT_VERSION 1 -#define MAX_PFN_LIST_COUNT 16 - -#define PFN_COMPLETE 1 -#define PFN_INCOMPLETE 0 - -#define DEFAULT_BESTN 2 -#define DEFAULT_MSCAN 0 -#define DEFAULT_REPEAT 10 -#define DEFAULT_EXP 2 - - -typedef struct wl_pfn_subnet_info { - struct ether_addr BSSID; - uint8 channel; - uint8 SSID_len; - uint8 SSID[32]; -} wl_pfn_subnet_info_t; - -typedef struct wl_pfn_net_info { - wl_pfn_subnet_info_t pfnsubnet; - int16 RSSI; - uint16 timestamp; -} wl_pfn_net_info_t; - -typedef struct wl_pfn_scanresults { - uint32 version; - uint32 status; - uint32 count; - wl_pfn_net_info_t netinfo[1]; -} wl_pfn_scanresults_t; - - -typedef struct wl_pfn_param { - int32 version; - int32 scan_freq; - int32 lost_network_timeout; - int16 flags; - int16 rssi_margin; - uint8 bestn; - uint8 mscan; - uint8 repeat; - uint8 exp; -} wl_pfn_param_t; - -typedef struct wl_pfn_bssid { - struct ether_addr macaddr; - - uint16 flags; -} wl_pfn_bssid_t; -#define WL_PFN_SUPPRESSFOUND_MASK 0x08 -#define WL_PFN_SUPPRESSLOST_MASK 0x10 - -typedef struct wl_pfn_cfg { - uint32 reporttype; - int32 channel_num; - uint16 channel_list[WL_NUMCHANNELS]; -} wl_pfn_cfg_t; -#define WL_PFN_REPORT_ALLNET 0 -#define WL_PFN_REPORT_SSIDNET 1 -#define WL_PFN_REPORT_BSSIDNET 2 - -typedef struct wl_pfn { - wlc_ssid_t ssid; - int32 flags; - int32 infra; - int32 auth; - int32 wpa_auth; - int32 wsec; -} wl_pfn_t; -#define WL_PFN_HIDDEN_BIT 2 -#define PNO_SCAN_MAX_FW 508*1000 -#define PNO_SCAN_MAX_FW_SEC PNO_SCAN_MAX_FW/1000 -#define PNO_SCAN_MIN_FW_SEC 10 -#define WL_PFN_HIDDEN_MASK 0x4 - - -#define TOE_TX_CSUM_OL 0x00000001 -#define TOE_RX_CSUM_OL 0x00000002 - - -#define TOE_ERRTEST_TX_CSUM 0x00000001 -#define TOE_ERRTEST_RX_CSUM 0x00000002 -#define TOE_ERRTEST_RX_CSUM2 0x00000004 - -struct toe_ol_stats_t { - - uint32 tx_summed; - - - uint32 tx_iph_fill; - uint32 tx_tcp_fill; - uint32 tx_udp_fill; - uint32 tx_icmp_fill; - - - uint32 rx_iph_good; - uint32 rx_iph_bad; - uint32 rx_tcp_good; - uint32 rx_tcp_bad; - uint32 rx_udp_good; - uint32 rx_udp_bad; - uint32 rx_icmp_good; - uint32 rx_icmp_bad; - - - uint32 tx_tcp_errinj; - uint32 tx_udp_errinj; - uint32 tx_icmp_errinj; - - - uint32 rx_tcp_errinj; - uint32 rx_udp_errinj; - uint32 rx_icmp_errinj; -}; - - -#define ARP_OL_AGENT 0x00000001 -#define ARP_OL_SNOOP 0x00000002 -#define ARP_OL_HOST_AUTO_REPLY 0x00000004 -#define ARP_OL_PEER_AUTO_REPLY 0x00000008 - - -#define ARP_ERRTEST_REPLY_PEER 0x1 -#define ARP_ERRTEST_REPLY_HOST 0x2 - -#define ARP_MULTIHOMING_MAX 8 - - -struct arp_ol_stats_t { - uint32 host_ip_entries; - uint32 host_ip_overflow; - - uint32 arp_table_entries; - uint32 arp_table_overflow; - - uint32 host_request; - uint32 host_reply; - uint32 host_service; - - uint32 peer_request; - uint32 peer_request_drop; - uint32 peer_reply; - uint32 peer_reply_drop; - uint32 peer_service; -}; - - - - -typedef struct wl_keep_alive_pkt { - uint32 period_msec; - uint16 len_bytes; - uint8 data[1]; -} wl_keep_alive_pkt_t; - -#define WL_KEEP_ALIVE_FIXED_LEN OFFSETOF(wl_keep_alive_pkt_t, data) - - - - -typedef enum wl_pkt_filter_type { - WL_PKT_FILTER_TYPE_PATTERN_MATCH -} wl_pkt_filter_type_t; - -#define WL_PKT_FILTER_TYPE wl_pkt_filter_type_t - - -typedef struct wl_pkt_filter_pattern { - uint32 offset; - uint32 size_bytes; - uint8 mask_and_pattern[1]; -} wl_pkt_filter_pattern_t; - - -typedef struct wl_pkt_filter { - uint32 id; - uint32 type; - uint32 negate_match; - union { - wl_pkt_filter_pattern_t pattern; - } u; -} wl_pkt_filter_t; - -#define WL_PKT_FILTER_FIXED_LEN OFFSETOF(wl_pkt_filter_t, u) -#define WL_PKT_FILTER_PATTERN_FIXED_LEN OFFSETOF(wl_pkt_filter_pattern_t, mask_and_pattern) - - -typedef struct wl_pkt_filter_enable { - uint32 id; - uint32 enable; -} wl_pkt_filter_enable_t; - - -typedef struct wl_pkt_filter_list { - uint32 num; - wl_pkt_filter_t filter[1]; -} wl_pkt_filter_list_t; - -#define WL_PKT_FILTER_LIST_FIXED_LEN OFFSETOF(wl_pkt_filter_list_t, filter) - - -typedef struct wl_pkt_filter_stats { - uint32 num_pkts_matched; - uint32 num_pkts_forwarded; - uint32 num_pkts_discarded; -} wl_pkt_filter_stats_t; - - -typedef struct wl_seq_cmd_ioctl { - uint32 cmd; - uint32 len; -} wl_seq_cmd_ioctl_t; - -#define WL_SEQ_CMD_ALIGN_BYTES 4 - - -#define WL_SEQ_CMDS_GET_IOCTL_FILTER(cmd) \ - (((cmd) == WLC_GET_MAGIC) || \ - ((cmd) == WLC_GET_VERSION) || \ - ((cmd) == WLC_GET_AP) || \ - ((cmd) == WLC_GET_INSTANCE)) - - - -#define WL_PKTENG_PER_TX_START 0x01 -#define WL_PKTENG_PER_TX_STOP 0x02 -#define WL_PKTENG_PER_RX_START 0x04 -#define WL_PKTENG_PER_RX_WITH_ACK_START 0x05 -#define WL_PKTENG_PER_TX_WITH_ACK_START 0x06 -#define WL_PKTENG_PER_RX_STOP 0x08 -#define WL_PKTENG_PER_MASK 0xff - -#define WL_PKTENG_SYNCHRONOUS 0x100 - -typedef struct wl_pkteng { - uint32 flags; - uint32 delay; - uint32 nframes; - uint32 length; - uint8 seqno; - struct ether_addr dest; - struct ether_addr src; -} wl_pkteng_t; - -#define NUM_80211b_RATES 4 -#define NUM_80211ag_RATES 8 -#define NUM_80211n_RATES 32 -#define NUM_80211_RATES (NUM_80211b_RATES+NUM_80211ag_RATES+NUM_80211n_RATES) -typedef struct wl_pkteng_stats { - uint32 lostfrmcnt; - int32 rssi; - int32 snr; - uint16 rxpktcnt[NUM_80211_RATES+1]; -} wl_pkteng_stats_t; - - -#define WL_WOWL_MAGIC (1 << 0) -#define WL_WOWL_NET (1 << 1) -#define WL_WOWL_DIS (1 << 2) -#define WL_WOWL_RETR (1 << 3) -#define WL_WOWL_BCN (1 << 4) -#define WL_WOWL_TST (1 << 5) -#define WL_WOWL_M1 (1 << 6) -#define WL_WOWL_EAPID (1 << 7) -#define WL_WOWL_KEYROT (1 << 14) -#define WL_WOWL_BCAST (1 << 15) - -#define MAGIC_PKT_MINLEN 102 - -typedef struct { - uint masksize; - uint offset; - uint patternoffset; - uint patternsize; - ulong id; - - -} wl_wowl_pattern_t; - -typedef struct { - uint count; - wl_wowl_pattern_t pattern[1]; -} wl_wowl_pattern_list_t; - -typedef struct { - uint8 pci_wakeind; - uint16 ucode_wakeind; -} wl_wowl_wakeind_t; - - -typedef struct wl_txrate_class { - uint8 init_rate; - uint8 min_rate; - uint8 max_rate; -} wl_txrate_class_t; - - - - -#define WLC_OBSS_SCAN_PASSIVE_DWELL_DEFAULT 20 -#define WLC_OBSS_SCAN_PASSIVE_DWELL_MIN 5 -#define WLC_OBSS_SCAN_PASSIVE_DWELL_MAX 1000 -#define WLC_OBSS_SCAN_ACTIVE_DWELL_DEFAULT 10 -#define WLC_OBSS_SCAN_ACTIVE_DWELL_MIN 10 -#define WLC_OBSS_SCAN_ACTIVE_DWELL_MAX 1000 -#define WLC_OBSS_SCAN_WIDTHSCAN_INTERVAL_DEFAULT 300 -#define WLC_OBSS_SCAN_WIDTHSCAN_INTERVAL_MIN 10 -#define WLC_OBSS_SCAN_WIDTHSCAN_INTERVAL_MAX 900 -#define WLC_OBSS_SCAN_CHANWIDTH_TRANSITION_DLY_DEFAULT 5 -#define WLC_OBSS_SCAN_CHANWIDTH_TRANSITION_DLY_MIN 5 -#define WLC_OBSS_SCAN_CHANWIDTH_TRANSITION_DLY_MAX 100 -#define WLC_OBSS_SCAN_PASSIVE_TOTAL_PER_CHANNEL_DEFAULT 200 -#define WLC_OBSS_SCAN_PASSIVE_TOTAL_PER_CHANNEL_MIN 200 -#define WLC_OBSS_SCAN_PASSIVE_TOTAL_PER_CHANNEL_MAX 10000 -#define WLC_OBSS_SCAN_ACTIVE_TOTAL_PER_CHANNEL_DEFAULT 20 -#define WLC_OBSS_SCAN_ACTIVE_TOTAL_PER_CHANNEL_MIN 20 -#define WLC_OBSS_SCAN_ACTIVE_TOTAL_PER_CHANNEL_MAX 10000 -#define WLC_OBSS_SCAN_ACTIVITY_THRESHOLD_DEFAULT 25 -#define WLC_OBSS_SCAN_ACTIVITY_THRESHOLD_MIN 0 -#define WLC_OBSS_SCAN_ACTIVITY_THRESHOLD_MAX 100 - - -typedef struct wl_obss_scan_arg { - int16 passive_dwell; - int16 active_dwell; - int16 bss_widthscan_interval; - int16 passive_total; - int16 active_total; - int16 chanwidth_transition_delay; - int16 activity_threshold; -} wl_obss_scan_arg_t; - -#define WL_OBSS_SCAN_PARAM_LEN sizeof(wl_obss_scan_arg_t) -#define WL_MIN_NUM_OBSS_SCAN_ARG 7 - -#define WL_COEX_INFO_MASK 0x07 -#define WL_COEX_INFO_REQ 0x01 -#define WL_COEX_40MHZ_INTOLERANT 0x02 -#define WL_COEX_WIDTH20 0x04 - -#define WLC_RSSI_INVALID 0 - -#define MAX_RSSI_LEVELS 8 - - -typedef struct wl_rssi_event { - uint32 rate_limit_msec; - uint8 num_rssi_levels; - int8 rssi_levels[MAX_RSSI_LEVELS]; -} wl_rssi_event_t; - -typedef struct wl_action_obss_coex_req { - uint8 info; - uint8 num; - uint8 ch_list[1]; -} wl_action_obss_coex_req_t; - - -#define EXTLOG_CUR_VER 0x0100 - -#define MAX_ARGSTR_LEN 18 - - -#define LOG_MODULE_COMMON 0x0001 -#define LOG_MODULE_ASSOC 0x0002 -#define LOG_MODULE_EVENT 0x0004 -#define LOG_MODULE_MAX 3 - - -#define WL_LOG_LEVEL_DISABLE 0 -#define WL_LOG_LEVEL_ERR 1 -#define WL_LOG_LEVEL_WARN 2 -#define WL_LOG_LEVEL_INFO 3 -#define WL_LOG_LEVEL_MAX WL_LOG_LEVEL_INFO - - -#define LOG_FLAG_EVENT 1 - - -#define LOG_ARGTYPE_NULL 0 -#define LOG_ARGTYPE_STR 1 -#define LOG_ARGTYPE_INT 2 -#define LOG_ARGTYPE_INT_STR 3 -#define LOG_ARGTYPE_STR_INT 4 - -typedef struct wlc_extlog_cfg { - int max_number; - uint16 module; - uint8 level; - uint8 flag; - uint16 version; -} wlc_extlog_cfg_t; - -typedef struct log_record { - uint32 time; - uint16 module; - uint16 id; - uint8 level; - uint8 sub_unit; - uint8 seq_num; - int32 arg; - char str[MAX_ARGSTR_LEN]; -} log_record_t; - -typedef struct wlc_extlog_req { - uint32 from_last; - uint32 num; -} wlc_extlog_req_t; - -typedef struct wlc_extlog_results { - uint16 version; - uint16 record_len; - uint32 num; - log_record_t logs[1]; -} wlc_extlog_results_t; - -typedef struct log_idstr { - uint16 id; - uint16 flag; - uint8 arg_type; - const char *fmt_str; -} log_idstr_t; - -#define FMTSTRF_USER 1 - - -typedef enum { - FMTSTR_DRIVER_UP_ID = 0, - FMTSTR_DRIVER_DOWN_ID = 1, - FMTSTR_SUSPEND_MAC_FAIL_ID = 2, - FMTSTR_NO_PROGRESS_ID = 3, - FMTSTR_RFDISABLE_ID = 4, - FMTSTR_REG_PRINT_ID = 5, - FMTSTR_EXPTIME_ID = 6, - FMTSTR_JOIN_START_ID = 7, - FMTSTR_JOIN_COMPLETE_ID = 8, - FMTSTR_NO_NETWORKS_ID = 9, - FMTSTR_SECURITY_MISMATCH_ID = 10, - FMTSTR_RATE_MISMATCH_ID = 11, - FMTSTR_AP_PRUNED_ID = 12, - FMTSTR_KEY_INSERTED_ID = 13, - FMTSTR_DEAUTH_ID = 14, - FMTSTR_DISASSOC_ID = 15, - FMTSTR_LINK_UP_ID = 16, - FMTSTR_LINK_DOWN_ID = 17, - FMTSTR_RADIO_HW_OFF_ID = 18, - FMTSTR_RADIO_HW_ON_ID = 19, - FMTSTR_EVENT_DESC_ID = 20, - FMTSTR_PNP_SET_POWER_ID = 21, - FMTSTR_RADIO_SW_OFF_ID = 22, - FMTSTR_RADIO_SW_ON_ID = 23, - FMTSTR_PWD_MISMATCH_ID = 24, - FMTSTR_FATAL_ERROR_ID = 25, - FMTSTR_AUTH_FAIL_ID = 26, - FMTSTR_ASSOC_FAIL_ID = 27, - FMTSTR_IBSS_FAIL_ID = 28, - FMTSTR_EXTAP_FAIL_ID = 29, - FMTSTR_MAX_ID -} log_fmtstr_id_t; - -#ifdef DONGLEOVERLAYS -typedef struct { - uint32 flags_idx; - uint32 offset; - uint32 len; - -} wl_ioctl_overlay_t; - -#define OVERLAY_IDX_MASK 0x000000ff -#define OVERLAY_IDX_SHIFT 0 -#define OVERLAY_FLAGS_MASK 0xffffff00 -#define OVERLAY_FLAGS_SHIFT 8 - -#define OVERLAY_FLAG_POSTLOAD 0x100 - -#define OVERLAY_FLAG_DEFER_DL 0x200 - -#define OVERLAY_FLAG_PRESLEEP 0x400 - -#define OVERLAY_DOWNLOAD_CHUNKSIZE 1024 -#endif - - -#include <packed_section_end.h> - - -#include <packed_section_start.h> - -#define VNDR_IE_CMD_LEN 4 - - -#define VNDR_IE_BEACON_FLAG 0x1 -#define VNDR_IE_PRBRSP_FLAG 0x2 -#define VNDR_IE_ASSOCRSP_FLAG 0x4 -#define VNDR_IE_AUTHRSP_FLAG 0x8 -#define VNDR_IE_PRBREQ_FLAG 0x10 -#define VNDR_IE_ASSOCREQ_FLAG 0x20 -#define VNDR_IE_CUSTOM_FLAG 0x100 - -#define VNDR_IE_INFO_HDR_LEN (sizeof(uint32)) - -typedef BWL_PRE_PACKED_STRUCT struct { - uint32 pktflag; - vndr_ie_t vndr_ie_data; -} BWL_POST_PACKED_STRUCT vndr_ie_info_t; - -typedef BWL_PRE_PACKED_STRUCT struct { - int iecount; - vndr_ie_info_t vndr_ie_list[1]; -} BWL_POST_PACKED_STRUCT vndr_ie_buf_t; - -typedef BWL_PRE_PACKED_STRUCT struct { - char cmd[VNDR_IE_CMD_LEN]; - vndr_ie_buf_t vndr_ie_buffer; -} BWL_POST_PACKED_STRUCT vndr_ie_setbuf_t; - - - -typedef BWL_PRE_PACKED_STRUCT struct sta_prbreq_wps_ie_hdr { - struct ether_addr staAddr; - uint16 ieLen; -} BWL_POST_PACKED_STRUCT sta_prbreq_wps_ie_hdr_t; - -typedef BWL_PRE_PACKED_STRUCT struct sta_prbreq_wps_ie_data { - sta_prbreq_wps_ie_hdr_t hdr; - uint8 ieData[1]; -} BWL_POST_PACKED_STRUCT sta_prbreq_wps_ie_data_t; - -typedef BWL_PRE_PACKED_STRUCT struct sta_prbreq_wps_ie_list { - uint32 totLen; - uint8 ieDataList[1]; -} BWL_POST_PACKED_STRUCT sta_prbreq_wps_ie_list_t; - - -#ifdef WLMEDIA_TXFAILEVENT -typedef BWL_PRE_PACKED_STRUCT struct { - char dest[ETHER_ADDR_LEN]; - uint8 prio; - uint8 flags; - uint32 tsf_l; - uint32 tsf_h; - uint16 rates; - uint16 txstatus; -} BWL_POST_PACKED_STRUCT txfailinfo_t; -#endif - -#include <packed_section_end.h> - - -#define ASSERTLOG_CUR_VER 0x0100 -#define MAX_ASSRTSTR_LEN 64 - -typedef struct assert_record { - uint32 time; - uint8 seq_num; - char str[MAX_ASSRTSTR_LEN]; -} assert_record_t; - -typedef struct assertlog_results { - uint16 version; - uint16 record_len; - uint32 num; - assert_record_t logs[1]; -} assertlog_results_t; - -#define LOGRRC_FIX_LEN 8 -#define IOBUF_ALLOWED_NUM_OF_LOGREC(type, len) ((len - LOGRRC_FIX_LEN)/sizeof(type)) - - - - - -#define CHANIM_DISABLE 0 -#define CHANIM_DETECT 1 -#define CHANIM_ACT 2 -#define CHANIM_MODE_MAX 2 - - -#define APCS_IOCTL 1 -#define APCS_CHANIM 2 -#define APCS_CSTIMER 3 -#define APCS_BTA 4 - - -#define CHANIM_ACS_RECORD 10 - - -typedef struct { - bool valid; - uint8 trigger; - chanspec_t selected_chspc; - uint32 glitch_cnt; - uint8 ccastats; - uint timestamp; -} chanim_acs_record_t; - -typedef struct { - chanim_acs_record_t acs_record[CHANIM_ACS_RECORD]; - uint8 count; - uint timestamp; -} wl_acs_record_t; - - - -#define SMFS_VERSION 1 - -typedef struct wl_smfs_elem { - uint32 count; - uint16 code; -} wl_smfs_elem_t; - -typedef struct wl_smf_stats { - uint32 version; - uint16 length; - uint8 type; - uint8 codetype; - uint32 ignored_cnt; - uint32 malformed_cnt; - uint32 count_total; - wl_smfs_elem_t elem[1]; -} wl_smf_stats_t; - -#define WL_SMFSTATS_FIXED_LEN OFFSETOF(wl_smf_stats_t, elem); - -enum { - SMFS_CODETYPE_SC, - SMFS_CODETYPE_RC -}; - - -#define SMFS_CODE_MALFORMED 0xFFFE -#define SMFS_CODE_IGNORED 0xFFFD - -typedef enum smfs_type { - SMFS_TYPE_AUTH, - SMFS_TYPE_ASSOC, - SMFS_TYPE_REASSOC, - SMFS_TYPE_DISASSOC_TX, - SMFS_TYPE_DISASSOC_RX, - SMFS_TYPE_DEAUTH_TX, - SMFS_TYPE_DEAUTH_RX, - SMFS_TYPE_MAX -} smfs_type_t; - -#ifdef PHYMON - -#define PHYMON_VERSION 1 - -typedef struct wl_phycal_core_state { - - int16 tx_iqlocal_a; - int16 tx_iqlocal_b; - int8 tx_iqlocal_ci; - int8 tx_iqlocal_cq; - int8 tx_iqlocal_di; - int8 tx_iqlocal_dq; - int8 tx_iqlocal_ei; - int8 tx_iqlocal_eq; - int8 tx_iqlocal_fi; - int8 tx_iqlocal_fq; - - - int16 rx_iqcal_a; - int16 rx_iqcal_b; - - uint8 tx_iqlocal_pwridx; - uint32 papd_epsilon_table[64]; - int16 papd_epsilon_offset; - uint8 curr_tx_pwrindex; - int8 idle_tssi; - int8 est_tx_pwr; - int8 est_rx_pwr; - uint16 rx_gaininfo; - uint16 init_gaincode; - int8 estirr_tx; - int8 estirr_rx; - -} wl_phycal_core_state_t; - -typedef struct wl_phycal_state { - int version; - int8 num_phy_cores; - int8 curr_temperature; - chanspec_t chspec; - bool aci_state; - uint16 crsminpower; - uint16 crsminpowerl; - uint16 crsminpoweru; - wl_phycal_core_state_t phycal_core[1]; -} wl_phycal_state_t; - -#define WL_PHYCAL_STAT_FIXED_LEN OFFSETOF(wl_phycal_state_t, phycal_core) -#endif - -#ifdef WLP2P - -typedef struct wl_p2p_disc_st { - uint8 state; - chanspec_t chspec; - uint16 dwell; -} wl_p2p_disc_st_t; - - -#define WL_P2P_DISC_ST_SCAN 0 -#define WL_P2P_DISC_ST_LISTEN 1 -#define WL_P2P_DISC_ST_SEARCH 2 - - -typedef struct wl_p2p_scan { - uint8 type; - uint8 reserved[3]; - -} wl_p2p_scan_t; - - -typedef struct wl_p2p_if { - struct ether_addr addr; - uint8 type; - chanspec_t chspec; -} wl_p2p_if_t; - - -#define WL_P2P_IF_CLIENT 0 -#define WL_P2P_IF_GO 1 -#define WL_P2P_IF_DYNBCN_GO 2 -#define WL_P2P_IF_DEV 3 - - -typedef struct wl_p2p_ifq { - uint bsscfgidx; - char ifname[BCM_MSG_IFNAME_MAX]; -} wl_p2p_ifq_t; - - -typedef struct wl_p2p_ops { - uint8 ops; - uint8 ctw; -} wl_p2p_ops_t; - - -typedef struct wl_p2p_sched_desc { - uint32 start; - uint32 interval; - uint32 duration; - uint32 count; -} wl_p2p_sched_desc_t; - - -#define WL_P2P_SCHED_RSVD 0 -#define WL_P2P_SCHED_REPEAT 255 - -typedef struct wl_p2p_sched { - uint8 type; - uint8 action; - uint8 option; - wl_p2p_sched_desc_t desc[1]; -} wl_p2p_sched_t; -#define WL_P2P_SCHED_FIXED_LEN 3 - - -#define WL_P2P_SCHED_TYPE_ABS 0 -#define WL_P2P_SCHED_TYPE_REQ_ABS 1 - - -#define WL_P2P_SCHED_ACTION_NONE 0 -#define WL_P2P_SCHED_ACTION_DOZE 1 - -#define WL_P2P_SCHED_ACTION_GOOFF 2 - -#define WL_P2P_SCHED_ACTION_RESET 255 - - -#define WL_P2P_SCHED_OPTION_NORMAL 0 -#define WL_P2P_SCHED_OPTION_BCNPCT 1 - -#define WL_P2P_SCHED_OPTION_TSFOFS 2 - - -#define WL_P2P_FEAT_GO_CSA (1 << 0) -#define WL_P2P_FEAT_GO_NOLEGACY (1 << 1) -#define WL_P2P_FEAT_RESTRICT_DEV_RESP (1 << 2) -#endif - - -#define BCM_ACTION_RFAWARE 0x77 -#define BCM_ACTION_RFAWARE_DCS 0x01 - - - -#define WL_11N_2x2 1 -#define WL_11N_3x3 3 -#define WL_11N_4x4 4 - - -#define WLFEATURE_DISABLE_11N 0x00000001 -#define WLFEATURE_DISABLE_11N_STBC_TX 0x00000002 -#define WLFEATURE_DISABLE_11N_STBC_RX 0x00000004 -#define WLFEATURE_DISABLE_11N_SGI_TX 0x00000008 -#define WLFEATURE_DISABLE_11N_SGI_RX 0x00000010 -#define WLFEATURE_DISABLE_11N_AMPDU_TX 0x00000020 -#define WLFEATURE_DISABLE_11N_AMPDU_RX 0x00000040 -#define WLFEATURE_DISABLE_11N_GF 0x00000080 - - -#define LQ_IDX_LAST 3 -#define MCS_INDEX_SIZE 33 - -#define LQ_IDX_MIN 0 -#define LQ_IDX_MAX 1 -#define LQ_IDX_AVG 2 -#define LQ_IDX_SUM 2 -#define LQ_IDX_LAST 3 -#define LQ_STOP_MONITOR 0 -#define LQ_START_MONITOR 1 - -#define LINKQUAL_V1 0x01 - -struct wl_lq { - int32 enable; - int32 rssi[LQ_IDX_LAST]; - int32 rssicnt; - int32 snr[LQ_IDX_LAST]; - uint32 nsamples; - uint8 isvalid; - uint8 version; -}; - -typedef struct wl_lq wl_lq_t; -typedef struct wl_lq wl_lq_stats_t; - -typedef struct { - struct ether_addr ea; - uint8 ac_cat; - uint8 num_pkts; -} wl_mac_ratehisto_cmd_t; - - -typedef struct { - uint32 rate[WLC_MAXRATE + 1]; - uint32 mcs_index[MCS_INDEX_SIZE]; - uint32 tsf_timer[2][2]; -} wl_mac_ratehisto_res_t; - -#ifdef PROP_TXSTATUS - - -#define WLFC_FLAGS_RSSI_SIGNALS 1 - - -#define WLFC_FLAGS_XONXOFF_SIGNALS 2 - - -#define WLFC_FLAGS_CREDIT_STATUS_SIGNALS 4 - -#define WLFC_FLAGS_HOST_PROPTXSTATUS_ACTIVE 8 -#define WLFC_FLAGS_PSQ_GENERATIONFSM_ENABLE 16 -#define WLFC_FLAGS_PSQ_ZERO_BUFFER_ENABLE 32 -#endif - -#define BTA_STATE_LOG_SZ 64 - - -enum { - HCIReset = 1, - HCIReadLocalAMPInfo, - HCIReadLocalAMPASSOC, - HCIWriteRemoteAMPASSOC, - HCICreatePhysicalLink, - HCIAcceptPhysicalLinkRequest, - HCIDisconnectPhysicalLink, - HCICreateLogicalLink, - HCIAcceptLogicalLink, - HCIDisconnectLogicalLink, - HCILogicalLinkCancel, - HCIAmpStateChange, - HCIWriteLogicalLinkAcceptTimeout -}; - -typedef struct flush_txfifo { - uint32 txfifobmp; - uint32 hwtxfifoflush; - struct ether_addr ea; -} flush_txfifo_t; - -#define CHANNEL_5G_LOW_START 36 -#define CHANNEL_5G_MID_START 52 -#define CHANNEL_5G_HIGH_START 100 -#define CHANNEL_5G_UPPER_START 149 - -enum { - SPATIAL_MODE_2G_IDX = 0, - SPATIAL_MODE_5G_LOW_IDX, - SPATIAL_MODE_5G_MID_IDX, - SPATIAL_MODE_5G_HIGH_IDX, - SPATIAL_MODE_5G_UPPER_IDX, - SPATIAL_MODE_MAX_IDX -}; - -#endif diff --git a/bcm4329/dhdutil/miniopt.c b/bcm4329/dhdutil/miniopt.c deleted file mode 100644 index fadb8aa..0000000 --- a/bcm4329/dhdutil/miniopt.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 1999-2011, Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: miniopt.c,v 1.8 2009-09-21 16:10:13 Exp $ - */ - -/* ---- Include Files ---------------------------------------------------- */ - -#include <typedefs.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <miniopt.h> - - -/* ---- Public Variables ------------------------------------------------- */ -/* ---- Private Constants and Types -------------------------------------- */ - - - -/* ---- Private Variables ------------------------------------------------ */ -/* ---- Private Function Prototypes -------------------------------------- */ -/* ---- Functions -------------------------------------------------------- */ - -/* ----------------------------------------------------------------------- */ -void -miniopt_init(miniopt_t *t, const char* name, const char* flags, bool longflags) -{ - static const char *null_flags = ""; - - memset(t, 0, sizeof(miniopt_t)); - t->name = name; - if (flags == NULL) - t->flags = null_flags; - else - t->flags = flags; - t->longflags = longflags; -} - - -/* ----------------------------------------------------------------------- */ -int -miniopt(miniopt_t *t, char **argv) -{ - int keylen; - char *p, *eq, *valstr, *endptr = NULL; - int err = 0; - - t->consumed = 0; - t->positional = FALSE; - memset(t->key, 0, MINIOPT_MAXKEY); - t->opt = '\0'; - t->valstr = NULL; - t->good_int = FALSE; - valstr = NULL; - - if (*argv == NULL) { - err = -1; - goto exit; - } - - p = *argv++; - t->consumed++; - - if (!t->opt_end && !strcmp(p, "--")) { - t->opt_end = TRUE; - if (*argv == NULL) { - err = -1; - goto exit; - } - p = *argv++; - t->consumed++; - } - - if (t->opt_end) { - t->positional = TRUE; - valstr = p; - } - else if (!strncmp(p, "--", 2)) { - eq = strchr(p, '='); - if (eq == NULL && !t->longflags) { - fprintf(stderr, - "%s: missing \" = \" in long param \"%s\"\n", t->name, p); - err = 1; - goto exit; - } - keylen = eq ? (eq - (p + 2)) : (int)strlen(p) - 2; - if (keylen > 63) keylen = 63; - memcpy(t->key, p + 2, keylen); - - if (eq) { - valstr = eq + 1; - if (*valstr == '\0') { - fprintf(stderr, - "%s: missing value after \" = \" in long param \"%s\"\n", - t->name, p); - err = 1; - goto exit; - } - } - } - else if (!strncmp(p, "-", 1)) { - t->opt = p[1]; - if (strlen(p) > 2) { - fprintf(stderr, - "%s: only single char options, error on param \"%s\"\n", - t->name, p); - err = 1; - goto exit; - } - if (strchr(t->flags, t->opt)) { - /* this is a flag option, no value expected */ - valstr = NULL; - } else { - if (*argv == NULL) { - fprintf(stderr, - "%s: missing value parameter after \"%s\"\n", t->name, p); - err = 1; - goto exit; - } - valstr = *argv; - argv++; - t->consumed++; - } - } else { - t->positional = TRUE; - valstr = p; - } - - /* parse valstr as int just in case */ - if (valstr) { - t->uval = (uint)strtoul(valstr, &endptr, 0); - t->val = (int)t->uval; - t->good_int = (*endptr == '\0'); - } - - t->valstr = valstr; - -exit: - if (err == 1) - t->opt = '?'; - - return err; -} |
