diff --git a/drivers/include/acpiutil.hpp b/drivers/include/acpiutil.hpp index a8e7623..94c276a 100644 --- a/drivers/include/acpiutil.hpp +++ b/drivers/include/acpiutil.hpp @@ -22,6 +22,8 @@ #ifndef __ACPIUTIL_HPP__ #define __ACPIUTIL_HPP__ +#pragma once +#include #define NONPAGED_SEGMENT_BEGIN \ __pragma(code_seg(push)) \ @@ -112,7 +114,7 @@ _IRQL_requires_max_(PASSIVE_LEVEL) NTSTATUS AcpiQueryDsd( _In_ DEVICE_OBJECT* PdoPtr, - _Outptr_result_bytebuffer_((*DsdBufferPptr)->Length) ACPI_EVAL_OUTPUT_BUFFER UNALIGNED** DsdBufferPptr); + _Outptr_result_bytebuffer_maybenull_((*DsdBufferPptr)->Length) ACPI_EVAL_OUTPUT_BUFFER UNALIGNED** DsdBufferPptr); _IRQL_requires_max_(DISPATCH_LEVEL) NTSTATUS @@ -198,6 +200,14 @@ AcpiQueryDsm( _In_ UINT32 RevisionId, _Out_ UINT32* SupportedFunctionsMaskPtr); +_IRQL_requires_max_(APC_LEVEL) +NTSTATUS +AcpiEvaluateMethod( + _In_ DEVICE_OBJECT* PdoPtr, + _In_reads_bytes_(InputBufferSize) ACPI_EVAL_INPUT_BUFFER* InputBufferPtr, + _In_ UINT32 InputBufferSize, + _Outptr_result_bytebuffer_maybenull_((*ReturnBufferPptr)->Length) ACPI_EVAL_OUTPUT_BUFFER UNALIGNED** ReturnBufferPptr); + _IRQL_requires_max_(APC_LEVEL) NTSTATUS AcpiExecuteDsmFunction( @@ -205,9 +215,9 @@ AcpiExecuteDsmFunction( _In_reads_bytes_(sizeof(GUID)) const GUID* GuidPtr, _In_ UINT32 RevisionId, _In_ UINT32 FunctionIdx, - _In_opt_ ACPI_METHOD_ARGUMENT* FunctionArgumentsPtr, + _In_reads_bytes_(FunctionArgumentsSize) ACPI_METHOD_ARGUMENT* FunctionArgumentsPtr, _In_ USHORT FunctionArgumentsSize, - _Outptr_opt_result_bytebuffer_((*ReturnBufferPptr)->Length) ACPI_EVAL_OUTPUT_BUFFER UNALIGNED** ReturnBufferPptr); + _Outptr_opt_result_bytebuffer_maybenull_((*ReturnBufferPptr)->Length) ACPI_EVAL_OUTPUT_BUFFER UNALIGNED** ReturnBufferPptr); _IRQL_requires_same_ NTSTATUS diff --git a/drivers/net/dwc_eqos/_acpiutil.cpp b/drivers/net/dwc_eqos/_acpiutil.cpp new file mode 100644 index 0000000..724faa2 --- /dev/null +++ b/drivers/net/dwc_eqos/_acpiutil.cpp @@ -0,0 +1,2 @@ +#include "precomp.h" +#include diff --git a/drivers/net/dwc_eqos/device.cpp b/drivers/net/dwc_eqos/device.cpp index f77a2fe..0831f80 100644 --- a/drivers/net/dwc_eqos/device.cpp +++ b/drivers/net/dwc_eqos/device.cpp @@ -10,6 +10,7 @@ #define CTRPP_VERIFY_COUNTER_SIZES 1 #include +#include #include /* @@ -24,8 +25,6 @@ CreateTxQueue DestroyCallback (DisarmWake) (ArmWake) */ -static auto constexpr DefaultAxiMaxWriteOutstanding = 4u; -static auto constexpr DefaultAxiMaxReadOutstanding = 8u; static auto constexpr DefaultCsrRate = 125'000'000u; static auto constexpr BusBytes = 8u; static auto constexpr QueuesSupported = 1u; // TODO: Support multiple queues? @@ -62,6 +61,7 @@ struct DeviceContext MacHwFeature3_t feature3; UINT8 permanentMacAddress[ETHERNET_LENGTH_OF_ADDRESS]; UINT8 currentMacAddress[ETHERNET_LENGTH_OF_ADDRESS]; + DeviceConfig config; // Mutable. @@ -421,11 +421,11 @@ AdapterCreateTxQueue( NT_ASSERT(context->txQueue == nullptr); return TxQueueCreate( context, + context->config, queueInit, context->dma, &context->regs->Dma_Ch[0], - &context->regs->Mtl_Q[0], - context->feature0.TxChecksumOffload != 0); + &context->regs->Mtl_Q[0]); } static EVT_NET_ADAPTER_CREATE_RXQUEUE AdapterCreateRxQueue; @@ -439,6 +439,7 @@ AdapterCreateRxQueue( NT_ASSERT(context->rxQueue == nullptr); return RxQueueCreate( context, + context->config, queueInit, context->dma, &context->regs->Dma_Ch[0]); @@ -591,7 +592,7 @@ DeviceD0Entry( macConfig.PacketBurstEnable = true; macConfig.ReceiverEnable = true; macConfig.TransmitterEnable = true; - macConfig.ChecksumOffloadEnable = context->feature0.TxChecksumOffload | context->feature0.RxChecksumOffload; + macConfig.ChecksumOffloadEnable = context->config.txCoeSel || context->config.rxCoeSel; Write32(&context->regs->Mac_Configuration, macConfig); // Clear and then enable interrupts. @@ -855,6 +856,169 @@ DevicePrepareHardware( } } + // Device Config + + { + context->config.txCoeSel = context->feature0.TxChecksumOffload; + context->config.rxCoeSel = context->feature0.RxChecksumOffload; + context->config.pblX8 = true; + context->config.pbl = 8; + context->config.txPbl = context->config.pbl; + context->config.rxPbl = context->config.pbl; + context->config.fixed_burst = false; + context->config.mixed_burst = true; + context->config.wr_osr_lmt = 4; + context->config.rd_osr_lmt = 8; + context->config.blen = 0x7; // 0x7 = 4, 8, 16 + + auto const deviceObject = WdfDeviceWdmGetPhysicalDevice(device); + PACPI_EVAL_OUTPUT_BUFFER outputBuffer = nullptr; + ACPI_METHOD_ARGUMENT const UNALIGNED* properties = nullptr; + ACPI_METHOD_ARGUMENT const UNALIGNED* blenProperties = nullptr; + UINT32 valueI32; + UINT32 valueLength; + + status = AcpiQueryDsd(deviceObject, &outputBuffer); + if (!NT_SUCCESS(status)) + { + TraceWrite("AcpiQueryDsd-failed", LEVEL_WARNING, + TraceLoggingNTStatus(status)); + goto DeviceConfigDone; + } + + status = AcpiParseDsdAsDeviceProperties(outputBuffer, &properties); + if (!NT_SUCCESS(status)) + { + TraceWrite("AcpiParseDsdAsDeviceProperties-DSD-failed", LEVEL_WARNING, + TraceLoggingNTStatus(status)); + goto DeviceConfigDone; + } + + status = AcpiDevicePropertiesQueryIntegerValue(properties, "snps,pblx8", &valueI32); + if (NT_SUCCESS(status) && valueI32 <= 1) + { + context->config.pblX8 = valueI32 != 0; + } + + status = AcpiDevicePropertiesQueryIntegerValue(properties, "snps,pbl", &valueI32); + if (NT_SUCCESS(status) && valueI32 <= 0x3F) + { + context->config.pbl = static_cast(valueI32); + context->config.txPbl = context->config.pbl; + context->config.rxPbl = context->config.pbl; + } + + status = AcpiDevicePropertiesQueryIntegerValue(properties, "snps,txpbl", &valueI32); + if (NT_SUCCESS(status) && valueI32 <= 0x3F) + { + context->config.txPbl = static_cast(valueI32); + } + + status = AcpiDevicePropertiesQueryIntegerValue(properties, "snps,rxpbl", &valueI32); + if (NT_SUCCESS(status) && valueI32 <= 0x3F) + { + context->config.rxPbl = static_cast(valueI32); + } + + status = AcpiDevicePropertiesQueryIntegerValue(properties, "snps,fixed-burst", &valueI32); + if (NT_SUCCESS(status) && valueI32 <= 1) + { + context->config.fixed_burst = valueI32 != 0; + } + + status = AcpiDevicePropertiesQueryIntegerValue(properties, "snps,mixed-burst", &valueI32); + if (NT_SUCCESS(status) && valueI32 <= 1) + { + context->config.mixed_burst = valueI32 != 0; + } + + CHAR valueString[5]; + status = AcpiDevicePropertiesQueryStringValue(properties, "snps,axi-config", sizeof(valueString), &valueLength, valueString); + if (!NT_SUCCESS(status) || valueLength != 5) + { + goto DeviceConfigDone; + } + + ExFreePoolWithTag(outputBuffer, ACPI_TAG_EVAL_OUTPUT_BUFFER); + outputBuffer = nullptr; + + ACPI_EVAL_INPUT_BUFFER inputBuffer; + inputBuffer = {}; + inputBuffer.Signature = ACPI_EVAL_INPUT_BUFFER_SIGNATURE; + + memcpy(inputBuffer.MethodName, valueString, sizeof(inputBuffer.MethodName)); + status = AcpiEvaluateMethod(deviceObject, &inputBuffer, sizeof(ACPI_EVAL_INPUT_BUFFER), &outputBuffer); + if (!NT_SUCCESS(status)) + { + TraceWrite("AcpiEvaluateMethod-AXIC-failed", LEVEL_WARNING, + TraceLoggingNTStatus(status)); + goto DeviceConfigDone; + } + + status = AcpiParseDsdAsDeviceProperties(outputBuffer, &properties); + if (!NT_SUCCESS(status)) + { + TraceWrite("AcpiParseDsdAsDeviceProperties-AXIC-failed", LEVEL_WARNING, + TraceLoggingNTStatus(status)); + goto DeviceConfigDone; + } + + status = AcpiDevicePropertiesQueryIntegerValue(properties, "snps,wr_osr_lmt", &valueI32); + if (NT_SUCCESS(status) && valueI32 <= 0x0F) + { + context->config.wr_osr_lmt = static_cast(valueI32); + } + + status = AcpiDevicePropertiesQueryIntegerValue(properties, "snps,rd_osr_lmt", &valueI32); + if (NT_SUCCESS(status) && valueI32 <= 0x0F) + { + context->config.rd_osr_lmt = static_cast(valueI32); + } + + status = AcpiDevicePropertiesQueryValue(properties, "snps,blen", &blenProperties); + if (NT_SUCCESS(status) && blenProperties->Type == ACPI_METHOD_ARGUMENT_PACKAGE) + { + UINT8 blen = 0; + unsigned count = 0; + + for (ACPI_METHOD_ARGUMENT const UNALIGNED* blenVal = nullptr;;) + { + status = AcpiPackageGetNextArgument(blenProperties, &blenVal); + if (!NT_SUCCESS(status) || + blenVal->Type != ACPI_METHOD_ARGUMENT_INTEGER || + blenVal->DataLength != sizeof(UINT32)) + { + break; + } + + count += 1; + switch (blenVal->Argument) + { + case 4: blen |= 0x1; break; + case 8: blen |= 0x2; break; + case 16: blen |= 0x4; break; + case 32: blen |= 0x8; break; + case 64: blen |= 0x10; break; + case 128: blen |= 0x20; break; + case 256: blen |= 0x40; break; + } + } + + if (count != 0) + { + context->config.blen = blen; + } + } + + DeviceConfigDone: + + if (outputBuffer) + { + ExFreePoolWithTag(outputBuffer, ACPI_TAG_EVAL_OUTPUT_BUFFER); + outputBuffer = nullptr; + } + } + // Create DMA enabler { @@ -943,7 +1107,7 @@ DevicePrepareHardware( NetPacketFilterFlagPromiscuous; NetAdapterSetReceiveFilterCapabilities(context->adapter, &rxFilterCaps); - if (context->feature0.TxChecksumOffload) + if (context->config.txCoeSel) { NET_ADAPTER_OFFLOAD_TX_CHECKSUM_CAPABILITIES txChecksumCaps; NET_ADAPTER_OFFLOAD_TX_CHECKSUM_CAPABILITIES_INIT(&txChecksumCaps, {}, AdapterOffloadSetTxChecksum); @@ -981,14 +1145,14 @@ DevicePrepareHardware( auto busMode = Read32(®s->Dma_SysBus_Mode); busMode.EnableLpi = true; // true = allow LPI, honor AXI LPI request. busMode.UnlockOnPacket = false; // false = Wake for any received packet, true = only wake for magic packet. - busMode.AxiMaxWriteOutstanding = DefaultAxiMaxWriteOutstanding; - busMode.AxiMaxReadOutstanding = DefaultAxiMaxReadOutstanding; + busMode.AxiMaxWriteOutstanding = context->config.wr_osr_lmt; + busMode.AxiMaxReadOutstanding = context->config.rd_osr_lmt; + busMode.Reserved14 = context->config.mixed_burst; // ??? This is what the NetBSD driver does. busMode.AddressAlignedBeats = true; // Seemed to have fewer Rx FIFO overflows with this set to true. busMode.AutoAxiLpi = true; // true = enter LPI after (Axi_Lpi_Entry_Interval + 1) * 64 idle clocks. - busMode.BurstLength16 = true; // true = allow 16-beat bursts. - busMode.BurstLength8 = true; // true = allow 8-beat bursts. - busMode.BurstLength4 = true; // true = allow 4-beat bursts. - busMode.FixedBurst = true; // true = fixed-burst, false = mixed-burst. + busMode.BurstLengths = context->config.blen; + + busMode.FixedBurst = context->config.fixed_burst; Write32(®s->Dma_SysBus_Mode, busMode); Write32(®s->Mac_1us_Tic_Counter, DefaultCsrRate / 1'000'000u - 1); @@ -999,7 +1163,7 @@ DevicePrepareHardware( "RxDescriptor must be a multiple of bus width."); ChannelDmaControl_t dmaControl = {}; dmaControl.DescriptorSkipLength = (sizeof(RxDescriptor) - 16) / BusBytes; - dmaControl.PblX8 = QueueBurstLengthX8; + dmaControl.PblX8 = context->config.pblX8; Write32(®s->Dma_Ch[0].Control, dmaControl); // Disable MMC counter interrupts. diff --git a/drivers/net/dwc_eqos/device.h b/drivers/net/dwc_eqos/device.h index 3b121d9..f6dab5b 100644 --- a/drivers/net/dwc_eqos/device.h +++ b/drivers/net/dwc_eqos/device.h @@ -3,7 +3,23 @@ Device behavior. Includes adapter and interrupt since they are 1:1 with the devi */ #pragma once -struct DeviceContext; +struct DeviceContext; // Multi-queue: change to DeviceQueueContext. + +// Information about the device provided to the queues. +struct DeviceConfig +{ + bool txCoeSel; // MAC_HW_Feature0\TXCOESEL (hardware support for tx checksum offload). + bool rxCoeSel; // MAC_HW_Feature0\RXCOESEL (hardware support for rx checksum offload). + bool pblX8; // _DSD\snps,pblx8 (default = 1). + UINT8 pbl; // _DSD\snps,pbl (default = 8). + UINT8 txPbl; // _DSD\snps,txpbl (default = pbl; effect depends on pblX8). + UINT8 rxPbl; // _DSD\snps,rxpbl (default = pbl; effect depends on pblX8). + bool fixed_burst; // _DSD\snps,fixed-burst (default = 0). + bool mixed_burst; // _DSD\snps,mixed-burst (default = 1). + UINT8 wr_osr_lmt; // AXIC\snps,wr_osr_lmt (default = 4). + UINT8 rd_osr_lmt; // AXIC\snps,rd_osr_lmt (default = 8). + UINT8 blen : 7; // AXIC\snps,blen bitmask of 7 booleans 4..256 (default = 4, 8, 16). +}; // Referenced in driver.cpp DriverEntry. // Called by WDF. diff --git a/drivers/net/dwc_eqos/driver.cpp b/drivers/net/dwc_eqos/driver.cpp index 3623c2b..ff29ef2 100644 --- a/drivers/net/dwc_eqos/driver.cpp +++ b/drivers/net/dwc_eqos/driver.cpp @@ -5,7 +5,6 @@ /* TODO list: - Support for 10/100 Mbps modes (requires ACPI support). -- Use ACPI to get AXI configuration (and/or tune AXI config). - Jumbo frames. - Receive queue memory optimization? - Configuration in registry (e.g. flow control). diff --git a/drivers/net/dwc_eqos/dwc_eqos.vcxproj b/drivers/net/dwc_eqos/dwc_eqos.vcxproj index eae9ec1..038c4e4 100644 --- a/drivers/net/dwc_eqos/dwc_eqos.vcxproj +++ b/drivers/net/dwc_eqos/dwc_eqos.vcxproj @@ -16,12 +16,14 @@ + Create Create + @@ -92,6 +94,7 @@ Use precomp.h stdcpp20 + ../../include;../../shared;$(IntDir);%(AdditionalIncludeDirectories) sha256 @@ -116,6 +119,7 @@ Use precomp.h stdcpp20 + ../../include;../../shared;$(IntDir);%(AdditionalIncludeDirectories) sha256 @@ -149,4 +153,4 @@ - + \ No newline at end of file diff --git a/drivers/net/dwc_eqos/dwc_eqos.vcxproj.filters b/drivers/net/dwc_eqos/dwc_eqos.vcxproj.filters index 1c405b7..ee9bd58 100644 --- a/drivers/net/dwc_eqos/dwc_eqos.vcxproj.filters +++ b/drivers/net/dwc_eqos/dwc_eqos.vcxproj.filters @@ -44,6 +44,9 @@ Header Files + + Header Files + @@ -64,6 +67,9 @@ Source Files + + Source Files + diff --git a/drivers/net/dwc_eqos/queue_common.h b/drivers/net/dwc_eqos/queue_common.h index ab98d8d..43963e4 100644 --- a/drivers/net/dwc_eqos/queue_common.h +++ b/drivers/net/dwc_eqos/queue_common.h @@ -7,9 +7,6 @@ UINT32 constexpr QueueDescriptorSize = 64; // 64 == sizeof(TxDescriptor) == size UINT32 constexpr QueueDescriptorMinCount = PAGE_SIZE / QueueDescriptorSize; UINT32 constexpr QueueDescriptorMaxCount = 0x400; -bool constexpr QueueBurstLengthX8 = true; -UINT32 constexpr QueueBurstLength = 64u / (QueueBurstLengthX8 ? 8 : 1); // TODO: load from ACPI? - // Alignment is mainly to make sure the allocation does not cross a 4GB boundary, // but it also simplifies the QueueDescriptorAddressToIndex implementation. auto const QueueDescriptorAlignment = QueueDescriptorMaxCount * QueueDescriptorSize; diff --git a/drivers/net/dwc_eqos/registers.h b/drivers/net/dwc_eqos/registers.h index 743e881..8342570 100644 --- a/drivers/net/dwc_eqos/registers.h +++ b/drivers/net/dwc_eqos/registers.h @@ -857,24 +857,22 @@ union DmaSysBusMode_t UINT32 Value32; struct { - UINT32 FixedBurst : 1; // FB - Fixed Burst Length - UINT32 BurstLength4 : 1; // BLEN4 - AXI Burst Length 4 - UINT32 BurstLength8 : 1; // BLEN8 - AXI Burst Length 8 - UINT32 BurstLength16 : 1; // BLEN16 - AXI Burst Length 16 - UINT32 Reserved4 : 6; - UINT32 AutoAxiLpi : 1; // AAL - Auto AXI LPI - UINT32 Reserved11 : 1; - UINT32 AddressAlignedBeats : 1; // AAL - Address Aligned Beats - UINT32 Reserved13 : 1; - UINT32 Reserved14 : 1; // mixed-burst? - UINT32 Reserved15 : 1; - - UINT32 AxiMaxReadOutstanding : 4; // RD_OSR_LMT - AXI Maximum Read Outstanding Request Limit - UINT32 Reserved20 : 4; - UINT32 AxiMaxWriteOutstanding : 4; // WR_OSR_LMT - AXI Maximum Write Outstanding Request Limit - UINT32 Reserved28 : 2; - UINT32 UnlockOnPacket : 1; // LPI_XIT_PKT - Unlock on Magic/Remote Wake-up Packet - UINT32 EnableLpi : 1; // EN_LPI - Enable Low Power Interface (LPI) + UINT8 FixedBurst : 1; // FB - 0 = mixed-burst, 1 = fixed-burst + UINT8 BurstLengths : 7; // BLEN4 .. BLEN256 - AXI Burst Length enable bits + UINT8 Reserved4 : 2; + UINT8 AutoAxiLpi : 1; // AAL - Auto AXI LPI + UINT8 Reserved11 : 1; + UINT8 AddressAlignedBeats : 1; // AAL - Address Aligned Beats + UINT8 Reserved13 : 1; + UINT8 Reserved14 : 1; // ??? NetBSD sets this to 1 for mixed-burst. + UINT8 Reserved15 : 1; + + UINT8 AxiMaxReadOutstanding : 4; // RD_OSR_LMT - AXI Maximum Read Outstanding Request Limit + UINT8 Reserved20 : 4; + UINT8 AxiMaxWriteOutstanding : 4; // WR_OSR_LMT - AXI Maximum Write Outstanding Request Limit + UINT8 Reserved28 : 2; + UINT8 UnlockOnPacket : 1; // LPI_XIT_PKT - Unlock on Magic/Remote Wake-up Packet + UINT8 EnableLpi : 1; // EN_LPI - Enable Low Power Interface (LPI) }; }; diff --git a/drivers/net/dwc_eqos/rxqueue.cpp b/drivers/net/dwc_eqos/rxqueue.cpp index 632a1c4..29041f9 100644 --- a/drivers/net/dwc_eqos/rxqueue.cpp +++ b/drivers/net/dwc_eqos/rxqueue.cpp @@ -20,6 +20,7 @@ struct RxQueueContext NET_EXTENSION packetChecksum; NET_EXTENSION fragmentLogical; UINT32 descCount; // A power of 2 between QueueDescriptorMinCount and QueueDescriptorMaxCount. + UINT8 rxPbl; bool running; UINT32 descBegin; // Start of the RECEIVE region. @@ -73,7 +74,7 @@ RxQueueStart(_In_ NETPACKETQUEUE queue) ChannelRxControl_t rxControl = {}; rxControl.Start = true; rxControl.ReceiveBufferSize = RxBufferSize; - rxControl.RxPbl = QueueBurstLength; + rxControl.RxPbl = context->rxPbl; Write32(&context->channelRegs->Rx_Control, rxControl); TraceEntryExit(RxQueueStart, LEVEL_INFO); @@ -339,6 +340,7 @@ RxQueueCleanup(_In_ WDFOBJECT queue) _Use_decl_annotations_ NTSTATUS RxQueueCreate( DeviceContext* deviceContext, + DeviceConfig const& deviceConfig, NETRXQUEUE_INIT* queueInit, WDFDMAENABLER dma, ChannelRegisters* channelRegs) @@ -380,6 +382,7 @@ RxQueueCreate( context->packetRing = NetRingCollectionGetPacketRing(rings); context->fragmentRing = NetRingCollectionGetFragmentRing(rings); context->descCount = QueueDescriptorCount(context->fragmentRing->NumberOfElements); + context->rxPbl = deviceConfig.rxPbl; TraceWrite("RxQueueCreate-size", LEVEL_VERBOSE, TraceLoggingHexInt32(context->packetRing->NumberOfElements, "packets"), diff --git a/drivers/net/dwc_eqos/rxqueue.h b/drivers/net/dwc_eqos/rxqueue.h index e3a0e05..f3f5805 100644 --- a/drivers/net/dwc_eqos/rxqueue.h +++ b/drivers/net/dwc_eqos/rxqueue.h @@ -4,6 +4,7 @@ Receive queue behavior. Similar to the transmit queue. #pragma once struct DeviceContext; +struct DeviceConfig; struct ChannelRegisters; auto constexpr RxBufferSize = 2048u; @@ -13,6 +14,7 @@ _IRQL_requires_(PASSIVE_LEVEL) NTSTATUS RxQueueCreate( _Inout_ DeviceContext* deviceContext, + _In_ DeviceConfig const& deviceConfig, _Inout_ NETRXQUEUE_INIT* queueInit, _In_ WDFDMAENABLER dma, _Inout_ ChannelRegisters* channelRegs); diff --git a/drivers/net/dwc_eqos/txqueue.cpp b/drivers/net/dwc_eqos/txqueue.cpp index 15ac44b..a1d7705 100644 --- a/drivers/net/dwc_eqos/txqueue.cpp +++ b/drivers/net/dwc_eqos/txqueue.cpp @@ -20,7 +20,8 @@ struct TxQueueContext NET_EXTENSION packetChecksum; NET_EXTENSION fragmentLogical; UINT32 descCount; // A power of 2 between QueueDescriptorMinCount and QueueDescriptorMaxCount. - bool checksumOffloadEnabled; + UINT8 txPbl; + bool txChecksumOffload; UINT32 descBegin; // Start of the TRANSMIT region. UINT32 descEnd; // End of the TRANSMIT region, start of the EMPTY region. @@ -72,7 +73,7 @@ TxQueueStart(_In_ NETPACKETQUEUE queue) ChannelTxControl_t txControl = {}; txControl.Start = true; txControl.OperateOnSecondPacket = true; - txControl.TxPbl = QueueBurstLength; + txControl.TxPbl = context->txPbl; Write32(&context->channelRegs->Tx_Control, txControl); TraceEntryExit(TxQueueStart, LEVEL_INFO); @@ -187,6 +188,7 @@ TxQueueAdvance(_In_ NETPACKETQUEUE queue) pktIndex = pktNext; // Number of EMPTY is (descBegin-1) - descEnd, wrapping around if necessary. + auto const txChecksumOffload = context->txChecksumOffload; auto const descEnd = context->descEnd; auto descEmpty = ((context->descBegin - 1) - descEnd) & descMask; descIndex = descEnd; @@ -208,7 +210,7 @@ TxQueueAdvance(_In_ NETPACKETQUEUE queue) // NetExtensionGetPacketChecksum because device.cpp didn't call // NetAdapterOffloadSetTxChecksumCapabilities. // If offload is disabled by software then the extension will be zeroed. - auto const checksum = context->checksumOffloadEnabled + auto const checksum = txChecksumOffload ? *NetExtensionGetPacketChecksum(&context->packetChecksum, pktIndex) : NET_PACKET_CHECKSUM{}; // Disabled by hardware. auto const checksumInsertion = @@ -410,11 +412,11 @@ TxQueueCleanup(_In_ WDFOBJECT queue) _Use_decl_annotations_ NTSTATUS TxQueueCreate( DeviceContext* deviceContext, + DeviceConfig const& deviceConfig, NETTXQUEUE_INIT* queueInit, WDFDMAENABLER dma, ChannelRegisters* channelRegs, - MtlQueueRegisters* mtlRegs, - bool checksumOffloadEnabled) + MtlQueueRegisters* mtlRegs) { // PASSIVE_LEVEL, nonpaged (resume path) NTSTATUS status; @@ -453,7 +455,8 @@ TxQueueCreate( context->packetRing = NetRingCollectionGetPacketRing(rings); context->fragmentRing = NetRingCollectionGetFragmentRing(rings); context->descCount = QueueDescriptorCount(context->fragmentRing->NumberOfElements); - context->checksumOffloadEnabled = checksumOffloadEnabled; + context->txPbl = deviceConfig.txPbl; + context->txChecksumOffload = deviceConfig.txCoeSel; TraceWrite("TxQueueCreate-size", LEVEL_VERBOSE, TraceLoggingHexInt32(context->packetRing->NumberOfElements, "packets"), @@ -486,7 +489,7 @@ TxQueueCreate( NET_EXTENSION_QUERY query; - if (context->checksumOffloadEnabled) + if (context->txChecksumOffload) { NET_EXTENSION_QUERY_INIT(&query, NET_PACKET_EXTENSION_CHECKSUM_NAME, diff --git a/drivers/net/dwc_eqos/txqueue.h b/drivers/net/dwc_eqos/txqueue.h index bf2e348..d8f5844 100644 --- a/drivers/net/dwc_eqos/txqueue.h +++ b/drivers/net/dwc_eqos/txqueue.h @@ -4,6 +4,7 @@ Transmit queue behavior. Similar to the receive queue. #pragma once struct DeviceContext; +struct DeviceConfig; struct ChannelRegisters; struct MtlQueueRegisters; @@ -13,8 +14,8 @@ _IRQL_requires_(PASSIVE_LEVEL) NTSTATUS TxQueueCreate( _Inout_ DeviceContext* deviceContext, + _In_ DeviceConfig const& deviceConfig, _Inout_ NETTXQUEUE_INIT* queueInit, _In_ WDFDMAENABLER dma, _Inout_ ChannelRegisters* channelRegs, - _Inout_ MtlQueueRegisters* mtlRegs, - bool checksumOffloadEnabled); + _Inout_ MtlQueueRegisters* mtlRegs); diff --git a/drivers/shared/acpiutil.cpp b/drivers/shared/acpiutil.cpp index 5c51919..3e08e0c 100644 --- a/drivers/shared/acpiutil.cpp +++ b/drivers/shared/acpiutil.cpp @@ -21,13 +21,7 @@ // #include - -extern "C" { - #include - #include -} // extern "C" - -#include "acpiutil.hpp" +#include #define ASSERT_MAX_IRQL(IRQL) NT_ASSERT(KeGetCurrentIrql() <= (IRQL)) @@ -90,19 +84,11 @@ AcpiFormatDsmFunctionInputBuffer( _In_ const GUID* GuidPtr, _In_ UINT32 RevisionId, _In_ UINT32 FunctionIdx, - _In_ ACPI_METHOD_ARGUMENT* FunctionArgumentsPtr, + _In_reads_bytes_(FunctionArgumentsSize) ACPI_METHOD_ARGUMENT* FunctionArgumentsPtr, _In_ USHORT FunctionArgumentsSize, _Outptr_result_bytebuffer_(*InputBufferSizePtr) ACPI_EVAL_INPUT_BUFFER_COMPLEX** InputBufferPptr, _Out_ UINT32* InputBufferSizePtr); -_IRQL_requires_max_(APC_LEVEL) -NTSTATUS -AcpiEvaluateMethod( - _In_ DEVICE_OBJECT* PdoPtr, - _In_reads_bytes_(InputBufferSize) ACPI_EVAL_INPUT_BUFFER* InputBufferPtr, - _In_ UINT32 InputBufferSize, - _Outptr_result_bytebuffer_((*ReturnBufferPptr)->Length) ACPI_EVAL_OUTPUT_BUFFER UNALIGNED** ReturnBufferPptr); - // // Internal Enumeration // @@ -565,7 +551,8 @@ AcpiSendIoctlSynchronously( irpPtr->IoStatus.Information = 0; irpPtr->UserBuffer = nullptr; - IO_STACK_LOCATION* irpStackPtr = IoGetNextIrpStackLocation(irpPtr); + IO_STACK_LOCATION* irpStackPtr; + irpStackPtr = IoGetNextIrpStackLocation(irpPtr); NT_ASSERT(irpStackPtr != nullptr); irpStackPtr->MajorFunction = IRP_MJ_DEVICE_CONTROL; irpStackPtr->Parameters.DeviceIoControl.IoControlCode = IoControlCode; @@ -981,7 +968,8 @@ AcpiFormatDsmFunctionInputBuffer( // // Argument 0: UUID // - ACPI_METHOD_ARGUMENT UNALIGNED* argumentPtr = &inputBufferPtr->Argument[0]; + ACPI_METHOD_ARGUMENT UNALIGNED* argumentPtr; + argumentPtr = &inputBufferPtr->Argument[0]; ACPI_METHOD_SET_ARGUMENT_BUFFER(argumentPtr, GuidPtr, sizeof(GUID)); //