From: Marcus Glocker Subject: Re: sys/qwx,sys/qwz: report RSSI as percentage To: "Kirill A. Korinsky" Cc: tech@openbsd.org, Stefan Sperling Date: Thu, 21 May 2026 22:19:49 +0200 On Wed, May 20, 2026 at 01:02:13AM +0200, Kirill A. Korinsky wrote: > tech@, > > I think that Report RSSI as percentage, it is more user friendly than dBm. > > So, here I've used the same conversion logic as iwx for both qwz and qwx. > > Ok? I prefer the % display as well, and the diff works fine with my qwz. So basically ok mglocker@, but maybe it would be good to have stsp@'s feedback as well before we go ahead committing it. > Index: sys/dev/ic/qwx.c > =================================================================== > RCS file: /home/cvs/src/sys/dev/ic/qwx.c,v > diff -u -p -r1.111 qwx.c > --- sys/dev/ic/qwx.c 19 May 2026 10:36:02 -0000 1.111 > +++ sys/dev/ic/qwx.c 19 May 2026 22:39:09 -0000 > @@ -13534,6 +13534,7 @@ qwx_mgmt_rx_event(struct qwx_softc *sc, > struct ieee80211_rxinfo rxi; > struct ieee80211_frame *wh; > struct ieee80211_node *ni; > + int rssi, rssi_dbm; > > if (qwx_pull_mgmt_rx_params_tlv(sc, m, &rx_ev) != 0) { > printf("%s: failed to extract mgmt rx event\n", > @@ -13570,7 +13571,10 @@ qwx_mgmt_rx_event(struct qwx_softc *sc, > } > > rxi.rxi_chan = rx_ev.channel; > - rxi.rxi_rssi = rx_ev.snr + ATH11K_DEFAULT_NOISE_FLOOR; > + rssi_dbm = rx_ev.snr + ATH11K_DEFAULT_NOISE_FLOOR; > + rssi = (0 - QWX_MIN_DBM) + rssi_dbm; /* normalize */ > + rssi = MIN(rssi, ic->ic_max_rssi); /* clip to max. 100% */ > + rxi.rxi_rssi = rssi; > #if 0 > status->rate_idx = ath11k_mac_bitrate_to_idx(sband, rx_ev.rate / 100); > #endif > @@ -13627,7 +13631,7 @@ qwx_mgmt_rx_event(struct qwx_softc *sc, > } > tap->wr_rate = rx_ev.rate / 500; > tap->wr_chan_flags = htole16(chan_flags); > - tap->wr_dbm_antsignal = rxi.rxi_rssi; > + tap->wr_dbm_antsignal = rssi_dbm; > > bpf_mtap_hdr(sc->sc_drvbpf, tap, sc->sc_rxtap_len, > m, BPF_DIRECTION_IN); > @@ -16109,11 +16113,13 @@ qwx_dp_tx_complete_msdu(struct qwx_softc > */ > if (ts->status == HAL_WBM_TQM_REL_REASON_FRAME_ACKED && > ts->ack_rssi != 0) { > - int8_t rssi_dbm = (int8_t)ts->ack_rssi; > + int rssi = (int8_t)ts->ack_rssi; > if (!isset(sc->wmi.svc_map, > WMI_TLV_SERVICE_HW_DB2DBM_CONVERSION_SUPPORT)) > - rssi_dbm += ATH11K_DEFAULT_NOISE_FLOOR; > - tx_data->ni->ni_rssi = rssi_dbm; > + rssi += ATH11K_DEFAULT_NOISE_FLOOR; > + rssi = (0 - QWX_MIN_DBM) + rssi; /* normalize */ > + rssi = MIN(rssi, ic->ic_max_rssi); /* clip to max. 100% */ > + tx_data->ni->ni_rssi = rssi; > } > > ieee80211_release_node(ic, tx_data->ni); > Index: sys/dev/ic/qwxreg.h > =================================================================== > RCS file: /home/cvs/src/sys/dev/ic/qwxreg.h,v > diff -u -p -r1.12 qwxreg.h > --- sys/dev/ic/qwxreg.h 4 Aug 2025 11:39:50 -0000 1.12 > +++ sys/dev/ic/qwxreg.h 19 May 2026 22:28:22 -0000 > @@ -89,6 +89,8 @@ enum ath11k_crypt_mode { > > /* Antenna noise floor */ > #define ATH11K_DEFAULT_NOISE_FLOOR -95 > +#define QWX_MIN_DBM -100 > +#define QWX_MAX_DBM -33 /* realistic guess */ > > /* > * wmi.h > Index: sys/dev/ic/qwz.c > =================================================================== > RCS file: /home/cvs/src/sys/dev/ic/qwz.c,v > diff -u -p -r1.33 qwz.c > --- sys/dev/ic/qwz.c 19 May 2026 21:15:21 -0000 1.33 > +++ sys/dev/ic/qwz.c 19 May 2026 22:36:42 -0000 > @@ -11636,6 +11636,7 @@ qwz_mgmt_rx_event(struct qwz_softc *sc, > struct ieee80211_rxinfo rxi; > struct ieee80211_frame *wh; > struct ieee80211_node *ni; > + int rssi; > > if (qwz_pull_mgmt_rx_params_tlv(sc, m, &rx_ev) != 0) { > printf("%s: failed to extract mgmt rx event\n", > @@ -11672,7 +11673,10 @@ qwz_mgmt_rx_event(struct qwz_softc *sc, > } > > rxi.rxi_chan = rx_ev.channel; > - rxi.rxi_rssi = rx_ev.snr + ATH12K_DEFAULT_NOISE_FLOOR; > + rssi = rx_ev.snr + ATH12K_DEFAULT_NOISE_FLOOR; > + rssi = (0 - QWZ_MIN_DBM) + rssi; /* normalize */ > + rssi = MIN(rssi, ic->ic_max_rssi); /* clip to max. 100% */ > + rxi.rxi_rssi = rssi; > #if 0 > status->rate_idx = ath12k_mac_bitrate_to_idx(sband, rx_ev.rate / 100); > #endif > Index: sys/dev/ic/qwzreg.h > =================================================================== > RCS file: /home/cvs/src/sys/dev/ic/qwzreg.h,v > diff -u -p -r1.15 qwzreg.h > --- sys/dev/ic/qwzreg.h 18 May 2026 13:47:32 -0000 1.15 > +++ sys/dev/ic/qwzreg.h 19 May 2026 22:28:22 -0000 > @@ -83,6 +83,8 @@ enum ath12k_crypt_mode { > > /* Antenna noise floor */ > #define ATH12K_DEFAULT_NOISE_FLOOR -95 > +#define QWZ_MIN_DBM -100 > +#define QWZ_MAX_DBM -33 /* realistic guess */ > > /* > * wmi.h > Index: sys/dev/pci/if_qwx_pci.c > =================================================================== > RCS file: /home/cvs/src/sys/dev/pci/if_qwx_pci.c,v > diff -u -p -r1.33 if_qwx_pci.c > --- sys/dev/pci/if_qwx_pci.c 19 May 2026 08:57:27 -0000 1.33 > +++ sys/dev/pci/if_qwx_pci.c 19 May 2026 22:28:22 -0000 > @@ -1105,6 +1105,8 @@ unsupported_wcn6855_soc: > /* IBSS channel undefined for now. */ > ic->ic_ibss_chan = &ic->ic_channels[1]; > > + ic->ic_max_rssi = QWX_MAX_DBM - QWX_MIN_DBM; > + > ifp->if_softc = sc; > ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; > ifp->if_ioctl = qwx_ioctl; > Index: sys/dev/pci/if_qwz_pci.c > =================================================================== > RCS file: /home/cvs/src/sys/dev/pci/if_qwz_pci.c,v > diff -u -p -r1.11 if_qwz_pci.c > --- sys/dev/pci/if_qwz_pci.c 18 May 2026 13:47:32 -0000 1.11 > +++ sys/dev/pci/if_qwz_pci.c 19 May 2026 22:28:22 -0000 > @@ -983,6 +983,8 @@ qwz_pci_attach(struct device *parent, st > /* IBSS channel undefined for now. */ > ic->ic_ibss_chan = &ic->ic_channels[1]; > > + ic->ic_max_rssi = QWZ_MAX_DBM - QWZ_MIN_DBM; > + > ifp->if_softc = sc; > ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; > ifp->if_ioctl = qwz_ioctl; > > > > -- > wbr, Kirill >