aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorChristian Lamparter <chunkeey@web.de>2008-12-14 09:05:42 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-12-19 15:23:19 -0500
commit0a5ec96ad68516582023a877aceff9db7636d141 (patch)
tree8a8346aabff7306d2b13a36d756f14000e629595 /drivers/net/wireless
parent69ba3e5d74a467a64248cd90ccafb524b1fddcb5 (diff)
p54: remove free_on_tx parameter
This patch simplifies the tx code a bit and will be necessary for the upcoming stlc45xx<->p54 port. In detail: we no longer have to tell all back-end drivers directly, if we want to free a frame right after it was send to the firmware, or if we do it in the library callback later. Signed-off-by: Christian Lamparter <chunkeey@web.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/p54/p54.h10
-rw-r--r--drivers/net/wireless/p54/p54common.c26
-rw-r--r--drivers/net/wireless/p54/p54common.h3
-rw-r--r--drivers/net/wireless/p54/p54pci.c12
-rw-r--r--drivers/net/wireless/p54/p54usb.c37
5 files changed, 37 insertions, 51 deletions
diff --git a/drivers/net/wireless/p54/p54.h b/drivers/net/wireless/p54/p54.h
index e0a68815a471..ab79e32f0b27 100644
--- a/drivers/net/wireless/p54/p54.h
+++ b/drivers/net/wireless/p54/p54.h
@@ -44,6 +44,9 @@ enum p54_control_frame_types {
44 P54_CONTROL_TYPE_BT_OPTIONS = 35 44 P54_CONTROL_TYPE_BT_OPTIONS = 35
45}; 45};
46 46
47#define P54_HDR_FLAG_CONTROL BIT(15)
48#define P54_HDR_FLAG_CONTROL_OPSET (BIT(15) + BIT(0))
49
47struct p54_hdr { 50struct p54_hdr {
48 __le16 flags; 51 __le16 flags;
49 __le16 len; 52 __le16 len;
@@ -54,6 +57,10 @@ struct p54_hdr {
54 u8 data[0]; 57 u8 data[0];
55} __attribute__ ((packed)); 58} __attribute__ ((packed));
56 59
60#define FREE_AFTER_TX(skb) \
61 ((((struct p54_hdr *) ((struct sk_buff *) skb)->data)-> \
62 flags) == cpu_to_le16(P54_HDR_FLAG_CONTROL_OPSET))
63
57struct p54_edcf_queue_param { 64struct p54_edcf_queue_param {
58 __le16 aifs; 65 __le16 aifs;
59 __le16 cwmin; 66 __le16 cwmin;
@@ -82,8 +89,7 @@ struct p54_common {
82 u32 rx_start; 89 u32 rx_start;
83 u32 rx_end; 90 u32 rx_end;
84 struct sk_buff_head tx_queue; 91 struct sk_buff_head tx_queue;
85 void (*tx)(struct ieee80211_hw *dev, struct sk_buff *skb, 92 void (*tx)(struct ieee80211_hw *dev, struct sk_buff *skb);
86 int free_on_tx);
87 int (*open)(struct ieee80211_hw *dev); 93 int (*open)(struct ieee80211_hw *dev);
88 void (*stop)(struct ieee80211_hw *dev); 94 void (*stop)(struct ieee80211_hw *dev);
89 int mode; 95 int mode;
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
index 05eb677aa3e1..82354b974a04 100644
--- a/drivers/net/wireless/p54/p54common.c
+++ b/drivers/net/wireless/p54/p54common.c
@@ -683,7 +683,7 @@ void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb)
683 freed = priv->rx_end - last_addr; 683 freed = priv->rx_end - last_addr;
684 __skb_unlink(skb, &priv->tx_queue); 684 __skb_unlink(skb, &priv->tx_queue);
685 spin_unlock_irqrestore(&priv->tx_queue.lock, flags); 685 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
686 kfree_skb(skb); 686 dev_kfree_skb_any(skb);
687 687
688 if (freed >= priv->headroom + sizeof(struct p54_hdr) + 48 + 688 if (freed >= priv->headroom + sizeof(struct p54_hdr) + 48 +
689 IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom) 689 IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom)
@@ -1088,7 +1088,7 @@ int p54_read_eeprom(struct ieee80211_hw *dev)
1088 eeprom_hdr->v2.magic2 = 0xf; 1088 eeprom_hdr->v2.magic2 = 0xf;
1089 memcpy(eeprom_hdr->v2.magic, (const char *)"LOCK", 4); 1089 memcpy(eeprom_hdr->v2.magic, (const char *)"LOCK", 4);
1090 } 1090 }
1091 priv->tx(dev, skb, 0); 1091 priv->tx(dev, skb);
1092 1092
1093 if (!wait_for_completion_interruptible_timeout(&priv->eeprom_comp, HZ)) { 1093 if (!wait_for_completion_interruptible_timeout(&priv->eeprom_comp, HZ)) {
1094 printk(KERN_ERR "%s: device does not respond!\n", 1094 printk(KERN_ERR "%s: device does not respond!\n",
@@ -1129,7 +1129,7 @@ static int p54_set_tim(struct ieee80211_hw *dev, struct ieee80211_sta *sta,
1129 tim = (struct p54_tim *) skb_put(skb, sizeof(*tim)); 1129 tim = (struct p54_tim *) skb_put(skb, sizeof(*tim));
1130 tim->count = 1; 1130 tim->count = 1;
1131 tim->entry[0] = cpu_to_le16(set ? (sta->aid | 0x8000) : sta->aid); 1131 tim->entry[0] = cpu_to_le16(set ? (sta->aid | 0x8000) : sta->aid);
1132 priv->tx(dev, skb, 1); 1132 priv->tx(dev, skb);
1133 return 0; 1133 return 0;
1134} 1134}
1135 1135
@@ -1147,7 +1147,7 @@ static int p54_sta_unlock(struct ieee80211_hw *dev, u8 *addr)
1147 1147
1148 sta = (struct p54_sta_unlock *)skb_put(skb, sizeof(*sta)); 1148 sta = (struct p54_sta_unlock *)skb_put(skb, sizeof(*sta));
1149 memcpy(sta->addr, addr, ETH_ALEN); 1149 memcpy(sta->addr, addr, ETH_ALEN);
1150 priv->tx(dev, skb, 1); 1150 priv->tx(dev, skb);
1151 return 0; 1151 return 0;
1152} 1152}
1153 1153
@@ -1190,7 +1190,7 @@ static int p54_tx_cancel(struct ieee80211_hw *dev, struct sk_buff *entry)
1190 hdr = (void *)entry->data; 1190 hdr = (void *)entry->data;
1191 cancel = (struct p54_txcancel *)skb_put(skb, sizeof(*cancel)); 1191 cancel = (struct p54_txcancel *)skb_put(skb, sizeof(*cancel));
1192 cancel->req_id = hdr->req_id; 1192 cancel->req_id = hdr->req_id;
1193 priv->tx(dev, skb, 1); 1193 priv->tx(dev, skb);
1194 return 0; 1194 return 0;
1195} 1195}
1196 1196
@@ -1419,7 +1419,7 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
1419 /* modifies skb->cb and with it info, so must be last! */ 1419 /* modifies skb->cb and with it info, so must be last! */
1420 if (unlikely(p54_assign_address(dev, skb, hdr, skb->len + tim_len))) 1420 if (unlikely(p54_assign_address(dev, skb, hdr, skb->len + tim_len)))
1421 goto err; 1421 goto err;
1422 priv->tx(dev, skb, 0); 1422 priv->tx(dev, skb);
1423 1423
1424 queue_delayed_work(dev->workqueue, &priv->work, 1424 queue_delayed_work(dev->workqueue, &priv->work,
1425 msecs_to_jiffies(P54_TX_FRAME_LIFETIME)); 1425 msecs_to_jiffies(P54_TX_FRAME_LIFETIME));
@@ -1498,7 +1498,7 @@ static int p54_setup_mac(struct ieee80211_hw *dev)
1498 setup->v2.lpf_bandwidth = cpu_to_le16(65535); 1498 setup->v2.lpf_bandwidth = cpu_to_le16(65535);
1499 setup->v2.osc_start_delay = cpu_to_le16(65535); 1499 setup->v2.osc_start_delay = cpu_to_le16(65535);
1500 } 1500 }
1501 priv->tx(dev, skb, 1); 1501 priv->tx(dev, skb);
1502 return 0; 1502 return 0;
1503} 1503}
1504 1504
@@ -1579,7 +1579,7 @@ static int p54_scan(struct ieee80211_hw *dev, u16 mode, u16 dwell)
1579 chan->v2.basic_rate_mask = cpu_to_le32(priv->basic_rate_mask); 1579 chan->v2.basic_rate_mask = cpu_to_le32(priv->basic_rate_mask);
1580 memset(chan->v2.rts_rates, 0, 8); 1580 memset(chan->v2.rts_rates, 0, 8);
1581 } 1581 }
1582 priv->tx(dev, skb, 1); 1582 priv->tx(dev, skb);
1583 return 0; 1583 return 0;
1584 1584
1585 err: 1585 err:
@@ -1605,7 +1605,7 @@ static int p54_set_leds(struct ieee80211_hw *dev, int mode, int link, int act)
1605 led->led_permanent = cpu_to_le16(link); 1605 led->led_permanent = cpu_to_le16(link);
1606 led->led_temporary = cpu_to_le16(act); 1606 led->led_temporary = cpu_to_le16(act);
1607 led->duration = cpu_to_le16(1000); 1607 led->duration = cpu_to_le16(1000);
1608 priv->tx(dev, skb, 1); 1608 priv->tx(dev, skb);
1609 return 0; 1609 return 0;
1610} 1610}
1611 1611
@@ -1645,7 +1645,7 @@ static int p54_set_edcf(struct ieee80211_hw *dev)
1645 edcf->flags = 0; 1645 edcf->flags = 0;
1646 memset(edcf->mapping, 0, sizeof(edcf->mapping)); 1646 memset(edcf->mapping, 0, sizeof(edcf->mapping));
1647 memcpy(edcf->queue, priv->qos_params, sizeof(edcf->queue)); 1647 memcpy(edcf->queue, priv->qos_params, sizeof(edcf->queue));
1648 priv->tx(dev, skb, 1); 1648 priv->tx(dev, skb);
1649 return 0; 1649 return 0;
1650} 1650}
1651 1651
@@ -1936,7 +1936,7 @@ static int p54_init_xbow_synth(struct ieee80211_hw *dev)
1936 xbow->magic2 = cpu_to_le16(0x2); 1936 xbow->magic2 = cpu_to_le16(0x2);
1937 xbow->freq = cpu_to_le16(5390); 1937 xbow->freq = cpu_to_le16(5390);
1938 memset(xbow->padding, 0, sizeof(xbow->padding)); 1938 memset(xbow->padding, 0, sizeof(xbow->padding));
1939 priv->tx(dev, skb, 1); 1939 priv->tx(dev, skb);
1940 return 0; 1940 return 0;
1941} 1941}
1942 1942
@@ -1962,7 +1962,7 @@ static void p54_work(struct work_struct *work)
1962 if (!skb) 1962 if (!skb)
1963 return ; 1963 return ;
1964 1964
1965 priv->tx(dev, skb, 0); 1965 priv->tx(dev, skb);
1966} 1966}
1967 1967
1968static int p54_get_stats(struct ieee80211_hw *dev, 1968static int p54_get_stats(struct ieee80211_hw *dev,
@@ -2094,7 +2094,7 @@ static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
2094 [NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY]), 8); 2094 [NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY]), 8);
2095 } 2095 }
2096 2096
2097 priv->tx(dev, skb, 1); 2097 priv->tx(dev, skb);
2098 mutex_unlock(&priv->conf_mutex); 2098 mutex_unlock(&priv->conf_mutex);
2099 return 0; 2099 return 0;
2100} 2100}
diff --git a/drivers/net/wireless/p54/p54common.h b/drivers/net/wireless/p54/p54common.h
index 6c824e40f3ba..f5729de83fe1 100644
--- a/drivers/net/wireless/p54/p54common.h
+++ b/drivers/net/wireless/p54/p54common.h
@@ -84,9 +84,6 @@ struct bootrec_desc {
84#define BR_CODE_END_OF_BRA 0xFF0000FF 84#define BR_CODE_END_OF_BRA 0xFF0000FF
85#define LEGACY_BR_CODE_END_OF_BRA 0xFFFFFFFF 85#define LEGACY_BR_CODE_END_OF_BRA 0xFFFFFFFF
86 86
87#define P54_HDR_FLAG_CONTROL BIT(15)
88#define P54_HDR_FLAG_CONTROL_OPSET (BIT(15) + BIT(0))
89
90#define P54_HDR_FLAG_DATA_ALIGN BIT(14) 87#define P54_HDR_FLAG_DATA_ALIGN BIT(14)
91#define P54_HDR_FLAG_DATA_OUT_PROMISC BIT(0) 88#define P54_HDR_FLAG_DATA_OUT_PROMISC BIT(0)
92#define P54_HDR_FLAG_DATA_OUT_TIMESTAMP BIT(1) 89#define P54_HDR_FLAG_DATA_OUT_TIMESTAMP BIT(1)
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c
index c28220e401b9..aa367a0ddc49 100644
--- a/drivers/net/wireless/p54/p54pci.c
+++ b/drivers/net/wireless/p54/p54pci.c
@@ -227,7 +227,9 @@ static void p54p_check_tx_ring(struct ieee80211_hw *dev, u32 *index,
227 227
228 while (i != idx) { 228 while (i != idx) {
229 desc = &ring[i]; 229 desc = &ring[i];
230 p54_free_skb(dev, tx_buf[i]); 230 if (tx_buf[i])
231 if (FREE_AFTER_TX((struct sk_buff *) tx_buf[i]))
232 p54_free_skb(dev, tx_buf[i]);
231 tx_buf[i] = NULL; 233 tx_buf[i] = NULL;
232 234
233 pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr), 235 pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr),
@@ -298,8 +300,7 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id)
298 return reg ? IRQ_HANDLED : IRQ_NONE; 300 return reg ? IRQ_HANDLED : IRQ_NONE;
299} 301}
300 302
301static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb, 303static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
302 int free_on_tx)
303{ 304{
304 struct p54p_priv *priv = dev->priv; 305 struct p54p_priv *priv = dev->priv;
305 struct p54p_ring_control *ring_control = priv->ring_control; 306 struct p54p_ring_control *ring_control = priv->ring_control;
@@ -314,6 +315,7 @@ static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
314 idx = le32_to_cpu(ring_control->host_idx[1]); 315 idx = le32_to_cpu(ring_control->host_idx[1]);
315 i = idx % ARRAY_SIZE(ring_control->tx_data); 316 i = idx % ARRAY_SIZE(ring_control->tx_data);
316 317
318 priv->tx_buf_data[i] = skb;
317 mapping = pci_map_single(priv->pdev, skb->data, skb->len, 319 mapping = pci_map_single(priv->pdev, skb->data, skb->len,
318 PCI_DMA_TODEVICE); 320 PCI_DMA_TODEVICE);
319 desc = &ring_control->tx_data[i]; 321 desc = &ring_control->tx_data[i];
@@ -324,10 +326,6 @@ static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
324 326
325 wmb(); 327 wmb();
326 ring_control->host_idx[1] = cpu_to_le32(idx + 1); 328 ring_control->host_idx[1] = cpu_to_le32(idx + 1);
327
328 if (free_on_tx)
329 priv->tx_buf_data[i] = skb;
330
331 spin_unlock_irqrestore(&priv->lock, flags); 329 spin_unlock_irqrestore(&priv->lock, flags);
332 330
333 P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_UPDATE)); 331 P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_UPDATE));
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
index c2789e53b984..17f89c7eb098 100644
--- a/drivers/net/wireless/p54/p54usb.c
+++ b/drivers/net/wireless/p54/p54usb.c
@@ -138,22 +138,16 @@ static void p54u_rx_cb(struct urb *urb)
138 } 138 }
139} 139}
140 140
141static void p54u_tx_reuse_skb_cb(struct urb *urb) 141static void p54u_tx_cb(struct urb *urb)
142{
143 struct sk_buff *skb = urb->context;
144 struct p54u_priv *priv = (struct p54u_priv *)((struct ieee80211_hw *)
145 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0)))->priv;
146
147 skb_pull(skb, priv->common.tx_hdr_len);
148}
149
150static void p54u_tx_free_skb_cb(struct urb *urb)
151{ 142{
152 struct sk_buff *skb = urb->context; 143 struct sk_buff *skb = urb->context;
153 struct ieee80211_hw *dev = (struct ieee80211_hw *) 144 struct ieee80211_hw *dev = (struct ieee80211_hw *)
154 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0)); 145 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
146 struct p54u_priv *priv = dev->priv;
155 147
156 p54_free_skb(dev, skb); 148 skb_pull(skb, priv->common.tx_hdr_len);
149 if (FREE_AFTER_TX(skb))
150 p54_free_skb(dev, skb);
157} 151}
158 152
159static void p54u_tx_dummy_cb(struct urb *urb) { } 153static void p54u_tx_dummy_cb(struct urb *urb) { }
@@ -213,8 +207,7 @@ static int p54u_init_urbs(struct ieee80211_hw *dev)
213 return ret; 207 return ret;
214} 208}
215 209
216static void p54u_tx_3887(struct ieee80211_hw *dev, struct sk_buff *skb, 210static void p54u_tx_3887(struct ieee80211_hw *dev, struct sk_buff *skb)
217 int free_on_tx)
218{ 211{
219 struct p54u_priv *priv = dev->priv; 212 struct p54u_priv *priv = dev->priv;
220 struct urb *addr_urb, *data_urb; 213 struct urb *addr_urb, *data_urb;
@@ -236,9 +229,7 @@ static void p54u_tx_3887(struct ieee80211_hw *dev, struct sk_buff *skb,
236 p54u_tx_dummy_cb, dev); 229 p54u_tx_dummy_cb, dev);
237 usb_fill_bulk_urb(data_urb, priv->udev, 230 usb_fill_bulk_urb(data_urb, priv->udev,
238 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA), 231 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
239 skb->data, skb->len, 232 skb->data, skb->len, p54u_tx_cb, skb);
240 free_on_tx ? p54u_tx_free_skb_cb :
241 p54u_tx_reuse_skb_cb, skb);
242 233
243 usb_anchor_urb(addr_urb, &priv->submitted); 234 usb_anchor_urb(addr_urb, &priv->submitted);
244 err = usb_submit_urb(addr_urb, GFP_ATOMIC); 235 err = usb_submit_urb(addr_urb, GFP_ATOMIC);
@@ -273,8 +264,7 @@ static __le32 p54u_lm87_chksum(const __le32 *data, size_t length)
273 return cpu_to_le32(chk); 264 return cpu_to_le32(chk);
274} 265}
275 266
276static void p54u_tx_lm87(struct ieee80211_hw *dev, struct sk_buff *skb, 267static void p54u_tx_lm87(struct ieee80211_hw *dev, struct sk_buff *skb)
277 int free_on_tx)
278{ 268{
279 struct p54u_priv *priv = dev->priv; 269 struct p54u_priv *priv = dev->priv;
280 struct urb *data_urb; 270 struct urb *data_urb;
@@ -293,9 +283,7 @@ static void p54u_tx_lm87(struct ieee80211_hw *dev, struct sk_buff *skb,
293 283
294 usb_fill_bulk_urb(data_urb, priv->udev, 284 usb_fill_bulk_urb(data_urb, priv->udev,
295 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA), 285 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
296 skb->data, skb->len, 286 skb->data, skb->len, p54u_tx_cb, skb);
297 free_on_tx ? p54u_tx_free_skb_cb :
298 p54u_tx_reuse_skb_cb, skb);
299 287
300 usb_anchor_urb(data_urb, &priv->submitted); 288 usb_anchor_urb(data_urb, &priv->submitted);
301 if (usb_submit_urb(data_urb, GFP_ATOMIC)) { 289 if (usb_submit_urb(data_urb, GFP_ATOMIC)) {
@@ -306,8 +294,7 @@ static void p54u_tx_lm87(struct ieee80211_hw *dev, struct sk_buff *skb,
306 usb_free_urb(data_urb); 294 usb_free_urb(data_urb);
307} 295}
308 296
309static void p54u_tx_net2280(struct ieee80211_hw *dev, struct sk_buff *skb, 297static void p54u_tx_net2280(struct ieee80211_hw *dev, struct sk_buff *skb)
310 int free_on_tx)
311{ 298{
312 struct p54u_priv *priv = dev->priv; 299 struct p54u_priv *priv = dev->priv;
313 struct urb *int_urb, *data_urb; 300 struct urb *int_urb, *data_urb;
@@ -354,9 +341,7 @@ static void p54u_tx_net2280(struct ieee80211_hw *dev, struct sk_buff *skb,
354 341
355 usb_fill_bulk_urb(data_urb, priv->udev, 342 usb_fill_bulk_urb(data_urb, priv->udev,
356 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA), 343 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
357 skb->data, skb->len, 344 skb->data, skb->len, p54u_tx_cb, skb);
358 free_on_tx ? p54u_tx_free_skb_cb :
359 p54u_tx_reuse_skb_cb, skb);
360 345
361 usb_anchor_urb(int_urb, &priv->submitted); 346 usb_anchor_urb(int_urb, &priv->submitted);
362 err = usb_submit_urb(int_urb, GFP_ATOMIC); 347 err = usb_submit_urb(int_urb, GFP_ATOMIC);