From nobody Thu Oct 31 20:52:38 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Xfbm66Qz7z5cMXN; Thu, 31 Oct 2024 20:52:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xfbm65LPlz4hbd; Thu, 31 Oct 2024 20:52:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730407958; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JA/zMARWMDC8apBzT6mQJgUiZJ8hqbCNdOjv1o01+wE=; b=YaVWGgdjhQh3kBXF0vgqes91KqItb9jv6pbGqMdK1kthFP/oAHu91eRxvCtJ4Y+zUQh4uN TaihXjFgAdIuSVqHgKEUDpnueyBmgmDCP684X1mxwWx4l4hdenY0X+lt+2lY5LCCDbxm3K q5tm3GU3gf+ENENBcYwVvKCDMS6fp5fMgNHquAUm4IbOKuiLhdS9WBv7X7DfdvQZlQTxJD xqjqTBXW9EjOt/4aR07VfA3tLrGTpinuMRnwOT18Kqt2ZE/8oqPdLFpegr5C+iENQTkvCq +mruIZ8Da3VB8cjBtOMS5rlGgS4bnzude1PS94e7eEbPM4HI5xWlwfj3UayszA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730407958; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JA/zMARWMDC8apBzT6mQJgUiZJ8hqbCNdOjv1o01+wE=; b=LD8qUrKl0pSZ+lvMNWkRDsnN+vMqQFBOLFOIG4vTWQhYF0iXNMAer/j/SmCAVH3GXCoNE8 Jf/BoS5ui0o9yE759qDpU8Z201e6lI/yiFTXs84P6RGmimTcOCmareNPVJtKoSehXX/Iqf hRfbwwpaflGXr0vfhlj+M/+D9UbCjkC9/1y33bXq66vB+EMggHGqZwelzIVwhuoVD3n2zW 3mbvMfSxYkQ75U2yWGuTRRrJnWO44llorM4+q3/hSuU+G9hr+kYTU3de4mWrPi1Doi8B2I QwneoYzNnjlzrnduzImGDos+HDGkrvMPguhAW2UtPxU4DMbbflytpJpUR9XrtQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730407958; a=rsa-sha256; cv=none; b=TR/FGi3HmE0vQU0ODjNGzGwAuIy4C3Eu8dk8pSx2VYbmgjPagrysvTSWLg2M35Wt0t7kSr AAEiBRq06TW8VIez6wfQVqltZ/lqdnrDQesm8pl4p2cPDtQCykp+OLh+G7mZQmC+aEl+mw z+0Yf8wHqiZn9KkREkizhbCth/7Oasd5Ar5A34o89IE17gLGHqn8ZQ6dzsMvQvA6IMlEmJ KxNKzuZ5sbGhJbjO1n5NCFAm22/wNQn443TYdlOKRJOZWB0rRUEO73BRiSq5PdzOs7cvDM nBzVSVz5WpP/gqtbfKNRVTMR6M+C85w0iUv/9t8asUCF/d1vcISzGcSgx7RGZA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Xfbm64xkjzrhZ; Thu, 31 Oct 2024 20:52:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49VKqcZ0022510; Thu, 31 Oct 2024 20:52:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49VKqclu022507; Thu, 31 Oct 2024 20:52:38 GMT (envelope-from git) Date: Thu, 31 Oct 2024 20:52:38 GMT Message-Id: <202410312052.49VKqclu022507@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 310743c4ccc5 - main - LinuxKPI: 802.11: improvements to (*ampdu_action)() callers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 310743c4ccc545d58401cb9fb7761432e12a9fb5 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=310743c4ccc545d58401cb9fb7761432e12a9fb5 commit 310743c4ccc545d58401cb9fb7761432e12a9fb5 Author: Bjoern A. Zeeb AuthorDate: 2024-01-27 13:24:27 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-10-31 20:52:28 +0000 LinuxKPI: 802.11: improvements to (*ampdu_action)() callers Annotate lkpi_ic_recv_action(), lkpi_ic_send_action(), and lkpi_ic_ampdu_enable() with HT specifc debug logging as we only hook them up currently for debug tracing but later should not need them anymore. Start the implementation for lkpi_ic_addba_request(), lkpi_ic_addba_response(), and lkpi_ic_addba_stop(). Improve the implementation of lkpi_ic_ampdu_rx_start() and lkpi_ic_ampdu_rx_stop(). Sponsored by: The FreeBSD Foundation (commit) MFC after: 3 days --- sys/compat/linuxkpi/common/src/linux_80211.c | 206 +++++++++++++++++++++++++-- 1 file changed, 192 insertions(+), 14 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 3417c7776567..ec471db21efd 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -3986,7 +3986,7 @@ lkpi_ic_recv_action(struct ieee80211_node *ni, const struct ieee80211_frame *wh, ic = ni->ni_ic; lhw = ic->ic_softc; - IMPROVE_HT(); + IMPROVE_HT("recv_action called; nothing to do in lkpi; make debugging"); return (lhw->ic_recv_action(ni, wh, frm, efrm)); } @@ -4000,7 +4000,7 @@ lkpi_ic_send_action(struct ieee80211_node *ni, int category, int action, void *s ic = ni->ni_ic; lhw = ic->ic_softc; - IMPROVE_HT(); + IMPROVE_HT("send_action called; nothing to do in lkpi; make debugging"); return (lhw->ic_send_action(ni, category, action, sa)); } @@ -4015,52 +4015,207 @@ lkpi_ic_ampdu_enable(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap) ic = ni->ni_ic; lhw = ic->ic_softc; - IMPROVE_HT(); + IMPROVE_HT("ieee80211_ampdu_enable called; nothing to do in lkpi for now; make debugging"); return (lhw->ic_ampdu_enable(ni, tap)); } +/* + * (*ic_addba_request)() is called by ieee80211_ampdu_request() before + * calling send_action(CAT_BA, BA_ADDBA_REQUEST). + * + * NB: returns 0 on ERROR! + */ static int lkpi_ic_addba_request(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, int dialogtoken, int baparamset, int batimeout) { struct ieee80211com *ic; struct lkpi_hw *lhw; + struct ieee80211_hw *hw; + struct ieee80211vap *vap; + struct lkpi_vif *lvif; + struct ieee80211_vif *vif; + struct lkpi_sta *lsta; + struct ieee80211_sta *sta; + struct ieee80211_ampdu_params params = { }; + int error; ic = ni->ni_ic; lhw = ic->ic_softc; + hw = LHW_TO_HW(lhw); + vap = ni->ni_vap; + lvif = VAP_TO_LVIF(vap); + vif = LVIF_TO_VIF(lvif); + lsta = ni->ni_drv_data; + sta = LSTA_TO_STA(lsta); - IMPROVE_HT(); + if (!lsta->added_to_drv) { + ic_printf(ic, "%s: lsta %p ni %p, sta %p not added to firmware\n", + __func__, lsta, ni, sta); + return (0); + } + + params.sta = sta; + params.action = IEEE80211_AMPDU_TX_START; + /* Keep 0 here! */ + params.buf_size = 0; + params.timeout = 0; + params.ssn = tap->txa_start & (IEEE80211_SEQ_RANGE-1); + params.tid = tap->txa_tid; + params.amsdu = false; + + IEEE80211_UNLOCK(ic); + LKPI_80211_LHW_LOCK(lhw); + error = lkpi_80211_mo_ampdu_action(hw, vif, ¶ms); + LKPI_80211_LHW_UNLOCK(lhw); + IEEE80211_LOCK(ic); + if (error != 0) { + ic_printf(ic, "%s: mo_ampdu_action returned %d. ni %p tap %p\n", + __func__, error, ni, tap); + return (0); + } return (lhw->ic_addba_request(ni, tap, dialogtoken, baparamset, batimeout)); } +/* + * (*ic_addba_response)() is called from ht_recv_action_ba_addba_response() + * and calls the default ieee80211_addba_response() which always returns 1. + * + * NB: No error checking in net80211! + * Staying with 0 is an error. + */ static int lkpi_ic_addba_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, int status, int baparamset, int batimeout) { struct ieee80211com *ic; struct lkpi_hw *lhw; + struct ieee80211_hw *hw; + struct ieee80211vap *vap; + struct lkpi_vif *lvif; + struct ieee80211_vif *vif; + struct lkpi_sta *lsta; + struct ieee80211_sta *sta; + struct ieee80211_ampdu_params params = { }; + int error; ic = ni->ni_ic; lhw = ic->ic_softc; + hw = LHW_TO_HW(lhw); + vap = ni->ni_vap; + lvif = VAP_TO_LVIF(vap); + vif = LVIF_TO_VIF(lvif); + lsta = ni->ni_drv_data; + sta = LSTA_TO_STA(lsta); - IMPROVE_HT(); + if (!lsta->added_to_drv) { + ic_printf(ic, "%s: lsta %p ni %p, sta %p not added to firmware\n", + __func__, lsta, ni, sta); + return (0); + } + + if (status == IEEE80211_STATUS_SUCCESS) { + params.sta = sta; + params.action = IEEE80211_AMPDU_TX_OPERATIONAL; + params.buf_size = tap->txa_wnd; + params.timeout = 0; + params.ssn = 0; + params.tid = tap->txa_tid; + if ((tap->txa_flags & IEEE80211_AGGR_AMSDU) != 0) + params.amsdu = true; + else + params.amsdu = false; + } else { + /* We need to free the allocated resources. */ + params.sta = sta; + switch (status) { + /* params.action = FLUSH, FLUSH_CONT */ + default: + params.action = IEEE80211_AMPDU_TX_STOP_CONT; + break; + } + params.buf_size = 0; + params.timeout = 0; + params.ssn = 0; + params.tid = tap->txa_tid; + params.amsdu = false; + } + + IEEE80211_UNLOCK(ic); + LKPI_80211_LHW_LOCK(lhw); + error = lkpi_80211_mo_ampdu_action(hw, vif, ¶ms); + LKPI_80211_LHW_UNLOCK(lhw); + IEEE80211_LOCK(ic); + if (error != 0) { + ic_printf(ic, "%s: mo_ampdu_action returned %d. ni %p tap %p\n", + __func__, error, ni, tap); + return (0); + } + + IMPROVE_HT("who unleashes the TXQ? and when?, do we need to ni->ni_txseqs[tid] = tap->txa_start & 0xfff;"); return (lhw->ic_addba_response(ni, tap, status, baparamset, batimeout)); } +/* + * (*ic_addba_stop)() is called from ampdu_tx_stop(), ht_recv_action_ba_delba(), + * and ieee80211_ampdu_stop() and calls the default ieee80211_addba_stop(). + */ static void lkpi_ic_addba_stop(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap) { struct ieee80211com *ic; struct lkpi_hw *lhw; + struct ieee80211_hw *hw; + struct ieee80211vap *vap; + struct lkpi_vif *lvif; + struct ieee80211_vif *vif; + struct lkpi_sta *lsta; + struct ieee80211_sta *sta; + struct ieee80211_ampdu_params params = { }; + int error; ic = ni->ni_ic; lhw = ic->ic_softc; + hw = LHW_TO_HW(lhw); + vap = ni->ni_vap; + lvif = VAP_TO_LVIF(vap); + vif = LVIF_TO_VIF(lvif); + lsta = ni->ni_drv_data; + sta = LSTA_TO_STA(lsta); - IMPROVE_HT(); + if (!lsta->added_to_drv) { + ic_printf(ic, "%s: lsta %p ni %p, sta %p not added to firmware\n", + __func__, lsta, ni, sta); + goto n80211; + } + /* We need to free the allocated resources. */ + params.sta = sta; + IMPROVE("net80211 does not provide a reason to us"); + params.action = IEEE80211_AMPDU_TX_STOP_CONT; /* params.action = FLUSH, FLUSH_CONT */ + params.buf_size = 0; + params.timeout = 0; + params.ssn = 0; + params.tid = tap->txa_tid; + params.amsdu = false; + + IEEE80211_UNLOCK(ic); + LKPI_80211_LHW_LOCK(lhw); + error = lkpi_80211_mo_ampdu_action(hw, vif, ¶ms); + LKPI_80211_LHW_UNLOCK(lhw); + IEEE80211_LOCK(ic); + if (error != 0) { + ic_printf(ic, "%s: mo_ampdu_action returned %d. ni %p tap %p\n", + __func__, error, ni, tap); + goto n80211; + } + + IMPROVE_HT("anyting else?"); + +n80211: lhw->ic_addba_stop(ni, tap); } @@ -4104,8 +4259,8 @@ lkpi_ic_ampdu_rx_start(struct ieee80211_node *ni, struct ieee80211_rx_ampdu *rap struct lkpi_vif *lvif; struct ieee80211_vif *vif; struct lkpi_sta *lsta; - struct ieee80211_sta *sta; - struct ieee80211_ampdu_params params; + struct ieee80211_sta *sta; + struct ieee80211_ampdu_params params = { }; int error; ic = ni->ni_ic; @@ -4117,6 +4272,14 @@ lkpi_ic_ampdu_rx_start(struct ieee80211_node *ni, struct ieee80211_rx_ampdu *rap lsta = ni->ni_drv_data; sta = LSTA_TO_STA(lsta); + IEEE80211_UNLOCK_ASSERT(ic); + + if (!lsta->added_to_drv) { + ic_printf(ic, "%s: lsta %p ni %p vap %p, sta %p not added to firmware\n", + __func__, lsta, ni, vap, sta); + return (-ENXIO); + } + params.sta = sta; params.action = IEEE80211_AMPDU_RX_START; params.buf_size = _IEEE80211_MASKSHIFT(le16toh(baparamset), IEEE80211_BAPS_BUFSIZ); @@ -4124,22 +4287,33 @@ lkpi_ic_ampdu_rx_start(struct ieee80211_node *ni, struct ieee80211_rx_ampdu *rap params.buf_size = IEEE80211_MAX_AMPDU_BUF_HT; else params.buf_size = min(params.buf_size, IEEE80211_MAX_AMPDU_BUF_HT); - if (params.buf_size > hw->max_rx_aggregation_subframes) + if (hw->max_rx_aggregation_subframes > 0 && + params.buf_size > hw->max_rx_aggregation_subframes) params.buf_size = hw->max_rx_aggregation_subframes; params.timeout = le16toh(batimeout); params.ssn = _IEEE80211_MASKSHIFT(le16toh(baseqctl), IEEE80211_BASEQ_START); params.tid = _IEEE80211_MASKSHIFT(le16toh(baparamset), IEEE80211_BAPS_TID); - params.amsdu = false; - IMPROVE_HT("Do we need to distinguish based on SUPPORTS_REORDERING_BUFFER?"); + /* Based on net80211::ampdu_rx_start(). */ + if ((vap->iv_htcaps & IEEE80211_HTC_RX_AMSDU_AMPDU) && + (_IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_AMSDU))) + params.amsdu = true; + else + params.amsdu = false; - /* This may call kalloc. Make sure we can sleep. */ + LKPI_80211_LHW_LOCK(lhw); error = lkpi_80211_mo_ampdu_action(hw, vif, ¶ms); + LKPI_80211_LHW_UNLOCK(lhw); if (error != 0) { ic_printf(ic, "%s: mo_ampdu_action returned %d. ni %p rap %p\n", __func__, error, ni, rap); return (error); } + + if (!ieee80211_hw_check(hw, SUPPORTS_REORDERING_BUFFER)) { + IMPROVE("%s: TODO: SUPPORTS_REORDERING_BUFFER not set; check net80211\n", __func__); + } + IMPROVE_HT("net80211 is missing the error check on return and assumes success"); error = lhw->ic_ampdu_rx_start(ni, rap, baparamset, batimeout, baseqctl); @@ -4156,8 +4330,8 @@ lkpi_ic_ampdu_rx_stop(struct ieee80211_node *ni, struct ieee80211_rx_ampdu *rap) struct lkpi_vif *lvif; struct ieee80211_vif *vif; struct lkpi_sta *lsta; - struct ieee80211_sta *sta; - struct ieee80211_ampdu_params params; + struct ieee80211_sta *sta; + struct ieee80211_ampdu_params params = { }; int error; uint8_t tid; @@ -4197,7 +4371,11 @@ lkpi_ic_ampdu_rx_stop(struct ieee80211_node *ni, struct ieee80211_rx_ampdu *rap) params.tid = tid; params.amsdu = false; + // IEEE80211_UNLOCK(ic); + LKPI_80211_LHW_LOCK(lhw); error = lkpi_80211_mo_ampdu_action(hw, vif, ¶ms); + LKPI_80211_LHW_UNLOCK(lhw); + // IEEE80211_LOCK(ic); if (error != 0) ic_printf(ic, "%s: mo_ampdu_action returned %d. ni %p rap %p\n", __func__, error, ni, rap);