Commit 27b2237b78fd86653c1484ea7bb0d08e6edd31e8

Show received signal strength information

This patch allows user space tools such as iwconfig, iwlist and
NetworkManager show the relative received signal strength. It is still
incomplete in the sense that:

* The only PHY data reported by the tested acx111 chip was the RSSI, but
the mapping from RSSI units to dBm or the maximum RSSI value (in order
to estimate a percentage) is still unknown.

* The Windows XP driver (using ndiswrapper) reports quality, signal
level and noise level. The first one in percentage, the latter two in
dBm. Whether these values are right, remains to be determined. The
GPL'ed part of the AVM FRITZ!WLAN USB Stick sources show that at least
on the TNETW1450 only the RSSI value (mapped to signal level) seems to
be supported.

* There is currently a mapping from RSSI to percentage in the
acx_signal_to_winlevel() function. However, the same function in the
FreeBSD/DragonFlyBSD driver uses different calculation constants
depending on the chip type. Furthermore, the OpenBSD driver defines
maximum RSSI levels depending on the type of radio transceiver (i.e.
Maxim, Ralink, Radia, etc.). Contacting them in order to find out how
they got to those results would probably be a good idea.

Commit diff

common.c

 
387387
388388/***********************************************************************
389389** Calculate level like the feb 2003 windows driver seems to do
390*
391* Note: the FreeBSD and DragonFlyBSD drivers seems to use different
392* so-called correction constants depending on the chip. They will be
393* defined for now, but as it is still unknown whether they are correct
394* or not, only the original value will be used. Something else to take
395* into account is that the OpenBSD driver uses another approach and
396* defines the maximum RSSI value depending on the chip, rather than
397* using a value of 100 for all of them, as it is currently done here.
390398*/
399#define ACX100_RSSI_CORR 8
400#define ACX111_RSSI_CORR 5
391401static u8 acx_signal_to_winlevel(u8 rawlevel)
392402{
393403 /* u8 winlevel = (u8) (0.5 + 0.625 * rawlevel); */
394 u8 winlevel = ((4 + (rawlevel * 5)) / 8);
404 u8 winlevel = (((ACX100_RSSI_CORR / 2) + (rawlevel * 5)) /
405 ACX100_RSSI_CORR);
395406
396407 if (winlevel > 100)
397408 winlevel = 100;
21542154 adev->tx_level_dbm = 15;
21552155 }
21562156 if (level_dbm != adev->tx_level_dbm)
2157 acx_log(LOG_WARNING, L_INIT, "acx111 firmware has specific "
2158 "power levels only: adjusted %d dBm to %d dBm!\n",
2159 level_dbm, adev->tx_level_dbm);
2157 acx_log(LOG_WARNING, L_INIT, "only predefined transmission "
2158 "power levels are supported at this time: "
2159 "adjusted %d dBm to %d dBm\n", level_dbm,
2160 adev->tx_level_dbm);
21602161
21612162 return acx_s_configure(adev, &tx_level, ACX1xx_REG_DOT11_TX_POWER_LEVEL);
21622163}
23562356 /* length of frame from control field to first byte of FCS */
23572357 buf_len = RXBUF_BYTES_RCVD(adev, rxbuf);
23582358
2359 acx_log_dump(LOG_DEBUG, L_DATA, hdr, buf_len, "RX: 802.11 buffer:\n");
2359 acx_log_dump(LOG_DEBUG, L_XFER | L_DATA, hdr, buf_len,
2360 "rx: 802.11 buffer:\n");
23602361
23612362 acx_l_rx(adev, rxbuf);
23622363 /* Now check Rx quality level, AFTER processing packet.
23672367 * be expressed in dBm, or it's some pretty complicated
23682368 * calculation. */
23692369
2370#ifdef FROM_SCAN_SOURCE_ONLY
2371 /* only consider packets originating from the MAC
2372 * address of the device that's managing our BSSID.
2373 * Disable it for now, since it removes information (levels
2374 * from different peers) and slows the Rx path. *//*
2375 if (adev->ap_client && mac_is_equal(hdr->a2, adev->ap_client->address)) {
2376*/
2377#endif
2370 /* TODO: only the RSSI seems to be reported */
2371 adev->rx_status.ssi = acx_signal_to_winlevel(rxbuf->phy_level);
23782372
23792373 FN_EXIT0;
23802374}
26832683// memset(&status, 0, sizeof(status));
26842684
26852685 status->mactime = rxbuf->time;
2686 status->ssi = acx_signal_to_winlevel(rxbuf->phy_level);
2687 /* TODO: they do not seem to be reported, at least on the acx111
2688 * (and TNETW1450?), therefore commenting them out
26862689 status->signal = acx_signal_to_winlevel(rxbuf->phy_level);
2687 status->noise = acx_signal_to_winlevel(rxbuf->phy_snr);
2690 status->noise = acx_signal_to_winlevel(rxbuf->phy_snr); */
26882691 status->flag = 0;
26892692 status->rate = rxbuf->phy_plcp_signal;
26902693 status->antenna = 1;
toggle raw diff

pci.c

 
14851485 */
14861486 ieee->queues = 1;
14871487
1488 /* TODO: although in the original driver the maximum value was 100,
1489 * the OpenBSD driver assigns maximum values depending on the type of
1490 * radio transceiver (i.e. Radia, Maxim, etc.). This value is always a
1491 * positive integer which most probably indicates the gain of the AGC
1492 * in the rx path of the chip, in dB steps (0.625 dB, for example?).
1493 * The mapping of this rssi value to dBm is still unknown, but it can
1494 * nevertheless be used as a measure of relative signal strength. The
1495 * other two values, i.e. max_signal and max_noise, do not seem to be
1496 * supported on my acx111 card (they are always 0), although iwconfig
1497 * reports them (in dBm) when using ndiswrapper with the Windows XP
1498 * driver. The GPL-licensed part of the AVM FRITZ!WLAN USB Stick
1499 * driver sources (for the TNETW1450, though) seems to also indicate
1500 * that only the RSSI is supported. In conclusion, the max_signal and
1501 * max_noise values will not be initialised by now, as they do not
1502 * seem to be supported or how to acquire them is still unknown. */
1503 ieee->max_rssi = 100;
1504
14881505 adev = ieee2adev(ieee);
14891506
14901507 memset(adev, 0, sizeof(*adev));
toggle raw diff