From: Eliad Peller <eliad@wizery.com>
To: Luciano Coelho <coelho@ti.com>
Cc: <linux-wireless@vger.kernel.org>
Subject: [PATCH 03/29] wl12xx: start reworking the init sequence
Date: Wed, 5 Oct 2011 11:55:40 +0200 [thread overview]
Message-ID: <1317808566-18857-4-git-send-email-eliad@wizery.com> (raw)
In-Reply-To: <1317808566-18857-1-git-send-email-eliad@wizery.com>
Split the init sequence into common commands (non role-specific)
and role-specific commands.
We still need to call the common commands only on add_interface()
(rather than on start()) as the fw must get the mac address
when uploading the nvs.
Future patches will refactor the init sequence further more.
Signed-off-by: Eliad Peller <eliad@wizery.com>
---
drivers/net/wireless/wl12xx/init.c | 306 +++++++++++++++++++-----------------
drivers/net/wireless/wl12xx/init.h | 5 +-
drivers/net/wireless/wl12xx/main.c | 8 +-
3 files changed, 171 insertions(+), 148 deletions(-)
diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c
index 4692a91..ff5c5f4 100644
--- a/drivers/net/wireless/wl12xx/init.c
+++ b/drivers/net/wireless/wl12xx/init.c
@@ -33,7 +33,7 @@
#include "tx.h"
#include "io.h"
-int wl1271_sta_init_templates_config(struct wl1271 *wl)
+int wl1271_init_templates_config(struct wl1271 *wl)
{
int ret, i;
@@ -88,6 +88,29 @@ int wl1271_sta_init_templates_config(struct wl1271 *wl)
if (ret < 0)
return ret;
+ /*
+ * Put very large empty placeholders for all templates. These
+ * reserve memory for later.
+ */
+ ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL,
+ WL1271_CMD_TEMPL_MAX_SIZE,
+ 0, WL1271_RATE_AUTOMATIC);
+ if (ret < 0)
+ return ret;
+
+ ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL,
+ WL1271_CMD_TEMPL_MAX_SIZE,
+ 0, WL1271_RATE_AUTOMATIC);
+ if (ret < 0)
+ return ret;
+
+ ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL,
+ sizeof
+ (struct wl12xx_disconn_template),
+ 0, WL1271_RATE_AUTOMATIC);
+ if (ret < 0)
+ return ret;
+
for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL,
WL1271_CMD_TEMPL_DFLT_SIZE, i,
@@ -185,68 +208,32 @@ out:
return ret;
}
-static int wl1271_ap_init_templates_config(struct wl1271 *wl)
+static int wl12xx_init_rx_config(struct wl1271 *wl)
{
int ret;
- /*
- * Put very large empty placeholders for all templates. These
- * reserve memory for later.
- */
- ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL,
- WL1271_CMD_TEMPL_MAX_SIZE,
- 0, WL1271_RATE_AUTOMATIC);
- if (ret < 0)
- return ret;
-
- ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL,
- WL1271_CMD_TEMPL_MAX_SIZE,
- 0, WL1271_RATE_AUTOMATIC);
- if (ret < 0)
- return ret;
-
- ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL,
- sizeof
- (struct wl12xx_disconn_template),
- 0, WL1271_RATE_AUTOMATIC);
- if (ret < 0)
- return ret;
-
- ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
- sizeof(struct wl12xx_null_data_template),
- 0, WL1271_RATE_AUTOMATIC);
- if (ret < 0)
- return ret;
-
- ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
- sizeof
- (struct wl12xx_qos_null_data_template),
- 0, WL1271_RATE_AUTOMATIC);
+ ret = wl1271_acx_rx_msdu_life_time(wl);
if (ret < 0)
return ret;
return 0;
}
-static int wl12xx_init_rx_config(struct wl1271 *wl)
+int wl1271_init_phy_config(struct wl1271 *wl)
{
int ret;
- ret = wl1271_acx_rx_msdu_life_time(wl);
+ ret = wl1271_acx_pd_threshold(wl);
if (ret < 0)
return ret;
return 0;
}
-int wl1271_init_phy_config(struct wl1271 *wl)
+static int wl12xx_init_phy_vif_config(struct wl1271 *wl)
{
int ret;
- ret = wl1271_acx_pd_threshold(wl);
- if (ret < 0)
- return ret;
-
ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
if (ret < 0)
return ret;
@@ -329,6 +316,7 @@ static int wl12xx_init_fwlog(struct wl1271 *wl)
return 0;
}
+/* generic sta initialization (non vif-specific) */
static int wl1271_sta_hw_init(struct wl1271 *wl)
{
int ret;
@@ -344,57 +332,20 @@ static int wl1271_sta_hw_init(struct wl1271 *wl)
if (ret < 0)
return ret;
- ret = wl1271_sta_init_templates_config(wl);
- if (ret < 0)
- return ret;
-
- ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
- if (ret < 0)
- return ret;
-
- /* Initialize connection monitoring thresholds */
- ret = wl1271_acx_conn_monit_params(wl, false);
- if (ret < 0)
- return ret;
-
- /* Beacon filtering */
- ret = wl1271_init_beacon_filter(wl);
- if (ret < 0)
- return ret;
-
/* FM WLAN coexistence */
ret = wl1271_acx_fm_coex(wl);
if (ret < 0)
return ret;
- /* Beacons and broadcast settings */
- ret = wl1271_init_beacon_broadcast(wl);
- if (ret < 0)
- return ret;
-
/* Configure for ELP power saving */
ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
if (ret < 0)
return ret;
- /* Configure rssi/snr averaging weights */
- ret = wl1271_acx_rssi_snr_avg_weights(wl);
- if (ret < 0)
- return ret;
-
ret = wl1271_acx_sta_rate_policies(wl);
if (ret < 0)
return ret;
- ret = wl12xx_acx_mem_cfg(wl);
- if (ret < 0)
- return ret;
-
- /* Configure the FW logger */
- ret = wl12xx_init_fwlog(wl);
- if (ret < 0)
- return ret;
-
return 0;
}
@@ -418,14 +369,11 @@ static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl)
return 0;
}
+/* generic ap initialization (non vif-specific) */
static int wl1271_ap_hw_init(struct wl1271 *wl)
{
int ret;
- ret = wl1271_ap_init_templates_config(wl);
- if (ret < 0)
- return ret;
-
/* Configure for power always on */
ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
if (ret < 0)
@@ -435,19 +383,6 @@ static int wl1271_ap_hw_init(struct wl1271 *wl)
if (ret < 0)
return ret;
- ret = wl1271_acx_ap_max_tx_retry(wl);
- if (ret < 0)
- return ret;
-
- ret = wl12xx_acx_mem_cfg(wl);
- if (ret < 0)
- return ret;
-
- /* initialize Tx power */
- ret = wl1271_acx_tx_power(wl, wl->power_level);
- if (ret < 0)
- return ret;
-
return 0;
}
@@ -578,14 +513,133 @@ out:
return ret;
}
+/* vif-specifc initialization */
+int wl12xx_init_sta_role(struct wl1271 *wl, struct ieee80211_vif *vif)
+{
+ int ret;
+
+ ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
+ if (ret < 0)
+ return ret;
+
+ /* Initialize connection monitoring thresholds */
+ ret = wl1271_acx_conn_monit_params(wl, false);
+ if (ret < 0)
+ return ret;
+
+ /* Beacon filtering */
+ ret = wl1271_init_beacon_filter(wl);
+ if (ret < 0)
+ return ret;
+
+ /* Beacons and broadcast settings */
+ ret = wl1271_init_beacon_broadcast(wl);
+ if (ret < 0)
+ return ret;
-int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif)
+ /* Configure rssi/snr averaging weights */
+ ret = wl1271_acx_rssi_snr_avg_weights(wl);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+/* vif-specific intialization */
+int wl12xx_init_ap_role(struct wl1271 *wl, struct ieee80211_vif *vif)
+{
+ int ret;
+
+ ret = wl1271_acx_ap_max_tx_retry(wl);
+ if (ret < 0)
+ return ret;
+
+ /* initialize Tx power */
+ ret = wl1271_acx_tx_power(wl, wl->power_level);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif)
{
struct conf_tx_ac_category *conf_ac;
struct conf_tx_tid *conf_tid;
- int ret, i;
bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
+ int ret, i;
+
+ /* Mode specific init */
+ if (is_ap) {
+ ret = wl1271_ap_hw_init(wl);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_init_ap_role(wl, vif);
+ if (ret < 0)
+ return ret;
+ } else {
+ ret = wl1271_sta_hw_init(wl);
+ if (ret < 0)
+ return ret;
+
+ ret = wl12xx_init_sta_role(wl, vif);
+ if (ret < 0)
+ return ret;
+ }
+
+ wl12xx_init_phy_vif_config(wl);
+
+ /* Default TID/AC configuration */
+ BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
+ for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
+ conf_ac = &wl->conf.tx.ac_conf[i];
+ ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
+ conf_ac->cw_max, conf_ac->aifsn,
+ conf_ac->tx_op_limit);
+ if (ret < 0)
+ return ret;
+
+ conf_tid = &wl->conf.tx.tid_conf[i];
+ ret = wl1271_acx_tid_cfg(wl,
+ conf_tid->queue_id,
+ conf_tid->channel_type,
+ conf_tid->tsid,
+ conf_tid->ps_scheme,
+ conf_tid->ack_policy,
+ conf_tid->apsd_conf[0],
+ conf_tid->apsd_conf[1]);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* Configure HW encryption */
+ ret = wl1271_acx_feature_cfg(wl);
+ if (ret < 0)
+ return ret;
+
+ /* Mode specific init - post mem init */
+ if (is_ap)
+ ret = wl1271_ap_hw_init_post_mem(wl, vif);
+ else
+ ret = wl1271_sta_hw_init_post_mem(wl);
+
+ if (ret < 0)
+ return ret;
+
+ /* Configure initiator BA sessions policies */
+ ret = wl1271_set_ba_policies(wl);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int wl1271_hw_init(struct wl1271 *wl)
+{
+ int ret;
+
if (wl->chip.id == CHIP_ID_1283_PG20)
ret = wl128x_cmd_general_parms(wl);
else
@@ -605,12 +659,17 @@ int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif)
if (ret < 0)
return ret;
- /* Mode specific init */
- if (is_ap)
- ret = wl1271_ap_hw_init(wl);
- else
- ret = wl1271_sta_hw_init(wl);
+ /* Init templates */
+ ret = wl1271_init_templates_config(wl);
+ if (ret < 0)
+ return ret;
+ ret = wl12xx_acx_mem_cfg(wl);
+ if (ret < 0)
+ return ret;
+
+ /* Configure the FW logger */
+ ret = wl12xx_init_fwlog(wl);
if (ret < 0)
return ret;
@@ -658,61 +717,20 @@ int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif)
if (ret < 0)
goto out_free_memmap;
- /* Default TID/AC configuration */
- BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
- for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
- conf_ac = &wl->conf.tx.ac_conf[i];
- ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
- conf_ac->cw_max, conf_ac->aifsn,
- conf_ac->tx_op_limit);
- if (ret < 0)
- goto out_free_memmap;
-
- conf_tid = &wl->conf.tx.tid_conf[i];
- ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id,
- conf_tid->channel_type,
- conf_tid->tsid,
- conf_tid->ps_scheme,
- conf_tid->ack_policy,
- conf_tid->apsd_conf[0],
- conf_tid->apsd_conf[1]);
- if (ret < 0)
- goto out_free_memmap;
- }
-
/* Enable data path */
ret = wl1271_cmd_data_path(wl, 1);
if (ret < 0)
goto out_free_memmap;
- /* Configure HW encryption */
- ret = wl1271_acx_feature_cfg(wl);
- if (ret < 0)
- goto out_free_memmap;
-
/* configure PM */
ret = wl1271_acx_pm_config(wl);
if (ret < 0)
goto out_free_memmap;
- /* Mode specific init - post mem init */
- if (is_ap)
- ret = wl1271_ap_hw_init_post_mem(wl, vif);
- else
- ret = wl1271_sta_hw_init_post_mem(wl);
-
- if (ret < 0)
- goto out_free_memmap;
-
ret = wl12xx_acx_set_rate_mgmt_params(wl);
if (ret < 0)
goto out_free_memmap;
- /* Configure initiator BA sessions policies */
- ret = wl1271_set_ba_policies(wl);
- if (ret < 0)
- goto out_free_memmap;
-
/* configure hangover */
ret = wl12xx_acx_config_hangover(wl);
if (ret < 0)
diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/init.h
index b1f97bc..64320c0 100644
--- a/drivers/net/wireless/wl12xx/init.h
+++ b/drivers/net/wireless/wl12xx/init.h
@@ -27,12 +27,13 @@
#include "wl12xx.h"
int wl1271_hw_init_power_auth(struct wl1271 *wl);
-int wl1271_sta_init_templates_config(struct wl1271 *wl);
+int wl1271_init_templates_config(struct wl1271 *wl);
int wl1271_init_phy_config(struct wl1271 *wl);
int wl1271_init_pta(struct wl1271 *wl);
int wl1271_init_energy_detection(struct wl1271 *wl);
int wl1271_chip_specific_init(struct wl1271 *wl);
-int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif);
+int wl1271_hw_init(struct wl1271 *wl);
+int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif);
int wl1271_init_ap_rates(struct wl1271 *wl);
int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif);
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index d676794..28f47e0 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -676,7 +676,7 @@ static int wl1271_plt_init(struct wl1271 *wl)
if (ret < 0)
return ret;
- ret = wl1271_sta_init_templates_config(wl);
+ ret = wl1271_init_templates_config(wl);
if (ret < 0)
return ret;
@@ -1919,6 +1919,10 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
if (ret < 0)
goto power_off;
+ ret = wl1271_hw_init(wl);
+ if (ret < 0)
+ goto irq_disable;
+
if (wl->bss_type == BSS_TYPE_STA_BSS ||
wl->bss_type == BSS_TYPE_IBSS) {
/*
@@ -1939,7 +1943,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
if (ret < 0)
goto irq_disable;
- ret = wl1271_hw_init(wl, vif);
+ ret = wl1271_init_vif_specific(wl, vif);
if (ret < 0)
goto irq_disable;
--
1.7.6.401.g6a319
next prev parent reply other threads:[~2011-10-05 9:56 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-05 9:55 [PATCH 00/29] wl12xx: start preparing the driver for multi-vif support Eliad Peller
2011-10-05 9:55 ` [PATCH 01/29] wl12xx: disable AP-mode-specific quirks Eliad Peller
2011-10-05 9:55 ` [PATCH 02/29] wl12xx: replace wl->mac_addr with vif->addr Eliad Peller
2011-10-05 9:55 ` Eliad Peller [this message]
2011-10-05 9:55 ` [PATCH 04/29] wl12xx: define wl12xx_vif Eliad Peller
2011-10-05 9:55 ` [PATCH 05/29] wl12xx: move rate_set into wlvif Eliad Peller
2011-10-05 9:55 ` [PATCH 06/29] wl12xx: move basic_rate " Eliad Peller
2011-10-05 9:55 ` [PATCH 07/29] wl12xx: replace wl->bssid with vif->bss_conf.bssid Eliad Peller
2011-10-05 9:55 ` [PATCH 08/29] wl12xx: move bss_type into wlvif Eliad Peller
2011-10-05 9:55 ` [PATCH 09/29] wl12xx: remove set_bss_type field Eliad Peller
2011-10-05 9:55 ` [PATCH 10/29] wl12xx: move p2p into wlvif Eliad Peller
2011-10-05 9:55 ` [PATCH 11/29] wl12xx: move ssid and ssid_len " Eliad Peller
2011-10-05 9:55 ` [PATCH 12/29] wl12xx: move probereq " Eliad Peller
2011-10-05 9:55 ` [PATCH 13/29] wl12xx: move aid " Eliad Peller
2011-10-05 9:55 ` [PATCH 14/29] wl12xx: move role_id " Eliad Peller
2011-10-05 9:55 ` [PATCH 15/29] wl12xx: move dev_role_id " Eliad Peller
2011-10-05 9:55 ` [PATCH 16/29] wl12xx: move sta_hlid " Eliad Peller
2011-10-05 9:55 ` [PATCH 17/29] wl12xx: move ap_global_hlid and ap_bcast_hlid " Eliad Peller
2011-10-05 9:55 ` [PATCH 18/29] wl12xx: move session_counter " Eliad Peller
2011-10-05 9:55 ` [PATCH 19/29] wl12xx: move some logic into wl12xx_init_vif_data Eliad Peller
2011-10-05 9:55 ` [PATCH 20/29] wl12xx: move dev_hlid into wlvif Eliad Peller
2011-10-05 9:55 ` [PATCH 21/29] wl12xx: move beacon_int " Eliad Peller
2011-10-05 9:55 ` [PATCH 22/29] wl12xx: move default_key " Eliad Peller
2011-10-05 9:56 ` [PATCH 23/29] wl12xx: move pspoll_work " Eliad Peller
2011-10-05 9:56 ` [PATCH 24/29] wl12xx: move ps_compl " Eliad Peller
2011-10-05 9:56 ` [PATCH 25/29] wl12xx: move ps_poll_failures and psm_entry_retry " Eliad Peller
2011-10-05 9:56 ` [PATCH 26/29] wl12xx: move rssi_thold and last_rssi_event " Eliad Peller
2011-10-05 9:56 ` [PATCH 27/29] wl12xx: move ba fields " Eliad Peller
2011-10-05 9:56 ` [PATCH 28/29] wl12xx: move ap_hlid_map into wlvif.ap Eliad Peller
2011-10-05 9:56 ` [PATCH 29/29] wl12xx: move recorded_ap_keys into wlvif Eliad Peller
2011-10-06 13:18 ` [PATCH 00/29] wl12xx: start preparing the driver for multi-vif support Luciano Coelho
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1317808566-18857-4-git-send-email-eliad@wizery.com \
--to=eliad@wizery.com \
--cc=coelho@ti.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox