2021-06-02 17:50:08 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Wireless daemon for Linux
|
|
|
|
*
|
|
|
|
* Copyright (C) 2021 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-06-02 17:58:38 +02:00
|
|
|
enum ofdm_channel_width {
|
|
|
|
OFDM_CHANNEL_WIDTH_20MHZ = 0,
|
|
|
|
OFDM_CHANNEL_WIDTH_40MHZ,
|
|
|
|
OFDM_CHANNEL_WIDTH_80MHZ,
|
|
|
|
OFDM_CHANNEL_WIDTH_160MHZ,
|
|
|
|
};
|
|
|
|
|
2021-09-18 21:19:41 +02:00
|
|
|
enum band_chandef_width {
|
|
|
|
BAND_CHANDEF_WIDTH_20NOHT = 0,
|
|
|
|
BAND_CHANDEF_WIDTH_20,
|
|
|
|
BAND_CHANDEF_WIDTH_40,
|
|
|
|
BAND_CHANDEF_WIDTH_80,
|
|
|
|
BAND_CHANDEF_WIDTH_80P80,
|
|
|
|
BAND_CHANDEF_WIDTH_160,
|
|
|
|
};
|
|
|
|
|
2021-11-30 00:12:58 +01:00
|
|
|
enum band_freq {
|
|
|
|
BAND_FREQ_2_4_GHZ = 0x1,
|
|
|
|
BAND_FREQ_5_GHZ = 0x2,
|
2022-02-25 18:58:02 +01:00
|
|
|
BAND_FREQ_6_GHZ = 0x4,
|
2021-11-30 00:12:58 +01:00
|
|
|
};
|
|
|
|
|
2021-09-18 21:19:41 +02:00
|
|
|
struct band_chandef {
|
|
|
|
uint32_t frequency;
|
|
|
|
uint32_t channel_width;
|
|
|
|
uint32_t center1_frequency;
|
|
|
|
uint32_t center2_frequency;
|
|
|
|
};
|
|
|
|
|
2022-07-19 20:55:36 +02:00
|
|
|
struct band_he_capabilities {
|
|
|
|
uint32_t iftypes;
|
|
|
|
uint8_t he_phy_capa[11];
|
|
|
|
uint8_t he_mcs_set[12];
|
|
|
|
};
|
|
|
|
|
2022-12-16 22:27:34 +01:00
|
|
|
struct band_freq_attrs {
|
2022-12-30 23:12:14 +01:00
|
|
|
uint8_t tx_power;
|
2022-12-16 22:27:34 +01:00
|
|
|
bool supported : 1;
|
|
|
|
bool disabled : 1;
|
|
|
|
bool no_ir : 1;
|
2022-12-20 22:43:10 +01:00
|
|
|
bool no_ht40_plus : 1;
|
|
|
|
bool no_ht40_minus : 1;
|
|
|
|
bool no_80mhz : 1;
|
|
|
|
bool no_160mhz : 1;
|
|
|
|
bool no_he : 1;
|
2022-12-16 22:27:34 +01:00
|
|
|
} __attribute__ ((packed));
|
|
|
|
|
2021-06-02 17:50:08 +02:00
|
|
|
struct band {
|
2022-07-19 20:55:35 +02:00
|
|
|
enum band_freq freq;
|
2022-12-16 22:27:34 +01:00
|
|
|
struct band_freq_attrs *freq_attrs;
|
|
|
|
size_t freqs_len;
|
2022-07-19 20:55:36 +02:00
|
|
|
/* Each entry is type struct band_he_capabilities */
|
|
|
|
struct l_queue *he_capabilities;
|
2021-06-02 17:50:08 +02:00
|
|
|
uint8_t vht_mcs_set[8];
|
|
|
|
uint8_t vht_capabilities[4];
|
|
|
|
bool vht_supported : 1;
|
|
|
|
uint8_t ht_mcs_set[16];
|
|
|
|
uint8_t ht_capabilities[2];
|
2022-12-20 22:43:11 +01:00
|
|
|
uint8_t ht_ampdu_params;
|
2021-06-02 17:50:08 +02:00
|
|
|
bool ht_supported : 1;
|
|
|
|
uint16_t supported_rates_len;
|
|
|
|
uint8_t supported_rates[];
|
|
|
|
};
|
|
|
|
|
|
|
|
void band_free(struct band *band);
|
2021-06-02 17:58:38 +02:00
|
|
|
|
|
|
|
bool band_ofdm_rate(uint8_t index, enum ofdm_channel_width width,
|
|
|
|
int32_t rssi, uint8_t nss, bool sgi,
|
|
|
|
uint64_t *data_rate);
|
2022-07-21 00:15:04 +02:00
|
|
|
int band_estimate_he_rx_rate(const struct band *band, const uint8_t *hec,
|
|
|
|
int32_t rssi, uint64_t *out_dat_rate);
|
2021-06-02 22:41:42 +02:00
|
|
|
int band_estimate_vht_rx_rate(const struct band *band,
|
|
|
|
const uint8_t *vhtc, const uint8_t *vhto,
|
|
|
|
const uint8_t *htc, const uint8_t *hto,
|
|
|
|
int32_t rssi, uint64_t *out_data_rate);
|
2021-06-03 22:35:23 +02:00
|
|
|
int band_estimate_ht_rx_rate(const struct band *band,
|
|
|
|
const uint8_t *htc, const uint8_t *hto,
|
|
|
|
int32_t rssi, uint64_t *out_data_rate);
|
2021-06-04 04:56:04 +02:00
|
|
|
int band_estimate_nonht_rate(const struct band *band,
|
|
|
|
const uint8_t *supported_rates,
|
|
|
|
const uint8_t *ext_supported_rates,
|
|
|
|
int32_t rssi, uint64_t *out_data_rate);
|
2022-12-28 23:32:28 +01:00
|
|
|
int band_freq_to_ht_chandef(uint32_t freq, const struct band_freq_attrs *attr,
|
|
|
|
struct band_chandef *chandef);
|
2021-09-15 19:55:55 +02:00
|
|
|
|
|
|
|
int oci_to_frequency(uint32_t operating_class, uint32_t channel);
|
2021-09-21 21:19:18 +02:00
|
|
|
|
|
|
|
int oci_verify(const uint8_t oci[static 3], const struct band_chandef *own);
|
2021-09-23 18:52:32 +02:00
|
|
|
int oci_from_chandef(const struct band_chandef *own, uint8_t oci[static 3]);
|
2021-11-30 00:12:58 +01:00
|
|
|
|
|
|
|
uint8_t band_freq_to_channel(uint32_t freq, enum band_freq *out_band);
|
|
|
|
uint32_t band_channel_to_freq(uint8_t channel, enum band_freq band);
|
|
|
|
enum band_freq band_oper_class_to_band(const uint8_t *country,
|
|
|
|
uint8_t oper_class);
|
2022-12-20 22:43:14 +01:00
|
|
|
const char *band_chandef_width_to_string(enum band_chandef_width width);
|