Commit 3e2342ed authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau
Browse files

mt76: move mt76x02_mac_poll_tx_status in mt76x02-lib moudle



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: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent b38383e6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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

+33 −0
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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
+23 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
 *
 * 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 <linux/module.h>

#ifndef __CHECKER__
#define CREATE_TRACE_POINTS
#include "mt76x02_trace.h"

#endif
+98 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
 *
 * 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 <linux/tracepoint.h>
#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 <trace/define_trace.h>
Loading