Skip to content

Commit

Permalink
mt76: add an intermediate struct for rx status information
Browse files Browse the repository at this point in the history
Preparation for passing in more internal rx data via skb->cb

Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
nbd168 committed Jan 21, 2018
1 parent 0f8327a commit ad3f8e9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
29 changes: 28 additions & 1 deletion mac80211.c
Expand Up @@ -384,10 +384,37 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx,
}
EXPORT_SYMBOL_GPL(mt76_get_survey);

static void
mt76_rx_convert(struct sk_buff *skb)
{
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
struct mt76_rx_status mstat;

mstat = *((struct mt76_rx_status *) skb->cb);
memset(status, 0, sizeof(*status));

status->flag = mstat.flag;
status->freq = mstat.freq;
status->enc_flags = mstat.enc_flags;
status->encoding = mstat.encoding;
status->bw = mstat.bw;
status->rate_idx = mstat.rate_idx;
status->nss = mstat.nss;
status->band = mstat.band;
status->signal = mstat.signal;
status->chains = mstat.chains;

BUILD_BUG_ON(sizeof(mstat) > sizeof(skb->cb));
BUILD_BUG_ON(sizeof(status->chain_signal) != sizeof(mstat.chain_signal));
memcpy(status->chain_signal, mstat.chain_signal, sizeof(mstat.chain_signal));
}

void mt76_rx_complete(struct mt76_dev *dev, enum mt76_rxq_id q)
{
struct sk_buff *skb;

while ((skb = __skb_dequeue(&dev->rx_skb[q])) != NULL)
while ((skb = __skb_dequeue(&dev->rx_skb[q])) != NULL) {
mt76_rx_convert(skb);
ieee80211_rx_napi(dev->hw, NULL, skb, &dev->napi[q]);
}
}
13 changes: 13 additions & 0 deletions mt76.h
Expand Up @@ -250,6 +250,19 @@ struct mt76_rate_power {
};
};

struct mt76_rx_status {
u32 flag;
u16 freq;
u8 enc_flags;
u8 encoding:2, bw:3;
u8 rate_idx;
u8 nss;
u8 band;
u8 signal;
u8 chains;
s8 chain_signal[IEEE80211_MAX_CHAINS];
};

#define mt76_rr(dev, ...) (dev)->mt76.bus->rr(&((dev)->mt76), __VA_ARGS__)
#define mt76_wr(dev, ...) (dev)->mt76.bus->wr(&((dev)->mt76), __VA_ARGS__)
#define mt76_rmw(dev, ...) (dev)->mt76.bus->rmw(&((dev)->mt76), __VA_ARGS__)
Expand Down
2 changes: 1 addition & 1 deletion mt7603_mac.c
Expand Up @@ -353,7 +353,7 @@ mt7603_get_rate(struct mt7603_dev *dev, struct ieee80211_supported_band *sband,
int
mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb)
{
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
struct mt76_rx_status *status = (struct mt76_rx_status *) skb->cb;
struct ieee80211_supported_band *sband;
__le32 *rxd = (__le32 *) skb->data;
u32 rxd0 = le32_to_cpu(rxd[0]);
Expand Down
4 changes: 2 additions & 2 deletions mt76x2_mac.c
Expand Up @@ -42,7 +42,7 @@ void mt76x2_mac_set_ext_mac(struct mt76x2_dev *dev, u8 idx, const u8 *addr)
}

static int
mt76x2_mac_process_rate(struct ieee80211_rx_status *status, u16 rate)
mt76x2_mac_process_rate(struct mt76_rx_status *status, u16 rate)
{
u8 idx = FIELD_GET(MT_RXWI_RATE_INDEX, rate);

Expand Down Expand Up @@ -281,7 +281,7 @@ static void mt76x2_remove_hdr_pad(struct sk_buff *skb)
int mt76x2_mac_process_rx(struct mt76x2_dev *dev, struct sk_buff *skb,
void *rxi)
{
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
struct mt76_rx_status *status = (struct mt76_rx_status *) skb->cb;
struct mt76x2_rxwi *rxwi = rxi;
u32 ctl = le32_to_cpu(rxwi->ctl);
u16 rate = le16_to_cpu(rxwi->rate);
Expand Down

0 comments on commit ad3f8e9

Please sign in to comment.