In Linux sk_buff, is skb->data a physical or virtual address?
I am investigating some memory corruption issues in the Ethernet driver for embedded systems.
I suspect there is a problem between the bus master DMA Controller and the slow SDRAM. So I want to use a bounce buffer in fast SRAM. To do this, I need to do two things: I have to put the physical address of SRAM (from a bus master’s point of view) into the DMA Controller buffer descriptor, and I have to report incoming packets in the DMA Controller.
I can’t be sure by reading
Is skb->data a physical address or a virtual address. i.e. I should call
memcpy(skb->data, phys_to_virt(bounce_addr), len);
or
memcpy(phys_to_virt(skb->data), phys_to_virt(bounce_addr), len);
Put the packet into sk_buff so that the rest of the Linux networking stack can process it?
Edit: This is the driver in I would say it’s passing the virtual address into the DMA Controller register, so it doesn’t work, but I have a dev kit that can run this code. However, my SDRAM is not as timings as devkit DDR SDRAM, so I’m considering implementing a bounce buffer.
Solution
It is virtual. Basically, any type of foo *
in the kernel will be
Virtual addresses, in fact, you would deal very, very, very little with physical addresses
Addresses outside of low-level memory management – you either have virtual
Address, or struct page
, you need to get the virtual address through kmap
.