src/dpdk/lib/librte_ipsec/esp_outb.c
uint16_t
esp_outb_tun_prepare(const struct rte_ipsec_session *ss, struct rte_mbuf *mb[],
	struct rte_crypto_op *cop[], uint16_t num)
{
	int32_t rc;
	uint32_t i, k, n;
	uint64_t sqn;
	rte_be64_t sqc;
	struct rte_ipsec_sa *sa;
	struct rte_cryptodev_sym_session *cs;
	union sym_op_data icv;
	uint64_t iv[IPSEC_MAX_IV_QWORD];
	uint32_t dr[num];

	sa = ss->sa;
	cs = ss->crypto.ses;

	n = num;
	sqn = esn_outb_update_sqn(sa, &n);
	if (n != num)
		rte_errno = EOVERFLOW;

	k = 0;
	for (i = 0; i != n; i++) {

		sqc = rte_cpu_to_be_64(sqn + i);
		gen_iv(iv, sqc);

		/* try to update the packet itself */
		rc = outb_tun_pkt_prepare(sa, sqc, iv, mb[i], &icv,
					  sa->sqh_len);
		/* success, setup crypto op */
		if (rc >= 0) {
			outb_pkt_xprepare(sa, sqc, &icv);
			lksd_none_cop_prepare(cop[k], cs, mb[i]);
			outb_cop_prepare(cop[k], sa, iv, &icv, 0, rc);
			k++;
		/* failure, put packet into the death-row */
		} else {
			dr[i - k] = i;
			rte_errno = -rc;
		}
	}

	 /* copy not prepared mbufs beyond good ones */
	if (k != n && k != 0)
		move_bad_mbufs(mb, dr, n, n - k);

	return k;
}
/*
 * setup/update packets and crypto ops for ESP outbound tunnel case.
 */
setup/update packets and crypto ops for ESP outbound tunnel case.
setup / update packets and crypto ops for ESP outbound tunnel case .
uint16_t
esp_outb_tun_prepare(const struct rte_ipsec_session *ss, struct rte_mbuf *mb[],
	struct rte_crypto_op *cop[], uint16_t num)
{
	int32_t rc;
	uint32_t i, k, n;
	uint64_t sqn;
	rte_be64_t sqc;
	struct rte_ipsec_sa *sa;
	struct rte_cryptodev_sym_session *cs;
	union sym_op_data icv;
	uint64_t iv[IPSEC_MAX_IV_QWORD];
	uint32_t dr[num];
	sa = ss->sa;
	cs = ss->crypto.ses;
	n = num;
	sqn = esn_outb_update_sqn(sa, &n);
	if (n != num)
		rte_errno = EOVERFLOW;
	k = 0;
	for (i = 0; i != n; i++) {
		sqc = rte_cpu_to_be_64(sqn + i);
		gen_iv(iv, sqc);
		rc = outb_tun_pkt_prepare(sa, sqc, iv, mb[i], &icv,
					  sa->sqh_len);
		if (rc >= 0) {
			outb_pkt_xprepare(sa, sqc, &icv);
			lksd_none_cop_prepare(cop[k], cs, mb[i]);
			outb_cop_prepare(cop[k], sa, iv, &icv, 0, rc);
			k++;
		} else {
			dr[i - k] = i;
			rte_errno = -rc;
		}
	}
	if (k != n && k != 0)
		move_bad_mbufs(mb, dr, n, n - k);
	return k;
}
uint16_t esp_outb_tun_prepare ( const struct rte_ipsec_session * ss , struct rte_mbuf * mb [ ] , struct rte_crypto_op * cop [ ] , uint16_t num ) { int32_t rc ; uint32_t i , k , n ; uint64_t sqn ; rte_be64_t sqc ; struct rte_ipsec_sa * sa ; struct rte_cryptodev_sym_session * cs ; union sym_op_data icv ; uint64_t iv [ IPSEC_MAX_IV_QWORD ] ; uint32_t dr [ num ] ; sa = ss -> sa ; cs = ss -> crypto . ses ; n = num ; sqn = esn_outb_update_sqn ( sa , & n ) ; if ( n != num ) rte_errno = EOVERFLOW ; k = 0 ; for ( i = 0 ; i != n ; i ++ ) { sqc = rte_cpu_to_be_64 ( sqn + i ) ; gen_iv ( iv , sqc ) ; rc = outb_tun_pkt_prepare ( sa , sqc , iv , mb [ i ] , & icv , sa -> sqh_len ) ; if ( rc >= 0 ) { outb_pkt_xprepare ( sa , sqc , & icv ) ; lksd_none_cop_prepare ( cop [ k ] , cs , mb [ i ] ) ; outb_cop_prepare ( cop [ k ] , sa , iv , & icv , 0 , rc ) ; k ++ ; } else { dr [ i - k ] = i ; rte_errno = - rc ; } } if ( k != n && k != 0 ) move_bad_mbufs ( mb , dr , n , n - k ) ; return k ; }
setup/update packets and crypto ops for ESP outbound tunnel case.
setup / update packets and crypto ops for ESP outbound tunnel case .
/* try to update the packet itself */ /* success, setup crypto op */ /* failure, put packet into the death-row */ /* copy not prepared mbufs beyond good ones */