Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp358900rdh; Tue, 19 Dec 2023 00:38:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFruYZ3wJXvbmgQOCqBmHwPHLBZPHfa2IhdeIx21jOAdRX6LFZOzBRDhlCnl5pkIWoXkopw X-Received: by 2002:a05:622a:15c1:b0:425:4b59:8f3c with SMTP id d1-20020a05622a15c100b004254b598f3cmr27393531qty.30.1702975133592; Tue, 19 Dec 2023 00:38:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702975133; cv=none; d=google.com; s=arc-20160816; b=T889VGzkEn3DvE3jpB0q54TY15l5JixBQQyvPuuCWTNwUde74sgTsyyMhPPAcJ9fC5 djfXi5Z5Iy8nA94jd92U0zBMS4/qY5Il4ZOL47gf1DKbA2R8KOW7zrDkfPopcTXIIDw1 3PuSi5fuxVeGVmtYL97Ctb8gKU/LYKC3/XaW5t6Nd3QrkC4CfQsTk2fzae1MfuzZU4Kw EqsHUpJA13gaBHyAklEvN86S+3g5mlotdgQ0C8TP9w6PAAn+oKZNOae+zX4LWwTfsG8i NnbNtVCF2AZcBZA7xziTUda2yWgKc0CObRiRsHmyIjZEZ4M1ZDFaoqNTBr7ipoUqW9Sr 31Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:organization:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=UHvRGWE//gUvtbANoWqZiHB5XEtj6NjVifsx6T5gAxY=; fh=lOkxZatjZt7UPH9b0z/hrhiS6HFZ08odBSUTGWPuVrA=; b=JeRBcT/+NjvVhhGqlKk1KIZprlXVKrJJ37Sho06y4ULzcHG1TySx7fm65+jEBqTmMK A+5+y4CZSZ7/Z8Dfp/zQZKBxqto6Aia/bVjs63u1MckjzJkgTR8uFCwtiE68kdGCahoo p0LyjtCx1nn9O2gJ8EquKSb5KJo+vVnYmn6Za9LSbC6vdElEABJV7jwRxmRweSTDAs3z vO1PJkabM+5VFNWf7FIMxTd+8mMVyQKrTjVQVSZMYexM9V97UL/Jy+9R0wnqWsztV4R8 7JLFoJQRocuzC95oj9smkvPShp3xdWmB2wOqhouGODasXgCzrkNyR7+nEH5gbSVP3b4Y YDAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b="GC/5cPFU"; spf=pass (google.com: domain of linux-wireless+bounces-975-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-975-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fa12-20020a05622a4ccc00b00425497dcb86si27550377qtb.387.2023.12.19.00.38.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 00:38:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-975-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b="GC/5cPFU"; spf=pass (google.com: domain of linux-wireless+bounces-975-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-975-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5C17F1C23ABC for ; Tue, 19 Dec 2023 08:38:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE8AE13ADF; Tue, 19 Dec 2023 08:38:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GC/5cPFU" X-Original-To: linux-wireless@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EFEE13AD5 for ; Tue, 19 Dec 2023 08:38:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702975093; x=1734511093; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qVh2sesQmYUuXYIAlRyZmjhOyWpIhESTOsf4CK1ea48=; b=GC/5cPFUvNX3pK/0KbiLODtDk6fO9LRz/fgnvHZOJAu6pOisX8xh05Vy 46HjiGjFxXTxnq8fdzm9CpPlfN0sYILUtPSBzUR2ObHBweQGy4JyYkIES bVxy4HFryLmNamp6+j5QshJ2OqNIox639k36uA7y5GGWTzKj1E6LlzSq+ d6S0r/qtOu2DCz01eMVHta8XhaM4sT4fdNQVgXNiwI8erHoTMIqPlttzm zkTkvvu/uzySfr10p4j5jsfsXUHw0buV3ZCe3H/8qXJv5CXjeVsjnxBr+ 56qKwdytBX96Rr5S3iBcuZAe3t44Vr2Lu2pxr85MFfE4GLPv1wb4Mr5RC g==; X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="459969250" X-IronPort-AV: E=Sophos;i="6.04,287,1695711600"; d="scan'208";a="459969250" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2023 00:38:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="846266468" X-IronPort-AV: E=Sophos;i="6.04,287,1695711600"; d="scan'208";a="846266468" Received: from unknown (HELO WEIS0040.iil.intel.com) ([10.12.217.108]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2023 00:38:10 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Ayala Beker , Berg@web.codeaurora.org, Johannes Subject: [PATCH 11/15] wifi: mac80211: fix advertised TTLM scheduling Date: Wed, 20 Dec 2023 04:37:59 +0200 Message-Id: <20231220043149.1f0f63cd03a2.I0dd50bcceff5953080cdd7aee5118b72c78c6507@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231220023803.2901117-1-miriam.rachel.korenblit@intel.com> References: <20231220023803.2901117-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited Content-Transfer-Encoding: 8bit From: Ayala Beker Handle a case of time overflow, where the switch time might be smaller than the partial TSF in the beacon. Additionally, apply advertised TTLM earlier in order to be ready on time on the newly activated links. Fixes: 702e80470a33 ("wifi: mac80211: support handling of advertised TID-to-link mapping") Signed-off-by: Ayala Beker Reviewed-by: Berg, Johannes Signed-off-by: Miri Korenblit --- net/mac80211/mlme.c | 49 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index fe0be3e5731b..b526ce589d4d 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -43,6 +43,9 @@ #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10) #define IEEE80211_ASSOC_MAX_TRIES 3 +#define IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS msecs_to_jiffies(100) +#define IEEE80211_ADV_TTLM_ST_UNDERFLOW 0xff00 + static int max_nullfunc_tries = 2; module_param(max_nullfunc_tries, int, 0644); MODULE_PARM_DESC(max_nullfunc_tries, @@ -5965,6 +5968,13 @@ ieee80211_parse_adv_t2l(struct ieee80211_sub_if_data *sdata, pos++; ttlm_info->switch_time = get_unaligned_le16(pos); + + /* Since ttlm_info->switch_time == 0 means no switch time, bump it + * by 1. + */ + if (!ttlm_info->switch_time) + ttlm_info->switch_time = 1; + pos += 2; if (control & IEEE80211_TTLM_CONTROL_EXPECTED_DUR_PRESENT) { @@ -6059,25 +6069,46 @@ static void ieee80211_process_adv_ttlm(struct ieee80211_sub_if_data *sdata, } if (ttlm_info.switch_time) { - u32 st_us, delay = 0; - u32 ts_l26 = beacon_ts & GENMASK(25, 0); + u16 beacon_ts_tu, st_tu, delay; + u32 delay_jiffies; + u64 mask; /* The t2l map switch time is indicated with a partial - * TSF value, convert it to TSF and calc the delay - * to the start time. + * TSF value (bits 10 to 25), get the partial beacon TS + * as well, and calc the delay to the start time. + */ + mask = GENMASK_ULL(25, 10); + beacon_ts_tu = (beacon_ts & mask) >> 10; + st_tu = ttlm_info.switch_time; + delay = st_tu - beacon_ts_tu; + + /* + * If the switch time is far in the future, then it + * could also be the previous switch still being + * announced. + * We can simply ignore it for now, if it is a future + * switch the AP will continue to announce it anyway. + */ + if (delay > IEEE80211_ADV_TTLM_ST_UNDERFLOW) + return; + + delay_jiffies = TU_TO_JIFFIES(delay); + + /* Link switching can take time, so schedule it + * 100ms before to be ready on time */ - st_us = ieee80211_tu_to_usec(ttlm_info.switch_time); - if (st_us > ts_l26) - delay = st_us - ts_l26; + if (delay_jiffies > IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS) + delay_jiffies -= + IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS; else - continue; + delay_jiffies = 0; sdata->u.mgd.ttlm_info = ttlm_info; wiphy_delayed_work_cancel(sdata->local->hw.wiphy, &sdata->u.mgd.ttlm_work); wiphy_delayed_work_queue(sdata->local->hw.wiphy, &sdata->u.mgd.ttlm_work, - usecs_to_jiffies(delay)); + delay_jiffies); return; } } -- 2.34.1