Skip to contentSkip to conversation

rt2x00: Create write_tx_data and kick_tx_queue functions

PATCH In review Ivo van Doorn 1 participant 1 message Feb 28, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 10/28 rt2x00: Create write_tx_data and kick_tx_queue functions

Create write_tx_data and kick_tx_queue functions. This will make the tx() function itself more generic which is something we need when we are going to add the rt2x00lib module.

---

drivers/net/wireless/mac80211/rt2x00/rt2400pci.c +65 -43
index afdaa9a..e9ff871 100644
@@ -1557,6 +1557,67 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
 }
 
 /*
+ * TX data initialization
+ */
+static int rt2400pci_write_tx_data(struct rt2x00_dev *rt2x00dev,
+	struct data_ring *ring, struct sk_buff *skb,
+	struct ieee80211_tx_control *control)
+{
+	struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr*)skb->data;
+	struct data_entry *entry = rt2x00_get_data_entry(ring);
+	struct data_desc *txd = entry->priv;
+	u32 word;
+	u16 fc;
+
+	if (rt2x00_ring_full(ring)) {
+		ieee80211_stop_queue(rt2x00dev->hw, control->queue);
+		return -EINVAL;
+	}
+
+	rt2x00_desc_read(txd, 0, &word);
+
+	if (rt2x00_get_field32(word, TXD_W0_OWNER_NIC) ||
+	    rt2x00_get_field32(word, TXD_W0_VALID)) {
+		ERROR("Arrived at non-free entry in the non-full queue %d.\n"
+		      "Please file bug report to %s.\n",
+		      control->queue, DRV_PROJECT);
+		ieee80211_stop_queue(rt2x00dev->hw, control->queue);
+		return -EINVAL;
+	}
+
+	memcpy(entry->data_addr, skb->data, skb->len);
+	rt2400pci_write_tx_desc(rt2x00dev, txd, ieee80211hdr,
+		skb->len, control);
+	memcpy(&entry->tx_status.control, control, sizeof(*control));
+	entry->skb = skb;
+
+	fc = le16_to_cpu(ieee80211hdr->frame_control);
+	if (is_cts_frame(fc) || is_rts_frame(fc))
+		SET_FLAG(entry, ENTRY_RTS_CTS_FRAME);
+
+	rt2x00_ring_index_inc(ring);
+
+	if (rt2x00_ring_full(ring))
+		ieee80211_stop_queue(rt2x00dev->hw, control->queue);
+
+	return 0;
+}
+
+static void rt2400pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev, int queue)
+{
+	u32 reg;
+
+	rt2x00_register_read(rt2x00dev, TXCSR0, &reg);
+	if (queue == IEEE80211_TX_QUEUE_DATA0)
+		rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, 1);
+	else if (queue == IEEE80211_TX_QUEUE_DATA1)
+		rt2x00_set_field32(&reg, TXCSR0_KICK_TX, 1);
+	else if (queue == IEEE80211_TX_QUEUE_AFTER_BEACON)
+		rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, 1);
+	rt2x00_register_write(rt2x00dev, TXCSR0, reg);
+}
+
+/*
  * Interrupt functions.
  */
 static void rt2400pci_beacondone(struct work_struct *work)
@@ -1670,7 +1731,7 @@ static void rt2400pci_txdone(struct work_struct *work)
 		 * was succesfull.
 		 */
 		ack = rt2x00_get_field32(word, TXD_W0_ACK);
-		rts = GET_FLAG(entry, ENTRY_RTS_FRAME);
+		rts = GET_FLAG(entry, ENTRY_RTS_CTS_FRAME);
 		tx_status = rt2x00_get_field32(word, TXD_W0_RESULT);
 		rt2x00_update_tx_stats(rt2x00dev, &entry->tx_status, tx_status,
 			ack, rts);
@@ -1694,7 +1755,7 @@ static void rt2400pci_txdone(struct work_struct *work)
 
 		rt2x00_set_field32(&word, TXD_W0_VALID, 0);
 		rt2x00_desc_write(txd, 0, word);
-		CLEAR_FLAG(entry, ENTRY_RTS_FRAME);
+		CLEAR_FLAG(entry, ENTRY_RTS_CTS_FRAME);
 		entry->skb = NULL;
 
 		rt2x00_ring_index_done_inc(ring);
@@ -1795,12 +1856,8 @@ static int rt2400pci_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
 	struct rt2x00_dev *rt2x00dev = hw->priv;
 	struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr*)skb->data;
 	struct data_ring *ring;
-	struct data_entry *entry;
-	struct data_desc *txd;
 	struct sk_buff *skb_rts;
 	u16 frame_control;
-	u32 word;
-	u32 reg;
 	int res;
 
 	/*
@@ -1840,45 +1897,10 @@ static int rt2400pci_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
 		}
 	}
 
-	entry = rt2x00_get_data_entry(ring);
-	txd = rt2x00_desc_addr(entry);
-	rt2x00_desc_read(txd, 0, &word);
-
-	if (rt2x00_get_field32(word, TXD_W0_OWNER_NIC) ||
-	    rt2x00_get_field32(word, TXD_W0_VALID)) {
-		ERROR("Arrived at non-free entry in the non-full queue %d.\n"
-			"Please file bug report to %s.\n",
-			control->queue, DRV_PROJECT);
-		ieee80211_stop_queue(hw, control->queue);
+	if (rt2400pci_write_tx_data(rt2x00dev, ring, skb, control))
 		return NETDEV_TX_BUSY;
-	}
-
-	/*
-	 * Set the software sequence number.
-	 */
-	rt2x00_set_sequence(skb, &rt2x00dev->interface.sequence);
-
-	memcpy(rt2x00_data_addr(entry), skb->data, skb->len);
-	rt2400pci_write_tx_desc(rt2x00dev, txd, ieee80211hdr,
-		skb->len, control);
-	memcpy(&entry->tx_status.control, control, sizeof(*control));
-	if (is_rts_frame(frame_control))
-		SET_FLAG(entry, ENTRY_RTS_FRAME);
-	entry->skb = skb;
 
-	rt2x00_ring_index_inc(ring);
-
-	if (rt2x00_ring_full(ring))
-		ieee80211_stop_queue(hw, control->queue);
-
-	rt2x00_register_read(rt2x00dev, TXCSR0, &reg);
-	if (control->queue == IEEE80211_TX_QUEUE_DATA0)
-		rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, 1);
-	else if (control->queue == IEEE80211_TX_QUEUE_DATA1)
-		rt2x00_set_field32(&reg, TXCSR0_KICK_TX, 1);
-	else if (control->queue == IEEE80211_TX_QUEUE_AFTER_BEACON)
-		rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, 1);
-	rt2x00_register_write(rt2x00dev, TXCSR0, reg);
+	rt2400pci_kick_tx_queue(rt2x00dev, control->queue);
 
 	return NETDEV_TX_OK;
 }
drivers/net/wireless/mac80211/rt2x00/rt2500pci.c +65 -43

142 lines not on this page · raw message

drivers/net/wireless/mac80211/rt2x00/rt2500usb.c +69 -48

152 lines not on this page · raw message

drivers/net/wireless/mac80211/rt2x00/rt2x00.h +5 -2
index fe9ac7d..d6e968c 100644
@@ -135,6 +135,9 @@ static int rt2x00_debug_level = 0;
 #define is_rts_frame(__fc) \
 	( !!((((__fc) &  IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && \
 	     (((__fc) &  IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_RTS)) )
+#define is_cts_frame(__fc) \
+	( !!((((__fc) &  IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && \
+	     (((__fc) &  IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_CTS)) )
 #define is_probe_resp(__fc) \
 	( !!((((__fc) & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && \
 	     (((__fc) & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP)) )
@@ -518,8 +521,8 @@ struct data_entry {
 	 * Status flags
 	 */
 	unsigned int flags;
-#define ENTRY_OWNER_NIC	0x00000001
-#define ENTRY_RTS_FRAME	0x00000002
+#define ENTRY_OWNER_NIC		0x00000001
+#define ENTRY_RTS_CTS_FRAME	0x00000002
 
 	/*
 	 * Ring we belong to.
drivers/net/wireless/mac80211/rt2x00/rt61pci.c +68 -42

144 lines not on this page · raw message

drivers/net/wireless/mac80211/rt2x00/rt73usb.c +68 -48

151 lines not on this page · raw message