Force client mode to connect at 20MHz and set data rates manually

I think I have found a solution to this problem.

Instead of forcing channel width to use 20MHz which I haven't found a way to do in OpenWrt.
I let 20MHz/40MHz coexistence work as is.
That way I can still get benefit of high throughput at 40MHz channel width when possible.

To make connection stable.
I changed wireless module parameters on mac80211 like this:

mac80211 beacon_loss_count=60 max_nullfunc_tries=60 max_probe_tries=60 probe_wait_ms=3600000

parm:           minstrel_vht_only:Use only VHT rates when VHT is supported by sta. (bool)
parm:           max_nullfunc_tries:Maximum nullfunc tx tries before disconnecting (reason 4). (int)
parm:           max_probe_tries:Maximum probe tries before disconnecting (reason 4). (int)
parm:           beacon_loss_count:Number of beacon intervals before we decide beacon was lost. (int)
parm:           probe_wait_ms:Maximum time(ms) to wait for probe response before disconnecting (reason 4). (int)
parm:           ieee80211_default_rc_algo:Default rate control algorithm for mac80211 to use (charp)

There is no problem in 2 days uptime!

References:

  1. https://forums.gentoo.org/viewtopic-t-1144053-start-0.html
  2. https://unix.stackexchange.com/questions/572962/system-setting-to-stop-wifi-from-dropping-connection

Notes: I have tried module parameter cfg80211_disable_40mhz_24ghz on cfg80211 but it does not work in client mode.