dpdk: device_id sorted order for cryptodev
[vpp.git] / src / plugins / dpdk / cryptodev / cryptodev.c
index 86cec8a..2ae09ce 100644 (file)
@@ -1181,9 +1181,23 @@ cryptodev_create_device (vlib_main_t *vm, u32 n_queues)
   return 0;
 }
 
+static int
+cryptodev_cmp (void *v1, void *v2)
+{
+  cryptodev_inst_t *a1 = v1;
+  cryptodev_inst_t *a2 = v2;
+
+  if (a1->q_id > a2->q_id)
+    return 1;
+  if (a1->q_id < a2->q_id)
+    return -1;
+  return 0;
+}
+
 static int
 cryptodev_probe (vlib_main_t *vm, u32 n_workers)
 {
+  cryptodev_main_t *cmt = &cryptodev_main;
   u32 n_queues = cryptodev_count_queue (vm->numa_node);
   u32 i;
   int ret;
@@ -1204,6 +1218,8 @@ cryptodev_probe (vlib_main_t *vm, u32 n_workers)
        return ret;
     }
 
+  vec_sort_with_function(cmt->cryptodev_inst, cryptodev_cmp);
+
   return 0;
 }