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" |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 27 | const char lbs_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION |
Dan Williams | 3ce4023 | 2007-05-10 23:03:07 -0400 | [diff] [blame] | 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 */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 35 | unsigned int lbs_debug; |
| 36 | EXPORT_SYMBOL_GPL(lbs_debug); |
| 37 | module_param_named(libertas_debug, lbs_debug, int, 0644); |
Holger Schurig | a46c641 | 2007-05-25 11:32:07 -0400 | [diff] [blame] | 38 | |
| 39 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 40 | #define LBS_TX_PWR_DEFAULT 20 /*100mW */ |
| 41 | #define LBS_TX_PWR_US_DEFAULT 20 /*100mW */ |
| 42 | #define LBS_TX_PWR_JP_DEFAULT 16 /*50mW */ |
| 43 | #define LBS_TX_PWR_FR_DEFAULT 20 /*100mW */ |
| 44 | #define LBS_TX_PWR_EMEA_DEFAULT 20 /*100mW */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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[] = { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 49 | {1, 2412, LBS_TX_PWR_US_DEFAULT}, |
| 50 | {2, 2417, LBS_TX_PWR_US_DEFAULT}, |
| 51 | {3, 2422, LBS_TX_PWR_US_DEFAULT}, |
| 52 | {4, 2427, LBS_TX_PWR_US_DEFAULT}, |
| 53 | {5, 2432, LBS_TX_PWR_US_DEFAULT}, |
| 54 | {6, 2437, LBS_TX_PWR_US_DEFAULT}, |
| 55 | {7, 2442, LBS_TX_PWR_US_DEFAULT}, |
| 56 | {8, 2447, LBS_TX_PWR_US_DEFAULT}, |
| 57 | {9, 2452, LBS_TX_PWR_US_DEFAULT}, |
| 58 | {10, 2457, LBS_TX_PWR_US_DEFAULT}, |
| 59 | {11, 2462, LBS_TX_PWR_US_DEFAULT} |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | /* band: 'B/G', region: Europe ETSI */ |
| 63 | static struct chan_freq_power channel_freq_power_EU_BG[] = { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 64 | {1, 2412, LBS_TX_PWR_EMEA_DEFAULT}, |
| 65 | {2, 2417, LBS_TX_PWR_EMEA_DEFAULT}, |
| 66 | {3, 2422, LBS_TX_PWR_EMEA_DEFAULT}, |
| 67 | {4, 2427, LBS_TX_PWR_EMEA_DEFAULT}, |
| 68 | {5, 2432, LBS_TX_PWR_EMEA_DEFAULT}, |
| 69 | {6, 2437, LBS_TX_PWR_EMEA_DEFAULT}, |
| 70 | {7, 2442, LBS_TX_PWR_EMEA_DEFAULT}, |
| 71 | {8, 2447, LBS_TX_PWR_EMEA_DEFAULT}, |
| 72 | {9, 2452, LBS_TX_PWR_EMEA_DEFAULT}, |
| 73 | {10, 2457, LBS_TX_PWR_EMEA_DEFAULT}, |
| 74 | {11, 2462, LBS_TX_PWR_EMEA_DEFAULT}, |
| 75 | {12, 2467, LBS_TX_PWR_EMEA_DEFAULT}, |
| 76 | {13, 2472, LBS_TX_PWR_EMEA_DEFAULT} |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | /* band: 'B/G', region: Spain */ |
| 80 | static struct chan_freq_power channel_freq_power_SPN_BG[] = { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 81 | {10, 2457, LBS_TX_PWR_DEFAULT}, |
| 82 | {11, 2462, LBS_TX_PWR_DEFAULT} |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | /* band: 'B/G', region: France */ |
| 86 | static struct chan_freq_power channel_freq_power_FR_BG[] = { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 87 | {10, 2457, LBS_TX_PWR_FR_DEFAULT}, |
| 88 | {11, 2462, LBS_TX_PWR_FR_DEFAULT}, |
| 89 | {12, 2467, LBS_TX_PWR_FR_DEFAULT}, |
| 90 | {13, 2472, LBS_TX_PWR_FR_DEFAULT} |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | /* band: 'B/G', region: Japan */ |
| 94 | static struct chan_freq_power channel_freq_power_JPN_BG[] = { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 95 | {1, 2412, LBS_TX_PWR_JP_DEFAULT}, |
| 96 | {2, 2417, LBS_TX_PWR_JP_DEFAULT}, |
| 97 | {3, 2422, LBS_TX_PWR_JP_DEFAULT}, |
| 98 | {4, 2427, LBS_TX_PWR_JP_DEFAULT}, |
| 99 | {5, 2432, LBS_TX_PWR_JP_DEFAULT}, |
| 100 | {6, 2437, LBS_TX_PWR_JP_DEFAULT}, |
| 101 | {7, 2442, LBS_TX_PWR_JP_DEFAULT}, |
| 102 | {8, 2447, LBS_TX_PWR_JP_DEFAULT}, |
| 103 | {9, 2452, LBS_TX_PWR_JP_DEFAULT}, |
| 104 | {10, 2457, LBS_TX_PWR_JP_DEFAULT}, |
| 105 | {11, 2462, LBS_TX_PWR_JP_DEFAULT}, |
| 106 | {12, 2467, LBS_TX_PWR_JP_DEFAULT}, |
| 107 | {13, 2472, LBS_TX_PWR_JP_DEFAULT}, |
| 108 | {14, 2484, LBS_TX_PWR_JP_DEFAULT} |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 156 | u16 lbs_region_code_to_index[MRVDRV_MAX_REGION_CODE] = |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 162 | u8 lbs_bg_rates[MAX_RATES] = |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 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 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 182 | u32 lbs_fw_index_to_data_rate(u8 idx) |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 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 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 195 | u8 lbs_data_rate_to_fw_index(u32 rate) |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 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 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 216 | static ssize_t lbs_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)); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 222 | lbs_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 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 233 | static ssize_t lbs_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 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 243 | lbs_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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 250 | int lbs_add_rtap(struct lbs_private *priv); |
| 251 | void lbs_remove_rtap(struct lbs_private *priv); |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 252 | |
| 253 | /** |
| 254 | * Get function for sysfs attribute rtap |
| 255 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 256 | static ssize_t lbs_rtap_get(struct device *dev, |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 257 | struct device_attribute *attr, char * buf) |
| 258 | { |
David Woodhouse | e7deced | 2007-12-08 18:29:16 +0000 | [diff] [blame] | 259 | struct lbs_private *priv = to_net_dev(dev)->priv; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 260 | return snprintf(buf, 5, "0x%X\n", priv->monitormode); |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Set function for sysfs attribute rtap |
| 265 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 266 | static ssize_t lbs_rtap_set(struct device *dev, |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 267 | struct device_attribute *attr, const char * buf, size_t count) |
| 268 | { |
| 269 | int monitor_mode; |
David Woodhouse | e7deced | 2007-12-08 18:29:16 +0000 | [diff] [blame] | 270 | struct lbs_private *priv = to_net_dev(dev)->priv; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 271 | |
| 272 | sscanf(buf, "%x", &monitor_mode); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 273 | if (monitor_mode != LBS_MONITOR_OFF) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 274 | if(priv->monitormode == monitor_mode) |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 275 | return strlen(buf); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 276 | if (priv->monitormode == LBS_MONITOR_OFF) { |
| 277 | if (priv->mode == IW_MODE_INFRA) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 278 | lbs_send_deauthentication(priv); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 279 | else if (priv->mode == IW_MODE_ADHOC) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 280 | lbs_stop_adhoc_network(priv); |
| 281 | lbs_add_rtap(priv); |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 282 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 283 | priv->monitormode = monitor_mode; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | else { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 287 | if (priv->monitormode == LBS_MONITOR_OFF) |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 288 | return strlen(buf); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 289 | priv->monitormode = LBS_MONITOR_OFF; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 290 | lbs_remove_rtap(priv); |
David Woodhouse | f86a93e | 2007-12-08 19:46:19 +0000 | [diff] [blame] | 291 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 292 | if (priv->currenttxskb) { |
| 293 | dev_kfree_skb_any(priv->currenttxskb); |
| 294 | priv->currenttxskb = NULL; |
David Woodhouse | f86a93e | 2007-12-08 19:46:19 +0000 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | /* Wake queues, command thread, etc. */ |
| 298 | lbs_host_to_card_done(priv); |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 299 | } |
| 300 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 301 | lbs_prepare_and_send_command(priv, |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 302 | CMD_802_11_MONITOR_MODE, CMD_ACT_SET, |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 303 | CMD_OPTION_WAITFORRSP, 0, &priv->monitormode); |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 304 | return strlen(buf); |
| 305 | } |
| 306 | |
| 307 | /** |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 308 | * lbs_rtap attribute to be exported per mshX interface |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 309 | * through sysfs (/sys/class/net/mshX/libertas-rtap) |
| 310 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 311 | static DEVICE_ATTR(lbs_rtap, 0644, lbs_rtap_get, |
| 312 | lbs_rtap_set ); |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 313 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 314 | /** |
Luis Carlos | 82fde74 | 2007-06-07 16:40:59 -0400 | [diff] [blame] | 315 | * anycast_mask attribute to be exported per mshX interface |
| 316 | * through sysfs (/sys/class/net/mshX/anycast_mask) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 317 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 318 | static DEVICE_ATTR(anycast_mask, 0644, lbs_anycast_get, lbs_anycast_set); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 319 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 320 | static ssize_t lbs_autostart_enabled_get(struct device *dev, |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 321 | struct device_attribute *attr, char * buf) |
| 322 | { |
| 323 | struct cmd_ds_mesh_access mesh_access; |
| 324 | |
| 325 | memset(&mesh_access, 0, sizeof(mesh_access)); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 326 | lbs_prepare_and_send_command(to_net_dev(dev)->priv, |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 327 | CMD_MESH_ACCESS, |
| 328 | CMD_ACT_MESH_GET_AUTOSTART_ENABLED, |
| 329 | CMD_OPTION_WAITFORRSP, 0, (void *)&mesh_access); |
| 330 | |
| 331 | return sprintf(buf, "%d\n", le32_to_cpu(mesh_access.data[0])); |
| 332 | } |
| 333 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 334 | static ssize_t lbs_autostart_enabled_set(struct device *dev, |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 335 | struct device_attribute *attr, const char * buf, size_t count) |
| 336 | { |
| 337 | struct cmd_ds_mesh_access mesh_access; |
| 338 | uint32_t datum; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 339 | struct lbs_private *priv = (to_net_dev(dev))->priv; |
Luis Carlos Cobo | d21b31f | 2007-08-02 13:16:02 -0400 | [diff] [blame] | 340 | int ret; |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 341 | |
| 342 | memset(&mesh_access, 0, sizeof(mesh_access)); |
| 343 | sscanf(buf, "%d", &datum); |
| 344 | mesh_access.data[0] = cpu_to_le32(datum); |
| 345 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 346 | ret = lbs_prepare_and_send_command(priv, |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 347 | CMD_MESH_ACCESS, |
| 348 | CMD_ACT_MESH_SET_AUTOSTART_ENABLED, |
| 349 | CMD_OPTION_WAITFORRSP, 0, (void *)&mesh_access); |
Luis Carlos Cobo | d21b31f | 2007-08-02 13:16:02 -0400 | [diff] [blame] | 350 | if (ret == 0) |
| 351 | priv->mesh_autostart_enabled = datum ? 1 : 0; |
| 352 | |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 353 | return strlen(buf); |
| 354 | } |
| 355 | |
| 356 | static DEVICE_ATTR(autostart_enabled, 0644, |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 357 | lbs_autostart_enabled_get, lbs_autostart_enabled_set); |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 358 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 359 | static struct attribute *lbs_mesh_sysfs_entries[] = { |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 360 | &dev_attr_anycast_mask.attr, |
| 361 | &dev_attr_autostart_enabled.attr, |
| 362 | NULL, |
| 363 | }; |
| 364 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 365 | static struct attribute_group lbs_mesh_attr_group = { |
| 366 | .attrs = lbs_mesh_sysfs_entries, |
Luis Carlos Cobo | a9f38d0 | 2007-08-02 11:52:29 -0400 | [diff] [blame] | 367 | }; |
| 368 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 369 | /** |
| 370 | * @brief Check if the device can be open and wait if necessary. |
| 371 | * |
| 372 | * @param dev A pointer to net_device structure |
| 373 | * @return 0 |
| 374 | * |
| 375 | * For USB adapter, on some systems the device open handler will be |
| 376 | * called before FW ready. Use the following flag check and wait |
| 377 | * function to work around the issue. |
| 378 | * |
| 379 | */ |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 380 | static int pre_open_check(struct net_device *dev) |
| 381 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 382 | struct lbs_private *priv = (struct lbs_private *) dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 383 | int i = 0; |
| 384 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 385 | while (!priv->fw_ready && i < 20) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 386 | i++; |
| 387 | msleep_interruptible(100); |
| 388 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 389 | if (!priv->fw_ready) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 390 | lbs_pr_err("firmware not ready\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 391 | return -1; |
| 392 | } |
| 393 | |
| 394 | return 0; |
| 395 | } |
| 396 | |
| 397 | /** |
| 398 | * @brief This function opens the device |
| 399 | * |
| 400 | * @param dev A pointer to net_device structure |
| 401 | * @return 0 |
| 402 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 403 | static int lbs_dev_open(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 404 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 405 | struct lbs_private *priv = (struct lbs_private *) dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 406 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 407 | lbs_deb_enter(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 408 | |
| 409 | priv->open = 1; |
| 410 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 411 | if (priv->connect_status == LBS_CONNECTED) |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 412 | netif_carrier_on(priv->dev); |
Brajesh Dave | 01d77d8 | 2007-11-20 17:44:14 -0500 | [diff] [blame] | 413 | else |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 414 | netif_carrier_off(priv->dev); |
Brajesh Dave | 01d77d8 | 2007-11-20 17:44:14 -0500 | [diff] [blame] | 415 | |
| 416 | if (priv->mesh_dev) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 417 | if (priv->mesh_connect_status == LBS_CONNECTED) |
Brajesh Dave | 01d77d8 | 2007-11-20 17:44:14 -0500 | [diff] [blame] | 418 | netif_carrier_on(priv->mesh_dev); |
| 419 | else |
Holger Schurig | 3cf8409 | 2007-08-02 11:50:12 -0400 | [diff] [blame] | 420 | netif_carrier_off(priv->mesh_dev); |
Javier Cardona | 51d84f5 | 2007-05-25 12:06:56 -0400 | [diff] [blame] | 421 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 422 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 423 | lbs_deb_leave(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 424 | return 0; |
| 425 | } |
| 426 | /** |
| 427 | * @brief This function opens the mshX interface |
| 428 | * |
| 429 | * @param dev A pointer to net_device structure |
| 430 | * @return 0 |
| 431 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 432 | static int lbs_mesh_open(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 433 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 434 | struct lbs_private *priv = (struct lbs_private *) dev->priv ; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 435 | |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 436 | if (pre_open_check(dev) == -1) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 437 | return -1; |
| 438 | priv->mesh_open = 1 ; |
Javier Cardona | 51d84f5 | 2007-05-25 12:06:56 -0400 | [diff] [blame] | 439 | netif_wake_queue(priv->mesh_dev); |
Brajesh Dave | 01d77d8 | 2007-11-20 17:44:14 -0500 | [diff] [blame] | 440 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 441 | priv->mesh_connect_status = LBS_CONNECTED; |
Brajesh Dave | 01d77d8 | 2007-11-20 17:44:14 -0500 | [diff] [blame] | 442 | |
| 443 | netif_carrier_on(priv->mesh_dev); |
| 444 | netif_wake_queue(priv->mesh_dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 445 | if (priv->infra_open == 0) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 446 | return lbs_dev_open(priv->dev) ; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 447 | return 0; |
| 448 | } |
| 449 | |
| 450 | /** |
| 451 | * @brief This function opens the ethX interface |
| 452 | * |
| 453 | * @param dev A pointer to net_device structure |
| 454 | * @return 0 |
| 455 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 456 | static int lbs_open(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 457 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 458 | struct lbs_private *priv = (struct lbs_private *) dev->priv ; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 459 | |
| 460 | if(pre_open_check(dev) == -1) |
| 461 | return -1; |
| 462 | priv->infra_open = 1 ; |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 463 | netif_wake_queue(priv->dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 464 | if (priv->open == 0) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 465 | return lbs_dev_open(priv->dev) ; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 466 | return 0; |
| 467 | } |
| 468 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 469 | static int lbs_dev_close(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 470 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 471 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 472 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 473 | lbs_deb_enter(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 474 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 475 | netif_carrier_off(priv->dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 476 | priv->open = 0; |
| 477 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 478 | lbs_deb_leave(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 479 | return 0; |
| 480 | } |
| 481 | |
| 482 | /** |
| 483 | * @brief This function closes the mshX interface |
| 484 | * |
| 485 | * @param dev A pointer to net_device structure |
| 486 | * @return 0 |
| 487 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 488 | static int lbs_mesh_close(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 489 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 490 | struct lbs_private *priv = (struct lbs_private *) (dev->priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 491 | |
| 492 | priv->mesh_open = 0; |
| 493 | netif_stop_queue(priv->mesh_dev); |
| 494 | if (priv->infra_open == 0) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 495 | return lbs_dev_close(dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 496 | else |
| 497 | return 0; |
| 498 | } |
| 499 | |
| 500 | /** |
| 501 | * @brief This function closes the ethX interface |
| 502 | * |
| 503 | * @param dev A pointer to net_device structure |
| 504 | * @return 0 |
| 505 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 506 | static int lbs_close(struct net_device *dev) |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 507 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 508 | struct lbs_private *priv = (struct lbs_private *) dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 509 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 510 | netif_stop_queue(dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 511 | priv->infra_open = 0; |
| 512 | if (priv->mesh_open == 0) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 513 | return lbs_dev_close(dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 514 | else |
| 515 | return 0; |
| 516 | } |
| 517 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 518 | static void lbs_tx_timeout(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 519 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 520 | struct lbs_private *priv = (struct lbs_private *) dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 521 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 522 | lbs_deb_enter(LBS_DEB_TX); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 523 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 524 | lbs_pr_err("tx watch dog timeout\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 525 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 526 | dev->trans_start = jiffies; |
| 527 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 528 | if (priv->currenttxskb) { |
David Woodhouse | a63b22b | 2007-12-08 20:56:44 +0000 | [diff] [blame] | 529 | priv->eventcause = 0x01000000; |
| 530 | lbs_send_tx_feedback(priv); |
Javier Cardona | 51d84f5 | 2007-05-25 12:06:56 -0400 | [diff] [blame] | 531 | } |
David Woodhouse | a63b22b | 2007-12-08 20:56:44 +0000 | [diff] [blame] | 532 | /* XX: Shouldn't we also call into the hw-specific driver |
| 533 | to kick it somehow? */ |
| 534 | lbs_host_to_card_done(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 535 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 536 | lbs_deb_leave(LBS_DEB_TX); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 537 | } |
| 538 | |
David Woodhouse | e775ed7 | 2007-12-06 14:36:11 +0000 | [diff] [blame] | 539 | void lbs_host_to_card_done(struct lbs_private *priv) |
| 540 | { |
David Woodhouse | a63b22b | 2007-12-08 20:56:44 +0000 | [diff] [blame] | 541 | unsigned long flags; |
| 542 | |
| 543 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | e775ed7 | 2007-12-06 14:36:11 +0000 | [diff] [blame] | 544 | |
| 545 | priv->dnld_sent = DNLD_RES_RECEIVED; |
| 546 | |
| 547 | /* Wake main thread if commands are pending */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 548 | if (!priv->cur_cmd) |
David Woodhouse | e775ed7 | 2007-12-06 14:36:11 +0000 | [diff] [blame] | 549 | wake_up_interruptible(&priv->waitq); |
| 550 | |
David Woodhouse | f86a93e | 2007-12-08 19:46:19 +0000 | [diff] [blame] | 551 | /* Don't wake netif queues if we're in monitor mode and |
David Woodhouse | a63b22b | 2007-12-08 20:56:44 +0000 | [diff] [blame] | 552 | a TX packet is already pending, or if there are commands |
| 553 | queued to be sent. */ |
| 554 | if (!priv->currenttxskb && list_empty(&priv->cmdpendingq)) { |
| 555 | if (priv->dev && priv->connect_status == LBS_CONNECTED) |
| 556 | netif_wake_queue(priv->dev); |
David Woodhouse | f86a93e | 2007-12-08 19:46:19 +0000 | [diff] [blame] | 557 | |
David Woodhouse | a63b22b | 2007-12-08 20:56:44 +0000 | [diff] [blame] | 558 | if (priv->mesh_dev && priv->mesh_connect_status == LBS_CONNECTED) |
| 559 | netif_wake_queue(priv->mesh_dev); |
| 560 | } |
| 561 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
David Woodhouse | e775ed7 | 2007-12-06 14:36:11 +0000 | [diff] [blame] | 562 | } |
| 563 | EXPORT_SYMBOL_GPL(lbs_host_to_card_done); |
| 564 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 565 | /** |
| 566 | * @brief This function returns the network statistics |
| 567 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 568 | * @param dev A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 569 | * @return A pointer to net_device_stats structure |
| 570 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 571 | static struct net_device_stats *lbs_get_stats(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 572 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 573 | struct lbs_private *priv = (struct lbs_private *) dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 574 | |
| 575 | return &priv->stats; |
| 576 | } |
| 577 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 578 | static int lbs_set_mac_address(struct net_device *dev, void *addr) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 579 | { |
| 580 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 581 | struct lbs_private *priv = (struct lbs_private *) dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 582 | struct sockaddr *phwaddr = addr; |
| 583 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 584 | lbs_deb_enter(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 585 | |
Luis Carlos Cobo Rus | 0a0d08a | 2007-05-25 23:05:27 -0400 | [diff] [blame] | 586 | /* In case it was called from the mesh device */ |
| 587 | dev = priv->dev ; |
| 588 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 589 | memset(priv->current_addr, 0, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 590 | |
| 591 | /* dev->dev_addr is 8 bytes */ |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 592 | 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] | 593 | |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 594 | lbs_deb_hex(LBS_DEB_NET, "addr", phwaddr->sa_data, ETH_ALEN); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 595 | memcpy(priv->current_addr, phwaddr->sa_data, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 596 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 597 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_MAC_ADDRESS, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 598 | CMD_ACT_SET, |
| 599 | CMD_OPTION_WAITFORRSP, 0, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 600 | |
| 601 | if (ret) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 602 | lbs_deb_net("set MAC address failed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 603 | ret = -1; |
| 604 | goto done; |
| 605 | } |
| 606 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 607 | lbs_deb_hex(LBS_DEB_NET, "priv->macaddr", priv->current_addr, ETH_ALEN); |
| 608 | memcpy(dev->dev_addr, priv->current_addr, ETH_ALEN); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 609 | if (priv->mesh_dev) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 610 | memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 611 | |
| 612 | done: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 613 | lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 614 | return ret; |
| 615 | } |
| 616 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 617 | static int lbs_copy_multicast_address(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 618 | struct net_device *dev) |
| 619 | { |
| 620 | int i = 0; |
| 621 | struct dev_mc_list *mcptr = dev->mc_list; |
| 622 | |
| 623 | for (i = 0; i < dev->mc_count; i++) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 624 | memcpy(&priv->multicastlist[i], mcptr->dmi_addr, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 625 | mcptr = mcptr->next; |
| 626 | } |
| 627 | |
| 628 | return i; |
| 629 | |
| 630 | } |
| 631 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 632 | static void lbs_set_multicast_list(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 633 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 634 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 635 | int oldpacketfilter; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 636 | DECLARE_MAC_BUF(mac); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 637 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 638 | lbs_deb_enter(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 639 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 640 | oldpacketfilter = priv->currentpacketfilter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 641 | |
| 642 | if (dev->flags & IFF_PROMISC) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 643 | lbs_deb_net("enable promiscuous mode\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 644 | priv->currentpacketfilter |= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 645 | CMD_ACT_MAC_PROMISCUOUS_ENABLE; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 646 | priv->currentpacketfilter &= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 647 | ~(CMD_ACT_MAC_ALL_MULTICAST_ENABLE | |
| 648 | CMD_ACT_MAC_MULTICAST_ENABLE); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 649 | } else { |
| 650 | /* Multicast */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 651 | priv->currentpacketfilter &= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 652 | ~CMD_ACT_MAC_PROMISCUOUS_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 653 | |
| 654 | if (dev->flags & IFF_ALLMULTI || dev->mc_count > |
| 655 | MRVDRV_MAX_MULTICAST_LIST_SIZE) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 656 | lbs_deb_net( "enabling all multicast\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 657 | priv->currentpacketfilter |= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 658 | CMD_ACT_MAC_ALL_MULTICAST_ENABLE; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 659 | priv->currentpacketfilter &= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 660 | ~CMD_ACT_MAC_MULTICAST_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 661 | } else { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 662 | priv->currentpacketfilter &= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 663 | ~CMD_ACT_MAC_ALL_MULTICAST_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 664 | |
| 665 | if (!dev->mc_count) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 666 | lbs_deb_net("no multicast addresses, " |
| 667 | "disabling multicast\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 668 | priv->currentpacketfilter &= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 669 | ~CMD_ACT_MAC_MULTICAST_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 670 | } else { |
| 671 | int i; |
| 672 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 673 | priv->currentpacketfilter |= |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 674 | CMD_ACT_MAC_MULTICAST_ENABLE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 675 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 676 | priv->nr_of_multicastmacaddr = |
| 677 | lbs_copy_multicast_address(priv, dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 678 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 679 | lbs_deb_net("multicast addresses: %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 680 | dev->mc_count); |
| 681 | |
| 682 | for (i = 0; i < dev->mc_count; i++) { |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 683 | lbs_deb_net("Multicast address %d:%s\n", |
| 684 | i, print_mac(mac, |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 685 | priv->multicastlist[i])); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 686 | } |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 687 | /* send multicast addresses to firmware */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 688 | lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 689 | CMD_MAC_MULTICAST_ADR, |
| 690 | CMD_ACT_SET, 0, 0, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 691 | NULL); |
| 692 | } |
| 693 | } |
| 694 | } |
| 695 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 696 | if (priv->currentpacketfilter != oldpacketfilter) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 697 | lbs_set_mac_packet_filter(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 698 | } |
| 699 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 700 | lbs_deb_leave(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | /** |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 704 | * @brief This function handles the major jobs in the LBS driver. |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 705 | * It handles all events generated by firmware, RX data received |
| 706 | * from firmware and TX data sent from kernel. |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 707 | * |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 708 | * @param data A pointer to lbs_thread structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 709 | * @return 0 |
| 710 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 711 | static int lbs_thread(void *data) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 712 | { |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 713 | struct net_device *dev = data; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 714 | struct lbs_private *priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 715 | wait_queue_t wait; |
| 716 | u8 ireg = 0; |
| 717 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 718 | lbs_deb_enter(LBS_DEB_THREAD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 719 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 720 | init_waitqueue_entry(&wait, current); |
| 721 | |
Dan Williams | b1b1907 | 2007-08-20 11:10:45 -0400 | [diff] [blame] | 722 | set_freezable(); |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 723 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 724 | for (;;) { |
David Woodhouse | b8d40bc | 2007-12-09 23:44:43 -0500 | [diff] [blame] | 725 | int shouldsleep; |
| 726 | |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 727 | lbs_deb_thread( "main-thread 111: intcounter=%d currenttxskb=%p dnld_sent=%d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 728 | priv->intcounter, priv->currenttxskb, priv->dnld_sent); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 729 | |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 730 | add_wait_queue(&priv->waitq, &wait); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 731 | set_current_state(TASK_INTERRUPTIBLE); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 732 | spin_lock_irq(&priv->driver_lock); |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 733 | |
David Woodhouse | b8d40bc | 2007-12-09 23:44:43 -0500 | [diff] [blame] | 734 | if (priv->surpriseremoved) |
| 735 | shouldsleep = 0; /* Bye */ |
| 736 | else if (priv->psstate == PS_STATE_SLEEP) |
| 737 | shouldsleep = 1; /* Sleep mode. Nothing we can do till it wakes */ |
| 738 | else if (priv->intcounter) |
| 739 | shouldsleep = 0; /* Interrupt pending. Deal with it now */ |
| 740 | else if (priv->dnld_sent) |
| 741 | shouldsleep = 1; /* Something is en route to the device already */ |
David Woodhouse | 2eb188a | 2007-12-09 23:54:27 -0500 | [diff] [blame] | 742 | else if (priv->tx_pending_len > 0) |
| 743 | shouldsleep = 0; /* We've a packet to send */ |
David Woodhouse | b8d40bc | 2007-12-09 23:44:43 -0500 | [diff] [blame] | 744 | else if (priv->cur_cmd) |
| 745 | shouldsleep = 1; /* Can't send a command; one already running */ |
| 746 | else if (!list_empty(&priv->cmdpendingq)) |
| 747 | shouldsleep = 0; /* We have a command to send */ |
| 748 | else |
| 749 | shouldsleep = 1; /* No command */ |
| 750 | |
| 751 | if (shouldsleep) { |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 752 | lbs_deb_thread("main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 753 | priv->connect_status, priv->intcounter, |
| 754 | priv->psmode, priv->psstate); |
| 755 | spin_unlock_irq(&priv->driver_lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 756 | schedule(); |
| 757 | } else |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 758 | spin_unlock_irq(&priv->driver_lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 759 | |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 760 | lbs_deb_thread("main-thread 222 (waking up): intcounter=%d currenttxskb=%p dnld_sent=%d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 761 | priv->intcounter, priv->currenttxskb, priv->dnld_sent); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 762 | |
| 763 | set_current_state(TASK_RUNNING); |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 764 | remove_wait_queue(&priv->waitq, &wait); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 765 | try_to_freeze(); |
| 766 | |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 767 | lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p dnld_sent=%d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 768 | priv->intcounter, priv->currenttxskb, priv->dnld_sent); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 769 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 770 | if (kthread_should_stop() || priv->surpriseremoved) { |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 771 | lbs_deb_thread("main-thread: break from main thread: surpriseremoved=0x%x\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 772 | priv->surpriseremoved); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 773 | break; |
| 774 | } |
| 775 | |
| 776 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 777 | spin_lock_irq(&priv->driver_lock); |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 778 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 779 | if (priv->intcounter) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 780 | u8 int_status; |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 781 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 782 | priv->intcounter = 0; |
Holger Schurig | 208fdd2 | 2007-05-25 12:17:06 -0400 | [diff] [blame] | 783 | int_status = priv->hw_get_int_status(priv, &ireg); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 784 | |
| 785 | if (int_status) { |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 786 | lbs_deb_thread("main-thread: reading HOST_INT_STATUS_REG failed\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 787 | spin_unlock_irq(&priv->driver_lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 788 | continue; |
| 789 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 790 | priv->hisregcpy |= ireg; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 791 | } |
| 792 | |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 793 | lbs_deb_thread("main-thread 444: intcounter=%d currenttxskb=%p dnld_sent=%d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 794 | priv->intcounter, priv->currenttxskb, priv->dnld_sent); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 795 | |
| 796 | /* command response? */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 797 | if (priv->hisregcpy & MRVDRV_CMD_UPLD_RDY) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 798 | lbs_deb_thread("main-thread: cmd response ready\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 799 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 800 | priv->hisregcpy &= ~MRVDRV_CMD_UPLD_RDY; |
| 801 | spin_unlock_irq(&priv->driver_lock); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 802 | lbs_process_rx_command(priv); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 803 | spin_lock_irq(&priv->driver_lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | /* Any Card Event */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 807 | if (priv->hisregcpy & MRVDRV_CARDEVENT) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 808 | lbs_deb_thread("main-thread: Card Event Activity\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 809 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 810 | priv->hisregcpy &= ~MRVDRV_CARDEVENT; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 811 | |
Holger Schurig | 208fdd2 | 2007-05-25 12:17:06 -0400 | [diff] [blame] | 812 | if (priv->hw_read_event_cause(priv)) { |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 813 | lbs_pr_alert("main-thread: hw_read_event_cause failed\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 814 | spin_unlock_irq(&priv->driver_lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 815 | continue; |
| 816 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 817 | spin_unlock_irq(&priv->driver_lock); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 818 | lbs_process_event(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 819 | } else |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 820 | spin_unlock_irq(&priv->driver_lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 821 | |
| 822 | /* Check if we need to confirm Sleep Request received previously */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 823 | if (priv->psstate == PS_STATE_PRE_SLEEP && |
| 824 | !priv->dnld_sent && !priv->cur_cmd) { |
| 825 | if (priv->connect_status == LBS_CONNECTED) { |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 826 | lbs_deb_thread("main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p dnld_sent=%d cur_cmd=%p, confirm now\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 827 | priv->intcounter, priv->currenttxskb, priv->dnld_sent, priv->cur_cmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 828 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 829 | lbs_ps_confirm_sleep(priv, (u16) priv->psmode); |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 830 | } else { |
| 831 | /* workaround for firmware sending |
| 832 | * deauth/linkloss event immediately |
| 833 | * after sleep request; remove this |
| 834 | * after firmware fixes it |
| 835 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 836 | priv->psstate = PS_STATE_AWAKE; |
David Woodhouse | 59f3e4b | 2007-12-08 17:42:59 +0000 | [diff] [blame] | 837 | lbs_pr_alert("main-thread: ignore PS_SleepConfirm in non-connected state\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 838 | } |
| 839 | } |
| 840 | |
| 841 | /* The PS state is changed during processing of Sleep Request |
| 842 | * event above |
| 843 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 844 | if ((priv->psstate == PS_STATE_SLEEP) || |
| 845 | (priv->psstate == PS_STATE_PRE_SLEEP)) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 846 | continue; |
| 847 | |
| 848 | /* Execute the next command */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 849 | if (!priv->dnld_sent && !priv->cur_cmd) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 850 | lbs_execute_next_command(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 851 | |
| 852 | /* Wake-up command waiters which can't sleep in |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 853 | * lbs_prepare_and_send_command |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 854 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 855 | if (!list_empty(&priv->cmdpendingq)) |
| 856 | wake_up_all(&priv->cmd_pending); |
David Woodhouse | 2eb188a | 2007-12-09 23:54:27 -0500 | [diff] [blame] | 857 | |
| 858 | spin_lock_irq(&priv->driver_lock); |
| 859 | if (!priv->dnld_sent && priv->tx_pending_len > 0) { |
| 860 | int ret = priv->hw_host_to_card(priv, MVMS_DAT, |
| 861 | priv->tx_pending_buf, |
| 862 | priv->tx_pending_len); |
| 863 | if (ret) { |
| 864 | lbs_deb_tx("host_to_card failed %d\n", ret); |
| 865 | priv->dnld_sent = DNLD_RES_RECEIVED; |
| 866 | } |
| 867 | priv->tx_pending_len = 0; |
| 868 | if (!priv->currenttxskb) { |
| 869 | /* We can wake the queues immediately if we aren't |
| 870 | waiting for TX feedback */ |
| 871 | if (priv->connect_status == LBS_CONNECTED) |
| 872 | netif_wake_queue(priv->dev); |
| 873 | if (priv->mesh_dev && |
| 874 | priv->mesh_connect_status == LBS_CONNECTED) |
| 875 | netif_wake_queue(priv->mesh_dev); |
| 876 | } |
| 877 | } |
| 878 | spin_unlock_irq(&priv->driver_lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 879 | } |
| 880 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 881 | del_timer(&priv->command_timer); |
| 882 | wake_up_all(&priv->cmd_pending); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 883 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 884 | lbs_deb_leave(LBS_DEB_THREAD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 885 | return 0; |
| 886 | } |
| 887 | |
| 888 | /** |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 889 | * @brief This function downloads firmware image, gets |
| 890 | * HW spec from firmware and set basic parameters to |
| 891 | * firmware. |
| 892 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 893 | * @param priv A pointer to struct lbs_private structure |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 894 | * @return 0 or -1 |
| 895 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 896 | static int lbs_setup_firmware(struct lbs_private *priv) |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 897 | { |
| 898 | int ret = -1; |
Luis Carlos Cobo | d21b31f | 2007-08-02 13:16:02 -0400 | [diff] [blame] | 899 | struct cmd_ds_mesh_access mesh_access; |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 900 | |
| 901 | lbs_deb_enter(LBS_DEB_FW); |
| 902 | |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 903 | /* |
| 904 | * Read MAC address from HW |
| 905 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 906 | memset(priv->current_addr, 0xff, ETH_ALEN); |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 907 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 908 | ret = lbs_prepare_and_send_command(priv, CMD_GET_HW_SPEC, |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 909 | 0, CMD_OPTION_WAITFORRSP, 0, NULL); |
| 910 | |
| 911 | if (ret) { |
| 912 | ret = -1; |
| 913 | goto done; |
| 914 | } |
| 915 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 916 | lbs_set_mac_packet_filter(priv); |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 917 | |
| 918 | /* Get the supported Data rates */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 919 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_DATA_RATE, |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 920 | CMD_ACT_GET_TX_RATE, |
| 921 | CMD_OPTION_WAITFORRSP, 0, NULL); |
| 922 | |
| 923 | if (ret) { |
| 924 | ret = -1; |
| 925 | goto done; |
| 926 | } |
| 927 | |
Luis Carlos Cobo | d21b31f | 2007-08-02 13:16:02 -0400 | [diff] [blame] | 928 | /* Disable mesh autostart */ |
| 929 | if (priv->mesh_dev) { |
| 930 | memset(&mesh_access, 0, sizeof(mesh_access)); |
| 931 | mesh_access.data[0] = cpu_to_le32(0); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 932 | ret = lbs_prepare_and_send_command(priv, |
Luis Carlos Cobo | d21b31f | 2007-08-02 13:16:02 -0400 | [diff] [blame] | 933 | CMD_MESH_ACCESS, |
| 934 | CMD_ACT_MESH_SET_AUTOSTART_ENABLED, |
| 935 | CMD_OPTION_WAITFORRSP, 0, (void *)&mesh_access); |
| 936 | if (ret) { |
| 937 | ret = -1; |
| 938 | goto done; |
| 939 | } |
| 940 | priv->mesh_autostart_enabled = 0; |
| 941 | } |
| 942 | |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 943 | ret = 0; |
| 944 | done: |
| 945 | lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret); |
| 946 | return ret; |
| 947 | } |
| 948 | |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 949 | /** |
| 950 | * This function handles the timeout of command sending. |
| 951 | * It will re-send the same command again. |
| 952 | */ |
| 953 | static void command_timer_fn(unsigned long data) |
| 954 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 955 | struct lbs_private *priv = (struct lbs_private *)data; |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 956 | struct cmd_ctrl_node *ptempnode; |
| 957 | struct cmd_ds_command *cmd; |
| 958 | unsigned long flags; |
| 959 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 960 | ptempnode = priv->cur_cmd; |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 961 | if (ptempnode == NULL) { |
| 962 | lbs_deb_fw("ptempnode empty\n"); |
| 963 | return; |
| 964 | } |
| 965 | |
| 966 | cmd = (struct cmd_ds_command *)ptempnode->bufvirtualaddr; |
| 967 | if (!cmd) { |
| 968 | lbs_deb_fw("cmd is NULL\n"); |
| 969 | return; |
| 970 | } |
| 971 | |
| 972 | lbs_deb_fw("command_timer_fn fired, cmd %x\n", cmd->command); |
| 973 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 974 | if (!priv->fw_ready) |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 975 | return; |
| 976 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 977 | spin_lock_irqsave(&priv->driver_lock, flags); |
| 978 | priv->cur_cmd = NULL; |
| 979 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 980 | |
| 981 | lbs_deb_fw("re-sending same command because of timeout\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 982 | lbs_queue_cmd(priv, ptempnode, 0); |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 983 | |
| 984 | wake_up_interruptible(&priv->waitq); |
| 985 | |
| 986 | return; |
| 987 | } |
| 988 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 989 | static int lbs_init_adapter(struct lbs_private *priv) |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 990 | { |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 991 | size_t bufsize; |
| 992 | int i, ret = 0; |
| 993 | |
| 994 | /* Allocate buffer to store the BSSID list */ |
| 995 | bufsize = MAX_NETWORK_COUNT * sizeof(struct bss_descriptor); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 996 | priv->networks = kzalloc(bufsize, GFP_KERNEL); |
| 997 | if (!priv->networks) { |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 998 | lbs_pr_err("Out of memory allocating beacons\n"); |
| 999 | ret = -1; |
| 1000 | goto out; |
| 1001 | } |
| 1002 | |
| 1003 | /* Initialize scan result lists */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1004 | INIT_LIST_HEAD(&priv->network_free_list); |
| 1005 | INIT_LIST_HEAD(&priv->network_list); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1006 | for (i = 0; i < MAX_NETWORK_COUNT; i++) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1007 | list_add_tail(&priv->networks[i].list, |
| 1008 | &priv->network_free_list); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1009 | } |
| 1010 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1011 | priv->lbs_ps_confirm_sleep.seqnum = cpu_to_le16(++priv->seqnum); |
| 1012 | priv->lbs_ps_confirm_sleep.command = |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1013 | cpu_to_le16(CMD_802_11_PS_MODE); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1014 | priv->lbs_ps_confirm_sleep.size = |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1015 | cpu_to_le16(sizeof(struct PS_CMD_ConfirmSleep)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1016 | priv->lbs_ps_confirm_sleep.action = |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1017 | cpu_to_le16(CMD_SUBCMD_SLEEP_CONFIRMED); |
| 1018 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1019 | memset(priv->current_addr, 0xff, ETH_ALEN); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1020 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1021 | priv->connect_status = LBS_DISCONNECTED; |
| 1022 | priv->mesh_connect_status = LBS_DISCONNECTED; |
| 1023 | priv->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
| 1024 | priv->mode = IW_MODE_INFRA; |
| 1025 | priv->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL; |
| 1026 | priv->currentpacketfilter = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON; |
| 1027 | priv->radioon = RADIO_ON; |
| 1028 | priv->auto_rate = 1; |
| 1029 | priv->capability = WLAN_CAPABILITY_SHORT_PREAMBLE; |
| 1030 | priv->psmode = LBS802_11POWERMODECAM; |
| 1031 | priv->psstate = PS_STATE_FULL_POWER; |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1032 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1033 | mutex_init(&priv->lock); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1034 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1035 | setup_timer(&priv->command_timer, command_timer_fn, |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1036 | (unsigned long)priv); |
| 1037 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1038 | INIT_LIST_HEAD(&priv->cmdfreeq); |
| 1039 | INIT_LIST_HEAD(&priv->cmdpendingq); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1040 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1041 | spin_lock_init(&priv->driver_lock); |
| 1042 | init_waitqueue_head(&priv->cmd_pending); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1043 | |
| 1044 | /* Allocate the command buffers */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1045 | if (lbs_allocate_cmd_buffer(priv)) { |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1046 | lbs_pr_err("Out of memory allocating command buffers\n"); |
| 1047 | ret = -1; |
| 1048 | } |
| 1049 | |
| 1050 | out: |
| 1051 | return ret; |
| 1052 | } |
| 1053 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1054 | static void lbs_free_adapter(struct lbs_private *priv) |
Holger Schurig | ac558ca | 2007-08-02 11:49:06 -0400 | [diff] [blame] | 1055 | { |
Holger Schurig | ac558ca | 2007-08-02 11:49:06 -0400 | [diff] [blame] | 1056 | lbs_deb_fw("free command buffer\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1057 | lbs_free_cmd_buffer(priv); |
Holger Schurig | ac558ca | 2007-08-02 11:49:06 -0400 | [diff] [blame] | 1058 | |
| 1059 | lbs_deb_fw("free command_timer\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1060 | del_timer(&priv->command_timer); |
Holger Schurig | ac558ca | 2007-08-02 11:49:06 -0400 | [diff] [blame] | 1061 | |
| 1062 | lbs_deb_fw("free scan results table\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1063 | kfree(priv->networks); |
| 1064 | priv->networks = NULL; |
Holger Schurig | ac558ca | 2007-08-02 11:49:06 -0400 | [diff] [blame] | 1065 | } |
| 1066 | |
Holger Schurig | 1df4e8f | 2007-08-02 11:45:12 -0400 | [diff] [blame] | 1067 | /** |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1068 | * @brief This function adds the card. it will probe the |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1069 | * card, allocate the lbs_priv and initialize the device. |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1070 | * |
| 1071 | * @param card A pointer to card |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1072 | * @return A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1073 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1074 | struct lbs_private *lbs_add_card(void *card, struct device *dmdev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1075 | { |
| 1076 | struct net_device *dev = NULL; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1077 | struct lbs_private *priv = NULL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1078 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1079 | lbs_deb_enter(LBS_DEB_NET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1080 | |
| 1081 | /* Allocate an Ethernet device and register it */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1082 | dev = alloc_etherdev(sizeof(struct lbs_private)); |
| 1083 | if (!dev) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1084 | lbs_pr_err("init ethX device failed\n"); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1085 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1086 | } |
Dan Williams | 64f104e | 2007-08-20 11:45:16 -0400 | [diff] [blame] | 1087 | priv = dev->priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1088 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1089 | if (lbs_init_adapter(priv)) { |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1090 | lbs_pr_err("failed to initialize adapter structure.\n"); |
| 1091 | goto err_init_adapter; |
| 1092 | } |
| 1093 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 1094 | priv->dev = dev; |
| 1095 | priv->card = card; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1096 | priv->mesh_open = 0; |
| 1097 | priv->infra_open = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1098 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1099 | /* Setup the OS Interface to our functions */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1100 | dev->open = lbs_open; |
David Woodhouse | 198cefb | 2007-12-09 15:04:19 -0500 | [diff] [blame] | 1101 | dev->hard_start_xmit = lbs_hard_start_xmit; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1102 | dev->stop = lbs_close; |
| 1103 | dev->set_mac_address = lbs_set_mac_address; |
| 1104 | dev->tx_timeout = lbs_tx_timeout; |
| 1105 | dev->get_stats = lbs_get_stats; |
Holger Schurig | fb3dddf | 2007-05-25 11:58:22 -0400 | [diff] [blame] | 1106 | dev->watchdog_timeo = 5 * HZ; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1107 | dev->ethtool_ops = &lbs_ethtool_ops; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1108 | #ifdef WIRELESS_EXT |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1109 | dev->wireless_handlers = (struct iw_handler_def *)&lbs_handler_def; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1110 | #endif |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1111 | dev->flags |= IFF_BROADCAST | IFF_MULTICAST; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1112 | dev->set_multicast_list = lbs_set_multicast_list; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1113 | |
Dan Williams | 7732ca4 | 2007-05-25 13:13:25 -0400 | [diff] [blame] | 1114 | SET_NETDEV_DEV(dev, dmdev); |
| 1115 | |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1116 | priv->rtap_net_dev = NULL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1117 | |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 1118 | lbs_deb_thread("Starting main thread...\n"); |
| 1119 | init_waitqueue_head(&priv->waitq); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1120 | priv->main_thread = kthread_run(lbs_thread, dev, "lbs_main"); |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 1121 | if (IS_ERR(priv->main_thread)) { |
| 1122 | lbs_deb_thread("Error creating main thread.\n"); |
David Woodhouse | e7deced | 2007-12-08 18:29:16 +0000 | [diff] [blame] | 1123 | goto err_init_adapter; |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 1124 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1125 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1126 | priv->work_thread = create_singlethread_workqueue("lbs_worker"); |
| 1127 | INIT_DELAYED_WORK(&priv->assoc_work, lbs_association_worker); |
| 1128 | INIT_DELAYED_WORK(&priv->scan_work, lbs_scan_worker); |
| 1129 | INIT_WORK(&priv->sync_channel, lbs_sync_channel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1130 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1131 | goto done; |
| 1132 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1133 | err_init_adapter: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1134 | lbs_free_adapter(priv); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1135 | free_netdev(dev); |
| 1136 | priv = NULL; |
| 1137 | |
| 1138 | done: |
| 1139 | lbs_deb_leave_args(LBS_DEB_NET, "priv %p", priv); |
| 1140 | return priv; |
| 1141 | } |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1142 | EXPORT_SYMBOL_GPL(lbs_add_card); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1143 | |
| 1144 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1145 | int lbs_remove_card(struct lbs_private *priv) |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1146 | { |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1147 | struct net_device *dev = priv->dev; |
| 1148 | union iwreq_data wrqu; |
| 1149 | |
| 1150 | lbs_deb_enter(LBS_DEB_MAIN); |
| 1151 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1152 | lbs_remove_rtap(priv); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1153 | |
| 1154 | dev = priv->dev; |
David Woodhouse | e7deced | 2007-12-08 18:29:16 +0000 | [diff] [blame] | 1155 | device_remove_file(&dev->dev, &dev_attr_lbs_rtap); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1156 | |
| 1157 | cancel_delayed_work(&priv->scan_work); |
| 1158 | cancel_delayed_work(&priv->assoc_work); |
| 1159 | destroy_workqueue(priv->work_thread); |
| 1160 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1161 | if (priv->psmode == LBS802_11POWERMODEMAX_PSP) { |
| 1162 | priv->psmode = LBS802_11POWERMODECAM; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1163 | lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1164 | } |
| 1165 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1166 | memset(wrqu.ap_addr.sa_data, 0xaa, ETH_ALEN); |
| 1167 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 1168 | wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); |
| 1169 | |
| 1170 | /* Stop the thread servicing the interrupts */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1171 | priv->surpriseremoved = 1; |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1172 | kthread_stop(priv->main_thread); |
| 1173 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1174 | lbs_free_adapter(priv); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1175 | |
| 1176 | priv->dev = NULL; |
| 1177 | free_netdev(dev); |
| 1178 | |
| 1179 | lbs_deb_leave(LBS_DEB_MAIN); |
| 1180 | return 0; |
| 1181 | } |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1182 | EXPORT_SYMBOL_GPL(lbs_remove_card); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1183 | |
| 1184 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1185 | int lbs_start_card(struct lbs_private *priv) |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1186 | { |
| 1187 | struct net_device *dev = priv->dev; |
| 1188 | int ret = -1; |
| 1189 | |
| 1190 | lbs_deb_enter(LBS_DEB_MAIN); |
| 1191 | |
| 1192 | /* poke the firmware */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1193 | ret = lbs_setup_firmware(priv); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1194 | if (ret) |
| 1195 | goto done; |
| 1196 | |
| 1197 | /* init 802.11d */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1198 | lbs_init_11d(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1199 | |
| 1200 | if (register_netdev(dev)) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1201 | lbs_pr_err("cannot register ethX device\n"); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1202 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1203 | } |
David Woodhouse | e7deced | 2007-12-08 18:29:16 +0000 | [diff] [blame] | 1204 | if (device_create_file(&dev->dev, &dev_attr_lbs_rtap)) |
| 1205 | lbs_pr_err("cannot register lbs_rtap attribute\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1206 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1207 | lbs_debugfs_init_one(priv, dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1208 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1209 | lbs_pr_info("%s: Marvell WLAN 802.11 adapter\n", dev->name); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1210 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1211 | ret = 0; |
| 1212 | |
Holger Schurig | 32a74b7 | 2007-05-25 12:04:31 -0400 | [diff] [blame] | 1213 | done: |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1214 | lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); |
Holger Schurig | 32a74b7 | 2007-05-25 12:04:31 -0400 | [diff] [blame] | 1215 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1216 | } |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1217 | EXPORT_SYMBOL_GPL(lbs_start_card); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1218 | |
| 1219 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1220 | int lbs_stop_card(struct lbs_private *priv) |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1221 | { |
| 1222 | struct net_device *dev = priv->dev; |
| 1223 | int ret = -1; |
| 1224 | struct cmd_ctrl_node *cmdnode; |
| 1225 | unsigned long flags; |
| 1226 | |
| 1227 | lbs_deb_enter(LBS_DEB_MAIN); |
| 1228 | |
| 1229 | netif_stop_queue(priv->dev); |
| 1230 | netif_carrier_off(priv->dev); |
| 1231 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1232 | lbs_debugfs_remove_one(priv); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1233 | |
| 1234 | /* Flush pending command nodes */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1235 | spin_lock_irqsave(&priv->driver_lock, flags); |
| 1236 | list_for_each_entry(cmdnode, &priv->cmdpendingq, list) { |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1237 | cmdnode->cmdwaitqwoken = 1; |
| 1238 | wake_up_interruptible(&cmdnode->cmdwait_q); |
| 1239 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1240 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1241 | |
| 1242 | unregister_netdev(dev); |
| 1243 | |
| 1244 | lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); |
| 1245 | return ret; |
| 1246 | } |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1247 | EXPORT_SYMBOL_GPL(lbs_stop_card); |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1248 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1249 | |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1250 | /** |
| 1251 | * @brief This function adds mshX interface |
| 1252 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1253 | * @param priv A pointer to the struct lbs_private structure |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1254 | * @return 0 if successful, -X otherwise |
| 1255 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1256 | int lbs_add_mesh(struct lbs_private *priv, struct device *dev) |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1257 | { |
| 1258 | struct net_device *mesh_dev = NULL; |
| 1259 | int ret = 0; |
| 1260 | |
| 1261 | lbs_deb_enter(LBS_DEB_MESH); |
| 1262 | |
| 1263 | /* Allocate a virtual mesh device */ |
| 1264 | if (!(mesh_dev = alloc_netdev(0, "msh%d", ether_setup))) { |
| 1265 | lbs_deb_mesh("init mshX device failed\n"); |
| 1266 | ret = -ENOMEM; |
| 1267 | goto done; |
| 1268 | } |
| 1269 | mesh_dev->priv = priv; |
| 1270 | priv->mesh_dev = mesh_dev; |
| 1271 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1272 | mesh_dev->open = lbs_mesh_open; |
David Woodhouse | 198cefb | 2007-12-09 15:04:19 -0500 | [diff] [blame] | 1273 | mesh_dev->hard_start_xmit = lbs_hard_start_xmit; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1274 | mesh_dev->stop = lbs_mesh_close; |
| 1275 | mesh_dev->get_stats = lbs_get_stats; |
| 1276 | mesh_dev->set_mac_address = lbs_set_mac_address; |
| 1277 | mesh_dev->ethtool_ops = &lbs_ethtool_ops; |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 1278 | memcpy(mesh_dev->dev_addr, priv->dev->dev_addr, |
| 1279 | sizeof(priv->dev->dev_addr)); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1280 | |
Dan Williams | 7732ca4 | 2007-05-25 13:13:25 -0400 | [diff] [blame] | 1281 | SET_NETDEV_DEV(priv->mesh_dev, dev); |
| 1282 | |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1283 | #ifdef WIRELESS_EXT |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 1284 | mesh_dev->wireless_handlers = (struct iw_handler_def *)&mesh_handler_def; |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1285 | #endif |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1286 | /* Register virtual mesh interface */ |
| 1287 | ret = register_netdev(mesh_dev); |
| 1288 | if (ret) { |
| 1289 | lbs_pr_err("cannot register mshX virtual interface\n"); |
| 1290 | goto err_free; |
| 1291 | } |
| 1292 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1293 | ret = sysfs_create_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1294 | if (ret) |
| 1295 | goto err_unregister; |
| 1296 | |
| 1297 | /* Everything successful */ |
| 1298 | ret = 0; |
| 1299 | goto done; |
| 1300 | |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1301 | err_unregister: |
| 1302 | unregister_netdev(mesh_dev); |
| 1303 | |
| 1304 | err_free: |
| 1305 | free_netdev(mesh_dev); |
| 1306 | |
| 1307 | done: |
| 1308 | lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret); |
| 1309 | return ret; |
| 1310 | } |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1311 | EXPORT_SYMBOL_GPL(lbs_add_mesh); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1312 | |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1313 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1314 | void lbs_remove_mesh(struct lbs_private *priv) |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1315 | { |
| 1316 | struct net_device *mesh_dev; |
| 1317 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1318 | lbs_deb_enter(LBS_DEB_MAIN); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1319 | |
| 1320 | if (!priv) |
| 1321 | goto out; |
| 1322 | |
| 1323 | mesh_dev = priv->mesh_dev; |
| 1324 | |
| 1325 | netif_stop_queue(mesh_dev); |
Javier Cardona | 51d84f5 | 2007-05-25 12:06:56 -0400 | [diff] [blame] | 1326 | netif_carrier_off(priv->mesh_dev); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1327 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1328 | sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1329 | unregister_netdev(mesh_dev); |
| 1330 | |
| 1331 | priv->mesh_dev = NULL ; |
| 1332 | free_netdev(mesh_dev); |
| 1333 | |
| 1334 | out: |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 1335 | lbs_deb_leave(LBS_DEB_MAIN); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1336 | } |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1337 | EXPORT_SYMBOL_GPL(lbs_remove_mesh); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 1338 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1339 | /** |
| 1340 | * @brief This function finds the CFP in |
| 1341 | * region_cfp_table based on region and band parameter. |
| 1342 | * |
| 1343 | * @param region The region code |
| 1344 | * @param band The band |
| 1345 | * @param cfp_no A pointer to CFP number |
| 1346 | * @return A pointer to CFP |
| 1347 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1348 | struct chan_freq_power *lbs_get_region_cfp_table(u8 region, u8 band, int *cfp_no) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1349 | { |
| 1350 | int i, end; |
| 1351 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1352 | lbs_deb_enter(LBS_DEB_MAIN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1353 | |
Denis Cheng | ff8ac60 | 2007-09-02 18:30:18 +0800 | [diff] [blame] | 1354 | end = ARRAY_SIZE(region_cfp_table); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1355 | |
| 1356 | for (i = 0; i < end ; i++) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1357 | lbs_deb_main("region_cfp_table[i].region=%d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1358 | region_cfp_table[i].region); |
| 1359 | if (region_cfp_table[i].region == region) { |
| 1360 | *cfp_no = region_cfp_table[i].cfp_no_BG; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1361 | lbs_deb_leave(LBS_DEB_MAIN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1362 | return region_cfp_table[i].cfp_BG; |
| 1363 | } |
| 1364 | } |
| 1365 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1366 | lbs_deb_leave_args(LBS_DEB_MAIN, "ret NULL"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1367 | return NULL; |
| 1368 | } |
| 1369 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1370 | int lbs_set_regiontable(struct lbs_private *priv, u8 region, u8 band) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1371 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1372 | int ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1373 | int i = 0; |
| 1374 | |
| 1375 | struct chan_freq_power *cfp; |
| 1376 | int cfp_no; |
| 1377 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1378 | lbs_deb_enter(LBS_DEB_MAIN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1379 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1380 | memset(priv->region_channel, 0, sizeof(priv->region_channel)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1381 | |
| 1382 | { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1383 | cfp = lbs_get_region_cfp_table(region, band, &cfp_no); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1384 | if (cfp != NULL) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1385 | priv->region_channel[i].nrcfp = cfp_no; |
| 1386 | priv->region_channel[i].CFP = cfp; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1387 | } else { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1388 | lbs_deb_main("wrong region code %#x in band B/G\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1389 | region); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1390 | ret = -1; |
| 1391 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1392 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1393 | priv->region_channel[i].valid = 1; |
| 1394 | priv->region_channel[i].region = region; |
| 1395 | priv->region_channel[i].band = band; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1396 | i++; |
| 1397 | } |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1398 | out: |
| 1399 | lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); |
| 1400 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1401 | } |
| 1402 | |
| 1403 | /** |
| 1404 | * @brief This function handles the interrupt. it will change PS |
| 1405 | * state if applicable. it will wake up main_thread to handle |
| 1406 | * the interrupt event as well. |
| 1407 | * |
| 1408 | * @param dev A pointer to net_device structure |
| 1409 | * @return n/a |
| 1410 | */ |
David Woodhouse | 4f67949 | 2007-12-10 14:58:37 -0500 | [diff] [blame^] | 1411 | void lbs_interrupt(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1412 | { |
Holger Schurig | ed37b51 | 2007-05-25 11:52:42 -0400 | [diff] [blame] | 1413 | lbs_deb_enter(LBS_DEB_THREAD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1414 | |
David Woodhouse | 4f67949 | 2007-12-10 14:58:37 -0500 | [diff] [blame^] | 1415 | lbs_deb_thread("lbs_interrupt: intcounter=%d\n", priv->intcounter); |
| 1416 | |
| 1417 | if (spin_trylock(&priv->driver_lock)) { |
| 1418 | spin_unlock(&priv->driver_lock); |
| 1419 | printk(KERN_CRIT "%s called without driver_lock held\n", __func__); |
| 1420 | WARN_ON(1); |
| 1421 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1422 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1423 | priv->intcounter++; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1424 | |
David Woodhouse | 4f67949 | 2007-12-10 14:58:37 -0500 | [diff] [blame^] | 1425 | if (priv->psstate == PS_STATE_SLEEP) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1426 | priv->psstate = PS_STATE_AWAKE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1427 | |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 1428 | wake_up_interruptible(&priv->waitq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1429 | |
Holger Schurig | ed37b51 | 2007-05-25 11:52:42 -0400 | [diff] [blame] | 1430 | lbs_deb_leave(LBS_DEB_THREAD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1431 | } |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1432 | EXPORT_SYMBOL_GPL(lbs_interrupt); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1433 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1434 | int lbs_reset_device(struct lbs_private *priv) |
Dan Williams | eedc2a3 | 2007-08-02 11:36:22 -0400 | [diff] [blame] | 1435 | { |
| 1436 | int ret; |
| 1437 | |
| 1438 | lbs_deb_enter(LBS_DEB_MAIN); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1439 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_RESET, |
Dan Williams | eedc2a3 | 2007-08-02 11:36:22 -0400 | [diff] [blame] | 1440 | CMD_ACT_HALT, 0, 0, NULL); |
| 1441 | msleep_interruptible(10); |
| 1442 | |
| 1443 | lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); |
| 1444 | return ret; |
| 1445 | } |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1446 | EXPORT_SYMBOL_GPL(lbs_reset_device); |
Dan Williams | eedc2a3 | 2007-08-02 11:36:22 -0400 | [diff] [blame] | 1447 | |
Andres Salomon | 4fb910f | 2007-11-20 17:43:45 -0500 | [diff] [blame] | 1448 | static int __init lbs_init_module(void) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1449 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1450 | lbs_deb_enter(LBS_DEB_MAIN); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1451 | lbs_debugfs_init(); |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1452 | lbs_deb_leave(LBS_DEB_MAIN); |
| 1453 | return 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1454 | } |
| 1455 | |
Andres Salomon | 4fb910f | 2007-11-20 17:43:45 -0500 | [diff] [blame] | 1456 | static void __exit lbs_exit_module(void) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1457 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1458 | lbs_deb_enter(LBS_DEB_MAIN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1459 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1460 | lbs_debugfs_remove(); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1461 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1462 | lbs_deb_leave(LBS_DEB_MAIN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1463 | } |
| 1464 | |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1465 | /* |
| 1466 | * rtap interface support fuctions |
| 1467 | */ |
| 1468 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1469 | static int lbs_rtap_open(struct net_device *dev) |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1470 | { |
| 1471 | netif_carrier_off(dev); |
| 1472 | netif_stop_queue(dev); |
| 1473 | return 0; |
| 1474 | } |
| 1475 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1476 | static int lbs_rtap_stop(struct net_device *dev) |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1477 | { |
| 1478 | return 0; |
| 1479 | } |
| 1480 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1481 | static int lbs_rtap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1482 | { |
| 1483 | netif_stop_queue(dev); |
| 1484 | return -EOPNOTSUPP; |
| 1485 | } |
| 1486 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1487 | static struct net_device_stats *lbs_rtap_get_stats(struct net_device *dev) |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1488 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1489 | struct lbs_private *priv = dev->priv; |
David Woodhouse | d9268fb | 2007-12-09 16:22:21 -0500 | [diff] [blame] | 1490 | return &priv->stats; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1491 | } |
| 1492 | |
| 1493 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1494 | void lbs_remove_rtap(struct lbs_private *priv) |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1495 | { |
| 1496 | if (priv->rtap_net_dev == NULL) |
| 1497 | return; |
| 1498 | unregister_netdev(priv->rtap_net_dev); |
David Woodhouse | d9268fb | 2007-12-09 16:22:21 -0500 | [diff] [blame] | 1499 | free_netdev(priv->rtap_net_dev); |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1500 | priv->rtap_net_dev = NULL; |
| 1501 | } |
| 1502 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1503 | int lbs_add_rtap(struct lbs_private *priv) |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1504 | { |
| 1505 | int rc = 0; |
David Woodhouse | d9268fb | 2007-12-09 16:22:21 -0500 | [diff] [blame] | 1506 | struct net_device *rtap_dev; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1507 | |
| 1508 | if (priv->rtap_net_dev) |
| 1509 | return -EPERM; |
| 1510 | |
David Woodhouse | d9268fb | 2007-12-09 16:22:21 -0500 | [diff] [blame] | 1511 | rtap_dev = alloc_netdev(0, "rtap%d", ether_setup); |
| 1512 | if (rtap_dev == NULL) |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1513 | return -ENOMEM; |
| 1514 | |
David Woodhouse | 121947c | 2007-12-09 19:54:11 -0500 | [diff] [blame] | 1515 | memcpy(rtap_dev->dev_addr, priv->current_addr, ETH_ALEN); |
David Woodhouse | d9268fb | 2007-12-09 16:22:21 -0500 | [diff] [blame] | 1516 | rtap_dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 1517 | rtap_dev->open = lbs_rtap_open; |
| 1518 | rtap_dev->stop = lbs_rtap_stop; |
| 1519 | rtap_dev->get_stats = lbs_rtap_get_stats; |
| 1520 | rtap_dev->hard_start_xmit = lbs_rtap_hard_start_xmit; |
| 1521 | rtap_dev->set_multicast_list = lbs_set_multicast_list; |
| 1522 | rtap_dev->priv = priv; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1523 | |
David Woodhouse | d9268fb | 2007-12-09 16:22:21 -0500 | [diff] [blame] | 1524 | rc = register_netdev(rtap_dev); |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1525 | if (rc) { |
David Woodhouse | d9268fb | 2007-12-09 16:22:21 -0500 | [diff] [blame] | 1526 | free_netdev(rtap_dev); |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1527 | return rc; |
| 1528 | } |
David Woodhouse | d9268fb | 2007-12-09 16:22:21 -0500 | [diff] [blame] | 1529 | priv->rtap_net_dev = rtap_dev; |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1530 | |
| 1531 | return 0; |
| 1532 | } |
| 1533 | |
| 1534 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1535 | module_init(lbs_init_module); |
| 1536 | module_exit(lbs_exit_module); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1537 | |
Holger Schurig | 084708b | 2007-05-25 12:37:58 -0400 | [diff] [blame] | 1538 | MODULE_DESCRIPTION("Libertas WLAN Driver Library"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1539 | MODULE_AUTHOR("Marvell International Ltd."); |
| 1540 | MODULE_LICENSE("GPL"); |