2 * Copyright 2008 Pavel Machek <pavel@suse.cz>
4 * Distribute under GPLv2.
6 #include <net/mac80211.h>
10 #include "mlmetxrx_f.h"
12 #include "wblinux_f.h"
14 MODULE_AUTHOR("Original by: Jeff Lee<YY_Lee@issc.com.tw> Adapted to 2.6.x by Costantino Leandro (Rxart Desktop) <le_costantino@pixartargentina.com.ar>");
15 MODULE_DESCRIPTION("IS89C35 802.11bg WLAN USB Driver");
16 MODULE_LICENSE("GPL");
17 MODULE_VERSION("0.1");
19 static struct usb_device_id wb35_table[] __devinitdata = {
20 {USB_DEVICE(0x0416, 0x0035)},
21 {USB_DEVICE(0x18E8, 0x6201)},
22 {USB_DEVICE(0x18E8, 0x6206)},
23 {USB_DEVICE(0x18E8, 0x6217)},
24 {USB_DEVICE(0x18E8, 0x6230)},
25 {USB_DEVICE(0x18E8, 0x6233)},
26 {USB_DEVICE(0x1131, 0x2035)},
30 MODULE_DEVICE_TABLE(usb, wb35_table);
32 static struct ieee80211_rate wbsoft_rates[] = {
33 { .bitrate = 10, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
36 static struct ieee80211_channel wbsoft_channels[] = {
37 { .center_freq = 2412},
40 static struct ieee80211_supported_band wbsoft_band_2GHz = {
41 .channels = wbsoft_channels,
42 .n_channels = ARRAY_SIZE(wbsoft_channels),
43 .bitrates = wbsoft_rates,
44 .n_bitrates = ARRAY_SIZE(wbsoft_rates),
49 static int wbsoft_add_interface(struct ieee80211_hw *dev,
50 struct ieee80211_if_init_conf *conf)
52 printk("wbsoft_add interface called\n");
56 static void wbsoft_remove_interface(struct ieee80211_hw *dev,
57 struct ieee80211_if_init_conf *conf)
59 printk("wbsoft_remove interface called\n");
62 static void wbsoft_stop(struct ieee80211_hw *hw)
64 printk(KERN_INFO "%s called\n", __func__);
67 static int wbsoft_get_stats(struct ieee80211_hw *hw,
68 struct ieee80211_low_level_stats *stats)
70 printk(KERN_INFO "%s called\n", __func__);
74 static int wbsoft_get_tx_stats(struct ieee80211_hw *hw,
75 struct ieee80211_tx_queue_stats *stats)
77 printk(KERN_INFO "%s called\n", __func__);
81 static void wbsoft_configure_filter(struct ieee80211_hw *dev,
82 unsigned int changed_flags,
83 unsigned int *total_flags,
84 int mc_count, struct dev_mc_list *mclist)
86 unsigned int bit_nr, new_flags;
92 if (*total_flags & FIF_PROMISC_IN_BSS) {
93 new_flags |= FIF_PROMISC_IN_BSS;
94 mc_filter[1] = mc_filter[0] = ~0;
95 } else if ((*total_flags & FIF_ALLMULTI) || (mc_count > 32)) {
96 new_flags |= FIF_ALLMULTI;
97 mc_filter[1] = mc_filter[0] = ~0;
99 mc_filter[1] = mc_filter[0] = 0;
100 for (i = 0; i < mc_count; i++) {
103 printk("Should call ether_crc here\n");
104 //bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
108 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
109 mclist = mclist->next;
113 dev->flags &= ~IEEE80211_HW_RX_INCLUDES_FCS;
115 *total_flags = new_flags;
118 static int wbsoft_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
120 struct wbsoft_priv *priv = dev->priv;
122 MLMESendFrame(priv, skb->data, skb->len, FRAME_TYPE_802_11_MANAGEMENT);
128 static int wbsoft_start(struct ieee80211_hw *dev)
131 printk("wbsoft_start called\n");
135 static int wbsoft_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
137 struct wbsoft_priv *priv = dev->priv;
140 printk("wbsoft_config called\n");
143 ch.ChanNo = 1; /* Should use channel_num, or something, as that is already pre-translated */
146 hal_set_current_channel(&priv->sHwData, ch);
147 hal_set_beacon_period(&priv->sHwData, conf->beacon_int);
148 // hal_set_cap_info(&priv->sHwData, ?? );
149 // hal_set_ssid(phw_data_t pHwData, u8 * pssid, u8 ssid_len); ??
150 hal_set_accept_broadcast(&priv->sHwData, 1);
151 hal_set_accept_promiscuous(&priv->sHwData, 1);
152 hal_set_accept_multicast(&priv->sHwData, 1);
153 hal_set_accept_beacon(&priv->sHwData, 1);
154 hal_set_radio_mode(&priv->sHwData, 0);
155 //hal_set_antenna_number( phw_data_t pHwData, u8 number )
156 //hal_set_rf_power(phw_data_t pHwData, u8 PowerIndex)
159 // hal_start_bss(&priv->sHwData, WLAN_BSSTYPE_INFRASTRUCTURE); ??
161 //void hal_set_rates(phw_data_t pHwData, u8 * pbss_rates,
162 // u8 length, unsigned char basic_rate_set)
167 static int wbsoft_config_interface(struct ieee80211_hw *dev,
168 struct ieee80211_vif *vif,
169 struct ieee80211_if_conf *conf)
171 printk("wbsoft_config_interface called\n");
175 static u64 wbsoft_get_tsf(struct ieee80211_hw *dev)
177 printk("wbsoft_get_tsf called\n");
181 static const struct ieee80211_ops wbsoft_ops = {
183 .start = wbsoft_start, /* Start can be pretty much empty as we do WbWLanInitialize() during probe? */
185 .add_interface = wbsoft_add_interface,
186 .remove_interface = wbsoft_remove_interface,
187 .config = wbsoft_config,
188 .config_interface = wbsoft_config_interface,
189 .configure_filter = wbsoft_configure_filter,
190 .get_stats = wbsoft_get_stats,
191 .get_tx_stats = wbsoft_get_tx_stats,
192 .get_tsf = wbsoft_get_tsf,
193 // conf_tx: hal_set_cwmin()/hal_set_cwmax;
196 static int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id_table)
199 struct usb_host_interface *interface;
200 struct usb_endpoint_descriptor *endpoint;
202 struct usb_device *udev = interface_to_usbdev(intf);
203 struct wbsoft_priv *priv;
204 struct ieee80211_hw *dev;
209 // 20060630.2 Check the device if it already be opened
210 err = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ),
211 0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN,
212 0x0, 0x400, <mp, 4, HZ*100 );
216 ltmp = cpu_to_le32(ltmp);
217 if (ltmp) { // Is already initialized?
222 dev = ieee80211_alloc_hw(sizeof(*priv), &wbsoft_ops);
228 pWbUsb = &priv->sHwData.WbUsb;
231 interface = intf->cur_altsetting;
232 endpoint = &interface->endpoint[0].desc;
234 if (endpoint[2].wMaxPacketSize == 512) {
235 printk("[w35und] Working on USB 2.0\n");
239 if (!WbWLanInitialize(dev)) {
244 SET_IEEE80211_DEV(dev, &udev->dev);
246 phw_data_t pHwData = &priv->sHwData;
247 unsigned char dev_addr[MAX_ADDR_LEN];
248 hal_get_permanent_address(pHwData, dev_addr);
249 SET_IEEE80211_PERM_ADDR(dev, dev_addr);
252 dev->extra_tx_headroom = 12; /* FIXME */
255 dev->channel_change_time = 1000;
258 dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &wbsoft_band_2GHz;
260 err = ieee80211_register_hw(dev);
264 usb_set_intfdata(intf, priv);
269 ieee80211_free_hw(dev);
275 void packet_came(struct ieee80211_hw *hw, char *pRxBufferAddress, int PacketSize)
278 struct ieee80211_rx_status rx_status = {0};
283 skb = dev_alloc_skb(PacketSize);
285 printk("Not enough memory for packet, FIXME\n");
289 memcpy(skb_put(skb, PacketSize),
295 rx_status.channel = 1;
296 rx_status.freq = 12345;
297 rx_status.phymode = MODE_IEEE80211B;
300 ieee80211_rx_irqsafe(hw, skb, &rx_status);
303 static void wb35_disconnect(struct usb_interface *intf)
305 struct wbsoft_priv *priv = usb_get_intfdata(intf);
309 usb_set_intfdata(intf, NULL);
310 usb_put_dev(interface_to_usbdev(intf));
313 static struct usb_driver wb35_driver = {
315 .id_table = wb35_table,
317 .disconnect = wb35_disconnect,
320 static int __init wb35_init(void)
322 return usb_register(&wb35_driver);
325 static void __exit wb35_exit(void)
327 usb_deregister(&wb35_driver);
330 module_init(wb35_init);
331 module_exit(wb35_exit);