From patchwork Mon Jan 27 10:46:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 216583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71C7CC33CB1 for ; Mon, 27 Jan 2020 10:47:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 32CBC207FD for ; Mon, 27 Jan 2020 10:47:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=quantenna.com header.i=@quantenna.com header.b="UljbKw+u" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729365AbgA0Krn (ORCPT ); Mon, 27 Jan 2020 05:47:43 -0500 Received: from mx0a-00183b01.pphosted.com ([67.231.149.44]:16354 "EHLO mx0a-00183b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726481AbgA0Krn (ORCPT ); Mon, 27 Jan 2020 05:47:43 -0500 Received: from pps.filterd (m0048106.ppops.net [127.0.0.1]) by mx0a-00183b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00RAh2jh020659 for ; Mon, 27 Jan 2020 03:47:41 -0700 Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by mx0a-00183b01.pphosted.com with ESMTP id 2xrhdav48w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 Jan 2020 03:47:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GkRu1ibwi+YEg2rky0jtqD1Gb6cDipD1sUE5o+6jlIKxpHxqMM/9dudRb65sV046DpMjgt8eGh4oHjxM+w+HEfqWuPZR+5aTUPEcjDt5mjbCT3g3VOVTCfCWBWKKwS2W/i0621lrByKcn7j8AmcnmlD82hxD+j5WSsa4cLAFFumfkXAkGNBJcnxs08khRvaFZc94DbmtSD51xvhOrMWIR2v7bxoAqdKS7A45AuFlwqBVN8TidWinwp1UgivUm4JX2hgk6tUxcJqGaLaqYJbIv4i/2drzLKhPr7QNLNGHZzVJlZMzOoA6ZtkgmjFc+lgC3Oq6223+ifExQ0cz0Sayeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ML2X7/K12x+4j58moGvcHB9OAFfTylFbyVXnmn963ho=; b=XhftJdnP706bZS/9zKflB4gzu3xR3zN5q9DAX6LqFrXCK5dR3p9kdWDcpRHRhJa2M5jsa+efKGqs5ZTUEP4KwoWymKLq1fcYIbeFsggjTCduJ5gDNb7QGwU97hzlWJqq15zq3KM7JxvST5bDPbzTpTNDM8hgNCRRYB8nA9K6u298LoQPRakb1LAHwXVU5oYOHj5qjpD13T4Cyhr+r2LU19GD13RkQhYvJ8+GQsayzOvySoxbJwO5+A66aSFvToYIC6WZvdu4fORn0epwSS5444ik04z61VX9KqjmirLTEk19ErE2TT/5Mcl5X63CiWpWYD8ffyX79J/74u3vLZz3zQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=quantenna.com; dmarc=pass action=none header.from=quantenna.com; dkim=pass header.d=quantenna.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantenna.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ML2X7/K12x+4j58moGvcHB9OAFfTylFbyVXnmn963ho=; b=UljbKw+uuA16G3KOFCyV3GZ3oslPugEbXhdx6XXQs/e2hIi7eDdedTMMvgf90cCl3mFp0J1zmxZydp6Q9khbrIIivLQkGRBCKwWwSNjMMMrbMrVkDNm/oWxHTiGsYpEV3BYy+JbnjPxT983vOIVrnf2frPYS8ILI5qzA4IkNdRk= Received: from SN6PR05MB4686.namprd05.prod.outlook.com (52.135.114.208) by SN6PR05MB4591.namprd05.prod.outlook.com (52.135.75.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.10; Mon, 27 Jan 2020 10:47:39 +0000 Received: from SN6PR05MB4686.namprd05.prod.outlook.com ([fe80::d5e9:ea40:273f:4129]) by SN6PR05MB4686.namprd05.prod.outlook.com ([fe80::d5e9:ea40:273f:4129%7]) with mapi id 15.20.2686.019; Mon, 27 Jan 2020 10:47:39 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com (52.135.117.74) by SN6PR05MB5391.namprd05.prod.outlook.com (52.135.111.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.18; Mon, 27 Jan 2020 10:46:44 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::2956:4ff3:7d5b:333c]) by SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::2956:4ff3:7d5b:333c%5]) with mapi id 15.20.2686.019; Mon, 27 Jan 2020 10:46:44 +0000 Received: from bars.quantenna.com (195.182.157.78) by HE1PR07CA0018.eurprd07.prod.outlook.com (2603:10a6:7:67::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.14 via Frontend Transport; Mon, 27 Jan 2020 10:46:43 +0000 From: Sergey Matyukevich To: "linux-wireless@vger.kernel.org" CC: Igor Mitsyanko , Mikhail Karpenko , Sergey Matyukevich Subject: [PATCH 01/10] qtnfmac: use MAJOR.MINOR format for firmware protocol Thread-Topic: [PATCH 01/10] qtnfmac: use MAJOR.MINOR format for firmware protocol Thread-Index: AQHV1P8RH4aLidAgdUeQ6uifwATGzQ== Date: Mon, 27 Jan 2020 10:46:44 +0000 Message-ID: <20200127104634.7248-2-sergey.matyukevich.os@quantenna.com> References: <20200127104634.7248-1-sergey.matyukevich.os@quantenna.com> In-Reply-To: <20200127104634.7248-1-sergey.matyukevich.os@quantenna.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR07CA0018.eurprd07.prod.outlook.com (2603:10a6:7:67::28) To SN6PR05MB4928.namprd05.prod.outlook.com (2603:10b6:805:9d::10) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.11.0 x-originating-ip: [195.182.157.78] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6bd5cb2b-a349-4e33-9f59-08d7a3163361 x-ms-traffictypediagnostic: SN6PR05MB5391:|SN6PR05MB4591: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-moderation-data: 1/27/2020 10:47:27 AM x-ms-oob-tlc-oobclassifiers: OLM:2733; x-forefront-prvs: 02951C14DC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(346002)(376002)(39840400004)(366004)(199004)(189003)(66476007)(66946007)(66446008)(64756008)(4326008)(66556008)(6486002)(107886003)(2906002)(478600001)(6916009)(36756003)(5660300002)(54906003)(316002)(8676002)(8936002)(52116002)(86362001)(956004)(2616005)(7696005)(71200400001)(16526019)(1076003)(81156014)(26005)(81166006)(186003)(103116003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR05MB4591; H:SN6PR05MB4686.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: XX+5qwSW6LN3JtLM/JFLFv9BZM6Ca7OzS1w3UX+bCOEDFy3phqrtV5aOKcMPrjCDofQPQseumTYhk5nOHkJM8DbH/sQyoFi/2iTtJHSxj2v3CdbeE1tAuHkIsw/BgzHds4WB/UKAppVME0SrQDj8k+LiVmibnizybf25ObVR50n1bBy3nsYfuaz78i7rUZViVKFTghQftDDTaPddcqqIPe5wW8gaWMWKxD3ODPwVFSMmiWQDEgN3u0WdIfEfEsJynk31QkY2FhvZIhEk3XYVkytWCYrsUXBSmRV551EQwgI5zvRG4Cc/8zgcLAg6trWDyuVs0hqoeGriXCqCJ390si8LjlN5uDRO5S+tHX/JFKSKSJkHjQILsrVWY7TLLeZHuFzYzocelFxSmau1qcx9jaEdkmHSc4deK34q+aDjLEBnEzyf9DaPhvy21s33zdHR x-ms-exchange-antispam-messagedata: jk9JIcyH4m5TnzNuLv5sR3gKQnbBb2Iptd0dCquMu7yaZlJHOHworTumcJFVZmeUL1Md4+x1m0Jn/lk2iv7pRNKd3h8cjx1W8kTbzPo44poviCXmg3GyhjuZzqo2nwzmjnKwBvwqAcIw5mz9H70PWw== MIME-Version: 1.0 X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bd5cb2b-a349-4e33-9f59-08d7a3163361 X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: jCC68gBy0E+e/GDdhRJJf9MsczdzU+UQGM4WTZpYSHK0WHCUUKsMFT5Rvj3WyYjou1+llwjU5d24Kuh63VvVgswLjQ+5e1mdvZHybI/ubU7oD0GA2NhQajDsPA9ppbwtHkyypqO5SmCVtVRz1bnLsw== X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jan 2020 10:47:39.3997 (UTC) X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR05MB4591 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-01-27_02:2020-01-24,2020-01-27 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 impostorscore=0 adultscore=0 phishscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1911200001 definitions=main-2001270091 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Igor Mitsyanko Use MAJOR.MINOR format for QLink firmware protocol. MAJOR part is incremented when backward compatibility is broken. Normally this part should not be incremented unless there is a good reason for that. MINOR part is incremented each time when new features are added to qlink.h, e.g. new TLVs, events, commands. These changes should not break backward compatibility. For instance, older firmware versions may not be able to parse new flags or send new types of events, but this does not impact normal system operations. As part of initialization sequence, driver requests protocol version from firmware and refuses to start in case there is a mismatch in MAJOR part of the version. Signed-off-by: Igor Mitsyanko --- drivers/net/wireless/quantenna/qtnfmac/commands.c | 59 ++++++++++++++--------- drivers/net/wireless/quantenna/qtnfmac/core.c | 16 +++--- drivers/net/wireless/quantenna/qtnfmac/core.h | 2 +- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 42 ++++++++++++++-- 4 files changed, 86 insertions(+), 33 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c index d0d7ec8794c4..4f52e2fd7f38 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c @@ -900,7 +900,6 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus, hwinfo->num_mac = resp->num_mac; hwinfo->mac_bitmap = resp->mac_bitmap; hwinfo->fw_ver = le32_to_cpu(resp->fw_ver); - hwinfo->ql_proto_ver = le16_to_cpu(resp->ql_proto_ver); hwinfo->total_tx_chain = resp->total_tx_chain; hwinfo->total_rx_chain = resp->total_rx_chain; hwinfo->hw_capab = le32_to_cpu(resp->hw_capab); @@ -954,25 +953,29 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus, tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); } - pr_info("fw_version=%d, MACs map %#x, chains Tx=%u Rx=%u, capab=0x%x\n", - hwinfo->fw_ver, hwinfo->mac_bitmap, - hwinfo->total_tx_chain, hwinfo->total_rx_chain, - hwinfo->hw_capab); - - pr_info("\nBuild name: %s" \ - "\nBuild revision: %s" \ - "\nBuild type: %s" \ - "\nBuild label: %s" \ - "\nBuild timestamp: %lu" \ - "\nPlatform ID: %lu" \ - "\nHardware ID: %s" \ - "\nCalibration version: %s" \ - "\nU-Boot version: %s" \ - "\nHardware version: 0x%08x\n", + pr_info("\nBuild name: %s\n" + "Build revision: %s\n" + "Build type: %s\n" + "Build label: %s\n" + "Build timestamp: %lu\n" + "Platform ID: %lu\n" + "Hardware ID: %s\n" + "Calibration version: %s\n" + "U-Boot version: %s\n" + "Hardware version: 0x%08x\n" + "Qlink ver: %u.%u\n" + "MACs map: %#x\n" + "Chains Rx-Tx: %ux%u\n" + "FW version: 0x%x\n", bld_name, bld_rev, bld_type, bld_label, (unsigned long)bld_tmstamp, (unsigned long)plat_id, - hw_id, calibration_ver, uboot_ver, hw_ver); + hw_id, calibration_ver, uboot_ver, hw_ver, + QLINK_VER_MAJOR(bus->hw_info.ql_proto_ver), + QLINK_VER_MINOR(bus->hw_info.ql_proto_ver), + hwinfo->mac_bitmap, + hwinfo->total_rx_chain, hwinfo->total_tx_chain, + hwinfo->fw_ver); strlcpy(hwinfo->fw_version, bld_label, sizeof(hwinfo->fw_version)); hwinfo->hw_version = hw_ver; @@ -1866,23 +1869,35 @@ int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed) int qtnf_cmd_send_init_fw(struct qtnf_bus *bus) { + struct sk_buff *resp_skb = NULL; + struct qlink_resp_init_fw *resp; + struct qlink_cmd_init_fw *cmd; struct sk_buff *cmd_skb; - int ret = 0; + size_t info_len = 0; + int ret; cmd_skb = qtnf_cmd_alloc_new_cmdskb(QLINK_MACID_RSVD, QLINK_VIFID_RSVD, QLINK_CMD_FW_INIT, - sizeof(struct qlink_cmd)); + sizeof(*cmd)); if (!cmd_skb) return -ENOMEM; + cmd = (struct qlink_cmd_init_fw *)cmd_skb->data; + cmd->qlink_proto_ver = cpu_to_le32(QLINK_PROTO_VER); + qtnf_bus_lock(bus); - ret = qtnf_cmd_send(bus, cmd_skb); + ret = qtnf_cmd_send_with_reply(bus, cmd_skb, &resp_skb, + sizeof(*resp), &info_len); + qtnf_bus_unlock(bus); + if (ret) goto out; -out: - qtnf_bus_unlock(bus); + resp = (struct qlink_resp_init_fw *)resp_skb->data; + bus->hw_info.ql_proto_ver = le32_to_cpu(resp->qlink_proto_ver); +out: + consume_skb(resp_skb); return ret; } diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c index 4320180f8c07..a21b09afd103 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.c +++ b/drivers/net/wireless/quantenna/qtnfmac/core.c @@ -756,6 +756,15 @@ int qtnf_core_attach(struct qtnf_bus *bus) goto error; } + if (QLINK_VER_MAJOR(bus->hw_info.ql_proto_ver) != + QLINK_PROTO_VER_MAJOR) { + pr_err("qlink driver vs FW version mismatch: %u vs %u\n", + QLINK_PROTO_VER_MAJOR, + QLINK_VER_MAJOR(bus->hw_info.ql_proto_ver)); + ret = -EPROTONOSUPPORT; + goto error; + } + bus->fw_state = QTNF_FW_STATE_ACTIVE; ret = qtnf_cmd_get_hw_info(bus); if (ret) { @@ -763,13 +772,6 @@ int qtnf_core_attach(struct qtnf_bus *bus) goto error; } - if (bus->hw_info.ql_proto_ver != QLINK_PROTO_VER) { - pr_err("qlink version mismatch %u != %u\n", - QLINK_PROTO_VER, bus->hw_info.ql_proto_ver); - ret = -EPROTONOSUPPORT; - goto error; - } - if ((bus->hw_info.hw_capab & QLINK_HW_CAPAB_HW_BRIDGE) && bus->bus_ops->data_tx_use_meta_set) bus->bus_ops->data_tx_use_meta_set(bus, true); diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.h b/drivers/net/wireless/quantenna/qtnfmac/core.h index d715e1cd0006..78fee516cea4 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.h +++ b/drivers/net/wireless/quantenna/qtnfmac/core.h @@ -117,7 +117,7 @@ struct qtnf_wmac { }; struct qtnf_hw_info { - u16 ql_proto_ver; + u32 ql_proto_ver; u8 num_mac; u8 mac_bitmap; u32 fw_ver; diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h index b2edb03819d1..3722e707232c 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h @@ -6,7 +6,18 @@ #include -#define QLINK_PROTO_VER 16 +#define QLINK_PROTO_VER_MAJOR_M 0xFFFF +#define QLINK_PROTO_VER_MAJOR_S 16 +#define QLINK_PROTO_VER_MINOR_M 0xFFFF +#define QLINK_VER_MINOR(_ver) ((_ver) & QLINK_PROTO_VER_MINOR_M) +#define QLINK_VER_MAJOR(_ver) \ + (((_ver) >> QLINK_PROTO_VER_MAJOR_S) & QLINK_PROTO_VER_MAJOR_M) +#define QLINK_VER(_maj, _min) (((_maj) << QLINK_PROTO_VER_MAJOR_S) | (_min)) + +#define QLINK_PROTO_VER_MAJOR 18 +#define QLINK_PROTO_VER_MINOR 0 +#define QLINK_PROTO_VER \ + QLINK_VER(QLINK_PROTO_VER_MAJOR, QLINK_PROTO_VER_MINOR) #define QLINK_MACID_RSVD 0xFF #define QLINK_VIFID_RSVD 0xFF @@ -327,6 +338,23 @@ struct qlink_cmd { } __packed; /** + * struct qlink_cmd_init_fw - data for QLINK_CMD_FW_INIT + * + * Initialize firmware based on specified host configuration. This is the first + * command sent to wifi card and it's fixed part should never be changed, any + * additions must be done by appending TLVs. + * If wifi card can not operate with a specified parameters it will return + * error. + * + * @qlink_proto_ver: QLINK protocol version used by host driver. + */ +struct qlink_cmd_init_fw { + struct qlink_cmd chdr; + __le32 qlink_proto_ver; + u8 var_info[0]; +} __packed; + +/** * struct qlink_cmd_manage_intf - interface management command * * Data for interface management commands QLINK_CMD_ADD_INTF, QLINK_CMD_DEL_INTF @@ -896,6 +924,16 @@ struct qlink_resp { } __packed; /** + * struct qlink_resp_init_fw - response for QLINK_CMD_FW_INIT + * + * @qlink_proto_ver: QLINK protocol version used by wifi card firmware. + */ +struct qlink_resp_init_fw { + struct qlink_resp rhdr; + __le32 qlink_proto_ver; +} __packed; + +/** * enum qlink_dfs_regions - regulatory DFS regions * * Corresponds to &enum nl80211_dfs_regions. @@ -953,7 +991,6 @@ struct qlink_resp_get_mac_info { * * @fw_ver: wireless hardware firmware version. * @hw_capab: Bitmap of capabilities supported by firmware. - * @ql_proto_ver: Version of QLINK protocol used by firmware. * @num_mac: Number of separate physical radio devices provided by hardware. * @mac_bitmap: Bitmap of MAC IDs that are active and can be used in firmware. * @total_tx_chains: total number of transmit chains used by device. @@ -967,7 +1004,6 @@ struct qlink_resp_get_hw_info { __le32 bld_tmstamp; __le32 plat_id; __le32 hw_ver; - __le16 ql_proto_ver; u8 num_mac; u8 mac_bitmap; u8 total_tx_chain; From patchwork Mon Jan 27 10:46:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 216582 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 008EBC32771 for ; Mon, 27 Jan 2020 10:47:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BF87B20CC7 for ; Mon, 27 Jan 2020 10:47:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=quantenna.com header.i=@quantenna.com header.b="jPrYn63Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730071AbgA0Krx (ORCPT ); Mon, 27 Jan 2020 05:47:53 -0500 Received: from mx0b-00183b01.pphosted.com ([67.231.157.42]:18680 "EHLO mx0a-00183b01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726481AbgA0Krw (ORCPT ); Mon, 27 Jan 2020 05:47:52 -0500 Received: from pps.filterd (m0048103.ppops.net [127.0.0.1]) by mx0b-00183b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00RAka4X020081 for ; Mon, 27 Jan 2020 03:47:51 -0700 Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by mx0b-00183b01.pphosted.com with ESMTP id 2xrkfeb1q9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 Jan 2020 03:47:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IFAauN29w6Tu3YwIUiBOA30arBgbxYxNxaTlOcgFQSW6kSCwkjMjzLtttaV6kyj7WiAKZ54Din7Vagqz8pT4wdFXfRO/4bIk6gdaSbwA8ZZB3IDTKVOE3LoSaMp8RzmU8N7noV7XYzmECU+NEKUeVovRE1SSCmp+4qIqHNxXi0+6BQ0rohOEEJCoZU986qBGIbraRbTRUPDCBFZSz7e7HQVwzoEBSiyF8qFihMuzsubj4/pWYs1iKu5mJX1FKK6Y7nNzuh4DiLebbb7mQEpv7fX6FfwYhjSm5caK6aLD5Nh+MsBoYTWkblzUUNS+Db/aRdcmk2dKHwGqlrXErKPg5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Liou6SrXUyYwCPlfKzZTd5mG9M8XwbUKH708V8pty+0=; b=keKOG6gczXIFAiuVykZKjH/xEwsIpMWqFr9vDjCKMRkoLSPavJ+zAwKmasleiTCWPAMfijyvp6xjlxOtb84plaC9ZN4/1mlr0GEckyd7gKLidDBfSW+WldFo6Si3ST/FJV2+KfYPkyvOVjwECFsy9oCE11KTvrInTm25qjVGa8sdzvj3pqmd1gnVAWEX4VqLJMQCibpZn+TjGcl7gJ6DxZQtTqsfcRIoii7dW/Ri4ECYxNVduean3yaw7TscnJDhV59sgBimwCWOVMForIwkDie3wTWAZTc3pRL1Ev0tPX2ao50/1YjXr0RJrPQzBN/Rw9SapmYsvfjCuaATZGdSXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=quantenna.com; dmarc=pass action=none header.from=quantenna.com; dkim=pass header.d=quantenna.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantenna.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Liou6SrXUyYwCPlfKzZTd5mG9M8XwbUKH708V8pty+0=; b=jPrYn63ZnVm2PzXqF8S61r7zhg1fEC7SBqEmfuLSLYYn/kK6Q/JF+sRRwtyn/gCAq9rVjCM4kc2PIa/POvoKGLHcWKIQRDBT761mK/zEI7mnSr/LSSTrdstbDk6T/fNdx3/rm8SrTlKOeYUNmHQIMUQ/7ENpUNQNnDpJulnOpdc= Received: from BYAPR05MB5653.namprd05.prod.outlook.com (20.177.186.21) by BYAPR05MB6200.namprd05.prod.outlook.com (20.178.55.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.15; Mon, 27 Jan 2020 10:47:49 +0000 Received: from BYAPR05MB5653.namprd05.prod.outlook.com ([fe80::ce6:7fe6:2cfe:855d]) by BYAPR05MB5653.namprd05.prod.outlook.com ([fe80::ce6:7fe6:2cfe:855d%2]) with mapi id 15.20.2686.019; Mon, 27 Jan 2020 10:47:49 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com (52.135.117.74) by SN6PR05MB5391.namprd05.prod.outlook.com (52.135.111.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.18; Mon, 27 Jan 2020 10:46:49 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::2956:4ff3:7d5b:333c]) by SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::2956:4ff3:7d5b:333c%5]) with mapi id 15.20.2686.019; Mon, 27 Jan 2020 10:46:49 +0000 Received: from bars.quantenna.com (195.182.157.78) by HE1PR07CA0018.eurprd07.prod.outlook.com (2603:10a6:7:67::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.14 via Frontend Transport; Mon, 27 Jan 2020 10:46:48 +0000 From: Sergey Matyukevich To: "linux-wireless@vger.kernel.org" CC: Igor Mitsyanko , Mikhail Karpenko , Sergey Matyukevich Subject: [PATCH 04/10] qtnfmac: drop QTN_TLV_ID_NUM_IFACE_COMB TLV type Thread-Topic: [PATCH 04/10] qtnfmac: drop QTN_TLV_ID_NUM_IFACE_COMB TLV type Thread-Index: AQHV1P8Tum6BfTbxR0aoEemeEu554Q== Date: Mon, 27 Jan 2020 10:46:49 +0000 Message-ID: <20200127104634.7248-5-sergey.matyukevich.os@quantenna.com> References: <20200127104634.7248-1-sergey.matyukevich.os@quantenna.com> In-Reply-To: <20200127104634.7248-1-sergey.matyukevich.os@quantenna.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR07CA0018.eurprd07.prod.outlook.com (2603:10a6:7:67::28) To SN6PR05MB4928.namprd05.prod.outlook.com (2603:10b6:805:9d::10) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.11.0 x-originating-ip: [195.182.157.78] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 67b629fb-decf-448c-5750-08d7a3163632 x-ms-traffictypediagnostic: SN6PR05MB5391:|BYAPR05MB6200: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-moderation-data: 1/27/2020 10:47:46 AM x-ms-oob-tlc-oobclassifiers: OLM:1051; x-forefront-prvs: 02951C14DC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39830400003)(136003)(366004)(396003)(346002)(376002)(199004)(189003)(71200400001)(478600001)(7696005)(52116002)(6486002)(6916009)(36756003)(66946007)(16526019)(186003)(86362001)(103116003)(956004)(2616005)(26005)(66556008)(64756008)(66476007)(66446008)(54906003)(81166006)(81156014)(8936002)(107886003)(4326008)(316002)(1076003)(8676002)(5660300002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR05MB6200; H:BYAPR05MB5653.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 1zCXFN9yt2yK8SjUZeLovcnI6QoTlppNQ4bwVEdnCmL0N41rjw1gv8O+8iJIDHMATv9d5ZqPkGIKwA9YNvb4eHfggESotIW8AxaohlEJnuy7z7sbqTE4ge9/qdOtD/cOzDlmN2xVy4eUybXTqABM78+CCryrzib8NCnrj98dQKovdVrPzG6J4+p3NudmChUlsvy3xdKNbiQ8WhGtnxpxUn+csRf4Op9pXZNmXF+ob//EMBl5G6llMv295VrOxYrLeurGRXtiJKENKIjPROPmTEV0vDXtiARNrTKDgI8xUd1LSwEZgOp6b+Ybin/W8T7TwLxRgO2B91zkm99GCvgEEHBgliYp9s39bJsB2l/xQzqz2O62nJLTnEfGGOZ6uw7PLQwmVspWkWfLxBPowcu+mba4K/a5BXTinRF8SycCYPe9ncDVTumTKv47mYMzqBMu x-ms-exchange-antispam-messagedata: w3aBjjBiSIa/p38opATAARAv5aUPbkyxxDlLHHWPMTqSWHnQbf2DOrFHn6kV3hOcOKYO9Vo/fnCP+2/3bGRSQabrQJzf+vNecnTfV+SCTxpKlVwHdFEOvEOK9cszZeuneZScO9YHw6ZY25QFGQxcaw== MIME-Version: 1.0 X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67b629fb-decf-448c-5750-08d7a3163632 X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: +PSPXGmiqeJqHDtLLi9xnnmVZ39wPElSnWKbvxCBzr40WoPcSrMWo7OJ7g47sY4LzhklX9w7VRdmNjEGjQdBlSKLe2+tQ0yAEXKHV3g/jedfiNK8Bc1QCnVOpEBu1klr+5/WMwFvDsjLEjyW4WW17mZVPC+fxg3taXpzW+M6CpqkWWKTv4TRJUqkkUCfYrMEqTLbVv/Uotc9LnyknrnyjwHtbLlyIghb9ljnIqYC2GU= X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jan 2020 10:47:49.0796 (UTC) X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR05MB6200 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-01-27_02:2020-01-24,2020-01-27 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 priorityscore=1501 suspectscore=0 clxscore=1015 adultscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1911200001 definitions=main-2001270091 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Igor Mitsyanko Information about interface combinations is now available in a fixed portion of struct qlink_resp_get_mac_info. Use that information to get interface combinations. TLV type QTN_TLV_ID_NUM_IFACE_COMB is not needed anymore and can be dropped. Signed-off-by: Igor Mitsyanko --- drivers/net/wireless/quantenna/qtnfmac/commands.c | 48 +++++++++-------------- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 5 --- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c index ca7d59a0a848..1cba0182a5b8 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c @@ -1023,10 +1023,9 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, size_t tlv_buf_size) { const u8 *tlv_buf = resp->var_info; - struct ieee80211_iface_combination *comb = NULL; + struct ieee80211_iface_combination *comb = mac->macinfo.if_comb; size_t n_comb = 0; struct ieee80211_iface_limit *limits; - const struct qlink_iface_comb_num *comb_num; const struct qlink_iface_limit_record *rec; const struct qlink_iface_limit *lim; const struct qlink_wowlan_capab_data *wowlan; @@ -1084,32 +1083,6 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, } switch (tlv_type) { - case QTN_TLV_ID_NUM_IFACE_COMB: - if (tlv_value_len != sizeof(*comb_num)) - return -EINVAL; - - comb_num = (void *)tlv->val; - - /* free earlier iface comb memory */ - qtnf_mac_iface_comb_free(mac); - - mac->macinfo.n_if_comb = - le32_to_cpu(comb_num->iface_comb_num); - - mac->macinfo.if_comb = - kcalloc(mac->macinfo.n_if_comb, - sizeof(*mac->macinfo.if_comb), - GFP_KERNEL); - - if (!mac->macinfo.if_comb) - return -ENOMEM; - - comb = mac->macinfo.if_comb; - - pr_debug("MAC%u: %zu iface combinations\n", - mac->macid, mac->macinfo.n_if_comb); - - break; case QTN_TLV_ID_IFACE_LIMIT: if (unlikely(!comb)) { pr_warn("MAC%u: no combinations advertised\n", @@ -1266,13 +1239,15 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, return 0; } -static void +static int qtnf_cmd_resp_proc_mac_info(struct qtnf_wmac *mac, const struct qlink_resp_get_mac_info *resp_info) { struct qtnf_mac_info *mac_info; struct qtnf_vif *vif; + qtnf_mac_iface_comb_free(mac); + mac_info = &mac->macinfo; mac_info->bands_cap = resp_info->bands_cap; @@ -1302,6 +1277,16 @@ qtnf_cmd_resp_proc_mac_info(struct qtnf_wmac *mac, sizeof(mac_info->ht_cap_mod_mask)); memcpy(&mac_info->vht_cap_mod_mask, &resp_info->vht_cap_mod_mask, sizeof(mac_info->vht_cap_mod_mask)); + + mac_info->n_if_comb = resp_info->n_iface_combinations; + mac_info->if_comb = kcalloc(mac->macinfo.n_if_comb, + sizeof(*mac->macinfo.if_comb), + GFP_KERNEL); + + if (!mac->macinfo.if_comb) + return -ENOMEM; + + return 0; } static void qtnf_cmd_resp_band_fill_htcap(const u8 *info, @@ -1657,7 +1642,10 @@ int qtnf_cmd_get_mac_info(struct qtnf_wmac *mac) goto out; resp = (const struct qlink_resp_get_mac_info *)resp_skb->data; - qtnf_cmd_resp_proc_mac_info(mac, resp); + ret = qtnf_cmd_resp_proc_mac_info(mac, resp); + if (ret) + goto out; + ret = qtnf_parse_variable_mac_info(mac, resp, var_data_len); out: diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h index 9838ea6b212a..8966fb68a61a 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h @@ -1399,7 +1399,6 @@ enum qlink_tlv_id { QTN_TLV_ID_STA_STATS = 0x0212, QTN_TLV_ID_COVERAGE_CLASS = 0x0213, QTN_TLV_ID_IFACE_LIMIT = 0x0214, - QTN_TLV_ID_NUM_IFACE_COMB = 0x0215, QTN_TLV_ID_CHANNEL_STATS = 0x0216, QTN_TLV_ID_KEY = 0x0302, QTN_TLV_ID_SEQ = 0x0303, @@ -1430,10 +1429,6 @@ struct qlink_tlv_hdr { u8 val[0]; } __packed; -struct qlink_iface_comb_num { - __le32 iface_comb_num; -} __packed; - struct qlink_iface_limit { __le16 max_num; __le16 type; From patchwork Mon Jan 27 10:46:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 216581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4823BC32771 for ; Mon, 27 Jan 2020 10:48:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E156B207FD for ; Mon, 27 Jan 2020 10:48:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=quantenna.com header.i=@quantenna.com header.b="Yhmrq+vU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730072AbgA0KsQ (ORCPT ); Mon, 27 Jan 2020 05:48:16 -0500 Received: from mx0a-00183b01.pphosted.com ([67.231.149.44]:63146 "EHLO mx0a-00183b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730011AbgA0KsQ (ORCPT ); Mon, 27 Jan 2020 05:48:16 -0500 Received: from pps.filterd (m0048105.ppops.net [127.0.0.1]) by mx0a-00183b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00RAgsQ5020773 for ; Mon, 27 Jan 2020 03:48:12 -0700 Received: from nam04-bn3-obe.outbound.protection.outlook.com (mail-bn3nam04lp2057.outbound.protection.outlook.com [104.47.46.57]) by mx0a-00183b01.pphosted.com with ESMTP id 2xrkum3utp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 Jan 2020 03:48:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gR4eQAgf0xD7Ly2ZN58u4afqBTULfseKKPBVFLNr7uN7nehZO2TsYDqYd3LjPxDhTgJI0QiZ6+6mDyd9RwrQePkwucz0kZPzSpsEKzswfNKhJPPKmZm9rdE9cHB3njoiDY74wFo5l0+VQ4F9wVtbyheQrQtqgNhv10r1y2Bm+oTK/mH8VvQh36g6ZRMeuZAoEQVKcZmx5C77K9ws1K5s/RFMsZnhbNubtI4aUviMsn+kkac39/2ebxQQf7/EowJaMZCgQ9j2QKGFQ98CpBpvzs388lsBqaC2YZlzX52+EFkjpPOwgaIRKMu/4Ve92rjc0PVcEgs2nj/rguaDNm04oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H86sMeOAMNXDtkig2hgtjKNI8PXVUJ3LZOQA13Zx+Bs=; b=IaDKXaQj5Jqsh6GksI0dPYOUNO2+sE9ZDtoGBA/VV+MO8KK5BSfZ4hSEf3kBohtmWyjoM33/BOn372Ng89I5aMrWE8mSHM9OFtMrXMrXaHShzELtGAaMgp9eN6XULA5CdoVjrs8psV44FUJJzbEWGiLsXjiJrnLbpp8ghWh0NjmrKaeZkgCXb0ytUteCYELy6wzUMn6saEtgqJOy/0S8CLdpiJfOULMwjO6Nji1tVkTc2+zzvRWCmkd2sk9rqGP3AojbO3lTrOrgy0lsYvHBcTSQV2ZwWbYqMGpluNNUF5SZaxLlYubA1XwY3aXZzZrblg6UavZuPOMfamzqGDGtjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=quantenna.com; dmarc=pass action=none header.from=quantenna.com; dkim=pass header.d=quantenna.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantenna.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H86sMeOAMNXDtkig2hgtjKNI8PXVUJ3LZOQA13Zx+Bs=; b=Yhmrq+vUP4oVC3/jxAJL9o96ajR1FDykI1J1ruXi2BomHz/GtI04CkGovgI55Tw9k/DbF6YLBXxJeNjgvUvdwZzbTst3m5wpfzFmDW48vZIUJsNQT5zVqdBOjq3gWrDDdkjWv2FjAxa6wQ++fuTcWgyZhFZZKcP4Jz4rm0ZhSxc= Received: from SN6PR05MB4845.namprd05.prod.outlook.com (52.135.114.206) by SN6PR05MB5168.namprd05.prod.outlook.com (20.177.250.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.12; Mon, 27 Jan 2020 10:48:10 +0000 Received: from SN6PR05MB4845.namprd05.prod.outlook.com ([fe80::6c4f:1012:10ba:848f]) by SN6PR05MB4845.namprd05.prod.outlook.com ([fe80::6c4f:1012:10ba:848f%4]) with mapi id 15.20.2686.019; Mon, 27 Jan 2020 10:48:10 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com (52.135.117.74) by SN6PR05MB5391.namprd05.prod.outlook.com (52.135.111.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.18; Mon, 27 Jan 2020 10:46:53 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::2956:4ff3:7d5b:333c]) by SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::2956:4ff3:7d5b:333c%5]) with mapi id 15.20.2686.019; Mon, 27 Jan 2020 10:46:53 +0000 Received: from bars.quantenna.com (195.182.157.78) by HE1PR07CA0018.eurprd07.prod.outlook.com (2603:10a6:7:67::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.14 via Frontend Transport; Mon, 27 Jan 2020 10:46:52 +0000 From: Sergey Matyukevich To: "linux-wireless@vger.kernel.org" CC: Igor Mitsyanko , Mikhail Karpenko , Sergey Matyukevich Subject: [PATCH 07/10] qtnfmac: cleanup alignment in firmware communication protocol Thread-Topic: [PATCH 07/10] qtnfmac: cleanup alignment in firmware communication protocol Thread-Index: AQHV1P8WuSgkX+NvKEWdD/uWL/S/sA== Date: Mon, 27 Jan 2020 10:46:53 +0000 Message-ID: <20200127104634.7248-8-sergey.matyukevich.os@quantenna.com> References: <20200127104634.7248-1-sergey.matyukevich.os@quantenna.com> In-Reply-To: <20200127104634.7248-1-sergey.matyukevich.os@quantenna.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR07CA0018.eurprd07.prod.outlook.com (2603:10a6:7:67::28) To SN6PR05MB4928.namprd05.prod.outlook.com (2603:10b6:805:9d::10) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.11.0 x-originating-ip: [195.182.157.78] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f280fb77-2afa-4d83-3b59-08d7a31638bb x-ms-traffictypediagnostic: SN6PR05MB5391:|SN6PR05MB5168: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-moderation-data: 1/27/2020 10:48:07 AM x-ms-oob-tlc-oobclassifiers: OLM:283; x-forefront-prvs: 02951C14DC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39840400004)(396003)(346002)(376002)(136003)(189003)(199004)(86362001)(30864003)(103116003)(66446008)(66946007)(66476007)(54906003)(36756003)(64756008)(66556008)(6916009)(316002)(5660300002)(8936002)(8676002)(81156014)(81166006)(1076003)(478600001)(52116002)(4326008)(71200400001)(107886003)(186003)(16526019)(26005)(7696005)(2906002)(2616005)(956004)(6486002)(579004); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR05MB5168; H:SN6PR05MB4845.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Wm7A0jCDhoCBn2Omc9KPFgCWGHvzOVxsPQcBDyXcA7VKt3ftsDsgy08pDN9rOFunMZDf+N1dINDek61CvxWMNvABIJP2vefNBcWhkNjGKIo//49SmUYEZZ9zHQlSk0wTw6W+bAvLk4vDuz/MNzjFumtyI1DxBDSy1UmHPKflqckx3XWRJDC00DdxjitkpvzHN9+eDl0tQsFvWyE7P4LhFx5DUhSiCsjOWnhf3VGMfXrcRru9kw8Rl4i2AUlYLZM0aE21dADsuSAUmLe0po3AF9F2xGybToaEFJkYw0OvdIxx01ez/ZUys6HSELLSLX8mE021v7J4D8jUF3amreqfzrmfBQSRqvIWbV2Pdh2xXgkIUjHrpdoeaswuUHavtHfUXs5fa5tM1acmvCtXT0N8vFiMpiZBwVCZla+EMXGKm2FFcMQ9yV5nJFrA5zcA+SVN x-ms-exchange-antispam-messagedata: L4xZEShZBCDYLoHSAT3jq4EbBqDZWm0dExEnJy9bOf3UzCcInwQofLqesnnQt3Zd6GZCpgH62Nj2cVge2Max7oekwyppvOvufMEoN85VaIPwTEHj7banpBNpGAHdHKOyMRU/xNtynKISPBYeQiDj3A== MIME-Version: 1.0 X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-Network-Message-Id: f280fb77-2afa-4d83-3b59-08d7a31638bb X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: s8ZMx2Vl7CrjkEGIEL1dfXMAR4vEjdav5n9EC7UcH+NhRgxII/NonfyBq4gmjmoR8uBJ9uT4pecouRFmalsHDVqM7t6qeYX7OVjf1n8NtAqOe3LhBxiWFiLS//hT7l9vy8NnBgb7IXV/JI7AxpB58hNuxfJcLxWEdMyJ8tk/SZonEAQQUM13U7dbmTY8OXTvAwICxECsbRe9qQsyTOIz3Q== X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jan 2020 10:48:10.2767 (UTC) X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR05MB5168 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-01-27_02:2020-01-24,2020-01-27 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1911200001 definitions=main-2001270091 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Igor Mitsyanko Make sure that all elements in QLINK protocol message are aligned to 4 bytes. For this purpose add necessary amount of padding bytes to each message. Besides, add padding for non-aligned variable length fields, e.g. SSID, so that the first byte of the next variable length element is aligned. to 4 bytes. Finally, introduce TLV parsing helpers to reduce boilerplate TLV parsing code. Signed-off-by: Igor Mitsyanko --- drivers/net/wireless/quantenna/qtnfmac/commands.c | 142 ++++++++------------- drivers/net/wireless/quantenna/qtnfmac/event.c | 58 ++------- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 27 +++- .../net/wireless/quantenna/qtnfmac/qlink_util.h | 37 +++--- 4 files changed, 103 insertions(+), 161 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c index a4be2aa19997..1271d38e4c7a 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c @@ -175,7 +175,8 @@ static void qtnf_cmd_tlv_ie_set_add(struct sk_buff *cmd_skb, u8 frame_type, { struct qlink_tlv_ie_set *tlv; - tlv = (struct qlink_tlv_ie_set *)skb_put(cmd_skb, sizeof(*tlv) + len); + tlv = (struct qlink_tlv_ie_set *)skb_put(cmd_skb, sizeof(*tlv) + + round_up(len, QLINK_ALIGN)); tlv->hdr.type = cpu_to_le16(QTN_TLV_ID_IE_SET); tlv->hdr.len = cpu_to_le16(len + sizeof(*tlv) - sizeof(tlv->hdr)); tlv->type = frame_type; @@ -190,20 +191,24 @@ static bool qtnf_cmd_start_ap_can_fit(const struct qtnf_vif *vif, { unsigned int len = sizeof(struct qlink_cmd_start_ap); - len += s->ssid_len; - len += s->beacon.head_len; - len += s->beacon.tail_len; - len += s->beacon.beacon_ies_len; - len += s->beacon.proberesp_ies_len; - len += s->beacon.assocresp_ies_len; - len += s->beacon.probe_resp_len; + len += round_up(s->ssid_len, QLINK_ALIGN); + len += round_up(s->beacon.head_len, QLINK_ALIGN); + len += round_up(s->beacon.tail_len, QLINK_ALIGN); + len += round_up(s->beacon.beacon_ies_len, QLINK_ALIGN); + len += round_up(s->beacon.proberesp_ies_len, QLINK_ALIGN); + len += round_up(s->beacon.assocresp_ies_len, QLINK_ALIGN); + len += round_up(s->beacon.probe_resp_len, QLINK_ALIGN); if (cfg80211_chandef_valid(&s->chandef)) len += sizeof(struct qlink_tlv_chandef); - if (s->acl) + if (s->acl) { + unsigned int acl_len = struct_size(s->acl, mac_addrs, + s->acl->n_acl_entries); + len += sizeof(struct qlink_tlv_hdr) + - struct_size(s->acl, mac_addrs, s->acl->n_acl_entries); + round_up(acl_len, QLINK_ALIGN); + } if (len > (sizeof(struct qlink_cmd) + QTNF_MAX_CMD_BUF_SIZE)) { pr_err("VIF%u.%u: can not fit AP settings: %u\n", @@ -315,7 +320,8 @@ int qtnf_cmd_send_start_ap(struct qtnf_vif *vif, if (s->ht_cap) { struct qlink_tlv_hdr *tlv = (struct qlink_tlv_hdr *) - skb_put(cmd_skb, sizeof(*tlv) + sizeof(*s->ht_cap)); + skb_put(cmd_skb, sizeof(*tlv) + + round_up(sizeof(*s->ht_cap), QLINK_ALIGN)); tlv->type = cpu_to_le16(WLAN_EID_HT_CAPABILITY); tlv->len = cpu_to_le16(sizeof(*s->ht_cap)); @@ -339,7 +345,8 @@ int qtnf_cmd_send_start_ap(struct qtnf_vif *vif, size_t acl_size = struct_size(s->acl, mac_addrs, s->acl->n_acl_entries); struct qlink_tlv_hdr *tlv = - skb_put(cmd_skb, sizeof(*tlv) + acl_size); + skb_put(cmd_skb, + sizeof(*tlv) + round_up(acl_size, QLINK_ALIGN)); tlv->type = cpu_to_le16(QTN_TLV_ID_ACL_DATA); tlv->len = cpu_to_le16(acl_size); @@ -581,10 +588,10 @@ qtnf_sta_info_parse_flags(struct nl80211_sta_flag_update *dst, } static void -qtnf_cmd_sta_info_parse(struct station_info *sinfo, - const struct qlink_tlv_hdr *tlv, +qtnf_cmd_sta_info_parse(struct station_info *sinfo, const u8 *data, size_t resp_size) { + const struct qlink_tlv_hdr *tlv; const struct qlink_sta_stats *stats = NULL; const u8 *map = NULL; unsigned int map_len = 0; @@ -595,7 +602,7 @@ qtnf_cmd_sta_info_parse(struct station_info *sinfo, (qtnf_utils_is_bit_set(map, bitn, map_len) && \ (offsetofend(struct qlink_sta_stats, stat_name) <= stats_len)) - while (resp_size >= sizeof(*tlv)) { + qlink_for_each_tlv(tlv, data, resp_size) { tlv_len = le16_to_cpu(tlv->len); switch (le16_to_cpu(tlv->type)) { @@ -610,9 +617,11 @@ qtnf_cmd_sta_info_parse(struct station_info *sinfo, default: break; } + } - resp_size -= tlv_len + sizeof(*tlv); - tlv = (const struct qlink_tlv_hdr *)(tlv->val + tlv_len); + if (!qlink_tlv_parsing_ok(tlv, data, resp_size)) { + pr_err("Malformed TLV buffer\n"); + return; } if (!map || !stats) @@ -736,9 +745,7 @@ int qtnf_cmd_get_sta_info(struct qtnf_vif *vif, const u8 *sta_mac, goto out; } - qtnf_cmd_sta_info_parse(sinfo, - (const struct qlink_tlv_hdr *)resp->info, - var_resp_len); + qtnf_cmd_sta_info_parse(sinfo, resp->info, var_resp_len); out: qtnf_bus_unlock(vif->mac->bus); @@ -907,18 +914,10 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus, plat_id = le32_to_cpu(resp->plat_id); hw_ver = le32_to_cpu(resp->hw_ver); - tlv = (const struct qlink_tlv_hdr *)resp->info; - - while (info_len >= sizeof(*tlv)) { + qlink_for_each_tlv(tlv, resp->info, info_len) { tlv_type = le16_to_cpu(tlv->type); tlv_len = le16_to_cpu(tlv->len); - if (tlv_len + sizeof(*tlv) > info_len) { - pr_warn("malformed TLV 0x%.2X; LEN: %u\n", - tlv_type, tlv_len); - return -EINVAL; - } - switch (tlv_type) { case QTN_TLV_ID_BUILD_NAME: bld_name = (const void *)tlv->val; @@ -948,9 +947,11 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus, default: break; } + } - info_len -= tlv_len + sizeof(*tlv); - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_len); + if (!qlink_tlv_parsing_ok(tlv, resp->info, info_len)) { + pr_err("Malformed TLV buffer\n"); + return -EINVAL; } pr_info("\nBuild name: %s\n" @@ -1019,7 +1020,6 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, const struct qlink_resp_get_mac_info *resp, size_t tlv_buf_size) { - const u8 *tlv_buf = resp->var_info; struct ieee80211_iface_combination *comb = mac->macinfo.if_comb; size_t n_comb = 0; struct ieee80211_iface_limit *limits; @@ -1029,7 +1029,6 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, u16 rec_len; u16 tlv_type; u16 tlv_value_len; - size_t tlv_full_len; const struct qlink_tlv_hdr *tlv; u8 *ext_capa = NULL; u8 *ext_capa_mask = NULL; @@ -1068,16 +1067,9 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, break; } - tlv = (const struct qlink_tlv_hdr *)tlv_buf; - while (tlv_buf_size >= sizeof(struct qlink_tlv_hdr)) { + qlink_for_each_tlv(tlv, resp->var_info, tlv_buf_size) { tlv_type = le16_to_cpu(tlv->type); tlv_value_len = le16_to_cpu(tlv->len); - tlv_full_len = tlv_value_len + sizeof(struct qlink_tlv_hdr); - if (tlv_full_len > tlv_buf_size) { - pr_warn("MAC%u: malformed TLV 0x%.2X; LEN: %u\n", - mac->macid, tlv_type, tlv_value_len); - return -EINVAL; - } switch (tlv_type) { case QTN_TLV_ID_IFACE_LIMIT: @@ -1183,14 +1175,10 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, mac->macid, tlv_type); break; } - - tlv_buf_size -= tlv_full_len; - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); } - if (tlv_buf_size) { - pr_warn("MAC%u: malformed TLV buf; bytes left: %zu\n", - mac->macid, tlv_buf_size); + if (!qlink_tlv_parsing_ok(tlv, resp->var_info, tlv_buf_size)) { + pr_err("Malformed TLV buffer\n"); return -EINVAL; } @@ -1383,7 +1371,6 @@ qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band, size_t payload_len) { u16 tlv_type; - size_t tlv_len; size_t tlv_dlen; const struct qlink_tlv_hdr *tlv; const struct qlink_channel *qchan; @@ -1418,24 +1405,15 @@ qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band, return -ENOMEM; } - tlv = (struct qlink_tlv_hdr *)resp->info; - - while (payload_len >= sizeof(*tlv)) { + qlink_for_each_tlv(tlv, resp->info, payload_len) { tlv_type = le16_to_cpu(tlv->type); tlv_dlen = le16_to_cpu(tlv->len); - tlv_len = tlv_dlen + sizeof(*tlv); - - if (tlv_len > payload_len) { - pr_warn("malformed TLV 0x%.2X; LEN: %zu\n", - tlv_type, tlv_len); - goto error_ret; - } switch (tlv_type) { case QTN_TLV_ID_CHANNEL: if (unlikely(tlv_dlen != sizeof(*qchan))) { pr_err("invalid channel TLV len %zu\n", - tlv_len); + tlv_dlen); goto error_ret; } @@ -1538,13 +1516,10 @@ qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band, pr_warn("unknown TLV type: %#x\n", tlv_type); break; } - - payload_len -= tlv_len; - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_dlen); } - if (payload_len) { - pr_err("malformed TLV buf; bytes left: %zu\n", payload_len); + if (!qlink_tlv_parsing_ok(tlv, resp->info, payload_len)) { + pr_err("Malformed TLV buffer\n"); goto error_ret; } @@ -1689,16 +1664,16 @@ int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed) qtnf_cmd_skb_put_tlv_u32(cmd_skb, QTN_TLV_ID_RTS_THRESH, wiphy->rts_threshold); if (changed & WIPHY_PARAM_COVERAGE_CLASS) - qtnf_cmd_skb_put_tlv_u8(cmd_skb, QTN_TLV_ID_COVERAGE_CLASS, - wiphy->coverage_class); + qtnf_cmd_skb_put_tlv_u32(cmd_skb, QTN_TLV_ID_COVERAGE_CLASS, + wiphy->coverage_class); if (changed & WIPHY_PARAM_RETRY_LONG) - qtnf_cmd_skb_put_tlv_u8(cmd_skb, QTN_TLV_ID_LRETRY_LIMIT, - wiphy->retry_long); + qtnf_cmd_skb_put_tlv_u32(cmd_skb, QTN_TLV_ID_LRETRY_LIMIT, + wiphy->retry_long); if (changed & WIPHY_PARAM_RETRY_SHORT) - qtnf_cmd_skb_put_tlv_u8(cmd_skb, QTN_TLV_ID_SRETRY_LIMIT, - wiphy->retry_short); + qtnf_cmd_skb_put_tlv_u32(cmd_skb, QTN_TLV_ID_SRETRY_LIMIT, + wiphy->retry_short); ret = qtnf_cmd_send(mac->bus, cmd_skb); if (ret) @@ -2054,13 +2029,13 @@ static void qtnf_cmd_scan_set_dwell(struct qtnf_wmac *mac, scan_req->duration_mandatory ? "mandatory" : "max", dwell_active, dwell_passive, duration); - qtnf_cmd_skb_put_tlv_u16(cmd_skb, + qtnf_cmd_skb_put_tlv_u32(cmd_skb, QTN_TLV_ID_SCAN_DWELL_ACTIVE, dwell_active); - qtnf_cmd_skb_put_tlv_u16(cmd_skb, + qtnf_cmd_skb_put_tlv_u32(cmd_skb, QTN_TLV_ID_SCAN_DWELL_PASSIVE, dwell_passive); - qtnf_cmd_skb_put_tlv_u16(cmd_skb, + qtnf_cmd_skb_put_tlv_u32(cmd_skb, QTN_TLV_ID_SCAN_SAMPLE_DURATION, duration); } @@ -2416,25 +2391,15 @@ qtnf_cmd_resp_proc_chan_stat_info(struct survey_info *survey, { const struct qlink_chan_stats *stats = NULL; const struct qlink_tlv_hdr *tlv; - size_t tlv_full_len; u16 tlv_value_len; u16 tlv_type; const u8 *map = NULL; unsigned int map_len = 0; unsigned int stats_len = 0; - tlv = (struct qlink_tlv_hdr *)payload; - - while (payload_len >= sizeof(*tlv)) { + qlink_for_each_tlv(tlv, payload, payload_len) { tlv_type = le16_to_cpu(tlv->type); tlv_value_len = le16_to_cpu(tlv->len); - tlv_full_len = tlv_value_len + sizeof(*tlv); - - if (tlv_full_len > payload_len) { - pr_warn("malformed TLV 0x%.2X; LEN: %u\n", - tlv_type, tlv_value_len); - return -ENOSPC; - } switch (tlv_type) { case QTN_TLV_ID_BITMAP: @@ -2449,13 +2414,10 @@ qtnf_cmd_resp_proc_chan_stat_info(struct survey_info *survey, pr_info("Unknown TLV type: %#x\n", tlv_type); break; } - - payload_len -= tlv_full_len; - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); } - if (payload_len) { - pr_warn("malformed TLV buf; bytes left: %zu\n", payload_len); + if (!qlink_tlv_parsing_ok(tlv, payload, payload_len)) { + pr_err("Malformed TLV buffer\n"); return -EINVAL; } @@ -2657,7 +2619,7 @@ int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif, if (!cmd_skb) return -ENOMEM; - tlv = skb_put(cmd_skb, sizeof(*tlv) + acl_size); + tlv = skb_put(cmd_skb, sizeof(*tlv) + round_up(acl_size, QLINK_ALIGN)); tlv->type = cpu_to_le16(QTN_TLV_ID_ACL_DATA); tlv->len = cpu_to_le16(acl_size); qlink_acl_data_cfg2q(params, (struct qlink_acl_data *)tlv->val); diff --git a/drivers/net/wireless/quantenna/qtnfmac/event.c b/drivers/net/wireless/quantenna/qtnfmac/event.c index 51af93bdf06e..9d3849488fc7 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/event.c +++ b/drivers/net/wireless/quantenna/qtnfmac/event.c @@ -25,7 +25,6 @@ qtnf_event_handle_sta_assoc(struct qtnf_wmac *mac, struct qtnf_vif *vif, size_t payload_len; u16 tlv_type; u16 tlv_value_len; - size_t tlv_full_len; const struct qlink_tlv_hdr *tlv; int ret = 0; @@ -58,23 +57,17 @@ qtnf_event_handle_sta_assoc(struct qtnf_wmac *mac, struct qtnf_vif *vif, sinfo->generation = vif->generation; payload_len = len - sizeof(*sta_assoc); - tlv = (const struct qlink_tlv_hdr *)sta_assoc->ies; - while (payload_len >= sizeof(*tlv)) { + qlink_for_each_tlv(tlv, sta_assoc->ies, payload_len) { tlv_type = le16_to_cpu(tlv->type); tlv_value_len = le16_to_cpu(tlv->len); - tlv_full_len = tlv_value_len + sizeof(struct qlink_tlv_hdr); - - if (tlv_full_len > payload_len) { - ret = -EINVAL; - goto out; - } if (tlv_type == QTN_TLV_ID_IE_SET) { const struct qlink_tlv_ie_set *ie_set; unsigned int ie_len; - if (payload_len < sizeof(*ie_set)) { + if (tlv_value_len < + (sizeof(*ie_set) - sizeof(ie_set->hdr))) { ret = -EINVAL; goto out; } @@ -88,12 +81,10 @@ qtnf_event_handle_sta_assoc(struct qtnf_wmac *mac, struct qtnf_vif *vif, sinfo->assoc_req_ies_len = ie_len; } } - - payload_len -= tlv_full_len; - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); } - if (payload_len) { + if (!qlink_tlv_parsing_ok(tlv, sta_assoc->ies, payload_len)) { + pr_err("Malformed TLV buffer\n"); ret = -EINVAL; goto out; } @@ -153,7 +144,6 @@ qtnf_event_handle_bss_join(struct qtnf_vif *vif, size_t payload_len; u16 tlv_type; u16 tlv_value_len; - size_t tlv_full_len; const struct qlink_tlv_hdr *tlv; const u8 *rsp_ies = NULL; size_t rsp_ies_len = 0; @@ -235,24 +225,17 @@ qtnf_event_handle_bss_join(struct qtnf_vif *vif, } payload_len = len - sizeof(*join_info); - tlv = (struct qlink_tlv_hdr *)join_info->ies; - while (payload_len >= sizeof(struct qlink_tlv_hdr)) { + qlink_for_each_tlv(tlv, join_info->ies, payload_len) { tlv_type = le16_to_cpu(tlv->type); tlv_value_len = le16_to_cpu(tlv->len); - tlv_full_len = tlv_value_len + sizeof(struct qlink_tlv_hdr); - - if (payload_len < tlv_full_len) { - pr_warn("invalid %u TLV\n", tlv_type); - status = WLAN_STATUS_UNSPECIFIED_FAILURE; - goto done; - } if (tlv_type == QTN_TLV_ID_IE_SET) { const struct qlink_tlv_ie_set *ie_set; unsigned int ie_len; - if (payload_len < sizeof(*ie_set)) { + if (tlv_value_len < + (sizeof(*ie_set) - sizeof(ie_set->hdr))) { pr_warn("invalid IE_SET TLV\n"); status = WLAN_STATUS_UNSPECIFIED_FAILURE; goto done; @@ -275,15 +258,10 @@ qtnf_event_handle_bss_join(struct qtnf_vif *vif, break; } } - - payload_len -= tlv_full_len; - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); } - if (payload_len) - pr_warn("VIF%u.%u: unexpected remaining payload: %zu\n", - vif->mac->macid, vif->vifid, payload_len); - + if (!qlink_tlv_parsing_ok(tlv, join_info->ies, payload_len)) + pr_warn("Malformed TLV buffer\n"); done: cfg80211_connect_result(vif->netdev, join_info->bssid, NULL, 0, rsp_ies, rsp_ies_len, status, GFP_KERNEL); @@ -368,7 +346,6 @@ qtnf_event_handle_scan_results(struct qtnf_vif *vif, size_t payload_len; u16 tlv_type; u16 tlv_value_len; - size_t tlv_full_len; const struct qlink_tlv_hdr *tlv; const u8 *ies = NULL; size_t ies_len = 0; @@ -387,21 +364,17 @@ qtnf_event_handle_scan_results(struct qtnf_vif *vif, } payload_len = len - sizeof(*sr); - tlv = (struct qlink_tlv_hdr *)sr->payload; - while (payload_len >= sizeof(struct qlink_tlv_hdr)) { + qlink_for_each_tlv(tlv, sr->payload, payload_len) { tlv_type = le16_to_cpu(tlv->type); tlv_value_len = le16_to_cpu(tlv->len); - tlv_full_len = tlv_value_len + sizeof(struct qlink_tlv_hdr); - - if (tlv_full_len > payload_len) - return -EINVAL; if (tlv_type == QTN_TLV_ID_IE_SET) { const struct qlink_tlv_ie_set *ie_set; unsigned int ie_len; - if (payload_len < sizeof(*ie_set)) + if (tlv_value_len < + (sizeof(*ie_set) - sizeof(ie_set->hdr))) return -EINVAL; ie_set = (const struct qlink_tlv_ie_set *)tlv; @@ -424,12 +397,9 @@ qtnf_event_handle_scan_results(struct qtnf_vif *vif, ies_len = ie_len; } } - - payload_len -= tlv_full_len; - tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); } - if (payload_len) + if (!qlink_tlv_parsing_ok(tlv, sr->payload, payload_len)) return -EINVAL; bss = cfg80211_inform_bss(wiphy, channel, frame_type, diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h index 16acb10386ad..3577482c5076 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h @@ -19,6 +19,8 @@ #define QLINK_PROTO_VER \ QLINK_VER(QLINK_PROTO_VER_MAJOR, QLINK_PROTO_VER_MINOR) +#define QLINK_ALIGN 4 + #define QLINK_MACID_RSVD 0xFF #define QLINK_VIFID_RSVD 0xFF @@ -184,7 +186,7 @@ struct qlink_chandef { __le16 center_freq1; __le16 center_freq2; u8 width; - u8 rsvd; + u8 rsvd[3]; } __packed; #define QLINK_MAX_NR_CIPHER_SUITES 5 @@ -340,9 +342,9 @@ struct qlink_cmd { struct qlink_msg_header mhdr; __le16 cmd_id; __le16 seq_num; - u8 rsvd[2]; u8 macid; u8 vifid; + u8 rsvd[2]; } __packed; /** @@ -404,6 +406,7 @@ struct qlink_cmd_mgmt_frame_register { struct qlink_cmd chdr; __le16 frame_type; u8 do_register; + u8 rsvd[1]; } __packed; /** @@ -441,6 +444,7 @@ struct qlink_cmd_frame_tx { struct qlink_cmd_get_sta_info { struct qlink_cmd chdr; u8 sta_addr[ETH_ALEN]; + u8 rsvd[2]; } __packed; /** @@ -460,6 +464,7 @@ struct qlink_cmd_add_key { u8 addr[ETH_ALEN]; __le32 cipher; __le16 vlanid; + u8 rsvd[2]; u8 key_data[0]; } __packed; @@ -489,6 +494,7 @@ struct qlink_cmd_set_def_key { u8 key_index; u8 unicast; u8 multicast; + u8 rsvd[1]; } __packed; /** @@ -499,6 +505,7 @@ struct qlink_cmd_set_def_key { struct qlink_cmd_set_def_mgmt_key { struct qlink_cmd chdr; u8 key_index; + u8 rsvd[3]; } __packed; /** @@ -515,6 +522,7 @@ struct qlink_cmd_change_sta { __le16 if_type; __le16 vlanid; u8 sta_addr[ETH_ALEN]; + u8 rsvd[2]; } __packed; /** @@ -525,8 +533,9 @@ struct qlink_cmd_change_sta { struct qlink_cmd_del_sta { struct qlink_cmd chdr; __le16 reason_code; - u8 subtype; u8 sta_addr[ETH_ALEN]; + u8 subtype; + u8 rsvd[3]; } __packed; enum qlink_sta_connect_flags { @@ -593,6 +602,7 @@ struct qlink_cmd_external_auth { struct qlink_cmd_disconnect { struct qlink_cmd chdr; __le16 reason; + u8 rsvd[2]; } __packed; /** @@ -604,6 +614,7 @@ struct qlink_cmd_disconnect { struct qlink_cmd_updown { struct qlink_cmd chdr; u8 if_up; + u8 rsvd[3]; } __packed; /** @@ -627,6 +638,7 @@ enum qlink_band { struct qlink_cmd_band_info_get { struct qlink_cmd chdr; u8 band; + u8 rsvd[3]; } __packed; /** @@ -702,6 +714,7 @@ struct qlink_cmd_chan_switch { u8 radar_required; u8 block_tx; u8 beacon_count; + u8 rsvd[3]; } __packed; /** @@ -805,6 +818,7 @@ struct qlink_cmd_pm_set { struct qlink_cmd chdr; __le32 pm_standby_timer; u8 pm_mode; + u8 rsvd[3]; } __packed; /** @@ -1225,6 +1239,7 @@ struct qlink_event_bss_join { struct qlink_event_bss_leave { struct qlink_event ehdr; __le16 reason; + u8 rsvd[2]; } __packed; /** @@ -1341,10 +1356,10 @@ struct qlink_event_radar { */ struct qlink_event_external_auth { struct qlink_event ehdr; + __le32 akm_suite; u8 ssid[IEEE80211_MAX_SSID_LEN]; - u8 ssid_len; u8 bssid[ETH_ALEN]; - __le32 akm_suite; + u8 ssid_len; u8 action; } __packed; @@ -1560,6 +1575,7 @@ struct qlink_tlv_ie_set { struct qlink_tlv_hdr hdr; u8 type; u8 flags; + u8 rsvd[2]; u8 ie_data[0]; } __packed; @@ -1572,6 +1588,7 @@ struct qlink_tlv_ie_set { struct qlink_tlv_ext_ie { struct qlink_tlv_hdr hdr; u8 eid_ext; + u8 rsvd[3]; u8 ie_data[0]; } __packed; diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h index f873beed2ae7..9164b750396c 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h @@ -20,8 +20,9 @@ static inline void qtnf_cmd_skb_put_tlv_arr(struct sk_buff *skb, u16 tlv_id, const u8 arr[], size_t arr_len) { - struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + arr_len); + struct qlink_tlv_hdr *hdr; + hdr = skb_put(skb, sizeof(*hdr) + round_up(arr_len, QLINK_ALIGN)); hdr->type = cpu_to_le16(tlv_id); hdr->len = cpu_to_le16(arr_len); memcpy(hdr->val, arr, arr_len); @@ -35,27 +36,6 @@ static inline void qtnf_cmd_skb_put_tlv_tag(struct sk_buff *skb, u16 tlv_id) hdr->len = cpu_to_le16(0); } -static inline void qtnf_cmd_skb_put_tlv_u8(struct sk_buff *skb, u16 tlv_id, - u8 value) -{ - struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value)); - - hdr->type = cpu_to_le16(tlv_id); - hdr->len = cpu_to_le16(sizeof(value)); - *hdr->val = value; -} - -static inline void qtnf_cmd_skb_put_tlv_u16(struct sk_buff *skb, - u16 tlv_id, u16 value) -{ - struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value)); - __le16 tmp = cpu_to_le16(value); - - hdr->type = cpu_to_le16(tlv_id); - hdr->len = cpu_to_le16(sizeof(value)); - memcpy(hdr->val, &tmp, sizeof(tmp)); -} - static inline void qtnf_cmd_skb_put_tlv_u32(struct sk_buff *skb, u16 tlv_id, u32 value) { @@ -85,4 +65,17 @@ u32 qlink_utils_chflags_cfg2q(u32 cfgflags); void qlink_utils_regrule_q2nl(struct ieee80211_reg_rule *rule, const struct qlink_tlv_reg_rule *tlv_rule); +#define qlink_for_each_tlv(_tlv, _start, _datalen) \ + for (_tlv = (const struct qlink_tlv_hdr *)(_start); \ + (const u8 *)(_start) + (_datalen) - (const u8 *)_tlv >= \ + (int)sizeof(*_tlv) && \ + (const u8 *)(_start) + (_datalen) - (const u8 *)_tlv >= \ + (int)sizeof(*_tlv) + le16_to_cpu(_tlv->len); \ + _tlv = (const struct qlink_tlv_hdr *)(_tlv->val + \ + round_up(le16_to_cpu(_tlv->len), QLINK_ALIGN))) + +#define qlink_tlv_parsing_ok(_tlv_last, _start, _datalen) \ + ((const u8 *)(_tlv_last) == \ + (const u8 *)(_start) + round_up(_datalen, QLINK_ALIGN)) + #endif /* _QTN_FMAC_QLINK_UTIL_H_ */ From patchwork Mon Jan 27 10:46:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 216579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D550FC32771 for ; Mon, 27 Jan 2020 10:48:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9CBF7207FD for ; Mon, 27 Jan 2020 10:48:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=quantenna.com header.i=@quantenna.com header.b="cXnZMLxk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730085AbgA0Ks2 (ORCPT ); Mon, 27 Jan 2020 05:48:28 -0500 Received: from mx0b-00183b01.pphosted.com ([67.231.157.42]:31258 "EHLO mx0a-00183b01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726428AbgA0Ks1 (ORCPT ); Mon, 27 Jan 2020 05:48:27 -0500 Received: from pps.filterd (m0059811.ppops.net [127.0.0.1]) by mx0b-00183b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00RAj2EA006182 for ; Mon, 27 Jan 2020 03:48:26 -0700 Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2102.outbound.protection.outlook.com [104.47.55.102]) by mx0b-00183b01.pphosted.com with ESMTP id 2xrh3032d9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 Jan 2020 03:48:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ISBqNd65ndI29uKjyO2n6UvtQ8SkA2i941Qi7OprcEY/v4k0AJmMfeV0czXpCO2Idmxi16W7d5dGbAfv8W8rbppk8lO6XXcUsg8K0O2XbZ5cw94P/0JHcoWP8dzACu+cK5hkI9/aOWeCicyENeMlggw3hI1LVfYeg8H6aMOKyOrlcRDlKVXDqV2Vh25uJp6Gn/073vtYk9A657mpFaFwlNxR5OpVKwxFHRhbH33OZp3PsbhlSXjLykP0QaDwYX2RU5uMMye5W0pzsgOVHfbLs7n+Ljh5hVAZYX9qt0wZ1RPop7tmucJKoRbsqq4TgravsooxSbKZfgzls7dy6NZM9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kV4Jd3neiwkvQntvpLJJ5bjawzqJGmw/YW99OPPXc8M=; b=gcJ7ZUqhgiH2LZgHyWurVI7dbHbisjp9cR5LauXA1tPtwD3is12tSQXAlpPdM/VeT414KRUWj5+OLKj+RBrd59Mu5SnIBb2KeFi+j1gC5iWL1flcyVqeBihAOpdZob4Id0UEW9bNS3REQXAg3OdwVhLOBvSQzcCl13ZMTTVJNPay/kLnqvIbf+X8l0JliJkHo99udv8QxTGrkfjULHijKMMLeDJNPIoUmDIKWSppO5xRSZ2ZO6yvA64PASoiugfswNYqvBD7zYE3hb+k5PJ5bBP72iKKBHIAchIJhOa+A6V2AVXwzCSBl4F9B3Ts+6WujO8fRMi7XR4ubl2cnDyjVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=quantenna.com; dmarc=pass action=none header.from=quantenna.com; dkim=pass header.d=quantenna.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantenna.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kV4Jd3neiwkvQntvpLJJ5bjawzqJGmw/YW99OPPXc8M=; b=cXnZMLxkjB9PxtIt9GthsOIjw8r0uWfdampnmATqXAg7NduH92fyDoQy/ybv+jUSq+nAlaWJMGbCi9JK/k4U82Z6wd031W7t2O8J08ADFTw3OdPDTX9/u7Js90uMBXnxpRL11Fv5o2QNyzkEznx+IRZaZShetcCodI4fdm2Ss5I= Received: from DM6PR05MB5786.namprd05.prod.outlook.com (20.178.25.95) by DM6PR05MB6332.namprd05.prod.outlook.com (20.178.227.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.14; Mon, 27 Jan 2020 10:48:24 +0000 Received: from DM6PR05MB5786.namprd05.prod.outlook.com ([fe80::a186:bc44:281:5774]) by DM6PR05MB5786.namprd05.prod.outlook.com ([fe80::a186:bc44:281:5774%6]) with mapi id 15.20.2686.019; Mon, 27 Jan 2020 10:48:24 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com (52.135.117.74) by SN6PR05MB5391.namprd05.prod.outlook.com (52.135.111.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.18; Mon, 27 Jan 2020 10:46:55 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::2956:4ff3:7d5b:333c]) by SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::2956:4ff3:7d5b:333c%5]) with mapi id 15.20.2686.019; Mon, 27 Jan 2020 10:46:55 +0000 Received: from bars.quantenna.com (195.182.157.78) by HE1PR07CA0018.eurprd07.prod.outlook.com (2603:10a6:7:67::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.14 via Frontend Transport; Mon, 27 Jan 2020 10:46:53 +0000 From: Sergey Matyukevich To: "linux-wireless@vger.kernel.org" CC: Igor Mitsyanko , Mikhail Karpenko , Sergey Matyukevich Subject: [PATCH 08/10] qtnfmac: update channel switch command to support 6GHz band Thread-Topic: [PATCH 08/10] qtnfmac: update channel switch command to support 6GHz band Thread-Index: AQHV1P8Xw/Yd+jgnmE6Z2jOn5zs8Mw== Date: Mon, 27 Jan 2020 10:46:55 +0000 Message-ID: <20200127104634.7248-9-sergey.matyukevich.os@quantenna.com> References: <20200127104634.7248-1-sergey.matyukevich.os@quantenna.com> In-Reply-To: <20200127104634.7248-1-sergey.matyukevich.os@quantenna.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR07CA0018.eurprd07.prod.outlook.com (2603:10a6:7:67::28) To SN6PR05MB4928.namprd05.prod.outlook.com (2603:10b6:805:9d::10) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.11.0 x-originating-ip: [195.182.157.78] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7bac7453-8e6f-4773-6358-08d7a31639a6 x-ms-traffictypediagnostic: SN6PR05MB5391:|DM6PR05MB6332: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-moderation-data: 1/27/2020 10:48:20 AM x-ms-oob-tlc-oobclassifiers: OLM:4941; x-forefront-prvs: 02951C14DC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39840400004)(366004)(136003)(346002)(376002)(189003)(199004)(26005)(186003)(16526019)(956004)(2616005)(36756003)(86362001)(103116003)(66446008)(7696005)(2906002)(66946007)(66556008)(71200400001)(66476007)(64756008)(478600001)(52116002)(81156014)(316002)(4326008)(54906003)(8676002)(107886003)(81166006)(5660300002)(8936002)(15650500001)(6486002)(6916009)(1076003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR05MB6332; H:DM6PR05MB5786.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wCIx4P22Cy0yjq59exbO6XPYZtPJF7WgzUwHUekETcdY+ejkL2KZmo7nnLFpqV+nPrZOBaqHfc4eclukYPqQO87g/NBM5bDy1oC6XA0UWYxlLGq0DOAheOSv06oDZFX6p4VvECLB4ldFCQOJABBjMsoeuCvv/Gf4ws+GsfSVr+alcMC8BXJN6m47pCz+gQ5v3QFSDRJJ54eyWeCh25vd/OkAhciP0E3Q1nGF0/XCLA7vhfvdjZzBTtmNIu3Ebl+xMVrOAEv7ToLJrMVPfN6vIFQ11qgUZnllZkV4w4sF7pJPijIUWIdANBYlccw7IZstMNEYxG0X44h37xoeC6fyG80fHsSX87m+A82UeJFU1jDOAhnLJgMzeBikQUAM2m6jZ4cmCI64+ZineVfTjdiW2FxNXvvlGhvly7eXhx9APBPxSL/xi0jcLWf/94IstgAt x-ms-exchange-antispam-messagedata: 0eE5ZEvaQmCoXW/XZ/bTaE1yM37pI8261ThIzs2C8xVtQBkmAdDt0v/+AharjKsbleTtJwberAzDM6mhC8l5VddLyaL6ibk6e8au/FiIcfsqHfOHu4ZkXTiy0uHjcMnhMX+Ai+kG9oiwD3PpffEmVQ== MIME-Version: 1.0 X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7bac7453-8e6f-4773-6358-08d7a31639a6 X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Ad3J3jbPcXD4QUPz9D0tT+Ula7V6y7RiWhf90Ho42NvQUiOXGxfUSb/iRUg1gXIugQoaRBif+LKHoBRs/kPkNvqq36lj/0RgZjm6FTswiE9zCFm3lG7MArv/X698F7KcCirnVQOU2IOSsE9qxHOKmdQqoa46OBcf+uvEC+snJ6Xd1IMK/ULJdTevYw2RcNnGGXMZ+tpfmLDGLlq60F3htA5LSTa5QhjDPgGe8wausL0= X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jan 2020 10:48:24.5152 (UTC) X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR05MB6332 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-01-27_02:2020-01-24,2020-01-27 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 clxscore=1015 mlxscore=0 phishscore=0 mlxlogscore=999 priorityscore=1501 lowpriorityscore=0 spamscore=0 impostorscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1911200001 definitions=main-2001270091 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Igor Mitsyanko With an addition of 6GHz band support, channel number can no longer be used to uniquely identify a specific channel. Modify channel switch command to use chandef data. Signed-off-by: Igor Mitsyanko --- drivers/net/wireless/quantenna/qtnfmac/commands.c | 17 +++++++-------- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 25 +++++++++++++++++------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c index 1271d38e4c7a..31286699a5b7 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c @@ -2519,6 +2519,7 @@ int qtnf_cmd_send_chan_switch(struct qtnf_vif *vif, struct qlink_cmd_chan_switch *cmd; struct sk_buff *cmd_skb; int ret; + u64 flags = 0; cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, vif->vifid, QLINK_CMD_CHAN_SWITCH, @@ -2526,19 +2527,19 @@ int qtnf_cmd_send_chan_switch(struct qtnf_vif *vif, if (!cmd_skb) return -ENOMEM; - qtnf_bus_lock(mac->bus); + if (params->radar_required) + flags |= QLINK_CHAN_SW_RADAR_REQUIRED; + + if (params->block_tx) + flags |= QLINK_CHAN_SW_BLOCK_TX; cmd = (struct qlink_cmd_chan_switch *)cmd_skb->data; - cmd->channel = cpu_to_le16(params->chandef.chan->hw_value); - cmd->radar_required = params->radar_required; - cmd->block_tx = params->block_tx; + qlink_chandef_cfg2q(¶ms->chandef, &cmd->channel); + cmd->flags = cpu_to_le64(flags); cmd->beacon_count = params->count; + qtnf_bus_lock(mac->bus); ret = qtnf_cmd_send(mac->bus, cmd_skb); - if (ret) - goto out; - -out: qtnf_bus_unlock(mac->bus); return ret; diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h index 3577482c5076..ab2bfae7ff3e 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h @@ -701,18 +701,31 @@ struct qlink_cmd_reg_notify { } __packed; /** + * enum qlink_chan_sw_flags - channel switch control flags + * + * @QLINK_CHAN_SW_RADAR_REQUIRED: whether radar detection is required on a new + * channel. + * @QLINK_CHAN_SW_BLOCK_TX: whether transmissions should be blocked while + * changing a channel. + */ +enum qlink_chan_sw_flags { + QLINK_CHAN_SW_RADAR_REQUIRED = BIT(0), + QLINK_CHAN_SW_BLOCK_TX = BIT(1), +}; + +/** * struct qlink_cmd_chan_switch - data for QLINK_CMD_CHAN_SWITCH command * - * @channel: channel number according to 802.11 17.3.8.3.2 and Annex J - * @radar_required: whether radar detection is required on the new channel - * @block_tx: whether transmissions should be blocked while changing + * @channel: channel to switch to. + * @flags: flags to control channel switch, bitmap of &enum qlink_chan_sw_flags. * @beacon_count: number of beacons until switch */ struct qlink_cmd_chan_switch { struct qlink_cmd chdr; - __le16 channel; - u8 radar_required; - u8 block_tx; + struct qlink_chandef channel; + __le64 flags; + __le32 n_counter_offsets_beacon; + __le32 n_counter_offsets_presp; u8 beacon_count; u8 rsvd[3]; } __packed; From patchwork Mon Jan 27 10:46:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 216580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B83EC32771 for ; Mon, 27 Jan 2020 10:48:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA1D6207FD for ; Mon, 27 Jan 2020 10:48:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=quantenna.com header.i=@quantenna.com header.b="k+Aj67E1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730079AbgA0KsY (ORCPT ); Mon, 27 Jan 2020 05:48:24 -0500 Received: from mx0a-00183b01.pphosted.com ([67.231.149.44]:60760 "EHLO mx0a-00183b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726428AbgA0KsY (ORCPT ); Mon, 27 Jan 2020 05:48:24 -0500 Received: from pps.filterd (m0048105.ppops.net [127.0.0.1]) by mx0a-00183b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00RAhEBP020883 for ; Mon, 27 Jan 2020 03:48:23 -0700 Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2106.outbound.protection.outlook.com [104.47.58.106]) by mx0a-00183b01.pphosted.com with ESMTP id 2xrkum3uu2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 Jan 2020 03:48:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hMmnWFYLlTGeVbwe7VSFNAb7eVH+kCpEA98kp8TfCsmOfUj0GM82+1RrKXOlS8Eb79g6FkwayWghANUzSzQFYRtP2hRO5ZoUWs+yhOxjWSSRGg9smO3uvuiLkx/+FZVxxhUtGmQBnPyIwcu+5jffgJg7CiUB9r1wwOdU1e5iS06nbVrA+ScqxzfOaM81v0dRo0iqxtxFFUHwE0iRYTJi14fxhHj5Lfji1uvkD4Xyv1ToUV3iuys3vtEtUM+wHfPiODfXWlNtuq8XqNpEXCaVaIpbHw0xpOyLDPoDLPsW1pJG91KmqjG6lmMV2oZ2BuNLsw08OWyvUh1/x1eyKno5Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TJXAxJb83EH5/8rOzK04//0qU6WmHjq1/3weduq6SQw=; b=Co/LShK0Gr+G3PDrMWO0SDSlD7RBs367M/TQT+a2mcHStTcfB69NfrFlLFzpVr5w3t74nxntH37RfhoEZKQ7HB5fume7f6pYpiOC6f8NuqXj/NXTtLjZTFd7Xm0LXDqhIH5bA5FmeIf/RgBiZSDjx0EmAtYSUaf8e3JnMdDVZBoKspc6kpprc/6EyN+Mn7P2YXjqeIkc0lIDURQXGlgX6ev2VZGaCi4mcsPVsoVSu9a8kx4XwQu7U5G8eDymdz7UpRehFu52VWfNGSuruJAqWj2RigsAAHaorcHFeV3/GqJbaiUU/cNKykzesA0XLFqkaZWxDm4ylQPfPnRIIPlBzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=quantenna.com; dmarc=pass action=none header.from=quantenna.com; dkim=pass header.d=quantenna.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantenna.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TJXAxJb83EH5/8rOzK04//0qU6WmHjq1/3weduq6SQw=; b=k+Aj67E1JXTt88LtYRwO//Z5xeDI30tALX8JgEfuU+vNj6voLKbvfNUVv+ayMBhv/4mM/afx5i/9WB8XSQ1ZRGtftEhwwnmk3m54v7sSn8D2pqJckDUpyBibPICnLHEHmERzu4sRvhPrtguT8juF0hlpd6BCkWJr1VEIEqDGwcM= Received: from SN6PR05MB4765.namprd05.prod.outlook.com (52.135.115.147) by SN6PR05MB4464.namprd05.prod.outlook.com (52.135.74.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.15; Mon, 27 Jan 2020 10:48:21 +0000 Received: from SN6PR05MB4765.namprd05.prod.outlook.com ([fe80::a182:388a:1296:d0fa]) by SN6PR05MB4765.namprd05.prod.outlook.com ([fe80::a182:388a:1296:d0fa%6]) with mapi id 15.20.2686.019; Mon, 27 Jan 2020 10:48:21 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com (52.135.117.74) by SN6PR05MB5391.namprd05.prod.outlook.com (52.135.111.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.18; Mon, 27 Jan 2020 10:46:58 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::2956:4ff3:7d5b:333c]) by SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::2956:4ff3:7d5b:333c%5]) with mapi id 15.20.2686.019; Mon, 27 Jan 2020 10:46:58 +0000 Received: from bars.quantenna.com (195.182.157.78) by HE1PR07CA0018.eurprd07.prod.outlook.com (2603:10a6:7:67::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.14 via Frontend Transport; Mon, 27 Jan 2020 10:46:57 +0000 From: Sergey Matyukevich To: "linux-wireless@vger.kernel.org" CC: Igor Mitsyanko , Mikhail Karpenko , Sergey Matyukevich Subject: [PATCH 10/10] qtnfmac: fix potential Spectre vulnerabilities Thread-Topic: [PATCH 10/10] qtnfmac: fix potential Spectre vulnerabilities Thread-Index: AQHV1P8ZYE5Gmf0CBk6P16moh5B8sw== Date: Mon, 27 Jan 2020 10:46:58 +0000 Message-ID: <20200127104634.7248-11-sergey.matyukevich.os@quantenna.com> References: <20200127104634.7248-1-sergey.matyukevich.os@quantenna.com> In-Reply-To: <20200127104634.7248-1-sergey.matyukevich.os@quantenna.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR07CA0018.eurprd07.prod.outlook.com (2603:10a6:7:67::28) To SN6PR05MB4928.namprd05.prod.outlook.com (2603:10b6:805:9d::10) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.11.0 x-originating-ip: [195.182.157.78] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b3172e1e-3db7-476b-b0c3-08d7a3163ba0 x-ms-traffictypediagnostic: SN6PR05MB5391:|SN6PR05MB4464: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-moderation-data: 1/27/2020 10:48:19 AM x-ms-oob-tlc-oobclassifiers: OLM:117; x-forefront-prvs: 02951C14DC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39840400004)(346002)(366004)(376002)(136003)(189003)(199004)(316002)(81156014)(107886003)(4326008)(5660300002)(1076003)(81166006)(8936002)(8676002)(54906003)(2906002)(6916009)(36756003)(6486002)(478600001)(71200400001)(7696005)(52116002)(86362001)(103116003)(186003)(16526019)(26005)(64756008)(66446008)(956004)(2616005)(66946007)(66476007)(66556008); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR05MB4464; H:SN6PR05MB4765.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: i7SUzcADkscy576swfMXUfXY3I5kUeHLXAtnI98UP7XnJde0hg+JabERPv8ot/0SopoUj/sjGQc7MgRz0wjj+xyzGsn8j3/K1nRTLZVdujT5UdhRy+ybl6MBb4irTs/Uqyt2419JXb5zjTRA9dQQIAA/Rlbz2wBRw3LMOz6OwgpxRZDy/THo9asTNOyVoWAED5X0DcmpnJ3UweUyt0wN2smZJoa/Dp/ATYO1cojujPOuq1nymh74biezLl4jIdIZ3PnMYdhGTTJYcrs9nNZpuTIx495LW5JmzkgJd+De9t7SsUkfrbcB/ni7rwhsIaAi6i3UOifEhq8njQ33KzQH1mjevdBY6fW4MpGI5IvdCO9KIbFL0jKndEomBaO/6dxru4B0Yqu7Y5sjG6gMaIgLDrbVJCqwVbMY/rf04FnhP+tO4TQlhsj6jas+XQg3TOZ0 x-ms-exchange-antispam-messagedata: hzos2pBCUuE0+3gryGkQ7LupkGuFoQGaa/G3vs+YCOYnutW5pwhSR8zCOrA6XYHDyGGCUBssT/Nw2/y48lfwVuwXBmUpRxNSelXgZaiEnddTrcbBa1r+bwDzmB7eIfXFw0u064rFoYqfKPYLfiPFeQ== MIME-Version: 1.0 X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3172e1e-3db7-476b-b0c3-08d7a3163ba0 X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: zoim+a/Wx0hSUn4JukEqhyDbHcSalJoo4z9cIH+yr+WKiEBE4XZTxQaGwnSJvAsRS0yY/aYwGZsOIs0GirAVnweVxppWAuLpAe3vjIW6rCo/d4BUOeT9O8LtHpysCZk3c1Kd4TolsaesnAzwXOGunRygMyDzQuA2lr3oWQYbqxy6YTCRvsD4D3sAbSkBztPVwvXqTTr84cm2rZHH9E+I9pGIUWHbWFq9DL+wWhj/9Dk= X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jan 2020 10:48:21.7088 (UTC) X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR05MB4464 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-01-27_02:2020-01-24,2020-01-27 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1911200001 definitions=main-2001270091 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Fix potential Spectre vulnerabilities and other warnings reported by smatch: drivers/net/wireless/quantenna/qtnfmac/core.c:49 qtnf_core_get_mac() warn: potential spectre issue 'bus->mac' [r] (local cap) drivers/net/wireless/quantenna/qtnfmac/core.c:51 qtnf_core_get_mac() warn: possible spectre second half. 'mac' drivers/net/wireless/quantenna/qtnfmac/event.c:671 qtnf_event_parse() warn: potential spectre issue 'mac->iflist' [r] (local cap) drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c:912 qtnf_pcie_skb_send() warn: variable dereferenced before check 'skb' (see line 881) Signed-off-by: Sergey Matyukevich --- drivers/net/wireless/quantenna/qtnfmac/core.c | 4 +++- drivers/net/wireless/quantenna/qtnfmac/event.c | 9 ++++++--- drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c index 74c9aa297ec9..9e666fac8b5f 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.c +++ b/drivers/net/wireless/quantenna/qtnfmac/core.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "core.h" #include "bus.h" @@ -41,11 +42,12 @@ struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid) { struct qtnf_wmac *mac = NULL; - if (unlikely(macid >= QTNF_MAX_MAC)) { + if (macid >= QTNF_MAX_MAC) { pr_err("invalid MAC index %u\n", macid); return NULL; } + macid = array_index_nospec(macid, QTNF_MAX_MAC); mac = bus->mac[macid]; if (unlikely(!mac)) { diff --git a/drivers/net/wireless/quantenna/qtnfmac/event.c b/drivers/net/wireless/quantenna/qtnfmac/event.c index 9d3849488fc7..7e408b5c5549 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/event.c +++ b/drivers/net/wireless/quantenna/qtnfmac/event.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "cfg80211.h" #include "core.h" @@ -632,18 +633,20 @@ static int qtnf_event_parse(struct qtnf_wmac *mac, int ret = -1; u16 event_id; u16 event_len; + u8 vifid; event = (const struct qlink_event *)event_skb->data; event_id = le16_to_cpu(event->event_id); event_len = le16_to_cpu(event->mhdr.len); - if (likely(event->vifid < QTNF_MAX_INTF)) { - vif = &mac->iflist[event->vifid]; - } else { + if (event->vifid >= QTNF_MAX_INTF) { pr_err("invalid vif(%u)\n", event->vifid); return -EINVAL; } + vifid = array_index_nospec(event->vifid, QTNF_MAX_INTF); + vif = &mac->iflist[vifid]; + switch (event_id) { case QLINK_EVENT_STA_ASSOCIATED: ret = qtnf_event_handle_sta_assoc(mac, vif, (const void *)event, diff --git a/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c index 8e0d8018208a..dbb241106d8a 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c +++ b/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c @@ -593,7 +593,7 @@ static int qtnf_pcie_skb_send(struct qtnf_bus *bus, struct sk_buff *skb) priv->tx_bd_w_index = i; tx_done: - if (ret && skb) { + if (ret) { pr_err_ratelimited("drop skb\n"); if (skb->dev) skb->dev->stats.tx_dropped++;