git: bb81db90f7e0 - main - LinuxKPI: 802.11: implement ieee80211_beacon_loss()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Tue, 22 Mar 2022 18:52:49 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=bb81db90f7e00f56df9ea14132a54ee983e7177f

commit bb81db90f7e00f56df9ea14132a54ee983e7177f
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-03-22 15:02:45 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2022-03-22 18:51:43 +0000

    LinuxKPI: 802.11: implement ieee80211_beacon_loss()
    
    Implement ieee80211_beacon_loss() similar to
    ieee80211_connection_loss() with different state handling.
    While here leave a comment in connection_loss() about the state
    change argument.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/compat/linuxkpi/common/include/net/mac80211.h |  3 ++-
 sys/compat/linuxkpi/common/src/linux_80211.c      | 28 ++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/net/mac80211.h b/sys/compat/linuxkpi/common/include/net/mac80211.h
index 8a74e3fcec1b..5cf2c8b75e40 100644
--- a/sys/compat/linuxkpi/common/include/net/mac80211.h
+++ b/sys/compat/linuxkpi/common/include/net/mac80211.h
@@ -904,6 +904,7 @@ void linuxkpi_ieee80211_txq_get_depth(struct ieee80211_txq *, uint64_t *,
     uint64_t *);
 struct wireless_dev *linuxkpi_ieee80211_vif_to_wdev(struct ieee80211_vif *);
 void linuxkpi_ieee80211_connection_loss(struct ieee80211_vif *);
+void linuxkpi_ieee80211_beacon_loss(struct ieee80211_vif *);
 
 /* -------------------------------------------------------------------------- */
 
@@ -1403,7 +1404,7 @@ ieee80211_beacon_get_template(struct ieee80211_hw *hw,
 static __inline void
 ieee80211_beacon_loss(struct ieee80211_vif *vif)
 {
-	TODO();
+	linuxkpi_ieee80211_beacon_loss(vif);
 }
 
 static __inline void
diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 2fe8b4ebddd0..ceb9c626c507 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -3708,13 +3708,39 @@ linuxkpi_ieee80211_connection_loss(struct ieee80211_vif *vif)
 	 * Let the statemachine handle all neccessary changes.
 	 */
 	nstate = IEEE80211_S_INIT;
-	arg = 0;
+	arg = 0;	/* Not a valid reason. */
 
 	if (debug_80211 & D80211_TRACE)
 		ic_printf(vap->iv_ic, "%s: vif %p\n", __func__, vif);
 	ieee80211_new_state(vap, nstate, arg);
 }
 
+void
+linuxkpi_ieee80211_beacon_loss(struct ieee80211_vif *vif)
+{
+	struct lkpi_vif *lvif;
+	struct ieee80211vap *vap;
+	enum ieee80211_state nstate;
+	int arg;
+
+	lvif = VIF_TO_LVIF(vif);
+	vap = LVIF_TO_VAP(lvif);
+
+	/*
+	 * Go to scan; otherwise we need to elaborately check state and
+	 * handle accordingly, e.g., if in RUN we could call iv_bmiss.
+	 * Let the statemachine handle all neccessary changes.
+	 */
+	nstate = IEEE80211_S_SCAN;
+	arg = 0;
+
+	/* We should be in RUN.  Can we assert that? */
+	if (debug_80211 & D80211_TRACE || vap->iv_state != IEEE80211_S_RUN)
+		ic_printf(vap->iv_ic, "%s: vif %p vap %p state %s\n", __func__,
+		    vif, vap, ieee80211_state_name[vap->iv_state]);
+	ieee80211_new_state(vap, nstate, arg);
+}
+
 MODULE_VERSION(linuxkpi_wlan, 1);
 MODULE_DEPEND(linuxkpi_wlan, linuxkpi, 1, 1, 1);
 MODULE_DEPEND(linuxkpi_wlan, wlan, 1, 1, 1);