From patchwork Tue Dec 20 21:43:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13078185 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75CB37E for ; Tue, 20 Dec 2022 21:43:24 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id n65-20020a17090a2cc700b0021bc5ef7a14so157211pjd.0 for ; Tue, 20 Dec 2022 13:43:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FDmKdCDStOBJTYeI1fytSDF+/+k8maCR22xXAvqpH7c=; b=c2EG602l6nJm0kOah+a73cugjx11b0jEH38jvWtoKh3eYZJUDh4ue6JuvJdlM/5iAh noKHaNqz9FTaQqbeI7gxhTvoL3gBiSN5+sfxirDQSBypl9DqLbw8gtb2anVWe9+AjQXv CGaIsbkx9xD8OKgVWDG+gM1m5lRB7QAtyKZabI/9OCAQ11GqICw8kHEMeIn4746Z4R7V /zkRVNMVe2uDkqZOL6FJzsQ1UXZ+vt1O8NUG4Z1vYbMagBlM7PhV6NMeftqK0uofEMYv RrN/LeT8kpnd+6Dw+cmfKHkZdvVVfhirtXNgUXB3A1GdiX01c6HkoVdZJMit1k1gFyqv IsBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FDmKdCDStOBJTYeI1fytSDF+/+k8maCR22xXAvqpH7c=; b=5howxhqtXNVnsDTgaGrhefTodLs7PJIo91pXLbMZxmimTzFIE2nxwmhwNbp6e7M7dR zLfeIK7iQocn/DsguXeGVBsEcz2IyZPCK36Dxb3wv9gfp54vYdrUbX2RHzxyOYO6Rfch LTSw5nxSZ1j1d9n4IDWAfzE4pNYzXg189P4/VX/TqIzQvVHWuel3rS2fT3ZBgOJ7XS42 Lz4Rpb0tSu4rC6TYFOSGJqa3kGlTpK3p59Y6vHtWBzXHOnkVut7OFRdrHTgXYmSqDkgM jL7/11vvzRc/k9vHvXULjKyoZugiV0jIF64qa+9blBi4046IXtaEEw4n7GPp5Z/huzQm B5eg== X-Gm-Message-State: AFqh2krNJVT8V6A8shbnbDq0KvKzn1Z1oTFTX1pnNmC8QnSObq5BbXQw eo4CTtWsWYJsK1XMLe/4VmDPhrxu26Q= X-Google-Smtp-Source: AMrXdXsM6cK4spYCktrMNH2MtK+N9ckj3OFyCrWNYG7Tj1vaWu0nIrXKZuGd7jBMiFOQnh05cy8Bfg== X-Received: by 2002:a17:90a:f317:b0:219:3a95:5b04 with SMTP id ca23-20020a17090af31700b002193a955b04mr17142253pjb.25.1671572603371; Tue, 20 Dec 2022 13:43:23 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id e88-20020a17090a6fe100b00219cf5c3829sm8153301pjk.57.2022.12.20.13.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 13:43:22 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 01/10] ap: make supported rates a common builder. Date: Tue, 20 Dec 2022 13:43:09 -0800 Message-Id: <20221220214318.2041986-1-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The supported rates IE was being built in two places. This makes that code common. Unfortunately it needs to support both an ie builder and using a pointer directly which is why it only builds the contents of the IE and the caller must set the type/length. --- src/ap.c | 68 +++++++++++++++++++++++++------------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/src/ap.c b/src/ap.c index a9027f79..595c71c9 100644 --- a/src/ap.c +++ b/src/ap.c @@ -802,6 +802,29 @@ static size_t ap_write_wsc_ie(struct ap_state *ap, return len; } +static size_t ap_build_supported_rates(struct ap_state *ap, + uint8_t *rates) +{ + uint32_t minr, maxr, count, r; + + minr = l_uintset_find_min(ap->rates); + maxr = l_uintset_find_max(ap->rates); + count = 0; + for (r = minr; r <= maxr && count < 8; r++) + if (l_uintset_contains(ap->rates, r)) { + uint8_t flag = 0; + + /* Mark only the lowest rate as Basic Rate */ + if (count == 0) + flag = 0x80; + + *rates++ = r | flag; + count++; + } + + return count; +} + static size_t ap_get_extra_ies_len(struct ap_state *ap, enum mpdu_management_subtype type, const struct mmpdu_header *client_frame, @@ -858,8 +881,7 @@ static size_t ap_build_beacon_pr_head(struct ap_state *ap, struct mmpdu_header *mpdu = (void *) out_buf; uint16_t capability = IE_BSS_CAP_ESS | IE_BSS_CAP_PRIVACY; const uint8_t *bssid = netdev_get_address(ap->netdev); - uint32_t minr, maxr, count, r; - uint8_t *rates; + size_t len; struct ie_tlv_builder builder; memset(mpdu, 0, 36); /* Zero out header + non-IE fields */ @@ -884,24 +906,8 @@ static size_t ap_build_beacon_pr_head(struct ap_state *ap, /* Supported Rates IE */ ie_tlv_builder_next(&builder, IE_TYPE_SUPPORTED_RATES); - rates = ie_tlv_builder_get_data(&builder); - - minr = l_uintset_find_min(ap->rates); - maxr = l_uintset_find_max(ap->rates); - count = 0; - for (r = minr; r <= maxr && count < 8; r++) - if (l_uintset_contains(ap->rates, r)) { - uint8_t flag = 0; - - /* Mark only the lowest rate as Basic Rate */ - if (count == 0) - flag = 0x80; - - *rates++ = r | flag; - count++; - } - - ie_tlv_builder_set_length(&builder, count); + len = ap_build_supported_rates(ap, ie_tlv_builder_get_data(&builder)); + ie_tlv_builder_set_length(&builder, len); /* DSSS Parameter Set IE for DSSS, HR, ERP and HT PHY rates */ ie_tlv_builder_next(&builder, IE_TYPE_DSSS_PARAMETER_SET); @@ -1540,8 +1546,8 @@ static uint32_t ap_assoc_resp(struct ap_state *ap, struct sta_state *sta, struct mmpdu_header *mpdu = (void *) mpdu_buf; struct mmpdu_association_response *resp; size_t ies_len = 0; + size_t len; uint16_t capability = IE_BSS_CAP_ESS | IE_BSS_CAP_PRIVACY; - uint32_t r, minr, maxr, count; memset(mpdu, 0, sizeof(*mpdu)); @@ -1561,23 +1567,9 @@ static uint32_t ap_assoc_resp(struct ap_state *ap, struct sta_state *sta, /* Supported Rates IE */ resp->ies[ies_len++] = IE_TYPE_SUPPORTED_RATES; - - minr = l_uintset_find_min(ap->rates); - maxr = l_uintset_find_max(ap->rates); - count = 0; - for (r = minr; r <= maxr && count < 8; r++) - if (l_uintset_contains(ap->rates, r)) { - uint8_t flag = 0; - - /* Mark only the lowest rate as Basic Rate */ - if (count == 0) - flag = 0x80; - - resp->ies[ies_len + 1 + count++] = r | flag; - } - - resp->ies[ies_len++] = count; - ies_len += count; + len = ap_build_supported_rates(ap, resp->ies + ies_len + 1); + resp->ies[ies_len++] = len; + ies_len += len; ies_len += ap_write_extra_ies(ap, stype, req, req_len, resp->ies + ies_len); From patchwork Tue Dec 20 21:43:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13078186 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCA688F75 for ; Tue, 20 Dec 2022 21:43:24 +0000 (UTC) Received: by mail-pj1-f50.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso162482pjt.0 for ; Tue, 20 Dec 2022 13:43:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZhdFfKuUELe8YmAY2y1ETVrJG+tP9cUhU7kQK4uAlCI=; b=mbubsD277a4TclDFRP61TVGEkPnxoGAwJhcutJOkG9Bv6wA/3g3lhrVuxy7BWwaM2u fbgxz1ufkxlwX50M2N2HdzEfin8FnNoSB1kmbzoRLYnMWpWQLD8ZPD7ol5KyEukgZrzA ur4u06wvzLUhIJbGUUNzbihIgBkcbUj41uRon8C4ymDhZ1ekXAKtCqeM61IOl2NtVu2j o+5ZFyyBpy3oHYda5BRRB23OhrA+BdLk86kGpbUMM4/9hVTv9kX2KN65rRUdfj4lAyux pUSwTM8RFDmk0Uc3lUMqG3hT9LcoPtw+q7ed19Sa7tp7/o0N+gQUqW/WjqM6mJDHkGfR jLiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZhdFfKuUELe8YmAY2y1ETVrJG+tP9cUhU7kQK4uAlCI=; b=15cHLUeIxl1AKiU9G/eXyaTAzwBHtFSzbGmizWJrVQdlVA9RY0RIc7V+2udwSM/ygt dE5iJBGLoWZNBb+U21dSpoFr6FaXo/4GMrUt+eNpir8bskngrTOEwG9Gko09GD57absH OSd9I86ngbwCqVhdspT+W041Q6VOvW3FZNOcc7LNO3seAO9/qsr3caeZhHyytGP83F+D ML+vVXZk0/5DaEplJythJF8RzeiGe4aw/mPktnyRJpXVLAmLedG0zqU1jm+TyVvUdQIM loX4YfB7Uvrq0yTNWnCwfYtaMcVt/RpukTLpngGY5bF/hk3Gzkd56oYPCshyKhHMXwqH wF+A== X-Gm-Message-State: ANoB5ploBpK9q4lTmQE68qbZ2CO1dZH7K1JFqjSINKZwuPm5Vi8Q6hRa i/NhAbRMiBMMkm7Z1o/x6vTBYwcITQc= X-Google-Smtp-Source: AA0mqf6rwHWKKwQFeDn5ay58Pqu3BgT1Pfzh7PpXFpXmAdKcSldSGA2HKIdDK3k7I/JS8I6nj81T5w== X-Received: by 2002:a17:90a:d347:b0:219:9676:fef5 with SMTP id i7-20020a17090ad34700b002199676fef5mr49867804pjx.12.1671572604137; Tue, 20 Dec 2022 13:43:24 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id e88-20020a17090a6fe100b00219cf5c3829sm8153301pjk.57.2022.12.20.13.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 13:43:23 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 02/10] nl80211util: parse additional channel restriction flags Date: Tue, 20 Dec 2022 13:43:10 -0800 Message-Id: <20221220214318.2041986-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221220214318.2041986-1-prestwoj@gmail.com> References: <20221220214318.2041986-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/band.h | 5 +++++ src/nl80211util.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/band.h b/src/band.h index da4c0ae5..e196a416 100644 --- a/src/band.h +++ b/src/band.h @@ -59,6 +59,11 @@ struct band_freq_attrs { bool supported : 1; bool disabled : 1; bool no_ir : 1; + bool no_ht40_plus : 1; + bool no_ht40_minus : 1; + bool no_80mhz : 1; + bool no_160mhz : 1; + bool no_he : 1; } __attribute__ ((packed)); struct band { diff --git a/src/nl80211util.c b/src/nl80211util.c index 712cdec3..400871fd 100644 --- a/src/nl80211util.c +++ b/src/nl80211util.c @@ -533,6 +533,21 @@ int nl80211_parse_supported_frequencies(struct l_genl_attr *band_freqs, case NL80211_FREQUENCY_ATTR_NO_IR: freq_attr.no_ir = true; break; + case NL80211_FREQUENCY_ATTR_NO_HT40_MINUS: + freq_attr.no_ht40_minus = true; + break; + case NL80211_FREQUENCY_ATTR_NO_HT40_PLUS: + freq_attr.no_ht40_plus = true; + break; + case NL80211_FREQUENCY_ATTR_NO_80MHZ: + freq_attr.no_80mhz = true; + break; + case NL80211_FREQUENCY_ATTR_NO_160MHZ: + freq_attr.no_160mhz = true; + break; + case NL80211_FREQUENCY_ATTR_NO_HE: + freq_attr.no_he = true; + break; } } From patchwork Tue Dec 20 21:43:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13078187 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F6ED8F76 for ; Tue, 20 Dec 2022 21:43:25 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so128204pjj.2 for ; Tue, 20 Dec 2022 13:43:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=00KWylBOnhMgUVU8WSuUTOt45h+P4F1QEAlCiWoOQmY=; b=cXlpG/w9rrAZ+1DTS5AT9lD/FXBFxbOzhnXwsqEwsAtGmr9lbr5oC9IejRFejCRyAy 7ClgcB1ZT07n7W/zpwRMgzVgQOZ1+N+seSHZMTwjTaOtbMndH6nbSGi2ZdA3ttoQ09J/ Qz5tVRJqzhZpK+D3eHQD9MIhKzOhdRQ6JIpiONiIcsaO7ckMF3QtA9AZoriAsz3MUwM1 NYfcHMZYeGmR0BOcrVKjW0oCejtRh7H6jjHjUPUfmrALHC8uCqMP1RYY0Z2JlMDLxuA0 mc1DOBYxhrxR9/qzlE/6VW4SPohhHiCpSRn/4Qo/UVN24tI3zv2M3bM6QrBPjAvNEbvl FLVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=00KWylBOnhMgUVU8WSuUTOt45h+P4F1QEAlCiWoOQmY=; b=vHDYwwx3kvfGPVIQLYmvdIqdctuPWS0L1jZvtkbcJRrZKhVFrI2e4YQLCJNl0S3Qcy j4pINfLYCGwCGZN1tY/1B/nKiJ3DjN/013+fHa2EothYszZZ71LqjyewWnjHwmgoO8R+ n4/AJ7CAFVAwp2p+BhELE+0bRy9MBDZmu9vNSdNWaWNX76r4MJB7H+Ub1uUhYD4/gL8U tNGl+1kXuzm+HSEqnwZsjzO59mK1e3aSzE19Siq4iE/B+qyzaGPRbUVsEw0/X5qzDoyz SGo/3E9TNgJmqD2oUMjrYQHDp7ttzLuPrn3IH5d/5RKKvSFiAwenFvryV4+RGUUwWcz6 SBcg== X-Gm-Message-State: ANoB5plGB0IzYID1rBi24Y5Rtw7WtJliz6rUo5yk3T+rMZQlbnOVorMn I+OVuLhZPQVd+M6ztsuiVn6MCHj4VXQ= X-Google-Smtp-Source: AA0mqf4o679rwgtt4/UwuIjGRKIYJNnNQUPzlcl8chv/p3g/jOSzgqLddaeupEfLHUCYzv21WX9oaA== X-Received: by 2002:a17:90a:4f4b:b0:219:15b0:3da3 with SMTP id w11-20020a17090a4f4b00b0021915b03da3mr48281182pjl.37.1671572604801; Tue, 20 Dec 2022 13:43:24 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id e88-20020a17090a6fe100b00219cf5c3829sm8153301pjk.57.2022.12.20.13.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 13:43:24 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 03/10] band: add ampdu_params value Date: Tue, 20 Dec 2022 13:43:11 -0800 Message-Id: <20221220214318.2041986-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221220214318.2041986-1-prestwoj@gmail.com> References: <20221220214318.2041986-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is the last bit of information the kernel exposes about the hardware's HT capabilities. --- src/band.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/band.h b/src/band.h index e196a416..a4652fd8 100644 --- a/src/band.h +++ b/src/band.h @@ -77,6 +77,7 @@ struct band { bool vht_supported : 1; uint8_t ht_mcs_set[16]; uint8_t ht_capabilities[2]; + uint8_t ht_ampdu_params; bool ht_supported : 1; uint16_t supported_rates_len; uint8_t supported_rates[]; From patchwork Tue Dec 20 21:43:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13078188 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B17D7E for ; Tue, 20 Dec 2022 21:43:26 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id n4so13641260plp.1 for ; Tue, 20 Dec 2022 13:43:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cEaqBAJs8KZVx6xGYybMYXUTMKboq4SR+aoTKzl27iY=; b=ijr/dBmGu04WZVHRtMfZWvtKHRRnrzaW9rLZmWSa+B3bjh4jEZDqQXCNlih/kTYVwt XHoQAG4WpH1qo8SslOom30s+EB2yq17YI23Ge1CFgEB0XAgb/wByLYqgGWtHQQMaNvgO IE/ynErfgl4TRUS8NwzlrhzxDqg3abEwpc0Vt8i7isS+3Ivc/MJjOaJgQgXNwTokQcVe XK0zpZF9AJCzXWpgPBIRf1sFVXpQu7lnSFFJFqAvWESpgnihFyz4vuJX/M/D+BVJw6X+ OoxTrurXtV5tqp95K9LDKibrDgKW9DTKLg5r+23RZThwjWrjga0JdVVEexXSVOIbk5dI Fa9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cEaqBAJs8KZVx6xGYybMYXUTMKboq4SR+aoTKzl27iY=; b=tjPuWwCQqKbF5hWVd2DLFEnZmZ/5JTN5A1nv94XJLXXANVkeDS9Oggn330ATg/2qam 4+VkypgejEZ68rnfhHtFEAJNHgNBYZrppr1K7ciNAH4AVT585RBfFfbYI5vh2tJVOBff mj+KEzQnJX+juJE/7nplWAIfBCS/v0YdvRwhBdVd+lBboKyDgbEd8e0/yHpMnIqCN4GL /0TWMRqSA0pwQIaBwRqehYnZ1y0bDVJGoHEaLnEFbR7/myG8PbgkrAzhhfZbYpoEe5+E 8eDG0wsMpwPrkBgz9eU/ijVywDdC+cU8c/wdpDRp0lc4zFQmBAaj7RuITjLHdMGpXAI2 TAdQ== X-Gm-Message-State: AFqh2kpfbs3nCMJp/OLKCNkHSWn3qyIwbCXPq5aiMFlSWDaChNUmjpYm 4W+cFZ0btLGgTRRZzCfa2vQV+zj+eVM= X-Google-Smtp-Source: AMrXdXsr5/jcPzCJM9A4Pj2hVayDZ311NPmMV0tDp8a53hrZ6iCVfsAsqVqHMxLIqyJiB5HwQhpEPQ== X-Received: by 2002:a17:90a:cc2:b0:219:9973:2746 with SMTP id 2-20020a17090a0cc200b0021999732746mr14938110pjt.0.1671572605631; Tue, 20 Dec 2022 13:43:25 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id e88-20020a17090a6fe100b00219cf5c3829sm8153301pjk.57.2022.12.20.13.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 13:43:25 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 04/10] wiphy: add getter for HT capabilities Date: Tue, 20 Dec 2022 13:43:12 -0800 Message-Id: <20221220214318.2041986-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221220214318.2041986-1-prestwoj@gmail.com> References: <20221220214318.2041986-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This adds some additional parsing to obtain the AMPDU parameter byte as well as wiphy_get_ht_capabilities() which returns the complete IE (combining the 3 separate kernel attributes). --- src/wiphy.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/wiphy.h | 3 +++ 2 files changed, 56 insertions(+) diff --git a/src/wiphy.c b/src/wiphy.c index 4ea7c3f8..ab8aa6c0 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -910,6 +910,42 @@ bool wiphy_country_is_unknown(struct wiphy *wiphy) (cc[0] == 'X' && cc[1] == 'X')); } +const uint8_t *wiphy_get_ht_capabilities(const struct wiphy *wiphy, + enum band_freq band, + size_t *size) +{ + static uint8_t ht_capa[26]; + const struct band *bandp = wiphy_get_band(wiphy, band); + + if (!bandp) + return NULL; + + if (!bandp->ht_supported) + return NULL; + + memset(ht_capa, 0, sizeof(ht_capa)); + + /* + * The kernel segments the HT capabilities element into multiple + * attributes. For convenience on the caller just combine them and + * return the full IE rather than adding 3 separate getters. This also + * provides a way to check if HT is supported. + */ + memcpy(ht_capa, bandp->ht_capabilities, 2); + ht_capa[2] = bandp->ht_ampdu_params; + memcpy(ht_capa + 3, bandp->ht_mcs_set, 16); + + /* + * TODO: HT Extended capabilities, beamforming, and ASEL capabilities + * are not available to get from the kernel, leave as zero. + */ + + if (size) + *size = sizeof(ht_capa); + + return ht_capa; +} + int wiphy_estimate_data_rate(struct wiphy *wiphy, const void *ies, uint16_t ies_len, const struct scan_bss *bss, @@ -1617,6 +1653,23 @@ static void parse_supported_bands(struct wiphy *wiphy, memcpy(band->ht_capabilities, data, len); band->ht_supported = true; break; + /* + * AMPDU factor/density are part of A-MPDU Parameters, + * 802.11-2020 Section 9.4.2.55.3. + */ + case NL80211_BAND_ATTR_HT_AMPDU_FACTOR: + if (L_WARN_ON(len != 1)) + continue; + + band->ht_ampdu_params |= l_get_u8(data) & 0x3; + break; + case NL80211_BAND_ATTR_HT_AMPDU_DENSITY: + if (L_WARN_ON(len != 1)) + continue; + + band->ht_ampdu_params |= + (l_get_u8(data) & 0x7) >> 2; + break; case NL80211_BAND_ATTR_IFTYPE_DATA: if (!l_genl_attr_recurse(&attr, &nested)) continue; diff --git a/src/wiphy.h b/src/wiphy.h index 6616da61..5cf22537 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -138,6 +138,9 @@ bool wiphy_get_rsnxe(const struct wiphy *wiphy, uint8_t *buf, size_t len); void wiphy_get_reg_domain_country(struct wiphy *wiphy, char *out); bool wiphy_country_is_unknown(struct wiphy *wiphy); +const uint8_t *wiphy_get_ht_capabilities(const struct wiphy *wiphy, + enum band_freq band, + size_t *size); void wiphy_generate_random_address(struct wiphy *wiphy, uint8_t addr[static 6]); void wiphy_generate_address_from_ssid(struct wiphy *wiphy, const char *ssid, uint8_t addr[static 6]); From patchwork Tue Dec 20 21:43:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13078189 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40EE28F75 for ; Tue, 20 Dec 2022 21:43:27 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so99984pje.5 for ; Tue, 20 Dec 2022 13:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WwFeoDNVXoxMz9Xc4iy4fI0FlAsU/4vYOHosD/5Cras=; b=dYzk5u7cTXE45YgMZXVNMiTJ9PEwEU/UGL5MYXhL9uHfJUjPebvHGgKjXQbztogh7B gC0Kd3qWCTUwZ4L3gWbb/9Bz/8a/D96ffKxXplMKRe97Fvvmk7SoakPFpnwCzExGrsnE 3mAkNAgMJYaWA9oKOMKcHhFXaEuvVkCMV/0Q4G3QIpoNnVWh9UsHpXfEn7doISLDh1tq yaXAky5KrztupJ5UEOq4hb2g86aZWxO4BPZTJ62QsHQqG8ZTxCAhqrn3cjaSQXTf19cu 5e9Jpq/Sf9W3KbrXEUaHVKk9oipG4oG2YWy3X8td6lpN/eAGZpnmRuloCRUCfxDWSqz/ TTZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WwFeoDNVXoxMz9Xc4iy4fI0FlAsU/4vYOHosD/5Cras=; b=27envnonQmgZgKDSl/mRfpeVmrEe+4vvE+Bd6vWG46K1DZ1vpJvJSswOkn1jC4RxcL a4JBv8q29LXM0UcO6CzA3Bm1MuCYGjgKP/p48rufWFowXG+1TRxnJ2kkW9uZnSYAQM5j FbWqkD4WC5tHgLzMe/H7bcNV2aX24pOfKv5MOB1IlS84yI+IzpTpWqHUpO2zR6od2EAf u7+aoRjBdEWKcA8oaXqpYXDQgDuVHIYHMZh6nxezgUt27v4sf/6CjmbNbclJ9+zJXrSl gUoRBE9fcUWmlxugbl8Ai1SdvE52HPBRTzdh7cgM97rJWePmNy66UFeuaor/GXZ2RRuy 6PiQ== X-Gm-Message-State: ANoB5plnMH7f35aXPbMySd8IwgmConYCRlQ3Drd4tKoneQh1rPqsEV0m zDRoIzWDJxEtKdRq63ZM8H2Og0ldplo= X-Google-Smtp-Source: AA0mqf4AWG/iiRoZrG7H7fJoB5pOtGXwae48J/vvE3770xf7wB0+cMibtHjSTPgE02R85h9Auv+vsA== X-Received: by 2002:a17:90a:1b0e:b0:219:787c:4925 with SMTP id q14-20020a17090a1b0e00b00219787c4925mr49646943pjq.14.1671572606504; Tue, 20 Dec 2022 13:43:26 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id e88-20020a17090a6fe100b00219cf5c3829sm8153301pjk.57.2022.12.20.13.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 13:43:25 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 05/10] band: add APIs to generate a chandef from frequency Date: Tue, 20 Dec 2022 13:43:13 -0800 Message-Id: <20221220214318.2041986-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221220214318.2041986-1-prestwoj@gmail.com> References: <20221220214318.2041986-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For AP mode its convenient for IWD to choose an appropriate channel definition rather than require the user provide very low level parameters such as channel width, center1 frequency etc. This adds two new APIs to generate a channel definition, one for legacy and one for HT. The legacy API is very simple and chooses the first matching operating class using 20Mhz channel widths. The HT API is a bit more complex since it has to take into account 40MHz and check any channel restrictions. If an operating class is found that is supported/not restricted it is marked as 'best' until a better one is found. In this case 'better' is a larger channel width. Since this is HT only 20mhz and 40mhz widths are checked. --- src/band.c | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/band.h | 4 ++ 2 files changed, 163 insertions(+) diff --git a/src/band.c b/src/band.c index d89b2a90..b1e319d7 100644 --- a/src/band.c +++ b/src/band.c @@ -1194,6 +1194,165 @@ int oci_from_chandef(const struct band_chandef *own, uint8_t oci[static 3]) return -ENOENT; } +static bool freq_in_oper_class(uint32_t freq, + const struct operating_class_info *info, + enum band_freq *out_band) +{ + uint8_t channel; + enum band_freq band; + + channel = band_freq_to_channel(freq, &band); + if (!channel) + return false; + + switch (band) { + case BAND_FREQ_2_4_GHZ: + if (info->starting_frequency > 5000) + return false; + break; + case BAND_FREQ_5_GHZ: + if (info->starting_frequency < 5000 || + info->starting_frequency > 5950) + return false; + break; + case BAND_FREQ_6_GHZ: + if (info->starting_frequency < 5900) + return false; + break; + } + + if (e4_channel_to_frequency(info, channel) < 0) + return false; + + if (out_band) + *out_band = band; + + return true; +} + +/* Find a legacy chandef for the frequency */ +int band_freq_to_chandef(uint32_t freq, const struct band_freq_attrs *attr, + struct band_chandef *chandef) +{ + enum band_freq band; + uint8_t channel; + unsigned int i; + const struct operating_class_info *best = NULL; + + channel = band_freq_to_channel(freq, &band); + if (!channel) + return -EINVAL; + + if (attr->disabled || !attr->supported) + return -EINVAL; + + for (i = 0; i < L_ARRAY_SIZE(e4_operating_classes); i++) { + const struct operating_class_info *info = + &e4_operating_classes[i]; + + if (!freq_in_oper_class(freq, info, NULL)) + continue; + + if (info->channel_spacing != 20) + continue; + + best = info; + break; + } + + if (!best) + return -ENOENT; + + chandef->frequency = freq; + chandef->channel_width = BAND_CHANDEF_WIDTH_20NOHT; + + return 0; +} + +/* Find an HT chandef for the frequency */ +int band_freq_to_ht_chandef(uint32_t freq, const struct band_freq_attrs *attr, + struct band_chandef *chandef) +{ + enum band_freq band; + enum band_chandef_width width; + unsigned int i; + const struct operating_class_info *best = NULL; + + if (attr->disabled || !attr->supported) + return -EINVAL; + + for (i = 0; i < L_ARRAY_SIZE(e4_operating_classes); i++) { + const struct operating_class_info *info = + &e4_operating_classes[i]; + enum band_chandef_width w; + + if (!freq_in_oper_class(freq, info, &band)) + continue; + + /* Any restrictions for this channel width? */ + switch (info->channel_spacing) { + case 20: + w = BAND_CHANDEF_WIDTH_20; + break; + case 40: + w = BAND_CHANDEF_WIDTH_40; + + /* 6GHz remove the upper/lower 40mhz channel concept */ + if (band == BAND_FREQ_6_GHZ) + break; + + if (info->flags & PRIMARY_CHANNEL_UPPER && + attr->no_ht40_plus) + continue; + + if (info->flags & PRIMARY_CHANNEL_LOWER && + attr->no_ht40_minus) + continue; + + break; + default: + continue; + } + + if (!best || best->channel_spacing < info->channel_spacing) { + best = info; + width = w; + } + } + + if (!best) + return -ENOENT; + + chandef->frequency = freq; + chandef->channel_width = width; + + /* + * Choose a secondary channel frequency: + * - 20mhz no secondary + * - 40mhz we can base the selection off the channel flags, either + * higher or lower. + */ + switch (width) { + case BAND_CHANDEF_WIDTH_20: + return 0; + case BAND_CHANDEF_WIDTH_40: + if (band == BAND_FREQ_6_GHZ) + return 0; + + if (best->flags & PRIMARY_CHANNEL_UPPER) + chandef->center1_frequency = freq - 10; + else + chandef->center1_frequency = freq + 10; + + return 0; + default: + /* Should never happen */ + return -EINVAL; + } + + return 0; +} + uint8_t band_freq_to_channel(uint32_t freq, enum band_freq *out_band) { uint32_t channel = 0; diff --git a/src/band.h b/src/band.h index a4652fd8..f7f0c318 100644 --- a/src/band.h +++ b/src/band.h @@ -101,6 +101,10 @@ int band_estimate_nonht_rate(const struct band *band, const uint8_t *supported_rates, const uint8_t *ext_supported_rates, int32_t rssi, uint64_t *out_data_rate); +int band_freq_to_chandef(uint32_t freq, const struct band_freq_attrs *attr, + struct band_chandef *chandef); +int band_freq_to_ht_chandef(uint32_t freq, const struct band_freq_attrs *attr, + struct band_chandef *chandef); int oci_to_frequency(uint32_t operating_class, uint32_t channel); From patchwork Tue Dec 20 21:43:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13078190 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08B0B7E for ; Tue, 20 Dec 2022 21:43:27 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id 4so13628156plj.3 for ; Tue, 20 Dec 2022 13:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ek5hqy6TWDWFNDt2QXR4ustj3ResW2SSPn9ODwkCkzc=; b=nMvb2TkbrYoJf5Y+eRfaI3OZdNxv5osHygyoPQbj590CvYh2EbFkIMHx6tcSqZ+M59 Oa3TFfuVaRhNxdssF+uID/rkzKib0Z6Rk/TOMPz1YPMVgy+r92Z9P3qgW2MlsVi5J8Hb fAW3/8woiIlnf+FaMm3C9e8caQt29m+6FpCyId21PuRNr+9xX6lq4yWPV/K/n9+fk4r+ qrloktwMzvRfzK89lZh9WYAeEvPKvNG4O22o9mzAD7AmIMADmoqs0TRRbSjOcgun4Tj7 fHCl4IdT43ThoZziBIUc0/gB0SRNdByrmwBTxR/jE22C6UxE3vGSj1SYAmSJe7WPYXpN nQ0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ek5hqy6TWDWFNDt2QXR4ustj3ResW2SSPn9ODwkCkzc=; b=ekDIjldd4CKB5f7inlfy4y07JYugOPJVBXN0+L2vWOeXNRh2enG0gS+xwt9vhOIjKx w+MXElTEX7gDmlEPJ8sqCgunHLUBglBVpL7S0C4qqV0TnR7DrUNtDgE8OJ5LfFnv3ewu 3DqBdZSXB6qkgIT8aBXYF74rHycSJ53m0972MnUs/XrTYtEINtKXr3eM8Rz8lT08i3Kp OFNi8R4pESVxXrwTbI/+hdA0eiANeQ/g5gsEJUF/1bC6Bq2NRZy3TNu4f3Q5bbudCZ6K 65sYjvbCdE/EwtR6k2hUeCh83z2ofY6Nn7x6azdMcMy2JlR5z/znkx7GYWzdgQn/ZJve CgSg== X-Gm-Message-State: ANoB5pk9/xwfYT/nC7bnmtaQ+pisVFrjLVRbNJomqd2DzwC7VTPkVuVV qg2rzv8/6kEnCnAWXROEY5YMAL/fTPQ= X-Google-Smtp-Source: AA0mqf4ASrwVC8ue5P1ILc8cYFx9d0KYImLbZHaMoS8XvivVTE1CEPiV0kNhi5GX1ljhbaER29fCgQ== X-Received: by 2002:a17:90a:fc95:b0:218:ff8e:5d6b with SMTP id ci21-20020a17090afc9500b00218ff8e5d6bmr50207260pjb.16.1671572607307; Tue, 20 Dec 2022 13:43:27 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id e88-20020a17090a6fe100b00219cf5c3829sm8153301pjk.57.2022.12.20.13.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 13:43:26 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 06/10] band: add band_chandef_width_to_string Date: Tue, 20 Dec 2022 13:43:14 -0800 Message-Id: <20221220214318.2041986-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221220214318.2041986-1-prestwoj@gmail.com> References: <20221220214318.2041986-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/band.c | 20 ++++++++++++++++++++ src/band.h | 1 + 2 files changed, 21 insertions(+) diff --git a/src/band.c b/src/band.c index b1e319d7..73a63c79 100644 --- a/src/band.c +++ b/src/band.c @@ -1581,3 +1581,23 @@ enum band_freq band_oper_class_to_band(const uint8_t *country, else return 0; } + +const char *band_chandef_width_to_string(enum band_chandef_width width) +{ + switch (width) { + case BAND_CHANDEF_WIDTH_20NOHT: + return "20MHz (no-HT)"; + case BAND_CHANDEF_WIDTH_20: + return "20MHz"; + case BAND_CHANDEF_WIDTH_40: + return "40MHz"; + case BAND_CHANDEF_WIDTH_80: + return "80MHz"; + case BAND_CHANDEF_WIDTH_80P80: + return "80+80MHz"; + case BAND_CHANDEF_WIDTH_160: + return "160MHz"; + } + + return NULL; +} diff --git a/src/band.h b/src/band.h index f7f0c318..1b3f1669 100644 --- a/src/band.h +++ b/src/band.h @@ -115,3 +115,4 @@ uint8_t band_freq_to_channel(uint32_t freq, enum band_freq *out_band); uint32_t band_channel_to_freq(uint8_t channel, enum band_freq band); enum band_freq band_oper_class_to_band(const uint8_t *country, uint8_t oper_class); +const char *band_chandef_width_to_string(enum band_chandef_width width); From patchwork Tue Dec 20 21:43:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13078191 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3AD48F75 for ; Tue, 20 Dec 2022 21:43:28 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id o8-20020a17090a9f8800b00223de0364beso104952pjp.4 for ; Tue, 20 Dec 2022 13:43:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5nGSpjR6nowXT9sI9DlmK6l5AWvbe028EgZZi0Itg7w=; b=KhkdqasfRhfWI6Efe3HoyfTTt5FW0acksJzsqUwa9BdsU2QWz3ImpaFcfyby4AQHsd dg4SN8oD6tEgghRcN6MwX8+6HW0i7ro2IbQctUQH7EbxtnZ84Uh5xtKG/eaDKtke27Xn 6Bm2nPKaMPi9Rircce3OH95cEGFBTL2n5RrPGpL5WwWxCzTKLOBqnAmT1EkFgTYyYp3b EIoMB0670TZvjStox/hlQVDjxhVOXh7L0Ihz6HPtxcYvrWnrOSySHB7MxBTjXCzzJwH3 Q1Z3E7k6auc/y81o4uKZiIQZN2dOVtBn3w/My+0131r/y951dH8blqUEotwBMCrLy1S+ LaQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5nGSpjR6nowXT9sI9DlmK6l5AWvbe028EgZZi0Itg7w=; b=1A8NnL4swSs6fKRihjldTJ/ctG8m0rt4qYLIKQwG4OY9kNbPeevIHLsb8kjYiELIel PXFeqrXULLM3cGMZezbQ+TzxVvomUMKRFExydX//YQqVhdxFUKDJcKpuSbL2SNTpSgZL aijS6DleGPzoN4PkESR4mjmFBtb5ECAWpv9OjbXdLsOLj2+YjteBO8/kDsqH9GmDfrd9 O0pYlb4r/ZDiQTfM2UunQnEtjg283HpomWxK+wrL6v4dRIriNoTDrK3mhsX1QwtfXh4y gjHHSTtrXaBApMJWSpbESGdYOuOr5/LYkajFS8qpsvMQWdp9DPSYrtKnUAeiOpJvXNwp bSjw== X-Gm-Message-State: AFqh2kqFTN1/STHPqDh5+y4MTbUKSOSmLrDj+5jHogAAwiHogA4oBne1 fdw8KUQy2hKpfkXYkuxAIViB+qVu+qI= X-Google-Smtp-Source: AMrXdXsmqmjzGt86jB0uI1JwA2rGOTPYy0Kj9cEAZowM/oTf3+4OUw+QnVfGGAhRGKsaVMwdZqT0kA== X-Received: by 2002:a17:90b:2492:b0:223:88c6:f831 with SMTP id nt18-20020a17090b249200b0022388c6f831mr15158075pjb.12.1671572608012; Tue, 20 Dec 2022 13:43:28 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id e88-20020a17090a6fe100b00219cf5c3829sm8153301pjk.57.2022.12.20.13.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 13:43:27 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 07/10] wiphy: add wiphy_supports_uapsd Date: Tue, 20 Dec 2022 13:43:15 -0800 Message-Id: <20221220214318.2041986-7-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221220214318.2041986-1-prestwoj@gmail.com> References: <20221220214318.2041986-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/wiphy.c | 9 +++++++++ src/wiphy.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/wiphy.c b/src/wiphy.c index ab8aa6c0..021b5e38 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -137,6 +137,7 @@ struct wiphy { bool registered : 1; bool self_managed : 1; bool ap_probe_resp_offload : 1; + bool supports_uapsd : 1; }; static struct l_queue *wiphy_list = NULL; @@ -910,6 +911,11 @@ bool wiphy_country_is_unknown(struct wiphy *wiphy) (cc[0] == 'X' && cc[1] == 'X')); } +bool wiphy_supports_uapsd(const struct wiphy *wiphy) +{ + return wiphy->supports_uapsd; +} + const uint8_t *wiphy_get_ht_capabilities(const struct wiphy *wiphy, enum band_freq band, size_t *size) @@ -1830,6 +1836,9 @@ static void wiphy_parse_attributes(struct wiphy *wiphy, case NL80211_ATTR_PROBE_RESP_OFFLOAD: wiphy->ap_probe_resp_offload = true; break; + case NL80211_ATTR_SUPPORT_AP_UAPSD: + wiphy->supports_uapsd = true; + break; } } } diff --git a/src/wiphy.h b/src/wiphy.h index 5cf22537..1056ac0c 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -137,6 +137,7 @@ const uint8_t *wiphy_get_rm_enabled_capabilities(struct wiphy *wiphy); bool wiphy_get_rsnxe(const struct wiphy *wiphy, uint8_t *buf, size_t len); void wiphy_get_reg_domain_country(struct wiphy *wiphy, char *out); bool wiphy_country_is_unknown(struct wiphy *wiphy); +bool wiphy_supports_uapsd(const struct wiphy *wiphy); const uint8_t *wiphy_get_ht_capabilities(const struct wiphy *wiphy, enum band_freq band, From patchwork Tue Dec 20 21:43:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13078192 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56E987E for ; Tue, 20 Dec 2022 21:43:29 +0000 (UTC) Received: by mail-pj1-f50.google.com with SMTP id gv5-20020a17090b11c500b00223f01c73c3so1782510pjb.0 for ; Tue, 20 Dec 2022 13:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eAMCPUCjV5MVgWosG1cUlDAq3SeN3eTOUOxztz5+QA8=; b=PFT23oQzQF1pY4CNkJRk/Yd9lB61FbNbW5BCvv8xFgSzp/xJAFQ7tenetA3eNBRihl KH6JEIb/pvCLaNd4yEHWsPbFjMvMFnczO+hzEGN9N6F/NgxuBvq+jeGDB6UCKwDbAgPZ MpfbBVIarQnw2bxTJkzmTGEjUzpV1flKYlC9lsbiWXBJuCbA8i4fAH4pIl+dYellL51/ YCLmj7v+P0Aj3RyIG18G5VCmaZB0pnD0aWEKOvGBVQQvg2TOIFl5fRhIWRM6eiNllZNv jGOqm3IztIYj0ZGLWDgV390NmB/c5/VbI658mKT45+KAex8qq8OypyJ460RwuXuZI5Yj 5eRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eAMCPUCjV5MVgWosG1cUlDAq3SeN3eTOUOxztz5+QA8=; b=HpyOT8cR/GPLvNf+6urBEK0MEkOXvGOyfka/U7nob1x9ifP5bVStEIYECVvr7FEusE Dx2skI6dpFZM2vEQOsC21QIyqzfjIckgSnbbZx/Pjv3NhAqNoRqESajj+MGJAey99TLr K/3vk3/qlQ/Zpcod+aBZ5N7Mn2DPGz/h3vCjVNXAjDiHGxE+cxll1++qPnCTXpm396M5 IlyxZa8lyXzlXwQmghx4ctpkXQbKky+zFT0ypNIKxYEPJIZdUXFObTleaOvdxfrp6BnB 5AtEr1w2RDiv5bCaBOVPm2oKOKEUpb5hVSC/VKsIm2028rhpHbEOUaC27hAFPKzM9pYx D+Yg== X-Gm-Message-State: ANoB5pnzZJndFKvQ2tAcGe/Gb9G7krrpqMEeHAB2jDewzAI4tSxTaiFt JgNBzcdKT0S/UAtFMMSEpLYfvFzJdPk= X-Google-Smtp-Source: AA0mqf6y23+2ikUl8aMnWJs7FmkRuBs1fm6+/4rFkfecVgI95906jj9foIT2kMIQgt46dRnPvu3BXw== X-Received: by 2002:a17:90a:ad47:b0:219:2da4:4168 with SMTP id w7-20020a17090aad4700b002192da44168mr49635181pjv.23.1671572608657; Tue, 20 Dec 2022 13:43:28 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id e88-20020a17090a6fe100b00219cf5c3829sm8153301pjk.57.2022.12.20.13.43.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 13:43:28 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 08/10] ap: include WMM parameter IE Date: Tue, 20 Dec 2022 13:43:16 -0800 Message-Id: <20221220214318.2041986-8-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221220214318.2041986-1-prestwoj@gmail.com> References: <20221220214318.2041986-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The WMM parameter IE is expected by the linux kernel for any AP supporting HT/VHT etc. IWD won't actually use WMM and its not clear exactly why the kernel uses this restriction, but regardless it must be included to support HT. --- src/ap.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/ap.c b/src/ap.c index 595c71c9..d3188d1d 100644 --- a/src/ap.c +++ b/src/ap.c @@ -111,6 +111,7 @@ struct ap_state { bool in_event : 1; bool free_pending : 1; bool scanning : 1; + bool supports_ht : 1; }; struct sta_state { @@ -834,6 +835,9 @@ static size_t ap_get_extra_ies_len(struct ap_state *ap, len += ap_get_wsc_ie_len(ap, type, client_frame, client_frame_len); + if (ap->supports_ht) + len += 26; + if (ap->ops->get_extra_ies_len) len += ap->ops->get_extra_ies_len(type, client_frame, client_frame_len, @@ -842,6 +846,56 @@ static size_t ap_get_extra_ies_len(struct ap_state *ap, return len; } +/* WMM Specification 2.2.2 WMM Parameter Element */ +struct ap_wmm_ac_record { + uint8_t aifsn : 4; + uint8_t acm : 1; + uint8_t aci : 2; + uint8_t reserved : 1; + uint8_t ecw_min : 4; + uint8_t ecw_max : 4; + __le16 txop_limit; +} __attribute__((packed)); + +static size_t ap_write_wmm_ies(struct ap_state *ap, uint8_t *out_buf) +{ + unsigned int i; + struct wiphy *wiphy = netdev_get_wiphy(ap->netdev); + + /* + * Linux kernel requires APs include WMM Information element if + * supporting HT/VHT/etc. + * + * The only value we can actually get from the kernel is UAPSD. The + * remaining values (AC parameter records) are made up or defaults + * defined in the WMM spec are used. + */ + *out_buf++ = IE_TYPE_VENDOR_SPECIFIC; + *out_buf++ = 24; + memcpy(out_buf, microsoft_oui, sizeof(microsoft_oui)); + out_buf += sizeof(microsoft_oui); + *out_buf++ = 2; /* WMM OUI Type */ + *out_buf++ = 1; /* WMM Parameter subtype */ + *out_buf++ = 1; /* WMM Version */ + *out_buf++ = wiphy_supports_uapsd(wiphy) ? 1 << 7 : 0; + *out_buf++ = 0; /* reserved */ + + for (i = 0; i < 4; i++) { + struct ap_wmm_ac_record ac = { 0 }; + + ac.aifsn = 2; + ac.acm = 0; + ac.aci = i; + ac.ecw_min = 1; + ac.ecw_max = 15; + l_put_le16(0, &ac.txop_limit); + + memcpy(out_buf + (i * 4), &ac, sizeof(struct ap_wmm_ac_record)); + } + + return 26; +} + static size_t ap_write_extra_ies(struct ap_state *ap, enum mpdu_management_subtype type, const struct mmpdu_header *client_frame, @@ -853,6 +907,9 @@ static size_t ap_write_extra_ies(struct ap_state *ap, len += ap_write_wsc_ie(ap, type, client_frame, client_frame_len, out_buf + len); + if (ap->supports_ht) + len += ap_write_wmm_ies(ap, out_buf + len); + if (ap->ops->write_extra_ies) len += ap->ops->write_extra_ies(type, client_frame, client_frame_len, @@ -3255,6 +3312,9 @@ static int ap_load_config(struct ap_state *ap, const struct l_settings *config, ap->band = BAND_FREQ_2_4_GHZ; } + ap->supports_ht = wiphy_get_ht_capabilities(wiphy, ap->band, + NULL) != NULL; + if (!ap_validate_band_channel(ap)) { l_error("AP Band and Channel combination invalid"); return -EINVAL; From patchwork Tue Dec 20 21:43:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13078193 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F40358F78 for ; Tue, 20 Dec 2022 21:43:29 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id 4so13628262plj.3 for ; Tue, 20 Dec 2022 13:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/PhUqHny25tvQOECSmuzfAI/G8ExD1F6jtx/3IL2rT0=; b=H7erReB1D+8gyUj84AO3vqUYkGUUIsJZf9uhdw6WWEevQmPu2jzDLuThVd7UTPHXpD hyh3qZcFSFJq6C6WLmMq35BuobH6ZCXaX+aiSrgZpszI+xOQPoi7UflH6Cbx5cuHTD2t Zbw2Gwphs7xqppzGlnQvf6v0+5HFsRuKZKgg+mxGMvaT2avKDNHQw3NihB8NlkRNnKCj RMuO+Ty2GyjUG/1fmizVFWO9fjctR23WoVIKxuhkOrzEFATVEQnw8LC8mT/rp/K7B3UM 5wiHNokglWxgMJ7C+hroi8wnvzW6dsTllErTgUWEkv6oApt4QNTrHCLgDLx9rc6aC19v QsWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/PhUqHny25tvQOECSmuzfAI/G8ExD1F6jtx/3IL2rT0=; b=A5OBIgfe/aKy2cSdg8xWA8fq/7KPlGnVeDkB7rYuXqXptqmOKYulXZGAEMzzcW9Xsn id8v17sptTyxb76BoLYea7/0ZDb58IH29NIGtD2L9KkZFFHHR6cvXY07vvgAP8f/cID8 lcmC8KFa2IfhuAkOXzmgGajceHkgIEpVGrKtd7DyyOPvxLmcfexSB1JvkH+KMhy/YaGv PJtHPJjBFUC9u5fUH3P6cJR+JbDOFeehx+u9teHm+Lb61EEU8n4giMPmxyRTnx5aMi8x IYbHiKBH4Chp2QJ+8wckSKd+sYTU4dCGKh5d21MK3DhHIN78yo2VCjDOtiTDTjZAA/rE sESA== X-Gm-Message-State: AFqh2kpfm+wCs6UXU2TSHLVIYlkMWpKtDvAF2bfVXaYiktXsxIelvhR6 UJWj6/FJsiaRKo62J6yusBfp2t0H3As= X-Google-Smtp-Source: AMrXdXtRbNbxm3DylYlacXo/xKA0v0VjGJWOji2gGDSWYcoiGgJ0vxWhH7qmivD/1t5oRB2l4GFW4w== X-Received: by 2002:a17:90b:1895:b0:223:9e00:85bd with SMTP id mn21-20020a17090b189500b002239e0085bdmr18184626pjb.40.1671572609421; Tue, 20 Dec 2022 13:43:29 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id e88-20020a17090a6fe100b00219cf5c3829sm8153301pjk.57.2022.12.20.13.43.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 13:43:28 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 09/10] ap: build HT Capabilities/Operation elements Date: Tue, 20 Dec 2022 13:43:17 -0800 Message-Id: <20221220214318.2041986-9-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221220214318.2041986-1-prestwoj@gmail.com> References: <20221220214318.2041986-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If supported this will include the HT capabilities and HT operations elements in beacons/probes. Some shortcuts were taken here since not all the information is currently parsed from the hardware. Namely the HT operation element does not include the basic MCS set. Still, this will at least show stations that the AP is capable of more than just basic rates. The builders themselves are structured similar to the basic rates builder where they build only the contents and return the length. The caller must set the type/length manually. This is to support the two use cases of using with an IE builder vs direct pointer. --- src/ap.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/src/ap.c b/src/ap.c index d3188d1d..58fb4a6b 100644 --- a/src/ap.c +++ b/src/ap.c @@ -136,6 +136,9 @@ struct sta_state { bool wsc_v2; struct l_dhcp_lease *ip_alloc_lease; bool ip_alloc_sent; + + bool ht_support : 1; + bool ht_greenfield : 1; }; struct ap_wsc_pbc_probe_record { @@ -918,6 +921,66 @@ static size_t ap_write_extra_ies(struct ap_state *ap, return len; } +static size_t ap_build_ht_capability(struct ap_state *ap, uint8_t *buf) +{ + struct wiphy *wiphy = netdev_get_wiphy(ap->netdev); + size_t ht_capa_len; + const uint8_t *ht_capa = wiphy_get_ht_capabilities(wiphy, ap->band, + &ht_capa_len); + + memcpy(buf, ht_capa, ht_capa_len); + + return ht_capa_len; +} + +static size_t ap_build_ht_operation(struct ap_state *ap, uint8_t *buf) +{ + const struct l_queue_entry *e; + unsigned int non_ht = false; + unsigned int non_greenfield = false; + + memset(buf, 0, 22); + *buf++ = ap->channel; + + /* + * If 40MHz set 'Secondary Channel Offset' (bits 0-1) to above/below + * and set 'STA Channel Width' (bit 2) to indicate non-20Mhz. + */ + if (ap->chandef.channel_width == BAND_CHANDEF_WIDTH_20) + goto check_stas; + else if (ap->chandef.frequency < ap->chandef.center1_frequency) + *buf |= 1 & 0x3; + else + *buf |= 3 & 0x3; + + *buf |= 1 << 2; + +check_stas: + for (e = l_queue_get_entries(ap->sta_states); e; e = e->next) { + struct sta_state *sta = e->data; + + if (!sta->associated) + continue; + + if (!sta->ht_support) + non_ht = true; + else if (!sta->ht_greenfield) + non_greenfield = true; + } + + if (non_greenfield) + set_bit(buf, 10); + + if (non_ht) + set_bit(buf, 12); + + /* + * TODO: Basic MCS set for all associated STAs + */ + + return 22; +} + /* * Build a Beacon frame or a Probe Response frame's header and body until * the TIM IE. Except for the optional TIM IE which is inserted by the @@ -970,6 +1033,18 @@ static size_t ap_build_beacon_pr_head(struct ap_state *ap, ie_tlv_builder_next(&builder, IE_TYPE_DSSS_PARAMETER_SET); ie_tlv_builder_set_data(&builder, &ap->channel, 1); + if (ap->supports_ht) { + ie_tlv_builder_next(&builder, IE_TYPE_HT_CAPABILITIES); + len = ap_build_ht_capability(ap, + ie_tlv_builder_get_data(&builder)); + ie_tlv_builder_set_length(&builder, len); + + ie_tlv_builder_next(&builder, IE_TYPE_HT_OPERATION); + len = ap_build_ht_operation(ap, + ie_tlv_builder_get_data(&builder)); + ie_tlv_builder_set_length(&builder, len); + } + ie_tlv_builder_finalize(&builder, &out_len); return 36 + out_len; } @@ -1628,6 +1703,18 @@ static uint32_t ap_assoc_resp(struct ap_state *ap, struct sta_state *sta, resp->ies[ies_len++] = len; ies_len += len; + if (ap->supports_ht) { + resp->ies[ies_len++] = IE_TYPE_HT_CAPABILITIES; + len = ap_build_ht_capability(ap, resp->ies + ies_len + 1); + resp->ies[ies_len++] = len; + ies_len += len; + + resp->ies[ies_len++] = IE_TYPE_HT_OPERATION; + len = ap_build_ht_operation(ap, resp->ies + ies_len + 1); + resp->ies[ies_len++] = len; + ies_len += len; + } + ies_len += ap_write_extra_ies(ap, stype, req, req_len, resp->ies + ies_len); @@ -1833,6 +1920,17 @@ static void ap_assoc_reassoc(struct sta_state *sta, bool reassoc, fils_ip_req = true; break; + case IE_TYPE_HT_CAPABILITIES: + if (ie_tlv_iter_get_length(&iter) != 26) { + err = MMPDU_REASON_CODE_INVALID_IE; + goto bad_frame; + } + + if (test_bit(ie_tlv_iter_get_data(&iter), 4)) + sta->ht_greenfield = true; + + sta->ht_support = true; + break; } if (!rates || !ssid || (!wsc_data && !rsn) || @@ -2676,6 +2774,9 @@ static void ap_handle_new_station(struct ap_state *ap, struct l_genl_msg *msg) l_queue_push_tail(ap->sta_states, sta); + if (ap->supports_ht) + ap_update_beacon(ap); + msg = nl80211_build_set_station_unauthorized( netdev_get_ifindex(ap->netdev), mac); @@ -3712,6 +3813,9 @@ bool ap_station_disconnect(struct ap_state *ap, const uint8_t *mac, if (!sta) return false; + if (ap->supports_ht) + ap_update_beacon(ap); + ap_del_station(sta, reason, false); ap_sta_free(sta); return true; From patchwork Tue Dec 20 21:43:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13078194 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E42F47E for ; Tue, 20 Dec 2022 21:43:30 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id v23so8533686pju.3 for ; Tue, 20 Dec 2022 13:43:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AoVxVSpVDriyDQNpHxubOB+S8bbM87MXS3mHz5U3W5A=; b=BRKQBmG+52oeYQ5NLk0JK7cO5ha0VM5zKVk5t/5ujphpRUcB/SeOdmJnWqIhHschno IdvL3Ch4K7j/ESIMZ1Bw+g1e1SdPE+69u2oqBz/y05r3qwnGCj8CobFs+8LCOWXgbEJ3 XcyD9axbpUsZ4/q52EpEIUxr55SJAgP6duTh/O7kFfFNGMnrB6caYSgbgobZlJw8E3GI bIwtm641LFkiYevVYLAVG6MDPwfnoEoRSSjgw6hBs2f0u088xyL0876R+F1m2G6rapjO vLZN636yatrL+UUm/xDigUctuzrQ+wzJbb7MNnbA+2aguAdOUuBpj9EWkKMeESp85omV 2p8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AoVxVSpVDriyDQNpHxubOB+S8bbM87MXS3mHz5U3W5A=; b=vppchtc9fbH7MlfkACue9BYiqyR/MrKeKtfy8g4769dw+muPIKZ/XAJi8HYPpxJ4q4 XHJFo6Ue4RvrtC7kZlbTBCkx+ZcAk34MZ5+XrLxo5SOb/hop7nEtxdtLBtvifGr8KHd4 HAe+IZaUhlw/pr5mvx0cfOUuz9vFZlNQIbQ0UAtefdfYMLcydhY006BcLAKIY5H2cSjM 4Z/3awbDl8Z/pFzv1qhvFDp9A2nrjS3ezvjWjfWBsedo/y0GFscpAqHBilqNGKveypKZ XQvIsB8y83oSe/qR4R6foxQ1TWDno2fYMgXOf0joL7EskAMhwOg75iy0YmICnMF7tj/J b1Hg== X-Gm-Message-State: AFqh2kpc9/bbdPj/6X+e3hqiAA73oHTZ34z+VK1lPFZ3ifoCi8LoaXO6 aPSDlmO5ZwXiKNSLqSvSAdr/oj5Rhnk= X-Google-Smtp-Source: AMrXdXveYKiXAE5tYFae6TCOc9QqHZ6XfZAMMyTznCVNhD1eXqzvzUxa9dUqjObc+tuB7645RI+RGQ== X-Received: by 2002:a17:90b:124b:b0:220:7147:c981 with SMTP id gx11-20020a17090b124b00b002207147c981mr14547388pjb.29.1671572610202; Tue, 20 Dec 2022 13:43:30 -0800 (PST) Received: from jprestwo-xps.none ([50.39.160.234]) by smtp.gmail.com with ESMTPSA id e88-20020a17090a6fe100b00219cf5c3829sm8153301pjk.57.2022.12.20.13.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 13:43:29 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 10/10] ap: generate chandef for starting AP Date: Tue, 20 Dec 2022 13:43:18 -0800 Message-Id: <20221220214318.2041986-10-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221220214318.2041986-1-prestwoj@gmail.com> References: <20221220214318.2041986-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To include HT support a chandef needs to be created for whatever frequency is being used. This allows IWD to provide a secondary channel to the kernel in the case of 40MHz operation. Now the AP will generate a chandef when starting based on the channel set in the user profile (or default). --- src/ap.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/ap.c b/src/ap.c index 58fb4a6b..2d859538 100644 --- a/src/ap.c +++ b/src/ap.c @@ -72,6 +72,7 @@ struct ap_state { uint8_t psk[32]; enum band_freq band; uint8_t channel; + struct band_chandef chandef; uint8_t *authorized_macs; unsigned int authorized_macs_num; char wsc_name[33]; @@ -2556,8 +2557,6 @@ static struct l_genl_msg *ap_build_cmd_start_ap(struct ap_state *ap) uint32_t nl_akm = CRYPTO_AKM_PSK; uint32_t wpa_version = NL80211_WPA_VERSION_2; uint32_t auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; - uint32_t ch_freq = band_channel_to_freq(ap->channel, ap->band); - uint32_t ch_width = NL80211_CHAN_WIDTH_20; unsigned int i; static const uint8_t bcast_addr[6] = { @@ -2605,8 +2604,13 @@ static struct l_genl_msg *ap_build_cmd_start_ap(struct ap_state *ap) l_genl_msg_append_attr(cmd, NL80211_ATTR_WPA_VERSIONS, 4, &wpa_version); l_genl_msg_append_attr(cmd, NL80211_ATTR_AKM_SUITES, 4, &nl_akm); l_genl_msg_append_attr(cmd, NL80211_ATTR_AUTH_TYPE, 4, &auth_type); - l_genl_msg_append_attr(cmd, NL80211_ATTR_WIPHY_FREQ, 4, &ch_freq); - l_genl_msg_append_attr(cmd, NL80211_ATTR_CHANNEL_WIDTH, 4, &ch_width); + l_genl_msg_append_attr(cmd, NL80211_ATTR_WIPHY_FREQ, 4, + &ap->chandef.frequency); + l_genl_msg_append_attr(cmd, NL80211_ATTR_CHANNEL_WIDTH, 4, + &ap->chandef.channel_width); + if (ap->chandef.center1_frequency) + l_genl_msg_append_attr(cmd, NL80211_ATTR_CENTER_FREQ1, 4, + &ap->chandef.center1_frequency); if (wiphy_supports_probe_resp_offload(wiphy)) { uint8_t probe_resp[head_len + tail_len]; @@ -3326,6 +3330,7 @@ static bool ap_validate_band_channel(struct ap_state *ap) struct wiphy *wiphy = netdev_get_wiphy(ap->netdev); uint32_t freq; const struct band_freq_attrs *attr; + int ret; if (!(wiphy_get_supported_bands(wiphy) & ap->band)) { l_error("AP hardware does not support band"); @@ -3345,6 +3350,22 @@ static bool ap_validate_band_channel(struct ap_state *ap) l_error("AP frequency %u disabled or unsupported", freq); return false; } + + if (!ap->supports_ht) + ret = band_freq_to_chandef(freq, attr, &ap->chandef); + else + ret = band_freq_to_ht_chandef(freq, attr, &ap->chandef); + + if (ret < 0) { + l_error("AP unable to find chandef for freq %u", freq); + return false; + } + + l_debug("AP using frequency %u and channel width %s", + ap->chandef.frequency, + band_chandef_width_to_string( + ap->chandef.channel_width)); + return true; }