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 for business | Windows Client for IT Pros | Devices and deployment | Other
Windows for business | Windows Server | Storage high availability | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,926 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--


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.