| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /* orinoco.h
 | 
					
						
							| 
									
										
										
										
											2009-01-25 23:08:43 +03:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  |  * Common definitions to all pieces of the various orinoco | 
					
						
							|  |  |  |  * drivers | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef _ORINOCO_H
 | 
					
						
							|  |  |  | #define _ORINOCO_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-07 04:11:02 -04:00
										 |  |  | #define DRIVER_VERSION "0.15"
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-21 23:28:04 +01:00
										 |  |  | #include <linux/interrupt.h>
 | 
					
						
							| 
									
										
										
										
											2008-11-22 10:37:28 +00:00
										 |  |  | #include <linux/suspend.h>
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #include <linux/netdevice.h>
 | 
					
						
							|  |  |  | #include <linux/wireless.h>
 | 
					
						
							| 
									
										
										
										
											2005-09-09 18:43:02 -04:00
										 |  |  | #include <net/iw_handler.h>
 | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:26 +01:00
										 |  |  | #include <net/cfg80211.h>
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "hermes.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* To enable debug messages */ | 
					
						
							| 
									
										
										
										
											2009-01-25 23:08:43 +03:00
										 |  |  | /*#define ORINOCO_DEBUG		3*/ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-25 23:08:43 +03:00
										 |  |  | #define WIRELESS_SPY		/* enable iwspy support */
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-06-19 01:27:51 +02:00
										 |  |  | #define MAX_SCAN_LEN		4096
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-05 21:23:28 +01:00
										 |  |  | #define ORINOCO_SEQ_LEN		8
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #define ORINOCO_MAX_KEY_SIZE	14
 | 
					
						
							|  |  |  | #define ORINOCO_MAX_KEYS	4
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct orinoco_key { | 
					
						
							| 
									
										
										
										
											2005-09-23 04:18:06 -04:00
										 |  |  | 	__le16 len;	/* always stored as little-endian */ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	char data[ORINOCO_MAX_KEY_SIZE]; | 
					
						
							| 
									
										
										
										
											2010-06-02 18:10:09 +00:00
										 |  |  | } __packed; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-21 23:28:02 +01:00
										 |  |  | #define TKIP_KEYLEN	16
 | 
					
						
							|  |  |  | #define MIC_KEYLEN	8
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct orinoco_tkip_key { | 
					
						
							|  |  |  | 	u8 tkip[TKIP_KEYLEN]; | 
					
						
							|  |  |  | 	u8 tx_mic[MIC_KEYLEN]; | 
					
						
							|  |  |  | 	u8 rx_mic[MIC_KEYLEN]; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-05 21:23:28 +01:00
										 |  |  | enum orinoco_alg { | 
					
						
							|  |  |  | 	ORINOCO_ALG_NONE, | 
					
						
							|  |  |  | 	ORINOCO_ALG_WEP, | 
					
						
							|  |  |  | 	ORINOCO_ALG_TKIP | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-13 11:19:57 -04:00
										 |  |  | enum fwtype { | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	FIRMWARE_TYPE_AGERE, | 
					
						
							|  |  |  | 	FIRMWARE_TYPE_INTERSIL, | 
					
						
							|  |  |  | 	FIRMWARE_TYPE_SYMBOL | 
					
						
							| 
									
										
										
										
											2011-07-13 11:19:57 -04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-10-19 12:06:11 +04:00
										 |  |  | struct firmware; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | struct orinoco_private { | 
					
						
							|  |  |  | 	void *card;	/* Pointer to card dependent structure */ | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:54 +01:00
										 |  |  | 	struct device *dev; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	int (*hard_reset)(struct orinoco_private *); | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:54 +01:00
										 |  |  | 	int (*stop_fw)(struct orinoco_private *, int); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:26 +01:00
										 |  |  | 	struct ieee80211_supported_band band; | 
					
						
							|  |  |  | 	struct ieee80211_channel channels[14]; | 
					
						
							|  |  |  | 	u32 cipher_suites[3]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	/* Synchronisation stuff */ | 
					
						
							|  |  |  | 	spinlock_t lock; | 
					
						
							|  |  |  | 	int hw_unavailable; | 
					
						
							|  |  |  | 	struct work_struct reset_work; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-21 23:28:04 +01:00
										 |  |  | 	/* Interrupt tasklets */ | 
					
						
							|  |  |  | 	struct tasklet_struct rx_tasklet; | 
					
						
							|  |  |  | 	struct list_head rx_list; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	/* driver state */ | 
					
						
							|  |  |  | 	int open; | 
					
						
							|  |  |  | 	u16 last_linkstatus; | 
					
						
							| 
									
										
										
										
											2005-06-19 01:27:51 +02:00
										 |  |  | 	struct work_struct join_work; | 
					
						
							| 
									
										
										
										
											2005-06-19 01:27:56 +02:00
										 |  |  | 	struct work_struct wevent_work; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Net device stuff */ | 
					
						
							|  |  |  | 	struct net_device *ndev; | 
					
						
							|  |  |  | 	struct net_device_stats stats; | 
					
						
							|  |  |  | 	struct iw_statistics wstats; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Hardware control variables */ | 
					
						
							| 
									
										
										
										
											2011-07-13 11:19:57 -04:00
										 |  |  | 	struct hermes hw; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	u16 txfid; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Capabilities of the hardware/firmware */ | 
					
						
							| 
									
										
										
										
											2011-07-13 11:19:57 -04:00
										 |  |  | 	enum fwtype firmware_type; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	int ibss_port; | 
					
						
							|  |  |  | 	int nicbuf_size; | 
					
						
							|  |  |  | 	u16 channel_mask; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Boolean capabilities */ | 
					
						
							|  |  |  | 	unsigned int has_ibss:1; | 
					
						
							|  |  |  | 	unsigned int has_port3:1; | 
					
						
							|  |  |  | 	unsigned int has_wep:1; | 
					
						
							|  |  |  | 	unsigned int has_big_wep:1; | 
					
						
							|  |  |  | 	unsigned int has_mwo:1; | 
					
						
							|  |  |  | 	unsigned int has_pm:1; | 
					
						
							|  |  |  | 	unsigned int has_preamble:1; | 
					
						
							|  |  |  | 	unsigned int has_sensitivity:1; | 
					
						
							| 
									
										
										
										
											2005-06-19 01:27:56 +02:00
										 |  |  | 	unsigned int has_hostscan:1; | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:56 +01:00
										 |  |  | 	unsigned int has_alt_txcntl:1; | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:58 +01:00
										 |  |  | 	unsigned int has_ext_scan:1; | 
					
						
							| 
									
										
										
										
											2008-08-21 23:28:02 +01:00
										 |  |  | 	unsigned int has_wpa:1; | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:54 +01:00
										 |  |  | 	unsigned int do_fw_download:1; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	unsigned int broken_disableport:1; | 
					
						
							| 
									
										
										
										
											2005-06-19 01:28:06 +02:00
										 |  |  | 	unsigned int broken_monitor:1; | 
					
						
							| 
									
										
										
										
											2009-08-05 21:23:27 +01:00
										 |  |  | 	unsigned int prefer_port3:1; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Configuration paramaters */ | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:32 +01:00
										 |  |  | 	enum nl80211_iftype iw_mode; | 
					
						
							| 
									
										
										
										
											2009-08-05 21:23:28 +01:00
										 |  |  | 	enum orinoco_alg encode_alg; | 
					
						
							|  |  |  | 	u16 wep_restrict, tx_key; | 
					
						
							| 
									
										
										
										
											2009-08-05 21:23:32 +01:00
										 |  |  | 	struct key_params keys[ORINOCO_MAX_KEYS]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	int bitratemode; | 
					
						
							| 
									
										
										
										
											2011-07-13 11:19:57 -04:00
										 |  |  | 	char nick[IW_ESSID_MAX_SIZE + 1]; | 
					
						
							|  |  |  | 	char desired_essid[IW_ESSID_MAX_SIZE + 1]; | 
					
						
							| 
									
										
										
										
											2005-06-19 01:27:51 +02:00
										 |  |  | 	char desired_bssid[ETH_ALEN]; | 
					
						
							|  |  |  | 	int bssid_fixed; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	u16 frag_thresh, mwo_robust; | 
					
						
							|  |  |  | 	u16 channel; | 
					
						
							|  |  |  | 	u16 ap_density, rts_thresh; | 
					
						
							|  |  |  | 	u16 pm_on, pm_mcast, pm_period, pm_timeout; | 
					
						
							|  |  |  | 	u16 preamble; | 
					
						
							| 
									
										
										
										
											2010-04-19 08:16:21 +01:00
										 |  |  | 	u16 short_retry_limit, long_retry_limit; | 
					
						
							|  |  |  | 	u16 retry_lifetime; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #ifdef WIRELESS_SPY
 | 
					
						
							| 
									
										
										
										
											2009-01-25 23:08:43 +03:00
										 |  |  | 	struct iw_spy_data spy_data; /* iwspy support */ | 
					
						
							| 
									
										
										
										
											2005-09-09 18:43:02 -04:00
										 |  |  | 	struct iw_public_data	wireless_data; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Configuration dependent variables */ | 
					
						
							|  |  |  | 	int port_type, createibss; | 
					
						
							|  |  |  | 	int promiscuous, mc_count; | 
					
						
							| 
									
										
										
										
											2005-06-19 01:27:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Scanning support */ | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:33 +01:00
										 |  |  | 	struct cfg80211_scan_request *scan_request; | 
					
						
							|  |  |  | 	struct work_struct process_scan; | 
					
						
							|  |  |  | 	struct list_head scan_list; | 
					
						
							|  |  |  | 	spinlock_t scan_lock; /* protects the scan list */ | 
					
						
							| 
									
										
										
										
											2008-08-21 23:28:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* WPA support */ | 
					
						
							|  |  |  | 	u8 *wpa_ie; | 
					
						
							|  |  |  | 	int wpa_ie_len; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-21 23:28:05 +01:00
										 |  |  | 	struct crypto_hash *rx_tfm_mic; | 
					
						
							|  |  |  | 	struct crypto_hash *tx_tfm_mic; | 
					
						
							| 
									
										
										
										
											2008-08-21 23:28:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	unsigned int wpa_enabled:1; | 
					
						
							|  |  |  | 	unsigned int tkip_cm_active:1; | 
					
						
							|  |  |  | 	unsigned int key_mgmt:3; | 
					
						
							| 
									
										
										
										
											2008-10-19 12:06:11 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-28 23:09:09 +03:00
										 |  |  | #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
 | 
					
						
							| 
									
										
										
										
											2008-11-22 10:37:26 +00:00
										 |  |  | 	/* Cached in memory firmware to use during ->resume. */ | 
					
						
							|  |  |  | 	const struct firmware *cached_pri_fw; | 
					
						
							| 
									
										
										
										
											2008-10-19 12:06:11 +04:00
										 |  |  | 	const struct firmware *cached_fw; | 
					
						
							| 
									
										
										
										
											2009-02-28 23:09:09 +03:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2008-11-22 10:37:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	struct notifier_block pm_notifier; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef ORINOCO_DEBUG
 | 
					
						
							|  |  |  | extern int orinoco_debug; | 
					
						
							| 
									
										
										
										
											2009-01-25 23:08:43 +03:00
										 |  |  | #define DEBUG(n, args...) do { \
 | 
					
						
							|  |  |  | 	if (orinoco_debug > (n)) \ | 
					
						
							|  |  |  | 		printk(KERN_DEBUG args); \ | 
					
						
							|  |  |  | } while (0) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #else
 | 
					
						
							|  |  |  | #define DEBUG(n, args...) do { } while (0)
 | 
					
						
							|  |  |  | #endif	/* ORINOCO_DEBUG */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************/ | 
					
						
							|  |  |  | /* Exported prototypes                                              */ | 
					
						
							|  |  |  | /********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-23 11:37:59 -07:00
										 |  |  | struct orinoco_private *alloc_orinocodev(int sizeof_card, struct device *device, | 
					
						
							|  |  |  | 					 int (*hard_reset)(struct orinoco_private *), | 
					
						
							|  |  |  | 					 int (*stop_fw)(struct orinoco_private *, int)); | 
					
						
							|  |  |  | void free_orinocodev(struct orinoco_private *priv); | 
					
						
							|  |  |  | int orinoco_init(struct orinoco_private *priv); | 
					
						
							|  |  |  | int orinoco_if_add(struct orinoco_private *priv, unsigned long base_addr, | 
					
						
							|  |  |  | 		   unsigned int irq, const struct net_device_ops *ops); | 
					
						
							|  |  |  | void orinoco_if_del(struct orinoco_private *priv); | 
					
						
							|  |  |  | int orinoco_up(struct orinoco_private *priv); | 
					
						
							|  |  |  | void orinoco_down(struct orinoco_private *priv); | 
					
						
							|  |  |  | irqreturn_t orinoco_interrupt(int irq, void *dev_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void __orinoco_ev_info(struct net_device *dev, struct hermes *hw); | 
					
						
							|  |  |  | void __orinoco_ev_rx(struct net_device *dev, struct hermes *hw); | 
					
						
							| 
									
										
										
										
											2010-05-01 14:05:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-04 22:54:41 +01:00
										 |  |  | int orinoco_process_xmit_skb(struct sk_buff *skb, | 
					
						
							|  |  |  | 			     struct net_device *dev, | 
					
						
							|  |  |  | 			     struct orinoco_private *priv, | 
					
						
							|  |  |  | 			     int *tx_control, | 
					
						
							|  |  |  | 			     u8 *mic); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-01 14:05:39 +01:00
										 |  |  | /* Common ndo functions exported for reuse by orinoco_usb */ | 
					
						
							|  |  |  | int orinoco_open(struct net_device *dev); | 
					
						
							|  |  |  | int orinoco_stop(struct net_device *dev); | 
					
						
							|  |  |  | struct net_device_stats *orinoco_get_stats(struct net_device *dev); | 
					
						
							|  |  |  | void orinoco_set_multicast_list(struct net_device *dev); | 
					
						
							|  |  |  | int orinoco_change_mtu(struct net_device *dev, int new_mtu); | 
					
						
							|  |  |  | void orinoco_tx_timeout(struct net_device *dev); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /********************************************************************/ | 
					
						
							|  |  |  | /* Locking and synchronization functions                            */ | 
					
						
							|  |  |  | /********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-15 20:45:00 -04:00
										 |  |  | static inline int orinoco_lock(struct orinoco_private *priv, | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 			       unsigned long *flags) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-05-01 14:05:40 +01:00
										 |  |  | 	priv->hw.ops->lock_irqsave(&priv->lock, flags); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	if (priv->hw_unavailable) { | 
					
						
							|  |  |  | 		DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n", | 
					
						
							|  |  |  | 		       priv->ndev); | 
					
						
							| 
									
										
										
										
											2010-05-01 14:05:40 +01:00
										 |  |  | 		priv->hw.ops->unlock_irqrestore(&priv->lock, flags); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 		return -EBUSY; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-15 20:45:00 -04:00
										 |  |  | static inline void orinoco_unlock(struct orinoco_private *priv, | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 				  unsigned long *flags) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-05-01 14:05:40 +01:00
										 |  |  | 	priv->hw.ops->unlock_irqrestore(&priv->lock, flags); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline void orinoco_lock_irq(struct orinoco_private *priv) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	priv->hw.ops->lock_irq(&priv->lock); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline void orinoco_unlock_irq(struct orinoco_private *priv) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	priv->hw.ops->unlock_irq(&priv->lock); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:26 +01:00
										 |  |  | /*** Navigate from net_device to orinoco_private ***/ | 
					
						
							|  |  |  | static inline struct orinoco_private *ndev_priv(struct net_device *dev) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct wireless_dev *wdev = netdev_priv(dev); | 
					
						
							|  |  |  | 	return wdev_priv(wdev); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif /* _ORINOCO_H */
 |