Skip to content

Commit

Permalink
fix unload issue. re calc rssi.
Browse files Browse the repository at this point in the history
  • Loading branch information
zxystd committed Jul 4, 2020
1 parent 0cc70ab commit dd4bec0
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 15 deletions.
4 changes: 2 additions & 2 deletions include/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ struct ioctl_sta_info {
int cur_mcs;
uint channel;
uint16_t band_width;//20 40 80 160
uint rssi;
uint noise;
int16_t rssi;
int16_t noise;
uint rate;
unsigned char ssid[NWID_LEN];
uint8_t bssid[ETHER_ADDR_LEN];
Expand Down
4 changes: 2 additions & 2 deletions itlwm/ItlNetworkUserClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ sSTA_INFO(OSObject* target, void* data, bool isSet)
st->channel = ieee80211_chan2ieee(&that->fSoft->sc_ic, ic_bss->ni_chan);
//TODO only support 20mhz band width now
st->band_width = 20;
st->rssi = ic_bss->ni_rssi;
st->rssi = -(0 - IWM_MIN_DBM - ic_bss->ni_rssi);
st->noise = 0;
st->rate = ic_bss->ni_rates.rs_rates[ic_bss->ni_txrate];
memset(st->ssid, 0, sizeof(st->ssid));
Expand Down Expand Up @@ -252,7 +252,7 @@ sSCAN_RESULT(OSObject* target, void* data, bool isSet)
ni->supported_rsnakms = that->fNextNodeToSend->ni_supported_rsnakms;
ni->supported_rsnprotos = that->fNextNodeToSend->ni_supported_rsnprotos;
ni->noise = 0;
ni->rssi = that->fNextNodeToSend->ni_rssi;
ni->rssi = -(0 - IWM_MIN_DBM - that->fNextNodeToSend->ni_rssi);
memcpy(ni->bssid, that->fNextNodeToSend->ni_bssid, 6);
memcpy(ni->ssid, that->fNextNodeToSend->ni_essid, 32);
that->fNextNodeToSend = RB_NEXT(ieee80211_tree, &ic->ic_tree, that->fNextNodeToSend);
Expand Down
5 changes: 2 additions & 3 deletions itlwm/itlwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ void itlwm::releaseAll()
if (lastSleepChan) {
wakeupOn(lastSleepChan);
}
_fCommandGate->disable();
// _fCommandGate->disable();
_fWorkloop->removeEventSource(_fCommandGate);
_fCommandGate->release();
_fCommandGate = NULL;
Expand Down Expand Up @@ -600,6 +600,5 @@ IOReturn itlwm::tsleepHandler(OSObject* owner, void* arg0, void* arg1, void* arg
}

IOReturn itlwm::getMaxPacketSize(UInt32 *maxSize) const {
*maxSize = ETHERNET_MTU + 18;
return kIOReturnSuccess;
return super::getMaxPacketSize(maxSize);
}
4 changes: 2 additions & 2 deletions itlwm/itlwm_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ bool itlwm_interface::init(IONetworkController *controller)
{
if (!super::init(controller))
return false;
IOLog("itlwm setting MTU to %d\n", ETHERNET_MTU);
setMaxTransferUnit(ETHERNET_MTU);
return true;
}

bool itlwm_interface::setMaxTransferUnit(UInt32 mtu) {
if (mtu > 1500) {
IOLog("itlwm setting MTU to %d\n", mtu);
if (mtu > ETHERNET_MTU) {
return false;
}
super::setMaxTransferUnit(mtu);
Expand Down
4 changes: 2 additions & 2 deletions itlwmx/ItlNetworkUserClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ sSTA_INFO(OSObject* target, void* data, bool isSet)
st->channel = ieee80211_chan2ieee(&that->fSoft->sc_ic, ic_bss->ni_chan);
//TODO only support 20mhz band width now
st->band_width = 20;
st->rssi = ic_bss->ni_rssi;
st->rssi = -(0 - IWX_MIN_DBM - ic_bss->ni_rssi);
st->noise = 0;
st->rate = ic_bss->ni_rates.rs_rates[ic_bss->ni_txrate];
memset(st->ssid, 0, sizeof(st->ssid));
Expand Down Expand Up @@ -252,7 +252,7 @@ sSCAN_RESULT(OSObject* target, void* data, bool isSet)
ni->supported_rsnakms = that->fNextNodeToSend->ni_supported_rsnakms;
ni->supported_rsnprotos = that->fNextNodeToSend->ni_supported_rsnprotos;
ni->noise = 0;
ni->rssi = that->fNextNodeToSend->ni_rssi;
ni->rssi = -(0 - IWX_MIN_DBM - that->fNextNodeToSend->ni_rssi);
memcpy(ni->bssid, that->fNextNodeToSend->ni_bssid, 6);
memcpy(ni->ssid, that->fNextNodeToSend->ni_essid, 32);
that->fNextNodeToSend = RB_NEXT(ieee80211_tree, &ic->ic_tree, that->fNextNodeToSend);
Expand Down
20 changes: 17 additions & 3 deletions itlwmx/itlwmx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ bool itlwmx::configureInterface(IONetworkInterface *netif) {
return true;
}

IONetworkInterface *itlwmx::createInterface()
{
itlwmx_interface *netif = new itlwmx_interface;
if (!netif) {
return NULL;
}
if (!netif->init(this)) {
netif->release();
return NULL;
}
return netif;
}

struct ifnet *itlwmx::getIfp()
{
return &com.sc_ic.ic_ac.ac_if;
Expand Down Expand Up @@ -366,7 +379,7 @@ void itlwmx::releaseAll()
if (lastSleepChan) {
wakeupOn(lastSleepChan);
}
_fCommandGate->disable();
// _fCommandGate->disable();
_fWorkloop->removeEventSource(_fCommandGate);
_fCommandGate->release();
_fCommandGate = NULL;
Expand Down Expand Up @@ -459,8 +472,9 @@ IOReturn itlwmx::setMulticastList(IOEthernetAddress* addr, UInt32 len) {
}

IOReturn itlwmx::getMaxPacketSize(UInt32 *maxSize) const {
*maxSize = ETHERNET_MTU + 18;
return kIOReturnSuccess;
IOReturn ret = super::getMaxPacketSize(maxSize);
XYLog("%s maxsize=%d\n", __FUNCTION__, *maxSize);
return ret;
}

void itlwmx::watchdogAction(IOTimerEventSource *timer)
Expand Down
2 changes: 2 additions & 0 deletions itlwmx/itlwmx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class itlwmx : public IOEthernetController {
IOReturn setMulticastMode(IOEnetMulticastMode mode) override;
IOReturn setMulticastList(IOEthernetAddress* addr, UInt32 len) override;
virtual IOReturn getMaxPacketSize(UInt32* maxSize) const override;
virtual IONetworkInterface * createInterface() override;

bool configureInterface(IONetworkInterface *netif) override;
static IOReturn tsleepHandler(OSObject* owner, void* arg0 = 0, void* arg1 = 0, void* arg2 = 0, void* arg3 = 0);
int tsleep_nsec(void *ident, int priority, const char *wmesg, int timo);
Expand Down
2 changes: 1 addition & 1 deletion itlwmx/itlwmx_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ bool itlwmx_interface::init(IONetworkController *controller)
{
if (!super::init(controller))
return false;
IOLog("itlwm setting MTU to %d\n", ETHERNET_MTU);
setMaxTransferUnit(ETHERNET_MTU);
return true;
}

bool itlwmx_interface::setMaxTransferUnit(UInt32 mtu) {
IOLog("itlwm setting MTU to %d\n", mtu);
if (mtu > ETHERNET_MTU) {
return false;
}
Expand Down

0 comments on commit dd4bec0

Please sign in to comment.