From patchwork Wed Oct 3 07:48:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10624379 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F16418A7 for ; Wed, 3 Oct 2018 07:49:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12830286B1 for ; Wed, 3 Oct 2018 07:49:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 065F2286B9; Wed, 3 Oct 2018 07:49:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 188B5286B1 for ; Wed, 3 Oct 2018 07:49:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727315AbeJCOgT (ORCPT ); Wed, 3 Oct 2018 10:36:19 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:50957 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726807AbeJCOgT (ORCPT ); Wed, 3 Oct 2018 10:36:19 -0400 Received: by mail-wm1-f66.google.com with SMTP id s12-v6so4683309wmc.0 for ; Wed, 03 Oct 2018 00:49:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7OFPf2RkG3iXmKd4QFxolPPMkeP1epF7OjTw9KYp3nA=; b=De9ZOIEcHSoYNxnLB52JQkKbF6XOT0DKrIHFofzA3C7cv3jQ++BZzRvDc6OhNGHV1f N65f4Hp9cj2JRYtk4fxKs6Qst+iSxkfWWkmMtHlRBpgI+no50N8QdfuoKrZrDccyYX1B MMsFM55XfwtprAKP3gbM7ZyJP9UfiFE62W+Rl7a/CXHIUe1zEQD4YhaUSdnKYnyjYFZ8 b2r7VvfpKSW3qXF1+LSidO8zYmjCnArmi71h8QWTYn/6jpA6MbsMQBzZS8iqqUyQDfzW otrbKO6M5vB/7gho+TOtw5w9rf0n2UY5Mc6dgift6lSPQ5y7TSz1X/+U5vXCKZNWXswp u4Ow== X-Gm-Message-State: ABuFfoifm6liqthCJOgnqoLPKIzQi2rKZXv+sHg0Q8myqICjAC5SlEOS 0FMqf5FYq7kk18I/nYirvvj+1Lv1RSI= X-Google-Smtp-Source: ACcGV62qufn9J/fOMctMiDr0UlJ7Csmmy1Ea3vb3srwDtRfJqSF3ZaYNWrkR9WaB03zMv+WOXyxtYQ== X-Received: by 2002:a1c:a683:: with SMTP id p125-v6mr576730wme.24.1538552942866; Wed, 03 Oct 2018 00:49:02 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id y3sm421878wrw.11.2018.10.03.00.49.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 00:49:02 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org Subject: [RFC 4/9] mt76: move mt76x02_mac_poll_tx_status in mt76x02-lib moudle Date: Wed, 3 Oct 2018 09:48:46 +0200 Message-Id: <771df821d12cf2659f2284915e4fa3237a8bfa73.1538552703.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move mt76x02_mac_poll_tx_status in mt76x02_mac.c in order to be reused by mt76x0 drivers for irq unification. Moreover introduce mt76x02_trace source file to define mt76x02 trace points Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/Makefile | 3 +- .../net/wireless/mediatek/mt76/mt76x02_mac.c | 33 +++++++ .../net/wireless/mediatek/mt76/mt76x02_mac.h | 1 + .../wireless/mediatek/mt76/mt76x02_trace.c | 23 +++++ .../wireless/mediatek/mt76/mt76x02_trace.h | 98 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt76x2/mac.h | 1 - .../wireless/mediatek/mt76/mt76x2/pci_core.c | 2 +- .../wireless/mediatek/mt76/mt76x2/pci_dma.c | 2 +- .../wireless/mediatek/mt76/mt76x2/pci_mac.c | 33 +------ .../net/wireless/mediatek/mt76/mt76x2/trace.h | 55 ----------- 10 files changed, 160 insertions(+), 91 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_trace.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x02_trace.h diff --git a/drivers/net/wireless/mediatek/mt76/Makefile b/drivers/net/wireless/mediatek/mt76/Makefile index 09c90eef61a4..9b8d7488c545 100644 --- a/drivers/net/wireless/mediatek/mt76/Makefile +++ b/drivers/net/wireless/mediatek/mt76/Makefile @@ -10,10 +10,11 @@ mt76-usb-y := usb.o usb_trace.o usb_mcu.o CFLAGS_trace.o := -I$(src) CFLAGS_usb_trace.o := -I$(src) +CFLAGS_mt76x02_trace.o := -I$(src) mt76x02-lib-y := mt76x02_util.o mt76x02_mac.o mt76x02_mcu.o \ mt76x02_eeprom.o mt76x02_phy.o mt76x02_mmio.o \ - mt76x02_txrx.o + mt76x02_txrx.o mt76x02_trace.o mt76x02-usb-y := mt76x02_usb_mcu.o mt76x02_usb_core.o diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c index a5058e4a9b14..a39c10b61df9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c @@ -16,6 +16,7 @@ */ #include "mt76x02.h" +#include "mt76x02_trace.h" enum mt76x02_cipher_type mt76x02_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data) @@ -681,3 +682,35 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb, return mt76x02_mac_process_rate(status, rate); } + +void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq) +{ + struct mt76x02_tx_status stat = {}; + unsigned long flags; + u8 update = 1; + bool ret; + + if (!test_bit(MT76_STATE_RUNNING, &dev->mt76.state)) + return; + + trace_mac_txstat_poll(dev); + + while (!irq || !kfifo_is_full(&dev->txstatus_fifo)) { + spin_lock_irqsave(&dev->mt76.mmio.irq_lock, flags); + ret = mt76x02_mac_load_tx_status(&dev->mt76, &stat); + spin_unlock_irqrestore(&dev->mt76.mmio.irq_lock, flags); + + if (!ret) + break; + + trace_mac_txstat_fetch(dev, &stat); + + if (!irq) { + mt76x02_send_tx_status(&dev->mt76, &stat, &update); + continue; + } + + kfifo_put(&dev->txstatus_fifo, stat); + } +} +EXPORT_SYMBOL_GPL(mt76x02_mac_poll_tx_status); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h index 857ab2308e8b..426e68041642 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h @@ -205,4 +205,5 @@ void mt76x02_mac_setaddr(struct mt76_dev *dev, u8 *addr); void mt76x02_mac_write_txwi(struct mt76_dev *dev, struct mt76x02_txwi *txwi, struct sk_buff *skb, struct mt76_wcid *wcid, struct ieee80211_sta *sta, int len); +void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq); #endif diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_trace.c b/drivers/net/wireless/mediatek/mt76/mt76x02_trace.c new file mode 100644 index 000000000000..5b42d2c87937 --- /dev/null +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_trace.c @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2016 Felix Fietkau + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#ifndef __CHECKER__ +#define CREATE_TRACE_POINTS +#include "mt76x02_trace.h" + +#endif diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_trace.h b/drivers/net/wireless/mediatek/mt76/mt76x02_trace.h new file mode 100644 index 000000000000..98580dd22e78 --- /dev/null +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_trace.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2016 Felix Fietkau + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(__MT76x02_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) +#define __MT76x02_TRACE_H + +#include +#include "mt76x02.h" + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM mt76x02 + +#define MAXNAME 32 +#define DEV_ENTRY __array(char, wiphy_name, 32) +#define DEV_ASSIGN strlcpy(__entry->wiphy_name, wiphy_name(mt76_hw(dev)->wiphy), MAXNAME) +#define DEV_PR_FMT "%s" +#define DEV_PR_ARG __entry->wiphy_name + +#define TXID_ENTRY __field(u8, wcid) __field(u8, pktid) +#define TXID_ASSIGN __entry->wcid = wcid; __entry->pktid = pktid +#define TXID_PR_FMT " [%d:%d]" +#define TXID_PR_ARG __entry->wcid, __entry->pktid + +DECLARE_EVENT_CLASS(dev_evt, + TP_PROTO(struct mt76x02_dev *dev), + TP_ARGS(dev), + TP_STRUCT__entry( + DEV_ENTRY + ), + TP_fast_assign( + DEV_ASSIGN; + ), + TP_printk(DEV_PR_FMT, DEV_PR_ARG) +); + +DEFINE_EVENT(dev_evt, mac_txstat_poll, + TP_PROTO(struct mt76x02_dev *dev), + TP_ARGS(dev) +); + +TRACE_EVENT(mac_txstat_fetch, + TP_PROTO(struct mt76x02_dev *dev, + struct mt76x02_tx_status *stat), + + TP_ARGS(dev, stat), + + TP_STRUCT__entry( + DEV_ENTRY + TXID_ENTRY + __field(bool, success) + __field(bool, aggr) + __field(bool, ack_req) + __field(u16, rate) + __field(u8, retry) + ), + + TP_fast_assign( + DEV_ASSIGN; + __entry->success = stat->success; + __entry->aggr = stat->aggr; + __entry->ack_req = stat->ack_req; + __entry->wcid = stat->wcid; + __entry->pktid = stat->pktid; + __entry->rate = stat->rate; + __entry->retry = stat->retry; + ), + + TP_printk( + DEV_PR_FMT TXID_PR_FMT + " success:%d aggr:%d ack_req:%d" + " rate:%04x retry:%d", + DEV_PR_ARG, TXID_PR_ARG, + __entry->success, __entry->aggr, __entry->ack_req, + __entry->rate, __entry->retry + ) +); + +#endif + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE mt76x02_trace + +#include diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/mac.h b/drivers/net/wireless/mediatek/mt76/mt76x2/mac.h index 6bd04b74e15a..6a6761050035 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/mac.h @@ -49,7 +49,6 @@ int mt76x2_mac_set_beacon(struct mt76x02_dev *dev, u8 vif_idx, struct sk_buff *skb); void mt76x2_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx, bool val); -void mt76x2_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq); void mt76x2_mac_process_tx_status_fifo(struct mt76x02_dev *dev); void mt76x2_mac_work(struct work_struct *work); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_core.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_core.c index 1738e025a57e..2abd891f229a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_core.c @@ -61,7 +61,7 @@ irqreturn_t mt76x2_irq_handler(int irq, void *dev_instance) mt76_queue_kick(dev, &dev->mt76.q_tx[MT_TXQ_PSD]); if (intr & MT_INT_TX_STAT) { - mt76x2_mac_poll_tx_status(dev, true); + mt76x02_mac_poll_tx_status(dev, true); tasklet_schedule(&dev->tx_tasklet); } diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_dma.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_dma.c index 2859812ac47a..bfb590d6f288 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_dma.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_dma.c @@ -26,7 +26,7 @@ void mt76x2_tx_tasklet(unsigned long data) for (i = MT_TXQ_MCU; i >= 0; i--) mt76_queue_tx_cleanup(dev, i, false); - mt76x2_mac_poll_tx_status(dev, false); + mt76x02_mac_poll_tx_status(dev, false); mt76x02_irq_enable(&dev->mt76, MT_INT_TX_DONE_ALL); } diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mac.c index 981633cbd527..8017db8a341b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mac.c @@ -28,37 +28,6 @@ void mt76x2_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 *addr) get_unaligned_le16(addr + 4)); } -void mt76x2_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq) -{ - struct mt76x02_tx_status stat = {}; - unsigned long flags; - u8 update = 1; - bool ret; - - if (!test_bit(MT76_STATE_RUNNING, &dev->mt76.state)) - return; - - trace_mac_txstat_poll(dev); - - while (!irq || !kfifo_is_full(&dev->txstatus_fifo)) { - spin_lock_irqsave(&dev->mt76.mmio.irq_lock, flags); - ret = mt76x02_mac_load_tx_status(&dev->mt76, &stat); - spin_unlock_irqrestore(&dev->mt76.mmio.irq_lock, flags); - - if (!ret) - break; - - trace_mac_txstat_fetch(dev, &stat); - - if (!irq) { - mt76x02_send_tx_status(&dev->mt76, &stat, &update); - continue; - } - - kfifo_put(&dev->txstatus_fifo, stat); - } -} - static void mt76x2_mac_queue_txdone(struct mt76x02_dev *dev, struct sk_buff *skb, void *txwi_ptr) @@ -66,7 +35,7 @@ mt76x2_mac_queue_txdone(struct mt76x02_dev *dev, struct sk_buff *skb, struct mt76x2_tx_info *txi = mt76x2_skb_tx_info(skb); struct mt76x02_txwi *txwi = txwi_ptr; - mt76x2_mac_poll_tx_status(dev, false); + mt76x02_mac_poll_tx_status(dev, false); txi->tries = 0; txi->jiffies = jiffies; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/trace.h b/drivers/net/wireless/mediatek/mt76/mt76x2/trace.h index ef88623fa6c9..8a49657380b4 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/trace.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/trace.h @@ -34,18 +34,6 @@ #define TXID_PR_FMT " [%d:%d]" #define TXID_PR_ARG __entry->wcid, __entry->pktid -DECLARE_EVENT_CLASS(dev_evt, - TP_PROTO(struct mt76x02_dev *dev), - TP_ARGS(dev), - TP_STRUCT__entry( - DEV_ENTRY - ), - TP_fast_assign( - DEV_ASSIGN; - ), - TP_printk(DEV_PR_FMT, DEV_PR_ARG) -); - DECLARE_EVENT_CLASS(dev_txid_evt, TP_PROTO(struct mt76x02_dev *dev, u8 wcid, u8 pktid), TP_ARGS(dev, wcid, pktid), @@ -63,54 +51,11 @@ DECLARE_EVENT_CLASS(dev_txid_evt, ) ); -DEFINE_EVENT(dev_evt, mac_txstat_poll, - TP_PROTO(struct mt76x02_dev *dev), - TP_ARGS(dev) -); - DEFINE_EVENT(dev_txid_evt, mac_txdone_add, TP_PROTO(struct mt76x02_dev *dev, u8 wcid, u8 pktid), TP_ARGS(dev, wcid, pktid) ); -TRACE_EVENT(mac_txstat_fetch, - TP_PROTO(struct mt76x02_dev *dev, - struct mt76x02_tx_status *stat), - - TP_ARGS(dev, stat), - - TP_STRUCT__entry( - DEV_ENTRY - TXID_ENTRY - __field(bool, success) - __field(bool, aggr) - __field(bool, ack_req) - __field(u16, rate) - __field(u8, retry) - ), - - TP_fast_assign( - DEV_ASSIGN; - __entry->success = stat->success; - __entry->aggr = stat->aggr; - __entry->ack_req = stat->ack_req; - __entry->wcid = stat->wcid; - __entry->pktid = stat->pktid; - __entry->rate = stat->rate; - __entry->retry = stat->retry; - ), - - TP_printk( - DEV_PR_FMT TXID_PR_FMT - " success:%d aggr:%d ack_req:%d" - " rate:%04x retry:%d", - DEV_PR_ARG, TXID_PR_ARG, - __entry->success, __entry->aggr, __entry->ack_req, - __entry->rate, __entry->retry - ) -); - - TRACE_EVENT(dev_irq, TP_PROTO(struct mt76x02_dev *dev, u32 val, u32 mask),