Applications must use pool capabilibty to check maximum values
for parameters. Used maximum segment length since application
seems to support only single segment packets.

Signed-off-by: Petri Savolainen <petri.savolai...@nokia.com>
---
 test/common_plat/performance/odp_crypto.c | 47 +++++++++++++++++++------------
 1 file changed, 29 insertions(+), 18 deletions(-)

diff --git a/test/common_plat/performance/odp_crypto.c 
b/test/common_plat/performance/odp_crypto.c
index 49a9f4b..39df78b 100644
--- a/test/common_plat/performance/odp_crypto.c
+++ b/test/common_plat/performance/odp_crypto.c
@@ -23,15 +23,10 @@
        fprintf(stderr, "%s:%d:%s(): Error: " fmt, __FILE__, \
                __LINE__, __func__, ##__VA_ARGS__)
 
-/** @def SHM_PKT_POOL_SIZE
- * @brief Size of the shared memory block
+/** @def POOL_NUM_PKT
+ * Number of packets in the pool
  */
-#define SHM_PKT_POOL_SIZE      (512 * 2048 * 2)
-
-/** @def SHM_PKT_POOL_BUF_SIZE
- * @brief Buffer size of the packet pool buffer
- */
-#define SHM_PKT_POOL_BUF_SIZE  (1024 * 32)
+#define POOL_NUM_PKT  64
 
 static uint8_t test_iv[8] = "01234567";
 
@@ -165,9 +160,7 @@ static void parse_args(int argc, char *argv[], 
crypto_args_t *cargs);
 static void usage(char *progname);
 
 /**
- * Set of predefined payloads. Make sure that maximum payload
- * size is not bigger than SHM_PKT_POOL_BUF_SIZE. May relax when
- * implementation start support segmented buffers/packets.
+ * Set of predefined payloads.
  */
 static unsigned int payloads[] = {
        16,
@@ -178,6 +171,9 @@ static unsigned int payloads[] = {
        16384
 };
 
+/** Number of payloads used in the test */
+static unsigned num_payloads;
+
 /**
  * Set of known algorithms to test
  */
@@ -680,12 +676,10 @@ run_measure_one_config(crypto_args_t *cargs,
                                             config, &result);
                        }
                } else {
-                       unsigned int i;
+                       unsigned i;
 
                        print_result_header();
-                       for (i = 0;
-                            i < (sizeof(payloads) / sizeof(unsigned int));
-                            i++) {
+                       for (i = 0; i < num_payloads; i++) {
                                rc = run_measure_one(cargs, config, &session,
                                                     payloads[i], &result);
                                if (rc)
@@ -728,6 +722,9 @@ int main(int argc, char *argv[])
        int num_workers = 1;
        odph_odpthread_t thr[num_workers];
        odp_instance_t instance;
+       odp_pool_capability_t capa;
+       uint32_t max_seg_len;
+       unsigned i;
 
        memset(&cargs, 0, sizeof(cargs));
 
@@ -743,11 +740,25 @@ int main(int argc, char *argv[])
        /* Init this thread */
        odp_init_local(instance, ODP_THREAD_WORKER);
 
+       if (odp_pool_capability(&capa)) {
+               app_err("Pool capability request failed.\n");
+               exit(EXIT_FAILURE);
+       }
+
+       max_seg_len = capa.pkt.max_seg_len;
+
+       for (i = 0; i < sizeof(payloads) / sizeof(unsigned int); i++) {
+               if (payloads[i] > max_seg_len)
+                       break;
+       }
+
+       num_payloads = i;
+
        /* Create packet pool */
        odp_pool_param_init(&params);
-       params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE;
-       params.pkt.len     = SHM_PKT_POOL_BUF_SIZE;
-       params.pkt.num     = SHM_PKT_POOL_SIZE / SHM_PKT_POOL_BUF_SIZE;
+       params.pkt.seg_len = max_seg_len;
+       params.pkt.len     = max_seg_len;
+       params.pkt.num     = POOL_NUM_PKT;
        params.type        = ODP_POOL_PACKET;
        pool = odp_pool_create("packet_pool", &params);
 
-- 
2.8.1

Reply via email to