mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-09-08 07:16:26 +00:00

iwlwifi is the driver of all Intel wifi devices since 2008. Since then, the hardware has changed a lot, but the firmware API has changed even more. The need to keep one driver that supports all those different APIs led us to introduce a new architecture circa 2012 which allowed us to keep the same interface to the hardware (DMAs, Tx queues, etc...) with a new layer to implement the mid-layer between mac80211 and the firmware. The first component is called the 'transport' and the latter is called 'operation_mode' a.k.a op_mode. In 2013 we took advantage of the new architecture to introduce iwlmvm which allowed us to implement the, then, new firmware API. This op_mode supports 7260 and up, those devices supports support at least VHT. Since then, wifi evolved and so did the firmware. It became much bigger and took a lot of functionality from the driver. It became increasingly hard to keep the same op_mode for the newest devices and we experienced frequent regressions on older devices. In order to avoid those regressions and keep the code maintainable, we decided it was about time to start a new op_mode. iwlmld is a new op_mode that supports BE200 or newer if the firmware being used is 97.ucode or newer. If the user has an older devices or BE200 with .96.ucode, iwlmvm will be loaded. Of course, this op_mode selection is seamless. All the features supported in iwlmvm are supported in iwlmld besides a few seldom used use cases: injection and Hotspot 2.0. Those are under work. A few points about the implementation: * iwlmld doesn't have any mutexes, it relies on the wiphy_lock * iwlmld is more "resource oriented": stations, links and interfaces are allocated and freed only after all the relevant flows are completed. * Firmware notifications' sizes are validated in a more structured way. We would love to see this new op_mode merged in 6.15. The firmware for this new driver (.97.ucode) is not yet publicly available but it'll be sent very soon. People eager to get an early version of this firmware can contact Emmanuel at: emmanuel.grumbach@intel.com I've listed the people who directly contributed code, but many others from various teams have contributed in other ways. Co-developed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Co-developed-by: Avraham Stern <avraham.stern@intel.com> Signed-off-by: Avraham Stern <avraham.stern@intel.com> Co-developed-by: Daniel Gabay <daniel.gabay@intel.com> Signed-off-by: Daniel Gabay <daniel.gabay@intel.com> Co-developed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Co-developed-by: Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com> Signed-off-by: Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com> Co-developed-by: Yedidya Benshimol <yedidya.ben.shimol@intel.com> Signed-off-by: Yedidya Benshimol <yedidya.ben.shimol@intel.com> Co-developed-by: Benjamin Berg <benjamin.berg@intel.com> Signed-off-by: Benjamin Berg <benjamin.berg@intel.com> Co-developed-by: Shaul Triebitz <shaul.triebitz@intel.com> Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://lore.kernel.org/linux-wireless/20250216094321.537988-1-miriam.rachel.korenblit@intel.com/ [fix Kconfig, fix api/phy.h includes, SPDX tag and coding style issues, duplicated includes per 0-day robot] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
354 lines
8.0 KiB
C
354 lines
8.0 KiB
C
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
|
/*
|
|
* KUnit tests for channel helper functions
|
|
*
|
|
* Copyright (C) 2024 Intel Corporation
|
|
*/
|
|
#include <kunit/test.h>
|
|
#include "utils.h"
|
|
#include "iwl-trans.h"
|
|
#include "mld.h"
|
|
#include "sta.h"
|
|
|
|
static const struct is_dup_case {
|
|
const char *desc;
|
|
struct {
|
|
/* ieee80211_hdr fields */
|
|
__le16 fc;
|
|
__le16 seq;
|
|
u8 tid;
|
|
bool multicast;
|
|
/* iwl_rx_mpdu_desc fields */
|
|
bool is_amsdu;
|
|
u8 sub_frame_idx;
|
|
} rx_pkt;
|
|
struct {
|
|
__le16 last_seq;
|
|
u8 last_sub_frame_idx;
|
|
u8 tid;
|
|
} dup_data_state;
|
|
struct {
|
|
bool is_dup;
|
|
u32 rx_status_flag;
|
|
} result;
|
|
} is_dup_cases[] = {
|
|
{
|
|
.desc = "Control frame",
|
|
.rx_pkt = {
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_CTL),
|
|
},
|
|
.result = {
|
|
.is_dup = false,
|
|
.rx_status_flag = 0,
|
|
}
|
|
},
|
|
{
|
|
.desc = "Null func frame",
|
|
.rx_pkt = {
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA |
|
|
IEEE80211_STYPE_NULLFUNC),
|
|
},
|
|
.result = {
|
|
.is_dup = false,
|
|
.rx_status_flag = 0,
|
|
}
|
|
},
|
|
{
|
|
.desc = "Multicast data",
|
|
.rx_pkt = {
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA),
|
|
.multicast = true,
|
|
},
|
|
.result = {
|
|
.is_dup = false,
|
|
.rx_status_flag = 0,
|
|
}
|
|
},
|
|
{
|
|
.desc = "QoS null func frame",
|
|
.rx_pkt = {
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA |
|
|
IEEE80211_STYPE_QOS_NULLFUNC),
|
|
},
|
|
.result = {
|
|
.is_dup = false,
|
|
.rx_status_flag = 0,
|
|
}
|
|
},
|
|
{
|
|
.desc = "QoS data new sequence",
|
|
.rx_pkt = {
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA |
|
|
IEEE80211_STYPE_QOS_DATA),
|
|
.seq = __cpu_to_le16(0x101),
|
|
},
|
|
.dup_data_state = {
|
|
.last_seq = __cpu_to_le16(0x100),
|
|
.last_sub_frame_idx = 0,
|
|
},
|
|
.result = {
|
|
.is_dup = false,
|
|
.rx_status_flag = RX_FLAG_DUP_VALIDATED,
|
|
},
|
|
},
|
|
{
|
|
.desc = "QoS data same sequence, no retry",
|
|
.rx_pkt = {
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA |
|
|
IEEE80211_STYPE_QOS_DATA),
|
|
.seq = __cpu_to_le16(0x100),
|
|
},
|
|
.dup_data_state = {
|
|
.last_seq = __cpu_to_le16(0x100),
|
|
.last_sub_frame_idx = 0,
|
|
},
|
|
.result = {
|
|
.is_dup = false,
|
|
.rx_status_flag = RX_FLAG_DUP_VALIDATED,
|
|
},
|
|
},
|
|
{
|
|
.desc = "QoS data same sequence, has retry",
|
|
.rx_pkt = {
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA |
|
|
IEEE80211_STYPE_QOS_DATA |
|
|
IEEE80211_FCTL_RETRY),
|
|
.seq = __cpu_to_le16(0x100),
|
|
},
|
|
.dup_data_state = {
|
|
.last_seq = __cpu_to_le16(0x100),
|
|
.last_sub_frame_idx = 0,
|
|
},
|
|
.result = {
|
|
.is_dup = true,
|
|
.rx_status_flag = 0,
|
|
},
|
|
},
|
|
{
|
|
.desc = "QoS data invalid tid",
|
|
.rx_pkt = {
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA |
|
|
IEEE80211_STYPE_QOS_DATA),
|
|
.seq = __cpu_to_le16(0x100),
|
|
.tid = IWL_MAX_TID_COUNT + 1,
|
|
},
|
|
.result = {
|
|
.is_dup = true,
|
|
.rx_status_flag = 0,
|
|
},
|
|
},
|
|
{
|
|
.desc = "non-QoS data, same sequence, same tid, no retry",
|
|
.rx_pkt = {
|
|
/* Driver will use tid = IWL_MAX_TID_COUNT */
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA),
|
|
.seq = __cpu_to_le16(0x100),
|
|
},
|
|
.dup_data_state = {
|
|
.tid = IWL_MAX_TID_COUNT,
|
|
.last_seq = __cpu_to_le16(0x100),
|
|
.last_sub_frame_idx = 0,
|
|
},
|
|
.result = {
|
|
.is_dup = false,
|
|
.rx_status_flag = RX_FLAG_DUP_VALIDATED,
|
|
},
|
|
},
|
|
{
|
|
.desc = "non-QoS data, same sequence, same tid, has retry",
|
|
.rx_pkt = {
|
|
/* Driver will use tid = IWL_MAX_TID_COUNT */
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA |
|
|
IEEE80211_FCTL_RETRY),
|
|
.seq = __cpu_to_le16(0x100),
|
|
},
|
|
.dup_data_state = {
|
|
.tid = IWL_MAX_TID_COUNT,
|
|
.last_seq = __cpu_to_le16(0x100),
|
|
.last_sub_frame_idx = 0,
|
|
},
|
|
.result = {
|
|
.is_dup = true,
|
|
.rx_status_flag = 0,
|
|
},
|
|
},
|
|
{
|
|
.desc = "non-QoS data, same sequence on different tid's",
|
|
.rx_pkt = {
|
|
/* Driver will use tid = IWL_MAX_TID_COUNT */
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA),
|
|
.seq = __cpu_to_le16(0x100),
|
|
},
|
|
.dup_data_state = {
|
|
.tid = 7,
|
|
.last_seq = __cpu_to_le16(0x100),
|
|
.last_sub_frame_idx = 0,
|
|
},
|
|
.result = {
|
|
.is_dup = false,
|
|
.rx_status_flag = RX_FLAG_DUP_VALIDATED,
|
|
},
|
|
},
|
|
{
|
|
.desc = "A-MSDU new subframe, allow same PN",
|
|
.rx_pkt = {
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA |
|
|
IEEE80211_STYPE_QOS_DATA),
|
|
.seq = __cpu_to_le16(0x100),
|
|
.is_amsdu = true,
|
|
.sub_frame_idx = 1,
|
|
},
|
|
.dup_data_state = {
|
|
.last_seq = __cpu_to_le16(0x100),
|
|
.last_sub_frame_idx = 0,
|
|
},
|
|
.result = {
|
|
.is_dup = false,
|
|
.rx_status_flag = RX_FLAG_ALLOW_SAME_PN |
|
|
RX_FLAG_DUP_VALIDATED,
|
|
},
|
|
},
|
|
{
|
|
.desc = "A-MSDU subframe with smaller idx, disallow same PN",
|
|
.rx_pkt = {
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA |
|
|
IEEE80211_STYPE_QOS_DATA),
|
|
.seq = __cpu_to_le16(0x100),
|
|
.is_amsdu = true,
|
|
.sub_frame_idx = 1,
|
|
},
|
|
.dup_data_state = {
|
|
.last_seq = __cpu_to_le16(0x100),
|
|
.last_sub_frame_idx = 2,
|
|
},
|
|
.result = {
|
|
.is_dup = false,
|
|
.rx_status_flag = RX_FLAG_DUP_VALIDATED,
|
|
},
|
|
},
|
|
{
|
|
.desc = "A-MSDU same subframe, no retry, disallow same PN",
|
|
.rx_pkt = {
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA |
|
|
IEEE80211_STYPE_QOS_DATA),
|
|
.seq = __cpu_to_le16(0x100),
|
|
.is_amsdu = true,
|
|
.sub_frame_idx = 0,
|
|
},
|
|
.dup_data_state = {
|
|
.last_seq = __cpu_to_le16(0x100),
|
|
.last_sub_frame_idx = 0,
|
|
},
|
|
.result = {
|
|
.is_dup = false,
|
|
.rx_status_flag = RX_FLAG_DUP_VALIDATED,
|
|
},
|
|
},
|
|
{
|
|
.desc = "A-MSDU same subframe, has retry",
|
|
.rx_pkt = {
|
|
.fc = __cpu_to_le16(IEEE80211_FTYPE_DATA |
|
|
IEEE80211_STYPE_QOS_DATA |
|
|
IEEE80211_FCTL_RETRY),
|
|
.seq = __cpu_to_le16(0x100),
|
|
.is_amsdu = true,
|
|
.sub_frame_idx = 0,
|
|
},
|
|
.dup_data_state = {
|
|
.last_seq = __cpu_to_le16(0x100),
|
|
.last_sub_frame_idx = 0,
|
|
},
|
|
.result = {
|
|
.is_dup = true,
|
|
.rx_status_flag = 0,
|
|
},
|
|
},
|
|
};
|
|
|
|
KUNIT_ARRAY_PARAM_DESC(test_is_dup, is_dup_cases, desc);
|
|
|
|
static void
|
|
setup_dup_data_state(struct ieee80211_sta *sta)
|
|
{
|
|
struct kunit *test = kunit_get_current_test();
|
|
const struct is_dup_case *param = (const void *)(test->param_value);
|
|
struct iwl_mld_sta *mld_sta = iwl_mld_sta_from_mac80211(sta);
|
|
u8 tid = param->dup_data_state.tid;
|
|
struct iwl_mld_rxq_dup_data *dup_data;
|
|
|
|
/* Allocate dup_data only for 1 queue */
|
|
KUNIT_ALLOC_AND_ASSERT(test, dup_data);
|
|
|
|
/* Initialize dup data, see iwl_mld_alloc_dup_data */
|
|
memset(dup_data->last_seq, 0xff, sizeof(dup_data->last_seq));
|
|
|
|
dup_data->last_seq[tid] = param->dup_data_state.last_seq;
|
|
dup_data->last_sub_frame_idx[tid] =
|
|
param->dup_data_state.last_sub_frame_idx;
|
|
|
|
mld_sta->dup_data = dup_data;
|
|
}
|
|
|
|
static void setup_rx_pkt(const struct is_dup_case *param,
|
|
struct ieee80211_hdr *hdr,
|
|
struct iwl_rx_mpdu_desc *mpdu_desc)
|
|
{
|
|
u8 tid = param->rx_pkt.tid;
|
|
|
|
/* Set "new rx packet" header */
|
|
hdr->frame_control = param->rx_pkt.fc;
|
|
hdr->seq_ctrl = param->rx_pkt.seq;
|
|
|
|
if (ieee80211_is_data_qos(hdr->frame_control)) {
|
|
u8 *qc = ieee80211_get_qos_ctl(hdr);
|
|
|
|
qc[0] = tid & IEEE80211_QOS_CTL_TID_MASK;
|
|
}
|
|
|
|
if (param->rx_pkt.multicast)
|
|
hdr->addr1[0] = 0x1;
|
|
|
|
/* Set mpdu_desc */
|
|
mpdu_desc->amsdu_info = param->rx_pkt.sub_frame_idx &
|
|
IWL_RX_MPDU_AMSDU_SUBFRAME_IDX_MASK;
|
|
if (param->rx_pkt.is_amsdu)
|
|
mpdu_desc->mac_flags2 |= IWL_RX_MPDU_MFLG2_AMSDU;
|
|
}
|
|
|
|
static void test_is_dup(struct kunit *test)
|
|
{
|
|
const struct is_dup_case *param = (const void *)(test->param_value);
|
|
struct iwl_mld *mld = test->priv;
|
|
struct iwl_rx_mpdu_desc mpdu_desc = { };
|
|
struct ieee80211_rx_status rx_status = { };
|
|
struct ieee80211_vif *vif;
|
|
struct ieee80211_sta *sta;
|
|
struct ieee80211_hdr hdr;
|
|
|
|
vif = iwlmld_kunit_add_vif(false, NL80211_IFTYPE_STATION);
|
|
sta = iwlmld_kunit_setup_sta(vif, IEEE80211_STA_AUTHORIZED, -1);
|
|
|
|
/* Prepare test case state */
|
|
setup_dup_data_state(sta);
|
|
setup_rx_pkt(param, &hdr, &mpdu_desc);
|
|
|
|
KUNIT_EXPECT_EQ(test,
|
|
iwl_mld_is_dup(mld, sta, &hdr, &mpdu_desc, &rx_status,
|
|
0), /* assuming only 1 queue */
|
|
param->result.is_dup);
|
|
KUNIT_EXPECT_EQ(test, rx_status.flag, param->result.rx_status_flag);
|
|
}
|
|
|
|
static struct kunit_case is_dup_test_cases[] = {
|
|
KUNIT_CASE_PARAM(test_is_dup, test_is_dup_gen_params),
|
|
{},
|
|
};
|
|
|
|
static struct kunit_suite is_dup = {
|
|
.name = "iwlmld-rx-is-dup",
|
|
.test_cases = is_dup_test_cases,
|
|
.init = iwlmld_kunit_test_init,
|
|
};
|
|
|
|
kunit_test_suite(is_dup);
|