From patchwork Tue Feb 13 06:10:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinming Hu X-Patchwork-Id: 10215231 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 9092F601C2 for ; Tue, 13 Feb 2018 06:10:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 805F528E46 for ; Tue, 13 Feb 2018 06:10:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7249E28E45; Tue, 13 Feb 2018 06:10:33 +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=ham 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 CACA228E4E for ; Tue, 13 Feb 2018 06:10:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754034AbeBMGKa (ORCPT ); Tue, 13 Feb 2018 01:10:30 -0500 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:53072 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753829AbeBMGK3 (ORCPT ); Tue, 13 Feb 2018 01:10:29 -0500 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1D6APlu010735; Mon, 12 Feb 2018 22:10:25 -0800 Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2g24f2wpph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 12 Feb 2018 22:10:25 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 12 Feb 2018 22:10:23 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Mon, 12 Feb 2018 22:10:23 -0800 Received: from smtp.marvell.com (unknown [10.38.32.132]) by maili.marvell.com (Postfix) with SMTP id 4A3063F703F; Mon, 12 Feb 2018 22:10:20 -0800 (PST) Received: by smtp.marvell.com (sSMTP sendmail emulation); Tue, 13 Feb 2018 14:10:16 +0800 From: Xinming Hu To: Linux Wireless CC: Kalle Valo , Brian Norris , Dmitry Torokhov , , Zhiyuan Yang , Tim Song , Cathy Luo , James Cao , Ganapathi Bhat , Ellie Reeves , Xinming Hu Subject: [PATCH] mwifiex: set different mac address for interfaces with same bss type Date: Tue, 13 Feb 2018 14:10:15 +0800 Message-ID: <1518502215-18820-1-git-send-email-huxm@marvell.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-13_03:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=614 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802130077 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 Multiple interfaces with same bss type could affect each other if they are sharing the same mac address. In this patch, different mac address is assigned to new interface which have same bss type with exist interfaces. Signed-off-by: Xinming Hu --- drivers/net/wireless/marvell/mwifiex/main.c | 24 +++++++++++++++++++----- drivers/net/wireless/marvell/mwifiex/main.h | 13 +++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c index 3dd8584..20737f5 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.c +++ b/drivers/net/wireless/marvell/mwifiex/main.c @@ -960,13 +960,26 @@ int mwifiex_set_mac_address(struct mwifiex_private *priv, struct net_device *dev) { int ret; - u64 mac_addr; + u64 mac_addr, old_mac_addr; - if (priv->bss_type != MWIFIEX_BSS_TYPE_P2P) - goto done; + if (priv->bss_type == MWIFIEX_BSS_TYPE_ANY) + return -ENOTSUPP; mac_addr = ether_addr_to_u64(priv->curr_addr); - mac_addr |= BIT_ULL(MWIFIEX_MAC_LOCAL_ADMIN_BIT); + old_mac_addr = mac_addr; + + if (priv->bss_type == MWIFIEX_BSS_TYPE_P2P) + mac_addr |= BIT_ULL(MWIFIEX_MAC_LOCAL_ADMIN_BIT); + + if (mwifiex_get_intf_num(priv->adapter, priv->bss_type) > 1) { + /* Set mac address based on bss_type/bss_num */ + mac_addr ^= BIT_ULL(priv->bss_type + 8); + mac_addr += priv->bss_num; + } + + if (mac_addr == old_mac_addr) + goto done; + u64_to_ether_addr(mac_addr, priv->curr_addr); /* Send request to firmware */ @@ -974,13 +987,14 @@ int mwifiex_set_mac_address(struct mwifiex_private *priv, HostCmd_ACT_GEN_SET, 0, NULL, true); if (ret) { + u64_to_ether_addr(old_mac_addr, priv->curr_addr); mwifiex_dbg(priv->adapter, ERROR, "set mac address failed: ret=%d\n", ret); return ret; } done: - memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN); + ether_addr_copy(dev->dev_addr, priv->curr_addr); return 0; } diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h index c4c6918..f607d0b 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.h +++ b/drivers/net/wireless/marvell/mwifiex/main.h @@ -1276,6 +1276,19 @@ int mwifiex_cmd_802_11_bg_scan_config(struct mwifiex_private *priv, return pos; } +/* This function return interface number with the same bss_type. + */ +static inline u8 +mwifiex_get_intf_num(struct mwifiex_adapter *adapter, u8 bss_type) +{ + u8 i, num = 0; + + for (i = 0; i < adapter->priv_num; i++) + if (adapter->priv[i] && adapter->priv[i]->bss_type == bss_type) + num++; + return num; +} + /* * This function returns the correct private structure pointer based * upon the BSS type and BSS number.