X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Focteontx2%2Fotx2_rx.h;h=ea29aec62fe58aab7bbc60c0f0de6b969561e11e;hb=6065f4cdc31ba83e41688691b61f025c03edb1c6;hp=926f614a4e04734236bfba812a403223c1d70b70;hpb=af50731085f5057df92813c362d31f0ad1b9efaf;p=dpdk.git diff --git a/drivers/net/octeontx2/otx2_rx.h b/drivers/net/octeontx2/otx2_rx.h index 926f614a4e..ea29aec62f 100644 --- a/drivers/net/octeontx2/otx2_rx.h +++ b/drivers/net/octeontx2/otx2_rx.h @@ -41,7 +41,6 @@ /* Inline IPsec offsets */ -#define INLINE_INB_RPTR_HDR 16 /* nix_cqe_hdr_s + nix_rx_parse_s + nix_rx_sg_s + nix_iova_s */ #define INLINE_CPT_RESULT_OFFSET 80 @@ -215,6 +214,7 @@ nix_cqe_xtract_mseg(const struct nix_rx_parse_s *rx, iova_list = (const rte_iova_t *)(iova_list + 1); } } + mbuf->next = NULL; } static __rte_always_inline uint16_t @@ -238,14 +238,18 @@ nix_rx_sec_sa_get(const void * const lookup_mem, int spi, uint16_t port) } static __rte_always_inline uint64_t -nix_rx_sec_mbuf_update(const struct nix_cqe_hdr_s *cq, struct rte_mbuf *m, +nix_rx_sec_mbuf_update(const struct nix_rx_parse_s *rx, + const struct nix_cqe_hdr_s *cq, struct rte_mbuf *m, const void * const lookup_mem) { + uint8_t *l2_ptr, *l3_ptr, *l2_ptr_actual, *l3_ptr_actual; struct otx2_ipsec_fp_in_sa *sa; - struct rte_ipv4_hdr *ipv4; - uint16_t m_len; + uint16_t m_len, l2_len, ip_len; + struct rte_ipv6_hdr *ip6h; + struct rte_ipv4_hdr *iph; + uint16_t *ether_type; uint32_t spi; - char *data; + int i; if (unlikely(nix_rx_sec_cptres_get(cq) != OTX2_SEC_COMP_GOOD)) return PKT_RX_SEC_OFFLOAD | PKT_RX_SEC_OFFLOAD_FAILED; @@ -256,22 +260,38 @@ nix_rx_sec_mbuf_update(const struct nix_cqe_hdr_s *cq, struct rte_mbuf *m, sa = nix_rx_sec_sa_get(lookup_mem, spi, m->port); *rte_security_dynfield(m) = sa->udata64; - data = rte_pktmbuf_mtod(m, char *); + l2_ptr = rte_pktmbuf_mtod(m, uint8_t *); + l2_len = rx->lcptr - rx->laptr; + l3_ptr = RTE_PTR_ADD(l2_ptr, l2_len); if (sa->replay_win_sz) { - if (cpt_ipsec_antireplay_check(sa, data) < 0) + if (cpt_ipsec_ip_antireplay_check(sa, l3_ptr) < 0) return PKT_RX_SEC_OFFLOAD | PKT_RX_SEC_OFFLOAD_FAILED; } - memcpy(data + INLINE_INB_RPTR_HDR, data, RTE_ETHER_HDR_LEN); + l2_ptr_actual = RTE_PTR_ADD(l2_ptr, + sizeof(struct otx2_ipsec_fp_res_hdr)); + l3_ptr_actual = RTE_PTR_ADD(l3_ptr, + sizeof(struct otx2_ipsec_fp_res_hdr)); - m->data_off += INLINE_INB_RPTR_HDR; + for (i = l2_len - RTE_ETHER_TYPE_LEN - 1; i >= 0; i--) + l2_ptr_actual[i] = l2_ptr[i]; - ipv4 = (struct rte_ipv4_hdr *)(data + INLINE_INB_RPTR_HDR + - RTE_ETHER_HDR_LEN); + m->data_off += sizeof(struct otx2_ipsec_fp_res_hdr); - m_len = rte_be_to_cpu_16(ipv4->total_length) + RTE_ETHER_HDR_LEN; + ether_type = RTE_PTR_SUB(l3_ptr_actual, RTE_ETHER_TYPE_LEN); + iph = (struct rte_ipv4_hdr *)l3_ptr_actual; + if ((iph->version_ihl >> 4) == 4) { + ip_len = rte_be_to_cpu_16(iph->total_length); + *ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); + } else { + ip6h = (struct rte_ipv6_hdr *)iph; + ip_len = rte_be_to_cpu_16(ip6h->payload_len); + *ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6); + } + + m_len = ip_len + l2_len; m->data_len = m_len; m->pkt_len = m_len; return PKT_RX_SEC_OFFLOAD; @@ -321,7 +341,7 @@ otx2_nix_cqe_to_mbuf(const struct nix_cqe_hdr_s *cq, const uint32_t tag, if ((flag & NIX_RX_OFFLOAD_SECURITY_F) && cq->cqe_type == NIX_XQE_TYPE_RX_IPSECH) { *(uint64_t *)(&mbuf->rearm_data) = val; - ol_flags |= nix_rx_sec_mbuf_update(cq, mbuf, lookup_mem); + ol_flags |= nix_rx_sec_mbuf_update(rx, cq, mbuf, lookup_mem); mbuf->ol_flags = ol_flags; return; } @@ -330,10 +350,12 @@ otx2_nix_cqe_to_mbuf(const struct nix_cqe_hdr_s *cq, const uint32_t tag, *(uint64_t *)(&mbuf->rearm_data) = val; mbuf->pkt_len = len; - if (flag & NIX_RX_MULTI_SEG_F) + if (flag & NIX_RX_MULTI_SEG_F) { nix_cqe_xtract_mseg(rx, mbuf, val); - else + } else { mbuf->data_len = len; + mbuf->next = NULL; + } } #define CKSUM_F NIX_RX_OFFLOAD_CHECKSUM_F