Path: blob/main/sys/contrib/dev/iwlwifi/iwl-nvm-utils.c
107265 views
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause1/*2* Copyright (C) 2005-2014, 2018-2021, 2023, 2025 Intel Corporation3* Copyright (C) 2015 Intel Mobile Communications GmbH4*/5#include <linux/types.h>6#include <linux/slab.h>7#include <linux/export.h>8#include "iwl-drv.h"9#include "iwl-modparams.h"10#include "iwl-nvm-utils.h"1112int iwl_init_sband_channels(struct iwl_nvm_data *data,13struct ieee80211_supported_band *sband,14int n_channels, enum nl80211_band band)15{16struct ieee80211_channel *chan = &data->channels[0];17int n = 0, idx = 0;1819while (idx < n_channels && chan->band != band)20chan = &data->channels[++idx];2122sband->channels = &data->channels[idx];2324while (idx < n_channels && chan->band == band) {25chan = &data->channels[++idx];26n++;27}2829sband->n_channels = n;3031return n;32}33IWL_EXPORT_SYMBOL(iwl_init_sband_channels);3435#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */36#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */3738void iwl_init_ht_hw_capab(struct iwl_trans *trans,39struct iwl_nvm_data *data,40struct ieee80211_sta_ht_cap *ht_info,41enum nl80211_band band,42u8 tx_chains, u8 rx_chains)43{44const struct iwl_rf_cfg *cfg = trans->cfg;45int max_bit_rate = 0;4647tx_chains = hweight8(tx_chains);48if (cfg->rx_with_siso_diversity)49rx_chains = 1;50else51rx_chains = hweight8(rx_chains);5253if (!(data->sku_cap_11n_enable) ||54(iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_ALL) ||55/* there are no devices with HT but without HT40 entirely */56!cfg->ht_params.ht40_bands) {57ht_info->ht_supported = false;58return;59}6061if (data->sku_cap_mimo_disabled)62rx_chains = 1;6364ht_info->ht_supported = true;65ht_info->cap = IEEE80211_HT_CAP_DSSSCCK40;6667if (cfg->ht_params.stbc) {68ht_info->cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);6970if (tx_chains > 1)71ht_info->cap |= IEEE80211_HT_CAP_TX_STBC;72}7374if (cfg->ht_params.ldpc)75ht_info->cap |= IEEE80211_HT_CAP_LDPC_CODING;7677if (trans->mac_cfg->mq_rx_supported ||78iwlwifi_mod_params.amsdu_size >= IWL_AMSDU_8K)79ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU;8081ht_info->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;82ht_info->ampdu_density = IEEE80211_HT_MPDU_DENSITY_4;8384ht_info->mcs.rx_mask[0] = 0xFF;85ht_info->mcs.rx_mask[1] = 0x00;86ht_info->mcs.rx_mask[2] = 0x00;8788if (rx_chains >= 2)89ht_info->mcs.rx_mask[1] = 0xFF;90if (rx_chains >= 3)91ht_info->mcs.rx_mask[2] = 0xFF;9293if (cfg->ht_params.ht_greenfield_support)94ht_info->cap |= IEEE80211_HT_CAP_GRN_FLD;95ht_info->cap |= IEEE80211_HT_CAP_SGI_20;9697max_bit_rate = MAX_BIT_RATE_20_MHZ;9899if (cfg->ht_params.ht40_bands & BIT(band)) {100ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;101ht_info->cap |= IEEE80211_HT_CAP_SGI_40;102max_bit_rate = MAX_BIT_RATE_40_MHZ;103}104105/* Highest supported Rx data rate */106max_bit_rate *= rx_chains;107WARN_ON(max_bit_rate & ~IEEE80211_HT_MCS_RX_HIGHEST_MASK);108ht_info->mcs.rx_highest = cpu_to_le16(max_bit_rate);109110/* Tx MCS capabilities */111ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;112if (tx_chains != rx_chains) {113ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF;114ht_info->mcs.tx_params |= ((tx_chains - 1) <<115IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);116}117}118IWL_EXPORT_SYMBOL(iwl_init_ht_hw_capab);119120121