All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislaw Gruszka <stf_xl@wp.pl>
To: Ho Jie Feng <hjf3108@gmail.com>
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH wireless-next v2 2/7] wifi: rt2800: calibrate the crystal of RT3593 with the beacons
Date: Thu, 5 Nov 2026 08:50:28 +0100	[thread overview]
Message-ID: <20261105075028.GB64923@wp.pl> (raw)
In-Reply-To: <20261031165117.2868671-3-hjf3108@gmail.com>

Hi,

On Sun, Nov 01, 2026 at 12:51:09AM +0800, Ho Jie Feng wrote:
> On a Netgear WNDA4100 (RT3593), as the adapter warms up, the
> frequency offset drifts enough to affect the link quality.
> In certain cases it can cause the link speed to drop
> to 1Mbit/s or below.
> 
> Add a frequency calibration step function to RT3593 to use
> the frequency offset obtained from the beacon frames of the AP
> for tuning.
> 
> Test results:
>    before after
> TX 27.7   28.5
> RX 31.6   69.7
> 
> Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
> ---
>  drivers/net/wireless/ralink/rt2x00/rt2800.h   |   1 +
>  .../net/wireless/ralink/rt2x00/rt2800lib.c    | 101 ++++++++++++++++++
>  .../net/wireless/ralink/rt2x00/rt2800lib.h    |   4 +
>  .../net/wireless/ralink/rt2x00/rt2800usb.c    |   1 +
>  drivers/net/wireless/ralink/rt2x00/rt2x00.h   |   6 ++
>  .../net/wireless/ralink/rt2x00/rt2x00lib.h    |   2 +
>  .../net/wireless/ralink/rt2x00/rt2x00link.c   |   9 ++
>  7 files changed, 124 insertions(+)
> 
> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h b/drivers/net/wireless/ralink/rt2x00/rt2800.h
> index 8930589b4967d..b9f6de3a462e3 100644
> --- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
> +++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
> @@ -3163,6 +3163,7 @@ enum rt2800_eeprom_word {
>   */
>  #define RXWI_W3_SNR0			FIELD32(0x000000ff)
>  #define RXWI_W3_SNR1			FIELD32(0x0000ff00)
> +#define RXWI_W3_FOFFSET			FIELD32(0xff000000)
>  
>  /*
>   * Macros for converting txpower from EEPROM to mac80211 value
> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
> index 2e2e382b62475..e7b6edf485099 100644
> --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
> +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
> @@ -897,6 +897,28 @@ static int rt2800_agc_to_rssi(struct rt2x00_dev *rt2x00dev, u32 rxwi_w2)
>  	return (int)max(rssi0, rssi2);
>  }
>  
> +static void rt2800_rx_freq_offset(struct queue_entry *entry,
> +				  struct rxdone_entry_desc *rxdesc)
> +{
> +	struct rt2800_drv_data *drv_data = entry->queue->rt2x00dev->drv_data;
> +	__le32 *rxwi = (__le32 *) entry->skb->data;
> +	struct ieee80211_hdr *hdr =
> +	    (void *)(entry->skb->data + entry->queue->winfo_size);
> +	u32 word;
> +
> +	if (!(rxdesc->dev_flags & RXDONE_MY_BSS) ||
> +	    (rxdesc->flags & RX_FLAG_FAILED_FCS_CRC) ||
> +	    !ieee80211_is_beacon(hdr->frame_control))
> +		return;
> +
> +	word = rt2x00_desc_read(rxwi, 3);
> +
> +	spin_lock_bh(&drv_data->bcn_lock);
> +	drv_data->bcn_freq_offset = rt2x00_get_field32(word, RXWI_W3_FOFFSET);
> +	drv_data->bcn_rate_mode = rxdesc->rate_mode;
> +	spin_unlock_bh(&drv_data->bcn_lock);
> +}
> +
>  void rt2800_process_rxwi(struct queue_entry *entry,
>  			 struct rxdone_entry_desc *rxdesc)
>  {
> @@ -935,6 +957,14 @@ void rt2800_process_rxwi(struct queue_entry *entry,
>  	 * Convert descriptor AGC value to RSSI value.
>  	 */
>  	rxdesc->rssi = rt2800_agc_to_rssi(entry->queue->rt2x00dev, word);
> +
> +	/*
> +	 * The frequency offset of the beacons is used for the frequency
> +	 * calibration.
> +	 */
> +	if (rt2x00_rt(entry->queue->rt2x00dev, RT3593))
> +		rt2800_rx_freq_offset(entry, rxdesc);
> +

I dislike fact that this is part of ->fill_rxdone() callback.
I think it would be better to add new field in rxdesc and
add flag there indicating the bcn_freq_offset is valid. 

Then add new function in rt2x00lib_rxdone_skb().

Regards
Stanislaw


  reply	other threads:[~2026-11-05  7:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-31 16:51 [PATCH wireless-next v2 0/7] wifi: rt2x00: improve the throughput of rt2800usb Ho Jie Feng
2026-10-31 16:51 ` [PATCH wireless-next v2 1/7] wifi: rt2x00: start the link tuner when an interface is added Ho Jie Feng
2026-11-05  7:41   ` Stanislaw Gruszka
2026-10-31 16:51 ` [PATCH wireless-next v2 2/7] wifi: rt2800: calibrate the crystal of RT3593 with the beacons Ho Jie Feng
2026-11-05  7:50   ` Stanislaw Gruszka [this message]
2026-10-31 16:51 ` [PATCH wireless-next v2 3/7] wifi: rt2800: make MCS 16 fall back to MCS 8 on devices with 3 TX chains Ho Jie Feng
2026-11-05  7:54   ` Stanislaw Gruszka
2026-10-31 16:51 ` [PATCH wireless-next v2 4/7] wifi: rt2800: don't report an A-MPDU length to minstrel_ht Ho Jie Feng
2026-11-05  7:54   ` Stanislaw Gruszka
2026-10-31 16:51 ` [PATCH wireless-next v2 5/7] wifi: rt2800: support A-MSDU in A-MPDU Ho Jie Feng
2026-11-05  7:55   ` Stanislaw Gruszka
2026-11-10 13:33     ` Jie Feng
2026-10-31 16:51 ` [PATCH wireless-next v2 6/7] wifi: rt2800usb: enable RX bulk aggregation Ho Jie Feng
2026-11-05  8:10   ` Stanislaw Gruszka
2026-11-06  5:18     ` Jie Feng
2026-11-06  9:53       ` Stanislaw Gruszka
2026-10-31 16:51 ` [PATCH wireless-next v2 7/7] wifi: rt2x00usb: use a threaded NAPI with GRO for RX Ho Jie Feng
2026-11-05  8:20   ` Stanislaw Gruszka
2026-11-06  7:38     ` Jie Feng
2026-10-31 16:55 ` [PATCH wireless-next v2 0/7] wifi: rt2x00: improve the throughput of rt2800usb Jie Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261105075028.GB64923@wp.pl \
    --to=stf_xl@wp.pl \
    --cc=hjf3108@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.