On 3/18/07, Tao Chen <[EMAIL PROTECTED]> wrote:
My PCI Network Interface Card(NIC) is 32 Little Endian. Host needs to tell it the addresses of packet send/receive buffer. I am wondering how to set up the [b]ddi_device_acc_attr[/b] (data access attributes structure) correctly which is critical for [i]ddi_dma_mem_alloc[/i] function to work correctly. >From the man page of ddi_device_acc_attr, it looks like for send buffer, devacc_attr_endian_flags must be DDI_STRUCTURE_LE_ACC, because the reader is PCi card which is Little Endian(LE). But how about receive buffer which can be LE or BE? Also, when I write packet data to send buffer, do i need to do some swapping manually? how about when reading from receive buffer, do i also need swapping? Can somebody kindly shed some light on the endianness issue that confuse many newbies?
You should never be endian swapping data; after all, it's data, how do you know what it is? So use a NEVERSWAP mapping for data. The LE_ACC and BE_ACC flags are for mapped control information. E.g. say your h/w DMAs a 'buffer descriptor' which it parses to locate the actual data buffer. If the NIC is LE then clearly descriptor information needs to be written LE. So, if you're on a BE CPU clearly you can't just write the descriptor information without swapping. The DDI takes care of this for you if you use ddi_getX and ddi_putX primitives to access memory allocated using ddi_dma_mem_alloc() with the LE flag. Paul -- Paul Durrant http://www.linkedin.com/in/pdurrant _______________________________________________ networking-discuss mailing list [email protected]
