From patchwork Tue Oct 5 13:53: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: 12536791 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99134C433EF for ; Tue, 5 Oct 2021 13:56:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 804C461074 for ; Tue, 5 Oct 2021 13:56:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236287AbhJEN6I (ORCPT ); Tue, 5 Oct 2021 09:58:08 -0400 Received: from mail-co1nam11on2066.outbound.protection.outlook.com ([40.107.220.66]:34049 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235601AbhJEN5U (ORCPT ); Tue, 5 Oct 2021 09:57:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FDlHdij7RDkbnu58uOt05LmpY9XFu8nwZGyBOpa3NJHuEmeakEIJlW5vnSIrwWapjm3clc+hqzSMKBlHBw8Se7+/MOMw1HXdtS3zAtHtio/RcgvuFWXRFHYMrOxjMfkM5J7WIgUPsmTTgQ3Avosvk9zExj8N3Sh9DhkeWaoZEOSHTcHvT8n/FzuFp9vvHwMjDc8YytQGJsEMAv30JqeEZF7qSEVjintP8d4ePRMeC24zr3q/cdNvFfpSF1oYxX/0UbbdahiMcERGVo2+PWwLmwpeCC8dpUgikeH3w+iMJnNs6WNNDWJlRrHBgcJlC8zRsosvOrhxHzRirVxRTM+9Vw== 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=GBnZqeb4Sp5OnrJs0hzKJp9ild+Ok2gpApXY2Eigxok=; b=fOpKEvroDUKwk9fYVFEilMTG5lo0XQabfyAibgtohev4tkj2IIUwVjUkV8N9JFwL1DhGnaIq2mWzFTFdItILyFbck595fDm9nserosqRpsuKWRvU3WodmNkiLZQSdm1w+BZoFhVfWHj9UUqMgJZNgyGDIRXSTReJoPsyTDccpL8c4LJ05Ldq7P+BF6QjMBWdDhLzMDpUnzO1Jj/fd+kpzGPb99p//lx0h5EVH54uXfTdslXBKuxvBrewKin8AcVM9kYoAmlWSKKRfL8LCJ9BiKi97jdBAbQvv84roa+bJ4QlkFYiPY6I262NTmOQ/VNwK/v2AK0GB1G8KvK2DnGnKg== 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=GBnZqeb4Sp5OnrJs0hzKJp9ild+Ok2gpApXY2Eigxok=; b=KP1LXav4edmWF50hu95lGhaOUCqj4ibdJCEgUyBTC2wSJ69yxbFnrSfsZnrvUuzxqwv6dr/rAPAAJuYEGWM9BiPwehbAtYDGFtaIrBcdL5QjopbYY95qKk1GncamHvG8JWt9BaQFonhHVnZuyNsx1ZSNS4av/K/qep3EVkbHD/0= 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 PH0PR11MB5657.namprd11.prod.outlook.com (2603:10b6:510:ee::19) by PH0PR11MB5627.namprd11.prod.outlook.com (2603:10b6:510:e4::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Tue, 5 Oct 2021 13:55:07 +0000 Received: from PH0PR11MB5657.namprd11.prod.outlook.com ([fe80::31cb:3b13:b0e8:d8f4]) by PH0PR11MB5657.namprd11.prod.outlook.com ([fe80::31cb:3b13:b0e8:d8f4%9]) with mapi id 15.20.4566.022; Tue, 5 Oct 2021 13:55:07 +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 v8 16/24] wfx: add data_rx.c/data_rx.h Date: Tue, 5 Oct 2021 15:53:52 +0200 Message-Id: <20211005135400.788058-17-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211005135400.788058-1-Jerome.Pouiller@silabs.com> References: <20211005135400.788058-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: PR3P189CA0084.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::29) To PH0PR11MB5657.namprd11.prod.outlook.com (2603:10b6:510:ee::19) MIME-Version: 1.0 Received: from pc-42.silabs.com (37.71.187.125) by PR3P189CA0084.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Tue, 5 Oct 2021 13:55:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 66df860f-d086-4def-e7bd-08d98807bd63 X-MS-TrafficTypeDiagnostic: PH0PR11MB5627: 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: 7VDFVPqTlHQXc2PWKoEmtF7w1OF9xpe9EPolVK1NchMnTIUcJenyhXZMD3YUUftiMM7uTV7e+Oo+X0hLsqJdsMrAVeKvy0Ws4B5feJlpHkYkz+/5PjOO998gzl2hfs+kF9q4iFeZSerVWUEWJ8e+AyNTrnLlIN2YqoUqI01pSP7JtRV0K5H3lwfAXbcLJfketpgMBs35XIB9ue/AijNOL24gM2sOZmWmhmO1qLLCj6UHrCuTJOmW3IO6nKCNQ4R9kzvDb859m55EvnqEt05rzFBXzp8KnMijuinPbzyJ4q2LmFeaw1XLENZmsXtVeEU+NsE0DVqyqug7Y8EuY9Ylst1eydHaER/GTnGT1GisoUvvcBwX6tYv6JkyAQJ/7xh9Uvx2ggbc0afQls1Egkcc3QXUFkbo8RSp+4liLY5HZtN3GpOoa/N0rZFF1z0CmS4EzsSStJ19J0CRx52aYDBi2RDqdBMl+otcgDYphybw3JUfZKjjOEH0UeYYJuSXqF7tjGI9e/jiwstCh5MoyVlJb090FfCW0TdyiUPzBYUj33xUigPrxPoA80AsTq0rFXRgkj5lxQG+dIG5fJYozyXszyJ5iLW6DXhUuy6IJXLp+nztCV5E7F5wNyLgeG6hT0lBpc+vb/DUXFl6cYTrvjkTQN1gAhKDnyTNFgQWtJWdvqqjdBbJG6x3DprIqrEFROctQOMystAdLl7ylvfUyRoYTg== 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)(52116002)(508600001)(8676002)(66946007)(66476007)(66556008)(7696005)(107886003)(316002)(4326008)(26005)(2906002)(6666004)(7416002)(1076003)(956004)(54906003)(5660300002)(2616005)(186003)(38350700002)(6486002)(83380400001)(86362001)(6916009)(8936002)(38100700002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?jzRRItc2g58ML2KMBBDWXWCBi5uN?= =?utf-8?q?uz7WTtu+rfe43QyQXno1RJzyeJADZXDGxh0mmt0ouZzIFPPNYoah6ZWealdQV9RWb?= =?utf-8?q?uRJkF0188dnprqiUMDHjIti5zoi/HDWnXsTeCIzvLOC9ziHYLMIUBYlH9u5tn521g?= =?utf-8?q?x3b9D4m47TymmhHWrbdLsEfFRECBu7v3HxS0aNSGN9M4AVii05dp7cCJITDnngNgi?= =?utf-8?q?j1ggZnMmq/avZKKRRihAIlJvCXIXpg3/jYCWfY+QL5i+NjouVwgpzZZPHrDpr65CY?= =?utf-8?q?tRwzoD1IVEARyjVU6soOzgrazNy0IHIc1NmerQu69kSOUawJ2pgt7ZJCQTsl3Ru5m?= =?utf-8?q?LNYl39b6eF8HhR00yCBPxmbdktw4Phnt9XLNho7Z1bGlXY9KRxCbgQuD5f94iAYUi?= =?utf-8?q?eZH+JhE8OVpzyX0qgziOr79/0PTDUUdf64j957vDlGrWlXUQtzZz7WJzWYGEBnu+j?= =?utf-8?q?S+wEe8LA7SDtqMNX3/OwTU+IG3vypUJfHEFDY1r0MXlzD8jElvkkFBFMqOcoUwMUh?= =?utf-8?q?s5UAATVFhcCVioqenmjf+MY3ZIeF927TesKoX61eI++AuWZZphI2TLG3jIQsEVM+d?= =?utf-8?q?GRA/lGuUsx7uEEvRWqSeF9X/N9YuzXIxoZ/6BDlysCk5zLxYLbwRhYmekJGUvwX2o?= =?utf-8?q?CYJSch2rmml83CV+5RGwsLXN6tlMDMiYANHsWFZCKyWUXN5JunBLr9wsOZW/KdR5F?= =?utf-8?q?uPcZ4TrJUPi6LwM9f186NTm7KFliwRV638ThrZKLORfAtOkzRPo3rOTAj9490vOBc?= =?utf-8?q?fBqDUkrlubaRKa5nnQ1b5FXnsLeTdIxPJ3iEkiC17u/UPzACAOJPeECAws8JF8m8D?= =?utf-8?q?kNuHqU5xgnXdxJ8uv/QGbif0m0r581JOKnLL+5QArSLw1bLrWBpeFB8nJnPlsGeso?= =?utf-8?q?geZsxcZSq3SIgKflq2dgIRjD4GpfzorDtqSSMqnPz3ECy7gz9bbW4Mm3fQrpRgRLq?= =?utf-8?q?2bRwKJ/nkmmCXteTq54H3YsuZtbb6eHok4zpGf8R5t4YstKknF0vSShWwub4vhWBx?= =?utf-8?q?gbFeQmDctL+V68IJGQs97W1XyOtbpW3LE7Vp9PB3f7/g01GXSm8ZygRLcMO5IOc8G?= =?utf-8?q?MOWNxBsy2Ej2ae6vCD48i0cjTaorNjSyzx2/v+gt0wO7l/seDBBcN7rXxhicvQZ4R?= =?utf-8?q?X5U6jABwnttOwGpW1wc6aAWmGHFGVI3K9WhHt0T22zMejHTmVvJ4HcqZjX03dkQyn?= =?utf-8?q?ZWN4zx294si1v5FPW9/KeUojE+EN53XD8VsqZ2ADc9PLg4OdGokFlxMt05WYtp0pY?= =?utf-8?q?PGW5YXK2F4UWgvIO?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66df860f-d086-4def-e7bd-08d98807bd63 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5657.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2021 13:55:07.7257 (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: FdWsucXwxYKZ5RB+crbgiiA06glB7mXTf+BLcl3TgSSOO1tssI/d6AyRWjkoSvkDDFB1GZGu9yrCsyL/JwhSzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5627 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..3fe67c4815e7 --- /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 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..7d77cdbbc31b --- /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 wfx_hif_ind_rx; + +void wfx_rx_cb(struct wfx_vif *wvif, + const struct wfx_hif_ind_rx *arg, struct sk_buff *skb); + +#endif