Commit d464550b authored by Yedidya Benshimol's avatar Yedidya Benshimol Committed by Johannes Berg
Browse files

wifi: iwlwifi: mvm: use link ID in missed beacon notification



This new version of missed beacon notification uses link_id
instead of mac_id. Also add an option to use link id for
retrieving vif.

Signed-off-by: default avatarYedidya Benshimol <yedidya.ben.shimol@intel.com>
Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230524203151.17fe1cc632f1.Id1fabb532e2174712fe17d4ad86a2c8c64ae84da@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 75f059d3
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -353,7 +353,7 @@ struct iwl_nonqos_seq_query_cmd {
} __packed; /* NON_QOS_TX_COUNTER_GET_SET_API_S_VER_1 */

/**
 * struct iwl_missed_beacons_notif - information on missed beacons
 * struct iwl_missed_beacons_notif_ver_3 - information on missed beacons
 * ( MISSED_BEACONS_NOTIFICATION = 0xa2 )
 * @mac_id: interface ID
 * @consec_missed_beacons_since_last_rx: number of consecutive missed
@@ -362,7 +362,7 @@ struct iwl_nonqos_seq_query_cmd {
 * @num_expected_beacons: number of expected beacons
 * @num_recvd_beacons: number of received beacons
 */
struct iwl_missed_beacons_notif {
struct iwl_missed_beacons_notif_ver_3 {
	__le32 mac_id;
	__le32 consec_missed_beacons_since_last_rx;
	__le32 consec_missed_beacons;
@@ -370,6 +370,24 @@ struct iwl_missed_beacons_notif {
	__le32 num_recvd_beacons;
} __packed; /* MISSED_BEACON_NTFY_API_S_VER_3 */

/**
 * struct iwl_missed_beacons_notif - information on missed beacons
 * ( MISSED_BEACONS_NOTIFICATION = 0xa2 )
 * @link_id: fw link ID
 * @consec_missed_beacons_since_last_rx: number of consecutive missed
 *	beacons since last RX.
 * @consec_missed_beacons: number of consecutive missed beacons
 * @num_expected_beacons: number of expected beacons
 * @num_recvd_beacons: number of received beacons
 */
struct iwl_missed_beacons_notif {
	__le32 link_id;
	__le32 consec_missed_beacons_since_last_rx;
	__le32 consec_missed_beacons;
	__le32 num_expected_beacons;
	__le32 num_recvd_beacons;
} __packed; /* MISSED_BEACON_NTFY_API_S_VER_4 */

/**
 * struct iwl_he_backoff_conf - used for backoff configuration
 * Per each trigger-based AC, (set by MU EDCA Parameter set info-element)
+3 −0
Original line number Diff line number Diff line
@@ -1591,6 +1591,9 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
		RCU_INIT_POINTER(mvm->fw_id_to_link_sta[i], NULL);
	}

	for (i = 0; i < IWL_MVM_FW_MAX_LINK_ID + 1; i++)
		RCU_INIT_POINTER(mvm->link_id_to_link_conf[i], NULL);

	memset(&mvm->fw_link_ids_map, 0, sizeof(mvm->fw_link_ids_map));

	mvm->tdls_cs.peer.sta_id = IWL_MVM_INVALID_STA;
+5 −0
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@ int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
								    mvmvif);
		if (link_info->fw_link_id == IWL_MVM_FW_LINK_ID_INVALID)
			return -EINVAL;

		rcu_assign_pointer(mvm->link_id_to_link_conf[link_info->fw_link_id],
				   link_conf);
	}

	/* Update SF - Disable if needed. if this fails, SF might still be on
@@ -260,6 +263,8 @@ int iwl_mvm_remove_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
		    link_info->fw_link_id == IWL_MVM_FW_LINK_ID_INVALID))
		return -EINVAL;

	RCU_INIT_POINTER(mvm->link_id_to_link_conf[link_info->fw_link_id],
			 NULL);
	cmd.link_id = cpu_to_le32(link_info->fw_link_id);
	iwl_mvm_release_fw_link_id(mvm, link_info->fw_link_id);
	link_info->fw_link_id = IWL_MVM_FW_LINK_ID_INVALID;
+23 −6
Original line number Diff line number Diff line
@@ -1555,21 +1555,38 @@ void iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
	u32 stop_trig_missed_bcon, stop_trig_missed_bcon_since_rx;
	u32 rx_missed_bcon, rx_missed_bcon_since_rx;
	struct ieee80211_vif *vif;
	u32 id = le32_to_cpu(mb->mac_id);
	/* Id can be mac/link id depending on the notification version */
	u32 id = le32_to_cpu(mb->link_id);
	union iwl_dbg_tlv_tp_data tp_data = { .fw_pkt = pkt };
	u32 mac_type;
	u8 notif_ver = iwl_fw_lookup_notif_ver(mvm->fw, LEGACY_GROUP,
					       MISSED_BEACONS_NOTIFICATION,
					       0);

	rcu_read_lock();

	/* before version four the ID in the notification refers to mac ID */
	if (notif_ver < 4) {
		vif = iwl_mvm_rcu_dereference_vif_id(mvm, id, true);
	} else {
		struct ieee80211_bss_conf *bss_conf =
			iwl_mvm_rcu_fw_link_id_to_link_conf(mvm, id, true);

		if (!bss_conf)
			goto out;

		vif = bss_conf->vif;
	}

	IWL_DEBUG_INFO(mvm,
		       "missed bcn mac_id=%u, consecutive=%u (%u, %u, %u)\n",
		       le32_to_cpu(mb->mac_id),
		       "missed bcn %s_id=%u, consecutive=%u (%u, %u, %u)\n",
		       notif_ver < 4 ? "mac" : "link",
		       id,
		       le32_to_cpu(mb->consec_missed_beacons),
		       le32_to_cpu(mb->consec_missed_beacons_since_last_rx),
		       le32_to_cpu(mb->num_recvd_beacons),
		       le32_to_cpu(mb->num_expected_beacons));

	rcu_read_lock();

	vif = iwl_mvm_rcu_dereference_vif_id(mvm, id, true);
	if (!vif)
		goto out;

+15 −0
Original line number Diff line number Diff line
@@ -1003,6 +1003,8 @@ struct iwl_mvm {

	struct ieee80211_vif __rcu *vif_id_to_mac[NUM_MAC_INDEX_DRIVER];

	struct ieee80211_bss_conf __rcu *link_id_to_link_conf[IWL_MVM_FW_MAX_LINK_ID + 1];

	/* -1 for always, 0 for never, >0 for that many times */
	s8 fw_restart;
	u8 *error_recovery_buf;
@@ -1302,6 +1304,19 @@ iwl_mvm_rcu_dereference_vif_id(struct iwl_mvm *mvm, u8 vif_id, bool rcu)
					 lockdep_is_held(&mvm->mutex));
}

static inline struct ieee80211_bss_conf *
iwl_mvm_rcu_fw_link_id_to_link_conf(struct iwl_mvm *mvm, u8 link_id, bool rcu)
{
	if (WARN_ON(link_id >= ARRAY_SIZE(mvm->link_id_to_link_conf)))
		return NULL;

	if (rcu)
		return rcu_dereference(mvm->link_id_to_link_conf[link_id]);

	return rcu_dereference_protected(mvm->link_id_to_link_conf[link_id],
					 lockdep_is_held(&mvm->mutex));
}

static inline bool iwl_mvm_is_adaptive_dwell_supported(struct iwl_mvm *mvm)
{
	return fw_has_api(&mvm->fw->ucode_capa,