Message ID | 20230322171905.492855-10-martin.kaistra@linutronix.de |
---|---|
State | Superseded |
Headers | show |
Series | wifi: rtl8xxxu: Add AP mode support for 8188f | expand |
> -----Original Message----- > From: Martin Kaistra <martin.kaistra@linutronix.de> > Sent: Thursday, March 23, 2023 1:19 AM > To: linux-wireless@vger.kernel.org > Cc: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; Ping-Ke Shih > <pkshih@realtek.com>; Bitterblue Smith <rtl8821cerfe2@gmail.com>; Sebastian Andrzej Siewior > <bigeasy@linutronix.de> > Subject: [RFC PATCH 09/14] wifi: rtl8xxxu: Add parameter role to report_connect > > This allows to tell the HW if a connection is made to a STA or an AP. > Add the implementation for the gen2 version. > > Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de> > --- > drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 9 ++++++--- > drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 11 ++++++----- > 2 files changed, 12 insertions(+), 8 deletions(-) > > diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h > b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h > index c06ad33645974..e78e0bbd23354 100644 > --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h > +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h > @@ -1280,6 +1280,9 @@ struct rtl8xxxu_rfregs { > #define H2C_JOIN_BSS_DISCONNECT 0 > #define H2C_JOIN_BSS_CONNECT 1 > > +#define H2C_ROLE_STA 1 > +#define H2C_ROLE_AP 2 > + > /* > * H2C (firmware) commands differ between the older generation chips > * 8188[cr]u, 819[12]cu, and 8723au, and the more recent chips 8723bu, > @@ -1908,7 +1911,7 @@ struct rtl8xxxu_fileops { > u32 ramask, u8 rateid, int sgi, int txbw_40mhz, > u8 macid); > void (*report_connect) (struct rtl8xxxu_priv *priv, > - u8 macid, bool connect); > + u8 macid, u8 role, bool connect); > void (*report_rssi) (struct rtl8xxxu_priv *priv, u8 macid, u8 rssi); > void (*fill_txdesc) (struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, > struct ieee80211_tx_info *tx_info, > @@ -2012,9 +2015,9 @@ void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv, > void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv, > u32 ramask, u8 rateid, int sgi, int txbw_40mhz, u8 macid); > void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, > - u8 macid, bool connect); > + u8 macid, u8 role, bool connect); > void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, > - u8 macid, bool connect); > + u8 macid, u8 role, bool connect); > void rtl8xxxu_gen1_report_rssi(struct rtl8xxxu_priv *priv, u8 macid, u8 rssi); > void rtl8xxxu_gen2_report_rssi(struct rtl8xxxu_priv *priv, u8 macid, u8 rssi); > void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv); > diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c > b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c > index 4209880d724be..5e36fddbbb488 100644 > --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c > +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c > @@ -4524,7 +4524,7 @@ void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv, > } > > void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, > - u8 macid, bool connect) > + u8 macid, u8 role, bool connect) > { > struct h2c_cmd h2c; > > @@ -4541,7 +4541,7 @@ void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, > } > > void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, > - u8 macid, bool connect) > + u8 macid, u8 role, bool connect) > { > /* > * The firmware turns on the rate control when it knows it's > @@ -4557,6 +4557,7 @@ void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, > else > h2c.media_status_rpt.parm &= ~BIT(0); > > + h2c.media_status_rpt.parm |= ((role << 4) & 0xf0); > h2c.media_status_rpt.macid = macid; > > rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.media_status_rpt)); > @@ -4886,13 +4887,13 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, > rtl8xxxu_write16(priv, REG_BCN_PSR_RPT, > 0xc000 | vif->cfg.aid); > > - priv->fops->report_connect(priv, 0, true); > + priv->fops->report_connect(priv, 0, H2C_ROLE_AP, true); Should it be called only AP mode? Because STA mode can run into this too. > } else { > val8 = rtl8xxxu_read8(priv, REG_BEACON_CTRL); > val8 |= BEACON_DISABLE_TSF_UPDATE; > rtl8xxxu_write8(priv, REG_BEACON_CTRL, val8); > > - priv->fops->report_connect(priv, 0, false); > + priv->fops->report_connect(priv, 0, H2C_ROLE_AP, false); > } > } > > @@ -4953,7 +4954,7 @@ static int rtl8xxxu_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, > dev_dbg(dev, "Start AP mode\n"); > rtl8xxxu_set_bssid(priv, vif->bss_conf.bssid); > rtl8xxxu_write16(priv, REG_BCN_INTERVAL, vif->bss_conf.beacon_int); > - priv->fops->report_connect(priv, 0, true); > + priv->fops->report_connect(priv, 0, 0, true); > > return 0; > } > -- > 2.30.2
On 22/03/2023 19:19, Martin Kaistra wrote: > This allows to tell the HW if a connection is made to a STA or an AP. > Add the implementation for the gen2 version. > > Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de> > --- > drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 9 ++++++--- > drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 11 ++++++----- > 2 files changed, 12 insertions(+), 8 deletions(-) > > diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h > index c06ad33645974..e78e0bbd23354 100644 > --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h > +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h > @@ -1280,6 +1280,9 @@ struct rtl8xxxu_rfregs { > #define H2C_JOIN_BSS_DISCONNECT 0 > #define H2C_JOIN_BSS_CONNECT 1 > > +#define H2C_ROLE_STA 1 > +#define H2C_ROLE_AP 2 > + They describe the role of a macid, so maybe call them H2C_MACID_ROLE_*. > /* > * H2C (firmware) commands differ between the older generation chips > * 8188[cr]u, 819[12]cu, and 8723au, and the more recent chips 8723bu, > @@ -1908,7 +1911,7 @@ struct rtl8xxxu_fileops { > u32 ramask, u8 rateid, int sgi, int txbw_40mhz, > u8 macid); > void (*report_connect) (struct rtl8xxxu_priv *priv, > - u8 macid, bool connect); > + u8 macid, u8 role, bool connect); > void (*report_rssi) (struct rtl8xxxu_priv *priv, u8 macid, u8 rssi); > void (*fill_txdesc) (struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, > struct ieee80211_tx_info *tx_info, > @@ -2012,9 +2015,9 @@ void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv, > void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv, > u32 ramask, u8 rateid, int sgi, int txbw_40mhz, u8 macid); > void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, > - u8 macid, bool connect); > + u8 macid, u8 role, bool connect); > void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, > - u8 macid, bool connect); > + u8 macid, u8 role, bool connect); > void rtl8xxxu_gen1_report_rssi(struct rtl8xxxu_priv *priv, u8 macid, u8 rssi); > void rtl8xxxu_gen2_report_rssi(struct rtl8xxxu_priv *priv, u8 macid, u8 rssi); > void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv); > diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c > index 4209880d724be..5e36fddbbb488 100644 > --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c > +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c > @@ -4524,7 +4524,7 @@ void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv, > } > > void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, > - u8 macid, bool connect) > + u8 macid, u8 role, bool connect) > { > struct h2c_cmd h2c; > > @@ -4541,7 +4541,7 @@ void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, > } > > void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, > - u8 macid, bool connect) > + u8 macid, u8 role, bool connect) > { > /* > * The firmware turns on the rate control when it knows it's > @@ -4557,6 +4557,7 @@ void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, > else > h2c.media_status_rpt.parm &= ~BIT(0); > > + h2c.media_status_rpt.parm |= ((role << 4) & 0xf0); > h2c.media_status_rpt.macid = macid; > > rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.media_status_rpt)); > @@ -4886,13 +4887,13 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, > rtl8xxxu_write16(priv, REG_BCN_PSR_RPT, > 0xc000 | vif->cfg.aid); > > - priv->fops->report_connect(priv, 0, true); > + priv->fops->report_connect(priv, 0, H2C_ROLE_AP, true); > } else { > val8 = rtl8xxxu_read8(priv, REG_BEACON_CTRL); > val8 |= BEACON_DISABLE_TSF_UPDATE; > rtl8xxxu_write8(priv, REG_BEACON_CTRL, val8); > > - priv->fops->report_connect(priv, 0, false); > + priv->fops->report_connect(priv, 0, H2C_ROLE_AP, false); > } > } > > @@ -4953,7 +4954,7 @@ static int rtl8xxxu_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, > dev_dbg(dev, "Start AP mode\n"); > rtl8xxxu_set_bssid(priv, vif->bss_conf.bssid); > rtl8xxxu_write16(priv, REG_BCN_INTERVAL, vif->bss_conf.beacon_int); > - priv->fops->report_connect(priv, 0, true); > + priv->fops->report_connect(priv, 0, 0, true); > > return 0; > }
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h index c06ad33645974..e78e0bbd23354 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h @@ -1280,6 +1280,9 @@ struct rtl8xxxu_rfregs { #define H2C_JOIN_BSS_DISCONNECT 0 #define H2C_JOIN_BSS_CONNECT 1 +#define H2C_ROLE_STA 1 +#define H2C_ROLE_AP 2 + /* * H2C (firmware) commands differ between the older generation chips * 8188[cr]u, 819[12]cu, and 8723au, and the more recent chips 8723bu, @@ -1908,7 +1911,7 @@ struct rtl8xxxu_fileops { u32 ramask, u8 rateid, int sgi, int txbw_40mhz, u8 macid); void (*report_connect) (struct rtl8xxxu_priv *priv, - u8 macid, bool connect); + u8 macid, u8 role, bool connect); void (*report_rssi) (struct rtl8xxxu_priv *priv, u8 macid, u8 rssi); void (*fill_txdesc) (struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, struct ieee80211_tx_info *tx_info, @@ -2012,9 +2015,9 @@ void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv, void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv, u32 ramask, u8 rateid, int sgi, int txbw_40mhz, u8 macid); void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, - u8 macid, bool connect); + u8 macid, u8 role, bool connect); void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, - u8 macid, bool connect); + u8 macid, u8 role, bool connect); void rtl8xxxu_gen1_report_rssi(struct rtl8xxxu_priv *priv, u8 macid, u8 rssi); void rtl8xxxu_gen2_report_rssi(struct rtl8xxxu_priv *priv, u8 macid, u8 rssi); void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv); diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 4209880d724be..5e36fddbbb488 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -4524,7 +4524,7 @@ void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv, } void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, - u8 macid, bool connect) + u8 macid, u8 role, bool connect) { struct h2c_cmd h2c; @@ -4541,7 +4541,7 @@ void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, } void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, - u8 macid, bool connect) + u8 macid, u8 role, bool connect) { /* * The firmware turns on the rate control when it knows it's @@ -4557,6 +4557,7 @@ void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, else h2c.media_status_rpt.parm &= ~BIT(0); + h2c.media_status_rpt.parm |= ((role << 4) & 0xf0); h2c.media_status_rpt.macid = macid; rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.media_status_rpt)); @@ -4886,13 +4887,13 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, rtl8xxxu_write16(priv, REG_BCN_PSR_RPT, 0xc000 | vif->cfg.aid); - priv->fops->report_connect(priv, 0, true); + priv->fops->report_connect(priv, 0, H2C_ROLE_AP, true); } else { val8 = rtl8xxxu_read8(priv, REG_BEACON_CTRL); val8 |= BEACON_DISABLE_TSF_UPDATE; rtl8xxxu_write8(priv, REG_BEACON_CTRL, val8); - priv->fops->report_connect(priv, 0, false); + priv->fops->report_connect(priv, 0, H2C_ROLE_AP, false); } } @@ -4953,7 +4954,7 @@ static int rtl8xxxu_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, dev_dbg(dev, "Start AP mode\n"); rtl8xxxu_set_bssid(priv, vif->bss_conf.bssid); rtl8xxxu_write16(priv, REG_BCN_INTERVAL, vif->bss_conf.beacon_int); - priv->fops->report_connect(priv, 0, true); + priv->fops->report_connect(priv, 0, 0, true); return 0; }
This allows to tell the HW if a connection is made to a STA or an AP. Add the implementation for the gen2 version. Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de> --- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 9 ++++++--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 11 ++++++----- 2 files changed, 12 insertions(+), 8 deletions(-)