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" |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 33 | #include "tx.h" |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 34 | #include "io.h" |
Arik Nemtsov | 8a9affc | 2011-12-13 12:15:09 +0200 | [diff] [blame] | 35 | #include "hw_ops.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; |
Eliad Peller | 5ec8a44 | 2012-02-02 12:22:09 +0200 | [diff] [blame] | 40 | size_t max_size; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 41 | |
| 42 | /* send empty templates for fw memory reservation */ |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 43 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
Eliad Peller | 78e2806 | 2012-11-22 18:06:15 +0200 | [diff] [blame] | 44 | wl->scan_templ_id_2_4, NULL, |
Ido Reis | c08e371 | 2012-02-02 13:54:27 +0200 | [diff] [blame] | 45 | WL1271_CMD_TEMPL_MAX_SIZE, |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 46 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 47 | if (ret < 0) |
| 48 | return ret; |
| 49 | |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 50 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
Eliad Peller | 78e2806 | 2012-11-22 18:06:15 +0200 | [diff] [blame] | 51 | wl->scan_templ_id_5, |
Ido Reis | c08e371 | 2012-02-02 13:54:27 +0200 | [diff] [blame] | 52 | NULL, WL1271_CMD_TEMPL_MAX_SIZE, 0, |
Juuso Oikarinen | 11eb542 | 2010-08-24 06:28:03 +0300 | [diff] [blame] | 53 | WL1271_RATE_AUTOMATIC); |
| 54 | if (ret < 0) |
| 55 | return ret; |
Teemu Paasikivi | abb0b3b | 2009-10-13 12:47:50 +0300 | [diff] [blame] | 56 | |
Yoni Divinsky | 3df74f4 | 2012-06-27 13:01:44 +0300 | [diff] [blame] | 57 | if (wl->quirks & WLCORE_QUIRK_DUAL_PROBE_TMPL) { |
| 58 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
Eliad Peller | 78e2806 | 2012-11-22 18:06:15 +0200 | [diff] [blame] | 59 | wl->sched_scan_templ_id_2_4, |
| 60 | NULL, |
Yoni Divinsky | 3df74f4 | 2012-06-27 13:01:44 +0300 | [diff] [blame] | 61 | WL1271_CMD_TEMPL_MAX_SIZE, |
| 62 | 0, WL1271_RATE_AUTOMATIC); |
| 63 | if (ret < 0) |
| 64 | return ret; |
| 65 | |
| 66 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
Eliad Peller | 78e2806 | 2012-11-22 18:06:15 +0200 | [diff] [blame] | 67 | wl->sched_scan_templ_id_5, |
| 68 | NULL, |
Yoni Divinsky | 3df74f4 | 2012-06-27 13:01:44 +0300 | [diff] [blame] | 69 | WL1271_CMD_TEMPL_MAX_SIZE, |
| 70 | 0, WL1271_RATE_AUTOMATIC); |
| 71 | if (ret < 0) |
| 72 | return ret; |
| 73 | } |
| 74 | |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 75 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
| 76 | CMD_TEMPL_NULL_DATA, NULL, |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 77 | sizeof(struct wl12xx_null_data_template), |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 78 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 79 | if (ret < 0) |
| 80 | return ret; |
| 81 | |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 82 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
| 83 | CMD_TEMPL_PS_POLL, NULL, |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 84 | sizeof(struct wl12xx_ps_poll_template), |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 85 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 86 | if (ret < 0) |
| 87 | return ret; |
| 88 | |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 89 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
| 90 | CMD_TEMPL_QOS_NULL_DATA, NULL, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 91 | sizeof |
Eliad Peller | 97127e6 | 2011-11-09 13:12:45 +0200 | [diff] [blame] | 92 | (struct ieee80211_qos_hdr), |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 93 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 94 | if (ret < 0) |
| 95 | return ret; |
| 96 | |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 97 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
| 98 | CMD_TEMPL_PROBE_RESPONSE, NULL, |
Eliad Peller | 154037d | 2011-08-14 13:17:12 +0300 | [diff] [blame] | 99 | WL1271_CMD_TEMPL_DFLT_SIZE, |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 100 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 101 | if (ret < 0) |
| 102 | return ret; |
| 103 | |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 104 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
| 105 | CMD_TEMPL_BEACON, NULL, |
Eliad Peller | 154037d | 2011-08-14 13:17:12 +0300 | [diff] [blame] | 106 | WL1271_CMD_TEMPL_DFLT_SIZE, |
Juuso Oikarinen | 606c148 | 2010-04-01 11:38:21 +0300 | [diff] [blame] | 107 | 0, WL1271_RATE_AUTOMATIC); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 108 | if (ret < 0) |
| 109 | return ret; |
| 110 | |
Eliad Peller | 5ec8a44 | 2012-02-02 12:22:09 +0200 | [diff] [blame] | 111 | max_size = sizeof(struct wl12xx_arp_rsp_template) + |
| 112 | WL1271_EXTRA_SPACE_MAX; |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 113 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
| 114 | CMD_TEMPL_ARP_RSP, NULL, |
Eliad Peller | 5ec8a44 | 2012-02-02 12:22:09 +0200 | [diff] [blame] | 115 | max_size, |
Eliad Peller | c531277 | 2010-12-09 11:31:27 +0200 | [diff] [blame] | 116 | 0, WL1271_RATE_AUTOMATIC); |
| 117 | if (ret < 0) |
| 118 | return ret; |
| 119 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 120 | /* |
| 121 | * Put very large empty placeholders for all templates. These |
| 122 | * reserve memory for later. |
| 123 | */ |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 124 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
| 125 | CMD_TEMPL_AP_PROBE_RESPONSE, NULL, |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 126 | WL1271_CMD_TEMPL_MAX_SIZE, |
| 127 | 0, WL1271_RATE_AUTOMATIC); |
| 128 | if (ret < 0) |
| 129 | return ret; |
| 130 | |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 131 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
| 132 | CMD_TEMPL_AP_BEACON, NULL, |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 133 | WL1271_CMD_TEMPL_MAX_SIZE, |
| 134 | 0, WL1271_RATE_AUTOMATIC); |
| 135 | if (ret < 0) |
| 136 | return ret; |
| 137 | |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 138 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
| 139 | CMD_TEMPL_DEAUTH_AP, NULL, |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 140 | sizeof |
| 141 | (struct wl12xx_disconn_template), |
| 142 | 0, WL1271_RATE_AUTOMATIC); |
| 143 | if (ret < 0) |
| 144 | return ret; |
| 145 | |
Eliad Peller | 001e39a | 2012-08-16 13:52:47 +0300 | [diff] [blame] | 146 | for (i = 0; i < WLCORE_MAX_KLV_TEMPLATES; i++) { |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 147 | ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, |
| 148 | CMD_TEMPL_KLV, NULL, |
Eliad Peller | 97127e6 | 2011-11-09 13:12:45 +0200 | [diff] [blame] | 149 | sizeof(struct ieee80211_qos_hdr), |
| 150 | i, WL1271_RATE_AUTOMATIC); |
Juuso Oikarinen | bfb24c9 | 2010-03-26 12:53:31 +0200 | [diff] [blame] | 151 | if (ret < 0) |
| 152 | return ret; |
| 153 | } |
| 154 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 155 | return 0; |
| 156 | } |
| 157 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 158 | static int wl1271_ap_init_deauth_template(struct wl1271 *wl, |
| 159 | struct wl12xx_vif *wlvif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 160 | { |
| 161 | struct wl12xx_disconn_template *tmpl; |
| 162 | int ret; |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 163 | u32 rate; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 164 | |
| 165 | tmpl = kzalloc(sizeof(*tmpl), GFP_KERNEL); |
| 166 | if (!tmpl) { |
| 167 | ret = -ENOMEM; |
| 168 | goto out; |
| 169 | } |
| 170 | |
| 171 | tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 172 | IEEE80211_STYPE_DEAUTH); |
| 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); |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 175 | ret = wl1271_cmd_template_set(wl, wlvif->role_id, |
| 176 | CMD_TEMPL_DEAUTH_AP, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 177 | tmpl, sizeof(*tmpl), 0, rate); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 178 | |
| 179 | out: |
| 180 | kfree(tmpl); |
| 181 | return ret; |
| 182 | } |
| 183 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 184 | static int wl1271_ap_init_null_template(struct wl1271 *wl, |
| 185 | struct ieee80211_vif *vif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 186 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 187 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 188 | struct ieee80211_hdr_3addr *nullfunc; |
| 189 | int ret; |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 190 | u32 rate; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 191 | |
| 192 | nullfunc = kzalloc(sizeof(*nullfunc), GFP_KERNEL); |
| 193 | if (!nullfunc) { |
| 194 | ret = -ENOMEM; |
| 195 | goto out; |
| 196 | } |
| 197 | |
| 198 | nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | |
| 199 | IEEE80211_STYPE_NULLFUNC | |
| 200 | IEEE80211_FCTL_FROMDS); |
| 201 | |
| 202 | /* nullfunc->addr1 is filled by FW */ |
| 203 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 204 | memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); |
| 205 | memcpy(nullfunc->addr3, vif->addr, ETH_ALEN); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 206 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 207 | rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 208 | ret = wl1271_cmd_template_set(wl, wlvif->role_id, |
| 209 | CMD_TEMPL_NULL_DATA, nullfunc, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 210 | sizeof(*nullfunc), 0, rate); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 211 | |
| 212 | out: |
| 213 | kfree(nullfunc); |
| 214 | return ret; |
| 215 | } |
| 216 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 217 | static int wl1271_ap_init_qos_null_template(struct wl1271 *wl, |
| 218 | struct ieee80211_vif *vif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 219 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 220 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 221 | struct ieee80211_qos_hdr *qosnull; |
| 222 | int ret; |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 223 | u32 rate; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 224 | |
| 225 | qosnull = kzalloc(sizeof(*qosnull), GFP_KERNEL); |
| 226 | if (!qosnull) { |
| 227 | ret = -ENOMEM; |
| 228 | goto out; |
| 229 | } |
| 230 | |
| 231 | qosnull->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | |
| 232 | IEEE80211_STYPE_QOS_NULLFUNC | |
| 233 | IEEE80211_FCTL_FROMDS); |
| 234 | |
| 235 | /* qosnull->addr1 is filled by FW */ |
| 236 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 237 | memcpy(qosnull->addr2, vif->addr, ETH_ALEN); |
| 238 | memcpy(qosnull->addr3, vif->addr, ETH_ALEN); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 239 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 240 | rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 241 | ret = wl1271_cmd_template_set(wl, wlvif->role_id, |
| 242 | CMD_TEMPL_QOS_NULL_DATA, qosnull, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 243 | sizeof(*qosnull), 0, rate); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 244 | |
| 245 | out: |
| 246 | kfree(qosnull); |
| 247 | return ret; |
| 248 | } |
| 249 | |
Eliad Peller | 08c1d1c | 2011-08-14 13:17:04 +0300 | [diff] [blame] | 250 | static int wl12xx_init_rx_config(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 251 | { |
| 252 | int ret; |
| 253 | |
Juuso Oikarinen | 8793f9b | 2009-10-13 12:47:40 +0300 | [diff] [blame] | 254 | ret = wl1271_acx_rx_msdu_life_time(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 255 | if (ret < 0) |
| 256 | return ret; |
| 257 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 258 | return 0; |
| 259 | } |
| 260 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 261 | static int wl12xx_init_phy_vif_config(struct wl1271 *wl, |
| 262 | struct wl12xx_vif *wlvif) |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 263 | { |
| 264 | int ret; |
| 265 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 266 | ret = wl1271_acx_slot(wl, wlvif, DEFAULT_SLOT_TIME); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 267 | if (ret < 0) |
| 268 | return ret; |
| 269 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 270 | ret = wl1271_acx_service_period_timeout(wl, wlvif); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 271 | if (ret < 0) |
| 272 | return ret; |
| 273 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 274 | ret = wl1271_acx_rts_threshold(wl, wlvif, wl->hw->wiphy->rts_threshold); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 275 | if (ret < 0) |
| 276 | return ret; |
| 277 | |
| 278 | return 0; |
| 279 | } |
| 280 | |
Arik Nemtsov | a693534 | 2011-10-24 17:25:20 +0200 | [diff] [blame] | 281 | static int wl1271_init_sta_beacon_filter(struct wl1271 *wl, |
| 282 | struct wl12xx_vif *wlvif) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 283 | { |
| 284 | int ret; |
| 285 | |
Arik Nemtsov | a693534 | 2011-10-24 17:25:20 +0200 | [diff] [blame] | 286 | ret = wl1271_acx_beacon_filter_table(wl, wlvif); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 287 | if (ret < 0) |
| 288 | return ret; |
| 289 | |
Eliad Peller | d881fa2 | 2014-02-10 13:47:33 +0200 | [diff] [blame] | 290 | /* disable beacon filtering until we get the first beacon */ |
| 291 | ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 292 | if (ret < 0) |
| 293 | return ret; |
| 294 | |
| 295 | return 0; |
| 296 | } |
| 297 | |
Luciano Coelho | 12419cce | 2010-02-18 13:25:44 +0200 | [diff] [blame] | 298 | int wl1271_init_pta(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 299 | { |
| 300 | int ret; |
| 301 | |
Eliad Peller | 3be4112 | 2011-08-14 13:17:19 +0300 | [diff] [blame] | 302 | ret = wl12xx_acx_sg_cfg(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 303 | if (ret < 0) |
| 304 | return ret; |
| 305 | |
Juuso Oikarinen | 7fc3a86 | 2010-03-18 12:26:32 +0200 | [diff] [blame] | 306 | ret = wl1271_acx_sg_enable(wl, wl->sg_enabled); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 307 | if (ret < 0) |
| 308 | return ret; |
| 309 | |
| 310 | return 0; |
| 311 | } |
| 312 | |
Luciano Coelho | 12419cce | 2010-02-18 13:25:44 +0200 | [diff] [blame] | 313 | int wl1271_init_energy_detection(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 314 | { |
| 315 | int ret; |
| 316 | |
| 317 | ret = wl1271_acx_cca_threshold(wl); |
| 318 | if (ret < 0) |
| 319 | return ret; |
| 320 | |
| 321 | return 0; |
| 322 | } |
| 323 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 324 | static int wl1271_init_beacon_broadcast(struct wl1271 *wl, |
| 325 | struct wl12xx_vif *wlvif) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 326 | { |
| 327 | int ret; |
| 328 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 329 | ret = wl1271_acx_bcn_dtim_options(wl, wlvif); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 330 | if (ret < 0) |
| 331 | return ret; |
| 332 | |
| 333 | return 0; |
| 334 | } |
| 335 | |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 336 | static int wl12xx_init_fwlog(struct wl1271 *wl) |
| 337 | { |
| 338 | int ret; |
| 339 | |
Luciano Coelho | 6f7dd16 | 2011-11-29 16:27:31 +0200 | [diff] [blame] | 340 | if (wl->quirks & WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED) |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 341 | return 0; |
| 342 | |
| 343 | ret = wl12xx_cmd_config_fwlog(wl); |
| 344 | if (ret < 0) |
| 345 | return ret; |
| 346 | |
| 347 | return 0; |
| 348 | } |
| 349 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 350 | /* generic sta initialization (non vif-specific) */ |
Eliad Peller | 7845af3 | 2015-07-30 22:38:22 +0300 | [diff] [blame] | 351 | int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 352 | { |
| 353 | int ret; |
| 354 | |
Eliad Peller | c8bde24 | 2011-02-02 09:59:35 +0200 | [diff] [blame] | 355 | /* PS config */ |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 356 | ret = wl12xx_acx_config_ps(wl, wlvif); |
Eliad Peller | c8bde24 | 2011-02-02 09:59:35 +0200 | [diff] [blame] | 357 | if (ret < 0) |
| 358 | return ret; |
| 359 | |
Shahar Levi | ff86843 | 2011-04-11 15:41:46 +0300 | [diff] [blame] | 360 | /* FM WLAN coexistence */ |
| 361 | ret = wl1271_acx_fm_coex(wl); |
| 362 | if (ret < 0) |
| 363 | return ret; |
| 364 | |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 365 | ret = wl1271_acx_sta_rate_policies(wl, wlvif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 366 | if (ret < 0) |
| 367 | return ret; |
| 368 | |
| 369 | return 0; |
| 370 | } |
| 371 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 372 | static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl, |
| 373 | struct ieee80211_vif *vif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 374 | { |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 375 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Eliad Peller | 001e39a | 2012-08-16 13:52:47 +0300 | [diff] [blame] | 376 | int ret; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 377 | |
| 378 | /* disable the keep-alive feature */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 379 | ret = wl1271_acx_keep_alive_mode(wl, wlvif, false); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 380 | if (ret < 0) |
| 381 | return ret; |
| 382 | |
| 383 | return 0; |
| 384 | } |
| 385 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 386 | /* generic ap initialization (non vif-specific) */ |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 387 | 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] | 388 | { |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 389 | int ret; |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 390 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 391 | ret = wl1271_init_ap_rates(wl, wlvif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 392 | if (ret < 0) |
| 393 | return ret; |
| 394 | |
Kobi L | e2f1e50 | 2014-12-29 08:24:06 +0200 | [diff] [blame] | 395 | /* configure AP sleep, if enabled */ |
| 396 | ret = wlcore_hw_ap_sleep(wl); |
| 397 | if (ret < 0) |
| 398 | return ret; |
| 399 | |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 400 | return 0; |
| 401 | } |
| 402 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 403 | int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif) |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 404 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 405 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 406 | int ret; |
| 407 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 408 | ret = wl1271_ap_init_deauth_template(wl, wlvif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 409 | if (ret < 0) |
| 410 | return ret; |
| 411 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 412 | ret = wl1271_ap_init_null_template(wl, vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 413 | if (ret < 0) |
| 414 | return ret; |
| 415 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 416 | ret = wl1271_ap_init_qos_null_template(wl, vif); |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 417 | if (ret < 0) |
| 418 | return ret; |
| 419 | |
Arik Nemtsov | 521a4a2 | 2011-04-18 14:15:22 +0300 | [diff] [blame] | 420 | /* |
| 421 | * when operating as AP we want to receive external beacons for |
| 422 | * configuring ERP protection. |
| 423 | */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 424 | ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); |
Arik Nemtsov | 521a4a2 | 2011-04-18 14:15:22 +0300 | [diff] [blame] | 425 | if (ret < 0) |
| 426 | return ret; |
| 427 | |
Arik Nemtsov | e0fe371 | 2010-10-16 18:19:53 +0200 | [diff] [blame] | 428 | return 0; |
| 429 | } |
| 430 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 431 | static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl, |
| 432 | struct ieee80211_vif *vif) |
Arik Nemtsov | c45a85b | 2011-04-18 14:15:26 +0300 | [diff] [blame] | 433 | { |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 434 | return wl1271_ap_init_templates(wl, vif); |
Arik Nemtsov | c45a85b | 2011-04-18 14:15:26 +0300 | [diff] [blame] | 435 | } |
| 436 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 437 | int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 438 | { |
| 439 | int i, ret; |
| 440 | struct conf_tx_rate_class rc; |
| 441 | u32 supported_rates; |
| 442 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 443 | wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", |
| 444 | wlvif->basic_rate_set); |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 445 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 446 | if (wlvif->basic_rate_set == 0) |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 447 | return -EINVAL; |
| 448 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 449 | rc.enabled_rates = wlvif->basic_rate_set; |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 450 | rc.long_retry_limit = 10; |
| 451 | rc.short_retry_limit = 10; |
| 452 | rc.aflags = 0; |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 453 | 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] | 454 | if (ret < 0) |
| 455 | return ret; |
| 456 | |
| 457 | /* use the min basic rate for AP broadcast/multicast */ |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 458 | 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] | 459 | rc.short_retry_limit = 10; |
| 460 | rc.long_retry_limit = 10; |
| 461 | rc.aflags = 0; |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 462 | 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] | 463 | if (ret < 0) |
| 464 | return ret; |
| 465 | |
| 466 | /* |
| 467 | * If the basic rates contain OFDM rates, use OFDM only |
| 468 | * rates for unicast TX as well. Else use all supported rates. |
| 469 | */ |
Arik Nemtsov | bc566f9 | 2014-02-10 13:47:28 +0200 | [diff] [blame] | 470 | if (wl->ofdm_only_ap && (wlvif->basic_rate_set & CONF_TX_OFDM_RATES)) |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 471 | supported_rates = CONF_TX_OFDM_RATES; |
| 472 | else |
Eliad Peller | 42ec1f8 | 2012-11-20 13:20:08 +0200 | [diff] [blame] | 473 | supported_rates = CONF_TX_ENABLED_RATES; |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 474 | |
Arik Nemtsov | 1a8adb6 | 2011-08-14 13:17:29 +0300 | [diff] [blame] | 475 | /* unconditionally enable HT rates */ |
| 476 | supported_rates |= CONF_TX_MCS_RATES; |
| 477 | |
Arik Nemtsov | ebc7e57 | 2012-05-10 12:13:34 +0300 | [diff] [blame] | 478 | /* get extra MIMO or wide-chan rates where the HW supports it */ |
| 479 | supported_rates |= wlcore_hw_ap_get_mimo_wide_rate_mask(wl, wlvif); |
| 480 | |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 481 | /* configure unicast TX rate classes */ |
| 482 | for (i = 0; i < wl->conf.tx.ac_conf_count; i++) { |
| 483 | rc.enabled_rates = supported_rates; |
| 484 | rc.short_retry_limit = 10; |
| 485 | rc.long_retry_limit = 10; |
| 486 | rc.aflags = 0; |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 487 | ret = wl1271_acx_ap_rate_policy(wl, &rc, |
| 488 | wlvif->ap.ucast_rate_idx[i]); |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 489 | if (ret < 0) |
| 490 | return ret; |
| 491 | } |
| 492 | |
| 493 | return 0; |
| 494 | } |
| 495 | |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 496 | 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] | 497 | { |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 498 | /* Reset the BA RX indicators */ |
Eliad Peller | d0802ab | 2011-10-05 11:56:04 +0200 | [diff] [blame] | 499 | wlvif->ba_allowed = true; |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 500 | wl->ba_rx_session_count = 0; |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 501 | |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 502 | /* BA is supported in STA/AP modes */ |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 503 | if (wlvif->bss_type != BSS_TYPE_AP_BSS && |
| 504 | wlvif->bss_type != BSS_TYPE_STA_BSS) { |
Eliad Peller | d0802ab | 2011-10-05 11:56:04 +0200 | [diff] [blame] | 505 | wlvif->ba_support = false; |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 506 | return 0; |
| 507 | } |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 508 | |
Eliad Peller | d0802ab | 2011-10-05 11:56:04 +0200 | [diff] [blame] | 509 | wlvif->ba_support = true; |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 510 | |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 511 | /* 802.11n initiator BA session setting */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 512 | return wl12xx_acx_set_ba_initiator_policy(wl, wlvif); |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 513 | } |
| 514 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 515 | /* vif-specifc initialization */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 516 | 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] | 517 | { |
| 518 | int ret; |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 519 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 520 | ret = wl1271_acx_group_address_tbl(wl, wlvif, true, NULL, 0); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 521 | if (ret < 0) |
| 522 | return ret; |
| 523 | |
| 524 | /* Initialize connection monitoring thresholds */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 525 | ret = wl1271_acx_conn_monit_params(wl, wlvif, false); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 526 | if (ret < 0) |
| 527 | return ret; |
| 528 | |
| 529 | /* Beacon filtering */ |
Arik Nemtsov | a693534 | 2011-10-24 17:25:20 +0200 | [diff] [blame] | 530 | ret = wl1271_init_sta_beacon_filter(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 531 | if (ret < 0) |
| 532 | return ret; |
| 533 | |
| 534 | /* Beacons and broadcast settings */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 535 | ret = wl1271_init_beacon_broadcast(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 536 | if (ret < 0) |
| 537 | return ret; |
| 538 | |
| 539 | /* Configure rssi/snr averaging weights */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 540 | ret = wl1271_acx_rssi_snr_avg_weights(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 541 | if (ret < 0) |
| 542 | return ret; |
| 543 | |
| 544 | return 0; |
| 545 | } |
| 546 | |
| 547 | /* vif-specific intialization */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 548 | 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] | 549 | { |
| 550 | int ret; |
| 551 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 552 | ret = wl1271_acx_ap_max_tx_retry(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 553 | if (ret < 0) |
| 554 | return ret; |
| 555 | |
| 556 | /* initialize Tx power */ |
Eliad Peller | 6bd6502 | 2011-10-10 10:13:11 +0200 | [diff] [blame] | 557 | ret = wl1271_acx_tx_power(wl, wlvif, wlvif->power_level); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 558 | if (ret < 0) |
| 559 | return ret; |
| 560 | |
Eliad Peller | 8cf77e1 | 2016-03-07 00:28:09 +0200 | [diff] [blame] | 561 | if (wl->radar_debug_mode) |
| 562 | wlcore_cmd_generic_cfg(wl, wlvif, |
| 563 | WLCORE_CFG_FEATURE_RADAR_DEBUG, |
| 564 | wl->radar_debug_mode, 0); |
| 565 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 566 | return 0; |
| 567 | } |
| 568 | |
| 569 | int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 570 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 571 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Kalle Valo | 243eeb5 | 2010-02-18 13:25:39 +0200 | [diff] [blame] | 572 | struct conf_tx_ac_category *conf_ac; |
Kalle Valo | f2054df | 2010-02-18 13:25:40 +0200 | [diff] [blame] | 573 | struct conf_tx_tid *conf_tid; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 574 | bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 575 | int ret, i; |
| 576 | |
Arik Nemtsov | 2f18cf7 | 2012-06-10 19:10:45 +0300 | [diff] [blame] | 577 | /* consider all existing roles before configuring psm. */ |
| 578 | |
| 579 | if (wl->ap_count == 0 && is_ap) { /* first AP */ |
Kobi L | e2f1e50 | 2014-12-29 08:24:06 +0200 | [diff] [blame] | 580 | ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); |
Arik Nemtsov | 2f18cf7 | 2012-06-10 19:10:45 +0300 | [diff] [blame] | 581 | if (ret < 0) |
| 582 | return ret; |
Eliad Peller | 71e996b | 2013-09-09 12:24:34 +0300 | [diff] [blame] | 583 | |
| 584 | /* unmask ap events */ |
| 585 | wl->event_mask |= wl->ap_event_mask; |
| 586 | ret = wl1271_event_unmask(wl); |
| 587 | if (ret < 0) |
| 588 | return ret; |
Arik Nemtsov | 2f18cf7 | 2012-06-10 19:10:45 +0300 | [diff] [blame] | 589 | /* first STA, no APs */ |
| 590 | } else if (wl->sta_count == 0 && wl->ap_count == 0 && !is_ap) { |
| 591 | u8 sta_auth = wl->conf.conn.sta_sleep_auth; |
| 592 | /* Configure for power according to debugfs */ |
| 593 | if (sta_auth != WL1271_PSM_ILLEGAL) |
| 594 | ret = wl1271_acx_sleep_auth(wl, sta_auth); |
Arik Nemtsov | 2f18cf7 | 2012-06-10 19:10:45 +0300 | [diff] [blame] | 595 | /* Configure for ELP power saving */ |
| 596 | else |
| 597 | ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); |
| 598 | |
| 599 | if (ret < 0) |
| 600 | return ret; |
Eliad Peller | a4e4130 | 2011-10-11 11:49:15 +0200 | [diff] [blame] | 601 | } |
| 602 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 603 | /* Mode specific init */ |
| 604 | if (is_ap) { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 605 | ret = wl1271_ap_hw_init(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 606 | if (ret < 0) |
| 607 | return ret; |
| 608 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 609 | ret = wl12xx_init_ap_role(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 610 | if (ret < 0) |
| 611 | return ret; |
| 612 | } else { |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 613 | ret = wl1271_sta_hw_init(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 614 | if (ret < 0) |
| 615 | return ret; |
| 616 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 617 | ret = wl12xx_init_sta_role(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 618 | if (ret < 0) |
| 619 | return ret; |
| 620 | } |
| 621 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 622 | wl12xx_init_phy_vif_config(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 623 | |
| 624 | /* Default TID/AC configuration */ |
| 625 | BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); |
| 626 | for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { |
| 627 | conf_ac = &wl->conf.tx.ac_conf[i]; |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 628 | ret = wl1271_acx_ac_cfg(wl, wlvif, conf_ac->ac, |
| 629 | conf_ac->cw_min, conf_ac->cw_max, |
| 630 | conf_ac->aifsn, conf_ac->tx_op_limit); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 631 | if (ret < 0) |
| 632 | return ret; |
| 633 | |
| 634 | conf_tid = &wl->conf.tx.tid_conf[i]; |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 635 | ret = wl1271_acx_tid_cfg(wl, wlvif, |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 636 | conf_tid->queue_id, |
| 637 | conf_tid->channel_type, |
| 638 | conf_tid->tsid, |
| 639 | conf_tid->ps_scheme, |
| 640 | conf_tid->ack_policy, |
| 641 | conf_tid->apsd_conf[0], |
| 642 | conf_tid->apsd_conf[1]); |
| 643 | if (ret < 0) |
| 644 | return ret; |
| 645 | } |
| 646 | |
| 647 | /* Configure HW encryption */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 648 | ret = wl1271_acx_feature_cfg(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 649 | if (ret < 0) |
| 650 | return ret; |
| 651 | |
| 652 | /* Mode specific init - post mem init */ |
| 653 | if (is_ap) |
| 654 | ret = wl1271_ap_hw_init_post_mem(wl, vif); |
| 655 | else |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 656 | ret = wl1271_sta_hw_init_post_mem(wl, vif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 657 | |
| 658 | if (ret < 0) |
| 659 | return ret; |
| 660 | |
| 661 | /* Configure initiator BA sessions policies */ |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 662 | ret = wl1271_set_ba_policies(wl, wlvif); |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 663 | if (ret < 0) |
| 664 | return ret; |
| 665 | |
Arik Nemtsov | 8a9affc | 2011-12-13 12:15:09 +0200 | [diff] [blame] | 666 | ret = wlcore_hw_init_vif(wl, wlvif); |
| 667 | if (ret < 0) |
| 668 | return ret; |
| 669 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 670 | return 0; |
| 671 | } |
| 672 | |
| 673 | int wl1271_hw_init(struct wl1271 *wl) |
| 674 | { |
| 675 | int ret; |
| 676 | |
Luciano Coelho | 9d68d1e | 2011-12-02 00:47:45 +0200 | [diff] [blame] | 677 | /* Chip-specific hw init */ |
| 678 | ret = wl->ops->hw_init(wl); |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 679 | if (ret < 0) |
| 680 | return ret; |
| 681 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 682 | /* Init templates */ |
| 683 | ret = wl1271_init_templates_config(wl); |
| 684 | if (ret < 0) |
| 685 | return ret; |
Juuso Oikarinen | 644a486 | 2010-10-05 13:11:56 +0200 | [diff] [blame] | 686 | |
Eliad Peller | 92c77c7 | 2011-10-05 11:55:40 +0200 | [diff] [blame] | 687 | ret = wl12xx_acx_mem_cfg(wl); |
| 688 | if (ret < 0) |
| 689 | return ret; |
| 690 | |
| 691 | /* Configure the FW logger */ |
| 692 | ret = wl12xx_init_fwlog(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 693 | if (ret < 0) |
| 694 | return ret; |
| 695 | |
Victor Goldenshtein | 6b70e7e | 2012-11-25 18:26:59 +0200 | [diff] [blame] | 696 | ret = wlcore_cmd_regdomain_config_locked(wl); |
| 697 | if (ret < 0) |
| 698 | return ret; |
| 699 | |
Arik Nemtsov | 801f870 | 2011-04-18 14:15:20 +0300 | [diff] [blame] | 700 | /* Bluetooth WLAN coexistence */ |
| 701 | ret = wl1271_init_pta(wl); |
| 702 | if (ret < 0) |
| 703 | return ret; |
| 704 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 705 | /* Default memory configuration */ |
| 706 | ret = wl1271_acx_init_mem_config(wl); |
| 707 | if (ret < 0) |
| 708 | return ret; |
| 709 | |
| 710 | /* RX config */ |
Eliad Peller | 08c1d1c | 2011-08-14 13:17:04 +0300 | [diff] [blame] | 711 | ret = wl12xx_init_rx_config(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 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 | } |