From patchwork Sat Oct 24 06:09:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Hall X-Patchwork-Id: 7984 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 045875A8B; Sat, 24 Oct 2015 08:09:36 +0200 (CEST) Received: from mail.mhcomputing.net (master.mhcomputing.net [74.208.46.186]) by dpdk.org (Postfix) with ESMTP id 34D4B5A6F for ; Sat, 24 Oct 2015 08:09:33 +0200 (CEST) Received: from mhall-osx-home.local (99-34-229-174.lightspeed.sntcca.sbcglobal.net [99.34.229.174]) by mail.mhcomputing.net (Postfix) with ESMTPSA id 164BD80C003; Fri, 23 Oct 2015 23:07:49 -0700 (PDT) To: Michal Jastrzebski , Michal Kobylinski References: <1445608311-8092-1-git-send-email-michalx.k.jastrzebski@intel.com> <20151023162033.GA10036@mhcomputing.net> From: Matthew Hall Message-ID: <562B209A.6030507@mhcomputing.net> Date: Fri, 23 Oct 2015 23:09:30 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151023162033.GA10036@mhcomputing.net> Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v1 0/3] lpm: increase number of next hops for lpm (ipv4) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 10/23/15 9:20 AM, Matthew Hall wrote: > On Fri, Oct 23, 2015 at 03:51:48PM +0200, Michal Jastrzebski wrote: >> From: Michal Kobylinski >> >> The current DPDK implementation for LPM for IPv4 and IPv6 limits the >> number of next hops to 256, as the next hop ID is an 8-bit long field. >> Proposed extension increase number of next hops for IPv4 to 2^24 and >> also allows 32-bits read/write operations. >> >> This patchset requires additional change to rte_table library to meet >> ABI compatibility requirements. A v2 will be sent next week. > > I also have a patchset for this. > > I will send it out as well so we could compare. > > Matthew. Sorry about the delay; I only work on DPDK in personal time and not as part of a job. My patchset is attached to this email. One possible advantage with my patchset, compared to others, is that the space problem is fixed in both IPV4 and in IPV6, to prevent asymmetry between these two standards, which is something I try to avoid as much as humanly possible. This is because my application code is green-field, so I absolutely don't want to put any ugly hacks or incompatibilities in this code if I can possibly avoid it. Otherwise, I am not necessarily as expert about rte_lpm as some of the full-time guys, but I think with four or five of us in the thread hammering out patches we will be able to create something amazing together and I am very very very very very happy about this. Matthew. From 6a8e3428344ed11af8a1999dcec5c31c10f37c3a Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Sat, 27 Jun 2015 22:49:46 +0000 Subject: [PATCH 1/8] rte_lpm.h: use 24 bit extended next hop Signed-off-by: Matthew Hall --- lib/librte_lpm/rte_lpm.h | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h index c299ce2..c677c4a 100644 --- a/lib/librte_lpm/rte_lpm.h +++ b/lib/librte_lpm/rte_lpm.h @@ -82,32 +82,36 @@ extern "C" { #endif /** @internal bitmask with valid and ext_entry/valid_group fields set */ -#define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x0300 +#define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x03000000 + +/** @internal bitmask with next_hop field set */ +#define RTE_LPM_NEXT_HOP_BITMASK 0x00FFFFFF /** Bitmask used to indicate successful lookup */ -#define RTE_LPM_LOOKUP_SUCCESS 0x0100 +#define RTE_LPM_LOOKUP_SUCCESS 0x01000000 + #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN /** @internal Tbl24 entry structure. */ struct rte_lpm_tbl24_entry { - /* Stores Next hop or group index (i.e. gindex)into tbl8. */ + /* Stores Next hop or group index (i.e. gindex) into tbl8. */ union { - uint8_t next_hop; - uint8_t tbl8_gindex; - }; + uint32_t next_hop :24; + uint32_t tbl8_gindex :24; + } __attribute__((__packed__)); /* Using single uint8_t to store 3 values. */ - uint8_t valid :1; /**< Validation flag. */ - uint8_t ext_entry :1; /**< External entry. */ - uint8_t depth :6; /**< Rule depth. */ + uint32_t valid :1; /**< Validation flag. */ + uint32_t ext_entry :1; /**< External entry. */ + uint32_t depth :6; /**< Rule depth. */ }; /** @internal Tbl8 entry structure. */ struct rte_lpm_tbl8_entry { - uint8_t next_hop; /**< next hop. */ + uint32_t next_hop :24; /**< next hop. */ /* Using single uint8_t to store 3 values. */ - uint8_t valid :1; /**< Validation flag. */ - uint8_t valid_group :1; /**< Group validation flag. */ - uint8_t depth :6; /**< Rule depth. */ + uint8_t valid :1; /**< Validation flag. */ + uint8_t valid_group :1; /**< Group validation flag. */ + uint8_t depth :6; /**< Rule depth. */ }; #else struct rte_lpm_tbl24_entry { @@ -130,8 +134,8 @@ struct rte_lpm_tbl8_entry { /** @internal Rule structure. */ struct rte_lpm_rule { - uint32_t ip; /**< Rule IP address. */ - uint8_t next_hop; /**< Rule next hop. */ + uint32_t ip; /**< Rule IP address. */ + uint32_t next_hop; /**< Rule next hop. */ }; /** @internal Contains metadata about the rules table. */ @@ -219,7 +223,7 @@ rte_lpm_free(struct rte_lpm *lpm); * 0 on success, negative value otherwise */ int -rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, uint8_t next_hop); +rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, uint32_t next_hop); /** * Check if a rule is present in the LPM table, @@ -238,7 +242,7 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, uint8_t next_hop); */ int rte_lpm_is_rule_present(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, -uint8_t *next_hop); +uint32_t *next_hop); /** * Delete a rule from the LPM table. @@ -301,6 +305,8 @@ rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint8_t *next_hop) *next_hop = (uint8_t)tbl_entry; return (tbl_entry & RTE_LPM_LOOKUP_SUCCESS) ? 0 : -ENOENT; } +int +rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop); /** * Lookup multiple IP addresses in an LPM table. This may be implemented as a @@ -360,6 +366,9 @@ rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t * ips, /* Mask four results. */ #define RTE_LPM_MASKX4_RES UINT64_C(0x00ff00ff00ff00ff) +int +rte_lpm_lookup_bulk(const struct rte_lpm *lpm, const uint32_t * ips, + uint32_t * next_hops, const unsigned n); /** * Lookup four IP addresses in an LPM table. @@ -472,6 +481,9 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, __m128i ip, uint16_t hop[4], hop[2] = (tbl[2] & RTE_LPM_LOOKUP_SUCCESS) ? (uint8_t)tbl[2] : defv; hop[3] = (tbl[3] & RTE_LPM_LOOKUP_SUCCESS) ? (uint8_t)tbl[3] : defv; } +void +rte_lpm_lookupx4(const struct rte_lpm *lpm, __m128i ip, uint32_t hop[4], + uint32_t defv); #ifdef __cplusplus }