Commit 61b5156b authored by Felix Fietkau's avatar Felix Fietkau
Browse files

mt76: make number of tokens configurable dynamically



Preparation for adding Wireless Ethernet Dispatch support

Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent d1ddc536
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -580,6 +580,7 @@ mt76_alloc_device(struct device *pdev, unsigned int size,
	INIT_LIST_HEAD(&dev->wcid_list);

	INIT_LIST_HEAD(&dev->txwi_cache);
	dev->token_size = dev->drv->token_size;

	for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++)
		skb_queue_head_init(&dev->rx_skb[i]);
+3 −3
Original line number Diff line number Diff line
@@ -719,7 +719,8 @@ struct mt76_dev {

	spinlock_t token_lock;
	struct idr token;
	int token_count;
	u16 token_count;
	u16 token_size;

	wait_queue_head_t tx_wait;
	/* spinclock used to protect wcid pktid linked list */
@@ -1381,8 +1382,7 @@ mt76_token_get(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi)
	int token;

	spin_lock_bh(&dev->token_lock);
	token = idr_alloc(&dev->token, *ptxwi, 0, dev->drv->token_size,
			  GFP_ATOMIC);
	token = idr_alloc(&dev->token, *ptxwi, 0, dev->token_size, GFP_ATOMIC);
	spin_unlock_bh(&dev->token_lock);

	return token;
+3 −4
Original line number Diff line number Diff line
@@ -722,12 +722,11 @@ int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi)

	spin_lock_bh(&dev->token_lock);

	token = idr_alloc(&dev->token, *ptxwi, 0, dev->drv->token_size,
			  GFP_ATOMIC);
	token = idr_alloc(&dev->token, *ptxwi, 0, dev->token_size, GFP_ATOMIC);
	if (token >= 0)
		dev->token_count++;

	if (dev->token_count >= dev->drv->token_size - MT76_TOKEN_FREE_THR)
	if (dev->token_count >= dev->token_size - MT76_TOKEN_FREE_THR)
		__mt76_set_tx_blocked(dev, true);

	spin_unlock_bh(&dev->token_lock);
@@ -747,7 +746,7 @@ mt76_token_release(struct mt76_dev *dev, int token, bool *wake)
	if (txwi)
		dev->token_count--;

	if (dev->token_count < dev->drv->token_size - MT76_TOKEN_FREE_THR &&
	if (dev->token_count < dev->token_size - MT76_TOKEN_FREE_THR &&
	    dev->phy.q_tx[0]->blocked)
		*wake = true;