From patchwork Wed Jul 1 15:06:57 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: 1320605 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=silabs.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-silabs-onmicrosoft-com header.b=YFJM2Fh7; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49xl3Z3yXyz9sTb for ; Thu, 2 Jul 2020 01:08:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731837AbgGAPIY (ORCPT ); Wed, 1 Jul 2020 11:08:24 -0400 Received: from mail-bn8nam12on2056.outbound.protection.outlook.com ([40.107.237.56]:52640 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731787AbgGAPIM (ORCPT ); Wed, 1 Jul 2020 11:08:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A2avvME+nOjwc5jQtUPyVKwhvWFVVV0+QfXeRFWMGyJNPKWTG4bLbsyYCs7bRr48TXWOXI7zPJlk8N7fDe7xm7R4YMS8S+BuScPc47Mza3dHsPQ0cduhwI0p42ynUjWO9WVXuKfjvfKxxWsJ4+aOajQeLkcO2FQQk7Q+26XUe2Trjcoi7wAh7YvwlqXmxteCF1nBuIgUjRo0v4bFDZdFMEBZFywgUw4uo3eJ7tnIYn6y2D3crcM3nvGsGF/y/25Q4ob+cC1CkYmBDzYuIanRw1AQ63znct6NFRgvup+zinN5KTIsYBrKBJYSASchS/DQTi7+xHsfE/p+P7jGZ8vw2w== 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=VNBkTpAfHPJyt4bgHDYKWshZzX+zwJScGMgyhbBEL+U=; b=JMzSLwGYV2G8L3IqmZIu+qD/aa/zyShMJyuNMkQdI8AHY/HBdXoaXyEr3wioas7p2u13Q0DD6/paTsQkQdYXv6NnypQ6QiKXYrF/XfQxIovZ63CKbFCfIsGnQMnW7iD/HJIxv2z0ZqVRDdzVnO2G/NPWD8afMsh4U9z/QSRQPOhe/yOldM2jafmqUr8Q6p6hbSwcCWNYsMDnq4KsLsrS74sB1tyu53H4wl/Zhru2BtKStX5cuMaD0ul3npBA04+Dkkl5S/bdn70B0o9OqzfA8Q7HSjuuFloGzP+rnSSwLu/gsOVKgaBkUZeNIVDYp7eBcQVte873eSqwT2GCr2+QDQ== 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=VNBkTpAfHPJyt4bgHDYKWshZzX+zwJScGMgyhbBEL+U=; b=YFJM2Fh77eSLEKDyUvZLvVwWoTsVe2c71fdhu9TALpH7bbYZifHw9hRBLrGQC1CPGZWqfSJpd9fLgq/YgsUL1VtCGg7zjk3CR5xms7r/Tgp6YC+NBO8+PMJiLx4KZpaphH9HVxYIulzFu75BwWMwbL5Lkxzf5yRNqHjbxQumHhE= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none;driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SA0PR11MB4736.namprd11.prod.outlook.com (2603:10b6:806:9f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22; Wed, 1 Jul 2020 15:08:05 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::c504:2d66:a8f7:2336]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::c504:2d66:a8f7:2336%7]) with mapi id 15.20.3131.033; Wed, 1 Jul 2020 15:08:05 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 03/13] staging: wfx: correctly retrieve vif ID from Tx confirmation Date: Wed, 1 Jul 2020 17:06:57 +0200 Message-Id: <20200701150707.222985-4-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200701150707.222985-1-Jerome.Pouiller@silabs.com> References: <20200701150707.222985-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: DM5PR07CA0143.namprd07.prod.outlook.com (2603:10b6:3:13e::33) 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 (2a01:e35:2435:66a0:544b:f17b:7ae8:fb7) by DM5PR07CA0143.namprd07.prod.outlook.com (2603:10b6:3:13e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.21 via Frontend Transport; Wed, 1 Jul 2020 15:08:03 +0000 X-Mailer: git-send-email 2.27.0 X-Originating-IP: [2a01:e35:2435:66a0:544b:f17b:7ae8:fb7] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 61ce94be-83b0-4da4-f8f4-08d81dd08e0d X-MS-TrafficTypeDiagnostic: SA0PR11MB4736: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 04519BA941 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u4mJ4NYYmaXHrt15/WNuOkzCXubx6oocPAH7bCPe1ug/fn2oKT/onndBGn84+qHNKJOHXTMvdAOKGvTHQkCYpVVkZP21su96cfwpL19RXkiqixJdHeJc2fbDvMmVfsh/0tGNkIBsWsqMY+VHGv/2jHvRwCBP9aMwpBrq0GOBa9Xy3YsslGk6EOzYv0AuU0WDb9yotWYaxIsempSUrGRs+ebFWevooezR1Mc6JWVPzjFSknY50hhxRPNt2+28arsWKgYIoDsQI7ZxAA953WTv+L1lHt4mp7C/AhWpppShDeyc2Ukag7SChPmHnklqzGlx 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;SFTY:;SFS:(39850400004)(366004)(346002)(376002)(396003)(136003)(5660300002)(6486002)(86362001)(6666004)(66574015)(36756003)(2906002)(186003)(83380400001)(16526019)(8936002)(66556008)(66476007)(107886003)(4326008)(8676002)(2616005)(1076003)(478600001)(316002)(54906003)(66946007)(52116002)(7696005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: mjI630kvkSYorw3tnOeuKGU7eStzgRRg4/EW+6PH98hsIdv0D5pHywFpyNHNYa1n1tuZDHYMx3NvJXsKnu84DhzyqhNMyn2CcMmyvoGnVnvh0Ldo3f6nH8AA0gaL2DZSRmkGw4QS8/LmdRLlhOI3Jfrb7VDeU5X+ac+cJ3PIefJZoF35QFi33aejOzsHYysQR9ZKzq0gzezNZ56d4WDzD5rhVrxplNGmfFZvQu9YnDOxRTUjHRlwdyeK2RXHT/yoKTkjOuWorlTiCN30Kd8Wnv+Rh7i8RbrYDX99trJOIlVlWw2xlWJrpNlwZaFgCXWOjbA/xn80EI0MM5E8L0TTpiLAe27zZay6W+h0mw6txde7J/hAlCL4js9ufDqeHUWEaD97mFaeRQnXackG0ZvIoJeIM744mdYUrQ435j2RXXJMB7uRe7sL9ZRZ2RaRpqyg1z9rPehQ6ZxPvbaFhPhY3PfftXOnBmU0fZleGyEHck/E3OBDnL/BNLtAr1tyZF1vCFpPa/7uvxay/YuFNTI/0DHnUxLeyoHjakHAR1m8sU0= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61ce94be-83b0-4da4-f8f4-08d81dd08e0d X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2020 15:08:05.3094 (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: KczwUX4CbmEKYaYB0RNHV6NudcCe0dvswV6WfXWsYGRYEKA8dIca10ChxZjA3W/7bj1TFkmtNLEidakm+6+P3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4736 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller The device is able to send multiple Tx confirmations in the one reply. In this case, there is only one vif identifier for all the confirmations. Unfortunately, to generate this kind of messages the device squashes all the confirmations whatever their vif ID and use the vif ID of the first confirmation. So, the driver cannot rely on the vif ID mentioned in the header. Fortunately, using the packet_id, the driver can retrieve the Tx request and the associated vif. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/data_tx.c | 16 ++++++++++------ drivers/staging/wfx/data_tx.h | 2 +- drivers/staging/wfx/hif_rx.c | 14 ++------------ drivers/staging/wfx/queue.c | 22 ++++++++++++---------- drivers/staging/wfx/queue.h | 2 +- 5 files changed, 26 insertions(+), 30 deletions(-) diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index ce3048c94961c..dcec722afb174 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -533,25 +533,29 @@ static void wfx_tx_fill_rates(struct wfx_dev *wdev, dev_dbg(wdev->dev, "%d more retries than expected\n", tx_count); } -void wfx_tx_confirm_cb(struct wfx_vif *wvif, const struct hif_cnf_tx *arg) +void wfx_tx_confirm_cb(struct wfx_dev *wdev, const struct hif_cnf_tx *arg) { struct ieee80211_tx_info *tx_info; const struct wfx_tx_priv *tx_priv; + struct wfx_vif *wvif; struct sk_buff *skb; - skb = wfx_pending_get(wvif, arg->packet_id); + skb = wfx_pending_get(wdev, arg->packet_id); if (!skb) { - dev_warn(wvif->wdev->dev, "received unknown packet_id (%#.8x) from chip\n", + dev_warn(wdev->dev, "received unknown packet_id (%#.8x) from chip\n", arg->packet_id); return; } + wvif = wdev_to_wvif(wdev, ((struct hif_msg *)skb->data)->interface); + WARN_ON(!wvif); + if (!wvif) + return; tx_info = IEEE80211_SKB_CB(skb); tx_priv = wfx_skb_tx_priv(skb); - _trace_tx_stats(arg, skb, - wfx_pending_get_pkt_us_delay(wvif->wdev, skb)); + _trace_tx_stats(arg, skb, wfx_pending_get_pkt_us_delay(wdev, skb)); // You can touch to tx_priv, but don't touch to tx_info->status. - wfx_tx_fill_rates(wvif->wdev, tx_info, arg); + wfx_tx_fill_rates(wdev, tx_info, arg); if (tx_priv->has_sta) wfx_tx_update_sta(wvif, wfx_skb_hdr80211(skb)); skb_trim(skb, skb->len - wfx_tx_get_icv_len(tx_priv->hw_key)); diff --git a/drivers/staging/wfx/data_tx.h b/drivers/staging/wfx/data_tx.h index 54fff24508fb9..b1727ddecd5e2 100644 --- a/drivers/staging/wfx/data_tx.h +++ b/drivers/staging/wfx/data_tx.h @@ -44,7 +44,7 @@ void wfx_tx_policy_upload_work(struct work_struct *work); void wfx_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, struct sk_buff *skb); -void wfx_tx_confirm_cb(struct wfx_vif *wvif, const struct hif_cnf_tx *arg); +void wfx_tx_confirm_cb(struct wfx_dev *wdev, const struct hif_cnf_tx *arg); void wfx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u32 queues, bool drop); diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index bb156033d1e16..e3ebd910fabfd 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -63,13 +63,8 @@ static int hif_tx_confirm(struct wfx_dev *wdev, const struct hif_msg *hif, const void *buf) { const struct hif_cnf_tx *body = buf; - struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); - WARN_ON(!wvif); - if (!wvif) - return -EFAULT; - - wfx_tx_confirm_cb(wvif, body); + wfx_tx_confirm_cb(wdev, body); return 0; } @@ -77,16 +72,11 @@ static int hif_multi_tx_confirm(struct wfx_dev *wdev, const struct hif_msg *hif, const void *buf) { const struct hif_cnf_multi_transmit *body = buf; - struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); int i; WARN(body->num_tx_confs <= 0, "corrupted message"); - WARN_ON(!wvif); - if (!wvif) - return -EFAULT; - for (i = 0; i < body->num_tx_confs; i++) - wfx_tx_confirm_cb(wvif, &body->tx_conf_payload[i]); + wfx_tx_confirm_cb(wdev, &body->tx_conf_payload[i]); return 0; } diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 6069143369f30..678f622639093 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -138,30 +138,32 @@ void wfx_pending_drop(struct wfx_dev *wdev, struct sk_buff_head *dropped) } } -struct sk_buff *wfx_pending_get(struct wfx_vif *wvif, u32 packet_id) +struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id) { struct wfx_queue *queue; struct hif_req_tx *req; + struct wfx_vif *wvif; struct hif_msg *hif; struct sk_buff *skb; - spin_lock_bh(&wvif->wdev->tx_pending.lock); - skb_queue_walk(&wvif->wdev->tx_pending, skb) { + spin_lock_bh(&wdev->tx_pending.lock); + skb_queue_walk(&wdev->tx_pending, skb) { hif = (struct hif_msg *)skb->data; req = (struct hif_req_tx *)hif->body; - if (req->packet_id == packet_id) { - spin_unlock_bh(&wvif->wdev->tx_pending.lock); + if (req->packet_id != packet_id) + continue; + spin_unlock_bh(&wdev->tx_pending.lock); + wvif = wdev_to_wvif(wdev, hif->interface); + if (wvif) { queue = &wvif->tx_queue[skb_get_queue_mapping(skb)]; - WARN(hif->interface != wvif->id, "sent frame %08x on vif %d, but get reply on vif %d", - req->packet_id, hif->interface, wvif->id); WARN_ON(skb_get_queue_mapping(skb) > 3); WARN_ON(!atomic_read(&queue->pending_frames)); atomic_dec(&queue->pending_frames); - skb_unlink(skb, &wvif->wdev->tx_pending); - return skb; } + skb_unlink(skb, &wdev->tx_pending); + return skb; } - spin_unlock_bh(&wvif->wdev->tx_pending.lock); + spin_unlock_bh(&wdev->tx_pending.lock); WARN(1, "cannot find packet in pending queue"); return NULL; } diff --git a/drivers/staging/wfx/queue.h b/drivers/staging/wfx/queue.h index dfbbe4b111113..22d7c936907f4 100644 --- a/drivers/staging/wfx/queue.h +++ b/drivers/staging/wfx/queue.h @@ -35,7 +35,7 @@ bool wfx_tx_queue_empty(struct wfx_vif *wvif, struct wfx_queue *queue); void wfx_tx_queue_drop(struct wfx_vif *wvif, struct wfx_queue *queue, struct sk_buff_head *dropped); -struct sk_buff *wfx_pending_get(struct wfx_vif *wvif, u32 packet_id); +struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id); void wfx_pending_drop(struct wfx_dev *wdev, struct sk_buff_head *dropped); unsigned int wfx_pending_get_pkt_us_delay(struct wfx_dev *wdev, struct sk_buff *skb);