From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 95604A0C3F; Thu, 15 Apr 2021 16:39:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1CBF11620EE; Thu, 15 Apr 2021 16:39:10 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id E0EC71620E4 for ; Thu, 15 Apr 2021 16:39:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618497548; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hR72SJ/HByl9aLEi8AWbHiZDAOW48kOThY1aouJUtIU=; b=W25G7CKjeyV8M9Qzg3meNU5IyqIOT+q8AsTaiYr9IIcAV9csuDxzLtB7CS2U+cyQdpSo1S wDeaXldkrN7zosiitIkXgbL4u8sgSwuJyPGKlhNOHMKWCiPdpciUkn0Jbnt18MGz5s5b1s 3WemmPUeThrQt4AjLMP8mpzr5cgkCq4= Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-239-_C6MIkg8MXeLX8HLRBE3iw-1; Thu, 15 Apr 2021 10:39:03 -0400 X-MC-Unique: _C6MIkg8MXeLX8HLRBE3iw-1 Received: by mail-vk1-f199.google.com with SMTP id a133-20020a1ffc8b0000b02901ca14ac4722so1326567vki.23 for ; Thu, 15 Apr 2021 07:39:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hR72SJ/HByl9aLEi8AWbHiZDAOW48kOThY1aouJUtIU=; b=CQ0h6c4Hwynra2muBBqw/I2kKVTKD2CoJKGGf+sRTDAuBzHHAz+oL26XA77WOwu21U fRYddra5gs3bx6cXSAzGX/5mYhK0+5Db+l/QkiXjlgA1rpLa9JTXuZvy9jFUL8wGaHo9 r5880ajs5kru6jRsTJx1NvnbgKv7lhsbyz/Cbj3QdgnkgMb7rCGdpiZ2dRR02+sx0UGz LIwXjHGXnNM+2wdVTmvWghZgbBpkKmq1qWyTBx5IXKVdmJfZjcdraeukxdWIgq1TMgFm bmk2DEOE+njsra/BUeMLzQ/Pe1WHYRCYGdkLEnm/Qv2xD5amGhQhjp4Sl/ZlK+33HFPI kdwA== X-Gm-Message-State: AOAM530B1Xmm28fweaF7U84bBRxsJpo5vzDiObnW3Io9NkdQ4hGHStdy +oIL9P3nKbVQVoH/NxixPqbYyg7DvBEQ679QNboSDyvtDlBdrC/f2nimvIXaqsp8aeypS6Z9Nh8 +JxI5d5BtxIHiirJMapc= X-Received: by 2002:a67:87c1:: with SMTP id j184mr2454619vsd.18.1618497542446; Thu, 15 Apr 2021 07:39:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQGVbNZgt1yJ9hAXvXSxWFn3MpAyPH8+HGUb8m1egLWWhA9/QxDZYMltxub6wTmPUQwv6ETK04lAVCZp2d26s= X-Received: by 2002:a67:87c1:: with SMTP id j184mr2454599vsd.18.1618497542187; Thu, 15 Apr 2021 07:39:02 -0700 (PDT) MIME-Version: 1.0 References: <20210402105252.1145821-1-conor.walsh@intel.com> <20210406111106.2020555-1-conor.walsh@intel.com> <20210406111106.2020555-3-conor.walsh@intel.com> In-Reply-To: <20210406111106.2020555-3-conor.walsh@intel.com> From: David Marchand Date: Thu, 15 Apr 2021 16:38:50 +0200 Message-ID: To: Conor Walsh Cc: Jerin Jacob Kollanukkaran , Stephen Hemminger , "Iremonger, Bernard" , "Ananyev, Konstantin" , Vladimir Medvedkin , "Burakov, Anatoly" , "Mcnamara, John" , dev Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v7 2/5] examples/l3fwd: move l3fwd routes to common header 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" On Tue, Apr 6, 2021 at 1:11 PM Conor Walsh wrote: > > To prevent code duplication from the addition of lookup methods > the routes specified in lpm should be moved to a common header. > > Signed-off-by: Conor Walsh > Acked-by: Konstantin Ananyev > Acked-by: Vladimir Medvedkin > --- > examples/l3fwd/l3fwd_common_route.h | 48 +++++++++++++++++++ > examples/l3fwd/l3fwd_lpm.c | 74 +++++++---------------------- > 2 files changed, 65 insertions(+), 57 deletions(-) > create mode 100644 examples/l3fwd/l3fwd_common_route.h > > diff --git a/examples/l3fwd/l3fwd_common_route.h b/examples/l3fwd/l3fwd_common_route.h > new file mode 100644 > index 0000000000..7f0125a8a5 > --- /dev/null > +++ b/examples/l3fwd/l3fwd_common_route.h > @@ -0,0 +1,48 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2021 Intel Corporation > + */ > + > +#include > +#include > + > +struct ipv4_l3fwd_common_route { Why "common" ? ipv4_l3fwd_route is enough. Plus, this is what we reference in the doc. doc/guides/sample_app_ug/l3_forward.rst: if ((1 << ipv4_l3fwd_route_array[i].if_out & enabled_port_mask) == 0) doc/guides/sample_app_ug/l3_forward.rst: ret = rte_lpm_add(ipv4_l3fwd_lookup_struct[socketid], ipv4_l3fwd_route_array[i].ip, doc/guides/sample_app_ug/l3_forward.rst: ipv4_l3fwd_route_array[i].depth, ipv4_l3fwd_route_array[i].if_out); doc/guides/sample_app_ug/l3_forward.rst: (unsigned)ipv4_l3fwd_route_array[i].ip, ipv4_l3fwd_route_array[i].depth, ipv4_l3fwd_route_array[i].if_out); > + uint32_t ip; > + uint8_t depth; > + uint8_t if_out; > +}; > + > +struct ipv6_l3fwd_common_route { > + uint8_t ip[16]; > + uint8_t depth; Unneeded double space. > + uint8_t if_out; > +}; > + > +/* > + * 198.18.0.0/16 are set aside for RFC2544 benchmarking (RFC5735). > + * 198.18.{0-7}.0/24 = Port {0-7} > + */ > +static const struct ipv4_l3fwd_common_route ipv4_l3fwd_common_route_array[] = { > + {RTE_IPV4(198, 18, 0, 0), 24, 0}, > + {RTE_IPV4(198, 18, 1, 0), 24, 1}, > + {RTE_IPV4(198, 18, 2, 0), 24, 2}, > + {RTE_IPV4(198, 18, 3, 0), 24, 3}, > + {RTE_IPV4(198, 18, 4, 0), 24, 4}, > + {RTE_IPV4(198, 18, 5, 0), 24, 5}, > + {RTE_IPV4(198, 18, 6, 0), 24, 6}, > + {RTE_IPV4(198, 18, 7, 0), 24, 7}, > +}; With static symbols, we end up with duplicating info in lpm / fib. $ nm build/examples/dpdk-l3fwd |grep ipv4_l3fwd_common_route_array 000000000100c260 r ipv4_l3fwd_common_route_array 000000000100c4c0 r ipv4_l3fwd_common_route_array You can declare global symbols in a common header, and define them in main.c. > + > +/* > + * 2001:200::/48 is IANA reserved range for IPv6 benchmarking (RFC5180). > + * 2001:200:0:{0-7}::/64 = Port {0-7} > + */ > +static const struct ipv6_l3fwd_common_route ipv6_l3fwd_common_route_array[] = { > + {{32, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 0}, > + {{32, 1, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 1}, > + {{32, 1, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 2}, > + {{32, 1, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 3}, > + {{32, 1, 2, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 4}, > + {{32, 1, 2, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 5}, > + {{32, 1, 2, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 6}, > + {{32, 1, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 7}, > +}; -- David Marchand