1 /* $Header: /var/lib/cvs/prism54-ng/ksrc/islpci_dev.h,v 1.53 2004/02/28 03:06:07 mcgrof Exp $
3 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <linux/version.h>
26 #include <linux/netdevice.h>
27 #include <linux/wireless.h>
28 #include <linux/list.h>
30 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41)
31 # include <linux/workqueue.h>
33 # include <linux/tqueue.h>
34 # define work_struct tq_struct
35 # define INIT_WORK INIT_TQUEUE
36 # define schedule_work schedule_task
39 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23)
40 #define free_netdev(x) kfree(x)
41 #define pci_name(x) x->slot_name
46 #include "islpci_mgt.h"
48 /* some states might not be superflous and may be removed when
49 design is finalized (hvr) */
51 PRV_STATE_OFF = 0, /* this means hw_unavailable is != 0 */
52 PRV_STATE_PREBOOT, /* we are in a pre-boot state (empty RAM) */
53 PRV_STATE_BOOT, /* boot state (fw upload, run fw) */
54 PRV_STATE_POSTBOOT, /* after boot state, need reset now */
55 PRV_STATE_PREINIT, /* pre-init state */
56 PRV_STATE_INIT, /* init state (restore MIB backup to device) */
57 PRV_STATE_READY, /* driver&device are in operational state */
58 PRV_STATE_SLEEP /* device in sleep mode */
61 /* ACL using MAC address */
63 struct list_head _list;
68 enum { MAC_POLICY_OPEN=0, MAC_POLICY_ACCEPT=1, MAC_POLICY_REJECT=2 } policy;
69 struct list_head mac_list; /* a list of mac_entry */
70 int size; /* size of queue */
71 struct semaphore sem; /* accessed in ioctls and trap_work */
74 struct islpci_membuf {
75 int size; /* size of memory */
76 void *mem; /* address of memory as seen by CPU */
77 dma_addr_t pci_addr; /* address of memory as seen by device */
80 #define MAX_BSS_WPA_IE_COUNT 64
81 #define MAX_WPA_IE_LEN 64
82 struct islpci_bss_wpa_ie {
83 struct list_head list;
84 unsigned long last_update;
86 u8 wpa_ie[MAX_WPA_IE_LEN];
92 spinlock_t slock; /* generic spinlock; */
98 struct rw_semaphore mib_sem;
100 char nickname[IW_ESSID_MAX_SIZE+1];
102 /* Take care of the wireless stats */
103 struct work_struct stats_work;
104 struct semaphore stats_sem;
105 /* remember when we last updated the stats */
106 unsigned long stats_timestamp;
107 /* The first is accessed under semaphore locking.
108 * The second is the clean one we return to iwconfig.
110 struct iw_statistics local_iwstatistics;
111 struct iw_statistics iwstatistics;
113 struct islpci_acl acl;
115 /* PCI bus allocation & configuration members */
116 struct pci_dev *pdev; /* PCI structure information */
117 u32 pci_state[16]; /* used for suspend/resume */
120 void *device_base; /* ioremapped device base address */
122 /* consistent DMA region */
123 void *driver_mem_address; /* base DMA address */
124 dma_addr_t device_host_address; /* base DMA address (bus address) */
125 dma_addr_t device_psm_buffer; /* host memory for PSM buffering (bus address) */
127 /* our network_device structure */
128 struct net_device *ndev;
130 /* device queue interface members */
131 struct isl38xx_cb *control_block; /* device control block
132 (== driver_mem_address!) */
134 /* Each queue has three indexes:
135 * free/index_mgmt/data_rx/tx (called index, see below),
136 * driver_curr_frag, and device_curr_frag (in the control block)
137 * All indexes are ever-increasing, but interpreted modulo the
138 * device queue size when used.
139 * index <= device_curr_frag <= driver_curr_frag at all times
140 * For rx queues, [index, device_curr_frag) contains fragments
141 * that the interrupt processing needs to handle (owned by driver).
142 * [device_curr_frag, driver_curr_frag) is the free space in the
143 * rx queue, waiting for data (owned by device). The driver
144 * increments driver_curr_frag to indicate to the device that more
145 * buffers are available.
146 * If device_curr_frag == driver_curr_frag, no more rx buffers are
147 * available, and the rx DMA engine of the device is halted.
148 * For tx queues, [index, device_curr_frag) contains fragments
149 * where tx is done; they need to be freed (owned by driver).
150 * [device_curr_frag, driver_curr_frag) contains the frames
151 * that are being transferred (owned by device). The driver
152 * increments driver_curr_frag to indicate that more tx work
155 u32 index_mgmt_rx; /* real index mgmt rx queue */
156 u32 index_mgmt_tx; /* read index mgmt tx queue */
157 u32 free_data_rx; /* free pointer data rx queue */
158 u32 free_data_tx; /* free pointer data tx queue */
159 u32 data_low_tx_full; /* full detected flag */
161 /* frame memory buffers for the device queues */
162 struct islpci_membuf mgmt_tx[ISL38XX_CB_MGMT_QSIZE];
163 struct islpci_membuf mgmt_rx[ISL38XX_CB_MGMT_QSIZE];
164 struct sk_buff *data_low_tx[ISL38XX_CB_TX_QSIZE];
165 struct sk_buff *data_low_rx[ISL38XX_CB_RX_QSIZE];
166 dma_addr_t pci_map_tx_address[ISL38XX_CB_TX_QSIZE];
167 dma_addr_t pci_map_rx_address[ISL38XX_CB_RX_QSIZE];
169 /* driver network interface members */
170 struct net_device_stats statistics;
172 /* wait for a reset interrupt */
173 wait_queue_head_t reset_done;
175 /* used by islpci_mgt_transaction */
176 struct semaphore mgmt_sem; /* serialize access to mailbox and wqueue */
177 struct islpci_mgmtframe *mgmt_received; /* mbox for incoming frame */
178 wait_queue_head_t mgmt_wqueue; /* waitqueue for mbox */
181 islpci_state_t state;
182 int state_off; /* enumeration of off-state, if 0 then
183 * we're not in any off-state */
186 int wpa; /* WPA mode enabled */
187 struct list_head bss_wpa_list;
189 struct semaphore wpa_sem;
192 static inline islpci_state_t
193 islpci_get_state(islpci_private *priv)
200 islpci_state_t islpci_set_state(islpci_private *priv, islpci_state_t new_state);
202 #define ISLPCI_TX_TIMEOUT (2*HZ)
204 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,75))
205 # define irqreturn_t void
210 irqreturn_t islpci_interrupt(int, void *, struct pt_regs *);
212 int prism54_post_setup(islpci_private *, int);
213 int islpci_reset(islpci_private *, int);
216 islpci_trigger(islpci_private *priv)
218 isl38xx_trigger_device(islpci_get_state(priv) == PRV_STATE_SLEEP,
222 struct net_device_stats *islpci_statistics(struct net_device *);
224 int prism54_bring_down(islpci_private *);
225 int islpci_alloc_memory(islpci_private *);
226 int islpci_free_memory(islpci_private *);
227 struct net_device *islpci_setup(struct pci_dev *);
228 #endif /* _ISLPCI_DEV_H */