⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rt2500usb.c

📁 linux内核源码
💻 C
📖 第 1 页 / 共 4 页
字号:
	{ 2,  0x00022020, 0x00080ca2, 0x00060111, 0x00000a1b },	{ 3,  0x00022020, 0x00080ca6, 0x00060111, 0x00000a1b },	{ 4,  0x00022020, 0x00080caa, 0x00060111, 0x00000a1b },	{ 5,  0x00022020, 0x00080cae, 0x00060111, 0x00000a1b },	{ 6,  0x00022020, 0x00080cb2, 0x00060111, 0x00000a1b },	{ 7,  0x00022020, 0x00080cb6, 0x00060111, 0x00000a1b },	{ 8,  0x00022020, 0x00080cba, 0x00060111, 0x00000a1b },	{ 9,  0x00022020, 0x00080cbe, 0x00060111, 0x00000a1b },	{ 10, 0x00022020, 0x00080d02, 0x00060111, 0x00000a1b },	{ 11, 0x00022020, 0x00080d06, 0x00060111, 0x00000a1b },	{ 12, 0x00022020, 0x00080d0a, 0x00060111, 0x00000a1b },	{ 13, 0x00022020, 0x00080d0e, 0x00060111, 0x00000a1b },	{ 14, 0x00022020, 0x00080d1a, 0x00060111, 0x00000a03 },};/* * RF value list for RF2525e * Supports: 2.4 GHz */static const struct rf_channel rf_vals_bg_2525e[] = {	{ 1,  0x00022010, 0x0000089a, 0x00060111, 0x00000e1b },	{ 2,  0x00022010, 0x0000089e, 0x00060111, 0x00000e07 },	{ 3,  0x00022010, 0x0000089e, 0x00060111, 0x00000e1b },	{ 4,  0x00022010, 0x000008a2, 0x00060111, 0x00000e07 },	{ 5,  0x00022010, 0x000008a2, 0x00060111, 0x00000e1b },	{ 6,  0x00022010, 0x000008a6, 0x00060111, 0x00000e07 },	{ 7,  0x00022010, 0x000008a6, 0x00060111, 0x00000e1b },	{ 8,  0x00022010, 0x000008aa, 0x00060111, 0x00000e07 },	{ 9,  0x00022010, 0x000008aa, 0x00060111, 0x00000e1b },	{ 10, 0x00022010, 0x000008ae, 0x00060111, 0x00000e07 },	{ 11, 0x00022010, 0x000008ae, 0x00060111, 0x00000e1b },	{ 12, 0x00022010, 0x000008b2, 0x00060111, 0x00000e07 },	{ 13, 0x00022010, 0x000008b2, 0x00060111, 0x00000e1b },	{ 14, 0x00022010, 0x000008b6, 0x00060111, 0x00000e23 },};/* * RF value list for RF5222 * Supports: 2.4 GHz & 5.2 GHz */static const struct rf_channel rf_vals_5222[] = {	{ 1,  0x00022020, 0x00001136, 0x00000101, 0x00000a0b },	{ 2,  0x00022020, 0x0000113a, 0x00000101, 0x00000a0b },	{ 3,  0x00022020, 0x0000113e, 0x00000101, 0x00000a0b },	{ 4,  0x00022020, 0x00001182, 0x00000101, 0x00000a0b },	{ 5,  0x00022020, 0x00001186, 0x00000101, 0x00000a0b },	{ 6,  0x00022020, 0x0000118a, 0x00000101, 0x00000a0b },	{ 7,  0x00022020, 0x0000118e, 0x00000101, 0x00000a0b },	{ 8,  0x00022020, 0x00001192, 0x00000101, 0x00000a0b },	{ 9,  0x00022020, 0x00001196, 0x00000101, 0x00000a0b },	{ 10, 0x00022020, 0x0000119a, 0x00000101, 0x00000a0b },	{ 11, 0x00022020, 0x0000119e, 0x00000101, 0x00000a0b },	{ 12, 0x00022020, 0x000011a2, 0x00000101, 0x00000a0b },	{ 13, 0x00022020, 0x000011a6, 0x00000101, 0x00000a0b },	{ 14, 0x00022020, 0x000011ae, 0x00000101, 0x00000a1b },	/* 802.11 UNI / HyperLan 2 */	{ 36, 0x00022010, 0x00018896, 0x00000101, 0x00000a1f },	{ 40, 0x00022010, 0x0001889a, 0x00000101, 0x00000a1f },	{ 44, 0x00022010, 0x0001889e, 0x00000101, 0x00000a1f },	{ 48, 0x00022010, 0x000188a2, 0x00000101, 0x00000a1f },	{ 52, 0x00022010, 0x000188a6, 0x00000101, 0x00000a1f },	{ 66, 0x00022010, 0x000188aa, 0x00000101, 0x00000a1f },	{ 60, 0x00022010, 0x000188ae, 0x00000101, 0x00000a1f },	{ 64, 0x00022010, 0x000188b2, 0x00000101, 0x00000a1f },	/* 802.11 HyperLan 2 */	{ 100, 0x00022010, 0x00008802, 0x00000101, 0x00000a0f },	{ 104, 0x00022010, 0x00008806, 0x00000101, 0x00000a0f },	{ 108, 0x00022010, 0x0000880a, 0x00000101, 0x00000a0f },	{ 112, 0x00022010, 0x0000880e, 0x00000101, 0x00000a0f },	{ 116, 0x00022010, 0x00008812, 0x00000101, 0x00000a0f },	{ 120, 0x00022010, 0x00008816, 0x00000101, 0x00000a0f },	{ 124, 0x00022010, 0x0000881a, 0x00000101, 0x00000a0f },	{ 128, 0x00022010, 0x0000881e, 0x00000101, 0x00000a0f },	{ 132, 0x00022010, 0x00008822, 0x00000101, 0x00000a0f },	{ 136, 0x00022010, 0x00008826, 0x00000101, 0x00000a0f },	/* 802.11 UNII */	{ 140, 0x00022010, 0x0000882a, 0x00000101, 0x00000a0f },	{ 149, 0x00022020, 0x000090a6, 0x00000101, 0x00000a07 },	{ 153, 0x00022020, 0x000090ae, 0x00000101, 0x00000a07 },	{ 157, 0x00022020, 0x000090b6, 0x00000101, 0x00000a07 },	{ 161, 0x00022020, 0x000090be, 0x00000101, 0x00000a07 },};static void rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev){	struct hw_mode_spec *spec = &rt2x00dev->spec;	u8 *txpower;	unsigned int i;	/*	 * Initialize all hw fields.	 */	rt2x00dev->hw->flags =	    IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE |	    IEEE80211_HW_RX_INCLUDES_FCS |	    IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;	rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE;	rt2x00dev->hw->max_signal = MAX_SIGNAL;	rt2x00dev->hw->max_rssi = MAX_RX_SSI;	rt2x00dev->hw->queues = 2;	SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_usb(rt2x00dev)->dev);	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,				rt2x00_eeprom_addr(rt2x00dev,						   EEPROM_MAC_ADDR_0));	/*	 * Convert tx_power array in eeprom.	 */	txpower = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);	for (i = 0; i < 14; i++)		txpower[i] = TXPOWER_FROM_DEV(txpower[i]);	/*	 * Initialize hw_mode information.	 */	spec->num_modes = 2;	spec->num_rates = 12;	spec->tx_power_a = NULL;	spec->tx_power_bg = txpower;	spec->tx_power_default = DEFAULT_TXPOWER;	if (rt2x00_rf(&rt2x00dev->chip, RF2522)) {		spec->num_channels = ARRAY_SIZE(rf_vals_bg_2522);		spec->channels = rf_vals_bg_2522;	} else if (rt2x00_rf(&rt2x00dev->chip, RF2523)) {		spec->num_channels = ARRAY_SIZE(rf_vals_bg_2523);		spec->channels = rf_vals_bg_2523;	} else if (rt2x00_rf(&rt2x00dev->chip, RF2524)) {		spec->num_channels = ARRAY_SIZE(rf_vals_bg_2524);		spec->channels = rf_vals_bg_2524;	} else if (rt2x00_rf(&rt2x00dev->chip, RF2525)) {		spec->num_channels = ARRAY_SIZE(rf_vals_bg_2525);		spec->channels = rf_vals_bg_2525;	} else if (rt2x00_rf(&rt2x00dev->chip, RF2525E)) {		spec->num_channels = ARRAY_SIZE(rf_vals_bg_2525e);		spec->channels = rf_vals_bg_2525e;	} else if (rt2x00_rf(&rt2x00dev->chip, RF5222)) {		spec->num_channels = ARRAY_SIZE(rf_vals_5222);		spec->channels = rf_vals_5222;		spec->num_modes = 3;	}}static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev){	int retval;	/*	 * Allocate eeprom data.	 */	retval = rt2500usb_validate_eeprom(rt2x00dev);	if (retval)		return retval;	retval = rt2500usb_init_eeprom(rt2x00dev);	if (retval)		return retval;	/*	 * Initialize hw specifications.	 */	rt2500usb_probe_hw_mode(rt2x00dev);	/*	 * This device requires the beacon ring	 */	__set_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags);	/*	 * Set the rssi offset.	 */	rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET;	return 0;}/* * IEEE80211 stack callback functions. */static void rt2500usb_configure_filter(struct ieee80211_hw *hw,				       unsigned int changed_flags,				       unsigned int *total_flags,				       int mc_count,				       struct dev_addr_list *mc_list){	struct rt2x00_dev *rt2x00dev = hw->priv;	struct interface *intf = &rt2x00dev->interface;	u16 reg;	/*	 * Mask off any flags we are going to ignore from	 * the total_flags field.	 */	*total_flags &=	    FIF_ALLMULTI |	    FIF_FCSFAIL |	    FIF_PLCPFAIL |	    FIF_CONTROL |	    FIF_OTHER_BSS |	    FIF_PROMISC_IN_BSS;	/*	 * Apply some rules to the filters:	 * - Some filters imply different filters to be set.	 * - Some things we can't filter out at all.	 * - Some filters are set based on interface type.	 */	if (mc_count)		*total_flags |= FIF_ALLMULTI;	if (*total_flags & FIF_OTHER_BSS ||	    *total_flags & FIF_PROMISC_IN_BSS)		*total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;	if (is_interface_type(intf, IEEE80211_IF_TYPE_AP))		*total_flags |= FIF_PROMISC_IN_BSS;	/*	 * Check if there is any work left for us.	 */	if (intf->filter == *total_flags)		return;	intf->filter = *total_flags;	/*	 * When in atomic context, reschedule and let rt2x00lib	 * call this function again.	 */	if (in_atomic()) {		queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->filter_work);		return;	}	/*	 * Start configuration steps.	 * Note that the version error will always be dropped	 * and broadcast frames will always be accepted since	 * there is no filter for it at this time.	 */	rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);	rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CRC,			   !(*total_flags & FIF_FCSFAIL));	rt2x00_set_field16(&reg, TXRX_CSR2_DROP_PHYSICAL,			   !(*total_flags & FIF_PLCPFAIL));	rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CONTROL,			   !(*total_flags & FIF_CONTROL));	rt2x00_set_field16(&reg, TXRX_CSR2_DROP_NOT_TO_ME,			   !(*total_flags & FIF_PROMISC_IN_BSS));	rt2x00_set_field16(&reg, TXRX_CSR2_DROP_TODS,			   !(*total_flags & FIF_PROMISC_IN_BSS));	rt2x00_set_field16(&reg, TXRX_CSR2_DROP_VERSION_ERROR, 1);	rt2x00_set_field16(&reg, TXRX_CSR2_DROP_MULTICAST,			   !(*total_flags & FIF_ALLMULTI));	rt2x00_set_field16(&reg, TXRX_CSR2_DROP_BROADCAST, 0);	rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);}static int rt2500usb_beacon_update(struct ieee80211_hw *hw,				   struct sk_buff *skb,				   struct ieee80211_tx_control *control){	struct rt2x00_dev *rt2x00dev = hw->priv;	struct usb_device *usb_dev =	    interface_to_usbdev(rt2x00dev_usb(rt2x00dev));	struct data_ring *ring =	    rt2x00lib_get_ring(rt2x00dev, IEEE80211_TX_QUEUE_BEACON);	struct data_entry *beacon;	struct data_entry *guardian;	int pipe = usb_sndbulkpipe(usb_dev, 1);	int length;	/*	 * Just in case the ieee80211 doesn't set this,	 * but we need this queue set for the descriptor	 * initialization.	 */	control->queue = IEEE80211_TX_QUEUE_BEACON;	/*	 * Obtain 2 entries, one for the guardian byte,	 * the second for the actual beacon.	 */	guardian = rt2x00_get_data_entry(ring);	rt2x00_ring_index_inc(ring);	beacon = rt2x00_get_data_entry(ring);	/*	 * First we create the beacon.	 */	skb_push(skb, ring->desc_size);	memset(skb->data, 0, ring->desc_size);	rt2x00lib_write_tx_desc(rt2x00dev, (struct data_desc *)skb->data,				(struct ieee80211_hdr *)(skb->data +							 ring->desc_size),				skb->len - ring->desc_size, control);	length = rt2500usb_get_tx_data_len(rt2x00dev, skb);	usb_fill_bulk_urb(beacon->priv, usb_dev, pipe,			  skb->data, length, rt2500usb_beacondone, beacon);	beacon->skb = skb;	/*	 * Second we need to create the guardian byte.	 * We only need a single byte, so lets recycle	 * the 'flags' field we are not using for beacons.	 */	guardian->flags = 0;	usb_fill_bulk_urb(guardian->priv, usb_dev, pipe,			  &guardian->flags, 1, rt2500usb_beacondone, guardian);	/*	 * Send out the guardian byte.	 */	usb_submit_urb(guardian->priv, GFP_ATOMIC);	/*	 * Enable beacon generation.	 */	rt2500usb_kick_tx_queue(rt2x00dev, IEEE80211_TX_QUEUE_BEACON);	return 0;}static const struct ieee80211_ops rt2500usb_mac80211_ops = {	.tx			= rt2x00mac_tx,	.start			= rt2x00mac_start,	.stop			= rt2x00mac_stop,	.add_interface		= rt2x00mac_add_interface,	.remove_interface	= rt2x00mac_remove_interface,	.config			= rt2x00mac_config,	.config_interface	= rt2x00mac_config_interface,	.configure_filter	= rt2500usb_configure_filter,	.get_stats		= rt2x00mac_get_stats,	.erp_ie_changed		= rt2x00mac_erp_ie_changed,	.conf_tx		= rt2x00mac_conf_tx,	.get_tx_stats		= rt2x00mac_get_tx_stats,	.beacon_update		= rt2500usb_beacon_update,};static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {	.probe_hw		= rt2500usb_probe_hw,	.initialize		= rt2x00usb_initialize,	.uninitialize		= rt2x00usb_uninitialize,	.set_device_state	= rt2500usb_set_device_state,	.link_stats		= rt2500usb_link_stats,	.reset_tuner		= rt2500usb_reset_tuner,	.link_tuner		= rt2500usb_link_tuner,	.write_tx_desc		= rt2500usb_write_tx_desc,	.write_tx_data		= rt2x00usb_write_tx_data,	.get_tx_data_len	= rt2500usb_get_tx_data_len,	.kick_tx_queue		= rt2500usb_kick_tx_queue,	.fill_rxdone		= rt2500usb_fill_rxdone,	.config_mac_addr	= rt2500usb_config_mac_addr,	.config_bssid		= rt2500usb_config_bssid,	.config_type		= rt2500usb_config_type,	.config_preamble	= rt2500usb_config_preamble,	.config			= rt2500usb_config,};static const struct rt2x00_ops rt2500usb_ops = {	.name		= DRV_NAME,	.rxd_size	= RXD_DESC_SIZE,	.txd_size	= TXD_DESC_SIZE,	.eeprom_size	= EEPROM_SIZE,	.rf_size	= RF_SIZE,	.lib		= &rt2500usb_rt2x00_ops,	.hw		= &rt2500usb_mac80211_ops,#ifdef CONFIG_RT2X00_LIB_DEBUGFS	.debugfs	= &rt2500usb_rt2x00debug,#endif /* CONFIG_RT2X00_LIB_DEBUGFS */};/* * rt2500usb module information. */static struct usb_device_id rt2500usb_device_table[] = {	/* ASUS */	{ USB_DEVICE(0x0b05, 0x1706), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x0b05, 0x1707), USB_DEVICE_DATA(&rt2500usb_ops) },	/* Belkin */	{ USB_DEVICE(0x050d, 0x7050), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x050d, 0x7051), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x050d, 0x705a), USB_DEVICE_DATA(&rt2500usb_ops) },	/* Cisco Systems */	{ USB_DEVICE(0x13b1, 0x000d), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x13b1, 0x0011), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x13b1, 0x001a), USB_DEVICE_DATA(&rt2500usb_ops) },	/* Conceptronic */	{ USB_DEVICE(0x14b2, 0x3c02), USB_DEVICE_DATA(&rt2500usb_ops) },	/* D-LINK */	{ USB_DEVICE(0x2001, 0x3c00), USB_DEVICE_DATA(&rt2500usb_ops) },	/* Gigabyte */	{ USB_DEVICE(0x1044, 0x8001), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x1044, 0x8007), USB_DEVICE_DATA(&rt2500usb_ops) },	/* Hercules */	{ USB_DEVICE(0x06f8, 0xe000), USB_DEVICE_DATA(&rt2500usb_ops) },	/* Melco */	{ USB_DEVICE(0x0411, 0x0066), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x0411, 0x0067), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x0411, 0x008b), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x0411, 0x0097), USB_DEVICE_DATA(&rt2500usb_ops) },	/* MSI */	{ USB_DEVICE(0x0db0, 0x6861), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x0db0, 0x6865), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x0db0, 0x6869), USB_DEVICE_DATA(&rt2500usb_ops) },	/* Ralink */	{ USB_DEVICE(0x148f, 0x1706), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x148f, 0x2570), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x148f, 0x2573), USB_DEVICE_DATA(&rt2500usb_ops) },	{ USB_DEVICE(0x148f, 0x9020), USB_DEVICE_DATA(&rt2500usb_ops) },	/* Siemens */	{ USB_DEVICE(0x0681, 0x3c06), USB_DEVICE_DATA(&rt2500usb_ops) },	/* SMC */	{ USB_DEVICE(0x0707, 0xee13), USB_DEVICE_DATA(&rt2500usb_ops) },	/* Spairon */	{ USB_DEVICE(0x114b, 0x0110), USB_DEVICE_DATA(&rt2500usb_ops) },	/* Trust */	{ USB_DEVICE(0x0eb0, 0x9020), USB_DEVICE_DATA(&rt2500usb_ops) },	/* Zinwell */	{ USB_DEVICE(0x5a57, 0x0260), USB_DEVICE_DATA(&rt2500usb_ops) },	{ 0, }};MODULE_AUTHOR(DRV_PROJECT);MODULE_VERSION(DRV_VERSION);MODULE_DESCRIPTION("Ralink RT2500 USB Wireless LAN driver.");MODULE_SUPPORTED_DEVICE("Ralink RT2570 USB chipset based cards");MODULE_DEVICE_TABLE(usb, rt2500usb_device_table);MODULE_LICENSE("GPL");static struct usb_driver rt2500usb_driver = {	.name		= DRV_NAME,	.id_table	= rt2500usb_device_table,	.probe		= rt2x00usb_probe,	.disconnect	= rt2x00usb_disconnect,	.suspend	= rt2x00usb_suspend,	.resume		= rt2x00usb_resume,};static int __init rt2500usb_init(void){	return usb_register(&rt2500usb_driver);}static void __exit rt2500usb_exit(void){	usb_deregister(&rt2500usb_driver);}module_init(rt2500usb_init);module_exit(rt2500usb_exit);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -