1 /*
2  * Copyright (c) 2010 Broadcom Corporation
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef _BRCM_MAC80211_IF_H_
18 #define _BRCM_MAC80211_IF_H_
19 
20 #include <linux/timer.h>
21 #include <linux/interrupt.h>
22 #include <linux/workqueue.h>
23 #include <linux/leds.h>
24 
25 #include "ucode_loader.h"
26 #include "led.h"
27 /*
28  * Starting index for 5G rates in the
29  * legacy rate table.
30  */
31 #define BRCMS_LEGACY_5G_RATE_OFFSET	4
32 
33 /* softmac ioctl definitions */
34 #define BRCMS_SET_SHORTSLOT_OVERRIDE		146
35 
36 struct brcms_timer {
37 	struct delayed_work dly_wrk;
38 	struct brcms_info *wl;
39 	void (*fn) (void *);	/* function called upon expiration */
40 	void *arg;		/* fixed argument provided to called function */
41 	uint ms;
42 	bool periodic;
43 	bool set;		/* indicates if timer is active */
44 	struct brcms_timer *next;	/* for freeing on unload */
45 #ifdef DEBUG
46 	char *name;		/* Description of the timer */
47 #endif
48 };
49 
50 struct brcms_if {
51 	uint subunit;		/* WDS/BSS unit */
52 	struct pci_dev *pci_dev;
53 };
54 
55 #define MAX_FW_IMAGES		4
56 struct brcms_firmware {
57 	u32 fw_cnt;
58 	const struct firmware *fw_bin[MAX_FW_IMAGES];
59 	const struct firmware *fw_hdr[MAX_FW_IMAGES];
60 	u32 hdr_num_entries[MAX_FW_IMAGES];
61 };
62 
63 struct brcms_info {
64 	struct brcms_pub *pub;		/* pointer to public wlc state */
65 	struct brcms_c_info *wlc;	/* pointer to private common data */
66 	u32 magic;
67 
68 	int irq;
69 
70 	spinlock_t lock;	/* per-device perimeter lock */
71 	spinlock_t isr_lock;	/* per-device ISR synchronization lock */
72 
73 	/* tx flush */
74 	wait_queue_head_t tx_flush_wq;
75 
76 	/* timer related fields */
77 	atomic_t callbacks;	/* # outstanding callback functions */
78 	struct brcms_timer *timers;	/* timer cleanup queue */
79 
80 	struct tasklet_struct tasklet;	/* dpc tasklet */
81 	bool resched;		/* dpc needs to be and is rescheduled */
82 	struct brcms_firmware fw;
83 	struct wiphy *wiphy;
84 	struct brcms_ucode ucode;
85 	bool mute_tx;
86 	struct brcms_led radio_led;
87 	struct led_classdev led_dev;
88 };
89 
90 /* misc callbacks */
91 void brcms_init(struct brcms_info *wl);
92 uint brcms_reset(struct brcms_info *wl);
93 void brcms_intrson(struct brcms_info *wl);
94 u32 brcms_intrsoff(struct brcms_info *wl);
95 void brcms_intrsrestore(struct brcms_info *wl, u32 macintmask);
96 int brcms_up(struct brcms_info *wl);
97 void brcms_down(struct brcms_info *wl);
98 void brcms_txflowcontrol(struct brcms_info *wl, struct brcms_if *wlif,
99 			 bool state, int prio);
100 bool brcms_rfkill_set_hw_state(struct brcms_info *wl);
101 
102 /* timer functions */
103 struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
104 				     void (*fn) (void *arg), void *arg,
105 				     const char *name);
106 void brcms_free_timer(struct brcms_timer *timer);
107 void brcms_add_timer(struct brcms_timer *timer, uint ms, int periodic);
108 bool brcms_del_timer(struct brcms_timer *timer);
109 void brcms_dpc(unsigned long data);
110 void brcms_timer(struct brcms_timer *t);
111 void brcms_fatal_error(struct brcms_info *wl);
112 
113 #endif				/* _BRCM_MAC80211_IF_H_ */
114