There's no use case for application to allocate zero length
packets. Application should always have some knowledge about
the new packet data length before allocation. Also
implementations are more efficient when a check for zero length
is avoided.

Also added a pool parameter to specify the maximum packet length
to be allocated from the pool. Implementations may use this
information to optimize e.g. memory usage, etc. Application must
not exceed the max_len parameter value on alloc calls. Pool
capabilities define already max_len.

Signed-off-by: Petri Savolainen <petri.savolai...@nokia.com>
---
 include/odp/api/spec/packet.h | 9 +++++----
 include/odp/api/spec/pool.h   | 6 ++++++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index 4a14f2d..faf62e2 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -82,13 +82,14 @@ extern "C" {
  * Allocate a packet from a packet pool
  *
  * Allocates a packet of the requested length from the specified packet pool.
- * Pool must have been created with ODP_POOL_PACKET type. The
+ * The pool must have been created with ODP_POOL_PACKET type. The
  * packet is initialized with data pointers and lengths set according to the
  * specified len, and the default headroom and tailroom length settings. All
- * other packet metadata are set to their default values.
+ * other packet metadata are set to their default values. Packet length must
+ * be greater than zero and not exceed packet pool parameter 'max_len' value.
  *
  * @param pool          Pool handle
- * @param len           Packet data length
+ * @param len           Packet data length (1 ... pool max_len)
  *
  * @return Handle of allocated packet
  * @retval ODP_PACKET_INVALID  Packet could not be allocated
@@ -105,7 +106,7 @@ odp_packet_t odp_packet_alloc(odp_pool_t pool, uint32_t 
len);
  * packets from a pool.
  *
  * @param pool          Pool handle
- * @param len           Packet data length
+ * @param len           Packet data length (1 ... pool max_len)
  * @param[out] pkt      Array of packet handles for output
  * @param num           Maximum number of packets to allocate
  *
diff --git a/include/odp/api/spec/pool.h b/include/odp/api/spec/pool.h
index a1331e3..041f4af 100644
--- a/include/odp/api/spec/pool.h
+++ b/include/odp/api/spec/pool.h
@@ -192,6 +192,12 @@ typedef struct odp_pool_param_t {
                            pkt.max_len. Use 0 for default. */
                        uint32_t len;
 
+                       /** Maximum packet length that will be allocated from
+                           the pool. The maximum value is defined by pool
+                           capability pkt.max_len. Use 0 for default (the
+                           pool maximum). */
+                       uint32_t max_len;
+
                        /** Minimum number of packet data bytes that are stored
                            in the first segment of a packet. The maximum value
                            is defined by pool capability pkt.max_seg_len.
-- 
2.8.1

Reply via email to