From patchwork Thu Jan 5 07:33:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya.Shankar@microchip.com X-Patchwork-Id: 9498539 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 10CD0606B5 for ; Thu, 5 Jan 2017 07:38:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 012E926223 for ; Thu, 5 Jan 2017 07:38:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9D0727FA9; Thu, 5 Jan 2017 07:38:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1BA126223 for ; Thu, 5 Jan 2017 07:38:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968052AbdAEHhu (ORCPT ); Thu, 5 Jan 2017 02:37:50 -0500 Received: from exsmtp03.microchip.com ([198.175.253.49]:20935 "EHLO email.microchip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S967172AbdAEHhZ (ORCPT ); Thu, 5 Jan 2017 02:37:25 -0500 Received: from localhost.localdomain (10.10.76.4) by chn-sv-exch03.mchp-main.com (10.10.76.49) with Microsoft SMTP Server id 14.3.181.6; Thu, 5 Jan 2017 00:34:43 -0700 From: Aditya Shankar To: Ganesh Krishna , Greg Kroah-Hartman CC: , , , Aditya Shankar Subject: [PATCH] staging: wilc1000: Connect to highest RSSI value for required SSID Date: Thu, 5 Jan 2017 13:03:41 +0530 Message-ID: <1483601621-27545-1-git-send-email-aditya.shankar@microchip.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Connect to the highest rssi with the required SSID in the shadow table if the connection criteria is based only on the SSID. For the first matching SSID, an index to the table is saved. Later the index is updated if matching SSID has a higher RSSI value than the last saved index. However if decision is made based on BSSID, there is only one match in the table and corresponding index is used. Signed-off-by: Aditya Shankar --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index c1a24f7..32206b8 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -665,6 +665,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, { s32 s32Error = 0; u32 i; + u32 sel_bssi_idx = last_scanned_cnt + 1; u8 u8security = NO_ENCRYPT; enum AUTHTYPE tenuAuth_type = ANY; @@ -688,18 +689,25 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, memcmp(last_scanned_shadow[i].ssid, sme->ssid, sme->ssid_len) == 0) { - if (!sme->bssid) - break; - else + if (!sme->bssid) { + if (sel_bssi_idx == (last_scanned_cnt + 1)) + sel_bssi_idx = i; + else if (last_scanned_shadow[i].rssi > + last_scanned_shadow[sel_bssi_idx].rssi) + sel_bssi_idx = i; + } else { if (memcmp(last_scanned_shadow[i].bssid, sme->bssid, - ETH_ALEN) == 0) + ETH_ALEN) == 0){ + sel_bssi_idx = i; break; + } + } } } - if (i < last_scanned_cnt) { - pstrNetworkInfo = &last_scanned_shadow[i]; + if (sel_bssi_idx < last_scanned_cnt) { + pstrNetworkInfo = &last_scanned_shadow[sel_bssi_idx]; } else { s32Error = -ENOENT; wilc_connecting = 0;