Skip to content

Commit

Permalink
mt76: fix using mac80211 tx skb header padding
Browse files Browse the repository at this point in the history
If the 802.11 frame has no payload, skip the padding.
Also add missing code to mt76x02u

Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
nbd168 committed Mar 22, 2019
1 parent 3a7e6bb commit deacb8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions mt76x02_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,14 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
struct mt76x02_txwi *txwi = txwi_ptr;
int hdrlen, len, pid, qsel = MT_QSEL_EDCA;
int hdrlen, pad, len, pid, qsel = MT_QSEL_EDCA;

if (qid == MT_TXQ_PSD && wcid && wcid->idx < 128)
mt76x02_mac_wcid_set_drop(dev, wcid->idx, false);

hdrlen = ieee80211_hdrlen(hdr->frame_control);
len = skb->len - (hdrlen & 2);
pad = skb->len > hdrlen ? (hdrlen & 2) : 0;
len = skb->len - pad;
mt76x02_mac_write_txwi(dev, txwi, skb, wcid, sta, len);

pid = mt76_tx_status_skb_add(mdev, wcid, skb);
Expand Down
5 changes: 4 additions & 1 deletion mt76x02_usb_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,14 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
struct mt76_tx_info *tx_info)
{
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
int pid, len = skb->len, ep = q2ep(mdev->q_tx[qid].q->hw_idx);
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
int pid, hdrlen, len = skb->len, ep = q2ep(mdev->q_tx[qid].q->hw_idx);
struct mt76x02_txwi *txwi;
enum mt76_qsel qsel;
u32 flags;

hdrlen = ieee80211_hdrlen(hdr->frame_control);
len -= skb->len > hdrlen ? (hdrlen & 2) : 0;
txwi = (struct mt76x02_txwi *)(skb->data - sizeof(struct mt76x02_txwi));
mt76x02_mac_write_txwi(dev, txwi, skb, wcid, sta, len);
skb_push(skb, sizeof(struct mt76x02_txwi));
Expand Down

0 comments on commit deacb8f

Please sign in to comment.