162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef __WL12XX_80211_H__
362306a36Sopenharmony_ci#define __WL12XX_80211_H__
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/if_ether.h>	/* ETH_ALEN */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci/* RATES */
862306a36Sopenharmony_ci#define IEEE80211_CCK_RATE_1MB		        0x02
962306a36Sopenharmony_ci#define IEEE80211_CCK_RATE_2MB		        0x04
1062306a36Sopenharmony_ci#define IEEE80211_CCK_RATE_5MB		        0x0B
1162306a36Sopenharmony_ci#define IEEE80211_CCK_RATE_11MB		        0x16
1262306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_6MB		        0x0C
1362306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_9MB		        0x12
1462306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_12MB		0x18
1562306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_18MB		0x24
1662306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_24MB		0x30
1762306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_36MB		0x48
1862306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_48MB		0x60
1962306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_54MB		0x6C
2062306a36Sopenharmony_ci#define IEEE80211_BASIC_RATE_MASK		0x80
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#define IEEE80211_CCK_RATE_1MB_MASK		(1<<0)
2362306a36Sopenharmony_ci#define IEEE80211_CCK_RATE_2MB_MASK		(1<<1)
2462306a36Sopenharmony_ci#define IEEE80211_CCK_RATE_5MB_MASK		(1<<2)
2562306a36Sopenharmony_ci#define IEEE80211_CCK_RATE_11MB_MASK		(1<<3)
2662306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_6MB_MASK		(1<<4)
2762306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_9MB_MASK		(1<<5)
2862306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_12MB_MASK		(1<<6)
2962306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_18MB_MASK		(1<<7)
3062306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_24MB_MASK		(1<<8)
3162306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_36MB_MASK		(1<<9)
3262306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_48MB_MASK		(1<<10)
3362306a36Sopenharmony_ci#define IEEE80211_OFDM_RATE_54MB_MASK		(1<<11)
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#define IEEE80211_CCK_RATES_MASK	  0x0000000F
3662306a36Sopenharmony_ci#define IEEE80211_CCK_BASIC_RATES_MASK	 (IEEE80211_CCK_RATE_1MB_MASK | \
3762306a36Sopenharmony_ci	IEEE80211_CCK_RATE_2MB_MASK)
3862306a36Sopenharmony_ci#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
3962306a36Sopenharmony_ci	IEEE80211_CCK_RATE_5MB_MASK | \
4062306a36Sopenharmony_ci	IEEE80211_CCK_RATE_11MB_MASK)
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define IEEE80211_OFDM_RATES_MASK	  0x00000FF0
4362306a36Sopenharmony_ci#define IEEE80211_OFDM_BASIC_RATES_MASK	  (IEEE80211_OFDM_RATE_6MB_MASK | \
4462306a36Sopenharmony_ci	IEEE80211_OFDM_RATE_12MB_MASK | \
4562306a36Sopenharmony_ci	IEEE80211_OFDM_RATE_24MB_MASK)
4662306a36Sopenharmony_ci#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
4762306a36Sopenharmony_ci	IEEE80211_OFDM_RATE_9MB_MASK  | \
4862306a36Sopenharmony_ci	IEEE80211_OFDM_RATE_18MB_MASK | \
4962306a36Sopenharmony_ci	IEEE80211_OFDM_RATE_36MB_MASK | \
5062306a36Sopenharmony_ci	IEEE80211_OFDM_RATE_48MB_MASK | \
5162306a36Sopenharmony_ci	IEEE80211_OFDM_RATE_54MB_MASK)
5262306a36Sopenharmony_ci#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
5362306a36Sopenharmony_ci				      IEEE80211_CCK_DEFAULT_RATES_MASK)
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* This really should be 8, but not for our firmware */
5762306a36Sopenharmony_ci#define MAX_SUPPORTED_RATES 32
5862306a36Sopenharmony_ci#define MAX_COUNTRY_TRIPLETS 32
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci/* Headers */
6162306a36Sopenharmony_cistruct ieee80211_header {
6262306a36Sopenharmony_ci	__le16 frame_ctl;
6362306a36Sopenharmony_ci	__le16 duration_id;
6462306a36Sopenharmony_ci	u8 da[ETH_ALEN];
6562306a36Sopenharmony_ci	u8 sa[ETH_ALEN];
6662306a36Sopenharmony_ci	u8 bssid[ETH_ALEN];
6762306a36Sopenharmony_ci	__le16 seq_ctl;
6862306a36Sopenharmony_ci	u8 payload[];
6962306a36Sopenharmony_ci} __packed;
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_cistruct wl12xx_ie_header {
7262306a36Sopenharmony_ci	u8 id;
7362306a36Sopenharmony_ci	u8 len;
7462306a36Sopenharmony_ci} __packed;
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* IEs */
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_cistruct wl12xx_ie_ssid {
7962306a36Sopenharmony_ci	struct wl12xx_ie_header header;
8062306a36Sopenharmony_ci	char ssid[IEEE80211_MAX_SSID_LEN];
8162306a36Sopenharmony_ci} __packed;
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_cistruct wl12xx_ie_rates {
8462306a36Sopenharmony_ci	struct wl12xx_ie_header header;
8562306a36Sopenharmony_ci	u8 rates[MAX_SUPPORTED_RATES];
8662306a36Sopenharmony_ci} __packed;
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_cistruct wl12xx_ie_ds_params {
8962306a36Sopenharmony_ci	struct wl12xx_ie_header header;
9062306a36Sopenharmony_ci	u8 channel;
9162306a36Sopenharmony_ci} __packed;
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_cistruct country_triplet {
9462306a36Sopenharmony_ci	u8 channel;
9562306a36Sopenharmony_ci	u8 num_channels;
9662306a36Sopenharmony_ci	u8 max_tx_power;
9762306a36Sopenharmony_ci} __packed;
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_cistruct wl12xx_ie_country {
10062306a36Sopenharmony_ci	struct wl12xx_ie_header header;
10162306a36Sopenharmony_ci	u8 country_string[IEEE80211_COUNTRY_STRING_LEN];
10262306a36Sopenharmony_ci	struct country_triplet triplets[MAX_COUNTRY_TRIPLETS];
10362306a36Sopenharmony_ci} __packed;
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci/* Templates */
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_cistruct wl12xx_beacon_template {
10962306a36Sopenharmony_ci	struct ieee80211_header header;
11062306a36Sopenharmony_ci	__le32 time_stamp[2];
11162306a36Sopenharmony_ci	__le16 beacon_interval;
11262306a36Sopenharmony_ci	__le16 capability;
11362306a36Sopenharmony_ci	struct wl12xx_ie_ssid ssid;
11462306a36Sopenharmony_ci	struct wl12xx_ie_rates rates;
11562306a36Sopenharmony_ci	struct wl12xx_ie_rates ext_rates;
11662306a36Sopenharmony_ci	struct wl12xx_ie_ds_params ds_params;
11762306a36Sopenharmony_ci	struct wl12xx_ie_country country;
11862306a36Sopenharmony_ci} __packed;
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_cistruct wl12xx_null_data_template {
12162306a36Sopenharmony_ci	struct ieee80211_header header;
12262306a36Sopenharmony_ci} __packed;
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_cistruct wl12xx_ps_poll_template {
12562306a36Sopenharmony_ci	__le16 fc;
12662306a36Sopenharmony_ci	__le16 aid;
12762306a36Sopenharmony_ci	u8 bssid[ETH_ALEN];
12862306a36Sopenharmony_ci	u8 ta[ETH_ALEN];
12962306a36Sopenharmony_ci} __packed;
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_cistruct wl12xx_qos_null_data_template {
13262306a36Sopenharmony_ci	struct ieee80211_header header;
13362306a36Sopenharmony_ci	__le16 qos_ctl;
13462306a36Sopenharmony_ci} __packed;
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_cistruct wl12xx_probe_req_template {
13762306a36Sopenharmony_ci	struct ieee80211_header header;
13862306a36Sopenharmony_ci	struct wl12xx_ie_ssid ssid;
13962306a36Sopenharmony_ci	struct wl12xx_ie_rates rates;
14062306a36Sopenharmony_ci	struct wl12xx_ie_rates ext_rates;
14162306a36Sopenharmony_ci} __packed;
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_cistruct wl12xx_probe_resp_template {
14562306a36Sopenharmony_ci	struct ieee80211_header header;
14662306a36Sopenharmony_ci	__le32 time_stamp[2];
14762306a36Sopenharmony_ci	__le16 beacon_interval;
14862306a36Sopenharmony_ci	__le16 capability;
14962306a36Sopenharmony_ci	struct wl12xx_ie_ssid ssid;
15062306a36Sopenharmony_ci	struct wl12xx_ie_rates rates;
15162306a36Sopenharmony_ci	struct wl12xx_ie_rates ext_rates;
15262306a36Sopenharmony_ci	struct wl12xx_ie_ds_params ds_params;
15362306a36Sopenharmony_ci	struct wl12xx_ie_country country;
15462306a36Sopenharmony_ci} __packed;
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci#endif
157