Commit 3fd31289 authored by Johannes Berg's avatar Johannes Berg
Browse files

wifi: iwlwifi: unify Bz/Gl device configurations



All the configurations for the various Bz/Gl devices
are basically identical, except for Gl A-step and the
firmware filename prefixes.

Add some infrastructure to auto-generate the firmware
filename prefix based on the detected MAC step and
RF name/step, and remove all the unneeded configs.

This reduces the size of the iwlwifi module by ~9k:
 517582	  27111	    560	 545253	  851e5	drivers/net/wireless/intel/iwlwifi/iwlwifi.ko
 526885	  27083	    560	 554528	  87620	drivers/net/wireless/intel/iwlwifi/iwlwifi.ko

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230621130443.1dc121ba338f.I07d651516eb82cbaded4724ef30558a50f2fa866@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent e3597e28
Loading
Loading
Loading
Loading
+4 −124
Original line number Diff line number Diff line
@@ -191,112 +191,8 @@ const struct iwl_cfg_trans_params iwl_bz_trans_cfg = {

const char iwl_bz_name[] = "Intel(R) TBD Bz device";

const struct iwl_cfg iwl_cfg_bz_a0_hr_a0 = {
	.fw_name_pre = IWL_BZ_A_HR_A_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_a0_hr_b0 = {
	.fw_name_pre = IWL_BZ_A_HR_B_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_a0_gf_a0 = {
	.fw_name_pre = IWL_BZ_A_GF_A_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_a0_gf4_a0 = {
	.fw_name_pre = IWL_BZ_A_GF4_A_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_b0_gf_a0 = {
	.fw_name_pre = IWL_BZ_B_GF_A_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_b0_gf4_a0 = {
	.fw_name_pre = IWL_BZ_B_GF4_A_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_a0_mr_a0 = {
	.fw_name_pre = IWL_BZ_A_MR_A_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_a0_fm_a0 = {
	.fw_name_pre = IWL_BZ_A_FM_A_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_a0_fm4_a0 = {
	.fw_name_pre = IWL_BZ_A_FM4_A_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_a0_fm_b0 = {
	.fw_name_pre = IWL_BZ_A_FM_B_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_a0_fm_c0 = {
	.fw_name_pre = IWL_BZ_A_FM_C_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_a0_fm4_b0 = {
	.fw_name_pre = IWL_BZ_A_FM4_B_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_b0_fm_b0 = {
	.fw_name_pre = IWL_BZ_B_FM_B_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_b0_fm4_b0 = {
	.fw_name_pre = IWL_BZ_B_FM4_B_FW_PRE,
const struct iwl_cfg iwl_cfg_bz = {
	.fw_name_mac = "bz",
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
@@ -311,24 +207,8 @@ const struct iwl_cfg iwl_cfg_gl_a0_fm_a0 = {
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_gl_b0_fm_b0 = {
	.fw_name_pre = IWL_GL_B_FM_B_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_gl_c0_fm_c0 = {
	.fw_name_pre = IWL_GL_C_FM_C_FW_PRE,
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
	.num_rbds = IWL_NUM_RBDS_BZ_HE,
};

const struct iwl_cfg iwl_cfg_bz_z0_gf_a0 = {
	.fw_name_pre = IWL_BZ_Z_GF_A_FW_PRE,
const struct iwl_cfg iwl_cfg_gl = {
	.fw_name_mac = "gl",
	.uhb_supported = true,
	IWL_DEVICE_BZ,
	.features = IWL_TX_CSUM_NETIF_FLAGS_BZ | NETIF_F_RXCSUM,
+10 −8
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
/******************************************************************************
 *
 * Copyright(c) 2020-2022 Intel Corporation
 *
 *****************************************************************************/

/*
 * Copyright(c) 2020-2023 Intel Corporation
 */
#ifndef __IWL_PNVM_H__
#define __IWL_PNVM_H__

#include "iwl-drv.h"
#include "fw/notif-wait.h"

#define MVM_UCODE_PNVM_TIMEOUT	(HZ / 4)
@@ -22,16 +20,20 @@ static inline
void iwl_pnvm_get_fs_name(struct iwl_trans *trans,
			  u8 *pnvm_name, size_t max_len)
{
	char _fw_name_pre[FW_NAME_PRE_BUFSIZE];
	const char *fw_name_pre;
	int pre_len;

	fw_name_pre = iwl_drv_get_fwname_pre(trans, _fw_name_pre);

	/*
	 * The prefix unfortunately includes a hyphen at the end, so
	 * don't add the dot here...
	 */
	snprintf(pnvm_name, max_len, "%spnvm", trans->cfg->fw_name_pre);
	snprintf(pnvm_name, max_len, "%spnvm", fw_name_pre);

	/* ...but replace the hyphen with the dot here. */
	pre_len = strlen(trans->cfg->fw_name_pre);
	pre_len = strlen(fw_name_pre);
	if (pre_len < max_len && pre_len > 0)
		pnvm_name[pre_len - 1] = '.';
}
+7 −17
Original line number Diff line number Diff line
@@ -310,6 +310,8 @@ struct iwl_fw_mon_regs {
 * @fw_name_pre: Firmware filename prefix. The api version and extension
 *	(.ucode) will be added to filename before loading from disk. The
 *	filename is constructed as fw_name_pre<api>.ucode.
 * @fw_name_mac: MAC name for this config, the remaining pieces of the
 *	name will be generated dynamically
 * @ucode_api_max: Highest version of uCode API supported by driver.
 * @ucode_api_min: Lowest version of uCode API supported by driver.
 * @max_inst_size: The maximal length of the fw inst section (only DVM)
@@ -363,6 +365,7 @@ struct iwl_cfg {
	/* params specific to an individual device within a device family */
	const char *name;
	const char *fw_name_pre;
	const char *fw_name_mac;
	/* params likely to change within a device family */
	const struct iwl_ht_params *ht_params;
	const struct iwl_eeprom_params *eeprom_params;
@@ -643,24 +646,11 @@ extern const struct iwl_cfg iwl_cfg_ma_b0_fm_a0;
extern const struct iwl_cfg iwl_cfg_so_a0_hr_a0;
extern const struct iwl_cfg iwl_cfg_so_a0_ms_a0;
extern const struct iwl_cfg iwl_cfg_quz_a0_hr_b0;
extern const struct iwl_cfg iwl_cfg_bz_a0_hr_a0;
extern const struct iwl_cfg iwl_cfg_bz_a0_hr_b0;
extern const struct iwl_cfg iwl_cfg_bz_a0_gf_a0;
extern const struct iwl_cfg iwl_cfg_bz_a0_gf4_a0;
extern const struct iwl_cfg iwl_cfg_bz_b0_gf_a0;
extern const struct iwl_cfg iwl_cfg_bz_b0_gf4_a0;
extern const struct iwl_cfg iwl_cfg_bz_a0_mr_a0;
extern const struct iwl_cfg iwl_cfg_bz_a0_fm_a0;
extern const struct iwl_cfg iwl_cfg_bz_a0_fm4_a0;
extern const struct iwl_cfg iwl_cfg_bz_a0_fm_b0;
extern const struct iwl_cfg iwl_cfg_bz_a0_fm_c0;
extern const struct iwl_cfg iwl_cfg_bz_a0_fm4_b0;
extern const struct iwl_cfg iwl_cfg_bz_b0_fm_b0;
extern const struct iwl_cfg iwl_cfg_bz_b0_fm4_b0;

extern const struct iwl_cfg iwl_cfg_bz;
extern const struct iwl_cfg iwl_cfg_gl_a0_fm_a0;
extern const struct iwl_cfg iwl_cfg_gl_b0_fm_b0;
extern const struct iwl_cfg iwl_cfg_gl_c0_fm_c0;
extern const struct iwl_cfg iwl_cfg_bz_z0_gf_a0;
extern const struct iwl_cfg iwl_cfg_gl;

extern const struct iwl_cfg iwl_cfg_sc_a0_fm_b0;
extern const struct iwl_cfg iwl_cfg_sc_a0_fm_c0;
extern const struct iwl_cfg iwl_cfg_sc_a0_hr_a0;
+65 −4
Original line number Diff line number Diff line
@@ -158,12 +158,71 @@ static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc,
	return 0;
}

static inline char iwl_drv_get_step(int step)
{
	if (step == SILICON_Z_STEP)
		return 'z';
	return 'a' + step;
}

const char *iwl_drv_get_fwname_pre(struct iwl_trans *trans, char *buf)
{
	char mac_step, rf_step;
	const char *rf, *cdb;

	if (trans->cfg->fw_name_pre)
		return trans->cfg->fw_name_pre;

	if (WARN_ON(!trans->cfg->fw_name_mac))
		return "unconfigured-";

	mac_step = iwl_drv_get_step(trans->hw_rev_step);

	switch (CSR_HW_RFID_TYPE(trans->hw_rf_id)) {
	case IWL_CFG_RF_TYPE_HR1:
	case IWL_CFG_RF_TYPE_HR2:
		rf = "hr";
		break;
	case IWL_CFG_RF_TYPE_GF:
		rf = "gf";
		break;
	case IWL_CFG_RF_TYPE_MR:
		rf = "mr";
		break;
	case IWL_CFG_RF_TYPE_MS:
		rf = "ms";
		break;
	case IWL_CFG_RF_TYPE_FM:
		rf = "fm";
		break;
	case IWL_CFG_RF_TYPE_WH:
		rf = "wh";
		break;
	default:
		return "unknown-rf-";
	}

	cdb = CSR_HW_RFID_IS_CDB(trans->hw_rf_id) ? "4" : "";

	rf_step = iwl_drv_get_step(CSR_HW_RFID_STEP(trans->hw_rf_id));

	scnprintf(buf, FW_NAME_PRE_BUFSIZE,
		  "iwlwifi-%s-%c0-%s%s-%c0",
		  trans->cfg->fw_name_mac, mac_step,
		  rf, cdb, rf_step);

	return buf;
}
IWL_EXPORT_SYMBOL(iwl_drv_get_fwname_pre);

static void iwl_req_fw_callback(const struct firmware *ucode_raw,
				void *context);

static int iwl_request_firmware(struct iwl_drv *drv, bool first)
{
	const struct iwl_cfg *cfg = drv->trans->cfg;
	char _fw_name_pre[FW_NAME_PRE_BUFSIZE];
	const char *fw_name_pre;

	if (drv->trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_9000 &&
	    (drv->trans->hw_rev_step != SILICON_B_STEP &&
@@ -174,6 +233,8 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
		return -EINVAL;
	}

	fw_name_pre = iwl_drv_get_fwname_pre(drv->trans, _fw_name_pre);

	if (first)
		drv->fw_index = cfg->ucode_api_max;
	else
@@ -183,13 +244,13 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
		IWL_ERR(drv, "no suitable firmware found!\n");

		if (cfg->ucode_api_min == cfg->ucode_api_max) {
			IWL_ERR(drv, "%s%d is required\n", cfg->fw_name_pre,
			IWL_ERR(drv, "%s%d is required\n", fw_name_pre,
				cfg->ucode_api_max);
		} else {
			IWL_ERR(drv, "minimum version required: %s%d\n",
				cfg->fw_name_pre, cfg->ucode_api_min);
				fw_name_pre, cfg->ucode_api_min);
			IWL_ERR(drv, "maximum version supported: %s%d\n",
				cfg->fw_name_pre, cfg->ucode_api_max);
				fw_name_pre, cfg->ucode_api_max);
		}

		IWL_ERR(drv,
@@ -198,7 +259,7 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
	}

	snprintf(drv->firmware_name, sizeof(drv->firmware_name), "%s%d.ucode",
		 cfg->fw_name_pre, drv->fw_index);
		 fw_name_pre, drv->fw_index);

	IWL_DEBUG_FW_INFO(drv, "attempting to load firmware '%s'\n",
			  drv->firmware_name);
+5 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
/*
 * Copyright (C) 2005-2014, 2020-2021 Intel Corporation
 * Copyright (C) 2005-2014, 2020-2021, 2023 Intel Corporation
 * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
 */
#ifndef __iwl_drv_h__
@@ -92,4 +92,8 @@ void iwl_drv_stop(struct iwl_drv *drv);
/* max retry for init flow */
#define IWL_MAX_INIT_RETRY 2

#define FW_NAME_PRE_BUFSIZE	64
struct iwl_trans;
const char *iwl_drv_get_fwname_pre(struct iwl_trans *trans, char *buf);

#endif /* __iwl_drv_h__ */
Loading