src/dpdk/drivers/common/dpaax/caamflib/desc/algo.h
static inline int
cnstr_shdsc_blkcipher(uint32_t *descbuf, bool ps, bool swap,
		      enum rta_share_type share,
		      struct alginfo *cipherdata,
		      uint32_t ivlen, uint8_t dir)
{
	struct program prg;
	struct program *p = &prg;
	uint32_t iv_off = 0, counter;
	const bool need_dk = (dir == DIR_DEC) &&
			     (cipherdata->algtype == OP_ALG_ALGSEL_AES) &&
			     (cipherdata->algmode == OP_ALG_AAI_CBC);
	LABEL(keyjmp);
	LABEL(skipdk);
	REFERENCE(pkeyjmp);
	REFERENCE(pskipdk);

	PROGRAM_CNTXT_INIT(p, descbuf, 0);
	if (swap)
		PROGRAM_SET_BSWAP(p);
	if (ps)
		PROGRAM_SET_36BIT_ADDR(p);
	SHR_HDR(p, share, 1, SC);

	pkeyjmp = JUMP(p, keyjmp, LOCAL_JUMP, ALL_TRUE, SHRD);
	/* Insert Key */
	KEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,
	    cipherdata->keylen, INLINE_KEY(cipherdata));

	if (need_dk) {
		ALG_OPERATION(p, cipherdata->algtype, cipherdata->algmode,
			      OP_ALG_AS_INITFINAL, ICV_CHECK_DISABLE, dir);

		pskipdk = JUMP(p, skipdk, LOCAL_JUMP, ALL_TRUE, 0);
	}
	SET_LABEL(p, keyjmp);

	if (need_dk) {
		ALG_OPERATION(p, OP_ALG_ALGSEL_AES, cipherdata->algmode |
			      OP_ALG_AAI_DK, OP_ALG_AS_INITFINAL,
			      ICV_CHECK_DISABLE, dir);
		SET_LABEL(p, skipdk);
	} else {
		ALG_OPERATION(p, cipherdata->algtype, cipherdata->algmode,
			      OP_ALG_AS_INITFINAL, ICV_CHECK_DISABLE, dir);
	}

	if (cipherdata->algmode == OP_ALG_AAI_CTR)
		iv_off = 16;

	/* IV is present first before the actual message */
	SEQLOAD(p, CONTEXT1, iv_off, ivlen, 0);

	/* If IV len is less than 16 bytes, set 'counter' as 1 */
	if (cipherdata->algmode == OP_ALG_AAI_CTR && ivlen < 16) {
		counter = 1;
		if (!swap)
			counter = swab32(1);

		LOAD(p, counter, CONTEXT1, (iv_off + ivlen), 16 - ivlen, IMMED);
	}

	MATHB(p, SEQINSZ, SUB, MATH2, VSEQINSZ, 4, 0);
	MATHB(p, SEQINSZ, SUB, MATH2, VSEQOUTSZ, 4, 0);

	/* Insert sequence load/store with VLF */
	SEQFIFOLOAD(p, MSG1, 0, VLF | LAST1);
	SEQFIFOSTORE(p, MSG, 0, 0, VLF);

	PATCH_JUMP(p, pkeyjmp, keyjmp);
	if (need_dk)
		PATCH_JUMP(p, pskipdk, skipdk);

	return PROGRAM_FINALIZE(p);
}
/**
 * cnstr_shdsc_blkcipher - block cipher transformation
 * @descbuf: pointer to descriptor-under-construction buffer
 * @ps: if 36/40bit addressing is desired, this parameter must be true
 * @swap: must be true when core endianness doesn't match SEC endianness
 * @share: sharing type of shared descriptor
 * @cipherdata: pointer to block cipher transform definitions
 *              Valid algorithm values one of OP_ALG_ALGSEL_* {DES, 3DES, AES}
 *              Valid modes for:
 *                  AES: OP_ALG_AAI_* {CBC, CTR}
 *                  DES, 3DES: OP_ALG_AAI_CBC
 * @iv: IV data; if NULL, "ivlen" bytes from the input frame will be read as IV
 * @ivlen: IV length
 * @dir: DIR_ENC/DIR_DEC
 *
 * Return: size of descriptor written in words or negative number on error
 */


size of descriptor written in words or negative number on error
size of descriptor written in words or negative number on error
static inline int
cnstr_shdsc_blkcipher(uint32_t *descbuf, bool ps, bool swap,
		      enum rta_share_type share,
		      struct alginfo *cipherdata,
		      uint32_t ivlen, uint8_t dir)
{
	struct program prg;
	struct program *p = &prg;
	uint32_t iv_off = 0, counter;
	const bool need_dk = (dir == DIR_DEC) &&
			     (cipherdata->algtype == OP_ALG_ALGSEL_AES) &&
			     (cipherdata->algmode == OP_ALG_AAI_CBC);
	LABEL(keyjmp);
	LABEL(skipdk);
	REFERENCE(pkeyjmp);
	REFERENCE(pskipdk);
	PROGRAM_CNTXT_INIT(p, descbuf, 0);
	if (swap)
		PROGRAM_SET_BSWAP(p);
	if (ps)
		PROGRAM_SET_36BIT_ADDR(p);
	SHR_HDR(p, share, 1, SC);
	pkeyjmp = JUMP(p, keyjmp, LOCAL_JUMP, ALL_TRUE, SHRD);
	KEY(p, KEY1, cipherdata->key_enc_flags, cipherdata->key,
	    cipherdata->keylen, INLINE_KEY(cipherdata));
	if (need_dk) {
		ALG_OPERATION(p, cipherdata->algtype, cipherdata->algmode,
			      OP_ALG_AS_INITFINAL, ICV_CHECK_DISABLE, dir);
		pskipdk = JUMP(p, skipdk, LOCAL_JUMP, ALL_TRUE, 0);
	}
	SET_LABEL(p, keyjmp);
	if (need_dk) {
		ALG_OPERATION(p, OP_ALG_ALGSEL_AES, cipherdata->algmode |
			      OP_ALG_AAI_DK, OP_ALG_AS_INITFINAL,
			      ICV_CHECK_DISABLE, dir);
		SET_LABEL(p, skipdk);
	} else {
		ALG_OPERATION(p, cipherdata->algtype, cipherdata->algmode,
			      OP_ALG_AS_INITFINAL, ICV_CHECK_DISABLE, dir);
	}
	if (cipherdata->algmode == OP_ALG_AAI_CTR)
		iv_off = 16;
	SEQLOAD(p, CONTEXT1, iv_off, ivlen, 0);
	if (cipherdata->algmode == OP_ALG_AAI_CTR && ivlen < 16) {
		counter = 1;
		if (!swap)
			counter = swab32(1);
		LOAD(p, counter, CONTEXT1, (iv_off + ivlen), 16 - ivlen, IMMED);
	}
	MATHB(p, SEQINSZ, SUB, MATH2, VSEQINSZ, 4, 0);
	MATHB(p, SEQINSZ, SUB, MATH2, VSEQOUTSZ, 4, 0);
	SEQFIFOLOAD(p, MSG1, 0, VLF | LAST1);
	SEQFIFOSTORE(p, MSG, 0, 0, VLF);
	PATCH_JUMP(p, pkeyjmp, keyjmp);
	if (need_dk)
		PATCH_JUMP(p, pskipdk, skipdk);
	return PROGRAM_FINALIZE(p);
}
static inline int cnstr_shdsc_blkcipher ( uint32_t * descbuf , bool ps , bool swap , enum rta_share_type share , struct alginfo * cipherdata , uint32_t ivlen , uint8_t dir ) { struct program prg ; struct program * p = & prg ; uint32_t iv_off = 0 , counter ; const bool need_dk = ( dir == DIR_DEC ) && ( cipherdata -> algtype == OP_ALG_ALGSEL_AES ) && ( cipherdata -> algmode == OP_ALG_AAI_CBC ) ; LABEL ( keyjmp ) ; LABEL ( skipdk ) ; REFERENCE ( pkeyjmp ) ; REFERENCE ( pskipdk ) ; PROGRAM_CNTXT_INIT ( p , descbuf , 0 ) ; if ( swap ) PROGRAM_SET_BSWAP ( p ) ; if ( ps ) PROGRAM_SET_36BIT_ADDR ( p ) ; SHR_HDR ( p , share , 1 , SC ) ; pkeyjmp = JUMP ( p , keyjmp , LOCAL_JUMP , ALL_TRUE , SHRD ) ; KEY ( p , KEY1 , cipherdata -> key_enc_flags , cipherdata -> key , cipherdata -> keylen , INLINE_KEY ( cipherdata ) ) ; if ( need_dk ) { ALG_OPERATION ( p , cipherdata -> algtype , cipherdata -> algmode , OP_ALG_AS_INITFINAL , ICV_CHECK_DISABLE , dir ) ; pskipdk = JUMP ( p , skipdk , LOCAL_JUMP , ALL_TRUE , 0 ) ; } SET_LABEL ( p , keyjmp ) ; if ( need_dk ) { ALG_OPERATION ( p , OP_ALG_ALGSEL_AES , cipherdata -> algmode | OP_ALG_AAI_DK , OP_ALG_AS_INITFINAL , ICV_CHECK_DISABLE , dir ) ; SET_LABEL ( p , skipdk ) ; } else { ALG_OPERATION ( p , cipherdata -> algtype , cipherdata -> algmode , OP_ALG_AS_INITFINAL , ICV_CHECK_DISABLE , dir ) ; } if ( cipherdata -> algmode == OP_ALG_AAI_CTR ) iv_off = 16 ; SEQLOAD ( p , CONTEXT1 , iv_off , ivlen , 0 ) ; if ( cipherdata -> algmode == OP_ALG_AAI_CTR && ivlen < 16 ) { counter = 1 ; if ( ! swap ) counter = swab32 ( 1 ) ; LOAD ( p , counter , CONTEXT1 , ( iv_off + ivlen ) , 16 - ivlen , IMMED ) ; } MATHB ( p , SEQINSZ , SUB , MATH2 , VSEQINSZ , 4 , 0 ) ; MATHB ( p , SEQINSZ , SUB , MATH2 , VSEQOUTSZ , 4 , 0 ) ; SEQFIFOLOAD ( p , MSG1 , 0 , VLF | LAST1 ) ; SEQFIFOSTORE ( p , MSG , 0 , 0 , VLF ) ; PATCH_JUMP ( p , pkeyjmp , keyjmp ) ; if ( need_dk ) PATCH_JUMP ( p , pskipdk , skipdk ) ; return PROGRAM_FINALIZE ( p ) ; }
cnstr_shdsc_blkcipher - block cipher transformation
 @descbuf: pointer to descriptor-under-construction buffer
 @ps: if 36/40bit addressing is desired, this parameter must be true
 @swap: must be true when core endianness doesn't match SEC endianness
 @share: sharing type of shared descriptor
 @cipherdata: pointer to block cipher transform definitions
              Valid algorithm values one of OP_ALG_ALGSEL_* {DES, 3DES, AES}
              Valid modes for:
                  AES: OP_ALG_AAI_* {CBC, CTR}
                  DES, 3DES: OP_ALG_AAI_CBC
 @iv: IV data; if NULL, "ivlen" bytes from the input frame will be read as IV
 @ivlen: IV length
 @dir: DIR_ENC/DIR_DEC
cnstr_shdsc_blkcipher - block cipher transformation @descbuf : pointer to descriptor - under - construction buffer @ps : if 36 / 40bit addressing is desired this parameter must be true @swap : must be true when core endianness doesn ' t match SEC endianness @share : sharing type of shared descriptor @cipherdata : pointer to block cipher transform definitions Valid algorithm values one of OP_ALG_ALGSEL_ * { DES 3DES AES } Valid modes for : AES : OP_ALG_AAI_ * { CBC CTR } DES 3DES : OP_ALG_AAI_CBC @iv : IV data ; if NULL " ivlen " bytes from the input frame will be read as IV @ivlen : IV length @dir : DIR_ENC / DIR_DEC
/* Insert Key */ /* IV is present first before the actual message */ /* If IV len is less than 16 bytes, set 'counter' as 1 */ /* Insert sequence load/store with VLF */