Linux wireless drivers development
 help / color / mirror / Atom feed
From: Stanislaw Gruszka <sgruszka@redhat.com>
To: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Cc: nbd@nbd.name, linux-wireless@vger.kernel.org
Subject: Re: [RFC 06/18] mt76x2: introduce mt76x2_mac_load_tx_status routine
Date: Wed, 2 May 2018 15:07:26 +0200	[thread overview]
Message-ID: <20180502130726.GA13887@redhat.com> (raw)
In-Reply-To: <9d50bf4d74ec52e141dd112768570e15a481ad2e.1525096206.git.lorenzo.bianconi@redhat.com>

On Mon, Apr 30, 2018 at 04:12:21PM +0200, Lorenzo Bianconi wrote:
> Add mt76x2_mac_load_tx_status routine since tx stats register map is
> shared between usb and pci based devices but usb devices do not have a
> tx stat irq line as pcie ones and it is necessary to load tx statistics
> using a workqueue
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x2_mac.c | 43 +++++++++++++++----------
>  1 file changed, 26 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x2_mac.c
> index d18315652583..0ddc84525ffa 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x2_mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_mac.c
> @@ -515,6 +515,28 @@ mt76x2_send_tx_status(struct mt76x2_dev *dev, struct mt76x2_tx_status *stat,
>  	rcu_read_unlock();
>  }
>  
> +static struct mt76x2_tx_status
> +mt76x2_mac_load_tx_status(struct mt76x2_dev *dev)
> +{
> +	struct mt76x2_tx_status stat = {};
> +	u32 stat1, stat2;
> +
> +	stat2 = mt76_rr(dev, MT_TX_STAT_FIFO_EXT);
> +	stat1 = mt76_rr(dev, MT_TX_STAT_FIFO);
> +
> +	stat.valid = !!(stat1 & MT_TX_STAT_FIFO_VALID);
> +	stat.success = !!(stat1 & MT_TX_STAT_FIFO_SUCCESS);
> +	stat.aggr = !!(stat1 & MT_TX_STAT_FIFO_AGGR);
> +	stat.ack_req = !!(stat1 & MT_TX_STAT_FIFO_ACKREQ);
> +	stat.wcid = FIELD_GET(MT_TX_STAT_FIFO_WCID, stat1);
> +	stat.rate = FIELD_GET(MT_TX_STAT_FIFO_RATE, stat1);
> +
> +	stat.retry = FIELD_GET(MT_TX_STAT_FIFO_EXT_RETRY, stat2);
> +	stat.pktid = FIELD_GET(MT_TX_STAT_FIFO_EXT_PKTID, stat2);
> +
> +	return stat;
> +}
> +

Just two minor points. We do not need fill structure if stat is
not valid. Also returning mt76x2_tx_status structure might require
full copy of it. Returning boolean indicator of validity and pass
pointer to struct mt76x2_tx_status to the subroutine would be more
efficient.

Regards
Stanislaw

  reply	other threads:[~2018-05-02 13:07 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-30 14:12 [RFC 00/18] add mt76x2u support to mt76 driver Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 01/18] mt76x2: use completion instead of wait_queue for mcu rx queue Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 02/18] mt76x2: move mt76x2_fw_header and mt76x2_patch_header definitions in mcu.h Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 03/18] mt76x2: move utility routines in mt76x2.h Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 04/18] mt76x2: introduce mt76x2_init_device routine Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 05/18] mt76x2: move currently mt76x2u unsupported features to mt76x2_init Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 06/18] mt76x2: introduce mt76x2_mac_load_tx_status routine Lorenzo Bianconi
2018-05-02 13:07   ` Stanislaw Gruszka [this message]
2018-05-02 13:34     ` Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 07/18] mt76x2: add napi struct to mt76_rx_poll_complete/mt76_rx_complete signatures Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 08/18] mt76x2: add buffer len to mt76x2_mac_write_txwi signature Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 09/18] mt76: introduce tx_queue_skb function pointer in mt76_bus_ops Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 10/18] mt76: introduce mt76x2-common module Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 11/18] mt76: add mt76x2_tx_common to " Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 12/18] mt76: add mt76x2_mac_common " Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 13/18] mt76: add mt76x2_init_common " Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 14/18] mt76: add mt76x2_common " Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 15/18] mt76: add mt76x2_phy_common " Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 16/18] mt76: move mt76x2_debugfs in mt76-common module Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 17/18] mt76: add usb suppor to mt76 layer Lorenzo Bianconi
2018-04-30 14:12 ` [RFC 18/18] mt76: add driver code for MT76x2u based devices Lorenzo Bianconi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180502130726.GA13887@redhat.com \
    --to=sgruszka@redhat.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=nbd@nbd.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox