aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2007-10-06 08:15:46 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:55:13 -0400
commitdd9fa2d21aebbb618318954867c5dfe3751328be (patch)
tree5487966881a7c4ca7061d52572d583ec4a9877d6 /drivers
parent9ee8f57e0adfd929759fee1ec6a7900ae6851bc5 (diff)
[PATCH] rt2x00: Add get_tx_data_len callback function
The TX datalen must always be converted to a value rt73 and rt2500usb understand. Both require to use a different size then skb->len. First off this is required because the descriptor must be added, but the second is because the value must be a multiple of either 2 or 4, and it should not be a multiple of the USB packetmax Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c32
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c29
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c16
4 files changed, 56 insertions, 23 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index c70c677b3f73..f536ff1b5c47 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1057,6 +1057,21 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1057 rt2x00_desc_write(txd, 0, word); 1057 rt2x00_desc_write(txd, 0, word);
1058} 1058}
1059 1059
1060static int rt2500usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
1061 int maxpacket, struct sk_buff *skb)
1062{
1063 int length;
1064
1065 /*
1066 * The length _must_ be a multiple of 2,
1067 * but it must _not_ be a multiple of the USB packet size.
1068 */
1069 length = roundup(skb->len, 2);
1070 length += (2 * !(length % maxpacket));
1071
1072 return length;
1073}
1074
1060/* 1075/*
1061 * TX data initialization 1076 * TX data initialization
1062 */ 1077 */
@@ -1653,6 +1668,8 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
1653 rt2x00lib_get_ring(rt2x00dev, IEEE80211_TX_QUEUE_BEACON); 1668 rt2x00lib_get_ring(rt2x00dev, IEEE80211_TX_QUEUE_BEACON);
1654 struct data_entry *beacon; 1669 struct data_entry *beacon;
1655 struct data_entry *guardian; 1670 struct data_entry *guardian;
1671 int pipe = usb_sndbulkpipe(usb_dev, 1);
1672 int max_packet = usb_maxpacket(usb_dev, pipe, 1);
1656 int length; 1673 int length;
1657 1674
1658 /* 1675 /*
@@ -1679,16 +1696,9 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
1679 ring->desc_size), 1696 ring->desc_size),
1680 skb->len - ring->desc_size, control); 1697 skb->len - ring->desc_size, control);
1681 1698
1682 /* 1699 length = rt2500usb_get_tx_data_len(rt2x00dev, max_packet, skb);
1683 * Length passed to usb_fill_urb cannot be an odd number,
1684 * so add 1 byte to make it even.
1685 */
1686 length = skb->len;
1687 if (length % 2)
1688 length++;
1689 1700
1690 usb_fill_bulk_urb(beacon->priv, usb_dev, 1701 usb_fill_bulk_urb(beacon->priv, usb_dev, pipe,
1691 usb_sndbulkpipe(usb_dev, 1),
1692 skb->data, length, rt2500usb_beacondone, beacon); 1702 skb->data, length, rt2500usb_beacondone, beacon);
1693 1703
1694 beacon->skb = skb; 1704 beacon->skb = skb;
@@ -1699,8 +1709,7 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
1699 * the 'flags' field we are not using for beacons. 1709 * the 'flags' field we are not using for beacons.
1700 */ 1710 */
1701 guardian->flags = 0; 1711 guardian->flags = 0;
1702 usb_fill_bulk_urb(guardian->priv, usb_dev, 1712 usb_fill_bulk_urb(guardian->priv, usb_dev, pipe,
1703 usb_sndbulkpipe(usb_dev, 1),
1704 &guardian->flags, 1, rt2500usb_beacondone, guardian); 1713 &guardian->flags, 1, rt2500usb_beacondone, guardian);
1705 1714
1706 /* 1715 /*
@@ -1741,6 +1750,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1741 .link_tuner = rt2500usb_link_tuner, 1750 .link_tuner = rt2500usb_link_tuner,
1742 .write_tx_desc = rt2500usb_write_tx_desc, 1751 .write_tx_desc = rt2500usb_write_tx_desc,
1743 .write_tx_data = rt2x00usb_write_tx_data, 1752 .write_tx_data = rt2x00usb_write_tx_data,
1753 .get_tx_data_len = rt2500usb_get_tx_data_len,
1744 .kick_tx_queue = rt2500usb_kick_tx_queue, 1754 .kick_tx_queue = rt2500usb_kick_tx_queue,
1745 .fill_rxdone = rt2500usb_fill_rxdone, 1755 .fill_rxdone = rt2500usb_fill_rxdone,
1746 .config_mac_addr = rt2500usb_config_mac_addr, 1756 .config_mac_addr = rt2500usb_config_mac_addr,
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 27bec6ec33df..a392e2a9d087 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -396,6 +396,8 @@ struct rt2x00lib_ops {
396 int (*write_tx_data) (struct rt2x00_dev *rt2x00dev, 396 int (*write_tx_data) (struct rt2x00_dev *rt2x00dev,
397 struct data_ring *ring, struct sk_buff *skb, 397 struct data_ring *ring, struct sk_buff *skb,
398 struct ieee80211_tx_control *control); 398 struct ieee80211_tx_control *control);
399 int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev, int maxpacket,
400 struct sk_buff *skb);
399 void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev, 401 void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev,
400 unsigned int queue); 402 unsigned int queue);
401 403
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index 66e47615f2a6..73cc726c4046 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -157,9 +157,10 @@ int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev,
157{ 157{
158 struct usb_device *usb_dev = 158 struct usb_device *usb_dev =
159 interface_to_usbdev(rt2x00dev_usb(rt2x00dev)); 159 interface_to_usbdev(rt2x00dev_usb(rt2x00dev));
160 struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr *)skb->data;
161 struct data_entry *entry = rt2x00_get_data_entry(ring); 160 struct data_entry *entry = rt2x00_get_data_entry(ring);
162 u32 length = skb->len; 161 int pipe = usb_sndbulkpipe(usb_dev, 1);
162 int max_packet = usb_maxpacket(usb_dev, pipe, 1);
163 u32 length;
163 164
164 if (rt2x00_ring_full(ring)) { 165 if (rt2x00_ring_full(ring)) {
165 ieee80211_stop_queue(rt2x00dev->hw, control->queue); 166 ieee80211_stop_queue(rt2x00dev->hw, control->queue);
@@ -178,25 +179,29 @@ int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev,
178 /* 179 /*
179 * Add the descriptor in front of the skb. 180 * Add the descriptor in front of the skb.
180 */ 181 */
181 skb_push(skb, rt2x00dev->hw->extra_tx_headroom); 182 skb_push(skb, ring->desc_size);
182 memset(skb->data, 0x00, rt2x00dev->hw->extra_tx_headroom); 183 memset(skb->data, 0, ring->desc_size);
183 184
184 rt2x00lib_write_tx_desc(rt2x00dev, (struct data_desc *)skb->data, 185 rt2x00lib_write_tx_desc(rt2x00dev, (struct data_desc *)skb->data,
185 ieee80211hdr, length, control); 186 (struct ieee80211_hdr *)(skb->data +
187 ring->desc_size),
188 skb->len - ring->desc_size, control);
186 memcpy(&entry->tx_status.control, control, sizeof(*control)); 189 memcpy(&entry->tx_status.control, control, sizeof(*control));
187 entry->skb = skb; 190 entry->skb = skb;
188 191
189 /* 192 /*
190 * Length passed to usb_fill_urb cannot be an odd number, 193 * USB devices cannot blindly pass the skb->len as the
191 * so add 1 byte to make it even. 194 * length of the data to usb_fill_bulk_urb. Pass the skb
195 * to the driver to determine what the length should be.
192 */ 196 */
193 length += rt2x00dev->hw->extra_tx_headroom; 197 length = rt2x00dev->ops->lib->get_tx_data_len(rt2x00dev,
194 if (length % 2) 198 max_packet, skb);
195 length++;
196 199
200 /*
201 * Initialize URB and send the frame to the device.
202 */
197 __set_bit(ENTRY_OWNER_NIC, &entry->flags); 203 __set_bit(ENTRY_OWNER_NIC, &entry->flags);
198 usb_fill_bulk_urb(entry->priv, usb_dev, 204 usb_fill_bulk_urb(entry->priv, usb_dev, pipe,
199 usb_sndbulkpipe(usb_dev, 1),
200 skb->data, length, rt2x00usb_interrupt_txdone, entry); 205 skb->data, length, rt2x00usb_interrupt_txdone, entry);
201 usb_submit_urb(entry->priv, GFP_ATOMIC); 206 usb_submit_urb(entry->priv, GFP_ATOMIC);
202 207
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 919cca593bc1..4a78ca79c94a 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -1286,6 +1286,21 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1286 rt2x00_desc_write(txd, 0, word); 1286 rt2x00_desc_write(txd, 0, word);
1287} 1287}
1288 1288
1289static int rt73usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
1290 int maxpacket, struct sk_buff *skb)
1291{
1292 int length;
1293
1294 /*
1295 * The length _must_ be a multiple of 4,
1296 * but it must _not_ be a multiple of the USB packet size.
1297 */
1298 length = roundup(skb->len, 4);
1299 length += (4 * !(length % maxpacket));
1300
1301 return length;
1302}
1303
1289/* 1304/*
1290 * TX data initialization 1305 * TX data initialization
1291 */ 1306 */
@@ -2012,6 +2027,7 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2012 .link_tuner = rt73usb_link_tuner, 2027 .link_tuner = rt73usb_link_tuner,
2013 .write_tx_desc = rt73usb_write_tx_desc, 2028 .write_tx_desc = rt73usb_write_tx_desc,
2014 .write_tx_data = rt2x00usb_write_tx_data, 2029 .write_tx_data = rt2x00usb_write_tx_data,
2030 .get_tx_data_len = rt73usb_get_tx_data_len,
2015 .kick_tx_queue = rt73usb_kick_tx_queue, 2031 .kick_tx_queue = rt73usb_kick_tx_queue,
2016 .fill_rxdone = rt73usb_fill_rxdone, 2032 .fill_rxdone = rt73usb_fill_rxdone,
2017 .config_mac_addr = rt73usb_config_mac_addr, 2033 .config_mac_addr = rt73usb_config_mac_addr,