Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, Mapping the skb data to dma sometimes includes a bounce buffer (if the skb is out of the dma area) My dma bitmask is unusual, and so I'm getting ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2014
    Posts
    6

    network device driver - copy skb data to dma region


    Hi,

    Mapping the skb data to dma sometimes includes a bounce buffer (if the skb is out of the dma area)
    My dma bitmask is unusual, and so I'm getting a lot of those bounce buffers.
    My question is -
    Is there a way to make sure that the skb is allocated in my dma region before I get it in the xmit function? This way I can keep the zero-copy in the tx, and avoid the bounce buffer at the same time.
    Only 2 options I came up with are:
    1. map the skb data (--> bounce buffer)
    2. memcpy the skb data and then map it (no more zero-copy)

    Thanks!
    Roy

  2. #2
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,305
    I'm not entirely sure I understand the question and I apologize if this off base. The data is being mapped to a bounce buffer because it is outside of the devices range so it seems to me any remapping isn't going to work without causing cache coherency problems? I might be way off base.

    If the goal is to reduce the overhead of the bounce buffers have you looked at scatterlists?

  3. #3
    Just Joined!
    Join Date
    May 2014
    Posts
    6
    Hi,

    Yes, you've got it right... That's exactly what I want: to avoid the overhead of using bounce buffers. The xmit function already receives an skb from the linux network stack, and this skb might be located outside of my device's range, so mapping the incoming packet means that either I'm going through a bounce buffer or I'm allocating my own buffers and memcpy the received skb into it. I would like to avoid both. My question was is there some way of making sure that the skb I get as an argument in my xmit function is already in my device's area? some way of telling the kernel that before it packs the incoming packet into the skb for me, it needs to check my dma mask?
    Haven't thought about scatterlists, I'm not sure I understand how they could fit in here

  4. #4
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,305
    The skb is mapped to a bounce because the kernel checks your mask and determines the devices can't access the skb without the bounce buffer, so I think what you're asking doesn't make sense.

    My understanding is, if the device accepts scatterlists then instead of creating a lot of smaller bounce buffers it will amalgamate them into larger buffers, reducing the overhead.

  5. #5
    Just Joined!
    Join Date
    May 2014
    Posts
    6
    No s\g in my device (yet).
    What I want to accomplish is avoiding the bounce buffer on an incoming packet (again - no s\g io, packet is made up of only one skb).
    I thought that maybe I might achieve it by somehow asking the kernel that once a packet arrives, and it comes to the conclusion that its destined to my device, before copying it into an skb, first check my device's dma mask, and then create an skb which corresponds to this mask, and only then hand it over to me.
    From your previous replies I guess that the the answer is no, correct?

  6. #6
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,305
    DMA is a shared resource and I suspect the answer is that the kernel wouldn't use a bounce buffer if it didn't need to.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •