add lookaside IPsec ESN and anti-replay support
Subsystems (2)
cover add lookaside IPsec ESN and anti-replay support
This series adds lookaside IPsec ESN and anti-replay support to OCTEON TX2 crypto PMD.
The functionality has been tested with ipsec-secgw application running in lookaside protocol offload mode.
Tejasree Kondoj (2):
crypto/octeontx2: make anti-replay routine generic crypto/octeontx2: add lookaside IPsec ESN and anti-replay support
doc/guides/cryptodevs/octeontx2.rst | 2 + doc/guides/rel_notes/release_21_02.rst | 5 ++ drivers/crypto/octeontx2/otx2_cryptodev_ops.c | 47 ++++++++++++++++++- drivers/crypto/octeontx2/otx2_cryptodev_sec.c | 21 +++++++++ .../crypto/octeontx2/otx2_ipsec_anti_replay.h | 32 ++++++++++--- drivers/crypto/octeontx2/otx2_ipsec_po.h | 5 ++ drivers/crypto/octeontx2/otx2_ipsec_po_ops.h | 2 + drivers/net/octeontx2/otx2_rx.h | 2 +- 8 files changed, 107 insertions(+), 9 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/2 crypto/octeontx2: make anti-replay routine generic
Adding changes to make anti-replay routine common to both inline and lookaside IPsec.
--- drivers/crypto/octeontx2/otx2_ipsec_anti_replay.h | 11 +++++------ drivers/net/octeontx2/otx2_rx.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-)
drivers/crypto/octeontx2/otx2_ipsec_anti_replay.h +5 -6
@@ -16,11 +16,10 @@#define IPSEC_ANTI_REPLAY_FAILED (-1)static inline int -anti_replay_check (uint64_t seq,struct otx2_ipsec_fp_in_sa *sa) +anti_replay_check (struct otx2_ipsec_replay *replay,uint64_t seq, +uint64_t winsz) { -struct otx2_ipsec_replay *replay = sa->replay;uint64_t *window = &replay->window[0 ]; -uint64_t winsz = sa->replay_win_sz;uint64_t ex_winsz = winsz +WORD_SIZE ;uint64_t winwords = ex_winsz >>WORD_SHIFT ;uint64_t base = replay->base;
@@ -166,8 +165,8 @@ anti_replay_check(uint64_t seq, struct otx2_ipsec_fp_in_sa *sa)return 0 ; } -static int -cpt_ipsec_antireplay_check (struct otx2_ipsec_fp_in_sa *sa,char *data) +static inline int +cpt_ipsec_ip_antireplay_check (struct otx2_ipsec_fp_in_sa *sa,char *data) {uint64_t seq_in_sa;uint32_t seqh =0 ;
@@ -192,7 +191,7 @@ cpt_ipsec_antireplay_check(struct otx2_ipsec_fp_in_sa *sa, char *data)return IPSEC_ANTI_REPLAY_FAILED ;rte_spinlock_lock (&sa->replay->lock); - ret =anti_replay_check (seq, sa); + ret =anti_replay_check (sa->replay, seq, sa->replay_win_sz);if (esn && (ret ==0 )) { seq_in_sa = ((uint64_t )rte_be_to_cpu_32 (sa->esn_hi) <<32 ) |rte_be_to_cpu_32 (sa->esn_low);
drivers/net/octeontx2/otx2_rx.h +1 -1
@@ -259,7 +259,7 @@ nix_rx_sec_mbuf_update(const struct nix_cqe_hdr_s *cq, struct rte_mbuf *m, data = rte_pktmbuf_mtod(m, char *);if (sa->replay_win_sz) { -if (cpt_ipsec_antireplay_check (sa, data) <0 ) +if (cpt_ipsec_ip_antireplay_check (sa, data) <0 )return PKT_RX_SEC_OFFLOAD |PKT_RX_SEC_OFFLOAD_FAILED ; }
Signature · 1 line
2.27.0
PATCH 2/2 crypto/octeontx2: add lookaside IPsec ESN and anti-replay support
In reply to Tejasree KondojAdding ESN and anti-replay support for lookaside IPsec.
--- doc/guides/cryptodevs/octeontx2.rst | 2 + doc/guides/rel_notes/release_21_02.rst | 5 ++ drivers/crypto/octeontx2/otx2_cryptodev_ops.c | 47 ++++++++++++++++++- drivers/crypto/octeontx2/otx2_cryptodev_sec.c | 21 +++++++++ .../crypto/octeontx2/otx2_ipsec_anti_replay.h | 21 +++++++++ drivers/crypto/octeontx2/otx2_ipsec_po.h | 5 ++ drivers/crypto/octeontx2/otx2_ipsec_po_ops.h | 2 + 7 files changed, 101 insertions(+), 2 deletions(-)
doc/guides/cryptodevs/octeontx2.rst +2 -0
@@ -175,4 +175,6 @@ Features supported * IPv6 * ESP * Tunnel mode +* ESN +* Anti-replay * AES-128/192/256-GCM
doc/guides/rel_notes/release_21_02.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated the OCTEON TX2 crypto PMD.** + + * Updated the OCTEON TX2 crypto PMD lookaside protocol offload for IPsec with + ESN and anti-replay support. + Removed Items -------------
drivers/crypto/octeontx2/otx2_cryptodev_ops.c +45 -2
78 lines not on this page · raw message
drivers/crypto/octeontx2/otx2_cryptodev_sec.c +21 -0
@@ -213,6 +213,7 @@ crypto_sec_ipsec_outb_session_create(struct rte_cryptodev *crypto_dev,int ret; sess =get_sec_session_private_data (sec_sess); + sess->ipsec.dir =RTE_SECURITY_IPSEC_SA_DIR_EGRESS ; lp = &sess->ipsec.lp; sa = &lp->out_sa;
@@ -351,6 +352,7 @@ crypto_sec_ipsec_inb_session_create(struct rte_cryptodev *crypto_dev,int ret; sess =get_sec_session_private_data (sec_sess); + sess->ipsec.dir =RTE_SECURITY_IPSEC_SA_DIR_INGRESS ; lp = &sess->ipsec.lp; sa = &lp->in_sa;
@@ -362,6 +364,7 @@ crypto_sec_ipsec_inb_session_create(struct rte_cryptodev *crypto_dev, }memset (sa,0 ,sizeof (struct otx2_ipsec_po_in_sa )); + sa->replay_win_sz = ipsec->replay_win_sz; ret =ipsec_po_sa_ctl_set (ipsec, crypto_xform, ctl);if (ret)
@@ -414,6 +417,24 @@ crypto_sec_ipsec_inb_session_create(struct rte_cryptodev *crypto_dev,set_session_misc_attributes (lp, crypto_xform, auth_xform, cipher_xform); +if (sa->replay_win_sz) { +if (sa->replay_win_sz >OTX2_IPSEC_MAX_REPLAY_WIN_SZ ) { +otx2_err ("Replay window size is not supported" ); +return -ENOTSUP ; + } + sa->replay =rte_zmalloc (NULL ,sizeof (struct otx2_ipsec_replay ), +0 ); +if (sa->replay ==NULL ) +return -ENOMEM ; + +/* Set window bottom to 1, base and top to size of window */ + sa->replay->winb =1 ; + sa->replay->wint = sa->replay_win_sz; + sa->replay->base = sa->replay_win_sz; + sa->esn_low =0 ; + sa->esn_hi =0 ; + } +return otx2_cpt_enq_sa_write (lp, crypto_dev->data->queue_pairs[0 ],OTX2_IPSEC_PO_WRITE_IPSEC_INB ); }
drivers/crypto/octeontx2/otx2_ipsec_anti_replay.h +21 -0
@@ -204,4 +204,25 @@ cpt_ipsec_ip_antireplay_check(struct otx2_ipsec_fp_in_sa *sa, char *data) return ret; } + +static inline uint32_t +anti_replay_get_seqh (uint32_t winsz,uint32_t seql, +uint32_t esn_hi,uint32_t esn_low) +{ +uint32_t win_low = esn_low - winsz +1 ; + +if (esn_low > winsz -1 ) { +/* Window is in one sequence number subspace */ +if (seql > win_low) +return esn_hi; +else +return esn_hi +1 ; + }else { +/* Window is split across two sequence number subspaces */ +if (seql > win_low) +return esn_hi -1 ; +else +return esn_hi; + } +}#endif /* __OTX2_IPSEC_ANTI_REPLAY_H__ */
drivers/crypto/octeontx2/otx2_ipsec_po.h +5 -0
@@ -161,6 +161,11 @@ struct otx2_ipsec_po_in_sa {uint8_t hmac_key[48 ];struct otx2_ipsec_po_traffic_selector selector; } aes_gcm; +union { +struct otx2_ipsec_replay *replay; +uint64_t replay64; + }; +uint32_t replay_win_sz; };struct otx2_ipsec_po_ip_template {
drivers/crypto/octeontx2/otx2_ipsec_po_ops.h +2 -0
@@ -124,6 +124,8 @@ process_outb_sa(struct rte_crypto_op *cop, req->ist.ei1 =rte_pktmbuf_iova (m_src); req->ist.ei2 = req->ist.ei1; + sa->esn_hi = sess->seq_hi; + hdr->seq =rte_cpu_to_be_32 (sess->seq_lo); hdr->ip_id =rte_cpu_to_be_32 (sess->ip_id);
Signature · 1 line
2.27.0
Quoted 10 lines
This series adds lookaside IPsec ESN and anti-replay support to OCTEON TX2 crypto PMD.
The functionality has been tested with ipsec-secgw application running in lookaside protocol offload mode.Tejasree Kondoj (2):
crypto/octeontx2: make anti-replay routine genericcrypto/octeontx2: add lookaside IPsec ESN and anti-replay support
Quoted 11 lines
doc/guides/cryptodevs/octeontx2.rst | 2 + doc/guides/rel_notes/release_21_02.rst | 5 ++ drivers/crypto/octeontx2/otx2_cryptodev_ops.c | 47 ++++++++++++++++++- drivers/crypto/octeontx2/otx2_cryptodev_sec.c | 21 +++++++++ .../crypto/octeontx2/otx2_ipsec_anti_replay.h | 32 ++++++++++--- drivers/crypto/octeontx2/otx2_ipsec_po.h | 5 ++ drivers/crypto/octeontx2/otx2_ipsec_po_ops.h | 2 + drivers/net/octeontx2/otx2_rx.h | 2 +- 8 files changed, 107 insertions(+), 9 deletions(-)
Series Acked-by: Anoob Joseph <[email protected]>
Akhil Goyal
AppliedQuoted 22 lines
Quoted 10 lines
This series adds lookaside IPsec ESN and anti-replay support to OCTEON TX2 crypto PMD.
The functionality has been tested with ipsec-secgw application running in lookaside protocol offload mode.Tejasree Kondoj (2):
crypto/octeontx2: make anti-replay routine genericcrypto/octeontx2: add lookaside IPsec ESN and anti-replay supportQuoted 11 lines
doc/guides/cryptodevs/octeontx2.rst | 2 + doc/guides/rel_notes/release_21_02.rst | 5 ++ drivers/crypto/octeontx2/otx2_cryptodev_ops.c | 47 ++++++++++++++++++- drivers/crypto/octeontx2/otx2_cryptodev_sec.c | 21 +++++++++ .../crypto/octeontx2/otx2_ipsec_anti_replay.h | 32 ++++++++++--- drivers/crypto/octeontx2/otx2_ipsec_po.h | 5 ++ drivers/crypto/octeontx2/otx2_ipsec_po_ops.h | 2 + drivers/net/octeontx2/otx2_rx.h | 2 +- 8 files changed, 107 insertions(+), 9 deletions(-)
Quoted 1 line
Series Acked-by: Anoob Joseph <[email protected]>
Applied to dpdk-next-crypto
Thanks.