From: William Tu <u9012063@gmail.com>
To: bjorn.topel@gmail.com, magnus.karlsson@gmail.com, ast@kernel.org,
daniel@iogearbox.net, netdev@vger.kernel.org,
makita.toshiaki@lab.ntt.co.jp, yihung.wei@gmail.com,
magnus.karlsson@intel.com
Subject: [PATCH bpf-next RFCv3 3/6] xsk: add new MEM type for virtual device.
Date: Wed, 26 Dec 2018 12:27:50 -0800 [thread overview]
Message-ID: <1545856073-8680-4-git-send-email-u9012063@gmail.com> (raw)
In-Reply-To: <1545856073-8680-1-git-send-email-u9012063@gmail.com>
Add MEM_TYPE_ZERO_COPY_VDEV for supporting the veth AF_XDP.
For zero-copy veth, the memory comes from userspace and does
not need to be freed at kernel. Thus, when xdp returns the
frame, detecting this type and doing nothing.
Signed-off-by: William Tu <u9012063@gmail.com>
---
include/net/xdp.h | 1 +
net/core/xdp.c | 1 +
net/xdp/xsk.c | 3 ++-
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/net/xdp.h b/include/net/xdp.h
index 0f25b3675c5c..010cb9efca90 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -38,6 +38,7 @@ enum xdp_mem_type {
MEM_TYPE_PAGE_ORDER0, /* Orig XDP full page model */
MEM_TYPE_PAGE_POOL,
MEM_TYPE_ZERO_COPY,
+ MEM_TYPE_ZERO_COPY_VDEV,
MEM_TYPE_MAX,
};
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 4b2b194f4f1f..d47f003714c4 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -355,6 +355,7 @@ static void __xdp_return(void *data, struct xdp_mem_info *mem, bool napi_direct,
xa = rhashtable_lookup(mem_id_ht, &mem->id, mem_id_rht_params);
xa->zc_alloc->free(xa->zc_alloc, handle);
rcu_read_unlock();
+ case MEM_TYPE_ZERO_COPY_VDEV:
default:
/* Not possible, checked in xdp_rxq_info_reg_mem_model() */
break;
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 0e252047f55f..3d151d64fc79 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -109,7 +109,8 @@ int xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
len = xdp->data_end - xdp->data;
- return (xdp->rxq->mem.type == MEM_TYPE_ZERO_COPY) ?
+ return (xdp->rxq->mem.type == MEM_TYPE_ZERO_COPY ||
+ xdp->rxq->mem.type == MEM_TYPE_ZERO_COPY_VDEV) ?
__xsk_rcv_zc(xs, xdp, len) : __xsk_rcv(xs, xdp, len);
}
--
2.7.4
next prev parent reply other threads:[~2018-12-26 20:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-26 20:27 [PATCH bpf-next RFCv3 0/6] AF_XDP support for veth William Tu
2018-12-26 20:27 ` [PATCH bpf-next RFCv3 1/6] xsk: add xsk_umem_consume_tx_virtual William Tu
2018-12-26 20:27 ` [PATCH bpf-next RFCv3 2/6] veth: support AF_XDP TX copy-mode William Tu
2019-01-01 13:44 ` Toshiaki Makita
2019-01-05 15:55 ` William Tu
2019-01-08 7:25 ` Toshiaki Makita
2018-12-26 20:27 ` William Tu [this message]
2018-12-26 20:27 ` [PATCH bpf-next RFCv3 4/6] veth: add zero-copy AF_XDP TX support William Tu
2018-12-26 20:27 ` [PATCH bpf-next RFCv3 5/6] veth: add AF_XDP RX support William Tu
2018-12-26 20:27 ` [PATCH bpf-next RFCv3 6/6] samples: bpf: add veth AF_XDP example William Tu
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=1545856073-8680-4-git-send-email-u9012063@gmail.com \
--to=u9012063@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@gmail.com \
--cc=daniel@iogearbox.net \
--cc=magnus.karlsson@gmail.com \
--cc=magnus.karlsson@intel.com \
--cc=makita.toshiaki@lab.ntt.co.jp \
--cc=netdev@vger.kernel.org \
--cc=yihung.wei@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).