Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of wl1271 |
| 3 | * |
| 4 | * Copyright (C) 2009 Nokia Corporation |
| 5 | * |
| 6 | * Contact: Luciano Coelho <luciano.coelho@nokia.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License |
| 10 | * version 2 as published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 20 | * 02110-1301 USA |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 26 | #include <linux/slab.h> |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 27 | |
Luciano Coelho | 0f4e312 | 2011-10-07 11:02:42 +0300 | [diff] [blame^] | 28 | #include "debug.h" |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 29 | #include "init.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 30 | #include "wl12xx_80211.h" |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 31 | #include "acx.h" |
| 32 | #include "cmd.h" |
| 33 | #include "reg.h" |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 34 | #include "tx.h" |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 35 | #include "io.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 36 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 37 | int wl1271_init_templates_config(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 38 | { |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 39 | int ret, i; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 40 | |
| 41 | /* send empty templates for fw memory reservation */ |
| 42 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL, |
Eliad Peller | 154037d | 2011-08-14 13:17:12 +0300 | [diff] [blame] | 43 | WL1271_CMD_TEMPL_DFLT_SIZE, |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 44 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 45 | if (ret < 0) |
| 46 | return ret; |
| 47 | |
Juuso Oikarinen | 11eb542 | 2010-08-24 06:28:03 +0300 | [diff] [blame] | 48 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5, |
Eliad Peller | 154037d | 2011-08-14 13:17:12 +0300 | [diff] [blame] | 49 | NULL, WL1271_CMD_TEMPL_DFLT_SIZE, 0, |
Juuso Oikarinen | 11eb542 | 2010-08-24 06:28:03 +0300 | [diff] [blame] | 50 | WL1271_RATE_AUTOMATIC); |
| 51 | if (ret < 0) |
| 52 | return ret; |
Teemu Paasikivi | abb0b3b | 2009-10-13 12:47:50 +0300 | [diff] [blame] | 53 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 54 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL, |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 55 | sizeof(struct wl12xx_null_data_template), |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 56 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 57 | if (ret < 0) |
| 58 | return ret; |
| 59 | |
| 60 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, NULL, |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 61 | sizeof(struct wl12xx_ps_poll_template), |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 62 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 63 | if (ret < 0) |
| 64 | return ret; |
| 65 | |
| 66 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL, |
| 67 | sizeof |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 68 | (struct wl12xx_qos_null_data_template), |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 69 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 70 | if (ret < 0) |
| 71 | return ret; |
| 72 | |
| 73 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL, |
Eliad Peller | 154037d | 2011-08-14 13:17:12 +0300 | [diff] [blame] | 74 | WL1271_CMD_TEMPL_DFLT_SIZE, |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 75 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 76 | if (ret < 0) |
| 77 | return ret; |
| 78 | |
| 79 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL, |
Eliad Peller | 154037d | 2011-08-14 13:17:12 +0300 | [diff] [blame] | 80 | WL1271_CMD_TEMPL_DFLT_SIZE, |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 81 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 82 | if (ret < 0) |
| 83 | return ret; |
| 84 | |
Eliad Peller | c531277 | 2010-12-09 11:31:27 +0200 | [diff] [blame] | 85 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, NULL, |
| 86 | sizeof |
| 87 | (struct wl12xx_arp_rsp_template), |
| 88 | 0, WL1271_RATE_AUTOMATIC); |
| 89 | if (ret < 0) |
| 90 | return ret; |
| 91 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 92 | /* |
| 93 | * Put very large empty placeholders for all templates. These |
| 94 | * reserve memory for later. |
| 95 | */ |
| 96 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL, |
| 97 | WL1271_CMD_TEMPL_MAX_SIZE, |
| 98 | 0, WL1271_RATE_AUTOMATIC); |
| 99 | if (ret < 0) |
| 100 | return ret; |
| 101 | |
| 102 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL, |
| 103 | WL1271_CMD_TEMPL_MAX_SIZE, |
| 104 | 0, WL1271_RATE_AUTOMATIC); |
| 105 | if (ret < 0) |
| 106 | return ret; |
| 107 | |
| 108 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL, |
| 109 | sizeof |
| 110 | (struct wl12xx_disconn_template), |
| 111 | 0, WL1271_RATE_AUTOMATIC); |
| 112 | if (ret < 0) |
| 113 | return ret; |
| 114 | |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 115 | for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { |
| 116 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL, |
Eliad Peller | 154037d | 2011-08-14 13:17:12 +0300 | [diff] [blame] | 117 | WL1271_CMD_TEMPL_DFLT_SIZE, i, |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 118 | WL1271_RATE_AUTOMATIC); |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 119 | if (ret < 0) |
| 120 | return ret; |
| 121 | } |
| 122 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 123 | return 0; |
| 124 | } |
| 125 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 126 | static int wl1271_ap_init_deauth_template(struct wl1271 *wl, |
| 127 | struct wl12xx_vif *wlvif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 128 | { |
| 129 | struct wl12xx_disconn_template *tmpl; |
| 130 | int ret; |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 131 | u32 rate; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 132 | |
| 133 | tmpl = kzalloc(sizeof(*tmpl), GFP_KERNEL); |
| 134 | if (!tmpl) { |
| 135 | ret = -ENOMEM; |
| 136 | goto out; |
| 137 | } |
| 138 | |
| 139 | tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 140 | IEEE80211_STYPE_DEAUTH); |
| 141 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 142 | rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 143 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 144 | tmpl, sizeof(*tmpl), 0, rate); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 145 | |
| 146 | out: |
| 147 | kfree(tmpl); |
| 148 | return ret; |
| 149 | } |
| 150 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 151 | static int wl1271_ap_init_null_template(struct wl1271 *wl, |
| 152 | struct ieee80211_vif *vif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 153 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 154 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 155 | struct ieee80211_hdr_3addr *nullfunc; |
| 156 | int ret; |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 157 | u32 rate; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 158 | |
| 159 | nullfunc = kzalloc(sizeof(*nullfunc), GFP_KERNEL); |
| 160 | if (!nullfunc) { |
| 161 | ret = -ENOMEM; |
| 162 | goto out; |
| 163 | } |
| 164 | |
| 165 | nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | |
| 166 | IEEE80211_STYPE_NULLFUNC | |
| 167 | IEEE80211_FCTL_FROMDS); |
| 168 | |
| 169 | /* nullfunc->addr1 is filled by FW */ |
| 170 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 171 | memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); |
| 172 | memcpy(nullfunc->addr3, vif->addr, ETH_ALEN); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 173 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 174 | rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 175 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 176 | sizeof(*nullfunc), 0, rate); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 177 | |
| 178 | out: |
| 179 | kfree(nullfunc); |
| 180 | return ret; |
| 181 | } |
| 182 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 183 | static int wl1271_ap_init_qos_null_template(struct wl1271 *wl, |
| 184 | struct ieee80211_vif *vif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 185 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 186 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 187 | struct ieee80211_qos_hdr *qosnull; |
| 188 | int ret; |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 189 | u32 rate; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 190 | |
| 191 | qosnull = kzalloc(sizeof(*qosnull), GFP_KERNEL); |
| 192 | if (!qosnull) { |
| 193 | ret = -ENOMEM; |
| 194 | goto out; |
| 195 | } |
| 196 | |
| 197 | qosnull->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | |
| 198 | IEEE80211_STYPE_QOS_NULLFUNC | |
| 199 | IEEE80211_FCTL_FROMDS); |
| 200 | |
| 201 | /* qosnull->addr1 is filled by FW */ |
| 202 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 203 | memcpy(qosnull->addr2, vif->addr, ETH_ALEN); |
| 204 | memcpy(qosnull->addr3, vif->addr, ETH_ALEN); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 205 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 206 | rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 207 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 208 | sizeof(*qosnull), 0, rate); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 209 | |
| 210 | out: |
| 211 | kfree(qosnull); |
| 212 | return ret; |
| 213 | } |
| 214 | |
Eliad Peller | 08c1d1c | 2011-08-14 13:17:04 +0300 | [diff] [blame] | 215 | static int wl12xx_init_rx_config(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 216 | { |
| 217 | int ret; |
| 218 | |
Juuso Oikarinen | 8793f9b | 2009-10-13 12:47:40 +0300 | [diff] [blame] | 219 | ret = wl1271_acx_rx_msdu_life_time(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 220 | if (ret < 0) |
| 221 | return ret; |
| 222 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 223 | return 0; |
| 224 | } |
| 225 | |
Luciano Coelho | 12419cc | 2010-02-18 13:25:44 +0200 | [diff] [blame] | 226 | int wl1271_init_phy_config(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 227 | { |
| 228 | int ret; |
| 229 | |
| 230 | ret = wl1271_acx_pd_threshold(wl); |
| 231 | if (ret < 0) |
| 232 | return ret; |
| 233 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 234 | return 0; |
| 235 | } |
| 236 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 237 | static int wl12xx_init_phy_vif_config(struct wl1271 *wl, |
| 238 | struct wl12xx_vif *wlvif) |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 239 | { |
| 240 | int ret; |
| 241 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 242 | ret = wl1271_acx_slot(wl, wlvif, DEFAULT_SLOT_TIME); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 243 | if (ret < 0) |
| 244 | return ret; |
| 245 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 246 | ret = wl1271_acx_service_period_timeout(wl, wlvif); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 247 | if (ret < 0) |
| 248 | return ret; |
| 249 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 250 | ret = wl1271_acx_rts_threshold(wl, wlvif, wl->hw->wiphy->rts_threshold); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 251 | if (ret < 0) |
| 252 | return ret; |
| 253 | |
| 254 | return 0; |
| 255 | } |
| 256 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 257 | static int wl1271_init_beacon_filter(struct wl1271 *wl, |
| 258 | struct wl12xx_vif *wlvif) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 259 | { |
| 260 | int ret; |
| 261 | |
Juuso Oikarinen | 1922167 | 2009-10-08 21:56:35 +0300 | [diff] [blame] | 262 | /* disable beacon filtering at this stage */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 263 | ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 264 | if (ret < 0) |
| 265 | return ret; |
| 266 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 267 | ret = wl1271_acx_beacon_filter_table(wl, wlvif); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 268 | if (ret < 0) |
| 269 | return ret; |
| 270 | |
| 271 | return 0; |
| 272 | } |
| 273 | |
Luciano Coelho | 12419cc | 2010-02-18 13:25:44 +0200 | [diff] [blame] | 274 | int wl1271_init_pta(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 275 | { |
| 276 | int ret; |
| 277 | |
Eliad Peller | 3be4112 | 2011-08-14 13:17:19 +0300 | [diff] [blame] | 278 | ret = wl12xx_acx_sg_cfg(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 279 | if (ret < 0) |
| 280 | return ret; |
| 281 | |
Juuso Oikarinen | 7fc3a86 | 2010-03-18 12:26:32 +0200 | [diff] [blame] | 282 | ret = wl1271_acx_sg_enable(wl, wl->sg_enabled); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 283 | if (ret < 0) |
| 284 | return ret; |
| 285 | |
| 286 | return 0; |
| 287 | } |
| 288 | |
Luciano Coelho | 12419cc | 2010-02-18 13:25:44 +0200 | [diff] [blame] | 289 | int wl1271_init_energy_detection(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 290 | { |
| 291 | int ret; |
| 292 | |
| 293 | ret = wl1271_acx_cca_threshold(wl); |
| 294 | if (ret < 0) |
| 295 | return ret; |
| 296 | |
| 297 | return 0; |
| 298 | } |
| 299 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 300 | static int wl1271_init_beacon_broadcast(struct wl1271 *wl, |
| 301 | struct wl12xx_vif *wlvif) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 302 | { |
| 303 | int ret; |
| 304 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 305 | ret = wl1271_acx_bcn_dtim_options(wl, wlvif); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 306 | if (ret < 0) |
| 307 | return ret; |
| 308 | |
| 309 | return 0; |
| 310 | } |
| 311 | |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 312 | static int wl12xx_init_fwlog(struct wl1271 *wl) |
| 313 | { |
| 314 | int ret; |
| 315 | |
| 316 | if (wl->quirks & WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED) |
| 317 | return 0; |
| 318 | |
| 319 | ret = wl12xx_cmd_config_fwlog(wl); |
| 320 | if (ret < 0) |
| 321 | return ret; |
| 322 | |
| 323 | return 0; |
| 324 | } |
| 325 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 326 | /* generic sta initialization (non vif-specific) */ |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 327 | static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 328 | { |
| 329 | int ret; |
| 330 | |
Shahar Levi | 49d750ca | 2011-03-06 16:32:09 +0200 | [diff] [blame] | 331 | if (wl->chip.id != CHIP_ID_1283_PG20) { |
| 332 | ret = wl1271_cmd_ext_radio_parms(wl); |
| 333 | if (ret < 0) |
| 334 | return ret; |
| 335 | } |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 336 | |
Eliad Peller | c8bde24 | 2011-02-02 09:59:35 +0200 | [diff] [blame] | 337 | /* PS config */ |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 338 | ret = wl12xx_acx_config_ps(wl, wlvif); |
Eliad Peller | c8bde24 | 2011-02-02 09:59:35 +0200 | [diff] [blame] | 339 | if (ret < 0) |
| 340 | return ret; |
| 341 | |
Shahar Levi | ff86843 | 2011-04-11 15:41:46 +0300 | [diff] [blame] | 342 | /* FM WLAN coexistence */ |
| 343 | ret = wl1271_acx_fm_coex(wl); |
| 344 | if (ret < 0) |
| 345 | return ret; |
| 346 | |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 347 | ret = wl1271_acx_sta_rate_policies(wl, wlvif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 348 | if (ret < 0) |
| 349 | return ret; |
| 350 | |
| 351 | return 0; |
| 352 | } |
| 353 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 354 | static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl, |
| 355 | struct ieee80211_vif *vif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 356 | { |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 357 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 358 | int ret, i; |
| 359 | |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 360 | /* disable all keep-alive templates */ |
| 361 | for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 362 | ret = wl1271_acx_keep_alive_config(wl, wlvif, i, |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 363 | ACX_KEEP_ALIVE_TPL_INVALID); |
| 364 | if (ret < 0) |
| 365 | return ret; |
| 366 | } |
| 367 | |
| 368 | /* disable the keep-alive feature */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 369 | ret = wl1271_acx_keep_alive_mode(wl, wlvif, false); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 370 | if (ret < 0) |
| 371 | return ret; |
| 372 | |
| 373 | return 0; |
| 374 | } |
| 375 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 376 | /* generic ap initialization (non vif-specific) */ |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 377 | static int wl1271_ap_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 378 | { |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 379 | int ret; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 380 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 381 | ret = wl1271_init_ap_rates(wl, wlvif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 382 | if (ret < 0) |
| 383 | return ret; |
| 384 | |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 385 | return 0; |
| 386 | } |
| 387 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 388 | int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 389 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 390 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 391 | int ret; |
| 392 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 393 | ret = wl1271_ap_init_deauth_template(wl, wlvif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 394 | if (ret < 0) |
| 395 | return ret; |
| 396 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 397 | ret = wl1271_ap_init_null_template(wl, vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 398 | if (ret < 0) |
| 399 | return ret; |
| 400 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 401 | ret = wl1271_ap_init_qos_null_template(wl, vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 402 | if (ret < 0) |
| 403 | return ret; |
| 404 | |
Arik Nemtsov | 521a4a2 | 2011-04-18 14:15:22 +0300 | [diff] [blame] | 405 | /* |
| 406 | * when operating as AP we want to receive external beacons for |
| 407 | * configuring ERP protection. |
| 408 | */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 409 | ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); |
Arik Nemtsov | 521a4a2 | 2011-04-18 14:15:22 +0300 | [diff] [blame] | 410 | if (ret < 0) |
| 411 | return ret; |
| 412 | |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 413 | return 0; |
| 414 | } |
| 415 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 416 | static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl, |
| 417 | struct ieee80211_vif *vif) |
Arik Nemtsov | c45a85b | 2011-04-18 14:15:26 +0300 | [diff] [blame] | 418 | { |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 419 | return wl1271_ap_init_templates(wl, vif); |
Arik Nemtsov | c45a85b | 2011-04-18 14:15:26 +0300 | [diff] [blame] | 420 | } |
| 421 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 422 | int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 423 | { |
| 424 | int i, ret; |
| 425 | struct conf_tx_rate_class rc; |
| 426 | u32 supported_rates; |
| 427 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 428 | wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", |
| 429 | wlvif->basic_rate_set); |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 430 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 431 | if (wlvif->basic_rate_set == 0) |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 432 | return -EINVAL; |
| 433 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 434 | rc.enabled_rates = wlvif->basic_rate_set; |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 435 | rc.long_retry_limit = 10; |
| 436 | rc.short_retry_limit = 10; |
| 437 | rc.aflags = 0; |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 438 | ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.mgmt_rate_idx); |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 439 | if (ret < 0) |
| 440 | return ret; |
| 441 | |
| 442 | /* use the min basic rate for AP broadcast/multicast */ |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 443 | rc.enabled_rates = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 444 | rc.short_retry_limit = 10; |
| 445 | rc.long_retry_limit = 10; |
| 446 | rc.aflags = 0; |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 447 | ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.bcast_rate_idx); |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 448 | if (ret < 0) |
| 449 | return ret; |
| 450 | |
| 451 | /* |
| 452 | * If the basic rates contain OFDM rates, use OFDM only |
| 453 | * rates for unicast TX as well. Else use all supported rates. |
| 454 | */ |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 455 | if ((wlvif->basic_rate_set & CONF_TX_OFDM_RATES)) |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 456 | supported_rates = CONF_TX_OFDM_RATES; |
| 457 | else |
| 458 | supported_rates = CONF_TX_AP_ENABLED_RATES; |
| 459 | |
Arik Nemtsov | 1a8adb6 | 2011-08-14 13:17:29 +0300 | [diff] [blame] | 460 | /* unconditionally enable HT rates */ |
| 461 | supported_rates |= CONF_TX_MCS_RATES; |
| 462 | |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 463 | /* configure unicast TX rate classes */ |
| 464 | for (i = 0; i < wl->conf.tx.ac_conf_count; i++) { |
| 465 | rc.enabled_rates = supported_rates; |
| 466 | rc.short_retry_limit = 10; |
| 467 | rc.long_retry_limit = 10; |
| 468 | rc.aflags = 0; |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 469 | ret = wl1271_acx_ap_rate_policy(wl, &rc, |
| 470 | wlvif->ap.ucast_rate_idx[i]); |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 471 | if (ret < 0) |
| 472 | return ret; |
| 473 | } |
| 474 | |
| 475 | return 0; |
| 476 | } |
| 477 | |
Eliad Peller | 536129c8 | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 478 | static int wl1271_set_ba_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 479 | { |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 480 | /* Reset the BA RX indicators */ |
Eliad Peller | d0802ab | 2011-10-05 11:56:04 +0200 | [diff] [blame] | 481 | wlvif->ba_allowed = true; |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 482 | wl->ba_rx_session_count = 0; |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 483 | |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 484 | /* BA is supported in STA/AP modes */ |
Eliad Peller | 536129c8 | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 485 | if (wlvif->bss_type != BSS_TYPE_AP_BSS && |
| 486 | wlvif->bss_type != BSS_TYPE_STA_BSS) { |
Eliad Peller | d0802ab | 2011-10-05 11:56:04 +0200 | [diff] [blame] | 487 | wlvif->ba_support = false; |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 488 | return 0; |
| 489 | } |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 490 | |
Eliad Peller | d0802ab | 2011-10-05 11:56:04 +0200 | [diff] [blame] | 491 | wlvif->ba_support = true; |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 492 | |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 493 | /* 802.11n initiator BA session setting */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 494 | return wl12xx_acx_set_ba_initiator_policy(wl, wlvif); |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 495 | } |
| 496 | |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 497 | int wl1271_chip_specific_init(struct wl1271 *wl) |
| 498 | { |
| 499 | int ret = 0; |
| 500 | |
| 501 | if (wl->chip.id == CHIP_ID_1283_PG20) { |
| 502 | u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE; |
| 503 | |
Ido Yariv | 0da13da | 2011-03-31 10:06:58 +0200 | [diff] [blame] | 504 | if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT) |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 505 | /* Enable SDIO padding */ |
| 506 | host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK; |
| 507 | |
| 508 | /* Must be before wl1271_acx_init_mem_config() */ |
| 509 | ret = wl1271_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap); |
| 510 | if (ret < 0) |
| 511 | goto out; |
| 512 | } |
| 513 | out: |
| 514 | return ret; |
| 515 | } |
| 516 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 517 | /* vif-specifc initialization */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 518 | static int wl12xx_init_sta_role(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 519 | { |
| 520 | int ret; |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 521 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 522 | ret = wl1271_acx_group_address_tbl(wl, wlvif, true, NULL, 0); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 523 | if (ret < 0) |
| 524 | return ret; |
| 525 | |
| 526 | /* Initialize connection monitoring thresholds */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 527 | ret = wl1271_acx_conn_monit_params(wl, wlvif, false); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 528 | if (ret < 0) |
| 529 | return ret; |
| 530 | |
| 531 | /* Beacon filtering */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 532 | ret = wl1271_init_beacon_filter(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 533 | if (ret < 0) |
| 534 | return ret; |
| 535 | |
| 536 | /* Beacons and broadcast settings */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 537 | ret = wl1271_init_beacon_broadcast(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 538 | if (ret < 0) |
| 539 | return ret; |
| 540 | |
| 541 | /* Configure rssi/snr averaging weights */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 542 | ret = wl1271_acx_rssi_snr_avg_weights(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 543 | if (ret < 0) |
| 544 | return ret; |
| 545 | |
| 546 | return 0; |
| 547 | } |
| 548 | |
| 549 | /* vif-specific intialization */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 550 | static int wl12xx_init_ap_role(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 551 | { |
| 552 | int ret; |
| 553 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 554 | ret = wl1271_acx_ap_max_tx_retry(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 555 | if (ret < 0) |
| 556 | return ret; |
| 557 | |
| 558 | /* initialize Tx power */ |
Eliad Peller | 6bd6502 | 2011-10-10 10:13:11 +0200 | [diff] [blame] | 559 | ret = wl1271_acx_tx_power(wl, wlvif, wlvif->power_level); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 560 | if (ret < 0) |
| 561 | return ret; |
| 562 | |
| 563 | return 0; |
| 564 | } |
| 565 | |
| 566 | int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 567 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 568 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Kalle Valo | 243eeb5 | 2010-02-18 13:25:39 +0200 | [diff] [blame] | 569 | struct conf_tx_ac_category *conf_ac; |
Kalle Valo | f2054df | 2010-02-18 13:25:40 +0200 | [diff] [blame] | 570 | struct conf_tx_tid *conf_tid; |
Eliad Peller | 536129c8 | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 571 | bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 572 | int ret, i; |
| 573 | |
Eliad Peller | a4e4130 | 2011-10-11 11:49:15 +0200 | [diff] [blame] | 574 | /* |
| 575 | * consider all existing roles before configuring psm. |
| 576 | * TODO: reconfigure on interface removal. |
| 577 | */ |
| 578 | if (!wl->ap_count) { |
| 579 | if (is_ap) { |
| 580 | /* Configure for power always on */ |
| 581 | ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM); |
| 582 | if (ret < 0) |
| 583 | return ret; |
| 584 | } else if (!wl->sta_count) { |
| 585 | /* Configure for ELP power saving */ |
| 586 | ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); |
| 587 | if (ret < 0) |
| 588 | return ret; |
| 589 | } |
| 590 | } |
| 591 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 592 | /* Mode specific init */ |
| 593 | if (is_ap) { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 594 | ret = wl1271_ap_hw_init(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 595 | if (ret < 0) |
| 596 | return ret; |
| 597 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 598 | ret = wl12xx_init_ap_role(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 599 | if (ret < 0) |
| 600 | return ret; |
| 601 | } else { |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 602 | ret = wl1271_sta_hw_init(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 603 | if (ret < 0) |
| 604 | return ret; |
| 605 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 606 | ret = wl12xx_init_sta_role(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 607 | if (ret < 0) |
| 608 | return ret; |
| 609 | } |
| 610 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 611 | wl12xx_init_phy_vif_config(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 612 | |
| 613 | /* Default TID/AC configuration */ |
| 614 | BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); |
| 615 | for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { |
| 616 | conf_ac = &wl->conf.tx.ac_conf[i]; |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 617 | ret = wl1271_acx_ac_cfg(wl, wlvif, conf_ac->ac, |
| 618 | conf_ac->cw_min, conf_ac->cw_max, |
| 619 | conf_ac->aifsn, conf_ac->tx_op_limit); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 620 | if (ret < 0) |
| 621 | return ret; |
| 622 | |
| 623 | conf_tid = &wl->conf.tx.tid_conf[i]; |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 624 | ret = wl1271_acx_tid_cfg(wl, wlvif, |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 625 | conf_tid->queue_id, |
| 626 | conf_tid->channel_type, |
| 627 | conf_tid->tsid, |
| 628 | conf_tid->ps_scheme, |
| 629 | conf_tid->ack_policy, |
| 630 | conf_tid->apsd_conf[0], |
| 631 | conf_tid->apsd_conf[1]); |
| 632 | if (ret < 0) |
| 633 | return ret; |
| 634 | } |
| 635 | |
| 636 | /* Configure HW encryption */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 637 | ret = wl1271_acx_feature_cfg(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 638 | if (ret < 0) |
| 639 | return ret; |
| 640 | |
| 641 | /* Mode specific init - post mem init */ |
| 642 | if (is_ap) |
| 643 | ret = wl1271_ap_hw_init_post_mem(wl, vif); |
| 644 | else |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 645 | ret = wl1271_sta_hw_init_post_mem(wl, vif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 646 | |
| 647 | if (ret < 0) |
| 648 | return ret; |
| 649 | |
| 650 | /* Configure initiator BA sessions policies */ |
Eliad Peller | 536129c8 | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 651 | ret = wl1271_set_ba_policies(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 652 | if (ret < 0) |
| 653 | return ret; |
| 654 | |
| 655 | return 0; |
| 656 | } |
| 657 | |
| 658 | int wl1271_hw_init(struct wl1271 *wl) |
| 659 | { |
| 660 | int ret; |
| 661 | |
Shahar Levi | 49d750ca | 2011-03-06 16:32:09 +0200 | [diff] [blame] | 662 | if (wl->chip.id == CHIP_ID_1283_PG20) |
| 663 | ret = wl128x_cmd_general_parms(wl); |
| 664 | else |
| 665 | ret = wl1271_cmd_general_parms(wl); |
Luciano Coelho | 4a90406 | 2009-11-23 23:22:18 +0200 | [diff] [blame] | 666 | if (ret < 0) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 667 | return ret; |
| 668 | |
Shahar Levi | 49d750ca | 2011-03-06 16:32:09 +0200 | [diff] [blame] | 669 | if (wl->chip.id == CHIP_ID_1283_PG20) |
| 670 | ret = wl128x_cmd_radio_parms(wl); |
| 671 | else |
| 672 | ret = wl1271_cmd_radio_parms(wl); |
Luciano Coelho | 4a90406 | 2009-11-23 23:22:18 +0200 | [diff] [blame] | 673 | if (ret < 0) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 674 | return ret; |
| 675 | |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 676 | /* Chip-specific init */ |
| 677 | ret = wl1271_chip_specific_init(wl); |
| 678 | if (ret < 0) |
| 679 | return ret; |
| 680 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 681 | /* Init templates */ |
| 682 | ret = wl1271_init_templates_config(wl); |
| 683 | if (ret < 0) |
| 684 | return ret; |
Juuso Oikarinen | 644a486 | 2010-10-05 13:11:56 +0200 | [diff] [blame] | 685 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 686 | ret = wl12xx_acx_mem_cfg(wl); |
| 687 | if (ret < 0) |
| 688 | return ret; |
| 689 | |
| 690 | /* Configure the FW logger */ |
| 691 | ret = wl12xx_init_fwlog(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 692 | if (ret < 0) |
| 693 | return ret; |
| 694 | |
Arik Nemtsov | 801f870 | 2011-04-18 14:15:20 +0300 | [diff] [blame] | 695 | /* Bluetooth WLAN coexistence */ |
| 696 | ret = wl1271_init_pta(wl); |
| 697 | if (ret < 0) |
| 698 | return ret; |
| 699 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 700 | /* Default memory configuration */ |
| 701 | ret = wl1271_acx_init_mem_config(wl); |
| 702 | if (ret < 0) |
| 703 | return ret; |
| 704 | |
| 705 | /* RX config */ |
Eliad Peller | 08c1d1c | 2011-08-14 13:17:04 +0300 | [diff] [blame] | 706 | ret = wl12xx_init_rx_config(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 707 | if (ret < 0) |
| 708 | goto out_free_memmap; |
| 709 | |
| 710 | /* PHY layer config */ |
| 711 | ret = wl1271_init_phy_config(wl); |
| 712 | if (ret < 0) |
| 713 | goto out_free_memmap; |
| 714 | |
Luciano Coelho | 6e92b41 | 2009-12-11 15:40:50 +0200 | [diff] [blame] | 715 | ret = wl1271_acx_dco_itrim_params(wl); |
| 716 | if (ret < 0) |
| 717 | goto out_free_memmap; |
| 718 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 719 | /* Configure TX patch complete interrupt behavior */ |
| 720 | ret = wl1271_acx_tx_config_options(wl); |
| 721 | if (ret < 0) |
| 722 | goto out_free_memmap; |
| 723 | |
| 724 | /* RX complete interrupt pacing */ |
| 725 | ret = wl1271_acx_init_rx_interrupt(wl); |
| 726 | if (ret < 0) |
| 727 | goto out_free_memmap; |
| 728 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 729 | /* Energy detection */ |
| 730 | ret = wl1271_init_energy_detection(wl); |
| 731 | if (ret < 0) |
| 732 | goto out_free_memmap; |
| 733 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 734 | /* Default fragmentation threshold */ |
Arik Nemtsov | 5f704d1 | 2011-04-18 14:15:21 +0300 | [diff] [blame] | 735 | ret = wl1271_acx_frag_threshold(wl, wl->hw->wiphy->frag_threshold); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 736 | if (ret < 0) |
| 737 | goto out_free_memmap; |
| 738 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 739 | /* Enable data path */ |
Luciano Coelho | 9421089 | 2009-12-11 15:40:55 +0200 | [diff] [blame] | 740 | ret = wl1271_cmd_data_path(wl, 1); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 741 | if (ret < 0) |
| 742 | goto out_free_memmap; |
| 743 | |
Juuso Oikarinen | 38ad2d8 | 2009-12-11 15:41:08 +0200 | [diff] [blame] | 744 | /* configure PM */ |
| 745 | ret = wl1271_acx_pm_config(wl); |
| 746 | if (ret < 0) |
| 747 | goto out_free_memmap; |
| 748 | |
Eliad Peller | fa6ad9f | 2011-08-14 13:17:14 +0300 | [diff] [blame] | 749 | ret = wl12xx_acx_set_rate_mgmt_params(wl); |
| 750 | if (ret < 0) |
| 751 | goto out_free_memmap; |
| 752 | |
Eliad Peller | 9487775 | 2011-08-28 15:11:56 +0300 | [diff] [blame] | 753 | /* configure hangover */ |
| 754 | ret = wl12xx_acx_config_hangover(wl); |
| 755 | if (ret < 0) |
| 756 | goto out_free_memmap; |
| 757 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 758 | return 0; |
| 759 | |
| 760 | out_free_memmap: |
| 761 | kfree(wl->target_mem_map); |
Juuso Oikarinen | 3441523 | 2009-10-08 21:56:33 +0300 | [diff] [blame] | 762 | wl->target_mem_map = NULL; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 763 | |
| 764 | return ret; |
| 765 | } |