X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fcrypto%2Focteontx2%2Fotx2_ipsec_anti_replay.h;h=089a3d073a2e34484e8a768d8026e4d276e6efaa;hb=40beec4bf4e37327437dbcf0e9991a48ed369848;hp=d599692a75b2a230f49137966b57dfbcae74e4fe;hpb=cc882d6469e5059b11d1fc2db81cdb8607b050bb;p=dpdk.git diff --git a/drivers/crypto/octeontx2/otx2_ipsec_anti_replay.h b/drivers/crypto/octeontx2/otx2_ipsec_anti_replay.h index d599692a75..089a3d073a 100644 --- a/drivers/crypto/octeontx2/otx2_ipsec_anti_replay.h +++ b/drivers/crypto/octeontx2/otx2_ipsec_anti_replay.h @@ -166,8 +166,9 @@ winupdate: } static inline int -cpt_ipsec_ip_antireplay_check(struct otx2_ipsec_fp_in_sa *sa, char *data) +cpt_ipsec_ip_antireplay_check(struct otx2_ipsec_fp_in_sa *sa, void *l3_ptr) { + struct otx2_ipsec_fp_res_hdr *hdr = l3_ptr; uint64_t seq_in_sa; uint32_t seqh = 0; uint32_t seql; @@ -176,14 +177,12 @@ cpt_ipsec_ip_antireplay_check(struct otx2_ipsec_fp_in_sa *sa, char *data) int ret; esn = sa->ctl.esn_en; - seql = rte_be_to_cpu_32(*((uint32_t *)(data + - OTX2_IPSEC_SEQNO_LO_INDEX))); + seql = rte_be_to_cpu_32(hdr->seq_no_lo); if (!esn) seq = (uint64_t)seql; else { - seqh = rte_be_to_cpu_32(*((uint32_t *)(data + - OTX2_IPSEC_SEQNO_HI_INDEX))); + seqh = rte_be_to_cpu_32(hdr->seq_no_hi); seq = ((uint64_t)seqh << 32) | seql; } @@ -204,4 +203,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__ */