From patchwork Fri Jun 3 11:11:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Morrissey X-Patchwork-Id: 112295 X-Patchwork-Delegate: thomas@monjalon.net 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 1CE36A055C; Fri, 3 Jun 2022 13:11:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EFA044069D; Fri, 3 Jun 2022 13:11:17 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 488D940694 for ; Fri, 3 Jun 2022 13:11:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654254676; x=1685790676; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=gDA+k8Yd31z5i8Y2c0uiSLx/DivgR47+4eEqxPll5fs=; b=DP+4jQDh5PVR/vuVG4RFPgrCIfk5dimWNiHkpGxuChj0k29pXHQL/xqI QW623ahuWruT9BHJEanjVfYdme9rbxhYvp0XeKNYsg8dDraECbD+aLUC5 QkGf4h/xjuO2HnhXpKUeDw01NqZNhwA2lrH/+M3YrOWRQlMMTidlWtg8J U4pcKyrmeGv7bnYJ+6+PHrfykMkemKncdB/gPB8Vw3AjAeVpudJcWCQNU ZegDU4JP+dFAM9UaqQq8TvVz+7CwegevphoyOPC60HnGLVvmMp+V+CfJJ wOWggVxMfBhsbjj8dF3mLT71YTcWqB8PcLTDNdUNywsusUznSOn5+EanH A==; X-IronPort-AV: E=McAfee;i="6400,9594,10366"; a="263876525" X-IronPort-AV: E=Sophos;i="5.91,274,1647327600"; d="scan'208";a="263876525" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2022 04:11:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,274,1647327600"; d="scan'208";a="613234763" Received: from silpixa00401215.ir.intel.com ([10.55.128.100]) by orsmga001.jf.intel.com with ESMTP; 03 Jun 2022 04:11:14 -0700 From: Sean Morrissey To: Bruce Richardson , Konstantin Ananyev Cc: dev@dpdk.org, Sean Morrissey Subject: [PATCH v1] docs: update l3fwd sample app docs Date: Fri, 3 Jun 2022 11:11:03 +0000 Message-Id: <20220603111103.2661619-1-sean.morrissey@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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 The L3FWD sample app doc contains outdated static code snippets and references to functions which no longer exist. This patch updates this doc to use up to date references. Signed-off-by: Sean Morrissey --- doc/guides/sample_app_ug/l3_forward.rst | 87 +++++++------------------ examples/l3fwd/l3fwd_em_hlm_sse.h | 2 + examples/l3fwd/l3fwd_lpm.c | 2 + 3 files changed, 28 insertions(+), 63 deletions(-) diff --git a/doc/guides/sample_app_ug/l3_forward.rst b/doc/guides/sample_app_ug/l3_forward.rst index 01d86db95d..50720f0e42 100644 --- a/doc/guides/sample_app_ug/l3_forward.rst +++ b/doc/guides/sample_app_ug/l3_forward.rst @@ -190,7 +190,7 @@ In this command: * The --mode option defines PMD to be used for packet I/O. -* The --eventq-sched option enables synchronization menthod of event queue so that packets will be scheduled accordingly. +* The --eventq-sched option enables synchronization method of event queue so that packets will be scheduled accordingly. If application uses S/W scheduler, it uses following DPDK services: @@ -290,36 +290,20 @@ for the convenience to execute hash performance test on 4M/8M/16M flows. which is used to specify the total hash entry number for all used ports in hash performance test, can be specified with --hash-entry-num VALUE in command line, being its default value 4. -.. code-block:: c - - #if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH) - - static void - setup_hash(int socketid) - { - // ... - - if (ipv6 == 0) { - /* populate the ipv4 hash */ - populate_ipv4_flow_into_table( - ipv4_l3fwd_em_lookup_struct[socketid]); - } else { - /* populate the ipv6 hash */ - populate_ipv6_flow_into_table( - ipv6_l3fwd_em_lookup_struct[socketid]); - } - } - #endif +.. literalinclude:: ../../../examples/l3fwd/l3fwd_em.c + :language: c + :start-after: Initialize exact match (hash) parameters. 8< + :end-before: >8 End of initialization of hash parameters. LPM Initialization ~~~~~~~~~~~~~~~~~~ The LPM object is created and loaded with the pre-configured entries read from a global array. -.. literalinclude:: ../../../examples/l3fwd/l3fwd_em.c +.. literalinclude:: ../../../examples/l3fwd/l3fwd_lpm.c :language: c - :start-after: Initialize exact match (hash) parameters. 8< - :end-before: >8 End of initialization of hash parameters. + :start-after: Initialize lpm (longest prefix match) parameters. 8< + :end-before: >8 End of initialization of lpm parameters. FIB Initialization ~~~~~~~~~~~~~~~~~~ @@ -337,62 +321,39 @@ the full setup function including the IPv6 setup can be seen in the app code. Packet Forwarding for Hash-based Lookups ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -For each input packet, the packet forwarding operation is done by the l3fwd_simple_forward() -or simple_ipv4_fwd_4pkts() function for IPv4 packets or the simple_ipv6_fwd_4pkts() function for IPv6 packets. -The l3fwd_simple_forward() function provides the basic functionality for both IPv4 and IPv6 packet forwarding +For each input packet, the packet forwarding operation is done by the l3fwd_em_simple_forward() +where the l3fwd_em_handle_ipv4() function handles IPv4 packets and the l3fwd_em_handle_ipv6() function handles IPv6 packets. +The l3fwd_em_simple_forward() function provides the basic functionality for both IPv4 and IPv6 packet forwarding for any number of burst packets received, and the packet forwarding decision (that is, the identification of the output interface for the packet) -for hash-based lookups is done by the get_ipv4_dst_port() or get_ipv6_dst_port() function. -The get_ipv4_dst_port() function is shown below: +for hash-based lookups is done by the em_get_ipv4_dst_port() or em_get_ipv6_dst_port() function. +The em_get_ipv4_dst_port() function is shown below: .. literalinclude:: ../../../examples/l3fwd/l3fwd_em.c :language: c :start-after: Performing hash-based lookups. 8< :end-before: >8 End of performing hash-based lookups. -The get_ipv6_dst_port() function is similar to the get_ipv4_dst_port() function. - -The simple_ipv4_fwd_4pkts() and simple_ipv6_fwd_4pkts() function are optimized for continuous 4 valid ipv4 and ipv6 packets, -they leverage the multiple buffer optimization to boost the performance of forwarding packets with the exact match on hash table. -The key code snippet of simple_ipv4_fwd_4pkts() is shown below: - -.. code-block:: c - - static inline void - simple_ipv4_fwd_4pkts(struct rte_mbuf* m[4], uint16_t portid, struct lcore_conf *qconf) - { - // ... - - data[0] = _mm_loadu_si128(( m128i*)(rte_pktmbuf_mtod(m[0], unsigned char *) + sizeof(struct rte_ether_hdr) + offsetof(struct rte_ipv4_hdr, time_to_live))); - data[1] = _mm_loadu_si128(( m128i*)(rte_pktmbuf_mtod(m[1], unsigned char *) + sizeof(struct rte_ether_hdr) + offsetof(struct rte_ipv4_hdr, time_to_live))); - data[2] = _mm_loadu_si128(( m128i*)(rte_pktmbuf_mtod(m[2], unsigned char *) + sizeof(struct rte_ether_hdr) + offsetof(struct rte_ipv4_hdr, time_to_live))); - data[3] = _mm_loadu_si128(( m128i*)(rte_pktmbuf_mtod(m[3], unsigned char *) + sizeof(struct rte_ether_hdr) + offsetof(struct rte_ipv4_hdr, time_to_live))); +The em_get_ipv6_dst_port() function is similar to the em_get_ipv4_dst_port() function. - key[0].xmm = _mm_and_si128(data[0], mask0); - key[1].xmm = _mm_and_si128(data[1], mask0); - key[2].xmm = _mm_and_si128(data[2], mask0); - key[3].xmm = _mm_and_si128(data[3], mask0); +The get_ipv4_5tuple() and get_ipv6_5tuple() function are optimized for continuous valid ipv4 and ipv6 packets, +along with em_get_dst_port_ipv4xN() and em_get_dst_port_ipv6xN() they leverage the multiple buffer +optimization to boost the performance of forwarding packets with the exact match on hash table. +The key code snippet of get_ipv4_5tuple() is shown below: - const void *key_array[4] = {&key[0], &key[1], &key[2],&key[3]}; - - rte_hash_lookup_bulk(qconf->ipv4_lookup_struct, &key_array[0], 4, ret); - - dst_port[0] = (ret[0] < 0)? portid:ipv4_l3fwd_out_if[ret[0]]; - dst_port[1] = (ret[1] < 0)? portid:ipv4_l3fwd_out_if[ret[1]]; - dst_port[2] = (ret[2] < 0)? portid:ipv4_l3fwd_out_if[ret[2]]; - dst_port[3] = (ret[3] < 0)? portid:ipv4_l3fwd_out_if[ret[3]]; - - // ... - } +.. literalinclude:: ../../../examples/l3fwd/l3fwd_em_hlm_sse.h + :language: c + :start-after: Optimized IPv4 tuple acquire. 8< + :end-before: >8 End of optimized IPv4 tuple acquire. -The simple_ipv6_fwd_4pkts() function is similar to the simple_ipv4_fwd_4pkts() function. +The get_ipv6_5tuple() function is similar to the get_ipv4_5tuple() function. Known issue: IP packets with extensions or IP packets which are not TCP/UDP cannot work well at this mode. Packet Forwarding for LPM-based Lookups ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -For each input packet, the packet forwarding operation is done by the l3fwd_simple_forward() function, +For each input packet, the packet forwarding operation is done by the l3fwd_lpm_simple_forward() function, but the packet forwarding decision (that is, the identification of the output interface for the packet) for LPM-based lookups is done by the get_ipv4_dst_port() function below: diff --git a/examples/l3fwd/l3fwd_em_hlm_sse.h b/examples/l3fwd/l3fwd_em_hlm_sse.h index 7964a92771..47bee6ad93 100644 --- a/examples/l3fwd/l3fwd_em_hlm_sse.h +++ b/examples/l3fwd/l3fwd_em_hlm_sse.h @@ -7,6 +7,7 @@ #include "l3fwd_sse.h" +/* Optimized IPv4 tuple acquire. 8< */ static __rte_always_inline void get_ipv4_5tuple(struct rte_mbuf *m0, __m128i mask0, union ipv4_5tuple_host *key) @@ -18,6 +19,7 @@ get_ipv4_5tuple(struct rte_mbuf *m0, __m128i mask0, key->xmm = _mm_and_si128(tmpdata0, mask0); } +/* >8 End of optimized IPv4 tuple acquire. */ static inline void get_ipv6_5tuple(struct rte_mbuf *m0, __m128i mask0, diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index d1b850dd5b..47437b453d 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -548,6 +548,7 @@ lpm_event_main_loop_tx_q_burst_vector(__rte_unused void *dummy) return 0; } +/* Initialize lpm (longest prefix match) parameters. 8< */ void setup_lpm(const int socketid) { @@ -645,6 +646,7 @@ setup_lpm(const int socketid) route_base_v6[i].if_out, dev_info.device->name); } } +/* >8 End of initialization of lpm parameters. */ int lpm_check_ptype(int portid)