From patchwork Fri Jul 26 18:01:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13743011 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (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 039A63BBF1 for ; Fri, 26 Jul 2024 18:02:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722016923; cv=none; b=P8egB7Fi3b6LtBtYPcH2CWMYiCXmeAuOScuQeccfSkVhzyBQnEUapV1O9EMeiwuz2ieKA+rD6ANRe25zf/gXxJKWY7iFfkdPYFGMJ9sYWPjm9l5t6plIYzVe+K6SoyfD9/tcaTltcIXpsFWTSVpIYXvSuPjpNFTMsHQpztm7lNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722016923; c=relaxed/simple; bh=Bje7IpN4RQsxkAYgKI8HY0lZdJMcf+8NhsJlKcPa6Wc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Eaj0m0rz8wN0anKO9Z+I+Pw9yOE6x+DgRIRqNQmjfNEOHhNYostbfeJWVK2fhcNV50AXeZ8mjkc2k38aIhHaC6ihbP+tTKQp5REVBg7iW8tYpVY3Gkbs+OnReFRDbHY9Mm6EvQ63s1KYbDoCqxxLn0Cv/iJRpc9h2JrrZ0S6WTM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jxcIK9Ps; arc=none smtp.client-ip=209.85.167.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jxcIK9Ps" Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3db1d0fca58so546303b6e.3 for ; Fri, 26 Jul 2024 11:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722016921; x=1722621721; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pnNGwxQsolwbKc9YoX7E5tOP7IITbKC2WKS9xrdWB6w=; b=jxcIK9PsffDzm+lUHhJfjZ/8YG4DwP5cPfT9W4fKf6lBJJuwgHH/TO0yoRfY7UaprZ KRyX6EXaewsC+prvRKJ+6FUpfmhzqVYPynO7Dq94m+bq0YZtqdA1Hlv0WYmjT68L2y8A e1BhdU448/59yFT+PRMolsLyLq3w7rh3T5F/UbbWlOJOv0indi0Sth8FhCqFRlJ+92aC ceazFipYye5FzcBzZi5q7j7fRf+S1pTphEGQOFhvZIeqpGvXmGh5mcogaHz7bXJSef/S P1Ct88QlDU+DNFbcwZDJyKfwJUfMH5AwGJ8kQmMj3AmuMiE6Qm+ldKnYbsf7bQAN50tb VD9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722016921; x=1722621721; 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=pnNGwxQsolwbKc9YoX7E5tOP7IITbKC2WKS9xrdWB6w=; b=M+zlxk26IQMzGsiWpRcJPmYvUVm9hE3rZd7jVtUhzqT6f6sSHD3SWmttURQCswQvSH j+BsqPFaKiSHgnX/0duMDH4hdmN2Mid8Qwdza/eHC5H1YrMi9QxEWdaZdJDkPWZcCJsR vuJGNalFHRPNFJ1VtZ7MPIkM9Qhevra7gZIsXrHzL7sRjbIk1pjlHEt0cxf6AYz91MRa P6pRXYNg1Ue0XHZ9RK2COqPci/19qOM+e/Czet1NGGkBAhMTLxIA7zxfCdRcCZyd74qL FHSDHbo+/K5WyVUx6TyC/vymYLFuz4Y4P+y0ZLbAAyp3m9Sn7hu9A8EGG3vGeJhzwA/1 eniQ== X-Gm-Message-State: AOJu0YxHGneyzUZXS2UWqKo+LxOh6RAcY1D22AKvrmcFL9V9GtsPnItI FbUyzeRZmd0ThEsjrprRQtXDhAX2/oan5I1IIPU/STM1BDNSJR8nZZz/6A== X-Google-Smtp-Source: AGHT+IF8yCvy3Zy3o7V71kqXGIP4v46G/N2BPvxXLYCS7/yvJKkhnI8/+xsXsk/CMKMGBCM5VUqe4w== X-Received: by 2002:a05:6808:1416:b0:3db:153d:5552 with SMTP id 5614622812f47-3db23d2a72bmr566574b6e.30.1722016920911; Fri, 26 Jul 2024 11:02:00 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3f8fccc8sm18877166d6.46.2024.07.26.11.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 11:02:00 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 1/3] wiphy: add flag for supporting remain on channel Date: Fri, 26 Jul 2024 11:01:55 -0700 Message-Id: <20240726180157.1654827-1-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 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 fb36ebb2..ad9bf59b 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -149,6 +149,7 @@ struct wiphy { bool self_managed : 1; bool ap_probe_resp_offload : 1; bool supports_uapsd : 1; + bool supports_cmd_offchannel : 1; }; static struct l_queue *wiphy_list = NULL; @@ -938,6 +939,11 @@ bool wiphy_supports_uapsd(const struct wiphy *wiphy) return wiphy->supports_uapsd; } +bool wiphy_supports_cmd_offchannel(const struct wiphy *wiphy) +{ + return wiphy->supports_cmd_offchannel; +} + const uint8_t *wiphy_get_ht_capabilities(const struct wiphy *wiphy, enum band_freq band, size_t *size) @@ -1384,6 +1390,9 @@ static void parse_supported_commands(struct wiphy *wiphy, case NL80211_CMD_ASSOCIATE: assoc = true; break; + case NL80211_CMD_REMAIN_ON_CHANNEL: + wiphy->supports_cmd_offchannel = true; + break; } } diff --git a/src/wiphy.h b/src/wiphy.h index bc82a007..17e53075 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -141,6 +141,7 @@ 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); +bool wiphy_supports_cmd_offchannel(const struct wiphy *wiphy); const uint8_t *wiphy_get_ht_capabilities(const struct wiphy *wiphy, enum band_freq band, From patchwork Fri Jul 26 18:01:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13743012 Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.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 93E293987B for ; Fri, 26 Jul 2024 18:02:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722016925; cv=none; b=gIetqZo7gJzCr2xebTJZA/D6yYEr9keVYshhh0Z5xTTrbUYu0kcPgAZQdRzP2pi0V7nALJDB5Ss1EKxtTy8y0e3vc2DmwlSmewhKQoFBsk+nqNZQWKUwTRzXvEagy5PhLSlEYtRYSsugClgELYya73X7nzFAdG2RgeyNxUI3ews= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722016925; c=relaxed/simple; bh=7zJusb69k140r21nHVW4UxozIWxBkc5LUReVwSFjqxE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Cf28rvAVTwKLvWYIqdPG1Rm0pMmGayKXJgBn26BXLYr/aur5jBgOFKW+E/+Vit9xvZERtN53D1AKnctfOULy/0GBSU3iBZ1lDwFxeo8IUXux2ibhpfJUqGID4BlmMoAX9g59icCK2LtYn6xU0qPPQ6xlgdMpqyetorO5gxp6Iqg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kTPrDm/0; arc=none smtp.client-ip=209.85.160.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kTPrDm/0" Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-44fea2d40adso5977921cf.0 for ; Fri, 26 Jul 2024 11:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722016922; x=1722621722; darn=lists.linux.dev; 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=XvcG0Xm+bCBh7iuKYU4k3BgYlEk1+pMHhaLMzx/1EOs=; b=kTPrDm/0vF+ylMBz7wHgq5j0Jd8X/t+MLu9PjFaKsPTglB9fLYZ1NHJBlrFVZNud27 0kKeoxMWSFogVJGcptqVc2Il36G68leHPUwga1v2x4JTIQfgv6kljw6Y3i1ZQCfNoCp2 J9W/4ulUl37G4q0ySqpi4rP23wRa36b8nnEsHfSsvHWPnjeIMh/Y73IAw31i5Bj0XAia OgoknfkiKU2wBFV/pmMviUltr4X+Y1a9Y6j8jq2FrGFz7b/6nnX/SQl7HLTm0HwaryS1 OLLjYHqkqSbckMC9XYSCM+/7Aobe3jf50ALPMGP/+9e9QnHdxoUXm6l9vHMw5wbDU+BZ 3Keg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722016922; x=1722621722; 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=XvcG0Xm+bCBh7iuKYU4k3BgYlEk1+pMHhaLMzx/1EOs=; b=izvFH65G2bBX2h5uInCb2P0eA2C4vHeifd1zVJ5U7p3sjWpv2U/bMPv6DeJmF48/BA swlrvVN6bUX1SQuyMrFsPGbYXOpm4vG/5RbD7oH1G68AfOJ7P/FDiYG9Y6Mx/9kKzfAW G78aVESwFJYeDBT5oGtw6hrsPfpBu3wl3Zar7ZyztdEp/Ku4OrIP6Qh+PfSwTYiRTiGu shoqCxgfpDS/gnHC7C/0R+DJU8cvXWZLEweYbs49JLK0Z+rcEHWFyTdu1uawyAsRSdwq pVBXiP0dAx0EsVo1VY4Rr5dmfH5oV45bO7mCfqbZzUZ+3jrzKtG/2Y/IQ2ztDtn30RuO X/og== X-Gm-Message-State: AOJu0YyA/JreILD9dtT6uEFxVEOuc5gdk6+JHz4LJQDSQoBHbz3FPdWQ IBqlWud8Vf7a7Px/MRyYSBVotgztBJGCy/yjHs8iZ/8A6d8bbkNaJGIQSA== X-Google-Smtp-Source: AGHT+IEKOgIq+B5OY12p9ytasEIsBR33F8q6pH2xdMHHf31c4Do1HkC8hT1fBWNoKYSKETucEPh4Cg== X-Received: by 2002:a05:6214:4106:b0:6b5:4865:948e with SMTP id 6a1803df08f44-6bb55a4642cmr6048426d6.32.1722016922155; Fri, 26 Jul 2024 11:02:02 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3f8fccc8sm18877166d6.46.2024.07.26.11.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 11:02:01 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 2/3] station: don't allow FT-over-Air without offchannel support Date: Fri, 26 Jul 2024 11:01:56 -0700 Message-Id: <20240726180157.1654827-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240726180157.1654827-1-prestwoj@gmail.com> References: <20240726180157.1654827-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If CMD_REMAIN_ON_CHANNEL isn't supported, don't allow FT-over-Air --- src/station.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/station.c b/src/station.c index db069981..44f8d33c 100644 --- a/src/station.c +++ b/src/station.c @@ -2004,7 +2004,8 @@ static void station_early_neighbor_report_cb(struct netdev *netdev, int err, &station->roam_freqs); } -static bool station_can_fast_transition(struct handshake_state *hs, +static bool station_can_fast_transition(struct station *station, + struct handshake_state *hs, struct scan_bss *bss) { uint16_t mdid; @@ -2032,6 +2033,16 @@ static bool station_can_fast_transition(struct handshake_state *hs, return false; } + /* + * FT-over-Air in its current form relies on CMD_REMAIN_ON_CHANNEL. Some + * drivers do not support this so only allow over-DS if this is the case + */ + if (!(hs->mde[4] & 1) && + !wiphy_supports_cmd_offchannel(station->wiphy)) { + l_debug("FT-over-Air needs offchannel, using reassociation"); + return false; + } + return true; } @@ -2495,7 +2506,7 @@ static bool station_try_next_transition(struct station *station, station->ap_directed_roaming = false; /* Can we use Fast Transition? */ - if (station_can_fast_transition(hs, bss) && !no_ft) + if (station_can_fast_transition(station, hs, bss) && !no_ft) return station_fast_transition(station, bss); /* Non-FT transition */ From patchwork Fri Jul 26 18:01:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13743013 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (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 D6A923BBF1 for ; Fri, 26 Jul 2024 18:02:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722016926; cv=none; b=kpcvkn4J2nPwwe1dFps97QT2nF5lK6Gxty65FWYKUPib804mQXSnEyvHQrp3oxu4vcTgZd297aSwliByvQmVKdIruJYFMRDTOPnJnXTdidILgZnkqb4F2F18C9tkDii+IIPJPwEvfJduhA8WSZH/+Nj9eIEwAcv9/v6CHA+cdn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722016926; c=relaxed/simple; bh=/QBvcYRv/QuBLo2peiVZ6trFiOhu6YMZJfPICZCtz+M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uZPLTe4av6JZ+8ZkWZmUElQjMPNYs5Cpj8rXg2+OoHYIqpeQjZmSOmHoFa3RLDBoj07YjUOtntBGn7C32SIJFpVCOJXvPRrwqiWgkFIz1C/qybLU3ndRTiIfiesvLDr8kdbgQ67qhSvv28aAMJd0IQmKR8nkDG1PpvoMeLdjZoY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GishLNMC; arc=none smtp.client-ip=209.85.219.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GishLNMC" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-6b7a3b75133so6907936d6.2 for ; Fri, 26 Jul 2024 11:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722016923; x=1722621723; darn=lists.linux.dev; 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=HcftX5HJW/ffAWLqOplaweDSHLZMd/m9+wbktsfZfmo=; b=GishLNMCxZeI+DOgWCEUi0xjcGchnpsSCuV52bymojSyZ3MZPqyO7zEymYNKDxZs2J rtBGdmNWdQHRDxOVs03CjzdyR2kCSgSGqe00dpY7Fh9hoRc9pV5d6KhMeMCK/3Zf4QK+ pQzPBst0EJ8O3OW5H1GKjZMLbSkYXjSxncx56V1EC/YOX9CmRhWOkVK2ouDpbz2AyExh Jb4MeP56r4gU+sEZGfz0RtRRicRcbFOYM9s3/SUmEY+/Oa3j8GP66DvicMpfi8IXOGka jjdXOJsLrl6kpkq+VuRuHbldgLBdzAlY5ByrZcp097eJiAS1dp/oQH/XasSTktnS/mF9 TmYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722016923; x=1722621723; 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=HcftX5HJW/ffAWLqOplaweDSHLZMd/m9+wbktsfZfmo=; b=CD2s4reDgO3kMz2M/XMYWwSWXE4OWV8TR8omBwfnT4zRPIQM3ZUFziW3OdjGMdlSMl FW77DAqsPBF010XrMSvY1Rx2xnNNPUTpxZStE+obWM17md0cfIWEu2/ew7qOmTmRT7/O zQVKlhCMdPmC4Ekjvwm8r+vRuspGzRaz2vIPpIRB3jKrzecd7TRSX6lwOpsqZCUc95cR sE2Fc9ZNc4X0Gvg95WZeyLsMQzKjptUlMCMZ98h3fTmV/XwnEQ8wrMUxoNUprYTHInwZ uzgsanxvFZZ+ZY6Cs9x1zOI5YTSjet7znSuMCS4U5mxsINGSVL804Yi9fCSbeRLTUEr5 PB7A== X-Gm-Message-State: AOJu0YxjngLf7lVhO2JMipDK0/CaQab5FVVxacPMOoS54O9RGdeye8i9 k1tq61P+WWXjZfnAUp2QkiE7C+K98h+V8kEQBoOuZR+yAdP1NIw8GLd+Yw== X-Google-Smtp-Source: AGHT+IFjqSuCLrSFFBb53rHiFR3Eb2HFnD8Ry83GlB35X9lJCmXG4JrOHDt2QOOdPNuWveL5x1FMpQ== X-Received: by 2002:a05:6214:1247:b0:6b4:dd2a:aa44 with SMTP id 6a1803df08f44-6bb55a83e51mr8909176d6.37.1722016923315; Fri, 26 Jul 2024 11:02:03 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3f8fccc8sm18877166d6.46.2024.07.26.11.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 11:02:03 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 3/3] netdev: fall back to RSSI polling if SET_CQM fails Date: Fri, 26 Jul 2024 11:01:57 -0700 Message-Id: <20240726180157.1654827-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240726180157.1654827-1-prestwoj@gmail.com> References: <20240726180157.1654827-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Some drivers fail to set a CQM threshold and report not supported. Its unclear exactly why but if this happens roaming is effectively broken. To work around this enable RSSI polling if -ENOTSUP is returned. The polling callback has been changed to emit the HIGH/LOW signal threshold events instead of just the RSSI level index, just as if a CQM event came from the kernel. --- src/netdev.c | 147 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 96 insertions(+), 51 deletions(-) v2: * Removed some changes that shouldn't have been in this patch diff --git a/src/netdev.c b/src/netdev.c index 2d70fc38..47825c1c 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -187,6 +187,7 @@ struct netdev { bool retry_auth : 1; bool in_reassoc : 1; bool privacy : 1; + bool cqm_poll_fallback : 1; }; struct netdev_preauth_state { @@ -206,6 +207,9 @@ static struct l_genl_family *nl80211; static struct l_queue *netdev_list; static struct watchlist netdev_watches; static bool mac_per_ssid; +/* Threshold RSSI for roaming to trigger, configurable in main.conf */ +static int LOW_SIGNAL_THRESHOLD; +static int LOW_SIGNAL_THRESHOLD_5GHZ; static unsigned int iov_ie_append(struct iovec *iov, unsigned int n_iov, unsigned int c, @@ -642,6 +646,46 @@ static void netdev_set_rssi_level_idx(struct netdev *netdev) netdev->cur_rssi_level_idx = new_level; } +static void netdev_cqm_event_rssi_value(struct netdev *netdev, int rssi_val) +{ + bool new_rssi_low; + uint8_t prev_rssi_level_idx = netdev->cur_rssi_level_idx; + int threshold = netdev->frequency > 4000 ? LOW_SIGNAL_THRESHOLD_5GHZ : + LOW_SIGNAL_THRESHOLD; + + if (!netdev->connected) + return; + + if (rssi_val > 127) + rssi_val = 127; + else if (rssi_val < -127) + rssi_val = -127; + + netdev->cur_rssi = rssi_val; + + if (!netdev->event_filter) + return; + + new_rssi_low = rssi_val < threshold; + if (netdev->cur_rssi_low != new_rssi_low) { + int event = new_rssi_low ? + NETDEV_EVENT_RSSI_THRESHOLD_LOW : + NETDEV_EVENT_RSSI_THRESHOLD_HIGH; + + netdev->cur_rssi_low = new_rssi_low; + netdev->event_filter(netdev, event, NULL, netdev->user_data); + } + + if (!netdev->rssi_levels_num) + return; + + netdev_set_rssi_level_idx(netdev); + if (netdev->cur_rssi_level_idx != prev_rssi_level_idx) + netdev->event_filter(netdev, NETDEV_EVENT_RSSI_LEVEL_NOTIFY, + &netdev->cur_rssi_level_idx, + netdev->user_data); +} + static void netdev_rssi_poll_cb(struct l_genl_msg *msg, void *user_data) { struct netdev *netdev = user_data; @@ -678,11 +722,16 @@ static void netdev_rssi_poll_cb(struct l_genl_msg *msg, void *user_data) netdev->cur_rssi = info.cur_rssi; /* - * Note we don't have to handle LOW_SIGNAL_THRESHOLD here. The - * CQM single threshold RSSI monitoring should work even if the - * kernel driver doesn't support multiple thresholds. So the - * polling only handles the client-supplied threshold list. + * If the CMD_SET_CQM call failed RSSI polling was started. In this case + * we should behave just like its a CQM event and check both the RSSI + * level indexes and the HIGH/LOW thresholds. */ + if (netdev->cqm_poll_fallback) { + netdev_cqm_event_rssi_value(netdev, info.cur_rssi); + goto done; + } + + /* Otherwise just update the level notifications, CQM events work */ netdev_set_rssi_level_idx(netdev); if (netdev->cur_rssi_level_idx != prev_rssi_level_idx) netdev->event_filter(netdev, NETDEV_EVENT_RSSI_LEVEL_NOTIFY, @@ -1027,6 +1076,9 @@ static void netdev_free(void *data) netdev->get_link_cmd_id = 0; } + if (netdev->rssi_poll_timeout) + l_timeout_remove(netdev->rssi_poll_timeout); + scan_wdev_remove(netdev->wdev_id); watchlist_destroy(&netdev->station_watches); @@ -1058,10 +1110,6 @@ struct netdev *netdev_find(int ifindex) return l_queue_find(netdev_list, netdev_match, L_UINT_TO_PTR(ifindex)); } -/* Threshold RSSI for roaming to trigger, configurable in main.conf */ -static int LOW_SIGNAL_THRESHOLD; -static int LOW_SIGNAL_THRESHOLD_5GHZ; - static void netdev_cqm_event_rssi_threshold(struct netdev *netdev, uint32_t rssi_event) { @@ -1085,46 +1133,6 @@ static void netdev_cqm_event_rssi_threshold(struct netdev *netdev, netdev->event_filter(netdev, event, NULL, netdev->user_data); } -static void netdev_cqm_event_rssi_value(struct netdev *netdev, int rssi_val) -{ - bool new_rssi_low; - uint8_t prev_rssi_level_idx = netdev->cur_rssi_level_idx; - int threshold = netdev->frequency > 4000 ? LOW_SIGNAL_THRESHOLD_5GHZ : - LOW_SIGNAL_THRESHOLD; - - if (!netdev->connected) - return; - - if (rssi_val > 127) - rssi_val = 127; - else if (rssi_val < -127) - rssi_val = -127; - - netdev->cur_rssi = rssi_val; - - if (!netdev->event_filter) - return; - - new_rssi_low = rssi_val < threshold; - if (netdev->cur_rssi_low != new_rssi_low) { - int event = new_rssi_low ? - NETDEV_EVENT_RSSI_THRESHOLD_LOW : - NETDEV_EVENT_RSSI_THRESHOLD_HIGH; - - netdev->cur_rssi_low = new_rssi_low; - netdev->event_filter(netdev, event, NULL, netdev->user_data); - } - - if (!netdev->rssi_levels_num) - return; - - netdev_set_rssi_level_idx(netdev); - if (netdev->cur_rssi_level_idx != prev_rssi_level_idx) - netdev->event_filter(netdev, NETDEV_EVENT_RSSI_LEVEL_NOTIFY, - &netdev->cur_rssi_level_idx, - netdev->user_data); -} - static void netdev_cqm_event(struct l_genl_msg *msg, struct netdev *netdev) { struct l_genl_attr attr; @@ -3634,11 +3642,48 @@ static struct l_genl_msg *netdev_build_cmd_cqm_rssi_update( static void netdev_cmd_set_cqm_cb(struct l_genl_msg *msg, void *user_data) { + struct netdev *netdev = user_data; int err = l_genl_msg_get_error(msg); const char *ext_error; - if (err >= 0) + if (err >= 0) { + /* + * Looking at some driver code it appears that the -ENOTSUP CQM + * failure could be transient. Just in case, reset the fallback + * flag if CQM happens to start working again. + */ + if (netdev->cqm_poll_fallback) { + l_debug("CMD_SET_CQM succeeded, stop polling fallback"); + + if (netdev->rssi_poll_timeout) { + l_timeout_remove(netdev->rssi_poll_timeout); + netdev->rssi_poll_timeout = NULL; + } + + netdev->cqm_poll_fallback = false; + } + + return; + } + + /* + * Some drivers enable beacon filtering but also use software CQM which + * mac80211 detects and returns -ENOTSUP. There is no way to check this + * ahead of time so if we see this start polling in order to get RSSI + * updates. + */ + if (err == -ENOTSUP) { + l_debug("CMD_SET_CQM not supported, falling back to polling"); + netdev->cqm_poll_fallback = true; + + if (netdev->rssi_poll_timeout) + return; + + netdev->rssi_poll_timeout = l_timeout_create(1, + netdev_rssi_poll, netdev, NULL); + return; + } ext_error = l_genl_msg_get_extended_error(msg); l_error("CMD_SET_CQM failed: %s", @@ -3662,7 +3707,7 @@ static int netdev_cqm_rssi_update(struct netdev *netdev) return -EINVAL; if (!l_genl_family_send(nl80211, msg, netdev_cmd_set_cqm_cb, - NULL, NULL)) { + netdev, NULL)) { l_genl_msg_unref(msg); return -EIO; } @@ -5260,7 +5305,7 @@ int netdev_set_rssi_report_levels(struct netdev *netdev, const int8_t *levels, return -EINVAL; if (!l_genl_family_send(nl80211, cmd_set_cqm, netdev_cmd_set_cqm_cb, - NULL, NULL)) { + netdev, NULL)) { l_genl_msg_unref(cmd_set_cqm); return -EIO; }