Plx使用手册学习----11 PlxPci_DmaTransferUserBuffer

该博客详细介绍了如何使用PLX驱动程序通过DMA通道传输用户提供的缓冲区。在某些Windows版本或超过4GB RAM的系统上,可能需要64位寻址。PLX驱动会自动处理这种情况。函数使用SGL模式进行DMA传输,但对应用程序透明。流程包括驱动程序锁定用户模式缓冲区,创建SGL描述符,并在传输完成后执行清理任务。

Syntax:
 

PLX_STATUS
PlxPci_DmaTransferUserBuffer(
PLX_DEVICE_OBJECT *pDevice,
U8 channel,
PLX_DMA_PARAMS *pDmaParams,
U64 Timeout_ms
);


PLX Chip Support:
9054, 9056, 9080, 9656, 8311, & 8000 DMA
* On some versions of Windows (e.g. 2003 Server) or system with more than 4GB of RAM, the physical address
of some user mode buffer pages may require 64-bit addressing. If this is detected, the PLX driver will
automatically use features in the PLX chip to access these pages. For legacy PCI DMA chips, PCI dualaddressing is enabled. For newer PCI Express switch DMA, extended descriptors are used as needed. Dualaddressing is not supported on the PLX 9080 device; therefore, the API will return an error if 64-bit is required
with this device.
Description:

使用DMA通道传输用户提供的缓冲区。使用DMA信道的SGL模式,

但这对应用程序是透明的。

功能工作如下:

−PLX驱动程序获取所提供的用户模式缓冲区并将其页面锁定到内存中。

—缓冲区通常分散在非连续页中的整个内存中。因此,驾驶员

然后确定缓冲区内存每页的物理地址,并创建一个SGL

每个页面的描述符。描述符被放置到内部驱动程序分配的缓冲区中。

−DMA信道被编程为从第一个描述符开始。

−DMA传输完成后,将发生中断,然后驱动程序将执行所有清理任务。

Transfers a user-supplied buffer using the DMA channel. SGL mode of the DMA channel is used, but this is
transparent to the application. The function works as follows:
- The PLX driver takes the provided user-mode buffer and page-locks it into memory.
- The buffer is typically scattered throughout memory in non-contiguous pages. As a result, the driver
then determines the physical address of each page of memory of the buffer and creates an SGL
descriptor for each page. The descriptors are placed into an internal driver allocated buffer.
- The DMA channel is programmed to start at the first descriptor.
- After DMA transfer completion, an interrupt will occur and the driver will then perform all cleanup tasks.
Parameters:
pDevice
Pointer to an open device
channel
The open DMA channel number to use for the transfer
pDmaParams
A pointer to a structure containing the DMA transfer parameters
Timeout_ms
Specifies the timeout, in milliseconds, for the function to wait for DMA completion.
If 0, the API returns immediately after starting the DMA transfer and does not wait for its completion.
To have the function wait indefinitely for DMA completion, use the value PLX_TIMEOUT_INFINITE.
5-39
Return Codes:

CodeDescription
ApiSuccessThe function returned successfully
ApiNullParamOne or more parameters is NULL
ApiInvalidDeviceInfoThe device object is not valid
ApiPowerDownThe PLX device is in a power state that is lower than required for this function
ApiDmaChannelInvalidThe DMA channel is not supported by the PLX chip
ApiDmaChannelUnavailableThe DMA channel was not previously opened by the caller
ApiDmaInProgressThe DMA transfer is currently in-progress
ApiWaitTimeoutNo interrupt was received to signal DMA completion
ApiDmaSglPagesGetErrorThe driver was unable to obtain the page list for the user- mode buffer
ApiDmaSglPagesLockErrorThe driver was unable to page lock the user-mode buffer
ApiInsufficientResourcesThe driver was unable to allocate an internal buffer to store SGL descriptors
ApiDeviceInUseThe DMA channel is open but owned by another calling thread or process

Notes:
The driver will always enable the DMA channel interrupt when this function is used. This is required so the
driver can perform cleanup routines, such as unlock the buffer and release descriptors, after the transfer has
completed.
The PLX_DMA_PARAMS structure contains members whose meanings may differ or even be ignored
depending on the DMA transfer type selected by the calling function.
PLX_DMA_PARAMS:

Structure ElementDescription
UserVaVirtual address of the user-mode buffer to transfer
AddrSourceIgnored
AddrDestIgnored
PciAddr(9000 DMA) Ignored
(8000 DMA) Specifies the PCI address to transfer to/from, depending upon Direction
LocalAddr(9000 DMA) The Local address for the transfer
ByteCountThe number of bytes to transfer
DirectionDirection of the transfer. Refer to PLX_DMA_DIR
bConstAddrSrc(8000 DMA) Keeps the source address constant
bConstAddrDest(8000 DMA) Keeps the destination address constant
bForceFlush(8000 DMA) DMA engine will issue a Zero-length TLP to flush final writes.
bIgnoreBlockIntIgnored. PLX driver always enables DMA done interrupt to cleanup SGL

Usage:

U8 *pBuffer;
PLX_DMA_PARAMS DmaParams;
// Allocate a 500k buffer
pBuffer = malloc(500 * 1024);
// Clear DMA parameters
memset( DmaParams, 0, sizeof(PLX_DMA_PARAMS) );
// Setup DMA parameters (9000 DMA)
DmaParams.UserVa = (PLX_UINT_PTR)pBuffer;
DmaParams.ByteCount = (500 * 1024);
if (pDevObj->Key.PlxChipFamily == PLX_FAMILY_BRIDGE_P2L)
{
// 9000/8311 DMA
DmaParams.LocalAddr = 0x0;
DmaParams.Direction = PLX_DMA_LOC_TO_PCI;
}
else
{
// 8000 DMA
DmaParams.PciAddr = 0x1F000000;
DmaParams.Direction = PLX_DMA_PCI_TO_USER;
}
rc =
PlxPci_DmaTransferUserBuffer(
pDevice,
0, // Channel 0
&DmaParams, // DMA transfer parameters
(3 * 1000) // Specify time to wait for DMA completion
);
if (rc != ApiSuccess)
{
if (rc == ApiWaitTimeout)
// Timed out waiting for DMA completion
else
// ERROR - Unable to perform DMA transfer
}

 

PCI8系列 PCI9系列 PCI9054 linux驱动程序 PLX SDK Samples ================================================================ ABOUT This document provides a brief description of the samples included in the PLX SDK. Please refer to the source code in each sample & the PLX SDK User's Manual for additional details. The PLX samples are intended to demonstrate use of the PLX API. The samples are not intended for debug or real world applications, although they can be extended to complex applications. They should be treated as a reference for writing custom software that utilizes the PLX API. Not all samples work with all PLX devices. The PLX API supports numerous PLX chip families in PCI/PCIe, including 6000-series PCI-to-PCI bridges, 9000-series PCI-to-Local bus bridges, & 8000-series PCI/PCIe bridges & switches. Some samples are provided only for specific chip families. SAMPLES - ApiTest Simple application that calls various PLX APIs for a selected device & verifies return codes & parameters. The API calls made depend upon the type of device selected. - DSlave Demonstrates how to read/write from a PLX 9000 PCI BAR space using the PLX API/driver to perform the data transer. This operation is often referred to as "Direct Slave". - DSlave_BypassApi Similar to the 'DSlave' sample, except this sample uses the PLX API only to map a PCI BAR space directly to the application's virtual space. The application can then directly access the space via simple memory dereferencing, bypassing the PLX API/driver & resulting in greater performance, especially for small transfers. The application is responsible for initializing the BAR space, such as setup of translation/remap registers. - LocalToPciInt [9000-series & 8311] Demonstrates how to wait for a generic Local-to-PCI interrupt using the PLX Notification API. - NT_DmaTest [8000-series switches with DMA & NT support] Demonstrates using the DMA engine in a PLX 8000 switch to transfer data through a PLX
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值