brintos

brintos / linux-shallow public Read only

0
0
Text · 4.1 KiB · 9a322a6 Raw
152 lines · c
1/*2 * Copyright (c) 2006 Damien Bergamini <damien.bergamini@free.fr>3 * Copyright (c) 2006 Sam Leffler, Errno Consulting4 * Copyright (c) 2007 Christoph Hellwig <hch@lst.de>5 * Copyright (c) 2008-2009 Weongyo Jeong <weongyo@freebsd.org>6 * Copyright (c) 2012 Pontus Fuchs <pontus.fuchs@gmail.com>7 *8 * Permission to use, copy, modify, and/or distribute this software for any9 * purpose with or without fee is hereby granted, provided that the above10 * copyright notice and this permission notice appear in all copies.11 *12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.19 */20 21#define AR5523_FLAG_PRE_FIRMWARE	(1 << 0)22#define AR5523_FLAG_ABG			(1 << 1)23 24#define AR5523_FIRMWARE_FILE	"ar5523.bin"25 26#define AR5523_CMD_TX_PIPE	0x0127#define	AR5523_DATA_TX_PIPE	0x0228#define	AR5523_CMD_RX_PIPE	0x8129#define	AR5523_DATA_RX_PIPE	0x8230 31#define ar5523_cmd_tx_pipe(dev) \32	usb_sndbulkpipe((dev), AR5523_CMD_TX_PIPE)33#define ar5523_data_tx_pipe(dev) \34	usb_sndbulkpipe((dev), AR5523_DATA_TX_PIPE)35#define ar5523_cmd_rx_pipe(dev) \36	usb_rcvbulkpipe((dev), AR5523_CMD_RX_PIPE)37#define ar5523_data_rx_pipe(dev) \38	usb_rcvbulkpipe((dev), AR5523_DATA_RX_PIPE)39 40#define	AR5523_DATA_TIMEOUT	1000041#define	AR5523_CMD_TIMEOUT	100042 43#define AR5523_TX_DATA_COUNT		844#define AR5523_TX_DATA_RESTART_COUNT	245#define AR5523_RX_DATA_COUNT		1646#define AR5523_RX_DATA_REFILL_COUNT	847 48#define AR5523_CMD_ID	149#define AR5523_DATA_ID	250 51#define AR5523_TX_WD_TIMEOUT	(HZ * 2)52#define AR5523_FLUSH_TIMEOUT	(HZ * 3)53 54enum AR5523_flags {55	AR5523_HW_UP,56	AR5523_USB_DISCONNECTED,57	AR5523_CONNECTED58};59 60struct ar5523_tx_cmd {61	struct ar5523		*ar;62	struct urb		*urb_tx;63	void			*buf_tx;64	void			*odata;65	int			olen;66	int			flags;67	int			res;68	struct completion	done;69};70 71/* This struct is placed in tx_info->driver_data. It must not be larger72 *  than IEEE80211_TX_INFO_DRIVER_DATA_SIZE.73 */74struct ar5523_tx_data {75	struct list_head	list;76	struct ar5523		*ar;77	struct urb		*urb;78};79 80struct ar5523_rx_data {81	struct	list_head	list;82	struct ar5523		*ar;83	struct urb		*urb;84	struct sk_buff		*skb;85};86 87struct ar5523 {88	struct usb_device	*dev;89	struct ieee80211_hw	*hw;90 91	unsigned long		flags;92	struct mutex		mutex;93	struct workqueue_struct *wq;94 95	struct ar5523_tx_cmd	tx_cmd;96 97	struct delayed_work	stat_work;98 99	struct timer_list	tx_wd_timer;100	struct work_struct	tx_wd_work;101	struct work_struct	tx_work;102	struct list_head	tx_queue_pending;103	struct list_head	tx_queue_submitted;104	spinlock_t		tx_data_list_lock;105	wait_queue_head_t	tx_flush_waitq;106 107	/* Queued + Submitted TX frames */108	atomic_t		tx_nr_total;109 110	/* Submitted TX frames */111	atomic_t		tx_nr_pending;112 113	void			*rx_cmd_buf;114	struct urb		*rx_cmd_urb;115 116	struct ar5523_rx_data	rx_data[AR5523_RX_DATA_COUNT];117	spinlock_t		rx_data_list_lock;118	struct list_head	rx_data_free;119	struct list_head	rx_data_used;120	atomic_t		rx_data_free_cnt;121 122	struct work_struct	rx_refill_work;123 124	unsigned int		rxbufsz;125	u8			serial[16];126 127	struct ieee80211_channel channels[14];128	struct ieee80211_rate	rates[12];129	struct ieee80211_supported_band band;130	struct ieee80211_vif	*vif;131};132 133/* flags for sending firmware commands */134#define AR5523_CMD_FLAG_READ	(1 << 1)135#define AR5523_CMD_FLAG_MAGIC	(1 << 2)136 137#define ar5523_dbg(ar, format, arg...) \138	dev_dbg(&(ar)->dev->dev, format, ## arg)139 140/* On USB hot-unplug there can be a lot of URBs in flight and they'll all141 * fail. Instead of dealing with them in every possible place just surpress142 * any messages on USB disconnect.143 */144#define ar5523_err(ar, format, arg...) \145do { \146	if (!test_bit(AR5523_USB_DISCONNECTED, &ar->flags)) { \147		dev_err(&(ar)->dev->dev, format, ## arg); \148	} \149} while (0)150#define ar5523_info(ar, format, arg...)	\151	dev_info(&(ar)->dev->dev, format, ## arg)152