diff mbox series

[net-next,v2,05/13] virtio_ring: introduce add api for premapped

Message ID 20241030082453.97310-6-xuanzhuo@linux.alibaba.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series virtio-net: support AF_XDP zero copy (tx) | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 7 this patch: 9
netdev/build_tools success Errors and warnings before: 0 (+0) this patch: 0 (+0)
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang fail Errors and warnings before: 5 this patch: 7
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 26 this patch: 28
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 79 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc fail Errors and warnings before: 22 this patch: 26
netdev/source_inline success Was 0 now: 0

Commit Message

Xuan Zhuo Oct. 30, 2024, 8:24 a.m. UTC
Two APIs are introduced to submit premapped per-buffers.

int virtqueue_add_inbuf_premapped(struct virtqueue *vq,
                                 struct scatterlist *sg, unsigned int num,
                                 void *data,
                                 void *ctx,
                                 bool premapped,
                                 gfp_t gfp);

int virtqueue_add_outbuf_premapped(struct virtqueue *vq,
                                  struct scatterlist *sg, unsigned int num,
                                  void *data,
                                  bool premapped,
                                  gfp_t gfp);

Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
 drivers/virtio/virtio_ring.c | 48 ++++++++++++++++++++++++++++++++++++
 include/linux/virtio.h       | 13 ++++++++++
 2 files changed, 61 insertions(+)

Comments

kernel test robot Oct. 31, 2024, 2:19 a.m. UTC | #1
Hi Xuan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Xuan-Zhuo/virtio_ring-introduce-vring_need_unmap_buffer/20241030-162739
base:   net-next/main
patch link:    https://lore.kernel.org/r/20241030082453.97310-6-xuanzhuo%40linux.alibaba.com
patch subject: [PATCH net-next v2 05/13] virtio_ring: introduce add api for premapped
config: x86_64-buildonly-randconfig-003-20241031 (https://download.01.org/0day-ci/archive/20241031/202410310925.LuCycrTj-lkp@intel.com/config)
compiler: clang version 19.1.2 (https://github.com/llvm/llvm-project 7ba7d8e2f7b6445b60679da826210cdde29eaf8b)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241031/202410310925.LuCycrTj-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410310925.LuCycrTj-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/virtio/virtio_ring.c:2293: warning: Function parameter or struct member 'premapped' not described in 'virtqueue_add_outbuf_premapped'
>> drivers/virtio/virtio_ring.c:2364: warning: Function parameter or struct member 'premapped' not described in 'virtqueue_add_inbuf_premapped'


vim +2293 drivers/virtio/virtio_ring.c

  2274	
  2275	/**
  2276	 * virtqueue_add_outbuf_premapped - expose output buffers to other end
  2277	 * @vq: the struct virtqueue we're talking about.
  2278	 * @sg: scatterlist (must be well-formed and terminated!)
  2279	 * @num: the number of entries in @sg readable by other side
  2280	 * @data: the token identifying the buffer.
  2281	 * @gfp: how to do memory allocations (if necessary).
  2282	 *
  2283	 * Caller must ensure we don't call this with other virtqueue operations
  2284	 * at the same time (except where noted).
  2285	 *
  2286	 * Returns zero or a negative error (ie. ENOSPC, ENOMEM, EIO).
  2287	 */
  2288	int virtqueue_add_outbuf_premapped(struct virtqueue *vq,
  2289					   struct scatterlist *sg, unsigned int num,
  2290					   void *data,
  2291					   bool premapped,
  2292					   gfp_t gfp)
> 2293	{
  2294		return virtqueue_add(vq, &sg, num, 1, 0, data, NULL, premapped, gfp);
  2295	}
  2296	EXPORT_SYMBOL_GPL(virtqueue_add_outbuf_premapped);
  2297	
  2298	/**
  2299	 * virtqueue_add_inbuf - expose input buffers to other end
  2300	 * @vq: the struct virtqueue we're talking about.
  2301	 * @sg: scatterlist (must be well-formed and terminated!)
  2302	 * @num: the number of entries in @sg writable by other side
  2303	 * @data: the token identifying the buffer.
  2304	 * @gfp: how to do memory allocations (if necessary).
  2305	 *
  2306	 * Caller must ensure we don't call this with other virtqueue operations
  2307	 * at the same time (except where noted).
  2308	 *
  2309	 * Returns zero or a negative error (ie. ENOSPC, ENOMEM, EIO).
  2310	 */
  2311	int virtqueue_add_inbuf(struct virtqueue *vq,
  2312				struct scatterlist *sg, unsigned int num,
  2313				void *data,
  2314				gfp_t gfp)
  2315	{
  2316		return virtqueue_add(vq, &sg, num, 0, 1, data, NULL, false, gfp);
  2317	}
  2318	EXPORT_SYMBOL_GPL(virtqueue_add_inbuf);
  2319	
  2320	/**
  2321	 * virtqueue_add_inbuf_ctx - expose input buffers to other end
  2322	 * @vq: the struct virtqueue we're talking about.
  2323	 * @sg: scatterlist (must be well-formed and terminated!)
  2324	 * @num: the number of entries in @sg writable by other side
  2325	 * @data: the token identifying the buffer.
  2326	 * @ctx: extra context for the token
  2327	 * @gfp: how to do memory allocations (if necessary).
  2328	 *
  2329	 * Caller must ensure we don't call this with other virtqueue operations
  2330	 * at the same time (except where noted).
  2331	 *
  2332	 * Returns zero or a negative error (ie. ENOSPC, ENOMEM, EIO).
  2333	 */
  2334	int virtqueue_add_inbuf_ctx(struct virtqueue *vq,
  2335				struct scatterlist *sg, unsigned int num,
  2336				void *data,
  2337				void *ctx,
  2338				gfp_t gfp)
  2339	{
  2340		return virtqueue_add(vq, &sg, num, 0, 1, data, ctx, false, gfp);
  2341	}
  2342	EXPORT_SYMBOL_GPL(virtqueue_add_inbuf_ctx);
  2343	
  2344	/**
  2345	 * virtqueue_add_inbuf_premapped - expose input buffers to other end
  2346	 * @vq: the struct virtqueue we're talking about.
  2347	 * @sg: scatterlist (must be well-formed and terminated!)
  2348	 * @num: the number of entries in @sg writable by other side
  2349	 * @data: the token identifying the buffer.
  2350	 * @ctx: extra context for the token
  2351	 * @gfp: how to do memory allocations (if necessary).
  2352	 *
  2353	 * Caller must ensure we don't call this with other virtqueue operations
  2354	 * at the same time (except where noted).
  2355	 *
  2356	 * Returns zero or a negative error (ie. ENOSPC, ENOMEM, EIO).
  2357	 */
  2358	int virtqueue_add_inbuf_premapped(struct virtqueue *vq,
  2359					  struct scatterlist *sg, unsigned int num,
  2360					  void *data,
  2361					  void *ctx,
  2362					  bool premapped,
  2363					  gfp_t gfp)
> 2364	{
  2365		return virtqueue_add(vq, &sg, num, 0, 1, data, ctx, premapped, gfp);
  2366	}
  2367	EXPORT_SYMBOL_GPL(virtqueue_add_inbuf_premapped);
  2368
Jason Wang Nov. 5, 2024, 4:28 a.m. UTC | #2
On Wed, Oct 30, 2024 at 4:25 PM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
>
> Two APIs are introduced to submit premapped per-buffers.
>
> int virtqueue_add_inbuf_premapped(struct virtqueue *vq,
>                                  struct scatterlist *sg, unsigned int num,
>                                  void *data,
>                                  void *ctx,
>                                  bool premapped,
>                                  gfp_t gfp);
>
> int virtqueue_add_outbuf_premapped(struct virtqueue *vq,
>                                   struct scatterlist *sg, unsigned int num,
>                                   void *data,
>                                   bool premapped,
>                                   gfp_t gfp);
>
> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> ---
>  drivers/virtio/virtio_ring.c | 48 ++++++++++++++++++++++++++++++++++++
>  include/linux/virtio.h       | 13 ++++++++++
>  2 files changed, 61 insertions(+)
>
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index a89295b79e66..525308d82728 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -2272,6 +2272,29 @@ int virtqueue_add_outbuf(struct virtqueue *vq,
>  }
>  EXPORT_SYMBOL_GPL(virtqueue_add_outbuf);
>
> +/**
> + * virtqueue_add_outbuf_premapped - expose output buffers to other end
> + * @vq: the struct virtqueue we're talking about.
> + * @sg: scatterlist (must be well-formed and terminated!)
> + * @num: the number of entries in @sg readable by other side
> + * @data: the token identifying the buffer.
> + * @gfp: how to do memory allocations (if necessary).
> + *
> + * Caller must ensure we don't call this with other virtqueue operations
> + * at the same time (except where noted).
> + *
> + * Returns zero or a negative error (ie. ENOSPC, ENOMEM, EIO).
> + */
> +int virtqueue_add_outbuf_premapped(struct virtqueue *vq,
> +                                  struct scatterlist *sg, unsigned int num,
> +                                  void *data,
> +                                  bool premapped,

We don't need this parameter consider:

1) we've already had virtqueue_add_outbuf() which implies the buf has
been mapped
2) no explanation for "premapped" in the function doc

Thanks

> +                                  gfp_t gfp)
> +{
> +       return virtqueue_add(vq, &sg, num, 1, 0, data, NULL, premapped, gfp);
> +}
> +EXPORT_SYMBOL_GPL(virtqueue_add_outbuf_premapped);
> +
>  /**
>   * virtqueue_add_inbuf - expose input buffers to other end
>   * @vq: the struct virtqueue we're talking about.
> @@ -2318,6 +2341,31 @@ int virtqueue_add_inbuf_ctx(struct virtqueue *vq,
>  }
>  EXPORT_SYMBOL_GPL(virtqueue_add_inbuf_ctx);
>
> +/**
> + * virtqueue_add_inbuf_premapped - expose input buffers to other end
> + * @vq: the struct virtqueue we're talking about.
> + * @sg: scatterlist (must be well-formed and terminated!)
> + * @num: the number of entries in @sg writable by other side
> + * @data: the token identifying the buffer.
> + * @ctx: extra context for the token
> + * @gfp: how to do memory allocations (if necessary).
> + *
> + * Caller must ensure we don't call this with other virtqueue operations
> + * at the same time (except where noted).
> + *
> + * Returns zero or a negative error (ie. ENOSPC, ENOMEM, EIO).
> + */
> +int virtqueue_add_inbuf_premapped(struct virtqueue *vq,
> +                                 struct scatterlist *sg, unsigned int num,
> +                                 void *data,
> +                                 void *ctx,
> +                                 bool premapped,
> +                                 gfp_t gfp)
> +{
> +       return virtqueue_add(vq, &sg, num, 0, 1, data, ctx, premapped, gfp);
> +}
> +EXPORT_SYMBOL_GPL(virtqueue_add_inbuf_premapped);
> +
>  /**
>   * virtqueue_dma_dev - get the dma dev
>   * @_vq: the struct virtqueue we're talking about.
> diff --git a/include/linux/virtio.h b/include/linux/virtio.h
> index 306137a15d07..19afa49b92d0 100644
> --- a/include/linux/virtio.h
> +++ b/include/linux/virtio.h
> @@ -56,6 +56,19 @@ int virtqueue_add_inbuf_ctx(struct virtqueue *vq,
>                             void *ctx,
>                             gfp_t gfp);
>
> +int virtqueue_add_inbuf_premapped(struct virtqueue *vq,
> +                                 struct scatterlist *sg, unsigned int num,
> +                                 void *data,
> +                                 void *ctx,
> +                                 bool premapped,
> +                                 gfp_t gfp);
> +
> +int virtqueue_add_outbuf_premapped(struct virtqueue *vq,
> +                                  struct scatterlist *sg, unsigned int num,
> +                                  void *data,
> +                                  bool premapped,
> +                                  gfp_t gfp);
> +
>  int virtqueue_add_sgs(struct virtqueue *vq,
>                       struct scatterlist *sgs[],
>                       unsigned int out_sgs,
> --
> 2.32.0.3.g01195cf9f
>
diff mbox series

Patch

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index a89295b79e66..525308d82728 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -2272,6 +2272,29 @@  int virtqueue_add_outbuf(struct virtqueue *vq,
 }
 EXPORT_SYMBOL_GPL(virtqueue_add_outbuf);
 
+/**
+ * virtqueue_add_outbuf_premapped - expose output buffers to other end
+ * @vq: the struct virtqueue we're talking about.
+ * @sg: scatterlist (must be well-formed and terminated!)
+ * @num: the number of entries in @sg readable by other side
+ * @data: the token identifying the buffer.
+ * @gfp: how to do memory allocations (if necessary).
+ *
+ * Caller must ensure we don't call this with other virtqueue operations
+ * at the same time (except where noted).
+ *
+ * Returns zero or a negative error (ie. ENOSPC, ENOMEM, EIO).
+ */
+int virtqueue_add_outbuf_premapped(struct virtqueue *vq,
+				   struct scatterlist *sg, unsigned int num,
+				   void *data,
+				   bool premapped,
+				   gfp_t gfp)
+{
+	return virtqueue_add(vq, &sg, num, 1, 0, data, NULL, premapped, gfp);
+}
+EXPORT_SYMBOL_GPL(virtqueue_add_outbuf_premapped);
+
 /**
  * virtqueue_add_inbuf - expose input buffers to other end
  * @vq: the struct virtqueue we're talking about.
@@ -2318,6 +2341,31 @@  int virtqueue_add_inbuf_ctx(struct virtqueue *vq,
 }
 EXPORT_SYMBOL_GPL(virtqueue_add_inbuf_ctx);
 
+/**
+ * virtqueue_add_inbuf_premapped - expose input buffers to other end
+ * @vq: the struct virtqueue we're talking about.
+ * @sg: scatterlist (must be well-formed and terminated!)
+ * @num: the number of entries in @sg writable by other side
+ * @data: the token identifying the buffer.
+ * @ctx: extra context for the token
+ * @gfp: how to do memory allocations (if necessary).
+ *
+ * Caller must ensure we don't call this with other virtqueue operations
+ * at the same time (except where noted).
+ *
+ * Returns zero or a negative error (ie. ENOSPC, ENOMEM, EIO).
+ */
+int virtqueue_add_inbuf_premapped(struct virtqueue *vq,
+				  struct scatterlist *sg, unsigned int num,
+				  void *data,
+				  void *ctx,
+				  bool premapped,
+				  gfp_t gfp)
+{
+	return virtqueue_add(vq, &sg, num, 0, 1, data, ctx, premapped, gfp);
+}
+EXPORT_SYMBOL_GPL(virtqueue_add_inbuf_premapped);
+
 /**
  * virtqueue_dma_dev - get the dma dev
  * @_vq: the struct virtqueue we're talking about.
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 306137a15d07..19afa49b92d0 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -56,6 +56,19 @@  int virtqueue_add_inbuf_ctx(struct virtqueue *vq,
 			    void *ctx,
 			    gfp_t gfp);
 
+int virtqueue_add_inbuf_premapped(struct virtqueue *vq,
+				  struct scatterlist *sg, unsigned int num,
+				  void *data,
+				  void *ctx,
+				  bool premapped,
+				  gfp_t gfp);
+
+int virtqueue_add_outbuf_premapped(struct virtqueue *vq,
+				   struct scatterlist *sg, unsigned int num,
+				   void *data,
+				   bool premapped,
+				   gfp_t gfp);
+
 int virtqueue_add_sgs(struct virtqueue *vq,
 		      struct scatterlist *sgs[],
 		      unsigned int out_sgs,