Skip to content

Commit f9f00f0

Browse files
Store GI in cfg80211_bitrate_mask, enhance MCS documentation, and integrate test script
This commit refactors the vwifi driver to store Guard Interval (GI) information solely in cfg80211_bitrate_mask, eliminating the redundant short_gi variable, and introduces a spatial stream index for future optimization. It also adds a comprehensive comment block for manual_mcs and updates the test script to validate all MCS indices (0–31) with sgi-2.4 and lgi-2.4. changes: - vwifi_vif: - Remove short_gi, storing GI in vif->bitrate_mask.control[NL80211_BAND_2GHZ].gi. - Add spatial_streams field (int, default 1) for future multi-stream support. - Add manual_mcs field with detailed comment block explaining its role in storing the first enabled MCS for consistent bitrate reporting. - vwifi_set_bitrate_mask: - Store GI in vif->bitrate_mask.control[NL80211_BAND_2GHZ].gi, removing short_gi usage. - vwifi_get_station: - GI logic using vif->bitrate_mask.gi for short (0.4µs), long (0.8µs), or default GI. - Correct pr_info format string for modulation and coding_rate alignment. - Configure sinfo->rxrate/txrate with vif->bitrate_mask.gi and vif->manual_mcs. Test script (test_vwifi_bitrates.sh): -Updated to test MCS 0–31 with sgi-2.4 and lgi-2.4: - Test header (Testing MCS <mcs> with <gi> on vw1). - GI status (Set GI to long/short). - iw dev vw1 link output (MAC, SSID, freq, RX/TX, signal, bitrates). - Success/failure message with actual vs. expected bitrate. - Add expected bitrate arrays for lgi-2.4 and sgi-2.4. - Enhance stability with 2s retry sleep, 1s sleep after iw set bitrates, and 2s setup delay. - Ensure cleanup resets bitrate. Testing: - Verified GI (0.4µs/0.8µs) and MCS (0–31) with iw dev vw1 set bitrates and iw dev vw1 link.
1 parent acc1bd1 commit f9f00f0

File tree

2 files changed

+231
-64
lines changed

2 files changed

+231
-64
lines changed

scripts/verify.sh

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ source $ROOT/scripts/common.sh
55

66
final_ret=0
77

8+
# Added logging setup from test_vwifi_bitrates
9+
LOG_DIR="/var/log/vwifi"
10+
LOG_FILE="$LOG_DIR/test_$(date +%F_%H-%M-%S).log"
11+
mkdir -p "$LOG_DIR"
12+
chmod 777 "$LOG_DIR"
13+
exec > >(tee -a "$LOG_FILE") 2>&1
14+
echo "vwifi Verification and Bitrate Test Log - $(date)" >> "$LOG_FILE"
15+
816
probe_kmod cfg80211
917
if [ $? -ne 0 ]; then
1018
final_ret=1
@@ -160,6 +168,86 @@ if [ $final_ret -eq 0 ]; then
160168
final_ret=7
161169
fi
162170

171+
# Bitrate testing from test_vwifi_bitrates
172+
echo "Testing MCS 0-31 with lgi-2.4 and sgi-2.4 on vw1" >> "$LOG_FILE"
173+
# Expected bitrates (Mbps) for MCS 0-31 for lgi-2.4 and sgi-2.4
174+
EXPECTED_BITRATES_LGI=(
175+
6.5 13.0 19.5 26.0 39.0 52.0 58.5 65.0 # MCS 0-7
176+
13.0 26.0 39.0 52.0 78.0 104.0 117.0 130.0 # MCS 8-15
177+
19.5 39.0 58.5 78.0 117.0 156.0 175.5 195.0 # MCS 16-23
178+
26.0 52.0 78.0 104.0 156.0 208.0 234.0 260.0 # MCS 24-31
179+
)
180+
EXPECTED_BITRATES_SGI=(
181+
7.2 14.4 21.7 28.9 43.3 57.8 65.0 72.2 # MCS 0-7
182+
14.4 28.9 43.3 57.8 86.7 115.6 130.0 144.4 # MCS 8-15
183+
21.7 43.3 65.0 86.7 130.0 173.3 195.0 216.7 # MCS 16-23
184+
28.9 57.8 86.7 115.6 173.3 231.1 260.0 288.9 # MCS 24-31
185+
)
186+
187+
# Function to test bitrate for a single MCS and GI
188+
test_bitrate() {
189+
local mcs=$1
190+
local gi=$2
191+
local expected_bitrate=$3
192+
local max_retries=3
193+
local retry=0
194+
local success=false
195+
196+
echo "----------------------------------------"
197+
echo "Testing MCS $mcs with $gi on vw1"
198+
199+
# Set GI string for logging
200+
if [ "$gi" = "sgi-2.4" ]; then
201+
echo "Set GI to short (0.4 µs)"
202+
else
203+
echo "Set GI to long (0.8 µs)"
204+
fi
205+
206+
while [ $retry -lt $max_retries ]; do
207+
# Set bitrate
208+
sudo ip netns exec ns1 iw dev vw1 set bitrates ht-mcs-2.4 $mcs $gi
209+
sleep 1 # Ensure bitrate applies
210+
211+
# Check connection
212+
output=$(sudo ip netns exec ns1 iw dev vw1 link)
213+
if echo "$output" | grep -q "Connected to"; then
214+
echo "$output"
215+
# Extract bitrate
216+
rx_bitrate=$(echo "$output" | grep "rx bitrate" | awk '{print $3}')
217+
rx_mcs=$(echo "$output" | grep "rx bitrate" | grep -o "MCS [0-9]\+")
218+
tx_bitrate=$(echo "$output" | grep "tx bitrate" | awk '{print $3}')
219+
tx_mcs=$(echo "$output" | grep "tx bitrate" | grep -o "MCS [0-9]\+")
220+
if [ "$rx_bitrate" = "$tx_bitrate" ] && [ "$rx_mcs" = "MCS $mcs" ] && [ "$tx_mcs" = "MCS $mcs" ] && [ "$rx_bitrate" = "$expected_bitrate" ]; then
221+
echo "Success: MCS $mcs $gi bitrate $rx_bitrate Mbps matches expected $expected_bitrate Mbps"
222+
success=true
223+
break
224+
fi
225+
fi
226+
retry=$((retry + 1))
227+
sleep 2 # Increase retry delay for stability
228+
done
229+
230+
if [ "$success" = false ]; then
231+
echo "Failed: MCS $mcs $gi did not connect or bitrate mismatch after $max_retries retries"
232+
final_ret=12 # New error code for bitrate test failure
233+
fi
234+
echo "----------------------------------------"
235+
}
236+
237+
# Test MCS 0-31 for lgi-2.4
238+
for mcs in {0..31}; do
239+
test_bitrate $mcs "lgi-2.4" "${EXPECTED_BITRATES_LGI[$mcs]}"
240+
done
241+
242+
# Test MCS 0-31 for sgi-2.4
243+
for mcs in {0..31}; do
244+
test_bitrate $mcs "sgi-2.4" "${EXPECTED_BITRATES_SGI[$mcs]}"
245+
done
246+
247+
# Reset bitrate to default
248+
sudo ip netns exec ns1 iw dev vw1 set bitrates ht-mcs-2.4 0 lgi-2.4
249+
echo "Bitrate reset to default MCS 0 lgi-2.4"
250+
163251
# vw3 becomes an IBSS and then joins the "ibss1" network.
164252
echo
165253
echo "=============="
@@ -276,4 +364,4 @@ fi
276364

277365
echo "FAILED (code: $final_ret)"
278366
echo "==== Test FAILED ===="
279-
exit $final_ret
367+
exit $final_ret

0 commit comments

Comments
 (0)