Debian Codegraph @

patches/bcm43xx-injection-linux-2.6.20.patch

raw
1 --- linux/drivers/net/wireless/bcm43xx/bcm43xx_main.c 2007-04-17 16:39:08.000000000 +0200
2 +++ linux-bcm43xx-patch/drivers/net/wireless/bcm43xx/bcm43xx_main.c 2007-04-20 00:09:09.000000000 +0200
3 @@ -104,6 +104,13 @@
4 #endif /* CONFIG_BCM43XX_DEBUG*/
5
6
7 +static ssize_t bcm43xx_inject_nofcs(struct device *dev,
8 + struct device_attribute *attr,
9 + const char *buf,
10 + size_t cnt);
11 +static DEVICE_ATTR(inject_nofcs, 0200,
12 + NULL, bcm43xx_inject_nofcs);
13 +
14 /* If you want to debug with just a single device, enable this,
15 * where the string is the pci device ID (as given by the kernel's
16 * pci_name function) of the device to be used.
17 @@ -3365,6 +3372,8 @@
18 static void bcm43xx_free_board(struct bcm43xx_private *bcm)
19 {
20 bcm43xx_rng_exit(bcm);
21 +
22 + device_remove_file(&bcm->pci_dev->dev, &dev_attr_inject_nofcs);
23 bcm43xx_sysfs_unregister(bcm);
24 bcm43xx_periodic_tasks_delete(bcm);
25
26 @@ -3636,6 +3645,10 @@
27 err = bcm43xx_rng_init(bcm);
28 if (err)
29 goto err_sysfs_unreg;
30 +
31 + err = device_create_file(&bcm->pci_dev->dev, &dev_attr_inject_nofcs);
32 + if (err)
33 + goto err_inject_if;
34 bcm43xx_periodic_tasks_setup(bcm);
35
36 /*FIXME: This should be handled by softmac instead. */
37 @@ -3645,7 +3658,8 @@
38 mutex_unlock(&(bcm)->mutex);
39
40 return err;
41 -
42 +err_inject_if:
43 + device_remove_file(&bcm->pci_dev->dev, &dev_attr_inject_nofcs);
44 err_sysfs_unreg:
45 bcm43xx_sysfs_unregister(bcm);
46 err_wlshutdown:
47 @@ -3892,6 +3906,48 @@
48 return err;
49 }
50
51 +static ssize_t bcm43xx_inject_nofcs(struct device *dev,
52 + struct device_attribute *attr,
53 + const char *buf,
54 + size_t cnt)
55 +{
56 + struct bcm43xx_private *bcm = dev_to_bcm(dev);
57 + struct ieee80211_txb *faketxb;
58 + struct sk_buff *skb;
59 + unsigned long flags;
60 + int err = -ENODEV;
61 +
62 + faketxb = kzalloc(sizeof(struct ieee80211_txb) + sizeof(void *), GFP_KERNEL);
63 + if (!faketxb)
64 + return -ENOMEM;
65 + faketxb->nr_frags = 1;
66 + faketxb->frag_size = cnt;
67 + faketxb->payload_size = cnt;
68 + skb = __dev_alloc_skb(cnt + bcm->ieee->tx_headroom, GFP_KERNEL);
69 + if (!skb) {
70 + kfree(faketxb);
71 + return -ENOMEM;
72 + }
73 + skb_reserve(skb, bcm->ieee->tx_headroom);
74 + memcpy(skb_put(skb, cnt), buf, cnt);
75 + faketxb->fragments[0] = skb;
76 +
77 + spin_lock_irqsave(&bcm->irq_lock, flags);
78 +
79 + if (likely(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED))
80 + err = bcm43xx_tx(bcm, faketxb);
81 +
82 + spin_unlock_irqrestore(&bcm->irq_lock, flags);
83 +
84 + if (unlikely(err)) {
85 + dev_kfree_skb(skb);
86 + kfree(faketxb);
87 + return err;
88 + }
89 +
90 + return cnt;
91 +}
92 +
93 static void bcm43xx_ieee80211_set_chan(struct net_device *net_dev,
94 u8 channel)
95 {