dpdk: selection of cryptodev engine data-path
[vpp.git] / src / vnet / crypto / crypto.c
index e52e68e..b98d219 100644 (file)
@@ -302,7 +302,7 @@ vnet_crypto_register_async_handler (vlib_main_t * vm, u32 engine_index,
     }
 
   ae = vec_elt_at_index (cm->engines, otd->active_engine_index_async);
-  if (ae->priority < e->priority)
+  if (ae->priority <= e->priority)
     {
       otd->active_engine_index_async = engine_index;
       cm->enqueue_handlers[opt] = enqueue_hdl;
@@ -429,9 +429,6 @@ vnet_crypto_key_add_linked (vlib_main_t * vm,
   key_crypto = pool_elt_at_index (cm->keys, index_crypto);
   key_integ = pool_elt_at_index (cm->keys, index_integ);
 
-  if (!key_crypto || !key_integ)
-    return ~0;
-
   linked_alg = vnet_crypto_link_algs (key_crypto->alg, key_integ->alg);
   if (linked_alg == ~0)
     return ~0;
@@ -480,9 +477,9 @@ crypto_dispatch_enable_disable (int is_enable)
   if (state_change)
     for (i = skip_master; i < tm->n_vlib_mains; i++)
       {
-       if (state !=
-           vlib_node_get_state (vlib_mains[i], cm->crypto_node_index))
-         vlib_node_set_state (vlib_mains[i], cm->crypto_node_index, state);
+       vlib_main_t *ovm = vlib_get_main_by_index (i);
+       if (state != vlib_node_get_state (ovm, cm->crypto_node_index))
+         vlib_node_set_state (ovm, cm->crypto_node_index, state);
       }
   return 0;
 }
@@ -590,9 +587,9 @@ vnet_crypto_request_async_mode (int is_enable)
   if (state_change)
     for (i = skip_master; i < tm->n_vlib_mains; i++)
       {
-       if (state !=
-           vlib_node_get_state (vlib_mains[i], cm->crypto_node_index))
-         vlib_node_set_state (vlib_mains[i], cm->crypto_node_index, state);
+       vlib_main_t *ovm = vlib_get_main_by_index (i);
+       if (state != vlib_node_get_state (ovm, cm->crypto_node_index))
+         vlib_node_set_state (ovm, cm->crypto_node_index, state);
       }
 
   if (is_enable)
@@ -626,8 +623,9 @@ vnet_crypto_set_async_dispatch_mode (u8 mode)
 
   for (i = skip_master; i < tm->n_vlib_mains; i++)
     {
-      if (state != vlib_node_get_state (vlib_mains[i], cm->crypto_node_index))
-       vlib_node_set_state (vlib_mains[i], cm->crypto_node_index, state);
+      vlib_main_t *ovm = vlib_get_main_by_index (i);
+      if (state != vlib_node_get_state (ovm, cm->crypto_node_index))
+       vlib_node_set_state (ovm, cm->crypto_node_index, state);
     }
 }
 
@@ -719,7 +717,8 @@ vnet_crypto_init (vlib_main_t * vm)
   cm->async_alg_index_by_name = hash_create_string (0, sizeof (uword));
   vec_validate_aligned (cm->threads, tm->n_vlib_mains, CLIB_CACHE_LINE_BYTES);
   vec_foreach (ct, cm->threads)
-    pool_alloc_aligned (ct->frame_pool, 1024, CLIB_CACHE_LINE_BYTES);
+    pool_alloc_aligned (ct->frame_pool, VNET_CRYPTO_FRAME_POOL_SIZE,
+                       CLIB_CACHE_LINE_BYTES);
   vec_validate (cm->algs, VNET_CRYPTO_N_ALGS);
   vec_validate (cm->async_algs, VNET_CRYPTO_N_ASYNC_ALGS);
   clib_bitmap_validate (cm->async_active_ids, VNET_CRYPTO_ASYNC_OP_N_IDS - 1);