<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> <o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> So, how do we want to fix this:<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> <o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> 1. Specify the allowed return values in the documentation for the mempool<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> library callback types, and require the mempool drivers to follow the updated<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> specification?<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> 2. Update mempool API documentation to list the many currently possible error<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> return values (-ENOBUFS, -ENOENT, -ENOMEM, and -EPERM (=-1))?<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> 3. Update mempool API documentation to say something along the lines of<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> "negative return value indicates error; rte_errno is not set if -1"?<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> 4. Switch to a general convention of returning -1 and setting rte_errno in all<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> DPDK APIs, starting with the mempool library? However; this would still require a<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> documented list of possible rte_errno values set by the functions - essentially<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> the problem would remain the same: "possible return values" vs. "possible<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> rte_errno values".<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> <o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> Personally, I am in strong favor of any option that tightens the API specification<o:p class="ContentPasted1"> </o:p></p>
<p class="MsoPlainText ContentPasted1" style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri, sans-serif">
> and treats non-conformance as bugs.<o:p class="ContentPasted1"> </o:p></p>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted2 ContentPasted3 ContentPasted4">
Thanks for your detailed reply!
<div><br class="ContentPasted2">
</div>
Couldn't agree more with your third option, which is much more generalized.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div class="elementToProof">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<p style="font-size: 10.5pt; font-family: 等线; text-align: justify; margin: 0px; color: rgb(36, 36, 36); background-color: rgb(255, 255, 255);">
<span lang="en-US" style="margin:0px" class="ContentPasted0">Best wishes,</span></p>
<p style="font-size: 10.5pt; font-family: 等线; text-align: justify; margin: 0px; color: rgb(36, 36, 36); background-color: rgb(255, 255, 255);">
Rma</p>
</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Morten Brørup <mb@smartsharesystems.com><br>
<b>Sent:</b> Wednesday, August 2, 2023 16:58<br>
<b>To:</b> Rma Ma <rma.ma@jaguarmicro.com>; dpdk-dev <dev@dpdk.org>; Olivier Matz <olivier.matz@6wind.com>; Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru><br>
<b>Cc:</b> Ashwin Sekhar T K <asekhar@marvell.com>; Pavan Nikhilesh <pbhagavatula@marvell.com>; Harman Kalra <hkalra@marvell.com>; Hemant Agrawal <hemant.agrawal@nxp.com>; Sachin Saxena <sachin.saxena@oss.nxp.com><br>
<b>Subject:</b> RE: [PATCH v1] mempool: fix some errors in html api</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">+CC various mempool driver maintainers<br>
<br>
> From: Rma Ma [<a href="mailto:rma.ma@jaguarmicro.com">mailto:rma.ma@jaguarmicro.com</a>]<br>
> Sent: Monday, 3 July 2023 08.18<br>
> <br>
> This patch fix some error descriptions of<br>
> return value in mempool api which affect in html api.<br>
> <br>
> Signed-off-by: Rma Ma <rma.ma@jaguarmicro.com><br>
> ---<br>
>  lib/mempool/rte_mempool.h | 12 ++++++------<br>
>  1 file changed, 6 insertions(+), 6 deletions(-)<br>
> <br>
> diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h<br>
> index 160975a7e7..d4d707533a 100644<br>
> --- a/lib/mempool/rte_mempool.h<br>
> +++ b/lib/mempool/rte_mempool.h<br>
> @@ -1610,7 +1610,7 @@ rte_mempool_do_generic_get(struct rte_mempool *mp, void<br>
> **obj_table,<br>
>   * Get several objects from the mempool.<br>
>   *<br>
>   * If cache is enabled, objects will be retrieved first from cache,<br>
> - * subsequently from the common pool. Note that it can return -ENOENT when<br>
> + * subsequently from the common pool. Note that it can return -ENOBUFS when<br>
>   * the local cache and common pool are empty, even if cache from other<br>
>   * lcores are full.<br>
>   *<br>
> @@ -1624,7 +1624,7 @@ rte_mempool_do_generic_get(struct rte_mempool *mp, void<br>
> **obj_table,<br>
>   *   A pointer to a mempool cache structure. May be NULL if not needed.<br>
>   * @return<br>
>   *   - 0: Success; objects taken.<br>
> - *   - -ENOENT: Not enough entries in the mempool; no object is retrieved.<br>
> + *   - -ENOBUFS: Not enough entries in the mempool; no object is retrieved.<br>
>   */<br>
>  static __rte_always_inline int<br>
>  rte_mempool_generic_get(struct rte_mempool *mp, void **obj_table,<br>
> @@ -1646,7 +1646,7 @@ rte_mempool_generic_get(struct rte_mempool *mp, void<br>
> **obj_table,<br>
>   * mempool creation time (see flags).<br>
>   *<br>
>   * If cache is enabled, objects will be retrieved first from cache,<br>
> - * subsequently from the common pool. Note that it can return -ENOENT when<br>
> + * subsequently from the common pool. Note that it can return -ENOBUFS when<br>
>   * the local cache and common pool are empty, even if cache from other<br>
>   * lcores are full.<br>
>   *<br>
> @@ -1658,7 +1658,7 @@ rte_mempool_generic_get(struct rte_mempool *mp, void<br>
> **obj_table,<br>
>   *   The number of objects to get from the mempool to obj_table.<br>
>   * @return<br>
>   *   - 0: Success; objects taken<br>
> - *   - -ENOENT: Not enough entries in the mempool; no object is retrieved.<br>
> + *   - -ENOBUFS: Not enough entries in the mempool; no object is retrieved.<br>
>   */<br>
>  static __rte_always_inline int<br>
>  rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned int<br>
> n)<br>
> @@ -1677,7 +1677,7 @@ rte_mempool_get_bulk(struct rte_mempool *mp, void<br>
> **obj_table, unsigned int n)<br>
>   * mempool creation (see flags).<br>
>   *<br>
>   * If cache is enabled, objects will be retrieved first from cache,<br>
> - * subsequently from the common pool. Note that it can return -ENOENT when<br>
> + * subsequently from the common pool. Note that it can return -ENOBUFS when<br>
>   * the local cache and common pool are empty, even if cache from other<br>
>   * lcores are full.<br>
>   *<br>
> @@ -1687,7 +1687,7 @@ rte_mempool_get_bulk(struct rte_mempool *mp, void<br>
> **obj_table, unsigned int n)<br>
>   *   A pointer to a void * pointer (object) that will be filled.<br>
>   * @return<br>
>   *   - 0: Success; objects taken.<br>
> - *   - -ENOENT: Not enough entries in the mempool; no object is retrieved.<br>
> + *   - -ENOBUFS: Not enough entries in the mempool; no object is retrieved.<br>
>   */<br>
>  static __rte_always_inline int<br>
>  rte_mempool_get(struct rte_mempool *mp, void **obj_p)<br>
> --<br>
> 2.17.1<br>
<br>
Unfortunately, it is not that simple...<br>
<br>
Here is the list of where mempool drivers are registered:<br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/C/ident/RTE_MEMPOOL_REGISTER_OPS">https://elixir.bootlin.com/dpdk/v23.07/C/ident/RTE_MEMPOOL_REGISTER_OPS</a><br>
<br>
Some of the mempool drivers return -ENOBUFS, e.g. the ring driver and the stack driver:<br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/ring/rte_mempool_ring.c#L145">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/ring/rte_mempool_ring.c#L145</a><br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/ring/rte_mempool_ring.c#L48">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/ring/rte_mempool_ring.c#L48</a><br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/stack/rte_mempool_stack.c#L78">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/stack/rte_mempool_stack.c#L78</a><br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/stack/rte_mempool_stack.c#L59">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/stack/rte_mempool_stack.c#L59</a><br>
<br>
However, I found one mempool driver (Marvell cnxk) that returns -ENOENT:<br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/cnxk/cn10k_hwpool_ops.c#L261">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/cnxk/cn10k_hwpool_ops.c#L261</a><br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/cnxk/cn10k_hwpool_ops.c#L69">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/cnxk/cn10k_hwpool_ops.c#L69</a><br>
<br>
And one mempool driver (Cavium OCTEON TX) returns -ENOMEM:<br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/octeontx/rte_mempool_octeontx.c#L194">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/octeontx/rte_mempool_octeontx.c#L194</a><br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/octeontx/rte_mempool_octeontx.c#L111">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/octeontx/rte_mempool_octeontx.c#L111</a><br>
<br>
One mempool driver (NXP dpaa) returns -ENOBUFS, or (if requesting too many objects) -1:<br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa/dpaa_mempool.c#L351">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa/dpaa_mempool.c#L351</a><br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa/dpaa_mempool.c#L225">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa/dpaa_mempool.c#L225</a><br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa/dpaa_mempool.c#L257">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa/dpaa_mempool.c#L257</a><br>
<br>
And one mempool driver (NXP dpaa2) returns -ENOBUFS, or in rare cases -ENOENT or -1:<br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa2/dpaa2_hw_mempool.c#L471">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa2/dpaa2_hw_mempool.c#L471</a><br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa2/dpaa2_hw_mempool.c#L373">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa2/dpaa2_hw_mempool.c#L373</a><br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa2/dpaa2_hw_mempool.c#L336">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa2/dpaa2_hw_mempool.c#L336</a><br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa2/dpaa2_hw_mempool.c#L342">https://elixir.bootlin.com/dpdk/v23.07/source/drivers/mempool/dpaa2/dpaa2_hw_mempool.c#L342</a><br>
<br>
<br>
The root cause for this misery is the general lack of documentation of callbacks in DPDK (not just in the mempool library!), which leaves the callback implementers unaware of what to return. E.g. the mempool driver enqueue and dequeue callback types have no
 descriptions of their return values:<br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/lib/mempool/rte_mempool.h#L467">https://elixir.bootlin.com/dpdk/v23.07/source/lib/mempool/rte_mempool.h#L467</a><br>
<a href="https://elixir.bootlin.com/dpdk/v23.07/source/lib/mempool/rte_mempool.h#L473">https://elixir.bootlin.com/dpdk/v23.07/source/lib/mempool/rte_mempool.h#L473</a><br>
<br>
So in theory, the mempool drivers are free to return any value... Initially, I didn't think any mempool drivers would return -1 and set rte_errno, but apparently they do (except the driver doesn't set rte_errno when returning -1)!<br>
<br>
On a techboard meeting not long ago, Tyler mentioned the lack of consistency in return value conventions as an general annoyance. Now having looked at these mempool drivers, I realize that the situation is much worse than I would imagine in my worst nightmare!<br>
<br>
<br>
So, how do we want to fix this:<br>
<br>
1. Specify the allowed return values in the documentation for the mempool library callback types, and require the mempool drivers to follow the updated specification?<br>
2. Update mempool API documentation to list the many currently possible error return values (-ENOBUFS, -ENOENT, -ENOMEM, and -EPERM (=-1))?<br>
3. Update mempool API documentation to say something along the lines of "negative return value indicates error; rte_errno is not set if -1"?<br>
4. Switch to a general convention of returning -1 and setting rte_errno in all DPDK APIs, starting with the mempool library? However; this would still require a documented list of possible rte_errno values set by the functions - essentially the problem would
 remain the same: "possible return values" vs. "possible rte_errno values".<br>
<br>
Personally, I am in strong favor of any option that tightens the API specification and treats non-conformance as bugs.<br>
<br>
</div>
</span></font></div>
</body>
</html>