bdev/crypto: assert that a QAT DMA never crosses a 2MB boundary

Because required alignment is already set to block size and by design
the crypto module does one crypto operation per block (it uses the
LBA as the initialization vector) it should not be possible to get
a physical address that spans however adding an assert just in case.

Change-Id: I1dc844d0a32395f9ed4869429368f60b919703a4
Signed-off-by: paul luse <paul.e.luse@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465107
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
paul luse 2019-08-13 18:12:28 -04:00 committed by Jim Harris
parent de03082191
commit 3966e0bf2e

View File

@ -598,7 +598,7 @@ _crypto_operation(struct spdk_bdev_io *bdev_io, enum rte_crypto_cipher_operation
uint32_t allocated = 0;
uint8_t *current_iov = NULL;
uint64_t total_remaining = 0;
uint64_t current_iov_remaining = 0;
uint64_t updated_length, current_iov_remaining = 0;
int completed = 0;
int crypto_index = 0;
uint32_t en_offset = 0;
@ -688,8 +688,9 @@ _crypto_operation(struct spdk_bdev_io *bdev_io, enum rte_crypto_cipher_operation
/* Set the mbuf elements address and length. Null out the next pointer. */
src_mbufs[crypto_index]->buf_addr = current_iov;
src_mbufs[crypto_index]->buf_iova = spdk_vtophys((void *)current_iov, NULL);
src_mbufs[crypto_index]->data_len = crypto_len;
src_mbufs[crypto_index]->data_len = updated_length = crypto_len;
src_mbufs[crypto_index]->buf_iova = spdk_vtophys((void *)current_iov, &updated_length);
assert(updated_length == crypto_len);
src_mbufs[crypto_index]->next = NULL;
/* Store context in every mbuf as we don't know anything about completion order */
src_mbufs[crypto_index]->userdata = bdev_io;
@ -721,9 +722,10 @@ _crypto_operation(struct spdk_bdev_io *bdev_io, enum rte_crypto_cipher_operation
/* Set the relevant destination en_mbuf elements. */
dst_mbufs[crypto_index]->buf_addr = io_ctx->cry_iov.iov_base + en_offset;
dst_mbufs[crypto_index]->data_len = updated_length = crypto_len;
dst_mbufs[crypto_index]->buf_iova = spdk_vtophys(dst_mbufs[crypto_index]->buf_addr,
NULL);
dst_mbufs[crypto_index]->data_len = crypto_len;
&updated_length);
assert(updated_length == crypto_len);
crypto_ops[crypto_index]->sym->m_dst = dst_mbufs[crypto_index];
en_offset += crypto_len;
dst_mbufs[crypto_index]->next = NULL;