From: Maxim Mikityanskiy <maximmi@mellanox.com>
To: "Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Björn Töpel" <bjorn.topel@intel.com>,
"Magnus Karlsson" <magnus.karlsson@intel.com>
Cc: "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Saeed Mahameed <saeedm@mellanox.com>, Jonathan Lemon <bsd@fb.com>,
Tariq Toukan <tariqt@mellanox.com>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
Jakub Kicinski <jakub.kicinski@netronome.com>,
Maciej Fijalkowski <maciejromanfijalkowski@gmail.com>,
Maxim Mikityanskiy <maximmi@mellanox.com>
Subject: [PATCH bpf-next v5 03/16] xsk: Add getsockopt XDP_OPTIONS
Date: Tue, 18 Jun 2019 12:00:45 +0000 [thread overview]
Message-ID: <20190618120024.16788-4-maximmi@mellanox.com> (raw)
In-Reply-To: <20190618120024.16788-1-maximmi@mellanox.com>
Make it possible for the application to determine whether the AF_XDP
socket is running in zero-copy mode. To achieve this, add a new
getsockopt option XDP_OPTIONS that returns flags. The only flag
supported for now is the zero-copy mode indicator.
Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Acked-by: Saeed Mahameed <saeedm@mellanox.com>
Acked-by: Björn Töpel <bjorn.topel@intel.com>
---
include/uapi/linux/if_xdp.h | 8 ++++++++
net/xdp/xsk.c | 20 ++++++++++++++++++++
tools/include/uapi/linux/if_xdp.h | 8 ++++++++
3 files changed, 36 insertions(+)
diff --git a/include/uapi/linux/if_xdp.h b/include/uapi/linux/if_xdp.h
index caed8b1614ff..faaa5ca2a117 100644
--- a/include/uapi/linux/if_xdp.h
+++ b/include/uapi/linux/if_xdp.h
@@ -46,6 +46,7 @@ struct xdp_mmap_offsets {
#define XDP_UMEM_FILL_RING 5
#define XDP_UMEM_COMPLETION_RING 6
#define XDP_STATISTICS 7
+#define XDP_OPTIONS 8
struct xdp_umem_reg {
__u64 addr; /* Start of packet data area */
@@ -60,6 +61,13 @@ struct xdp_statistics {
__u64 tx_invalid_descs; /* Dropped due to invalid descriptor */
};
+struct xdp_options {
+ __u32 flags;
+};
+
+/* Flags for the flags field of struct xdp_options */
+#define XDP_OPTIONS_ZEROCOPY (1 << 0)
+
/* Pgoff for mmaping the rings */
#define XDP_PGOFF_RX_RING 0
#define XDP_PGOFF_TX_RING 0x80000000
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index b68a380f50b3..35ca531ac74e 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -650,6 +650,26 @@ static int xsk_getsockopt(struct socket *sock, int level, int optname,
return 0;
}
+ case XDP_OPTIONS:
+ {
+ struct xdp_options opts = {};
+
+ if (len < sizeof(opts))
+ return -EINVAL;
+
+ mutex_lock(&xs->mutex);
+ if (xs->zc)
+ opts.flags |= XDP_OPTIONS_ZEROCOPY;
+ mutex_unlock(&xs->mutex);
+
+ len = sizeof(opts);
+ if (copy_to_user(optval, &opts, len))
+ return -EFAULT;
+ if (put_user(len, optlen))
+ return -EFAULT;
+
+ return 0;
+ }
default:
break;
}
diff --git a/tools/include/uapi/linux/if_xdp.h b/tools/include/uapi/linux/if_xdp.h
index caed8b1614ff..faaa5ca2a117 100644
--- a/tools/include/uapi/linux/if_xdp.h
+++ b/tools/include/uapi/linux/if_xdp.h
@@ -46,6 +46,7 @@ struct xdp_mmap_offsets {
#define XDP_UMEM_FILL_RING 5
#define XDP_UMEM_COMPLETION_RING 6
#define XDP_STATISTICS 7
+#define XDP_OPTIONS 8
struct xdp_umem_reg {
__u64 addr; /* Start of packet data area */
@@ -60,6 +61,13 @@ struct xdp_statistics {
__u64 tx_invalid_descs; /* Dropped due to invalid descriptor */
};
+struct xdp_options {
+ __u32 flags;
+};
+
+/* Flags for the flags field of struct xdp_options */
+#define XDP_OPTIONS_ZEROCOPY (1 << 0)
+
/* Pgoff for mmaping the rings */
#define XDP_PGOFF_RX_RING 0
#define XDP_PGOFF_TX_RING 0x80000000
--
2.19.1
next prev parent reply other threads:[~2019-06-18 12:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-18 12:00 [PATCH bpf-next v5 00/16] AF_XDP infrastructure improvements and mlx5e support Maxim Mikityanskiy
2019-06-18 12:00 ` [PATCH bpf-next v5 01/16] net/mlx5e: Attach/detach XDP program safely Maxim Mikityanskiy
2019-06-18 12:00 ` [PATCH bpf-next v5 02/16] xsk: Add API to check for available entries in FQ Maxim Mikityanskiy
2019-06-18 12:00 ` Maxim Mikityanskiy [this message]
2019-06-18 12:00 ` [PATCH bpf-next v5 04/16] libbpf: Support getsockopt XDP_OPTIONS Maxim Mikityanskiy
2019-06-18 12:00 ` [PATCH bpf-next v5 05/16] xsk: Change the default frame size to 4096 and allow controlling it Maxim Mikityanskiy
2019-06-18 12:00 ` [PATCH bpf-next v5 06/16] xsk: Return the whole xdp_desc from xsk_umem_consume_tx Maxim Mikityanskiy
2019-06-18 12:00 ` [PATCH bpf-next v5 07/16] net/mlx5e: Replace deprecated PCI_DMA_TODEVICE Maxim Mikityanskiy
2019-06-18 12:00 ` [PATCH bpf-next v5 08/16] net/mlx5e: Calculate linear RX frag size considering XSK Maxim Mikityanskiy
2019-06-18 12:00 ` [PATCH bpf-next v5 09/16] net/mlx5e: Allow ICO SQ to be used by multiple RQs Maxim Mikityanskiy
2019-06-18 12:00 ` [PATCH bpf-next v5 10/16] net/mlx5e: Refactor struct mlx5e_xdp_info Maxim Mikityanskiy
2019-06-18 12:01 ` [PATCH bpf-next v5 11/16] net/mlx5e: Share the XDP SQ for XDP_TX between RQs Maxim Mikityanskiy
2019-06-18 12:01 ` [PATCH bpf-next v5 12/16] net/mlx5e: XDP_TX from UMEM support Maxim Mikityanskiy
2019-06-18 12:01 ` [PATCH bpf-next v5 13/16] net/mlx5e: Consider XSK in XDP MTU limit calculation Maxim Mikityanskiy
2019-06-18 12:01 ` [PATCH bpf-next v5 14/16] net/mlx5e: Encapsulate open/close queues into a function Maxim Mikityanskiy
2019-06-18 12:01 ` [PATCH bpf-next v5 15/16] net/mlx5e: Move queue param structs to en/params.h Maxim Mikityanskiy
2019-06-18 12:01 ` [PATCH bpf-next v5 16/16] net/mlx5e: Add XSK zero-copy support Maxim Mikityanskiy
2019-06-20 9:13 ` [PATCH bpf-next v5 00/16] AF_XDP infrastructure improvements and mlx5e support Björn Töpel
2019-06-21 19:52 ` Saeed Mahameed
2019-06-23 11:53 ` Tariq Toukan
2019-06-24 14:48 ` Daniel Borkmann
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=20190618120024.16788-4-maximmi@mellanox.com \
--to=maximmi@mellanox.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@intel.com \
--cc=bpf@vger.kernel.org \
--cc=bsd@fb.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=jakub.kicinski@netronome.com \
--cc=kafai@fb.com \
--cc=maciejromanfijalkowski@gmail.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.com \
--cc=songliubraving@fb.com \
--cc=tariqt@mellanox.com \
--cc=yhs@fb.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).