Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010 Broadcom Corporation |
| 3 | * |
| 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. |
| 7 | * |
| 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. |
| 15 | */ |
| 16 | #include <linux/types.h> |
| 17 | #include <linux/if_ether.h> |
| 18 | #include <linux/spinlock.h> |
| 19 | #include <linux/skbuff.h> |
| 20 | #include <linux/netdevice.h> |
| 21 | #include <linux/err.h> |
| 22 | #include <uapi/linux/nl80211.h> |
| 23 | |
| 24 | #include <brcmu_utils.h> |
| 25 | #include <brcmu_wifi.h> |
| 26 | #include "dhd.h" |
| 27 | #include "dhd_dbg.h" |
| 28 | #include "fwil.h" |
| 29 | #include "fweh.h" |
| 30 | #include "fwsignal.h" |
| 31 | |
| 32 | /** |
| 33 | * DOC: Firmware Signalling |
| 34 | * |
| 35 | * Firmware can send signals to host and vice versa, which are passed in the |
| 36 | * data packets using TLV based header. This signalling layer is on top of the |
| 37 | * BDC bus protocol layer. |
| 38 | */ |
| 39 | |
| 40 | /* |
| 41 | * single definition for firmware-driver flow control tlv's. |
| 42 | * |
| 43 | * each tlv is specified by BRCMF_FWS_TLV_DEF(name, ID, length). |
| 44 | * A length value 0 indicates variable length tlv. |
| 45 | */ |
| 46 | #define BRCMF_FWS_TLV_DEFLIST \ |
| 47 | BRCMF_FWS_TLV_DEF(MAC_OPEN, 1, 1) \ |
| 48 | BRCMF_FWS_TLV_DEF(MAC_CLOSE, 2, 1) \ |
| 49 | BRCMF_FWS_TLV_DEF(MAC_REQUEST_CREDIT, 3, 2) \ |
| 50 | BRCMF_FWS_TLV_DEF(TXSTATUS, 4, 4) \ |
| 51 | BRCMF_FWS_TLV_DEF(PKTTAG, 5, 4) \ |
| 52 | BRCMF_FWS_TLV_DEF(MACDESC_ADD, 6, 8) \ |
| 53 | BRCMF_FWS_TLV_DEF(MACDESC_DEL, 7, 8) \ |
| 54 | BRCMF_FWS_TLV_DEF(RSSI, 8, 1) \ |
| 55 | BRCMF_FWS_TLV_DEF(INTERFACE_OPEN, 9, 1) \ |
| 56 | BRCMF_FWS_TLV_DEF(INTERFACE_CLOSE, 10, 1) \ |
| 57 | BRCMF_FWS_TLV_DEF(FIFO_CREDITBACK, 11, 8) \ |
| 58 | BRCMF_FWS_TLV_DEF(PENDING_TRAFFIC_BMP, 12, 2) \ |
| 59 | BRCMF_FWS_TLV_DEF(MAC_REQUEST_PACKET, 13, 3) \ |
| 60 | BRCMF_FWS_TLV_DEF(HOST_REORDER_RXPKTS, 14, 10) \ |
| 61 | BRCMF_FWS_TLV_DEF(TRANS_ID, 18, 6) \ |
| 62 | BRCMF_FWS_TLV_DEF(COMP_TXSTATUS, 19, 1) \ |
| 63 | BRCMF_FWS_TLV_DEF(FILLER, 255, 0) |
| 64 | |
| 65 | /** |
| 66 | * enum brcmf_fws_tlv_type - definition of tlv identifiers. |
| 67 | */ |
| 68 | #define BRCMF_FWS_TLV_DEF(name, id, len) \ |
| 69 | BRCMF_FWS_TYPE_ ## name = id, |
| 70 | enum brcmf_fws_tlv_type { |
| 71 | BRCMF_FWS_TLV_DEFLIST |
| 72 | BRCMF_FWS_TYPE_INVALID |
| 73 | }; |
| 74 | #undef BRCMF_FWS_TLV_DEF |
| 75 | |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 76 | #ifdef DEBUG |
| 77 | /** |
| 78 | * brcmf_fws_tlv_names - array of tlv names. |
| 79 | */ |
| 80 | #define BRCMF_FWS_TLV_DEF(name, id, len) \ |
| 81 | { id, #name }, |
| 82 | static struct { |
| 83 | enum brcmf_fws_tlv_type id; |
| 84 | const char *name; |
| 85 | } brcmf_fws_tlv_names[] = { |
| 86 | BRCMF_FWS_TLV_DEFLIST |
| 87 | }; |
| 88 | #undef BRCMF_FWS_TLV_DEF |
| 89 | |
| 90 | static const char *brcmf_fws_get_tlv_name(enum brcmf_fws_tlv_type id) |
| 91 | { |
| 92 | int i; |
| 93 | |
| 94 | for (i = 0; i < ARRAY_SIZE(brcmf_fws_tlv_names); i++) |
| 95 | if (brcmf_fws_tlv_names[i].id == id) |
| 96 | return brcmf_fws_tlv_names[i].name; |
| 97 | |
| 98 | return "INVALID"; |
| 99 | } |
| 100 | #else |
| 101 | static const char *brcmf_fws_get_tlv_name(enum brcmf_fws_tlv_type id) |
| 102 | { |
| 103 | return "NODEBUG"; |
| 104 | } |
| 105 | #endif /* DEBUG */ |
| 106 | |
| 107 | /** |
| 108 | * flags used to enable tlv signalling from firmware. |
| 109 | */ |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 110 | #define BRCMF_FWS_FLAGS_RSSI_SIGNALS 0x0001 |
| 111 | #define BRCMF_FWS_FLAGS_XONXOFF_SIGNALS 0x0002 |
| 112 | #define BRCMF_FWS_FLAGS_CREDIT_STATUS_SIGNALS 0x0004 |
| 113 | #define BRCMF_FWS_FLAGS_HOST_PROPTXSTATUS_ACTIVE 0x0008 |
| 114 | #define BRCMF_FWS_FLAGS_PSQ_GENERATIONFSM_ENABLE 0x0010 |
| 115 | #define BRCMF_FWS_FLAGS_PSQ_ZERO_BUFFER_ENABLE 0x0020 |
| 116 | #define BRCMF_FWS_FLAGS_HOST_RXREORDER_ACTIVE 0x0040 |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 117 | |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 118 | #define BRCMF_FWS_HANGER_MAXITEMS 1024 |
| 119 | #define BRCMF_FWS_HANGER_ITEM_STATE_FREE 1 |
| 120 | #define BRCMF_FWS_HANGER_ITEM_STATE_INUSE 2 |
| 121 | #define BRCMF_FWS_HANGER_ITEM_STATE_INUSE_SUPPRESSED 3 |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 122 | |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 123 | #define BRCMF_FWS_STATE_OPEN 1 |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 124 | #define BRCMF_FWS_STATE_CLOSE 2 |
| 125 | |
| 126 | #define BRCMF_FWS_FCMODE_NONE 0 |
| 127 | #define BRCMF_FWS_FCMODE_IMPLIED_CREDIT 1 |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 128 | #define BRCMF_FWS_FCMODE_EXPLICIT_CREDIT 2 |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 129 | |
| 130 | #define BRCMF_FWS_MAC_DESC_TABLE_SIZE 32 |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 131 | #define BRCMF_FWS_MAX_IFNUM 16 |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 132 | #define BRCMF_FWS_MAC_DESC_ID_INVALID 0xff |
| 133 | |
| 134 | #define BRCMF_FWS_HOSTIF_FLOWSTATE_OFF 0 |
| 135 | #define BRCMF_FWS_HOSTIF_FLOWSTATE_ON 1 |
| 136 | |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 137 | #define BRCMF_FWS_PSQ_PREC_COUNT ((NL80211_NUM_ACS + 1) * 2) |
| 138 | #define BRCMF_FWS_PSQ_LEN 256 |
| 139 | |
| 140 | /** |
Arend van Spriel | ebb9388 | 2013-04-03 12:40:35 +0200 | [diff] [blame] | 141 | * enum brcmf_fws_skb_state - indicates processing state of skb. |
| 142 | */ |
| 143 | enum brcmf_fws_skb_state { |
| 144 | WLFC_PKTTYPE_NEW, |
| 145 | WLFC_PKTTYPE_DELAYED, |
| 146 | WLFC_PKTTYPE_SUPPRESSED, |
| 147 | WLFC_PKTTYPE_MAX |
| 148 | }; |
| 149 | |
| 150 | /** |
| 151 | * struct brcmf_skbuff_cb - control buffer associated with skbuff. |
| 152 | * |
| 153 | * @if_flags: holds interface index and packet related flags. |
| 154 | * @da: destination MAC address extracted from skbuff once. |
| 155 | * @htod: host to device packet identifier (used in PKTTAG tlv). |
| 156 | * @needs_hdr: the packet does not yet have a BDC header. |
| 157 | * @state: transmit state of the packet. |
| 158 | * @mac: descriptor related to destination for this packet. |
| 159 | * |
| 160 | * This information is stored in control buffer struct sk_buff::cb, which |
| 161 | * provides 48 bytes of storage so this structure should not exceed that. |
| 162 | */ |
| 163 | struct brcmf_skbuff_cb { |
| 164 | u16 if_flags; |
| 165 | u8 da[ETH_ALEN]; |
| 166 | u32 htod; |
| 167 | u8 needs_hdr; |
| 168 | enum brcmf_fws_skb_state state; |
| 169 | struct brcmf_fws_mac_descriptor *mac; |
| 170 | }; |
| 171 | |
| 172 | /** |
| 173 | * macro casting skbuff control buffer to struct brcmf_skbuff_cb. |
| 174 | */ |
| 175 | #define brcmf_skbcb(skb) ((struct brcmf_skbuff_cb *)((skb)->cb)) |
| 176 | |
| 177 | /** |
| 178 | * sk_buff control if flags |
| 179 | * |
| 180 | * b[11] - packet sent upon firmware request. |
| 181 | * b[10] - packet only contains signalling data. |
| 182 | * b[9] - packet is a tx packet. |
| 183 | * b[8] - packet uses FIFO credit (non-pspoll). |
| 184 | * b[7] - interface in AP mode. |
| 185 | * b[6:4] - AC FIFO number. |
| 186 | * b[3:0] - interface index. |
| 187 | */ |
| 188 | #define BRCMF_SKB_IF_FLAGS_REQUESTED_MASK 0x0800 |
| 189 | #define BRCMF_SKB_IF_FLAGS_REQUESTED_SHIFT 11 |
| 190 | #define BRCMF_SKB_IF_FLAGS_SIGNAL_ONLY_MASK 0x0400 |
| 191 | #define BRCMF_SKB_IF_FLAGS_SIGNAL_ONLY_SHIFT 10 |
| 192 | #define BRCMF_SKB_IF_FLAGS_TRANSMIT_MASK 0x0200 |
| 193 | #define BRCMF_SKB_IF_FLAGS_TRANSMIT_SHIFT 9 |
| 194 | #define BRCMF_SKB_IF_FLAGS_CREDITCHECK_MASK 0x0100 |
| 195 | #define BRCMF_SKB_IF_FLAGS_CREDITCHECK_SHIFT 8 |
| 196 | #define BRCMF_SKB_IF_FLAGS_IF_AP_MASK 0x0080 |
| 197 | #define BRCMF_SKB_IF_FLAGS_IF_AP_SHIFT 7 |
| 198 | #define BRCMF_SKB_IF_FLAGS_FIFO_MASK 0x0070 |
| 199 | #define BRCMF_SKB_IF_FLAGS_FIFO_SHIFT 4 |
| 200 | #define BRCMF_SKB_IF_FLAGS_INDEX_MASK 0x000f |
| 201 | #define BRCMF_SKB_IF_FLAGS_INDEX_SHIFT 0 |
| 202 | |
| 203 | #define brcmf_skb_if_flags_set_field(skb, field, value) \ |
| 204 | brcmu_maskset16(&(brcmf_skbcb(skb)->if_flags), \ |
| 205 | BRCMF_SKB_IF_FLAGS_ ## field ## _MASK, \ |
| 206 | BRCMF_SKB_IF_FLAGS_ ## field ## _SHIFT, (value)) |
| 207 | #define brcmf_skb_if_flags_get_field(skb, field) \ |
| 208 | brcmu_maskget16(brcmf_skbcb(skb)->if_flags, \ |
| 209 | BRCMF_SKB_IF_FLAGS_ ## field ## _MASK, \ |
| 210 | BRCMF_SKB_IF_FLAGS_ ## field ## _SHIFT) |
| 211 | |
| 212 | /** |
| 213 | * sk_buff control packet identifier |
| 214 | * |
| 215 | * 32-bit packet identifier used in PKTTAG tlv from host to dongle. |
| 216 | * |
| 217 | * - Generated at the host (e.g. dhd) |
| 218 | * - Seen as a generic sequence number by firmware except for the flags field. |
| 219 | * |
| 220 | * Generation : b[31] => generation number for this packet [host->fw] |
| 221 | * OR, current generation number [fw->host] |
| 222 | * Flags : b[30:27] => command, status flags |
| 223 | * FIFO-AC : b[26:24] => AC-FIFO id |
| 224 | * h-slot : b[23:8] => hanger-slot |
| 225 | * freerun : b[7:0] => A free running counter |
| 226 | */ |
| 227 | #define BRCMF_SKB_HTOD_TAG_GENERATION_MASK 0x80000000 |
| 228 | #define BRCMF_SKB_HTOD_TAG_GENERATION_SHIFT 31 |
| 229 | #define BRCMF_SKB_HTOD_TAG_FLAGS_MASK 0x78000000 |
| 230 | #define BRCMF_SKB_HTOD_TAG_FLAGS_SHIFT 27 |
| 231 | #define BRCMF_SKB_HTOD_TAG_FIFO_MASK 0x07000000 |
| 232 | #define BRCMF_SKB_HTOD_TAG_FIFO_SHIFT 24 |
| 233 | #define BRCMF_SKB_HTOD_TAG_HSLOT_MASK 0x00ffff00 |
| 234 | #define BRCMF_SKB_HTOD_TAG_HSLOT_SHIFT 8 |
| 235 | #define BRCMF_SKB_HTOD_TAG_FREERUN_MASK 0x000000ff |
| 236 | #define BRCMF_SKB_HTOD_TAG_FREERUN_SHIFT 0 |
| 237 | |
| 238 | #define brcmf_skb_htod_tag_set_field(skb, field, value) \ |
| 239 | brcmu_maskset32(&(brcmf_skbcb(skb)->htod_tag), \ |
| 240 | BRCMF_SKB_HTOD_TAG_ ## field ## _MASK, \ |
| 241 | BRCMF_SKB_HTOD_TAG_ ## field ## _SHIFT, (value)) |
| 242 | #define brcmf_skb_htod_tag_get_field(skb, field) \ |
| 243 | brcmu_maskget32(brcmf_skbcb(skb)->htod_tag, \ |
| 244 | BRCMF_SKB_HTOD_TAG_ ## field ## _MASK, \ |
| 245 | BRCMF_SKB_HTOD_TAG_ ## field ## _SHIFT) |
| 246 | |
| 247 | /** |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 248 | * struct brcmf_fws_mac_descriptor - firmware signalling data per node/interface |
| 249 | * |
| 250 | * @occupied: slot is in use. |
Arend van Spriel | ce814c1 | 2013-04-03 12:40:31 +0200 | [diff] [blame] | 251 | * @mac_handle: handle for mac entry determined by firmware. |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 252 | * @interface_id: interface index. |
| 253 | * @state: current state. |
| 254 | * @ac_bitmap: ac queue bitmap. |
| 255 | * @requested_credit: credits requested by firmware. |
| 256 | * @ea: ethernet address. |
| 257 | * @psq: power-save queue. |
| 258 | */ |
| 259 | struct brcmf_fws_mac_descriptor { |
| 260 | u8 occupied; |
Arend van Spriel | ce814c1 | 2013-04-03 12:40:31 +0200 | [diff] [blame] | 261 | u8 mac_handle; |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 262 | u8 interface_id; |
| 263 | u8 state; |
| 264 | u8 ac_bitmap; |
| 265 | u8 requested_credit; |
| 266 | u8 ea[ETH_ALEN]; |
| 267 | struct pktq psq; |
| 268 | }; |
| 269 | |
Arend van Spriel | 6971280 | 2013-04-03 12:40:37 +0200 | [diff] [blame^] | 270 | #define BRCMF_FWS_HANGER_MAXITEMS 1024 |
| 271 | |
| 272 | /** |
| 273 | * enum brcmf_fws_hanger_item_state - state of hanger item. |
| 274 | * |
| 275 | * @WLFC_HANGER_ITEM_STATE_FREE: item is free for use. |
| 276 | * @WLFC_HANGER_ITEM_STATE_INUSE: item is in use. |
| 277 | * @WLFC_HANGER_ITEM_STATE_INUSE_SUPPRESSED: item was suppressed. |
| 278 | */ |
| 279 | enum brcmf_fws_hanger_item_state { |
| 280 | WLFC_HANGER_ITEM_STATE_FREE = 1, |
| 281 | WLFC_HANGER_ITEM_STATE_INUSE, |
| 282 | WLFC_HANGER_ITEM_STATE_INUSE_SUPPRESSED |
| 283 | }; |
| 284 | |
| 285 | |
| 286 | /** |
| 287 | * struct brcmf_fws_hanger_item - single entry for tx pending packet. |
| 288 | * |
| 289 | * @state: entry is either free or occupied. |
| 290 | * @gen: generation. |
| 291 | * @identifier: packet identifier. |
| 292 | * @pkt: packet itself. |
| 293 | */ |
| 294 | struct brcmf_fws_hanger_item { |
| 295 | enum brcmf_fws_hanger_item_state state; |
| 296 | u8 gen; |
| 297 | u8 pad[2]; |
| 298 | u32 identifier; |
| 299 | struct sk_buff *pkt; |
| 300 | }; |
| 301 | |
| 302 | /** |
| 303 | * struct brcmf_fws_hanger - holds packets awaiting firmware txstatus. |
| 304 | * |
| 305 | * @max_items: number of packets it can hold. |
| 306 | * @pushed: packets pushed to await txstatus. |
| 307 | * @popped: packets popped upon handling txstatus. |
| 308 | * @failed_to_push: packets that could not be pushed. |
| 309 | * @failed_to_pop: packets that could not be popped. |
| 310 | * @failed_slotfind: packets for which failed to find an entry. |
| 311 | * @slot_pos: last returned item index for a free entry. |
| 312 | * @items: array of hanger items. |
| 313 | */ |
| 314 | struct brcmf_fws_hanger { |
| 315 | u32 pushed; |
| 316 | u32 popped; |
| 317 | u32 failed_to_push; |
| 318 | u32 failed_to_pop; |
| 319 | u32 failed_slotfind; |
| 320 | u32 slot_pos; |
| 321 | struct brcmf_fws_hanger_item items[BRCMF_FWS_HANGER_MAXITEMS]; |
| 322 | }; |
| 323 | |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 324 | struct brcmf_fws_info { |
| 325 | struct brcmf_pub *drvr; |
| 326 | struct brcmf_fws_stats stats; |
Arend van Spriel | 6971280 | 2013-04-03 12:40:37 +0200 | [diff] [blame^] | 327 | struct brcmf_fws_hanger hanger; |
Arend van Spriel | ce814c1 | 2013-04-03 12:40:31 +0200 | [diff] [blame] | 328 | struct brcmf_fws_mac_descriptor nodes[BRCMF_FWS_MAC_DESC_TABLE_SIZE]; |
Arend van Spriel | fba1400 | 2013-04-03 12:40:33 +0200 | [diff] [blame] | 329 | struct brcmf_fws_mac_descriptor other; |
Arend van Spriel | 43fa635 | 2013-04-03 12:40:32 +0200 | [diff] [blame] | 330 | int fifo_credit[NL80211_NUM_ACS+1+1]; |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 331 | }; |
| 332 | |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 333 | /** |
| 334 | * brcmf_fws_get_tlv_len() - returns defined length for given tlv id. |
| 335 | */ |
| 336 | #define BRCMF_FWS_TLV_DEF(name, id, len) \ |
| 337 | case BRCMF_FWS_TYPE_ ## name: \ |
| 338 | return len; |
| 339 | |
| 340 | static int brcmf_fws_get_tlv_len(struct brcmf_fws_info *fws, |
| 341 | enum brcmf_fws_tlv_type id) |
| 342 | { |
| 343 | switch (id) { |
| 344 | BRCMF_FWS_TLV_DEFLIST |
| 345 | default: |
| 346 | brcmf_err("invalid tlv id: %d\n", id); |
| 347 | fws->stats.tlv_invalid_type++; |
| 348 | break; |
| 349 | } |
| 350 | return -EINVAL; |
| 351 | } |
| 352 | #undef BRCMF_FWS_TLV_DEF |
| 353 | |
Arend van Spriel | 6971280 | 2013-04-03 12:40:37 +0200 | [diff] [blame^] | 354 | static void brcmf_fws_hanger_init(struct brcmf_fws_hanger *hanger) |
| 355 | { |
| 356 | int i; |
| 357 | |
| 358 | brcmf_dbg(TRACE, "enter\n"); |
| 359 | memset(hanger, 0, sizeof(*hanger)); |
| 360 | for (i = 0; i < ARRAY_SIZE(hanger->items); i++) |
| 361 | hanger->items[i].state = WLFC_HANGER_ITEM_STATE_FREE; |
| 362 | } |
| 363 | |
| 364 | static __used u32 brcmf_fws_hanger_get_free_slot(struct brcmf_fws_hanger *h) |
| 365 | { |
| 366 | u32 i; |
| 367 | |
| 368 | brcmf_dbg(TRACE, "enter\n"); |
| 369 | i = (h->slot_pos + 1) % BRCMF_FWS_HANGER_MAXITEMS; |
| 370 | |
| 371 | while (i != h->slot_pos) { |
| 372 | if (h->items[i].state == WLFC_HANGER_ITEM_STATE_FREE) { |
| 373 | h->slot_pos = i; |
| 374 | return i; |
| 375 | } |
| 376 | i++; |
| 377 | if (i == BRCMF_FWS_HANGER_MAXITEMS) |
| 378 | i = 0; |
| 379 | } |
| 380 | brcmf_err("all slots occupied\n"); |
| 381 | h->failed_slotfind++; |
| 382 | return BRCMF_FWS_HANGER_MAXITEMS; |
| 383 | } |
| 384 | |
| 385 | static __used int brcmf_fws_hanger_pushpkt(struct brcmf_fws_hanger *h, |
| 386 | struct sk_buff *pkt, u32 slot_id) |
| 387 | { |
| 388 | brcmf_dbg(TRACE, "enter\n"); |
| 389 | if (slot_id >= BRCMF_FWS_HANGER_MAXITEMS) |
| 390 | return -ENOENT; |
| 391 | |
| 392 | if (h->items[slot_id].state != BRCMF_FWS_HANGER_ITEM_STATE_FREE) { |
| 393 | brcmf_err("slot is not free\n"); |
| 394 | h->failed_to_push++; |
| 395 | return -EINVAL; |
| 396 | } |
| 397 | |
| 398 | h->items[slot_id].state = BRCMF_FWS_HANGER_ITEM_STATE_INUSE; |
| 399 | h->items[slot_id].pkt = pkt; |
| 400 | h->items[slot_id].identifier = slot_id; |
| 401 | h->pushed++; |
| 402 | return 0; |
| 403 | } |
| 404 | |
| 405 | static __used int brcmf_fws_hanger_poppkt(struct brcmf_fws_hanger *h, |
| 406 | u32 slot_id, struct sk_buff **pktout, |
| 407 | bool remove_item) |
| 408 | { |
| 409 | brcmf_dbg(TRACE, "enter\n"); |
| 410 | if (slot_id >= BRCMF_FWS_HANGER_MAXITEMS) |
| 411 | return -ENOENT; |
| 412 | |
| 413 | if (h->items[slot_id].state == BRCMF_FWS_HANGER_ITEM_STATE_FREE) { |
| 414 | brcmf_err("entry not in use\n"); |
| 415 | h->failed_to_pop++; |
| 416 | return -EINVAL; |
| 417 | } |
| 418 | |
| 419 | *pktout = h->items[slot_id].pkt; |
| 420 | if (remove_item) { |
| 421 | h->items[slot_id].state = BRCMF_FWS_HANGER_ITEM_STATE_FREE; |
| 422 | h->items[slot_id].pkt = NULL; |
| 423 | h->items[slot_id].identifier = 0; |
| 424 | h->items[slot_id].gen = 0xff; |
| 425 | h->popped++; |
| 426 | } |
| 427 | return 0; |
| 428 | } |
| 429 | |
| 430 | static __used int brcmf_fws_hanger_mark_suppressed(struct brcmf_fws_hanger *h, |
| 431 | u32 slot_id, u8 gen) |
| 432 | { |
| 433 | brcmf_dbg(TRACE, "enter\n"); |
| 434 | |
| 435 | if (slot_id >= BRCMF_FWS_HANGER_MAXITEMS) |
| 436 | return -ENOENT; |
| 437 | |
| 438 | h->items[slot_id].gen = gen; |
| 439 | |
| 440 | if (h->items[slot_id].state != WLFC_HANGER_ITEM_STATE_INUSE) { |
| 441 | brcmf_err("entry not in use\n"); |
| 442 | return -EINVAL; |
| 443 | } |
| 444 | |
| 445 | h->items[slot_id].state = WLFC_HANGER_ITEM_STATE_INUSE_SUPPRESSED; |
| 446 | return 0; |
| 447 | } |
| 448 | |
| 449 | static __used int brcmf_fws_hanger_get_genbit(struct brcmf_fws_hanger *hanger, |
| 450 | struct sk_buff *pkt, u32 slot_id, |
| 451 | int *gen) |
| 452 | { |
| 453 | brcmf_dbg(TRACE, "enter\n"); |
| 454 | *gen = 0xff; |
| 455 | |
| 456 | if (slot_id >= BRCMF_FWS_HANGER_MAXITEMS) |
| 457 | return -ENOENT; |
| 458 | |
| 459 | if (hanger->items[slot_id].state == BRCMF_FWS_HANGER_ITEM_STATE_FREE) { |
| 460 | brcmf_err("slot not in use\n"); |
| 461 | return -EINVAL; |
| 462 | } |
| 463 | |
| 464 | *gen = hanger->items[slot_id].gen; |
| 465 | return 0; |
| 466 | } |
| 467 | |
| 468 | static void brcmf_fws_hanger_cleanup(struct brcmf_fws_hanger *h, |
| 469 | bool (*fn)(struct sk_buff *, void *), |
| 470 | int ifidx) |
| 471 | { |
| 472 | struct sk_buff *skb; |
| 473 | int i; |
| 474 | enum brcmf_fws_hanger_item_state s; |
| 475 | |
| 476 | brcmf_dbg(TRACE, "enter: ifidx=%d\n", ifidx); |
| 477 | for (i = 0; i < ARRAY_SIZE(h->items); i++) { |
| 478 | s = h->items[i].state; |
| 479 | if (s == BRCMF_FWS_HANGER_ITEM_STATE_INUSE || |
| 480 | s == BRCMF_FWS_HANGER_ITEM_STATE_INUSE_SUPPRESSED) { |
| 481 | skb = h->items[i].pkt; |
| 482 | if (fn == NULL || fn(skb, &ifidx)) { |
| 483 | /* suppress packets freed from psq */ |
| 484 | if (s == BRCMF_FWS_HANGER_ITEM_STATE_INUSE) |
| 485 | brcmu_pkt_buf_free_skb(skb); |
| 486 | h->items[i].state = |
| 487 | BRCMF_FWS_HANGER_ITEM_STATE_FREE; |
| 488 | } |
| 489 | } |
| 490 | } |
| 491 | } |
| 492 | |
Arend van Spriel | ce814c1 | 2013-04-03 12:40:31 +0200 | [diff] [blame] | 493 | static void brcmf_fws_init_mac_descriptor(struct brcmf_fws_mac_descriptor *desc, |
| 494 | u8 *addr, u8 ifidx) |
| 495 | { |
| 496 | brcmf_dbg(TRACE, "enter: ea=%pM, ifidx=%u\n", addr, ifidx); |
| 497 | desc->occupied = 1; |
| 498 | desc->state = BRCMF_FWS_STATE_OPEN; |
| 499 | desc->requested_credit = 0; |
| 500 | /* depending on use may need ifp->bssidx instead */ |
| 501 | desc->interface_id = ifidx; |
| 502 | desc->ac_bitmap = 0xff; /* update this when handling APSD */ |
| 503 | memcpy(&desc->ea[0], addr, ETH_ALEN); |
| 504 | } |
| 505 | |
| 506 | static |
| 507 | void brcmf_fws_clear_mac_descriptor(struct brcmf_fws_mac_descriptor *desc) |
| 508 | { |
| 509 | brcmf_dbg(TRACE, |
| 510 | "enter: ea=%pM, ifidx=%u\n", desc->ea, desc->interface_id); |
| 511 | desc->occupied = 0; |
| 512 | desc->state = BRCMF_FWS_STATE_CLOSE; |
| 513 | desc->requested_credit = 0; |
| 514 | } |
| 515 | |
| 516 | static struct brcmf_fws_mac_descriptor * |
| 517 | brcmf_fws_mac_descriptor_lookup(struct brcmf_fws_info *fws, u8 *ea) |
| 518 | { |
| 519 | struct brcmf_fws_mac_descriptor *entry; |
| 520 | int i; |
| 521 | |
| 522 | brcmf_dbg(TRACE, "enter: ea=%pM\n", ea); |
| 523 | if (ea == NULL) |
| 524 | return ERR_PTR(-EINVAL); |
| 525 | |
| 526 | entry = &fws->nodes[0]; |
| 527 | for (i = 0; i < ARRAY_SIZE(fws->nodes); i++) { |
| 528 | if (entry->occupied && !memcmp(entry->ea, ea, ETH_ALEN)) |
| 529 | return entry; |
| 530 | entry++; |
| 531 | } |
| 532 | |
| 533 | return ERR_PTR(-ENOENT); |
| 534 | } |
| 535 | |
Arend van Spriel | fba1400 | 2013-04-03 12:40:33 +0200 | [diff] [blame] | 536 | static void brcmf_fws_mac_desc_cleanup(struct brcmf_fws_mac_descriptor *entry, |
| 537 | bool (*fn)(struct sk_buff *, void *), |
| 538 | int ifidx) |
| 539 | { |
| 540 | brcmf_dbg(TRACE, "enter: entry=(ea=%pM,ifid=%d), ifidx=%d\n", |
| 541 | entry->ea, entry->interface_id, ifidx); |
| 542 | if (entry->occupied && (fn == NULL || (ifidx == entry->interface_id))) { |
| 543 | brcmf_dbg(TRACE, "flush delayQ: ifidx=%d, qlen=%d\n", |
| 544 | ifidx, entry->psq.len); |
| 545 | /* release packets held in DELAYQ */ |
| 546 | brcmu_pktq_flush(&entry->psq, true, fn, &ifidx); |
| 547 | entry->occupied = !!(entry->psq.len); |
| 548 | } |
| 549 | } |
| 550 | |
Arend van Spriel | a3e993c | 2013-04-03 12:40:36 +0200 | [diff] [blame] | 551 | static bool brcmf_fws_ifidx_match(struct sk_buff *skb, void *arg) |
| 552 | { |
| 553 | u32 ifidx = brcmf_skb_if_flags_get_field(skb, INDEX); |
| 554 | return ifidx == *(int *)arg; |
| 555 | } |
| 556 | |
Arend van Spriel | fba1400 | 2013-04-03 12:40:33 +0200 | [diff] [blame] | 557 | static void brcmf_fws_cleanup(struct brcmf_fws_info *fws, int ifidx) |
| 558 | { |
| 559 | int i; |
| 560 | struct brcmf_fws_mac_descriptor *table; |
Arend van Spriel | a3e993c | 2013-04-03 12:40:36 +0200 | [diff] [blame] | 561 | bool (*matchfn)(struct sk_buff *, void *) = NULL; |
Arend van Spriel | fba1400 | 2013-04-03 12:40:33 +0200 | [diff] [blame] | 562 | |
| 563 | brcmf_dbg(TRACE, "enter: ifidx=%d\n", ifidx); |
| 564 | if (fws == NULL) |
| 565 | return; |
| 566 | |
Arend van Spriel | a3e993c | 2013-04-03 12:40:36 +0200 | [diff] [blame] | 567 | if (ifidx != -1) |
| 568 | matchfn = brcmf_fws_ifidx_match; |
| 569 | |
Arend van Spriel | fba1400 | 2013-04-03 12:40:33 +0200 | [diff] [blame] | 570 | /* cleanup individual nodes */ |
| 571 | table = &fws->nodes[0]; |
| 572 | for (i = 0; i < ARRAY_SIZE(fws->nodes); i++) |
Arend van Spriel | a3e993c | 2013-04-03 12:40:36 +0200 | [diff] [blame] | 573 | brcmf_fws_mac_desc_cleanup(&table[i], matchfn, ifidx); |
Arend van Spriel | fba1400 | 2013-04-03 12:40:33 +0200 | [diff] [blame] | 574 | |
Arend van Spriel | a3e993c | 2013-04-03 12:40:36 +0200 | [diff] [blame] | 575 | brcmf_fws_mac_desc_cleanup(&fws->other, matchfn, ifidx); |
Arend van Spriel | 6971280 | 2013-04-03 12:40:37 +0200 | [diff] [blame^] | 576 | brcmf_fws_hanger_cleanup(&fws->hanger, matchfn, ifidx); |
Arend van Spriel | fba1400 | 2013-04-03 12:40:33 +0200 | [diff] [blame] | 577 | } |
| 578 | |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 579 | static int brcmf_fws_rssi_indicate(struct brcmf_fws_info *fws, s8 rssi) |
| 580 | { |
| 581 | brcmf_dbg(CTL, "rssi %d\n", rssi); |
| 582 | return 0; |
| 583 | } |
| 584 | |
Arend van Spriel | ce814c1 | 2013-04-03 12:40:31 +0200 | [diff] [blame] | 585 | static |
| 586 | int brcmf_fws_macdesc_indicate(struct brcmf_fws_info *fws, u8 type, u8 *data) |
| 587 | { |
| 588 | struct brcmf_fws_mac_descriptor *entry, *existing; |
| 589 | u8 mac_handle; |
| 590 | u8 ifidx; |
| 591 | u8 *addr; |
| 592 | |
| 593 | mac_handle = *data++; |
| 594 | ifidx = *data++; |
| 595 | addr = data; |
| 596 | |
| 597 | entry = &fws->nodes[mac_handle & 0x1F]; |
| 598 | if (type == BRCMF_FWS_TYPE_MACDESC_DEL) { |
| 599 | brcmf_dbg(TRACE, "deleting mac %pM idx %d\n", addr, ifidx); |
| 600 | if (entry->occupied) { |
| 601 | entry->occupied = 0; |
| 602 | entry->state = BRCMF_FWS_STATE_CLOSE; |
| 603 | entry->requested_credit = 0; |
| 604 | } else { |
| 605 | fws->stats.mac_update_failed++; |
| 606 | } |
| 607 | return 0; |
| 608 | } |
| 609 | |
| 610 | brcmf_dbg(TRACE, "add mac %pM idx %d\n", addr, ifidx); |
| 611 | existing = brcmf_fws_mac_descriptor_lookup(fws, addr); |
| 612 | if (IS_ERR(existing)) { |
| 613 | if (!entry->occupied) { |
| 614 | entry->mac_handle = mac_handle; |
| 615 | brcmf_fws_init_mac_descriptor(entry, addr, ifidx); |
| 616 | brcmu_pktq_init(&entry->psq, BRCMF_FWS_PSQ_PREC_COUNT, |
| 617 | BRCMF_FWS_PSQ_LEN); |
| 618 | } else { |
| 619 | fws->stats.mac_update_failed++; |
| 620 | } |
| 621 | } else { |
| 622 | if (entry != existing) { |
| 623 | brcmf_dbg(TRACE, "relocate mac\n"); |
| 624 | memcpy(entry, existing, |
| 625 | offsetof(struct brcmf_fws_mac_descriptor, psq)); |
| 626 | entry->mac_handle = mac_handle; |
| 627 | brcmf_fws_clear_mac_descriptor(existing); |
| 628 | } else { |
| 629 | brcmf_dbg(TRACE, "use existing\n"); |
| 630 | WARN_ON(entry->mac_handle != mac_handle); |
| 631 | /* TODO: what should we do here: continue, reinit, .. */ |
| 632 | } |
| 633 | } |
| 634 | return 0; |
| 635 | } |
| 636 | |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 637 | static int brcmf_fws_dbg_seqnum_check(struct brcmf_fws_info *fws, u8 *data) |
| 638 | { |
| 639 | __le32 timestamp; |
| 640 | |
| 641 | memcpy(×tamp, &data[2], sizeof(timestamp)); |
| 642 | brcmf_dbg(INFO, "received: seq %d, timestamp %d\n", data[1], |
| 643 | le32_to_cpu(timestamp)); |
| 644 | return 0; |
| 645 | } |
| 646 | |
| 647 | /* using macro so sparse checking does not complain |
| 648 | * about locking imbalance. |
| 649 | */ |
| 650 | #define brcmf_fws_lock(drvr, flags) \ |
| 651 | do { \ |
| 652 | flags = 0; \ |
| 653 | spin_lock_irqsave(&((drvr)->fws_spinlock), (flags)); \ |
| 654 | } while (0) |
| 655 | |
| 656 | /* using macro so sparse checking does not complain |
| 657 | * about locking imbalance. |
| 658 | */ |
| 659 | #define brcmf_fws_unlock(drvr, flags) \ |
| 660 | spin_unlock_irqrestore(&((drvr)->fws_spinlock), (flags)) |
| 661 | |
Arend van Spriel | 43fa635 | 2013-04-03 12:40:32 +0200 | [diff] [blame] | 662 | static int brcmf_fws_notify_credit_map(struct brcmf_if *ifp, |
| 663 | const struct brcmf_event_msg *e, |
| 664 | void *data) |
| 665 | { |
| 666 | struct brcmf_fws_info *fws = ifp->drvr->fws; |
| 667 | int i; |
| 668 | ulong flags; |
| 669 | u8 *credits = data; |
| 670 | |
| 671 | brcmf_fws_lock(ifp->drvr, flags); |
| 672 | for (i = 0; i < ARRAY_SIZE(fws->fifo_credit); i++) |
| 673 | fws->fifo_credit[i] = *credits++; |
| 674 | brcmf_fws_unlock(ifp->drvr, flags); |
| 675 | return 0; |
| 676 | } |
| 677 | |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 678 | int brcmf_fws_init(struct brcmf_pub *drvr) |
| 679 | { |
Arend van Spriel | ce814c1 | 2013-04-03 12:40:31 +0200 | [diff] [blame] | 680 | u32 tlv = 0; |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 681 | int rc; |
| 682 | |
| 683 | /* enable rssi signals */ |
Arend van Spriel | ce814c1 | 2013-04-03 12:40:31 +0200 | [diff] [blame] | 684 | if (drvr->fw_signals) |
| 685 | tlv = BRCMF_FWS_FLAGS_RSSI_SIGNALS | |
| 686 | BRCMF_FWS_FLAGS_XONXOFF_SIGNALS; |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 687 | |
| 688 | spin_lock_init(&drvr->fws_spinlock); |
| 689 | |
| 690 | drvr->fws = kzalloc(sizeof(*(drvr->fws)), GFP_KERNEL); |
| 691 | if (!drvr->fws) { |
| 692 | rc = -ENOMEM; |
| 693 | goto fail; |
| 694 | } |
| 695 | |
| 696 | /* enable proptxtstatus signaling by default */ |
| 697 | rc = brcmf_fil_iovar_int_set(drvr->iflist[0], "tlv", tlv); |
| 698 | if (rc < 0) { |
| 699 | brcmf_err("failed to set bdcv2 tlv signaling\n"); |
| 700 | goto fail; |
| 701 | } |
Arend van Spriel | 43fa635 | 2013-04-03 12:40:32 +0200 | [diff] [blame] | 702 | |
| 703 | if (brcmf_fweh_register(drvr, BRCMF_E_FIFO_CREDIT_MAP, |
| 704 | brcmf_fws_notify_credit_map)) { |
| 705 | brcmf_err("register credit map handler failed\n"); |
| 706 | goto fail; |
| 707 | } |
| 708 | |
Arend van Spriel | 6971280 | 2013-04-03 12:40:37 +0200 | [diff] [blame^] | 709 | brcmf_fws_hanger_init(&drvr->fws->hanger); |
| 710 | |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 711 | /* create debugfs file for statistics */ |
| 712 | brcmf_debugfs_create_fws_stats(drvr, &drvr->fws->stats); |
| 713 | |
Arend van Spriel | fba1400 | 2013-04-03 12:40:33 +0200 | [diff] [blame] | 714 | /* set linkage back */ |
| 715 | drvr->fws->drvr = drvr; |
| 716 | |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 717 | /* TODO: remove upon feature delivery */ |
| 718 | brcmf_err("%s bdcv2 tlv signaling [%x]\n", |
| 719 | drvr->fw_signals ? "enabled" : "disabled", tlv); |
| 720 | return 0; |
| 721 | |
| 722 | fail: |
| 723 | /* disable flow control entirely */ |
| 724 | drvr->fw_signals = false; |
| 725 | brcmf_fws_deinit(drvr); |
| 726 | return rc; |
| 727 | } |
| 728 | |
| 729 | void brcmf_fws_deinit(struct brcmf_pub *drvr) |
| 730 | { |
Arend van Spriel | fba1400 | 2013-04-03 12:40:33 +0200 | [diff] [blame] | 731 | struct brcmf_fws_info *fws = drvr->fws; |
| 732 | ulong flags; |
| 733 | |
| 734 | /* cleanup */ |
| 735 | brcmf_fws_lock(drvr, flags); |
| 736 | brcmf_fws_cleanup(fws, -1); |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 737 | drvr->fws = NULL; |
Arend van Spriel | fba1400 | 2013-04-03 12:40:33 +0200 | [diff] [blame] | 738 | brcmf_fws_unlock(drvr, flags); |
| 739 | |
| 740 | /* free top structure */ |
| 741 | kfree(fws); |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | int brcmf_fws_hdrpull(struct brcmf_pub *drvr, int ifidx, s16 signal_len, |
| 745 | struct sk_buff *skb) |
| 746 | { |
| 747 | struct brcmf_fws_info *fws = drvr->fws; |
| 748 | ulong flags; |
| 749 | u8 *signal_data; |
| 750 | s16 data_len; |
| 751 | u8 type; |
| 752 | u8 len; |
| 753 | u8 *data; |
| 754 | |
| 755 | brcmf_dbg(TRACE, "enter: ifidx %d, skblen %u, sig %d\n", |
| 756 | ifidx, skb->len, signal_len); |
| 757 | |
| 758 | WARN_ON(signal_len > skb->len); |
| 759 | |
| 760 | /* if flow control disabled, skip to packet data and leave */ |
| 761 | if (!signal_len || !drvr->fw_signals) { |
| 762 | skb_pull(skb, signal_len); |
| 763 | return 0; |
| 764 | } |
| 765 | |
| 766 | /* lock during tlv parsing */ |
| 767 | brcmf_fws_lock(drvr, flags); |
| 768 | |
| 769 | fws->stats.header_pulls++; |
| 770 | data_len = signal_len; |
| 771 | signal_data = skb->data; |
| 772 | |
| 773 | while (data_len > 0) { |
| 774 | /* extract tlv info */ |
| 775 | type = signal_data[0]; |
| 776 | |
| 777 | /* FILLER type is actually not a TLV, but |
| 778 | * a single byte that can be skipped. |
| 779 | */ |
| 780 | if (type == BRCMF_FWS_TYPE_FILLER) { |
| 781 | signal_data += 1; |
| 782 | data_len -= 1; |
| 783 | continue; |
| 784 | } |
| 785 | len = signal_data[1]; |
| 786 | data = signal_data + 2; |
| 787 | |
| 788 | /* abort parsing when length invalid */ |
| 789 | if (data_len < len + 2) |
| 790 | break; |
| 791 | |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 792 | if (len != brcmf_fws_get_tlv_len(fws, type)) |
| 793 | break; |
| 794 | |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 795 | brcmf_dbg(INFO, "tlv type=%d (%s), len=%d\n", type, |
| 796 | brcmf_fws_get_tlv_name(type), len); |
| 797 | switch (type) { |
| 798 | case BRCMF_FWS_TYPE_MAC_OPEN: |
| 799 | case BRCMF_FWS_TYPE_MAC_CLOSE: |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 800 | case BRCMF_FWS_TYPE_MAC_REQUEST_CREDIT: |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 801 | case BRCMF_FWS_TYPE_TXSTATUS: |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 802 | case BRCMF_FWS_TYPE_PKTTAG: |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 803 | case BRCMF_FWS_TYPE_INTERFACE_OPEN: |
| 804 | case BRCMF_FWS_TYPE_INTERFACE_CLOSE: |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 805 | case BRCMF_FWS_TYPE_FIFO_CREDITBACK: |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 806 | case BRCMF_FWS_TYPE_PENDING_TRAFFIC_BMP: |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 807 | case BRCMF_FWS_TYPE_MAC_REQUEST_PACKET: |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 808 | case BRCMF_FWS_TYPE_HOST_REORDER_RXPKTS: |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 809 | case BRCMF_FWS_TYPE_COMP_TXSTATUS: |
Arend van Spriel | ce814c1 | 2013-04-03 12:40:31 +0200 | [diff] [blame] | 810 | break; |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 811 | case BRCMF_FWS_TYPE_MACDESC_ADD: |
| 812 | case BRCMF_FWS_TYPE_MACDESC_DEL: |
Arend van Spriel | ce814c1 | 2013-04-03 12:40:31 +0200 | [diff] [blame] | 813 | brcmf_fws_macdesc_indicate(fws, type, data); |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 814 | break; |
| 815 | case BRCMF_FWS_TYPE_RSSI: |
| 816 | brcmf_fws_rssi_indicate(fws, *data); |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 817 | break; |
| 818 | case BRCMF_FWS_TYPE_TRANS_ID: |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 819 | brcmf_fws_dbg_seqnum_check(fws, data); |
| 820 | break; |
Arend van Spriel | 349e710 | 2013-03-03 12:45:28 +0100 | [diff] [blame] | 821 | default: |
| 822 | fws->stats.tlv_invalid_type++; |
| 823 | break; |
| 824 | } |
| 825 | |
| 826 | signal_data += len + 2; |
| 827 | data_len -= len + 2; |
| 828 | } |
| 829 | |
| 830 | if (data_len != 0) |
| 831 | fws->stats.tlv_parse_failed++; |
| 832 | |
| 833 | /* signalling processing result does |
| 834 | * not affect the actual ethernet packet. |
| 835 | */ |
| 836 | skb_pull(skb, signal_len); |
| 837 | |
| 838 | /* this may be a signal-only packet |
| 839 | */ |
| 840 | if (skb->len == 0) |
| 841 | fws->stats.header_only_pkt++; |
| 842 | |
| 843 | brcmf_fws_unlock(drvr, flags); |
| 844 | return 0; |
| 845 | } |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 846 | |
| 847 | void brcmf_fws_reset_interface(struct brcmf_if *ifp) |
| 848 | { |
| 849 | struct brcmf_fws_mac_descriptor *entry = ifp->fws_desc; |
| 850 | |
| 851 | brcmf_dbg(TRACE, "enter: idx=%d\n", ifp->bssidx); |
| 852 | if (!entry) |
| 853 | return; |
| 854 | |
Arend van Spriel | ce814c1 | 2013-04-03 12:40:31 +0200 | [diff] [blame] | 855 | brcmf_fws_init_mac_descriptor(entry, ifp->mac_addr, ifp->ifidx); |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | void brcmf_fws_add_interface(struct brcmf_if *ifp) |
| 859 | { |
| 860 | struct brcmf_fws_mac_descriptor *entry; |
| 861 | |
| 862 | brcmf_dbg(TRACE, "enter: idx=%d, mac=%pM\n", |
| 863 | ifp->bssidx, ifp->mac_addr); |
| 864 | if (!ifp->drvr->fw_signals) |
| 865 | return; |
| 866 | |
| 867 | entry = kzalloc(sizeof(*entry), GFP_ATOMIC); |
| 868 | if (entry) { |
| 869 | ifp->fws_desc = entry; |
Arend van Spriel | ce814c1 | 2013-04-03 12:40:31 +0200 | [diff] [blame] | 870 | brcmf_fws_init_mac_descriptor(entry, ifp->mac_addr, ifp->ifidx); |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 871 | brcmu_pktq_init(&entry->psq, BRCMF_FWS_PSQ_PREC_COUNT, |
| 872 | BRCMF_FWS_PSQ_LEN); |
| 873 | } else { |
| 874 | brcmf_err("no firmware signalling\n"); |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | void brcmf_fws_del_interface(struct brcmf_if *ifp) |
| 879 | { |
| 880 | struct brcmf_fws_mac_descriptor *entry = ifp->fws_desc; |
| 881 | |
| 882 | brcmf_dbg(TRACE, "enter: idx=%d\n", ifp->bssidx); |
| 883 | if (!entry) |
| 884 | return; |
| 885 | |
| 886 | ifp->fws_desc = NULL; |
Arend van Spriel | ce814c1 | 2013-04-03 12:40:31 +0200 | [diff] [blame] | 887 | brcmf_fws_clear_mac_descriptor(entry); |
Arend van Spriel | a3e993c | 2013-04-03 12:40:36 +0200 | [diff] [blame] | 888 | brcmf_fws_cleanup(ifp->drvr->fws, ifp->ifidx); |
Arend van Spriel | bb8c806 | 2013-04-03 12:40:30 +0200 | [diff] [blame] | 889 | kfree(entry); |
| 890 | } |