staging: brcm80211: fix build with BCMDBG unset.
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / brcm80211 / brcmsmac / wlc_key.h
blob4991e9921de3afa50aaa82a9921110edc0ef9286
1 /*
2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef _wlc_key_h_
18 #define _wlc_key_h_
20 struct scb;
21 struct wlc_info;
22 struct wlc_bsscfg;
23 /* Maximum # of keys that wl driver supports in S/W.
24 * Keys supported in H/W is less than or equal to WSEC_MAX_KEYS.
26 #define WSEC_MAX_KEYS 54 /* Max # of keys (50 + 4 default keys) */
27 #define WLC_DEFAULT_KEYS 4 /* Default # of keys */
29 #define WSEC_MAX_WOWL_KEYS 5 /* Max keys in WOWL mode (1 + 4 default keys) */
31 #define WPA2_GTK_MAX 3
34 * Max # of keys currently supported:
36 * s/w keys if WSEC_SW(wlc->wsec).
37 * h/w keys otherwise.
39 #define WLC_MAX_WSEC_KEYS(wlc) WSEC_MAX_KEYS
41 /* number of 802.11 default (non-paired, group keys) */
42 #define WSEC_MAX_DEFAULT_KEYS 4 /* # of default keys */
44 /* Max # of hardware keys supported */
45 #define WLC_MAX_WSEC_HW_KEYS(wlc) WSEC_MAX_RCMTA_KEYS
47 /* Max # of hardware TKIP MIC keys supported */
48 #define WLC_MAX_TKMIC_HW_KEYS(wlc) ((D11REV_GE((wlc)->pub->corerev, 13)) ? \
49 WSEC_MAX_TKMIC_ENGINE_KEYS : 0)
51 #define WSEC_HW_TKMIC_KEY(wlc, key, bsscfg) \
52 (((D11REV_GE((wlc)->pub->corerev, 13)) && ((wlc)->machwcap & MCAP_TKIPMIC)) && \
53 (key) && ((key)->algo == CRYPTO_ALGO_TKIP) && \
54 !WSEC_SOFTKEY(wlc, key, bsscfg) && \
55 WSEC_KEY_INDEX(wlc, key) >= WLC_DEFAULT_KEYS && \
56 (WSEC_KEY_INDEX(wlc, key) < WSEC_MAX_TKMIC_ENGINE_KEYS))
58 /* index of key in key table */
59 #define WSEC_KEY_INDEX(wlc, key) ((key)->idx)
61 #define WSEC_SOFTKEY(wlc, key, bsscfg) (WLC_SW_KEYS(wlc, bsscfg) || \
62 WSEC_KEY_INDEX(wlc, key) >= WLC_MAX_WSEC_HW_KEYS(wlc))
64 /* get a key, non-NULL only if key allocated and not clear */
65 #define WSEC_KEY(wlc, i) (((wlc)->wsec_keys[i] && (wlc)->wsec_keys[i]->len) ? \
66 (wlc)->wsec_keys[i] : NULL)
68 #define WSEC_SCB_KEY_VALID(scb) (((scb)->key && (scb)->key->len) ? true : false)
70 /* default key */
71 #define WSEC_BSS_DEFAULT_KEY(bsscfg) (((bsscfg)->wsec_index == -1) ? \
72 (struct wsec_key *)NULL:(bsscfg)->bss_def_keys[(bsscfg)->wsec_index])
74 /* Macros for key management in IBSS mode */
75 #define WSEC_IBSS_MAX_PEERS 16 /* Max # of IBSS Peers */
76 #define WSEC_IBSS_RCMTA_INDEX(idx) \
77 (((idx - WSEC_MAX_DEFAULT_KEYS) % WSEC_IBSS_MAX_PEERS) + WSEC_MAX_DEFAULT_KEYS)
79 /* contiguous # key slots for infrastructure mode STA */
80 #define WSEC_BSS_STA_KEY_GROUP_SIZE 5
82 typedef struct wsec_iv {
83 u32 hi; /* upper 32 bits of IV */
84 u16 lo; /* lower 16 bits of IV */
85 } wsec_iv_t;
87 #define WLC_NUMRXIVS 16 /* # rx IVs (one per 802.11e TID) */
89 typedef struct wsec_key {
90 u8 ea[ETH_ALEN]; /* per station */
91 u8 idx; /* key index in wsec_keys array */
92 u8 id; /* key ID [0-3] */
93 u8 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
94 u8 rcmta; /* rcmta entry index, same as idx by default */
95 u16 flags; /* misc flags */
96 u8 algo_hw; /* cache for hw register */
97 u8 aes_mode; /* cache for hw register */
98 s8 iv_len; /* IV length */
99 s8 icv_len; /* ICV length */
100 u32 len; /* key length..don't move this var */
101 /* data is 4byte aligned */
102 u8 data[DOT11_MAX_KEY_SIZE]; /* key data */
103 wsec_iv_t rxiv[WLC_NUMRXIVS]; /* Rx IV (one per TID) */
104 wsec_iv_t txiv; /* Tx IV */
106 } wsec_key_t;
108 #define broken_roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
110 /* For use with wsec_key_t.flags */
112 #define WSEC_BS_UPDATE (1 << 0) /* Indicates hw needs key update on BS switch */
113 #define WSEC_PRIMARY_KEY (1 << 1) /* Indicates this key is the primary (ie tx) key */
114 #define WSEC_TKIP_ERROR (1 << 2) /* Provoke deliberate MIC error */
115 #define WSEC_REPLAY_ERROR (1 << 3) /* Provoke deliberate replay */
116 #define WSEC_IBSS_PEER_GROUP_KEY (1 << 7) /* Flag: group key for a IBSS PEER */
117 #define WSEC_ICV_ERROR (1 << 8) /* Provoke deliberate ICV error */
119 #define wlc_key_insert(a, b, c, d, e, f, g, h, i, j) (BCME_ERROR)
120 #define wlc_key_update(a, b, c) do {} while (0)
121 #define wlc_key_remove(a, b, c) do {} while (0)
122 #define wlc_key_remove_all(a, b) do {} while (0)
123 #define wlc_key_delete(a, b, c) do {} while (0)
124 #define wlc_scb_key_delete(a, b) do {} while (0)
125 #define wlc_key_lookup(a, b, c, d, e) (NULL)
126 #define wlc_key_hw_init_all(a) do {} while (0)
127 #define wlc_key_hw_init(a, b, c) do {} while (0)
128 #define wlc_key_hw_wowl_init(a, b, c, d) do {} while (0)
129 #define wlc_key_sw_wowl_update(a, b, c, d, e) do {} while (0)
130 #define wlc_key_sw_wowl_create(a, b, c) (BCME_ERROR)
131 #define wlc_key_iv_update(a, b, c, d, e) do {(void)e; } while (0)
132 #define wlc_key_iv_init(a, b, c) do {} while (0)
133 #define wlc_key_set_error(a, b, c) (BCME_ERROR)
134 #define wlc_key_dump_hw(a, b) (BCME_ERROR)
135 #define wlc_key_dump_sw(a, b) (BCME_ERROR)
136 #define wlc_key_defkeyflag(a) (0)
137 #define wlc_rcmta_add_bssid(a, b) do {} while (0)
138 #define wlc_rcmta_del_bssid(a, b) do {} while (0)
139 #define wlc_key_scb_delete(a, b) do {} while (0)
141 #endif /* _wlc_key_h_ */