Commit ef13edc0 authored by Felix Fietkau's avatar Felix Fietkau
Browse files

mt76: move mt76x02_phy_get_min_avg_rssi to mt76 core



This will be used by mt7603 as well

Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 9313faac
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -548,7 +548,7 @@ mt76_check_ccmp_pn(struct sk_buff *skb)
}

static void
mt76_check_ps(struct mt76_dev *dev, struct sk_buff *skb)
mt76_check_sta(struct mt76_dev *dev, struct sk_buff *skb)
{
	struct mt76_rx_status *status = (struct mt76_rx_status *) skb->cb;
	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
@@ -567,6 +567,9 @@ mt76_check_ps(struct mt76_dev *dev, struct sk_buff *skb)

	sta = container_of((void *) wcid, struct ieee80211_sta, drv_priv);

	ewma_signal_add(&wcid->rssi, status->signal);
	wcid->inactive_count = 0;

	if (!test_bit(MT_WCID_FLAG_CHECK_PS, &wcid->flags))
		return;

@@ -626,7 +629,7 @@ void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
	__skb_queue_head_init(&frames);

	while ((skb = __skb_dequeue(&dev->rx_skb[q])) != NULL) {
		mt76_check_ps(dev, skb);
		mt76_check_sta(dev, skb);
		mt76_rx_aggr_reorder(skb, &frames);
	}

@@ -660,6 +663,7 @@ mt76_sta_add(struct mt76_dev *dev, struct ieee80211_vif *vif,
		mt76_txq_init(dev, sta->txq[i]);
	}

	ewma_signal_init(&wcid->rssi);
	rcu_assign_pointer(dev->wcid[wcid->idx], wcid);

out:
+8 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <linux/skbuff.h>
#include <linux/leds.h>
#include <linux/usb.h>
#include <linux/average.h>
#include <net/mac80211.h>
#include "util.h"

@@ -174,6 +175,8 @@ enum mt76_wcid_flags {

#define MT76_N_WCIDS 128

DECLARE_EWMA(signal, 10, 8);

struct mt76_wcid {
	struct mt76_rx_tid __rcu *aggr[IEEE80211_NUM_TIDS];

@@ -181,6 +184,9 @@ struct mt76_wcid {

	unsigned long flags;

	struct ewma_signal rssi;
	int inactive_count;

	u8 idx;
	u8 hw_key_idx;

@@ -680,6 +686,8 @@ int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif,

struct ieee80211_sta *mt76_rx_convert(struct sk_buff *skb);

int mt76_get_min_avg_rssi(struct mt76_dev *dev);

int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
		     int *dbm);

+3 −1
Original line number Diff line number Diff line
@@ -1077,7 +1077,9 @@ mt76x0_phy_update_channel_gain(struct mt76x02_dev *dev)
	u8 gain_delta;
	int low_gain;

	dev->cal.avg_rssi_all = mt76x02_phy_get_min_avg_rssi(dev);
	dev->cal.avg_rssi_all = mt76_get_min_avg_rssi(&dev->mt76);
	if (!dev->cal.avg_rssi_all)
		dev->cal.avg_rssi_all = -75;

	low_gain = (dev->cal.avg_rssi_all > mt76x02_get_rssi_gain_thresh(dev)) +
		   (dev->cal.avg_rssi_all > mt76x02_get_low_rssi_gain_thresh(dev));
+0 −5
Original line number Diff line number Diff line
@@ -656,11 +656,6 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
	status->tid = FIELD_GET(MT_RXWI_TID, tid_sn);
	status->seqno = FIELD_GET(MT_RXWI_SN, tid_sn);

	if (sta) {
		ewma_signal_add(&sta->rssi, status->signal);
		sta->inactive_count = 0;
	}

	return mt76x02_mac_process_rate(status, rate);
}

+0 −6
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@
#ifndef __MT76X02_MAC_H
#define __MT76X02_MAC_H

#include <linux/average.h>

struct mt76x02_dev;

struct mt76x02_tx_status {
@@ -41,8 +39,6 @@ struct mt76x02_vif {
	u8 idx;
};

DECLARE_EWMA(signal, 10, 8);

struct mt76x02_sta {
	struct mt76_wcid wcid; /* must be first */

@@ -50,8 +46,6 @@ struct mt76x02_sta {
	struct mt76x02_tx_status status;
	int n_frames;

	struct ewma_signal rssi;
	int inactive_count;
};

#define MT_RXINFO_BA			BIT(0)
Loading