Skip to content

Support transmit power #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2024
Merged

Support transmit power #68

merged 1 commit into from
Jun 5, 2024

Conversation

jychen0611
Copy link
Collaborator

@jychen0611 jychen0611 commented Jun 2, 2024

Add tx_power to the virtual interface to describe the device's transmit power.

Implement vwifi_set_tx_power and vwifi_get_tx_power to correspond to set_tx_power and get_tx_power in cfg80211_ops, respectively.
vwifi_set_tx_power can set the device's transmit power, while vwifi_get_tx_power can retrieve the transmit power information.

The transmit power can be set using the iwconfig vwn txpower command.

phy#12
	Interface vw2
		ifindex 14
		wdev 0xc00000001
		addr 00:76:77:32:00:00
		type managed
		txpower 13.00 dBm
phy#11
	Interface vw1
		ifindex 13
		wdev 0xb00000001
		addr 00:76:77:31:00:00
		type managed
		txpower 12.00 dBm
phy#10
	Interface vw0
		ifindex 12
		wdev 0xa00000001
		addr 00:76:77:30:00:00
		type managed
		txpower 11.00 dBm

@jserv jserv requested review from rickywu0421 and dungru June 2, 2024 13:06
@jychen0611
Copy link
Collaborator Author

In the future, we may be able to introduce device coordinate parameters to calculate the RSSI value in free space in conjunction with transmit power.

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve the git commit message. Consider the following:

This commit introduces 'tx_power' to the virtual interface to specify
the device's transmit power level. It also adds vwifi_set_tx_power()
and vwifi_get_tx_power() to align with 'set_tx_power' and 'get_tx_power'
in cfg80211_ops, respectively. The vwifi_set_tx_power() enables the
setting of the device's transmit power, whereas vwifi_get_tx_power()
facilitates the retrieval of this information.

Users can adjust the transmit power by employing the command:
iwconfig vwN txpower
where N stands for the entry of network interface.

Also, you should avoid using "iwconfig," which is deprecated. Use "iw" command for consistency.

See https://dougvitale.wordpress.com/2011/12/21/deprecated-linux-networking-commands-and-their-replacements/#iwconfig

@jychen0611
Copy link
Collaborator Author

jychen0611 commented Jun 3, 2024

Also, you should avoid using "iwconfig," which is deprecated. Use "iw" command for consistency.

See https://dougvitale.wordpress.com/2011/12/21/deprecated-linux-networking-commands-and-their-replacements/#iwconfig

I'm currently facing an problem when using sudo iw dev vw0 set txpower fixed 1000
The wdev is NULL.

[ 1623.934439] wdev: 0000000000000000, vif: 0000000000000000
[ 1623.934447] wdev is NULL

Thus, I tried using wiphy to obtain vif, and it worked. 👍 👍

I found that the current set_tx_power function in Linux does not use the wdev parameter either.
Could this be related to the changes between iwconfig and iw ?

I found that the function definition didn't use wdev before v3.7.10.
In v3.8-rc1, wdev was added to the function definition.

v3.7.10

int	(*set_tx_power)(struct wiphy* wiphy, enum nl80211_tx_power_setting type, int mbm);

cfg80211: allow per interface TX power setting

The TX power setting is currently per wiphy (hardware
device) but with multi-channel capabilities that doesn't
make much sense any more.

Allow drivers (and mac80211) to advertise support for
per-interface TX power configuration. When the TX power
is configured for the wiphy, the wdev will be NULL
and
the driver can still handle that, but when a wdev is
given the TX power can be set only for that wdev now.

Signed-off-by: Johannes Berg johannes.berg@intel.com

v3.8-rc1

int	(*set_tx_power)(struct wiphy* wiphy, struct wireless_dev* wdev, enum nl80211_tx_power_setting type, int mbm);

mwifiex: add a cfg80211 .get_tx_power operation callback

The mwifiex driver implements a cfg80211 .set_tx_power operation handler
but doesn't have the inverse .get_tx_power callback.

This not only has the effect that the Tx power can't be reported to user
space tools such as iwconfig and iwlist but also that the wireless core
prints a warning when a new wiphy is created due an cfg80211 operation
being implemented without its counterpart.

After this patch, the Tx power is properly reported to user-space tools:
$ iwlist mlan0 txpower
mlan0 unknown transmit-power information.
Current Tx-Power=13 dBm (19 mW)

@jserv
Copy link
Contributor

jserv commented Jun 5, 2024

If this pull request is ready for reviewing, use git rebase -i to squash and refine the git commit message. Then, request the reviewers via GitHub web page.

This commit introduces 'tx_power' to the virtual interface to specify
the device's transmit power level. It also adds vwifi_set_tx_power()
and vwifi_get_tx_power() to align with 'set_tx_power' and 'get_tx_power'
in cfg80211_ops, respectively. The vwifi_set_tx_power() enables the
setting of the device's transmit power, whereas vwifi_get_tx_power()
facilitates the retrieval of this information.

Users can adjust the transmit power by employing the command:

iw dev [interface] set txpower auto/limit/fixed [transmit power (mBm)]

auto: Use default transmit power
limit: Restrict power limits to a specific value
fixed: Set power freely

Since using the above command results in the 'wdev' parameter NULL,
a new function 'wiphy_get_vwifi_vif' was added to obtain the virtual
interface. Additionally, the 'type' parameter is used to distinguish
between "auto/limit/fixed".

This commit also modifies the comments regarding mBm.
In Linux source files, the correct terminology is mBm rather than mdBm.
In traditional measurements, 'm' usually represents 10 to the power of
negative three. However, 1 dBm equals 100 mBm, so using mdBm could be
misleading.
@jychen0611 jychen0611 requested a review from jserv June 5, 2024 05:40
@jserv jserv merged commit db7245e into sysprog21:main Jun 5, 2024
4 checks passed
@jserv
Copy link
Contributor

jserv commented Jun 5, 2024

Thank @jychen0611 for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants