examples/ipsec-secgw: fix cryptodev to SA mapping
PATCH 1/1 examples/ipsec-secgw: fix cryptodev to SA mapping
There are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function. Also add a check to verify that a CQP is available for the current lcore.
--- examples/ipsec-secgw/ipsec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
examples/ipsec-secgw/ipsec.c +8 -5
@@ -288,10 +288,9 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[],if (cdev_id ==RTE_CRYPTO_MAX_DEVS ) cdev_id = ipsec_ctx->tbl[cdev_id_qp].id;else if (cdev_id != ipsec_ctx->tbl[cdev_id_qp].id) { -RTE_LOG (ERR ,IPSEC , -"SA mapping to multiple cryptodevs is " -"not supported!" ); -return -EINVAL ; +RTE_LOG (WARNING ,IPSEC , +"SA mapped to multiple cryptodevs for SPI %d\n" , + sa->spi); }/* Store per core queue pair information */
@@ -908,7 +907,11 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,continue ; } -enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +if (sa->cqp[ipsec_ctx->lcore_id]) +enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +else +RTE_LOG (ERR ,IPSEC ,"No CQP available for lcore %d\n" , + ipsec_ctx->lcore_id); } }
Signature · 1 line
2.25.1
--- examples/ipsec-secgw/ipsec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
examples/ipsec-secgw/ipsec.c +3 -4
@@ -288,10 +288,9 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[],if (cdev_id ==RTE_CRYPTO_MAX_DEVS ) cdev_id = ipsec_ctx->tbl[cdev_id_qp].id;else if (cdev_id != ipsec_ctx->tbl[cdev_id_qp].id) { -RTE_LOG (ERR ,IPSEC , -"SA mapping to multiple cryptodevs is " -"not supported!" ); -return -EINVAL ; +RTE_LOG (WARNING ,IPSEC , +"SA mapped to multiple cryptodevs for SPI %d\n" , + sa->spi); } /* Store per core queue pair information */ @@ -908,7 +907,11 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
continue;
}
- enqueue_cop(sa->cqp[ipsec_ctx->lcore_id], &priv->cop);
+ if (sa->cqp[ipsec_ctx->lcore_id])
+ enqueue_cop(sa->cqp[ipsec_ctx->lcore_id], &priv->cop);
+ else
+ RTE_LOG(ERR, IPSEC, "No CQP available for lcore %d\n",
+ ipsec_ctx->lcore_id);
}
}
--
2.25.1
-----Original Message-----
From: Nicolau, Radu <[email protected]>
Sent: Monday, December 11, 2023 5:54 PM
To: Nicolau, Radu <[email protected]>; Akhil Goyal <[email protected]>
Cc: [email protected]; Power, Ciara <[email protected]>; Ku, Ting-Kai <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] examples/ipsec-secgw: fix cryptodev to SA mapping
There are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function.
Also add a check to verify that a CQP is available for the current lcore.
--- examples/ipsec-secgw/ipsec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
examples/ipsec-secgw/ipsec.c +3 -4
@@ -288,10 +288,9 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[],if (cdev_id ==RTE_CRYPTO_MAX_DEVS ) cdev_id = ipsec_ctx->tbl[cdev_id_qp].id;else if (cdev_id != ipsec_ctx->tbl[cdev_id_qp].id) { -RTE_LOG (ERR ,IPSEC , -"SA mapping to multiple cryptodevs is " -"not supported!" ); -return -EINVAL ; +RTE_LOG (WARNING ,IPSEC , +"SA mapped to multiple cryptodevs for SPI %d\n" , + sa->spi); } /* Store per core queue pair information */ @@ -908,7 +907,11 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
continue;
}
- enqueue_cop(sa->cqp[ipsec_ctx->lcore_id], &priv->cop);
+ if (sa->cqp[ipsec_ctx->lcore_id])
+ enqueue_cop(sa->cqp[ipsec_ctx->lcore_id], &priv->cop);
+ else
+ RTE_LOG(ERR, IPSEC, "No CQP available for lcore %d\n",
+ ipsec_ctx->lcore_id);
}
}
--
2.25.1
Hi Radu,
Quoted 16 lines
-----Original Message-----
From: Nicolau, Radu <[email protected]>
Sent: Monday, December 11, 2023 9:54 AM
To: Nicolau, Radu <[email protected]>; Akhil Goyal <[email protected]>
Cc: [email protected]; Power, Ciara <[email protected]>; Ku, Ting-Kai <ting- [email protected]>; [email protected]; [email protected]
Subject: [PATCH] examples/ipsec-secgw: fix cryptodev to SA mappingThere are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function.
Also add a check to verify that a CQP is available for the current lcore.Fixes a8ade12123c3 ("examples/ipsec-secgw: create lookaside sessions at
Quoted 8 lines
init")
Cc: [email protected]
Cc: [email protected]Signed-off-by Radu Nicolau <[email protected]>--- examples/ipsec-secgw/ipsec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
________________________________
From: Radu Nicolau <[email protected]>
Sent: 11 December 2023 09:53
To: Nicolau, Radu <[email protected]>; Akhil Goyal <[email protected]>
Cc: [email protected] <[email protected]>; Power, Ciara <[email protected]>; Ku, Ting-Kai <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Subject: [PATCH] examples/ipsec-secgw: fix cryptodev to SA mapping
There are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function. Also add a check to verify that a CQP is available for the current lcore.
---
--
2.25.1
examples/ipsec-secgw/ipsec.c ipsec_enqueue(ipsec_xform_fn xform_func, struct · line 915
Quoted 11 lines
examples/ipsec-secgw/ipsec.c +5
-1@@ -908,7 +907,11 @@ ipsec_enqueue(ipsec_xform_fn xform_func, structipsec_ctx *ipsec_ctx, continue; } -enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +if (sa->cqp[ipsec_ctx->lcore_id]) +enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +else +RTE_LOG (ERR ,IPSEC ,"No CQP available for lcore %d\n" , + ipsec_ctx->lcore_id);
Can we add likely here?
PATCH v2 1/1 examples/ipsec-secgw: fix cryptodev to SA mapping
In reply to Radu NicolauThere are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function. Also add a check to verify that a CQP is available for the current lcore.
---
v2: add likely to CQP available branch
examples/ipsec-secgw/ipsec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
examples/ipsec-secgw/ipsec.c +8 -5
@@ -288,10 +288,9 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[],if (cdev_id ==RTE_CRYPTO_MAX_DEVS ) cdev_id = ipsec_ctx->tbl[cdev_id_qp].id;else if (cdev_id != ipsec_ctx->tbl[cdev_id_qp].id) { -RTE_LOG (ERR ,IPSEC , -"SA mapping to multiple cryptodevs is " -"not supported!" ); -return -EINVAL ; +RTE_LOG (WARNING ,IPSEC , +"SA mapped to multiple cryptodevs for SPI %d\n" , + sa->spi); }/* Store per core queue pair information */
@@ -908,7 +907,11 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,continue ; } -enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +if (likely (sa->cqp[ipsec_ctx->lcore_id])) +enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +else +RTE_LOG (ERR ,IPSEC ,"No CQP available for lcore %d\n" , + ipsec_ctx->lcore_id); } }
Signature · 1 line
2.34.1
Hi Radu,
Using same session across multiple devices would only work if the device instances are same. For example, if you use QAT device 0 & QAT device 1, then the sharing is okay. But if we have QAT and some SW crypto PMD, then the same session will not work. Is it possible to throw a warning when the crypto devices are not of same type?
Thanks,
Anoob
Quoted 69 lines
-----Original Message-----
From: Radu Nicolau <[email protected]>
Sent: Friday, February 23, 2024 4:31 PM
To: [email protected]
Cc: Radu Nicolau <[email protected]>; [email protected]; Volodymyr Fialko <[email protected]>; Ting-Kai Ku <[email protected]>; Ciara Power <[email protected]>; Kai Ji <[email protected]>; Akhil Goyal <[email protected]>
Subject: [EXT] [PATCH v2] examples/ipsec-secgw: fix cryptodev to SA mappingExternal Email
----------------------------------------------------------------------
There are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function. Also add a check to verify that a CQP is available for the current lcore.Fixes a8ade12123c3 ("examples/ipsec-secgw: create lookaside sessions at init")Signed-off-by Radu Nicolau <[email protected]>Signed-off-by Radu Nicolau <[email protected]>Tested-by Ting-Kai Ku <[email protected]>Signed-off-by Radu Nicolau <[email protected]>Acked-by Ciara Power <[email protected]>Acked-by Kai Ji <[email protected]>---
v2: add likely to CQP available branchexamples/ipsec-secgw/ipsec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)examples/ipsec-secgw/ipsec.c index renamed from examples/ipsec-secgw/ipsec.c +0
-0
f5cec4a928..7bb9646736100644examples/ipsec-secgw/ipsec.c +3
-4@@ -288,10 +288,9 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[], if (cdev_id == RTE_CRYPTO_MAX_DEVS) cdev_id = ipsec_ctx->tbl[cdev_id_qp].id; else if (cdev_id != ipsec_ctx->tbl[cdev_id_qp].id) { -RTE_LOG (ERR ,IPSEC , -"SA mapping to multiple cryptodevs is " -"not supported!" ); -return -EINVAL ; +RTE_LOG (WARNING ,IPSEC , + "SA mapped to multiple cryptodevs for SPI %d\n", + sa->spi); }/* Store per core queue pair information */ @@ -908,7 +907,11
@@ ipsec_enqueue(ipsec_xform_fnxform_func, structipsec_ctx*ipsec_ctx,examples/ipsec-secgw/ipsec.c +5
-2continue ; } -enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +if (likely (sa->cqp[ipsec_ctx->lcore_id])) +enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +else +RTE_LOG (ERR ,IPSEC ,"No CQP available for lcore %d\n" , + ipsec_ctx->lcore_id); } } --2.34.1
PATCH v3 1/1 examples/ipsec-secgw: fix cryptodev to SA mapping
In reply to Radu NicolauThere are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function. Also add a check to verify that a CQP is available for the current lcore.
---
v3: check if the cryptodev are not of the same type
examples/ipsec-secgw/ipsec.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
examples/ipsec-secgw/ipsec.c +20 -5
@@ -288,10 +288,21 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[],if (cdev_id ==RTE_CRYPTO_MAX_DEVS ) cdev_id = ipsec_ctx->tbl[cdev_id_qp].id;else if (cdev_id != ipsec_ctx->tbl[cdev_id_qp].id) { -RTE_LOG (ERR ,IPSEC , -"SA mapping to multiple cryptodevs is " -"not supported!" ); -return -EINVAL ; +struct rte_cryptodev_info dev_info_1, dev_info_2; +rte_cryptodev_info_get (cdev_id, &dev_info_1); +rte_cryptodev_info_get (ipsec_ctx->tbl[cdev_id_qp].id, + &dev_info_2); +if (dev_info_1.driver_id == dev_info_2.driver_id) { +RTE_LOG (WARNING ,IPSEC , +"SA mapped to multiple cryptodevs for SPI %d\n" , + sa->spi); + + }else { +RTE_LOG (WARNING ,IPSEC , +"SA mapped to multiple cryptodevs of different types for SPI %d\n" , + sa->spi); + + } }/* Store per core queue pair information */
@@ -908,7 +919,11 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,continue ; } -enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +if (likely (sa->cqp[ipsec_ctx->lcore_id])) +enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +else +RTE_LOG (ERR ,IPSEC ,"No CQP available for lcore %d\n" , + ipsec_ctx->lcore_id); } }
Signature · 1 line
2.34.1
Recheck-request: iol-broadcom-Performance
This patch should not fail a performance test in CI - checking with a rerun now.
Quoted 78 lines · Radu Nicolau
There are use cases where a SA should be able to use different cryptodevs on
different lcores, for example there can be cryptodevs with just 1 qp per VF.
For this purpose this patch relaxes the check in create lookaside session function.
Also add a check to verify that a CQP is available for the current lcore.Fixes a8ade12123c3 ("examples/ipsec-secgw: create lookaside sessions atinit")
Cc: [email protected]
Cc: [email protected]Signed-off-by Radu Nicolau <[email protected]>Tested-by Ting-Kai Ku <[email protected]>Acked-by Ciara Power <[email protected]>Acked-by Kai Ji <[email protected]>---
v3: check if the cryptodev are not of the same typeexamples/ipsec-secgw/ipsec.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)examples/ipsec-secgw/ipsec.c +0
-2@@ -288,10 +288,21 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[], if (cdev_id == RTE_CRYPTO_MAX_DEVS) cdev_id = ipsec_ctx->tbl[cdev_id_qp].id; else if (cdev_id != ipsec_ctx->tbl[cdev_id_qp].id) { - RTE_LOG(ERR, IPSEC, - "SA mapping to multiple cryptodevsis "
examples/ipsec-secgw/ipsec.c +7
-2- "not supported!"); -return -EINVAL ; +struct rte_cryptodev_info dev_info_1, dev_info_2; +rte_cryptodev_info_get (cdev_id, &dev_info_1); +rte_cryptodev_info_get (ipsec_ctx->tbl[cdev_id_qp].id, + &dev_info_2); +if (dev_info_1.driver_id == dev_info_2.driver_id) { + RTE_LOG(WARNING, IPSEC, + "SA mapped to multiple cryptodevsfor SPI %d\n",
examples/ipsec-secgw/ipsec.c +5
-0+ sa->spi); + + }else { + RTE_LOG(WARNING, IPSEC, + "SA mapped to multiple cryptodevsof different types for SPI %d\n",
examples/ipsec-secgw/ipsec.c +8
-1+ sa->spi); + + } }/* Store per core queue pair information */ @@ -908,7 +919,11 @@ ipsec_enqueue(ipsec_xform_fn xform_func, structipsec_ctx *ipsec_ctx, continue; } -enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +if (likely (sa->cqp[ipsec_ctx->lcore_id])) +enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +else + RTE_LOG(ERR, IPSEC, "No CQP available for lcore %d\n", + ipsec_ctx->lcore_id);}}
--
2.34.1
Hi Radu,
Thanks for making the changes. I've one more question. Please see inline.
Thanks,
Anoob
Quoted 67 lines
-----Original Message-----
From: Radu Nicolau <[email protected]>
Sent: Monday, February 26, 2024 3:56 PM
To: [email protected]
Cc: Anoob Joseph <[email protected]>; Radu Nicolau <[email protected]>; [email protected]; Volodymyr Fialko <[email protected]>; Ting-Kai Ku <[email protected]>; Ciara Power <[email protected]>; Kai Ji <[email protected]>; Akhil Goyal <[email protected]>
Subject: [EXT] [PATCH v3] examples/ipsec-secgw: fix cryptodev to SA mappingExternal Email
----------------------------------------------------------------------
There are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function. Also add a check to verify that a CQP is available for the current lcore.Fixes a8ade12123c3 ("examples/ipsec-secgw: create lookaside sessions at init")Signed-off-by Radu Nicolau <[email protected]>Tested-by Ting-Kai Ku <[email protected]>Acked-by Ciara Power <[email protected]>Acked-by Kai Ji <[email protected]>---
v3: check if the cryptodev are not of the same typeexamples/ipsec-secgw/ipsec.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)examples/ipsec-secgw/ipsec.c index renamed from examples/ipsec-secgw/ipsec.c +0
-0
f5cec4a928..b59576c049100644examples/ipsec-secgw/ipsec.c +15
-4@@ -288,10 +288,21 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[], if (cdev_id == RTE_CRYPTO_MAX_DEVS) cdev_id = ipsec_ctx->tbl[cdev_id_qp].id; else if (cdev_id != ipsec_ctx->tbl[cdev_id_qp].id) { -RTE_LOG (ERR ,IPSEC , -"SA mapping to multiple cryptodevs is " -"not supported!" ); -return -EINVAL ; +struct rte_cryptodev_info dev_info_1, dev_info_2; +rte_cryptodev_info_get (cdev_id, &dev_info_1); +rte_cryptodev_info_get (ipsec_ctx->tbl[cdev_id_qp].id, + &dev_info_2); +if (dev_info_1.driver_id == dev_info_2.driver_id) { +RTE_LOG (WARNING ,IPSEC , + "SA mapped to multiple cryptodevs for SPI %d\n", + sa->spi); + + }else { +RTE_LOG (WARNING ,IPSEC , + "SA mapped to multiple cryptodevs of different types for SPI %d\n", + sa->spi); + + }examples/ipsec-secgw/ipsec.c +0
-0} /* Store per core queue pair information */ @@ -908,7 +919,11@@ ipsec_enqueue(ipsec_xform_fn
xform_func, structipsec_ctx*ipsec_ctx,
examples/ipsec-secgw/ipsec.c ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx, · line 926
Quoted 9 lines
examples/ipsec-secgw/ipsec.c +5
-1continue ; } -enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +if (likely (sa->cqp[ipsec_ctx->lcore_id])) +enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +else +RTE_LOG (ERR ,IPSEC ,"No CQP available for lcore %d\n" , + ipsec_ctx->lcore_id);
[Anoob] Throwing an error won't be good enough, right? Won't this lead to packet leaks? Since it is datapath, can't we assume that the configuration would be done correctly in control path?
I would suggest drop this specific change and we can enable multiple cryptodevs with lookaside SAs with the changes proposed.
Quoted 5 lines
}
}--
2.34.1
Hi Anoob, reply inline.
Regards,
Radu
Quoted 85 lines · Anoob Joseph
Hi Radu,
Thanks for making the changes. I've one more question. Please see inline.
Thanks,
AnoobQuoted 70 lines
-----Original Message-----
From: Radu Nicolau <[email protected]>
Sent: Monday, February 26, 2024 3:56 PM
To: [email protected]
Cc: Anoob Joseph <[email protected]>; Radu Nicolau <[email protected]>; [email protected]; Volodymyr Fialko <[email protected]>; Ting-Kai Ku <[email protected]>; Ciara Power <[email protected]>; Kai Ji <[email protected]>; Akhil Goyal <[email protected]>
Subject: [EXT] [PATCH v3] examples/ipsec-secgw: fix cryptodev to SA mappingExternal Email
----------------------------------------------------------------------
There are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function. Also add a check to verify that a CQP is available for the current lcore.Fixes a8ade12123c3 ("examples/ipsec-secgw: create lookaside sessions at init")Signed-off-by Radu Nicolau <[email protected]>Tested-by Ting-Kai Ku <[email protected]>Acked-by Ciara Power <[email protected]>Acked-by Kai Ji <[email protected]>---
v3: check if the cryptodev are not of the same typeexamples/ipsec-secgw/ipsec.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)examples/ipsec-secgw/ipsec.c index renamed from examples/ipsec-secgw/ipsec.c +0
-0
f5cec4a928..b59576c049100644examples/ipsec-secgw/ipsec.c +15
-4@@ -288,10 +288,21 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[], if (cdev_id == RTE_CRYPTO_MAX_DEVS) cdev_id = ipsec_ctx->tbl[cdev_id_qp].id; else if (cdev_id != ipsec_ctx->tbl[cdev_id_qp].id) { -RTE_LOG (ERR ,IPSEC , -"SA mapping to multiple cryptodevs is " -"not supported!" ); -return -EINVAL ; +struct rte_cryptodev_info dev_info_1, dev_info_2; +rte_cryptodev_info_get (cdev_id, &dev_info_1); +rte_cryptodev_info_get (ipsec_ctx->tbl[cdev_id_qp].id, + &dev_info_2); +if (dev_info_1.driver_id == dev_info_2.driver_id) { +RTE_LOG (WARNING ,IPSEC , + "SA mapped to multiple cryptodevs for SPI %d\n", + sa->spi); + + }else { +RTE_LOG (WARNING ,IPSEC , + "SA mapped to multiple cryptodevs of different types for SPI %d\n", + sa->spi); + + }}/* Store per core queue pair information */ @@ -908,7 +919,11
@@ ipsec_enqueue(ipsec_xform_fnxform_func, structipsec_ctx*ipsec_ctx,
continue;
}examples/ipsec-secgw/ipsec.c ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx, · line 926
Quoted 6 lines
examples/ipsec-secgw/ipsec.c +5
-1-enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +if (likely (sa->cqp[ipsec_ctx->lcore_id])) +enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +else +RTE_LOG (ERR ,IPSEC ,"No CQP available for lcore %d\n" , + ipsec_ctx->lcore_id);[Anoob] Throwing an error won't be good enough, right? Won't this lead to packet leaks? Since it is datapath, can't we assume that the configuration would be done correctly in control path?
Quoted 1 line
I would suggest drop this specific change and we can enable multiple cryptodevs with lookaside SAs with the changes proposed.
With the change that removed the lazy initialization of SAs ("examples/ipsec-secgw: create lookaside sessions at init") we can't assume anymore that a worker core has the proper CQP assigned, that is the reason I added the check here, the control path had no errors but there was no CQP assigned to a lcore. Indeed there will be dropped packets but at least there will be no segfault and the user will have an indication on what needs to be done - assign more cryptodevs.
Quoted 5 lines
Quoted 5 lines
} }--
2.34.1
Hi Radu,
Please see inline.
Thanks,
Anoob
Quoted 115 lines
-----Original Message-----
From: Radu Nicolau <[email protected]>
Sent: Tuesday, February 27, 2024 3:41 PM
To: Anoob Joseph <[email protected]>
Cc: [email protected]; Volodymyr Fialko <[email protected]>; Ting-Kai Ku <[email protected]>; Ciara Power <[email protected]>; Kai Ji <[email protected]>; Akhil Goyal <[email protected]>; [email protected]
Subject: Re: [EXT] [PATCH v3] examples/ipsec-secgw: fix cryptodev to SA mappingHi Anoob, reply inline.
Regards,
Radu
Quoted 26 lines · Anoob Joseph
Hi Radu,
Thanks for making the changes. I've one more question. Please see inline.
Thanks,
AnoobQuoted 19 lines
-----Original Message-----
From: Radu Nicolau <[email protected]>
Sent: Monday, February 26, 2024 3:56 PM
To: [email protected]
Cc: Anoob Joseph <[email protected]>; Radu Nicolau <[email protected]>; [email protected]; Volodymyr Fialko <[email protected]>; Ting-Kai Ku <[email protected]>; Ciara Power <[email protected]>; Kai Ji <[email protected]>; Akhil Goyal <[email protected]>
Subject: [EXT] [PATCH v3] examples/ipsec-secgw: fix cryptodev to SA mappingExternal Email
---------------------------------------------------------------------
- There are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF.
For this purpose this patch relaxes the check in create lookaside sessionfunction.
Quoted 17 lines
Quoted 17 lines
Also add a check to verify that a CQP is available for the current lcore.
Fixes a8ade12123c3 ("examples/ipsec-secgw: create lookaside sessionsat init")
Cc: [email protected]
Cc: [email protected]Signed-off-by Radu Nicolau <[email protected]>Tested-by Ting-Kai Ku <[email protected]>Acked-by Ciara Power <[email protected]>Acked-by Kai Ji <[email protected]>---
v3: check if the cryptodev are not of the same typeexamples/ipsec-secgw/ipsec.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)Quoted 12 lines
examples/ipsec-secgw/ipsec.c create_lookaside_session(struct ipsec_ctx · line 293
Quoted 12 lines
(quoted diff) +0
-0
b/examples/ipsec-secgw/ipsec.cindexf5cec4a928..b59576c049100644examples/ipsec-secgw/ipsec.c +0
-2@@ -288,10 +288,21 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[], if (cdev_id == RTE_CRYPTO_MAX_DEVS) cdev_id = ipsec_ctx->tbl[cdev_id_qp].id; else if (cdev_id != ipsec_ctx->tbl[cdev_id_qp].id) { - RTE_LOG(ERR, IPSEC, - "SA mapping to multiple cryptodevs is"
Quoted 9 lines
examples/ipsec-secgw/ipsec.c create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[],
Quoted 9 lines
examples/ipsec-secgw/ipsec.c +7
-2- "not supported!"); -return -EINVAL ; +struct rte_cryptodev_info dev_info_1, dev_info_2; +rte_cryptodev_info_get (cdev_id, &dev_info_1); +rte_cryptodev_info_get (ipsec_ctx->tbl[cdev_id_qp].id, + &dev_info_2); +if (dev_info_1.driver_id == dev_info_2.driver_id) { + RTE_LOG(WARNING, IPSEC, + "SA mapped to multiple cryptodevsfor
Quoted 12 lines
Quoted 12 lines
examples/ipsec-secgw/ipsec.c +8
-0SPI %d\n", + sa->spi); + + }else { +RTE_LOG (WARNING ,IPSEC , + "SA mapped to multiple cryptodevs of different types for SPI %d\n", + sa->spi); + + }}Quoted 1 line
Quoted 1 line
/* Store per core queue pair information */ @@ -908,7
+919,11 @@
Quoted 10 lines
examples/ipsec-secgw/ipsec.c ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
Quoted 7 lines
ipsec_enqueue(ipsec_xform_fn
xform_func, structipsec_ctx*ipsec_ctx,
continue;
}examples/ipsec-secgw/ipsec.c +2
-1-enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); +if (likely (sa->cqp[ipsec_ctx->lcore_id])) + enqueue_cop(sa->cqp[ipsec_ctx->lcore_id], &priv-cop);
examples/ipsec-secgw/ipsec.c
Quoted 2 lines
examples/ipsec-secgw/ipsec.c +2
-0+else + RTE_LOG(ERR, IPSEC, "No CQP available for lcore%d\n",
Quoted 2 lines
examples/ipsec-secgw/ipsec.c ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx, · line 926
Quoted 1 line
examples/ipsec-secgw/ipsec.c +1
-0+ ipsec_ctx->lcore_id);[Anoob] Throwing an error won't be good enough, right? Won't this lead to
packet leaks? Since it is datapath, can't we assume that the configuration would be done correctly in control path?
Quoted 2 lines
I would suggest drop this specific change and we can enable multiple
Quoted 8 lines
cryptodevs with lookaside SAs with the changes proposed.
With the change that removed the lazy initialization of SAs ("examples/ipsec-secgw: create lookaside sessions at init") we can't assume anymore that a worker core has the proper CQP assigned, that is the reason I added the check here, the control path had no errors but there was no CQP assigned to a lcore. Indeed there will be dropped packets but at least there will be no segfault and the user will have an indication on what needs to be done - assign more cryptodevs.
[Anoob] I understand your concern. I was just worried about an extra check coming in data path which can impact performance benchmarks with valid configuration. Can we keep the check under a debug flag? Is that okay?
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
} }--
2.34.1
PATCH v4 1/1 examples/ipsec-secgw: fix cryptodev to SA mapping
In reply to Radu NicolauThere are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function. Also add a check to verify that a CQP is available for the current lcore.
---
v4: replaced plain if with RTE_ASSERT
examples/ipsec-secgw/ipsec.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
examples/ipsec-secgw/ipsec.c +16 -4
@@ -288,10 +288,21 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx_lcore[],if (cdev_id ==RTE_CRYPTO_MAX_DEVS ) cdev_id = ipsec_ctx->tbl[cdev_id_qp].id;else if (cdev_id != ipsec_ctx->tbl[cdev_id_qp].id) { -RTE_LOG (ERR ,IPSEC , -"SA mapping to multiple cryptodevs is " -"not supported!" ); -return -EINVAL ; +struct rte_cryptodev_info dev_info_1, dev_info_2; +rte_cryptodev_info_get (cdev_id, &dev_info_1); +rte_cryptodev_info_get (ipsec_ctx->tbl[cdev_id_qp].id, + &dev_info_2); +if (dev_info_1.driver_id == dev_info_2.driver_id) { +RTE_LOG (WARNING ,IPSEC , +"SA mapped to multiple cryptodevs for SPI %d\n" , + sa->spi); + + }else { +RTE_LOG (WARNING ,IPSEC , +"SA mapped to multiple cryptodevs of different types for SPI %d\n" , + sa->spi); + + } }/* Store per core queue pair information */
@@ -908,6 +919,7 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,continue ; } +RTE_ASSERT (sa->cqp[ipsec_ctx->lcore_id] !=NULL );enqueue_cop (sa->cqp[ipsec_ctx->lcore_id], &priv->cop); } }
Signature · 1 line
2.34.1
Quoted 9 lines
----------------------------------------------------------------------
There are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function.
Also add a check to verify that a CQP is available for the current lcore.Fixes a8ade12123c3 ("examples/ipsec-secgw: create lookaside sessions at
Quoted 8 lines
init")
Cc: [email protected]
Cc: [email protected]Signed-off-by Radu Nicolau <[email protected]>Tested-by Ting-Kai Ku <[email protected]>Acked-by Ciara Power <[email protected]>Acked-by Kai Ji <[email protected]>
Akhil Goyal
AppliedQuoted 11 lines
Quoted 11 lines
There are use cases where a SA should be able to use different cryptodevs on different lcores, for example there can be cryptodevs with just 1 qp per VF. For this purpose this patch relaxes the check in create lookaside session function.
Also add a check to verify that a CQP is available for the current lcore.Fixes a8ade12123c3 ("examples/ipsec-secgw: create lookaside sessions atinit")
Cc: [email protected]
Cc: [email protected]
Quoted 7 lines
Quoted 4 lines
Signed-off-by Radu Nicolau <[email protected]>Tested-by Ting-Kai Ku <[email protected]>Acked-by Ciara Power <[email protected]>Acked-by Kai Ji <[email protected]>Acked-by Anoob Joseph <[email protected]>
Applied to dpdk-next-crypto
Thanks.