wifi: iwlwifi: Add support for tx-override feature.
PATCH 1/1 wifi: iwlwifi: Add support for tx-override feature.
From: Ben Greear <[email protected]>
This lets user-space request specific rates for 400+ byte dataframes, used for testing tx and rx sensitivity and correctness.
Signed-off-by Ben Greear <[email protected]>
---
Patch is against recent iwlwifi backports, and on top of other patches I've posted recently.
.../net/wireless/intel/iwlwifi/mvm/debugfs.c | 139 ++++++++++++++++++ drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 16 ++ drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 131 +++++++++++++++-- 3 files changed, 276 insertions(+), 10 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +139 -0
@@ -2546,6 +2546,142 @@ MVM_DEBUGFS_READ_WRITE_FILE_OPS(he_sniffer_params, 32);MVM_DEBUGFS_WRITE_FILE_OPS (ltr_config,512 );MVM_DEBUGFS_READ_WRITE_FILE_OPS (rfi_freq_table,16 ); +static ssize_t iwl_dbgfs_read_set_rate_override (struct file *file, +char __user *user_buf, +size_t count,loff_t *ppos) +{ +struct iwl_mvm *mvm = file->private_data; +struct iwl_txo_data *td = &mvm->txo_data; +char *buf2; +int size =8000 ; +int rv, sofar; +const char buf[] = +"This allows specifying tx rate parameters for larger DATA" +" frames. TPC is ignored for now. Dev-name is ignored, settings\n" +" apply radio wide for now.\n" +"To set a value, you specify the dev-name and key-value pairs:\n" +"tpc=10 sgi=1 mcs=x nss=x pream=x retries=x bw=x enable=0|1\n" +"pream: 0=cck, 1=ofdm, 2=HT, 3=VHT, 4=HE_SU, 5=EHT\n" +"cck-mcs: 0=1Mbps, 1=2Mbps, 3=5.5Mbps, 3=11Mbps\n" +"ofdm-mcs: 0=6Mbps, 1=9Mbps, 2=12Mbps, 3=18Mbps, 4=24Mbps, 5=36Mbps," +" 6=48Mbps, 7=54Mbps\n" +"tpc: adjust power from defaults, in 1/2 db units 0 - 31, 16 is default\n" +"sgi: VHT and lower: 0 off, 1 on\n" +"sgi: HE-SU: 0 1xLTF+0.8us, 1 2xLTF+0.8us, 2 2xLTF+1.6us, 3 4xLTF+3.2us, 4 4xLTF+0.8us\n" +"bw is 0-4 for 20-320\n" +" For example, wlan0:\n" +"echo \"wlan0 tpc=255 sgi=1 mcs=0 nss=1 pream=3 retries=1 bw=0" +" active=1\" > ...iwlwifi/set_rate_override\n" ; + + buf2 =kzalloc (size,GFP_KERNEL ); +if (!buf2) +return -ENOMEM ; +strcpy (buf2, buf); + sofar =strlen (buf2); + + sofar +=scnprintf (buf2 + sofar, size - sofar, +"vdev (%s) active=%d tpc=%d sgi=%d mcs=%d nss=%d" +" pream=%d retries=%d bw=%d\n" , +"all" , + td->txo_active, td->tx_power, + td->tx_rate_sgi, td->tx_rate_idx, + td->tx_rate_nss, td->tx_rate_mode, + td->tx_xmit_count, td->txbw); + + rv =simple_read_from_buffer (user_buf, count, ppos, buf2, sofar); +kfree (buf2); +return rv; +} + +/* Set the rate overrides for data frames. +*/ +static ssize_t iwl_dbgfs_write_set_rate_override (struct file *file, +const char __user *user_buf, +size_t count,loff_t *ppos) +{ +struct iwl_mvm *mvm = file->private_data; +struct iwl_txo_data *td = &mvm->txo_data; +char buf[180 ]; +char tmp[20 ]; +char *tok; +int ret; +char *bufptr = buf; +long rc; + +memset (buf,0 ,sizeof (buf)); + +simple_write_to_buffer (buf,sizeof (buf) -1 , ppos, user_buf, count); + +/* make sure that buf is null terminated */ + buf[sizeof (buf) -1 ] =0 ; + +/* drop the possible '\n' from the end */ +if (buf[count -1 ] =='\n' ) + buf[count -1 ] =0 ; + +/* Ignore empty lines, 'echo' appends them sometimes at least. */ +if (buf[0 ] ==0 ) { + ret = count; + goto exit; + } + +/* String starts with vdev name, ie 'wlan0' Find the proper vif that +* matches the name. (Well, ignore that for now actually.) +*/ + bufptr =strstr (buf," " ); +if (bufptr) + bufptr++;/* move past space */ + +#define IWLWIFI_PARSE_LTOK (a, b) \ + do { \ + tok = strstr(bufptr, " " #a "="); \ + if (tok) { \ + char *tspace; \ + tok += 1;/* move past initial space */ \ + strncpy(tmp, tok + strlen(#a "="), sizeof(tmp) - 1); \ + tmp[sizeof(tmp) - 1] = 0; \ + tspace = strstr(tmp, " "); \ + if (tspace) \ + *tspace = 0; \ + if (kstrtol(tmp, 0, &rc) != 0) \ + pr_info( \ + "mt7915: set-rate-override: " #a \ + "= could not be parsed, tmp: %s\n", \ + tmp); \ + else \ + td->b = rc; \ + } \ + } while (0) + +IWLWIFI_PARSE_LTOK (tpc, tx_power); +IWLWIFI_PARSE_LTOK (sgi, tx_rate_sgi); +IWLWIFI_PARSE_LTOK (mcs, tx_rate_idx); +IWLWIFI_PARSE_LTOK (nss, tx_rate_nss); +IWLWIFI_PARSE_LTOK (pream, tx_rate_mode); +IWLWIFI_PARSE_LTOK (retries, tx_xmit_count); +IWLWIFI_PARSE_LTOK (bw, txbw); +IWLWIFI_PARSE_LTOK (active, txo_active); + +pr_info ("iwlwifi: set-rate-overrides, active=%d tpc=%d sgi=%d mcs=%d" +" nss=%d pream=%d retries=%d bw=%d\n" , + td->txo_active, td->tx_power, td->tx_rate_sgi, td->tx_rate_idx, + td->tx_rate_nss, td->tx_rate_mode, td->tx_xmit_count, + td->txbw); + + ret = count; + +exit: +return ret; +} + +static const struct file_operations fops_set_rate_override = { + .read = iwl_dbgfs_read_set_rate_override, + .write = iwl_dbgfs_write_set_rate_override, + .open = simple_open, + .owner =THIS_MODULE , + .llseek = default_llseek, +}; +static ssize_t iwl_dbgfs_mem_read (struct file *file,char __user *user_buf,size_t count,loff_t *ppos) {
@@ -2842,6 +2978,9 @@ void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm)debugfs_create_file ("mem" ,0600 , mvm->debugfs_dir, mvm, &iwl_dbgfs_mem_ops); +debugfs_create_file ("set_rate_override" ,0600 , mvm->debugfs_dir, + mvm, &fops_set_rate_override); +/* * Create a symlink with mac80211. It will be removed when mac80211 * exists (before the opmode exists which removes the target.)
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +16 -0
@@ -902,6 +902,21 @@ struct iwl_time_sync_data {bool active; }; +struct iwl_txo_data { +u8 txo_active;/* tx overrides are active */ +u8 txbw;/* specify TX bandwidth: 0 20Mhz, 1 40Mhz, 2 80Mhz, 3 160Mhz, 4 320Mhz */ +/* SGI: VHT and lower: 0 off, 1 on +* HE-SU: 0 1xLTF+0.8us, 1 2xLTF+0.8us, 2 2xLTF+1.6us, 3 4xLTF+3.2us, 4 4xLTF+0.8us +*/ +u8 tx_rate_sgi; +u8 tx_rate_mode;/* 0=cck, 1=ofdm, 2=HT, 3=VHT, 4=HE_SU, 5=EHT */ +u8 tx_rate_idx; +u8 tx_rate_nss; + +u8 tx_power; +u8 tx_xmit_count;/* 0 means no-ack, 1 means one transmit, etc */ +}; +struct iwl_mvm {/* for logger access */ struct device *dev;
@@ -947,6 +962,7 @@ struct iwl_mvm {struct mvm_statistics_rx rx_stats; };struct iwl_mvm_ethtool_stats ethtool_stats; +struct iwl_txo_data txo_data;struct {u64 rx_time;
drivers/net/wireless/intel/iwlwifi/mvm/tx.c +121 -10
182 lines not on this page · raw message
Signature · 1 line
2.40.0
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h struct iwl_mvm { · line 965
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +1
-0struct iwl_mvm_ethtool_stats ethtool_stats; +struct iwl_txo_data txo_data;
Might be nicer to have this a pointer and be NULL if not active? that way you can also use proper RCU protection for it when changing it.
johannes