band.h (3613B)
1 /* 2 * 3 * Wireless daemon for Linux 4 * 5 * Copyright (C) 2021 Intel Corporation. All rights reserved. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 * 21 */ 22 23 enum ofdm_channel_width { 24 OFDM_CHANNEL_WIDTH_20MHZ = 0, 25 OFDM_CHANNEL_WIDTH_40MHZ, 26 OFDM_CHANNEL_WIDTH_80MHZ, 27 OFDM_CHANNEL_WIDTH_160MHZ, 28 }; 29 30 enum band_chandef_width { 31 BAND_CHANDEF_WIDTH_20NOHT = 0, 32 BAND_CHANDEF_WIDTH_20, 33 BAND_CHANDEF_WIDTH_40, 34 BAND_CHANDEF_WIDTH_80, 35 BAND_CHANDEF_WIDTH_80P80, 36 BAND_CHANDEF_WIDTH_160, 37 }; 38 39 enum band_freq { 40 BAND_FREQ_2_4_GHZ = 0x1, 41 BAND_FREQ_5_GHZ = 0x2, 42 BAND_FREQ_6_GHZ = 0x4, 43 }; 44 45 struct band_chandef { 46 uint32_t frequency; 47 uint32_t channel_width; 48 uint32_t center1_frequency; 49 uint32_t center2_frequency; 50 }; 51 52 struct band_he_capabilities { 53 uint32_t iftypes; 54 uint8_t he_phy_capa[11]; 55 uint8_t he_mcs_set[12]; 56 }; 57 58 struct band_freq_attrs { 59 uint8_t tx_power; 60 bool supported : 1; 61 bool disabled : 1; 62 bool no_ir : 1; 63 bool no_ht40_plus : 1; 64 bool no_ht40_minus : 1; 65 bool no_80mhz : 1; 66 bool no_160mhz : 1; 67 bool no_he : 1; 68 } __attribute__ ((packed)); 69 70 struct band { 71 enum band_freq freq; 72 struct band_freq_attrs *freq_attrs; 73 size_t freqs_len; 74 /* Each entry is type struct band_he_capabilities */ 75 struct l_queue *he_capabilities; 76 uint8_t vht_mcs_set[8]; 77 uint8_t vht_capabilities[4]; 78 bool vht_supported : 1; 79 uint8_t ht_mcs_set[16]; 80 uint8_t ht_capabilities[2]; 81 uint8_t ht_ampdu_params; 82 bool ht_supported : 1; 83 uint16_t supported_rates_len; 84 uint8_t supported_rates[]; 85 }; 86 87 void band_free(struct band *band); 88 89 bool band_ofdm_rate(uint8_t index, enum ofdm_channel_width width, 90 int32_t rssi, uint8_t nss, bool sgi, 91 uint64_t *data_rate); 92 int band_estimate_he_rx_rate(const struct band *band, const uint8_t *hec, 93 int32_t rssi, uint64_t *out_dat_rate); 94 int band_estimate_vht_rx_rate(const struct band *band, 95 const uint8_t *vhtc, const uint8_t *vhto, 96 const uint8_t *htc, const uint8_t *hto, 97 int32_t rssi, uint64_t *out_data_rate); 98 int band_estimate_ht_rx_rate(const struct band *band, 99 const uint8_t *htc, const uint8_t *hto, 100 int32_t rssi, uint64_t *out_data_rate); 101 int band_estimate_nonht_rate(const struct band *band, 102 const uint8_t *supported_rates, 103 const uint8_t *ext_supported_rates, 104 int32_t rssi, uint64_t *out_data_rate); 105 int band_freq_to_ht_chandef(uint32_t freq, const struct band_freq_attrs *attr, 106 struct band_chandef *chandef); 107 108 int oci_to_frequency(uint32_t operating_class, uint32_t channel); 109 110 int oci_verify(const uint8_t oci[static 3], const struct band_chandef *own); 111 int oci_from_chandef(const struct band_chandef *own, uint8_t oci[static 3]); 112 113 uint8_t band_freq_to_channel(uint32_t freq, enum band_freq *out_band); 114 uint32_t band_channel_to_freq(uint8_t channel, enum band_freq band); 115 enum band_freq band_oper_class_to_band(const uint8_t *country, 116 uint8_t oper_class); 117 const char *band_chandef_width_to_string(enum band_chandef_width width);