Search Linux Wireless

Re: [PATCH 1/6] mt76: use mac80211 txq scheduling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Felix Fietkau <nbd@xxxxxxxx> writes:

> Performance improvement and preparation for adding airtime fairness
> support

Great to see this! Do you have a plan for the airtime fairness part?
I.e., how to get the airtime information?

Only one other comment, below.

> Signed-off-by: Felix Fietkau <nbd@xxxxxxxx>
> ---
>  drivers/net/wireless/mediatek/mt76/dma.c  |  6 +-
>  drivers/net/wireless/mediatek/mt76/mt76.h |  3 +-
>  drivers/net/wireless/mediatek/mt76/tx.c   | 98 ++++++++++-------------
>  drivers/net/wireless/mediatek/mt76/usb.c  |  3 +-
>  4 files changed, 50 insertions(+), 60 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
> index 7b8a998103d7..09978757e7d1 100644
> --- a/drivers/net/wireless/mediatek/mt76/dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/dma.c
> @@ -184,9 +184,7 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush)
>  			last = ioread32(&q->regs->dma_idx);
>  	}
>  
> -	if (!flush)
> -		mt76_txq_schedule(dev, sq);
> -	else
> +	if (flush)
>  		mt76_dma_sync_idx(dev, q);
>  
>  	wake = wake && q->stopped &&
> @@ -199,6 +197,8 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush)
>  
>  	spin_unlock_bh(&q->lock);
>  
> +	if (!flush)
> +		mt76_txq_schedule(dev, qid);
>  	if (wake)
>  		ieee80211_wake_queue(dev->hw, qid);
>  }
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
> index edff44f32c8e..5d44f721d184 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76.h
> @@ -224,7 +224,6 @@ struct mt76_wcid {
>  };
>  
>  struct mt76_txq {
> -	struct list_head list;
>  	struct mt76_sw_queue *swq;
>  	struct mt76_wcid *wcid;
>  
> @@ -683,7 +682,7 @@ void mt76_txq_remove(struct mt76_dev *dev, struct ieee80211_txq *txq);
>  void mt76_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq);
>  void mt76_stop_tx_queues(struct mt76_dev *dev, struct ieee80211_sta *sta,
>  			 bool send_bar);
> -void mt76_txq_schedule(struct mt76_dev *dev, struct mt76_sw_queue *sq);
> +void mt76_txq_schedule(struct mt76_dev *dev, enum mt76_txq_id qid);
>  void mt76_txq_schedule_all(struct mt76_dev *dev);
>  void mt76_release_buffered_frames(struct ieee80211_hw *hw,
>  				  struct ieee80211_sta *sta,
> diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
> index 2c82db0b5834..ef9a0bbd64c1 100644
> --- a/drivers/net/wireless/mediatek/mt76/tx.c
> +++ b/drivers/net/wireless/mediatek/mt76/tx.c
> @@ -479,23 +479,37 @@ mt76_txq_send_burst(struct mt76_dev *dev, struct mt76_sw_queue *sq,
>  }
>  
>  static int
> -mt76_txq_schedule_list(struct mt76_dev *dev, struct mt76_sw_queue *sq)
> +mt76_txq_schedule_list(struct mt76_dev *dev, enum mt76_txq_id qid)
>  {
> +	struct mt76_sw_queue *sq = &dev->q_tx[qid];
>  	struct mt76_queue *hwq = sq->q;
> -	struct mt76_txq *mtxq, *mtxq_last;
> -	int len = 0;
> +	struct ieee80211_txq *txq;
> +	struct mt76_txq *mtxq;
> +	struct mt76_wcid *wcid;
> +	int ret = 0;
>  
> -restart:
> -	mtxq_last = list_last_entry(&sq->swq, struct mt76_txq, list);
> -	while (!list_empty(&sq->swq)) {
> +	spin_lock_bh(&hwq->lock);
> +	while (1) {
>  		bool empty = false;
> -		int cur;
> +
> +		if (sq->swq_queued >= 4)
> +			break;
>  
>  		if (test_bit(MT76_OFFCHANNEL, &dev->state) ||
> -		    test_bit(MT76_RESET, &dev->state))
> -			return -EBUSY;
> +		    test_bit(MT76_RESET, &dev->state)) {
> +			ret = -EBUSY;
> +			break;
> +		}
> +
> +		txq = ieee80211_next_txq(dev->hw, qid);
> +		if (!txq)
> +			break;
> +
> +		mtxq = (struct mt76_txq *)txq->drv_priv;
> +		wcid = mtxq->wcid;
> +		if (wcid && test_bit(MT_WCID_FLAG_PS, &wcid->flags))
> +			continue;
>  
> -		mtxq = list_first_entry(&sq->swq, struct mt76_txq, list);
>  		if (mtxq->send_bar && mtxq->aggr) {
>  			struct ieee80211_txq *txq = mtxq_to_txq(mtxq);
>  			struct ieee80211_sta *sta = txq->sta;
> @@ -507,38 +521,36 @@ mt76_txq_schedule_list(struct mt76_dev *dev, struct mt76_sw_queue *sq)
>  			spin_unlock_bh(&hwq->lock);
>  			ieee80211_send_bar(vif, sta->addr, tid, agg_ssn);
>  			spin_lock_bh(&hwq->lock);
> -			goto restart;
>  		}
>  
> -		list_del_init(&mtxq->list);
> -
> -		cur = mt76_txq_send_burst(dev, sq, mtxq, &empty);
> +		ret += mt76_txq_send_burst(dev, sq, mtxq, &empty);
>  		if (!empty)
> -			list_add_tail(&mtxq->list, &sq->swq);
> -
> -		if (cur < 0)
> -			return cur;
> -
> -		len += cur;
> -
> -		if (mtxq == mtxq_last)
> -			break;
> +			ieee80211_return_txq(dev->hw, txq);

The call to ieee80211_return_txq() is really meant to be unconditional.
The TXQ will only actually be scheduled if it still has packets queued.
I know it's slightly more expensive to have the check in mac80211, but
this is what makes it possible to change the implementation without
touching the drivers (such as in the RFC patch I sent earlier that
switches the scheduling algorithm)...

-Toke



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux