Re: [RFC PATCH net-next V2 6/6] virtio-net: support XDP rx handler

From: Jason Wang
Date: Tue Aug 14 2018 - 09:28:39 EST

On 2018å08æ14æ 17:22, Jesper Dangaard Brouer wrote:
On Mon, 13 Aug 2018 11:17:30 +0800
Jason Wang<jasowang@xxxxxxxxxx> wrote:

This patch tries to add the support of XDP rx handler to
virtio-net. This is straight-forward, just call xdp_do_pass() and
behave depends on its return value.

Test was done by using XDP_DROP (xdp1) for macvlan on top of
virtio-net. PPS of SKB mode was ~1.2Mpps while PPS of native XDP mode
was ~2.2Mpps. About 83% improvement was measured.
I'm not convinced...

Why are you not using XDP_REDIRECT, which is already implemented in
receive_mergeable (which you modify below).

The macvlan driver just need to implement ndo_xdp_xmit(), and then you
can redirect (with XDP prog from physical driver into the guest). It
should be much faster...

Macvlan is different from macvtap. For host RX, macvtap deliver the packet to a pointer ring which could be accessed through a socket but macvlan deliver the packet to the normal networking stack. As an example of XDP rx handler, this series just try to make native XDP works for macvlan, macvtap path will still go for skb (but it's not hard to add it on top).

Consider the case of fast forwarding between host and guest. For TAP, XDP_REDIRECT works perfectly since from the host point of view, host RX is guest TX and host guest RX is host TX. But for macvtap which is based on macvlan, transmitting packet to macvtap/macvlan means transmitting packets to under layer device which is either a physical NIC or another macvlan device. That's why we can't use XDP_REDIRECT with ndo_xdp_xmit().