From patchwork Thu Aug 29 11:41:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13783060 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 DE4F1191F86 for ; Thu, 29 Aug 2024 11:41:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724931668; cv=none; b=lEzOriqD/vMQjVVnT1jmPmpkl7kL9R4qv5KnJXVbNY1UeP/JbKyqVOEAaF0tN1yLKdAxkZzyL+QzO8iM58SMpclP8OMELx/DVu6PrbU46M+kliL6QL1ieJhR9h26KM1g4t9lOo0BB0ClDRJJ5ciXq/H8muC7N964+tIKWzzOepQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724931668; c=relaxed/simple; bh=A9yY3+o6FFyKAlUQ0LAV9mLrk2JGbqeG5iTdK3MDjY8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Yehtc0Vh8fM5wxMKJectO6lGJspiD2NnXWTKcWKutgyvut0QmB8FY8obDUc4PN0pqJPxNSWXuFBATg03WafJJxYfO/8650ZGnD+/AWmCBf+oGccp+1C3q+4ya37xTjAtRK84L+ONRHGDSiNJ82fuyGMNrk9ZsYsL26H8zs/ZZis= 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=lhyWPyIy; arc=none smtp.client-ip=209.85.214.171 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="lhyWPyIy" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-201ee6b084bso4409025ad.2 for ; Thu, 29 Aug 2024 04:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724931666; x=1725536466; 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=oUQPqErKvzcKGx1kBxvI9e2IL6KbK8/k9dhcf8zHyrM=; b=lhyWPyIypj2w5hTc5Wzzdk3f2FC9BXG4INnboUEFjqYP1jTqPSMEksk68e6Gg28pYt 8hd+bkNU5HqK1pnvoLtdVVTcZlnWM3yukOkP4htF9I6BmoZqL5sBtOTpOkwEZ8+YDjp6 FvWKyCu6YfYDfp/sPLKJW5Cuk4XHzp4GObnr20pbyiktQUGbYTeXa1Rg6KKmXRmiTsp/ sa6TRSPBgj2wb/W9RAT0WW/fTbPp6r2uS3BXgSRP/wEVdr2c0R92aPJbrhqJF69rMq7T /Zk9G3bmGXaKqR8OM5f71mjVWjeotdkugiS6XJrVCG1caqIw73PhhM6S1vy+0JhIYh2e LGhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724931666; x=1725536466; 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=oUQPqErKvzcKGx1kBxvI9e2IL6KbK8/k9dhcf8zHyrM=; b=q4lbW/zzI2ULI+HjT35Y15aDwrkfPVe3/FqDqRUnYeip+5is+Eqm7W9A6Go/ZMyiuy no2ydwVWSKQ6Tfsop52CWEPGwBZ/yK3+3zBvvgRxHFpBFSGg4tSygMh/lUhI7/wQz2D8 M37HmVeCuuzOvUYKBdh2M+7sk7spkugQ/X4Jdh2BCHjMYdB5xYtVVMoby85w3H8uMpGj EcF4znJ4bI9BYpDONgBBZmB1hiiBBPlzVy+6MxSKS/wvEp70BhTyA/f12H6BGyF3dlc+ pRt8r/Xv9zA7MQntynsGUbgHbY+gLA+OYsUyZCxkVJXUo1cuNufvagX+jspo6hgvqQal TFWA== X-Gm-Message-State: AOJu0YysY3dwvlt3+u07dcyOT/3DbdY79YO1TxusUP3/wE1feFJVLNfY aLYKl1i2es3bpenvUHY+X8xxUdGGogGVfM8frfiZ0OdLULV9b30qA0Jpew== X-Google-Smtp-Source: AGHT+IG1hl77OKTuK5CWYKbulzRpSG7TeXW3V2S4fZOEhZiAme9JX+SqRLjPbpm5uQkszhAVSQwDjQ== X-Received: by 2002:a17:902:ecc5:b0:202:49ea:b6f4 with SMTP id d9443c01a7336-2050c3c8968mr28290755ad.37.1724931665602; Thu, 29 Aug 2024 04:41:05 -0700 (PDT) Received: from LOCLAP699.localdomain (h69-130-12-20.bendor.broadband.dynamic.tds.net. [69.130.12.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-205152b37d5sm9699315ad.25.2024.08.29.04.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 04:41:04 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 1/3] wiphy: add flag for supporting remain on channel Date: Thu, 29 Aug 2024 04:41:00 -0700 Message-Id: <20240829114102.56284-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 13d498a5..cdaa89ad 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; @@ -939,6 +940,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) @@ -1385,6 +1391,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 Thu Aug 29 11:41:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13783061 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.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 6DED0158DB1 for ; Thu, 29 Aug 2024 11:41:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724931668; cv=none; b=p0uXqOtOLdye2RUI1sEtDdkPidOmtpl74sp+w6XOFiZotmrZRX1/vHSwxmAka0IwUswRTVBogBxGgDZmyBXzXbgbioBJmh3nBHRR8wFzllUjEQYWNj5KFzFVlLgZ3S7f4EqBRDDmqJTjGkuWRMP8b867iwEJF0OQhZDcQywq4Bk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724931668; c=relaxed/simple; bh=Gp1IAKVY7rrkac/tCaYKnWKQnH3vQrMI2KZTwfwKicE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PrS/0XSTF8mTaa9lvH1HZJYATKt66gIBR2uwPq4+54SVpz35lRdpgYIvm+wEShL6/x8ZX+ZY2g04j042uUh6y1ujO/8aJwj5Urb+znjYZWjs58kzb8F6vGNDF4TZVKEcz4kTmb+Em2tlFxykO2+8XZZ1a/WNbGJqTegMwfGRfcc= 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=fnAt3kWN; arc=none smtp.client-ip=209.85.210.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="fnAt3kWN" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-714287e4083so509488b3a.2 for ; Thu, 29 Aug 2024 04:41:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724931666; x=1725536466; 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=rkhYR/btK9h5NdKiQMAcxkX+jV8fpC/zK7q59e7K3wg=; b=fnAt3kWNVyUH5q/PhvaZM2BLm2llJQBjPbihFliU8O/1IgqhylEFK0D4ck+25tj6lV O5QXK3fxOhBEEsfA13j0ICnD/msmqrF7thNrInWIRbVQN2a0Ne+zUDCS0BPio25rmF7/ QsAM0hw5BxaNIJLD2YTUFog/CeGj10iuCTj4kk9CCC+OW0UjfkmCCYrn2K7MfET1my2W ZAPAHpUQc/s2+7fW8boP1xUAZgbirGXCaa6XFpm5VT0iXKVuGUz1yrojiQOj3gP5ojyN Ggk8Cg86RBv4VMcUvC/krceM12xmiQIwzZ+VlZMH1/g2XxxJcMvIv7/tUbsLNotcKtkY HQrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724931666; x=1725536466; 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=rkhYR/btK9h5NdKiQMAcxkX+jV8fpC/zK7q59e7K3wg=; b=M+lnX+NQo5PEeg+/SpDzORPsMuO4uQFQtgHjBtZZiYsP8F3vKAtRjMo29I3/nHn2le zEjOdUCtSPQcbrrUD/LVKKMrcA4V+xvqX9gmeyr39YCMaWsSaApfFustWNDyQolSFG0t HkeWRLnb64nnvZF+qqcKYtuwx49WNZBpJciAb5h89b4JnAtgROVtuR/WsRRU1BBWMOgr d+ijpibyBzLsAmLKrslCzOaNkrcsGh+jqo+hNU7w55kJ5e517/9lcgXdx1dxiet15tOg 32kEZWtQIjKOnJtDJQ7I8+HOP7jwiD7DYeLUjqdazdukA7Y/gD52vPRYCZW9pmJGJZ5H QWlg== X-Gm-Message-State: AOJu0YxZTHI7orkWqKZzfUeX4bZYJ264onf1wzJCdcohpGv7By2suFlS f55vBrVwv1EqPU74CFtoFtDC4dnByuPvN6n79mi0QPfGjZIeMOqPY6vvUQ== X-Google-Smtp-Source: AGHT+IGIGoLWa8mrIZfpmKuskcsQeSz/YpZplu27fAlOehWGXXRwqFFo+Cab4fAexy1H4bLiZTQDug== X-Received: by 2002:a17:902:e54a:b0:202:3735:6239 with SMTP id d9443c01a7336-2050c37233fmr26960325ad.34.1724931666326; Thu, 29 Aug 2024 04:41:06 -0700 (PDT) Received: from LOCLAP699.localdomain (h69-130-12-20.bendor.broadband.dynamic.tds.net. [69.130.12.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-205152b37d5sm9699315ad.25.2024.08.29.04.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 04:41:05 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 2/3] station: don't allow FT-over-Air without offchannel support Date: Thu, 29 Aug 2024 04:41:01 -0700 Message-Id: <20240829114102.56284-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240829114102.56284-1-prestwoj@gmail.com> References: <20240829114102.56284-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 30a1232a..5f174a70 100644 --- a/src/station.c +++ b/src/station.c @@ -2105,7 +2105,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; @@ -2133,6 +2134,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; } @@ -2596,7 +2607,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 Thu Aug 29 11:41:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13783062 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 E8640191F86 for ; Thu, 29 Aug 2024 11:41:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724931670; cv=none; b=k2fQ6HTE280frZgKjxciAX6PX5s8t8VMJcJESwEWVikdyzPpD3tNpaTzyXD3Nmp4vr8pP3u8LrOJji9QyS0oUeD0EnHJBL7Zezkq+mDXEYw8THL1ofQCz9KjS3j3ukvTEqrsPY08K9L7WvoTb9Tzqdblp8m6mv73nS+epF+CD4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724931670; c=relaxed/simple; bh=7cT5JcsGKVY6X7cDZ4Pk/Ji9Jze9qLAcCSURUEn+GCs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cbc1frtJJdVneK3V8k0K0pJUJU7pR6BkrnNR4GI9IB/wB2uTkBfnal//tYbK4+/dzz4TFqJZcfTYEVqWXrc0m/aZ9FOwqlFxshf5CSz3q57gPRgLMXj+826E5APqDvhHwkxE61PKZqN+0rlrtfHQCjyzaOBw8zUysazEfghlI+Q= 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=lwZJv/bR; arc=none smtp.client-ip=209.85.214.179 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="lwZJv/bR" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-201e64607a5so4069665ad.2 for ; Thu, 29 Aug 2024 04:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724931668; x=1725536468; 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=x5OfJAe8ZW64mX7Q04gXNdWXbJK9ByzUW3zTM/JAWUs=; b=lwZJv/bReOspvKk2AbQwN9dkzAUrO4ufL4kmRDikeFqG21Skou+GW9nrwc8KHxOrAZ 0BHb4/hTk16cRPy++BjIUdfpnd9RAa+4oo3J15qi6I3Hbu/TuKbYreFh4hUsLu+0IKrv iWKWceCBzm8s8AQ27Fo3fU3kU/ONjq7BlCsOIXJ3w1RAinhMfzQKoQFWmuVHxCQzUklq wkT6iCJLQmzRamXohWmymyaoVSUorErUQVOVvKZbX/xoTEFxkQjctgkTM3YtzjUOQnVB RZUVmJgJob6Etb4OumON3I7qkCodXAdz1YBLvGq5JsRLmV3YWW/L7OkGvwsyp2HZBozG Om8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724931668; x=1725536468; 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=x5OfJAe8ZW64mX7Q04gXNdWXbJK9ByzUW3zTM/JAWUs=; b=dSWcplK45ucVMrTyKifLa9sSLdPAfvFp1z8Aw2MuW7BfDcg5z5dVze4W2SDg57pSVK 50UsT8PEXvRIN677s93mN731s5zsRZpH+8Cjp1WMdT1tOkFPKbv0p1Cacd5pg8ZJW1/a AvA1lqYQZOzxdElSh5E0o154TZx8LfBiFRqfArFFm5obPjkKZOiU2xMNIi9UoY5SaiUG iAmTz+Ua2YbKfKiPX/8kFwxoo4NugTiMEsqhMYzJZmrvl2iCfwIMAcgMVgSvbNSq3vPE 9lVsaqjyMpxCvQjbcTjTDx39DFHCSFRZFJJ3CWKq2dtBhyKM/eobO/+IMZbTM1Vv+XPf HNnQ== X-Gm-Message-State: AOJu0YxDXjH8zXSiZiLWzBt+QgJ1+pyaVmV78qO7P3GXTobj+4fZFp82 3HabaIDkZFkm7j3L3bG02+zQec/rkPJmFUqOSBPHA132npCKQjNZ+Xo5ZQ== X-Google-Smtp-Source: AGHT+IFeF/BkpFEioR80qbOEhy10z86brzfhcIyBQnQ3pyUMCs+SHaIpmUN1soABZff1DuEHT0NqeQ== X-Received: by 2002:a17:902:e807:b0:202:1bf1:b96d with SMTP id d9443c01a7336-2050c34303fmr25525035ad.27.1724931667805; Thu, 29 Aug 2024 04:41:07 -0700 (PDT) Received: from LOCLAP699.localdomain (h69-130-12-20.bendor.broadband.dynamic.tds.net. [69.130.12.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-205152b37d5sm9699315ad.25.2024.08.29.04.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 04:41:06 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 3/3] netdev: fall back to RSSI polling if SET_CQM fails Date: Thu, 29 Aug 2024 04:41:02 -0700 Message-Id: <20240829114102.56284-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240829114102.56284-1-prestwoj@gmail.com> References: <20240829114102.56284-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 | 142 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 94 insertions(+), 48 deletions(-) v3: * Rebaed on top of upstream diff --git a/src/netdev.c b/src/netdev.c index 73fbf0c1..a3f72deb 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -190,6 +190,7 @@ struct netdev { bool retry_auth : 1; bool in_reassoc : 1; bool privacy : 1; + bool cqm_poll_fallback : 1; }; struct netdev_preauth_state { @@ -650,6 +651,47 @@ 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 ? + netdev->low_signal_threshold_5ghz : + netdev->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; @@ -686,11 +728,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, @@ -1039,6 +1086,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); @@ -1093,47 +1143,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 ? - netdev->low_signal_threshold_5ghz : - netdev->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; @@ -3644,11 +3653,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", @@ -3672,7 +3718,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; } @@ -5310,7 +5356,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; }