From patchwork Wed Aug 25 06:35:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 97292 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B4C4BA0C57; Wed, 25 Aug 2021 08:35:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43D4D40140; Wed, 25 Aug 2021 08:35:55 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 4C6FB40041 for ; Wed, 25 Aug 2021 08:35:54 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17OIRjLD022892; Tue, 24 Aug 2021 23:35:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=pfpt0220; bh=JBVRfZZ3Pl3UIRENP5jrnkb3f6kLxS/qLmfmDo33IW4=; b=JRZpcBoqZjfyv8wqEIbGtcXTyTHKNtUzQ6JalIHWV3CX2AlSBGZvNoPFz2eeTUp45Ctd 7Rc5+CLuzEBERkfriJUuhSU8kHBco1DN3JuGkigjpqFDGiaKQwGZrGBzn/7U6MdSAAtu eGGWY9MSao2N17VF64ALYdRo0OhLTuuWl32n86cz6XzztQzACuuLtCR9CALYNB/ClyGT tIMhOP8AnAl7tJm9oSvJVyLwDvl0tqz2cNfwypmXbZgSmEUeGlQ6LjIXe2QwntJCGj6E CerHUZwsF4P1rG247QLBINxQalJFbDzyr3rIf/tsfIFE7qX5LHH05rIpnLxlJ9gRPV17 jw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 3an62kt41x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 24 Aug 2021 23:35:53 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 24 Aug 2021 23:35:51 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Tue, 24 Aug 2021 23:35:51 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id AE9E53F7077; Tue, 24 Aug 2021 23:35:49 -0700 (PDT) From: Nithin Dabilpuram To: Radu Nicolau , Akhil Goyal CC: , , Nithin Dabilpuram Date: Wed, 25 Aug 2021 12:05:42 +0530 Message-ID: <20210825063542.23882-1-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 89qE9QHHjg74xVAOghCjJHjbDzsU3uTn X-Proofpoint-GUID: 89qE9QHHjg74xVAOghCjJHjbDzsU3uTn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-08-25_02,2021-08-25_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH] examples/ipsec-secgw: use mbuf packet type in ev worker X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Use mbuf packet type for traffic identification as packet is parsed already by HW before and HW/PMD updates necessary info in mbuf packet type of the found protocols. This change is specifically for event mode. Signed-off-by: Nithin Dabilpuram Acked-by: Akhil Goyal --- examples/ipsec-secgw/ipsec_worker.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/ipsec-secgw/ipsec_worker.c b/examples/ipsec-secgw/ipsec_worker.c index 647e22d..b77afb5 100644 --- a/examples/ipsec-secgw/ipsec_worker.c +++ b/examples/ipsec-secgw/ipsec_worker.c @@ -16,19 +16,22 @@ static inline enum pkt_type process_ipsec_get_pkt_type(struct rte_mbuf *pkt, uint8_t **nlp) { struct rte_ether_hdr *eth; + uint32_t ptype = pkt->packet_type; eth = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); - if (eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) { + rte_prefetch0(eth); + + if (RTE_ETH_IS_IPV4_HDR(ptype)) { *nlp = RTE_PTR_ADD(eth, RTE_ETHER_HDR_LEN + offsetof(struct ip, ip_p)); - if (**nlp == IPPROTO_ESP) + if ((ptype & RTE_PTYPE_TUNNEL_MASK) == RTE_PTYPE_TUNNEL_ESP) return PKT_TYPE_IPSEC_IPV4; else return PKT_TYPE_PLAIN_IPV4; - } else if (eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) { + } else if (RTE_ETH_IS_IPV6_HDR(ptype)) { *nlp = RTE_PTR_ADD(eth, RTE_ETHER_HDR_LEN + offsetof(struct ip6_hdr, ip6_nxt)); - if (**nlp == IPPROTO_ESP) + if ((ptype & RTE_PTYPE_TUNNEL_MASK) == RTE_PTYPE_TUNNEL_ESP) return PKT_TYPE_IPSEC_IPV6; else return PKT_TYPE_PLAIN_IPV6; @@ -336,7 +339,7 @@ process_ipsec_ev_outbound(struct ipsec_ctx *ctx, struct route_table *rt, } /* Validate sa_idx */ - if (sa_idx >= ctx->sa_ctx->nb_sa) + if (unlikely(sa_idx >= ctx->sa_ctx->nb_sa)) goto drop_pkt_and_exit; /* Else the packet has to be protected */ @@ -351,7 +354,7 @@ process_ipsec_ev_outbound(struct ipsec_ctx *ctx, struct route_table *rt, sess = ipsec_get_primary_session(sa); /* Allow only inline protocol for now */ - if (sess->type != RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) { + if (unlikely(sess->type != RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL)) { RTE_LOG(ERR, IPSEC, "SA type not supported\n"); goto drop_pkt_and_exit; }