1 Reply Latest reply on May 8, 2019 10:53 PM by KandlaguntaR_36

    large dma packets

    EtWh_2921621

      I'm using a CX3 chip, and I want to transfer 4K bufffers from the CX3 to the PC, in response to a command from the PC. I have opened up two bulk channels, one to receive, one to send, and have set up the dma channels...The dma channel's max buffer size is 1024.

       

      On the CX3 send side, I can't figure out if I'm supposed to ask for one giant 4K-sized buffer in DmaChannelGetBuffer (and send 1 buffer), or if I need to ask for a 1024 buffer 4 times, and send 4 times. If I send 4 times, do I need the PC-side code to ask me for each buffer individually? Or do I just send 4 times? Basically, what I'm really asking is "how do I send large buffers across a 1024-max-sized DMA channel, who packages and unpackages the large buffers, and how do I set up the DMA channel parameters to allow this?" One of the things I don't understand is the dmabuffer's "status" flag. When to set the EOP and when not to set it. Another thing I don't understand (that is documented poorly) is DmaChannelConfig's "count" and "prodAvailCount", and the "burst mode" parameter provided in the descriptor structure. What if the burst mode is 1? What if it's 15?

       

      On the PC side, I can't figure out how to do "big reads" so that if the CX3 on the send side, sent a big buffer, how to auto-collect those mini packets, reassemble them, and receive only 1 big one on the PC side. Is the DMA gather code in the PC's kernel supposed to do that for me, or do I have to write that code myself?

        • 1. Re: large dma packets
          KandlaguntaR_36

          DMA confiuration:

           

          Typically, you need to provide the DMA buffer size and count; producer socket and consumer socket to create a DMA channel.

           

          The size and count depends on the amount of data that the producer is putting into buffers.

           

          Say, you are streaming a video, which needs larger buffer and maximum possible count.

          Say you are streaming data from a I2C slave, which needs small buffers and minimal count is fine.

           

          Note that the DMA buffer is committed automatically, if the buffer is full (Consider AUTO DMA Channel). Refer Chapter 5 in FX3_TRM.

          Partailly filled buffers do not commit automatically, so we need to wrapup partially filled buffer manually.

           

          But if the producer is USB: (Bulk OUT - PC is sending data to device)

           

          The buffers will be committed: 1. Full buffer 2. Zero packet received 3. Short packet received (i.e. size of packet is less than end point size (1024 bytes in USB 3.0 and 512 bytes in USB 2.0)).

           

          prodAvailCount:

          Minimum available empty buffers before producer is active. By default, this should be zero. A non-zero value will activate this feature. The producer socket will not receive data into memory until the specified number of free buffers are available. This feature should be used only for very specific use cases where there is a requirement that there should always be free buffers during the transfer

           

          Burst Mode:

           

          In USB protocol, device or host will send the next data packet, once it receives the acknowledgement for previously sent packet (not applies to Isochronous transfers).

           

          In USB Superspeed Spec., they introduced Burst Mode. i.e. host or device can send the number data packets set in burst mode instead waiting for the acknowledgement of previous packet. This improves the throughput.

           

          Say burst mode is set to 15. The device can send maximum 15 packets without looking for acknowledgement for previously sent packets.

           

          If the burst mode is set to 0, the device can send the next data packet only after receiving the acknowledgement for previously sent packet.

           

          Bulk-IN request:

           

          On the PC side, you may ask for 4K chunk or 4 1K chunks.

           

          The device can send 1K packet at a time, irrespective of what is the amount of data is present in the buffer.

           

          -- Say you have created a DMA channel with 8 1K buffer size (count - 8; size - 1K).

           

                    On the host side,

           

                          1. You are requesting for 4K (Xferdata).

                              The host waits untill it receives 4K  ((if the timeout for Xferdata is set to infinite) or a partial packet or zero length packet

                          2. You are requesting for 4 1K Xferdata. Here the host waits untill it receives 1K buffer received or partial packet or zero length packet is recieved.

                              Since you need to receive 4 1K buffers, you need  to call Xferdata with 1K size four times.

           

          --  Say you have created a DMA channel with 2 4K buffer size (count - 8; size - 1K).

           

                        On the host side,

           

                          1. You are requesting for 4K (Xferdata).

                              The host waits untill it receives 4K  ((if the timeout for Xferdata is set to infinite) or a partial packet or zero length packet

                          

                          2. You are requesting for 4 1K Xferdata. Here the host waits untill it receives 1K buffer received or partial packet or zero length packet is recieved.

                              Since you need to receive 4 1K buffers, you need to call Xferdata with 1K size four times.

           

                           In the above two cases,

                            Say the 4K buffer of device is half full (2K bytes). Since the 4K is not full, even though you request  for data on the host, the device can not send it.

                            Because the buffer will get committed untill it is full or we need to forcefully commit it.

           

          Xferdata is the API used in the host application to send or receive data to/from the device. Refer USBSuite in the FX3 SDK : C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\doc\SuiteUSB

           

          FX3 SDK documentation is available in this path: C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\doc