How to set SGE address and length alignment for storport?

Wenwj 1 Reputation point
2022-01-20T05:50:59.393+00:00

Use WDK10, target env: windows server2019

Created a storage miniport driver base on storport.

For bus master DMA with scatter/gather supported, is there a way to make the address and length of each physical segment aligned to special Byte(32B/128B/512B/4K)?
or change the default alignment?

From https://learn.microsoft.com/zh-cn/windows-hardware/drivers/ddi/storport/ns-storport-_port_configuration_information
PORT_CONFIGURATION_INFORMATION.AlignmentMask = FILE_32_BYTE_ALIGNMENT
PORT_CONFIGURATION_INFORMATION.ScatterGather= TRUE
PORT_CONFIGURATION_INFORMATION.Dma32BitAddresses = TRUE;
PORT_CONFIGURATION_INFORMATION.Dma64BitAddresses = SCSI_DMA64_MINIPORT_FULL64BIT_SUPPORTED;

BUT the SRB data buffer physical address always 16Byte alignment, AlignmentMask invalid.
HwStartIo:srb opcode:0x28 ,data buffer phy:0x84a277b90, len:512
HwStartIo:srb opcode:0x25 ,data buffer phy:0x1efe54470, len:8
HwStartIo:srb opcode:0x25 ,data buffer phy:0x1efe540c0, len:8
HwStartIo:srb opcode:0x28 ,data buffer phy:0x1883a0b80, len:512
HwStartIo:srb opcode:0x28 ,data buffer phy:0x1824d3270, len:512

Compare to Linux: provide the api "blk_queue_dma_alignment" to set scsi io sge address alignment.

Windows Hardware Performance
Windows Hardware Performance
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Hardware Performance: Delivering / providing hardware or hardware systems or adjusting / adapting hardware or hardware systems.
1,557 questions
Windows Server Storage
Windows Server Storage
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Storage: The hardware and software system used to retain data for subsequent retrieval.
637 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,436 Reputation points
    2022-01-21T10:17:50.397+00:00

    Hi there,

    Have you set these requirements in your port config info? I think lots of storage controllers have these requirements or even stricter of 16. I think SBP2PORT is maybe the only storage port that has no alignment requirement at all. If your driver gets a Read/Write buffer that does not meet your hardware aliment requirements just allocate buffer internally and use this buffer for DMA. For Write I/O make memory copy before DMA and for reading I/O after DMA. Because it should not happen often using the internal buffer would not harm device performance. Don't forget to free the internal buffer before completing SRB.


    --If the reply is helpful, please Upvote and Accept it as an answer--