Skip to content

Commit a580f4a

Browse files
committed
Support transmit power
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.
1 parent a8bdf8a commit a580f4a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

scripts/verify.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ if [ $final_ret -eq 0 ]; then
2424
# to avoid device or resource busy error
2525
sleep 0.5
2626

27+
# set transmit power
28+
sudo iwconfig vw0 txpower 11
29+
sudo iwconfig vw1 txpower 12
30+
sudo iwconfig vw2 txpower 13
31+
2732
# get phy number of each interface
2833
sudo iw dev > device.log
2934
vw0_phy=$(get_wiphy_name vw0)

vwifi.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ struct vwifi_vif {
155155

156156
/* Packet virtio header size */
157157
u8 vnet_hdr_len;
158+
159+
/* Transmit power */
160+
s32 tx_power;
158161
};
159162

160163
static int station = 2;
@@ -1840,6 +1843,28 @@ static int vwifi_delete_interface(struct vwifi_vif *vif)
18401843
return 0;
18411844
}
18421845

1846+
/* Set transmit power for the virtual interface */
1847+
static int vwifi_set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
1848+
enum nl80211_tx_power_setting type, int mbm)
1849+
{
1850+
struct vwifi_vif *vif = wdev_get_vwifi_vif(wdev);
1851+
if (mutex_lock_interruptible(&vif->lock))
1852+
return -ERESTARTSYS;
1853+
/* 1 DBM = 100 MBM */
1854+
vif->tx_power = MBM_TO_DBM(mbm);
1855+
mutex_unlock(&vif->lock);
1856+
return 0;
1857+
}
1858+
1859+
/* Get transmit power from the virtual interface */
1860+
static int vwifi_get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
1861+
int *dbm)
1862+
{
1863+
struct vwifi_vif *vif = wdev_get_vwifi_vif(wdev);
1864+
*dbm = vif->tx_power;
1865+
return 0;
1866+
}
1867+
18431868
/* Structure of functions for FullMAC 80211 drivers. Functions implemented
18441869
* along with fields/flags in the wiphy structure represent driver features.
18451870
* This module can only perform "scan" and "connect". Some functions cannot
@@ -1860,6 +1885,8 @@ static struct cfg80211_ops vwifi_cfg_ops = {
18601885
.del_key = vwifi_del_key,
18611886
.set_default_key = vwifi_set_default_key,
18621887
.change_station = vwifi_change_station,
1888+
.set_tx_power = vwifi_set_tx_power,
1889+
.get_tx_power = vwifi_get_tx_power,
18631890
};
18641891

18651892
/* Macro for defining 2GHZ channel array */

0 commit comments

Comments
 (0)