p54.h 6.0 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0-only */
2 3 4 5 6 7 8 9 10
/*
 * Shared defines for all mac80211 Prism54 code
 *
 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
 *
 * Based on the islsm (softmac prism54) driver, which is:
 * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
 */

11 12 13
#ifndef P54_H
#define P54_H

14
#ifdef CONFIG_P54_LEDS
15
#include <linux/leds.h>
16
#endif /* CONFIG_P54_LEDS */
17

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#define ISL38XX_DEV_FIRMWARE_ADDR 0x20000

#define BR_CODE_MIN			0x80000000
#define BR_CODE_COMPONENT_ID		0x80000001
#define BR_CODE_COMPONENT_VERSION	0x80000002
#define BR_CODE_DEPENDENT_IF		0x80000003
#define BR_CODE_EXPOSED_IF		0x80000004
#define BR_CODE_DESCR			0x80000101
#define BR_CODE_MAX			0x8FFFFFFF
#define BR_CODE_END_OF_BRA		0xFF0000FF
#define LEGACY_BR_CODE_END_OF_BRA	0xFFFFFFFF

struct bootrec {
	__le32 code;
	__le32 len;
	u32 data[10];
} __packed;

/* Interface role definitions */
#define BR_INTERFACE_ROLE_SERVER	0x0000
#define BR_INTERFACE_ROLE_CLIENT	0x8000

#define BR_DESC_PRIV_CAP_WEP		BIT(0)
#define BR_DESC_PRIV_CAP_TKIP		BIT(1)
#define BR_DESC_PRIV_CAP_MICHAEL	BIT(2)
#define BR_DESC_PRIV_CAP_CCX_CP		BIT(3)
#define BR_DESC_PRIV_CAP_CCX_MIC	BIT(4)
#define BR_DESC_PRIV_CAP_AESCCMP	BIT(5)

struct bootrec_desc {
	__le16 modes;
	__le16 flags;
	__le32 rx_start;
	__le32 rx_end;
	u8 headroom;
	u8 tailroom;
	u8 tx_queues;
	u8 tx_depth;
	u8 privacy_caps;
	u8 rx_keycache_size;
	u8 time_size;
	u8 padding;
	u8 rates[16];
	u8 padding2[4];
	__le16 rx_mtu;
} __packed;

#define FW_FMAC 0x464d4143
#define FW_LM86 0x4c4d3836
#define FW_LM87 0x4c4d3837
#define FW_LM20 0x4c4d3230

struct bootrec_comp_id {
	__le32 fw_variant;
} __packed;

struct bootrec_comp_ver {
	char fw_version[24];
} __packed;

struct bootrec_end {
	__le16 crc;
	u8 padding[2];
	u8 md5[16];
} __packed;
83

84 85 86 87 88 89 90
/* provide 16 bytes for the transport back-end */
#define P54_TX_INFO_DATA_SIZE		16

/* stored in ieee80211_tx_info's rate_driver_data */
struct p54_tx_info {
	u32 start_addr;
	u32 end_addr;
91 92 93 94 95 96
	union {
		void *data[P54_TX_INFO_DATA_SIZE / sizeof(void *)];
		struct {
			u32 extra_len;
		};
	};
97 98
};

99 100
#define P54_MAX_CTRL_FRAME_LEN		0x1000

101 102 103 104 105 106 107
#define P54_SET_QUEUE(queue, ai_fs, cw_min, cw_max, _txop)	\
do {								\
	queue.aifs = cpu_to_le16(ai_fs);			\
	queue.cwmin = cpu_to_le16(cw_min);			\
	queue.cwmax = cpu_to_le16(cw_max);			\
	queue.txop = cpu_to_le16(_txop);			\
} while (0)
108

C
Christian Lamparter 已提交
109 110 111 112 113
struct p54_edcf_queue_param {
	__le16 aifs;
	__le16 cwmin;
	__le16 cwmax;
	__le16 txop;
114
} __packed;
C
Christian Lamparter 已提交
115

116 117
struct p54_rssi_db_entry {
	u16 freq;
118 119 120 121 122 123
	s16 mul;
	s16 add;
	s16 longbow_unkn;
	s16 longbow_unk2;
};

124 125 126 127 128
struct p54_cal_database {
	size_t entries;
	size_t entry_size;
	size_t offset;
	size_t len;
129
	u8 data[];
130 131
};

132
#define EEPROM_READBACK_LEN 0x3fc
133

C
Christian Lamparter 已提交
134 135 136 137 138 139 140 141
enum fw_state {
	FW_STATE_OFF,
	FW_STATE_BOOTING,
	FW_STATE_READY,
	FW_STATE_RESET,
	FW_STATE_RESETTING,
};

142
#ifdef CONFIG_P54_LEDS
143 144 145 146 147 148 149 150

#define P54_LED_MAX_NAME_LEN 31

struct p54_led_dev {
	struct ieee80211_hw *hw_dev;
	struct led_classdev led_dev;
	char name[P54_LED_MAX_NAME_LEN + 1];

C
Christian Lamparter 已提交
151
	unsigned int toggled;
152 153 154 155
	unsigned int index;
	unsigned int registered;
};

156
#endif /* CONFIG_P54_LEDS */
157

158 159 160 161 162 163
struct p54_tx_queue_stats {
	unsigned int len;
	unsigned int limit;
	unsigned int count;
};

164
struct p54_common {
165
	struct ieee80211_hw *hw;
166
	struct ieee80211_vif *vif;
167
	void (*tx)(struct ieee80211_hw *dev, struct sk_buff *skb);
168 169
	int (*open)(struct ieee80211_hw *dev);
	void (*stop)(struct ieee80211_hw *dev);
170
	struct sk_buff_head tx_pending;
171 172
	struct sk_buff_head tx_queue;
	struct mutex conf_mutex;
173
	bool registered;
174 175 176 177

	/* memory management (as seen by the firmware) */
	u32 rx_start;
	u32 rx_end;
178 179 180
	u16 rx_mtu;
	u8 headroom;
	u8 tailroom;
181 182 183 184 185 186 187 188 189

	/* firmware/hardware info */
	unsigned int tx_hdr_len;
	unsigned int fw_var;
	unsigned int fw_interface;
	u8 version;

	/* (e)DCF / QOS state */
	bool use_short_slot;
190
	spinlock_t tx_stats_lock;
191
	struct p54_tx_queue_stats tx_stats[8];
192 193 194 195
	struct p54_edcf_queue_param qos_params[8];

	/* Radio data */
	u16 rxhw;
196 197
	u8 rx_diversity_mask;
	u8 tx_diversity_mask;
198
	unsigned int output_power;
199
	struct p54_rssi_db_entry *cur_rssi;
C
Christian Lamparter 已提交
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
	struct ieee80211_channel *curchan;
	struct survey_info *survey;
	unsigned int chan_num;
	struct completion stat_comp;
	bool update_stats;
	struct {
		unsigned int timestamp;
		unsigned int cached_cca;
		unsigned int cached_tx;
		unsigned int cached_rssi;
		u64 active;
		u64 cca;
		u64 tx;
		u64 rssi;
	} survey_raw;

216 217
	int noise;
	/* calibration, output power limit and rssi<->dBm conversation data */
218 219
	struct pda_iq_autocal_entry *iq_autocal;
	unsigned int iq_autocal_len;
220
	struct p54_cal_database *curve_data;
221
	struct p54_cal_database *output_limit;
222
	struct p54_cal_database *rssi_db;
223
	struct ieee80211_supported_band *band_table[NUM_NL80211_BANDS];
224 225 226 227

	/* BBP/MAC state */
	u8 mac_addr[ETH_ALEN];
	u8 bssid[ETH_ALEN];
228
	u8 mc_maclist[4][ETH_ALEN];
229
	u16 wakeup_timer;
C
Christian Lamparter 已提交
230
	unsigned int filter_flags;
231
	int mc_maclist_num;
232 233
	int mode;
	u32 tsf_low32, tsf_high32;
234
	u32 basic_rate_mask;
235
	u16 aid;
236
	u8 coverage_class;
C
Christian Lamparter 已提交
237 238
	bool phy_idle;
	bool phy_ps;
239
	bool powersave_override;
240
	__le32 beacon_req_id;
241
	struct completion beacon_comp;
242 243

	/* cryptographic engine information */
244 245
	u8 privacy_caps;
	u8 rx_keycache_size;
246
	unsigned long *used_rxkeys;
247

248
	/* LED management */
249
#ifdef CONFIG_P54_LEDS
C
Christian Lamparter 已提交
250 251
	struct p54_led_dev leds[4];
	struct delayed_work led_work;
252
#endif /* CONFIG_P54_LEDS */
253
	u16 softled_state;		/* bit field of glowing LEDs */
254 255 256 257 258 259 260 261

	/* statistics */
	struct ieee80211_low_level_stats stats;
	struct delayed_work work;

	/* eeprom handling */
	void *eeprom;
	struct completion eeprom_comp;
262
	struct mutex eeprom_mutex;
263 264
};

265
/* interfaces for the drivers */
266
int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb);
C
Christian Lamparter 已提交
267
void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb);
268
int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw);
C
Christian Lamparter 已提交
269
int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len);
270
int p54_read_eeprom(struct ieee80211_hw *dev);
271

272
struct ieee80211_hw *p54_init_common(size_t priv_data_len);
273
int p54_register_common(struct ieee80211_hw *dev, struct device *pdev);
274 275
void p54_free_common(struct ieee80211_hw *dev);

276 277
void p54_unregister_common(struct ieee80211_hw *dev);

278
#endif /* P54_H */