Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
main.h
Go to the documentation of this file.
1 /*
2  * Marvell Wireless LAN device driver: major data structures and prototypes
3  *
4  * Copyright (C) 2011, Marvell International Ltd.
5  *
6  * This software file (the "File") is distributed by Marvell International
7  * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8  * (the "License"). You may use, redistribute and/or modify this File in
9  * accordance with the terms and conditions of the License, a copy of which
10  * is available by writing to the Free Software Foundation, Inc.,
11  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12  * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13  *
14  * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16  * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17  * this warranty disclaimer.
18  */
19 
20 #ifndef _MWIFIEX_MAIN_H_
21 #define _MWIFIEX_MAIN_H_
22 
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/sched.h>
26 #include <linux/semaphore.h>
27 #include <linux/ip.h>
28 #include <linux/skbuff.h>
29 #include <linux/if_arp.h>
30 #include <linux/etherdevice.h>
31 #include <net/sock.h>
32 #include <net/lib80211.h>
33 #include <linux/firmware.h>
34 #include <linux/ctype.h>
35 
36 #include "decl.h"
37 #include "ioctl.h"
38 #include "util.h"
39 #include "fw.h"
40 #include "pcie.h"
41 
42 extern const char driver_version[];
43 
44 enum {
47 };
48 
49 #define MWIFIEX_MAX_AP 64
50 
51 #define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT (5 * HZ)
52 
53 #define MWIFIEX_TIMER_10S 10000
54 #define MWIFIEX_TIMER_1S 1000
55 
56 #define MAX_TX_PENDING 100
57 #define LOW_TX_PENDING 80
58 
59 #define MWIFIEX_UPLD_SIZE (2312)
60 
61 #define MAX_EVENT_SIZE 1024
62 
63 #define ARP_FILTER_MAX_BUF_SIZE 68
64 
65 #define MWIFIEX_KEY_BUFFER_SIZE 16
66 #define MWIFIEX_DEFAULT_LISTEN_INTERVAL 10
67 #define MWIFIEX_MAX_REGION_CODE 7
68 
69 #define DEFAULT_BCN_AVG_FACTOR 8
70 #define DEFAULT_DATA_AVG_FACTOR 8
71 
72 #define FIRST_VALID_CHANNEL 0xff
73 #define DEFAULT_AD_HOC_CHANNEL 6
74 #define DEFAULT_AD_HOC_CHANNEL_A 36
75 
76 #define DEFAULT_BCN_MISS_TIMEOUT 5
77 
78 #define MAX_SCAN_BEACON_BUFFER 8000
79 
80 #define SCAN_BEACON_ENTRY_PAD 6
81 
82 #define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 110
83 #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME 30
84 #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME 30
85 
86 #define SCAN_RSSI(RSSI) (0x100 - ((u8)(RSSI)))
87 
88 #define MWIFIEX_MAX_TOTAL_SCAN_TIME (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
89 
90 #define MWIFIEX_MAX_SCAN_DELAY_CNT 50
91 #define MWIFIEX_MAX_EMPTY_TX_Q_CNT 10
92 #define MWIFIEX_SCAN_DELAY_MSEC 20
93 
94 #define MWIFIEX_MIN_TX_PENDING_TO_CANCEL_SCAN 2
95 
96 #define RSN_GTK_OUI_OFFSET 2
97 
98 #define MWIFIEX_OUI_NOT_PRESENT 0
99 #define MWIFIEX_OUI_PRESENT 1
100 
101 #define PKT_TYPE_MGMT 0xE5
102 
103 /*
104  * Do not check for data_received for USB, as data_received
105  * is handled in mwifiex_usb_recv for USB
106  */
107 #define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
108  adapter->event_received || \
109  ((adapter->iface_type != MWIFIEX_USB) && \
110  adapter->data_received) || \
111  ((adapter->iface_type == MWIFIEX_USB) && \
112  !skb_queue_empty(&adapter->usb_rx_data_q)))
113 
114 #define MWIFIEX_TYPE_CMD 1
115 #define MWIFIEX_TYPE_DATA 0
116 #define MWIFIEX_TYPE_EVENT 3
117 
118 #define DBG_CMD_NUM 5
119 
120 #define MAX_BITMAP_RATES_SIZE 10
121 
122 #define MAX_CHANNEL_BAND_BG 14
123 #define MAX_CHANNEL_BAND_A 165
124 
125 #define MAX_FREQUENCY_BAND_BG 2484
126 
127 #define MWIFIEX_EVENT_HEADER_LEN 4
128 #define MWIFIEX_UAP_EVENT_EXTRA_HEADER 2
129 
130 #define MWIFIEX_TYPE_LEN 4
131 #define MWIFIEX_USB_TYPE_CMD 0xF00DFACE
132 #define MWIFIEX_USB_TYPE_DATA 0xBEADC0DE
133 #define MWIFIEX_USB_TYPE_EVENT 0xBEEFFACE
134 
135 struct mwifiex_dbg {
156 };
157 
166 };
167 
171 };
172 
175 };
176 
182 };
183 
188 };
189 
194 };
195 
200 };
201 
203  struct list_head list;
211 };
212 
215  /* spin lock for tid table */
218 };
219 
220 #define WMM_HIGHEST_PRIORITY 7
221 #define HIGH_PRIO_TID 7
222 #define LOW_PRIO_TID 0
223 #define NO_PKT_PRIO_TID (-1)
224 
228  /* spin lock to protect ra_list */
235  /* Number of transmit packets queued */
237  /* Tracks highest priority with a packet queued */
239 };
240 
250 };
251 
255 } __packed;
256 
260 } __packed;
261 
265 } __packed;
266 
279  /* Network band.
280  * BAND_B(0x01): 'b' band
281  * BAND_G(0x02): 'g' band
282  * BAND_A(0X04): 'a' band
283  */
308 };
309 
317 };
318 
326 };
327 
331 };
332 
338 };
339 
340 #define MAX_REGION_CHANNEL_NUM 2
341 
347 };
348 
352 };
353 
354 #define MWIFIEX_MAX_TRIPLET_802_11D 83
355 
361 };
362 
367 };
368 
369 struct wps {
371 };
372 
377 };
378 
379 struct mwifiex_adapter;
380 struct mwifiex_private;
381 
433  u8 wpa_ie[256];
437  u8 wapi_ie[256];
446  /* spin lock for associated station list */
449  /* spin lock for tx_ba_stream_tbl_ptr queue */
455  /* spin lock for rx_reorder_tbl_ptr queue */
457  /* spin lock for Rx packets */
459 
460 #define MWIFIEX_ASSOC_RSP_BUF_SIZE 500
463 
464 #define MWIFIEX_GENIE_BUF_SIZE 256
467 
469 
470 #define MWIFIEX_ASSOC_TLV_BUF_SIZE 256
473 
476  /* spin lock for beacon buffer */
480  char version_str[128];
481 #ifdef CONFIG_DEBUG_FS
482  struct dentry *dfs_dev_dir;
483 #endif
492  struct wps wps;
507 };
508 
513 };
514 
516  struct list_head list;
517  int tid;
520 };
521 
523 
528 };
529 
531  struct list_head list;
532  int tid;
535  int win_size;
539 };
540 
542  struct list_head list;
544 };
545 
548  /* spin lock for bss priority */
551 };
552 
553 struct cmd_ctrl_node {
554  struct list_head list;
558  struct sk_buff *cmd_skb;
559  struct sk_buff *resp_skb;
560  void *data_buf;
562  struct sk_buff *skb;
565 };
566 
570 };
571 
572 /* This is AP specific structure which stores information
573  * about associated STA
574  */
576  struct list_head list;
583 };
584 
586  int (*init_if) (struct mwifiex_adapter *);
589  int (*prog_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
594  int (*host_to_card) (struct mwifiex_adapter *, u8, struct sk_buff *,
595  struct mwifiex_tx_param *);
596  int (*wakeup) (struct mwifiex_adapter *);
598 
599  /* Interface specific functions */
602  int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
603  int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
604  int (*data_complete) (struct mwifiex_adapter *, struct sk_buff *);
605  int (*dnld_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
606 };
607 
612  const struct firmware *firmware;
613  char fw_name[32];
614  int winner;
615  struct device *dev;
616  struct wiphy *wiphy;
621  void *card;
629  /* spin lock for init/shutdown */
631  /* spin lock for main process */
641  /* spin lock for interrupt handling */
655  /* spin lock for command */
661  /* spin lock for cmd_free_q */
664  /* spin lock for cmd_pending_q */
667  /* spin lock for scan_pending_q */
713  struct mwifiex_dbg dbg;
720  spinlock_t queue_lock; /* lock for tx queues */
728 };
729 
731 
733 
734 void mwifiex_stop_net_dev_queue(struct net_device *netdev,
735  struct mwifiex_adapter *adapter);
736 
737 void mwifiex_wake_up_net_dev_queue(struct net_device *netdev,
738  struct mwifiex_adapter *adapter);
739 
742 
744 
746 
748 
750 
751 int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
752 
753 int mwifiex_recv_packet(struct mwifiex_adapter *, struct sk_buff *skb);
754 
756  struct sk_buff *skb);
757 
759 
761  struct cmd_ctrl_node *cmd_node);
762 
764  u16 cmd_action, u32 cmd_oid, void *data_buf);
765 
767  u16 cmd_action, u32 cmd_oid, void *data_buf);
768 
769 void mwifiex_cmd_timeout_func(unsigned long function_context);
770 
772  struct mwifiex_debug_info *);
773 
778 
780  struct cmd_ctrl_node *cmd_node);
781 
783  struct cmd_ctrl_node *cmd_node,
784  u32 addtail);
785 
789  struct sk_buff *skb);
790 int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
791  struct mwifiex_tx_param *tx_param);
794  struct sk_buff *skb, int status);
799  u32);
801  struct host_cmd_ds_command *cmd,
802  u16 cmd_action, uint16_t ps_bitmap,
803  struct mwifiex_ds_auto_ds *auto_ds);
805  struct host_cmd_ds_command *resp,
806  struct mwifiex_ds_pm_cfg *pm_cfg);
809  u8 activated);
811  struct host_cmd_ds_command *resp);
813  struct sk_buff *skb);
815  u16 cmd_action, u32 cmd_oid,
816  void *data_buf, void *cmd_buf);
818  u16 cmd_action, u32 cmd_oid,
819  void *data_buf, void *cmd_buf);
820 int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
821  struct host_cmd_ds_command *resp);
823  struct sk_buff *skb);
825  struct sk_buff *skb);
827  struct sk_buff *skb);
830 struct mwifiex_sta_node *
833 void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
834 void *mwifiex_process_uap_txpd(struct mwifiex_private *, struct sk_buff *skb);
835 int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta);
837  struct mwifiex_scan_cmd_config *scan_cfg);
839  struct cmd_ctrl_node *cmd_node);
841  struct host_cmd_ds_command *resp);
842 s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2);
844  struct mwifiex_bssdescriptor *bss_desc);
846  struct host_cmd_ds_command *cmd,
847  struct mwifiex_bssdescriptor *bss_desc);
849  struct host_cmd_ds_command *resp);
854  struct cfg80211_ssid *adhoc_ssid);
856  struct mwifiex_bssdescriptor *bss_desc);
858  struct host_cmd_ds_command *cmd,
859  struct cfg80211_ssid *req_ssid);
861  struct host_cmd_ds_command *cmd,
862  struct mwifiex_bssdescriptor *bss_desc);
864  struct host_cmd_ds_command *resp);
867  u8 band, u16 channel, u32 freq);
869  u8 ht_info);
871 int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
872  u8 **buffer);
874  u8 *rates);
881  struct host_cmd_ds_command *cmd);
883  struct host_cmd_ds_command *resp);
886  struct net_device *dev);
888  struct mwifiex_uap_bss_param *bss_config,
889  struct cfg80211_ap_settings *params);
891  struct mwifiex_uap_bss_param *bss_cfg,
892  struct cfg80211_ap_settings *params);
893 void mwifiex_set_uap_rates(struct mwifiex_uap_bss_param *bss_cfg,
894  struct cfg80211_ap_settings *params);
895 
896 /*
897  * This function checks if the queuing is RA based or not.
898  */
899 static inline u8
900 mwifiex_queuing_ra_based(struct mwifiex_private *priv)
901 {
902  /*
903  * Currently we assume if we are in Infra, then DA=RA. This might not be
904  * true in the future
905  */
906  if ((priv->bss_mode == NL80211_IFTYPE_STATION) &&
908  return false;
909 
910  return true;
911 }
912 
913 /*
914  * This function copies rates.
915  */
916 static inline u32
917 mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
918 {
919  int i;
920 
921  for (i = 0; i < len && src[i]; i++, pos++) {
922  if (pos >= MWIFIEX_SUPPORTED_RATES)
923  break;
924  dest[pos] = src[i];
925  }
926 
927  return pos;
928 }
929 
930 /*
931  * This function returns the correct private structure pointer based
932  * upon the BSS type and BSS number.
933  */
934 static inline struct mwifiex_private *
935 mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
937 {
938  int i;
939 
940  for (i = 0; i < adapter->priv_num; i++) {
941  if (adapter->priv[i]) {
942  if ((adapter->priv[i]->bss_num == bss_num) &&
943  (adapter->priv[i]->bss_type == bss_type))
944  break;
945  }
946  }
947  return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
948 }
949 
950 /*
951  * This function returns the first available private structure pointer
952  * based upon the BSS role.
953  */
954 static inline struct mwifiex_private *
955 mwifiex_get_priv(struct mwifiex_adapter *adapter,
957 {
958  int i;
959 
960  for (i = 0; i < adapter->priv_num; i++) {
961  if (adapter->priv[i]) {
962  if (bss_role == MWIFIEX_BSS_ROLE_ANY ||
963  GET_BSS_ROLE(adapter->priv[i]) == bss_role)
964  break;
965  }
966  }
967 
968  return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
969 }
970 
971 /*
972  * This function returns the driver private structure of a network device.
973  */
974 static inline struct mwifiex_private *
975 mwifiex_netdev_get_priv(struct net_device *dev)
976 {
977  return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
978 }
979 
980 /*
981  * This function checks if a skb holds a management frame.
982  */
983 static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff *skb)
984 {
985  return (*(u32 *)skb->data == PKT_TYPE_MGMT);
986 }
987 
989  u32 func_init_shutdown);
990 int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8);
991 int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *);
992 
993 void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
994  int maxlen);
996  struct mwifiex_multicast_list *mcast_list);
998  struct net_device *dev);
999 int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter);
1000 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
1001  struct cfg80211_ssid *req_ssid);
1002 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
1003 int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
1004 int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
1006 int mwifiex_request_scan(struct mwifiex_private *priv,
1007  struct cfg80211_ssid *req_ssid);
1008 int mwifiex_scan_networks(struct mwifiex_private *priv,
1009  const struct mwifiex_user_scan_cfg *user_scan_in);
1010 int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
1011 
1012 int mwifiex_set_encode(struct mwifiex_private *priv, struct key_params *kp,
1013  const u8 *key, int key_len, u8 key_index,
1014  const u8 *mac_addr, int disable);
1015 
1016 int mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len);
1017 
1018 int mwifiex_get_ver_ext(struct mwifiex_private *priv);
1019 
1021  struct ieee80211_channel *chan,
1023  unsigned int duration);
1024 
1025 int mwifiex_set_bss_role(struct mwifiex_private *priv, u8 bss_role);
1026 
1027 int mwifiex_get_stats_info(struct mwifiex_private *priv,
1028  struct mwifiex_ds_get_stats *log);
1029 
1030 int mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1031  u32 reg_offset, u32 reg_value);
1032 
1033 int mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1034  u32 reg_offset, u32 *value);
1035 
1037  u8 *value);
1038 
1039 int mwifiex_set_11n_httx_cfg(struct mwifiex_private *priv, int data);
1040 
1041 int mwifiex_get_11n_httx_cfg(struct mwifiex_private *priv, int *data);
1042 
1043 int mwifiex_set_tx_rate_cfg(struct mwifiex_private *priv, int tx_rate_index);
1044 
1045 int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index);
1046 
1047 int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode);
1048 
1050  char *version, int max_len);
1051 
1052 int mwifiex_set_tx_power(struct mwifiex_private *priv,
1053  struct mwifiex_power_cfg *power_cfg);
1054 
1056 
1057 int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb);
1058 
1060  struct mwifiex_bss_info *);
1062  struct cfg80211_bss *bss,
1063  struct mwifiex_bssdescriptor *bss_desc);
1065  struct mwifiex_bssdescriptor *bss_entry);
1067  struct mwifiex_bssdescriptor *bss_desc);
1068 
1070 
1072  const char *name,
1073  enum nl80211_iftype type,
1074  u32 *flags,
1075  struct vif_params *params);
1076 int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev);
1077 
1079 
1080 int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
1081  struct cfg80211_beacon_data *data);
1082 int mwifiex_del_mgmt_ies(struct mwifiex_private *priv);
1084 
1085 #ifdef CONFIG_DEBUG_FS
1086 void mwifiex_debugfs_init(void);
1087 void mwifiex_debugfs_remove(void);
1088 
1089 void mwifiex_dev_debugfs_init(struct mwifiex_private *priv);
1090 void mwifiex_dev_debugfs_remove(struct mwifiex_private *priv);
1091 #endif
1092 #endif /* !_MWIFIEX_MAIN_H_ */