Path: blob/main/sys/contrib/dev/iwlwifi/mvm/rfi.c
107936 views
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause1/*2* Copyright (C) 2020 - 2022 Intel Corporation3*/45#include "mvm.h"6#include "fw/api/commands.h"7#include "fw/api/phy-ctxt.h"89/*10* DDR needs frequency in units of 16.666MHz, so provide FW with the11* frequency values in the adjusted format.12*/13static const struct iwl_rfi_lut_entry iwl_rfi_table[IWL_RFI_LUT_SIZE] = {14/* frequency 2667MHz */15{cpu_to_le16(160), {50, 58, 60, 62, 64, 52, 54, 56},16{PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,17PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,}},1819/* frequency 2933MHz */20{cpu_to_le16(176), {149, 151, 153, 157, 159, 161, 165, 163, 167, 169,21171, 173, 175},22{PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,23PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,24PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,}},2526/* frequency 3200MHz */27{cpu_to_le16(192), {79, 81, 83, 85, 87, 89, 91, 93},28{PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,29PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,}},3031/* frequency 3733MHz */32{cpu_to_le16(223), {114, 116, 118, 120, 122, 106, 110, 124, 126},33{PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,34PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,}},3536/* frequency 4000MHz */37{cpu_to_le16(240), {114, 151, 155, 157, 159, 161, 165},38{PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,39PHY_BAND_5, PHY_BAND_5,}},4041/* frequency 4267MHz */42{cpu_to_le16(256), {79, 83, 85, 87, 89, 91, 93,},43{PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,44PHY_BAND_6, PHY_BAND_6,}},4546/* frequency 4400MHz */47{cpu_to_le16(264), {111, 119, 123, 125, 129, 131, 133, 135, 143,},48{PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,49PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,}},5051/* frequency 5200MHz */52{cpu_to_le16(312), {36, 38, 40, 42, 44, 46, 50,},53{PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,54PHY_BAND_5, PHY_BAND_5,}},5556/* frequency 5600MHz */57{cpu_to_le16(336), {106, 110, 112, 114, 116, 118, 120, 122},58{PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,59PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,}},6061/* frequency 6000MHz */62{cpu_to_le16(360), {3, 5, 7, 9, 11, 13, 15,},63{PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,64PHY_BAND_6, PHY_BAND_6,}},6566/* frequency 6400MHz */67{cpu_to_le16(384), {79, 83, 85, 87, 89, 91, 93,},68{PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,69PHY_BAND_6, PHY_BAND_6,}},70};7172bool iwl_rfi_supported(struct iwl_mvm *mvm)73{74/* The feature depends on a platform bugfix, so for now75* it's always disabled.76* When the platform support detection is implemented we should77* check FW TLV and platform support instead.78*/79return false;80}8182int iwl_rfi_send_config_cmd(struct iwl_mvm *mvm, struct iwl_rfi_lut_entry *rfi_table)83{84int ret;85struct iwl_rfi_config_cmd cmd;86struct iwl_host_cmd hcmd = {87.id = WIDE_ID(SYSTEM_GROUP, RFI_CONFIG_CMD),88.dataflags[0] = IWL_HCMD_DFL_DUP,89.data[0] = &cmd,90.len[0] = sizeof(cmd),91};9293if (!iwl_rfi_supported(mvm))94return -EOPNOTSUPP;9596lockdep_assert_held(&mvm->mutex);9798/* in case no table is passed, use the default one */99if (!rfi_table) {100memcpy(cmd.table, iwl_rfi_table, sizeof(cmd.table));101} else {102memcpy(cmd.table, rfi_table, sizeof(cmd.table));103/* notify FW the table is not the default one */104cmd.oem = 1;105}106107ret = iwl_mvm_send_cmd(mvm, &hcmd);108109if (ret)110IWL_ERR(mvm, "Failed to send RFI config cmd %d\n", ret);111112return ret;113}114115struct iwl_rfi_freq_table_resp_cmd *iwl_rfi_get_freq_table(struct iwl_mvm *mvm)116{117struct iwl_rfi_freq_table_resp_cmd *resp;118int resp_size = sizeof(*resp);119int ret;120struct iwl_host_cmd cmd = {121.id = WIDE_ID(SYSTEM_GROUP, RFI_GET_FREQ_TABLE_CMD),122.flags = CMD_WANT_SKB,123};124125if (!iwl_rfi_supported(mvm))126return ERR_PTR(-EOPNOTSUPP);127128mutex_lock(&mvm->mutex);129ret = iwl_mvm_send_cmd(mvm, &cmd);130mutex_unlock(&mvm->mutex);131if (ret)132return ERR_PTR(ret);133134if (WARN_ON_ONCE(iwl_rx_packet_payload_len(cmd.resp_pkt) !=135resp_size)) {136iwl_free_resp(&cmd);137return ERR_PTR(-EIO);138}139140resp = kmemdup(cmd.resp_pkt->data, resp_size, GFP_KERNEL);141iwl_free_resp(&cmd);142143if (!resp)144return ERR_PTR(-ENOMEM);145146return resp;147}148149void iwl_rfi_deactivate_notif_handler(struct iwl_mvm *mvm,150struct iwl_rx_cmd_buffer *rxb)151{152struct iwl_rx_packet *pkt = rxb_addr(rxb);153struct iwl_rfi_deactivate_notif *notif = (void *)pkt->data;154155IWL_INFO(mvm, "RFIm is deactivated, reason = %d\n", notif->reason);156}157158159