From d1248615b275d8c828eac96c66086b61a46c8981 Mon Sep 17 00:00:00 2001 From: hatf0 Date: Sat, 4 Apr 2020 20:33:21 -0400 Subject: [PATCH] general: fix all sev-5 cpplint issues --- .../project.pbxproj | 9 +- .../AppleIntelWifiAdapterV2.cpp | 94 +- .../AppleIntelWifiAdapterV2.hpp | 15 +- .../AppleIntelWifi_iokit.cpp | 95 +- .../HackIOEthernetInterface.h | 311 ----- .../HackIONetworkInterface.h | 1026 ----------------- AppleIntelWifiAdapter/IWLCachedScan.cpp | 78 +- AppleIntelWifiAdapter/IWLCachedScan.hpp | 6 +- AppleIntelWifiAdapter/IWLCoex.cpp | 4 +- AppleIntelWifiAdapter/IWLCtxtInfo.hpp | 6 +- AppleIntelWifiAdapter/IWLDebug.c | 6 +- AppleIntelWifiAdapter/IWLDebug.h | 10 +- AppleIntelWifiAdapter/IWLDevice.cpp | 12 +- AppleIntelWifiAdapter/IWLDevice.hpp | 6 +- AppleIntelWifiAdapter/IWLFH.h | 6 +- AppleIntelWifiAdapter/IWLInternal.hpp | 6 +- AppleIntelWifiAdapter/IWLPhyDb.hpp | 6 +- AppleIntelWifiAdapter/fw/FWFile.h | 27 +- AppleIntelWifiAdapter/fw/FWImg.h | 6 +- AppleIntelWifiAdapter/fw/IWLFw.cpp | 39 +- AppleIntelWifiAdapter/fw/IWLUcodeParse.hpp | 8 +- AppleIntelWifiAdapter/fw/NotificationWait.hpp | 6 +- AppleIntelWifiAdapter/fw/fw-api.h | 6 +- AppleIntelWifiAdapter/mvm/IWLApple80211.cpp | 6 +- AppleIntelWifiAdapter/mvm/IWLApple80211.hpp | 6 +- AppleIntelWifiAdapter/mvm/IWLConstants.h | 6 +- AppleIntelWifiAdapter/mvm/IWLMac80211.cpp | 4 +- AppleIntelWifiAdapter/mvm/IWLMvmDriver.cpp | 47 +- AppleIntelWifiAdapter/mvm/IWLMvmDriver.hpp | 6 +- AppleIntelWifiAdapter/mvm/IWLMvmMac.cpp | 118 +- AppleIntelWifiAdapter/mvm/IWLMvmMac.hpp | 6 +- AppleIntelWifiAdapter/mvm/IWLMvmPhy.cpp | 9 +- AppleIntelWifiAdapter/mvm/IWLMvmPhy.hpp | 6 +- AppleIntelWifiAdapter/mvm/IWLMvmScan.hpp | 6 +- AppleIntelWifiAdapter/mvm/IWLMvmSmartFifo.cpp | 5 +- AppleIntelWifiAdapter/mvm/IWLMvmSmartFifo.hpp | 6 +- AppleIntelWifiAdapter/mvm/IWLMvmSta.cpp | 14 +- AppleIntelWifiAdapter/mvm/IWLMvmSta.hpp | 6 +- .../mvm/IWLMvmTransOpsGen1.cpp | 16 +- .../mvm/IWLMvmTransOpsGen1.hpp | 8 +- .../mvm/IWLMvmTransOpsGen2.hpp | 8 +- AppleIntelWifiAdapter/mvm/IWMHdr.h | 6 +- AppleIntelWifiAdapter/mvm/Mvm.h | 7 +- AppleIntelWifiAdapter/mvm/MvmCmd.hpp | 8 +- AppleIntelWifiAdapter/nvm/IWLNvm.cpp | 3 +- AppleIntelWifiAdapter/nvm/IWLNvmParser.cpp | 18 +- AppleIntelWifiAdapter/nvm/IWLNvmParser.hpp | 6 +- AppleIntelWifiAdapter/nvm/IWLeeprom.h | 12 +- AppleIntelWifiAdapter/trans/IWLIO.hpp | 6 +- AppleIntelWifiAdapter/trans/IWLSCD.h | 6 +- AppleIntelWifiAdapter/trans/IWLTransOps.h | 8 +- AppleIntelWifiAdapter/trans/IWLTransport.cpp | 14 +- AppleIntelWifiAdapter/trans/IWLTransport.hpp | 6 +- .../trans/IWLTransportRx.cpp | 65 +- .../trans/IWLTransportTx.cpp | 20 +- AppleIntelWifiAdapter/trans/TransHdr.h | 6 +- .../trans/TransOpsCommon.cpp | 70 +- scripts/build.sh | 9 +- scripts/env.sh | 11 + scripts/format.sh | 10 + scripts/lint.sh | 18 + scripts/load.sh | 9 +- scripts/unload.sh | 9 +- 63 files changed, 511 insertions(+), 1887 deletions(-) delete mode 100644 AppleIntelWifiAdapter/HackIOEthernetInterface.h delete mode 100644 AppleIntelWifiAdapter/HackIONetworkInterface.h create mode 100755 scripts/env.sh create mode 100644 scripts/format.sh create mode 100755 scripts/lint.sh diff --git a/AppleIntelWifiAdapter.xcodeproj/project.pbxproj b/AppleIntelWifiAdapter.xcodeproj/project.pbxproj index 143bd0b..c985542 100644 --- a/AppleIntelWifiAdapter.xcodeproj/project.pbxproj +++ b/AppleIntelWifiAdapter.xcodeproj/project.pbxproj @@ -267,7 +267,7 @@ 026C2F702359CB3300C832EF /* IOSkywalkEthernetInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IOSkywalkEthernetInterface.h; sourceTree = ""; }; 026E8CC92356F0ED000BFD46 /* AppleIntelWifiAdapterV2.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AppleIntelWifiAdapterV2.kext; sourceTree = BUILT_PRODUCTS_DIR; }; 026E8CCC2356F0ED000BFD46 /* AppleIntelWifiAdapterV2.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AppleIntelWifiAdapterV2.hpp; sourceTree = ""; }; - 026E8CCE2356F0ED000BFD46 /* AppleIntelWifiAdapterV2.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AppleIntelWifiAdapterV2.cpp; sourceTree = ""; }; + 026E8CCE2356F0ED000BFD46 /* AppleIntelWifiAdapterV2.cpp */ = {isa = PBXFileReference; indentWidth = 8; lastKnownFileType = sourcecode.cpp.cpp; path = AppleIntelWifiAdapterV2.cpp; sourceTree = ""; tabWidth = 8; usesTabs = 1; }; 026E8CD02356F0ED000BFD46 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 026E8CD72356F2AD000BFD46 /* apple80211_ioctl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = apple80211_ioctl.h; sourceTree = ""; }; 026E8CD82356F2AD000BFD46 /* apple80211_wps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = apple80211_wps.h; sourceTree = ""; }; @@ -394,8 +394,6 @@ 68651D6F23F5EE6900A39FAD /* iwlwifi-8265-34.ucode */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iwlwifi-8265-34.ucode"; sourceTree = ""; }; 6865B3B52421D65B0044C9FE /* IWLApple80211.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IWLApple80211.cpp; sourceTree = ""; }; 6865B3B62421D65B0044C9FE /* IWLApple80211.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = IWLApple80211.hpp; sourceTree = ""; }; - 6868731923FA49ED001C7DEA /* HackIONetworkInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HackIONetworkInterface.h; path = AppleIntelWifiAdapter/HackIONetworkInterface.h; sourceTree = SOURCE_ROOT; }; - 6868731A23FA49ED001C7DEA /* HackIOEthernetInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HackIOEthernetInterface.h; path = AppleIntelWifiAdapter/HackIOEthernetInterface.h; sourceTree = SOURCE_ROOT; }; 6868731D23FA4AB4001C7DEA /* IWLSCD.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; path = IWLSCD.h; sourceTree = ""; }; 686AD3E8241C24A6008080E6 /* ioctl_dbg.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ioctl_dbg.h; sourceTree = ""; }; 686EA48324377F3A00C88E9B /* OVERVIEW.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = OVERVIEW.md; sourceTree = ""; }; @@ -500,7 +498,10 @@ 026CE67F2357F7F70034342E /* Frameworks */, 68FC255123F5C040004958FC /* Recovered References */, ); + indentWidth = 8; sourceTree = ""; + tabWidth = 8; + usesTabs = 1; }; 026E8CCA2356F0ED000BFD46 /* Products */ = { isa = PBXGroup; @@ -551,8 +552,6 @@ 026E8CD72356F2AD000BFD46 /* apple80211_ioctl.h */, 026E8CDA2356F2AD000BFD46 /* apple80211_var.h */, 026E8CD82356F2AD000BFD46 /* apple80211_wps.h */, - 6868731A23FA49ED001C7DEA /* HackIOEthernetInterface.h */, - 6868731923FA49ED001C7DEA /* HackIONetworkInterface.h */, 0248A083235833CB00A85BA3 /* IO80211Controller.h */, 026E8CDB2356F2AD000BFD46 /* IO80211Interface.h */, 026C2F6F2359CA9600C832EF /* IO80211SkywalkInterface.h */, diff --git a/AppleIntelWifiAdapter/AppleIntelWifiAdapterV2.cpp b/AppleIntelWifiAdapter/AppleIntelWifiAdapterV2.cpp index 67ccad6..4986670 100644 --- a/AppleIntelWifiAdapter/AppleIntelWifiAdapterV2.cpp +++ b/AppleIntelWifiAdapter/AppleIntelWifiAdapterV2.cpp @@ -1,4 +1,11 @@ -/* add your code here */ +// +// AppleIntelWifiAdapterV2.cpp +// AppleIntelWifiAdapter +// +// Created by Harrison Ford on 4/4/20. +// Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. +// + #include "AppleIntelWifiAdapterV2.hpp" #include @@ -13,28 +20,29 @@ OSDefineMetaClassAndStructors(AppleIntelWifiAdapterV2, IO80211Controller) #define MBit 1000000 -void AppleIntelWifiAdapterV2::releaseAll() { +void AppleIntelWifiAdapterV2::releaseAll() +{ IWL_DEBUG(0, "Releasing everything\n"); - if(fInterrupt) { + if (fInterrupt) { irqLoop->removeEventSource(fInterrupt); fInterrupt->disable(); fInterrupt = NULL; } - if(gate) { + if (gate) { gate->release(); gate = NULL; } - if(irqLoop) { + if (irqLoop) { irqLoop->release(); irqLoop = NULL; } - if(workLoop) { + if (workLoop) { workLoop->release(); workLoop = NULL; } - if(netif) { + if (netif) { netif->release(); netif = NULL; } @@ -45,7 +53,8 @@ void AppleIntelWifiAdapterV2::releaseAll() { } } -void AppleIntelWifiAdapterV2::free() { +void AppleIntelWifiAdapterV2::free() +{ IWL_DEBUG(0, "Driver free()\n"); releaseAll(); super::free(); @@ -53,24 +62,23 @@ void AppleIntelWifiAdapterV2::free() { bool AppleIntelWifiAdapterV2::init(OSDictionary *properties) { - IWL_DEBUG(0, "Driver init()\n"); - if(!super::init(properties)) { - return false; - } - - return true; + IWL_DEBUG(0, "Driver init()\n"); + if (!super::init(properties)) + return false; + + return true; } -IO80211Interface* AppleIntelWifiAdapterV2::getInterface() { - return netif; +IO80211Interface* AppleIntelWifiAdapterV2::getInterface() +{ + return netif; } IOService* AppleIntelWifiAdapterV2::probe(IOService *provider, SInt32 *score) { IWL_DEBUG(0, "Driver Probe()\n"); - if(!super::probe(provider, score)) { + if (!super::probe(provider, score)) return NULL; - } IOPCIDevice *pciDevice = OSDynamicCast(IOPCIDevice, provider); if (!pciDevice) { @@ -92,13 +100,11 @@ IOService* AppleIntelWifiAdapterV2::probe(IOService *provider, SInt32 *score) } } - if(!valid) { + if (!valid) return NULL; - } IWL_DEBUG(0, "found pci device====>vendorID=0x%04x, deviceID=0x%04x, subSystemVendorID=0x%04x, subSystemDeviceID=0x%04x, revision=0x%02x\n", vendorID, deviceID, subSystemVendorID, subSystemDeviceID, revision); - //pciDevice->retain(); this->drv = new IWLMvmDriver(); this->drv->m_pDevice = new IWLDevice(); this->drv->m_pDevice->pciDevice = pciDevice; @@ -109,9 +115,8 @@ IOService* AppleIntelWifiAdapterV2::probe(IOService *provider, SInt32 *score) } bool AppleIntelWifiAdapterV2::createWorkLoop() { - if(!workLoop) { + if (!workLoop) workLoop = IO80211WorkLoop::workLoop(); - } return (workLoop != NULL); } @@ -123,11 +128,10 @@ IOWorkLoop* AppleIntelWifiAdapterV2::getWorkLoop() const { bool AppleIntelWifiAdapterV2::start(IOService *provider) { IWL_DEBUG(0, "Driver Start()\n"); - if (!super::start(provider)) { + if (!super::start(provider)) return false; - } - if(!this->drv) { + if (!this->drv) { IWL_CRIT(0, "Missing this->drv\n"); releaseAll(); return false; @@ -135,32 +139,30 @@ bool AppleIntelWifiAdapterV2::start(IOService *provider) this->drv->controller = static_cast(this); - if (!this->drv->init()) { + if (!this->drv->init()) return false; - } - if(!this->drv->probe()) { + if (!this->drv->probe()) return false; - } irqLoop = IO80211WorkLoop::workLoop(); initTimeout(irqLoop); - if(!this->drv->m_pDevice) { + if (!this->drv->m_pDevice) { IWL_CRIT(0, "Missing this->m_pDevice\n"); releaseAll(); return false; } - if(!this->drv->m_pDevice->pciDevice) { + if (!this->drv->m_pDevice->pciDevice) { IWL_CRIT(0, "Missing this->m_pDevice->pciDevice\n"); releaseAll(); return false; } gate = IOCommandGate::commandGate(this); - if(!gate) { + if (!gate) { IWL_CRIT(0, "Failed to create command gate\n"); releaseAll(); return false; @@ -179,12 +181,11 @@ IOReturn AppleIntelWifiAdapterV2::_doCommand(OSObject *target, void *arg0, void int* status = (int*)arg1; IOService* provider = (IOService*)arg2; - if(arg0 == (void*)16) { - if(!device->startGated(provider)) { + if (arg0 == (void*)16) { + if (!device->startGated(provider)) { OSIncrementAtomic(status); } - } - else { + } else { return kIOReturnError; } return kIOReturnSuccess; @@ -255,7 +256,7 @@ bool AppleIntelWifiAdapterV2::startGated(IOService *provider) { return false; } - if (!setSelectedMedium(mediumTable[MEDIUM_TYPE_AUTO])){ + if (!setSelectedMedium(mediumTable[MEDIUM_TYPE_AUTO])) { IWL_CRIT(0, "start fail, can not set current medium\n"); releaseAll(); return false; @@ -268,7 +269,7 @@ bool AppleIntelWifiAdapterV2::startGated(IOService *provider) { return false; } - if(!drv->drvStart()) { + if (!drv->drvStart()) { IWL_CRIT(0, "Driver failed to start\n"); releaseAll(); return false; @@ -294,9 +295,8 @@ bool AppleIntelWifiAdapterV2::intrFilter(OSObject *object, IOFilterInterruptEven { AppleIntelWifiAdapterV2* me = (AppleIntelWifiAdapterV2*)object; - if(me == 0) { + if (me == 0) return false; - } //kprintf("interrupt filter ran\n"); me->drv->trans->iwlWrite32(CSR_INT_MASK, 0x00000000); @@ -306,9 +306,8 @@ bool AppleIntelWifiAdapterV2::intrFilter(OSObject *object, IOFilterInterruptEven void AppleIntelWifiAdapterV2::intrOccured(OSObject *object, IOInterruptEventSource* sender, int count) { AppleIntelWifiAdapterV2* o = (AppleIntelWifiAdapterV2*)object; - if(o == 0) { + if (o == 0) return; - } kprintf("interrupt!!!\n"); o->drv->irqHandler(0, NULL); @@ -343,7 +342,7 @@ void AppleIntelWifiAdapterV2::stop(IOService *provider) IOReturn AppleIntelWifiAdapterV2::enable(IONetworkInterface *netif) { IWL_DEBUG(0, "Driver Enable()\n"); - if(super::enable(netif) != kIOReturnSuccess) { + if (super::enable(netif) != kIOReturnSuccess) { IWL_CRIT(0, "super::enable() failed\n"); return kIOReturnError; } @@ -351,8 +350,8 @@ IOReturn AppleIntelWifiAdapterV2::enable(IONetworkInterface *netif) IOMediumType mediumType = kIOMediumIEEE80211Auto; IONetworkMedium *medium = IONetworkMedium::getMediumWithType(mediumDict, mediumType); setLinkStatus(kIONetworkLinkValid, medium); - if(this->drv) { - if(!this->drv->enableDevice()) { + if (this->drv) { + if (!this->drv->enableDevice()) { IWL_CRIT(0, "Enabling device failed\n"); return kIOReturnError; } @@ -365,9 +364,8 @@ IOReturn AppleIntelWifiAdapterV2::enable(IONetworkInterface *netif) } const OSString* AppleIntelWifiAdapterV2::newModelString() const { - if(drv) { + if (drv) return OSString::withCString("Wireless Network Adapter (802.11 a/b/g/n/ac)"); - } return OSString::withCString("Wireless Card"); } diff --git a/AppleIntelWifiAdapter/AppleIntelWifiAdapterV2.hpp b/AppleIntelWifiAdapter/AppleIntelWifiAdapterV2.hpp index d8e7fe5..08c4707 100644 --- a/AppleIntelWifiAdapter/AppleIntelWifiAdapterV2.hpp +++ b/AppleIntelWifiAdapter/AppleIntelWifiAdapterV2.hpp @@ -1,6 +1,13 @@ -/* add your code here */ -#ifndef AppleIntelWifiAdapter_hpp -#define AppleIntelWifiAdapter_hpp +// +// AppleIntelWifiAdapterV2.hpp +// AppleIntelWifiAdapter +// +// Created by Harrison Ford on 4/4/20. +// Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. +// + +#ifndef APPLEINTELWIFIADAPTER_APPLEINTELWIFIADAPTERV2_HPP_ +#define APPLEINTELWIFIADAPTER_APPLEINTELWIFIADAPTERV2_HPP_ //#include "HackIO80211Interface.h" #include "IO80211Controller.h" @@ -165,4 +172,4 @@ class AppleIntelWifiAdapterV2 : public IO80211Controller }; -#endif +#endif // APPLEINTELWIFIADAPTER_APPLEINTELWIFIADAPTERV2_HPP_ diff --git a/AppleIntelWifiAdapter/AppleIntelWifi_iokit.cpp b/AppleIntelWifiAdapter/AppleIntelWifi_iokit.cpp index 5675dad..4ac48fb 100644 --- a/AppleIntelWifiAdapter/AppleIntelWifi_iokit.cpp +++ b/AppleIntelWifiAdapter/AppleIntelWifi_iokit.cpp @@ -7,7 +7,7 @@ // #include "AppleIntelWifiAdapterV2.hpp" -#include "ioctl_dbg.h" +#include "apple80211/ioctl_dbg.h" #include "IWLApple80211.hpp" #include "IWLMvmMac.hpp" #include "IWLCachedScan.hpp" @@ -28,9 +28,7 @@ SInt32 AppleIntelWifiAdapterV2::apple80211Request(unsigned int request_type, } IOReturn ret = 0; - bool isGet = (request_type == SIOCGA80211); - #define IOCTL(REQ_TYPE, REQ, DATA_TYPE) \ if (REQ_TYPE == SIOCGA80211) { \ ret = get##REQ(interface, (struct DATA_TYPE* )data); \ @@ -42,6 +40,7 @@ ret = set##REQ(interface, (struct DATA_TYPE* )data); \ if (REQ_TYPE == SIOCGA80211) { \ ret = get##REQ(interface, (struct DATA_TYPE* )data); \ } + #define IOCTL_SET(REQ_TYPE, REQ, DATA_TYPE) \ if (REQ_TYPE == SIOCSA80211) { \ ret = set##REQ(interface, (struct DATA_TYPE* )data); \ @@ -52,7 +51,7 @@ if (REQ_TYPE == SIOCSA80211) { \ request_number, IOCTL_NAMES[request_number]); - switch(request_number) { + switch (request_number) { case APPLE80211_IOC_SSID: // 1 IOCTL(request_type, SSID, apple80211_ssid_data); break; @@ -173,7 +172,7 @@ if (REQ_TYPE == SIOCSA80211) { \ IOReturn AppleIntelWifiAdapterV2::getSSID(IO80211Interface *interface, struct apple80211_ssid_data *sd) { - if(drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { + if (drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { return APPLE80211_REASON_NOT_AUTHED; } @@ -235,7 +234,7 @@ IOReturn AppleIntelWifiAdapterV2::getCHANNEL(IO80211Interface *interface, IOReturn AppleIntelWifiAdapterV2::getPROTMODE(IO80211Interface* interface, struct apple80211_protmode_data* pd) { - if(drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { + if (drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { return APPLE80211_REASON_NOT_AUTHED; } @@ -243,7 +242,7 @@ IOReturn AppleIntelWifiAdapterV2::getPROTMODE(IO80211Interface* interface, struc } IOReturn AppleIntelWifiAdapterV2::setPROTMODE(IO80211Interface* interface, struct apple80211_protmode_data* pd) { - if(drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { + if (drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { return APPLE80211_REASON_NOT_AUTHED; } @@ -269,7 +268,7 @@ IOReturn AppleIntelWifiAdapterV2::getTXPOWER(IO80211Interface *interface, IOReturn AppleIntelWifiAdapterV2::getRATE(IO80211Interface *interface, struct apple80211_rate_data *rd) { - if(drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { + if (drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { return APPLE80211_REASON_NOT_AUTHED; } @@ -286,7 +285,7 @@ IOReturn AppleIntelWifiAdapterV2::getRATE(IO80211Interface *interface, struct ap IOReturn AppleIntelWifiAdapterV2::getBSSID(IO80211Interface *interface, struct apple80211_bssid_data *bd) { - if(drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { + if (drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { return APPLE80211_REASON_NOT_AUTHED; } @@ -319,7 +318,7 @@ int iwl_config_runtime_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { int num_channels = appleReq->num_channels; - if(num_channels > IEEE80211_CHAN_MAX) { + if (num_channels > IEEE80211_CHAN_MAX) { IWL_ERR(0, "ucode asked for %d channels\n", num_channels); IOFree(cfg, len); return -1; @@ -329,7 +328,7 @@ int iwl_config_runtime_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { for (nchan = 0; nchan < num_channels; nchan++) { c = &appleReq->channels[nchan]; - if(!c) + if (!c) continue; IWL_INFO(0, "Adding channel %d to scan", c->channel); @@ -359,7 +358,7 @@ IOReturn AppleIntelWifiAdapterV2::scanAction(OSObject *target, void *arg0, void apple80211_scan_data* sd = (apple80211_scan_data*)arg1; dev->m_pDevice->ie_dev->scanning = true; - for(int i = 0; i < sd->num_channels; i++) { + for (int i = 0; i < sd->num_channels; i++) { IWL_INFO(0, "%d: ch %d\n", i, sd->channels[i].channel); } @@ -367,22 +366,21 @@ IOReturn AppleIntelWifiAdapterV2::scanAction(OSObject *target, void *arg0, void IWL_INFO(0, "scanning (ptr: %x, dev_ptr: %x, dev: %s, umac: %s)\n", dev, dev->m_pDevice, dev->m_pDevice->name, dev->m_pDevice->umac_scanning ? "yes" : "no"); - if(dev->m_pDevice->ie_dev->scanCache == NULL) { + if (dev->m_pDevice->ie_dev->scanCache == NULL) IWL_ERR(0, "scan cache was null?\n"); - } #ifdef notyet - if(fw_has_capa(&dev->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { + if (fw_has_capa(&dev->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { #else - if(1) { + if (1) { #endif - if(iwl_umac_scan(dev, sd) != 0) { + if (iwl_umac_scan(dev, sd) != 0) { IWL_ERR(0, "umac scan failed\n"); ret = kIOReturnError; } } else { //IWL_ERR(0, "lmac scanning not implemented yet (device: %s)\n", &dev->m_pDevice->name); - if(iwl_lmac_scan(dev, sd) != 0) { + if (iwl_lmac_scan(dev, sd) != 0) { IWL_ERR(0, "lmac scan failed\n"); ret = kIOReturnError; } @@ -400,7 +398,7 @@ IOReturn AppleIntelWifiAdapterV2::scanAction(OSObject *target, void *arg0, void IOReturn AppleIntelWifiAdapterV2::setSCAN_REQ(IO80211Interface *interface, struct apple80211_scan_data *sd) { - if(drv->m_pDevice->ie_dev->scanning) { + if (drv->m_pDevice->ie_dev->scanning) { IWL_ERR(0, "Denying scan because device is already scanning\n"); return 0xe0820446; } @@ -432,23 +430,22 @@ IOReturn AppleIntelWifiAdapterV2::setSCAN_REQ(IO80211Interface *interface, memset(&drv->m_pDevice->ie_dev->channels_scan, 0, 256 * sizeof(apple80211_channel)); - if(sd->num_channels == 0 && sd->ssid_len == 0) { + if (sd->num_channels == 0 && sd->ssid_len == 0) memcpy(&drv->m_pDevice->ie_dev->channels_scan, &drv->m_pDevice->ie_dev->channels, drv->m_pDevice->fw.ucode_capa.n_scan_channels * sizeof(apple80211_channel)); - } else { + else memcpy(&drv->m_pDevice->ie_dev->channels_scan, &sd->channels, sd->num_channels * sizeof(apple80211_channel)); - } drv->m_pDevice->ie_dev->n_scan_chans = sd->num_channels; drv->m_pDevice->ie_dev->scan_max = 0; drv->m_pDevice->ie_dev->scan_index = 0; - if(sd->scan_type == 3) { + if (sd->scan_type == 3) { interface->postMessage(APPLE80211_M_SCAN_DONE); return kIOReturnSuccess; } - if(interface) { + if (interface) { apple80211_scan_data* request = (apple80211_scan_data*)IOMalloc(sizeof(apple80211_scan_data)); memcpy(request, sd, sizeof(apple80211_scan_data)); @@ -497,7 +494,7 @@ IOReturn AppleIntelWifiAdapterV2::getSCAN_RESULT(IO80211Interface *interface, struct apple80211_scan_result **sr) { IWL_DEBUG(0, "Locking mutex\n"); - if(!IOLockTryLock(drv->m_pDevice->ie_dev->scanCacheLock)) { + if (!IOLockTryLock(drv->m_pDevice->ie_dev->scanCacheLock)) { IWL_INFO(0, "Could not lock mutex\n"); return -1; } @@ -506,25 +503,22 @@ IOReturn AppleIntelWifiAdapterV2::getSCAN_RESULT(IO80211Interface *interface, - if(drv->m_pDevice->ie_dev->scan_data != NULL && drv->m_pDevice->ie_dev->scan_data->ssid_len != 0) { - - for(int i = drv->m_pDevice->ie_dev->scan_index; i < drv->m_pDevice->ie_dev->scanCache->getCount(); i++) { + if (drv->m_pDevice->ie_dev->scan_data != NULL && drv->m_pDevice->ie_dev->scan_data->ssid_len != 0) { + for (int i = drv->m_pDevice->ie_dev->scan_index; i < drv->m_pDevice->ie_dev->scanCache->getCount(); i++) { OSObject* _can = drv->m_pDevice->ie_dev->scanCache->getObject(i); - if(_can == NULL) + if (_can == NULL) continue; IWLCachedScan* candidate = OSDynamicCast(IWLCachedScan, _can); - if(candidate == NULL) + if (candidate == NULL) continue; - if(candidate->getSSIDLen() == drv->m_pDevice->ie_dev->scan_data->ssid_len) { - + if (candidate->getSSIDLen() == drv->m_pDevice->ie_dev->scan_data->ssid_len) { const char* candidate_ssid = candidate->getSSID(); - if(memcmp(candidate_ssid, drv->m_pDevice->ie_dev->scan_data->ssid, candidate->getSSIDLen()) == 0) { - - if(drv->m_pDevice->ie_dev->scan_data->num_channels != 0) { - for(int chan = 0; chan < drv->m_pDevice->ie_dev->scan_data->num_channels; chan++) { - if(drv->m_pDevice->ie_dev->scan_data->channels[chan].channel == + if (memcmp(candidate_ssid, drv->m_pDevice->ie_dev->scan_data->ssid, candidate->getSSIDLen()) == 0) { + if (drv->m_pDevice->ie_dev->scan_data->num_channels != 0) { + for (int chan = 0; chan < drv->m_pDevice->ie_dev->scan_data->num_channels; chan++) { + if (drv->m_pDevice->ie_dev->scan_data->channels[chan].channel == candidate->getChannel().channel) { IWL_INFO(0, "Scan result (SSID: %s, channel: %d, RSSI: %d)\n", candidate_ssid, candidate->getChannel().channel, candidate->getRSSI()); @@ -535,8 +529,7 @@ IOReturn AppleIntelWifiAdapterV2::getSCAN_RESULT(IO80211Interface *interface, return kIOReturnSuccess; } } - } - else { + } else { IWL_INFO(0, "Scan result (SSID: %s, channel: %d, RSSI: %d)\n", candidate_ssid, candidate->getChannel().channel, candidate->getRSSI()); IOFree((void*)candidate_ssid, candidate->getSSIDLen() + 1); *sr = candidate->getNativeType(); @@ -551,16 +544,15 @@ IOReturn AppleIntelWifiAdapterV2::getSCAN_RESULT(IO80211Interface *interface, drv->m_pDevice->ie_dev->scan_data = NULL; IOLockUnlock(drv->m_pDevice->ie_dev->scanCacheLock); return 5; - } - else { + } else { obj = drv->m_pDevice->ie_dev->scanCache->getObject(drv->m_pDevice->ie_dev->scan_index++); } - if(obj == NULL || drv->m_pDevice->ie_dev->scan_data == NULL) { + if (obj == NULL || drv->m_pDevice->ie_dev->scan_data == NULL) { IWL_INFO(0, "Reached end of scan\n"); - if(drv->m_pDevice->ie_dev->scan_data != NULL) { + if (drv->m_pDevice->ie_dev->scan_data != NULL) { IOFree(drv->m_pDevice->ie_dev->scan_data, sizeof(apple80211_scan_data)); drv->m_pDevice->ie_dev->scan_data = NULL; } @@ -569,14 +561,14 @@ IOReturn AppleIntelWifiAdapterV2::getSCAN_RESULT(IO80211Interface *interface, } IWLCachedScan* scan = OSDynamicCast(IWLCachedScan, obj); - if(!scan) { + if (!scan) { IWL_INFO(0, "Could not cast OSObject to cached scan...\n"); IOLockUnlock(drv->m_pDevice->ie_dev->scanCacheLock); return -1; } apple80211_scan_result* result = scan->getNativeType(); - if(result != NULL) { + if (result != NULL) { *sr = result; // valid until the next scan request, cannot guarantee whether IE will remain IWL_INFO(0, "Scan result (SSID: %s, channel: %d, RSSI: %d)\n", result->asr_ssid, result->asr_channel.channel, result->asr_rssi); @@ -701,9 +693,8 @@ IOReturn AppleIntelWifiAdapterV2::getOP_MODE(IO80211Interface *interface, IOReturn AppleIntelWifiAdapterV2::getRSSI(IO80211Interface *interface, struct apple80211_rssi_data *rd) { - if(drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { + if (drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) return APPLE80211_REASON_NOT_AUTHED; - } //bzero(rd, sizeof(*rd)); rd->version = APPLE80211_VERSION; rd->num_radios = 1; @@ -720,9 +711,8 @@ IOReturn AppleIntelWifiAdapterV2::getRSSI(IO80211Interface *interface, IOReturn AppleIntelWifiAdapterV2::getNOISE(IO80211Interface *interface, struct apple80211_noise_data *nd) { - if(drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { + if (drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) return APPLE80211_REASON_NOT_AUTHED; - } bzero(nd, sizeof(*nd)); nd->version = APPLE80211_VERSION; @@ -806,9 +796,9 @@ IOReturn AppleIntelWifiAdapterV2::getSUPPORTED_CHANNELS(IO80211Interface *interf ad->version = APPLE80211_VERSION; ad->num_channels = this->drv->m_pDevice->ie_dev->n_chans; - if(ad->num_channels > 64) { + if (ad->num_channels > 64) ad->num_channels = 64; - } + memcpy(&ad->supported_channels, this->drv->m_pDevice->ie_dev->channels, sizeof(apple80211_channel) * ad->num_channels); return kIOReturnSuccess; @@ -899,9 +889,8 @@ IOReturn AppleIntelWifiAdapterV2::getCOUNTRY_CODE(IO80211Interface *interface, // MARK: 57 - MCS // IOReturn AppleIntelWifiAdapterV2::getMCS(IO80211Interface* interface, struct apple80211_mcs_data* md) { - if(drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { + if (drv->m_pDevice->ie_dev->state == APPLE80211_S_INIT || drv->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) return APPLE80211_REASON_NOT_AUTHED; - } md->version = APPLE80211_VERSION; md->index = APPLE80211_MCS_INDEX_AUTO; return kIOReturnSuccess; diff --git a/AppleIntelWifiAdapter/HackIOEthernetInterface.h b/AppleIntelWifiAdapter/HackIOEthernetInterface.h deleted file mode 100644 index 7be165e..0000000 --- a/AppleIntelWifiAdapter/HackIOEthernetInterface.h +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright (c) 1998-2008 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -#ifndef _IOETHERNETINTERFACE_H -#define _IOETHERNETINTERFACE_H - -/*! @defined kIOEthernetInterfaceClass - @abstract The name of the - IOEthernetInterface class. -*/ - -#define kIOEthernetInterfaceClass "IOEthernetInterface" - -/*! @defined kIOActivePacketFilters - @abstract A property of IOEthernetInterface objects. - @discussion The kIOActivePacketFilters property has an OSDictionary value that describes the current - set of packet filters that have been successfully activated. Each - entry in the dictionary is a key/value pair consisting of the filter - group name, and an OSNumber describing the set of active filters for - that group. Entries in this dictionary will mirror those in - kIORequiredPacketFilters if the controller has reported success for - all filter change requests from the IOEthernetInterface object. -*/ - -#define kIOActivePacketFilters "IOActivePacketFilters" - -/*! @defined kIORequiredPacketFilters - @abstract A property of IOEthernetInterface objects. - @discussion The kIORequiredPacketFilters property has an OSDictionary value that describes the current - set of required packet filters. Each entry in the dictionary is a - key/value pair consisting of the filter group name, and an OSNumber - describing the set of required filters for that group. -*/ - -#define kIORequiredPacketFilters "IORequiredPacketFilters" - -/*! @defined kIOMulticastAddressList - @abstract A property of IOEthernetInterface objects. - @discussion The kIOMulticastAddressList property is an OSData object that describes the - list of multicast addresses that are being used by the - controller to match against the destination address of an - incoming frame. -*/ - -#define kIOMulticastAddressList "IOMulticastAddressList" -#define kIOMulticastFilterData kIOMulticastAddressList - -#ifdef KERNEL -#ifdef __cplusplus - -#include "HackIONetworkInterface.h" -#include -#include - -/*! @class IOEthernetInterface - @abstract The Ethernet interface object. - @discussion An Ethernet controller driver, - that is a subclass of IOEthernetController, will instantiate an object - of this class when the driver calls the attachInterface() method. - This interface object will then vend an Ethernet interface to DLIL, - and manage the connection between the controller driver and the upper - networking layers. Drivers will seldom need to subclass - IOEthernetInterface. -*/ - -class IOEthernetInterface : public IONetworkInterface -{ - OSDeclareDefaultStructors( IOEthernetInterface ) - -private: - thread_call_t _inputEventThreadCall; // inputEvent() thread call - UInt32 _mcAddrCount; // # of multicast addresses - bool _ctrEnabled; // Is controller enabled? - OSDictionary * _supportedFilters; // Controller's supported filters - OSDictionary * _requiredFilters; // The required filters - OSDictionary * _activeFilters; // Currently active filters - bool _controllerLostPower; // true if controller is unusable - - struct ExpansionData { - UInt32 altMTU; // track the physical mtu of controller - UInt32 publishedFeatureID; // id for published wake packet - uint32_t supportedWakeFilters; // bitmask of supported wake filters - OSNumber * disabledWakeFilters; // OSNumber of disabled wake filters - uint64_t wompEnabledAssertionID; - }; - /*! @var reserved - Reserved for future use. (Internal use only) */ - ExpansionData * _reserved; - - - IOReturn enableController(IONetworkController * ctr); - IOReturn setupMulticastFilter(IONetworkController * ctr); - - UInt32 getFilters(const OSDictionary * dict, - const OSSymbol * group); - - bool setFilters(OSDictionary * dict, - const OSSymbol * group, - UInt32 filters); - - IOReturn disableFilter(IONetworkController * ctr, - const OSSymbol * group, - UInt32 filter, - IOOptionBits options = 0); - - IOReturn enableFilter(IONetworkController * ctr, - const OSSymbol * group, - UInt32 filter, - IOOptionBits options = 0); - - int syncSIOCSIFFLAGS(IONetworkController * ctr); - int syncSIOCSIFADDR(IONetworkController * ctr); - int syncSIOCADDMULTI(IONetworkController * ctr); - int syncSIOCDELMULTI(IONetworkController * ctr); - int syncSIOCSIFMTU(IONetworkController * ctr, struct ifreq * ifr, bool); - int syncSIOCGIFDEVMTU(IONetworkController * ctr, struct ifreq * ifr); - int syncSIOCSIFLLADDR(IONetworkController * ctr, const char * lladdr, int len); - void _fixupVlanPacket(mbuf_t, u_int16_t, int); - void reportInterfaceWakeFlags(IONetworkController * ctr); - - static void handleEthernetInputEvent(thread_call_param_t param0, thread_call_param_t param1); - static int performGatedCommand(void *, void *, void *, void *, void *); - static IOReturn enableFilter_Wrapper( - IOEthernetInterface *, IONetworkController *, const OSSymbol *, UInt32 , IOOptionBits); - -public: - -/*! @function init - @abstract Initializes an IOEthernetInterface instance. - @discussion Instance variables are initialized, and an arpcom - structure is allocated. - @param controller A network controller object that will service - the interface object being initialized. - @result Returns true on success, false otherwise. -*/ - - virtual bool init( IONetworkController * controller ); - -/*! @function getNamePrefix - @abstract Returns a string containing the prefix to use when - creating a BSD name for this interface. - @discussion The BSD name for each interface object is created by - concatenating a string returned by this method, with an unique - unit number assigned by IONetworkStack. - @result Returns a pointer to a constant C string "en". Therefore, Ethernet - interfaces will be registered with BSD as en0, en1, etc. -*/ - - virtual const char * getNamePrefix() const; - -protected: - -/*! @function free - @abstract Frees the IOEthernetInterface instance. - @discussion The memory allocated for the arpcom structure is released, - followed by a call to super::free(). -*/ - - virtual void free(); - -/*! @function performCommand - @abstract Handles an ioctl command sent to the Ethernet interface. - @discussion This method handles socket ioctl commands sent to the Ethernet - interface from DLIL. Commands recognized and processed by this method are - SIOCSIFADDR, SIOCSIFFLAGS, SIOCADDMULTI, and SIOCDELMULTI. Other commands - are passed to the superclass. - @param controller The controller object. - @param cmd The ioctl command code. - @param arg0 Command argument 0. Generally a pointer to an ifnet structure - associated with the interface. - @param arg1 Command argument 1. - @result Returns a BSD return value defined in bsd/sys/errno.h. -*/ - - virtual SInt32 performCommand(IONetworkController * controller, - unsigned long cmd, - void * arg0, - void * arg1); - -/*! @function controllerDidOpen - @abstract A notification that the interface has opened the network - controller. - @discussion This method will be called by IONetworkInterface after a - network controller has accepted an open from this interface object. - IOEthernetInterface will first call the implementation in its - superclass, then inspect the controller through properties published - in the registry. This method is called with the arbitration lock held. - @param controller The controller object that was opened. - @result Returns true on success, false otherwise. Returning false will - cause the controller to be closed, and any pending client opens to be - rejected. -*/ - - virtual bool controllerDidOpen(IONetworkController * controller); - -/*! @function controllerWillClose - @abstract A notification that the interface will close the network - controller. - @discussion This method will simply call super to propagate the method - call. This method is called with the arbitration lock held. - @param controller The controller that is about to be closed. -*/ - - virtual void controllerWillClose(IONetworkController * controller); - - -/*! @function controllerWillChangePowerState - @abstract Handles a notification that the network controller - servicing this interface object is about to transition to a new power state. - @discussion If the controller is about to transition to an unusable state, - and it is currently enabled, then the disable() method on the controller is - called. - @param controller The network controller object. - @param flags Flags that describe the capability of the controller in the new - power state. - @param stateNumber An index to a state in the network controller's - power state array that the controller is switching to. - @param policyMaker A reference to the network controller's policy-maker, - and is also the originator of this notification. - @result Always returns kIOReturnSuccess. -*/ - - virtual IOReturn controllerWillChangePowerState( - IONetworkController * controller, - IOPMPowerFlags flags, - UInt32 stateNumber, - IOService * policyMaker); - -/*! @function controllerDidChangePowerState - @abstract Handles a notification that the network controller servicing - this interface object has transitioned to a new power state. - @discussion If the controller did transition to a usable state, and it was - previously disabled due to a previous power change, then it is re-enabled. - @param controller The network controller object. - @param flags Flags that describe the capability of the controller in the new - power state. - @param stateNumber An index to a state in the network controller's - power state array that the controller has switched to. - @param policyMaker A reference to the network controller's policy-maker, - and is also the originator of this notification. - @result Always returns kIOReturnSuccess. -*/ - - virtual IOReturn controllerDidChangePowerState( - IONetworkController * controller, - IOPMPowerFlags flags, - UInt32 stateNumber, - IOService * policyMaker); - -public: - /* Override IONetworkInterface::willTerminate() */ - - virtual bool willTerminate( IOService * provider, - IOOptionBits options ); - - /* Override IONetworkInterface::attachToDataLinkLayer() */ - - virtual IOReturn attachToDataLinkLayer( IOOptionBits options, - void * parameter ); - - /* Override IONetworkInterface::inputEvent() */ - - virtual bool inputEvent( UInt32 type, void * data ); - -protected: - virtual void feedPacketInputTap(mbuf_t); - virtual void feedPacketOutputTap(mbuf_t); - virtual bool initIfnetParams(struct ifnet_init_params *params); - -public: - // Virtual function padding - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 0); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 1); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 2); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 3); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 4); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 5); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 6); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 7); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 8); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 9); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 10); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 11); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 12); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 13); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 14); - OSMetaClassDeclareReservedUnused( IOEthernetInterface, 15); -}; - -#endif /* __cplusplus */ -#endif /* KERNEL */ -#endif /* !_IOETHERNETINTERFACE_H */ diff --git a/AppleIntelWifiAdapter/HackIONetworkInterface.h b/AppleIntelWifiAdapter/HackIONetworkInterface.h deleted file mode 100644 index 8c5f35a..0000000 --- a/AppleIntelWifiAdapter/HackIONetworkInterface.h +++ /dev/null @@ -1,1026 +0,0 @@ -/* - * Copyright (c) 1998-2008 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -#ifndef _IONETWORKINTERFACE_H -#define _IONETWORKINTERFACE_H - -/*! @defined kIONetworkInterfaceClass - @abstract The name of the IONetworkInterface class. -*/ - -#define kIONetworkInterfaceClass "IONetworkInterface" - -/*! @defined kIONetworkData - @abstract A property of IONetworkInterface objects. - @discussion The kIONetworkData property has an OSDictionary value and is a - container for the set of IONetworkData objects managed by the interface. - Each entry in the dictionary is a key/value pair consisting of - the network data name, and an OSDictionary describing the - contents of the network data. -*/ - -#define kIONetworkData "IONetworkData" - -/*! @defined kIOInterfaceType - @abstract A property of IONetworkInterface objects. - @discussion The kIOInterfaceType property has an OSNumber value that - specifies the type of network interface that this interface represents. - The type constants are defined in bsd/net/if_types.h. -*/ - -#define kIOInterfaceType "IOInterfaceType" - -/*! @defined kIOMaxTransferUnit - @abstract A property of IONetworkInterface objects. - @discussion The kIOMaxTransferUnit property has an OSNumber value that - specifies the maximum transfer unit for the interface in bytes. -*/ - -#define kIOMaxTransferUnit "IOMaxTransferUnit" - -/*! @defined kIOMediaAddressLength - @abstract A property of IONetworkInterface objects. - @discussion The kIOMediaAddressLength property has an OSNumber value that - specifies the size of the media address in bytes. -*/ - -#define kIOMediaAddressLength "IOMediaAddressLength" - -/*! @defined kIOMediaHeaderLength - @abstract A property of IONetworkInterface objects. - @discussion The kIOMediaHeaderLength property has an OSNumber value that - specifies the size of the media header in bytes. -*/ - -#define kIOMediaHeaderLength "IOMediaHeaderLength" - -/*! @defined kIOInterfaceFlags - @abstract A property of IONetworkInterface objects. - @discussion The kIOInterfaceFlags property has an OSNumber value that - specifies the current value of the interface flags. The flag constants - are defined in bsd/net/if.h. -*/ - -#define kIOInterfaceFlags "IOInterfaceFlags" - -/*! @defined kIOInterfaceExtraFlags - @abstract A property of IONetworkInterface objects. - @discussion The kIOInterfaceExtraFlags property has an OSNumber value that - specifies the current value of the interface eflags. The eflag constants - are defined in bsd/net/if.h. -*/ - -#define kIOInterfaceExtraFlags "IOInterfaceExtraFlags" - -/*! @defined kIOInterfaceUnit - @abstract A property of IONetworkInterface objects. - @discussion The kIOInterfaceUnit property has an OSNumber value that - describes the unit number assigned to the interface object. -*/ - -#define kIOInterfaceUnit "IOInterfaceUnit" - -/*! @defined kIOInterfaceState - @abstract A property of IONetworkInterface objects. - @discussion The kIOInterfaceState property has an OSNumber value that - describes the current state of the interface object. This property is - not exported to BSD via the ifnet structure. -*/ - -#define kIOInterfaceState "IOInterfaceState" - -/*! @defined kIOInterfaceNamePrefix - @abstract A property of IONetworkInterface objects. - @discussion The kIOInterfaceNamePrefix property has an OSString value that - describes the string prefix for the BSD name assigned to the interface. -*/ - -#define kIOInterfaceNamePrefix "IOInterfaceNamePrefix" - -/*! @defined kIOPrimaryInterface - @abstract A property of IONetworkInterface objects. - @discussion The kIOInterfaceNamePrefix property has an OSBoolean value that - describes whether the interface is the primary or the built-in network - interface. -*/ - -#define kIOPrimaryInterface "IOPrimaryInterface" - -/*! @defined kIOBuiltin - @abstract kIOBuiltin is a property of IONetworkInterface - objects. It has an OSBoolean value. - @discussion The kIOBuiltin property describes whether the - interface is built-in. -*/ - -#define kIOBuiltin "IOBuiltin" - -/*! @defined kIOLocation - @abstract kIOLocation is a property of IONetworkInterface - objects. It has an OSString value. - @discussion The kIOLocation property describes the physical - location of built-in interfaces. -*/ - -#define kIOLocation "IOLocation" - -/*! @defined kIONetworkNoBSDAttachKey - @abstract kIONetworkNoBSDAttachKey is a property of IONetworkInterface - objects. It has an OSBoolean value. - @discussion Adding a property with this key and the value kOSBooleanTrue - before the interface is published will hold off the BSD attach. - When the interface is ready to attach to BSD, remove the property - and then re-publish the interface by calling registerService(). -*/ - -#define kIONetworkNoBSDAttachKey "IONetworkNoBSDAttach" - -/*! @enum InterfaceObjectStates - @discussion Constants used to encode the state of the interface object. - @constant kIONetworkInterfaceRegisteredState The interface object has - registered with the data link layer. - @constant kIONetworkInterfaceOpenedState One or more clients have an - open on the interface object. - @constant kIONetworkInterfaceDisabledState The interface is temporarily - unable to service its clients. This will occur when the network - controller that is servicing the interface has entered a low power - state that renders it unusable. -*/ - -enum { - kIONetworkInterfaceRegisteredState = 0x1, - kIONetworkInterfaceOpenedState = 0x2, - kIONetworkInterfaceDisabledState = 0x4 -}; - -#ifdef KERNEL -#ifdef __cplusplus - -#include -#include -#include -#include -#include - -class IONetworkController; -class IONetworkStack; -class IOCommandGate; -struct IOMbufQueue; - -/*! @typedef IOOutputAction - @discussion Prototype for an output packet handler that will process - all outbound packets sent to the interface from the data link layer. - An output handler is registered with the interface by calling - registerOutputHandler(). - @param mbuf_t A packet mbuf. - @param param A parameter for the output request. */ - -typedef UInt32 (OSObject::*IOOutputAction)(mbuf_t, void * param); - -/*! @typedef BPF_FUNC - @discussion Prototype for the BPF tap handler. This will disappear - when the correct DLIL header file is included. */ - -typedef int (*BPF_FUNC)(struct ifnet *, struct mbuf *); - -// Network event types recognized by inputEvent(). -// -enum { - /* DLIL defined event, argument must be a pointer to a - kern_event_msg structure. */ - kIONetworkEventTypeDLIL = 0xff000001, - - /* Link up event, no argument */ - kIONetworkEventTypeLinkUp = 0xff000002, - - /* Link down event, no argument */ - kIONetworkEventTypeLinkDown = 0xff000003, - - /* Wake on LAN support changed, no argument */ - kIONetworkEventWakeOnLANSupportChanged = 0xff000004, - - /* Link speed changed */ - kIONetworkEventTypeLinkSpeedChange = 0xff000005 -}; - - -/*! @class IONetworkInterface - @abstract Abstract class that manages the connection between an - IONetworkController and the data link interface layer. - @discussion An IONetworkInterface object manages the connection between - an IONetworkController and the data link interface layer (DLIL). - All interactions between the controller and DLIL must go through an - interface object. Any data structures that are required by DLIL for a - particular interface type shall be allocated and mantained by the - interface object. IONetworkInterface is an abstract class that must be - extended by a concrete subclass to specialize for a particular network - type. - - Although most drivers will allocate a single interface object, - it is possible for multiple interfaces to be attached to a single - controller. This controller driver will be responsible for arbitrating - access among its multiple interface clients. - - IONetworkInterface also maintains a dictionary of IONetworkData - objects containing statistics structures. Controller drivers can - ask for a particular data object by name and update the - statistics counters within directly. This dictionary is added to - the interface's property table and is visible outside of the kernel. -*/ - -class IONetworkInterface : public IOService -{ - OSDeclareAbstractStructors( IONetworkInterface ) - - friend class IONetworkStack; - - -private: - IONetworkController * _driver; - ifnet_t _backingIfnet; - IOLock * _privateLock; - OSSet * _clientSet; - OSNumber * _stateBits; - bpf_packet_func _inputFilterFunc; - bpf_packet_func _outputFilterFunc; - OSObject * _outTarget; - IOOutputAction _outAction; - UInt32 _clientVar[4]; - OSDictionary * _dataDict; - IOMbufQueue * _inputPushQueue; - void * _unused1; - UInt32 _unused2; - - struct ExpansionData { - int unit; - int type; - int mtu; - int flags; - int eflags; - int addrlen; - int hdrlen; - int32_t loggingLevel; - uint32_t outputQueueModel; - IONetworkStats driverStats; - IONetworkStats lastDriverStats; - ifnet_stat_increment_param inputDeltas; - IORecursiveLock * publicLock; - char * remote_NMI_pattern; - unsigned int remote_NMI_len; - IONetworkController * controller; - uint32_t configFlags; - uint32_t txRingSize; - uint32_t txPullOptions; - uint32_t txQueueSize; - uint32_t txSchedulingModel; - uint32_t txTargetQdelay; - uint32_t txThreadState; - volatile UInt32 txThreadFlags; - uint32_t txThreadSignal; - uint32_t txThreadSignalLast; - thread_t txStartThread; - void * txStartAction; - IOWorkLoop * txWorkLoop; - uint32_t rxRingSize; - uint32_t rxPollOptions; - uint32_t rxPollModel; - void * rxPollAction; - void * rxCtlAction; - uint64_t rxPollEmpty; - uint64_t rxPollTotal; - uint16_t txStartDelayQueueLength; /* optional */ - uint16_t txStartDelayTimeout; /* optional */ - }; - - ExpansionData * _reserved; - - bool _syncNetworkDataDict(); - SInt32 syncSIOCSIFMEDIA(IONetworkController * ctr, struct ifreq * ifr); - SInt32 syncSIOCGIFMEDIA(IONetworkController * ctr, struct ifreq * ifr, - unsigned long cmd); - SInt32 syncSIOCSIFMTU(IONetworkController * ctr, struct ifreq * ifr); - void drainOutputQueue(ifnet_t ifp, IONetworkController * driver); - IOReturn haltOutputThread(uint32_t stateBit); - void pushInputQueue( IOMbufQueue * queue ); - void pushInputPacket( mbuf_t packet, uint32_t length ); - int if_start_precheck( ifnet_t ifp ); - static int performGatedCommand(void *, void *, void *, void *, void *); - static void powerChangeHandler(void *, void *, void *); - static errno_t if_ioctl(ifnet_t ifp, unsigned long cmd, void * data); - static int if_output(ifnet_t ifp, mbuf_t); - static errno_t if_set_bpf_tap(ifnet_t ifp, bpf_tap_mode, bpf_packet_func); - static void if_detach(ifnet_t ifp); - static void if_start(ifnet_t ifp); - static void if_start_gated(ifnet_t ifp); - static void if_input_poll(ifnet_t ifp, uint32_t flags, - uint32_t max_count, - mbuf_t * first_packet, mbuf_t * last_packet, - uint32_t * cnt, uint32_t * len); - static void if_input_poll_gated(ifnet_t ifp, uint32_t flags, - uint32_t max_count, - mbuf_t * first_packet, mbuf_t * last_packet, - uint32_t * cnt, uint32_t * len); - void notifyDriver( uint32_t type, void * data ); - -public: - -/*! @function isPrimaryInterface - @abstract Queries whether the interface is the primary network interface - on the system. - @discussion The definition of a primary interface and its discovery is - platform specific. - @result Returns true if the interface is the primary interface, - false otherwise. -*/ - virtual bool isPrimaryInterface( void ) const; - -/*! @function init - @abstract Initializes the IONetworkInterface object. - @discussion Resources are allocated, but an ifnet_t will not - be allocated until the interface is assigned a BSD name and attached to the - network stack. - @param controller A network controller object that will service the - the interface. - @result Returns true on success, false otherwise. -*/ - virtual bool init( IONetworkController * controller ); - -/*! @function isRegistered - @abstract Queries if the interface has attached to the BSD network stack. - @discussion Once attached a kIOBSDNameKey property is added - to the interface object with the assigned BSD name. - @result Returns true if interface is registered and attached to the network - stack, false otherwise. -*/ - virtual bool isRegistered( void ) const; - -/*! @function getInterfaceState - @abstract Reports the current state of the interface object. - @result Returns the current interface state flags. -*/ - virtual UInt32 getInterfaceState( void ) const; - -/*! @function getController - @abstract Gets the IONetworkController object that created - this interface. - @discussion The controller object passed to init() will be retained until - the interface closes the controller. Subclasses can safely call this method - before the controller is closed. - @result Returns the parent IONetworkController object. -*/ - virtual IONetworkController * getController( void ) const; - -/*! @function inputPacket - @abstract For drivers to submit a received packet to the network stack. - @discussion The packet provided to this method may be added to an input - queue managed by the interface object, which the driver can use to postpone - the packet handoff to the network stack, until all received packets have been - added to the input queue. A subsequent call to flushInputQueue(), - will transfer the entire contents of the input queue to the network stack. - This input queue is not protected by a lock. Drivers that leverage this - input queue must either access the queue from a single thread, or enforce - serialized access. - @param mbuf_t The mbuf containing the received packet. - @param length Specify the size of the received packet in the mbuf. - The mbuf length fields are updated with this value. If zero, then the mbuf - length fields are not updated. - @param options Pass kInputOptionQueuePacket to enqueue the - input packet. Pass zero to bypass the input queue, and immediately submit - the packet to the network stack. - @param param A parameter provided by the driver. Not used. - @result Returns the number of packets that were submitted to the network - stack, or zero if the packet was enqueued. -*/ - virtual UInt32 inputPacket( - mbuf_t packet, - UInt32 length = 0, - IOOptionBits options = 0, - void * param = 0 ); - -/*! @enum InputOptionQueuePacket - @discussion Options for inputPacket(). - @constant kInputOptionQueuePacket Enqueue the input packet provided to the - input packet queue. Calls to inputPacket() must be serialized. -*/ - enum { - kInputOptionQueuePacket = 0x1 - }; - -/*! @function flushInputQueue - @abstract Submit all packets held in the input queue to the network stack. - @discussion Allow drivers to remove all packets from the input queue and - submit them to the network stack. This method should be used in concert - with the inputPacket() method, to flush the input queue after - queueing a number of received packets. - @result Returns the number of packets that were submitted to the network - stack. Returns zero if the queue was empty. -*/ - virtual UInt32 flushInputQueue( void ); - -/*! @function clearInputQueue - @abstract Discards all packets in the input queue. - @discussion This method removes all packets from the input queue and - releases them back to the free mbuf pool. It is unusual for a driver to - call this method. - @result Returns the number of packets freed. -*/ - virtual UInt32 clearInputQueue( void ); - -/*! @function inputEvent - @abstract Sends an event to the network stack. - @discussion This method can be used by the driver to send an event to the - network stack. - @param type A constant describing the event type. - @param data An optional data associated with the event. - @result Returns true if the event was delivered, false if the event type - specified is invalid, or if the event delivery failed. -*/ - virtual bool inputEvent( UInt32 type, void * data ); - -/*! @function registerOutputHandler - @abstract Registers a target/action to handle outbound packets. - @discussion The interface object will forward all output packets sent from - the network stack to the target and action registered using this method. - The registration must occur before the interface is registered and opened - by IONetworkStack, otherwise the default handler will be used. - The default target and action is set by init() as the - controller, and the handler returned by the controller's - getOutputHandler() method. - @param target Object that implements the output handler. - @param action The function that will handle output packets. - @result Returns true if the target/action provided was accepted, - false otherwise. -*/ - virtual bool registerOutputHandler( - OSObject * target, - IOOutputAction action ); - - /** - add by zxy, it is an export symbol but not contain in header files, modify this file add this function, - it cause this project should compile with this version of sdk(10.11) unless you modify other version headers like what I have done. - */ - bool setInterfaceSubType(uint type); - -/*! @function getNamePrefix - @abstract Returns the BSD name prefix as a C-string. - @discussion The BSD name for each interface object is generated by - concatenating the string returned by this method, along with an unit number - assigned by IONetworkStack. A concrete interface subclass must - implement this method and return a distinct name prefix for its instances. - @result Returns a pointer to a constant C-string. -*/ - virtual const char * getNamePrefix() const = 0; - -/*! @function getInterfaceType - @abstract Gets the interface type. - @discussion This method returns the interface type previously set by - setInterfaceType. - @result Returns a constant defined in bsd/net/if_types.h - that describes the interface type. -*/ - virtual UInt8 getInterfaceType( void ) const; - -/*! @function getMaxTransferUnit - @abstract Gets the maximum transfer unit for this interface. - @discussion This method calls ifnet_mtu and returns the - maximum transfer unit. - @result Returns the interface MTU size in bytes. -*/ - virtual UInt32 getMaxTransferUnit( void ) const; - -/*! @function getFlags - @abstract Gets the current interface flags. - @discussion This method calls ifnet_flags and returns the - current interface flags. - @result Returns the interface flags. -*/ - virtual UInt16 getFlags( void ) const; - -/*! @function getExtraFlags - @abstract Gets the current interface eflags. - @discussion This method calls ifnet_eflags and returns the - current interface eflags. - @result Returns the value of the interface eflags. -*/ - virtual UInt32 getExtraFlags( void ) const; - -/*! @function getMediaAddressLength - @abstract Gets the size of the media (MAC-layer) address. - @discussion This method calls ifnet_addrlen and returns the - media address length. - @result Returns the size of the media address in bytes. -*/ - virtual UInt8 getMediaAddressLength( void ) const; - -/*! @function getMediaHeaderLength - @abstract Gets the size of the media header. - @discussion This method calls ifnet_hdrlen and returns the - media header length. - @result Returns the size of the media header in bytes. -*/ - virtual UInt8 getMediaHeaderLength( void ) const; - -/*! @function getUnitNumber - @abstract Gets the unit number assigned to this interface object. - @discussion This method calls ifnet_unit and returns the - unit number assigned by IONetworkStack. - @result Returns the assigned interface unit number. -*/ - virtual UInt16 getUnitNumber( void ) const; - -/*! @function addNetworkData - @abstract Adds an IONetworkData object to the interface. - @discussion The IONetworkData object is added to a - collection using the key from IONetworkData::getKey(). - The object provided is retained. - @param aData The IONetworkData object. - @result Returns true if the object was added, false otherwise. -*/ - virtual bool addNetworkData( IONetworkData * aData ); - -/*! @function removeNetworkData - @abstract Removes an IONetworkData object from the interface. - @discussion This method removes an IONetworkData object from - the collection managed by the interface. The object removed is released. - @param aKey An OSSymbol identifying the object to be removed. - @result Returns true if the object was found and removed, false otherwise. -*/ - virtual bool removeNetworkData( const OSSymbol * aKey ); - -/*! @function removeNetworkData - @abstract Removes an IONetworkData object from the interface. - @discussion This method removes an IONetworkData object from - the collection managed by the interface. The object removed is released. - @param aKey A C-string identifying the object to be removed. - @result Returns true if the object was found and removed, false otherwise. -*/ - virtual bool removeNetworkData( const char * aKey ); - -/*! @function getNetworkData - @abstract Gets an IONetworkData object from the interface. - @discussion Returns a reference to an IONetworkData object - that was previously added to the interface, and is associated with the - provided key. - @param aKey A C-string identifying the object. - @result Returns a reference to the matching IONetworkData - object, or NULL if no match was found. -*/ - virtual IONetworkData * getNetworkData( const char * aKey ) const; - -/*! @function getNetworkData - @abstract Gets an IONetworkData object from the interface. - @discussion Returns a reference to an IONetworkData object - that was previously added to the interface, and is associated with the - provided key. - @param aKey An OSSymbol identifying the object. - @result Returns a reference to the matching IONetworkData - object, or NULL if no match was found. -*/ - virtual IONetworkData * getNetworkData(const OSSymbol * aKey) const; - - /* Compatibility methods */ - IONetworkData * getParameter(const char * aKey) const; - bool setExtendedFlags(UInt32 flags, UInt32 clear = 0); - - /* Override IOService::message() */ - virtual IOReturn message( UInt32 type, IOService * provider, void * argument ); - -/*! @function debuggerRegistered - @abstract Tells the IONetworkData that this interface will be - used by the debugger. -*/ - void debuggerRegistered( void ); - -protected: -/*! @function setInterfaceType - @abstract Sets the interface type. - @discussion Sets the interface type before the interface is attached to - the network stack. See bsd/net/if_types.h for defined types. - The kIOInterfaceType is also updated using the provided type. - @param type A constant defined in bsd/net/if_types.h that - describes the interface type. - @result Returns true to indicate success if the interface has not yet - attached to the network stack, otherwise returns false. -*/ - virtual bool setInterfaceType( UInt8 type ); - -/*! @function setMaxTransferUnit - @abstract Sets the maximum transfer unit for this interface. - @discussion Calls ifnet_set_mtu if the interface is attached - to the network stack, and updates the kIOMaxTransferUnit - property using the provided value. - @param mtu The interface MTU size in bytes. - @result Always returns true. -*/ - virtual bool setMaxTransferUnit( UInt32 mtu ); - -/*! @function setFlags - @abstract Performs a read-modify-write operation on the current - interface flags value. - @discussion Calls ifnet_set_flags if the interface is attached - to the network stack, and updates the kIOInterfaceFlags - property using the provided value. See bsd/net/if.h header - file for the flag constants. - @param flags The bits that should be set. - @param clear The bits that should be cleared. If zero, then non - of the flags are cleared and the result is formed by OR'ing the - original flags value with the new flags. - @result Always returns true. -*/ - virtual bool setFlags( UInt16 flags, UInt16 clear = 0 ); - - /* Deprecated. No replacement. */ - virtual bool setExtraFlags( UInt32 flags, UInt32 clear = 0 ); - -/*! @function setMediaAddressLength - @abstract Sets the size of the media (MAC-layer) address. - @discussion Calls ifnet_set_addrlen if interface is attached - to the network stack, and updates the kIOMediaAddressLength - property using the provided value. - @param length The size of the media address in bytes. - @result Always returns true. -*/ - virtual bool setMediaAddressLength( UInt8 length ); - -/*! @function setMediaHeaderLength - @abstract Sets the size of the media header. - @discussion Calls ifnet_set_hdrlen if interface is attached - to the network stack, and updates the kIOMediaHeaderLength - property using the provided value. - @param length The size of the media header in bytes. - @result Always returns true. -*/ - virtual bool setMediaHeaderLength( UInt8 length ); - -/*! @function setUnitNumber - @abstract Assigns an unique unit number to this interface. - @discussion This method is called internally before the interface is - attached to the network stack, to assign an unique unit number to the - interface object. The kIOInterfaceUnit property is also - updated using the provided value. - @param unit The unit number assigned to this interface object. - @result Returns true to indicate success if the interface has not yet - attached to the network stack, otherwise returns false. -*/ - virtual bool setUnitNumber( UInt16 unit ); - -/*! @function free - @abstract Frees the IONetworkInterface object. - @discussion Resource allocated by init() are released, and - clearInputQueue() is called to ensure that the input queue is empty. - The interface should have already detached from the network stack. -*/ - virtual void free( void ); - - /* Override IOService::handleOpen() */ - virtual bool handleOpen( IOService * client, - IOOptionBits options, - void * argument ); - - /* Override IOService::handleClose() */ - virtual void handleClose( IOService * client, IOOptionBits options ); - - /* Override IOService::handleIsOpen() */ - virtual bool handleIsOpen( const IOService * client ) const; - -/*! @function lock - @abstract Acquires a recursive lock owned by the interface. - @discussion A recursive lock is allocated and initialized in - init(). This lock is otherwise not used by the - IONetworkInterface class. This method call acquires - the lock and must be balanced with an unlock(). -*/ - virtual void lock( void ); - -/*! @function unlock - @abstract Releases the recursive lock owned by the interface. - @discussion A recursive lock is allocated and initialized in - init(). This lock is otherwise not used by the - IONetworkInterface class. This method call releases - the lock to balance a prior lock(). -*/ - virtual void unlock( void ); - -/*! @function controllerDidOpen - @abstract Sends a notification that the interface has opened the network - controller. - @discussion This method is called by handleOpen() to notify - subclasses that the controller was opened. The open on the controller - occurs when the interface receives the initial open request from a client. - Subclasses can override this method and inspect the controller before - allowing the client open. This method is called with the arbitration lock - held, hence issuing I/O to the controller must be avoided to eliminate the - possibility of a deadlock. - @param controller The controller that was opened. - @result Must return true in order for handleOpen() to accept the client - open. If the return is false, then the controller will be closed and the - client open will fail. -*/ - virtual bool controllerDidOpen( IONetworkController * controller ); - -/*! @function controllerWillClose - @abstract Sends a notification that the interface will close the network - controller. - @discussion This method is called by handleClose() after - receiving a close from the last interface client, and just before the - controller is closed. Subclasses can override this method to perform any - cleanup action before the controller is closed. This method is called with - the arbitration lock held, hence issuing I/O to the controller should be - avoided to eliminate the possibility of a deadlock. - @param controller The controller that is about to be closed. -*/ - virtual void controllerWillClose( IONetworkController * controller ); - -/*! @function performCommand - @abstract Handles an ioctl command sent to the network interface. - @discussion This method handles socket ioctl commands sent to the - network interface from DLIL. - IONetworkInterface handles commands that are common for all network - interface types. A subclass of IONetworkInterface may override this - method to override the command handling in IONetworkInterface, or - to extend the command processing to handle additional commands. - The ioctl commands handled by IONetworkInterface are - SIOCGIFMTU (Get interface MTU size), - SIOCSIFMTU (Set interface MTU size), - SIOCSIFMEDIA (Set media), and - SIOCGIFMEDIA (Get media and link status). - @param controller The controller object. - @param cmd The ioctl command code. - @param arg0 Command argument 0. Generally a pointer to an ifnet structure - associated with the interface. - @param arg1 Command argument 1. - @result Returns a BSD return value defined in bsd/sys/errno.h. -*/ - virtual SInt32 performCommand( - IONetworkController * controller, - unsigned long cmd, - void * arg0, - void * arg1 ); - -public: - -/*! @function getIfnet - @abstract Returns the ifnet_t allocated by the interface object. - @discussion Gets the interface's ifnet_t, which is managed - primarily by IONetworkInterface, however subclasses or drivers - can use this method to obtain a reference to the ifnet_t for - interface KPI calls. - @result Returns the ifnet_t after the interface has attached - to the network stack and before the interface is detached, otherwise returns - NULL. -*/ - virtual ifnet_t getIfnet( void ) const; - -protected: - - /* Deprecated. Use initIfnetParams instead. */ - virtual bool initIfnet( struct ifnet * ifp ); - -/*! @function handleClientOpen - @abstract Handles a client open on the interface. - @discussion This method is called by handleOpen() to allow a - subclass to handle a client close. The arbitration lock is held. - @param client The client object requesting the open. - @param options Options passed to handleOpen(). - @param argument Argument passed to handleOpen(). - @result Returns true to accept the client open, false to reject the open. -*/ - virtual bool handleClientOpen( IOService * client, - IOOptionBits options, - void * argument ); - -/*! @function handleClientClose - @abstract Handles a client close on the interface. - @discussion This method is called by handleClose() to allow a - subclass to handle a client close. The arbitration lock is held. - @param client The client object requesting the close. - @param options Options same options passed to handleClose(). -*/ - virtual void handleClientClose( IOService * client, - IOOptionBits options ); - - /* Override IOService::newUserClient() */ - virtual IOReturn newUserClient( task_t owningTask, - void * security_id, - UInt32 type, - IOUserClient ** handler ); - -/*! @function setInterfaceState - @abstract Updates the interface object state flags. - @discussion The flags reflect the current state of the interface, and is - also published through the kIOInterfaceState property. - @param set The flags that should be set. - @param clear The flags that should be cleared. - @result Returns the new interface state flags. -*/ - virtual UInt32 setInterfaceState( UInt32 set, UInt32 clear = 0 ); - -/*! @function powerStateWillChangeTo - @abstract Handles a pre-change power interest notification from the - network controller. - @discussion The controllerWillChangePowerState() method is - called by this handler. Subclasses are not expected to override this method. - @param flags Flags that describe the capability of the controller in the - new power state. - @param stateNumber An index to a state in the network controller's - power state array that the controller is switching to. - @param policyMaker A reference to the network controller's policy-maker, - and is also the originator of this notification. - @result Returns IOPMAckImplied to indicate synchronous completion. -*/ - virtual IOReturn powerStateWillChangeTo( - IOPMPowerFlags flags, - unsigned long stateNumber, - IOService * policyMaker ); - -/*! @function powerStateDidChangeTo - @abstract Handles a post-change power interest notification from the - network controller. - @discussion The controllerDidChangePowerState() method is - called by this handler. Subclasses are not expected to override this method. - @param flags Flags that describe the capability of the controller in the - new power state. - @param stateNumber An index to a state in the network controller's - power state array that the controller has switched to. - @param policyMaker A reference to the network controller's policy-maker, - and is also the originator of this notification. - @result Returns IOPMAckImplied to indicate synchronous completion. -*/ - virtual IOReturn powerStateDidChangeTo( - IOPMPowerFlags flags, - unsigned long stateNumber, - IOService * policyMaker ); - -/*! @function controllerWillChangePowerState - @abstract Handles a notification that the network controller servicing - this interface object will transition to a new power state. - @param controller The network controller object. - @param flags Flags that describe the capability of the controller in the - new power state. - @param stateNumber An index to a state in the network controller's - power state array that the controller is switching to. - @param policyMaker A reference to the network controller's policy-maker, - and is also the originator of this notification. - @result The return value is always kIOReturnSuccess. -*/ - virtual IOReturn controllerWillChangePowerState( - IONetworkController * controller, - IOPMPowerFlags flags, - UInt32 stateNumber, - IOService * policyMaker ); - -/*! @function controllerDidChangePowerState - @abstract Handles a notification that the network controller servicing - this interface object has transitioned to a new power state. - @param controller The network controller object. - @param flags Flags that describe the capability of the controller in the - new power state. - @param stateNumber An index to a state in the network controller's - power state array that the controller has switched to. - @param policyMaker A reference to the network controller's policy-maker, - and is also the originator of this notification. - @result The return value is always kIOReturnSuccess. -*/ - virtual IOReturn controllerDidChangePowerState( - IONetworkController * controller, - IOPMPowerFlags flags, - UInt32 stateNumber, - IOService * policyMaker ); - -public: - /* Override IOService::willTerminate() */ - virtual bool willTerminate( - IOService * provider, - IOOptionBits options ); - - /* Override IOService::requestTerminate() */ - virtual bool requestTerminate( - IOService * provider, IOOptionBits options ); - - /* Override IOService::serializeProperties() */ - virtual bool serializeProperties( OSSerialize * s ) const; - -/*! @function attachToDataLinkLayer - @abstract Attach the network interface to the BSD data link layer. - @discussion This method is called internally to attach the network - interface to the BSD data link layer, after an unit number has been - assigned. The calling context is not synchronized against the driver's - work loop. Subclasses may override this method to perform additional - setup before the network stack attach. The getIfnet() method - will return the BSD interface being attached. - @param options Options for the attach call. None are currently defined. - @param parameter Parameter for the attach call. Not currently used. - @result Returns kIOReturnSuccess on success. -*/ - virtual IOReturn attachToDataLinkLayer( IOOptionBits options, - void * parameter ); - - OSMetaClassDeclareReservedUsed(IONetworkInterface, 0); - -/*! @function detachFromDataLinkLayer - @abstract Detach the network interface from the BSD data link layer. - @discussion This method is called internally to detach the network - interface from the BSD data link layer, after the interface has been - terminated and before the last client close. This method will block until - the detach operation is complete. The calling context is not synchronized - against the driver's work loop. Subclasses may override this method to - perform additional cleanup before or after detaching from the network - stack. The getIfnet() method will return NULL after detach. - @param options Options for the detach call. None are currently defined. - @param parameter Parameter for the detach call. Not currently used. -*/ - virtual void detachFromDataLinkLayer( IOOptionBits options, - void * parameter ); - - OSMetaClassDeclareReservedUsed(IONetworkInterface, 1); - -protected: -/*! @function feedPacketInputTap - @abstract Feed received packets to the BPF - @discussion This function is called internally to send input packets to - the BPF input tap when it is enabled. Subclasses are not expected to - override this method. - @param mbuf_t Pointer to the input packet. -*/ - virtual void feedPacketInputTap( mbuf_t ); - - OSMetaClassDeclareReservedUsed(IONetworkInterface, 2); - -/*! @function feedPacketOutputTap - @abstract Feed output packets to the BPF - @discussion This function is called internally to send output packets to - the BPF output tap when it is enabled. Subclasses are not expected to - override this method. - @param mbuf_t Pointer to the output packet. -*/ - virtual void feedPacketOutputTap( mbuf_t ); - - OSMetaClassDeclareReservedUsed(IONetworkInterface, 3); - -/*! @function initIfnetParams - @abstract Allows a subclass to provide ifnet initialization parameters - specific to an interface type. - @discussion This method initializes the parameters that are common to all - network interfaces. An interface subclass is expected to override this - method, call the superclass implementation first, then initialize the - parameters specific to that interface type. This method is called after - an unit number has been assigned to the interface, and just before the - interface is attached to BSD. - @param params Pointer to an ifnet_init_params allocated by - the caller. - @result Returns true on success, false otherwise. -*/ - virtual bool initIfnetParams( struct ifnet_init_params * params ); - - OSMetaClassDeclareReservedUsed(IONetworkInterface, 4); - -/*! @function configureOutputStartDelay - @abstract Configure the output start delay - @discussion This optional routine, if used, needs to be called after - IONetworkInterface::init() and before IONetworkInterface::attachToDataLinkLayer(). - This allows for over-riding ifnet_init_eparams.start_delay_qlen and - ifnet_init_eparams.start_delay_timeout. - @param outputStartDelayQueueLength, maps to ifnet_init_eparams.start_delay_qlen - @param outputStartDelayTimeout, maps to ifnet_init_eparams.start_delay_timeout - @result kIOReturnSuccess if interface was successfully - configured. - */ - IOReturn configureOutputStartDelay( uint16_t outputStartDelayQueueLength, - uint16_t outputStartDelayTimeout ); - -public: - OSMetaClassDeclareReservedUnused( IONetworkInterface, 5); - OSMetaClassDeclareReservedUnused( IONetworkInterface, 6); - OSMetaClassDeclareReservedUnused( IONetworkInterface, 7); - OSMetaClassDeclareReservedUnused( IONetworkInterface, 8); - OSMetaClassDeclareReservedUnused( IONetworkInterface, 9); - OSMetaClassDeclareReservedUnused( IONetworkInterface, 10); - OSMetaClassDeclareReservedUnused( IONetworkInterface, 11); - OSMetaClassDeclareReservedUnused( IONetworkInterface, 12); - OSMetaClassDeclareReservedUnused( IONetworkInterface, 13); - OSMetaClassDeclareReservedUnused( IONetworkInterface, 14); - OSMetaClassDeclareReservedUnused( IONetworkInterface, 15); -}; - -#endif /* __cplusplus */ -#endif /* KERNEL */ -#endif /* !_IONETWORKINTERFACE_H */ diff --git a/AppleIntelWifiAdapter/IWLCachedScan.cpp b/AppleIntelWifiAdapter/IWLCachedScan.cpp index 5a53589..09a5440 100644 --- a/AppleIntelWifiAdapter/IWLCachedScan.cpp +++ b/AppleIntelWifiAdapter/IWLCachedScan.cpp @@ -17,7 +17,7 @@ #define super OSObject OSDefineMetaClassAndStructors(IWLCachedScan, OSObject); -#define check_packet() if(!packet) \ +#define check_packet() if (!packet) \ { IWL_ERR(0, "Packet should exist in IWLCachedScan (func: %s)\n", __FUNCTION__); return NULL; } /* @@ -28,22 +28,19 @@ OSDefineMetaClassAndStructors(IWLCachedScan, OSObject); SInt32 orderCachedScans(const OSMetaClassBase * obj1, const OSMetaClassBase * obj2, void * context) { IWLCachedScan* cachedScan_l = OSDynamicCast(IWLCachedScan, obj1); - if(!cachedScan_l) { + if (!cachedScan_l) return 0; - } IWLCachedScan* cachedScan_r = OSDynamicCast(IWLCachedScan, obj2); - if(!cachedScan_r) { + if (!cachedScan_r) return 0; - } - if(cachedScan_l->getTimestamp() < cachedScan_r->getTimestamp()) { // smaller timestamps go before + if (cachedScan_l->getTimestamp() < cachedScan_r->getTimestamp()) // smaller timestamps go before return 1; - } else if(cachedScan_l->getTimestamp() == cachedScan_r->getTimestamp()) { + else if (cachedScan_l->getTimestamp() == cachedScan_r->getTimestamp()) return 0; - } else { // object 2 is older, put it before + else // object 2 is older, put it before return -1; - } } @@ -60,38 +57,34 @@ bool IWLCachedScan::update(iwl_rx_phy_info* phy_info, int rssi, int noise) { bool IWLCachedScan::init(mbuf_t mbuf, int offset, int whOffset, iwl_rx_phy_info* phy_info, int rssi, int noise) { - if(!super::init()) { + if (!super::init()) return false; - } errno_t err = mbuf_dup(mbuf, MBUF_DONTWAIT, &buf); - if(err != 0) { + if (err != 0) { IWL_ERR(0, "mbuf dup complained\n"); return false; } - if(!buf) { + if (!buf) return false; - } packet = (iwl_rx_packet*)((u8*)mbuf_data((mbuf_t)buf) + (offset)); - if(!packet) { + if (!packet) return false; - } wh = (ieee80211_frame*)(packet->data + whOffset); iwl_rx_mpdu_res_start* rx_res = (iwl_rx_mpdu_res_start*)packet->data; this->ie_len = rx_res->byte_count - 36; - if(this->ie_len <= 0) + if (this->ie_len <= 0) return false; - if(le16toh(rx_res->byte_count) <= 36) { + if (le16toh(rx_res->byte_count) <= 36) return false; - } this->ie = ((uint8_t*)wh + 36); @@ -102,7 +95,7 @@ bool IWLCachedScan::init(mbuf_t mbuf, int offset, int whOffset, iwl_rx_phy_info* this->absolute_time = mach_absolute_time(); - if(this->ie[0] != 0x00) { + if (this->ie[0] != 0x00) { IWL_ERR(0, "potentially uncompliant frame\n"); IWL_INFO(0, "wh: %x, ie: %x\n", ((uint8_t*)wh)[39], ie[5]); IWL_INFO(0, "wh: %x, ie: %x\n", ((uint8_t*)wh)[38], ie[4]); // first byte @@ -132,13 +125,13 @@ bool IWLCachedScan::init(mbuf_t mbuf, int offset, int whOffset, iwl_rx_phy_info* } */ - if (channel.channel < 15) { + if (channel.channel < 15) channel.flags |= APPLE80211_C_FLAG_2GHZ; - } else { + else channel.flags |= APPLE80211_C_FLAG_5GHZ; - } + - switch(this->phy_info.rate_n_flags & RATE_MCS_CHAN_WIDTH_MSK) { + switch (this->phy_info.rate_n_flags & RATE_MCS_CHAN_WIDTH_MSK) { case RATE_MCS_CHAN_WIDTH_20: IWL_INFO(0, "Chan width 20mhz\n"); channel.flags |= APPLE80211_C_FLAG_20MHZ; @@ -168,7 +161,7 @@ bool IWLCachedScan::init(mbuf_t mbuf, int offset, int whOffset, iwl_rx_phy_info* void IWLCachedScan::free() { super::free(); - if(buf) { + if (buf) { mbuf_freem(buf); } packet = NULL; @@ -189,7 +182,7 @@ uint64_t IWLCachedScan::getSysTimestamp() { const char* IWLCachedScan::getSSID() { // ensure to free this resulting buffer check_packet() - if(ie[0] != 0x00) { + if (ie[0] != 0x00) { IWL_ERR(0, "haven't handled this yet\n"); return NULL; } @@ -198,7 +191,7 @@ const char* IWLCachedScan::getSSID() { // ensure to free this resulting buffer const char* ssid = (const char*)kzalloc(ssid_len + 1); // include null terminator - if(!ssid) + if (!ssid) return NULL; memcpy((void*)ssid, &ie[2], ssid_len); // 0x00 == type, 0x01 == size, 0x02 onwards == data @@ -209,14 +202,14 @@ const char* IWLCachedScan::getSSID() { // ensure to free this resulting buffer uint32_t IWLCachedScan::getSSIDLen() { check_packet() - if(ie[0] != 0x00) { + if (ie[0] != 0x00) { IWL_ERR(0, "haven't handled this yet\n"); return NULL; } uint8_t ssid_len = ie[1]; - if(ssid_len > 32) { + if (ssid_len > 32) { IWL_ERR(0, "ssid length too large, clamping to 32\n"); ssid_len = 32; } @@ -251,30 +244,28 @@ uint8_t* IWLCachedScan::getRates() { uint8_t* rate_ptr; size_t index = 0; - if(ie[index++] == 0x00) { // index is 1 when we enter in the frame + if (ie[index++] == 0x00) { // index is 1 when we enter in the frame index += ie[1] + 1; // increment by size of ssid AND skip over length byte - } - else { + } else { IWL_ERR(0, "still can't handle this\n"); return NULL; } - if(index >= ie_len) { + if (index >= ie_len) { IWL_ERR(0, "tried to access too far within IE, buffer overrun\n"); return NULL; } - if(ie[index++] == 0x01) { + if (ie[index++] == 0x01) { //good, we found it! uint32_t rate_size = ie[index++]; - if(rate_size != 8) { + if (rate_size != 8) { IWL_ERR(0, "rate set is NOT correct\n"); return NULL; } rate_ptr = &ie[index]; - } - else { + } else { IWL_ERR(0, "found ssid, but no rateset\n"); return NULL; } @@ -297,9 +288,8 @@ apple80211_scan_result* IWLCachedScan::getNativeType() { // be sure to free this result = (apple80211_scan_result*)kzalloc(sizeof(apple80211_scan_result)); - if(result == NULL) { + if (result == NULL) return NULL; - } result->version = APPLE80211_VERSION; @@ -312,7 +302,7 @@ apple80211_scan_result* IWLCachedScan::getNativeType() { // be sure to free this result->asr_ie_len = this->getIELen(); IWL_INFO(0, "IE length: %d\n", result->asr_ie_len); - if(result->asr_ie_len != 0) { + if (result->asr_ie_len != 0) { result->asr_ie_data = ie; //uint8_t* buf = (uint8_t*)result->asr_ie_data; @@ -325,8 +315,8 @@ apple80211_scan_result* IWLCachedScan::getNativeType() { // be sure to free this uint8_t* rates = this->getRates(); - if(rates != NULL) { - for(int i = 0; i < 8; i++) { + if (rates != NULL) { + for (int i = 0; i < 8; i++) { result->asr_rates[i] = (rates[i] >> 1) & 0x3F; // stolen magic } result->asr_nrates = 8; @@ -345,11 +335,11 @@ apple80211_scan_result* IWLCachedScan::getNativeType() { // be sure to free this result->asr_ssid_len = this->getSSIDLen(); - if(this->getSSIDLen() != 0) { + if (this->getSSIDLen() != 0) { const char* ssid = this->getSSID(); - if(ssid) { + if (ssid) { memcpy(&result->asr_ssid, ssid, this->getSSIDLen() + 1); IOFree((void*)ssid, this->getSSIDLen() + 1); diff --git a/AppleIntelWifiAdapter/IWLCachedScan.hpp b/AppleIntelWifiAdapter/IWLCachedScan.hpp index 8fb45b3..2b3371e 100644 --- a/AppleIntelWifiAdapter/IWLCachedScan.hpp +++ b/AppleIntelWifiAdapter/IWLCachedScan.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLCachedScan_hpp -#define IWLCachedScan_hpp +#ifndef APPLEINTELWIFIADAPTER_IWLCACHEDSCAN_HPP_ +#define APPLEINTELWIFIADAPTER_IWLCACHEDSCAN_HPP_ #include #include @@ -64,4 +64,4 @@ class IWLCachedScan : public OSObject { mbuf_t buf; // copied in from the ISR }; -#endif /* IWLCachedScan_hpp */ +#endif // APPLEINTELWIFIADAPTER_IWLCACHEDSCAN_HPP_ diff --git a/AppleIntelWifiAdapter/IWLCoex.cpp b/AppleIntelWifiAdapter/IWLCoex.cpp index 9750283..9067421 100644 --- a/AppleIntelWifiAdapter/IWLCoex.cpp +++ b/AppleIntelWifiAdapter/IWLCoex.cpp @@ -14,9 +14,9 @@ int IWLMvmDriver::sendBTInitConf() u32 mode; IOLockLock(trans->mutex); - if(unlikely(m_pDevice->btForceAntMode != BT_FORCE_ANT_DIS)) + if (unlikely(m_pDevice->btForceAntMode != BT_FORCE_ANT_DIS)) { - switch(m_pDevice->btForceAntMode) { + switch (m_pDevice->btForceAntMode) { case BT_FORCE_ANT_BT: mode = BT_COEX_BT; break; diff --git a/AppleIntelWifiAdapter/IWLCtxtInfo.hpp b/AppleIntelWifiAdapter/IWLCtxtInfo.hpp index 54f3a36..583f738 100644 --- a/AppleIntelWifiAdapter/IWLCtxtInfo.hpp +++ b/AppleIntelWifiAdapter/IWLCtxtInfo.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLCtxtInfo_hpp -#define IWLCtxtInfo_hpp +#ifndef APPLEINTELWIFIADAPTER_IWLCTXTINFO_HPP_ +#define APPLEINTELWIFIADAPTER_IWLCTXTINFO_HPP_ #include "IWLTransport.hpp" #include "IWLInternal.hpp" @@ -403,4 +403,4 @@ struct iwl_context_info_gen3 { __le32 reserved; } __packed; /* IPC_CONTEXT_INFO_S */ -#endif /* IWLCtxtInfo_hpp */ +#endif // APPLEINTELWIFIADAPTER_IWLCTXTINFO_HPP_ diff --git a/AppleIntelWifiAdapter/IWLDebug.c b/AppleIntelWifiAdapter/IWLDebug.c index 523aa1a..005cbca 100644 --- a/AppleIntelWifiAdapter/IWLDebug.c +++ b/AppleIntelWifiAdapter/IWLDebug.c @@ -145,11 +145,11 @@ unsigned char * base64_decode(const unsigned char *src, size_t len, *pos++ = (block[2] << 6) | block[3]; count = 0; if (pad) { - if (pad == 1) + if (pad == 1) { pos--; - else if (pad == 2) + } else if (pad == 2) { pos -= 2; - else { + } else { /* Invalid padding */ IOFree(out, olen); return NULL; diff --git a/AppleIntelWifiAdapter/IWLDebug.h b/AppleIntelWifiAdapter/IWLDebug.h index 389b5ed..8dcc419 100644 --- a/AppleIntelWifiAdapter/IWLDebug.h +++ b/AppleIntelWifiAdapter/IWLDebug.h @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLDebug_h -#define IWLDebug_h +#ifndef APPLEINTELWIFIADAPTER_IWLDEBUG_H_ +#define APPLEINTELWIFIADAPTER_IWLDEBUG_H_ #include @@ -45,7 +45,7 @@ do { size_t out_len = 0; unsigned char* buf = base64_encode((const unsigned char DebugLog("AppleIntelWifiAdapter DEBUG: buffer is %s\n", buf); \ _FREE(buf, out_len + 1); \ } \ -} while(0) +} while (0) /* No matter what is m (priv, bus, trans), this will work */ #define IWL_ERR_DEV(m, f, a...) \ @@ -77,7 +77,7 @@ do { size_t out_len = 0; unsigned char* buf = base64_encode((const unsigned char #define IWL_DEBUG_BUF(b, s) \ do { \ __iwl_dbg_buf(b, s); \ - } while(0) + } while (0) unsigned char * base64_encode(unsigned char *src, size_t len, size_t *out_len); @@ -85,4 +85,4 @@ unsigned char * base64_encode(unsigned char *src, size_t len, unsigned char * base64_decode(const unsigned char *src, size_t len, size_t *out_len); -#endif /* IWLDebug_h */ +#endif // APPLEINTELWIFIADAPTER_IWLDEBUG_H_ diff --git a/AppleIntelWifiAdapter/IWLDevice.cpp b/AppleIntelWifiAdapter/IWLDevice.cpp index a24e11a..c4221c4 100644 --- a/AppleIntelWifiAdapter/IWLDevice.cpp +++ b/AppleIntelWifiAdapter/IWLDevice.cpp @@ -16,9 +16,9 @@ bool IWLDevice::init() this->ie_dev = new IWL80211Device(); this->registerRWLock = IOSimpleLockAlloc(); UInt16 vendorID = pciDevice->configRead16(kIOPCIConfigVendorID); - if (vendorID != PCI_VENDOR_ID_INTEL) { + if (vendorID != PCI_VENDOR_ID_INTEL) return false; - } + deviceID = pciDevice->configRead16(kIOPCIConfigDeviceID); for (int i = 0; i < ARRAY_SIZE(iwl_hw_card_ids); i++) { pci_device_id dev = iwl_hw_card_ids[i]; @@ -30,11 +30,10 @@ bool IWLDevice::init() subSystemDeviceID = pciDevice->configRead16(kIOPCIConfigSubSystemID); this->rx_sync_waitq = IOLockAlloc(); this->last_ebs_successful = true; - if(this->cfg != NULL) { + if (this->cfg != NULL) { pciDevice->retain(); return true; - } - else { + } else { this->pciDevice = NULL; return false; } @@ -51,9 +50,8 @@ void IWLDevice::release() this->rx_sync_waitq = NULL; } - if(this->pciDevice) { + if (this->pciDevice) this->pciDevice->release(); - } } void IWLDevice::enablePCI() diff --git a/AppleIntelWifiAdapter/IWLDevice.hpp b/AppleIntelWifiAdapter/IWLDevice.hpp index 58fe9f6..11bc63c 100644 --- a/AppleIntelWifiAdapter/IWLDevice.hpp +++ b/AppleIntelWifiAdapter/IWLDevice.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLDevice_hpp -#define IWLDevice_hpp +#ifndef APPLEINTELWIFIADAPTER_IWLDEVICE_HPP_ +#define APPLEINTELWIFIADAPTER_IWLDEVICE_HPP_ #include #include @@ -564,4 +564,4 @@ struct iwl_rate_info { u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */ }; -#endif /* IWLDevice_hpp */ +#endif // APPLEINTELWIFIADAPTER_IWLDEVICE_HPP_ diff --git a/AppleIntelWifiAdapter/IWLFH.h b/AppleIntelWifiAdapter/IWLFH.h index 14c225b..101a634 100644 --- a/AppleIntelWifiAdapter/IWLFH.h +++ b/AppleIntelWifiAdapter/IWLFH.h @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLFH_h -#define IWLFH_h +#ifndef APPLEINTELWIFIADAPTER_IWLFH_H_ +#define APPLEINTELWIFIADAPTER_IWLFH_H_ #include #include @@ -702,4 +702,4 @@ struct iwl_gen3_bc_tbl { __le16 tfd_offset[TFD_QUEUE_BC_SIZE_GEN3]; } __packed; -#endif /* IWLFH_h */ +#endif // APPLEINTELWIFIADAPTER_IWLFH_H_ diff --git a/AppleIntelWifiAdapter/IWLInternal.hpp b/AppleIntelWifiAdapter/IWLInternal.hpp index 4cd9c75..0e362b0 100644 --- a/AppleIntelWifiAdapter/IWLInternal.hpp +++ b/AppleIntelWifiAdapter/IWLInternal.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLInternal_hpp -#define IWLInternal_hpp +#ifndef APPLEINTELWIFIADAPTER_IWLINTERNAL_HPP_ +#define APPLEINTELWIFIADAPTER_IWLINTERNAL_HPP_ #include #include @@ -27,4 +27,4 @@ struct iwl_dma_ptr* allocate_dma_buf32(size_t size); void free_dma_buf(struct iwl_dma_ptr *dma_ptr); -#endif /* IWLInternal_hpp */ +#endif // APPLEINTELWIFIADAPTER_IWLINTERNAL_HPP_ diff --git a/AppleIntelWifiAdapter/IWLPhyDb.hpp b/AppleIntelWifiAdapter/IWLPhyDb.hpp index 7f362eb..f4d0678 100644 --- a/AppleIntelWifiAdapter/IWLPhyDb.hpp +++ b/AppleIntelWifiAdapter/IWLPhyDb.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLPhyDb_hpp -#define IWLPhyDb_hpp +#ifndef APPLEINTELWIFIADAPTER_IWLPHYDB_HPP_ +#define APPLEINTELWIFIADAPTER_IWLPHYDB_HPP_ #include #include @@ -71,4 +71,4 @@ int iwl_phy_db_get_section_data(struct iwl_phy_db *phy_db, int iwl_send_phy_db_data(struct iwl_phy_db *phy_db); -#endif /* IWLPhyDb_hpp */ +#endif // APPLEINTELWIFIADAPTER_IWLPHYDB_HPP_ diff --git a/AppleIntelWifiAdapter/fw/FWFile.h b/AppleIntelWifiAdapter/fw/FWFile.h index b061c98..009a03a 100644 --- a/AppleIntelWifiAdapter/fw/FWFile.h +++ b/AppleIntelWifiAdapter/fw/FWFile.h @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef FWFile_h -#define FWFile_h +#ifndef APPLEINTELWIFIADAPTER_FW_FWFILE_H_ +#define APPLEINTELWIFIADAPTER_FW_FWFILE_H_ #include #include @@ -1045,26 +1045,19 @@ struct iwl_error_event_table { uint32_t frame_ptr; /* frame pointer */ uint32_t stack_ptr; /* stack pointer */ uint32_t hcmd; /* last host command header */ - uint32_t isr0; /* isr status register LMPM_NIC_ISR0: - * rxtx_flag */ - uint32_t isr1; /* isr status register LMPM_NIC_ISR1: - * host_flag */ - uint32_t isr2; /* isr status register LMPM_NIC_ISR2: - * enc_flag */ - uint32_t isr3; /* isr status register LMPM_NIC_ISR3: - * time_flag */ - uint32_t isr4; /* isr status register LMPM_NIC_ISR4: - * wico interrupt */ + uint32_t isr0; /* isr status register LMPM_NIC_ISR0: rxtx_flag */ + uint32_t isr1; /* isr status register LMPM_NIC_ISR1: host_flag */ + uint32_t isr2; /* isr status register LMPM_NIC_ISR2: enc_flag */ + uint32_t isr3; /* isr status register LMPM_NIC_ISR3: time_flag */ + uint32_t isr4; /* isr status register LMPM_NIC_ISR4: wico interrupt */ uint32_t last_cmd_id; /* last HCMD id handled by the firmware */ uint32_t wait_event; /* wait event() caller address */ uint32_t l2p_control; /* L2pControlField */ uint32_t l2p_duration; /* L2pDurationField */ uint32_t l2p_mhvalid; /* L2pMhValidBits */ uint32_t l2p_addr_match; /* L2pAddrMatchStat */ - uint32_t lmpm_pmg_sel; /* indicate which clocks are turned on - * (LMPM_PMG_SEL) */ - uint32_t u_timestamp; /* indicate when the date and time of the - * compilation */ + uint32_t lmpm_pmg_sel; /* indicate which clocks are turned on (LMPM_PMG_SEL) */ + uint32_t u_timestamp; /* indicate when the date and time of the compilation */ uint32_t flow_handler; /* FH read/write pointers, RX credit */ } __packed /* LOG_ERROR_TABLE_API_S_VER_3 */; @@ -1111,4 +1104,4 @@ static inline size_t _iwl_tlv_array_len(const struct iwl_ucode_tlv *tlv, sizeof(_struct_ptr->_memb[0])) -#endif /* FWFile_h */ +#endif // APPLEINTELWIFIADAPTER_FW_FWFILE_H_ diff --git a/AppleIntelWifiAdapter/fw/FWImg.h b/AppleIntelWifiAdapter/fw/FWImg.h index 8d9cf08..7bab40d 100644 --- a/AppleIntelWifiAdapter/fw/FWImg.h +++ b/AppleIntelWifiAdapter/fw/FWImg.h @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef FWImg_h -#define FWImg_h +#ifndef APPLEINTELWIFIADAPTER_FW_FWIMG_H_ +#define APPLEINTELWIFIADAPTER_FW_FWIMG_H_ #include #include "../IWLInternal.hpp" @@ -394,4 +394,4 @@ iwl_fw_lookup_notif_ver(const struct iwl_fw *fw, u8 grp, u8 cmd, u8 def) return def; } -#endif /* FWImg_h */ +#endif // APPLEINTELWIFIADAPTER_FW_FWIMG_H_ diff --git a/AppleIntelWifiAdapter/fw/IWLFw.cpp b/AppleIntelWifiAdapter/fw/IWLFw.cpp index 6fe146c..fceb87e 100644 --- a/AppleIntelWifiAdapter/fw/IWLFw.cpp +++ b/AppleIntelWifiAdapter/fw/IWLFw.cpp @@ -40,17 +40,17 @@ int IWLMvmDriver::runInitMvmUCode(bool read_nvm) //this->trans->mutex = IOLockAlloc(); - if(!this->trans) { + if (!this->trans) { IWL_ERR(0, "trans ???"); return 0; } - if(!this->trans->mutex) { + if (!this->trans->mutex) { IWL_ERR(0, "Could not alloc mutex\n"); return 0; } - if(!IOLockTryLock(this->trans->mutex)) { + if (!IOLockTryLock(this->trans->mutex)) { IWL_ERR(0, "Could not lock mutex\n"); return 0; } @@ -311,7 +311,7 @@ int IWLMvmDriver::sendPhyCfgCmd() phy_cfg_cmd.phy_cfg = cpu_to_le32(iwl_mvm_get_phy_config(m_pDevice)); //phy_cfg_cmd.phy_cfg |= cpu_to_le32(m_pDevice->cfg->) - if(trans->m_pDevice->cfg->tx_with_siso_diversity) { + if (trans->m_pDevice->cfg->tx_with_siso_diversity) { phy_cfg_cmd.phy_cfg = cpu_to_le32(FW_PHY_CFG_CHAIN_SAD_ENABLED); } @@ -325,7 +325,7 @@ int IWLMvmDriver::sendPhyCfgCmd() u8 cmd_ver = iwl_fw_lookup_cmd_ver(&trans->m_pDevice->fw, IWL_ALWAYS_LONG_GROUP, PHY_CONFIGURATION_CMD); - if(cmd_ver == 3) { + if (cmd_ver == 3) { iwl_mvm_phy_filter_init(this, &phy_filters); memcpy(&phy_cfg_cmd.phy_specific_cfg, &phy_filters, sizeof(struct iwl_phy_specific_cfg)); @@ -393,21 +393,19 @@ static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait, } bool free_paging(IWLMvmDriver* drv) { - if(drv->m_pDevice->fw_paging_db[0].fw_paging_block) { - if(drv->m_pDevice->fw_paging_db[0].fw_paging_block->addr != NULL) { - for(int i = 0; i < NUM_OF_FW_PAGING_BLOCKS; i++) { - if(drv->m_pDevice->fw_paging_db[i].fw_paging_block) { + if (drv->m_pDevice->fw_paging_db[0].fw_paging_block) { + if (drv->m_pDevice->fw_paging_db[0].fw_paging_block->addr != NULL) { + for (int i = 0; i < NUM_OF_FW_PAGING_BLOCKS; i++) { + if (drv->m_pDevice->fw_paging_db[i].fw_paging_block) { free_dma_buf(drv->m_pDevice->fw_paging_db[i].fw_paging_block); drv->m_pDevice->fw_paging_db[i].fw_paging_block = NULL; } } memset(drv->m_pDevice->fw_paging_db, 0, sizeof(drv->m_pDevice->fw_paging_db)); - } - else { + } else { return false; } - } - else { + } else { return false; } @@ -417,8 +415,8 @@ bool free_paging(IWLMvmDriver* drv) { bool alloc_pages(IWLMvmDriver* drv, fw_img* img) { int blk_idx = 0; - if(drv->m_pDevice->fw_paging_db[0].fw_paging_block) { - if(drv->m_pDevice->fw_paging_db[0].fw_paging_block->addr != NULL) { + if (drv->m_pDevice->fw_paging_db[0].fw_paging_block) { + if (drv->m_pDevice->fw_paging_db[0].fw_paging_block->addr != NULL) { return false; } } @@ -434,10 +432,9 @@ bool alloc_pages(IWLMvmDriver* drv, fw_img* img) { int error; iwl_dma_ptr* ptr = allocate_dma_buf(4096, drv->trans->dma_mask); - if(ptr) { + if (ptr) { drv->m_pDevice->fw_paging_db[blk_idx].fw_paging_block = ptr; - } - else { + } else { free_paging(drv); return false; } @@ -698,14 +695,14 @@ int IWLMvmDriver::loadUcodeWaitAlive(enum iwl_ucode_type ucode_type) set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &m_pDevice->status); - if(m_pDevice->fw.img[m_pDevice->cur_fw_img].paging_mem_size) { + if (m_pDevice->fw.img[m_pDevice->cur_fw_img].paging_mem_size) { ret = save_paging(this, &m_pDevice->fw.img[m_pDevice->cur_fw_img]); - if(ret) + if (ret) return ret; ret = send_paging(this, &m_pDevice->fw.img[m_pDevice->cur_fw_img]); - if(ret) { + if (ret) { free_paging(this); return ret; diff --git a/AppleIntelWifiAdapter/fw/IWLUcodeParse.hpp b/AppleIntelWifiAdapter/fw/IWLUcodeParse.hpp index 5191090..1fbb93e 100644 --- a/AppleIntelWifiAdapter/fw/IWLUcodeParse.hpp +++ b/AppleIntelWifiAdapter/fw/IWLUcodeParse.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLUcodeParse_hpp -#define IWLUcodeParse_hpp +#ifndef APPLEINTELWIFIADAPTER_FW_IWLUCODEPARSE_HPP_ +#define APPLEINTELWIFIADAPTER_FW_IWLUCODEPARSE_HPP_ #include @@ -19,7 +19,7 @@ class IWLUcodeParse { public: - IWLUcodeParse(IWLDevice *drv); + explicit IWLUcodeParse(IWLDevice *drv); ~IWLUcodeParse(); bool parseFW(const void *raw, size_t len, struct iwl_fw *fw, struct iwl_firmware_pieces *pieces); @@ -71,4 +71,4 @@ class IWLUcodeParse { IWLDevice *drv; }; -#endif /* IWLUcodeParse_hpp */ +#endif // APPLEINTELWIFIADAPTER_FW_IWLUCODEPARSE_HPP_ diff --git a/AppleIntelWifiAdapter/fw/NotificationWait.hpp b/AppleIntelWifiAdapter/fw/NotificationWait.hpp index 30493b6..5616139 100644 --- a/AppleIntelWifiAdapter/fw/NotificationWait.hpp +++ b/AppleIntelWifiAdapter/fw/NotificationWait.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef NotificationWait_hpp -#define NotificationWait_hpp +#ifndef APPLEINTELWIFIADAPTER_FW_NOTIFICATIONWAIT_HPP_ +#define APPLEINTELWIFIADAPTER_FW_NOTIFICATIONWAIT_HPP_ #include "../trans/TransHdr.h" @@ -99,4 +99,4 @@ iwl_wait_notification(struct iwl_notif_wait_data *notif_data, struct iwl_notific void __releases(wait_entry) iwl_remove_notification(struct iwl_notif_wait_data *notif_data, struct iwl_notification_wait *wait_entry); -#endif /* NotificationWait_hpp */ +#endif // APPLEINTELWIFIADAPTER_FW_NOTIFICATIONWAIT_HPP_ diff --git a/AppleIntelWifiAdapter/fw/fw-api.h b/AppleIntelWifiAdapter/fw/fw-api.h index 15857ba..5be9917 100644 --- a/AppleIntelWifiAdapter/fw/fw-api.h +++ b/AppleIntelWifiAdapter/fw/fw-api.h @@ -62,8 +62,8 @@ * *****************************************************************************/ -#ifndef __fw_api_h__ -#define __fw_api_h__ +#ifndef APPLEINTELWIFIADAPTER_FW_FW_API_H_ +#define APPLEINTELWIFIADAPTER_FW_FW_API_H_ #include "tdls.h" #include "mac-cfg.h" @@ -96,4 +96,4 @@ #include "tx.h" #include "testing.h" -#endif /* __fw_api_h__ */ +#endif // APPLEINTELWIFIADAPTER_FW_FW_API_H_ diff --git a/AppleIntelWifiAdapter/mvm/IWLApple80211.cpp b/AppleIntelWifiAdapter/mvm/IWLApple80211.cpp index 20d021e..25b7f38 100644 --- a/AppleIntelWifiAdapter/mvm/IWLApple80211.cpp +++ b/AppleIntelWifiAdapter/mvm/IWLApple80211.cpp @@ -22,12 +22,12 @@ bool IWL80211Device::init(IWLMvmDriver* drv) { bool IWL80211Device::release() { - if(scanCacheLock) { + if (scanCacheLock) { IOLockFree(scanCacheLock); scanCacheLock = NULL; } - if(scanCache) { + if (scanCache) { scanCache->release(); scanCache = NULL; } @@ -36,7 +36,7 @@ bool IWL80211Device::release() { } bool IWL80211Device::scanDone() { - if(iface != NULL) { + if (iface != NULL) { //fDrv->m_pDevice->interface->postMessage(APPLE80211_M_SCAN_DONE); fDrv->controller->getNetworkInterface()->postMessage(APPLE80211_M_SCAN_DONE); return true; diff --git a/AppleIntelWifiAdapter/mvm/IWLApple80211.hpp b/AppleIntelWifiAdapter/mvm/IWLApple80211.hpp index 641f174..5054afc 100644 --- a/AppleIntelWifiAdapter/mvm/IWLApple80211.hpp +++ b/AppleIntelWifiAdapter/mvm/IWLApple80211.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLApple80211_hpp -#define IWLApple80211_hpp +#ifndef APPLEINTELWIFIADAPTER_MVM_IWLAPPLE80211_HPP_ +#define APPLEINTELWIFIADAPTER_MVM_IWLAPPLE80211_HPP_ #include "IWLMvmDriver.hpp" @@ -49,4 +49,4 @@ class IWL80211Device { IWLMvmDriver* fDrv; }; -#endif /* IWLApple80211_hpp */ +#endif // APPLEINTELWIFIADAPTER_MVM_IWLAPPLE80211_HPP_ diff --git a/AppleIntelWifiAdapter/mvm/IWLConstants.h b/AppleIntelWifiAdapter/mvm/IWLConstants.h index 15c57c5..26a4396 100644 --- a/AppleIntelWifiAdapter/mvm/IWLConstants.h +++ b/AppleIntelWifiAdapter/mvm/IWLConstants.h @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLConstants_h -#define IWLConstants_h +#ifndef APPLEINTELWIFIADAPTER_MVM_IWLCONSTANTS_H_ +#define APPLEINTELWIFIADAPTER_MVM_IWLCONSTANTS_H_ #include "fw-api.h" @@ -111,4 +111,4 @@ #define IWL_MVM_PHY_FILTER_CHAIN_C 0 #define IWL_MVM_PHY_FILTER_CHAIN_D 0 -#endif /* IWLConstants_h */ +#endif // APPLEINTELWIFIADAPTER_MVM_IWLCONSTANTS_H_ diff --git a/AppleIntelWifiAdapter/mvm/IWLMac80211.cpp b/AppleIntelWifiAdapter/mvm/IWLMac80211.cpp index d39aacd..8c098dd 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMac80211.cpp +++ b/AppleIntelWifiAdapter/mvm/IWLMac80211.cpp @@ -138,14 +138,14 @@ int IWLMvmDriver::iwm_newstate(struct ieee80211com *ic, enum ieee80211_state nst { struct ifnet *ifp = &ic->ic_if; - if(!ifp) { + if (!ifp) { IWL_ERR(0, "got null ifp\n"); return -1; } IWLMvmDriver *sc = (IWLMvmDriver*)ifp->if_softc; struct iwm_node *in = (struct iwm_node *)ic->ic_bss; - if(!in) { + if (!in) { IWL_ERR(0, "could not get bss\n"); return -1; } diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmDriver.cpp b/AppleIntelWifiAdapter/mvm/IWLMvmDriver.cpp index 3440d8a..7dea70c 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmDriver.cpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmDriver.cpp @@ -25,7 +25,7 @@ OSDefineMetaClassAndStructors(IWLMvmDriver, OSObject); bool IWLMvmDriver::init(IOPCIDevice *pciDevice) { - if(!super::init()) { + if (!super::init()) { return false; } this->fwLoadLock = IOLockAlloc(); @@ -496,7 +496,7 @@ bool IWLMvmDriver::enableDevice() { // now we run the proper ucode - if(err) + if (err) goto fail; stopDevice(); @@ -505,7 +505,7 @@ bool IWLMvmDriver::enableDevice() { m_pDevice->cur_fw_img = IWL_UCODE_REGULAR; err = loadUcodeWaitAlive(IWL_UCODE_REGULAR); - if(err < 0) { + if (err < 0) { IWL_ERR(0, "Failed to run REGULAR ucode: %d\n", err); goto fail; } @@ -515,20 +515,20 @@ bool IWLMvmDriver::enableDevice() { */ err = iwl_sf_config(this, SF_INIT_OFF); - if(err < 0) { + if (err < 0) { IWL_ERR(0, "Smart FIFO failed to activate: %d\n", err); goto fail; } err = sendTXAntCfg(iwl_mvm_get_valid_tx_ant(m_pDevice)); - if(err < 0) { + if (err < 0) { IWL_ERR(0, "Failed to send TX ant: %d\n", err); goto fail; } - if(!iwl_mvm_has_unified_ucode(m_pDevice)) { + if (!iwl_mvm_has_unified_ucode(m_pDevice)) { err = iwl_send_phy_db_data(&phy_db); - if(err < 0) { + if (err < 0) { IWL_ERR(0, "Failed to send phy db: %d\n", err); goto fail; } @@ -544,13 +544,13 @@ bool IWLMvmDriver::enableDevice() { err = sendBTInitConf(); - if(err < 0) { + if (err < 0) { IWL_ERR(0, "Failed to activate BT coex: %d\n", err); goto fail; } - if(fw_has_capa(&this->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_DQA_SUPPORT)) + if (fw_has_capa(&this->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_DQA_SUPPORT)) { iwl_dqa_enable_cmd cmd = { .cmd_queue = cpu_to_le32(IWL_MVM_DQA_CMD_QUEUE), @@ -559,19 +559,19 @@ bool IWLMvmDriver::enableDevice() { u32 cmd_id = iwl_cmd_id(DQA_ENABLE_CMD, DATA_PATH_GROUP, 0); int ret = sendCmdPdu(cmd_id, 0, sizeof(cmd), &cmd); - if(ret) + if (ret) IWL_ERR(0, "Failed to send DQA enabling commands: %d\n", ret); else IWL_INFO(0, "Working in DQA mode\n"); } err = iwl_mvm_add_aux_sta(this); - if(err < 0) { + if (err < 0) { IWL_ERR(0, "Failed to add aux station: %d\n", err); goto fail; } - for(int i = 0; i < NUM_PHY_CTX; i++) + for (int i = 0; i < NUM_PHY_CTX; i++) { this->m_pDevice->phy_ctx[i].channel = &m_pDevice->ie_dev->channels[0]; IWL_INFO(0, "flags of channel: %d",m_pDevice->ie_dev->channels[0].flags); @@ -580,7 +580,7 @@ bool IWLMvmDriver::enableDevice() { goto fail; } - if(!fw_has_capa(&this->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_SET_LTR_GEN2)) + if (!fw_has_capa(&this->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_SET_LTR_GEN2)) { iwl_ltr_config_cmd cmd = { .flags = htole32(LTR_CFG_FLAG_FEATURE_ENABLE), @@ -590,42 +590,42 @@ bool IWLMvmDriver::enableDevice() { } err = this->sendPowerStatus(); - if(err < 0) { + if (err < 0) { IWL_ERR(0, "Failed to send power status command: %d\n", err); goto fail; } - if(fw_has_capa(&this->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_LAR_SUPPORT)) { + if (fw_has_capa(&this->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_LAR_SUPPORT)) { err = (this->updateMcc("ZZ", MCC_SOURCE_OLD_FW) == NULL); - if(err < 0) { + if (err < 0) { IWL_ERR(0, "Failed to update MCC: %d\n", err); goto fail; } IWL_INFO(0, "LAR Support\n"); } - if(fw_has_capa(&this->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { + if (fw_has_capa(&this->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { IWL_INFO(0, "umac scanning enabled (ptr: 0x%x)\n", this->m_pDevice); this->m_pDevice->umac_scanning = true; err = iwl_config_umac_scan(this); - if(err < 0) { + if (err < 0) { IWL_ERR(0, "Failed to init scan config: %d\n", err); goto fail; } } - for(int ac = 0; ac < 4; ac++) //WME_NUM_AC == 4 + for (int ac = 0; ac < 4; ac++) //WME_NUM_AC == 4 { err = iwl_enable_txq(this, 0, ac + IWL_MVM_DQA_MIN_MGMT_QUEUE, iwl_mvm_ac_to_tx_fifo[ac]); - if(err) { + if (err) { IWL_ERR(0, "Could not enable tx queue %d (error %d)\n", ac, err); goto fail; } } err = iwl_disable_beacon_filter(this); - if(err) { + if (err) { IWL_ERR(0, "Could not disable beacon filter (%d)\n", err); goto fail; } @@ -867,7 +867,7 @@ int IWLMvmDriver::sendPowerStatus() { .flags = 0 }; - if(!fw_has_capa(&this->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_FLAGS_DEVICE_PS_CMD)) { + if (!fw_has_capa(&this->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_FLAGS_DEVICE_PS_CMD)) { IWL_INFO(0, "No PS Support\n"); return 0; } @@ -875,9 +875,6 @@ int IWLMvmDriver::sendPowerStatus() { cmd.flags |= htole16(DEVICE_POWER_FLAGS_CAM_MSK); // cmd.flags |= htole16(DEVICE_POWER_FLAGS_32K_CLK_VALID_MSK); // cmd.flags |= htole16(DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK); - IWL_INFO(0, "Sending power command with flags (0x%0x)\n", cmd.flags); - return sendCmdPdu(POWER_TABLE_CMD, 0, sizeof(cmd), &cmd); } - diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmDriver.hpp b/AppleIntelWifiAdapter/mvm/IWLMvmDriver.hpp index ff509b7..c1ab232 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmDriver.hpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmDriver.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLMvmDriver_hpp -#define IWLMvmDriver_hpp +#ifndef APPLEINTELWIFIADAPTER_MVM_IWLMVMDRIVER_HPP_ +#define APPLEINTELWIFIADAPTER_MVM_IWLMVMDRIVER_HPP_ #include #include @@ -146,4 +146,4 @@ static inline bool iwl_mvm_has_new_rx_api(struct iwl_fw *fw) IWL_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT); } -#endif /* IWLMvmDriver_hpp */ +#endif // APPLEINTELWIFIADAPTER_MVM_IWLMVMDRIVER_HPP_ diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmMac.cpp b/AppleIntelWifiAdapter/mvm/IWLMvmMac.cpp index fd936b8..3e386e9 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmMac.cpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmMac.cpp @@ -18,8 +18,8 @@ int iwl_config_umac_scan(IWLMvmDriver* drv) { struct iwl_scan_config_v1* cfg; int nchan, err; size_t len; - if(iwl_mvm_cdb_scan_api(drv->m_pDevice)) { - if(iwl_mvm_is_cdb_supported(drv->m_pDevice)) { + if (iwl_mvm_cdb_scan_api(drv->m_pDevice)) { + if (iwl_mvm_is_cdb_supported(drv->m_pDevice)) { len = sizeof(iwl_scan_config_v2) + (drv->m_pDevice->fw.ucode_capa.n_scan_channels); } else { len = sizeof(iwl_scan_config_v1) + (drv->m_pDevice->fw.ucode_capa.n_scan_channels); @@ -64,7 +64,7 @@ int iwl_config_umac_scan(IWLMvmDriver* drv) { cfg->rx_chains = cpu_to_le32(iwl_mvm_get_valid_rx_ant(drv->m_pDevice)); cfg->legacy_rates = cpu_to_le32(rates | SCAN_CONFIG_SUPPORTED_RATE(rates)); - if(iwl_mvm_cdb_scan_api(drv->m_pDevice) && iwl_mvm_is_cdb_supported(drv->m_pDevice)) { + if (iwl_mvm_cdb_scan_api(drv->m_pDevice) && iwl_mvm_is_cdb_supported(drv->m_pDevice)) { IWL_INFO(0, "cfg_v2 scan config being used\n"); iwl_scan_config_v2* cfg_v2 = (iwl_scan_config_v2*)cfg; cfg_v2->dwell.active = 10; @@ -89,7 +89,7 @@ int iwl_config_umac_scan(IWLMvmDriver* drv) { int num_channels = drv->m_pDevice->fw.ucode_capa.n_scan_channels; - if(num_channels > IEEE80211_CHAN_MAX) { + if (num_channels > IEEE80211_CHAN_MAX) { IWL_ERR(0, "ucode asked for %d channels\n", num_channels); IOFree(cfg, len); return -1; @@ -99,10 +99,10 @@ int iwl_config_umac_scan(IWLMvmDriver* drv) { for (nchan = 0; nchan < num_channels; nchan++) { c = &drv->m_pDevice->ie_dev->channels[nchan]; - if(!c) + if (!c) continue; - if(c->flags == 0) + if (c->flags == 0) continue; IWL_DEBUG(0, "Adding channel %d to scan config\n", c->channel); @@ -130,7 +130,7 @@ int iwl_config_umac_scan(IWLMvmDriver* drv) { int num_channels = drv->m_pDevice->fw.ucode_capa.n_scan_channels; - if(num_channels > IEEE80211_CHAN_MAX) { + if (num_channels > IEEE80211_CHAN_MAX) { IWL_ERR(0, "ucode asked for %d channels\n", num_channels); IOFree(cfg, len); return -1; @@ -140,10 +140,10 @@ int iwl_config_umac_scan(IWLMvmDriver* drv) { for (nchan = 0; nchan < num_channels; nchan++) { c = &drv->m_pDevice->ie_dev->channels[nchan]; - if(!c) + if (!c) continue; - if(c->flags == 0) + if (c->flags == 0) continue; IWL_DEBUG(0, "Adding channel %d to scan config\n", c->channel); @@ -155,7 +155,7 @@ int iwl_config_umac_scan(IWLMvmDriver* drv) { err = drv->sendCmd(&hcmd); - if(!err) + if (!err) IWL_DEBUG(0, "sent umac config successfully\n"); IOFree(cfg, len); @@ -168,12 +168,11 @@ int iwl_fill_probe_req(IWLMvmDriver* drv, apple80211_scan_data* appleReq, iwl_sc iwl_scan_probe_req* preq_v2; struct ieee80211_frame* wh; - if(ext_chan) { + if (ext_chan) { preq_v2 = (iwl_scan_probe_req*)preq; memset(preq_v2, 0, sizeof(*preq_v2)); wh = (ieee80211_frame*)preq_v2->buf; - } - else { + } else { memset(preq, 0, sizeof(*preq)); wh = (ieee80211_frame*)preq->buf; } @@ -182,7 +181,7 @@ int iwl_fill_probe_req(IWLMvmDriver* drv, apple80211_scan_data* appleReq, iwl_sc size_t remain = sizeof(preq->buf); uint8_t *frm, *pos; - if(WARN_ON(appleReq->ssid_len > sizeof(appleReq->ssid))) { + if (WARN_ON(appleReq->ssid_len > sizeof(appleReq->ssid))) { IWL_ERR(0, "ssid_len longer then sizeof?\n"); return -1; } @@ -232,7 +231,7 @@ int iwl_fill_probe_req(IWLMvmDriver* drv, apple80211_scan_data* appleReq, iwl_sc preq->band_data[0].len = htole16(frm - pos); remain -= frm - pos; - if(fw_has_capa(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT)) { + if (fw_has_capa(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT)) { if (remain < 3) { IWL_ERR(0, "no space for ie support\n"); return ENOBUFS; @@ -243,7 +242,7 @@ int iwl_fill_probe_req(IWLMvmDriver* drv, apple80211_scan_data* appleReq, iwl_sc remain -= 3; } - if(drv->m_pDevice->nvm_data->sku_cap_band_52ghz_enable) { + if (drv->m_pDevice->nvm_data->sku_cap_band_52ghz_enable) { memset(&rs, 0, sizeof(ieee80211_rateset)); memcpy(&rs, &ieee80211_std_rateset_11a, sizeof(ieee80211_std_rateset_11a )); @@ -266,7 +265,7 @@ int iwl_fill_probe_req(IWLMvmDriver* drv, apple80211_scan_data* appleReq, iwl_sc remain -= frm - pos; } - if(ext_chan) { + if (ext_chan) { preq_v2->common_data.offset = htole16(frm - (uint8_t *)wh); pos = frm; @@ -297,7 +296,7 @@ int iwl_umac_scan_fill_channels(IWLMvmDriver* drv, apple80211_scan_data* appleRe bool scan_all = false; - if(num_channels == 0) { + if (num_channels == 0) { // they probably want us to scan every channel num_channels = drv->m_pDevice->n_chans; scan_all = true; @@ -309,26 +308,26 @@ int iwl_umac_scan_fill_channels(IWLMvmDriver* drv, apple80211_scan_data* appleRe uint8_t nchan; for (nchan = 0; nchan < num_channels; nchan++) { - if(!scan_all) { + if (!scan_all) { c = &drv->m_pDevice->ie_dev->channels_scan[nchan]; } else { c = &drv->m_pDevice->ie_dev->channels[nchan]; } - if(c->channel == 0) // channel should never be 0 + if (c->channel == 0) // channel should never be 0 continue; IWL_DEBUG(0, "adding chan %d to scan\n", c->channel); chan->v1.channel_num = htole16(c->channel); #ifndef notyet - if(fw_has_api(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER)) { + if (fw_has_api(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER)) { #else - if(0) { + if (0) { #endif - if (c->flags & APPLE80211_C_FLAG_5GHZ) { + if (c->flags & APPLE80211_C_FLAG_5GHZ) chan->v2.band = 1; - } + chan->v2.iter_count = 1; chan->v2.iter_interval = htole16(0); } else { @@ -361,14 +360,14 @@ int iwl_umac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { bool adaptive_dwell = fw_has_api(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_API_ADAPTIVE_DWELL); bool ext_chan; - - if(drv->m_pDevice->cfg->trans.device_family == IWL_DEVICE_FAMILY_8000) { - // Patch out ext_chan for 8xxx devices.. - // Without this patch, we would not be able to scan (for some god awful reason) + + // Patch out ext_chan for 8xxx devices.. + // Without this patch, we would not be able to scan (for some god awful reason) + if (drv->m_pDevice->cfg->trans.device_family == IWL_DEVICE_FAMILY_8000) ext_chan = false; - } else { + else ext_chan = fw_has_api(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER); - } + //bool adaptive_dwell = false; #ifdef notyet @@ -384,21 +383,19 @@ int iwl_umac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { size_t req_len; int err; - if(!fw_has_capa(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { + if (!fw_has_capa(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) IWL_ERR(0, "firmware does not support umac\n"); - } else { + else IWL_INFO(0, "firmware supports umac :)\n"); - } - - if(!adaptive_dwell) { + if (!adaptive_dwell) { IWL_INFO(0, "no adaptive dwell\n"); req_len = IWL_SCAN_REQ_UMAC_SIZE_V1 + (sizeof(iwl_scan_channel_cfg_umac) * num_channels) + sizeof(iwl_scan_req_umac_tail_v1); } else { IWL_INFO(0, "adaptive dwell\n"); - if(ext_chan) { + if (ext_chan) { req_len = IWL_SCAN_REQ_UMAC_SIZE_V7 + (sizeof(iwl_scan_channel_cfg_umac) * num_channels) + sizeof(iwl_scan_req_umac_tail_v2); @@ -410,7 +407,7 @@ int iwl_umac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { } - if(req_len > MAX_CMD_PAYLOAD_SIZE) { + if (req_len > MAX_CMD_PAYLOAD_SIZE) { IWL_ERR(0, "request length is longer then payload size? (wanted: %lu, max: %lu)\n", req_len, MAX_CMD_PAYLOAD_SIZE); return ENOMEM; } @@ -423,7 +420,7 @@ int iwl_umac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { req->general_flags = cpu_to_le16(IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL); req->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH); - if(!adaptive_dwell) { + if (!adaptive_dwell) { IWL_INFO(0, "no adaptive dwell 2\n"); req->general_flags |= cpu_to_le32(IWL_UMAC_SCAN_GEN_FLAGS_EXTENDED_DWELL); } else { @@ -439,14 +436,13 @@ int iwl_umac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE | IWL_SCAN_CHANNEL_FLAG_CACHE_ADD; - if(fw_has_api(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_API_FRAG_EBS)) { + if (fw_has_api(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_API_FRAG_EBS)) channel_flags |= IWL_SCAN_CHANNEL_FLAG_EBS_FRAG; - } } req->scan_start_mac_id = 4; - if(adaptive_dwell) { + if (adaptive_dwell) { IWL_INFO(0, "adaptive dwell targeted\n"); req->v7.active_dwell = 10; req->v7.passive_dwell = 110; @@ -461,7 +457,7 @@ int iwl_umac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { req->v9.adwell_default_hb_n_aps = 8; // IWL_SCAN_ADWELL_DEFAULT_HB_N_APS } - if(fw_has_capa(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_CDB_SUPPORT)) { + if (fw_has_capa(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_CDB_SUPPORT)) { req->v7.max_out_time[0] = htole32(120); req->v7.suspend_time[0] = htole32(120); } @@ -487,7 +483,7 @@ int iwl_umac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { req->v8.general_flags2 = IWL_UMAC_SCAN_GEN_FLAGS2_ALLOW_CHNL_REORDER; - if(fw_has_capa(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_CDB_SUPPORT)) { + if (fw_has_capa(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_CDB_SUPPORT)) { req->v8.active_dwell[1] = 10; req->v8.passive_dwell[1] = 110; } @@ -495,14 +491,12 @@ int iwl_umac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { IWL_INFO(0, "adaptive v2\n"); } - if(ext_chan) { + if (ext_chan) tail_v2 = (struct iwl_scan_req_umac_tail_v2 *)((char*)&req->v7.data + sizeof(struct iwl_scan_channel_cfg_umac) * num_channels); - } else { + else tail = (struct iwl_scan_req_umac_tail_v1 *)((char*)&req->v7.data + sizeof(struct iwl_scan_channel_cfg_umac) * num_channels); - } - } else { IWL_INFO(0, "no adaptive dwell\n"); req->v1.active_dwell = 10; @@ -518,14 +512,13 @@ int iwl_umac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { sizeof(struct iwl_scan_channel_cfg_umac) * num_channels); } - if(appleReq->ssid_len != 0) { + if (appleReq->ssid_len != 0) { IWL_INFO(0, "Directed scan towards: %s\n", appleReq->ssid); - if(ext_chan) { + if (ext_chan) { tail_v2->direct_scan[0].id = IEEE80211_ELEMID_SSID; tail_v2->direct_scan[0].len = appleReq->ssid_len; memcpy(tail_v2->direct_scan[0].ssid, appleReq->ssid, appleReq->ssid_len); - } - else { + } else { tail->direct_scan[0].id = IEEE80211_ELEMID_SSID; tail->direct_scan[0].len = appleReq->ssid_len; memcpy(tail->direct_scan[0].ssid, appleReq->ssid, appleReq->ssid_len); @@ -536,25 +529,23 @@ int iwl_umac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { req->general_flags |= cpu_to_le16(IWL_UMAC_SCAN_GEN_FLAGS_PASSIVE); } - if(fw_has_capa(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT)) { + if (fw_has_capa(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT)) req->general_flags |= cpu_to_le16(IWL_UMAC_SCAN_GEN_FLAGS_RRM_ENABLED); - } IWL_INFO(0, "Filling probe request\n"); - if(ext_chan) { + if (ext_chan) err = iwl_fill_probe_req(drv, appleReq, (iwl_scan_probe_req_v1*)&tail_v2->preq); - } else { + else err = iwl_fill_probe_req(drv, appleReq, &tail->preq); - } - if(err) { + if (err) { IWL_ERR(0, "filling probe req failed\n"); IOFree(req, req_len); return err; } - if(ext_chan) { + if (ext_chan) { tail_v2->schedule[0].interval = 0; tail_v2->schedule[0].iter_count = 1; } else { @@ -622,7 +613,7 @@ iwl_lmac_scan_fill_channels(IWLMvmDriver* drv, apple80211_scan_data* appleReq, chan->flags = htole32(IWL_UNIFIED_SCAN_CHANNEL_PARTIAL); chan->flags |= htole32(IWL_SCAN_CHANNEL_NSSIDS(n_ssids)); - if((c->flags & APPLE80211_C_FLAG_ACTIVE) && n_ssids != 0) + if ((c->flags & APPLE80211_C_FLAG_ACTIVE) && n_ssids != 0) chan->flags |= htole32(IWL_SCAN_CHANNEL_TYPE_ACTIVE); chan++; @@ -648,9 +639,9 @@ int iwl_lmac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { (sizeof(iwl_scan_channel_cfg_lmac) * appleReq->num_channels) + sizeof(iwl_scan_probe_req_v1); - if(len > MAX_CMD_PAYLOAD_SIZE) { + if (len > MAX_CMD_PAYLOAD_SIZE) return ENOMEM; - } + req = (iwl_scan_req_lmac*)kzalloc(len); hcmd.len[0] = len; hcmd.data[0] = req; @@ -675,6 +666,7 @@ int iwl_lmac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { req->scan_flags |= htole32(IWL_MVM_LMAC_SCAN_FLAG_PASSIVE); else req->scan_flags |= htole32(IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION); + if (fw_has_capa(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT)) req->scan_flags |= htole32(IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED); @@ -699,7 +691,7 @@ int iwl_lmac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { iwl_scan_rate_n_flags(drv, IEEE80211_CHAN_5GHZ, 1/*XXX*/); req->tx_cmd[1].sta_id = IWM_AUX_STA_ID; - if(appleReq->ssid_len != 0) { + if (appleReq->ssid_len != 0) { req->direct_scan[0].id = IEEE80211_ELEMID_SSID; req->direct_scan[0].len = appleReq->ssid_len; memcpy(req->direct_scan[0].ssid, appleReq->ssid, appleReq->ssid_len); @@ -712,7 +704,7 @@ int iwl_lmac_scan(IWLMvmDriver* drv, apple80211_scan_data* appleReq) { err = iwl_fill_probe_req(drv, appleReq, (iwl_scan_probe_req_v1*)(req->data + sizeof(struct iwl_scan_channel_cfg_lmac) * appleReq->num_channels)); - if(err) { + if (err) { IWL_ERR(0, "filling probe req failed\n"); IOFree(req, len); return err; diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmMac.hpp b/AppleIntelWifiAdapter/mvm/IWLMvmMac.hpp index c49702b..595c528 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmMac.hpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmMac.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLMvmMac_hpp -#define IWLMvmMac_hpp +#ifndef APPLEINTELWIFIADAPTER_MVM_IWLMVMMAC_HPP_ +#define APPLEINTELWIFIADAPTER_MVM_IWLMVMMAC_HPP_ #include "IWLMvmDriver.hpp" @@ -18,4 +18,4 @@ int iwl_lmac_scan(IWLMvmDriver* drv, apple80211_scan_data* req); int iwl_enable_beacon_filter(IWLMvmDriver* drv); int iwl_disable_beacon_filter(IWLMvmDriver* drv); -#endif /* IWLMvmMac_h */ +#endif // APPLEINTELWIFIADAPTER_MVM_IWLMVMMAC_HPP_ diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmPhy.cpp b/AppleIntelWifiAdapter/mvm/IWLMvmPhy.cpp index 74fde2c..1628917 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmPhy.cpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmPhy.cpp @@ -11,7 +11,7 @@ /* Channel info utils */ static inline bool iwl_mvm_has_ultra_hb_channel(IWLMvmDriver *mvm) { - if( mvm->m_pDevice->cfg->trans.device_family == IWL_DEVICE_FAMILY_8000) + if (mvm->m_pDevice->cfg->trans.device_family == IWL_DEVICE_FAMILY_8000) return false; return fw_has_capa(&mvm->m_pDevice->fw.ucode_capa, @@ -83,9 +83,8 @@ iwl_phy_ctxt_apply(IWLMvmDriver* drv, struct iwl_phy_context_cmd cmd; int ret; - if(iwl_mvm_has_ultra_hb_channel(drv)) { + if (iwl_mvm_has_ultra_hb_channel(drv)) IWL_INFO(0, "got ultra hb chan\n"); - } u16 len = sizeof(cmd) - iwl_mvm_chan_info_padding(drv); iwl_phy_ctxt_cmd_hdr(drv, ctxt, &cmd, action, apply_time); @@ -93,9 +92,9 @@ iwl_phy_ctxt_apply(IWLMvmDriver* drv, chains_static, chains_dynamic); ret = drv->sendCmdPdu(PHY_CONTEXT_CMD, 0, len, &cmd); - if(ret) { + if (ret) IWL_ERR(0, "Could not send phy context?\n"); - } + return ret; } diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmPhy.hpp b/AppleIntelWifiAdapter/mvm/IWLMvmPhy.hpp index 1353714..380ca53 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmPhy.hpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmPhy.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLMvmPhy_hpp -#define IWLMvmPhy_hpp +#ifndef APPLEINTELWIFIADAPTER_MVM_IWLMVMPHY_HPP_ +#define APPLEINTELWIFIADAPTER_MVM_IWLMVMPHY_HPP_ #include "IWLMvmDriver.hpp" @@ -37,4 +37,4 @@ iwl_phy_ctxt_cmd_hdr(IWLMvmDriver* drv, struct iwl_phy_ctx *ctxt, struct iwl_phy_context_cmd *cmd, uint32_t action, uint32_t apply_time); -#endif /* IWLMvmPhy_hpp */ +#endif // APPLEINTELWIFIADAPTER_MVM_IWLMVMPHY_HPP_ diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmScan.hpp b/AppleIntelWifiAdapter/mvm/IWLMvmScan.hpp index bf62275..d9a70a5 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmScan.hpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmScan.hpp @@ -6,7 +6,7 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLMvmScan_hpp -#define IWLMvmScan_hpp +#ifndef APPLEINTELWIFIADAPTER_MVM_IWLMVMSCAN_HPP_ +#define APPLEINTELWIFIADAPTER_MVM_IWLMVMSCAN_HPP_ -#endif /* IWLMvmScan_hpp */ +#endif // APPLEINTELWIFIADAPTER_MVM_IWLMVMSCAN_HPP_ diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmSmartFifo.cpp b/AppleIntelWifiAdapter/mvm/IWLMvmSmartFifo.cpp index 2bc43a7..774c0b1 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmSmartFifo.cpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmSmartFifo.cpp @@ -28,9 +28,10 @@ void iwl_fill_sf_cmd(IWLMvmDriver* dev, iwl_sf_cfg_cmd* cmd, ieee80211_node* ni) else #endif watermark = SF_W_MARK_SISO; - } else + } else { #endif watermark = SF_W_MARK_LEGACY; + } } else { watermark = SF_W_MARK_MIMO2; @@ -57,7 +58,7 @@ void iwl_fill_sf_cmd(IWLMvmDriver* dev, iwl_sf_cfg_cmd* cmd, ieee80211_node* ni) int iwl_sf_config(IWLMvmDriver* drv, int new_state) { IWLTransport* trans = drv->trans; ieee80211com* ic = &trans->m_pDevice->ie_ic; - if(!ic) + if (!ic) return -1; struct iwl_sf_cfg_cmd sf_cmd = { diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmSmartFifo.hpp b/AppleIntelWifiAdapter/mvm/IWLMvmSmartFifo.hpp index 739ae26..ca3d7e5 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmSmartFifo.hpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmSmartFifo.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLMvmSmartFifo_hpp -#define IWLMvmSmartFifo_hpp +#ifndef APPLEINTELWIFIADAPTER_MVM_IWLMVMSMARTFIFO_HPP_ +#define APPLEINTELWIFIADAPTER_MVM_IWLMVMSMARTFIFO_HPP_ #include "../fw/api/sf.h" #include "../trans/IWLTransport.hpp" @@ -65,4 +65,4 @@ iwl_sf_full_timeout[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES] = { int iwl_sf_config(IWLMvmDriver* drv, int new_state); void iwl_fill_sf_cmd(IWLMvmDriver* drv, iwl_sf_cfg_cmd *sf_cmd, ieee80211_node *ni); -#endif /* IWLMvmSmartFifo_hpp */ +#endif // APPLEINTELWIFIADAPTER_MVM_IWLMVMSMARTFIFO_HPP_ diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmSta.cpp b/AppleIntelWifiAdapter/mvm/IWLMvmSta.cpp index b77eed5..046d91e 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmSta.cpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmSta.cpp @@ -23,7 +23,7 @@ int iwl_enable_txq(IWLMvmDriver* drv, int sta_id, int qid, int fifo) { }; */ IOInterruptState state; - if(!drv->trans->grabNICAccess(&state)) + if (!drv->trans->grabNICAccess(&state)) return 1; @@ -34,7 +34,7 @@ int iwl_enable_txq(IWLMvmDriver* drv, int sta_id, int qid, int fifo) { drv->trans->iwlWrite32(HBUS_TARG_WRPTR, qid << 8 | 0); - if(qid == IWL_MVM_DQA_CMD_QUEUE) { + if (qid == IWL_MVM_DQA_CMD_QUEUE) { drv->trans->iwlWritePRPHNoGrab(SCD_QUEUE_STATUS_BITS(qid), (0 << SCD_QUEUE_STTS_REG_POS_ACTIVE) | (1 << SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); @@ -42,7 +42,7 @@ int iwl_enable_txq(IWLMvmDriver* drv, int sta_id, int qid, int fifo) { drv->trans->iwlClearBitsPRPH(SCD_AGGR_SEL, (1 << qid)); - if(!drv->trans->grabNICAccess(&state)) + if (!drv->trans->grabNICAccess(&state)) return 1; drv->trans->iwlWritePRPHNoGrab(SCD_QUEUE_RDPTR(qid), 0); @@ -58,7 +58,7 @@ int iwl_enable_txq(IWLMvmDriver* drv, int sta_id, int qid, int fifo) { << SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & SCD_QUEUE_CTX_REG2_FRAME_LIMIT)); - if(!drv->trans->grabNICAccess(&state)) + if (!drv->trans->grabNICAccess(&state)) return 1; drv->trans->iwlWritePRPHNoGrab(SCD_QUEUE_STATUS_BITS(qid), @@ -83,13 +83,13 @@ int iwl_enable_txq(IWLMvmDriver* drv, int sta_id, int qid, int fifo) { drv->trans->releaseNICAccess(&state); - if((err = drv->sendCmdPdu(SCD_QUEUE_CFG, 0, sizeof(cfg), &cfg))) { + if ((err = drv->sendCmdPdu(SCD_QUEUE_CFG, 0, sizeof(cfg), &cfg))) { return err; } - if(!drv->trans->grabNICAccess(&state)) + if (!drv->trans->grabNICAccess(&state)) return 1; } @@ -108,7 +108,7 @@ int iwl_mvm_add_aux_sta(IWLMvmDriver* drv) { uint32_t status; err = iwl_enable_txq(drv, 1, 15, IWL_MVM_TX_FIFO_MCAST); - if(err) + if (err) return err; memset(&cmd, 0, sizeof(cmd)); diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmSta.hpp b/AppleIntelWifiAdapter/mvm/IWLMvmSta.hpp index 9e0133f..ab0c8e4 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmSta.hpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmSta.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLMvmSta_hpp -#define IWLMvmSta_hpp +#ifndef APPLEINTELWIFIADAPTER_MVM_IWLMVMSTA_HPP_ +#define APPLEINTELWIFIADAPTER_MVM_IWLMVMSTA_HPP_ #include "../trans/IWLTransport.hpp" #include "../mvm/IWLMvmDriver.hpp" @@ -32,4 +32,4 @@ int iwl_mvm_add_aux_sta(IWLMvmDriver* drv); int iwl_mvm_sta_send_to_fw(IWLMvmDriver* drv, struct iwm_node *in, bool update, unsigned int flags); -#endif /* IWLMvmSta_hpp */ +#endif // APPLEINTELWIFIADAPTER_MVM_IWLMVMSTA_HPP_ diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen1.cpp b/AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen1.cpp index e836d19..e9ccdb5 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen1.cpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen1.cpp @@ -21,7 +21,7 @@ int IWLMvmTransOpsGen1::nicInit() if (ret) return ret; - if(trans->m_pDevice->cfg->trans.device_family == IWL_DEVICE_FAMILY_7000) + if (trans->m_pDevice->cfg->trans.device_family == IWL_DEVICE_FAMILY_7000) setPwr(false); nicConfig(); @@ -29,7 +29,7 @@ int IWLMvmTransOpsGen1::nicInit() IWL_INFO(0, "Allocating both queues\n"); /* Allocate the RX queue, or reset if it is already allocated */ - if(rxInit()) + if (rxInit()) return -ENOMEM; /* Allocate or reset and init all Tx and Command queues */ if (txInit()) @@ -54,12 +54,10 @@ int IWLMvmTransOpsGen1::nicInit() IEEE80211_C_SHPREAMBLE | IEEE80211_C_RSN | IEEE80211_C_QOS | - IEEE80211_C_TXPMGT - //IEEE80211_C_BGSCAN - ; + IEEE80211_C_TXPMGT; - for(int i = 0; i < NUM_PHY_CTX; i++) { + for (int i = 0; i < NUM_PHY_CTX; i++) { trans->m_pDevice->phy_ctx[i].id = i; trans->m_pDevice->phy_ctx[i].color = 0; trans->m_pDevice->phy_ctx[i].ref = 0; @@ -221,7 +219,7 @@ int IWLMvmTransOpsGen1::startFW(const struct fw_img *fw, bool run_in_rfkill) void IWLMvmTransOpsGen1::stopDevice() { bool was_in_rfkill; - if(!IOLockTryLock(trans->mutex)) { + if (!IOLockTryLock(trans->mutex)) { IWL_ERR(0, "unable to lock mutex\n"); return; } @@ -390,10 +388,10 @@ void IWLMvmTransOpsGen1::apmStop(bool op_mode_leave) if (!test_bit(STATUS_DEVICE_ENABLED, &trans->status)) apmInit(); /* inform ME that we are leaving */ - if (trans->m_pDevice->cfg->trans.device_family == IWL_DEVICE_FAMILY_7000) + if (trans->m_pDevice->cfg->trans.device_family == IWL_DEVICE_FAMILY_7000) { trans->iwlSetBitsPRPH(APMG_PCIDEV_STT_REG, APMG_PCIDEV_STT_VAL_WAKE_ME); - else if (trans->m_pDevice->cfg->trans.device_family >= + } else if (trans->m_pDevice->cfg->trans.device_family >= IWL_DEVICE_FAMILY_8000) { trans->setBit(CSR_DBG_LINK_PWR_MGMT_REG, CSR_RESET_LINK_PWR_MGMT_DISABLED); diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen1.hpp b/AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen1.hpp index a85ec5d..0bf287e 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen1.hpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen1.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLMvmTransOpsGen1_hpp -#define IWLMvmTransOpsGen1_hpp +#ifndef APPLEINTELWIFIADAPTER_MVM_IWLMVMTRANSOPSGEN1_HPP_ +#define APPLEINTELWIFIADAPTER_MVM_IWLMVMTRANSOPSGEN1_HPP_ #include "IWLIO.hpp" #include "IWLTransOps.h" @@ -18,7 +18,7 @@ class IWLMvmTransOpsGen1 : public IWLTransOps { public: IWLMvmTransOpsGen1() {} - IWLMvmTransOpsGen1(IWLTransport *trans) : IWLTransOps(trans) {} + explicit IWLMvmTransOpsGen1(IWLTransport *trans) : IWLTransOps(trans) {} virtual ~IWLMvmTransOpsGen1() {} int nicInit() override; @@ -45,4 +45,4 @@ class IWLMvmTransOpsGen1 : public IWLTransOps { void setPwr(bool vaux); }; -#endif /* IWLMvmTransOpsGen1_hpp */ +#endif // APPLEINTELWIFIADAPTER_MVM_IWLMVMTRANSOPSGEN1_HPP_ diff --git a/AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen2.hpp b/AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen2.hpp index 31bdac2..1b30dd2 100644 --- a/AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen2.hpp +++ b/AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen2.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLMvmTransOpsGen2_hpp -#define IWLMvmTransOpsGen2_hpp +#ifndef APPLEINTELWIFIADAPTER_MVM_IWLMVMTRANSOPSGEN2_HPP_ +#define APPLEINTELWIFIADAPTER_MVM_IWLMVMTRANSOPSGEN2_HPP_ #include "IWLTransOps.h" @@ -16,7 +16,7 @@ class IWLMvmTransOpsGen2 : public IWLTransOps { public: IWLMvmTransOpsGen2() {} - IWLMvmTransOpsGen2(IWLTransport *trans) : IWLTransOps(trans) {} + explicit IWLMvmTransOpsGen2(IWLTransport *trans) : IWLTransOps(trans) {} virtual ~IWLMvmTransOpsGen2() {} int nicInit() override; @@ -41,4 +41,4 @@ class IWLMvmTransOpsGen2 : public IWLTransOps { int rxInit(); }; -#endif /* IWLMvmTransOpsGen2_hpp */ +#endif // APPLEINTELWIFIADAPTER_MVM_IWLMVMTRANSOPSGEN2_HPP_ diff --git a/AppleIntelWifiAdapter/mvm/IWMHdr.h b/AppleIntelWifiAdapter/mvm/IWMHdr.h index 668bd46..5c2a326 100644 --- a/AppleIntelWifiAdapter/mvm/IWMHdr.h +++ b/AppleIntelWifiAdapter/mvm/IWMHdr.h @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWMHdr_h -#define IWMHdr_h +#ifndef APPLEINTELWIFIADAPTER_MVM_IWMHDR_H_ +#define APPLEINTELWIFIADAPTER_MVM_IWMHDR_H_ #include "../compat/openbsd/net80211/ieee80211_var.h" #include "../compat/openbsd/net80211/ieee80211_amrr.h" @@ -36,4 +36,4 @@ struct iwm_node { }; -#endif /* IWMHdr_h */ +#endif // APPLEINTELWIFIADAPTER_MVM_IWMHDR_H_ diff --git a/AppleIntelWifiAdapter/mvm/Mvm.h b/AppleIntelWifiAdapter/mvm/Mvm.h index 6a41835..066c225 100644 --- a/AppleIntelWifiAdapter/mvm/Mvm.h +++ b/AppleIntelWifiAdapter/mvm/Mvm.h @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef Mvm_h -#define Mvm_h +#ifndef APPLEINTELWIFIADAPTER_MVM_MVM_H_ +#define APPLEINTELWIFIADAPTER_MVM_MVM_H_ #define MVM_UCODE_ALIVE_TIMEOUT (HZ * CPTCFG_IWL_TIMEOUT_FACTOR) #define MVM_UCODE_CALIB_TIMEOUT (2 * HZ * CPTCFG_IWL_TIMEOUT_FACTOR) @@ -17,7 +17,6 @@ struct iwl_mvm_alive_data { bool valid; u32 scd_base_addr; - uint32_t uc_error_event_table; uint32_t uc_umac_error_event_table; uint32_t uc_log_event_table; @@ -215,4 +214,4 @@ struct iwl_phy_cfg_cmd { #define IWL_MVM_NUM_CIPHERS 10 -#endif /* Mvm_h */ +#endif // APPLEINTELWIFIADAPTER_MVM_MVM_H_ diff --git a/AppleIntelWifiAdapter/mvm/MvmCmd.hpp b/AppleIntelWifiAdapter/mvm/MvmCmd.hpp index 97b5219..dea8818 100644 --- a/AppleIntelWifiAdapter/mvm/MvmCmd.hpp +++ b/AppleIntelWifiAdapter/mvm/MvmCmd.hpp @@ -6,11 +6,11 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef MvmCmd_hpp -#define MvmCmd_hpp +#ifndef APPLEINTELWIFIADAPTER_MVM_MVMCMD_HPP_ +#define APPLEINTELWIFIADAPTER_MVM_MVMCMD_HPP_ #include "IWLTransport.hpp" -#include "fw-api.h" +#include "../fw/fw-api.h" #include "debug.h" #include "nan.h" @@ -333,4 +333,4 @@ static const struct iwl_hcmd_arr iwl_mvm_groups[] = { HCMD_ARR(iwl_mvm_regulatory_and_nvm_names), }; -#endif /* MvmCmd_hpp */ +#endif // APPLEINTELWIFIADAPTER_MVM_MVMCMD_HPP_ diff --git a/AppleIntelWifiAdapter/nvm/IWLNvm.cpp b/AppleIntelWifiAdapter/nvm/IWLNvm.cpp index 3ace17d..216fcd0 100644 --- a/AppleIntelWifiAdapter/nvm/IWLNvm.cpp +++ b/AppleIntelWifiAdapter/nvm/IWLNvm.cpp @@ -461,7 +461,7 @@ int IWLMvmDriver::nvmInit() m_pDevice->nvm_data->nvm_version); u8* hw_addr = m_pDevice->nvm_data->hw_addr; - if(hw_addr) { + if (hw_addr) { // ideally, if we're successful then this should pass and we should get the MAC from our card IWL_INFO(0, "addr: %02x:%02x:%02x:%02x:%02x:%02x\n", hw_addr[0], hw_addr[1], hw_addr[2], @@ -531,7 +531,6 @@ struct iwl_mcc_update_resp *IWLMvmDriver::updateMcc(const char *alpha2, enum iwl resp_cp = (struct iwl_mcc_update_resp *)ERR_PTR(-ENOMEM); goto exit; } - resp_cp->status = mcc_resp_v3->status; resp_cp->mcc = mcc_resp_v3->mcc; resp_cp->cap = cpu_to_le16(mcc_resp_v3->cap); diff --git a/AppleIntelWifiAdapter/nvm/IWLNvmParser.cpp b/AppleIntelWifiAdapter/nvm/IWLNvmParser.cpp index fbf55dc..873bfbd 100644 --- a/AppleIntelWifiAdapter/nvm/IWLNvmParser.cpp +++ b/AppleIntelWifiAdapter/nvm/IWLNvmParser.cpp @@ -309,11 +309,9 @@ static int iwl_init_channel_map(IWLDevice *dev, const struct iwl_cfg *cfg, enum nl80211_band band = iwl_nl80211_band_from_channel_idx(ch_idx); - if(v4) { + if (v4) IWL_INFO(0, "weird thing\n"); - } - if (v4) ch_flags = __le32_to_cpup((__le32 *)nvm_ch_flags + ch_idx); @@ -362,19 +360,19 @@ static int iwl_init_channel_map(IWLDevice *dev, const struct iwl_cfg *cfg, channel.flags |= APPLE80211_C_FLAG_ACTIVE; } - if(ch_flags & NVM_CHANNEL_IBSS) { + if (ch_flags & NVM_CHANNEL_IBSS) { channel.flags |= APPLE80211_C_FLAG_IBSS; } - if(ch_flags & NVM_CHANNEL_20MHZ) { + if (ch_flags & NVM_CHANNEL_20MHZ) { channel.flags |= APPLE80211_C_FLAG_20MHZ; } - if(ch_flags & NVM_CHANNEL_40MHZ) { + if (ch_flags & NVM_CHANNEL_40MHZ) { channel.flags |= APPLE80211_C_FLAG_40MHZ; } - if(ch_flags & NVM_CHANNEL_80MHZ) { + if (ch_flags & NVM_CHANNEL_80MHZ) { channel.flags |= APPLE80211_C_FLAG_EXT_ABV; } @@ -971,13 +969,11 @@ iwl_parse_nvm_data(IWLTransport *trans, const struct iwl_cfg *cfg, // data_size = struct_size(data, channels, // IWL_NVM_NUM_CHANNELS_UHB); data_size = sizeof(*data) + sizeof(ieee80211_channel) * IWL_NVM_NUM_CHANNELS_UHB; - } - else if (cfg->nvm_type != IWL_NVM_EXT) { + } else if (cfg->nvm_type != IWL_NVM_EXT) { // data_size = struct_size(data, channels, // IWL_NVM_NUM_CHANNELS); data_size = sizeof(*data) + sizeof(ieee80211_channel) * IWL_NVM_NUM_CHANNELS; - } - else { + } else { // data_size = struct_size(data, channels, // IWL_NVM_NUM_CHANNELS_EXT); data_size = sizeof(*data) + sizeof(ieee80211_channel) * IWL_NVM_NUM_CHANNELS_EXT; diff --git a/AppleIntelWifiAdapter/nvm/IWLNvmParser.hpp b/AppleIntelWifiAdapter/nvm/IWLNvmParser.hpp index 2a8890b..771dea1 100644 --- a/AppleIntelWifiAdapter/nvm/IWLNvmParser.hpp +++ b/AppleIntelWifiAdapter/nvm/IWLNvmParser.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLNvmParser_hpp -#define IWLNvmParser_hpp +#ifndef APPLEINTELWIFIADAPTER_NVM_IWLNVMPARSER_HPP_ +#define APPLEINTELWIFIADAPTER_NVM_IWLNVMPARSER_HPP_ #include "IWLeeprom.h" #include "IWLTransport.hpp" @@ -93,4 +93,4 @@ void iwl_init_sbands(IWLTransport *trans, const void *nvm_ch_flags, u8 tx_chains, u8 rx_chains, u32 sbands_flags, bool v4); -#endif /* IWLNvmParser_hpp */ +#endif // APPLEINTELWIFIADAPTER_NVM_IWLNVMPARSER_HPP_ diff --git a/AppleIntelWifiAdapter/nvm/IWLeeprom.h b/AppleIntelWifiAdapter/nvm/IWLeeprom.h index 8057f21..c04b29f 100644 --- a/AppleIntelWifiAdapter/nvm/IWLeeprom.h +++ b/AppleIntelWifiAdapter/nvm/IWLeeprom.h @@ -6,10 +6,10 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLeeprom_h -#define IWLeeprom_h +#ifndef APPLEINTELWIFIADAPTER_NVM_IWLEEPROM_H_ +#define APPLEINTELWIFIADAPTER_NVM_IWLEEPROM_H_ -//#include +// #include #include #include #include @@ -46,8 +46,8 @@ struct iwl_nvm_data { bool lar_enabled; bool vht160_supported; - //TODO - //ieee80211_supported_band bands[NUM_NL80211_BANDS]; + // TODO + // ieee80211_supported_band bands[NUM_NL80211_BANDS]; struct ieee80211_channel channels[]; }; @@ -63,4 +63,4 @@ struct iwl_nvm_section { const u8 *data; }; -#endif /* IWLeeprom_h */ +#endif // APPLEINTELWIFIADAPTER_NVM_IWLEEPROM_H_ diff --git a/AppleIntelWifiAdapter/trans/IWLIO.hpp b/AppleIntelWifiAdapter/trans/IWLIO.hpp index d2c44b3..b89e0b1 100644 --- a/AppleIntelWifiAdapter/trans/IWLIO.hpp +++ b/AppleIntelWifiAdapter/trans/IWLIO.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLIO_hpp -#define IWLIO_hpp +#ifndef APPLEINTELWIFIADAPTER_TRANS_IWLIO_HPP_ +#define APPLEINTELWIFIADAPTER_TRANS_IWLIO_HPP_ #include #include @@ -130,4 +130,4 @@ class IWLIO { }; -#endif /* IWLIO_hpp */ +#endif // APPLEINTELWIFIADAPTER_TRANS_IWLIO_HPP_ diff --git a/AppleIntelWifiAdapter/trans/IWLSCD.h b/AppleIntelWifiAdapter/trans/IWLSCD.h index 05b1af6..f9b50f7 100644 --- a/AppleIntelWifiAdapter/trans/IWLSCD.h +++ b/AppleIntelWifiAdapter/trans/IWLSCD.h @@ -7,8 +7,8 @@ // #include "IWLTransport.hpp" -#ifndef IWLSCD_h -#define IWLSCD_h +#ifndef APPLEINTELWIFIADAPTER_TRANS_IWLSCD_H_ +#define APPLEINTELWIFIADAPTER_TRANS_IWLSCD_H_ static inline void iwl_scd_txq_set_chain(IWLTransport *trans, u16 txq_id) @@ -82,4 +82,4 @@ static inline void iwl_scd_txq_set_inactive(IWLTransport *trans, (1 << SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); } -#endif /* IWLSCD_h */ +#endif // APPLEINTELWIFIADAPTER_TRANS_IWLSCD_H_ diff --git a/AppleIntelWifiAdapter/trans/IWLTransOps.h b/AppleIntelWifiAdapter/trans/IWLTransOps.h index 58b30ef..91557c6 100644 --- a/AppleIntelWifiAdapter/trans/IWLTransOps.h +++ b/AppleIntelWifiAdapter/trans/IWLTransOps.h @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLTransOps_h -#define IWLTransOps_h +#ifndef APPLEINTELWIFIADAPTER_TRANS_IWLTRANSOPS_H_ +#define APPLEINTELWIFIADAPTER_TRANS_IWLTRANSOPS_H_ #include #include "IWLTransport.hpp" @@ -19,7 +19,7 @@ class IWLTransOps { public: IWLTransOps() {} - IWLTransOps(IWLTransport *trans); + explicit IWLTransOps(IWLTransport *trans); virtual ~IWLTransOps() {} void nicConfig(); // nic_config @@ -80,4 +80,4 @@ class IWLTransOps { }; -#endif /* IWLTransOps_h */ +#endif // APPLEINTELWIFIADAPTER_TRANS_IWLTRANSOPS_H_ diff --git a/AppleIntelWifiAdapter/trans/IWLTransport.cpp b/AppleIntelWifiAdapter/trans/IWLTransport.cpp index a58ba04..434aea8 100644 --- a/AppleIntelWifiAdapter/trans/IWLTransport.cpp +++ b/AppleIntelWifiAdapter/trans/IWLTransport.cpp @@ -9,21 +9,18 @@ #include "IWLTransport.hpp" #include "IWLDebug.h" #include "IWLFH.h" -#include "tx.h" +#include "../fw/api/tx.h" #include "IWLSCD.h" #define super IWLIO -IWLTransport::IWLTransport() -{ +IWLTransport::IWLTransport() { } -IWLTransport::~IWLTransport() -{ +IWLTransport::~IWLTransport() { } -bool IWLTransport::prepareCardHW() -{ +bool IWLTransport::prepareCardHW() { IWL_INFO(0, "prepareCardHW\n"); int t = 0; int ret = setHWReady(); @@ -40,7 +37,6 @@ bool IWLTransport::prepareCardHW() ret = setHWReady(); if (ret >= 0) return false; - IODelay(1000); t += 200; } while (t < 150000); @@ -205,7 +201,7 @@ void IWLTransport::release() this->rba.alloc_wq = NULL; } - if(this->rba.lock) { + if (this->rba.lock) { IOSimpleLockFree(this->rba.lock); this->rba.lock = NULL; } diff --git a/AppleIntelWifiAdapter/trans/IWLTransport.hpp b/AppleIntelWifiAdapter/trans/IWLTransport.hpp index ec53968..932f6e8 100644 --- a/AppleIntelWifiAdapter/trans/IWLTransport.hpp +++ b/AppleIntelWifiAdapter/trans/IWLTransport.hpp @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef IWLTransport_hpp -#define IWLTransport_hpp +#ifndef APPLEINTELWIFIADAPTER_TRANS_IWLTRANSPORT_HPP_ +#define APPLEINTELWIFIADAPTER_TRANS_IWLTRANSPORT_HPP_ #include "IWLIO.hpp" #include "../IWLDevice.hpp" @@ -352,4 +352,4 @@ static inline void *iwl_pcie_get_tfd(IWLTransport *trans_pcie, struct iwl_txq *t return (u8*)txq->tfds + trans_pcie->tfd_size * iwl_pcie_get_cmd_index(txq, idx); } -#endif /* IWLTransport_hpp */ +#endif // APPLEINTELWIFIADAPTER_TRANS_IWLTRANSPORT_HPP_ diff --git a/AppleIntelWifiAdapter/trans/IWLTransportRx.cpp b/AppleIntelWifiAdapter/trans/IWLTransportRx.cpp index a188e63..b6297fe 100644 --- a/AppleIntelWifiAdapter/trans/IWLTransportRx.cpp +++ b/AppleIntelWifiAdapter/trans/IWLTransportRx.cpp @@ -51,7 +51,7 @@ static void iwl_pcie_rx_allocator_get(IWLTransport *trans, struct iwl_rxq *rxq) /* Get next free Rx buffer, remove it from free list */ struct iwl_rx_mem_buffer *rxb = TAILQ_FIRST(&rba->rbd_allocated); - if(!rxb) + if (!rxb) continue; TAILQ_REMOVE(&rba->rbd_allocated, rxb, list); @@ -336,12 +336,12 @@ static mbuf_t iwl_pcie_rx_alloc_page(IWLTransport *trans, u32 *offset) { mbuf_t m; unsigned int size; - if(!trans->m_pDevice) { + if (!trans->m_pDevice) { IWL_WARN(0, "m_pDevice == NULL\n"); return 0; } - if(!trans->m_pDevice->controller) { + if (!trans->m_pDevice->controller) { IWL_WARN(0, "controller == NULL\n"); int error; //IOOptionBits options = kIODirectionInOut | kIOMemoryPhysicallyContiguous | kIOMemoryKernelUserShared; @@ -356,19 +356,18 @@ static mbuf_t iwl_pcie_rx_alloc_page(IWLTransport *trans, u32 *offset) //IWL_INFO(0, "packet: %d\n", count); - if(error == 0) { + if (error == 0) return 0; - } - else { + else IWL_WARN(0, "mbuf_allocpacket error: %d\n", error); - } + return 0; } m = trans->m_pDevice->controller->allocatePacket(PAGE_SIZE); - if(m == 0) { + if (m == 0) IWL_WARN(0, "allocatePacket failed!\n"); - } + //IWL_WARN(0, "allocated the normal way\n"); //mbuf_allocpacket(MBUF_DONTWAIT, PAGE_SIZE, &size, &m); return m; @@ -710,7 +709,7 @@ void IWLTransport::rxMqHWInit() } if (m_pDevice->cfg->trans.device_family == IWL_DEVICE_FAMILY_9000) { - if(!m_pDevice->cfg->trans.integrated) { + if (!m_pDevice->cfg->trans.integrated) { } } @@ -805,7 +804,7 @@ void IWLTransport::rxSqRestock(struct iwl_rxq *_rxq) /* Get next free Rx buffer, remove from free list */ rxb = TAILQ_FIRST(&_rxq->rx_free); - if(!rxb) { + if (!rxb) { IWL_ERR(0, "RXB should never be null?\n"); return; } @@ -1205,9 +1204,9 @@ int allocate_rxb(OSObject* target, void* arg0, void* arg1, void* arg2, void* arg IOSimpleLockUnlock(rba->lock); - while(pending) { + while (pending) { TAILQ_INIT(&local_allocated); - for(int i = 0; i < RX_CLAIM_REQ_ALLOC;) { + for (int i = 0; i < RX_CLAIM_REQ_ALLOC;) { struct iwl_rx_mem_buffer* rxb; mbuf_t page; @@ -1215,23 +1214,23 @@ int allocate_rxb(OSObject* target, void* arg0, void* arg1, void* arg2, void* arg rxb = TAILQ_FIRST(&local_empty); - if(!rxb) { + if (!rxb) { IWL_ERR(0, "rxb == null\n"); continue; } - if(rxb->page) + if (rxb->page) IWL_ERR(0, "page isn't null\n"); page = iwl_pcie_rx_alloc_page(trans, &rxb->offset); - if(!page) + if (!page) continue; rxb->page = page; IOMbufNaturalMemoryCursor* cursor = IOMbufNaturalMemoryCursor::withSpecification(PAGE_SIZE, 1); int err = cursor->getPhysicalSegments(rxb->page, &rxb->vec, 1); - if(err == 0) { + if (err == 0) { rxb->page = NULL; IWL_ERR(0, "Unable to map\n"); continue; @@ -1247,20 +1246,20 @@ int allocate_rxb(OSObject* target, void* arg0, void* arg1, void* arg2, void* arg OSDecrementAtomic(&rba->req_pending); pending--; - if(!pending) { + if (!pending) { pending = rba->req_pending; - if(pending) + if (pending) IWL_INFO(0, "Got more pending\n"); } IOSimpleLockLock(rba->lock); - if(!TAILQ_EMPTY(&local_allocated)) { + if (!TAILQ_EMPTY(&local_allocated)) { TAILQ_CONCAT(&rba->rbd_allocated, &local_allocated, list); } else { IWL_ERR(0, "local_allocated should not be null\n"); } - if(!TAILQ_EMPTY(&rba->rbd_empty)) { + if (!TAILQ_EMPTY(&rba->rbd_empty)) { TAILQ_CONCAT(&local_empty, &rba->rbd_empty, list); TAILQ_INIT(&rba->rbd_empty); } @@ -1270,7 +1269,7 @@ int allocate_rxb(OSObject* target, void* arg0, void* arg1, void* arg2, void* arg //rba->req_ready++; } IOSimpleLockLock(rba->lock); - if(!TAILQ_EMPTY(&local_empty)) { + if (!TAILQ_EMPTY(&local_empty)) { TAILQ_CONCAT(&rba->rbd_empty, &local_empty, list); } IOSimpleLockUnlock(rba->lock); @@ -1287,7 +1286,7 @@ static void iwl_pcie_rx_reuse_rbd(IWLTransport *trans, struct iwl_rb_allocator *rba = &trans_pcie->rba; TAILQ_INSERT_TAIL(&rxq->rx_used, rxb, list); - if(unlikely(emergency)) + if (unlikely(emergency)) return; rxq->used_count++; @@ -1389,7 +1388,7 @@ static void iwl_pcie_rx_handle_rb(IWLTransport *trans, struct iwl_rxq *rxq, stru u32 cmd_id = iwl_cmd_id(pkt->hdr.cmd, pkt->hdr.group_id, 0);; - switch(cmd_id) { + switch (cmd_id) { case MVM_ALIVE: break; @@ -1426,11 +1425,11 @@ static void iwl_pcie_rx_handle_rb(IWLTransport *trans, struct iwl_rxq *rxq, stru case SCAN_ITERATION_COMPLETE_UMAC: case SCAN_COMPLETE_UMAC: { - if(trans->m_pDevice->ie_dev->scanning) { + if (trans->m_pDevice->ie_dev->scanning) { trans->m_pDevice->last_ebs_successful = true; trans->m_pDevice->ie_dev->scanning = false; trans->m_pDevice->ie_dev->published = true; - if(!IOLockTryLock(trans->m_pDevice->ie_dev->scanCacheLock)) { + if (!IOLockTryLock(trans->m_pDevice->ie_dev->scanCacheLock)) { IWL_ERR(0, "Failed to lock mutex\n"); break; } @@ -1442,7 +1441,7 @@ static void iwl_pcie_rx_handle_rb(IWLTransport *trans, struct iwl_rxq *rxq, stru IOLockUnlock(trans->m_pDevice->ie_dev->scanCacheLock); - if(trans->m_pDevice->ie_dev->scanDone()) { + if (trans->m_pDevice->ie_dev->scanDone()) { IWL_INFO(0, "posted results\n"); } else { IWL_ERR(0, "Interface was null?\n"); @@ -1490,18 +1489,18 @@ static void iwl_pcie_rx_handle_rb(IWLTransport *trans, struct iwl_rxq *rxq, stru offset += LNX_ALIGN(len, FH_RSCSR_FRAME_ALIGN); } - if(page_stolen) { + if (page_stolen) { IWL_ERR(0, "page stolen, free here\n"); mbuf_freem(rxb->page); rxb->page = NULL; } - if(rxb->page != NULL) { + if (rxb->page != NULL) { IWL_ERR(0, "rx passed, but page not freed\n"); IOMbufNaturalMemoryCursor* cursor = IOMbufNaturalMemoryCursor::withSpecification(PAGE_SIZE, 1); int err = cursor->getPhysicalSegments(rxb->page, &rxb->vec, 1); - if(err == 0) { + if (err == 0) { IWL_ERR(0, "LEAK PAGE\n"); rxb->page = NULL; iwl_pcie_rx_reuse_rbd(trans, rxb, rxq, emergency); @@ -1533,11 +1532,11 @@ void IWLTransport::handleRx(int queue) { if (i == r) IWL_INFO(trans, "Q %d: HW = SW = %d (nothing was sent??) \n", _rxq->id, r); - while(i != r) { + while (i != r) { struct iwl_rx_mem_buffer *rxb; u32 rb_pending_alloc = rba.req_pending * RX_CLAIM_REQ_ALLOC; - if(unlikely(rb_pending_alloc >= _rxq->queue_size / 2 && !emergency)) { + if (unlikely(rb_pending_alloc >= _rxq->queue_size / 2 && !emergency)) { move_to_allocator(&rba, _rxq); emergency = true; IWL_ERR(0, "RX path is in emergency. Pending allocs: %d\n", rb_pending_alloc); @@ -1546,7 +1545,7 @@ void IWLTransport::handleRx(int queue) { if (_rxq->used_count == _rxq->queue_size / 2) emergency = true; - if(m_pDevice->cfg->trans.mq_rx_supported) { + if (m_pDevice->cfg->trans.mq_rx_supported) { //TODO: implement u16 vid = le32_to_cpu(((__le32*)rxq->used_bd)[i]) & 0x0FFF; diff --git a/AppleIntelWifiAdapter/trans/IWLTransportTx.cpp b/AppleIntelWifiAdapter/trans/IWLTransportTx.cpp index 908a9c6..19c5e5b 100644 --- a/AppleIntelWifiAdapter/trans/IWLTransportTx.cpp +++ b/AppleIntelWifiAdapter/trans/IWLTransportTx.cpp @@ -476,9 +476,9 @@ int IWLTransport::txInit() { int ret; int txq_id, slots_num; bool alloc = false; - if(!this->txq_memory) { + if (!this->txq_memory) { ret = iwl_pcie_tx_alloc(this); - if(ret) { + if (ret) { goto error; } alloc = true; @@ -1060,7 +1060,7 @@ static int iwl_pcie_send_hcmd_sync(IWLTransport *trans, iwl_get_cmd_string(trans, cmd->id)); if (test_and_set_bit(STATUS_SYNC_HCMD_ACTIVE, - &trans->status)){ + &trans->status)) { IWL_INFO(0, "Command %s: a command is already active!\n", iwl_get_cmd_string(trans, cmd->id)); return -EIO; @@ -1201,11 +1201,11 @@ iwl_trans_txq_enable_cfg(IWLTransport *trans, int queue, u16 ssn, int txq_id = queue; int fifo = -1; bool scd_bug = false; - if(test_and_set_bit(txq_id, trans->queue_used)) + if (test_and_set_bit(txq_id, trans->queue_used)) IWL_WARN(0, "queue %d used already, expect issues", txq_id); txq->wd_timeout = queue_wdg_timeout; - if(cfg) { + if (cfg) { fifo = cfg->fifo; /* Disable the scheduler prior configuring the cmd queue */ @@ -1219,7 +1219,7 @@ iwl_trans_txq_enable_cfg(IWLTransport *trans, int queue, u16 ssn, /* Set this queue as a chain-building queue unless it is CMD */ if (txq_id != trans->cmd_queue) iwl_scd_txq_set_chain(trans, txq_id); - if(cfg->aggregate) { + if (cfg->aggregate) { u16 ra_tid = BUILD_RAxTID(cfg->sta_id, cfg->tid); IWL_WARN(0, "need to fix aggregate\n"); //iwl_pcie_txq_set_ratid_map(ra_tid, txq_id); @@ -1239,7 +1239,7 @@ iwl_trans_txq_enable_cfg(IWLTransport *trans, int queue, u16 ssn, txq->read_ptr = (ssn & 0xff); txq->write_ptr = (ssn & 0xff); - if(cfg) { + if (cfg) { u8 frame_limit = cfg->frame_limit; trans->iwlWritePRPH(SCD_QUEUE_RDPTR(txq_id), ssn); @@ -1256,7 +1256,7 @@ iwl_trans_txq_enable_cfg(IWLTransport *trans, int queue, u16 ssn, (1 << SCD_QUEUE_STTS_REG_POS_WSL) | SCD_QUEUE_STTS_REG_MSK); - if(txq_id == trans->cmd_queue && + if (txq_id == trans->cmd_queue && trans->scd_set_active) iwl_scd_enable_set_active(trans, BIT(txq_id)); @@ -1299,7 +1299,7 @@ void IWLTransport::txStop() IOSimpleLockLock(irq_lock); - if(!grabNICAccess(&state)) + if (!grabNICAccess(&state)) goto out; for (ch = 0; ch < FH_TCSR_CHNL_NUM; ch++) { @@ -1308,7 +1308,7 @@ void IWLTransport::txStop() } ret = iwlPollBit(FH_TSSR_TX_STATUS_REG, mask, mask, 5000); - if(ret < 0) + if (ret < 0) IWL_ERR(this, "failing on interrupt to disable DMA channel %d [0x%0x]\n", ch, iwlRead32(FH_TSSR_TX_STATUS_REG)); diff --git a/AppleIntelWifiAdapter/trans/TransHdr.h b/AppleIntelWifiAdapter/trans/TransHdr.h index c9b5e28..849c61b 100644 --- a/AppleIntelWifiAdapter/trans/TransHdr.h +++ b/AppleIntelWifiAdapter/trans/TransHdr.h @@ -6,8 +6,8 @@ // Copyright © 2020 IntelWifi for MacOS authors. All rights reserved. // -#ifndef TransHdr_h -#define TransHdr_h +#ifndef APPLEINTELWIFIADAPTER_TRANS_TRANSHDR_H_ +#define APPLEINTELWIFIADAPTER_TRANS_TRANSHDR_H_ #include #include "IWLFH.h" @@ -593,4 +593,4 @@ enum iwl_ini_cfg_state { }; -#endif /* TransHdr_h */ +#endif // APPLEINTELWIFIADAPTER_TRANS_TRANSHDR_H_ diff --git a/AppleIntelWifiAdapter/trans/TransOpsCommon.cpp b/AppleIntelWifiAdapter/trans/TransOpsCommon.cpp index c872fc9..97fa042 100644 --- a/AppleIntelWifiAdapter/trans/TransOpsCommon.cpp +++ b/AppleIntelWifiAdapter/trans/TransOpsCommon.cpp @@ -232,13 +232,13 @@ void IWLTransOps::restartNIC(bool fw_error) { //if(!this->trans->fw_resta) - if(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &trans->m_pDevice->status)) { + if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &trans->m_pDevice->status)) { IWL_ERR(0, "failure while probing\n"); - } else if(test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &trans->m_pDevice->status)) { + } else if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &trans->m_pDevice->status)) { IWL_WARN(0, "restart requested, but not started\n"); - } else if(trans->m_pDevice->cur_fw_img == IWL_UCODE_REGULAR && + } else if (trans->m_pDevice->cur_fw_img == IWL_UCODE_REGULAR && !test_bit(STATUS_TRANS_DEAD, &trans->m_pDevice->status)) { - if(trans->m_pDevice->fw.ucode_capa.error_log_size) { + if (trans->m_pDevice->fw.ucode_capa.error_log_size) { u32 src_size = trans->m_pDevice->fw.ucode_capa.error_log_size; u32 src_addr = trans->m_pDevice->fw.ucode_capa.error_log_addr; u8 *recover_buf = (u8*)kzalloc(src_size); @@ -360,7 +360,7 @@ void IWLTransOps::rxMpdu(iwl_rx_cmd_buffer* rxcb) { u8 channel, energy_a, energy_b; len = le16toh(desc->mpdu_len); - if(trans->m_pDevice->cfg->trans.device_family >= IWL_DEVICE_FAMILY_AX210) { + if (trans->m_pDevice->cfg->trans.device_family >= IWL_DEVICE_FAMILY_AX210) { rate_n_flags = desc->v3.rate_n_flags; time = desc->v3.gp2_on_air_rise; channel = desc->v3.channel; @@ -408,7 +408,7 @@ void IWLTransOps::rxMpdu(iwl_rx_cmd_buffer* rxcb) { return; } - if(fw_has_capa(&trans->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_FLAGS_RX_ENERGY_API)) { + if (fw_has_capa(&trans->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_FLAGS_RX_ENERGY_API)) { rssi = get_signal_strength(trans); } else { rssi = calc_rssi(trans); @@ -426,23 +426,23 @@ void IWLTransOps::rxMpdu(iwl_rx_cmd_buffer* rxcb) { rxcb->_page_stolen = true; - if(len <= sizeof(*wh)) { + if (len <= sizeof(*wh)) { IWL_INFO(0, "SKIPPING BEACON PACKET BECAUSE TOO SHORT\n"); return; } uint32_t device_timestamp = le32toh(last_phy_info->system_timestamp); - if(trans->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { - if(ieee80211_is_beacon(wh->i_fc[0])) { - if(last_phy_info->channel != 0) { - if(trans->m_pDevice->ie_dev->scanCache == NULL) { + if (trans->m_pDevice->ie_dev->state == APPLE80211_S_SCAN) { + if (ieee80211_is_beacon(wh->i_fc[0])) { + if (last_phy_info->channel != 0) { + if (trans->m_pDevice->ie_dev->scanCache == NULL) { IWL_ERR(0, "Scan cache was null, not allocating a new one\n"); return; } - if(!IOLockTryLock(trans->m_pDevice->ie_dev->scanCacheLock)) { + if (!IOLockTryLock(trans->m_pDevice->ie_dev->scanCacheLock)) { IWL_INFO(0, "Skipped beacon packet because scan cache is already locked\n"); // we CANNOT block. return; @@ -457,33 +457,32 @@ void IWLTransOps::rxMpdu(iwl_rx_cmd_buffer* rxcb) { OSCollectionIterator* it = OSCollectionIterator::withCollection(trans->m_pDevice->ie_dev->scanCache); - if(!it->isValid()) { + if (!it->isValid()) { IWL_ERR(0, "Iterator not valid, not recreating\n"); return; } OSObject* obj = NULL; - while((obj = it->getNextObject()) != NULL) { + while ((obj = it->getNextObject()) != NULL) { - if(obj == NULL) + if (obj == NULL) break; IWLCachedScan* cachedScan = OSDynamicCast(IWLCachedScan, obj); - if(!cachedScan) { + if (!cachedScan) continue; - } - if(cachedScan->getTimestamp() <= oldest) { // the smaller the timestamp, the older + if (cachedScan->getTimestamp() <= oldest) { // the smaller the timestamp, the older // absolute time only increments oldest = cachedScan->getTimestamp(); oldest_obj = obj; } - if(memcmp(cachedScan->getBSSID(), &wh->i_addr3[0], 6) == 0) + if (memcmp(cachedScan->getBSSID(), &wh->i_addr3[0], 6) == 0) { - if(cachedScan->getChannel().channel == last_phy_info->channel) { + if (cachedScan->getChannel().channel == last_phy_info->channel) { // existing entry, remove the old one and add in the new one update_old_scan = true; IWL_INFO(0, "Updating old entry\n"); @@ -494,30 +493,28 @@ void IWLTransOps::rxMpdu(iwl_rx_cmd_buffer* rxcb) { } } - if(trans->m_pDevice->ie_dev->scanCache->getCapacity() == indx && !update_old_scan) { + if (trans->m_pDevice->ie_dev->scanCache->getCapacity() == indx && !update_old_scan) { // purge the scan cache of the oldest object IWL_INFO(0, "Purging oldest object because we are at capacity\n"); - if(oldest_obj != NULL) { + + if (oldest_obj != NULL) trans->m_pDevice->ie_dev->scanCache->removeObject(oldest_obj); - } } - if(!update_old_scan) { + if (!update_old_scan) { IWL_INFO(0, "Adding new object to scan cache\n"); IWLCachedScan* scan = new IWLCachedScan(); - if(!scan->init(page, rxcb->_offset, whOffset, last_phy_info, rssi, -101)) { + if (!scan->init(page, rxcb->_offset, whOffset, last_phy_info, rssi, -101)) { scan->free(); IWL_ERR(0, "failed to init new cached scan object\n"); - IOLockUnlock(trans->m_pDevice->ie_dev->scanCacheLock); + IOLockUnlock(trans->m_pDevice->ie_dev->scanCacheLock); return; } - trans->m_pDevice->ie_dev->scanCache->setObject(scan); // new scanned object, add it to the list + + trans->m_pDevice->ie_dev->scanCache->setObject(scan); // new scanned object, add it to the list } - - it->release(); - IOLockUnlock(trans->m_pDevice->ie_dev->scanCacheLock); } } else { @@ -574,16 +571,15 @@ void print_umac(IWLTransport* trans) { base = trans->m_pDevice->uc.uc_umac_error_event_table; - if(base < 0x800000) { + if (base < 0x800000) { IWL_ERR(0, "Invalid error event table ptr: 0x%0x\n", base); return; } trans->iwlReadMem(base, &t, sizeof(t)/sizeof(uint32_t)); - if(!t.valid) { + if (!t.valid) IWL_ERR(0, "Error log not found\n"); - } if (ERROR_START_OFFSET <= t.valid * ERROR_ELEM_SIZE) { IWL_ERR(0, "Start uMAC Error Log Dump:\n"); @@ -614,7 +610,7 @@ void print_umac(IWLTransport* trans) { } void IWLTransOps::fwError() { - if(test_bit(STATUS_TRANS_DEAD, &trans->status)) { + if (test_bit(STATUS_TRANS_DEAD, &trans->status)) { return; } @@ -624,14 +620,14 @@ void IWLTransOps::fwError() { IWL_ERR(0, "Dumping device error log\n"); base = this->trans->m_pDevice->uc.uc_error_event_table; - if(base < 0x800000) { + if (base < 0x800000) { IWL_ERR(0, "Invalid error event table ptr: 0x%0x\n", base); return; } trans->iwlReadMem(base, &t, sizeof(t)/sizeof(uint32_t)); - if(!t.valid) { + if (!t.valid) { IWL_ERR(0, "Error log not found\n"); } @@ -683,7 +679,7 @@ void IWLTransOps::fwError() { IWL_ERR(0, "%08X | timestamp\n", t.u_timestamp); IWL_ERR(0, "%08X | flow_handler\n", t.flow_handler); - if(this->trans->m_pDevice->uc.uc_umac_error_event_table) + if (this->trans->m_pDevice->uc.uc_umac_error_event_table) print_umac(trans); diff --git a/scripts/build.sh b/scripts/build.sh index fc330f2..c492921 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,12 +1,5 @@ #!/bin/bash -DIR=$(echo $PWD | rev | cut -d '/' -f1 | rev) -BUILD="../build" -PROJECT="../AppleIntelWifiAdapter.xcodeproj" - -if [ "$DIR" != "scripts" ]; then -BUILD="./build" -PROJECT="./AppleIntelWifiAdapter.xcodeproj" -fi +source "$(cd "$(dirname "$0")" && pwd)"/env.sh if [ ! -d "$BUILD" ]; then mkdir $BUILD diff --git a/scripts/env.sh b/scripts/env.sh new file mode 100755 index 0000000..f7364e1 --- /dev/null +++ b/scripts/env.sh @@ -0,0 +1,11 @@ +#!/bin/bash +DIR=$(echo $PWD | rev | cut -d '/' -f1 | rev) +BUILD="../build" +PROJECT="../AppleIntelWifiAdapter.xcodeproj" +SRC="../AppleIntelWifiAdapter/" + +if [ "$DIR" != "scripts" ]; then +BUILD="./build" +PROJECT="./AppleIntelWifiAdapter.xcodeproj" +SRC="./AppleIntelWifiAdapter/" +fi diff --git a/scripts/format.sh b/scripts/format.sh new file mode 100644 index 0000000..44e6fdb --- /dev/null +++ b/scripts/format.sh @@ -0,0 +1,10 @@ +#!/bin/bash +source "$(cd "$(dirname "$0")" && pwd)"/env.sh + +if ! [ -x "$(command -v clang-format)" ]; then + echo "Please install clang-format on your machine" + exit 1 +fi + + + diff --git a/scripts/lint.sh b/scripts/lint.sh new file mode 100755 index 0000000..3d999f1 --- /dev/null +++ b/scripts/lint.sh @@ -0,0 +1,18 @@ +#!/bin/bash +source "$(cd "$(dirname "$0")" && pwd)"/env.sh + +if ! [ -x "$(command -v cpplint)" ]; then + echo "Please install cpplint on your machine" + exit 1 +fi + +cpplint --exclude="$SRC"/compat/linux/* \ +--exclude=$SRC/compat/openbsd/crypto/* \ +--exclude=$SRC/compat/openbsd/net80211/* \ +--exclude=$SRC/compat/openbsd/sys/* \ +--exclude=$SRC/fw/api/* \ +--exclude=$SRC/device/* \ +--exclude=$SRC/apple80211/* \ +--recursive \ +--verbose 4 \ +$SRC diff --git a/scripts/load.sh b/scripts/load.sh index 142ba06..c21600d 100755 --- a/scripts/load.sh +++ b/scripts/load.sh @@ -1,12 +1,5 @@ #!/bin/bash -DIR=$(echo $PWD | rev | cut -d '/' -f1 | rev) -BUILD="../build" -PROJECT="../AppleIntelWifiAdapter.xcodeproj" - -if [ "$DIR" != "scripts" ]; then -BUILD="./build" -PROJECT="./AppleIntelWifiAdapter.xcodeproj" -fi +source "$(cd "$(dirname "$0")" && pwd)"/env.sh if [ ! -d "$BUILD" ]; then echo "Build the kext with ./scripts/build.sh before running this script." diff --git a/scripts/unload.sh b/scripts/unload.sh index 8340c07..3090bac 100755 --- a/scripts/unload.sh +++ b/scripts/unload.sh @@ -1,12 +1,5 @@ #!/bin/bash -DIR=$(echo $PWD | rev | cut -d '/' -f1 | rev) -BUILD="../build" -PROJECT="../AppleIntelWifiAdapter.xcodeproj" - -if [ "$DIR" != "scripts" ]; then -BUILD="./build" -PROJECT="./AppleIntelWifiAdapter.xcodeproj" -fi +source "$(cd "$(dirname "$0")" && pwd)"/env.sh if [ ! -d "$BUILD" ]; then echo "Build the kext with ./scripts/build.sh before running this script."