From patchwork Mon Mar 15 13:24:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 400957 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 CF2EBC41518 for ; Mon, 15 Mar 2021 13:26:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CBF964F04 for ; Mon, 15 Mar 2021 13:26:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231320AbhCON0e (ORCPT ); Mon, 15 Mar 2021 09:26:34 -0400 Received: from mail-dm3nam07on2076.outbound.protection.outlook.com ([40.107.95.76]:48947 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230433AbhCON0I (ORCPT ); Mon, 15 Mar 2021 09:26:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dl35aLdhWeg7hEK221G7Y17/PMvBBEm8LWTfV8BrQ+9Dp9CKmprcOAMhdVCgTCd0Sl5MHF58NrSnQW3PPm6KMYuH71dM+KBH1obuBz62H6FdCR1l1nmJgnc+Nddico69fGVTK9XinIzoRbrnwIst7R1gEoeLS77aSDkc+GwcTKGQwa1ybz/f2M8bk5/reGpsrtKtGf8fcR9XvhEfus/cycQCZJMhgIbkpf8J9mJ0RM44JhGmhw3m6PhHBL/dTmiWuWM42rKGAruh8175MKJYoyy6bHmXhFueVSJQaNI0I3J4873dO+BO6oLFK7qxxhe81Mt3YxB/JyrvQzDAd3OulA== 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=SW4BtkZL8WRQ60zcsW+NImcmNj6y8xm8RPzeIlkg/0k=; b=FyCROBMXQqt8SjqfMKB2Do6fCwfUlv+0G2AiW2NUjKtIGPr5/HB+pRWGutPUw2ALd8LxqSWUlsqvjmAzdHUNzeayOZkigEArGbYby1D+2YoCx7bQ4ax6asjERVEQTFXXkNHFIosuiNBWKISxGEfbRNtE2AfQivOaQhhPXZ/jTXDLaPVC4fsUYJFaItwva6v8omK2iauh1xN3E9gaTIAcdmt5srsvxoOvEwpalR3Qu+kt4Wt+hEy3eqvhjEprN9DDG2K/MopdD2zqom0uVJhiaTg9ONGd6dXUAk/D0DNAcbk35qTwq0+Bc5lzegEo+tG6wDXCkeTutBefrrUxTl0EHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SW4BtkZL8WRQ60zcsW+NImcmNj6y8xm8RPzeIlkg/0k=; b=igbMBgfCTus251Lmb3w+UXVvBdy4HuvcuPGdwPhgEecn5N8bQrMhOg5bx3n2FQmeGDAoLkVDhakjQOs07fBQseZm6Z6edYLlg5OZA2WQO609AtP+X1JZjxfyxXWU5EVe3J9VlwMD7nA9y8SyW34UA4hQiFTIbZfEBxVQyiWKRp4= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SN6PR11MB3117.namprd11.prod.outlook.com (2603:10b6:805:d7::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.32; Mon, 15 Mar 2021 13:26:07 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::41bc:5ce:dfa0:9701]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::41bc:5ce:dfa0:9701%7]) with mapi id 15.20.3933.032; Mon, 15 Mar 2021 13:26:07 +0000 From: Jerome Pouiller To: linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , devicetree@vger.kernel.org, Rob Herring , linux-mmc@vger.kernel.org, =?utf-8?q?Pali_Roh=C3=A1r?= , Ulf Hansson , =?utf-8?b?SsOpcsO0bWUg?= =?utf-8?q?Pouiller?= Subject: [PATCH v5 16/24] wfx: add data_rx.c/data_rx.h Date: Mon, 15 Mar 2021 14:24:53 +0100 Message-Id: <20210315132501.441681-17-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315132501.441681-1-Jerome.Pouiller@silabs.com> References: <20210315132501.441681-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [2a01:e35:2435:66a0:544b:f17b:7ae8:fb7] X-ClientProxiedBy: SN4PR0801CA0014.namprd08.prod.outlook.com (2603:10b6:803:29::24) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (2a01:e35:2435:66a0:544b:f17b:7ae8:fb7) by SN4PR0801CA0014.namprd08.prod.outlook.com (2603:10b6:803:29::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.32 via Frontend Transport; Mon, 15 Mar 2021 13:26:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b0a24ef9-2cba-4f54-b915-08d8e7b5e394 X-MS-TrafficTypeDiagnostic: SN6PR11MB3117: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:644; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TxzJtu3pTJy3XDjAEfW93YJNeD6f2ZYWLv5X3WsXkNPBTNIdMDtYfuWswWbbSX+3zzjgjng8EcVcJZjCLJ62Jw+pGiIUiEfn94J1QW26PsQ6e8w8knq7rRNZcNAi9ysznjQIVY/klRhEijfKxh4TeYobsqSqhUKYpF6AXripMcY1rgXTIqCoxSGbCa9fYlH2P7Qa3/MHQraKb0zB7ET7k46LpJ7tKsdxkYsqMSwUU781CxnxeUZxmLmyjOcmIwPuHvSNoOUSN6aZ540Lk0JWCk8csdSubs0wfiNz/KVP9J5Eiipotw91ptzOucPQu3dVxGIiPjVy4V8RZZkxWI4DgqK1vDCsn/Rj4WUUNsEsUyaL+VFjlq1HQpG2SIiBDVLBSF6XythRMkhV7nERPgA6yhc+229pKNVbFfhadvit7hOa+v7QAiNsDJIaL/hwjtAlOC/O+8gDmVJ8P8/MBV6U3phm6A+kRtxM2V67DSpo6lRr/uw/a8hAufSqVDcTOgRcrIJl3Z3V4WZ77K0/RXGRIMMUPyNyu5FiT+o+Xn5M+yYyskbNRjJ20LP+Rbro5onS X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB2718.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(39850400004)(376002)(346002)(366004)(1076003)(7696005)(54906003)(2906002)(66946007)(52116002)(316002)(86362001)(16526019)(107886003)(6666004)(7416002)(66556008)(2616005)(8676002)(478600001)(6486002)(186003)(8936002)(83380400001)(5660300002)(4326008)(36756003)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?1yCF7/9as7xNFm9BEuDYQSvQy4k?= =?utf-8?q?2t0aFGPwuygPwUFmW2MpRmQ3JFs4jKFvqAkc45EaCEPssvy/fMRSglY2?= =?utf-8?q?B6Z10GbKIuP8gbe8VOaNZPaTfXbrZsV3oR9/s5Q+5PuzV9L6A+/WFZif?= =?utf-8?q?PjxUhLRLq62AZX2fh4l/tHootlN3Reh8JCCsiyh3SHIG0OFt1NhqEZpL?= =?utf-8?q?PRIPF6c2WpCGUihnUU9ckBGtrDypjhO3/ztB/V4NCjSNLVm+M7nKi/4F?= =?utf-8?q?BaChZGMAyUcyi126hPM+W2ruhUd4TNL8w2TapuMtGU3Hv2GjnPOPHghX?= =?utf-8?q?VcoXbCIkiCSF3v4jfe2qhC5WnyseIJJMYsbnbmJJRjMYaW+FEjWykuhL?= =?utf-8?q?5ryz+jfXOiGDqcxH/AMJMSKy3bW5BdAd8NMorEHH4JDY+ts66BjAU4J1?= =?utf-8?q?iYnXpEt3grcb4a2CUvLw6RNbIyfKIthDgz/xV6cDIwSnTG3B8w5nfgun?= =?utf-8?q?CpMBrmv5wAvWh3bG+5jZvYuoX+vAafvFnOQjs5+eDUZQVm17ce2UD4zR?= =?utf-8?q?ATl/RB4ldv0oMWzSm12AE6u8kPZLpNkGYx5yg+TrpYdZ0PNUGds8LW8n?= =?utf-8?q?cqCJIn+fpvLFUK+TU9ntcvdGQfDRL/VV73sxTGfWIldWl5RsmRaLath9?= =?utf-8?q?oxU1yv2tS1rrTtOKXT758eBYc2e3eLxZL6PIqNAH+3WBs+Rj1ysvWysZ?= =?utf-8?q?ieyqajfBGTC/UuoD2hB7pbTrf9QvzFm+3FXWcB6/We40+8C2OCF13V0C?= =?utf-8?q?EKM97dyZkzjMarVoM+4avAGucOjxK8GkgSvhRFMcroqKZcw2kGIPK6Vy?= =?utf-8?q?HO37QYLzD7MdZmwYPZYxkRhB9YK3mpQLEahUD9DM5Gc97wmJ/ATiyKVn?= =?utf-8?q?b302ToD4u672quKoDs2uTkHTqt789bs6aHUgxeOf1nHQelMo0ueTYwQT?= =?utf-8?q?jauA8vz5Rmh1Y0qOAfScqaKnF2KzS4keSGZdFobahsNJr8mxl6SphugU?= =?utf-8?q?iXHU7y6UeX9PsCxyhU6OSCKOqvengaoY0pnGTrf1k15FsXYCXIsvewy1?= =?utf-8?q?chQS9k179PLI+569RSunCbAO+EzLCJViPoJ7+fp6x8GeLCoodxVYrPVk?= =?utf-8?q?aUYOQxNpj29ppGAGPlUgPdQ238fHQ13d2tjGHXporXw07zOzrnXf2ij8?= =?utf-8?q?Ywd2ieUg3f0FQRl5KMP/dYdqLLunDqzeeD5Wf5u6mJ7hx7G6yCT/Eugb?= =?utf-8?q?gB83df/p47jQQmFkR0+21QuJ3F2kN+6CUl0/gx+PkBeA7Z00JB5A/VUM?= =?utf-8?q?FMRcjXLrgX+s3sKoLf+7RA8ZImUJyt5tgOheaAPpKka6F78P2icW/L8r?= =?utf-8?q?bsEJCEPVDw8mkN5XHA9BmdVSEh2j52Oduxus9I+hSF0g1Qh4Xqn977N8?= =?utf-8?q?scruPy5SjL78ujBv2nLe7XHz8GoJFKkHw3w1W?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0a24ef9-2cba-4f54-b915-08d8e7b5e394 X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2021 13:26:06.8615 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DSzIA9qx3h/HK4hTyE0t0kUwMSBE9P4r3nfmIqAxvvaoIKXMM0NQSTW3BeQW+xoq8PShkLmL0l1MooTIPCcBpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3117 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller Signed-off-by: Jérôme Pouiller --- drivers/net/wireless/silabs/wfx/data_rx.c | 94 +++++++++++++++++++++++ drivers/net/wireless/silabs/wfx/data_rx.h | 18 +++++ 2 files changed, 112 insertions(+) create mode 100644 drivers/net/wireless/silabs/wfx/data_rx.c create mode 100644 drivers/net/wireless/silabs/wfx/data_rx.h diff --git a/drivers/net/wireless/silabs/wfx/data_rx.c b/drivers/net/wireless/silabs/wfx/data_rx.c new file mode 100644 index 000000000000..e6d9d8746d4d --- /dev/null +++ b/drivers/net/wireless/silabs/wfx/data_rx.c @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Datapath implementation. + * + * Copyright (c) 2017-2020, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include +#include + +#include "data_rx.h" +#include "wfx.h" +#include "bh.h" +#include "sta.h" + +static void wfx_rx_handle_ba(struct wfx_vif *wvif, struct ieee80211_mgmt *mgmt) +{ + int params, tid; + + if (wfx_api_older_than(wvif->wdev, 3, 6)) + return; + + switch (mgmt->u.action.u.addba_req.action_code) { + case WLAN_ACTION_ADDBA_REQ: + params = le16_to_cpu(mgmt->u.action.u.addba_req.capab); + tid = (params & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; + ieee80211_start_rx_ba_session_offl(wvif->vif, mgmt->sa, tid); + break; + case WLAN_ACTION_DELBA: + params = le16_to_cpu(mgmt->u.action.u.delba.params); + tid = (params & IEEE80211_DELBA_PARAM_TID_MASK) >> 12; + ieee80211_stop_rx_ba_session_offl(wvif->vif, mgmt->sa, tid); + break; + } +} + +void wfx_rx_cb(struct wfx_vif *wvif, + const struct hif_ind_rx *arg, struct sk_buff *skb) +{ + struct ieee80211_rx_status *hdr = IEEE80211_SKB_RXCB(skb); + struct ieee80211_hdr *frame = (struct ieee80211_hdr *)skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data; + + memset(hdr, 0, sizeof(*hdr)); + + if (arg->status == HIF_STATUS_RX_FAIL_MIC) + hdr->flag |= RX_FLAG_MMIC_ERROR | RX_FLAG_IV_STRIPPED; + else if (arg->status) + goto drop; + + if (skb->len < sizeof(struct ieee80211_pspoll)) { + dev_warn(wvif->wdev->dev, "malformed SDU received\n"); + goto drop; + } + + hdr->band = NL80211_BAND_2GHZ; + hdr->freq = ieee80211_channel_to_frequency(arg->channel_number, + hdr->band); + + if (arg->rxed_rate >= 14) { + hdr->encoding = RX_ENC_HT; + hdr->rate_idx = arg->rxed_rate - 14; + } else if (arg->rxed_rate >= 4) { + hdr->rate_idx = arg->rxed_rate - 2; + } else { + hdr->rate_idx = arg->rxed_rate; + } + + if (!arg->rcpi_rssi) { + hdr->flag |= RX_FLAG_NO_SIGNAL_VAL; + dev_info(wvif->wdev->dev, "received frame without RSSI data\n"); + } + hdr->signal = arg->rcpi_rssi / 2 - 110; + hdr->antenna = 0; + + if (arg->encryp) + hdr->flag |= RX_FLAG_DECRYPTED; + + /* Block ack negotiation is offloaded by the firmware. However, + * re-ordering must be done by the mac80211. + */ + if (ieee80211_is_action(frame->frame_control) && + mgmt->u.action.category == WLAN_CATEGORY_BACK && + skb->len > IEEE80211_MIN_ACTION_SIZE) { + wfx_rx_handle_ba(wvif, mgmt); + goto drop; + } + + ieee80211_rx_irqsafe(wvif->wdev->hw, skb); + return; + +drop: + dev_kfree_skb(skb); +} diff --git a/drivers/net/wireless/silabs/wfx/data_rx.h b/drivers/net/wireless/silabs/wfx/data_rx.h new file mode 100644 index 000000000000..a320cd858273 --- /dev/null +++ b/drivers/net/wireless/silabs/wfx/data_rx.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Datapath implementation. + * + * Copyright (c) 2017-2020, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_DATA_RX_H +#define WFX_DATA_RX_H + +struct wfx_vif; +struct sk_buff; +struct hif_ind_rx; + +void wfx_rx_cb(struct wfx_vif *wvif, + const struct hif_ind_rx *arg, struct sk_buff *skb); + +#endif