From patchwork Fri Jul 26 16:37:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13742986 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 E883017E447 for ; Fri, 26 Jul 2024 16:37:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722011880; cv=none; b=XXE9FaChemkZ40fsOCmDyGQcAxKZ4/PdE3vSIJILtZdYXiIDmgf4R3mWGYZszbpvBE+xrpWyplzeheKNWiB6xkxAqyZm/hcyaZ4kqm44dVBiADbjHH1BFj3vBc0gSOZX58NE1VM2Y5vE77VE5wpPaewmg60MsztZUy6ZE3+/0Zc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722011880; c=relaxed/simple; bh=Bje7IpN4RQsxkAYgKI8HY0lZdJMcf+8NhsJlKcPa6Wc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=PkptCgQr3nSZbEvC9tKbyB4KxSI0WldY2nupORqaJEDtUoM+dcbvm06bjMKKDWl/mMLg3mQKDxty4ifH0m+xzncg2keO48eLnFnDMoiMFlCTVKsW5COFFzxWIGjxI/fvuu0wl7p4u7q5/OXZ4PZvbnErEa2T5S6PTVVoc2fDHdQ= 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=G1KlyBB4; arc=none smtp.client-ip=209.85.210.47 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="G1KlyBB4" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-704156d0e0dso763376a34.1 for ; Fri, 26 Jul 2024 09:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722011878; x=1722616678; 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=G1KlyBB4nHg3aPqK7DKpSzbtlV+r+8I0fP1EfATfibXbZgW2p9IFZhAPDNU1o7V1pA CIIh5go8Fu22hIJgi1K+6NIYQO/qZfKiyZZlDggZ6l2GabOVuNmPNmWJyHIeVYdgOD7F TBw3FwydwZdZ5wMYVVlER15BBiyt53m5ntV6qmnNhxXKwmZ8ReBdt5zJ6M3S09EE/L2w sX/wj7dUQ6lqyPschcAlBri+pF9Ve2TVGzndi/cJt+SzDl5SjL6+HhK3OagDVbgYIJQQ wo9/zZkM5rByBXRHVR68odBnMuRwlPOJFvs9fw0xpUUegiwqPmYpcQG/aRA3+X8+t26i mg7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722011878; x=1722616678; 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=HlcMExJtgyfWbVkovLsE7GCAskPfgKI+jKRp6X7GUFBztdxYGfU6JR69MVjwQp3hvr U/J/3e9GX9E+1FTPGIP+kJ4Gjgfs+OWZFqgE/wOzW2ZLQCEbhGnDutMTnnf+AFSK1pHN wKSMn62hBDslRDBYn2L7oym38Rpvp4XEKBHRwv0V5u4Sw27cajvWg+MP9So1HySxzlpU XmRoySgxLDryudSYFI5odJg0RzvL/hFmBwRhNqxvGNDyG0BN0j4Ln5x2npemZYn+vEGu CXX0RaD4RYHC627/m+9Y+Y/4PmNP/FaLQq+P7bTxFBCjIGPK+KH0jrzVTwDd86QXDeMa 8mJg== X-Gm-Message-State: AOJu0YwNx5j6JqQq3lcFCLWOuEFCWf2s+rHips2zxFd/sqqpXXh0RP5p e0iAOPedDI6SaJhIM3BD1q2NmueZRB7t86x1H7TyU2x3/B2BkY3oQ/puXA== X-Google-Smtp-Source: AGHT+IGjK++yGKEBqjXnu5xp0cUz5TOP6CzZtOJ0g7eqgmrGFoQZY4s8ev+d4+q056Qn3yscup4r7Q== X-Received: by 2002:a05:6830:2a04:b0:708:b2f3:5f11 with SMTP id 46e09a7af769-70940c6d80emr121374a34.27.1722011877794; Fri, 26 Jul 2024 09:37:57 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe81463easm14841081cf.26.2024.07.26.09.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 09:37:57 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 1/3] wiphy: add flag for supporting remain on channel Date: Fri, 26 Jul 2024 09:37:50 -0700 Message-Id: <20240726163752.1651669-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 16:37:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13742987 Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 20EC017DE3B for ; Fri, 26 Jul 2024 16:37:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722011881; cv=none; b=aidqj1pLPnQE2YBUoOrNn7sFGzfGQV96RwEJWykf6+pXS5oVPtkjOTk8grX3oZnG8Ay0rQsse6tquU+bCZifFKTk8ISvAaBY4bDhU5WnQ99IAPIuxkhsj0/FtEVCiq7Yl/SGVH4uq6Baz4YFFEEkpbxkpVv3tbqVz6yKH7pfW/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722011881; c=relaxed/simple; bh=7zJusb69k140r21nHVW4UxozIWxBkc5LUReVwSFjqxE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g2GxMPC+cOIssEkVQFjVXpKK1QIXRCVPcqYCO337DXg1YUAqBAfT1r82euGbQtU4WJ+dxsUyScPRzFpFgfkRZqS06uNOVYfnWFqArodlbwWRNdu7p0sfpro8alGIq9+JV4Fm92rLvzDRjzc4NAGJhZIQLVg+ftl0oxvFIY1ezbs= 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=dqlQk6Qy; arc=none smtp.client-ip=209.85.167.174 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="dqlQk6Qy" Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3db14930a1aso764830b6e.3 for ; Fri, 26 Jul 2024 09:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722011879; x=1722616679; 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=dqlQk6QycGjicaypwLbwdbijHRTRooldTic80lBJV14esZbWrThnGfthJLzLOeiUne jiPhiYAZRFVPS18e/iqLKf3KuxCbWntwzWfA36A0t2aMcXzX9cRGlhiLDqRt+B+90EgF UsdCZTXLLk2BlphYxFccUCCOH7S9Z8803eJxENhLV2X071DpPIcW10ogbOKtXYP86lzJ bw4ZLRFxRNHQAa8nSkq44mrRByvuFjzoFqlmOhqNsYuQLkV4O3a75J1Vo7Mg1FXNSfwW H5OcxC7qKYBPa2V1fLaBsrcBPTS6xUlBgwLZZHl41VkmZhyMoLPQaUskejXium4PF/Gt kliQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722011879; x=1722616679; 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=fs/eoj/BzdQmVquxkAnmVnz7z3vu0Tlx2B4hkt6x/XVysoEKYa+VQSLoG+ZcMEo0TI XV8LfPtitDIb3FKE8G+HdtR1mAsR4fuHMtgB+EM4qfA9o2iF5WzD8cRpyZldWub29s0g YjByaH2A6CJY6Btx0Y+raeLMaVlefsGSLdb91KbY1OndVlw6ouhXA34KqO5xn4uRGdmv u8V05IVRXAKJPkf2dCtHrx3D8lHghoKENOyjUPLissbYYPs7GGesgWLXjbHIippk7HW+ jNlTKnHRH+WGUrSRQ5g8dd9q1INFi/ccYPy53GNONk/HArKS6uoqphzvuDLVV4YEcQvR Dlfw== X-Gm-Message-State: AOJu0Yz0j+Tz6DGbbxtZAZEvKxYWP9FhH0/caUoVMunPC5A7gnFSFkUz DxFvWum6INLILHaFcDBr+7DHMPGqcedLiVaulBLJbmiHbVVgSGkoEdY1vA== X-Google-Smtp-Source: AGHT+IF/gZSyKcTJ3JtKz9ZLa9mL9dSpN/YaI2Cv1brNWxhOUr8PccbkV1dz+Cd+16E6maSfCvr4Pw== X-Received: by 2002:a05:6808:2185:b0:3d9:2920:bc2f with SMTP id 5614622812f47-3db238c0e08mr276075b6e.10.1722011878967; Fri, 26 Jul 2024 09:37:58 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe81463easm14841081cf.26.2024.07.26.09.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 09:37:58 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 2/3] station: don't allow FT-over-Air without offchannel support Date: Fri, 26 Jul 2024 09:37:51 -0700 Message-Id: <20240726163752.1651669-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240726163752.1651669-1-prestwoj@gmail.com> References: <20240726163752.1651669-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 16:37:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13742988 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.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 85FEE17E463 for ; Fri, 26 Jul 2024 16:38:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722011883; cv=none; b=hKO0QC2jtXAFm/zqWQKVtbYOP3vpnU2rBjt7U1cA2/bPMMeYbMcWPSHzkeOuGCau/XtY5x2/fqtZs+f/34bNpM9A+7ShRSTY3B6c+M1oYIMnKYvJLTc1dmaBa0kttAVuRMAZewbJfFiv6kME+HBt/+rXVK/HtNEJK4P6hm05oDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722011883; c=relaxed/simple; bh=UOzLrOLlpW/i5rx77xgP0PmLTJNR0ORSA04mabNWTrg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i4PRtGIVMSx7VtQ1NURLarB5HLCRvs3NmOFlkD8gfqZzDTJCPoaT7XlgDWWHCSEqu4C1mT/UYTI4A69uPiH461KiPfaEJZUh7IBEN58gIYMqmu1C/vJe3WAK0MCmXh2HSPKnKUhyygZ9D72k+wS/a45FrswzOp1iMk3xLagOm+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=T+bFvz39; arc=none smtp.client-ip=209.85.160.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="T+bFvz39" Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-44ff398cefcso5196641cf.0 for ; Fri, 26 Jul 2024 09:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722011880; x=1722616680; 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=jNF5ZkPARZ7yN+jz1TbO/LIa252kat/za5rNygnosvA=; b=T+bFvz39uvuWcpeAWSdk0LB3052R4lz+QEICdBnTq3K06b9vKxLfMtYZ6dl+VoIFa5 mlSiVVo9nuw1/Mh5x+t/mnpWW0KLi7x8ldxPh1oQssdlOiCpsr0IqbpT0sxcz++JPwar RSNNg58TMZ13VbHKrH3CGCGH1Yi1vFsTQG0s+Q2wAj9ILuP7L/q2MuSCg36cqE3m7ltX fBVYC2l+bBdKIlAmEytypMzfHI85oJrXnUinyuXvPpy3SO8J5vwv/j0NXmRdtXX0ujh/ dEKYmP3+uokuHUruI+fAjZuc3snl8gzSJAMcBMhC2mW2XyNr1Zid0GmQE7Y8i9PmkYQ7 +8MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722011880; x=1722616680; 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=jNF5ZkPARZ7yN+jz1TbO/LIa252kat/za5rNygnosvA=; b=oj7CQadasjVFY8hs/oqTGMIjKVNpvnmiYAAZI07hE0WOwf2Sz9a4LPQ4tWkTCSc1fF U/AGW8fvEPmiLOp6OY2cUz/423Czss4wq5aOopWp4cGza03ui++Bqk1OP7stmJ0THJ5C fma9yXI4K2k48lVushrC8RnZIAUqZXkLqhlsKhxWM4wT8loHozvVuzUnRYfvZrTgvjkH wLyTUYGrwDP06ubuJOjObebTQXTP/88xVZtTpaEFBlI5JSCCUFD1i0060lDZz9loMplY KCePlm0DI/zrn7MICatrEXvTNKrTU6pWk2FrSnqogwdLYxSB6WuXWeSdQmdn8duYYUQQ ZlvQ== X-Gm-Message-State: AOJu0Yx0KM86HDJKk/NExuSJgNhkiaWWYjW3ISch1eJeLN0EzGPeUVZR nEIK7q/ROlvHCfB+4GEbIUkf0BIVp6UN5LDyjSbNd17nBJaJkEiSpvqGsA== X-Google-Smtp-Source: AGHT+IE650KfN/jEJWuYaDjTTrvl6sZYqRcQZ4tRm3tA9Ljqq6m49at5Hw8Hxs7V/CoeQ3sC4tFy+A== X-Received: by 2002:ac8:7d03:0:b0:446:6053:e47e with SMTP id d75a77b69052e-45004d8d0camr3552841cf.23.1722011880171; Fri, 26 Jul 2024 09:38:00 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe81463easm14841081cf.26.2024.07.26.09.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 09:37:59 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 3/3] netdev: fall back to RSSI polling if SET_CQM fails Date: Fri, 26 Jul 2024 09:37:52 -0700 Message-Id: <20240726163752.1651669-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240726163752.1651669-1-prestwoj@gmail.com> References: <20240726163752.1651669-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 | 155 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 104 insertions(+), 51 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 2d70fc38..c0e91e31 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; @@ -1372,6 +1380,9 @@ static void netdev_operstate_cb(int error, uint16_t type, strerror(-error)); } +static int netdev_cqm_rssi_update(struct netdev *netdev); + + static void netdev_connect_ok(struct netdev *netdev) { l_debug(""); @@ -1383,6 +1394,8 @@ static void netdev_connect_ok(struct netdev *netdev) netdev->operational = true; + netdev_cqm_rssi_update(netdev); + if (netdev->fw_roam_bss) { if (netdev->event_filter) netdev->event_filter(netdev, NETDEV_EVENT_ROAMED, @@ -3634,11 +3647,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 +3712,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; } @@ -4204,18 +4254,21 @@ static int netdev_tx_ft_frame(uint32_t ifindex, uint16_t frame_type, uint32_t frequency, const uint8_t *dest, struct iovec *iov, size_t iov_len) { + struct netdev *netdev = netdev_find(ifindex); struct l_genl_msg *msg = nl80211_build_cmd_frame(netdev->index, frame_type, netdev->addr, dest, frequency, iov, iov_len); + uint32_t duration = 200; /* * Even though the kernel is doing offchannel for Authentication this * flag is still required otherwise the kernel gives -EBUSY. */ l_genl_msg_append_attr(msg, NL80211_ATTR_OFFCHANNEL_TX_OK, 0, NULL); + l_genl_msg_append_attr(msg, NL80211_ATTR_DURATION, 4, &duration); if (!l_genl_family_send(nl80211, msg, netdev_ft_frame_cb, netdev, NULL)) { @@ -5260,7 +5313,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; }