Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1 | /** |
| 2 | * This file contains the major functions in WLAN |
| 3 | * driver. It includes init, exit, open, close and main |
| 4 | * thread etc.. |
| 5 | */ |
| 6 | |
Holger Schurig | a46c641 | 2007-05-25 11:32:07 -0400 | [diff] [blame] | 7 | #include <linux/moduleparam.h> |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 8 | #include <linux/delay.h> |
| 9 | #include <linux/freezer.h> |
| 10 | #include <linux/etherdevice.h> |
| 11 | #include <linux/netdevice.h> |
| 12 | #include <linux/if_arp.h> |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 13 | #include <linux/kthread.h> |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 14 | |
| 15 | #include <net/iw_handler.h> |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 16 | #include <net/ieee80211.h> |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 17 | |
| 18 | #include "host.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 19 | #include "decl.h" |
| 20 | #include "dev.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 21 | #include "wext.h" |
| 22 | #include "debugfs.h" |
| 23 | #include "assoc.h" |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 24 | #include "join.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 25 | |
Dan Williams | 7856a54 | 2007-08-03 09:43:03 -0400 | [diff] [blame] | 26 | #define DRIVER_RELEASE_VERSION "323.p0" |
Dan Williams | 3ce4023 | 2007-05-10 23:03:07 -0400 | [diff] [blame] | 27 | const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION |
| 28 | #ifdef DEBUG |
| 29 | "-dbg" |
| 30 | #endif |
| 31 | ""; |
| 32 | |
Holger Schurig | a46c641 | 2007-05-25 11:32:07 -0400 | [diff] [blame] | 33 | |
| 34 | /* Module parameters */ |
| 35 | unsigned int libertas_debug = 0; |
| 36 | module_param(libertas_debug, int, 0644); |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 37 | EXPORT_SYMBOL_GPL(libertas_debug); |
Holger Schurig | a46c641 | 2007-05-25 11:32:07 -0400 | [diff] [blame] | 38 | |
| 39 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 40 | #define WLAN_TX_PWR_DEFAULT 20 /*100mW */ |
| 41 | #define WLAN_TX_PWR_US_DEFAULT 20 /*100mW */ |
| 42 | #define WLAN_TX_PWR_JP_DEFAULT 16 /*50mW */ |
| 43 | #define WLAN_TX_PWR_FR_DEFAULT 20 /*100mW */ |
| 44 | #define WLAN_TX_PWR_EMEA_DEFAULT 20 /*100mW */ |
| 45 | |
| 46 | /* Format { channel, frequency (MHz), maxtxpower } */ |
| 47 | /* band: 'B/G', region: USA FCC/Canada IC */ |
| 48 | static struct chan_freq_power channel_freq_power_US_BG[] = { |
| 49 | {1, 2412, WLAN_TX_PWR_US_DEFAULT}, |
| 50 | {2, 2417, WLAN_TX_PWR_US_DEFAULT}, |
| 51 | {3, 2422, WLAN_TX_PWR_US_DEFAULT}, |
| 52 | {4, 2427, WLAN_TX_PWR_US_DEFAULT}, |
| 53 | {5, 2432, WLAN_TX_PWR_US_DEFAULT}, |
| 54 | {6, 2437, WLAN_TX_PWR_US_DEFAULT}, |
| 55 | {7, 2442, WLAN_TX_PWR_US_DEFAULT}, |
| 56 | {8, 2447, WLAN_TX_PWR_US_DEFAULT}, |
| 57 | {9, 2452, WLAN_TX_PWR_US_DEFAULT}, |
| 58 | {10, 2457, WLAN_TX_PWR_US_DEFAULT}, |
| 59 | {11, 2462, WLAN_TX_PWR_US_DEFAULT} |
| 60 | }; |
| 61 | |
| 62 | /* band: 'B/G', region: Europe ETSI */ |
| 63 | static struct chan_freq_power channel_freq_power_EU_BG[] = { |
| 64 | {1, 2412, WLAN_TX_PWR_EMEA_DEFAULT}, |
| 65 | {2, 2417, WLAN_TX_PWR_EMEA_DEFAULT}, |
| 66 | {3, 2422, WLAN_TX_PWR_EMEA_DEFAULT}, |
| 67 | {4, 2427, WLAN_TX_PWR_EMEA_DEFAULT}, |
| 68 | {5, 2432, WLAN_TX_PWR_EMEA_DEFAULT}, |
| 69 | {6, 2437, WLAN_TX_PWR_EMEA_DEFAULT}, |
| 70 | {7, 2442, WLAN_TX_PWR_EMEA_DEFAULT}, |
| 71 | {8, 2447, WLAN_TX_PWR_EMEA_DEFAULT}, |
| 72 | {9, 2452, WLAN_TX_PWR_EMEA_DEFAULT}, |
| 73 | {10, 2457, WLAN_TX_PWR_EMEA_DEFAULT}, |
| 74 | {11, 2462, WLAN_TX_PWR_EMEA_DEFAULT}, |
| 75 | {12, 2467, WLAN_TX_PWR_EMEA_DEFAULT}, |
| 76 | {13, 2472, WLAN_TX_PWR_EMEA_DEFAULT} |
| 77 | }; |
| 78 | |
| 79 | /* band: 'B/G', region: Spain */ |
| 80 | static struct chan_freq_power channel_freq_power_SPN_BG[] = { |
| 81 | {10, 2457, WLAN_TX_PWR_DEFAULT}, |
| 82 | {11, 2462, WLAN_TX_PWR_DEFAULT} |
| 83 | }; |
| 84 | |
| 85 | /* band: 'B/G', region: France */ |
| 86 | static struct chan_freq_power channel_freq_power_FR_BG[] = { |
| 87 | {10, 2457, WLAN_TX_PWR_FR_DEFAULT}, |
| 88 | {11, 2462, WLAN_TX_PWR_FR_DEFAULT}, |
| 89 | {12, 2467, WLAN_TX_PWR_FR_DEFAULT}, |
| 90 | {13, 2472, WLAN_TX_PWR_FR_DEFAULT} |
| 91 | }; |
| 92 | |
| 93 | /* band: 'B/G', region: Japan */ |
| 94 | static struct chan_freq_power channel_freq_power_JPN_BG[] = { |
| 95 | {1, 2412, WLAN_TX_PWR_JP_DEFAULT}, |
| 96 | {2, 2417, WLAN_TX_PWR_JP_DEFAULT}, |
| 97 | {3, 2422, WLAN_TX_PWR_JP_DEFAULT}, |
| 98 | {4, 2427, WLAN_TX_PWR_JP_DEFAULT}, |
| 99 | {5, 2432, WLAN_TX_PWR_JP_DEFAULT}, |
| 100 | {6, 2437, WLAN_TX_PWR_JP_DEFAULT}, |
| 101 | {7, 2442, WLAN_TX_PWR_JP_DEFAULT}, |
| 102 | {8, 2447, WLAN_TX_PWR_JP_DEFAULT}, |
| 103 | {9, 2452, WLAN_TX_PWR_JP_DEFAULT}, |
| 104 | {10, 2457, WLAN_TX_PWR_JP_DEFAULT}, |
| 105 | {11, 2462, WLAN_TX_PWR_JP_DEFAULT}, |
| 106 | {12, 2467, WLAN_TX_PWR_JP_DEFAULT}, |
| 107 | {13, 2472, WLAN_TX_PWR_JP_DEFAULT}, |
| 108 | {14, 2484, WLAN_TX_PWR_JP_DEFAULT} |
| 109 | }; |
| 110 | |
| 111 | /** |
| 112 | * the structure for channel, frequency and power |
| 113 | */ |
| 114 | struct region_cfp_table { |
| 115 | u8 region; |
| 116 | struct chan_freq_power *cfp_BG; |
| 117 | int cfp_no_BG; |
| 118 | }; |
| 119 | |
| 120 | /** |
| 121 | * the structure for the mapping between region and CFP |
| 122 | */ |
| 123 | static struct region_cfp_table region_cfp_table[] = { |
| 124 | {0x10, /*US FCC */ |
| 125 | channel_freq_power_US_BG, |
Denis Cheng | ff8ac60 | 2007-09-02 18:30:18 +0800 | [diff] [blame] | 126 | ARRAY_SIZE(channel_freq_power_US_BG), |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 127 | } |
| 128 | , |
| 129 | {0x20, /*CANADA IC */ |
| 130 | channel_freq_power_US_BG, |
Denis Cheng | ff8ac60 | 2007-09-02 18:30:18 +0800 | [diff] [blame] | 131 | ARRAY_SIZE(channel_freq_power_US_BG), |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 132 | } |
| 133 | , |
| 134 | {0x30, /*EU*/ channel_freq_power_EU_BG, |
Denis Cheng | ff8ac60 | 2007-09-02 18:30:18 +0800 | [diff] [blame] | 135 | ARRAY_SIZE(channel_freq_power_EU_BG), |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 136 | } |
| 137 | , |
| 138 | {0x31, /*SPAIN*/ channel_freq_power_SPN_BG, |
Denis Cheng | ff8ac60 | 2007-09-02 18:30:18 +0800 | [diff] [blame] | 139 | ARRAY_SIZE(channel_freq_power_SPN_BG), |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 140 | } |
| 141 | , |
| 142 | {0x32, /*FRANCE*/ channel_freq_power_FR_BG, |
Denis Cheng | ff8ac60 | 2007-09-02 18:30:18 +0800 | [diff] [blame] | 143 | ARRAY_SIZE(channel_freq_power_FR_BG), |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 144 | } |
| 145 | , |
| 146 | {0x40, /*JAPAN*/ channel_freq_power_JPN_BG, |
Denis Cheng | ff8ac60 | 2007-09-02 18:30:18 +0800 | [diff] [blame] | 147 | ARRAY_SIZE(channel_freq_power_JPN_BG), |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 148 | } |
| 149 | , |
| 150 | /*Add new region here */ |
| 151 | }; |
| 152 | |
| 153 | /** |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 154 | * the table to keep region code |
| 155 | */ |
| 156 | u16 libertas_region_code_to_index[MRVDRV_MAX_REGION_CODE] = |
| 157 | { 0x10, 0x20, 0x30, 0x31, 0x32, 0x40 }; |
| 158 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 159 | /** |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 160 | * 802.11b/g supported bitrates (in 500Kb/s units) |
| 161 | */ |
| 162 | u8 libertas_bg_rates[MAX_RATES] = |
| 163 | { 0x02, 0x04, 0x0b, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c, |
| 164 | 0x00, 0x00 }; |
| 165 | |
| 166 | /** |
| 167 | * FW rate table. FW refers to rates by their index in this table, not by the |
| 168 | * rate value itself. Values of 0x00 are |
| 169 | * reserved positions. |
| 170 | */ |
| 171 | static u8 fw_data_rates[MAX_RATES] = |
| 172 | { 0x02, 0x04, 0x0B, 0x16, 0x00, 0x0C, 0x12, |
| 173 | 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x00 |
| 174 | }; |
| 175 | |
| 176 | /** |
| 177 | * @brief use index to get the data rate |
| 178 | * |
| 179 | * @param idx The index of data rate |
| 180 | * @return data rate or 0 |
| 181 | */ |
| 182 | u32 libertas_fw_index_to_data_rate(u8 idx) |
| 183 | { |
| 184 | if (idx >= sizeof(fw_data_rates)) |
| 185 | idx = 0; |
| 186 | return fw_data_rates[idx]; |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * @brief use rate to get the index |
| 191 | * |
| 192 | * @param rate data rate |
| 193 | * @return index or 0 |
| 194 | */ |
| 195 | u8 libertas_data_rate_to_fw_index(u32 rate) |
| 196 | { |
| 197 | u8 i; |
| 198 | |
| 199 | if (!rate) |
| 200 | return 0; |
| 201 | |
| 202 | for (i = 0; i < sizeof(fw_data_rates); i++) { |
| 203 | if (rate == fw_data_rates[i]) |
| 204 | return i; |
| 205 | } |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | /** |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 210 | * Attributes exported through sysfs |
| 211 | */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 212 | |
| 213 | /** |
Luis Carlos | 82fde74 | 2007-06-07 16:40:59 -0400 | [diff] [blame] | 214 | * @brief Get function for sysfs attribute anycast_mask |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 215 | */ |
Luis Carlos | 82fde74 | 2007-06-07 16:40:59 -0400 | [diff] [blame] | 216 | static ssize_t libertas_anycast_get(struct device * dev, |
Dan Williams | b59bb61 | 2007-06-18 11:50:43 -0400 | [diff] [blame] | 217 | struct device_attribute *attr, char * buf) |
| 218 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 219 | struct cmd_ds_mesh_access mesh_access; |
| 220 | |
| 221 | memset(&mesh_access, 0, sizeof(mesh_access)); |
| 222 | libertas_prepare_and_send_command(to_net_dev(dev)->priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 223 | CMD_MESH_ACCESS, |
| 224 | CMD_ACT_MESH_GET_ANYCAST, |
| 225 | CMD_OPTION_WAITFORRSP, 0, (void *)&mesh_access); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 226 | |
Luis Carlos | 82fde74 | 2007-06-07 16:40:59 -0400 | [diff] [blame] | 227 | return snprintf(buf, 12, "0x%X\n", le32_to_cpu(mesh_access.data[0])); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | /** |
Luis Carlos | 82fde74 | 2007-06-07 16:40:59 -0400 | [diff] [blame] | 231 | * @brief Set function for sysfs attribute anycast_mask |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 232 | */ |
Luis Carlos | 82fde74 | 2007-06-07 16:40:59 -0400 | [diff] [blame] | 233 | static ssize_t libertas_anycast_set(struct device * dev, |
Dan Williams | b59bb61 | 2007-06-18 11:50:43 -0400 | [diff] [blame] | 234 | struct device_attribute *attr, const char * buf, size_t count) |
| 235 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 236 | struct cmd_ds_mesh_access mesh_access; |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 237 | uint32_t datum; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 238 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 239 | memset(&mesh_access, 0, sizeof(mesh_access)); |
Luis Carlos | 82fde74 | 2007-06-07 16:40:59 -0400 | [diff] [blame] | 240 | sscanf(buf, "%x", &datum); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 241 | mesh_access.data[0] = cpu_to_le32(datum); |
| 242 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 243 | libertas_prepare_and_send_command((to_net_dev(dev))->priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 244 | CMD_MESH_ACCESS, |
| 245 | CMD_ACT_MESH_SET_ANYCAST, |
| 246 | CMD_OPTION_WAITFORRSP, 0, (void *)&mesh_access); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 247 | return strlen(buf); |
| 248 | } |
| 249 | |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 250 | int libertas_add_rtap(wlan_private *priv); |
| 251 | void libertas_remove_rtap(wlan_private *priv); |
| 252 | |
| 253 | /** |
| 254 | * Get function for sysfs attribute rtap |
| 255 | */ |
| 256 | static ssize_t libertas_rtap_get(struct device * dev, |
| 257 | struct device_attribute *attr, char * buf) |
| 258 | { |
Dan Williams | 64f104e | 2007-08-20 11:45:16 -0400 | [diff] [blame] | 259 | wlan_private *priv = (wlan_private *) (to_net_dev(dev))->priv; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 260 | wlan_adapter *adapter = priv->adapter; |
| 261 | return snprintf(buf, 5, "0x%X\n", adapter->monitormode); |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * Set function for sysfs attribute rtap |
| 266 | */ |
| 267 | static ssize_t libertas_rtap_set(struct device * dev, |
| 268 | struct device_attribute *attr, const char * buf, size_t count) |
| 269 | { |
| 270 | int monitor_mode; |
Dan Williams | 64f104e | 2007-08-20 11:45:16 -0400 | [diff] [blame] | 271 | wlan_private *priv = (wlan_private *) (to_net_dev(dev))->priv; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 272 | wlan_adapter *adapter = priv->adapter; |
| 273 | |
| 274 | sscanf(buf, "%x", &monitor_mode); |
| 275 | if (monitor_mode != WLAN_MONITOR_OFF) { |
| 276 | if(adapter->monitormode == monitor_mode) |
| 277 | return strlen(buf); |
| 278 | if (adapter->monitormode == WLAN_MONITOR_OFF) { |
| 279 | if (adapter->mode == IW_MODE_INFRA) |
| 280 | libertas_send_deauthentication(priv); |
| 281 | else if (adapter->mode == IW_MODE_ADHOC) |
| 282 | libertas_stop_adhoc_network(priv); |
| 283 | libertas_add_rtap(priv); |
| 284 | } |
| 285 | adapter->monitormode = monitor_mode; |
| 286 | } |
| 287 | |
| 288 | else { |
| 289 | if(adapter->monitormode == WLAN_MONITOR_OFF) |
| 290 | return strlen(buf); |
| 291 | adapter->monitormode = WLAN_MONITOR_OFF; |
| 292 | libertas_remove_rtap(priv); |
| 293 | netif_wake_queue(priv->dev); |
| 294 | netif_wake_queue(priv->mesh_dev); |
| 295 | } |
| 296 | |
| 297 | libertas_prepare_and_send_command(priv, |
| 298 | CMD_802_11_MONITOR_MODE, CMD_ACT_SET, |
| 299 | CMD_OPTION_WAITFORRSP, 0, &adapter->monitormode); |
| 300 | return strlen(buf); |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * libertas_rtap attribute to be exported per mshX interface |
| 305 | * through sysfs (/sys/class/net/mshX/libertas-rtap) |
| 306 | */ |
| 307 | static DEVICE_ATTR(libertas_rtap, 0644, libertas_rtap_get, |
| 308 | libertas_rtap_set ); |
| 309 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 310 | /** |
Luis Carlos | 82fde74 | 2007-06-07 16:40:59 -0400 | [diff] [blame] | 311 | * anycast_mask attribute to be exported per mshX interface |
| 312 | * through sysfs (/sys/class/net/mshX/anycast_mask) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 313 | */ |
Luis Carlos | 82fde74 | 2007-06-07 16:40:59 -0400 | [diff] [blame] | 314 | static DEVICE_ATTR(anycast_mask, 0644, libertas_anycast_get, libertas_anycast_set); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 315 | |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 316 | static ssize_t libertas_autostart_enabled_get(struct device * dev, |
| 317 | struct device_attribute *attr, char * buf) |
| 318 | { |
| 319 | struct cmd_ds_mesh_access mesh_access; |
| 320 | |
| 321 | memset(&mesh_access, 0, sizeof(mesh_access)); |
| 322 | libertas_prepare_and_send_command(to_net_dev(dev)->priv, |
| 323 | CMD_MESH_ACCESS, |
| 324 | CMD_ACT_MESH_GET_AUTOSTART_ENABLED, |
| 325 | CMD_OPTION_WAITFORRSP, 0, (void *)&mesh_access); |
| 326 | |
| 327 | return sprintf(buf, "%d\n", le32_to_cpu(mesh_access.data[0])); |
| 328 | } |
| 329 | |
| 330 | static ssize_t libertas_autostart_enabled_set(struct device * dev, |
| 331 | struct device_attribute *attr, const char * buf, size_t count) |
| 332 | { |
| 333 | struct cmd_ds_mesh_access mesh_access; |
| 334 | uint32_t datum; |
Luis Carlos Cobo | d21b31f | 2007-08-02 13:16:02 -0400 | [diff] [blame] | 335 | wlan_private * priv = (to_net_dev(dev))->priv; |
| 336 | int ret; |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 337 | |
| 338 | memset(&mesh_access, 0, sizeof(mesh_access)); |
| 339 | sscanf(buf, "%d", &datum); |
| 340 | mesh_access.data[0] = cpu_to_le32(datum); |
| 341 | |
Luis Carlos Cobo | d21b31f | 2007-08-02 13:16:02 -0400 | [diff] [blame] | 342 | ret = libertas_prepare_and_send_command(priv, |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 343 | CMD_MESH_ACCESS, |
| 344 | CMD_ACT_MESH_SET_AUTOSTART_ENABLED, |
| 345 | CMD_OPTION_WAITFORRSP, 0, (void *)&mesh_access); |
Luis Carlos Cobo | d21b31f | 2007-08-02 13:16:02 -0400 | [diff] [blame] | 346 | if (ret == 0) |
| 347 | priv->mesh_autostart_enabled = datum ? 1 : 0; |
| 348 | |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 349 | return strlen(buf); |
| 350 | } |
| 351 | |
| 352 | static DEVICE_ATTR(autostart_enabled, 0644, |
| 353 | libertas_autostart_enabled_get, libertas_autostart_enabled_set); |
| 354 | |
| 355 | static struct attribute *libertas_mesh_sysfs_entries[] = { |
| 356 | &dev_attr_anycast_mask.attr, |
| 357 | &dev_attr_autostart_enabled.attr, |
| 358 | NULL, |
| 359 | }; |
| 360 | |
| 361 | static struct attribute_group libertas_mesh_attr_group = { |
| 362 | .attrs = libertas_mesh_sysfs_entries, |
| 363 | }; |
| 364 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 365 | /** |
| 366 | * @brief Check if the device can be open and wait if necessary. |
| 367 | * |
| 368 | * @param dev A pointer to net_device structure |
| 369 | * @return 0 |
| 370 | * |
| 371 | * For USB adapter, on some systems the device open handler will be |
| 372 | * called before FW ready. Use the following flag check and wait |
| 373 | * function to work around the issue. |
| 374 | * |
| 375 | */ |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 376 | static int pre_open_check(struct net_device *dev) |
| 377 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 378 | wlan_private *priv = (wlan_private *) dev->priv; |
| 379 | wlan_adapter *adapter = priv->adapter; |
| 380 | int i = 0; |
| 381 | |
| 382 | while (!adapter->fw_ready && i < 20) { |
| 383 | i++; |
| 384 | msleep_interruptible(100); |
| 385 | } |
| 386 | if (!adapter->fw_ready) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 387 | lbs_pr_err("firmware not ready\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 388 | return -1; |
| 389 | } |
| 390 | |
| 391 | return 0; |
| 392 | } |
| 393 | |
| 394 | /** |
| 395 | * @brief This function opens the device |
| 396 | * |
| 397 | * @param dev A pointer to net_device structure |
| 398 | * @return 0 |
| 399 | */ |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 400 | static int libertas_dev_open(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 401 | { |
| 402 | wlan_private *priv = (wlan_private *) dev->priv; |
| 403 | wlan_adapter *adapter = priv->adapter; |
| 404 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 405 | lbs_deb_enter(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 406 | |
| 407 | priv->open = 1; |
| 408 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 409 | if (adapter->connect_status == LIBERTAS_CONNECTED) { |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 410 | netif_carrier_on(priv->dev); |
Holger Schurig | 3cf8409 | 2007-08-02 11:50:12 -0400 | [diff] [blame] | 411 | if (priv->mesh_dev) |
| 412 | netif_carrier_on(priv->mesh_dev); |
Javier Cardona | 51d84f5 | 2007-05-25 12:06:56 -0400 | [diff] [blame] | 413 | } else { |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 414 | netif_carrier_off(priv->dev); |
Holger Schurig | 3cf8409 | 2007-08-02 11:50:12 -0400 | [diff] [blame] | 415 | if (priv->mesh_dev) |
| 416 | netif_carrier_off(priv->mesh_dev); |
Javier Cardona | 51d84f5 | 2007-05-25 12:06:56 -0400 | [diff] [blame] | 417 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 418 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 419 | lbs_deb_leave(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 420 | return 0; |
| 421 | } |
| 422 | /** |
| 423 | * @brief This function opens the mshX interface |
| 424 | * |
| 425 | * @param dev A pointer to net_device structure |
| 426 | * @return 0 |
| 427 | */ |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 428 | static int libertas_mesh_open(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 429 | { |
| 430 | wlan_private *priv = (wlan_private *) dev->priv ; |
| 431 | |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 432 | if (pre_open_check(dev) == -1) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 433 | return -1; |
| 434 | priv->mesh_open = 1 ; |
Javier Cardona | 51d84f5 | 2007-05-25 12:06:56 -0400 | [diff] [blame] | 435 | netif_wake_queue(priv->mesh_dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 436 | if (priv->infra_open == 0) |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 437 | return libertas_dev_open(priv->dev) ; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 438 | return 0; |
| 439 | } |
| 440 | |
| 441 | /** |
| 442 | * @brief This function opens the ethX interface |
| 443 | * |
| 444 | * @param dev A pointer to net_device structure |
| 445 | * @return 0 |
| 446 | */ |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 447 | static int libertas_open(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 448 | { |
| 449 | wlan_private *priv = (wlan_private *) dev->priv ; |
| 450 | |
| 451 | if(pre_open_check(dev) == -1) |
| 452 | return -1; |
| 453 | priv->infra_open = 1 ; |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 454 | netif_wake_queue(priv->dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 455 | if (priv->open == 0) |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 456 | return libertas_dev_open(priv->dev) ; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 457 | return 0; |
| 458 | } |
| 459 | |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 460 | static int libertas_dev_close(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 461 | { |
| 462 | wlan_private *priv = dev->priv; |
| 463 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 464 | lbs_deb_enter(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 465 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 466 | netif_carrier_off(priv->dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 467 | priv->open = 0; |
| 468 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 469 | lbs_deb_leave(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 470 | return 0; |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * @brief This function closes the mshX interface |
| 475 | * |
| 476 | * @param dev A pointer to net_device structure |
| 477 | * @return 0 |
| 478 | */ |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 479 | static int libertas_mesh_close(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 480 | { |
| 481 | wlan_private *priv = (wlan_private *) (dev->priv); |
| 482 | |
| 483 | priv->mesh_open = 0; |
| 484 | netif_stop_queue(priv->mesh_dev); |
| 485 | if (priv->infra_open == 0) |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 486 | return libertas_dev_close(dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 487 | else |
| 488 | return 0; |
| 489 | } |
| 490 | |
| 491 | /** |
| 492 | * @brief This function closes the ethX interface |
| 493 | * |
| 494 | * @param dev A pointer to net_device structure |
| 495 | * @return 0 |
| 496 | */ |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 497 | static int libertas_close(struct net_device *dev) |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 498 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 499 | wlan_private *priv = (wlan_private *) dev->priv; |
| 500 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 501 | netif_stop_queue(dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 502 | priv->infra_open = 0; |
| 503 | if (priv->mesh_open == 0) |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 504 | return libertas_dev_close(dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 505 | else |
| 506 | return 0; |
| 507 | } |
| 508 | |
| 509 | |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 510 | static int libertas_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 511 | { |
| 512 | int ret = 0; |
| 513 | wlan_private *priv = dev->priv; |
| 514 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 515 | lbs_deb_enter(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 516 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 517 | if (priv->dnld_sent || priv->adapter->TxLockFlag) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 518 | priv->stats.tx_dropped++; |
| 519 | goto done; |
| 520 | } |
| 521 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 522 | netif_stop_queue(priv->dev); |
Holger Schurig | 3cf8409 | 2007-08-02 11:50:12 -0400 | [diff] [blame] | 523 | if (priv->mesh_dev) |
| 524 | netif_stop_queue(priv->mesh_dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 525 | |
| 526 | if (libertas_process_tx(priv, skb) == 0) |
| 527 | dev->trans_start = jiffies; |
| 528 | done: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 529 | lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 530 | return ret; |
| 531 | } |
| 532 | |
| 533 | /** |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 534 | * @brief Mark mesh packets and handover them to libertas_hard_start_xmit |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 535 | * |
| 536 | */ |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 537 | static int libertas_mesh_pre_start_xmit(struct sk_buff *skb, |
| 538 | struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 539 | { |
| 540 | wlan_private *priv = dev->priv; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 541 | int ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 542 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 543 | lbs_deb_enter(LBS_DEB_MESH); |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 544 | if(priv->adapter->monitormode != WLAN_MONITOR_OFF) { |
| 545 | netif_stop_queue(dev); |
| 546 | return -EOPNOTSUPP; |
| 547 | } |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 548 | |
| 549 | SET_MESH_FRAME(skb); |
| 550 | |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 551 | ret = libertas_hard_start_xmit(skb, priv->dev); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 552 | lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret); |
| 553 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | /** |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 557 | * @brief Mark non-mesh packets and handover them to libertas_hard_start_xmit |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 558 | * |
| 559 | */ |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 560 | static int libertas_pre_start_xmit(struct sk_buff *skb, struct net_device *dev) |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 561 | { |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 562 | wlan_private *priv = dev->priv; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 563 | int ret; |
| 564 | |
| 565 | lbs_deb_enter(LBS_DEB_NET); |
| 566 | |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 567 | if(priv->adapter->monitormode != WLAN_MONITOR_OFF) { |
| 568 | netif_stop_queue(dev); |
| 569 | return -EOPNOTSUPP; |
| 570 | } |
| 571 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 572 | UNSET_MESH_FRAME(skb); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 573 | |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 574 | ret = libertas_hard_start_xmit(skb, dev); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 575 | lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); |
| 576 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 577 | } |
| 578 | |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 579 | static void libertas_tx_timeout(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 580 | { |
| 581 | wlan_private *priv = (wlan_private *) dev->priv; |
| 582 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 583 | lbs_deb_enter(LBS_DEB_TX); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 584 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 585 | lbs_pr_err("tx watch dog timeout\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 586 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 587 | priv->dnld_sent = DNLD_RES_RECEIVED; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 588 | dev->trans_start = jiffies; |
| 589 | |
| 590 | if (priv->adapter->currenttxskb) { |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 591 | if (priv->adapter->monitormode != WLAN_MONITOR_OFF) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 592 | /* If we are here, we have not received feedback from |
| 593 | the previous packet. Assume TX_FAIL and move on. */ |
| 594 | priv->adapter->eventcause = 0x01000000; |
| 595 | libertas_send_tx_feedback(priv); |
| 596 | } else |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 597 | wake_up_interruptible(&priv->waitq); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 598 | } else if (priv->adapter->connect_status == LIBERTAS_CONNECTED) { |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 599 | netif_wake_queue(priv->dev); |
Holger Schurig | 3cf8409 | 2007-08-02 11:50:12 -0400 | [diff] [blame] | 600 | if (priv->mesh_dev) |
| 601 | netif_wake_queue(priv->mesh_dev); |
Javier Cardona | 51d84f5 | 2007-05-25 12:06:56 -0400 | [diff] [blame] | 602 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 603 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 604 | lbs_deb_leave(LBS_DEB_TX); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | /** |
| 608 | * @brief This function returns the network statistics |
| 609 | * |
| 610 | * @param dev A pointer to wlan_private structure |
| 611 | * @return A pointer to net_device_stats structure |
| 612 | */ |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 613 | static struct net_device_stats *libertas_get_stats(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 614 | { |
| 615 | wlan_private *priv = (wlan_private *) dev->priv; |
| 616 | |
| 617 | return &priv->stats; |
| 618 | } |
| 619 | |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 620 | static int libertas_set_mac_address(struct net_device *dev, void *addr) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 621 | { |
| 622 | int ret = 0; |
| 623 | wlan_private *priv = (wlan_private *) dev->priv; |
| 624 | wlan_adapter *adapter = priv->adapter; |
| 625 | struct sockaddr *phwaddr = addr; |
| 626 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 627 | lbs_deb_enter(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 628 | |
Luis Carlos Cobo Rus | 0a0d08a | 2007-05-25 23:05:27 -0400 | [diff] [blame] | 629 | /* In case it was called from the mesh device */ |
| 630 | dev = priv->dev ; |
| 631 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 632 | memset(adapter->current_addr, 0, ETH_ALEN); |
| 633 | |
| 634 | /* dev->dev_addr is 8 bytes */ |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 635 | lbs_deb_hex(LBS_DEB_NET, "dev->dev_addr", dev->dev_addr, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 636 | |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 637 | lbs_deb_hex(LBS_DEB_NET, "addr", phwaddr->sa_data, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 638 | memcpy(adapter->current_addr, phwaddr->sa_data, ETH_ALEN); |
| 639 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 640 | ret = libertas_prepare_and_send_command(priv, CMD_802_11_MAC_ADDRESS, |
| 641 | CMD_ACT_SET, |
| 642 | CMD_OPTION_WAITFORRSP, 0, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 643 | |
| 644 | if (ret) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 645 | lbs_deb_net("set MAC address failed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 646 | ret = -1; |
| 647 | goto done; |
| 648 | } |
| 649 | |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 650 | lbs_deb_hex(LBS_DEB_NET, "adapter->macaddr", adapter->current_addr, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 651 | memcpy(dev->dev_addr, adapter->current_addr, ETH_ALEN); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 652 | if (priv->mesh_dev) |
| 653 | memcpy(priv->mesh_dev->dev_addr, adapter->current_addr, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 654 | |
| 655 | done: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 656 | lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 657 | return ret; |
| 658 | } |
| 659 | |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 660 | static int libertas_copy_multicast_address(wlan_adapter * adapter, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 661 | struct net_device *dev) |
| 662 | { |
| 663 | int i = 0; |
| 664 | struct dev_mc_list *mcptr = dev->mc_list; |
| 665 | |
| 666 | for (i = 0; i < dev->mc_count; i++) { |
| 667 | memcpy(&adapter->multicastlist[i], mcptr->dmi_addr, ETH_ALEN); |
| 668 | mcptr = mcptr->next; |
| 669 | } |
| 670 | |
| 671 | return i; |
| 672 | |
| 673 | } |
| 674 | |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 675 | static void libertas_set_multicast_list(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 676 | { |
| 677 | wlan_private *priv = dev->priv; |
| 678 | wlan_adapter *adapter = priv->adapter; |
| 679 | int oldpacketfilter; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 680 | DECLARE_MAC_BUF(mac); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 681 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 682 | lbs_deb_enter(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 683 | |
| 684 | oldpacketfilter = adapter->currentpacketfilter; |
| 685 | |
| 686 | if (dev->flags & IFF_PROMISC) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 687 | lbs_deb_net("enable promiscuous mode\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 688 | adapter->currentpacketfilter |= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 689 | CMD_ACT_MAC_PROMISCUOUS_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 690 | adapter->currentpacketfilter &= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 691 | ~(CMD_ACT_MAC_ALL_MULTICAST_ENABLE | |
| 692 | CMD_ACT_MAC_MULTICAST_ENABLE); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 693 | } else { |
| 694 | /* Multicast */ |
| 695 | adapter->currentpacketfilter &= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 696 | ~CMD_ACT_MAC_PROMISCUOUS_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 697 | |
| 698 | if (dev->flags & IFF_ALLMULTI || dev->mc_count > |
| 699 | MRVDRV_MAX_MULTICAST_LIST_SIZE) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 700 | lbs_deb_net( "enabling all multicast\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 701 | adapter->currentpacketfilter |= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 702 | CMD_ACT_MAC_ALL_MULTICAST_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 703 | adapter->currentpacketfilter &= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 704 | ~CMD_ACT_MAC_MULTICAST_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 705 | } else { |
| 706 | adapter->currentpacketfilter &= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 707 | ~CMD_ACT_MAC_ALL_MULTICAST_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 708 | |
| 709 | if (!dev->mc_count) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 710 | lbs_deb_net("no multicast addresses, " |
| 711 | "disabling multicast\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 712 | adapter->currentpacketfilter &= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 713 | ~CMD_ACT_MAC_MULTICAST_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 714 | } else { |
| 715 | int i; |
| 716 | |
| 717 | adapter->currentpacketfilter |= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 718 | CMD_ACT_MAC_MULTICAST_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 719 | |
| 720 | adapter->nr_of_multicastmacaddr = |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 721 | libertas_copy_multicast_address(adapter, dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 722 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 723 | lbs_deb_net("multicast addresses: %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 724 | dev->mc_count); |
| 725 | |
| 726 | for (i = 0; i < dev->mc_count; i++) { |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 727 | lbs_deb_net("Multicast address %d:%s\n", |
| 728 | i, print_mac(mac, |
| 729 | adapter->multicastlist[i])); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 730 | } |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 731 | /* send multicast addresses to firmware */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 732 | libertas_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 733 | CMD_MAC_MULTICAST_ADR, |
| 734 | CMD_ACT_SET, 0, 0, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 735 | NULL); |
| 736 | } |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | if (adapter->currentpacketfilter != oldpacketfilter) { |
| 741 | libertas_set_mac_packet_filter(priv); |
| 742 | } |
| 743 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 744 | lbs_deb_leave(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | /** |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 748 | * @brief This function handles the major jobs in the WLAN driver. |
| 749 | * It handles all events generated by firmware, RX data received |
| 750 | * from firmware and TX data sent from kernel. |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 751 | * |
| 752 | * @param data A pointer to wlan_thread structure |
| 753 | * @return 0 |
| 754 | */ |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 755 | static int libertas_thread(void *data) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 756 | { |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 757 | struct net_device *dev = data; |
| 758 | wlan_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 759 | wlan_adapter *adapter = priv->adapter; |
| 760 | wait_queue_t wait; |
| 761 | u8 ireg = 0; |
| 762 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 763 | lbs_deb_enter(LBS_DEB_THREAD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 764 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 765 | init_waitqueue_entry(&wait, current); |
| 766 | |
Dan Williams | b1b1907 | 2007-08-20 11:10:45 -0400 | [diff] [blame] | 767 | set_freezable(); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 768 | for (;;) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 769 | lbs_deb_thread( "main-thread 111: intcounter=%d " |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 770 | "currenttxskb=%p dnld_sent=%d\n", |
| 771 | adapter->intcounter, |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 772 | adapter->currenttxskb, priv->dnld_sent); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 773 | |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 774 | add_wait_queue(&priv->waitq, &wait); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 775 | set_current_state(TASK_INTERRUPTIBLE); |
| 776 | spin_lock_irq(&adapter->driver_lock); |
| 777 | if ((adapter->psstate == PS_STATE_SLEEP) || |
| 778 | (!adapter->intcounter |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 779 | && (priv->dnld_sent || adapter->cur_cmd || |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 780 | list_empty(&adapter->cmdpendingq)))) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 781 | lbs_deb_thread( |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 782 | "main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n", |
| 783 | adapter->connect_status, adapter->intcounter, |
| 784 | adapter->psmode, adapter->psstate); |
| 785 | spin_unlock_irq(&adapter->driver_lock); |
| 786 | schedule(); |
| 787 | } else |
| 788 | spin_unlock_irq(&adapter->driver_lock); |
| 789 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 790 | lbs_deb_thread( |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 791 | "main-thread 222 (waking up): intcounter=%d currenttxskb=%p " |
| 792 | "dnld_sent=%d\n", adapter->intcounter, |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 793 | adapter->currenttxskb, priv->dnld_sent); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 794 | |
| 795 | set_current_state(TASK_RUNNING); |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 796 | remove_wait_queue(&priv->waitq, &wait); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 797 | try_to_freeze(); |
| 798 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 799 | lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p " |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 800 | "dnld_sent=%d\n", |
| 801 | adapter->intcounter, |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 802 | adapter->currenttxskb, priv->dnld_sent); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 803 | |
| 804 | if (kthread_should_stop() |
| 805 | || adapter->surpriseremoved) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 806 | lbs_deb_thread( |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 807 | "main-thread: break from main thread: surpriseremoved=0x%x\n", |
| 808 | adapter->surpriseremoved); |
| 809 | break; |
| 810 | } |
| 811 | |
| 812 | |
| 813 | spin_lock_irq(&adapter->driver_lock); |
| 814 | if (adapter->intcounter) { |
| 815 | u8 int_status; |
| 816 | adapter->intcounter = 0; |
Holger Schurig | 208fdd2 | 2007-05-25 12:17:06 -0400 | [diff] [blame] | 817 | int_status = priv->hw_get_int_status(priv, &ireg); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 818 | |
| 819 | if (int_status) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 820 | lbs_deb_thread( |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 821 | "main-thread: reading HOST_INT_STATUS_REG failed\n"); |
| 822 | spin_unlock_irq(&adapter->driver_lock); |
| 823 | continue; |
| 824 | } |
| 825 | adapter->hisregcpy |= ireg; |
| 826 | } |
| 827 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 828 | lbs_deb_thread("main-thread 444: intcounter=%d currenttxskb=%p " |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 829 | "dnld_sent=%d\n", |
| 830 | adapter->intcounter, |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 831 | adapter->currenttxskb, priv->dnld_sent); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 832 | |
| 833 | /* command response? */ |
Holger Schurig | c95c7f9 | 2007-08-02 11:49:45 -0400 | [diff] [blame] | 834 | if (adapter->hisregcpy & MRVDRV_CMD_UPLD_RDY) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 835 | lbs_deb_thread("main-thread: cmd response ready\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 836 | |
Holger Schurig | c95c7f9 | 2007-08-02 11:49:45 -0400 | [diff] [blame] | 837 | adapter->hisregcpy &= ~MRVDRV_CMD_UPLD_RDY; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 838 | spin_unlock_irq(&adapter->driver_lock); |
| 839 | libertas_process_rx_command(priv); |
| 840 | spin_lock_irq(&adapter->driver_lock); |
| 841 | } |
| 842 | |
| 843 | /* Any Card Event */ |
Holger Schurig | c95c7f9 | 2007-08-02 11:49:45 -0400 | [diff] [blame] | 844 | if (adapter->hisregcpy & MRVDRV_CARDEVENT) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 845 | lbs_deb_thread("main-thread: Card Event Activity\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 846 | |
Holger Schurig | c95c7f9 | 2007-08-02 11:49:45 -0400 | [diff] [blame] | 847 | adapter->hisregcpy &= ~MRVDRV_CARDEVENT; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 848 | |
Holger Schurig | 208fdd2 | 2007-05-25 12:17:06 -0400 | [diff] [blame] | 849 | if (priv->hw_read_event_cause(priv)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 850 | lbs_pr_alert( |
Holger Schurig | 208fdd2 | 2007-05-25 12:17:06 -0400 | [diff] [blame] | 851 | "main-thread: hw_read_event_cause failed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 852 | spin_unlock_irq(&adapter->driver_lock); |
| 853 | continue; |
| 854 | } |
| 855 | spin_unlock_irq(&adapter->driver_lock); |
| 856 | libertas_process_event(priv); |
| 857 | } else |
| 858 | spin_unlock_irq(&adapter->driver_lock); |
| 859 | |
| 860 | /* Check if we need to confirm Sleep Request received previously */ |
| 861 | if (adapter->psstate == PS_STATE_PRE_SLEEP) { |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 862 | if (!priv->dnld_sent && !adapter->cur_cmd) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 863 | if (adapter->connect_status == |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 864 | LIBERTAS_CONNECTED) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 865 | lbs_deb_thread( |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 866 | "main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p " |
| 867 | "dnld_sent=%d cur_cmd=%p, confirm now\n", |
| 868 | adapter->intcounter, |
| 869 | adapter->currenttxskb, |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 870 | priv->dnld_sent, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 871 | adapter->cur_cmd); |
| 872 | |
| 873 | libertas_ps_confirm_sleep(priv, |
| 874 | (u16) adapter->psmode); |
| 875 | } else { |
| 876 | /* workaround for firmware sending |
| 877 | * deauth/linkloss event immediately |
| 878 | * after sleep request, remove this |
| 879 | * after firmware fixes it |
| 880 | */ |
| 881 | adapter->psstate = PS_STATE_AWAKE; |
| 882 | lbs_pr_alert( |
| 883 | "main-thread: ignore PS_SleepConfirm in non-connected state\n"); |
| 884 | } |
| 885 | } |
| 886 | } |
| 887 | |
| 888 | /* The PS state is changed during processing of Sleep Request |
| 889 | * event above |
| 890 | */ |
| 891 | if ((priv->adapter->psstate == PS_STATE_SLEEP) || |
| 892 | (priv->adapter->psstate == PS_STATE_PRE_SLEEP)) |
| 893 | continue; |
| 894 | |
| 895 | /* Execute the next command */ |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 896 | if (!priv->dnld_sent && !priv->adapter->cur_cmd) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 897 | libertas_execute_next_command(priv); |
| 898 | |
| 899 | /* Wake-up command waiters which can't sleep in |
| 900 | * libertas_prepare_and_send_command |
| 901 | */ |
| 902 | if (!adapter->nr_cmd_pending) |
| 903 | wake_up_all(&adapter->cmd_pending); |
| 904 | |
| 905 | libertas_tx_runqueue(priv); |
| 906 | } |
| 907 | |
| 908 | del_timer(&adapter->command_timer); |
| 909 | adapter->nr_cmd_pending = 0; |
| 910 | wake_up_all(&adapter->cmd_pending); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 911 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 912 | lbs_deb_leave(LBS_DEB_THREAD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 913 | return 0; |
| 914 | } |
| 915 | |
| 916 | /** |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 917 | * @brief This function downloads firmware image, gets |
| 918 | * HW spec from firmware and set basic parameters to |
| 919 | * firmware. |
| 920 | * |
| 921 | * @param priv A pointer to wlan_private structure |
| 922 | * @return 0 or -1 |
| 923 | */ |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 924 | static int wlan_setup_firmware(wlan_private * priv) |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 925 | { |
| 926 | int ret = -1; |
| 927 | wlan_adapter *adapter = priv->adapter; |
Luis Carlos Cobo | d21b31f | 2007-08-02 13:16:02 -0400 | [diff] [blame] | 928 | struct cmd_ds_mesh_access mesh_access; |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 929 | |
| 930 | lbs_deb_enter(LBS_DEB_FW); |
| 931 | |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 932 | /* |
| 933 | * Read MAC address from HW |
| 934 | */ |
| 935 | memset(adapter->current_addr, 0xff, ETH_ALEN); |
| 936 | |
| 937 | ret = libertas_prepare_and_send_command(priv, CMD_GET_HW_SPEC, |
| 938 | 0, CMD_OPTION_WAITFORRSP, 0, NULL); |
| 939 | |
| 940 | if (ret) { |
| 941 | ret = -1; |
| 942 | goto done; |
| 943 | } |
| 944 | |
| 945 | libertas_set_mac_packet_filter(priv); |
| 946 | |
| 947 | /* Get the supported Data rates */ |
| 948 | ret = libertas_prepare_and_send_command(priv, CMD_802_11_DATA_RATE, |
| 949 | CMD_ACT_GET_TX_RATE, |
| 950 | CMD_OPTION_WAITFORRSP, 0, NULL); |
| 951 | |
| 952 | if (ret) { |
| 953 | ret = -1; |
| 954 | goto done; |
| 955 | } |
| 956 | |
Luis Carlos Cobo | d21b31f | 2007-08-02 13:16:02 -0400 | [diff] [blame] | 957 | /* Disable mesh autostart */ |
| 958 | if (priv->mesh_dev) { |
| 959 | memset(&mesh_access, 0, sizeof(mesh_access)); |
| 960 | mesh_access.data[0] = cpu_to_le32(0); |
| 961 | ret = libertas_prepare_and_send_command(priv, |
| 962 | CMD_MESH_ACCESS, |
| 963 | CMD_ACT_MESH_SET_AUTOSTART_ENABLED, |
| 964 | CMD_OPTION_WAITFORRSP, 0, (void *)&mesh_access); |
| 965 | if (ret) { |
| 966 | ret = -1; |
| 967 | goto done; |
| 968 | } |
| 969 | priv->mesh_autostart_enabled = 0; |
| 970 | } |
| 971 | |
Luis Carlos Cobo | 63f0023 | 2007-08-02 13:19:24 -0400 | [diff] [blame] | 972 | /* Set the boot2 version in firmware */ |
| 973 | ret = libertas_prepare_and_send_command(priv, CMD_SET_BOOT2_VER, |
| 974 | 0, CMD_OPTION_WAITFORRSP, 0, NULL); |
| 975 | |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 976 | ret = 0; |
| 977 | done: |
| 978 | lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret); |
| 979 | return ret; |
| 980 | } |
| 981 | |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 982 | /** |
| 983 | * This function handles the timeout of command sending. |
| 984 | * It will re-send the same command again. |
| 985 | */ |
| 986 | static void command_timer_fn(unsigned long data) |
| 987 | { |
| 988 | wlan_private *priv = (wlan_private *)data; |
| 989 | wlan_adapter *adapter = priv->adapter; |
| 990 | struct cmd_ctrl_node *ptempnode; |
| 991 | struct cmd_ds_command *cmd; |
| 992 | unsigned long flags; |
| 993 | |
| 994 | ptempnode = adapter->cur_cmd; |
| 995 | if (ptempnode == NULL) { |
| 996 | lbs_deb_fw("ptempnode empty\n"); |
| 997 | return; |
| 998 | } |
| 999 | |
| 1000 | cmd = (struct cmd_ds_command *)ptempnode->bufvirtualaddr; |
| 1001 | if (!cmd) { |
| 1002 | lbs_deb_fw("cmd is NULL\n"); |
| 1003 | return; |
| 1004 | } |
| 1005 | |
| 1006 | lbs_deb_fw("command_timer_fn fired, cmd %x\n", cmd->command); |
| 1007 | |
| 1008 | if (!adapter->fw_ready) |
| 1009 | return; |
| 1010 | |
| 1011 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 1012 | adapter->cur_cmd = NULL; |
| 1013 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 1014 | |
| 1015 | lbs_deb_fw("re-sending same command because of timeout\n"); |
| 1016 | libertas_queue_cmd(adapter, ptempnode, 0); |
| 1017 | |
| 1018 | wake_up_interruptible(&priv->waitq); |
| 1019 | |
| 1020 | return; |
| 1021 | } |
| 1022 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1023 | static int libertas_init_adapter(wlan_private * priv) |
| 1024 | { |
| 1025 | wlan_adapter *adapter = priv->adapter; |
| 1026 | size_t bufsize; |
| 1027 | int i, ret = 0; |
| 1028 | |
| 1029 | /* Allocate buffer to store the BSSID list */ |
| 1030 | bufsize = MAX_NETWORK_COUNT * sizeof(struct bss_descriptor); |
| 1031 | adapter->networks = kzalloc(bufsize, GFP_KERNEL); |
| 1032 | if (!adapter->networks) { |
| 1033 | lbs_pr_err("Out of memory allocating beacons\n"); |
| 1034 | ret = -1; |
| 1035 | goto out; |
| 1036 | } |
| 1037 | |
| 1038 | /* Initialize scan result lists */ |
| 1039 | INIT_LIST_HEAD(&adapter->network_free_list); |
| 1040 | INIT_LIST_HEAD(&adapter->network_list); |
| 1041 | for (i = 0; i < MAX_NETWORK_COUNT; i++) { |
| 1042 | list_add_tail(&adapter->networks[i].list, |
| 1043 | &adapter->network_free_list); |
| 1044 | } |
| 1045 | |
| 1046 | adapter->libertas_ps_confirm_sleep.seqnum = cpu_to_le16(++adapter->seqnum); |
| 1047 | adapter->libertas_ps_confirm_sleep.command = |
| 1048 | cpu_to_le16(CMD_802_11_PS_MODE); |
| 1049 | adapter->libertas_ps_confirm_sleep.size = |
| 1050 | cpu_to_le16(sizeof(struct PS_CMD_ConfirmSleep)); |
| 1051 | adapter->libertas_ps_confirm_sleep.action = |
| 1052 | cpu_to_le16(CMD_SUBCMD_SLEEP_CONFIRMED); |
| 1053 | |
| 1054 | memset(adapter->current_addr, 0xff, ETH_ALEN); |
| 1055 | |
| 1056 | adapter->connect_status = LIBERTAS_DISCONNECTED; |
| 1057 | adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
| 1058 | adapter->mode = IW_MODE_INFRA; |
| 1059 | adapter->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL; |
| 1060 | adapter->currentpacketfilter = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON; |
| 1061 | adapter->radioon = RADIO_ON; |
| 1062 | adapter->auto_rate = 1; |
| 1063 | adapter->capability = WLAN_CAPABILITY_SHORT_PREAMBLE; |
| 1064 | adapter->psmode = WLAN802_11POWERMODECAM; |
| 1065 | adapter->psstate = PS_STATE_FULL_POWER; |
| 1066 | |
| 1067 | mutex_init(&adapter->lock); |
| 1068 | |
| 1069 | memset(&adapter->tx_queue_ps, 0, NR_TX_QUEUE*sizeof(struct sk_buff*)); |
| 1070 | adapter->tx_queue_idx = 0; |
| 1071 | spin_lock_init(&adapter->txqueue_lock); |
| 1072 | |
| 1073 | setup_timer(&adapter->command_timer, command_timer_fn, |
| 1074 | (unsigned long)priv); |
| 1075 | |
| 1076 | INIT_LIST_HEAD(&adapter->cmdfreeq); |
| 1077 | INIT_LIST_HEAD(&adapter->cmdpendingq); |
| 1078 | |
| 1079 | spin_lock_init(&adapter->driver_lock); |
| 1080 | init_waitqueue_head(&adapter->cmd_pending); |
| 1081 | adapter->nr_cmd_pending = 0; |
| 1082 | |
| 1083 | /* Allocate the command buffers */ |
| 1084 | if (libertas_allocate_cmd_buffer(priv)) { |
| 1085 | lbs_pr_err("Out of memory allocating command buffers\n"); |
| 1086 | ret = -1; |
| 1087 | } |
| 1088 | |
| 1089 | out: |
| 1090 | return ret; |
| 1091 | } |
| 1092 | |
Holger Schurig | ac558ca | 2007-08-02 11:49:06 -0400 | [diff] [blame] | 1093 | static void libertas_free_adapter(wlan_private * priv) |
| 1094 | { |
| 1095 | wlan_adapter *adapter = priv->adapter; |
| 1096 | |
| 1097 | if (!adapter) { |
| 1098 | lbs_deb_fw("why double free adapter?\n"); |
| 1099 | return; |
| 1100 | } |
| 1101 | |
| 1102 | lbs_deb_fw("free command buffer\n"); |
| 1103 | libertas_free_cmd_buffer(priv); |
| 1104 | |
| 1105 | lbs_deb_fw("free command_timer\n"); |
| 1106 | del_timer(&adapter->command_timer); |
| 1107 | |
| 1108 | lbs_deb_fw("free scan results table\n"); |
| 1109 | kfree(adapter->networks); |
| 1110 | adapter->networks = NULL; |
| 1111 | |
| 1112 | /* Free the adapter object itself */ |
| 1113 | lbs_deb_fw("free adapter\n"); |
| 1114 | kfree(adapter); |
| 1115 | priv->adapter = NULL; |
| 1116 | } |
| 1117 | |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 1118 | /** |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1119 | * @brief This function adds the card. it will probe the |
| 1120 | * card, allocate the wlan_priv and initialize the device. |
| 1121 | * |
| 1122 | * @param card A pointer to card |
| 1123 | * @return A pointer to wlan_private structure |
| 1124 | */ |
Dan Williams | 7732ca4 | 2007-05-25 13:13:25 -0400 | [diff] [blame] | 1125 | wlan_private *libertas_add_card(void *card, struct device *dmdev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1126 | { |
| 1127 | struct net_device *dev = NULL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1128 | wlan_private *priv = NULL; |
| 1129 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1130 | lbs_deb_enter(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1131 | |
| 1132 | /* Allocate an Ethernet device and register it */ |
| 1133 | if (!(dev = alloc_etherdev(sizeof(wlan_private)))) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1134 | lbs_pr_err("init ethX device failed\n"); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1135 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1136 | } |
Dan Williams | 64f104e | 2007-08-20 11:45:16 -0400 | [diff] [blame] | 1137 | priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1138 | |
| 1139 | /* allocate buffer for wlan_adapter */ |
Holger Schurig | fb3dddf | 2007-05-25 11:58:22 -0400 | [diff] [blame] | 1140 | if (!(priv->adapter = kzalloc(sizeof(wlan_adapter), GFP_KERNEL))) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1141 | lbs_pr_err("allocate buffer for wlan_adapter failed\n"); |
Holger Schurig | fb3dddf | 2007-05-25 11:58:22 -0400 | [diff] [blame] | 1142 | goto err_kzalloc; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1143 | } |
| 1144 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1145 | if (libertas_init_adapter(priv)) { |
| 1146 | lbs_pr_err("failed to initialize adapter structure.\n"); |
| 1147 | goto err_init_adapter; |
| 1148 | } |
| 1149 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 1150 | priv->dev = dev; |
| 1151 | priv->card = card; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1152 | priv->mesh_open = 0; |
| 1153 | priv->infra_open = 0; |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1154 | priv->hotplug_device = dmdev; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1155 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1156 | /* Setup the OS Interface to our functions */ |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 1157 | dev->open = libertas_open; |
| 1158 | dev->hard_start_xmit = libertas_pre_start_xmit; |
| 1159 | dev->stop = libertas_close; |
| 1160 | dev->set_mac_address = libertas_set_mac_address; |
| 1161 | dev->tx_timeout = libertas_tx_timeout; |
| 1162 | dev->get_stats = libertas_get_stats; |
Holger Schurig | fb3dddf | 2007-05-25 11:58:22 -0400 | [diff] [blame] | 1163 | dev->watchdog_timeo = 5 * HZ; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1164 | dev->ethtool_ops = &libertas_ethtool_ops; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1165 | #ifdef WIRELESS_EXT |
| 1166 | dev->wireless_handlers = (struct iw_handler_def *)&libertas_handler_def; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1167 | #endif |
| 1168 | #define NETIF_F_DYNALLOC 16 |
| 1169 | dev->features |= NETIF_F_DYNALLOC; |
| 1170 | dev->flags |= IFF_BROADCAST | IFF_MULTICAST; |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 1171 | dev->set_multicast_list = libertas_set_multicast_list; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1172 | |
Dan Williams | 7732ca4 | 2007-05-25 13:13:25 -0400 | [diff] [blame] | 1173 | SET_NETDEV_DEV(dev, dmdev); |
| 1174 | |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1175 | priv->rtap_net_dev = NULL; |
| 1176 | if (device_create_file(dmdev, &dev_attr_libertas_rtap)) |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1177 | goto err_init_adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1178 | |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 1179 | lbs_deb_thread("Starting main thread...\n"); |
| 1180 | init_waitqueue_head(&priv->waitq); |
| 1181 | priv->main_thread = kthread_run(libertas_thread, dev, "libertas_main"); |
| 1182 | if (IS_ERR(priv->main_thread)) { |
| 1183 | lbs_deb_thread("Error creating main thread.\n"); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1184 | goto err_kthread_run; |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 1185 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1186 | |
Dan Williams | 2afc0c5 | 2007-08-02 13:19:04 -0400 | [diff] [blame] | 1187 | priv->work_thread = create_singlethread_workqueue("libertas_worker"); |
Holger Schurig | eb3ce63 | 2007-05-24 23:41:15 -0400 | [diff] [blame] | 1188 | INIT_DELAYED_WORK(&priv->assoc_work, libertas_association_worker); |
Dan Williams | 2afc0c5 | 2007-08-02 13:19:04 -0400 | [diff] [blame] | 1189 | INIT_DELAYED_WORK(&priv->scan_work, libertas_scan_worker); |
Luis Carlos Cobo Rus | b8bedef | 2007-05-30 12:14:34 -0400 | [diff] [blame] | 1190 | INIT_WORK(&priv->sync_channel, libertas_sync_channel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1191 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1192 | goto done; |
| 1193 | |
| 1194 | err_kthread_run: |
| 1195 | device_remove_file(dmdev, &dev_attr_libertas_rtap); |
| 1196 | |
| 1197 | err_init_adapter: |
| 1198 | libertas_free_adapter(priv); |
| 1199 | |
| 1200 | err_kzalloc: |
| 1201 | free_netdev(dev); |
| 1202 | priv = NULL; |
| 1203 | |
| 1204 | done: |
| 1205 | lbs_deb_leave_args(LBS_DEB_NET, "priv %p", priv); |
| 1206 | return priv; |
| 1207 | } |
| 1208 | EXPORT_SYMBOL_GPL(libertas_add_card); |
| 1209 | |
| 1210 | |
| 1211 | int libertas_remove_card(wlan_private *priv) |
| 1212 | { |
| 1213 | wlan_adapter *adapter = priv->adapter; |
| 1214 | struct net_device *dev = priv->dev; |
| 1215 | union iwreq_data wrqu; |
| 1216 | |
| 1217 | lbs_deb_enter(LBS_DEB_MAIN); |
| 1218 | |
| 1219 | libertas_remove_rtap(priv); |
| 1220 | |
| 1221 | dev = priv->dev; |
| 1222 | device_remove_file(priv->hotplug_device, &dev_attr_libertas_rtap); |
| 1223 | |
| 1224 | cancel_delayed_work(&priv->scan_work); |
| 1225 | cancel_delayed_work(&priv->assoc_work); |
| 1226 | destroy_workqueue(priv->work_thread); |
| 1227 | |
| 1228 | if (adapter->psmode == WLAN802_11POWERMODEMAX_PSP) { |
| 1229 | adapter->psmode = WLAN802_11POWERMODECAM; |
| 1230 | libertas_ps_wakeup(priv, CMD_OPTION_WAITFORRSP); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1231 | } |
| 1232 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1233 | memset(wrqu.ap_addr.sa_data, 0xaa, ETH_ALEN); |
| 1234 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 1235 | wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); |
| 1236 | |
| 1237 | /* Stop the thread servicing the interrupts */ |
| 1238 | adapter->surpriseremoved = 1; |
| 1239 | kthread_stop(priv->main_thread); |
| 1240 | |
| 1241 | libertas_free_adapter(priv); |
| 1242 | |
| 1243 | priv->dev = NULL; |
| 1244 | free_netdev(dev); |
| 1245 | |
| 1246 | lbs_deb_leave(LBS_DEB_MAIN); |
| 1247 | return 0; |
| 1248 | } |
| 1249 | EXPORT_SYMBOL_GPL(libertas_remove_card); |
| 1250 | |
| 1251 | |
| 1252 | int libertas_start_card(wlan_private *priv) |
| 1253 | { |
| 1254 | struct net_device *dev = priv->dev; |
| 1255 | int ret = -1; |
| 1256 | |
| 1257 | lbs_deb_enter(LBS_DEB_MAIN); |
| 1258 | |
| 1259 | /* poke the firmware */ |
| 1260 | ret = wlan_setup_firmware(priv); |
| 1261 | if (ret) |
| 1262 | goto done; |
| 1263 | |
| 1264 | /* init 802.11d */ |
| 1265 | libertas_init_11d(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1266 | |
| 1267 | if (register_netdev(dev)) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1268 | lbs_pr_err("cannot register ethX device\n"); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1269 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1270 | } |
| 1271 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1272 | libertas_debugfs_init_one(priv, dev); |
| 1273 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1274 | lbs_pr_info("%s: Marvell WLAN 802.11 adapter\n", dev->name); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1275 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1276 | ret = 0; |
| 1277 | |
Holger Schurig | 32a74b7 | 2007-05-25 12:04:31 -0400 | [diff] [blame] | 1278 | done: |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1279 | lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); |
Holger Schurig | 32a74b7 | 2007-05-25 12:04:31 -0400 | [diff] [blame] | 1280 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1281 | } |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1282 | EXPORT_SYMBOL_GPL(libertas_start_card); |
| 1283 | |
| 1284 | |
| 1285 | int libertas_stop_card(wlan_private *priv) |
| 1286 | { |
| 1287 | struct net_device *dev = priv->dev; |
| 1288 | int ret = -1; |
| 1289 | struct cmd_ctrl_node *cmdnode; |
| 1290 | unsigned long flags; |
| 1291 | |
| 1292 | lbs_deb_enter(LBS_DEB_MAIN); |
| 1293 | |
| 1294 | netif_stop_queue(priv->dev); |
| 1295 | netif_carrier_off(priv->dev); |
| 1296 | |
| 1297 | libertas_debugfs_remove_one(priv); |
| 1298 | |
| 1299 | /* Flush pending command nodes */ |
| 1300 | spin_lock_irqsave(&priv->adapter->driver_lock, flags); |
| 1301 | list_for_each_entry(cmdnode, &priv->adapter->cmdpendingq, list) { |
| 1302 | cmdnode->cmdwaitqwoken = 1; |
| 1303 | wake_up_interruptible(&cmdnode->cmdwait_q); |
| 1304 | } |
| 1305 | spin_unlock_irqrestore(&priv->adapter->driver_lock, flags); |
| 1306 | |
| 1307 | unregister_netdev(dev); |
| 1308 | |
| 1309 | lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); |
| 1310 | return ret; |
| 1311 | } |
| 1312 | EXPORT_SYMBOL_GPL(libertas_stop_card); |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1313 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1314 | |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1315 | /** |
| 1316 | * @brief This function adds mshX interface |
| 1317 | * |
| 1318 | * @param priv A pointer to the wlan_private structure |
| 1319 | * @return 0 if successful, -X otherwise |
| 1320 | */ |
Dan Williams | 7732ca4 | 2007-05-25 13:13:25 -0400 | [diff] [blame] | 1321 | int libertas_add_mesh(wlan_private *priv, struct device *dev) |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1322 | { |
| 1323 | struct net_device *mesh_dev = NULL; |
| 1324 | int ret = 0; |
| 1325 | |
| 1326 | lbs_deb_enter(LBS_DEB_MESH); |
| 1327 | |
| 1328 | /* Allocate a virtual mesh device */ |
| 1329 | if (!(mesh_dev = alloc_netdev(0, "msh%d", ether_setup))) { |
| 1330 | lbs_deb_mesh("init mshX device failed\n"); |
| 1331 | ret = -ENOMEM; |
| 1332 | goto done; |
| 1333 | } |
| 1334 | mesh_dev->priv = priv; |
| 1335 | priv->mesh_dev = mesh_dev; |
| 1336 | |
Dan Williams | e524147 | 2007-08-02 11:39:19 -0400 | [diff] [blame] | 1337 | mesh_dev->open = libertas_mesh_open; |
| 1338 | mesh_dev->hard_start_xmit = libertas_mesh_pre_start_xmit; |
| 1339 | mesh_dev->stop = libertas_mesh_close; |
| 1340 | mesh_dev->get_stats = libertas_get_stats; |
| 1341 | mesh_dev->set_mac_address = libertas_set_mac_address; |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1342 | mesh_dev->ethtool_ops = &libertas_ethtool_ops; |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 1343 | memcpy(mesh_dev->dev_addr, priv->dev->dev_addr, |
| 1344 | sizeof(priv->dev->dev_addr)); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1345 | |
Dan Williams | 7732ca4 | 2007-05-25 13:13:25 -0400 | [diff] [blame] | 1346 | SET_NETDEV_DEV(priv->mesh_dev, dev); |
| 1347 | |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1348 | #ifdef WIRELESS_EXT |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 1349 | mesh_dev->wireless_handlers = (struct iw_handler_def *)&mesh_handler_def; |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1350 | #endif |
| 1351 | #define NETIF_F_DYNALLOC 16 |
| 1352 | |
| 1353 | /* Register virtual mesh interface */ |
| 1354 | ret = register_netdev(mesh_dev); |
| 1355 | if (ret) { |
| 1356 | lbs_pr_err("cannot register mshX virtual interface\n"); |
| 1357 | goto err_free; |
| 1358 | } |
| 1359 | |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 1360 | ret = sysfs_create_group(&(mesh_dev->dev.kobj), &libertas_mesh_attr_group); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1361 | if (ret) |
| 1362 | goto err_unregister; |
| 1363 | |
| 1364 | /* Everything successful */ |
| 1365 | ret = 0; |
| 1366 | goto done; |
| 1367 | |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1368 | err_unregister: |
| 1369 | unregister_netdev(mesh_dev); |
| 1370 | |
| 1371 | err_free: |
| 1372 | free_netdev(mesh_dev); |
| 1373 | |
| 1374 | done: |
| 1375 | lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret); |
| 1376 | return ret; |
| 1377 | } |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1378 | EXPORT_SYMBOL_GPL(libertas_add_mesh); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1379 | |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1380 | |
| 1381 | void libertas_remove_mesh(wlan_private *priv) |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1382 | { |
| 1383 | struct net_device *mesh_dev; |
| 1384 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1385 | lbs_deb_enter(LBS_DEB_MAIN); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1386 | |
| 1387 | if (!priv) |
| 1388 | goto out; |
| 1389 | |
| 1390 | mesh_dev = priv->mesh_dev; |
| 1391 | |
| 1392 | netif_stop_queue(mesh_dev); |
Javier Cardona | 51d84f5 | 2007-05-25 12:06:56 -0400 | [diff] [blame] | 1393 | netif_carrier_off(priv->mesh_dev); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1394 | |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 1395 | sysfs_remove_group(&(mesh_dev->dev.kobj), &libertas_mesh_attr_group); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1396 | unregister_netdev(mesh_dev); |
| 1397 | |
| 1398 | priv->mesh_dev = NULL ; |
| 1399 | free_netdev(mesh_dev); |
| 1400 | |
| 1401 | out: |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1402 | lbs_deb_leave(LBS_DEB_MAIN); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1403 | } |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1404 | EXPORT_SYMBOL_GPL(libertas_remove_mesh); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1405 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1406 | /** |
| 1407 | * @brief This function finds the CFP in |
| 1408 | * region_cfp_table based on region and band parameter. |
| 1409 | * |
| 1410 | * @param region The region code |
| 1411 | * @param band The band |
| 1412 | * @param cfp_no A pointer to CFP number |
| 1413 | * @return A pointer to CFP |
| 1414 | */ |
| 1415 | struct chan_freq_power *libertas_get_region_cfp_table(u8 region, u8 band, int *cfp_no) |
| 1416 | { |
| 1417 | int i, end; |
| 1418 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1419 | lbs_deb_enter(LBS_DEB_MAIN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1420 | |
Denis Cheng | ff8ac60 | 2007-09-02 18:30:18 +0800 | [diff] [blame] | 1421 | end = ARRAY_SIZE(region_cfp_table); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1422 | |
| 1423 | for (i = 0; i < end ; i++) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1424 | lbs_deb_main("region_cfp_table[i].region=%d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1425 | region_cfp_table[i].region); |
| 1426 | if (region_cfp_table[i].region == region) { |
| 1427 | *cfp_no = region_cfp_table[i].cfp_no_BG; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1428 | lbs_deb_leave(LBS_DEB_MAIN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1429 | return region_cfp_table[i].cfp_BG; |
| 1430 | } |
| 1431 | } |
| 1432 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1433 | lbs_deb_leave_args(LBS_DEB_MAIN, "ret NULL"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1434 | return NULL; |
| 1435 | } |
| 1436 | |
| 1437 | int libertas_set_regiontable(wlan_private * priv, u8 region, u8 band) |
| 1438 | { |
| 1439 | wlan_adapter *adapter = priv->adapter; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1440 | int ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1441 | int i = 0; |
| 1442 | |
| 1443 | struct chan_freq_power *cfp; |
| 1444 | int cfp_no; |
| 1445 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1446 | lbs_deb_enter(LBS_DEB_MAIN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1447 | |
| 1448 | memset(adapter->region_channel, 0, sizeof(adapter->region_channel)); |
| 1449 | |
| 1450 | { |
| 1451 | cfp = libertas_get_region_cfp_table(region, band, &cfp_no); |
| 1452 | if (cfp != NULL) { |
| 1453 | adapter->region_channel[i].nrcfp = cfp_no; |
| 1454 | adapter->region_channel[i].CFP = cfp; |
| 1455 | } else { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1456 | lbs_deb_main("wrong region code %#x in band B/G\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1457 | region); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1458 | ret = -1; |
| 1459 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1460 | } |
| 1461 | adapter->region_channel[i].valid = 1; |
| 1462 | adapter->region_channel[i].region = region; |
| 1463 | adapter->region_channel[i].band = band; |
| 1464 | i++; |
| 1465 | } |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1466 | out: |
| 1467 | lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); |
| 1468 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1469 | } |
| 1470 | |
| 1471 | /** |
| 1472 | * @brief This function handles the interrupt. it will change PS |
| 1473 | * state if applicable. it will wake up main_thread to handle |
| 1474 | * the interrupt event as well. |
| 1475 | * |
| 1476 | * @param dev A pointer to net_device structure |
| 1477 | * @return n/a |
| 1478 | */ |
| 1479 | void libertas_interrupt(struct net_device *dev) |
| 1480 | { |
| 1481 | wlan_private *priv = dev->priv; |
| 1482 | |
Holger Schurig | ed37b51 | 2007-05-25 11:52:42 -0400 | [diff] [blame] | 1483 | lbs_deb_enter(LBS_DEB_THREAD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1484 | |
Holger Schurig | ed37b51 | 2007-05-25 11:52:42 -0400 | [diff] [blame] | 1485 | lbs_deb_thread("libertas_interrupt: intcounter=%d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1486 | priv->adapter->intcounter); |
| 1487 | |
| 1488 | priv->adapter->intcounter++; |
| 1489 | |
| 1490 | if (priv->adapter->psstate == PS_STATE_SLEEP) { |
| 1491 | priv->adapter->psstate = PS_STATE_AWAKE; |
| 1492 | netif_wake_queue(dev); |
Holger Schurig | 3cf8409 | 2007-08-02 11:50:12 -0400 | [diff] [blame] | 1493 | if (priv->mesh_dev) |
| 1494 | netif_wake_queue(priv->mesh_dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1495 | } |
| 1496 | |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 1497 | wake_up_interruptible(&priv->waitq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1498 | |
Holger Schurig | ed37b51 | 2007-05-25 11:52:42 -0400 | [diff] [blame] | 1499 | lbs_deb_leave(LBS_DEB_THREAD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1500 | } |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1501 | EXPORT_SYMBOL_GPL(libertas_interrupt); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1502 | |
Dan Williams | eedc2a3 | 2007-08-02 11:36:22 -0400 | [diff] [blame] | 1503 | int libertas_reset_device(wlan_private *priv) |
| 1504 | { |
| 1505 | int ret; |
| 1506 | |
| 1507 | lbs_deb_enter(LBS_DEB_MAIN); |
| 1508 | ret = libertas_prepare_and_send_command(priv, CMD_802_11_RESET, |
| 1509 | CMD_ACT_HALT, 0, 0, NULL); |
| 1510 | msleep_interruptible(10); |
| 1511 | |
| 1512 | lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); |
| 1513 | return ret; |
| 1514 | } |
| 1515 | EXPORT_SYMBOL_GPL(libertas_reset_device); |
| 1516 | |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1517 | static int libertas_init_module(void) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1518 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1519 | lbs_deb_enter(LBS_DEB_MAIN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1520 | libertas_debugfs_init(); |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1521 | lbs_deb_leave(LBS_DEB_MAIN); |
| 1522 | return 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1523 | } |
| 1524 | |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1525 | static void libertas_exit_module(void) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1526 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1527 | lbs_deb_enter(LBS_DEB_MAIN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1528 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1529 | libertas_debugfs_remove(); |
| 1530 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1531 | lbs_deb_leave(LBS_DEB_MAIN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1532 | } |
| 1533 | |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1534 | /* |
| 1535 | * rtap interface support fuctions |
| 1536 | */ |
| 1537 | |
| 1538 | static int libertas_rtap_open(struct net_device *dev) |
| 1539 | { |
| 1540 | netif_carrier_off(dev); |
| 1541 | netif_stop_queue(dev); |
| 1542 | return 0; |
| 1543 | } |
| 1544 | |
| 1545 | static int libertas_rtap_stop(struct net_device *dev) |
| 1546 | { |
| 1547 | return 0; |
| 1548 | } |
| 1549 | |
| 1550 | static int libertas_rtap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| 1551 | { |
| 1552 | netif_stop_queue(dev); |
| 1553 | return -EOPNOTSUPP; |
| 1554 | } |
| 1555 | |
| 1556 | static struct net_device_stats *libertas_rtap_get_stats(struct net_device *dev) |
| 1557 | { |
| 1558 | wlan_private *priv = dev->priv; |
| 1559 | return &priv->ieee->stats; |
| 1560 | } |
| 1561 | |
| 1562 | |
| 1563 | void libertas_remove_rtap(wlan_private *priv) |
| 1564 | { |
| 1565 | if (priv->rtap_net_dev == NULL) |
| 1566 | return; |
| 1567 | unregister_netdev(priv->rtap_net_dev); |
| 1568 | free_ieee80211(priv->rtap_net_dev); |
| 1569 | priv->rtap_net_dev = NULL; |
| 1570 | } |
| 1571 | |
| 1572 | int libertas_add_rtap(wlan_private *priv) |
| 1573 | { |
| 1574 | int rc = 0; |
| 1575 | |
| 1576 | if (priv->rtap_net_dev) |
| 1577 | return -EPERM; |
| 1578 | |
| 1579 | priv->rtap_net_dev = alloc_ieee80211(0); |
| 1580 | if (priv->rtap_net_dev == NULL) |
| 1581 | return -ENOMEM; |
| 1582 | |
| 1583 | |
| 1584 | priv->ieee = netdev_priv(priv->rtap_net_dev); |
| 1585 | |
| 1586 | strcpy(priv->rtap_net_dev->name, "rtap%d"); |
| 1587 | |
| 1588 | priv->rtap_net_dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 1589 | priv->rtap_net_dev->open = libertas_rtap_open; |
| 1590 | priv->rtap_net_dev->stop = libertas_rtap_stop; |
| 1591 | priv->rtap_net_dev->get_stats = libertas_rtap_get_stats; |
| 1592 | priv->rtap_net_dev->hard_start_xmit = libertas_rtap_hard_start_xmit; |
| 1593 | priv->rtap_net_dev->set_multicast_list = libertas_set_multicast_list; |
| 1594 | priv->rtap_net_dev->priv = priv; |
| 1595 | |
| 1596 | priv->ieee->iw_mode = IW_MODE_MONITOR; |
| 1597 | |
| 1598 | rc = register_netdev(priv->rtap_net_dev); |
| 1599 | if (rc) { |
| 1600 | free_ieee80211(priv->rtap_net_dev); |
| 1601 | priv->rtap_net_dev = NULL; |
| 1602 | return rc; |
| 1603 | } |
| 1604 | |
| 1605 | return 0; |
| 1606 | } |
| 1607 | |
| 1608 | |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1609 | module_init(libertas_init_module); |
| 1610 | module_exit(libertas_exit_module); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1611 | |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1612 | MODULE_DESCRIPTION("Libertas WLAN Driver Library"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1613 | MODULE_AUTHOR("Marvell International Ltd."); |
| 1614 | MODULE_LICENSE("GPL"); |