From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org, corbet@lwn.net,
vladimir.oltean@nxp.com, willemb@google.com,
sdf.kernel@gmail.com, ecree.xilinx@gmail.com,
jesse.brandeburg@intel.com, linux-doc@vger.kernel.org,
Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 04/10] docs: net: update devmem code examples
Date: Tue, 26 May 2026 09:01:45 -0700 [thread overview]
Message-ID: <20260526160151.2793354-5-kuba@kernel.org> (raw)
In-Reply-To: <20260526160151.2793354-1-kuba@kernel.org>
Update the code examples
- update the YNL sample with the latest(?) APIs
- struct dmabuf_tx_cmsg does not exist, use __u32 directly
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
Documentation/networking/devmem.rst | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/Documentation/networking/devmem.rst b/Documentation/networking/devmem.rst
index a6cd7236bfbd..6a3f3c2ac19c 100644
--- a/Documentation/networking/devmem.rst
+++ b/Documentation/networking/devmem.rst
@@ -103,24 +103,22 @@ The user must bind a dmabuf to any number of RX queues on a given NIC using
the netlink API::
/* Bind dmabuf to NIC RX queue 15 */
- struct netdev_queue *queues;
- queues = malloc(sizeof(*queues) * 1);
+ struct netdev_queue_id *queues;
- queues[0]._present.type = 1;
- queues[0]._present.idx = 1;
- queues[0].type = NETDEV_RX_QUEUE_TYPE_RX;
- queues[0].idx = 15;
+ queues = netdev_queue_id_alloc(1);
+ netdev_queue_id_set_type(&queues[0], NETDEV_QUEUE_TYPE_RX);
+ netdev_queue_id_set_id(&queues[0], 15);
*ys = ynl_sock_create(&ynl_netdev_family, &yerr);
req = netdev_bind_rx_req_alloc();
netdev_bind_rx_req_set_ifindex(req, 1 /* ifindex */);
- netdev_bind_rx_req_set_dmabuf_fd(req, dmabuf_fd);
- __netdev_bind_rx_req_set_queues(req, queues, n_queue_index);
+ netdev_bind_rx_req_set_fd(req, dmabuf_fd);
+ __netdev_bind_rx_req_set_queues(req, queues, 1);
rsp = netdev_bind_rx(*ys, req);
- dmabuf_id = rsp->dmabuf_id;
+ dmabuf_id = rsp->id;
The netlink API returns a dmabuf_id: a unique ID that refers to this dmabuf
@@ -302,13 +300,12 @@ The user should create a msghdr where,
* iov_base is set to the offset into the dmabuf to start sending from
* iov_len is set to the number of bytes to be sent from the dmabuf
-The user passes the dma-buf id to send from via the dmabuf_tx_cmsg.dmabuf_id.
+The user passes the dma-buf id to send from as a u32 cmsg payload.
The example below sends 1024 bytes from offset 100 into the dmabuf, and 2048
from offset 2000 into the dmabuf. The dmabuf to send from is tx_dmabuf_id::
- char ctrl_data[CMSG_SPACE(sizeof(struct dmabuf_tx_cmsg))];
- struct dmabuf_tx_cmsg ddmabuf;
+ char ctrl_data[CMSG_SPACE(sizeof(__u32))];
struct msghdr msg = {};
struct cmsghdr *cmsg;
struct iovec iov[2];
@@ -327,11 +324,9 @@ The example below sends 1024 bytes from offset 100 into the dmabuf, and 2048
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_DEVMEM_DMABUF;
- cmsg->cmsg_len = CMSG_LEN(sizeof(struct dmabuf_tx_cmsg));
+ cmsg->cmsg_len = CMSG_LEN(sizeof(__u32));
- ddmabuf.dmabuf_id = tx_dmabuf_id;
-
- *((struct dmabuf_tx_cmsg *)CMSG_DATA(cmsg)) = ddmabuf;
+ *((__u32 *)CMSG_DATA(cmsg)) = tx_dmabuf_id;
sendmsg(socket_fd, &msg, MSG_ZEROCOPY);
--
2.54.0
next prev parent reply other threads:[~2026-05-26 16:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 16:01 [PATCH net-next 00/10] docs: net: updates for old and cobwebbed docs Jakub Kicinski
2026-05-26 16:01 ` [PATCH net-next 01/10] docs: net: netdevices: small fixes and clarifications Jakub Kicinski
2026-05-26 22:12 ` Stanislav Fomichev
2026-05-26 16:01 ` [PATCH net-next 02/10] docs: net: fix minor issues with driver guide Jakub Kicinski
2026-05-26 16:01 ` [PATCH net-next 03/10] docs: net: statistics: fix kernel-internal stats list Jakub Kicinski
2026-05-26 16:01 ` Jakub Kicinski [this message]
2026-05-26 22:17 ` [PATCH net-next 04/10] docs: net: update devmem code examples Stanislav Fomichev
2026-05-26 16:01 ` [PATCH net-next 05/10] docs: net: fix minor issues with the NAPI guide Jakub Kicinski
2026-05-26 16:01 ` [PATCH net-next 06/10] docs: net: refresh netdev feature guidance Jakub Kicinski
2026-05-26 18:41 ` Maxime Chevallier
2026-05-26 22:35 ` Jakub Kicinski
2026-05-27 7:53 ` Maxime Chevallier
2026-05-26 16:01 ` [PATCH net-next 07/10] docs: net: fix minor issues with checksum offloads Jakub Kicinski
2026-05-26 16:01 ` [PATCH net-next 08/10] docs: net: add Rx notes to the checksum guide Jakub Kicinski
2026-05-26 18:56 ` Willem de Bruijn
2026-05-26 16:01 ` [PATCH net-next 09/10] docs: net: render the checksum comment in checksum-offloads.rst Jakub Kicinski
2026-05-26 18:56 ` Willem de Bruijn
2026-05-26 16:01 ` [PATCH net-next 10/10] docs: net: fix minor issues with segmentation offloads Jakub Kicinski
2026-05-26 18:48 ` [PATCH net-next 00/10] docs: net: updates for old and cobwebbed docs Randy Dunlap
2026-05-26 22:37 ` Jakub Kicinski
2026-05-26 22:40 ` Jakub Kicinski
2026-05-27 0:51 ` Randy Dunlap
2026-05-27 1:15 ` Jakub Kicinski
2026-05-27 2:39 ` Randy Dunlap
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=20260526160151.2793354-5-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jesse.brandeburg@intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf.kernel@gmail.com \
--cc=vladimir.oltean@nxp.com \
--cc=willemb@google.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