aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/src/linux_80211.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat/linuxkpi/common/src/linux_80211.h')
-rw-r--r--sys/compat/linuxkpi/common/src/linux_80211.h210
1 files changed, 193 insertions, 17 deletions
diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h
index 3c107f76de32..b0156a5ade3f 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.h
+++ b/sys/compat/linuxkpi/common/src/linux_80211.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2020-2022 The FreeBSD Foundation
+ * Copyright (c) 2020-2023 The FreeBSD Foundation
* Copyright (c) 2020-2021 Bjoern A. Zeeb
*
* This software was developed by Björn Zeeb under sponsorship from
@@ -42,6 +42,52 @@
#ifndef _LKPI_SRC_LINUX_80211_H
#define _LKPI_SRC_LINUX_80211_H
+/* #define LINUXKPI_DEBUG_80211 */
+
+#ifndef D80211_TODO
+#define D80211_TODO 0x00000001
+#endif
+#ifndef D80211_IMPROVE
+#define D80211_IMPROVE 0x00000002
+#endif
+#define D80211_IMPROVE_TXQ 0x00000004
+#define D80211_TRACE 0x00000010
+#define D80211_TRACEOK 0x00000020
+#define D80211_TRACE_TX 0x00000100
+#define D80211_TRACE_TX_DUMP 0x00000200
+#define D80211_TRACE_RX 0x00001000
+#define D80211_TRACE_RX_DUMP 0x00002000
+#define D80211_TRACE_RX_BEACONS 0x00004000
+#define D80211_TRACEX (D80211_TRACE_TX|D80211_TRACE_RX)
+#define D80211_TRACEX_DUMP (D80211_TRACE_TX_DUMP|D80211_TRACE_RX_DUMP)
+#define D80211_TRACE_STA 0x00010000
+#define D80211_TRACE_MO 0x00100000
+#define D80211_TRACE_MODE 0x0f000000
+#define D80211_TRACE_MODE_HT 0x01000000
+#define D80211_TRACE_MODE_VHT 0x02000000
+#define D80211_TRACE_MODE_HE 0x04000000
+#define D80211_TRACE_MODE_EHT 0x08000000
+
+#define IMPROVE_TXQ(...) \
+ if (linuxkpi_debug_80211 & D80211_IMPROVE_TXQ) \
+ printf("%s:%d: XXX LKPI80211 IMPROVE_TXQ\n", __func__, __LINE__)
+
+#define IMPROVE_HT(...) \
+ if (linuxkpi_debug_80211 & D80211_TRACE_MODE_HT) \
+ printf("%s:%d: XXX LKPI80211 IMPROVE_HT\n", __func__, __LINE__)
+
+#define MTAG_ABI_LKPI80211 1707696513 /* LinuxKPI 802.11 KBI */
+
+/*
+ * Deferred RX path.
+ * We need to pass *ni along (and possibly more in the future so
+ * we use a struct right from the start.
+ */
+#define LKPI80211_TAG_RXNI 0 /* deferred RX path */
+struct lkpi_80211_tag_rxni {
+ struct ieee80211_node *ni; /* MUST hold a reference to it. */
+};
+
struct lkpi_radiotap_tx_hdr {
struct ieee80211_radiotap_header wt_ihdr;
uint8_t wt_flags;
@@ -73,7 +119,12 @@ struct lkpi_radiotap_rx_hdr {
(1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
struct lkpi_txq {
+ TAILQ_ENTRY(lkpi_txq) txq_entry;
+
+ struct mtx ltxq_mtx;
bool seen_dequeue;
+ bool stopped;
+ uint32_t txq_generation;
struct sk_buff_head skbq;
/* Must be last! */
@@ -95,6 +146,7 @@ struct lkpi_sta {
struct ieee80211_key_conf *kc;
enum ieee80211_sta_state state;
+ bool txq_ready; /* Can we run the taskq? */
bool added_to_drv; /* Driver knows; i.e. we called ...(). */
bool in_mgd; /* XXX-BZ should this be per-vif? */
@@ -117,8 +169,12 @@ struct lkpi_vif {
struct ieee80211_node * (*iv_update_bss)(struct ieee80211vap *,
struct ieee80211_node *);
TAILQ_HEAD(, lkpi_sta) lsta_head;
+ struct lkpi_sta *lvif_bss;
+ bool lvif_bss_synched;
bool added_to_drv; /* Driver knows; i.e. we called add_interface(). */
+ bool hw_queue_stopped[IEEE80211_NUM_ACS];
+
/* Must be last! */
struct ieee80211_vif vif __aligned(CACHE_LINE_SIZE);
};
@@ -142,7 +198,21 @@ struct lkpi_hw { /* name it mac80211_sc? */
TAILQ_HEAD(, lkpi_vif) lvif_head;
struct sx lvif_sx;
- struct mtx mtx;
+ struct sx sx;
+
+ struct mtx txq_mtx;
+ uint32_t txq_generation[IEEE80211_NUM_ACS];
+ TAILQ_HEAD(, lkpi_txq) scheduled_txqs[IEEE80211_NUM_ACS];
+
+ /* Deferred RX path. */
+ struct task rxq_task;
+ struct mbufq rxq;
+ struct mtx rxq_mtx;
+
+ /* Scan functions we overload to handle depending on scan mode. */
+ void (*ic_scan_curchan)(struct ieee80211_scan_state *,
+ unsigned long);
+ void (*ic_scan_mindwell)(struct ieee80211_scan_state *);
/* Node functions we overload to sync state. */
struct ieee80211_node * (*ic_node_alloc)(struct ieee80211vap *,
@@ -151,16 +221,43 @@ struct lkpi_hw { /* name it mac80211_sc? */
void (*ic_node_cleanup)(struct ieee80211_node *);
void (*ic_node_free)(struct ieee80211_node *);
+ /* HT and later functions. */
+ int (*ic_recv_action)(struct ieee80211_node *,
+ const struct ieee80211_frame *,
+ const uint8_t *, const uint8_t *);
+ int (*ic_send_action)(struct ieee80211_node *,
+ int, int, void *);
+ int (*ic_ampdu_enable)(struct ieee80211_node *,
+ struct ieee80211_tx_ampdu *);
+ int (*ic_addba_request)(struct ieee80211_node *,
+ struct ieee80211_tx_ampdu *, int, int, int);
+ int (*ic_addba_response)(struct ieee80211_node *,
+ struct ieee80211_tx_ampdu *, int, int, int);
+ void (*ic_addba_stop)(struct ieee80211_node *,
+ struct ieee80211_tx_ampdu *);
+ void (*ic_addba_response_timeout)(struct ieee80211_node *,
+ struct ieee80211_tx_ampdu *);
+ void (*ic_bar_response)(struct ieee80211_node *,
+ struct ieee80211_tx_ampdu *, int);
+ int (*ic_ampdu_rx_start)(struct ieee80211_node *,
+ struct ieee80211_rx_ampdu *, int, int, int);
+ void (*ic_ampdu_rx_stop)(struct ieee80211_node *,
+ struct ieee80211_rx_ampdu *);
+
#define LKPI_MAC80211_DRV_STARTED 0x00000001
uint32_t sc_flags;
-#define LKPI_SCAN_RUNNING 0x00000001
+#define LKPI_LHW_SCAN_RUNNING 0x00000001
+#define LKPI_LHW_SCAN_HW 0x00000002
uint32_t scan_flags;
+ struct mtx scan_mtx;
int supbands; /* Number of supported bands. */
int max_rates; /* Maximum number of bitrates supported in any channel. */
int scan_ie_len; /* Length of common per-band scan IEs. */
bool update_mc;
+ bool update_wme;
+ bool rxq_stopped;
/* Must be last! */
struct ieee80211_hw hw __aligned(CACHE_LINE_SIZE);
@@ -168,6 +265,15 @@ struct lkpi_hw { /* name it mac80211_sc? */
#define LHW_TO_HW(_lhw) (&(_lhw)->hw)
#define HW_TO_LHW(_hw) container_of(_hw, struct lkpi_hw, hw)
+struct lkpi_chanctx {
+ bool added_to_drv; /* Managed by MO */
+ struct ieee80211_chanctx_conf conf __aligned(CACHE_LINE_SIZE);
+};
+#define LCHANCTX_TO_CHANCTX_CONF(_lchanctx) \
+ (&(_lchanctx)->conf)
+#define CHANCTX_CONF_TO_LCHANCTX(_conf) \
+ container_of(_conf, struct lkpi_chanctx, conf)
+
struct lkpi_wiphy {
const struct cfg80211_ops *ops;
@@ -177,13 +283,57 @@ struct lkpi_wiphy {
#define WIPHY_TO_LWIPHY(_wiphy) container_of(_wiphy, struct lkpi_wiphy, wiphy)
#define LWIPHY_TO_WIPHY(_lwiphy) (&(_lwiphy)->wiphy)
-
-#define LKPI_80211_LHW_LOCK(_lhw) mtx_lock(&(_lhw)->mtx)
-#define LKPI_80211_LHW_UNLOCK(_lhw) mtx_unlock(&(_lhw)->mtx)
-#define LKPI_80211_LHW_LOCK_ASSERT(_lhw) \
- mtx_assert(&(_lhw)->mtx, MA_OWNED)
-#define LKPI_80211_LHW_UNLOCK_ASSERT(_lhw) \
- mtx_assert(&(_lhw)->mtx, MA_NOTOWNED)
+#define LKPI_80211_LHW_LOCK_INIT(_lhw) \
+ sx_init_flags(&(_lhw)->sx, "lhw", SX_RECURSE);
+#define LKPI_80211_LHW_LOCK_DESTROY(_lhw) \
+ sx_destroy(&(_lhw)->sx);
+#define LKPI_80211_LHW_LOCK(_lhw) \
+ sx_xlock(&(_lhw)->sx)
+#define LKPI_80211_LHW_UNLOCK(_lhw) \
+ sx_xunlock(&(_lhw)->sx)
+#define LKPI_80211_LHW_LOCK_ASSERT(_lhw) \
+ sx_assert(&(_lhw)->sx, SA_LOCKED)
+#define LKPI_80211_LHW_UNLOCK_ASSERT(_lhw) \
+ sx_assert(&(_lhw)->sx, SA_UNLOCKED)
+
+#define LKPI_80211_LHW_SCAN_LOCK_INIT(_lhw) \
+ mtx_init(&(_lhw)->scan_mtx, "lhw-scan", NULL, MTX_DEF | MTX_RECURSE);
+#define LKPI_80211_LHW_SCAN_LOCK_DESTROY(_lhw) \
+ mtx_destroy(&(_lhw)->scan_mtx);
+#define LKPI_80211_LHW_SCAN_LOCK(_lhw) \
+ mtx_lock(&(_lhw)->scan_mtx)
+#define LKPI_80211_LHW_SCAN_UNLOCK(_lhw) \
+ mtx_unlock(&(_lhw)->scan_mtx)
+#define LKPI_80211_LHW_SCAN_LOCK_ASSERT(_lhw) \
+ mtx_assert(&(_lhw)->scan_mtx, MA_OWNED)
+#define LKPI_80211_LHW_SCAN_UNLOCK_ASSERT(_lhw) \
+ mtx_assert(&(_lhw)->scan_mtx, MA_NOTOWNED)
+
+#define LKPI_80211_LHW_TXQ_LOCK_INIT(_lhw) \
+ mtx_init(&(_lhw)->txq_mtx, "lhw-txq", NULL, MTX_DEF | MTX_RECURSE);
+#define LKPI_80211_LHW_TXQ_LOCK_DESTROY(_lhw) \
+ mtx_destroy(&(_lhw)->txq_mtx);
+#define LKPI_80211_LHW_TXQ_LOCK(_lhw) \
+ mtx_lock(&(_lhw)->txq_mtx)
+#define LKPI_80211_LHW_TXQ_UNLOCK(_lhw) \
+ mtx_unlock(&(_lhw)->txq_mtx)
+#define LKPI_80211_LHW_TXQ_LOCK_ASSERT(_lhw) \
+ mtx_assert(&(_lhw)->txq_mtx, MA_OWNED)
+#define LKPI_80211_LHW_TXQ_UNLOCK_ASSERT(_lhw) \
+ mtx_assert(&(_lhw)->txq_mtx, MA_NOTOWNED)
+
+#define LKPI_80211_LHW_RXQ_LOCK_INIT(_lhw) \
+ mtx_init(&(_lhw)->rxq_mtx, "lhw-rxq", NULL, MTX_DEF | MTX_RECURSE);
+#define LKPI_80211_LHW_RXQ_LOCK_DESTROY(_lhw) \
+ mtx_destroy(&(_lhw)->rxq_mtx);
+#define LKPI_80211_LHW_RXQ_LOCK(_lhw) \
+ mtx_lock(&(_lhw)->rxq_mtx)
+#define LKPI_80211_LHW_RXQ_UNLOCK(_lhw) \
+ mtx_unlock(&(_lhw)->rxq_mtx)
+#define LKPI_80211_LHW_RXQ_LOCK_ASSERT(_lhw) \
+ mtx_assert(&(_lhw)->rxq_mtx, MA_OWNED)
+#define LKPI_80211_LHW_RXQ_UNLOCK_ASSERT(_lhw) \
+ mtx_assert(&(_lhw)->rxq_mtx, MA_NOTOWNED)
#define LKPI_80211_LHW_LVIF_LOCK(_lhw) sx_xlock(&(_lhw)->lvif_sx)
#define LKPI_80211_LHW_LVIF_UNLOCK(_lhw) sx_xunlock(&(_lhw)->lvif_sx)
@@ -191,12 +341,35 @@ struct lkpi_wiphy {
#define LKPI_80211_LVIF_LOCK(_lvif) mtx_lock(&(_lvif)->mtx)
#define LKPI_80211_LVIF_UNLOCK(_lvif) mtx_unlock(&(_lvif)->mtx)
-#define LKPI_80211_LSTA_LOCK(_lsta) mtx_lock(&(_lsta)->txq_mtx)
-#define LKPI_80211_LSTA_UNLOCK(_lsta) mtx_unlock(&(_lsta)->txq_mtx)
-
+#define LKPI_80211_LSTA_TXQ_LOCK_INIT(_lsta) \
+ mtx_init(&(_lsta)->txq_mtx, "lsta-txq", NULL, MTX_DEF);
+#define LKPI_80211_LSTA_TXQ_LOCK_DESTROY(_lsta) \
+ mtx_destroy(&(_lsta)->txq_mtx);
+#define LKPI_80211_LSTA_TXQ_LOCK(_lsta) \
+ mtx_lock(&(_lsta)->txq_mtx)
+#define LKPI_80211_LSTA_TXQ_UNLOCK(_lsta) \
+ mtx_unlock(&(_lsta)->txq_mtx)
+#define LKPI_80211_LSTA_TXQ_LOCK_ASSERT(_lsta) \
+ mtx_assert(&(_lsta)->txq_mtx, MA_OWNED)
+#define LKPI_80211_LSTA_TXQ_UNLOCK_ASSERT(_lsta) \
+ mtx_assert(&(_lsta)->txq_mtx, MA_NOTOWNED)
+
+#define LKPI_80211_LTXQ_LOCK_INIT(_ltxq) \
+ mtx_init(&(_ltxq)->ltxq_mtx, "ltxq", NULL, MTX_DEF);
+#define LKPI_80211_LTXQ_LOCK_DESTROY(_ltxq) \
+ mtx_destroy(&(_ltxq)->ltxq_mtx);
+#define LKPI_80211_LTXQ_LOCK(_ltxq) \
+ mtx_lock(&(_ltxq)->ltxq_mtx)
+#define LKPI_80211_LTXQ_UNLOCK(_ltxq) \
+ mtx_unlock(&(_ltxq)->ltxq_mtx)
+#define LKPI_80211_LTXQ_LOCK_ASSERT(_ltxq) \
+ mtx_assert(&(_ltxq)->ltxq_mtx, MA_OWNED)
+#define LKPI_80211_LTXQ_UNLOCK_ASSERT(_ltxq) \
+ mtx_assert(&(_ltxq)->ltxq_mtx, MA_NOTOWNED)
int lkpi_80211_mo_start(struct ieee80211_hw *);
void lkpi_80211_mo_stop(struct ieee80211_hw *);
+int lkpi_80211_mo_get_antenna(struct ieee80211_hw *, u32 *, u32 *);
int lkpi_80211_mo_set_frag_threshold(struct ieee80211_hw *, uint32_t);
int lkpi_80211_mo_set_rts_threshold(struct ieee80211_hw *, uint32_t);
int lkpi_80211_mo_add_interface(struct ieee80211_hw *, struct ieee80211_vif *);
@@ -212,12 +385,12 @@ u64 lkpi_80211_mo_prepare_multicast(struct ieee80211_hw *,
void lkpi_80211_mo_configure_filter(struct ieee80211_hw *, unsigned int,
unsigned int *, u64);
int lkpi_80211_mo_sta_state(struct ieee80211_hw *, struct ieee80211_vif *,
- struct ieee80211_sta *, enum ieee80211_sta_state);
+ struct lkpi_sta *, enum ieee80211_sta_state);
int lkpi_80211_mo_config(struct ieee80211_hw *, uint32_t);
int lkpi_80211_mo_assign_vif_chanctx(struct ieee80211_hw *, struct ieee80211_vif *,
- struct ieee80211_chanctx_conf *);
+ struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf *);
void lkpi_80211_mo_unassign_vif_chanctx(struct ieee80211_hw *, struct ieee80211_vif *,
- struct ieee80211_chanctx_conf **);
+ struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf **);
int lkpi_80211_mo_add_chanctx(struct ieee80211_hw *, struct ieee80211_chanctx_conf *);
void lkpi_80211_mo_change_chanctx(struct ieee80211_hw *,
struct ieee80211_chanctx_conf *, uint32_t);
@@ -226,7 +399,7 @@ void lkpi_80211_mo_remove_chanctx(struct ieee80211_hw *,
void lkpi_80211_mo_bss_info_changed(struct ieee80211_hw *, struct ieee80211_vif *,
struct ieee80211_bss_conf *, uint64_t);
int lkpi_80211_mo_conf_tx(struct ieee80211_hw *, struct ieee80211_vif *,
- uint16_t, const struct ieee80211_tx_queue_params *);
+ uint32_t, uint16_t, const struct ieee80211_tx_queue_params *);
void lkpi_80211_mo_flush(struct ieee80211_hw *, struct ieee80211_vif *,
uint32_t, bool);
void lkpi_80211_mo_mgd_prepare_tx(struct ieee80211_hw *, struct ieee80211_vif *,
@@ -242,5 +415,8 @@ void lkpi_80211_mo_sta_pre_rcu_remove(struct ieee80211_hw *,
int lkpi_80211_mo_set_key(struct ieee80211_hw *, enum set_key_cmd,
struct ieee80211_vif *, struct ieee80211_sta *,
struct ieee80211_key_conf *);
+int lkpi_80211_mo_ampdu_action(struct ieee80211_hw *, struct ieee80211_vif *,
+ struct ieee80211_ampdu_params *);
+
#endif /* _LKPI_SRC_LINUX_80211_H */