usb_asix: style cleanup
* While I was in the neighbourhood * No functional change
This commit is contained in:
@@ -37,29 +37,29 @@ struct TRXHeader {
|
||||
|
||||
|
||||
ASIXDevice::ASIXDevice(usb_device device, DeviceInfo& deviceInfo)
|
||||
:
|
||||
fDevice(device),
|
||||
fStatus(B_ERROR),
|
||||
fOpen(false),
|
||||
fRemoved(false),
|
||||
fHasConnection(false),
|
||||
fNonBlocking(false),
|
||||
fInsideNotify(0),
|
||||
fFrameSize(0),
|
||||
fNotifyEndpoint(0),
|
||||
fReadEndpoint(0),
|
||||
fWriteEndpoint(0),
|
||||
fActualLengthRead(0),
|
||||
fActualLengthWrite(0),
|
||||
fStatusRead(B_OK),
|
||||
fStatusWrite(B_OK),
|
||||
fNotifyReadSem(-1),
|
||||
fNotifyWriteSem(-1),
|
||||
fNotifyBuffer(NULL),
|
||||
fNotifyBufferLength(0),
|
||||
fLinkStateChangeSem(-1),
|
||||
fUseTRXHeader(false),
|
||||
fReadNodeIDRequest(kInvalidRequest)
|
||||
:
|
||||
fDevice(device),
|
||||
fStatus(B_ERROR),
|
||||
fOpen(false),
|
||||
fRemoved(false),
|
||||
fHasConnection(false),
|
||||
fNonBlocking(false),
|
||||
fInsideNotify(0),
|
||||
fFrameSize(0),
|
||||
fNotifyEndpoint(0),
|
||||
fReadEndpoint(0),
|
||||
fWriteEndpoint(0),
|
||||
fActualLengthRead(0),
|
||||
fActualLengthWrite(0),
|
||||
fStatusRead(B_OK),
|
||||
fStatusWrite(B_OK),
|
||||
fNotifyReadSem(-1),
|
||||
fNotifyWriteSem(-1),
|
||||
fNotifyBuffer(NULL),
|
||||
fNotifyBufferLength(0),
|
||||
fLinkStateChangeSem(-1),
|
||||
fUseTRXHeader(false),
|
||||
fReadNodeIDRequest(kInvalidRequest)
|
||||
{
|
||||
fDeviceInfo = deviceInfo;
|
||||
|
||||
@@ -72,14 +72,14 @@ ASIXDevice::ASIXDevice(usb_device device, DeviceInfo& deviceInfo)
|
||||
fNotifyReadSem = create_sem(0, DRIVER_NAME"_notify_read");
|
||||
if (fNotifyReadSem < B_OK) {
|
||||
TRACE_ALWAYS("Error of creating read notify semaphore:%#010x\n",
|
||||
fNotifyReadSem);
|
||||
fNotifyReadSem);
|
||||
return;
|
||||
}
|
||||
|
||||
fNotifyWriteSem = create_sem(0, DRIVER_NAME"_notify_write");
|
||||
if (fNotifyWriteSem < B_OK) {
|
||||
TRACE_ALWAYS("Error of creating write notify semaphore:%#010x\n",
|
||||
fNotifyWriteSem);
|
||||
fNotifyWriteSem);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ ASIXDevice::Open(uint32 flags)
|
||||
|
||||
// setup state notifications
|
||||
result = gUSBModule->queue_interrupt(fNotifyEndpoint, fNotifyBuffer,
|
||||
fNotifyBufferLength, _NotifyCallback, this);
|
||||
fNotifyBufferLength, _NotifyCallback, this);
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of requesting notify interrupt:%#010x\n", result);
|
||||
return result;
|
||||
@@ -170,7 +170,7 @@ ASIXDevice::Read(uint8 *buffer, size_t *numBytes)
|
||||
|
||||
if (fRemoved) {
|
||||
TRACE_ALWAYS("Error of receiving %d bytes from removed device.\n",
|
||||
numBytesToRead);
|
||||
numBytesToRead);
|
||||
return B_DEVICE_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,8 @@ ASIXDevice::Read(uint8 *buffer, size_t *numBytes)
|
||||
size_t chunkCount = fUseTRXHeader ? 2 : 1 ;
|
||||
|
||||
status_t result = gUSBModule->queue_bulk_v(fReadEndpoint,
|
||||
&rxData[startIndex], chunkCount, _ReadCallback, this);
|
||||
&rxData[startIndex], chunkCount, _ReadCallback, this);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of queue_bulk_v request:%#010x\n", result);
|
||||
return result;
|
||||
@@ -205,7 +206,7 @@ ASIXDevice::Read(uint8 *buffer, size_t *numBytes)
|
||||
USB_FEATURE_ENDPOINT_HALT);
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error during clearing of HALT state:%#010x.\n",
|
||||
result);
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -213,13 +214,13 @@ ASIXDevice::Read(uint8 *buffer, size_t *numBytes)
|
||||
if (fUseTRXHeader) {
|
||||
if (fActualLengthRead < sizeof(TRXHeader)) {
|
||||
TRACE_ALWAYS("Error: no place for TRXHeader:only %d of %d bytes.\n",
|
||||
fActualLengthRead, sizeof(TRXHeader));
|
||||
fActualLengthRead, sizeof(TRXHeader));
|
||||
return B_ERROR; // TODO: ???
|
||||
}
|
||||
|
||||
if (!header.IsValid()) {
|
||||
TRACE_ALWAYS("Error:TRX Header is invalid: len:%#04x; ilen:%#04x\n",
|
||||
header.fLength, header.fInvertedLength);
|
||||
header.fLength, header.fInvertedLength);
|
||||
return B_ERROR; // TODO: ???
|
||||
}
|
||||
|
||||
@@ -227,7 +228,7 @@ ASIXDevice::Read(uint8 *buffer, size_t *numBytes)
|
||||
|
||||
if (fActualLengthRead - sizeof(TRXHeader) > header.Length()) {
|
||||
TRACE_ALWAYS("MISMATCH of the frame length: hdr %d; received:%d\n",
|
||||
header.Length(), fActualLengthRead - sizeof(TRXHeader));
|
||||
header.Length(), fActualLengthRead - sizeof(TRXHeader));
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -248,7 +249,7 @@ ASIXDevice::Write(const uint8 *buffer, size_t *numBytes)
|
||||
|
||||
if (fRemoved) {
|
||||
TRACE_ALWAYS("Error of writing %d bytes to removed device.\n",
|
||||
numBytesToWrite);
|
||||
numBytesToWrite);
|
||||
return B_DEVICE_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -264,7 +265,8 @@ ASIXDevice::Write(const uint8 *buffer, size_t *numBytes)
|
||||
size_t chunkCount = fUseTRXHeader ? 2 : 1 ;
|
||||
|
||||
status_t result = gUSBModule->queue_bulk_v(fWriteEndpoint,
|
||||
&txData[startIndex], chunkCount, _WriteCallback, this);
|
||||
&txData[startIndex], chunkCount, _WriteCallback, this);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of queue_bulk_v request:%#010x\n", result);
|
||||
return result;
|
||||
@@ -380,17 +382,18 @@ ASIXDevice::SetupDevice(bool deviceReplugged)
|
||||
}
|
||||
|
||||
TRACE("MAC address is:%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
address.ebyte[0], address.ebyte[1], address.ebyte[2],
|
||||
address.ebyte[3], address.ebyte[4], address.ebyte[5]);
|
||||
address.ebyte[0], address.ebyte[1], address.ebyte[2],
|
||||
address.ebyte[3], address.ebyte[4], address.ebyte[5]);
|
||||
|
||||
if (deviceReplugged) {
|
||||
// this might be the same device that was replugged - read the MAC
|
||||
// address (which should be at the same index) to make sure
|
||||
if (memcmp(&address, &fMACAddress, sizeof(address)) != 0) {
|
||||
TRACE_ALWAYS("Cannot replace device with MAC address:"
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
fMACAddress.ebyte[0], fMACAddress.ebyte[1], fMACAddress.ebyte[2],
|
||||
fMACAddress.ebyte[3], fMACAddress.ebyte[4], fMACAddress.ebyte[5]);
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x\n", fMACAddress.ebyte[0],
|
||||
fMACAddress.ebyte[1], fMACAddress.ebyte[2],
|
||||
fMACAddress.ebyte[3], fMACAddress.ebyte[4],
|
||||
fMACAddress.ebyte[5]);
|
||||
return B_BAD_VALUE; // is not the same
|
||||
}
|
||||
} else
|
||||
@@ -473,30 +476,26 @@ ASIXDevice::_SetupEndpoints()
|
||||
for (size_t ep = 0; ep < interface->endpoint_count; ep++) {
|
||||
usb_endpoint_descriptor *epd = interface->endpoint[ep].descr;
|
||||
if ((epd->attributes & USB_ENDPOINT_ATTR_MASK)
|
||||
== USB_ENDPOINT_ATTR_INTERRUPT)
|
||||
{
|
||||
== USB_ENDPOINT_ATTR_INTERRUPT) {
|
||||
notifyEndpoint = ep;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((epd->attributes & USB_ENDPOINT_ATTR_MASK)
|
||||
!= USB_ENDPOINT_ATTR_BULK)
|
||||
{
|
||||
!= USB_ENDPOINT_ATTR_BULK) {
|
||||
TRACE_ALWAYS("Error: USB endpoint type %#04x is unknown.\n",
|
||||
epd->attributes);
|
||||
epd->attributes);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((epd->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN)
|
||||
== USB_ENDPOINT_ADDR_DIR_IN)
|
||||
{
|
||||
== USB_ENDPOINT_ADDR_DIR_IN) {
|
||||
readEndpoint = ep;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((epd->endpoint_address & USB_ENDPOINT_ADDR_DIR_OUT)
|
||||
== USB_ENDPOINT_ADDR_DIR_OUT)
|
||||
{
|
||||
== USB_ENDPOINT_ADDR_DIR_OUT) {
|
||||
writeEndpoint = ep;
|
||||
continue;
|
||||
}
|
||||
@@ -504,16 +503,16 @@ ASIXDevice::_SetupEndpoints()
|
||||
|
||||
if (notifyEndpoint == -1 || readEndpoint == -1 || writeEndpoint == -1) {
|
||||
TRACE_ALWAYS("Error: not all USB endpoints were found: "
|
||||
"notify:%d; read:%d; write:%d\n",
|
||||
notifyEndpoint, readEndpoint, writeEndpoint);
|
||||
"notify:%d; read:%d; write:%d\n", notifyEndpoint, readEndpoint,
|
||||
writeEndpoint);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
gUSBModule->set_configuration(fDevice, config);
|
||||
|
||||
fNotifyEndpoint = interface->endpoint[notifyEndpoint].handle;
|
||||
fReadEndpoint = interface->endpoint[readEndpoint ].handle;
|
||||
fWriteEndpoint = interface->endpoint[writeEndpoint ].handle;
|
||||
fReadEndpoint = interface->endpoint[readEndpoint].handle;
|
||||
fWriteEndpoint = interface->endpoint[writeEndpoint].handle;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
@@ -524,9 +523,9 @@ ASIXDevice::ReadMACAddress(ether_address_t *address)
|
||||
{
|
||||
size_t actual_length = 0;
|
||||
status_t result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
|
||||
fReadNodeIDRequest, 0, 0, sizeof(ether_address),
|
||||
address, &actual_length);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, fReadNodeIDRequest,
|
||||
0, 0, sizeof(ether_address), address, &actual_length);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of reading MAC address:%#010x\n", result);
|
||||
return result;
|
||||
@@ -549,14 +548,13 @@ ASIXDevice::ReadRXControlRegister(uint16 *rxcontrol)
|
||||
*rxcontrol = 0;
|
||||
|
||||
status_t result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
|
||||
READ_RX_CONTROL, 0, 0,
|
||||
sizeof(*rxcontrol), rxcontrol, &actual_length);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_RX_CONTROL,
|
||||
0, 0, sizeof(*rxcontrol), rxcontrol, &actual_length);
|
||||
|
||||
if (sizeof(*rxcontrol) != actual_length) {
|
||||
TRACE_ALWAYS("Mismatch during reading RX control register."
|
||||
"Read %d bytes instead of %d.\n",
|
||||
actual_length, sizeof(*rxcontrol));
|
||||
"Read %d bytes instead of %d.\n", actual_length,
|
||||
sizeof(*rxcontrol));
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -567,8 +565,8 @@ status_t
|
||||
ASIXDevice::WriteRXControlRegister(uint16 rxcontrol)
|
||||
{
|
||||
status_t result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_RX_CONTROL, rxcontrol, 0, 0, 0, 0);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_RX_CONTROL,
|
||||
rxcontrol, 0, 0, 0, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -578,9 +576,8 @@ ASIXDevice::StopDevice()
|
||||
{
|
||||
status_t result = WriteRXControlRegister(0);
|
||||
|
||||
if (result != B_OK) {
|
||||
if (result != B_OK)
|
||||
TRACE_ALWAYS("Error of writing %#04x RX Control:%#010x\n", 0, result);
|
||||
}
|
||||
|
||||
TRACE_RET(result);
|
||||
return result;
|
||||
@@ -607,7 +604,7 @@ ASIXDevice::SetPromiscuousMode(bool on)
|
||||
|
||||
if (result != B_OK ) {
|
||||
TRACE_ALWAYS("Error of writing %#04x RX Control:%#010x\n",
|
||||
rxcontrol, result);
|
||||
rxcontrol, result);
|
||||
}
|
||||
|
||||
TRACE_RET(result);
|
||||
@@ -681,9 +678,9 @@ ASIXDevice::ModifyMulticastTable(bool join, ether_address_t* group)
|
||||
// write multicast hash table
|
||||
size_t actualLength = 0;
|
||||
result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_MF_ARRAY, 0, 0,
|
||||
hashLength, hashTable, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_MF_ARRAY,
|
||||
0, 0, hashLength, hashTable, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error writing hash table in MAR: %#010x.\n", result);
|
||||
return result;
|
||||
@@ -691,7 +688,7 @@ ASIXDevice::ModifyMulticastTable(bool join, ether_address_t* group)
|
||||
|
||||
if (actualLength != hashLength)
|
||||
TRACE_ALWAYS("Incomplete writing of hash table: %d bytes of %d\n",
|
||||
actualLength, hashLength);
|
||||
actualLength, hashLength);
|
||||
|
||||
result = WriteRXControlRegister(rxcontrol);
|
||||
if (result != B_OK)
|
||||
|
||||
@@ -124,8 +124,8 @@ const uint16 maxFrameSize = 1518;
|
||||
|
||||
|
||||
AX88172Device::AX88172Device(usb_device device, DeviceInfo& deviceInfo)
|
||||
:
|
||||
ASIXDevice(device, deviceInfo)
|
||||
:
|
||||
ASIXDevice(device, deviceInfo)
|
||||
{
|
||||
fStatus = InitDevice();
|
||||
}
|
||||
@@ -175,8 +175,8 @@ AX88172Device::StartDevice()
|
||||
|
||||
for (size_t i = 0; i < sizeof(fIPG) / sizeof(fIPG[0]); i++) {
|
||||
status_t result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_IPG0, 0, 0, sizeof(fIPG[i]), &fIPG[i], &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_IPG0,
|
||||
0, 0, sizeof(fIPG[i]), &fIPG[i], &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error writing IPG%d: %#010x\n", i, result);
|
||||
@@ -193,7 +193,7 @@ AX88172Device::StartDevice()
|
||||
status_t result = WriteRXControlRegister(rxcontrol);
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of writing %#04x RX Control:%#010x\n",
|
||||
rxcontrol, result);
|
||||
rxcontrol, result);
|
||||
}
|
||||
|
||||
TRACE_RET(result);
|
||||
@@ -206,7 +206,7 @@ AX88172Device::OnNotify(uint32 actualLength)
|
||||
{
|
||||
if (actualLength < sizeof(AX88172Notify)) {
|
||||
TRACE_ALWAYS("Data underrun error. %d of %d bytes received\n",
|
||||
actualLength, sizeof(AX88172Notify));
|
||||
actualLength, sizeof(AX88172Notify));
|
||||
return B_BAD_DATA;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ AX88172Device::OnNotify(uint32 actualLength)
|
||||
|
||||
if (notification->btA1 != 0xa1) {
|
||||
TRACE_ALWAYS("Notify magic byte is invalid: %#02x\n",
|
||||
notification->btA1);
|
||||
notification->btA1);
|
||||
}
|
||||
|
||||
uint phyIndex = 0;
|
||||
@@ -222,11 +222,13 @@ AX88172Device::OnNotify(uint32 actualLength)
|
||||
switch(fMII.ActivePHY()) {
|
||||
case PrimaryPHY:
|
||||
phyIndex = 1;
|
||||
linkIsUp = (notification->btNN & LINK_STATE_PHY1) == LINK_STATE_PHY1;
|
||||
linkIsUp = (notification->btNN & LINK_STATE_PHY1)
|
||||
== LINK_STATE_PHY1;
|
||||
break;
|
||||
case SecondaryPHY:
|
||||
phyIndex = 2;
|
||||
linkIsUp = (notification->btNN & LINK_STATE_PHY2) == LINK_STATE_PHY2;
|
||||
linkIsUp = (notification->btNN & LINK_STATE_PHY2)
|
||||
== LINK_STATE_PHY2;
|
||||
break;
|
||||
default:
|
||||
case CurrentPHY:
|
||||
@@ -239,7 +241,7 @@ AX88172Device::OnNotify(uint32 actualLength)
|
||||
|
||||
if (linkStateChange) {
|
||||
TRACE("Link state of PHY%d has been changed to '%s'\n",
|
||||
phyIndex, fHasConnection ? "up" : "down");
|
||||
phyIndex, fHasConnection ? "up" : "down");
|
||||
}
|
||||
|
||||
if (linkStateChange && fLinkStateChangeSem >= B_OK)
|
||||
@@ -275,15 +277,15 @@ AX88172Device::GetLinkState(ether_link_state *linkState)
|
||||
|
||||
linkState->media = IFM_ETHER | (fHasConnection ? IFM_ACTIVE : 0);
|
||||
linkState->media |= mediumStatus & (ANLPAR_TX_FD | ANLPAR_10_FD) ?
|
||||
IFM_FULL_DUPLEX : IFM_HALF_DUPLEX;
|
||||
IFM_FULL_DUPLEX : IFM_HALF_DUPLEX;
|
||||
|
||||
linkState->speed = mediumStatus & (ANLPAR_TX_FD | ANLPAR_TX_HD)
|
||||
? 100000000 : 10000000;
|
||||
? 100000000 : 10000000;
|
||||
|
||||
TRACE_FLOW("Medium state: %s, %lld MBit/s, %s duplex.\n",
|
||||
(linkState->media & IFM_ACTIVE) ? "active" : "inactive",
|
||||
linkState->speed / 1000000,
|
||||
(linkState->media & IFM_FULL_DUPLEX) ? "full" : "half");
|
||||
(linkState->media & IFM_ACTIVE) ? "active" : "inactive",
|
||||
linkState->speed / 1000000,
|
||||
(linkState->media & IFM_FULL_DUPLEX) ? "full" : "half");
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,8 +158,8 @@ const uint16 maxFrameSize = 1536;
|
||||
|
||||
|
||||
AX88178Device::AX88178Device(usb_device device, DeviceInfo& deviceInfo)
|
||||
:
|
||||
ASIXDevice(device, deviceInfo)
|
||||
:
|
||||
ASIXDevice(device, deviceInfo)
|
||||
{
|
||||
fStatus = InitDevice();
|
||||
}
|
||||
@@ -202,8 +202,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
|
||||
size_t actualLength = 0;
|
||||
// get the "magic" word from EEPROM
|
||||
result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_SROM_ENABLE, 0, 0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SROM_ENABLE,
|
||||
0, 0, 0, 0, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of enabling SROM access:%#010x\n", result);
|
||||
@@ -212,9 +212,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
|
||||
|
||||
uint16 eepromData = 0;
|
||||
status_t op_result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
|
||||
READ_SROM, 0x17, 0,
|
||||
sizeof(eepromData), &eepromData, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_SROM,
|
||||
0x17, 0, sizeof(eepromData), &eepromData, &actualLength);
|
||||
|
||||
if (op_result != B_OK) {
|
||||
TRACE_ALWAYS("Error of reading SROM data:%#010x\n", result);
|
||||
@@ -222,13 +221,12 @@ AX88178Device::SetupDevice(bool deviceReplugged)
|
||||
|
||||
if (actualLength != sizeof(eepromData)) {
|
||||
TRACE_ALWAYS("Mismatch of reading SROM data."
|
||||
"Read %d bytes instead of %d\n",
|
||||
actualLength, sizeof(eepromData));
|
||||
"Read %d bytes instead of %d\n", actualLength, sizeof(eepromData));
|
||||
}
|
||||
|
||||
result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_SROM_DISABLE, 0, 0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SROM_DISABLE,
|
||||
0, 0, 0, 0, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of disabling SROM access: %#010x\n", result);
|
||||
@@ -261,15 +259,14 @@ AX88178Device::SetupDevice(bool deviceReplugged)
|
||||
|
||||
for (size_t i = from; i <= to; i++) {
|
||||
result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_GPIOS, GPIOCommands[i].value,
|
||||
0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_GPIOS,
|
||||
GPIOCommands[i].value, 0, 0, 0, &actualLength);
|
||||
|
||||
snooze(GPIOCommands[i].delay);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of GPIO setup command %d:[%#04x]: %#010x\n",
|
||||
i, GPIOCommands[i].value, result);
|
||||
i, GPIOCommands[i].value, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -277,8 +274,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
|
||||
uint8 uSWReset = 0;
|
||||
// finally a bit of exercises for SW reset register...
|
||||
result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_SOFT_RESET, uSWReset, 0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
|
||||
uSWReset, 0, 0, 0, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of SW reset to %#02x: %#010x\n", uSWReset, result);
|
||||
@@ -289,8 +286,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
|
||||
|
||||
uSWReset = SW_RESET_PRL | SW_RESET_BIT6;
|
||||
result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_SOFT_RESET, uSWReset, 0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
|
||||
uSWReset, 0, 0, 0, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of SW reset to %#02x: %#010x\n", uSWReset, result);
|
||||
@@ -317,8 +314,8 @@ AX88178Device::StartDevice()
|
||||
{
|
||||
size_t actualLength = 0;
|
||||
status_t result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_IPGS, 0, 0, sizeof(fIPG), fIPG, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_IPGS,
|
||||
0, 0, sizeof(fIPG), fIPG, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of writing IPGs:%#010x\n", result);
|
||||
@@ -327,14 +324,14 @@ AX88178Device::StartDevice()
|
||||
|
||||
if (actualLength != sizeof(fIPG)) {
|
||||
TRACE_ALWAYS("Mismatch of written IPGs data. "
|
||||
"%d bytes of %d written.\n", actualLength, sizeof(fIPG));
|
||||
"%d bytes of %d written.\n", actualLength, sizeof(fIPG));
|
||||
}
|
||||
|
||||
uint16 rxcontrol = RXCTL_START | RXCTL_BROADCAST;
|
||||
result = WriteRXControlRegister(rxcontrol);
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of writing %#04x RX Control:%#010x\n",
|
||||
rxcontrol, result);
|
||||
rxcontrol, result);
|
||||
}
|
||||
|
||||
TRACE_RET(result);
|
||||
@@ -347,7 +344,7 @@ AX88178Device::OnNotify(uint32 actualLength)
|
||||
{
|
||||
if (actualLength < sizeof(AX88178_Notify)) {
|
||||
TRACE_ALWAYS("Data underrun error. %d of %d bytes received\n",
|
||||
actualLength, sizeof(AX88178_Notify));
|
||||
actualLength, sizeof(AX88178_Notify));
|
||||
return B_BAD_DATA;
|
||||
}
|
||||
|
||||
@@ -355,7 +352,7 @@ AX88178Device::OnNotify(uint32 actualLength)
|
||||
|
||||
if (notification->btA1 != 0xa1) {
|
||||
TRACE_ALWAYS("Notify magic byte is invalid: %#02x\n",
|
||||
notification->btA1);
|
||||
notification->btA1);
|
||||
}
|
||||
|
||||
uint phyIndex = 0;
|
||||
@@ -363,11 +360,13 @@ AX88178Device::OnNotify(uint32 actualLength)
|
||||
switch(fMII.ActivePHY()) {
|
||||
case PrimaryPHY:
|
||||
phyIndex = 1;
|
||||
linkIsUp = (notification->btBB & LINK_STATE_PPLS) == LINK_STATE_PPLS;
|
||||
linkIsUp = (notification->btBB & LINK_STATE_PPLS)
|
||||
== LINK_STATE_PPLS;
|
||||
break;
|
||||
case SecondaryPHY:
|
||||
phyIndex = 2;
|
||||
linkIsUp = (notification->btBB & LINK_STATE_SPLS) == LINK_STATE_SPLS;
|
||||
linkIsUp = (notification->btBB & LINK_STATE_SPLS)
|
||||
== LINK_STATE_SPLS;
|
||||
break;
|
||||
default:
|
||||
case CurrentPHY:
|
||||
@@ -380,7 +379,7 @@ AX88178Device::OnNotify(uint32 actualLength)
|
||||
|
||||
if (linkStateChange) {
|
||||
TRACE("Link state of PHY%d has been changed to '%s'\n",
|
||||
phyIndex, fHasConnection ? "up" : "down");
|
||||
phyIndex, fHasConnection ? "up" : "down");
|
||||
}
|
||||
|
||||
if (linkStateChange && fLinkStateChangeSem >= B_OK)
|
||||
@@ -396,9 +395,8 @@ AX88178Device::GetLinkState(ether_link_state *linkState)
|
||||
size_t actualLength = 0;
|
||||
uint16 mediumStatus = 0;
|
||||
status_t result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
|
||||
READ_MEDIUM_STATUS, 0, 0, sizeof(mediumStatus),
|
||||
&mediumStatus, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_MEDIUM_STATUS,
|
||||
0, 0, sizeof(mediumStatus), &mediumStatus, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of reading medium status:%#010x.\n", result);
|
||||
@@ -415,19 +413,19 @@ AX88178Device::GetLinkState(ether_link_state *linkState)
|
||||
|
||||
linkState->quality = 1000;
|
||||
|
||||
linkState->media = IFM_ETHER | (fHasConnection ? IFM_ACTIVE : 0);
|
||||
linkState->media |= (mediumStatus & MEDIUM_STATE_FD) ?
|
||||
IFM_FULL_DUPLEX : IFM_HALF_DUPLEX;
|
||||
linkState->media = IFM_ETHER | (fHasConnection ? IFM_ACTIVE : 0);
|
||||
linkState->media |= (mediumStatus & MEDIUM_STATE_FD) ?
|
||||
IFM_FULL_DUPLEX : IFM_HALF_DUPLEX;
|
||||
|
||||
linkState->speed = (mediumStatus & MEDIUM_STATE_PS_100)
|
||||
? 100000000 : 10000000;
|
||||
linkState->speed = (mediumStatus & MEDIUM_STATE_GM) ?
|
||||
1000000000 : linkState->speed;
|
||||
linkState->speed = (mediumStatus & MEDIUM_STATE_PS_100)
|
||||
? 100000000 : 10000000;
|
||||
linkState->speed = (mediumStatus & MEDIUM_STATE_GM) ?
|
||||
1000000000 : linkState->speed;
|
||||
|
||||
TRACE_FLOW("Medium state: %s, %lld MBit/s, %s duplex.\n",
|
||||
(linkState->media & IFM_ACTIVE) ? "active" : "inactive",
|
||||
linkState->speed / 1000000,
|
||||
(linkState->media & IFM_FULL_DUPLEX) ? "full" : "half");
|
||||
(linkState->media & IFM_ACTIVE) ? "active" : "inactive",
|
||||
linkState->speed / 1000000,
|
||||
(linkState->media & IFM_FULL_DUPLEX) ? "full" : "half");
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -203,8 +203,8 @@ const uint16 maxFrameSize = 1536;
|
||||
|
||||
|
||||
AX88772Device::AX88772Device(usb_device device, DeviceInfo& deviceInfo)
|
||||
:
|
||||
ASIXDevice(device, deviceInfo)
|
||||
:
|
||||
ASIXDevice(device, deviceInfo)
|
||||
{
|
||||
fStatus = InitDevice();
|
||||
}
|
||||
@@ -290,12 +290,10 @@ AX88772Device::SetupDevice(bool deviceReplugged)
|
||||
|
||||
size_t actualLength = 0;
|
||||
result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_MEDIUM_MODE,
|
||||
MEDIUM_STATE_FD | MEDIUM_STATE_BIT2 |
|
||||
MEDIUM_STATE_RFC| MEDIUM_STATE_TFC |
|
||||
MEDIUM_STATE_RE | MEDIUM_STATE_PS_100,
|
||||
0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_MEDIUM_MODE,
|
||||
MEDIUM_STATE_FD | MEDIUM_STATE_BIT2 | MEDIUM_STATE_RFC
|
||||
| MEDIUM_STATE_TFC | MEDIUM_STATE_RE | MEDIUM_STATE_PS_100,
|
||||
0, 0, 0, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of setting medium mode: %#010x\n", result);
|
||||
@@ -313,8 +311,8 @@ AX88772Device::_SetupAX88772()
|
||||
// enable GPIO2 - magic from FreeBSD's if_axe
|
||||
uint16 GPIOs = GPIO_OO_2EN | GPIO_IO_2 | GPIO_RSE;
|
||||
status_t result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_GPIOS, GPIOs, 0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_GPIOS,
|
||||
GPIOs, 0, 0, 0, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of wrinting GPIOs: %#010x\n", result);
|
||||
@@ -323,16 +321,16 @@ AX88772Device::_SetupAX88772()
|
||||
|
||||
// select PHY
|
||||
bool useEmbeddedPHY = fMII.PHYID() == PHYIDEmbedded;
|
||||
uint16 selectPHY = useEmbeddedPHY ?
|
||||
SW_PHY_SEL_STATUS_INT : SW_PHY_SEL_STATUS_EXT;
|
||||
uint16 selectPHY = useEmbeddedPHY
|
||||
? SW_PHY_SEL_STATUS_INT : SW_PHY_SEL_STATUS_EXT;
|
||||
|
||||
result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_PHY_SEL, selectPHY, 0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_PHY_SEL, selectPHY, 0, 0, 0, &actualLength);
|
||||
snooze(10000);
|
||||
|
||||
TRACE("Selecting %s PHY[%#02x].\n",
|
||||
useEmbeddedPHY ? "embedded" : "external", selectPHY);
|
||||
useEmbeddedPHY ? "embedded" : "external", selectPHY);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of selecting PHY:%#010x\n", result);
|
||||
@@ -362,15 +360,14 @@ AX88772Device::_SetupAX88772()
|
||||
|
||||
for (size_t i = from; i <= to; i++) {
|
||||
result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_SOFT_RESET, resetCommands[i].reset,
|
||||
0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
|
||||
resetCommands[i].reset, 0, 0, 0, &actualLength);
|
||||
|
||||
snooze(resetCommands[i].delay);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of SW reset command %d:[%#04x]: %#010x\n",
|
||||
i, resetCommands[i].reset, result);
|
||||
i, resetCommands[i].reset, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -386,19 +383,19 @@ AX88772Device::_WakeupPHY()
|
||||
{
|
||||
// select PHY
|
||||
bool useEmbeddedPHY = fMII.PHYID() == PHYIDEmbedded;
|
||||
uint16 selectPHY = useEmbeddedPHY ?
|
||||
SW_PHY_SEL_STATUS_INT : SW_PHY_SEL_STATUS_EXT;
|
||||
uint16 selectPHY = useEmbeddedPHY
|
||||
? SW_PHY_SEL_STATUS_INT : SW_PHY_SEL_STATUS_EXT;
|
||||
|
||||
selectPHY |= SW_PHY_SEL_STATUS_SS_MII | SW_PHY_SEL_STATUS_SS_ENB;
|
||||
|
||||
size_t actualLength = 0;
|
||||
status_t result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_PHY_SEL, selectPHY, 0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_PHY_SEL,
|
||||
selectPHY, 0, 0, 0, &actualLength);
|
||||
snooze(31000);
|
||||
|
||||
TRACE("Selecting %s PHY[%#02x].\n",
|
||||
useEmbeddedPHY ? "embedded" : "external", selectPHY);
|
||||
useEmbeddedPHY ? "embedded" : "external", selectPHY);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of selecting PHY:%#010x\n", result);
|
||||
@@ -417,15 +414,14 @@ AX88772Device::_WakeupPHY()
|
||||
|
||||
for (size_t i = 0; i < _countof(resetCommands); i++) {
|
||||
result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_SOFT_RESET, resetCommands[i].reset,
|
||||
0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
|
||||
resetCommands[i].reset, 0, 0, 0, &actualLength);
|
||||
|
||||
snooze(resetCommands[i].delay);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of SW reset command %d:[%#04x]: %#010x\n",
|
||||
i, resetCommands[i].reset, result);
|
||||
i, resetCommands[i].reset, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -440,8 +436,8 @@ AX88772Device::_SetupAX88772A()
|
||||
// Reload EEPROM
|
||||
size_t actualLength = 0;
|
||||
status_t result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_GPIOS, GPIO_RSE, 0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_GPIOS,
|
||||
GPIO_RSE, 0, 0, 0, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of reloading EEPROM: %#010x\n", result);
|
||||
@@ -466,8 +462,8 @@ AX88772Device::_SetupAX88772B()
|
||||
// Reload EEPROM
|
||||
size_t actualLength = 0;
|
||||
status_t result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_GPIOS, GPIO_RSE, 0, 0, 0, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_GPIOS,
|
||||
GPIO_RSE, 0, 0, 0, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of reloading EEPROM: %#010x\n", result);
|
||||
@@ -491,8 +487,8 @@ AX88772Device::StartDevice()
|
||||
{
|
||||
size_t actualLength = 0;
|
||||
status_t result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||
WRITE_IPGS, 0, 0, sizeof(fIPG), fIPG, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_IPGS,
|
||||
0, 0, sizeof(fIPG), fIPG, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of writing IPGs:%#010x\n", result);
|
||||
@@ -501,12 +497,12 @@ AX88772Device::StartDevice()
|
||||
|
||||
if (actualLength != sizeof(fIPG)) {
|
||||
TRACE_ALWAYS("Mismatch of written IPGs data. "
|
||||
"%d bytes of %d written.\n", actualLength, sizeof(fIPG));
|
||||
"%d bytes of %d written.\n", actualLength, sizeof(fIPG));
|
||||
|
||||
}
|
||||
|
||||
|
||||
uint16 rxcontrol = 0;
|
||||
|
||||
|
||||
// AX88772B uses different maximum frame burst configuration.
|
||||
if (fDeviceInfo.fType == DeviceInfo::AX88772B) {
|
||||
result = gUSBModule->send_request(fDevice,
|
||||
@@ -524,7 +520,7 @@ AX88772Device::StartDevice()
|
||||
} else {
|
||||
// TODO: FreeBSD documents this to speed up xfers, I don't
|
||||
// have the hardware to test however.
|
||||
//rxcontrol = RXCTL_USB_MFB_MAX;
|
||||
// rxcontrol = RXCTL_USB_MFB_MAX;
|
||||
}
|
||||
|
||||
rxcontrol |= RXCTL_START | RXCTL_BROADCAST;
|
||||
@@ -544,15 +540,15 @@ AX88772Device::OnNotify(uint32 actualLength)
|
||||
{
|
||||
if (actualLength < sizeof(AX88772_Notify)) {
|
||||
TRACE_ALWAYS("Data underrun error. %d of %d bytes received\n",
|
||||
actualLength, sizeof(AX88772_Notify));
|
||||
actualLength, sizeof(AX88772_Notify));
|
||||
return B_BAD_DATA;
|
||||
}
|
||||
|
||||
AX88772_Notify *notification = (AX88772_Notify *)fNotifyBuffer;
|
||||
AX88772_Notify *notification = (AX88772_Notify *)fNotifyBuffer;
|
||||
|
||||
if (notification->btA1 != 0xa1) {
|
||||
TRACE_ALWAYS("Notify magic byte is invalid: %#02x\n",
|
||||
notification->btA1);
|
||||
notification->btA1);
|
||||
}
|
||||
|
||||
uint phyIndex = 0;
|
||||
@@ -560,11 +556,13 @@ AX88772Device::OnNotify(uint32 actualLength)
|
||||
switch(fMII.ActivePHY()) {
|
||||
case PrimaryPHY:
|
||||
phyIndex = 1;
|
||||
linkIsUp = (notification->btBB & LINK_STATE_PPLS) == LINK_STATE_PPLS;
|
||||
linkIsUp = (notification->btBB & LINK_STATE_PPLS)
|
||||
== LINK_STATE_PPLS;
|
||||
break;
|
||||
case SecondaryPHY:
|
||||
phyIndex = 2;
|
||||
linkIsUp = (notification->btBB & LINK_STATE_SPLS) == LINK_STATE_SPLS;
|
||||
linkIsUp = (notification->btBB & LINK_STATE_SPLS)
|
||||
== LINK_STATE_SPLS;
|
||||
break;
|
||||
default:
|
||||
case CurrentPHY:
|
||||
@@ -577,7 +575,7 @@ AX88772Device::OnNotify(uint32 actualLength)
|
||||
|
||||
if (linkStateChange) {
|
||||
TRACE("Link state of PHY%d has been changed to '%s'\n",
|
||||
phyIndex, fHasConnection ? "up" : "down");
|
||||
phyIndex, fHasConnection ? "up" : "down");
|
||||
}
|
||||
|
||||
if (linkStateChange && fLinkStateChangeSem >= B_OK)
|
||||
@@ -593,9 +591,8 @@ AX88772Device::GetLinkState(ether_link_state *linkState)
|
||||
size_t actualLength = 0;
|
||||
uint16 mediumStatus = 0;
|
||||
status_t result = gUSBModule->send_request(fDevice,
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
|
||||
READ_MEDIUM_STATUS, 0, 0, sizeof(mediumStatus),
|
||||
&mediumStatus, &actualLength);
|
||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_MEDIUM_STATUS,
|
||||
0, 0, sizeof(mediumStatus), &mediumStatus, &actualLength);
|
||||
|
||||
if (result != B_OK) {
|
||||
TRACE_ALWAYS("Error of reading medium status:%#010x.\n", result);
|
||||
@@ -604,25 +601,25 @@ AX88772Device::GetLinkState(ether_link_state *linkState)
|
||||
|
||||
if (actualLength != sizeof(mediumStatus)) {
|
||||
TRACE_ALWAYS("Mismatch of reading medium status."
|
||||
"Read %d bytes instead of %d\n",
|
||||
actualLength, sizeof(mediumStatus));
|
||||
"Read %d bytes instead of %d\n", actualLength,
|
||||
sizeof(mediumStatus));
|
||||
}
|
||||
|
||||
TRACE_FLOW("Medium status is %#04x\n", mediumStatus);
|
||||
|
||||
linkState->quality = 1000;
|
||||
|
||||
linkState->media = IFM_ETHER | (fHasConnection ? IFM_ACTIVE : 0);
|
||||
linkState->media |= (mediumStatus & MEDIUM_STATE_FD) ?
|
||||
IFM_FULL_DUPLEX : IFM_HALF_DUPLEX;
|
||||
linkState->media = IFM_ETHER | (fHasConnection ? IFM_ACTIVE : 0);
|
||||
linkState->media |= (mediumStatus & MEDIUM_STATE_FD) ?
|
||||
IFM_FULL_DUPLEX : IFM_HALF_DUPLEX;
|
||||
|
||||
linkState->speed = (mediumStatus & MEDIUM_STATE_PS_100)
|
||||
? 100000000 : 10000000;
|
||||
linkState->speed = (mediumStatus & MEDIUM_STATE_PS_100)
|
||||
? 100000000 : 10000000;
|
||||
|
||||
TRACE_FLOW("Medium state: %s, %lld MBit/s, %s duplex.\n",
|
||||
(linkState->media & IFM_ACTIVE) ? "active" : "inactive",
|
||||
linkState->speed / 1000000,
|
||||
(linkState->media & IFM_FULL_DUPLEX) ? "full" : "half");
|
||||
(linkState->media & IFM_ACTIVE) ? "active" : "inactive",
|
||||
linkState->speed / 1000000,
|
||||
(linkState->media & IFM_FULL_DUPLEX) ? "full" : "half");
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user