Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1525170rdb; Wed, 20 Sep 2023 11:30:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuQ1AEG4bjLcoNVwwifqE+XG1F536guv67XIMH9T3/JhQRUJo1StGZiyQwnDgCenYdxB3x X-Received: by 2002:a17:902:7e8f:b0:1c4:4c0f:8d91 with SMTP id z15-20020a1709027e8f00b001c44c0f8d91mr2755677pla.69.1695234611729; Wed, 20 Sep 2023 11:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695234611; cv=none; d=google.com; s=arc-20160816; b=boDboK5s8N9iQoQG5BQCoamgFGAUqJ2ItuTFAnS/A18kxOjEC3MxkU0OIZ1+JCnizO VS6c7HVALgIEVYPPku+Lr+zQw3pJvMKVDm3j+rxCJghdVpIJWly4PTYEuJgCsa6UoKeW ajwRUDqJi3YZrHlSlRnRqxTJoDz6S2k5PEsbHPJDv5lY9VRSG8e+b7b5rvpWOCjeBkKx MDuX2ykevXG5Joqiw/71VsZ+sUvRx6MTidTXi7EVyWhUOXA+cCyOaBfkwruQ1tzwmokF eUvX3iEA988+xyDKPJnaDTA5YlC3e/ar0q+cioPpuPCjLQJ+va58ZGJQUuwqZGkDRAAw Wtag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oRUGRFWH0Yag8O3iR85AuVPSQoSzfyk6SPi7YLJ3lHw=; fh=Y2IfAqdjkYQAx7XZcGq/8JceY1atOOwfX771vvMvH7o=; b=H5/uXFovS+gplOASgtIVdVDanFhLURTsN+XBksv+cNQYck2xnJNfXCnjKrqExil9GN brLfFjKYqbqHd2KPtTiq482tlvApVAfShmdSVUMTn5yDj85CfIin35Z4oezBGWQZpmQa s2wKwDvlRks97HH/oOzoo4vdyG6meHRP+HFa04TQZ3kC9WGrmnF/kGSnCelg1I1C0cBz Nn4v+aCmCOBZWXn7pgxRcmqCgUXQAlKzC5dQKmYseq0c31n4hqSf8o3UP76y/9G3agMj 1UJD1K8+Hj80wZkZBcxmRHZbm0H0ThiuS0YWUpDQ1YGRPbj65oL/1ALVwk2FF1GjtIft 9Yxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="mA/L3Zkg"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id u11-20020a170902e80b00b001bbbbb61c71si12976334plg.399.2023.09.20.11.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 11:30:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="mA/L3Zkg"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id A3D9483266AF; Wed, 20 Sep 2023 11:27:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbjITS1L (ORCPT + 56 others); Wed, 20 Sep 2023 14:27:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229768AbjITS1K (ORCPT ); Wed, 20 Sep 2023 14:27:10 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA15B102 for ; Wed, 20 Sep 2023 11:26:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695234413; x=1726770413; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ImIZWYwbj64OIR1qqV5uzN8y9JlAcP4kuqxGbalDbCY=; b=mA/L3ZkgVWBLv5DO3lUvAeinxc8wKS8QYkZkZm4ntNJPGG/8+u7Mso55 m+aQT0KVeaGIkyYEP/NiU/vDI1g53ehRnyq4nn9HHhnnexzLEqDlCxU3m +uc8W68bJDM9S4tfw+jh3gF33iHckK9EaIn/QSx6tsJimB2ZIbJtLZh39 revGo0E0kSReQMLA7jtgGfjjZBr8AMHLWoKC3qqYQJOl5gOoGBg9uHTsz Xi2gmqy6R4TGWN6xwV61ndzxNUFsneREGeCkJA78+/E/eCnNkBIVCFR5H DcY1bJYwRfW6Oarl0dAQuABO3SBcIotlvVvn9tys4jBFzh+DKYJi0/qGJ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10839"; a="360556444" X-IronPort-AV: E=Sophos;i="6.03,162,1694761200"; d="scan'208";a="360556444" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2023 11:26:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10839"; a="723424280" X-IronPort-AV: E=Sophos;i="6.03,162,1694761200"; d="scan'208";a="723424280" Received: from dmani-mobl1.ger.corp.intel.com (HELO ggreenma-mobl2.lan) ([10.214.217.100]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2023 11:26:45 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg , Gregory Greenman Subject: [PATCH v2 15/18] wifi: mac80211: support antenna control in injection Date: Wed, 20 Sep 2023 21:25:26 +0300 Message-Id: <20230920211508.f71001aa4da9.I00ccb762a806ea62bc3d728fa3a0d29f4f285eeb@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230920182529.659973-1-gregory.greenman@intel.com> References: <20230920182529.659973-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 20 Sep 2023 11:27:31 -0700 (PDT) From: Johannes Berg Support antenna control for injection by parsing the antenna radiotap field (which may be presented multiple times) and telling the driver about the resulting antenna bitmap. Of course there's no guarantee the driver will actually honour this, just like any other injection control. If misconfigured, i.e. the injected HT/VHT MCS needs more chains than antennas are configured, the bitmap is reset to zero, indicating no selection. For now this is only set up for two anntenas so we keep more free bits, but that can be trivially extended if any driver implements support for it that can deal with hardware with more antennas. Signed-off-by: Johannes Berg Signed-off-by: Gregory Greenman --- include/linux/ieee80211.h | 2 ++ include/net/mac80211.h | 6 +++++- net/mac80211/tx.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index f2965ff3d7c1..3b02f038d509 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -1705,6 +1705,8 @@ struct ieee80211_mcs_info { #define IEEE80211_HT_MCS_TX_MAX_STREAMS 4 #define IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION 0x10 +#define IEEE80211_HT_MCS_CHAINS(mcs) ((mcs) == 32 ? 1 : (1 + ((mcs) >> 3))) + /* * 802.11n D5.0 20.3.5 / 20.6 says: * - indices 0 to 7 and 32 are single spatial stream diff --git a/include/net/mac80211.h b/include/net/mac80211.h index b3df8cb2919b..b67583ddae9c 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1178,7 +1178,11 @@ struct ieee80211_tx_info { u8 use_cts_prot:1; u8 short_preamble:1; u8 skip_table:1; - /* 2 bytes free */ + + /* for injection only (bitmap) */ + u8 antennas:2; + + /* 14 bits free */ }; /* only needed before rate control */ unsigned long jiffies; diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 932516f8cc13..a984fc54644e 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -2162,6 +2162,11 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, rate_found = true; break; + case IEEE80211_RADIOTAP_ANTENNA: + /* this can appear multiple times, keep a bitmap */ + info->control.antennas |= BIT(*iterator.this_arg); + break; + case IEEE80211_RADIOTAP_DATA_RETRIES: rate_retries = *iterator.this_arg; break; @@ -2256,8 +2261,17 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, } if (rate_flags & IEEE80211_TX_RC_MCS) { + /* reset antennas if not enough */ + if (IEEE80211_HT_MCS_CHAINS(rate) > + hweight8(info->control.antennas)) + info->control.antennas = 0; + info->control.rates[0].idx = rate; } else if (rate_flags & IEEE80211_TX_RC_VHT_MCS) { + /* reset antennas if not enough */ + if (vht_nss > hweight8(info->control.antennas)) + info->control.antennas = 0; + ieee80211_rate_set_vht(info->control.rates, vht_mcs, vht_nss); } else if (sband) { -- 2.38.1