linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Cavagnolo <brian@cozybit.com>
To: linux-wireless@vger.kernel.org
Cc: buytenh@wantstofly.org, Pradeep Nemavat <pnemavat@marvell.com>,
	Nishant Sarmukadam <nishants@marvell.com>,
	Brian Cavagnolo <brian@cozybit.com>
Subject: [PATCH 3/7] mwl8k: allow for padding in AP transmit descriptor
Date: Mon,  1 Nov 2010 17:55:47 -0700	[thread overview]
Message-ID: <1288659351-22313-3-git-send-email-brian@cozybit.com> (raw)
In-Reply-To: <1288659351-22313-1-git-send-email-brian@cozybit.com>

From: Pradeep Nemavat <pnemavat@marvell.com>

The AP transmit descriptor has padding of 20 bytes at the
end of the descriptor. This padding is not used by mwl8k driver
but it still has to be accounted for while calculating the size
of the descriptor in order to calculate start of next descriptor.
Allow for different transmit descriptor size due to padding for AP
transmit descriptor.

Signed-off-by: Nishant Sarmukadam <nishants@marvell.com>
Signed-off-by: Brian Cavagnolo <brian@cozybit.com>
---
 drivers/net/wireless/mwl8k.c |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index cfda87a..9d614b8 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -121,7 +121,8 @@ struct mwl8k_tx_queue {
 	int tail;
 
 	unsigned int len;
-	struct mwl8k_tx_desc *txd;
+	void *txd;
+
 	dma_addr_t txd_dma;
 	struct sk_buff **skb;
 };
@@ -210,6 +211,9 @@ struct mwl8k_priv {
 
 	/* Most recently reported noise in dBm */
 	s8 noise;
+
+	/* Size of the tx descriptor for the currently loaded firmware */
+	unsigned short txd_size;
 };
 
 /* Per interface specific private data */
@@ -1116,6 +1120,15 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
 #define MWL8K_QOS_ACK_POLICY_BLOCKACK		0x0060
 #define MWL8K_QOS_EOSP				0x0010
 
+/*
+ * The size of the tx descriptors used by the firmware varies depending on
+ * whether we use AP firmware or STA firmware.  However, the fields used by
+ * this driver are identical, so the difference in size is treated as padding
+ * at the end of the structure.
+ */
+#define MWL8K_TX_DESC_SIZE_STA			32
+#define MWL8K_TX_DESC_SIZE_AP			52
+
 struct mwl8k_tx_desc {
 	__le32 status;
 	__u8 data_rate;
@@ -1144,7 +1157,7 @@ static int mwl8k_txq_init(struct ieee80211_hw *hw, int index)
 	txq->head = 0;
 	txq->tail = 0;
 
-	size = MWL8K_TX_DESCS * sizeof(struct mwl8k_tx_desc);
+	size = MWL8K_TX_DESCS * priv->txd_size;
 
 	txq->txd = pci_alloc_consistent(priv->pdev, size, &txq->txd_dma);
 	if (txq->txd == NULL) {
@@ -1165,12 +1178,12 @@ static int mwl8k_txq_init(struct ieee80211_hw *hw, int index)
 		struct mwl8k_tx_desc *tx_desc;
 		int nexti;
 
-		tx_desc = txq->txd + i;
+		tx_desc = txq->txd + i * priv->txd_size;
 		nexti = (i + 1) % MWL8K_TX_DESCS;
 
 		tx_desc->status = 0;
 		tx_desc->next_txd_phys_addr =
-			cpu_to_le32(txq->txd_dma + nexti * sizeof(*tx_desc));
+			cpu_to_le32(txq->txd_dma + nexti * priv->txd_size);
 	}
 
 	return 0;
@@ -1198,9 +1211,10 @@ static void mwl8k_dump_tx_rings(struct ieee80211_hw *hw)
 		int desc;
 
 		for (desc = 0; desc < MWL8K_TX_DESCS; desc++) {
-			struct mwl8k_tx_desc *tx_desc = txq->txd + desc;
+			struct mwl8k_tx_desc *tx_desc;
 			u32 status;
 
+			tx_desc = txq->txd + desc * priv->txd_size;
 			status = le32_to_cpu(tx_desc->status);
 			if (status & MWL8K_TXD_STATUS_FW_OWNED)
 				fw_owned++;
@@ -1309,7 +1323,7 @@ mwl8k_txq_reclaim(struct ieee80211_hw *hw, int index, int limit, int force)
 		u32 status;
 
 		tx = txq->head;
-		tx_desc = txq->txd + tx;
+		tx_desc = txq->txd + tx * priv->txd_size;
 
 		status = le32_to_cpu(tx_desc->status);
 
@@ -1367,7 +1381,7 @@ static void mwl8k_txq_deinit(struct ieee80211_hw *hw, int index)
 	txq->skb = NULL;
 
 	pci_free_consistent(priv->pdev,
-			    MWL8K_TX_DESCS * sizeof(struct mwl8k_tx_desc),
+			    MWL8K_TX_DESCS * priv->txd_size,
 			    txq->txd, txq->txd_dma);
 	txq->txd = NULL;
 }
@@ -1440,7 +1454,7 @@ mwl8k_txq_xmit(struct ieee80211_hw *hw, int index, struct sk_buff *skb)
 	BUG_ON(txq->skb[txq->tail] != NULL);
 	txq->skb[txq->tail] = skb;
 
-	tx = txq->txd + txq->tail;
+	tx = txq->txd + txq->tail * priv->txd_size;
 	tx->data_rate = txdatarate;
 	tx->tx_priority = index;
 	tx->qos_control = cpu_to_le16(qos);
@@ -4038,8 +4052,10 @@ static int __devinit mwl8k_probe(struct pci_dev *pdev,
 				  "Driver does not have AP firmware image support for this hardware\n");
 			goto err_stop_firmware;
 		}
+		priv->txd_size = MWL8K_TX_DESC_SIZE_AP;
 	} else {
 		priv->rxd_ops = &rxd_sta_ops;
+		priv->txd_size = MWL8K_TX_DESC_SIZE_STA;
 	}
 
 	priv->sniffer_enabled = false;
-- 
1.7.1.1


  parent reply	other threads:[~2010-11-02  0:56 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-02  0:55 [PATCH 1/7] mwl8k: add firmware files for 8366 Brian Cavagnolo
2010-11-02  0:55 ` [PATCH 2/7] mwl8k: rf_tx_power cmd deprecated for AP firmware Brian Cavagnolo
2010-11-02  8:32   ` Lennert Buytenhek
2010-11-02  0:55 ` Brian Cavagnolo [this message]
2010-11-02  8:53   ` [PATCH 3/7] mwl8k: allow for padding in AP transmit descriptor Lennert Buytenhek
2010-11-02  0:55 ` [PATCH 4/7] mwl8k: force AP mode to use non-AMPDU frames Brian Cavagnolo
2010-11-02  8:57   ` Lennert Buytenhek
2010-11-02  0:55 ` [PATCH 5/7] mwl8k: factor out firmware loading and hw init code Brian Cavagnolo
2010-11-02  9:01   ` Lennert Buytenhek
2010-11-02  0:55 ` [PATCH 6/7] mwl8k: choose proper firmware image as directed by user Brian Cavagnolo
2010-11-02  8:30   ` Lennert Buytenhek
2010-11-04  0:19     ` Brian Cavagnolo
2010-11-02  0:55 ` [PATCH 7/7] mac80211: unset SDATA_STATE_OFFCHANNEL when cancelling a scan Brian Cavagnolo
2010-11-02  8:31   ` Lennert Buytenhek
2010-11-04  0:20     ` Brian Cavagnolo
2010-11-02  8:22 ` [PATCH 1/7] mwl8k: add firmware files for 8366 Lennert Buytenhek
2010-11-04  0:19   ` Brian Cavagnolo
2010-11-04 15:36     ` Johannes Berg
2010-11-04 20:53       ` Brian Cavagnolo
2010-11-05  0:15     ` Lennert Buytenhek
2010-11-13  1:23 ` [PATCH V2 0/6] mwl8k: add initial support for AP firmware on 8366 Brian Cavagnolo
2010-11-13  1:23 ` [PATCH V2 1/7] mwl8k: revert unnecessary modification of tx descriptor Brian Cavagnolo
2010-11-13  1:23 ` [PATCH V2 2/7] mwl8k: rf_tx_power cmd not supported by AP firmware APIv1 Brian Cavagnolo
2010-11-13  1:23 ` [PATCH V2 3/7] mwl8k: factor out firmware loading and hw init code Brian Cavagnolo
2010-11-13  1:25   ` Brian Cavagnolo
2010-11-13  1:23 ` [PATCH V2 4/7] mwl8k: choose proper firmware image as directed by user Brian Cavagnolo
2010-11-13  1:25   ` Brian Cavagnolo
2010-11-13  1:23 ` [PATCH V2 5/7] mwl8k: add API version checking for AP firmware Brian Cavagnolo
2010-11-13  1:23 ` [PATCH V2 6/7] mwl8k: make initial firmware load asynchronous Brian Cavagnolo
2010-11-13  1:23 ` [PATCH V2 7/7] mwl8k: use const struct fw pointers throughout Brian Cavagnolo

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=1288659351-22313-3-git-send-email-brian@cozybit.com \
    --to=brian@cozybit.com \
    --cc=buytenh@wantstofly.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nishants@marvell.com \
    --cc=pnemavat@marvell.com \
    /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;
as well as URLs for NNTP newsgroup(s).