Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75fb4df7 authored by Eliad Peller's avatar Eliad Peller Committed by John W. Linville
Browse files

wlcore/wl12xx/wl18xx: simplify fw_status handling



Instead of splitting the fw_status into 2 and using some
complex calculations, read the fw status and let each low-level
driver (wl12xx/wl18xx) convert it into a common struct.

This is required for the upcoming fw api changes, which
break the current logic anyway.

Signed-off-by: default avatarEliad Peller <eliad@wizery.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 7a536265
Loading
Loading
Loading
Loading
+34 −1
Original line number Diff line number Diff line
@@ -1378,7 +1378,7 @@ static u32 wl12xx_get_rx_packet_len(struct wl1271 *wl, void *rx_data,

static int wl12xx_tx_delayed_compl(struct wl1271 *wl)
{
	if (wl->fw_status_1->tx_results_counter ==
	if (wl->fw_status->tx_results_counter ==
	    (wl->tx_results_count & 0xff))
		return 0;

@@ -1438,6 +1438,37 @@ static int wl12xx_hw_init(struct wl1271 *wl)
	return ret;
}

static void wl12xx_convert_fw_status(struct wl1271 *wl, void *raw_fw_status,
				     struct wl_fw_status *fw_status)
{
	struct wl12xx_fw_status *int_fw_status = raw_fw_status;

	fw_status->intr = le32_to_cpu(int_fw_status->intr);
	fw_status->fw_rx_counter = int_fw_status->fw_rx_counter;
	fw_status->drv_rx_counter = int_fw_status->drv_rx_counter;
	fw_status->tx_results_counter = int_fw_status->tx_results_counter;
	fw_status->rx_pkt_descs = int_fw_status->rx_pkt_descs;

	fw_status->fw_localtime = le32_to_cpu(int_fw_status->fw_localtime);
	fw_status->link_ps_bitmap = le32_to_cpu(int_fw_status->link_ps_bitmap);
	fw_status->link_fast_bitmap =
			le32_to_cpu(int_fw_status->link_fast_bitmap);
	fw_status->total_released_blks =
			le32_to_cpu(int_fw_status->total_released_blks);
	fw_status->tx_total = le32_to_cpu(int_fw_status->tx_total);

	fw_status->counters.tx_released_pkts =
			int_fw_status->counters.tx_released_pkts;
	fw_status->counters.tx_lnk_free_pkts =
			int_fw_status->counters.tx_lnk_free_pkts;
	fw_status->counters.tx_voice_released_blks =
			int_fw_status->counters.tx_voice_released_blks;
	fw_status->counters.tx_last_rate =
			int_fw_status->counters.tx_last_rate;

	fw_status->log_start_addr = le32_to_cpu(int_fw_status->log_start_addr);
}

static u32 wl12xx_sta_get_ap_rate_mask(struct wl1271 *wl,
				       struct wl12xx_vif *wlvif)
{
@@ -1677,6 +1708,7 @@ static struct wlcore_ops wl12xx_ops = {
	.tx_delayed_compl	= wl12xx_tx_delayed_compl,
	.hw_init		= wl12xx_hw_init,
	.init_vif		= NULL,
	.convert_fw_status	= wl12xx_convert_fw_status,
	.sta_get_ap_rate_mask	= wl12xx_sta_get_ap_rate_mask,
	.get_pg_ver		= wl12xx_get_pg_ver,
	.get_mac		= wl12xx_get_mac,
@@ -1725,6 +1757,7 @@ static int wl12xx_setup(struct wl1271 *wl)
	wl->band_rate_to_idx = wl12xx_band_rate_to_idx;
	wl->hw_tx_rate_tbl_size = WL12XX_CONF_HW_RXTX_RATE_MAX;
	wl->hw_min_ht_rate = WL12XX_CONF_HW_RXTX_RATE_MCS0;
	wl->fw_status_len = sizeof(struct wl12xx_fw_status);
	wl->fw_status_priv_len = 0;
	wl->stats.fw_stats_len = sizeof(struct wl12xx_acx_statistics);
	wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ, &wl12xx_ht_cap);
+50 −0
Original line number Diff line number Diff line
@@ -79,4 +79,54 @@ struct wl12xx_priv {
	struct wl127x_rx_mem_pool_addr *rx_mem_addr;
};

struct wl12xx_fw_packet_counters {
	/* Cumulative counter of released packets per AC */
	u8 tx_released_pkts[NUM_TX_QUEUES];

	/* Cumulative counter of freed packets per HLID */
	u8 tx_lnk_free_pkts[WL12XX_MAX_LINKS];

	/* Cumulative counter of released Voice memory blocks */
	u8 tx_voice_released_blks;

	/* Tx rate of the last transmitted packet */
	u8 tx_last_rate;

	u8 padding[2];
} __packed;

/* FW status registers */
struct wl12xx_fw_status {
	__le32 intr;
	u8  fw_rx_counter;
	u8  drv_rx_counter;
	u8  reserved;
	u8  tx_results_counter;
	__le32 rx_pkt_descs[WL12XX_NUM_RX_DESCRIPTORS];

	__le32 fw_localtime;

	/*
	 * A bitmap (where each bit represents a single HLID)
	 * to indicate if the station is in PS mode.
	 */
	__le32 link_ps_bitmap;

	/*
	 * A bitmap (where each bit represents a single HLID) to indicate
	 * if the station is in Fast mode
	 */
	__le32 link_fast_bitmap;

	/* Cumulative counter of total released mem blocks since FW-reset */
	__le32 total_released_blks;

	/* Size (in Memory Blocks) of TX pool */
	__le32 tx_total;

	struct wl12xx_fw_packet_counters counters;

	__le32 log_start_addr;
} __packed;

#endif /* __WL12XX_PRIV_H__ */
+37 −2
Original line number Diff line number Diff line
@@ -1133,6 +1133,39 @@ static int wl18xx_hw_init(struct wl1271 *wl)
	return ret;
}

static void wl18xx_convert_fw_status(struct wl1271 *wl, void *raw_fw_status,
				     struct wl_fw_status *fw_status)
{
	struct wl18xx_fw_status *int_fw_status = raw_fw_status;

	fw_status->intr = le32_to_cpu(int_fw_status->intr);
	fw_status->fw_rx_counter = int_fw_status->fw_rx_counter;
	fw_status->drv_rx_counter = int_fw_status->drv_rx_counter;
	fw_status->tx_results_counter = int_fw_status->tx_results_counter;
	fw_status->rx_pkt_descs = int_fw_status->rx_pkt_descs;

	fw_status->fw_localtime = le32_to_cpu(int_fw_status->fw_localtime);
	fw_status->link_ps_bitmap = le32_to_cpu(int_fw_status->link_ps_bitmap);
	fw_status->link_fast_bitmap =
			le32_to_cpu(int_fw_status->link_fast_bitmap);
	fw_status->total_released_blks =
			le32_to_cpu(int_fw_status->total_released_blks);
	fw_status->tx_total = le32_to_cpu(int_fw_status->tx_total);

	fw_status->counters.tx_released_pkts =
			int_fw_status->counters.tx_released_pkts;
	fw_status->counters.tx_lnk_free_pkts =
			int_fw_status->counters.tx_lnk_free_pkts;
	fw_status->counters.tx_voice_released_blks =
			int_fw_status->counters.tx_voice_released_blks;
	fw_status->counters.tx_last_rate =
			int_fw_status->counters.tx_last_rate;

	fw_status->log_start_addr = le32_to_cpu(int_fw_status->log_start_addr);

	fw_status->priv = &int_fw_status->priv;
}

static void wl18xx_set_tx_desc_csum(struct wl1271 *wl,
				    struct wl1271_tx_hw_descr *desc,
				    struct sk_buff *skb)
@@ -1572,7 +1605,7 @@ static bool wl18xx_lnk_high_prio(struct wl1271 *wl, u8 hlid,
{
	u8 thold;
	struct wl18xx_fw_status_priv *status_priv =
		(struct wl18xx_fw_status_priv *)wl->fw_status_2->priv;
		(struct wl18xx_fw_status_priv *)wl->fw_status->priv;
	u32 suspend_bitmap = le32_to_cpu(status_priv->link_suspend_bitmap);

	/* suspended links are never high priority */
@@ -1594,7 +1627,7 @@ static bool wl18xx_lnk_low_prio(struct wl1271 *wl, u8 hlid,
{
	u8 thold;
	struct wl18xx_fw_status_priv *status_priv =
		(struct wl18xx_fw_status_priv *)wl->fw_status_2->priv;
		(struct wl18xx_fw_status_priv *)wl->fw_status->priv;
	u32 suspend_bitmap = le32_to_cpu(status_priv->link_suspend_bitmap);

	if (test_bit(hlid, (unsigned long *)&suspend_bitmap))
@@ -1632,6 +1665,7 @@ static struct wlcore_ops wl18xx_ops = {
	.tx_immediate_compl = wl18xx_tx_immediate_completion,
	.tx_delayed_compl = NULL,
	.hw_init	= wl18xx_hw_init,
	.convert_fw_status = wl18xx_convert_fw_status,
	.set_tx_desc_csum = wl18xx_set_tx_desc_csum,
	.get_pg_ver	= wl18xx_get_pg_ver,
	.set_rx_csum = wl18xx_set_rx_csum,
@@ -1726,6 +1760,7 @@ static int wl18xx_setup(struct wl1271 *wl)
	wl->band_rate_to_idx = wl18xx_band_rate_to_idx;
	wl->hw_tx_rate_tbl_size = WL18XX_CONF_HW_RXTX_RATE_MAX;
	wl->hw_min_ht_rate = WL18XX_CONF_HW_RXTX_RATE_MCS0;
	wl->fw_status_len = sizeof(struct wl18xx_fw_status);
	wl->fw_status_priv_len = sizeof(struct wl18xx_fw_status_priv);
	wl->stats.fw_stats_len = sizeof(struct wl18xx_acx_statistics);
	wl->static_data_priv_len = sizeof(struct wl18xx_static_data_priv);
+2 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ static
void wl18xx_get_last_tx_rate(struct wl1271 *wl, struct ieee80211_vif *vif,
			     struct ieee80211_tx_rate *rate)
{
	u8 fw_rate = wl->fw_status_2->counters.tx_last_rate;
	u8 fw_rate = wl->fw_status->counters.tx_last_rate;

	if (fw_rate > CONF_HW_RATE_INDEX_MAX) {
		wl1271_error("last Tx rate invalid: %d", fw_rate);
@@ -139,7 +139,7 @@ static void wl18xx_tx_complete_packet(struct wl1271 *wl, u8 tx_stat_byte)
void wl18xx_tx_immediate_complete(struct wl1271 *wl)
{
	struct wl18xx_fw_status_priv *status_priv =
		(struct wl18xx_fw_status_priv *)wl->fw_status_2->priv;
		(struct wl18xx_fw_status_priv *)wl->fw_status->priv;
	struct wl18xx_priv *priv = wl->priv;
	u8 i;

+53 −0
Original line number Diff line number Diff line
@@ -109,6 +109,59 @@ struct wl18xx_fw_status_priv {
	u8 padding[3];
};

struct wl18xx_fw_packet_counters {
	/* Cumulative counter of released packets per AC */
	u8 tx_released_pkts[NUM_TX_QUEUES];

	/* Cumulative counter of freed packets per HLID */
	u8 tx_lnk_free_pkts[WL12XX_MAX_LINKS];

	/* Cumulative counter of released Voice memory blocks */
	u8 tx_voice_released_blks;

	/* Tx rate of the last transmitted packet */
	u8 tx_last_rate;

	u8 padding[2];
} __packed;

/* FW status registers */
struct wl18xx_fw_status {
	__le32 intr;
	u8  fw_rx_counter;
	u8  drv_rx_counter;
	u8  reserved;
	u8  tx_results_counter;
	__le32 rx_pkt_descs[WL18XX_NUM_RX_DESCRIPTORS];

	__le32 fw_localtime;

	/*
	 * A bitmap (where each bit represents a single HLID)
	 * to indicate if the station is in PS mode.
	 */
	__le32 link_ps_bitmap;

	/*
	 * A bitmap (where each bit represents a single HLID) to indicate
	 * if the station is in Fast mode
	 */
	__le32 link_fast_bitmap;

	/* Cumulative counter of total released mem blocks since FW-reset */
	__le32 total_released_blks;

	/* Size (in Memory Blocks) of TX pool */
	__le32 tx_total;

	struct wl18xx_fw_packet_counters counters;

	__le32 log_start_addr;

	/* Private status to be used by the lower drivers */
	struct wl18xx_fw_status_priv priv;
} __packed;

#define WL18XX_PHY_VERSION_MAX_LEN 20

struct wl18xx_static_data_priv {
Loading