From nobody Tue Mar 22 18:52:50 2022 X-Original-To: dev-commits-src-main@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 849B31A29C2D; Tue, 22 Mar 2022 18:52:51 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KNLGC0fNFz3sZC; Tue, 22 Mar 2022 18:52:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647975171; 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=lzUI+8obnBAs5SH5TF6eiJ+F1aMo04LGQACimk0GOBc=; b=gVkZM7/zc/puUzl7b2oxrP1vWNHxTgp7Tiy9oJThYnZXY0i7WW2PRxvQDOtbm/OdzP95YL WOxoQcWiM7SIPTq67B0BvgfYYnovGJPKvABq36WFMFWJLfEW3VCszcofXaEMwmlIpYEU/+ xyvoSZofC6L7pCnoEboOnFYUIxNMdeD6gi1bhH2Yp3p3w2Bh9/IzKjMZsM21oUGFriXpXi +TpqXUp3vxLqThhacbABGux8JFn7unRPAE+H5cqa+C/p4c0MBc2796WsE6AYMFj4k6RnPN FxRdEUPtokDiM3TxLW4NFj+O5nXI5K8ZsbBuE8hyE2eJXQEsHFUyuyre3sRC/w== 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 CA48215083; Tue, 22 Mar 2022 18:52:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22MIqoxS099413; Tue, 22 Mar 2022 18:52:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22MIqom0099412; Tue, 22 Mar 2022 18:52:50 GMT (envelope-from git) Date: Tue, 22 Mar 2022 18:52:50 GMT Message-Id: <202203221852.22MIqom0099412@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: 4f61ef8b78b2 - main - LinuxKPI: 802.11: factor out lkpi_lsta_alloc() from lkpi_ic_node_alloc() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 4f61ef8b78b25761b1b859ce39213f92fcbb24ce Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647975171; 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=lzUI+8obnBAs5SH5TF6eiJ+F1aMo04LGQACimk0GOBc=; b=FlVGeu1p3FqxfN19RJiuqJLtEh2YWUy+Dkjx/zFv5NmP9QlTBF47u6j6S4nmnddwKnFgpl 48NT7/lmUFuL2OeloPjEJWDgfp3s8Thz7eG2fFlVQFO/VDEiGT/E7vJxqLADzA136UlgYP RlWv+pAKAnep/F1pZynxihLSZdCkqQkorKVS1Toxafld9tE9R7cGgIeAW62+lEj9/1fFlD ReDZKPD79SzV2rxbUwR+mSavP6yXOvdG86zwqVbhaLCO6pfwWpkKvpgfVxoe4RIyB3lMLK hGGVsVugVtNBJX8CZG8jPLHV2p2QsfrnlW0urec84GM/yw89spYJ9I/ZHsCIQg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647975171; a=rsa-sha256; cv=none; b=pbrULaAlLe5FzYMs+Z4+K3EHyDepgObMqGhAG6IjHO3bgLWvuM74aH/t9q+WFWp4LtCF79 CmZ9DSMDlBAain85vmM/xHp9fYhCkxnATfvLUZEBXdNOD/SWVa6GjmxTx/VHtuhPiSo2tn pnDInqwSQkvcAXno3/sVc54pL0VjtceCxe5WYDjHuGiLaU8rWXG+tII9ll3C7e+fRNEk+g aOSd4/FkpDMflbuBnBvzV9X6UDUsjjv/3WPtKjEgumGYEMzqHqvzp6u7s4tsjY67/7eqEX SRi+S9V0+yrnOaGB6ddsrynzUxlkG9GwoFe3fVmPwP83tHudBDCM+2wsUwRlvA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=4f61ef8b78b25761b1b859ce39213f92fcbb24ce commit 4f61ef8b78b25761b1b859ce39213f92fcbb24ce Author: Bjoern A. Zeeb AuthorDate: 2022-03-22 15:14:31 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-03-22 18:51:43 +0000 LinuxKPI: 802.11: factor out lkpi_lsta_alloc() from lkpi_ic_node_alloc() Split lkpi_ic_node_alloc() into two functions to make the code simpler and to allow lkpi_lsta_alloc() to be re-used from another part of the code related to (*iv_update_bss)(). Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/compat/linuxkpi/common/src/linux_80211.c | 178 ++++++++++++++------------- 1 file changed, 95 insertions(+), 83 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index ceb9c626c507..fd5d18bca5d4 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -112,6 +112,20 @@ SYSCTL_INT(_compat_linuxkpi, OID_AUTO, debug_80211, CTLFLAG_RWTUN, /* This is DSAP | SSAP | CTRL | ProtoID/OrgCode{3}. */ const uint8_t rfc1042_header[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; +const uint8_t tid_to_mac80211_ac[] = { + IEEE80211_AC_BE, + IEEE80211_AC_BK, + IEEE80211_AC_BK, + IEEE80211_AC_BE, + IEEE80211_AC_VI, + IEEE80211_AC_VI, + IEEE80211_AC_VO, + IEEE80211_AC_VO, +#if 0 + IEEE80211_AC_VO, /* We treat MGMT as TID 8, which is set as AC_VO */ +#endif +}; + const struct cfg80211_ops linuxkpi_mac80211cfgops = { /* * XXX TODO need a "glue layer" to link cfg80211 ops to @@ -125,6 +139,79 @@ static struct lkpi_sta *lkpi_find_lsta_by_ni(struct lkpi_vif *, static void lkpi_80211_txq_task(void *, int); static void lkpi_ieee80211_free_skb_mbuf(void *); +static struct lkpi_sta * +lkpi_lsta_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN], + struct ieee80211_hw *hw, struct ieee80211_node *ni) +{ + struct lkpi_sta *lsta; + struct lkpi_vif *lvif; + struct ieee80211_vif *vif; + struct ieee80211_sta *sta; + int tid; + + lsta = malloc(sizeof(*lsta) + hw->sta_data_size, M_LKPI80211, + M_NOWAIT | M_ZERO); + if (lsta == NULL) + return (NULL); + + lsta->added_to_drv = false; + lsta->state = IEEE80211_STA_NOTEXIST; +#if 0 + /* + * This needs to be done in node_init() as ieee80211_alloc_node() + * will initialise the refcount after us. + */ + lsta->ni = ieee80211_ref_node(ni); +#endif + /* The back-pointer "drv_data" to net80211_node let's us get lsta. */ + ni->ni_drv_data = lsta; + + lvif = VAP_TO_LVIF(vap); + vif = LVIF_TO_VIF(lvif); + sta = LSTA_TO_STA(lsta); + + IEEE80211_ADDR_COPY(sta->addr, mac); + for (tid = 0; tid < nitems(sta->txq); tid++) { + struct lkpi_txq *ltxq; + + /* + * We are neither limiting ourselves to hw.queues here, + * nor do we check if driver wants IEEE80211_NUM_TIDS queue. + */ + + ltxq = malloc(sizeof(*ltxq) + hw->txq_data_size, + M_LKPI80211, M_NOWAIT | M_ZERO); + if (ltxq == NULL) + goto cleanup; + ltxq->seen_dequeue = false; + skb_queue_head_init(<xq->skbq); + /* iwlwifi//mvm/sta.c::tid_to_mac80211_ac[] */ + if (tid == IEEE80211_NUM_TIDS) { + IMPROVE(); + ltxq->txq.ac = IEEE80211_AC_VO; + } else { + ltxq->txq.ac = tid_to_mac80211_ac[tid & 7]; + } + ltxq->txq.tid = tid; + ltxq->txq.sta = sta; + ltxq->txq.vif = vif; + sta->txq[tid] = <xq->txq; + } + + /* Deferred TX path. */ + mtx_init(&lsta->txq_mtx, "lsta_txq", NULL, MTX_DEF); + TASK_INIT(&lsta->txq_task, 0, lkpi_80211_txq_task, lsta); + mbufq_init(&lsta->txq, IFQ_MAXLEN); + + return (lsta); + +cleanup: + for (; tid >= 0; tid--) + free(sta->txq[tid], M_LKPI80211); + free(lsta, M_LKPI80211); + return (NULL); +} + static enum nl80211_band lkpi_net80211_chan_to_nl80211_band(struct ieee80211_channel *c) { @@ -564,20 +651,6 @@ lkpi_update_mcast_filter(struct ieee80211com *ic, bool force) __func__, &mc_list, mc_list.count)); } -const uint8_t tid_to_mac80211_ac[] = { - IEEE80211_AC_BE, - IEEE80211_AC_BK, - IEEE80211_AC_BK, - IEEE80211_AC_BE, - IEEE80211_AC_VI, - IEEE80211_AC_VI, - IEEE80211_AC_VO, - IEEE80211_AC_VO, -#if 0 - IEEE80211_AC_VO, /* We treat MGMT as TID 8, which is set as AC_VO */ -#endif -}; - static void lkpi_stop_hw_scan(struct lkpi_hw *lhw, struct ieee80211_vif *vif) { @@ -2161,91 +2234,30 @@ lkpi_ic_node_alloc(struct ieee80211vap *vap, { struct ieee80211com *ic; struct lkpi_hw *lhw; + struct ieee80211_node *ni; struct ieee80211_hw *hw; struct lkpi_sta *lsta; - struct ieee80211_sta *sta; - struct lkpi_vif *lvif; - struct ieee80211_vif *vif; - struct ieee80211_node *ni; - int tid; ic = vap->iv_ic; lhw = ic->ic_softc; /* We keep allocations de-coupled so we can deal with the two worlds. */ - if (lhw->ic_node_alloc != NULL) { - ni = lhw->ic_node_alloc(vap, mac); - if (ni == NULL) - return (NULL); - } + if (lhw->ic_node_alloc == NULL) + return (NULL); + + ni = lhw->ic_node_alloc(vap, mac); + if (ni == NULL) + return (NULL); hw = LHW_TO_HW(lhw); - lsta = malloc(sizeof(*lsta) + hw->sta_data_size, M_LKPI80211, - M_NOWAIT | M_ZERO); + lsta = lkpi_lsta_alloc(vap, mac, hw, ni); if (lsta == NULL) { if (lhw->ic_node_free != NULL) lhw->ic_node_free(ni); return (NULL); } - lsta->added_to_drv = false; - lsta->state = IEEE80211_STA_NOTEXIST; -#if 0 - /* - * This needs to be done in node_init() as ieee80211_alloc_node() - * will initialise the refcount after us. - */ - lsta->ni = ieee80211_ref_node(ni); -#endif - /* The back-pointer "drv_data" to net80211_node let's us get lsta. */ - ni->ni_drv_data = lsta; - - lvif = VAP_TO_LVIF(vap); - vif = LVIF_TO_VIF(lvif); - sta = LSTA_TO_STA(lsta); - - IEEE80211_ADDR_COPY(sta->addr, mac); - for (tid = 0; tid < nitems(sta->txq); tid++) { - struct lkpi_txq *ltxq; - - /* - * We are neither limiting ourselves to hw.queues here, - * nor do we check if driver wants IEEE80211_NUM_TIDS queue. - */ - - ltxq = malloc(sizeof(*ltxq) + hw->txq_data_size, - M_LKPI80211, M_NOWAIT | M_ZERO); - if (ltxq == NULL) - goto cleanup; - ltxq->seen_dequeue = false; - skb_queue_head_init(<xq->skbq); - /* iwlwifi//mvm/sta.c::tid_to_mac80211_ac[] */ - if (tid == IEEE80211_NUM_TIDS) { - IMPROVE(); - ltxq->txq.ac = IEEE80211_AC_VO; - } else { - ltxq->txq.ac = tid_to_mac80211_ac[tid & 7]; - } - ltxq->txq.tid = tid; - ltxq->txq.sta = sta; - ltxq->txq.vif = vif; - sta->txq[tid] = <xq->txq; - } - - /* Deferred TX path. */ - mtx_init(&lsta->txq_mtx, "lsta_txq", NULL, MTX_DEF); - TASK_INIT(&lsta->txq_task, 0, lkpi_80211_txq_task, lsta); - mbufq_init(&lsta->txq, IFQ_MAXLEN); - return (ni); - -cleanup: - for (; tid >= 0; tid--) - free(sta->txq[tid], M_LKPI80211); - free(lsta, M_LKPI80211); - if (lhw->ic_node_free != NULL) - lhw->ic_node_free(ni); - return (NULL); } static int