[2/2] rtw88: report RX power for each antenna
diff mbox series

Message ID 1568270355-29727-3-git-send-email-yhchuang@realtek.com
State Accepted
Commit 98ab76ef6b6d16f3fcb5e13ed19448bcc7de83d2
Delegated to: Kalle Valo
Headers show
Series
  • rtw88: report RX signal strength for each antenna
Related show

Commit Message

Tony Chuang Sept. 12, 2019, 6:39 a.m. UTC
From: Yan-Hsuan Chuang <yhchuang@realtek.com>

Report chains and chain_signal in ieee80211_rx_status.
It is useful for program such as tcpdump to see if the
antennas are well connected/placed.

8822C is able to receive CCK rates with 2 antennas, while
8822B can only use 1 antenna path to receive CCK rates.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
---
 drivers/net/wireless/realtek/rtw88/rtw8822b.c | 1 +
 drivers/net/wireless/realtek/rtw88/rtw8822c.c | 6 +++---
 drivers/net/wireless/realtek/rtw88/rx.c       | 5 +++++
 3 files changed, 9 insertions(+), 3 deletions(-)

Comments

Chris Chiu Sept. 12, 2019, 7:15 a.m. UTC | #1
On Thu, Sep 12, 2019 at 2:39 PM <yhchuang@realtek.com> wrote:
>
> From: Yan-Hsuan Chuang <yhchuang@realtek.com>
>
> Report chains and chain_signal in ieee80211_rx_status.
> It is useful for program such as tcpdump to see if the
> antennas are well connected/placed.
>
> 8822C is able to receive CCK rates with 2 antennas, while
> 8822B can only use 1 antenna path to receive CCK rates.
>
> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
> ---
>  drivers/net/wireless/realtek/rtw88/rtw8822b.c | 1 +
>  drivers/net/wireless/realtek/rtw88/rtw8822c.c | 6 +++---
>  drivers/net/wireless/realtek/rtw88/rx.c       | 5 +++++
>  3 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> index 568033a..0861195 100644
> --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> @@ -766,6 +766,7 @@ static void query_phy_status_page0(struct rtw_dev *rtwdev, u8 *phy_status,
>         s8 min_rx_power = -120;
>         u8 pwdb = GET_PHY_STAT_P0_PWDB(phy_status);
>
> +       /* 8822B uses only 1 antenna to RX CCK rates */
>         pkt_stat->rx_power[RF_PATH_A] = pwdb - 110;

It only uses PATH_A for receiving CCK rates packets? The comment seems
not clear enough.

Chris
Tony Chuang Sept. 12, 2019, 7:43 a.m. UTC | #2
> From: Chris Chiu 
> 
> On Thu, Sep 12, 2019 at 2:39 PM <yhchuang@realtek.com> wrote:
> >
> > From: Yan-Hsuan Chuang <yhchuang@realtek.com>
> >
> > Report chains and chain_signal in ieee80211_rx_status.
> > It is useful for program such as tcpdump to see if the
> > antennas are well connected/placed.
> >
> > 8822C is able to receive CCK rates with 2 antennas, while
> > 8822B can only use 1 antenna path to receive CCK rates.
> >
> > Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
> > ---
> >  drivers/net/wireless/realtek/rtw88/rtw8822b.c | 1 +
> >  drivers/net/wireless/realtek/rtw88/rtw8822c.c | 6 +++---
> >  drivers/net/wireless/realtek/rtw88/rx.c       | 5 +++++
> >  3 files changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> > index 568033a..0861195 100644
> > --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> > +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
> > @@ -766,6 +766,7 @@ static void query_phy_status_page0(struct rtw_dev
> *rtwdev, u8 *phy_status,
> >         s8 min_rx_power = -120;
> >         u8 pwdb = GET_PHY_STAT_P0_PWDB(phy_status);
> >
> > +       /* 8822B uses only 1 antenna to RX CCK rates */
> >         pkt_stat->rx_power[RF_PATH_A] = pwdb - 110;
> 
> It only uses PATH_A for receiving CCK rates packets? The comment seems
> not clear enough.
> 

Yes, it can only use PATH_A, so we don't have PWDB_[A|B] for 8822B.

Yan-Hsuan
Chris Chiu Sept. 12, 2019, 9:11 a.m. UTC | #3
On Thu, Sep 12, 2019 at 3:43 PM Tony Chuang <yhchuang@realtek.com> wrote:

> > >
> > > From: Yan-Hsuan Chuang <yhchuang@realtek.com>
> > >
> > > Report chains and chain_signal in ieee80211_rx_status.
> > > It is useful for program such as tcpdump to see if the
> > > antennas are well connected/placed.
> > >
> > > 8822C is able to receive CCK rates with 2 antennas, while
> > > 8822B can only use 1 antenna path to receive CCK rates.
> > >
> > > Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Reviewed-by: Chris Chiu <chiu@endlessm.com>

Patch
diff mbox series

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
index 568033a..0861195 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
@@ -766,6 +766,7 @@  static void query_phy_status_page0(struct rtw_dev *rtwdev, u8 *phy_status,
 	s8 min_rx_power = -120;
 	u8 pwdb = GET_PHY_STAT_P0_PWDB(phy_status);
 
+	/* 8822B uses only 1 antenna to RX CCK rates */
 	pkt_stat->rx_power[RF_PATH_A] = pwdb - 110;
 	pkt_stat->rssi = rtw_phy_rf_power_2_rssi(pkt_stat->rx_power, 1);
 	pkt_stat->bw = RTW_CHANNEL_WIDTH_20;
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c
index 24b27bc..75c77ac 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c
@@ -1627,9 +1627,9 @@  static void query_phy_status_page0(struct rtw_dev *rtwdev, u8 *phy_status,
 	rx_power[RF_PATH_A] -= 110;
 	rx_power[RF_PATH_B] -= 110;
 
-	pkt_stat->rx_power[RF_PATH_A] = max3(rx_power[RF_PATH_A],
-					     rx_power[RF_PATH_B],
-					     min_rx_power);
+	pkt_stat->rx_power[RF_PATH_A] = rx_power[RF_PATH_A];
+	pkt_stat->rx_power[RF_PATH_B] = rx_power[RF_PATH_B];
+
 	pkt_stat->rssi = rtw_phy_rf_power_2_rssi(pkt_stat->rx_power, 1);
 	pkt_stat->bw = RTW_CHANNEL_WIDTH_20;
 	pkt_stat->signal_power = max(pkt_stat->rx_power[RF_PATH_A],
diff --git a/drivers/net/wireless/realtek/rtw88/rx.c b/drivers/net/wireless/realtek/rtw88/rx.c
index 4d837f0..48b9ed4 100644
--- a/drivers/net/wireless/realtek/rtw88/rx.c
+++ b/drivers/net/wireless/realtek/rtw88/rx.c
@@ -90,6 +90,7 @@  void rtw_rx_fill_rx_status(struct rtw_dev *rtwdev,
 			   u8 *phy_status)
 {
 	struct ieee80211_hw *hw = rtwdev->hw;
+	u8 path;
 
 	memset(rx_status, 0, sizeof(*rx_status));
 	rx_status->freq = hw->conf.chandef.chan->center_freq;
@@ -146,6 +147,10 @@  void rtw_rx_fill_rx_status(struct rtw_dev *rtwdev,
 		rx_status->bw = RATE_INFO_BW_20;
 
 	rx_status->signal = pkt_stat->signal_power;
+	for (path = 0; path < rtwdev->hal.rf_path_num; path++) {
+		rx_status->chains |= BIT(path);
+		rx_status->chain_signal[path] = pkt_stat->rx_power[path];
+	}
 
 	rtw_rx_addr_match(rtwdev, pkt_stat, hdr);
 }