aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2500usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2500usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c201
1 files changed, 119 insertions, 82 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index bd4bbcc639c3..edc16a5fc754 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1027,10 +1027,10 @@ static int rt2500usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1027 */ 1027 */
1028static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, 1028static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1029 struct sk_buff *skb, 1029 struct sk_buff *skb,
1030 struct txdata_entry_desc *desc, 1030 struct txentry_desc *txdesc,
1031 struct ieee80211_tx_control *control) 1031 struct ieee80211_tx_control *control)
1032{ 1032{
1033 struct skb_desc *skbdesc = get_skb_desc(skb); 1033 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
1034 __le32 *txd = skbdesc->desc; 1034 __le32 *txd = skbdesc->desc;
1035 u32 word; 1035 u32 word;
1036 1036
@@ -1039,31 +1039,31 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1039 */ 1039 */
1040 rt2x00_desc_read(txd, 1, &word); 1040 rt2x00_desc_read(txd, 1, &word);
1041 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, IEEE80211_HEADER); 1041 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, IEEE80211_HEADER);
1042 rt2x00_set_field32(&word, TXD_W1_AIFS, desc->aifs); 1042 rt2x00_set_field32(&word, TXD_W1_AIFS, txdesc->aifs);
1043 rt2x00_set_field32(&word, TXD_W1_CWMIN, desc->cw_min); 1043 rt2x00_set_field32(&word, TXD_W1_CWMIN, txdesc->cw_min);
1044 rt2x00_set_field32(&word, TXD_W1_CWMAX, desc->cw_max); 1044 rt2x00_set_field32(&word, TXD_W1_CWMAX, txdesc->cw_max);
1045 rt2x00_desc_write(txd, 1, word); 1045 rt2x00_desc_write(txd, 1, word);
1046 1046
1047 rt2x00_desc_read(txd, 2, &word); 1047 rt2x00_desc_read(txd, 2, &word);
1048 rt2x00_set_field32(&word, TXD_W2_PLCP_SIGNAL, desc->signal); 1048 rt2x00_set_field32(&word, TXD_W2_PLCP_SIGNAL, txdesc->signal);
1049 rt2x00_set_field32(&word, TXD_W2_PLCP_SERVICE, desc->service); 1049 rt2x00_set_field32(&word, TXD_W2_PLCP_SERVICE, txdesc->service);
1050 rt2x00_set_field32(&word, TXD_W2_PLCP_LENGTH_LOW, desc->length_low); 1050 rt2x00_set_field32(&word, TXD_W2_PLCP_LENGTH_LOW, txdesc->length_low);
1051 rt2x00_set_field32(&word, TXD_W2_PLCP_LENGTH_HIGH, desc->length_high); 1051 rt2x00_set_field32(&word, TXD_W2_PLCP_LENGTH_HIGH, txdesc->length_high);
1052 rt2x00_desc_write(txd, 2, word); 1052 rt2x00_desc_write(txd, 2, word);
1053 1053
1054 rt2x00_desc_read(txd, 0, &word); 1054 rt2x00_desc_read(txd, 0, &word);
1055 rt2x00_set_field32(&word, TXD_W0_RETRY_LIMIT, control->retry_limit); 1055 rt2x00_set_field32(&word, TXD_W0_RETRY_LIMIT, control->retry_limit);
1056 rt2x00_set_field32(&word, TXD_W0_MORE_FRAG, 1056 rt2x00_set_field32(&word, TXD_W0_MORE_FRAG,
1057 test_bit(ENTRY_TXD_MORE_FRAG, &desc->flags)); 1057 test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
1058 rt2x00_set_field32(&word, TXD_W0_ACK, 1058 rt2x00_set_field32(&word, TXD_W0_ACK,
1059 test_bit(ENTRY_TXD_ACK, &desc->flags)); 1059 test_bit(ENTRY_TXD_ACK, &txdesc->flags));
1060 rt2x00_set_field32(&word, TXD_W0_TIMESTAMP, 1060 rt2x00_set_field32(&word, TXD_W0_TIMESTAMP,
1061 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &desc->flags)); 1061 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
1062 rt2x00_set_field32(&word, TXD_W0_OFDM, 1062 rt2x00_set_field32(&word, TXD_W0_OFDM,
1063 test_bit(ENTRY_TXD_OFDM_RATE, &desc->flags)); 1063 test_bit(ENTRY_TXD_OFDM_RATE, &txdesc->flags));
1064 rt2x00_set_field32(&word, TXD_W0_NEW_SEQ, 1064 rt2x00_set_field32(&word, TXD_W0_NEW_SEQ,
1065 !!(control->flags & IEEE80211_TXCTL_FIRST_FRAGMENT)); 1065 !!(control->flags & IEEE80211_TXCTL_FIRST_FRAGMENT));
1066 rt2x00_set_field32(&word, TXD_W0_IFS, desc->ifs); 1066 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
1067 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); 1067 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len);
1068 rt2x00_set_field32(&word, TXD_W0_CIPHER, CIPHER_NONE); 1068 rt2x00_set_field32(&word, TXD_W0_CIPHER, CIPHER_NONE);
1069 rt2x00_desc_write(txd, 0, word); 1069 rt2x00_desc_write(txd, 0, word);
@@ -1114,42 +1114,61 @@ static void rt2500usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1114/* 1114/*
1115 * RX control handlers 1115 * RX control handlers
1116 */ 1116 */
1117static void rt2500usb_fill_rxdone(struct data_entry *entry, 1117static void rt2500usb_fill_rxdone(struct queue_entry *entry,
1118 struct rxdata_entry_desc *desc) 1118 struct rxdone_entry_desc *rxdesc)
1119{ 1119{
1120 struct skb_desc *skbdesc = get_skb_desc(entry->skb); 1120 struct queue_entry_priv_usb_rx *priv_rx = entry->priv_data;
1121 struct urb *urb = entry->priv; 1121 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1122 __le32 *rxd = (__le32 *)(entry->skb->data + 1122 __le32 *rxd =
1123 (urb->actual_length - entry->ring->desc_size)); 1123 (__le32 *)(entry->skb->data +
1124 (priv_rx->urb->actual_length - entry->queue->desc_size));
1125 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)entry->skb->data;
1126 int header_size = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control));
1124 u32 word0; 1127 u32 word0;
1125 u32 word1; 1128 u32 word1;
1126 1129
1127 rt2x00_desc_read(rxd, 0, &word0); 1130 rt2x00_desc_read(rxd, 0, &word0);
1128 rt2x00_desc_read(rxd, 1, &word1); 1131 rt2x00_desc_read(rxd, 1, &word1);
1129 1132
1130 desc->flags = 0; 1133 rxdesc->flags = 0;
1131 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) 1134 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR))
1132 desc->flags |= RX_FLAG_FAILED_FCS_CRC; 1135 rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
1133 if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR)) 1136 if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR))
1134 desc->flags |= RX_FLAG_FAILED_PLCP_CRC; 1137 rxdesc->flags |= RX_FLAG_FAILED_PLCP_CRC;
1135 1138
1136 /* 1139 /*
1137 * Obtain the status about this packet. 1140 * Obtain the status about this packet.
1138 */ 1141 */
1139 desc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL); 1142 rxdesc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL);
1140 desc->rssi = rt2x00_get_field32(word1, RXD_W1_RSSI) - 1143 rxdesc->rssi = rt2x00_get_field32(word1, RXD_W1_RSSI) -
1141 entry->ring->rt2x00dev->rssi_offset; 1144 entry->queue->rt2x00dev->rssi_offset;
1142 desc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM); 1145 rxdesc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM);
1143 desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); 1146 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1144 desc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS); 1147 rxdesc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS);
1145 1148
1146 /* 1149 /*
1147 * Set descriptor and data pointer. 1150 * The data behind the ieee80211 header must be
1151 * aligned on a 4 byte boundary.
1152 */
1153 if (header_size % 4 == 0) {
1154 skb_push(entry->skb, 2);
1155 memmove(entry->skb->data, entry->skb->data + 2,
1156 entry->skb->len - 2);
1157 }
1158
1159 /*
1160 * Set descriptor pointer.
1148 */ 1161 */
1149 skbdesc->desc = entry->skb->data + desc->size;
1150 skbdesc->desc_len = entry->ring->desc_size;
1151 skbdesc->data = entry->skb->data; 1162 skbdesc->data = entry->skb->data;
1152 skbdesc->data_len = desc->size; 1163 skbdesc->data_len = entry->queue->data_size;
1164 skbdesc->desc = entry->skb->data + rxdesc->size;
1165 skbdesc->desc_len = entry->queue->desc_size;
1166
1167 /*
1168 * Remove descriptor from skb buffer and trim the whole thing
1169 * down to only contain data.
1170 */
1171 skb_trim(entry->skb, rxdesc->size);
1153} 1172}
1154 1173
1155/* 1174/*
@@ -1157,10 +1176,10 @@ static void rt2500usb_fill_rxdone(struct data_entry *entry,
1157 */ 1176 */
1158static void rt2500usb_beacondone(struct urb *urb) 1177static void rt2500usb_beacondone(struct urb *urb)
1159{ 1178{
1160 struct data_entry *entry = (struct data_entry *)urb->context; 1179 struct queue_entry *entry = (struct queue_entry *)urb->context;
1161 struct data_ring *ring = entry->ring; 1180 struct queue_entry_priv_usb_bcn *priv_bcn = entry->priv_data;
1162 1181
1163 if (!test_bit(DEVICE_ENABLED_RADIO, &ring->rt2x00dev->flags)) 1182 if (!test_bit(DEVICE_ENABLED_RADIO, &entry->queue->rt2x00dev->flags))
1164 return; 1183 return;
1165 1184
1166 /* 1185 /*
@@ -1169,18 +1188,11 @@ static void rt2500usb_beacondone(struct urb *urb)
1169 * Otherwise we should free the sk_buffer, the device 1188 * Otherwise we should free the sk_buffer, the device
1170 * should be doing the rest of the work now. 1189 * should be doing the rest of the work now.
1171 */ 1190 */
1172 if (ring->index == 1) { 1191 if (priv_bcn->guardian_urb == urb) {
1173 rt2x00_ring_index_done_inc(ring); 1192 usb_submit_urb(priv_bcn->urb, GFP_ATOMIC);
1174 entry = rt2x00_get_data_entry(ring); 1193 } else if (priv_bcn->urb == urb) {
1175 usb_submit_urb(entry->priv, GFP_ATOMIC); 1194 dev_kfree_skb(entry->skb);
1176 rt2x00_ring_index_inc(ring); 1195 entry->skb = NULL;
1177 } else if (ring->index_done == 1) {
1178 entry = rt2x00_get_data_entry_done(ring);
1179 if (entry->skb) {
1180 dev_kfree_skb(entry->skb);
1181 entry->skb = NULL;
1182 }
1183 rt2x00_ring_index_done_inc(ring);
1184 } 1196 }
1185} 1197}
1186 1198
@@ -1599,9 +1611,10 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1599 rt2500usb_probe_hw_mode(rt2x00dev); 1611 rt2500usb_probe_hw_mode(rt2x00dev);
1600 1612
1601 /* 1613 /*
1602 * This device requires the beacon ring 1614 * This device requires the atim queue
1603 */ 1615 */
1604 __set_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags); 1616 __set_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags);
1617 __set_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags);
1605 1618
1606 /* 1619 /*
1607 * Set the rssi offset. 1620 * Set the rssi offset.
@@ -1691,12 +1704,11 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
1691 struct ieee80211_tx_control *control) 1704 struct ieee80211_tx_control *control)
1692{ 1705{
1693 struct rt2x00_dev *rt2x00dev = hw->priv; 1706 struct rt2x00_dev *rt2x00dev = hw->priv;
1694 struct usb_device *usb_dev = 1707 struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev);
1695 interface_to_usbdev(rt2x00dev_usb(rt2x00dev)); 1708 struct queue_entry_priv_usb_bcn *priv_bcn;
1696 struct skb_desc *desc; 1709 struct skb_frame_desc *skbdesc;
1697 struct data_ring *ring; 1710 struct data_queue *queue;
1698 struct data_entry *beacon; 1711 struct queue_entry *entry;
1699 struct data_entry *guardian;
1700 int pipe = usb_sndbulkpipe(usb_dev, 1); 1712 int pipe = usb_sndbulkpipe(usb_dev, 1);
1701 int length; 1713 int length;
1702 1714
@@ -1706,32 +1718,26 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
1706 * initialization. 1718 * initialization.
1707 */ 1719 */
1708 control->queue = IEEE80211_TX_QUEUE_BEACON; 1720 control->queue = IEEE80211_TX_QUEUE_BEACON;
1709 ring = rt2x00lib_get_ring(rt2x00dev, control->queue); 1721 queue = rt2x00queue_get_queue(rt2x00dev, control->queue);
1710 1722 entry = rt2x00queue_get_entry(queue, Q_INDEX);
1711 /* 1723 priv_bcn = entry->priv_data;
1712 * Obtain 2 entries, one for the guardian byte,
1713 * the second for the actual beacon.
1714 */
1715 guardian = rt2x00_get_data_entry(ring);
1716 rt2x00_ring_index_inc(ring);
1717 beacon = rt2x00_get_data_entry(ring);
1718 1724
1719 /* 1725 /*
1720 * Add the descriptor in front of the skb. 1726 * Add the descriptor in front of the skb.
1721 */ 1727 */
1722 skb_push(skb, ring->desc_size); 1728 skb_push(skb, queue->desc_size);
1723 memset(skb->data, 0, ring->desc_size); 1729 memset(skb->data, 0, queue->desc_size);
1724 1730
1725 /* 1731 /*
1726 * Fill in skb descriptor 1732 * Fill in skb descriptor
1727 */ 1733 */
1728 desc = get_skb_desc(skb); 1734 skbdesc = get_skb_frame_desc(skb);
1729 desc->desc_len = ring->desc_size; 1735 memset(skbdesc, 0, sizeof(*skbdesc));
1730 desc->data_len = skb->len - ring->desc_size; 1736 skbdesc->data = skb->data + queue->desc_size;
1731 desc->desc = skb->data; 1737 skbdesc->data_len = queue->data_size;
1732 desc->data = skb->data + ring->desc_size; 1738 skbdesc->desc = skb->data;
1733 desc->ring = ring; 1739 skbdesc->desc_len = queue->desc_size;
1734 desc->entry = beacon; 1740 skbdesc->entry = entry;
1735 1741
1736 rt2x00lib_write_tx_desc(rt2x00dev, skb, control); 1742 rt2x00lib_write_tx_desc(rt2x00dev, skb, control);
1737 1743
@@ -1742,22 +1748,23 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
1742 */ 1748 */
1743 length = rt2500usb_get_tx_data_len(rt2x00dev, skb); 1749 length = rt2500usb_get_tx_data_len(rt2x00dev, skb);
1744 1750
1745 usb_fill_bulk_urb(beacon->priv, usb_dev, pipe, 1751 usb_fill_bulk_urb(priv_bcn->urb, usb_dev, pipe,
1746 skb->data, length, rt2500usb_beacondone, beacon); 1752 skb->data, length, rt2500usb_beacondone, entry);
1747 1753
1748 /* 1754 /*
1749 * Second we need to create the guardian byte. 1755 * Second we need to create the guardian byte.
1750 * We only need a single byte, so lets recycle 1756 * We only need a single byte, so lets recycle
1751 * the 'flags' field we are not using for beacons. 1757 * the 'flags' field we are not using for beacons.
1752 */ 1758 */
1753 guardian->flags = 0; 1759 priv_bcn->guardian_data = 0;
1754 usb_fill_bulk_urb(guardian->priv, usb_dev, pipe, 1760 usb_fill_bulk_urb(priv_bcn->guardian_urb, usb_dev, pipe,
1755 &guardian->flags, 1, rt2500usb_beacondone, guardian); 1761 &priv_bcn->guardian_data, 1, rt2500usb_beacondone,
1762 entry);
1756 1763
1757 /* 1764 /*
1758 * Send out the guardian byte. 1765 * Send out the guardian byte.
1759 */ 1766 */
1760 usb_submit_urb(guardian->priv, GFP_ATOMIC); 1767 usb_submit_urb(priv_bcn->guardian_urb, GFP_ATOMIC);
1761 1768
1762 /* 1769 /*
1763 * Enable beacon generation. 1770 * Enable beacon generation.
@@ -1805,12 +1812,42 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1805 .config = rt2500usb_config, 1812 .config = rt2500usb_config,
1806}; 1813};
1807 1814
1815static const struct data_queue_desc rt2500usb_queue_rx = {
1816 .entry_num = RX_ENTRIES,
1817 .data_size = DATA_FRAME_SIZE,
1818 .desc_size = RXD_DESC_SIZE,
1819 .priv_size = sizeof(struct queue_entry_priv_usb_rx),
1820};
1821
1822static const struct data_queue_desc rt2500usb_queue_tx = {
1823 .entry_num = TX_ENTRIES,
1824 .data_size = DATA_FRAME_SIZE,
1825 .desc_size = TXD_DESC_SIZE,
1826 .priv_size = sizeof(struct queue_entry_priv_usb_tx),
1827};
1828
1829static const struct data_queue_desc rt2500usb_queue_bcn = {
1830 .entry_num = BEACON_ENTRIES,
1831 .data_size = MGMT_FRAME_SIZE,
1832 .desc_size = TXD_DESC_SIZE,
1833 .priv_size = sizeof(struct queue_entry_priv_usb_bcn),
1834};
1835
1836static const struct data_queue_desc rt2500usb_queue_atim = {
1837 .entry_num = ATIM_ENTRIES,
1838 .data_size = DATA_FRAME_SIZE,
1839 .desc_size = TXD_DESC_SIZE,
1840 .priv_size = sizeof(struct queue_entry_priv_usb_tx),
1841};
1842
1808static const struct rt2x00_ops rt2500usb_ops = { 1843static const struct rt2x00_ops rt2500usb_ops = {
1809 .name = KBUILD_MODNAME, 1844 .name = KBUILD_MODNAME,
1810 .rxd_size = RXD_DESC_SIZE,
1811 .txd_size = TXD_DESC_SIZE,
1812 .eeprom_size = EEPROM_SIZE, 1845 .eeprom_size = EEPROM_SIZE,
1813 .rf_size = RF_SIZE, 1846 .rf_size = RF_SIZE,
1847 .rx = &rt2500usb_queue_rx,
1848 .tx = &rt2500usb_queue_tx,
1849 .bcn = &rt2500usb_queue_bcn,
1850 .atim = &rt2500usb_queue_atim,
1814 .lib = &rt2500usb_rt2x00_ops, 1851 .lib = &rt2500usb_rt2x00_ops,
1815 .hw = &rt2500usb_mac80211_ops, 1852 .hw = &rt2500usb_mac80211_ops,
1816#ifdef CONFIG_RT2X00_LIB_DEBUGFS 1853#ifdef CONFIG_RT2X00_LIB_DEBUGFS