From patchwork Mon Sep 20 16:11:28 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: 12505845 X-Patchwork-Delegate: kvalo@adurom.com 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, 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 76B87C433EF for ; Mon, 20 Sep 2021 16:13:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E14960F58 for ; Mon, 20 Sep 2021 16:13:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242927AbhITQOq (ORCPT ); Mon, 20 Sep 2021 12:14:46 -0400 Received: from mail-bn7nam10on2065.outbound.protection.outlook.com ([40.107.92.65]:4704 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S242488AbhITQOD (ORCPT ); Mon, 20 Sep 2021 12:14:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XfisY/rp0PhYT9gOpFjuy9Uk045UHLNEdDKWApYT0wziqgtjmG5Z8+Qcjuslxmv3Y3g9QfHcqBpfY4l5012hG3pyUoClzXVLNX4v/qKx4TNwK6QgXQoDtKAAj6gNb7IaO/J7MAg/yrbNH1eCEfF2VOxHrZppFHhVx/+FhqCskWXhoHX7sYZxnGWE4T0ucG8uBDCEBb7+ZHjtmRkIgSuKeNIy8tAFUbvFToEzXPG3AScZmQ8IggWboeKazCynfuPrawqiS4nZlgyvFmFYJS82OIicaQmgp4ZzI/h6B/tJ0C7M31EBKRquWbAxPUuOXicsVlG54U0zsYYYOgLfAZlgfA== 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=k3XEYUcEa0xsp4UHlp6XIp+URFi0TcTtaKyHSEe0NlUrYuqkCUXGvPVP2CQlewCy42JxbNbh+7yFt/WCE1adR+l9bycBlsUvQYasE9mBCu3eTMQmEFLkhuY4SCtYTnd7+nV4UWWwvlRN++f0IA/G0eq9dHPWuBMif3oUfrJU8N6tig9DGNA8dhndGrB0zqrBreR1Ux+NSZItkFRwhkIWAMcGOy/bPJ8k4OotRoRbHTXpRSiBpbkrE/piBL7H5tSrVKnbm8KjNoJE9wMzpqDuaQyAVzqilxj/rTVCz5r6pM7QU+FLUHkViLTOZK523f8k4k9dRsTDC0vpyl9DdCqYvw== 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=SPsjqo2sYZd4bNRpR6HnYIRLWBSvKdAQjXeWap5SFA27cVHv/f5Em8ttYqc9fbzTcnxKCuT2SD7ulRwi95yCiX1f/pv3y8d96xZ2mtjAb1zwFCv5iV9meXf48IKMPNbpD3bf3o35hKoRLAkQF7vDy7iTm8OImXaWeQF8JLkeoY0= 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 SN6PR11MB3168.namprd11.prod.outlook.com (2603:10b6:805:c4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.18; Mon, 20 Sep 2021 16:12:33 +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.4523.018; Mon, 20 Sep 2021 16:12:33 +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 v7 16/24] wfx: add data_rx.c/data_rx.h Date: Mon, 20 Sep 2021 18:11:28 +0200 Message-Id: <20210920161136.2398632-17-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920161136.2398632-1-Jerome.Pouiller@silabs.com> References: <20210920161136.2398632-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: SA0PR11CA0064.namprd11.prod.outlook.com (2603:10b6:806:d2::9) 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 SA0PR11CA0064.namprd11.prod.outlook.com (2603:10b6:806:d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Mon, 20 Sep 2021 16:12:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5ba37bf1-be34-434e-c9a2-08d97c517443 X-MS-TrafficTypeDiagnostic: SN6PR11MB3168: 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: qMZLNYJbLXeRkBoW1R57FH4pVX+Hd+rxAys2z6z6YKGPERJHEQf9GRNiWRkuUQE2aicstgeBbGlVa1Ts59kIGQJ+/aEznqUcGUqDxj/nCteBG2SK3VCn/ct7JJBVFPydJ2dbRPvUJg94QVlLZm9U5WZc7YsH53nfOJk03WonuV5+spz+94Qk/WymUeHmcosK7d6NuS/PO5cEGFyxJWEGz14zDVeBKi2ZVfq8UkCscmONgMYRwzU0wtqReCaUWEVA+X6HCgxlFgJP98bn7uE414es6GtlZabgzL/K+FOwB8LK0MIP5Sg0Cchrh0zD/uByNmewBlmVBJFwvL/v1oPmBgFGpQCwESdXQctdmZ23EcaYXFGoO6TwckinBxyGeo+IToWh0SMuRtFRhgrCRquhMYR3jPudOPhHaxE3tpEnk0Nu6HqtQwnDIp/Kb7u4vxQjU/KK+udQ3jaJp1QGA60nNlbKcFRIw+fSrCU3202x6kP2yo/zrAZiteDUjPkWPprLDA++2L/f8NKFmnqOg3Y0gfE09V/bdsLWDFsrg3tqTMTX8kLl5kyzqeT/XRZJkbr+9HFZT5r3MGmSkRcg5MpL8AX/ervVJTPHLR1sbZ/xQMz5LtEqWd8d4ZdKR0RYKvuuUBfzIfHmjp9ElzmyRUSJnQ== 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)(86362001)(1076003)(6666004)(54906003)(5660300002)(8676002)(6916009)(2906002)(38100700002)(8936002)(107886003)(52116002)(186003)(66946007)(6486002)(66476007)(4326008)(36756003)(2616005)(508600001)(7416002)(66556008)(7696005)(316002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y9XphkNrew3dqm8kmObPi4QupnJb8i63DfrzvMPojOf2iDsLAKdOK/Shz6Z4bOB2BpU/QsC+7uY810BEKlOFpCJTbI0P+DSNdS7X70ofIE5mcxi6Kpcx/PC86AGH+2rj0LzuqTLZqxgt3yZAENO+x1QqVoN2biuVGkA4H2ffxAYlq2D/zkOATmItWxETEjLgqSCs2Y926VtG+iF71jtl87cdE4UZzMrNZMi16HPU6hrV/Nx5EOWeskESMjV7FCn68izAUCIUmhME1qIvlbRRslUyWSd4V2/O10qaIcOpml6EnhlsENN1rVM4O5GuO1MK0UyZNZ6LhIkImoedtUDIczlUy8mEsJUrmAjWY+Re1hFoBCFddlBw6wcBJ/pi+4LMoQzlIr9AZGnjyIf1mRnIefk/uXJbO60sK8A/BxYuaxNZI0bPGewfT+dL6fWDdajxua2b3YERtUmuxwUrm5HVNgmKw8M/lAF6yOXNnyd/ZphJAJNgg5OXnHVyIl9c2K7Nq287y96mN3PfhroBM5/0llZYk2GhHCn3iaZVJcKzy3+b7dGJV1zupo3OSrZvnNQSh/IJNOBTWHxvRrTKuZCaGmBdzQQMmb3yn91PveGSAzo8p1zRNZIl+UHN9mWdYBMj4IzR3j/u6/3APT4yU1Y6vooP27P7j2yYUjNlJlZliff3VbNhSQpt6l5/UAvK0iaMu0CGBb9CeXpfT/glNHF4ohE+Pk8L8wCmfsLshFREgW596yMeCRT9BVBfsowOpwslmiV/zTaYg4Bpf/EN57p7WXBlCBJOhndamZtt+grJLLC4ukH5ISGr4T0jKAhOJLvc X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ba37bf1-be34-434e-c9a2-08d97c517443 X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2021 16:12:33.7089 (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: QRi2RGdZU2KJSnZQQAVxcX70WmxLigozZaQNE0D6fij91QuYMJIRxduDLc04WEzC3Ng/Mt6NVrsaWPaMfRCDcQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3168 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..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