From patchwork Tue Jan 11 17:14:16 2022 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: 531340 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DD2AC4332F for ; Tue, 11 Jan 2022 17:16:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344069AbiAKRQD (ORCPT ); Tue, 11 Jan 2022 12:16:03 -0500 Received: from mail-dm6nam08on2088.outbound.protection.outlook.com ([40.107.102.88]:54880 "EHLO NAM04-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1344083AbiAKRPa (ORCPT ); Tue, 11 Jan 2022 12:15:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H66fWT+z7L7rQiGvsf5uD+12aaFh5xPLCJ003QTwqgLCHHDU1gfca4S4bJymq1OwjJ4wKhHN1Qd6n/ceHcyjw4KgXBHvwQ/vDh4p2S+PpGlIhCGxDZ0/fZ8bONV53TSxf4mXg+FiujR5f4/kQfUvQ/tbXMNlGTZLbVw72zMCqb7gEH26xxQI4XoSl04jkg+kTrOWUzFiDpcd6PSjEtBcI/7gjXa+0LQTib5Cm1vHnnqoEVjehfRlo4itz9KwkMNydqXUzmtcZikn4svzUoXfl+EqMi0aA+PhDc1faVuVKV9qBsZMzj1rbRjEqxWLp/ok5jTyNbCMefCotpxhRNbIVQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Laa+FpIvHKHjdSdPVWts6lBXNK06rPxwoCWe69GbX7w=; b=cZ5kXiOkIGT9Mf480jAE0NyBhOj9vSxBURMwzXl0WZLNTEumPUYI9pxiD5SYOj+Ygrx2M0Cl5sEpCnGnA+KvZ/nbXu5ry/PaSULVkuy7RoYPR1MNI5IiLuX0ucxK3pU8PQTiP5nY1dyEfgFe5BoBOjfgtsPDdraXiSLtbI2PVLgjsOpEgCsGZj7+DcEx7HMljvFAf9xh0cHNVXV9B/JWFS1pQXPzQzccNyB3eBx3gxVQH1j8lKfoZ1IiUOq0498JUmh55w3fBzPPnR2ZlH76N60jBNLzj76mAN69eFta6AakIH5x2Vy4G9Ks2d9l8yLJMctPNxNwHXfVrlv2++0taA== 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=Laa+FpIvHKHjdSdPVWts6lBXNK06rPxwoCWe69GbX7w=; b=j9p8ep2rascBdDE45waMuUCFjEm3opUhAxhtk4Oqx/0riCZntnpLopLJGHP3Fh2NLOkRkfpIf0N7h/qJ8K2mQXtjrwAaFqB+266jvav1U7nLkV3pjkysbvcn4K7S1edqQ3cE7wgWk+JY+iozeH0CtzVssf3mR4uICWdHEBhzNE4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=silabs.com; Received: from PH0PR11MB5657.namprd11.prod.outlook.com (2603:10b6:510:ee::19) by PH0PR11MB5626.namprd11.prod.outlook.com (2603:10b6:510:ee::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.9; Tue, 11 Jan 2022 17:15:28 +0000 Received: from PH0PR11MB5657.namprd11.prod.outlook.com ([fe80::d031:da9e:71a:73e4]) by PH0PR11MB5657.namprd11.prod.outlook.com ([fe80::d031:da9e:71a:73e4%6]) with mapi id 15.20.4867.012; Tue, 11 Jan 2022 17:15:28 +0000 From: Jerome Pouiller To: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Kalle Valo Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "David S . Miller" , devicetree@vger.kernel.org, Rob Herring , linux-mmc@vger.kernel.org, =?utf-8?q?Pali?= =?utf-8?q?_Roh=C3=A1r?= , Ulf Hansson , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH v9 16/24] wfx: add data_rx.c/data_rx.h Date: Tue, 11 Jan 2022 18:14:16 +0100 Message-Id: <20220111171424.862764-17-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220111171424.862764-1-Jerome.Pouiller@silabs.com> References: <20220111171424.862764-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: SN1PR12CA0099.namprd12.prod.outlook.com (2603:10b6:802:21::34) To PH0PR11MB5657.namprd11.prod.outlook.com (2603:10b6:510:ee::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 469599b6-2308-4bb0-6234-08d9d525f6ad X-MS-TrafficTypeDiagnostic: PH0PR11MB5626:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:644; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I9D0n3tdHc+ykpzBdGXADWpQImsdyeUG2EyAzghxVS+7KFmZ4waOJS0KGRQ9CBL5kIIsi+lr9jTscUqyi4bAdYa8duJvlptscB3dU53UhlpIO1cqsXpw8ho+7dnxJjRnpiRf+y7Nr7aK0mRQA6ePxlrOJLBRg/fjBxUa9OvTa4OxbRcboFwjScqEYcEbd9N1maKa7naIsmCqq4b5cWDZuJAJOnDLRTWUUyvnBivQMz9iv+TwEbmRt3ZH3qfNI1xHV5y/01WK1+2cRINsqu52BvTeE+5jGn/Ia9YV+9FOF5UvSXbPEq43kmoIWNS2++0Fnb1EGwD2VzWLYVEqXWauMFfy/KTuEHyMsiIx5wVeHmFM+bqF8g3Ip+sAAjtJSqEG9asA791f1refqkOm3491PlaN6PGws8H48oVVI4mtHdF4bYSZQ9yDx1UKthA0YeOYKkvCHuE+YrZfaCDOFyZeeSkqNa0QbXq3ATCb3+StEgYSoUQJWJM9p1GI3qTjeRYGeyQEX40YLvzdKq0WJl8xgaesRaPXNAqHZVaAJamJJX3QJsr+vB+uFNNepx/0ysxIL1m5FXiU3kV6JkZocq14zmbYyvyNnsTsci7BDb4TSktzpzQLrJ+3MGOC9/cbcSHhd4fhPYLJNGfa48IC0bui0Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5657.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(1076003)(83380400001)(38100700002)(54906003)(86362001)(8676002)(186003)(508600001)(6512007)(6666004)(8936002)(6916009)(6506007)(36756003)(2616005)(6486002)(52116002)(2906002)(107886003)(4326008)(316002)(5660300002)(7416002)(66556008)(66946007)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?2yRI4Y2zDpUKNEhNc3rJ6dTxKLUq?= =?utf-8?q?BAnNHA2nkJr1zc/wkyS7TvykoeJLNWMyO6hG92157lc0Ta4hgn/qT3V2XZ+DnXRmA?= =?utf-8?q?B8KEa8WWtkFA1d3F5tXbCYlDX4l0NN/aPshbEJ1Hu53jx6PrVU3+PeK7c62dfTiaw?=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=?utf-8?q?v4gUg+klLGBF1OEm8UttGo+yLMWjPF3nk/uvj9PjDAJ42r4TWhSnqeX9qahmrn2Pu?= =?utf-8?q?Kih9qyhaQBKIMSTzDHZvWCQzKofsnBvMC61S3cE+6Q8HLp/pt8EBrE1AaBGoGM+mZ?= =?utf-8?q?UzCAKV7SnNleYfXYxx8xbb2d6skKP1sW2JLmNG+oBVSxfAM5bcX5QZPLE++XER4Av?= =?utf-8?q?WS5XJUiK4irRhcRkWxMh5FBMcNtdBbOr3k9VOZkJwG/LKYoYxIh8AoNFZF4Z/gVtd?= =?utf-8?q?ptSCCell7muC/EqOchJxFbOucgqOhYUh5p7E5mu3TlhJY6G5ja4b3Ko9bqK31WZiy?= =?utf-8?q?hScRHMZaRdP+RJt9RXMnzZWM5btIqtzmnkRCPZbWbvD4LvNHvsLBRppkgudvwUpKB?= =?utf-8?q?GFTbipSHKbmOu+KDUQDovcRMIqOuF3HRwRwc2DSW73iho6CALtRaVZyk5R3PBnk7i?= =?utf-8?q?u10GNlYnMgogFDxXSFPUVasbHp+wskPmXEJ7gGHE8vdYua4JuFkpvZOlsUXx3OQM5?= =?utf-8?q?bHNCveqdoxMwLEyunOhsHCj5DiGaxAEYy6YBH4t7tj38LOO+bAdkVGGpd+Yuu/4KD?= =?utf-8?q?Tp+dgNQ3Gs1DPgbYXg9VHuVDmxgvKg2Vzx6lNwiUQbDSyfYJOe58kU=3D?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 469599b6-2308-4bb0-6234-08d9d525f6ad X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5657.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 17:15:28.1824 (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: e48AqxcoyFEOGQtGD8EVq0jCPWuN7KkaY2U8KW3EXTp1U0M4OWdqVutkANg/dJy+QbPWGjLMUVh0oenPVsM/UQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5626 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 | 92 +++++++++++++++++++++++ drivers/net/wireless/silabs/wfx/data_rx.h | 17 +++++ 2 files changed, 109 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..a4b5ffe158e4 --- /dev/null +++ b/drivers/net/wireless/silabs/wfx/data_rx.c @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Data receiving 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 wfx_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..cf708f16d602 --- /dev/null +++ b/drivers/net/wireless/silabs/wfx/data_rx.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Data receiving 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 wfx_hif_ind_rx; + +void wfx_rx_cb(struct wfx_vif *wvif, const struct wfx_hif_ind_rx *arg, struct sk_buff *skb); + +#endif