From patchwork Fri Sep 17 15:13:52 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: 12502471 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.7 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,URIBL_BLOCKED, 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 B4470C4332F for ; Fri, 17 Sep 2021 15:17:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E50160FA0 for ; Fri, 17 Sep 2021 15:17:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344029AbhIQPSX (ORCPT ); Fri, 17 Sep 2021 11:18:23 -0400 Received: from mail-mw2nam12on2053.outbound.protection.outlook.com ([40.107.244.53]:15265 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1344026AbhIQPRJ (ORCPT ); Fri, 17 Sep 2021 11:17:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kmsAJtoyMo0GdiZjNQ0ReX3kpOhEv5PfM/6qK20URHbU1raK+wvggeYWmaMiqMENWv46WvJzzZmcB2baWr1XBL4YdFbdeiqyC8Udgk/6eYluMpBUk9FOzh44e9M3jMvJYKhnyTJ4JtbAh8QBpanITwSVSZ637r4JgDtscJvF8IvoLZHL7eO7DH5oar+rH1LOKWRE8wkR4cdREjibndkwrba1pUxA+HazxTKDZ0DvTdNZPUDE39212amLGOgWyzjNk7a/OBm2Hsc03VZ7FA/PaKeHhFOQfAp8uWk+hmXoVi2/Z3ex2f2La6YleGQhlVgEEO2zMTRDoNb3+Dvt+6YldA== 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; bh=B060dwVEfeTW4dRn140ZNuQdsL6yUQFgWMlzSPffF14=; b=j2+mD2e3Arfr6Jj3p7eZPbFqdsg69wPrRRkJoe+shFz6Nz9YKIFExRIPtWfSDpQ7l4Lbsg/pUsl//SfGqdLfvUEyu31hFYVsiFJvY4wigTPNGv/5sqeZ7ZzuMTdSH6zahwJIRnmdrO49ol26MaLzySi+3iEuVKnL6qfes/WFwCG2eukDuQym5TpqCYT0q9AAhf53HtDnqUnYkuNSWMzWjMVjYa9R8eMOVUc5iwa0cA875X1S5hLmh8jOnFaF8jRpeYauzw3rDKb3Qy9ueOelMb34cv0S73hwZJS3RqHsIGZV+eIrVm4k3Aasjmgnz1vxKuV21t2zff0Rram9rzaYLg== 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=B060dwVEfeTW4dRn140ZNuQdsL6yUQFgWMlzSPffF14=; b=ZA3RtcJ/KXjB1HcrrdbOa/gv8DygjB6PoIcaJN7FAzJTz4QnOc09byZabP/GFD382LFEn1+HKYoObY/C4qlCenXUwkuW6BXK+BAvvWtp0diDbwolgJn72hRzqHci5iNEp9+NaHkfBxIa1RXImEmSJS6eQENkILq3fWfs0PafF1M= 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 SA2PR11MB4876.namprd11.prod.outlook.com (2603:10b6:806:119::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Fri, 17 Sep 2021 15:14:59 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::7050:a0a:415:2ccd]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::7050:a0a:415:2ccd%7]) with mapi id 15.20.4500.017; Fri, 17 Sep 2021 15:14:59 +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 v6 16/24] wfx: add data_rx.c/data_rx.h Date: Fri, 17 Sep 2021 17:13:52 +0200 Message-Id: <20210917151401.2274772-17-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210917151401.2274772-1-Jerome.Pouiller@silabs.com> References: <20210917151401.2274772-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: SA9PR03CA0029.namprd03.prod.outlook.com (2603:10b6:806:20::34) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 Received: from pc-42.silabs.com (2a01:e34:ecb5:66a0:9876:e1d7:65be:d294) by SA9PR03CA0029.namprd03.prod.outlook.com (2603:10b6:806:20::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 15:14:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ffa1fd2c-18d0-459f-16d9-08d979edea3a X-MS-TrafficTypeDiagnostic: SA2PR11MB4876: X-MS-Exchange-Transport-Forked: True 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: 59cEB7ArmhXp9LT2MQTSQZ3hW2YqPnMqnXUXb9VLr1AfnLwqCj+R3KQmO/dwzuIoH2hX0vQH+dd5aT4GvpCZQ4ghZEhjLUPeh2F31/wSnd6xFrZ9LFy+OQkmWpg17w7XhXFb4XFmYW4+0OSH9E16CzGnLQb6UWHQ6lB376v6sPAX7ZX2JunUpKFGqUdmhIgwikJhc6WDSh+YdYkJ4NdvMqZkW0ItvRThmayw1lI4i8EUsJjvZASD1A3j2VSD7RVe7tyaVRayrb51nviy0YGvWQDhRArPp5gsslVqXMQmCMU5zx8c1Fs+jAzVGOkxUu/+HPkyLGu0v4IldpOuR9tf5TxihsaiCgzGiHkUkeqP6U7KFWbxpFeAQSDE4ETN2D+a8yhP7/zPsTxZtZg9TetSnPPRn8Zyy7pXUFUAKGqAf2BNmGTC4CXzBjujHImZDODKrJsp1FH95fdY4+0NIGkq3RZ7BC1ECtTl0jkBGfWZo49RIHRWYXRrV6+KMVQIQwcc+TldvY4G1YxVu6xmHMBrOI5HmoQ6ga3wE7p0KWlSYNqhG9C6b0zm978joFig6V8Y8ZqnSN2utZ8aWwwNImLIQX7gu/CpFjWPUDq4d7kDmb0FtEjw6j7KhbTysHxrTrRL1nO+Xc6BY/yydI+zPxnkfQ== 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:(366004)(83380400001)(1076003)(6486002)(38100700002)(107886003)(36756003)(8936002)(2906002)(7416002)(54906003)(5660300002)(186003)(8676002)(508600001)(52116002)(7696005)(6916009)(66476007)(66946007)(66556008)(2616005)(86362001)(316002)(4326008)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?TLGoUd4f+laJ7THmjFdRkzsY1mIU?= =?utf-8?q?qGVt0UGTYOvyeoClLBuwzFd6uikO16rtnPKbbpPb87TdlZvnbewxcnHW2PSVA9kPS?= =?utf-8?q?YJrx0HtFekWiYDwVzMnOq+gqhE1go00iSXIO57m9VTeFcIKxPx53QsFlN4IyCdUL5?= =?utf-8?q?JRqzuTIMHEXb+pBYGfYQcp2Br5lAQGV6BzEz4yRwt/ytlYBrLSAXiyei5rpPjO5Hj?= =?utf-8?q?0U12FwErfGOoybrgcLYz21/XbF7LGcNhK2ANZjEfzJ96M2z8BYpr8TOtENhWlwLHC?= =?utf-8?q?/cpyID3zIgIySFisXV0/e3JT8GNLjferwoRh+bIqph1Bd0NAcV8JtRVwDTDytxciU?= =?utf-8?q?xQxINMKkXprsnY+FInT0zKGvE0f9XB5HZtMaWJxdjctJeZH7HxzlQ6Ai9Z53o1JGI?= =?utf-8?q?vYEiEBt05Anl5m1ufvKL1jdjZHN8j81FQWXjK5Z54h28HguWbt9tpEcnj+jjlzmXH?= =?utf-8?q?MWAa0i3iwKfqYWwSQjjtwVjc/hmEEzqkJTcAcF4BoTdp+Mcp8k5w8tknnFhLLTNVJ?= =?utf-8?q?AgjYCGvv55otjSAjPAlrCYMjxdEqruKgvcjloicwEZpTC+mevY39vVd9lgoDR+g7f?= =?utf-8?q?H744Wwlu3/Zkt8SWTLa2k2j+yeNcBqCmz4YwCYZ0bnpJeZTUHpR0Hmz1NUbAQqzGv?= =?utf-8?q?EppUnteWvYEtV/MUZi7JlL+WsbVhBVWM4OyhRJ7CMGpkQWdzhA1eweYds3AwibZ2Y?= =?utf-8?q?Al09MZU4sMKoErYVWTxiCXL0xhyhYSAs/TnVajLvLwjgtYNOCe8kKaBv+QpQzUR0Q?= =?utf-8?q?B6s1EhT3ON++9rHDnzaHetrL/J3Cp7mf5O/5hg+52Qy2e3h9x3sBiU0i1NL1xRUTQ?= =?utf-8?q?Y/Owp4UTX8KoT91Fkxq1Nd0kESjIvwOWtoUYEFereENFKVdQ2FTzuSxNb8WmRHX9M?= =?utf-8?q?/5pgQK4+/X63UxIKCx2haLCsbBShJvzsIJ2c9jdpabRZPpl8BbKB0l0D4GTGnExMH?= =?utf-8?q?m8YjNqmrVIUlCk8qUEtKscWV3TRwbgbwHhTtdeCpUXJK2o5kNVvdu8FrEmmMis2mZ?= =?utf-8?q?1YgYAuWXbiDJLARrFclORrtI6ZSa07nUv74zlcguSEm6kqVf/CkdGj9V08eanWkuP?= =?utf-8?q?NeJGMELTdL+dJSt/qQUU9Am9ngIdqGyvfK/kqvO9NIc+AQFxmuxp44TNqOxBUxBj6?= =?utf-8?q?6rXHh2J0tibZ0lL1G7H0hnJj3kOtTELgrwuarTZBiJyfacqMa8/QdYDslunCT3ETD?= =?utf-8?q?sE3IsVyh1Pv0i/pNBes2DsM5HK7HKWfk2uRJ7xHCo66FCsurjH4oTwM1bzItQxSAR?= =?utf-8?q?K3U3C1sKEI/uz3DfIM7FARbX5jGR6s1I9mzT1+QQIaZzSg3RcKy+8tjF0fZSXafOu?= =?utf-8?q?eQ763IMgMjcv6CS?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: ffa1fd2c-18d0-459f-16d9-08d979edea3a X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 15:14:59.5720 (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: 6ox7nSdFo/MGYAvBSyQJX3NpePNA5L+fXsTkOd4MVaqf06N5EbvFCo4wpuU0zpTQq9ci4lOVNEhArAgdgoRq8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB4876 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 | 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..bfc3961b7b89 --- /dev/null +++ b/drivers/net/wireless/silabs/wfx/data_rx.c @@ -0,0 +1,94 @@ +// 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 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..84d0e3c0507b --- /dev/null +++ b/drivers/net/wireless/silabs/wfx/data_rx.h @@ -0,0 +1,18 @@ +/* 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 hif_ind_rx; + +void wfx_rx_cb(struct wfx_vif *wvif, + const struct hif_ind_rx *arg, struct sk_buff *skb); + +#endif