src/dpdk/drivers/crypto/dpaa_sec/dpaa_sec.c
static int
dpaa_sec_prep_ipsec_cdb(dpaa_sec_session *ses)
{
	struct alginfo cipherdata = {0}, authdata = {0};
	struct sec_cdb *cdb = &ses->cdb;
	int32_t shared_desc_len = 0;
	int err;
#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
	int swap = false;
#else
	int swap = true;
#endif

	cipherdata.key = (size_t)ses->cipher_key.data;
	cipherdata.keylen = ses->cipher_key.length;
	cipherdata.key_enc_flags = 0;
	cipherdata.key_type = RTA_DATA_IMM;
	cipherdata.algtype = ses->cipher_key.alg;
	cipherdata.algmode = ses->cipher_key.algmode;

	if (ses->auth_key.length) {
		authdata.key = (size_t)ses->auth_key.data;
		authdata.keylen = ses->auth_key.length;
		authdata.key_enc_flags = 0;
		authdata.key_type = RTA_DATA_IMM;
		authdata.algtype = ses->auth_key.alg;
		authdata.algmode = ses->auth_key.algmode;
	}

	cdb->sh_desc[0] = cipherdata.keylen;
	cdb->sh_desc[1] = authdata.keylen;
	err = rta_inline_query(IPSEC_AUTH_VAR_AES_DEC_BASE_DESC_LEN,
			       DESC_JOB_IO_LEN,
			       (unsigned int *)cdb->sh_desc,
			       &cdb->sh_desc[2], 2);

	if (err < 0) {
		DPAA_SEC_ERR("Crypto: Incorrect key lengths");
		return err;
	}
	if (cdb->sh_desc[2] & 1)
		cipherdata.key_type = RTA_DATA_IMM;
	else {
		cipherdata.key = (size_t)rte_dpaa_mem_vtop(
					(void *)(size_t)cipherdata.key);
		cipherdata.key_type = RTA_DATA_PTR;
	}
	if (cdb->sh_desc[2] & (1<<1))
		authdata.key_type = RTA_DATA_IMM;
	else {
		authdata.key = (size_t)rte_dpaa_mem_vtop(
					(void *)(size_t)authdata.key);
		authdata.key_type = RTA_DATA_PTR;
	}

	cdb->sh_desc[0] = 0;
	cdb->sh_desc[1] = 0;
	cdb->sh_desc[2] = 0;
	if (ses->dir == DIR_ENC) {
		shared_desc_len = cnstr_shdsc_ipsec_new_encap(
				cdb->sh_desc,
				true, swap, SHR_SERIAL,
				&ses->encap_pdb,
				(uint8_t *)&ses->ip4_hdr,
				&cipherdata, &authdata);
	} else if (ses->dir == DIR_DEC) {
		shared_desc_len = cnstr_shdsc_ipsec_new_decap(
				cdb->sh_desc,
				true, swap, SHR_SERIAL,
				&ses->decap_pdb,
				&cipherdata, &authdata);
	}
	return shared_desc_len;
}
/* prepare ipsec proto command block of the session */
prepare ipsec proto command block of the session
prepare ipsec proto command block of the session
static int
dpaa_sec_prep_ipsec_cdb(dpaa_sec_session *ses)
{
	struct alginfo cipherdata = {0}, authdata = {0};
	struct sec_cdb *cdb = &ses->cdb;
	int32_t shared_desc_len = 0;
	int err;
#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
	int swap = false;
#else
	int swap = true;
#endif
	cipherdata.key = (size_t)ses->cipher_key.data;
	cipherdata.keylen = ses->cipher_key.length;
	cipherdata.key_enc_flags = 0;
	cipherdata.key_type = RTA_DATA_IMM;
	cipherdata.algtype = ses->cipher_key.alg;
	cipherdata.algmode = ses->cipher_key.algmode;
	if (ses->auth_key.length) {
		authdata.key = (size_t)ses->auth_key.data;
		authdata.keylen = ses->auth_key.length;
		authdata.key_enc_flags = 0;
		authdata.key_type = RTA_DATA_IMM;
		authdata.algtype = ses->auth_key.alg;
		authdata.algmode = ses->auth_key.algmode;
	}
	cdb->sh_desc[0] = cipherdata.keylen;
	cdb->sh_desc[1] = authdata.keylen;
	err = rta_inline_query(IPSEC_AUTH_VAR_AES_DEC_BASE_DESC_LEN,
			       DESC_JOB_IO_LEN,
			       (unsigned int *)cdb->sh_desc,
			       &cdb->sh_desc[2], 2);
	if (err < 0) {
		DPAA_SEC_ERR("Crypto: Incorrect key lengths");
		return err;
	}
	if (cdb->sh_desc[2] & 1)
		cipherdata.key_type = RTA_DATA_IMM;
	else {
		cipherdata.key = (size_t)rte_dpaa_mem_vtop(
					(void *)(size_t)cipherdata.key);
		cipherdata.key_type = RTA_DATA_PTR;
	}
	if (cdb->sh_desc[2] & (1<<1))
		authdata.key_type = RTA_DATA_IMM;
	else {
		authdata.key = (size_t)rte_dpaa_mem_vtop(
					(void *)(size_t)authdata.key);
		authdata.key_type = RTA_DATA_PTR;
	}
	cdb->sh_desc[0] = 0;
	cdb->sh_desc[1] = 0;
	cdb->sh_desc[2] = 0;
	if (ses->dir == DIR_ENC) {
		shared_desc_len = cnstr_shdsc_ipsec_new_encap(
				cdb->sh_desc,
				true, swap, SHR_SERIAL,
				&ses->encap_pdb,
				(uint8_t *)&ses->ip4_hdr,
				&cipherdata, &authdata);
	} else if (ses->dir == DIR_DEC) {
		shared_desc_len = cnstr_shdsc_ipsec_new_decap(
				cdb->sh_desc,
				true, swap, SHR_SERIAL,
				&ses->decap_pdb,
				&cipherdata, &authdata);
	}
	return shared_desc_len;
}
static int dpaa_sec_prep_ipsec_cdb ( dpaa_sec_session * ses ) { struct alginfo cipherdata = { 0 } , authdata = { 0 } ; struct sec_cdb * cdb = & ses -> cdb ; int32_t shared_desc_len = 0 ; int err ; #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN int swap = false ; #else int swap = true ; #endif cipherdata . key = ( size_t ) ses -> cipher_key . data ; cipherdata . keylen = ses -> cipher_key . length ; cipherdata . key_enc_flags = 0 ; cipherdata . key_type = RTA_DATA_IMM ; cipherdata . algtype = ses -> cipher_key . alg ; cipherdata . algmode = ses -> cipher_key . algmode ; if ( ses -> auth_key . length ) { authdata . key = ( size_t ) ses -> auth_key . data ; authdata . keylen = ses -> auth_key . length ; authdata . key_enc_flags = 0 ; authdata . key_type = RTA_DATA_IMM ; authdata . algtype = ses -> auth_key . alg ; authdata . algmode = ses -> auth_key . algmode ; } cdb -> sh_desc [ 0 ] = cipherdata . keylen ; cdb -> sh_desc [ 1 ] = authdata . keylen ; err = rta_inline_query ( IPSEC_AUTH_VAR_AES_DEC_BASE_DESC_LEN , DESC_JOB_IO_LEN , ( unsigned int * ) cdb -> sh_desc , & cdb -> sh_desc [ 2 ] , 2 ) ; if ( err < 0 ) { DPAA_SEC_ERR ( " " ) ; return err ; } if ( cdb -> sh_desc [ 2 ] & 1 ) cipherdata . key_type = RTA_DATA_IMM ; else { cipherdata . key = ( size_t ) rte_dpaa_mem_vtop ( ( void * ) ( size_t ) cipherdata . key ) ; cipherdata . key_type = RTA_DATA_PTR ; } if ( cdb -> sh_desc [ 2 ] & ( 1 << 1 ) ) authdata . key_type = RTA_DATA_IMM ; else { authdata . key = ( size_t ) rte_dpaa_mem_vtop ( ( void * ) ( size_t ) authdata . key ) ; authdata . key_type = RTA_DATA_PTR ; } cdb -> sh_desc [ 0 ] = 0 ; cdb -> sh_desc [ 1 ] = 0 ; cdb -> sh_desc [ 2 ] = 0 ; if ( ses -> dir == DIR_ENC ) { shared_desc_len = cnstr_shdsc_ipsec_new_encap ( cdb -> sh_desc , true , swap , SHR_SERIAL , & ses -> encap_pdb , ( uint8_t * ) & ses -> ip4_hdr , & cipherdata , & authdata ) ; } else if ( ses -> dir == DIR_DEC ) { shared_desc_len = cnstr_shdsc_ipsec_new_decap ( cdb -> sh_desc , true , swap , SHR_SERIAL , & ses -> decap_pdb , & cipherdata , & authdata ) ; } return shared_desc_len ; }
prepare ipsec proto command block of the session
prepare ipsec proto command block of the session