From patchwork Tue Jun 2 00:10:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1301983 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=PZpgjWRK; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=MB3qxmUs; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bXWK585xz9sTc for ; Tue, 2 Jun 2020 10:10:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=rCrjstkJEz++tZQxpzb/uODMcdPJeRid/J4ttcLeXio=; b=PZpgjWRKJUih8V cT4nSL8TgcZTxqhMb+5NsIvAxWMQSQgiAJ1GaHiEo/7LQFaLRNOXC1amiCKFzb+1OP4GdzFEJXJtx 2NKANuQtfb1Bwr2TFCoKK6bk5XF27jHEb6cv+J1uoFU9ttJsx/NbejIH26pigoarj18Aji3xIHobx MxwmnGZwB9Jo1Rwzqma8jLpPYhNPK8Q9TF4WFMDoa1Q+7QCS7YRRV/XlnV5j2Tqq3B1uIcgNK/V7g cee8Lalr75Gs8ocLIeGJYnzFFh8JhrRH4C0pkUwP5ymZFsdU1vT4a3RWi/W5WdIExUBnivWXQ5KPb I+kjE+Bli3JLTLRoILnA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfuVj-0006kl-QL; Tue, 02 Jun 2020 00:10:31 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfuVd-0006kA-Pw for hostap@lists.infradead.org; Tue, 02 Jun 2020 00:10:28 +0000 Received: by mail-pj1-x1044.google.com with SMTP id s88so561563pjb.5 for ; Mon, 01 Jun 2020 17:10:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pZkRx16RcaHlbTqvzmRFlqNyVruMfbEdB8ELUjOYecA=; b=MB3qxmUsTN2+/3toC2khGaCK2PBzmyhPsSSkvPOsLrWfW7sRFIX9CtIC8oJEx7OyyY GR8T0vscVucPL1NlivJyZg+CUETn3DMjO2yNQDC5FMGsvF5wzNLfRtYBgRpJ8XLc04lT SFUTX39APC8kCpObTQN/I+cj9TCL0/hwP9ZVs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pZkRx16RcaHlbTqvzmRFlqNyVruMfbEdB8ELUjOYecA=; b=EhYNHT4oe1g/eA3+MQsoNuFMpHt82XluUVI6WBdEI8XTMX294xaaKJCCd90Sws91wJ iB0ad8rHIz+K7GE73G4fBK7iCnHpJUeHEQiFbBPAPB63Q+aa0JOTw5+fLkl90tzm5d/E blq/Z8OAicrrqE8+n6mzH4oNKlYpKR34lJ4Gf9n/d12a4r0YhkB/TA9Hl+KfhltU/sjK mjgAAHSQA00cVGbgqVeLL67xAWWl1OJtVsj8K2yc9jykPHdYXvHKh2MpQBS8Cg3DR16V dEt4gVKEcii8VT3Ko5oeOuNwVauI/wOmZrejtXJEUn7X4W+8OzfKqJ2Dp1+ge6S8v6XK 30AQ== X-Gm-Message-State: AOAM533Mlo60M+LJ6Fu8T2UTnVsAo57JmgjqICcmZtOhsOJGs3Xtrih7 f1x27Z629lmiHSSeLl95OtUITw== X-Google-Smtp-Source: ABdhPJwmyL07RNrk2F9WipBSUPWH4CkvSR2PVXH07h8+87Z5iotTLM5r5JNAU3xZosUX283AYtMtBw== X-Received: by 2002:a17:902:9e0c:: with SMTP id d12mr23579867plq.29.1591056623289; Mon, 01 Jun 2020 17:10:23 -0700 (PDT) Received: from localhost ([2620:15c:202:201:2b10:8627:31e7:c5ec]) by smtp.gmail.com with ESMTPSA id p31sm517884pgb.46.2020.06.01.17.10.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2020 17:10:22 -0700 (PDT) From: Matthew Wang To: j@w1.fi Subject: [PATCH 1/6] Use LUT instead of macro Date: Mon, 1 Jun 2020 17:10:13 -0700 Message-Id: <20200602001018.83640-1-matthewmwang@chromium.org> X-Mailer: git-send-email 2.27.0.rc2.251.g90737beb825-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200601_171025_860136_C7BB0E9E X-CRM114-Status: GOOD ( 11.94 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1044 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hostap@lists.infradead.org, Matthew Wang Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Change INTERPOLATE_RATE macro to a lookup-table instead for the sake of readability. Signed-off-by: Matthew Wang --- wpa_supplicant/scan.c | 127 ++++++++++++++++++++++++++---------------- 1 file changed, 79 insertions(+), 48 deletions(-) diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index b47573094..85513779f 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -2186,6 +2186,63 @@ void scan_snr(struct wpa_scan_res *res) } } +/* Minimum SNR required to achieve a certain bitrate. */ +struct minsnr_bitrate_entry { + int minsnr; + unsigned int bitrate; /* in Mbps */ +}; + + +/* VHT needs to be enabled in order to achieve MCS8 and MCS9 rates. */ +static const int vht_mcs = 8; + + +static struct minsnr_bitrate_entry vht20_table[] = { + {0, 0}, + {2, 6500}, /* HT20 MCS0 */ + {5, 13000}, /* HT20 MCS1 */ + {9, 19500}, /* HT20 MCS2 */ + {11, 26000}, /* HT20 MCS3 */ + {15, 39000}, /* HT20 MCS4 */ + {18, 52000}, /* HT20 MCS5 */ + {20, 58500}, /* HT20 MCS6 */ + {25, 65000}, /* HT20 MCS7 */ + {29, 78000}, /* VHT20 MCS8 */ + {-1, 78000} /* SNR > 29 */ +}; + + +static struct minsnr_bitrate_entry vht40_table[] = { + {0, 0}, + {5, 13500}, /* HT40 MCS0 */ + {8, 27000}, /* HT40 MCS1 */ + {12, 40500}, /* HT40 MCS2 */ + {14, 54000}, /* HT40 MCS3 */ + {18, 81000}, /* HT40 MCS4 */ + {21, 108000}, /* HT40 MCS5 */ + {23, 121500}, /* HT40 MCS6 */ + {28, 135000}, /* HT40 MCS7 */ + {32, 162000}, /* VHT40 MCS8 */ + {34, 180000}, /* VHT40 MCS9 */ + {-1, 180000} /* SNR > 34 */ +}; + + +static struct minsnr_bitrate_entry vht80_table[] = { + {0, 0}, + {8, 29300}, /* VHT80 MCS0 */ + {11, 58500}, /* VHT80 MCS1 */ + {15, 87800}, /* VHT80 MCS2 */ + {17, 117000}, /* VHT80 MCS3 */ + {21, 175500}, /* VHT80 MCS4 */ + {24, 234000}, /* VHT80 MCS5 */ + {26, 263300}, /* VHT80 MCS6 */ + {31, 292500}, /* VHT80 MCS7 */ + {35, 351000}, /* VHT80 MCS8 */ + {37, 390000}, /* VHT80 MCS9 */ + {-1, 390000} /* SNR > 37 */ +}; + static unsigned int interpolate_rate(int snr, int snr0, int snr1, int rate0, int rate1) @@ -2194,67 +2251,41 @@ static unsigned int interpolate_rate(int snr, int snr0, int snr1, } -#define INTERPOLATE_RATE(snr0, snr1, rate0, rate1) \ - if (snr < (snr1)) \ - return interpolate_rate(snr, (snr0), (snr1), (rate0), (rate1)) +static unsigned int max_rate(struct minsnr_bitrate_entry table[], + int snr, int vht) +{ + struct minsnr_bitrate_entry *prev, *entry = table; + + while ((entry->minsnr != -1) && + (snr >= entry->minsnr) && + (vht || entry - table <= vht_mcs)) + entry++; + if (entry == table) + return entry->bitrate; + prev = entry - 1; + if (entry->minsnr == -1 || (!vht && entry - table > vht_mcs)) + return prev->bitrate; + return interpolate_rate(snr, prev->minsnr, entry->minsnr, prev->bitrate, + entry->bitrate); +} + static unsigned int max_ht20_rate(int snr, int vht) { - if (snr < 0) - return 0; - INTERPOLATE_RATE(0, 2, 0, 6500); /* HT20 MCS0 */ - INTERPOLATE_RATE(2, 5, 6500, 13000); /* HT20 MCS1 */ - INTERPOLATE_RATE(5, 9, 13000, 19500); /* HT20 MCS2 */ - INTERPOLATE_RATE(9, 11, 19500, 26000); /* HT20 MCS3 */ - INTERPOLATE_RATE(11, 15, 26000, 39000); /* HT20 MCS4 */ - INTERPOLATE_RATE(15, 18, 39000, 52000); /* HT20 MCS5 */ - INTERPOLATE_RATE(18, 20, 52000, 58500); /* HT20 MCS6 */ - INTERPOLATE_RATE(20, 25, 58500, 65000); /* HT20 MCS7 */ - if (!vht) - return 65000; - INTERPOLATE_RATE(25, 29, 65000, 78000); /* VHT20 MCS8 */ - return 78000; + return max_rate(vht20_table, snr, vht); } static unsigned int max_ht40_rate(int snr, int vht) { - if (snr < 0) - return 0; - INTERPOLATE_RATE(0, 5, 0, 13500); /* HT40 MCS0 */ - INTERPOLATE_RATE(5, 8, 13500, 27000); /* HT40 MCS1 */ - INTERPOLATE_RATE(8, 12, 27000, 40500); /* HT40 MCS2 */ - INTERPOLATE_RATE(12, 14, 40500, 54000); /* HT40 MCS3 */ - INTERPOLATE_RATE(14, 18, 54000, 81000); /* HT40 MCS4 */ - INTERPOLATE_RATE(18, 21, 81000, 108000); /* HT40 MCS5 */ - INTERPOLATE_RATE(21, 23, 108000, 121500); /* HT40 MCS6 */ - INTERPOLATE_RATE(23, 28, 121500, 135000); /* HT40 MCS7 */ - if (!vht) - return 135000; - INTERPOLATE_RATE(28, 32, 135000, 162000); /* VHT40 MCS8 */ - INTERPOLATE_RATE(32, 34, 162000, 180000); /* VHT40 MCS9 */ - return 180000; + return max_rate(vht40_table, snr, vht); } static unsigned int max_vht80_rate(int snr) { - if (snr < 0) - return 0; - INTERPOLATE_RATE(0, 8, 0, 29300); /* VHT80 MCS0 */ - INTERPOLATE_RATE(8, 11, 29300, 58500); /* VHT80 MCS1 */ - INTERPOLATE_RATE(11, 15, 58500, 87800); /* VHT80 MCS2 */ - INTERPOLATE_RATE(15, 17, 87800, 117000); /* VHT80 MCS3 */ - INTERPOLATE_RATE(17, 21, 117000, 175500); /* VHT80 MCS4 */ - INTERPOLATE_RATE(21, 24, 175500, 234000); /* VHT80 MCS5 */ - INTERPOLATE_RATE(24, 26, 234000, 263300); /* VHT80 MCS6 */ - INTERPOLATE_RATE(26, 31, 263300, 292500); /* VHT80 MCS7 */ - INTERPOLATE_RATE(31, 35, 292500, 351000); /* VHT80 MCS8 */ - INTERPOLATE_RATE(35, 37, 351000, 390000); /* VHT80 MCS9 */ - return 390000; -} - -#undef INTERPOLATE_RATE + return max_rate(vht80_table, snr, 1); +} unsigned int wpas_get_est_tpt(const struct wpa_supplicant *wpa_s, From patchwork Tue Jun 2 00:10:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1301982 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=PCNxlaVR; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Xywrdbb7; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bXWL1ZXhz9sVK for ; Tue, 2 Jun 2020 10:10:54 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HCMy7m0wdxAW/pTFyQf7WMFdQydLc5vIfcPRFJFD7Kc=; b=PCNxlaVRRsy1KQ 3qME+Q7EiU16UacsK7Z79RMSGPTPmiICEv0ujCVqX7+UCoTJltJZzKrkwc0/XOrjwGDE1obrKiwVf 6cBlFYtY6F83JzhNFibmi+qHcDQil9+w5VInc/oPpXxVaNNOjwsl1NT+iNDuNhAClgKhymdTJ2Qgu QqDMUIpPQvxKFfNH6OkTWqIV/ENRqgHXIx8C8hOxOUfPZK7d7lyLDiaa/nKMH76GCSG7s2OCseq3P YV3HCp+LyO27FI03MR7oEwzbCNNCvq8whb13Bg2atQbcSZsmEEY7Nwq01HMf1JJn+HnYb4d4/WHqQ kdZWhX38K6eUTmua9k5g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfuVp-0006rC-BW; Tue, 02 Jun 2020 00:10:37 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfuVl-0006mq-Rg for hostap@lists.infradead.org; Tue, 02 Jun 2020 00:10:35 +0000 Received: by mail-pg1-x52f.google.com with SMTP id u5so4241125pgn.5 for ; Mon, 01 Jun 2020 17:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rSCu6eQc/RjFkdk8EnABCSJrfL6bvXFxfnK72lHWXUw=; b=Xywrdbb77igxtW1UYh8zqVV7W1alA8p/77Bo/PtuDfXyq9lHMeXR0asZvIGChYQoTn IhLdFx1AL8HAtBtPKbv74k9E+I/lXm2EgwsSu/rcsFSCP5H9QqAnpmCOAm5+eoLAKHqS tQkTPd2HZUXleIucZ179sCB8X7Ys1RRgX58F0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rSCu6eQc/RjFkdk8EnABCSJrfL6bvXFxfnK72lHWXUw=; b=QNBRgzQ9ZKA3L5plFcnrRuJHjvVw6Gcjbi39HsekpyB1pJg2W2nVFQ2W5g74J2YhhO YRSfWNu4WS+taraq53fLZgAeB+bFPyfEridH3RByuzhwrShO45Qm4wqZGUMy6p39RCDW KdPV+rOW11u+nXG8yvwwYzDkB9SETzaIpnOX+uNSjOc3RjeWBtmsiAiIOYhtv52UZfA2 aCKzcVd/Nt5uYCMqUPU9jQs7T3p3KUc0o92vTfNPcliMEg4h8rFXAkk5fM/HUVTTVBIT eOIofUywgGJ+nArdCe05bU46FUA6R+Ev3hKM5FHki59OQGPBTSzvtBMIGWmG6umWyrRo Vkxw== X-Gm-Message-State: AOAM530w7uqomPHgBwys+QPxXxdfyC7bLidR4hC7onkWwAOkGt6yKlbT FvVZ6ol/l5HwiEntzUGyk3MVjxn4FRY= X-Google-Smtp-Source: ABdhPJwCT3KxeJOQbwfLhqxx5QLmSumvQUGzSGKOZWFCznlt4yydLqZeh3yyJu5MWWXWgPOZGi8ngw== X-Received: by 2002:a05:6a00:1583:: with SMTP id u3mr10551318pfk.145.1591056632959; Mon, 01 Jun 2020 17:10:32 -0700 (PDT) Received: from localhost ([2620:15c:202:201:2b10:8627:31e7:c5ec]) by smtp.gmail.com with ESMTPSA id x2sm463644pfj.142.2020.06.01.17.10.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2020 17:10:32 -0700 (PDT) From: Matthew Wang To: j@w1.fi Subject: [PATCH 2/6] Rewrite roaming logic Date: Mon, 1 Jun 2020 17:10:14 -0700 Message-Id: <20200602001018.83640-2-matthewmwang@chromium.org> X-Mailer: git-send-email 2.27.0.rc2.251.g90737beb825-goog In-Reply-To: <20200602001018.83640-1-matthewmwang@chromium.org> References: <20200602001018.83640-1-matthewmwang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200601_171033_903504_7A7115F6 X-CRM114-Status: GOOD ( 17.03 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:52f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hostap@lists.infradead.org, Matthew Wang Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The roaming logic is currently too aggressive and full of holes. In particular, the (arbitrary) values we currently assign to the roaming difficulty are too small; an AP can reasonably move up or down 5dB in RSSI in an enterprise environment even when the device is static. The logic needs to be more resilient to these small fluctuations. The following notes describe each of the changes made and the rationale behind it. 1. Remove all short-circuiting and allow the roaming logic below to run its course. This way we avoid overlooking important factors. 2. Add a to_2ghz flag that indicates if we are moving from a 5ghz AP to a 2ghz AP. This should increase the difficulty to roam in that direction and mirror the to_5ghz flag. 3. Adjust the min_diff upward across the board. Originally, we would roam with a RSSI imporvement of 1dB in the weakest bucket and 5dB in the strongest bucket. RSSI is fairly fickle and APs can easily fluctuate by more than that in a normal enterprise environment. Additionally, there should be more buckets. We currently stop differentiating after the RSSI is at least -70dB. This is still pretty weak, and the difficulty should continue to increase above that. Move the threshold up to 4dB in the weakest bucket and 10dB in the strongest bucket, and add two more buckets (up to -60dB). 4. We adjust the roam difficulty up and down based on the estimated throughput of the selected AP relative to the estimated throughput of the current AP. Small gains or losses in estimated throughput should not be rewarded or penalized as heavily as they are now since estimated throughput is a hand-wavy measurement to begin with. Relax these adjustments. 5. At lower signal levels, we shouldn't care as much about estimated throughput gains. In particular, below a certain threshold, we should only be chasing RSSI gains in search of a more stable connection. For example, it doesn't matter that we gain 10% estimated throughput if our RSSI is bad. Introduce an adjust_factor so that we can weight estimated throughput differently. Signed-off-by: Matthew Wang --- wpa_supplicant/events.c | 103 +++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 53 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index f0f91892f..d6e4be3c7 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1782,8 +1782,10 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, struct wpa_bss *current_bss = NULL; #ifndef CONFIG_NO_ROAMING int min_diff, diff; - int to_5ghz; + int to_2ghz, to_5ghz; int cur_level; + int adjust = 0; + double adjust_factor, est_ratio; unsigned int cur_est, sel_est; struct wpa_signal_info si; int cur_snr = 0; @@ -1871,65 +1873,60 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, cur_level, cur_snr, cur_est); } - if (sel_est > cur_est + 5000) { - wpa_dbg(wpa_s, MSG_DEBUG, - "Allow reassociation - selected BSS has better estimated throughput"); - return 1; - } - + to_2ghz = current_bss->freq > 4000 && selected->freq < 4000; to_5ghz = selected->freq > 4000 && current_bss->freq < 4000; - if (cur_level < 0 && cur_level > selected->level + to_5ghz * 2 && - sel_est < cur_est * 1.2) { - wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - Current BSS has better " - "signal level"); - return 0; - } - - if (cur_est > sel_est + 5000) { - wpa_dbg(wpa_s, MSG_DEBUG, - "Skip roam - Current BSS has better estimated throughput"); - return 0; + /* + * Set the minimum RSSI difference needed to roam (`min_diff`) and the + * estimated throughput weight (`adjust_factor`) based on the RSSI of + * the current AP. At low RSSI (< -70 dBm), we ignore estimated + * throughput gains and only consider RSSI gains. At higher RSSI, + * `adjust_factor` is multiplied by `adjust` (set below according to the + * selected AP's estimated throughput relative to the current AP's + * estimated throughput) to influence the `min_diff`. + */ + if (cur_level < -85) { /* ..-86 dBm */ + min_diff = 4; + adjust_factor = 0; + } else if (cur_level < -80) { /* -85..-81 dBm */ + min_diff = 5; + adjust_factor = 0.2; + } else if (cur_level < -75) { /* -80..-76 dBm */ + min_diff = 6; + adjust_factor = 0.4; + } else if (cur_level < -70) { /* -75..-71 dBm */ + min_diff = 7; + adjust_factor = 0.6; + } else if (cur_level < -65) { /* -70..-66 dBm */ + min_diff = 8; + adjust_factor = 0.8; + } else if (cur_level < -60) { /* -65..-61 dBm */ + min_diff = 9; + adjust_factor = 1.0; + } else if (cur_level < 0) { /* -60..-1 dBm */ + min_diff = 10; + adjust_factor = 1.2; + } else { /* unspecified units (not in dBm) */ + min_diff = 5; + adjust_factor = 1.0; } - if (cur_snr > GREAT_SNR) { - wpa_dbg(wpa_s, MSG_DEBUG, - "Skip roam - Current BSS has good SNR (%u > %u)", - cur_snr, GREAT_SNR); - return 0; + sel_est = selected->est_throughput; + if (cur_est > sel_est) { + adjust = 1; + est_ratio = sel_est == 0 ? 2 : (double) cur_est / sel_est; + } else { + adjust = -1; + est_ratio = cur_est == 0 ? 2 : (double) sel_est / cur_est; } + if (est_ratio > 2) + est_ratio = 2; + adjust *= (int) ((est_ratio - 1) * 10); + min_diff += adjust * adjust_factor; - if (cur_level < -85) /* ..-86 dBm */ - min_diff = 1; - else if (cur_level < -80) /* -85..-81 dBm */ - min_diff = 2; - else if (cur_level < -75) /* -80..-76 dBm */ - min_diff = 3; - else if (cur_level < -70) /* -75..-71 dBm */ - min_diff = 4; - else if (cur_level < 0) /* -70..-1 dBm */ - min_diff = 5; - else /* unspecified units (not in dBm) */ - min_diff = 2; - - if (cur_est > sel_est * 1.5) - min_diff += 10; - else if (cur_est > sel_est * 1.2) - min_diff += 5; - else if (cur_est > sel_est * 1.1) + if (to_2ghz) min_diff += 2; - else if (cur_est > sel_est) - min_diff++; - else if (sel_est > cur_est * 1.5) - min_diff -= 10; - else if (sel_est > cur_est * 1.2) - min_diff -= 5; - else if (sel_est > cur_est * 1.1) - min_diff -= 2; - else if (sel_est > cur_est) - min_diff--; - - if (to_5ghz) + else if (to_5ghz) min_diff -= 2; diff = selected->level - cur_level; if (diff < min_diff) { From patchwork Tue Jun 2 00:10:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1301984 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=AZ3j50ct; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ERN5Ml1d; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bXWW0WxJz9sVK for ; Tue, 2 Jun 2020 10:11:03 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Rq7et8KP511Wh4CgwbZTRVAGMHcqm4hL+BSG5cKmdew=; b=AZ3j50ct1t4dts RPnl5AzmZ6YWY2TZ8LenoLYMXIkVY9OyWdU8Xz+AZjj7nWFcXxUYogsaPosaaWVaGYPjPHl3bsy/Z +IjGJsmaU2XR0We20rU0Um7gnzeMgsZd8zwALascZTI8la3liTCikllVb5l8uJBfktw2EYudIo/56 5cCz3ChFpTRna2g0s32h0saY0GZAP9RUpVK7H9s41fcTG4i1rWuW7t/NttTFkDRIYPP9NHItFpv+A jfqxNo35aTKsu+NcrYgUF0SnrqWQfzt47DsdM+qPFgpVljofiFPk8W26WhIrwPij6ECeoGmrKj8Hz CHv1cV0FqUOWUmAEdgdg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfuW3-0007Ep-3e; Tue, 02 Jun 2020 00:10:51 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfuVp-0006rD-Kp for hostap@lists.infradead.org; Tue, 02 Jun 2020 00:10:39 +0000 Received: by mail-pj1-x1042.google.com with SMTP id q24so572952pjd.1 for ; Mon, 01 Jun 2020 17:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Irg8GT4nRyGSk/ZXWnaO870mUF+1VM9S/R1guIufvnA=; b=ERN5Ml1d8i5nOENUtSN4w8IGBCOw4D1ua2EUuiMJjXvlB0pjlkRRGVLHVVMwNtgMmR HxmpbpYINjTO3j53GTLafs+ENMBW1WNj/STdSkE6c+hJL7HtnNLr1KQpb/48rmw48Sjw 1NtufTcb6Iq1QUHGIC/yeGW60eOxed5zsKuGA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Irg8GT4nRyGSk/ZXWnaO870mUF+1VM9S/R1guIufvnA=; b=fxYFjGXoqQVZ8hgG6gwUTHyXxvb4r036zLr0kTWjpjIB7AFIn7YIvBmdDTpl+vKfkD pFTP0+A6XUTzZPFu6N3NJlmKb1GnAKRp46fYU2E0Whm2LlrPLHUszWBUXDBZ5gew3XZ4 W8n7zh0ve7cyZaxl0tYO/WOvbWrQeFtezFgQnOUoOn0mHLCpMTgj16ITh1MRNdsJWNHr R5Sk1h2QwGVj7xZNOFJadrsSoLN6RK8Uqh3ThC42NsovPW7ju7NiXLy2c+DesRuWTjp9 A9AO9wTc4bpv60i7HW8xWWQdufNb4nKKrYg4L30DHYCW8pNcNALVaWAgll2fq4CYZTls szLA== X-Gm-Message-State: AOAM533/R4BcOjYPbAxGN4iSTgqZlBRifd3unEkWan5cZtvTlXj4tjnr crtE1Srq7MoPfdJp66W4L7gtMw== X-Google-Smtp-Source: ABdhPJzEgu/KjBuapQmUHR09InqaBihNqoALJeCdJg+iihZlgkuJZ0TxmmES09mBmSclByMSUv7ZEQ== X-Received: by 2002:a17:90a:3608:: with SMTP id s8mr2051582pjb.167.1591056636851; Mon, 01 Jun 2020 17:10:36 -0700 (PDT) Received: from localhost ([2620:15c:202:201:2b10:8627:31e7:c5ec]) by smtp.gmail.com with ESMTPSA id o21sm487512pfp.12.2020.06.01.17.10.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2020 17:10:36 -0700 (PDT) From: Matthew Wang To: j@w1.fi Subject: [PATCH 3/6] Refactor need_to_roam Date: Mon, 1 Jun 2020 17:10:15 -0700 Message-Id: <20200602001018.83640-3-matthewmwang@chromium.org> X-Mailer: git-send-email 2.27.0.rc2.251.g90737beb825-goog In-Reply-To: <20200602001018.83640-1-matthewmwang@chromium.org> References: <20200602001018.83640-1-matthewmwang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200601_171037_734719_F0197F6E X-CRM114-Status: GOOD ( 15.76 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1042 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hostap@lists.infradead.org, Matthew Wang Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Pull all the within-ESS roam code out of wpa_supplicant_need_to_roam() and into its own function, wpa_supplicant_need_to_roam_within_ess(). This way, we avoid interleaving several #ifndef's in the original function and wrap the new function in one big #ifndef. This also modularizes the within-ESS roam code and makes it easier to test. Signed-off-by: Matthew Wang --- wpa_supplicant/events.c | 81 +++++++++++++++++-------------- wpa_supplicant/wpa_supplicant_i.h | 5 ++ 2 files changed, 49 insertions(+), 37 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index d6e4be3c7..60cbf5a54 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1772,15 +1772,11 @@ wpas_get_est_throughput_from_bss_snr(const struct wpa_supplicant *wpa_s, return wpas_get_est_tpt(wpa_s, ies, ie_len, rate, snr); } -#endif /* CONFIG_NO_ROAMING */ - -static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, - struct wpa_bss *selected, - struct wpa_ssid *ssid) +int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s, + struct wpa_bss *current_bss, + struct wpa_bss *selected) { - struct wpa_bss *current_bss = NULL; -#ifndef CONFIG_NO_ROAMING int min_diff, diff; int to_2ghz, to_5ghz; int cur_level; @@ -1789,37 +1785,7 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, unsigned int cur_est, sel_est; struct wpa_signal_info si; int cur_snr = 0; -#endif /* CONFIG_NO_ROAMING */ - - if (wpa_s->reassociate) - return 1; /* explicit request to reassociate */ - if (wpa_s->wpa_state < WPA_ASSOCIATED) - return 1; /* we are not associated; continue */ - if (wpa_s->current_ssid == NULL) - return 1; /* unknown current SSID */ - if (wpa_s->current_ssid != ssid) - return 1; /* different network block */ - - if (wpas_driver_bss_selection(wpa_s)) - return 0; /* Driver-based roaming */ - - if (wpa_s->current_ssid->ssid) - current_bss = wpa_bss_get(wpa_s, wpa_s->bssid, - wpa_s->current_ssid->ssid, - wpa_s->current_ssid->ssid_len); - if (!current_bss) - current_bss = wpa_bss_get_bssid(wpa_s, wpa_s->bssid); - if (!current_bss) - return 1; /* current BSS not seen in scan results */ - - if (current_bss == selected) - return 0; - - if (selected->last_update_idx > current_bss->last_update_idx) - return 1; /* current BSS not seen in the last scan */ - -#ifndef CONFIG_NO_ROAMING wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation"); wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR " freq=%d level=%d snr=%d est_throughput=%u", @@ -1940,6 +1906,47 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, "Allow reassociation due to difference in signal level (%d >= %d)", diff, min_diff); return 1; +} + +#endif /* CONFIG_NO_ROAMING */ + +static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, + struct wpa_bss *selected, + struct wpa_ssid *ssid) +{ + struct wpa_bss *current_bss = NULL; + + if (wpa_s->reassociate) + return 1; /* explicit request to reassociate */ + if (wpa_s->wpa_state < WPA_ASSOCIATED) + return 1; /* we are not associated; continue */ + if (wpa_s->current_ssid == NULL) + return 1; /* unknown current SSID */ + if (wpa_s->current_ssid != ssid) + return 1; /* different network block */ + + if (wpas_driver_bss_selection(wpa_s)) + return 0; /* Driver-based roaming */ + + if (wpa_s->current_ssid->ssid) + current_bss = wpa_bss_get(wpa_s, wpa_s->bssid, + wpa_s->current_ssid->ssid, + wpa_s->current_ssid->ssid_len); + if (!current_bss) + current_bss = wpa_bss_get_bssid(wpa_s, wpa_s->bssid); + + if (!current_bss) + return 1; /* current BSS not seen in scan results */ + + if (current_bss == selected) + return 0; + + if (selected->last_update_idx > current_bss->last_update_idx) + return 1; /* current BSS not seen in the last scan */ + +#ifndef CONFIG_NO_ROAMING + return wpa_supplicant_need_to_roam_within_ess(wpa_s, current_bss, + selected); #else /* CONFIG_NO_ROAMING */ return 0; #endif /* CONFIG_NO_ROAMING */ diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 28867f04e..e7bc0bc41 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1523,6 +1523,11 @@ struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s, int wpas_temp_disabled(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); void wpa_supplicant_update_channel_list(struct wpa_supplicant *wpa_s, struct channel_list_changed *info); +#ifndef CONFIG_NO_ROAMING +int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s, + struct wpa_bss *current_bss, + struct wpa_bss *seleceted); +#endif /* CONFIG_NO_ROAMING */ /* eap_register.c */ int eap_register_methods(void); From patchwork Tue Jun 2 00:10:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1301985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=neteaExR; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=HtJecEMs; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bXWj60F1z9sTc for ; Tue, 2 Jun 2020 10:11:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=y8j57Dws8QjmFvWFFtwOAZQSLh0EgfTCnMQKNCRix7M=; b=neteaExRopaMra r25mjcUy1kzHrYYDyjeEyVjSsItsbPViOtpB+SRtj+8r4zunaKz8j0h2TXGfSa5On7/OK+qMg+16i ov6MinmOsRPQUZCeoDy4XBeHuwb0hQSau5fCFSdlKazHlewViJ8qGEoSOet5afxB6fRqsuLASB0fd XNKWBI1IgUcpx7J+AS67Gdb0juLD4A0SOtK40/i/XaE39RPvqQ0RF4YfA9I7DekxS+nqV+Ljsir0z 6M+SJRooWGXk5Yq28uo634ihwvYaco+3rca9OI2mNjbnDY2oTPoqgrY8jnYVo8JCghXFzNDJFp93y n2RTkir09AboAdOm4f3Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfuWD-0007Qb-NQ; Tue, 02 Jun 2020 00:11:01 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfuVs-0006ul-Kn for hostap@lists.infradead.org; Tue, 02 Jun 2020 00:10:42 +0000 Received: by mail-pg1-x541.google.com with SMTP id p21so4221697pgm.13 for ; Mon, 01 Jun 2020 17:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rhLQjqbr9PdnzsBRAJVQD8DumtYfTmfsQvIj2IjnHSM=; b=HtJecEMsg1FbauaG8ZHnekuKfR5CtOMQKosBFbe/HQM6YKlCUYAn2C5pzJWpOWRFBz se7Jgx63rFh5IOIZJmNhR+TKSmsCAkgA7+mrRAcFgzvH4HyFy031oeFY93aNNXVolO78 sJB6qMWrmQ5VvzhU6t280EI0TPXKigdkYBmCA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rhLQjqbr9PdnzsBRAJVQD8DumtYfTmfsQvIj2IjnHSM=; b=IWoxKGVZa9LFvKhMiWC8sRTDVpLJrtPYuJlcFr2J4YJCDiCsGNIOWamW5g1PN2X13l d87tQg45cyKVxfkEROWhn1MhfP8wqAjRvmfivddQoFUevezXMhgH2LqHDH7X+07bvYJp QO7MrfWffAe0rOpNV5+of9Of83UC89cBbbenmWqskGKHxDk76Hi8r1y+DAtDBDlANuSs kBwSjFZ89yc2RZsZ3P+Kqlt4ZiGgHQW8Z7Q3t/sXISk6gYskxmyxLOk1PpwllnZe1LRQ CBo0jssDaW2F5H9Ls1ZFT6Tb9dznkT9v1rwf8CzztQoPOTdTHCjn/x27DCPS3Hh+yUH/ wvPA== X-Gm-Message-State: AOAM5320XEjFVDcaDuXXRD3SzbOPs3oglLhQfjKlFYB9xRNQwd0Tvlvz GEk/UgYTgJss5n+HrN5u1U+aH1/Hm/s= X-Google-Smtp-Source: ABdhPJwWnxXUHUshVXBI78VCl2Ef8CA5H9Sb0hQbyXLIb/UYby8ctyswnrEo1wVjpuhm9Ai/Mpl6jQ== X-Received: by 2002:a65:5349:: with SMTP id w9mr21824679pgr.281.1591056639696; Mon, 01 Jun 2020 17:10:39 -0700 (PDT) Received: from localhost ([2620:15c:202:201:2b10:8627:31e7:c5ec]) by smtp.gmail.com with ESMTPSA id t14sm486502pju.42.2020.06.01.17.10.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2020 17:10:39 -0700 (PDT) From: Matthew Wang To: j@w1.fi Subject: [PATCH 4/6] wpas_module_tests: add need_to_roam module test Date: Mon, 1 Jun 2020 17:10:16 -0700 Message-Id: <20200602001018.83640-4-matthewmwang@chromium.org> X-Mailer: git-send-email 2.27.0.rc2.251.g90737beb825-goog In-Reply-To: <20200602001018.83640-1-matthewmwang@chromium.org> References: <20200602001018.83640-1-matthewmwang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200601_171040_709654_58B5D196 X-CRM114-Status: GOOD ( 13.50 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:541 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hostap@lists.infradead.org, Matthew Wang Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Sanity check the wpa_supplicant_need_to_roam function to ensure that we're roaming (or not) in obvious situations. Signed-off-by: Matthew Wang --- wpa_supplicant/wpas_module_tests.c | 90 ++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/wpa_supplicant/wpas_module_tests.c b/wpa_supplicant/wpas_module_tests.c index 4e37591be..c721c2514 100644 --- a/wpa_supplicant/wpas_module_tests.c +++ b/wpa_supplicant/wpas_module_tests.c @@ -12,6 +12,18 @@ #include "utils/module_tests.h" #include "wpa_supplicant_i.h" #include "blacklist.h" +#ifndef CONFIG_NO_ROAMING +#include "bss.h" +#include "config.h" +#include "scan.h" + + +enum roam_type { + ROAM_SAME_BAND, + ROAM_TO_5, + ROAM_TO_2, +}; +#endif /* CONFIG_NO_ROAMING */ static int wpas_blacklist_module_tests(void) @@ -70,6 +82,79 @@ fail: } +#ifndef CONFIG_NO_ROAMING +static int check_roam(struct wpa_supplicant *wpa_s, struct wpa_bss *curr, + struct wpa_bss *sel, enum roam_type type, int cur_level, + int sel_level, int cur_est, int sel_est) +{ + if (type == ROAM_TO_5) { + curr->freq = 2412; + sel->freq = 5180; + } else if (type == ROAM_TO_2) { + curr->freq = 5180; + sel->freq = 2412; + } else { + curr->freq = 2412; + sel->freq = 2417; + } + curr->level = cur_level; + sel->level = sel_level; + curr->snr = curr->level - (IS_5GHZ(curr->freq) ? + DEFAULT_NOISE_FLOOR_5GHZ : + DEFAULT_NOISE_FLOOR_2GHZ); + sel->snr = sel->level - (IS_5GHZ(sel->freq) ? + DEFAULT_NOISE_FLOOR_5GHZ : + DEFAULT_NOISE_FLOOR_2GHZ); + curr->est_throughput = cur_est; + sel->est_throughput = sel_est; + return wpa_supplicant_need_to_roam_within_ess(wpa_s, curr, sel); +} + + +static int wpas_need_to_roam_module_tests() +{ + wpa_printf(MSG_INFO, "need_to_roam module tests"); + struct wpa_supplicant wpa_s; + struct wpa_global global; + struct wpa_bss curr, sel; + struct wpa_ssid ssid; + struct wpa_driver_ops dummy_driver; + + /* Initialize both BSSes. */ + os_memset(&curr, 0, sizeof(curr)); + curr.bssid[0] = 1; + os_memset(&sel, 0, sizeof(sel)); + sel.bssid[0] = 2; + + /* Initialize the SSID. */ + os_memset(&ssid, 0, sizeof(ssid)); + ssid.bssid_set = 0; + + /* Initialize wpa_supplicant. We don't call *_init() functions because + * we'd like to do the bare minimum amount of setup necessary to test + * the wpa_supplicant_need_to_roam_within_ess() logic. + */ + os_memset(&wpa_s, 0, sizeof(wpa_s)); + os_memset(&dummy_driver, 0, sizeof(dummy_driver)); + os_memset(&global, 0, sizeof(global)); + os_memcpy(&wpa_s.ifname, "roam0", 5); + wpa_s.global = &global; + wpa_s.driver = &dummy_driver; + wpa_s.current_ssid = &ssid; + if (check_roam(&wpa_s, &curr, &sel, ROAM_TO_5, + -50, -80, 65000, 175500) || + !check_roam(&wpa_s, &curr, &sel, ROAM_TO_2, + -80, -50, 175500, 65000) || + check_roam(&wpa_s, &curr, &sel, ROAM_SAME_BAND, + -80, -80, 19500, 19500)) { + wpa_printf(MSG_ERROR, "need_to_roam module test failure"); + return -1; + } + return 0; +} +#endif /* CONFIG_NO_ROAMING */ + + int wpas_module_tests(void) { int ret = 0; @@ -79,6 +164,11 @@ int wpas_module_tests(void) if (wpas_blacklist_module_tests() < 0) ret = -1; +#ifndef CONFIG_NO_ROAMING + if (wpas_need_to_roam_module_tests() < 0) + ret = -1; +#endif /* CONFIG_NO_ROAMING */ + #ifdef CONFIG_WPS if (wps_module_tests() < 0) ret = -1; From patchwork Tue Jun 2 00:10:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1301986 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=SBFk6yLk; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=B/GyXX48; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bXWw0F0Gz9sTc for ; Tue, 2 Jun 2020 10:11:24 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uyG7yh+5kMIFlzZV6T/S9dqGNbjefyAK6Wc34bmwLYg=; b=SBFk6yLky370ns MvFh2hzetCbub3Kdtv5XGRa7ljBOaASTDO3m/W2BPB0DmZY6kP2r5tTK7XnAASZ/OuvAR+EHumHJF XxP3mC0krnRhH3DagEJxp6bTiiL7bZ7KTZsp3pTIwz8zky8hcJbMcrZOi2/OBjiuGKJ6nmRhZCune 9D1tMKeuC8OUbzpOOy3AIKqtE1NdfTVEtM+RlnRS7En95QOFUnz8s0FoYvV9e0E3sYX0MUyZZKnen hJB/m224eZoV/eSmm63Ft0WINwZkLk7DxONLAH0qpeRs5lJf9MPVLPrktSWy+4GIWy7C4FXf0bhsW kWM1ML3aPBnqrHajU4jA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfuWO-0007bx-Ad; Tue, 02 Jun 2020 00:11:12 +0000 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfuVv-000719-8n for hostap@lists.infradead.org; Tue, 02 Jun 2020 00:10:46 +0000 Received: by mail-pj1-x1043.google.com with SMTP id m2so568271pjv.2 for ; Mon, 01 Jun 2020 17:10:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sQ8k5/eZ3+sqFbqtRdpmVA00xLvRbXTy/pSigxVebhY=; b=B/GyXX48aEEqSRYK7mSHutvp0tS/tKZz+lye1m/sFly1q+WwrJkZ15D61UP/F4TcCt X1x2bFH75PFhfMvfIPd+lSPGO8Garns2cWcxGU+tJCmyEwzBZHiYvhZd/s9Uf/6jEPUU qLw/8JqOuxMDuPkb8nBx7OU/l5QorA4MyevgM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sQ8k5/eZ3+sqFbqtRdpmVA00xLvRbXTy/pSigxVebhY=; b=U6JyrIUpSEUa7kjQfIeG23jqKnrm9PyHcdcCvUREAUXhXQY28d3RUOFg3H8pl9GFY9 E4OT15lXVAKZqleIyky9V/qbqBDot0RVipxbQz1PcZ5EiM6MOLJVORq7MH4q3i/2QiJQ Kij2xYMmTI1cpjxTXB/smhqJmhKBtJFP1PeB9LbkQzDz1RjO5kl3yTuUb+kBytp558Ve sDHyVDegVWbQTcqvwRb7a8G+cOt33BLY7tDWL2ERyHInhqsKBimiEicy+ZTBmoG1zPtQ 4SwAJYUH1V6lJ806YoAjcfINfZ8vKviz9hwhAer/PhVE08x+SqEVteSXAvk49iWKfdte JtSg== X-Gm-Message-State: AOAM532OLSgb84MOYRB0WzT8FOpnnTsKblVix7K7pgcg81iUHbiLYxBG TFBs7DIKy4rARrSc5vvGLIKptA== X-Google-Smtp-Source: ABdhPJzRrJn/H56yEpISUsGDjr8pRULj4iLls1uOBNgGksHRJCvIpSJNfQKXYel7OXEr9shaVpHm0w== X-Received: by 2002:a17:902:7c05:: with SMTP id x5mr23151250pll.278.1591056642100; Mon, 01 Jun 2020 17:10:42 -0700 (PDT) Received: from localhost ([2620:15c:202:201:2b10:8627:31e7:c5ec]) by smtp.gmail.com with ESMTPSA id 12sm459488pfj.149.2020.06.01.17.10.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2020 17:10:41 -0700 (PDT) From: Matthew Wang To: j@w1.fi Subject: [PATCH 5/6] Decrease cross-threshold roam difficulty Date: Mon, 1 Jun 2020 17:10:17 -0700 Message-Id: <20200602001018.83640-5-matthewmwang@chromium.org> X-Mailer: git-send-email 2.27.0.rc2.251.g90737beb825-goog In-Reply-To: <20200602001018.83640-1-matthewmwang@chromium.org> References: <20200602001018.83640-1-matthewmwang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200601_171043_386159_F8E939A5 X-CRM114-Status: GOOD ( 13.43 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1043 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hostap@lists.infradead.org, Matthew Wang Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Decrease the roam difficulty when we roam across the short background scan threshold (i.e. when the current BSS RSSI is below the threshold and the selected BSS RSSI is above the threshold). This tends to happen in normal roaming scenarios when we walk from the domain of one AP to the domain of the other. Signed-off-by: Matthew Wang --- wpa_supplicant/bgscan_simple.c | 5 ++++- wpa_supplicant/events.c | 6 +++++- wpa_supplicant/wpa_supplicant_i.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/bgscan_simple.c b/wpa_supplicant/bgscan_simple.c index 41a26df0d..740b1f8cf 100644 --- a/wpa_supplicant/bgscan_simple.c +++ b/wpa_supplicant/bgscan_simple.c @@ -134,6 +134,7 @@ static void * bgscan_simple_init(struct wpa_supplicant *wpa_s, data->scan_interval = data->short_interval; data->max_short_scans = data->long_interval / data->short_interval + 1; if (data->signal_threshold) { + wpa_s->signal_threshold = data->signal_threshold; /* Poll for signal info to set initial scan interval */ struct wpa_signal_info siginfo; if (wpa_drv_signal_poll(wpa_s, &siginfo) == 0 && @@ -161,8 +162,10 @@ static void bgscan_simple_deinit(void *priv) { struct bgscan_simple_data *data = priv; eloop_cancel_timeout(bgscan_simple_timeout, data, NULL); - if (data->signal_threshold) + if (data->signal_threshold) { + data->wpa_s->signal_threshold = 0; wpa_drv_signal_monitor(data->wpa_s, 0, 0); + } os_free(data); } diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 60cbf5a54..f70d84b75 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1779,7 +1779,7 @@ int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s, { int min_diff, diff; int to_2ghz, to_5ghz; - int cur_level; + int cur_level, sel_level; int adjust = 0; double adjust_factor, est_ratio; unsigned int cur_est, sel_est; @@ -1878,6 +1878,7 @@ int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s, } sel_est = selected->est_throughput; + sel_level = selected->level; if (cur_est > sel_est) { adjust = 1; est_ratio = sel_est == 0 ? 2 : (double) cur_est / sel_est; @@ -1894,6 +1895,9 @@ int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s, min_diff += 2; else if (to_5ghz) min_diff -= 2; + if (wpa_s->signal_threshold && cur_level <= wpa_s->signal_threshold && + sel_level > wpa_s->signal_threshold) + min_diff -= 2; diff = selected->level - cur_level; if (diff < min_diff) { wpa_dbg(wpa_s, MSG_DEBUG, diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index e7bc0bc41..ff398888c 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -988,6 +988,7 @@ struct wpa_supplicant { struct wpa_ssid *bgscan_ssid; const struct bgscan_ops *bgscan; void *bgscan_priv; + int signal_threshold; const struct autoscan_ops *autoscan; struct wpa_driver_scan_params *autoscan_params; From patchwork Tue Jun 2 00:10:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1301987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=lfDxL+/2; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=NDHb/M0V; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bXXF6vf2z9sTc for ; Tue, 2 Jun 2020 10:11:41 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wcobNbus/SASlRTwI7Vz/0rr3SP6L6H5hE5e9M2I2UY=; b=lfDxL+/2wOswFr l4aO9Bd5+ra/Njhztfe/cweYNA4XHlQzVpuWazgwbiwGWIeXKWJJfATTl7b6yiXtCoTahHGjr2hZ0 LFTxaSSNFJUV9VwJ7pfUncDgZSPLWWpI47ZbaQdYIgQ9TifXJttBc8kT/AqZzcjxoIPOOdeVvZq6H czXGXqIFCFTTmtQXivWFJ1bErSGjzItHLULfJsjRmNJB9oBJ+ZeYEq3qgoSISFR8Y5kq6DwY599O1 FjvDWZ/WqlVcytjYw5meBcT5+BMDa7avC4jgg00siqQunVtyeOnyT8EctCc0o4pka/7qfTzk2ATni hlzwLUPGt6cBRaPmYe2w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfuWd-0007r0-MO; Tue, 02 Jun 2020 00:11:27 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfuVy-00079W-CY for hostap@lists.infradead.org; Tue, 02 Jun 2020 00:10:47 +0000 Received: by mail-pj1-x1033.google.com with SMTP id 5so573738pjd.0 for ; Mon, 01 Jun 2020 17:10:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q1YxZNDYoSgCTwQPz/ePdNEf6FMl6kuzXCsrk3dgizQ=; b=NDHb/M0V505ZHGoRIkM2x1/jwcCRYZ7tVY/ZfGrClgsDVrTDGARX8FGyyqXONtrrsJ Lf1FtPx6W2uy9eF0HP9Pfw7TbiiqsV1I2YRqnayH62WGwiDWVG8xK7qmwZKCcMaPkkOq V/MleO8sJu6LGznZSHuEVtGqWDdgpuVl+LoaM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q1YxZNDYoSgCTwQPz/ePdNEf6FMl6kuzXCsrk3dgizQ=; b=p70wN2mGnnLAA3J8MTztfOU5VubbB01s7f9jc8mJCQjNV/AKe36sr7IVXYl0cpkcNN Qtu2U7zUBuJHD6w4kxVNTtnQhOtNH9OJrb8iqP7liNUJn3RSmVHBoDVFMzUb2SPBumzN P2PoaKGDIGlAynIRPADFdPVXoUqtwwOSZjsqTLNEkLLhCSS/okidHckKvmnf9fQBXnuj 0GOci++Esw1gsi0Wz1VWJNA6Cq1EWp/++htcgnTG4Uq3V4QaiKzWRTozDCrxf/ywdYz+ 2ybqdOi6pHi40v2IKmRghKqw9r8aPFOsS33pFh8l1LG27N6UHZNWVTc7mpNZXm2Yn8bD 8gLg== X-Gm-Message-State: AOAM532UH6FJA2OnsYwgOfekUNRN2TS2e5r9l8HL/mXJWI+XxB/QsA70 /cUrMVV9a4KYadv+F5hVNfEBog== X-Google-Smtp-Source: ABdhPJyc5jY4cDGNyvfXAtrYJO+XHt9NoA9TX2co6aLA8W5tG/oSi+Oi7oh7y3eXu20D+cz19dcIXg== X-Received: by 2002:a17:902:7847:: with SMTP id e7mr22662935pln.157.1591056644988; Mon, 01 Jun 2020 17:10:44 -0700 (PDT) Received: from localhost ([2620:15c:202:201:2b10:8627:31e7:c5ec]) by smtp.gmail.com with ESMTPSA id m14sm506552pgt.6.2020.06.01.17.10.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2020 17:10:44 -0700 (PDT) From: Matthew Wang To: j@w1.fi Subject: [PATCH 6/6] Add WPA_EVENT_{DO,SKIP}_ROAM events Date: Mon, 1 Jun 2020 17:10:18 -0700 Message-Id: <20200602001018.83640-6-matthewmwang@chromium.org> X-Mailer: git-send-email 2.27.0.rc2.251.g90737beb825-goog In-Reply-To: <20200602001018.83640-1-matthewmwang@chromium.org> References: <20200602001018.83640-1-matthewmwang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200601_171046_466454_6FDC72D3 X-CRM114-Status: GOOD ( 11.81 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1033 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hostap@lists.infradead.org, Matthew Wang Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add events for within-ESS reassociation. This allows us to monitor roam events, both skipped and allowed, in tests. Signed-off-by: Matthew Wang --- src/common/wpa_ctrl.h | 4 ++++ wpa_supplicant/events.c | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h index 488e4addc..d84718d56 100644 --- a/src/common/wpa_ctrl.h +++ b/src/common/wpa_ctrl.h @@ -97,6 +97,10 @@ extern "C" { "CTRL-EVENT-SAE-UNKNOWN-PASSWORD-IDENTIFIER " /** Unprotected Beacon frame dropped */ #define WPA_EVENT_UNPROT_BEACON "CTRL-EVENT-UNPROT-BEACON " +/** Decision made to do a within-ESS roam */ +#define WPA_EVENT_DO_ROAM "CTRL-EVENT-DO-ROAM" +/** Decision made to skip a within-ESS roam */ +#define WPA_EVENT_SKIP_ROAM "CTRL-EVENT-SKIP-ROAM" /** IP subnet status change notification * diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index f70d84b75..700958ef3 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1785,6 +1785,7 @@ int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s, unsigned int cur_est, sel_est; struct wpa_signal_info si; int cur_snr = 0; + int ret = 0; wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation"); wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR @@ -1903,13 +1904,22 @@ int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s, wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - too small difference in signal level (%d < %d)", diff, min_diff); - return 0; + ret = 0; + } else { + wpa_dbg(wpa_s, MSG_DEBUG, + "Allow reassociation due to difference in signal level (%d >= %d)", + diff, min_diff); + ret = 1; } - - wpa_dbg(wpa_s, MSG_DEBUG, - "Allow reassociation due to difference in signal level (%d >= %d)", - diff, min_diff); - return 1; + wpa_msg_ctrl(wpa_s, MSG_INFO, "%s " + "cur_bssid=" MACSTR " cur_freq=%d cur_level=%d cur_est=%d " + "sel_bssid=" MACSTR " sel_freq=%d sel_level=%d sel_est=%d", + ret ? WPA_EVENT_DO_ROAM : WPA_EVENT_SKIP_ROAM, + MAC2STR(current_bss->bssid), + current_bss->freq, cur_level, cur_est, + MAC2STR(selected->bssid), + selected->freq, sel_level, sel_est); + return ret; } #endif /* CONFIG_NO_ROAMING */