18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2002,2003 Oliver Kurth
48c2ecf20Sopenharmony_ci *	     (c) 2003,2004 Joerg Albert <joerg.albert@gmx.de>
58c2ecf20Sopenharmony_ci *	     (c) 2007 Guido Guenther <agx@sigxcpu.org>
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * This driver was based on information from the Sourceforge driver
88c2ecf20Sopenharmony_ci * released and maintained by Atmel:
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci *  http://sourceforge.net/projects/atmelwlandriver/
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Although the code was completely re-written,
138c2ecf20Sopenharmony_ci * it would have been impossible without Atmel's decision to
148c2ecf20Sopenharmony_ci * release an Open Source driver (unfortunately the firmware was
158c2ecf20Sopenharmony_ci * kept binary only). Thanks for that decision to Atmel!
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#ifndef _AT76_USB_H
198c2ecf20Sopenharmony_ci#define _AT76_USB_H
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci/* Board types */
228c2ecf20Sopenharmony_cienum board_type {
238c2ecf20Sopenharmony_ci	BOARD_503_ISL3861 = 1,
248c2ecf20Sopenharmony_ci	BOARD_503_ISL3863 = 2,
258c2ecf20Sopenharmony_ci	BOARD_503 = 3,
268c2ecf20Sopenharmony_ci	BOARD_503_ACC = 4,
278c2ecf20Sopenharmony_ci	BOARD_505 = 5,
288c2ecf20Sopenharmony_ci	BOARD_505_2958 = 6,
298c2ecf20Sopenharmony_ci	BOARD_505A = 7,
308c2ecf20Sopenharmony_ci	BOARD_505AMX = 8
318c2ecf20Sopenharmony_ci};
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define CMD_STATUS_IDLE				0x00
348c2ecf20Sopenharmony_ci#define CMD_STATUS_COMPLETE			0x01
358c2ecf20Sopenharmony_ci#define CMD_STATUS_UNKNOWN			0x02
368c2ecf20Sopenharmony_ci#define CMD_STATUS_INVALID_PARAMETER		0x03
378c2ecf20Sopenharmony_ci#define CMD_STATUS_FUNCTION_NOT_SUPPORTED	0x04
388c2ecf20Sopenharmony_ci#define CMD_STATUS_TIME_OUT			0x07
398c2ecf20Sopenharmony_ci#define CMD_STATUS_IN_PROGRESS			0x08
408c2ecf20Sopenharmony_ci#define CMD_STATUS_HOST_FAILURE			0xff
418c2ecf20Sopenharmony_ci#define CMD_STATUS_SCAN_FAILED			0xf0
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* answers to get op mode */
448c2ecf20Sopenharmony_ci#define OPMODE_NONE				0x00
458c2ecf20Sopenharmony_ci#define OPMODE_NORMAL_NIC_WITH_FLASH		0x01
468c2ecf20Sopenharmony_ci#define OPMODE_HW_CONFIG_MODE			0x02
478c2ecf20Sopenharmony_ci#define OPMODE_DFU_MODE_WITH_FLASH		0x03
488c2ecf20Sopenharmony_ci#define OPMODE_NORMAL_NIC_WITHOUT_FLASH		0x04
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define CMD_SET_MIB		0x01
518c2ecf20Sopenharmony_ci#define CMD_GET_MIB		0x02
528c2ecf20Sopenharmony_ci#define CMD_SCAN		0x03
538c2ecf20Sopenharmony_ci#define CMD_JOIN		0x04
548c2ecf20Sopenharmony_ci#define CMD_START_IBSS		0x05
558c2ecf20Sopenharmony_ci#define CMD_RADIO_ON		0x06
568c2ecf20Sopenharmony_ci#define CMD_RADIO_OFF		0x07
578c2ecf20Sopenharmony_ci#define CMD_STARTUP		0x0B
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define MIB_LOCAL		0x01
608c2ecf20Sopenharmony_ci#define MIB_MAC_ADDR		0x02
618c2ecf20Sopenharmony_ci#define MIB_MAC			0x03
628c2ecf20Sopenharmony_ci#define MIB_MAC_MGMT		0x05
638c2ecf20Sopenharmony_ci#define MIB_MAC_WEP		0x06
648c2ecf20Sopenharmony_ci#define MIB_PHY			0x07
658c2ecf20Sopenharmony_ci#define MIB_FW_VERSION		0x08
668c2ecf20Sopenharmony_ci#define MIB_MDOMAIN		0x09
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define ADHOC_MODE		1
698c2ecf20Sopenharmony_ci#define INFRASTRUCTURE_MODE	2
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci/* values for struct mib_local, field preamble_type */
728c2ecf20Sopenharmony_ci#define PREAMBLE_TYPE_LONG	0
738c2ecf20Sopenharmony_ci#define PREAMBLE_TYPE_SHORT	1
748c2ecf20Sopenharmony_ci#define PREAMBLE_TYPE_AUTO	2
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci/* values for tx_rate */
778c2ecf20Sopenharmony_ci#define TX_RATE_1MBIT		0
788c2ecf20Sopenharmony_ci#define TX_RATE_2MBIT		1
798c2ecf20Sopenharmony_ci#define TX_RATE_5_5MBIT 	2
808c2ecf20Sopenharmony_ci#define TX_RATE_11MBIT		3
818c2ecf20Sopenharmony_ci#define TX_RATE_AUTO		4
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/* power management modes */
848c2ecf20Sopenharmony_ci#define AT76_PM_OFF		1
858c2ecf20Sopenharmony_ci#define AT76_PM_ON		2
868c2ecf20Sopenharmony_ci#define AT76_PM_SMART		3
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_cistruct hwcfg_r505 {
898c2ecf20Sopenharmony_ci	u8 cr39_values[14];
908c2ecf20Sopenharmony_ci	u8 reserved1[14];
918c2ecf20Sopenharmony_ci	u8 bb_cr[14];
928c2ecf20Sopenharmony_ci	u8 pidvid[4];
938c2ecf20Sopenharmony_ci	u8 mac_addr[ETH_ALEN];
948c2ecf20Sopenharmony_ci	u8 regulatory_domain;
958c2ecf20Sopenharmony_ci	u8 reserved2[14];
968c2ecf20Sopenharmony_ci	u8 cr15_values[14];
978c2ecf20Sopenharmony_ci	u8 reserved3[3];
988c2ecf20Sopenharmony_ci} __packed;
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_cistruct hwcfg_rfmd {
1018c2ecf20Sopenharmony_ci	u8 cr20_values[14];
1028c2ecf20Sopenharmony_ci	u8 cr21_values[14];
1038c2ecf20Sopenharmony_ci	u8 bb_cr[14];
1048c2ecf20Sopenharmony_ci	u8 pidvid[4];
1058c2ecf20Sopenharmony_ci	u8 mac_addr[ETH_ALEN];
1068c2ecf20Sopenharmony_ci	u8 regulatory_domain;
1078c2ecf20Sopenharmony_ci	u8 low_power_values[14];
1088c2ecf20Sopenharmony_ci	u8 normal_power_values[14];
1098c2ecf20Sopenharmony_ci	u8 reserved1[3];
1108c2ecf20Sopenharmony_ci} __packed;
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_cistruct hwcfg_intersil {
1138c2ecf20Sopenharmony_ci	u8 mac_addr[ETH_ALEN];
1148c2ecf20Sopenharmony_ci	u8 cr31_values[14];
1158c2ecf20Sopenharmony_ci	u8 cr58_values[14];
1168c2ecf20Sopenharmony_ci	u8 pidvid[4];
1178c2ecf20Sopenharmony_ci	u8 regulatory_domain;
1188c2ecf20Sopenharmony_ci	u8 reserved[1];
1198c2ecf20Sopenharmony_ci} __packed;
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ciunion at76_hwcfg {
1228c2ecf20Sopenharmony_ci	struct hwcfg_intersil i;
1238c2ecf20Sopenharmony_ci	struct hwcfg_rfmd r3;
1248c2ecf20Sopenharmony_ci	struct hwcfg_r505 r5;
1258c2ecf20Sopenharmony_ci};
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#define WEP_SMALL_KEY_LEN	(40 / 8)
1288c2ecf20Sopenharmony_ci#define WEP_LARGE_KEY_LEN	(104 / 8)
1298c2ecf20Sopenharmony_ci#define WEP_KEYS		(4)
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_cistruct at76_card_config {
1328c2ecf20Sopenharmony_ci	u8 exclude_unencrypted;
1338c2ecf20Sopenharmony_ci	u8 promiscuous_mode;
1348c2ecf20Sopenharmony_ci	u8 short_retry_limit;
1358c2ecf20Sopenharmony_ci	u8 encryption_type;
1368c2ecf20Sopenharmony_ci	__le16 rts_threshold;
1378c2ecf20Sopenharmony_ci	__le16 fragmentation_threshold;	/* 256..2346 */
1388c2ecf20Sopenharmony_ci	u8 basic_rate_set[4];
1398c2ecf20Sopenharmony_ci	u8 auto_rate_fallback;	/* 0,1 */
1408c2ecf20Sopenharmony_ci	u8 channel;
1418c2ecf20Sopenharmony_ci	u8 privacy_invoked;
1428c2ecf20Sopenharmony_ci	u8 wep_default_key_id;	/* 0..3 */
1438c2ecf20Sopenharmony_ci	u8 current_ssid[32];
1448c2ecf20Sopenharmony_ci	u8 wep_default_key_value[4][WEP_LARGE_KEY_LEN];
1458c2ecf20Sopenharmony_ci	u8 ssid_len;
1468c2ecf20Sopenharmony_ci	u8 short_preamble;
1478c2ecf20Sopenharmony_ci	__le16 beacon_period;
1488c2ecf20Sopenharmony_ci} __packed;
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_cistruct at76_command {
1518c2ecf20Sopenharmony_ci	u8 cmd;
1528c2ecf20Sopenharmony_ci	u8 reserved;
1538c2ecf20Sopenharmony_ci	__le16 size;
1548c2ecf20Sopenharmony_ci	u8 data[];
1558c2ecf20Sopenharmony_ci} __packed;
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci/* Length of Atmel-specific Rx header before 802.11 frame */
1588c2ecf20Sopenharmony_ci#define AT76_RX_HDRLEN offsetof(struct at76_rx_buffer, packet)
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_cistruct at76_rx_buffer {
1618c2ecf20Sopenharmony_ci	__le16 wlength;
1628c2ecf20Sopenharmony_ci	u8 rx_rate;
1638c2ecf20Sopenharmony_ci	u8 newbss;
1648c2ecf20Sopenharmony_ci	u8 fragmentation;
1658c2ecf20Sopenharmony_ci	u8 rssi;
1668c2ecf20Sopenharmony_ci	u8 link_quality;
1678c2ecf20Sopenharmony_ci	u8 noise_level;
1688c2ecf20Sopenharmony_ci	__le32 rx_time;
1698c2ecf20Sopenharmony_ci	u8 packet[IEEE80211_MAX_FRAG_THRESHOLD];
1708c2ecf20Sopenharmony_ci} __packed;
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci/* Length of Atmel-specific Tx header before 802.11 frame */
1738c2ecf20Sopenharmony_ci#define AT76_TX_HDRLEN offsetof(struct at76_tx_buffer, packet)
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_cistruct at76_tx_buffer {
1768c2ecf20Sopenharmony_ci	__le16 wlength;
1778c2ecf20Sopenharmony_ci	u8 tx_rate;
1788c2ecf20Sopenharmony_ci	u8 padding;
1798c2ecf20Sopenharmony_ci	u8 reserved[4];
1808c2ecf20Sopenharmony_ci	u8 packet[IEEE80211_MAX_FRAG_THRESHOLD];
1818c2ecf20Sopenharmony_ci} __packed;
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci/* defines for scan_type below */
1848c2ecf20Sopenharmony_ci#define SCAN_TYPE_ACTIVE	0
1858c2ecf20Sopenharmony_ci#define SCAN_TYPE_PASSIVE	1
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_cistruct at76_req_scan {
1888c2ecf20Sopenharmony_ci	u8 bssid[ETH_ALEN];
1898c2ecf20Sopenharmony_ci	u8 essid[32];
1908c2ecf20Sopenharmony_ci	u8 scan_type;
1918c2ecf20Sopenharmony_ci	u8 channel;
1928c2ecf20Sopenharmony_ci	__le16 probe_delay;
1938c2ecf20Sopenharmony_ci	__le16 min_channel_time;
1948c2ecf20Sopenharmony_ci	__le16 max_channel_time;
1958c2ecf20Sopenharmony_ci	u8 essid_size;
1968c2ecf20Sopenharmony_ci	u8 international_scan;
1978c2ecf20Sopenharmony_ci} __packed;
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_cistruct at76_req_ibss {
2008c2ecf20Sopenharmony_ci	u8 bssid[ETH_ALEN];
2018c2ecf20Sopenharmony_ci	u8 essid[32];
2028c2ecf20Sopenharmony_ci	u8 bss_type;
2038c2ecf20Sopenharmony_ci	u8 channel;
2048c2ecf20Sopenharmony_ci	u8 essid_size;
2058c2ecf20Sopenharmony_ci	u8 reserved[3];
2068c2ecf20Sopenharmony_ci} __packed;
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_cistruct at76_req_join {
2098c2ecf20Sopenharmony_ci	u8 bssid[ETH_ALEN];
2108c2ecf20Sopenharmony_ci	u8 essid[32];
2118c2ecf20Sopenharmony_ci	u8 bss_type;
2128c2ecf20Sopenharmony_ci	u8 channel;
2138c2ecf20Sopenharmony_ci	__le16 timeout;
2148c2ecf20Sopenharmony_ci	u8 essid_size;
2158c2ecf20Sopenharmony_ci	u8 reserved;
2168c2ecf20Sopenharmony_ci} __packed;
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_cistruct mib_local {
2198c2ecf20Sopenharmony_ci	u16 reserved0;
2208c2ecf20Sopenharmony_ci	u8 beacon_enable;
2218c2ecf20Sopenharmony_ci	u8 txautorate_fallback;
2228c2ecf20Sopenharmony_ci	u8 reserved1;
2238c2ecf20Sopenharmony_ci	u8 ssid_size;
2248c2ecf20Sopenharmony_ci	u8 promiscuous_mode;
2258c2ecf20Sopenharmony_ci	u16 reserved2;
2268c2ecf20Sopenharmony_ci	u8 preamble_type;
2278c2ecf20Sopenharmony_ci	u16 reserved3;
2288c2ecf20Sopenharmony_ci} __packed;
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_cistruct mib_mac_addr {
2318c2ecf20Sopenharmony_ci	u8 mac_addr[ETH_ALEN];
2328c2ecf20Sopenharmony_ci	u8 res[2];		/* ??? */
2338c2ecf20Sopenharmony_ci	u8 group_addr[4][ETH_ALEN];
2348c2ecf20Sopenharmony_ci	u8 group_addr_status[4];
2358c2ecf20Sopenharmony_ci} __packed;
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_cistruct mib_mac {
2388c2ecf20Sopenharmony_ci	__le32 max_tx_msdu_lifetime;
2398c2ecf20Sopenharmony_ci	__le32 max_rx_lifetime;
2408c2ecf20Sopenharmony_ci	__le16 frag_threshold;
2418c2ecf20Sopenharmony_ci	__le16 rts_threshold;
2428c2ecf20Sopenharmony_ci	__le16 cwmin;
2438c2ecf20Sopenharmony_ci	__le16 cwmax;
2448c2ecf20Sopenharmony_ci	u8 short_retry_time;
2458c2ecf20Sopenharmony_ci	u8 long_retry_time;
2468c2ecf20Sopenharmony_ci	u8 scan_type;		/* active or passive */
2478c2ecf20Sopenharmony_ci	u8 scan_channel;
2488c2ecf20Sopenharmony_ci	__le16 probe_delay;	/* delay before ProbeReq in active scan, RO */
2498c2ecf20Sopenharmony_ci	__le16 min_channel_time;
2508c2ecf20Sopenharmony_ci	__le16 max_channel_time;
2518c2ecf20Sopenharmony_ci	__le16 listen_interval;
2528c2ecf20Sopenharmony_ci	u8 desired_ssid[32];
2538c2ecf20Sopenharmony_ci	u8 desired_bssid[ETH_ALEN];
2548c2ecf20Sopenharmony_ci	u8 desired_bsstype;	/* ad-hoc or infrastructure */
2558c2ecf20Sopenharmony_ci	u8 reserved2;
2568c2ecf20Sopenharmony_ci} __packed;
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_cistruct mib_mac_mgmt {
2598c2ecf20Sopenharmony_ci	__le16 beacon_period;
2608c2ecf20Sopenharmony_ci	__le16 CFP_max_duration;
2618c2ecf20Sopenharmony_ci	__le16 medium_occupancy_limit;
2628c2ecf20Sopenharmony_ci	__le16 station_id;	/* assoc id */
2638c2ecf20Sopenharmony_ci	__le16 ATIM_window;
2648c2ecf20Sopenharmony_ci	u8 CFP_mode;
2658c2ecf20Sopenharmony_ci	u8 privacy_option_implemented;
2668c2ecf20Sopenharmony_ci	u8 DTIM_period;
2678c2ecf20Sopenharmony_ci	u8 CFP_period;
2688c2ecf20Sopenharmony_ci	u8 current_bssid[ETH_ALEN];
2698c2ecf20Sopenharmony_ci	u8 current_essid[32];
2708c2ecf20Sopenharmony_ci	u8 current_bss_type;
2718c2ecf20Sopenharmony_ci	u8 power_mgmt_mode;
2728c2ecf20Sopenharmony_ci	/* rfmd and 505 */
2738c2ecf20Sopenharmony_ci	u8 ibss_change;
2748c2ecf20Sopenharmony_ci	u8 res;
2758c2ecf20Sopenharmony_ci	u8 multi_domain_capability_implemented;
2768c2ecf20Sopenharmony_ci	u8 multi_domain_capability_enabled;
2778c2ecf20Sopenharmony_ci	u8 country_string[IEEE80211_COUNTRY_STRING_LEN];
2788c2ecf20Sopenharmony_ci	u8 reserved[3];
2798c2ecf20Sopenharmony_ci} __packed;
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_cistruct mib_mac_wep {
2828c2ecf20Sopenharmony_ci	u8 privacy_invoked;	/* 0 disable encr., 1 enable encr */
2838c2ecf20Sopenharmony_ci	u8 wep_default_key_id;
2848c2ecf20Sopenharmony_ci	u8 wep_key_mapping_len;
2858c2ecf20Sopenharmony_ci	u8 exclude_unencrypted;
2868c2ecf20Sopenharmony_ci	__le32 wep_icv_error_count;
2878c2ecf20Sopenharmony_ci	__le32 wep_excluded_count;
2888c2ecf20Sopenharmony_ci	u8 wep_default_keyvalue[WEP_KEYS][WEP_LARGE_KEY_LEN];
2898c2ecf20Sopenharmony_ci	u8 encryption_level;	/* 1 for 40bit, 2 for 104bit encryption */
2908c2ecf20Sopenharmony_ci} __packed;
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_cistruct mib_phy {
2938c2ecf20Sopenharmony_ci	__le32 ed_threshold;
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_ci	__le16 slot_time;
2968c2ecf20Sopenharmony_ci	__le16 sifs_time;
2978c2ecf20Sopenharmony_ci	__le16 preamble_length;
2988c2ecf20Sopenharmony_ci	__le16 plcp_header_length;
2998c2ecf20Sopenharmony_ci	__le16 mpdu_max_length;
3008c2ecf20Sopenharmony_ci	__le16 cca_mode_supported;
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci	u8 operation_rate_set[4];
3038c2ecf20Sopenharmony_ci	u8 channel_id;
3048c2ecf20Sopenharmony_ci	u8 current_cca_mode;
3058c2ecf20Sopenharmony_ci	u8 phy_type;
3068c2ecf20Sopenharmony_ci	u8 current_reg_domain;
3078c2ecf20Sopenharmony_ci} __packed;
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_cistruct mib_fw_version {
3108c2ecf20Sopenharmony_ci	u8 major;
3118c2ecf20Sopenharmony_ci	u8 minor;
3128c2ecf20Sopenharmony_ci	u8 patch;
3138c2ecf20Sopenharmony_ci	u8 build;
3148c2ecf20Sopenharmony_ci} __packed;
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_cistruct mib_mdomain {
3178c2ecf20Sopenharmony_ci	u8 tx_powerlevel[14];
3188c2ecf20Sopenharmony_ci	u8 channel_list[14];	/* 0 for invalid channels */
3198c2ecf20Sopenharmony_ci} __packed;
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_cistruct set_mib_buffer {
3228c2ecf20Sopenharmony_ci	u8 type;
3238c2ecf20Sopenharmony_ci	u8 size;
3248c2ecf20Sopenharmony_ci	u8 index;
3258c2ecf20Sopenharmony_ci	u8 reserved;
3268c2ecf20Sopenharmony_ci	union {
3278c2ecf20Sopenharmony_ci		u8 byte;
3288c2ecf20Sopenharmony_ci		__le16 word;
3298c2ecf20Sopenharmony_ci		u8 addr[ETH_ALEN];
3308c2ecf20Sopenharmony_ci		struct mib_mac_wep wep_mib;
3318c2ecf20Sopenharmony_ci	} data;
3328c2ecf20Sopenharmony_ci} __packed;
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_cistruct at76_fw_header {
3358c2ecf20Sopenharmony_ci	__le32 crc;		/* CRC32 of the whole image */
3368c2ecf20Sopenharmony_ci	__le32 board_type;	/* firmware compatibility code */
3378c2ecf20Sopenharmony_ci	u8 build;		/* firmware build number */
3388c2ecf20Sopenharmony_ci	u8 patch;		/* firmware patch level */
3398c2ecf20Sopenharmony_ci	u8 minor;		/* firmware minor version */
3408c2ecf20Sopenharmony_ci	u8 major;		/* firmware major version */
3418c2ecf20Sopenharmony_ci	__le32 str_offset;	/* offset of the copyright string */
3428c2ecf20Sopenharmony_ci	__le32 int_fw_offset;	/* internal firmware image offset */
3438c2ecf20Sopenharmony_ci	__le32 int_fw_len;	/* internal firmware image length */
3448c2ecf20Sopenharmony_ci	__le32 ext_fw_offset;	/* external firmware image offset */
3458c2ecf20Sopenharmony_ci	__le32 ext_fw_len;	/* external firmware image length */
3468c2ecf20Sopenharmony_ci} __packed;
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci/* a description of a regulatory domain and the allowed channels */
3498c2ecf20Sopenharmony_cistruct reg_domain {
3508c2ecf20Sopenharmony_ci	u16 code;
3518c2ecf20Sopenharmony_ci	char const *name;
3528c2ecf20Sopenharmony_ci	u32 channel_map;	/* if bit N is set, channel (N+1) is allowed */
3538c2ecf20Sopenharmony_ci};
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_ci/* Data for one loaded firmware file */
3568c2ecf20Sopenharmony_cistruct fwentry {
3578c2ecf20Sopenharmony_ci	const char *const fwname;
3588c2ecf20Sopenharmony_ci	const struct firmware *fw;
3598c2ecf20Sopenharmony_ci	int extfw_size;
3608c2ecf20Sopenharmony_ci	int intfw_size;
3618c2ecf20Sopenharmony_ci	/* pointer to loaded firmware, no need to free */
3628c2ecf20Sopenharmony_ci	u8 *extfw;		/* external firmware, extfw_size bytes long */
3638c2ecf20Sopenharmony_ci	u8 *intfw;		/* internal firmware, intfw_size bytes long */
3648c2ecf20Sopenharmony_ci	enum board_type board_type;	/* board type */
3658c2ecf20Sopenharmony_ci	struct mib_fw_version fw_version;
3668c2ecf20Sopenharmony_ci	int loaded;		/* Loaded and parsed successfully */
3678c2ecf20Sopenharmony_ci};
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_cistruct at76_priv {
3708c2ecf20Sopenharmony_ci	struct usb_device *udev;	/* USB device pointer */
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	struct sk_buff *rx_skb;	/* skbuff for receiving data */
3738c2ecf20Sopenharmony_ci	struct sk_buff *tx_skb;	/* skbuff for transmitting data */
3748c2ecf20Sopenharmony_ci	void *bulk_out_buffer;	/* buffer for sending data */
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ci	struct urb *tx_urb;	/* URB for sending data */
3778c2ecf20Sopenharmony_ci	struct urb *rx_urb;	/* URB for receiving data */
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci	unsigned int tx_pipe;	/* bulk out pipe */
3808c2ecf20Sopenharmony_ci	unsigned int rx_pipe;	/* bulk in pipe */
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_ci	struct mutex mtx;	/* locks this structure */
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_ci	/* work queues */
3858c2ecf20Sopenharmony_ci	struct work_struct work_set_promisc;
3868c2ecf20Sopenharmony_ci	struct work_struct work_submit_rx;
3878c2ecf20Sopenharmony_ci	struct work_struct work_join_bssid;
3888c2ecf20Sopenharmony_ci	struct delayed_work dwork_hw_scan;
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci	struct tasklet_struct rx_tasklet;
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci	/* the WEP stuff */
3938c2ecf20Sopenharmony_ci	int wep_enabled;	/* 1 if WEP is enabled */
3948c2ecf20Sopenharmony_ci	int wep_key_id;		/* key id to be used */
3958c2ecf20Sopenharmony_ci	u8 wep_keys[WEP_KEYS][WEP_LARGE_KEY_LEN];	/* WEP keys */
3968c2ecf20Sopenharmony_ci	u8 wep_keys_len[WEP_KEYS];	/* length of WEP keys */
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_ci	int channel;
3998c2ecf20Sopenharmony_ci	int iw_mode;
4008c2ecf20Sopenharmony_ci	u8 bssid[ETH_ALEN];
4018c2ecf20Sopenharmony_ci	u8 essid[IW_ESSID_MAX_SIZE];
4028c2ecf20Sopenharmony_ci	int essid_size;
4038c2ecf20Sopenharmony_ci	int radio_on;
4048c2ecf20Sopenharmony_ci	int promisc;
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci	int preamble_type;	/* 0 - long, 1 - short, 2 - auto */
4078c2ecf20Sopenharmony_ci	int auth_mode;		/* authentication type: 0 open, 1 shared key */
4088c2ecf20Sopenharmony_ci	int txrate;		/* 0,1,2,3 = 1,2,5.5,11 Mbps, 4 is auto */
4098c2ecf20Sopenharmony_ci	int frag_threshold;	/* threshold for fragmentation of tx packets */
4108c2ecf20Sopenharmony_ci	int rts_threshold;	/* threshold for RTS mechanism */
4118c2ecf20Sopenharmony_ci	int short_retry_limit;
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci	int scan_min_time;	/* scan min channel time */
4148c2ecf20Sopenharmony_ci	int scan_max_time;	/* scan max channel time */
4158c2ecf20Sopenharmony_ci	int scan_mode;		/* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */
4168c2ecf20Sopenharmony_ci	int scan_need_any;	/* if set, need to scan for any ESSID */
4178c2ecf20Sopenharmony_ci	bool scanning;		/* if set, the scan is running */
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ci	u16 assoc_id;		/* current association ID, if associated */
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_ci	u8 pm_mode;		/* power management mode */
4228c2ecf20Sopenharmony_ci	u32 pm_period;		/* power management period in microseconds */
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci	struct reg_domain const *domain;	/* reg domain description */
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci	/* These fields contain HW config provided by the device (not all of
4278c2ecf20Sopenharmony_ci	 * these fields are used by all board types) */
4288c2ecf20Sopenharmony_ci	u8 mac_addr[ETH_ALEN];
4298c2ecf20Sopenharmony_ci	u8 regulatory_domain;
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci	struct at76_card_config card_config;
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ci	enum board_type board_type;
4348c2ecf20Sopenharmony_ci	struct mib_fw_version fw_version;
4358c2ecf20Sopenharmony_ci
4368c2ecf20Sopenharmony_ci	unsigned int device_unplugged:1;
4378c2ecf20Sopenharmony_ci	unsigned int netdev_registered:1;
4388c2ecf20Sopenharmony_ci	struct set_mib_buffer mib_buf;	/* global buffer for set_mib calls */
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci	int beacon_period;	/* period of mgmt beacons, Kus */
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci	struct ieee80211_hw *hw;
4438c2ecf20Sopenharmony_ci	int mac80211_registered;
4448c2ecf20Sopenharmony_ci};
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci#define AT76_SUPPORTED_FILTERS 0
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_ci#define SCAN_POLL_INTERVAL	(HZ / 4)
4498c2ecf20Sopenharmony_ci
4508c2ecf20Sopenharmony_ci#define CMD_COMPLETION_TIMEOUT	(5 * HZ)
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_ci#define DEF_RTS_THRESHOLD	1536
4538c2ecf20Sopenharmony_ci#define DEF_FRAG_THRESHOLD	1536
4548c2ecf20Sopenharmony_ci#define DEF_SHORT_RETRY_LIMIT	8
4558c2ecf20Sopenharmony_ci#define DEF_CHANNEL		10
4568c2ecf20Sopenharmony_ci#define DEF_SCAN_MIN_TIME	10
4578c2ecf20Sopenharmony_ci#define DEF_SCAN_MAX_TIME	120
4588c2ecf20Sopenharmony_ci
4598c2ecf20Sopenharmony_ci/* the max padding size for tx in bytes (see calc_padding) */
4608c2ecf20Sopenharmony_ci#define MAX_PADDING_SIZE	53
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ci#endif				/* _AT76_USB_H */
463