Crypto PMDs would specify the head/tailroom it would use while
processing the crypto requests. This need to be considered while
verifying buffers processed by crypto PMDs.

Signed-off-by: Anoob Joseph <anoob.jos...@caviumnetworks.com>
---
v1:
* Added patch

 test/test/test_cryptodev_blockcipher.c | 60 ++++++++++++++++++++++++++++++----
 1 file changed, 54 insertions(+), 6 deletions(-)

diff --git a/test/test/test_cryptodev_blockcipher.c 
b/test/test/test_cryptodev_blockcipher.c
index 256a7da..c64b0c1 100644
--- a/test/test/test_cryptodev_blockcipher.c
+++ b/test/test/test_cryptodev_blockcipher.c
@@ -75,8 +75,9 @@ test_blockcipher_one_case(const struct blockcipher_test_case 
*t,
 
        int nb_segs = 1;
 
+       rte_cryptodev_info_get(dev_id, &dev_info);
+
        if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SG) {
-               rte_cryptodev_info_get(dev_id, &dev_info);
                if (!(dev_info.feature_flags &
                                RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
                        printf("Device doesn't support scatter-gather. "
@@ -438,11 +439,34 @@ test_blockcipher_one_case(const struct 
blockcipher_test_case *t,
                uint8_t value;
                uint32_t head_unchanged_len, changed_len = 0;
                uint32_t i;
+               uint32_t hdroom_used = 0, tlroom_used = 0;
+               uint32_t hdroom = 0;
 
                mbuf = sym_op->m_src;
+               /*
+                * Crypto PMDs specify the headroom & tailroom it would use
+                * when processing the crypto operation. PMD is free to modify
+                * this space, and so the verification check should skip that
+                * block.
+                */
+               hdroom_used = dev_info.min_mbuf_headroom_req;
+               tlroom_used = dev_info.min_mbuf_tailroom_req;
+
+               /* Get headroom */
+               hdroom = rte_pktmbuf_headroom(mbuf);
+
                head_unchanged_len = mbuf->buf_len;
 
                for (i = 0; i < mbuf->buf_len; i++) {
+
+                       /* Skip headroom used by PMD */
+                       if (i == hdroom - hdroom_used)
+                               i += hdroom_used;
+
+                       /* Skip tailroom used by PMD */
+                       if (i == (hdroom + mbuf->data_len))
+                               i += tlroom_used;
+
                        value = *((uint8_t *)(mbuf->buf_addr)+i);
                        if (value != tmp_src_buf[i]) {
                                snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
@@ -455,14 +479,13 @@ test_blockcipher_one_case(const struct 
blockcipher_test_case *t,
 
                mbuf = sym_op->m_dst;
                if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
-                       head_unchanged_len = rte_pktmbuf_headroom(mbuf) +
-                                               sym_op->auth.data.offset;
+                       head_unchanged_len = hdroom + sym_op->auth.data.offset;
                        changed_len = sym_op->auth.data.length;
                        if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
                                changed_len += digest_len;
                } else {
                        /* cipher-only */
-                       head_unchanged_len = rte_pktmbuf_headroom(mbuf) +
+                       head_unchanged_len = hdroom +
                                        sym_op->cipher.data.offset;
                        changed_len = sym_op->cipher.data.length;
                }
@@ -486,15 +509,30 @@ test_blockcipher_one_case(const struct 
blockcipher_test_case *t,
                uint8_t value;
                uint32_t head_unchanged_len = 0, changed_len = 0;
                uint32_t i;
+               uint32_t hdroom_used = 0, tlroom_used = 0;
+               uint32_t hdroom = 0;
+
+               /*
+                * Crypto PMDs specify the headroom & tailroom it would use
+                * when processing the crypto operation. PMD is free to modify
+                * this space, and so the verification check should skip that
+                * block.
+                */
+               hdroom_used = dev_info.min_mbuf_headroom_req;
+               tlroom_used = dev_info.min_mbuf_tailroom_req;
 
                mbuf = sym_op->m_src;
+
+               /* Get headroom */
+               hdroom = rte_pktmbuf_headroom(mbuf);
+
                if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
-                       head_unchanged_len = rte_pktmbuf_headroom(mbuf) +
+                       head_unchanged_len = hdroom +
                                        sym_op->cipher.data.offset;
                        changed_len = sym_op->cipher.data.length;
                } else {
                        /* auth-only */
-                       head_unchanged_len = rte_pktmbuf_headroom(mbuf) +
+                       head_unchanged_len = hdroom +
                                        sym_op->auth.data.offset +
                                        sym_op->auth.data.length;
                        changed_len = 0;
@@ -504,8 +542,18 @@ test_blockcipher_one_case(const struct 
blockcipher_test_case *t,
                        changed_len += digest_len;
 
                for (i = 0; i < mbuf->buf_len; i++) {
+
+                       /* Skip headroom used by PMD */
+                       if (i == hdroom - hdroom_used)
+                               i += hdroom_used;
+
                        if (i == head_unchanged_len)
                                i += changed_len;
+
+                       /* Skip tailroom used by PMD */
+                       if (i == (hdroom + mbuf->data_len))
+                               i += tlroom_used;
+
                        value = *((uint8_t *)(mbuf->buf_addr)+i);
                        if (value != tmp_src_buf[i]) {
                                snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
-- 
2.7.4

Reply via email to