public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Mina Almasry <almasrymina@google.com>
Cc: andrew+netdev@lunn.ch, asml.silence@gmail.com, axboe@kernel.dk,
	corbet@lwn.net, davem@davemloft.net, donald.hunter@gmail.com,
	dsahern@kernel.org, dw@davidwei.uk, edumazet@google.com,
	eperezma@redhat.com, horms@kernel.org, hramamurthy@google.com,
	io-uring@vger.kernel.org, jasowang@redhat.com,
	jeroendb@google.com, jhs@mojatatu.com, kaiyuanz@google.com,
	kuba@kernel.org, kuniyu@amazon.com, kvm@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, mst@redhat.com,
	ncardwell@google.com, netdev@vger.kernel.org, pabeni@redhat.com,
	pctammela@mojatatu.com, sdf@fomichev.me, sgarzare@redhat.com,
	shuah@kernel.org, skhawaja@google.com, stefanha@redhat.com,
	victor@mojatatu.com, virtualization@lists.linux.dev,
	willemb@google.com, xuanzhuo@linux.alibaba.com
Subject: Re: [PATCH net-next v12 4/9] net: devmem: Implement TX path
Date: Sat, 26 Apr 2025 17:12:58 +0200	[thread overview]
Message-ID: <fceb6891-2749-496a-a6d5-db0748728e8a@wanadoo.fr> (raw)
In-Reply-To: <20250425204743.617260-5-almasrymina@google.com>

Le 25/04/2025 à 22:47, Mina Almasry a écrit :
> Augment dmabuf binding to be able to handle TX. Additional to all the RX
> binding, we also create tx_vec needed for the TX path.
> 
> Provide API for sendmsg to be able to send dmabufs bound to this device:
> 
> - Provide a new dmabuf_tx_cmsg which includes the dmabuf to send from.
> - MSG_ZEROCOPY with SCM_DEVMEM_DMABUF cmsg indicates send from dma-buf.
> 
> Devmem is uncopyable, so piggyback off the existing MSG_ZEROCOPY
> implementation, while disabling instances where MSG_ZEROCOPY falls back
> to copying.

...

> @@ -270,24 +284,34 @@ net_devmem_bind_dmabuf(struct net_device *dev, unsigned int dmabuf_fd,
>   			niov->owner = &owner->area;
>   			page_pool_set_dma_addr_netmem(net_iov_to_netmem(niov),
>   						      net_devmem_get_dma_addr(niov));
> +			if (direction == DMA_TO_DEVICE)
> +				binding->tx_vec[owner->area.base_virtual / PAGE_SIZE + i] = niov;
>   		}
>   
>   		virtual += len;
>   	}
>   
> +	err = xa_alloc_cyclic(&net_devmem_dmabuf_bindings, &binding->id,
> +			      binding, xa_limit_32b, &id_alloc_next,
> +			      GFP_KERNEL);
> +	if (err < 0)
> +		goto err_free_id;
> +
>   	return binding;
>   
> +err_free_id:
> +	xa_erase(&net_devmem_dmabuf_bindings, binding->id);

Not sure this is correct now that xa_alloc_cyclic() is the last function 
which is called.
I guess that that the last goto should be to err_free_chunks.

>   err_free_chunks:
>   	gen_pool_for_each_chunk(binding->chunk_pool,
>   				net_devmem_dmabuf_free_chunk_owner, NULL);
>   	gen_pool_destroy(binding->chunk_pool);
> +err_tx_vec:
> +	kvfree(binding->tx_vec);
>   err_unmap:
>   	dma_buf_unmap_attachment_unlocked(binding->attachment, binding->sgt,
>   					  DMA_FROM_DEVICE);
>   err_detach:
>   	dma_buf_detach(dmabuf, binding->attachment);
> -err_free_id:
> -	xa_erase(&net_devmem_dmabuf_bindings, binding->id);
>   err_free_binding:
>   	kfree(binding);
>   err_put_dmabuf:

...

> diff --git a/net/core/sock.c b/net/core/sock.c
> index b64df2463300b..9dd2989040357 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -3017,6 +3017,12 @@ int __sock_cmsg_send(struct sock *sk, struct cmsghdr *cmsg,
>   		if (!sk_set_prio_allowed(sk, *(u32 *)CMSG_DATA(cmsg)))
>   			return -EPERM;
>   		sockc->priority = *(u32 *)CMSG_DATA(cmsg);
> +		break;
> +	case SCM_DEVMEM_DMABUF:
> +		if (cmsg->cmsg_len != CMSG_LEN(sizeof(u32)))
> +			return -EINVAL;
> +		sockc->dmabuf_id = *(u32 *)CMSG_DATA(cmsg);
> +

Nitpick: Unneeded newline, to be consistent with the surrounding code.

>   		break;
>   	default:
>   		return -EINVAL;

...

CJ

  reply	other threads:[~2025-04-26 15:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-25 20:47 [PATCH net-next v12 0/9] Device memory TCP TX Mina Almasry
2025-04-25 20:47 ` [PATCH net-next v12 1/9] netmem: add niov->type attribute to distinguish different net_iov types Mina Almasry
2025-04-26  6:31   ` Christophe JAILLET
2025-04-25 20:47 ` [PATCH net-next v12 2/9] net: add get_netmem/put_netmem support Mina Almasry
2025-04-25 20:47 ` [PATCH net-next v12 3/9] net: devmem: TCP tx netlink api Mina Almasry
2025-04-25 20:47 ` [PATCH net-next v12 4/9] net: devmem: Implement TX path Mina Almasry
2025-04-26 15:12   ` Christophe JAILLET [this message]
2025-04-25 20:47 ` [PATCH net-next v12 5/9] net: add devmem TCP TX documentation Mina Almasry
2025-04-25 20:47 ` [PATCH net-next v12 6/9] net: enable driver support for netmem TX Mina Almasry
2025-04-25 20:47 ` [PATCH net-next v12 7/9] gve: add netmem TX support to GVE DQO-RDA mode Mina Almasry
2025-04-25 20:47 ` [PATCH net-next v12 8/9] net: check for driver support in netmem TX Mina Almasry
2025-04-25 20:47 ` [PATCH net-next v12 9/9] selftests: ncdevmem: Implement devmem TCP TX Mina Almasry

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=fceb6891-2749-496a-a6d5-db0748728e8a@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=almasrymina@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=dw@davidwei.uk \
    --cc=edumazet@google.com \
    --cc=eperezma@redhat.com \
    --cc=horms@kernel.org \
    --cc=hramamurthy@google.com \
    --cc=io-uring@vger.kernel.org \
    --cc=jasowang@redhat.com \
    --cc=jeroendb@google.com \
    --cc=jhs@mojatatu.com \
    --cc=kaiyuanz@google.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pctammela@mojatatu.com \
    --cc=sdf@fomichev.me \
    --cc=sgarzare@redhat.com \
    --cc=shuah@kernel.org \
    --cc=skhawaja@google.com \
    --cc=stefanha@redhat.com \
    --cc=victor@mojatatu.com \
    --cc=virtualization@lists.linux.dev \
    --cc=willemb@google.com \
    --cc=xuanzhuo@linux.alibaba.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