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

mt76: usb: use mt76x02u_tx_prepare_skb to fill txwi



Use mt76x02u_tx_prepare_skb routine to fill txwi in mt76x2u and
mt76x0u driver and remove duplicated code. Moreover add static
qualifier to mt76x02_mac_tx_rate_val and mt76x02_mac_fill_txwi
routines

Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 427f9ebe
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -168,11 +168,6 @@ void mt76x0_mac_set_ampdu_factor(struct mt76x0_dev *dev);
/* TX */
void mt76x0_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
		struct sk_buff *skb);
struct mt76x02_txwi *
mt76x0_push_txwi(struct mt76x0_dev *dev, struct sk_buff *skb,
		 struct ieee80211_sta *sta, struct mt76_wcid *wcid,
		 int pkt_len);

void mt76x0_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
			 struct sk_buff *skb);

+0 −38
Original line number Diff line number Diff line
@@ -17,44 +17,6 @@
#include "../mt76x02_util.h"
#include "../mt76x02_usb.h"

struct mt76x02_txwi *
mt76x0_push_txwi(struct mt76x0_dev *dev, struct sk_buff *skb,
		 struct ieee80211_sta *sta, struct mt76_wcid *wcid,
		 int pkt_len)
{
	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
	struct ieee80211_tx_rate *rate = &info->control.rates[0];
	struct mt76x02_txwi *txwi;
	unsigned long flags;
	u16 rate_ctl;
	u8 nss;

	txwi = (struct mt76x02_txwi *)skb_push(skb, sizeof(struct mt76x02_txwi));
	memset(txwi, 0, sizeof(*txwi));

	if (!wcid->tx_rate_set)
		ieee80211_get_tx_rates(info->control.vif, sta, skb,
				       info->control.rates, 1);

	spin_lock_irqsave(&dev->mt76.lock, flags);
	if (rate->idx < 0 || !rate->count) {
		rate_ctl = wcid->tx_rate;
		nss = wcid->tx_rate_nss;
	} else {
		rate_ctl = mt76x02_mac_tx_rate_val(&dev->mt76, rate, &nss);
	}
	spin_unlock_irqrestore(&dev->mt76.lock, flags);

	txwi->wcid = wcid->idx;
	txwi->rate = cpu_to_le16(rate_ctl);
	txwi->pktid = (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) ? 1 : 0;

	mt76x02_mac_fill_txwi(txwi, skb, sta, pkt_len, nss);

	return txwi;
}
EXPORT_SYMBOL_GPL(mt76x0_push_txwi);

void mt76x0_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
	       struct sk_buff *skb)
{
+1 −16
Original line number Diff line number Diff line
@@ -159,21 +159,6 @@ static const struct ieee80211_ops mt76x0u_ops = {
	.wake_tx_queue = mt76_wake_tx_queue,
};

static int mt76x0u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
				  struct sk_buff *skb, struct mt76_queue *q,
				  struct mt76_wcid *wcid, struct ieee80211_sta *sta,
				  u32 *tx_info)
{
	struct mt76x0_dev *dev = container_of(mdev, struct mt76x0_dev, mt76);
	struct mt76x02_txwi *txwi;
	int len = skb->len;

	mt76x02_insert_hdr_pad(skb);
	txwi = mt76x0_push_txwi(dev, skb, sta, wcid, len);

	return mt76x02u_set_txinfo(skb, wcid, q2ep(q->hw_idx));
}

static int mt76x0u_register_device(struct mt76x0_dev *dev)
{
	struct ieee80211_hw *hw = dev->mt76.hw;
@@ -230,7 +215,7 @@ static int mt76x0u_probe(struct usb_interface *usb_intf,
			 const struct usb_device_id *id)
{
	static const struct mt76_driver_ops drv_ops = {
		.tx_prepare_skb = mt76x0u_tx_prepare_skb,
		.tx_prepare_skb = mt76x02u_tx_prepare_skb,
		.tx_complete_skb = mt76x02_tx_complete_skb,
		.tx_status_data = mt76x02_tx_status_data,
		.rx_skb = mt76x0_queue_rx_skb,
+4 −5
Original line number Diff line number Diff line
@@ -157,7 +157,8 @@ void mt76x02_txq_init(struct mt76_dev *dev, struct ieee80211_txq *txq)
}
EXPORT_SYMBOL_GPL(mt76x02_txq_init);

void mt76x02_mac_fill_txwi(struct mt76x02_txwi *txwi, struct sk_buff *skb,
static void
mt76x02_mac_fill_txwi(struct mt76x02_txwi *txwi, struct sk_buff *skb,
		      struct ieee80211_sta *sta, int len, u8 nss)
{
	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -197,9 +198,8 @@ void mt76x02_mac_fill_txwi(struct mt76x02_txwi *txwi, struct sk_buff *skb,
	txwi->flags |= cpu_to_le16(txwi_flags);
	txwi->len_ctl = cpu_to_le16(len);
}
EXPORT_SYMBOL_GPL(mt76x02_mac_fill_txwi);

__le16
static __le16
mt76x02_mac_tx_rate_val(struct mt76_dev *dev,
		       const struct ieee80211_tx_rate *rate, u8 *nss_val)
{
@@ -249,7 +249,6 @@ mt76x02_mac_tx_rate_val(struct mt76_dev *dev,
	*nss_val = nss;
	return cpu_to_le16(rateval);
}
EXPORT_SYMBOL_GPL(mt76x02_mac_tx_rate_val);

void mt76x02_mac_wcid_set_rate(struct mt76_dev *dev, struct mt76_wcid *wcid,
			      const struct ieee80211_tx_rate *rate)
+0 −5
Original line number Diff line number Diff line
@@ -180,8 +180,6 @@ static inline bool mt76x02_wait_for_mac(struct mt76_dev *dev)
}

void mt76x02_txq_init(struct mt76_dev *dev, struct ieee80211_txq *txq);
void mt76x02_mac_fill_txwi(struct mt76x02_txwi *txwi, struct sk_buff *skb,
			  struct ieee80211_sta *sta, int len, u8 nss);
enum mt76x02_cipher_type
mt76x02_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data);

@@ -193,9 +191,6 @@ void mt76x02_mac_wcid_setup(struct mt76_dev *dev, u8 idx, u8 vif_idx, u8 *mac);
void mt76x02_mac_wcid_set_drop(struct mt76_dev *dev, u8 idx, bool drop);
void mt76x02_mac_wcid_set_rate(struct mt76_dev *dev, struct mt76_wcid *wcid,
			      const struct ieee80211_tx_rate *rate);
__le16
mt76x02_mac_tx_rate_val(struct mt76_dev *dev,
		       const struct ieee80211_tx_rate *rate, u8 *nss_val);
bool mt76x02_mac_load_tx_status(struct mt76_dev *dev,
			       struct mt76x02_tx_status *stat);
void mt76x02_send_tx_status(struct mt76_dev *dev,
Loading