All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Djimeli <kdjimeli@igalia.com>
To: "Björn Töpel" <bjorn.topel@gmail.com>
Cc: xdp-newbies@vger.kernel.org
Subject: Re: AF_XDP socket (sock2) unable to read, after writing with another AF_XDP socket (sock1)
Date: Mon, 26 Nov 2018 17:04:55 +0100	[thread overview]
Message-ID: <9048f6bb806c304588e89aba8456fc22@igalia.com> (raw)
In-Reply-To: <CAJ+HfNhdtpqQHPq8=DTtwduL-g6SQT01JZsEWmCQQeLUhXRh8w@mail.gmail.com>

Hello Björn,

On 2018-11-10 15:31, Björn Töpel wrote:
> Den tors 8 nov. 2018 kl 16:15 skrev Konrad Djimeli <kdjimeli@igalia.com>:
>>
> [...]
>> > In terms of correctness:
>> >
>> > In 3. you pass the same UMEM indicies to the Tx ring (ids={0,
>> > FRAME_SIZE, 2*FRAME_SIZE, ...}), as you have passed to the fill
>> > ring. This is not correct. Userspace to track what ids are owned by
>> > the user and by the kernel. Now, both the fill ring and Tx ring
>> > contain the same id.
>> Please I have been looking into this for some days now, but I have not
>> been able to understand what you where referring to and how to fix it.
>>
> 
> Ok, let's talk about the basics, and hopefully it will clear up. The
> indicies/ids into the UMEM are used to point out packet buffers.
> 
> The Rx/Tx/Completion/Fill rings are used to pass ownership between the
> kernel and the user application. E.g. if fill id X with data and pass
> that to the kernel for transmission, the application has passed
> ownership of buffer X to the kernel. The application cannot (well,
> shouldn't) touch the buffer pointed out by X until the kernel is done
> with the buffer -- in other words, when the buffer is passed back to
> the application via the completion ring. Analogous, when you pass id Y
> to the fill ring, Y is owned by the kernel. The application cannot
> (again, shouldn't) touch the data pointed out by Y until ownership is
> passed back to the application via the Rx ring.
> 
> What you did in your old code (I haven't looked at your updates!) is
> that you passed X, Y and Z to the fill ring. And then, prior obtaining
> ownership of the buffers, you passed X, Y and Z to the Tx ring.
> 

Sorry for the delayed response, I took some time off from the work I was
doing. Thanks a lot for the detailed explanation and I think I have been

able to identify the issue you were pointing out.

What I have done to address the problem is, since the location passed to

the fill ring are  {0, 2*FRAME_SIZE, 3*FRAME_SIZE, … , 
(NUM_DESCS-1)*FRAME_SIZE}, I updated the ids passed to the tx ring to 
{NUM_DESCS*FRAME_SIZE,  (NUM_DESCS+1)*FRAME_SIZE,
(NUM_DESCS+2)*FRAME_SIZE, … , 
(NUM_FRAMES-1)*FRAME_SIZE} [0].

The link below points to the commit addressing the issue. I hope I have
not
still gotten things mixedup. 

[0]
https://github.com/djkonro/afxdp/commit/c199b496ac6949771fc02260165f4822ccd2f51a#diff-e1b95b7ab6213d7c19f2eacc1290f955

Thanks,
Konrad

>> I also updated the xdp program bpf_redirect_map index to write to the
>> second socket (sock2) but I can not observe the reading working when I
>> use any other networking interface except for the 'lo' interface. I
>> would like to inquire if it may have something to do with the code.
>> - https://github.com/djkonro/afxdp/blob/master/xdpsock/xdpsock_kern.c
>> - https://github.com/djkonro/afxdp/blob/master/xdpsock/xdpsock_user.c
>>
> 
> If you rely on that all sent packets out to a certain interface should
> be hairpinned back to same interface, you need to set that up in your
> switching plane. Or continue to use the loopback interface as you
> do(?).
> 
> 
> Björn
> 
> 
>> Thanks
>> Konrad
>>
>> >
>> > I'm not sure what the expected output of your program should be? Have
>> > you verified that packets are being sent? Is the inferface/queue 0
>> > receiving packets?
>> >
>> > I think it would help if you explained what you are trying to do
>> > first!
>> >
>> > What XDP program are you running?
>> >
>> >
>> > Cheers,
>> > Björn
>> >
>> >
>> >
>> > *
>> >
>> >> Thanks,
>> >> Konrad
>> >> www.djimeli.me

      parent reply	other threads:[~2018-11-27  2:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01 16:52 AF_XDP socket (sock2) unable to read, after writing with another AF_XDP socket (sock1) Konrad Djimeli
2018-11-01 18:27 ` Marius Gerling
2018-11-02 15:30   ` Konrad Djimeli
2018-11-01 18:49 ` Björn Töpel
2018-11-02 16:08   ` Konrad Djimeli
2018-11-03  8:38     ` Björn Töpel
2018-11-08 15:15   ` Konrad Djimeli
2018-11-10 14:31     ` Björn Töpel
2018-11-10 14:58       ` William Tu
2018-11-26 16:03         ` Konrad Djimeli
2018-11-26 16:04       ` Konrad Djimeli [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9048f6bb806c304588e89aba8456fc22@igalia.com \
    --to=kdjimeli@igalia.com \
    --cc=bjorn.topel@gmail.com \
    --cc=xdp-newbies@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.