src/dpdk/drivers/crypto/bcmfs/bcmfs_sym_session.c
static int
crypto_set_session_parameters(struct bcmfs_sym_session *sess,
			      struct rte_crypto_sym_xform *xform)
{
	int rc = 0;
	struct rte_crypto_cipher_xform *cipher_xform =
			crypto_get_cipher_xform(xform);
	struct rte_crypto_auth_xform *auth_xform =
			crypto_get_auth_xform(xform);

	sess->chain_order = crypto_get_chain_order(xform);

	switch (sess->chain_order) {
	case BCMFS_SYM_CHAIN_ONLY_CIPHER:
		if (crypto_set_session_cipher_parameters(sess, cipher_xform))
			rc = -EINVAL;
		break;
	case BCMFS_SYM_CHAIN_ONLY_AUTH:
		if (crypto_set_session_auth_parameters(sess, auth_xform))
			rc = -EINVAL;
		break;
	case BCMFS_SYM_CHAIN_AUTH_CIPHER:
		sess->cipher_first = false;
		if (crypto_set_session_auth_parameters(sess, auth_xform)) {
			rc = -EINVAL;
			goto error;
		}

		if (crypto_set_session_cipher_parameters(sess, cipher_xform))
			rc = -EINVAL;
		break;
	case BCMFS_SYM_CHAIN_CIPHER_AUTH:
		sess->cipher_first = true;
		if (crypto_set_session_auth_parameters(sess, auth_xform)) {
			rc = -EINVAL;
			goto error;
		}

		if (crypto_set_session_cipher_parameters(sess, cipher_xform))
			rc = -EINVAL;
		break;
	case BCMFS_SYM_CHAIN_AEAD:
		if (crypto_set_session_aead_parameters(sess, xform))
			rc = -EINVAL;
		break;
	default:
		BCMFS_DP_LOG(ERR, "Invalid chain order\n");
		rc = -EINVAL;
		break;
	}

error:
	return rc;
}
/** Parse crypto xform chain and set private session parameters */
Parse crypto xform chain and set private session parameters
Parse crypto xform chain and set private session parameters
static int
crypto_set_session_parameters(struct bcmfs_sym_session *sess,
			      struct rte_crypto_sym_xform *xform)
{
	int rc = 0;
	struct rte_crypto_cipher_xform *cipher_xform =
			crypto_get_cipher_xform(xform);
	struct rte_crypto_auth_xform *auth_xform =
			crypto_get_auth_xform(xform);
	sess->chain_order = crypto_get_chain_order(xform);
	switch (sess->chain_order) {
	case BCMFS_SYM_CHAIN_ONLY_CIPHER:
		if (crypto_set_session_cipher_parameters(sess, cipher_xform))
			rc = -EINVAL;
		break;
	case BCMFS_SYM_CHAIN_ONLY_AUTH:
		if (crypto_set_session_auth_parameters(sess, auth_xform))
			rc = -EINVAL;
		break;
	case BCMFS_SYM_CHAIN_AUTH_CIPHER:
		sess->cipher_first = false;
		if (crypto_set_session_auth_parameters(sess, auth_xform)) {
			rc = -EINVAL;
			goto error;
		}
		if (crypto_set_session_cipher_parameters(sess, cipher_xform))
			rc = -EINVAL;
		break;
	case BCMFS_SYM_CHAIN_CIPHER_AUTH:
		sess->cipher_first = true;
		if (crypto_set_session_auth_parameters(sess, auth_xform)) {
			rc = -EINVAL;
			goto error;
		}
		if (crypto_set_session_cipher_parameters(sess, cipher_xform))
			rc = -EINVAL;
		break;
	case BCMFS_SYM_CHAIN_AEAD:
		if (crypto_set_session_aead_parameters(sess, xform))
			rc = -EINVAL;
		break;
	default:
		BCMFS_DP_LOG(ERR, "Invalid chain order\n");
		rc = -EINVAL;
		break;
	}
error:
	return rc;
}
static int crypto_set_session_parameters ( struct bcmfs_sym_session * sess , struct rte_crypto_sym_xform * xform ) { int rc = 0 ; struct rte_crypto_cipher_xform * cipher_xform = crypto_get_cipher_xform ( xform ) ; struct rte_crypto_auth_xform * auth_xform = crypto_get_auth_xform ( xform ) ; sess -> chain_order = crypto_get_chain_order ( xform ) ; switch ( sess -> chain_order ) { case BCMFS_SYM_CHAIN_ONLY_CIPHER : if ( crypto_set_session_cipher_parameters ( sess , cipher_xform ) ) rc = - EINVAL ; break ; case BCMFS_SYM_CHAIN_ONLY_AUTH : if ( crypto_set_session_auth_parameters ( sess , auth_xform ) ) rc = - EINVAL ; break ; case BCMFS_SYM_CHAIN_AUTH_CIPHER : sess -> cipher_first = false ; if ( crypto_set_session_auth_parameters ( sess , auth_xform ) ) { rc = - EINVAL ; goto error ; } if ( crypto_set_session_cipher_parameters ( sess , cipher_xform ) ) rc = - EINVAL ; break ; case BCMFS_SYM_CHAIN_CIPHER_AUTH : sess -> cipher_first = true ; if ( crypto_set_session_auth_parameters ( sess , auth_xform ) ) { rc = - EINVAL ; goto error ; } if ( crypto_set_session_cipher_parameters ( sess , cipher_xform ) ) rc = - EINVAL ; break ; case BCMFS_SYM_CHAIN_AEAD : if ( crypto_set_session_aead_parameters ( sess , xform ) ) rc = - EINVAL ; break ; default : BCMFS_DP_LOG ( ERR , " \n " ) ; rc = - EINVAL ; break ; } error : return rc ; }
Parse crypto xform chain and set private session parameters
Parse crypto xform chain and set private session parameters