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

📄 orinoco.c

📁 pcmcia source code
💻 C
📖 第 1 页 / 共 5 页
字号:
/* orinoco.c 0.11b	- (formerly known as dldwd_cs.c and orinoco_cs.c) * * A driver for Hermes or Prism 2 chipset based PCMCIA wireless * adaptors, with Lucent/Agere, Intersil or Symbol firmware. * * Copyright (C) 2000 David Gibson, Linuxcare Australia <hermes@gibson.dropbear.id.au> *	With some help from : * Copyright (C) 2001 Jean Tourrilhes, HP Labs <jt@hpl.hp.com> * Copyright (C) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org> * * Based on dummy_cs.c 1.27 2000/06/12 21:27:25 * * Portions based on wvlan_cs.c 1.0.6, Copyright Andreas Neuhaus <andy@fasta.fh-dortmund.de> *      http://www.fasta.fh-dortmund.de/users/andy/wvlan/ * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License * at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and * limitations under the License. * * The initial developer of the original code is David A. Hinds * <dahinds@users.sourceforge.net>.  Portions created by David * A. Hinds are Copyright (C) 1999 David A. Hinds.  All Rights * Reserved. * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License version 2 (the "GPL"), in * which case the provisions of the GPL are applicable instead of the * above.  If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the MPL, indicate your decision by * deleting the provisions above and replace them with the notice and * other provisions required by the GPL.  If you do not delete the * provisions above, a recipient may use your version of this file * under either the MPL or the GPL.  *//* * v0.01 -> v0.02 - 21/3/2001 - Jean II *	o Allow to use regular ethX device name instead of dldwdX *	o Warning on IBSS with ESSID=any for firmware 6.06 *	o Put proper range.throughput values (optimistic) *	o IWSPY support (IOCTL and stat gather in Rx path) *	o Allow setting frequency in Ad-Hoc mode *	o Disable WEP setting if !has_wep to work on old firmware *	o Fix txpower range *	o Start adding support for Samsung/Compaq firmware * * v0.02 -> v0.03 - 23/3/2001 - Jean II *	o Start adding Symbol support - need to check all that *	o Fix Prism2/Symbol WEP to accept 128 bits keys *	o Add Symbol WEP (add authentication type) *	o Add Prism2/Symbol rate *	o Add PM timeout (holdover duration) *	o Enable "iwconfig eth0 key off" and friends (toggle flags) *	o Enable "iwconfig eth0 power unicast/all" (toggle flags) *	o Try with an intel card. It report firmware 1.01, behave like *	  an antiquated firmware, however on windows it says 2.00. Yuck ! *	o Workaround firmware bug in allocate buffer (Intel 1.01) *	o Finish external renaming to orinoco... *	o Testing with various Wavelan firmwares * * v0.03 -> v0.04 - 30/3/2001 - Jean II *	o Update to Wireless 11 -> add retry limit/lifetime support *	o Tested with a D-Link DWL 650 card, fill in firmware support *	o Warning on Vcc mismatch (D-Link 3.3v card in Lucent 5v only slot) *	o Fixed the Prims2 WEP bugs that I introduced in v0.03 :-( *	  It work on D-Link *only* after a tcpdump. Weird... *	  And still doesn't work on Intel card. Grrrr... *	o Update the mode after a setport3 *	o Add preamble setting for Symbol cards (not yet enabled) *	o Don't complain as much about Symbol cards... * * v0.04 -> v0.04b - 22/4/2001 - David Gibson *      o Removed the 'eth' parameter - always use ethXX as the *        interface name instead of dldwdXX.  The other was racy *        anyway. *	o Clean up RID definitions in hermes.h, other cleanups * * v0.04b -> v0.04c - 24/4/2001 - Jean II *	o Tim Hurley <timster@seiki.bliztech.com> reported a D-Link card *	  with vendor 02 and firmware 0.08. Added in the capabilities... *	o Tested Lucent firmware 7.28, everything works... * * v0.04c -> v0.05 - 3/5/2001 - Benjamin Herrenschmidt *	o Spin-off Pcmcia code. This file is renamed orinoco.c, *	  and orinoco_cs.c now contains only the Pcmcia specific stuff *	o Add Airport driver support on top of orinoco.c (see airport.c) * * v0.05 -> v0.05a - 4/5/2001 - Jean II *	o Revert to old Pcmcia code to fix breakage of Ben's changes... * * v0.05a -> v0.05b - 4/5/2001 - Jean II *	o add module parameter 'ignore_cis_vcc' for D-Link @ 5V *	o D-Link firmware doesn't support multicast. We just print a few *	  error messages, but otherwise everything works... *	o For David : set/getport3 works fine, just upgrade iwpriv... * * v0.05b -> v0.05c - 5/5/2001 - Benjamin Herrenschmidt *	o Adapt airport.c to latest changes in orinoco.c *	o Remove deferred power enabling code * * v0.05c -> v0.05d - 5/5/2001 - Jean II *	o Workaround to SNAP decapsulate frame from LinkSys AP *	  original patch from : Dong Liu <dliu@research.bell-labs.com> *	  (note : the memcmp bug was mine - fixed) *	o Remove set_retry stuff, no firmware support it (bloat--). * * v0.05d -> v0.06 - 25/5/2001 - Jean II *		Original patch from "Hong Lin" <alin@redhat.com>, *		"Ian Kinner" <ikinner@redhat.com> *		and "David Smith" <dsmith@redhat.com> *	o Init of priv->tx_rate_ctrl in firmware specific section. *	o Prism2/Symbol rate, upto should be 0xF and not 0x15. Doh ! *	o Spectrum card always need cor_reset (for every reset) *	o Fix cor_reset to not loose bit 7 in the register *	o flush_stale_links to remove zombie Pcmcia instances *	o Ack previous hermes event before reset *		Me (with my little hands) *	o Allow orinoco.c to call cor_reset via priv->card_reset_handler *	o Add priv->need_card_reset to toggle this feature *	o Fix various buglets when setting WEP in Symbol firmware *	  Now, encryption is fully functional on Symbol cards. Youpi ! * * v0.06 -> v0.06b - 25/5/2001 - Jean II *	o IBSS on Symbol use port_mode = 4. Please don't ask... * * v0.06b -> v0.06c - 29/5/2001 - Jean II *	o Show first spy address in /proc/net/wireless for IBSS mode as well * * v0.06c -> v0.06d - 6/7/2001 - David Gibson *      o Change a bunch of KERN_INFO messages to KERN_DEBUG, as per Linus' *        wishes to reduce the number of unecessary messages. *	o Removed bogus message on CRC error. *	o Merged fixeds for v0.08 Prism 2 firmware from William Waghorn *	  <willwaghorn@yahoo.co.uk> *	o Slight cleanup/re-arrangement of firmware detection code. * * v0.06d -> v0.06e - 1/8/2001 - David Gibson *	o Removed some redundant global initializers (orinoco_cs.c). *	o Added some module metadataa * * v0.06e -> v0.06f - 14/8/2001 - David Gibson *	o Wording fix to license *	o Added a 'use_alternate_encaps' module parameter for APs which need an *	  oui of 00:00:00.  We really need a better way of handling this, but *	  the module flag is better than nothing for now. * * v0.06f -> v0.07 - 20/8/2001 - David Gibson *	o Removed BAP error retries from hermes_bap_seek().  For Tx we now *	  let the upper layers handle the retry, we retry explicitly in the *	  Rx path, but don't make as much noise about it. *	o Firmware detection cleanups. * * v0.07 -> v0.07a - 1/10/3001 - Jean II *	o Add code to read Symbol firmware revision, inspired by latest code *	  in Spectrum24 by Lee John Keyser-Allen - Thanks Lee ! *	o Thanks to Jared Valentine <hidden@xmission.com> for "providing" me *	  a 3Com card with a recent firmware, fill out Symbol firmware *	  capabilities of latest rev (2.20), as well as older Symbol cards. *	o Disable Power Management in newer Symbol firmware, the API  *	  has changed (documentation needed). * * v0.07a -> v0.08 - 3/10/2001 - David Gibson *	o Fixed a possible buffer overrun found by the Stanford checker (in *	  dldwd_ioctl_setiwencode()).  Can only be called by root anyway, so not *	  a big problem. *	o Turned has_big_wep on for Intersil cards.  That's not true for all of *	  them but we should at least let the capable ones try. *	o Wait for BUSY to clear at the beginning of hermes_bap_seek().  I *	  realised that my assumption that the driver's serialization *	  would prevent the BAP being busy on entry was possibly false, because *	  things other than seeks may make the BAP busy. *	o Use "alternate" (oui 00:00:00) encapsulation by default. *	  Setting use_old_encaps will mimic the old behaviour, but I think we *	  will be able to eliminate this. *	o Don't try to make __initdata const (the version string).  This can't *	  work because of the way the __initdata sectioning works. *	o Added MODULE_LICENSE tags. *	o Support for PLX (transparent PCMCIA->PCI brdge) cards. *	o Changed to using the new type-facist min/max. * * v0.08 -> v0.08a - 9/10/2001 - David Gibson *	o Inserted some missing acknowledgements/info into the Changelog. *	o Fixed some bugs in the normalisation of signel level reporting. *	o Fixed bad bug in WEP key handling on Intersil and Symbol firmware, *	  which led to an instant crash on big-endian machines. * * v0.08a -> v0.08b - 20/11/2001 - David Gibson *	o Lots of cleanup and bugfixes in orinoco_plx.c *	o Cleanup to handling of Tx rate setting. *	o Removed support for old encapsulation method. *	o Removed old "dldwd" names. *	o Split RID constants into a new file hermes_rid.h *	o Renamed RID constants to match linux-wlan-ng and prism2.o *	o Bugfixes in hermes.c *	o Poke the PLX's INTCSR register, so it actually starts *	  generating interrupts.  These cards might actually work now. *	o Update to wireless extensions v12 (Jean II) *	o Support for tallies and inquire command (Jean II) *	o Airport updates for newer PPC kernels (BenH) * * v0.08b -> v0.09 - 21/12/2001 - David Gibson *	o Some new PCI IDs for PLX cards. *	o Removed broken attempt to do ALLMULTI reception.  Just use *	  promiscuous mode instead *	o Preliminary work for list-AP (Jean II) *	o Airport updates from (BenH) *	o Eliminated racy hw_ready stuff *	o Fixed generation of fake events in irq handler.  This should *	  finally kill the EIO problems (Jean II & dgibson) *	o Fixed breakage of bitrate set/get on Agere firmware (Jean II) * * v0.09 -> v0.09a - 2/1/2002 - David Gibson *	o Fixed stupid mistake in multicast list handling, triggering *	  a BUG() * * v0.09a -> v0.09b - 16/1/2002 - David Gibson *	o Fixed even stupider mistake in new interrupt handling, which *	  seriously broke things on big-endian machines. *	o Removed a bunch of redundant includes and exports. *	o Removed a redundant MOD_{INC,DEC}_USE_COUNT pair in airport.c *	o Don't attempt to do hardware level multicast reception on *	  Intersil firmware, just go promisc instead. *	o Typo fixed in hermes_issue_cmd() *	o Eliminated WIRELESS_SPY #ifdefs *	o Status code reported on Tx exceptions *	o Moved netif_wake_queue() from ALLOC interrupts to TX and TXEXC *	  interrupts, which should fix the timeouts we're seeing. * * v0.09b -> v0.10 - 25 Feb 2002 - David Gibson *	o Removed nested structures used for header parsing, so the *	  driver should now work without hackery on ARM *	o Fix for WEP handling on Intersil (Hawk Newton) *	o Eliminated the /proc/hermes/ethXX/regs debugging file.  It *	  was never very useful. *	o Make Rx errors less noisy. * * v0.10 -> v0.11 - 5 Apr Mar 2002 - David Gibson *	o Laid the groundwork in hermes.[ch] for devices which map *	  into PCI memory space rather than IO space. *	o Fixed bug in multicast handling (cleared multicast list when *	  leaving promiscuous mode). *	o Relegated Tx error messages to debug. *	o Cleaned up / corrected handling of allocation lengths. *	o Set OWNSSID in IBSS mode for WinXP interoperability (jimc). *	o Change to using alloc_etherdev() for structure allocations.  *	o Check for and drop undersized packets. *	o Fixed a race in stopping/waking the queue.  This should fix *	  the timeout problems (Pavel Roskin) *	o Reverted to netif_wake_queue() on the ALLOC event. *	o Fixes for recent Symbol firmwares which lack AP density *	  (Pavel Roskin). * * v0.11 -> v0.11b - 29 Apr 2002 - David Gibson *	o Handle different register spacing, necessary for Prism 2.5 *	  PCI adaptors (Steve Hill). *	o Cleaned up initialization of card structures in orinoco_cs *	  and airport.  Removed card->priv field. *	o Make response structure optional for hermes_docmd_wait() *	  Pavel Roskin) *	o Added PCI id for Nortel emobility to orinoco_plx.c. *	o Cleanup to handling of Symbol's allocation bug. (Pavel Roskin) *	o Cleanups to firmware capability detection. *	o Arrange for orinoco_pci.c to override firmware detection. *	  We should be able to support the PCI Intersil cards now. *	o Cleanup handling of reset_cor and hard_reset (Pavel Roskin). *	o Remove erroneous use of USER_BAP in the TxExc handler (Jouni *	  Malinen). *	o Makefile changes for better integration into David Hinds *	  pcmcia-cs package. * * v0.11a -> v0.11b - 1 May 2002 - David Gibson *	o Better error reporting in orinoco_plx_init_one() *	o Fixed multiple bad kfree() bugs introduced by the *	  alloc_orinocodev() changes. * * TODO *	o New wireless extensions API *	o Handle de-encapsulation within network layer, provide 802.11 *	  headers *	o Fix possible races in SPY handling. *	o Disconnect wireless extensions from fundamental configuration. * *	o Convert /proc debugging stuff to seqfile *	o Use multiple Tx buffers *//* Notes on locking: * * The basic principle of operation is that everything except the * interrupt handler is serialized through a single spinlock in the * struct orinoco_private structure, using orinoco_lock() and * orinoco_unlock() (which in turn use spin_lock_bh() and * spin_unlock_bh()). * * The kernel's IRQ handling stuff ensures that the interrupt handler * does not re-enter itself. The interrupt handler is written such * that everything it does is safe without a lock: chiefly this means * that the Rx path uses one of the Hermes chipset's BAPs while * everything else uses the other. * * Actually, strictly speaking, the updating of the statistics from * the interrupt handler isn't safe without a lock.  However the worst * that can happen is that we perturb the packet/byte counts slightly. * We could fix this to use atomic types, but it's probably not worth * it. * * The big exception is that that we don't want the irq handler * running when we actually reset or shut down the card, because * strange things might happen (probably the worst would be one packet * of garbage, but you can't be too careful). For this we use * __orinoco_stop_irqs() which will set a flag to disable the interrupt * handler, and wait for any outstanding instances of the handler to * complete. THIS WILL LOSE INTERRUPTS! so it shouldn't be used except * for resets, where losing a few interrupts is acceptable. */#include <linux/config.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/init.h>#include <linux/sched.h>#include <linux/ptrace.h>#include <linux/slab.h>#include <linux/string.h>#include <linux/timer.h>#include <linux/ioport.h>#include <asm/uaccess.h>#include <asm/io.h>#include <asm/system.h>#include <linux/proc_fs.h>#include <linux/seq_file.h>#include <linux/netdevice.h>#include <linux/if_arp.h>#include <linux/etherdevice.h>#include <linux/wireless.h>#include <linux/list.h>#include "hermes.h"#include "hermes_rid.h"#include "orinoco.h"#include "ieee802_11.h"/* Wireless extensions backwards compatibility */#ifndef SIOCIWFIRSTPRIV#define SIOCIWFIRSTPRIV		SIOCDEVPRIVATE#endif /* SIOCIWFIRSTPRIV *//* We do this this way to avoid ifdefs in the actual code */#ifdef WIRELESS_SPY#define SPY_NUMBER(priv)	(priv->spy_number)#else#define SPY_NUMBER(priv)	0#endif /* WIRELESS_SPY */static char version[] __initdata = "orinoco.c 0.11b (David Gibson <hermes@gibson.dropbear.id.au> and others)";MODULE_AUTHOR("David Gibson <hermes@gibson.dropbear.id.au>");MODULE_DESCRIPTION("Driver for Lucent Orinoco, Prism II based and similar wireless cards");#ifdef MODULE_LICENSEMODULE_LICENSE("Dual MPL/GPL");#endif/* Level of debugging. Used in the macros in orinoco.h */#ifdef ORINOCO_DEBUGint orinoco_debug = ORINOCO_DEBUG;MODULE_PARM(orinoco_debug, "i");EXPORT_SYMBOL(orinoco_debug);#endif#define ORINOCO_MIN_MTU		256#define ORINOCO_MAX_MTU		(IEEE802_11_DATA_LEN - ENCAPS_OVERHEAD)#define SYMBOL_MAX_VER_LEN	(14)#define USER_BAP		0#define IRQ_BAP			1#define MAX_IRQLOOPS_PER_IRQ	10#define MAX_IRQLOOPS_PER_JIFFY	(20000/HZ)	/* Based on a guestimate of how many events the						   device can legitimately generate */#define SMALL_KEY_SIZE		5#define LARGE_KEY_SIZE		13#define TX_NICBUF_SIZE_BUG	1585		/* Bug in Symbol firmware */#define DUMMY_FID		0xFFFF/*#define MAX_MULTICAST(priv)	(priv->firmware_type == FIRMWARE_TYPE_AGERE ? \  HERMES_MAX_MULTICAST : 0)*/#define MAX_MULTICAST(priv)	(HERMES_MAX_MULTICAST)/********************************************************************//* Data tables                                                      *//********************************************************************//* The frequency of each channel in MHz */const long channel_frequency[] = {	2412, 2417, 2422, 2427, 2432, 2437, 2442,	2447, 2452, 2457, 2462, 2467, 2472, 2484};#define NUM_CHANNELS ( sizeof(channel_frequency) / sizeof(channel_frequency[0]) )/* This tables gives the actual meanings of the bitrate IDs returned by the firmware. */struct {	int bitrate; /* in 100s of kilbits */	int automatic;	u16 agere_txratectrl;	u16 intersil_txratectrl;} bitrate_table[] = {	{110, 1,  3, 15}, /* Entry 0 is the default */	{10,  0,  1,  1},	{10,  1,  1,  1},	{20,  0,  2,  2},	{20,  1,  6,  3},	{55, 0,  4,  4},	{55, 1,  7,  7},	{110, 0,  5,  8},};#define BITRATE_TABLE_SIZE (sizeof(bitrate_table) / sizeof(bitrate_table[0]))struct header_struct {	/* 802.3 */

⌨️ 快捷键说明

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