1 /*
2 * Common define of private data for XRadio drivers
3 *
4 * Copyright (c) 2013
5 * Xradio Technology Co., Ltd. <www.xradiotech.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12 #ifndef XRADIO_H
13 #define XRADIO_H
14
15 #include <linux/wait.h>
16 #include <linux/mutex.h>
17 #include <linux/workqueue.h>
18 #include <linux/sched.h>
19 #include <linux/atomic.h>
20 #include <net/mac80211.h>
21 #include <asm/bitops.h>
22 #include <linux/version.h>
23
24
25 /*Macroses for Driver parameters.*/
26 #define XRWL_MAX_QUEUE_SZ (128)
27 #define AC_QUEUE_NUM 4
28
29 #ifdef P2P_MULTIVIF
30 #define XRWL_MAX_VIFS (3)
31 #else
32 #define XRWL_MAX_VIFS (2)
33 #endif
34 #define XRWL_GENERIC_IF_ID (2)
35 /* (XRWL_MAX_QUEUE_SZ/(XRWL_MAX_VIFS-1))*0.9 */
36 #define XRWL_HOST_VIF0_11N_THROTTLE (58)
37 /* (XRWL_MAX_QUEUE_SZ/(XRWL_MAX_VIFS-1))*0.9 */
38 #define XRWL_HOST_VIF1_11N_THROTTLE (58)
39 /* XRWL_HOST_VIF0_11N_THROTTLE*0.6 = 35 */
40 #define XRWL_HOST_VIF0_11BG_THROTTLE (35)
41 /* XRWL_HOST_VIF0_11N_THROTTLE*0.6 = 35 */
42 #define XRWL_HOST_VIF1_11BG_THROTTLE (35)
43
44 #if 0
45 #define XRWL_FW_VIF0_THROTTLE (15)
46 #define XRWL_FW_VIF1_THROTTLE (15)
47 #endif
48
49 #ifdef SUPPORT_HT40
50
51 #define MAX_RATES_STAGE 6
52
53 #else
54
55 #define MAX_RATES_STAGE 8
56
57 #endif
58
59 #define MAX_RATES_RETRY 15
60
61 #define IEEE80211_FCTL_WEP 0x4000
62 #define IEEE80211_QOS_DATAGRP 0x0080
63 #define WSM_KEY_MAX_IDX 20
64
65 #ifdef BH_PROC_THREAD
66 /*process tx in proc thread*/
67 #define BH_PROC_TX 1
68 /*process rx in proc thread*/
69 #define BH_PROC_RX 1
70 /*Dynamic priority adjust*/
71 #define BH_PROC_DPA 0
72 #else
73 #define BH_PROC_TX 0
74 #define BH_PROC_RX 0
75 #define BH_PROC_DPA 0
76 #endif
77
78 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
79 #include <uapi/linux/time.h>
80 #include <linux/timekeeping.h>
81 #include <linux/timekeeping32.h>
82
83 void xr_do_gettimeofday(struct timespec64 *tv);
84 void xr_get_monotonic_boottime(struct timespec64 *ts);
85
86 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) */
87
88 #include "common.h"
89 #include "queue.h"
90 #include "wsm.h"
91 #include "scan.h"
92 #include "txrx.h"
93 #include "bh.h"
94 #include "ht.h"
95 #include "pm.h"
96 #include "fwio.h"
97 #ifdef CONFIG_XRADIO_TESTMODE
98 #include "nl80211_testmode_msg_copy.h"
99 #endif /*CONFIG_XRADIO_TESTMODE*/
100 #ifdef CONFIG_XRADIO_ETF
101 #include "etf.h"
102 #endif
103
104 /* #define ROC_DEBUG */
105 /* hidden ssid is only supported when separate probe resp IE
106 configuration is supported */
107 #ifdef PROBE_RESP_EXTRA_IE
108 #define HIDDEN_SSID 1
109 #endif
110
111 #define XRADIO_MAX_CTRL_FRAME_LEN (0x1000)
112
113 #define MAX_STA_IN_AP_MODE (14)
114 #define WLAN_LINK_ID_MAX (MAX_STA_IN_AP_MODE + 3)
115
116 #define XRADIO_MAX_STA_IN_AP_MODE (5)
117 #define XRADIO_MAX_REQUEUE_ATTEMPTS (5)
118 #define XRADIO_LINK_ID_UNMAPPED (15)
119 #define XRADIO_MAX_TID (8)
120
121 #define XRADIO_TX_BLOCK_ACK_ENABLED_FOR_ALL_TID (0x3F)
122 #define XRADIO_RX_BLOCK_ACK_ENABLED_FOR_ALL_TID (0x3F)
123 #define XRADIO_RX_BLOCK_ACK_ENABLED_FOR_BE_TID \
124 (XRADIO_TX_BLOCK_ACK_ENABLED_FOR_ALL_TID & 0x01)
125 #define XRADIO_TX_BLOCK_ACK_DISABLED_FOR_ALL_TID (0)
126 #define XRADIO_RX_BLOCK_ACK_DISABLED_FOR_ALL_TID (0)
127
128 #define XRADIO_BLOCK_ACK_CNT (30)
129 #define XRADIO_BLOCK_ACK_THLD (800)
130 #define XRADIO_BLOCK_ACK_HIST (3)
131 #define XRADIO_BLOCK_ACK_INTERVAL (1 * HZ / XRADIO_BLOCK_ACK_HIST)
132 #define XRWL_ALL_IFS (-1)
133
134 #ifdef ROAM_OFFLOAD
135 #define XRADIO_SCAN_TYPE_ACTIVE 0x1000
136 #define XRADIO_SCAN_BAND_5G 0x2000
137 #endif /*ROAM_OFFLOAD*/
138
139 #define IEEE80211_FCTL_WEP 0x4000
140 #define IEEE80211_QOS_DATAGRP 0x0080
141 #ifdef CONFIG_XRADIO_TESTMODE
142 #define XRADIO_SCAN_MEASUREMENT_PASSIVE (0)
143 #define XRADIO_SCAN_MEASUREMENT_ACTIVE (1)
144 #endif
145
146 #ifdef MCAST_FWDING
147 #define WSM_MAX_BUF 30
148 #endif
149
150 #define XRADIO_PLAT_DEVICE "xradio_device"
151 #define XRADIO_WORKQUEUE "xradio_wq"
152 #define XRADIO_SPARE_WORKQUEUE "xradio_spare_wq"
153 #define WIFI_CONF_PATH "/data/vendor/wifi/xr_wifi.conf"
154 #define XRADIO_HWINFO_FILE "/data/vendor/wifi/hwinfo.bin"
155
156 extern char *drv_version;
157 extern char *drv_buildtime;
158 #define DRV_VERSION drv_version
159 #define DRV_BUILDTIME drv_buildtime
160
161 /* extern */ struct sbus_ops;
162 /* extern */ struct task_struct;
163 /* extern */ struct xradio_debug_priv;
164 /* extern */ struct xradio_debug_common;
165 /* extern */ struct firmware;
166
167 /* Please keep order */
168 enum xradio_join_status {
169 XRADIO_JOIN_STATUS_PASSIVE = 0,
170 XRADIO_JOIN_STATUS_MONITOR,
171 XRADIO_JOIN_STATUS_STA,
172 XRADIO_JOIN_STATUS_AP,
173 };
174
175 enum xradio_link_status {
176 XRADIO_LINK_OFF,
177 XRADIO_LINK_RESERVE,
178 XRADIO_LINK_SOFT,
179 XRADIO_LINK_HARD,
180 #if defined(CONFIG_XRADIO_USE_EXTENSIONS)
181 XRADIO_LINK_RESET,
182 XRADIO_LINK_RESET_REMAP,
183 #endif
184 };
185
186 enum xradio_bss_loss_status {
187 XRADIO_BSS_LOSS_NONE,
188 XRADIO_BSS_LOSS_CHECKING,
189 XRADIO_BSS_LOSS_CONFIRMING,
190 XRADIO_BSS_LOSS_CONFIRMED,
191 };
192
193 struct xradio_link_entry {
194 unsigned long timestamp;
195 enum xradio_link_status status;
196 #if defined(CONFIG_XRADIO_USE_EXTENSIONS)
197 enum xradio_link_status prev_status;
198 #endif
199 u8 mac[ETH_ALEN];
200 u8 buffered[XRADIO_MAX_TID];
201 struct sk_buff_head rx_queue;
202 };
203
204 #if defined(ROAM_OFFLOAD) || defined(CONFIG_XRADIO_TESTMODE)
205 struct xradio_testframe {
206 u8 len;
207 u8 *data;
208 };
209 #endif
210 #ifdef CONFIG_XRADIO_TESTMODE
211 struct advance_scan_elems {
212 u8 scanMode;
213 u16 duration;
214 };
215 /**
216 * xradio_tsm_info - Keeps information about ongoing TSM collection
217 * @ac: Access category for which metrics to be collected
218 * @use_rx_roaming: Use received voice packets to compute roam delay
219 * @sta_associated: Set to 1 after association
220 * @sta_roamed: Set to 1 after successful roaming
221 * @roam_delay: Roam delay
222 * @rx_timestamp_vo: Timestamp of received voice packet
223 * @txconf_timestamp_vo: Timestamp of received tx confirmation for
224 * successfully transmitted VO packet
225 * @sum_pkt_q_delay: Sum of packet queue delay
226 * @sum_media_delay: Sum of media delay
227 *
228 */
229 struct xradio_tsm_info {
230 u8 ac;
231 u8 use_rx_roaming;
232 u8 sta_associated;
233 u8 sta_roamed;
234 u16 roam_delay;
235 u32 rx_timestamp_vo;
236 u32 txconf_timestamp_vo;
237 u32 sum_pkt_q_delay;
238 u32 sum_media_delay;
239 };
240
241 /**
242 * xradio_start_stop_tsm - To start or stop collecting TSM metrics in
243 * xradio driver
244 * @start: To start or stop collecting TSM metrics
245 * @up: up for which metrics to be collected
246 * @packetization_delay: Packetization delay for this TID
247 *
248 */
249 struct xradio_start_stop_tsm {
250 u8 start; /*1: To start, 0: To stop*/
251 u8 up;
252 u16 packetization_delay;
253 };
254
255 #endif /* CONFIG_XRADIO_TESTMODE */
256 struct xradio_common {
257 struct xradio_debug_common *debug;
258 struct xradio_queue tx_queue[AC_QUEUE_NUM];
259 struct xradio_queue_stats tx_queue_stats;
260
261 struct platform_device *plat_device;
262 struct ieee80211_hw *hw;
263 /*
264 * 0 for sta or ap
265 * 1 for p2p device
266 * 2 for p2p interface
267 */
268 struct mac_address addresses[XRWL_MAX_VIFS];
269
270 /*Will be a pointer to a list of VIFs - Dynamically allocated */
271 struct ieee80211_vif *vif_list[XRWL_MAX_VIFS];
272 atomic_t num_vifs;
273 spinlock_t vif_list_lock;
274 u32 if_id_slot;
275 struct device *pdev;
276 struct workqueue_struct *workqueue;
277
278 struct semaphore conf_lock;
279
280 /* some works can not push into a same workqueue, so create a
281 * spare workqueue to separate them.
282 */
283 struct workqueue_struct *spare_workqueue;
284
285 const struct sbus_ops *sbus_ops;
286 struct sbus_priv *sbus_priv;
287 int driver_ready;
288
289 /* HW/FW type (HIF_...) */
290 int hw_type;
291 int hw_revision;
292 int fw_revision;
293
294 /* firmware/hardware info */
295 unsigned int tx_hdr_len;
296
297 /* Radio data */
298 int output_power;
299 int noise;
300
301 /* calibration, output power limit and rssi<->dBm conversation data */
302
303 /* BBP/MAC state */
304 const struct firmware *sdd;
305 struct ieee80211_rate *rates;
306 struct ieee80211_rate *mcs_rates;
307 u8 mac_addr[ETH_ALEN];
308 /*TODO:COMBO: To be made per VIFF after mac80211 support */
309 struct ieee80211_channel *channel;
310 int channel_switch_in_progress;
311 wait_queue_head_t channel_switch_done;
312 u8 channel_changed;
313 u8 long_frame_max_tx_count;
314 u8 short_frame_max_tx_count;
315 /* TODO:COMBO: According to Hong aggregation will happen per VIFF.
316 * Keeping in common structure for the time being. Will be moved to VIFF
317 * after the mechanism is clear */
318 u8 ba_tid_mask;
319 int ba_acc; /*TODO: Same as above */
320 int ba_cnt; /*TODO: Same as above */
321 int ba_cnt_rx; /*TODO: Same as above */
322 int ba_acc_rx; /*TODO: Same as above */
323 int ba_hist; /*TODO: Same as above */
324 struct timer_list ba_timer;/*TODO: Same as above */
325 spinlock_t ba_lock; /*TODO: Same as above */
326 bool ba_ena; /*TODO: Same as above */
327 struct work_struct ba_work; /*TODO: Same as above */
328 #ifdef CONFIG_PM
329 struct xradio_pm_state pm_state;
330 #endif
331 /* BT status*/
332 bool is_BT_Present;
333 u16 BT_active;
334 unsigned long BT_duration; /*timer jiffies*/
335 struct timer_list BT_timer;
336 bool is_go_thru_go_neg;
337 u8 conf_listen_interval;
338
339 /* BH */
340 atomic_t bh_rx;
341 atomic_t bh_tx;
342 atomic_t bh_term;
343 atomic_t bh_suspend;
344 struct task_struct *bh_thread;
345 int bh_error;
346 #ifdef BH_USE_SEMAPHORE
347 struct semaphore bh_sem;
348 atomic_t bh_wk;
349 #else
350 wait_queue_head_t bh_wq;
351 #endif
352 wait_queue_head_t bh_evt_wq;
353 #ifdef BH_PROC_THREAD
354 struct bh_proc proc;
355 #endif
356
357 int buf_id_tx; /* byte */
358 int buf_id_rx; /* byte */
359 int wsm_rx_seq; /* byte */
360 int wsm_tx_seq; /* byte */
361 int hw_bufs_used;
362 int hw_bufs_used_vif[XRWL_MAX_VIFS];
363 struct sk_buff *skb_cache;
364 struct sk_buff *skb_reserved;
365 int skb_resv_len;
366 spinlock_t cache_lock;
367 bool powersave_enabled;
368 bool device_can_sleep;
369 /* Keep xradio awake (WUP = 1) 1 second after each scan to avoid
370 * FW issue with sleeping/waking up. */
371 atomic_t recent_scan;
372 atomic_t suspend_state;
373 atomic_t suspend_lock_state;
374 wait_queue_head_t wsm_wakeup_done;
375 #ifdef HW_RESTART
376 bool exit_sync;
377 int hw_restart_work_running;
378 bool hw_restart;
379 bool hw_cant_wakeup;
380 struct work_struct hw_restart_work;
381 #endif
382
383 /* WSM */
384 struct wsm_caps wsm_caps;
385 struct semaphore wsm_cmd_sema;
386 struct wsm_buf wsm_cmd_buf;
387 struct wsm_cmd wsm_cmd;
388 wait_queue_head_t wsm_cmd_wq;
389 wait_queue_head_t wsm_startup_done;
390 struct wsm_cbc wsm_cbc;
391 struct semaphore tx_lock_sem;
392 atomic_t tx_lock;
393 struct semaphore dtor_lock;
394 u32 pending_frame_id;
395 #ifdef CONFIG_XRADIO_TESTMODE
396 /* Device Power Range */
397 struct wsm_tx_power_range txPowerRange[2];
398 /* Advance Scan */
399 struct advance_scan_elems advanceScanElems;
400 bool enable_advance_scan;
401 struct delayed_work advance_scan_timeout;
402 #endif /* CONFIG_XRADIO_TESTMODE */
403
404 /* WSM debug */
405 int wsm_enable_wsm_dumps;
406 u32 wsm_dump_max_size;
407 u32 query_packetID;
408 atomic_t query_cnt;
409 struct work_struct query_work; /* for query packet */
410
411 /* Scan status */
412 struct xradio_scan scan;
413 int scan_delay_status[XRWL_MAX_VIFS];
414 unsigned long scan_delay_time[XRWL_MAX_VIFS];
415
416 /* TX/RX */
417 unsigned long rx_timestamp;
418
419 /* WSM events */
420 spinlock_t event_queue_lock;
421 struct list_head event_queue;
422 struct work_struct event_handler;
423
424 /* TX rate policy cache */
425 struct tx_policy_cache tx_policy_cache;
426 struct work_struct tx_policy_upload_work;
427 atomic_t upload_count;
428
429 /* cryptographic engine information */
430
431 /* bit field of glowing LEDs */
432 u16 softled_state;
433
434 /* statistics */
435 struct ieee80211_low_level_stats stats;
436
437 struct xradio_ht_info ht_info;
438 int tx_burst_idx;
439
440 struct ieee80211_iface_limit if_limits1[2];
441 struct ieee80211_iface_limit if_limits2[2];
442 struct ieee80211_iface_limit if_limits3[3];
443 struct ieee80211_iface_combination if_combs[3];
444
445 struct semaphore wsm_oper_lock;
446 struct delayed_work rem_chan_timeout;
447 atomic_t remain_on_channel;
448 int roc_if_id;
449 u64 roc_cookie;
450 wait_queue_head_t offchannel_wq;
451 u16 offchannel_done;
452 u16 prev_channel;
453 int if_id_selected;
454 u32 key_map;
455 struct wsm_add_key keys[WSM_KEY_MAX_INDEX + 1];
456 #ifdef MCAST_FWDING
457 struct wsm_buf wsm_release_buf;
458 u8 buf_released;
459 #endif
460 #ifdef ROAM_OFFLOAD
461 u8 auto_scanning;
462 u8 frame_rcvd;
463 u8 num_scanchannels;
464 u8 num_2g_channels;
465 u8 num_5g_channels;
466 struct wsm_scan_ch scan_channels[48];
467 struct sk_buff *beacon;
468 struct sk_buff *beacon_bkp;
469 struct xradio_testframe testframe;
470 #endif /*ROAM_OFFLOAD*/
471 #ifdef CONFIG_XRADIO_TESTMODE
472 struct xradio_testframe test_frame;
473 struct xr_tsm_stats tsm_stats;
474 struct xradio_tsm_info tsm_info;
475 spinlock_t tsm_lock;
476 struct xradio_start_stop_tsm start_stop_tsm;
477 #endif /* CONFIG_XRADIO_TESTMODE */
478 u8 connected_sta_cnt;
479 u16 vif0_throttle;
480 u16 vif1_throttle;
481 #ifdef MONITOR_MODE
482 int monitor_if_id;
483 bool monitor_running;
484 #endif
485 #ifdef BOOT_NOT_READY_FIX
486 u8 boot_not_ready_cnt;
487 u8 boot_not_ready;
488 #endif
489 u8 join_chan;
490 };
491
492 /* Virtual Interface State. One copy per VIF */
493 struct xradio_vif {
494 atomic_t enabled;
495 spinlock_t vif_lock;
496 int if_id;
497 /*TODO: Split into Common and VIF parts */
498 struct xradio_debug_priv *debug;
499 /* BBP/MAC state */
500 u8 bssid[ETH_ALEN];
501 struct wsm_edca_params edca;
502 struct wsm_tx_queue_params tx_queue_params;
503 struct wsm_association_mode association_mode;
504 struct wsm_set_bss_params bss_params;
505 struct wsm_set_pm powersave_mode;
506 struct wsm_set_pm firmware_ps_mode;
507 int power_set_true;
508 int user_power_set_true;
509 u8 user_pm_mode;
510 int cqm_rssi_thold;
511 unsigned cqm_rssi_hyst;
512 unsigned cqm_tx_failure_thold;
513 unsigned cqm_tx_failure_count;
514 bool cqm_use_rssi;
515 int cqm_link_loss_count;
516 int cqm_beacon_loss_count;
517 int mode;
518 bool enable_beacon;
519 int beacon_int;
520 size_t ssid_length;
521 u8 ssid[IEEE80211_MAX_SSID_LEN];
522 #ifdef HIDDEN_SSID
523 bool hidden_ssid;
524 #endif
525 bool listening;
526 struct wsm_rx_filter rx_filter;
527 struct wsm_beacon_filter_table bf_table;
528 struct wsm_beacon_filter_control bf_control;
529 struct wsm_multicast_filter multicast_filter;
530 bool has_multicast_subscription;
531 struct wsm_broadcast_addr_filter broadcast_filter;
532 bool disable_beacon_filter;
533 struct wsm_arp_ipv4_filter filter4;
534 #ifdef IPV6_FILTERING
535 struct wsm_ndp_ipv6_filter filter6;
536 #endif /*IPV6_FILTERING*/
537 struct work_struct update_filtering_work;
538 struct work_struct set_beacon_wakeup_period_work;
539 #ifdef CONFIG_PM
540 struct xradio_pm_state_vif pm_state_vif;
541 #endif
542 /*TODO: Add support in mac80211 for psmode info per VIF */
543 struct wsm_p2p_ps_modeinfo p2p_ps_modeinfo;
544 struct wsm_uapsd_info uapsd_info;
545 bool setbssparams_done;
546 u32 listen_interval;
547 u32 erp_info;
548 bool powersave_enabled;
549
550 /* WSM Join */
551 enum xradio_join_status join_status;
552 u8 join_bssid[ETH_ALEN];
553 struct work_struct join_work;
554 struct delayed_work join_timeout;
555 struct work_struct unjoin_work;
556 struct delayed_work unjoin_delayed_work;
557 struct work_struct offchannel_work;
558 int join_dtim_period;
559 atomic_t delayed_unjoin;
560
561 /* Security */
562 s8 wep_default_key_id;
563 struct work_struct wep_key_work;
564 unsigned long rx_timestamp;
565 u32 unicast_cipher_type;
566
567
568 /* AP powersave */
569 u32 link_id_map;
570 u32 max_sta_ap_mode;
571 u32 link_id_after_dtim;
572 u32 link_id_uapsd;
573 u32 link_id_max;
574 u32 wsm_key_max_idx;
575 struct xradio_link_entry link_id_db[MAX_STA_IN_AP_MODE];
576 struct work_struct link_id_work;
577 struct delayed_work link_id_gc_work;
578 u32 sta_asleep_mask;
579 u32 pspoll_mask;
580 bool aid0_bit_set;
581 spinlock_t ps_state_lock;
582 bool buffered_multicasts;
583 bool tx_multicast;
584 u8 last_tim[8]; /*for softap dtim*/
585 struct work_struct set_tim_work;
586 struct delayed_work set_cts_work;
587 struct work_struct multicast_start_work;
588 struct work_struct multicast_stop_work;
589 struct timer_list mcast_timeout;
590
591 /* CQM Implementation */
592 struct delayed_work bss_loss_work;
593 struct delayed_work connection_loss_work;
594 struct work_struct tx_failure_work;
595 int delayed_link_loss;
596 spinlock_t bss_loss_lock;
597 int bss_loss_status;
598 int bss_loss_confirm_id;
599
600 struct ieee80211_vif *vif;
601 struct xradio_common *hw_priv;
602 struct ieee80211_hw *hw;
603
604 /* ROC implementation */
605 struct delayed_work pending_offchanneltx_work;
606 #if defined(CONFIG_XRADIO_USE_EXTENSIONS)
607 /* Workaround for WFD testcase 6.1.10*/
608 struct work_struct linkid_reset_work;
609 u8 action_frame_sa[ETH_ALEN];
610 u8 action_linkid;
611 #endif
612 /* Some optimizations for tx rate build.*/
613 u32 base_rates;
614 u32 oper_rates;
615
616 bool htcap;
617 #ifdef AP_HT_CAP_UPDATE
618 u16 ht_info;
619 struct work_struct ht_info_update_work;
620 #endif
621
622 #ifdef AP_HT_COMPAT_FIX
623 u16 ht_compat_cnt;
624 u16 ht_compat_det;
625 #endif
626
627 #ifdef AP_ARP_COMPAT_FIX
628 u16 arp_compat_cnt;
629 #endif
630 bool is_mfp_connect;
631 };
632 struct xradio_sta_priv {
633 int link_id;
634 struct xradio_vif *priv;
635 };
636 enum xradio_data_filterid {
637 IPV4ADDR_FILTER_ID = 0,
638 #ifdef IPV6_FILTERING
639 IPV6ADDR_FILTER_ID,
640 #endif /*IPV6_FILTERING*/
641 };
642
643 #ifdef IPV6_FILTERING
644 /* IPV6 host addr info */
645 struct ipv6_addr_info {
646 u8 filter_mode;
647 u8 address_mode;
648 u16 ipv6[8];
649 };
650 #endif /*IPV6_FILTERING*/
651
652 /* Datastructure for LLC-SNAP HDR */
653 #define P80211_OUI_LEN 3
654 struct ieee80211_snap_hdr {
655 u8 dsap; /* always 0xAA */
656 u8 ssap; /* always 0xAA */
657 u8 ctrl; /* always 0x03 */
658 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
659 } __packed;
660
661
662 #ifdef TES_P2P_0002_ROC_RESTART
663 extern s32 TES_P2P_0002_roc_dur;
664 extern s32 TES_P2P_0002_roc_sec;
665 extern s32 TES_P2P_0002_roc_usec;
666 extern u32 TES_P2P_0002_packet_id;
667 extern u32 TES_P2P_0002_state;
668
669 #define TES_P2P_0002_STATE_IDLE 0x00
670 #define TES_P2P_0002_STATE_SEND_RESP 0x01
671 #define TES_P2P_0002_STATE_GET_PKTID 0x02
672 #endif
673
674 /* debug.h must be here because refer to struct xradio_vif and
675 struct xradio_common.*/
676 #include "debug.h"
677
678 /*******************************************************
679 interfaces for operations of vif.
680 ********************************************************/
681 static inline
xrwl_vifpriv_to_hwpriv(struct xradio_vif * priv)682 struct xradio_common *xrwl_vifpriv_to_hwpriv(struct xradio_vif *priv)
683 {
684 return priv->hw_priv;
685 }
686
687 static inline
xrwl_get_vif_from_ieee80211(struct ieee80211_vif * vif)688 struct xradio_vif *xrwl_get_vif_from_ieee80211(struct ieee80211_vif *vif)
689 {
690 return (struct xradio_vif *)vif->drv_priv;
691 }
692
693 static inline
xrwl_hwpriv_to_vifpriv(struct xradio_common * hw_priv,int if_id)694 struct xradio_vif *xrwl_hwpriv_to_vifpriv(struct xradio_common *hw_priv,
695 int if_id)
696 {
697 struct xradio_vif *vif;
698
699 if (SYS_WARN((-1 == if_id) || (if_id > XRWL_MAX_VIFS)))
700 return NULL;
701 /* TODO:COMBO: During scanning frames can be received
702 * on interface ID 3 */
703 spin_lock(&hw_priv->vif_list_lock);
704 if (!hw_priv->vif_list[if_id]) {
705 spin_unlock(&hw_priv->vif_list_lock);
706 return NULL;
707 }
708
709 vif = xrwl_get_vif_from_ieee80211(hw_priv->vif_list[if_id]);
710 SYS_WARN(!vif);
711 if (vif && atomic_read(&vif->enabled))
712 spin_lock(&vif->vif_lock);
713 else
714 vif = NULL;
715 spin_unlock(&hw_priv->vif_list_lock);
716 return vif;
717 }
718
719 static inline
__xrwl_hwpriv_to_vifpriv(struct xradio_common * hw_priv,int if_id)720 struct xradio_vif *__xrwl_hwpriv_to_vifpriv(struct xradio_common *hw_priv,
721 int if_id)
722 {
723 SYS_WARN((-1 == if_id) || (if_id > XRWL_MAX_VIFS));
724 /* TODO:COMBO: During scanning frames can be received
725 * on interface ID 3 */
726 if (!hw_priv->vif_list[if_id]) {
727 return NULL;
728 }
729
730 return xrwl_get_vif_from_ieee80211(hw_priv->vif_list[if_id]);
731 }
732
733 static inline
xrwl_get_activevif(struct xradio_common * hw_priv)734 struct xradio_vif *xrwl_get_activevif(struct xradio_common *hw_priv)
735 {
736 return xrwl_hwpriv_to_vifpriv(hw_priv, ffs(hw_priv->if_id_slot)-1);
737 }
738
is_hardware_xradio(struct xradio_common * hw_priv)739 static inline bool is_hardware_xradio(struct xradio_common *hw_priv)
740 {
741 return (hw_priv->hw_revision == XR829_HW_REV0);
742 }
743
xrwl_get_nr_hw_ifaces(struct xradio_common * hw_priv)744 static inline int xrwl_get_nr_hw_ifaces(struct xradio_common *hw_priv)
745 {
746 switch (hw_priv->hw_revision) {
747 case XR829_HW_REV0:
748 default:
749 return 1;
750 }
751 }
752
753 #define xradio_for_each_vif(_hw_priv, _priv, _i) \
754 for ( \
755 _i = 0; \
756 (_i < XRWL_MAX_VIFS) \
757 && ((_priv = _hw_priv->vif_list[_i] ? \
758 xrwl_get_vif_from_ieee80211(_hw_priv->vif_list[_i]) : NULL), 1); \
759 _i++ \
760 )
761
762 /*******************************************************
763 interfaces for operations of queue.
764 ********************************************************/
xradio_tx_queues_lock(struct xradio_common * hw_priv)765 static inline void xradio_tx_queues_lock(struct xradio_common *hw_priv)
766 {
767 int i;
768 for (i = 0; i < 4; ++i)
769 xradio_queue_lock(&hw_priv->tx_queue[i]);
770 }
771
xradio_tx_queues_unlock(struct xradio_common * hw_priv)772 static inline void xradio_tx_queues_unlock(struct xradio_common *hw_priv)
773 {
774 int i;
775 for (i = 0; i < 4; ++i)
776 xradio_queue_unlock(&hw_priv->tx_queue[i]);
777 }
778
779 /*******************************************************
780 interfaces for BT.
781 ********************************************************/
xradio_bt_active_bit(u8 link_type)782 static inline u16 xradio_bt_active_bit(u8 link_type)
783 {
784 if (link_type == BT_LINK_TPYE_INQUIRY)
785 return BIT(1);
786 else
787 return BIT(0);
788 }
789
xradio_bt_block_type(u8 link_type)790 static inline bool xradio_bt_block_type(u8 link_type)
791 {
792 if (link_type == BT_LINK_TPYE_INQUIRY)
793 return 1;
794 else
795 return 0;
796 }
797
xradio_is_bt_block(struct xradio_common * hw_priv)798 static inline bool xradio_is_bt_block(struct xradio_common *hw_priv)
799 {
800 return (hw_priv->BT_active &
801 xradio_bt_active_bit(BT_LINK_TPYE_INQUIRY));
802 }
803
804 #endif /* XRADIO_H */
805