Commit cf74ce02 authored by Johannes Berg's avatar Johannes Berg
Browse files

wifi: iwlwifi: add kunit test for devinfo ordering



We used to have a test built into the code for this internally,
but now we can put that into kunit and let everyone run it, to
verify the devinfo table ordering if it's changed.

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Reviewed-by: default avatarBenjamin Berg <benjamin.berg@intel.com>
Reviewed-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240123200528.a4a8af7c091f.I0fb09083317b331168b99b8db39656a126a5cc4d@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent d60277ac
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -46,6 +46,15 @@ config IWLWIFI

if IWLWIFI

config IWLWIFI_KUNIT_TESTS
	tristate
	depends on KUNIT
	default KUNIT_ALL_TESTS
	help
	  Enable this option for iwlwifi kunit tests.

	  If unsure, say N.

config IWLWIFI_LEDS
	bool
	depends on LEDS_CLASS=y || LEDS_CLASS=MAC80211
+2 −0
Original line number Diff line number Diff line
@@ -33,4 +33,6 @@ obj-$(CONFIG_IWLDVM) += dvm/
obj-$(CONFIG_IWLMVM)	+= mvm/
obj-$(CONFIG_IWLMEI)	+= mei/

obj-$(CONFIG_IWLWIFI_KUNIT_TESTS) += tests/

CFLAGS_iwl-devtrace.o := -I$(src)
+10 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include <linux/ieee80211.h>
#include <linux/nl80211.h>
#include "iwl-csr.h"
#include "iwl-drv.h"

enum iwl_device_family {
	IWL_DEVICE_FAMILY_UNDEFINED,
@@ -471,6 +472,15 @@ struct iwl_dev_info {
	const char *name;
};

#if IS_ENABLED(CONFIG_IWLWIFI_KUNIT_TESTS)
extern const struct iwl_dev_info iwl_dev_info_table[];
extern const unsigned int iwl_dev_info_table_size;
const struct iwl_dev_info *
iwl_pci_find_dev_info(u16 device, u16 subsystem_device,
		      u16 mac_type, u8 mac_step, u16 rf_type, u8 cdb,
		      u8 jacket, u8 rf_id, u8 no_160, u8 cores, u8 rf_step);
#endif

/*
 * This list declares the config structures for all devices.
 */
+9 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
#ifndef __iwl_drv_h__
#define __iwl_drv_h__
#include <linux/export.h>
#include <kunit/visibility.h>

/* for all modules */
#define DRV_NAME        "iwlwifi"
@@ -89,6 +90,14 @@ void iwl_drv_stop(struct iwl_drv *drv);
#define IWL_EXPORT_SYMBOL(sym)
#endif

#if IS_ENABLED(CONFIG_IWLWIFI_KUNIT_TESTS)
#define EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(sym)	EXPORT_SYMBOL_IF_KUNIT(sym)
#define VISIBLE_IF_IWLWIFI_KUNIT
#else
#define EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(sym)
#define VISIBLE_IF_IWLWIFI_KUNIT static
#endif

/* max retry for init flow */
#define IWL_MAX_INIT_RETRY 2

+9 −2
Original line number Diff line number Diff line
@@ -526,7 +526,7 @@ MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
		      IWL_CFG_ANY, IWL_CFG_ANY, IWL_CFG_ANY, IWL_CFG_ANY, IWL_CFG_ANY,  \
		      IWL_CFG_ANY, _cfg, _name)

static const struct iwl_dev_info iwl_dev_info_table[] = {
VISIBLE_IF_IWLWIFI_KUNIT const struct iwl_dev_info iwl_dev_info_table[] = {
#if IS_ENABLED(CONFIG_IWLMVM)
/* 9000 */
	IWL_DEV_INFO(0x2526, 0x1550, iwl9260_2ac_cfg, iwl9260_killer_1550_name),
@@ -1117,6 +1117,12 @@ static const struct iwl_dev_info iwl_dev_info_table[] = {
		      iwl_cfg_sc, iwl_sc_name),
#endif /* CONFIG_IWLMVM */
};
EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_dev_info_table);

#if IS_ENABLED(CONFIG_IWLWIFI_KUNIT_TESTS)
const unsigned int iwl_dev_info_table_size = ARRAY_SIZE(iwl_dev_info_table);
EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_dev_info_table_size);
#endif

/*
 * Read rf id and cdb info from prph register and store it
@@ -1236,7 +1242,7 @@ static int map_crf_id(struct iwl_trans *iwl_trans)
/* PCI registers */
#define PCI_CFG_RETRY_TIMEOUT	0x041

static const struct iwl_dev_info *
VISIBLE_IF_IWLWIFI_KUNIT const struct iwl_dev_info *
iwl_pci_find_dev_info(u16 device, u16 subsystem_device,
		      u16 mac_type, u8 mac_step, u16 rf_type, u8 cdb,
		      u8 jacket, u8 rf_id, u8 no_160, u8 cores, u8 rf_step)
@@ -1299,6 +1305,7 @@ iwl_pci_find_dev_info(u16 device, u16 subsystem_device,

	return NULL;
}
EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_pci_find_dev_info);

static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
Loading