examples/ipsec-secgw: attach session-qp
authorAkhil Goyal <akhil.goyal@nxp.com>
Fri, 24 Mar 2017 09:29:21 +0000 (14:59 +0530)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Wed, 5 Apr 2017 22:17:44 +0000 (00:17 +0200)
adding support for attaching session to queue pairs.
This is required as underlying crypto driver may only
support limited number of sessions per queue pair
if max_nb_sessions_per_qp > 0, session should be
attached to a particular qp.

Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
examples/ipsec-secgw/ipsec.c

index 144f0aa..edca5f0 100644 (file)
@@ -47,6 +47,7 @@
 static inline int
 create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
 {
+       struct rte_cryptodev_info cdev_info;
        unsigned long cdev_id_qp = 0;
        int32_t ret;
        struct cdev_key key = { 0 };
@@ -73,6 +74,18 @@ create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa)
        sa->crypto_session = rte_cryptodev_sym_session_create(
                        ipsec_ctx->tbl[cdev_id_qp].id, sa->xforms);
 
+       rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id, &cdev_info);
+       if (cdev_info.sym.max_nb_sessions_per_qp > 0) {
+               ret = rte_cryptodev_queue_pair_attach_sym_session(
+                               ipsec_ctx->tbl[cdev_id_qp].qp,
+                               sa->crypto_session);
+               if (ret < 0) {
+                       RTE_LOG(ERR, IPSEC,
+                               "Session cannot be attached to qp %u ",
+                               ipsec_ctx->tbl[cdev_id_qp].qp);
+                       return -1;
+               }
+       }
        sa->cdev_id_qp = cdev_id_qp;
 
        return 0;