| .. | .. |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | #include "nitrox_dev.h" |
|---|
| 9 | 9 | |
|---|
| 10 | +#define PENDING_SIG 0xFFFFFFFFFFFFFFFFUL |
|---|
| 11 | +#define PRIO 4001 |
|---|
| 12 | + |
|---|
| 13 | +typedef void (*sereq_completion_t)(void *req, int err); |
|---|
| 14 | + |
|---|
| 10 | 15 | /** |
|---|
| 11 | 16 | * struct gphdr - General purpose Header |
|---|
| 12 | 17 | * @param0: first parameter. |
|---|
| .. | .. |
|---|
| 46 | 51 | } s; |
|---|
| 47 | 52 | }; |
|---|
| 48 | 53 | |
|---|
| 49 | | -struct nitrox_sglist { |
|---|
| 50 | | - u16 len; |
|---|
| 51 | | - u16 raz0; |
|---|
| 52 | | - u32 raz1; |
|---|
| 53 | | - dma_addr_t dma; |
|---|
| 54 | | -}; |
|---|
| 55 | | - |
|---|
| 56 | 54 | #define MAX_IV_LEN 16 |
|---|
| 57 | 55 | |
|---|
| 58 | 56 | /** |
|---|
| .. | .. |
|---|
| 62 | 60 | * @ctx_handle: Crypto context handle. |
|---|
| 63 | 61 | * @gph: GP Header |
|---|
| 64 | 62 | * @ctrl: Request Information. |
|---|
| 65 | | - * @in: Input sglist |
|---|
| 66 | | - * @out: Output sglist |
|---|
| 63 | + * @orh: ORH address |
|---|
| 64 | + * @comp: completion address |
|---|
| 65 | + * @src: Input sglist |
|---|
| 66 | + * @dst: Output sglist |
|---|
| 67 | 67 | */ |
|---|
| 68 | 68 | struct se_crypto_request { |
|---|
| 69 | 69 | u8 opcode; |
|---|
| .. | .. |
|---|
| 73 | 73 | |
|---|
| 74 | 74 | struct gphdr gph; |
|---|
| 75 | 75 | union se_req_ctrl ctrl; |
|---|
| 76 | | - |
|---|
| 77 | | - u8 iv[MAX_IV_LEN]; |
|---|
| 78 | | - u16 ivsize; |
|---|
| 76 | + u64 *orh; |
|---|
| 77 | + u64 *comp; |
|---|
| 79 | 78 | |
|---|
| 80 | 79 | struct scatterlist *src; |
|---|
| 81 | 80 | struct scatterlist *dst; |
|---|
| .. | .. |
|---|
| 110 | 109 | CIPHER_INVALID |
|---|
| 111 | 110 | }; |
|---|
| 112 | 111 | |
|---|
| 112 | +enum flexi_auth { |
|---|
| 113 | + AUTH_NULL = 0, |
|---|
| 114 | + AUTH_MD5, |
|---|
| 115 | + AUTH_SHA1, |
|---|
| 116 | + AUTH_SHA2_SHA224, |
|---|
| 117 | + AUTH_SHA2_SHA256, |
|---|
| 118 | + AUTH_SHA2_SHA384, |
|---|
| 119 | + AUTH_SHA2_SHA512, |
|---|
| 120 | + AUTH_GMAC, |
|---|
| 121 | + AUTH_INVALID |
|---|
| 122 | +}; |
|---|
| 123 | + |
|---|
| 113 | 124 | /** |
|---|
| 114 | 125 | * struct crypto_keys - Crypto keys |
|---|
| 115 | 126 | * @key: Encryption key or KEY1 for AES-XTS |
|---|
| .. | .. |
|---|
| 136 | 147 | u8 opad[64]; |
|---|
| 137 | 148 | }; |
|---|
| 138 | 149 | |
|---|
| 150 | +union fc_ctx_flags { |
|---|
| 151 | + __be64 f; |
|---|
| 152 | + struct { |
|---|
| 153 | +#if defined(__BIG_ENDIAN_BITFIELD) |
|---|
| 154 | + u64 cipher_type : 4; |
|---|
| 155 | + u64 reserved_59 : 1; |
|---|
| 156 | + u64 aes_keylen : 2; |
|---|
| 157 | + u64 iv_source : 1; |
|---|
| 158 | + u64 hash_type : 4; |
|---|
| 159 | + u64 reserved_49_51 : 3; |
|---|
| 160 | + u64 auth_input_type: 1; |
|---|
| 161 | + u64 mac_len : 8; |
|---|
| 162 | + u64 reserved_0_39 : 40; |
|---|
| 163 | +#else |
|---|
| 164 | + u64 reserved_0_39 : 40; |
|---|
| 165 | + u64 mac_len : 8; |
|---|
| 166 | + u64 auth_input_type: 1; |
|---|
| 167 | + u64 reserved_49_51 : 3; |
|---|
| 168 | + u64 hash_type : 4; |
|---|
| 169 | + u64 iv_source : 1; |
|---|
| 170 | + u64 aes_keylen : 2; |
|---|
| 171 | + u64 reserved_59 : 1; |
|---|
| 172 | + u64 cipher_type : 4; |
|---|
| 173 | +#endif |
|---|
| 174 | + } w0; |
|---|
| 175 | +}; |
|---|
| 139 | 176 | /** |
|---|
| 140 | 177 | * struct flexi_crypto_context - Crypto context |
|---|
| 141 | 178 | * @cipher_type: Encryption cipher type |
|---|
| .. | .. |
|---|
| 150 | 187 | * @auth: Authentication keys |
|---|
| 151 | 188 | */ |
|---|
| 152 | 189 | struct flexi_crypto_context { |
|---|
| 153 | | - union { |
|---|
| 154 | | - __be64 flags; |
|---|
| 155 | | - struct { |
|---|
| 156 | | -#if defined(__BIG_ENDIAN_BITFIELD) |
|---|
| 157 | | - u64 cipher_type : 4; |
|---|
| 158 | | - u64 reserved_59 : 1; |
|---|
| 159 | | - u64 aes_keylen : 2; |
|---|
| 160 | | - u64 iv_source : 1; |
|---|
| 161 | | - u64 hash_type : 4; |
|---|
| 162 | | - u64 reserved_49_51 : 3; |
|---|
| 163 | | - u64 auth_input_type: 1; |
|---|
| 164 | | - u64 mac_len : 8; |
|---|
| 165 | | - u64 reserved_0_39 : 40; |
|---|
| 166 | | -#else |
|---|
| 167 | | - u64 reserved_0_39 : 40; |
|---|
| 168 | | - u64 mac_len : 8; |
|---|
| 169 | | - u64 auth_input_type: 1; |
|---|
| 170 | | - u64 reserved_49_51 : 3; |
|---|
| 171 | | - u64 hash_type : 4; |
|---|
| 172 | | - u64 iv_source : 1; |
|---|
| 173 | | - u64 aes_keylen : 2; |
|---|
| 174 | | - u64 reserved_59 : 1; |
|---|
| 175 | | - u64 cipher_type : 4; |
|---|
| 176 | | -#endif |
|---|
| 177 | | - } w0; |
|---|
| 178 | | - }; |
|---|
| 179 | | - |
|---|
| 190 | + union fc_ctx_flags flags; |
|---|
| 180 | 191 | struct crypto_keys crypto; |
|---|
| 181 | 192 | struct auth_keys auth; |
|---|
| 182 | 193 | }; |
|---|
| .. | .. |
|---|
| 194 | 205 | struct flexi_crypto_context *fctx; |
|---|
| 195 | 206 | } u; |
|---|
| 196 | 207 | struct crypto_ctx_hdr *chdr; |
|---|
| 208 | + sereq_completion_t callback; |
|---|
| 197 | 209 | }; |
|---|
| 198 | 210 | |
|---|
| 199 | 211 | struct nitrox_kcrypt_request { |
|---|
| 200 | 212 | struct se_crypto_request creq; |
|---|
| 201 | | - struct nitrox_crypto_ctx *nctx; |
|---|
| 202 | | - struct skcipher_request *skreq; |
|---|
| 213 | + u8 *src; |
|---|
| 214 | + u8 *dst; |
|---|
| 215 | + u8 *iv_out; |
|---|
| 216 | +}; |
|---|
| 217 | + |
|---|
| 218 | +/** |
|---|
| 219 | + * struct nitrox_aead_rctx - AEAD request context |
|---|
| 220 | + * @nkreq: Base request context |
|---|
| 221 | + * @cryptlen: Encryption/Decryption data length |
|---|
| 222 | + * @assoclen: AAD length |
|---|
| 223 | + * @srclen: Input buffer length |
|---|
| 224 | + * @dstlen: Output buffer length |
|---|
| 225 | + * @iv: IV data |
|---|
| 226 | + * @ivsize: IV data length |
|---|
| 227 | + * @flags: AEAD req flags |
|---|
| 228 | + * @ctx_handle: Device context handle |
|---|
| 229 | + * @src: Source sglist |
|---|
| 230 | + * @dst: Destination sglist |
|---|
| 231 | + * @ctrl_arg: Identifies the request type (ENCRYPT/DECRYPT) |
|---|
| 232 | + */ |
|---|
| 233 | +struct nitrox_aead_rctx { |
|---|
| 234 | + struct nitrox_kcrypt_request nkreq; |
|---|
| 235 | + unsigned int cryptlen; |
|---|
| 236 | + unsigned int assoclen; |
|---|
| 237 | + unsigned int srclen; |
|---|
| 238 | + unsigned int dstlen; |
|---|
| 239 | + u8 *iv; |
|---|
| 240 | + int ivsize; |
|---|
| 241 | + u32 flags; |
|---|
| 242 | + u64 ctx_handle; |
|---|
| 243 | + struct scatterlist *src; |
|---|
| 244 | + struct scatterlist *dst; |
|---|
| 245 | + u8 ctrl_arg; |
|---|
| 246 | +}; |
|---|
| 247 | + |
|---|
| 248 | +/** |
|---|
| 249 | + * struct nitrox_rfc4106_rctx - rfc4106 cipher request context |
|---|
| 250 | + * @base: AEAD request context |
|---|
| 251 | + * @src: Source sglist |
|---|
| 252 | + * @dst: Destination sglist |
|---|
| 253 | + * @assoc: AAD |
|---|
| 254 | + */ |
|---|
| 255 | +struct nitrox_rfc4106_rctx { |
|---|
| 256 | + struct nitrox_aead_rctx base; |
|---|
| 257 | + struct scatterlist src[3]; |
|---|
| 258 | + struct scatterlist dst[3]; |
|---|
| 259 | + u8 assoc[20]; |
|---|
| 203 | 260 | }; |
|---|
| 204 | 261 | |
|---|
| 205 | 262 | /** |
|---|
| .. | .. |
|---|
| 347 | 404 | }; |
|---|
| 348 | 405 | |
|---|
| 349 | 406 | /** |
|---|
| 407 | + * struct aqmq_command_s - The 32 byte command for AE processing. |
|---|
| 408 | + * @opcode: Request opcode |
|---|
| 409 | + * @param1: Request control parameter 1 |
|---|
| 410 | + * @param2: Request control parameter 2 |
|---|
| 411 | + * @dlen: Input length |
|---|
| 412 | + * @dptr: Input pointer points to buffer in remote host |
|---|
| 413 | + * @rptr: Result pointer points to buffer in remote host |
|---|
| 414 | + * @grp: AQM Group (0..7) |
|---|
| 415 | + * @cptr: Context pointer |
|---|
| 416 | + */ |
|---|
| 417 | +struct aqmq_command_s { |
|---|
| 418 | + __be16 opcode; |
|---|
| 419 | + __be16 param1; |
|---|
| 420 | + __be16 param2; |
|---|
| 421 | + __be16 dlen; |
|---|
| 422 | + __be64 dptr; |
|---|
| 423 | + __be64 rptr; |
|---|
| 424 | + union { |
|---|
| 425 | + __be64 word3; |
|---|
| 426 | +#if defined(__BIG_ENDIAN_BITFIELD) |
|---|
| 427 | + u64 grp : 3; |
|---|
| 428 | + u64 cptr : 61; |
|---|
| 429 | +#else |
|---|
| 430 | + u64 cptr : 61; |
|---|
| 431 | + u64 grp : 3; |
|---|
| 432 | +#endif |
|---|
| 433 | + }; |
|---|
| 434 | +}; |
|---|
| 435 | + |
|---|
| 436 | +/** |
|---|
| 350 | 437 | * struct ctx_hdr - Book keeping data about the crypto context |
|---|
| 351 | 438 | * @pool: Pool used to allocate crypto context |
|---|
| 352 | 439 | * @dma: Base DMA address of the cypto context |
|---|
| .. | .. |
|---|
| 376 | 463 | |
|---|
| 377 | 464 | /* |
|---|
| 378 | 465 | * strutct nitrox_sgtable - SG list information |
|---|
| 379 | | - * @map_cnt: Number of buffers mapped |
|---|
| 380 | | - * @nr_comp: Number of sglist components |
|---|
| 466 | + * @sgmap_cnt: Number of buffers mapped |
|---|
| 381 | 467 | * @total_bytes: Total bytes in sglist. |
|---|
| 382 | | - * @len: Total sglist components length. |
|---|
| 383 | | - * @dma: DMA address of sglist component. |
|---|
| 384 | | - * @dir: DMA direction. |
|---|
| 385 | | - * @buf: crypto request buffer. |
|---|
| 386 | | - * @sglist: SG list of input/output buffers. |
|---|
| 468 | + * @sgcomp_len: Total sglist components length. |
|---|
| 469 | + * @sgcomp_dma: DMA address of sglist component. |
|---|
| 470 | + * @sg: crypto request buffer. |
|---|
| 387 | 471 | * @sgcomp: sglist component for NITROX. |
|---|
| 388 | 472 | */ |
|---|
| 389 | 473 | struct nitrox_sgtable { |
|---|
| 390 | | - u8 map_bufs_cnt; |
|---|
| 391 | | - u8 nr_sgcomp; |
|---|
| 474 | + u8 sgmap_cnt; |
|---|
| 392 | 475 | u16 total_bytes; |
|---|
| 393 | | - u32 len; |
|---|
| 394 | | - dma_addr_t dma; |
|---|
| 395 | | - enum dma_data_direction dir; |
|---|
| 396 | | - |
|---|
| 397 | | - struct scatterlist *buf; |
|---|
| 398 | | - struct nitrox_sglist *sglist; |
|---|
| 476 | + u32 sgcomp_len; |
|---|
| 477 | + dma_addr_t sgcomp_dma; |
|---|
| 478 | + struct scatterlist *sg; |
|---|
| 399 | 479 | struct nitrox_sgcomp *sgcomp; |
|---|
| 400 | 480 | }; |
|---|
| 401 | 481 | |
|---|
| .. | .. |
|---|
| 405 | 485 | #define COMP_HLEN 8 |
|---|
| 406 | 486 | |
|---|
| 407 | 487 | struct resp_hdr { |
|---|
| 408 | | - u64 orh; |
|---|
| 409 | | - dma_addr_t orh_dma; |
|---|
| 410 | | - u64 completion; |
|---|
| 411 | | - dma_addr_t completion_dma; |
|---|
| 488 | + u64 *orh; |
|---|
| 489 | + u64 *completion; |
|---|
| 412 | 490 | }; |
|---|
| 413 | 491 | |
|---|
| 414 | | -typedef void (*completion_t)(struct skcipher_request *skreq, int err); |
|---|
| 492 | +typedef void (*completion_t)(void *arg, int err); |
|---|
| 415 | 493 | |
|---|
| 416 | 494 | /** |
|---|
| 417 | 495 | * struct nitrox_softreq - Represents the NIROX Request. |
|---|
| .. | .. |
|---|
| 434 | 512 | u32 flags; |
|---|
| 435 | 513 | gfp_t gfp; |
|---|
| 436 | 514 | atomic_t status; |
|---|
| 437 | | - bool inplace; |
|---|
| 438 | 515 | |
|---|
| 439 | 516 | struct nitrox_device *ndev; |
|---|
| 440 | 517 | struct nitrox_cmdq *cmdq; |
|---|
| .. | .. |
|---|
| 447 | 524 | unsigned long tstamp; |
|---|
| 448 | 525 | |
|---|
| 449 | 526 | completion_t callback; |
|---|
| 450 | | - struct skcipher_request *skreq; |
|---|
| 527 | + void *cb_arg; |
|---|
| 451 | 528 | }; |
|---|
| 452 | 529 | |
|---|
| 530 | +static inline int flexi_aes_keylen(int keylen) |
|---|
| 531 | +{ |
|---|
| 532 | + int aes_keylen; |
|---|
| 533 | + |
|---|
| 534 | + switch (keylen) { |
|---|
| 535 | + case AES_KEYSIZE_128: |
|---|
| 536 | + aes_keylen = 1; |
|---|
| 537 | + break; |
|---|
| 538 | + case AES_KEYSIZE_192: |
|---|
| 539 | + aes_keylen = 2; |
|---|
| 540 | + break; |
|---|
| 541 | + case AES_KEYSIZE_256: |
|---|
| 542 | + aes_keylen = 3; |
|---|
| 543 | + break; |
|---|
| 544 | + default: |
|---|
| 545 | + aes_keylen = -EINVAL; |
|---|
| 546 | + break; |
|---|
| 547 | + } |
|---|
| 548 | + return aes_keylen; |
|---|
| 549 | +} |
|---|
| 550 | + |
|---|
| 551 | +static inline void *alloc_req_buf(int nents, int extralen, gfp_t gfp) |
|---|
| 552 | +{ |
|---|
| 553 | + size_t size; |
|---|
| 554 | + |
|---|
| 555 | + size = sizeof(struct scatterlist) * nents; |
|---|
| 556 | + size += extralen; |
|---|
| 557 | + |
|---|
| 558 | + return kzalloc(size, gfp); |
|---|
| 559 | +} |
|---|
| 560 | + |
|---|
| 561 | +/** |
|---|
| 562 | + * create_single_sg - Point SG entry to the data |
|---|
| 563 | + * @sg: Destination SG list |
|---|
| 564 | + * @buf: Data |
|---|
| 565 | + * @buflen: Data length |
|---|
| 566 | + * |
|---|
| 567 | + * Returns next free entry in the destination SG list |
|---|
| 568 | + **/ |
|---|
| 569 | +static inline struct scatterlist *create_single_sg(struct scatterlist *sg, |
|---|
| 570 | + void *buf, int buflen) |
|---|
| 571 | +{ |
|---|
| 572 | + sg_set_buf(sg, buf, buflen); |
|---|
| 573 | + sg++; |
|---|
| 574 | + return sg; |
|---|
| 575 | +} |
|---|
| 576 | + |
|---|
| 577 | +/** |
|---|
| 578 | + * create_multi_sg - Create multiple sg entries with buflen data length from |
|---|
| 579 | + * source sglist |
|---|
| 580 | + * @to_sg: Destination SG list |
|---|
| 581 | + * @from_sg: Source SG list |
|---|
| 582 | + * @buflen: Data length |
|---|
| 583 | + * |
|---|
| 584 | + * Returns next free entry in the destination SG list |
|---|
| 585 | + **/ |
|---|
| 586 | +static inline struct scatterlist *create_multi_sg(struct scatterlist *to_sg, |
|---|
| 587 | + struct scatterlist *from_sg, |
|---|
| 588 | + int buflen) |
|---|
| 589 | +{ |
|---|
| 590 | + struct scatterlist *sg = to_sg; |
|---|
| 591 | + unsigned int sglen; |
|---|
| 592 | + |
|---|
| 593 | + for (; buflen && from_sg; buflen -= sglen) { |
|---|
| 594 | + sglen = from_sg->length; |
|---|
| 595 | + if (sglen > buflen) |
|---|
| 596 | + sglen = buflen; |
|---|
| 597 | + |
|---|
| 598 | + sg_set_buf(sg, sg_virt(from_sg), sglen); |
|---|
| 599 | + from_sg = sg_next(from_sg); |
|---|
| 600 | + sg++; |
|---|
| 601 | + } |
|---|
| 602 | + |
|---|
| 603 | + return sg; |
|---|
| 604 | +} |
|---|
| 605 | + |
|---|
| 606 | +static inline void set_orh_value(u64 *orh) |
|---|
| 607 | +{ |
|---|
| 608 | + WRITE_ONCE(*orh, PENDING_SIG); |
|---|
| 609 | +} |
|---|
| 610 | + |
|---|
| 611 | +static inline void set_comp_value(u64 *comp) |
|---|
| 612 | +{ |
|---|
| 613 | + WRITE_ONCE(*comp, PENDING_SIG); |
|---|
| 614 | +} |
|---|
| 615 | + |
|---|
| 616 | +static inline int alloc_src_req_buf(struct nitrox_kcrypt_request *nkreq, |
|---|
| 617 | + int nents, int ivsize) |
|---|
| 618 | +{ |
|---|
| 619 | + struct se_crypto_request *creq = &nkreq->creq; |
|---|
| 620 | + |
|---|
| 621 | + nkreq->src = alloc_req_buf(nents, ivsize, creq->gfp); |
|---|
| 622 | + if (!nkreq->src) |
|---|
| 623 | + return -ENOMEM; |
|---|
| 624 | + |
|---|
| 625 | + return 0; |
|---|
| 626 | +} |
|---|
| 627 | + |
|---|
| 628 | +static inline void nitrox_creq_copy_iv(char *dst, char *src, int size) |
|---|
| 629 | +{ |
|---|
| 630 | + memcpy(dst, src, size); |
|---|
| 631 | +} |
|---|
| 632 | + |
|---|
| 633 | +static inline struct scatterlist *nitrox_creq_src_sg(char *iv, int ivsize) |
|---|
| 634 | +{ |
|---|
| 635 | + return (struct scatterlist *)(iv + ivsize); |
|---|
| 636 | +} |
|---|
| 637 | + |
|---|
| 638 | +static inline void nitrox_creq_set_src_sg(struct nitrox_kcrypt_request *nkreq, |
|---|
| 639 | + int nents, int ivsize, |
|---|
| 640 | + struct scatterlist *src, int buflen) |
|---|
| 641 | +{ |
|---|
| 642 | + char *iv = nkreq->src; |
|---|
| 643 | + struct scatterlist *sg; |
|---|
| 644 | + struct se_crypto_request *creq = &nkreq->creq; |
|---|
| 645 | + |
|---|
| 646 | + creq->src = nitrox_creq_src_sg(iv, ivsize); |
|---|
| 647 | + sg = creq->src; |
|---|
| 648 | + sg_init_table(sg, nents); |
|---|
| 649 | + |
|---|
| 650 | + /* Input format: |
|---|
| 651 | + * +----+----------------+ |
|---|
| 652 | + * | IV | SRC sg entries | |
|---|
| 653 | + * +----+----------------+ |
|---|
| 654 | + */ |
|---|
| 655 | + |
|---|
| 656 | + /* IV */ |
|---|
| 657 | + sg = create_single_sg(sg, iv, ivsize); |
|---|
| 658 | + /* SRC entries */ |
|---|
| 659 | + create_multi_sg(sg, src, buflen); |
|---|
| 660 | +} |
|---|
| 661 | + |
|---|
| 662 | +static inline int alloc_dst_req_buf(struct nitrox_kcrypt_request *nkreq, |
|---|
| 663 | + int nents) |
|---|
| 664 | +{ |
|---|
| 665 | + int extralen = ORH_HLEN + COMP_HLEN; |
|---|
| 666 | + struct se_crypto_request *creq = &nkreq->creq; |
|---|
| 667 | + |
|---|
| 668 | + nkreq->dst = alloc_req_buf(nents, extralen, creq->gfp); |
|---|
| 669 | + if (!nkreq->dst) |
|---|
| 670 | + return -ENOMEM; |
|---|
| 671 | + |
|---|
| 672 | + return 0; |
|---|
| 673 | +} |
|---|
| 674 | + |
|---|
| 675 | +static inline void nitrox_creq_set_orh(struct nitrox_kcrypt_request *nkreq) |
|---|
| 676 | +{ |
|---|
| 677 | + struct se_crypto_request *creq = &nkreq->creq; |
|---|
| 678 | + |
|---|
| 679 | + creq->orh = (u64 *)(nkreq->dst); |
|---|
| 680 | + set_orh_value(creq->orh); |
|---|
| 681 | +} |
|---|
| 682 | + |
|---|
| 683 | +static inline void nitrox_creq_set_comp(struct nitrox_kcrypt_request *nkreq) |
|---|
| 684 | +{ |
|---|
| 685 | + struct se_crypto_request *creq = &nkreq->creq; |
|---|
| 686 | + |
|---|
| 687 | + creq->comp = (u64 *)(nkreq->dst + ORH_HLEN); |
|---|
| 688 | + set_comp_value(creq->comp); |
|---|
| 689 | +} |
|---|
| 690 | + |
|---|
| 691 | +static inline struct scatterlist *nitrox_creq_dst_sg(char *dst) |
|---|
| 692 | +{ |
|---|
| 693 | + return (struct scatterlist *)(dst + ORH_HLEN + COMP_HLEN); |
|---|
| 694 | +} |
|---|
| 695 | + |
|---|
| 696 | +static inline void nitrox_creq_set_dst_sg(struct nitrox_kcrypt_request *nkreq, |
|---|
| 697 | + int nents, int ivsize, |
|---|
| 698 | + struct scatterlist *dst, int buflen) |
|---|
| 699 | +{ |
|---|
| 700 | + struct se_crypto_request *creq = &nkreq->creq; |
|---|
| 701 | + struct scatterlist *sg; |
|---|
| 702 | + char *iv = nkreq->src; |
|---|
| 703 | + |
|---|
| 704 | + creq->dst = nitrox_creq_dst_sg(nkreq->dst); |
|---|
| 705 | + sg = creq->dst; |
|---|
| 706 | + sg_init_table(sg, nents); |
|---|
| 707 | + |
|---|
| 708 | + /* Output format: |
|---|
| 709 | + * +-----+----+----------------+-----------------+ |
|---|
| 710 | + * | ORH | IV | DST sg entries | COMPLETION Bytes| |
|---|
| 711 | + * +-----+----+----------------+-----------------+ |
|---|
| 712 | + */ |
|---|
| 713 | + |
|---|
| 714 | + /* ORH */ |
|---|
| 715 | + sg = create_single_sg(sg, creq->orh, ORH_HLEN); |
|---|
| 716 | + /* IV */ |
|---|
| 717 | + sg = create_single_sg(sg, iv, ivsize); |
|---|
| 718 | + /* DST entries */ |
|---|
| 719 | + sg = create_multi_sg(sg, dst, buflen); |
|---|
| 720 | + /* COMPLETION Bytes */ |
|---|
| 721 | + create_single_sg(sg, creq->comp, COMP_HLEN); |
|---|
| 722 | +} |
|---|
| 723 | + |
|---|
| 453 | 724 | #endif /* __NITROX_REQ_H */ |
|---|