From patchwork Tue Oct 20 12:58:09 2020 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: 286534 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=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, 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 611E7C5517A for ; Tue, 20 Oct 2020 13:01:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BDF6224B1 for ; Tue, 20 Oct 2020 13:01:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="O1LJv+gY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407173AbgJTNBQ (ORCPT ); Tue, 20 Oct 2020 09:01:16 -0400 Received: from mail-bn7nam10on2070.outbound.protection.outlook.com ([40.107.92.70]:55456 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2406935AbgJTM7b (ORCPT ); Tue, 20 Oct 2020 08:59:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VBKrxSNFByEuXlR4jVMkNk+iBR6/jGqwzdG7CBRuN4PfvynaFuRxstTirL3RQeo/+oXj6VRP69c/Ct5dile2hJ6U8oCE9Lf2X+TxEyekUg3fcpeuGjXklgaDmmourReb6bqQc/cWL8RuRLojCKoaDrmyd/Jeqf0O1bqVVTqOKND4Uvwag1rmH7cpzhf8AX4U5jb8m/B3aZ4P+2FhVH52iUsBH3EMqHsDSrS7DN6XxDk47muBYDSyNoM0KyyCuchRcLGbRyWTDLM+RAosAxFHpkUdy0M7KHccm3+YVHIq2u8b2l+4xq3XGPkq88sISsdddAd+LokFTV/AuqxYgvcL8A== 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=edc12fpY37LlQK8Q6v4oXf+Qq4aIaiABOQkqEIdKP7k=; b=PzTeEfyyDMVZ9iZJH4K7JjBTI41Bgx8qV8H7qtyO1D9nv9YgBjWawIJiIgYiO7x7UDdWzbAxdGKpsOmWSRKspIMjMYlzBIBJnD0VrehVsVWP64XZR8ljTwk01HzZ13sGyeW6xjqXqtQVo965umZXz+S+9/XqhB+k3TIlNcJUGSIhgGQ0LnSXzCcu8SFB2OcgAA1n9/zG8/gK9eH0eygeofue/4ZpTc5RgH8kG+enO6NBl3HQSykj8rRGONgxbTA66fSmvuHhT7MDzqii+7OYy6Huzo2QJ0itwqRSoWKAX3nRiiqWSBn+ctoIw044AF4tuYZpBd1ygVz5APEfVe9lBA== 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=edc12fpY37LlQK8Q6v4oXf+Qq4aIaiABOQkqEIdKP7k=; b=O1LJv+gYWViv67UrGW9esi+OKxZ0up9LXHBePOxXVl52oe0y1a//NImUp/zkAjFxngcvbCdxQkkf0EOG6gvfYf36T/9kDs6SzCHIbGQ+BpJmSqFW+fSn1ynzc3V+ugOxf3zXXxr0sIp2evC+cklydUog8D6OxBBkMFMbpTCycWY= 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 SN6PR11MB3040.namprd11.prod.outlook.com (2603:10b6:805:db::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.28; Tue, 20 Oct 2020 12:59:19 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a%5]) with mapi id 15.20.3477.028; Tue, 20 Oct 2020 12:59:19 +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 v2 16/24] wfx: add data_rx.c/data_rx.h Date: Tue, 20 Oct 2020 14:58:09 +0200 Message-Id: <20201020125817.1632995-17-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201020125817.1632995-1-Jerome.Pouiller@silabs.com> References: <20201020125817.1632995-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [37.71.187.125] X-ClientProxiedBy: PR3P192CA0026.EURP192.PROD.OUTLOOK.COM (2603:10a6:102:56::31) 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 (37.71.187.125) by PR3P192CA0026.EURP192.PROD.OUTLOOK.COM (2603:10a6:102:56::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21 via Frontend Transport; Tue, 20 Oct 2020 12:59:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 12f95308-7941-4fcb-f079-08d874f7f527 X-MS-TrafficTypeDiagnostic: SN6PR11MB3040: 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: KcRdqoqU/0iaI68W2msOF8BaReA07LU8fcpgyMokzstvlmxbmfKIpV0z7fFHtoK4cnM4DKmS2F05ATSdDid9yO83RNv2bRgVoR9A8828UItvWM/iv7YSzOZO3AvejWB36gBxFEsn2lzPXxNmFPW0IqyTuLlY2Jwx8hSDwgeBVikWreVIqjZ4gaZGt212p6IIRw2pHZB7onOiAmL6iyDx7ogOsSW7S5q9kWHViEgkyWaiqBlWJP7r5TG/PExM7VjJSQF9gY9I7KHXni+ir4UDNYWLgBPICMN6XBuqTFWRd4cgtjNfs95ZAczgTFwiA2+Y/ks3jmaBt5tx6HUe45UVrA== 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:(346002)(396003)(376002)(136003)(366004)(39840400004)(4326008)(5660300002)(54906003)(478600001)(83380400001)(86362001)(316002)(1076003)(2906002)(186003)(6486002)(16526019)(7696005)(66556008)(7416002)(36756003)(26005)(8676002)(66476007)(52116002)(66946007)(107886003)(956004)(2616005)(6666004)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: feuMRTDd/sILu7mqCxcs8u0jHWg2zyhSJ4YJJEZ+fa1B5vxnp90M68olorI4FTnTpS9ZTANJPOt6A40OXN5DqITX1PMRW/5eOufibhCSYvRCE5aIjiRoQdAoxSMhOr/omKfLm4G1FKC51w+QY27OcWrDkWXGk+ttYxLV7P0wZuAToEn4ta5XHnwAoYpizAHgiHQwAzH8iAUx2GtAARsNSebjaNo2ko4fwZaw96wxpo47f/bcoLVwnUsmnDO9NQJ308/aIleDn5ySYd3k6qSUgDiMAJ827XBnuijtwHTDrPQxjICxrLyqVO73Z2+hfUpeFEEgnHiKz8i2WLObHwen1E4/ZVOrFhjZLPSCvR7XILHBaTzg6J1lJNAxm5KU4e1meUTXveA0/RjQrQXSJkXWE+9Y/ke7jNkgjokxtvvs1Mt+xof96Mfz9aq+PfNsAmdwRt53dpl5GRn0EVJqXmVU2GN1MX1byDpivm9zM6wRlfqb/EYBjrFunniL+Ehv8rwQEvR8q5yV4e7qjSociz/tNBy9ki4aaP6HssoiY4FqPa4ZCwzlIw5468ZIUaMAo15L3cn0J1P5yzCz1Qksfc8aQWvwKmR1nDi4bEd+8XDz2rDT/aVo4uJ0ECgrNR4hyoDAiYFVM6UyfDrR4DRB5TLu1w== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12f95308-7941-4fcb-f079-08d874f7f527 X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 12:59:19.6711 (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: hMeY4tFNvoaziDbf6IIPCT5qSdObHyNZy6zo2S+CvOGXVv/J/grBdSLIXCx2bu+NFUpd6lzUOuteaYqlfmy4Hw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3040 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Jérôme Pouiller Signed-off-by: Jérôme Pouiller --- drivers/net/wireless/silabs/wfx/data_rx.c | 93 +++++++++++++++++++++++ drivers/net/wireless/silabs/wfx/data_rx.h | 18 +++++ 2 files changed, 111 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..385f2d42a0e2 --- /dev/null +++ b/drivers/net/wireless/silabs/wfx/data_rx.c @@ -0,0 +1,93 @@ +// 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..4c0da37f2084 --- /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 /* WFX_DATA_RX_H */