lpm: increase number of next hops for lpm (ipv4)
cover lpm: increase number of next hops for lpm (ipv4)
From: Michal Kobylinski <[email protected]>
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.
Michal Kobylinski (3):
lpm: increase number of next hops for lpm (ipv4)
examples: update of apps using librte_lpm (ipv4)
doc: update release 2.2 after changes in librte_lpm
app/test/test_func_reentrancy.c | 4 +- app/test/test_lpm.c | 227 ++++----- doc/guides/rel_notes/release_2_2.rst | 2 + examples/ip_fragmentation/main.c | 10 +- examples/ip_reassembly/main.c | 9 +- examples/l3fwd-power/main.c | 2 +- examples/l3fwd-vf/main.c | 2 +- examples/l3fwd/main.c | 16 +- examples/load_balancer/runtime.c | 3 +- lib/librte_lpm/rte_lpm.c | 887 ++++++++++++++++++++++++++++++++++- lib/librte_lpm/rte_lpm.h | 295 +++++++++++- lib/librte_lpm/rte_lpm_version.map | 59 ++- lib/librte_table/rte_table_lpm.c | 10 +- 13 files changed, 1345 insertions(+), 181 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/3 lpm: increase number of next hops for lpm (ipv4)
From: Michal Kobylinski <[email protected]>
Main implementation - changes to lpm library regarding new data types. Additionally this patch implements changes required by test application. ABI versioning requirements are met only for lpm library, for table library it will be sent in v2 of this patch-set.
--- app/test/test_func_reentrancy.c | 4 +- app/test/test_lpm.c | 227 +++++----- lib/librte_lpm/rte_lpm.c | 887 ++++++++++++++++++++++++++++++++++++- lib/librte_lpm/rte_lpm.h | 295 +++++++++++- lib/librte_lpm/rte_lpm_version.map | 59 ++- lib/librte_table/rte_table_lpm.c | 10 +- 6 files changed, 1322 insertions(+), 160 deletions(-)
app/test/test_func_reentrancy.c +2 -2
@@ -343,7 +343,7 @@ static void lpm_clean(unsigned lcore_id) {char lpm_name[MAX_STRING_SIZE ]; -struct rte_lpm *lpm; +struct rte_lpm_extend *lpm;int i;for (i =0 ; i <MAX_LPM_ITER_TIMES ; i++) {
@@ -358,7 +358,7 @@ static int lpm_create_free(__attribute__((unused)) void *arg) {unsigned lcore_self =rte_lcore_id (); -struct rte_lpm *lpm; +struct rte_lpm_extend *lpm;char lpm_name[MAX_STRING_SIZE ];int i;
app/test/test_lpm.c +118 -109
717 lines not on this page · raw message
lib/librte_lpm/rte_lpm.c +875 -12
1,037 lines not on this page · raw message
lib/librte_lpm/rte_lpm.h +283 -12
417 lines not on this page · raw message
lib/librte_lpm/rte_lpm_version.map +39 -20
62 lines not on this page · raw message
lib/librte_table/rte_table_lpm.c +5 -5
@@ -70,7 +70,7 @@ struct rte_table_lpm {uint32_t offset;/* Handle to low-level LPM table */ -struct rte_lpm *lpm; +struct rte_lpm_extend *lpm;/* Next Hop Table (NHT) */ uint32_t nht_users[RTE_TABLE_LPM_MAX_NEXT_HOPS ];
@@ -202,7 +202,7 @@ rte_table_lpm_entry_add(struct rte_table_lpm_key *ip_prefix = (struct rte_table_lpm_key *) key;uint32_t nht_pos, nht_pos0_valid;int status; -uint8_t nht_pos0 =0 ; +uint32_t nht_pos0 =0 ;/* Check input parameters */ if (lpm ==NULL ) {
@@ -268,7 +268,7 @@ rte_table_lpm_entry_delete( {struct rte_table_lpm *lpm = (struct rte_table_lpm *) table;struct rte_table_lpm_key *ip_prefix = (struct rte_table_lpm_key *) key; -uint8_t nht_pos; +uint32_t nht_pos;int status;/* Check input parameters */
@@ -342,9 +342,9 @@ rte_table_lpm_lookup(uint32_t ip =rte_bswap32 (RTE_MBUF_METADATA_UINT32 (pkt, lpm->offset));int status; -uint8_t nht_pos; +uint32_t nht_pos; - status =rte_lpm_lookup (lpm->lpm, ip, &nht_pos); + status =rte_lpm_lookup_extend (lpm->lpm, ip, &nht_pos);if (status ==0 ) { pkts_out_mask |= pkt_mask; entries[i] = (void *) &lpm->nht[nht_pos *
Signature · 1 line
1.9.1
Quoted 22 lines · Michal Jastrzebski
From: Michal Kobylinski <[email protected]>
Main implementation - changes to lpm library regarding new data types. Additionally this patch implements changes required by test application. ABI versioning requirements are met only for lpm library, for table library it will be sent in v2 of this patch-set.
Signed-off-by Michal Kobylinski <[email protected]>--- app/test/test_func_reentrancy.c | 4 +- app/test/test_lpm.c | 227 +++++----- lib/librte_lpm/rte_lpm.c | 887 ++++++++++++++++++++++++++++++++++++- lib/librte_lpm/rte_lpm.h | 295 +++++++++++- lib/librte_lpm/rte_lpm_version.map | 59 ++- lib/librte_table/rte_table_lpm.c | 10 +- 6 files changed, 1322 insertions(+), 160 deletions(-)app/test/test_func_reentrancy.c +0
-0
app/test/test_func_reentrancy.c static void · line 346
Quoted 5 lines
app/test/test_func_reentrancy.c +1
-1@@ -343,7 +343,7 @@ static void lpm_clean(unsigned lcore_id) {char lpm_name[MAX_STRING_SIZE ]; -struct rte_lpm *lpm; +struct rte_lpm_extend *lpm;
I thought this patchset was just to increase the size of the lpm entries, not to create a whole new entry type? The structure names etc. should all stay the same, and let the ABI versionning take care of handling code using the older structures.
/Bruce
Quoted 45 lines
-----Original Message-----
From: Richardson, Bruce
Sent: Friday, October 23, 2015 4:39 PM
To: Jastrzebski, MichalX K
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v1 1/3] lpm: increase number of next hops for lpm (ipv4)Quoted 7 lines · Michal Jastrzebski
From: Michal Kobylinski <[email protected]>
Main implementation - changes to lpm library regarding new data types. Additionally this patch implements changes required by test application. ABI versioning requirements are met only for lpm library, for table library it will be sent in v2 of this patch-set.
Quoted 5 lines
Signed-off-by Michal Kobylinski <[email protected]>--- app/test/test_func_reentrancy.c | 4 +- app/test/test_lpm.c | 227 +++++----- lib/librte_lpm/rte_lpm.c | 887++++++++++++++++++++++++++++++++++++-
Review
Quoted 6 lines
lib/librte_lpm/rte_lpm.h | 295 +++++++++++- lib/librte_lpm/rte_lpm_version.map | 59 ++- lib/librte_table/rte_table_lpm.c | 10 +- 6 files changed, 1322 insertions(+), 160 deletions(-)(quoted diff) +0
-0
b/app/test/test_func_reentrancy.capp/test/test_func_reentrancy.c static void · line 346
Quoted 9 lines
index dbecc52..331ab29 100644
app/test/test_func_reentrancy.c +1
-1@@ -343,7 +343,7 @@ static void lpm_clean(unsigned lcore_id) {char lpm_name[MAX_STRING_SIZE ]; -struct rte_lpm *lpm; +struct rte_lpm_extend *lpm;I thought this patchset was just to increase the size of the lpm entries, not to create a whole new entry type? The structure names etc. should all stay the
same, and let the ABI versionning take care of handling code using the older structures.
Quoted 1 line
/Bruce
Hi Bruce,
I see Your point. I think we should use here RTE_NEXT_ABI macro.
The code will have to be duplicated but it will allow to use old names in a new version.
Michal
PATCH 2/3 examples: update of apps using librte_lpm (ipv4)
In reply to Michal JastrzebskiFrom: Michal Kobylinski <[email protected]>
This patch is adapting examples to use new rte_lpm structures.
--- examples/ip_fragmentation/main.c | 10 +++++----- examples/ip_reassembly/main.c | 9 +++++---- examples/l3fwd-power/main.c | 2 +- examples/l3fwd-vf/main.c | 2 +- examples/l3fwd/main.c | 16 ++++++++-------- examples/load_balancer/runtime.c | 3 +-- 6 files changed, 21 insertions(+), 21 deletions(-)
examples/ip_fragmentation/main.c +5 -5
@@ -266,8 +266,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf, uint8_t queueid, uint8_t port_in) {struct rx_queue *rxq; -uint32_t i, len; -uint8_t next_hop, port_out, ipv6; +uint32_t i, len, next_hop; +uint8_t next_hop6, port_out, ipv6;int32_t len2; ipv6 =0 ;
@@ -327,9 +327,9 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf, ip_hdr = rte_pktmbuf_mtod(m, struct ipv6_hdr *);/* Find destination port */ -if (rte_lpm6_lookup (rxq->lpm6, ip_hdr->dst_addr, &next_hop) ==0 && - (enabled_port_mask &1 << next_hop) !=0 ) { - port_out = next_hop; +if (rte_lpm6_lookup (rxq->lpm6, ip_hdr->dst_addr, &next_hop6) ==0 && + (enabled_port_mask &1 << next_hop6) !=0 ) { + port_out = next_hop6;/* Build transmission burst for new port */ len = qconf->tx_mbufs[port_out].len;
examples/ip_reassembly/main.c +5 -4
@@ -347,7 +347,8 @@ reassemble(struct rte_mbuf *m, uint8_t portid, uint32_t queue,struct rte_ip_frag_death_row *dr;struct rx_queue *rxq;void *d_addr_bytes; -uint8_t next_hop, dst_port; +uint8_t dst_port, next_hop6; +uint32_t next_hop; rxq = &qconf->rx_queue_list[queue];
@@ -427,9 +428,9 @@ reassemble(struct rte_mbuf *m, uint8_t portid, uint32_t queue, }/* Find destination port */ -if (rte_lpm6_lookup (rxq->lpm6, ip_hdr->dst_addr, &next_hop) ==0 && - (enabled_port_mask &1 << next_hop) !=0 ) { - dst_port = next_hop; +if (rte_lpm6_lookup (rxq->lpm6, ip_hdr->dst_addr, &next_hop6) ==0 && + (enabled_port_mask &1 << next_hop6) !=0 ) { + dst_port = next_hop6; } eth_hdr->ether_type =rte_be_to_cpu_16 (ETHER_TYPE_IPv6);
examples/l3fwd-power/main.c +1 -1
@@ -631,7 +631,7 @@ static inline uint8_t get_ipv4_dst_port(struct ipv4_hdr *ipv4_hdr, uint8_t portid, lookup_struct_t *ipv4_l3fwd_lookup_struct) { - uint8_t next_hop; + uint32_t next_hop; return (uint8_t) ((rte_lpm_lookup(ipv4_l3fwd_lookup_struct, rte_be_to_cpu_32(ipv4_hdr->dst_addr), &next_hop) == 0)?
examples/l3fwd-vf/main.c +1 -1
@@ -440,7 +440,7 @@ get_dst_port(struct ipv4_hdr *ipv4_hdr, uint8_t portid, lookup_struct_t * l3fwdstatic inline uint8_t get_dst_port (struct ipv4_hdr *ipv4_hdr,uint8_t portid,lookup_struct_t * l3fwd_lookup_struct) { -uint8_t next_hop; +uint32_t next_hop; return (uint8_t) ((rte_lpm_lookup(l3fwd_lookup_struct, rte_be_to_cpu_32(ipv4_hdr->dst_addr), &next_hop) == 0)?
examples/l3fwd/main.c +8 -8
@@ -710,7 +710,7 @@ get_ipv6_dst_port(void *ipv6_hdr, uint8_t portid, lookup_struct_t * ipv6_l3fwd_static inline uint8_t get_ipv4_dst_port (void *ipv4_hdr,uint8_t portid,lookup_struct_t * ipv4_l3fwd_lookup_struct) { -uint8_t next_hop; +uint32_t next_hop; return (uint8_t) ((rte_lpm_lookup(ipv4_l3fwd_lookup_struct, rte_be_to_cpu_32(((struct ipv4_hdr *)ipv4_hdr)->dst_addr),
@@ -1151,7 +1151,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, struct lcore_conf *qcon* to BAD_PORT value. */ static inline __attribute__((always_inline))void -rfc1812_process (struct ipv4_hdr *ipv4_hdr,uint16_t *dp,uint32_t ptype) +rfc1812_process (struct ipv4_hdr *ipv4_hdr,uint32_t *dp,uint32_t ptype) {uint8_t ihl;
@@ -1182,7 +1182,7 @@ static inline __attribute__((always_inline)) uint16_t get_dst_port(const struct lcore_conf *qconf, struct rte_mbuf *pkt, uint32_t dst_ipv4, uint8_t portid) { - uint8_t next_hop; + uint32_t next_hop;struct ipv6_hdr *ipv6_hdr;struct ether_hdr *eth_hdr;
@@ -1194,7 +1194,7 @@ get_dst_port(const struct lcore_conf *qconf, struct rte_mbuf *pkt, eth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *); ipv6_hdr = (struct ipv6_hdr *)(eth_hdr +1 );if (rte_lpm6_lookup (qconf->ipv6_lookup_struct, - ipv6_hdr->dst_addr, &next_hop) !=0 ) + ipv6_hdr->dst_addr, (uint8_t *)&next_hop) !=0 ) next_hop = portid; }else { next_hop = portid;
@@ -1205,7 +1205,7 @@ get_dst_port(const struct lcore_conf *qconf, struct rte_mbuf *pkt,static inline void process_packet (struct lcore_conf *qconf,struct rte_mbuf *pkt, -uint16_t *dst_port,uint8_t portid) +uint32_t *dst_port,uint8_t portid) {struct ether_hdr *eth_hdr;struct ipv4_hdr *ipv4_hdr;
@@ -1275,7 +1275,7 @@ processx4_step2(const struct lcore_conf *qconf,uint32_t ipv4_flag, uint8_t portid, struct rte_mbuf *pkt[FWDSTEP], - uint16_t dprt[FWDSTEP]) + uint32_t dprt[FWDSTEP]) { rte_xmm_t dst; const __m128i bswap_mask = _mm_set_epi8(12, 13, 14, 15, 8, 9, 10, 11,
@@ -1301,7 +1301,7 @@ processx4_step2(const struct lcore_conf *qconf,* Perform RFC1812 checks and updates for IPV4 packets. */ static inline void -processx4_step3 (struct rte_mbuf *pkt[FWDSTEP ],uint16_t dst_port[FWDSTEP ]) +processx4_step3 (struct rte_mbuf *pkt[FWDSTEP ],uint32_t dst_port[FWDSTEP ]) {__m128i te[FWDSTEP ];__m128i ve[FWDSTEP ];
@@ -1527,7 +1527,7 @@ main_loop(__attribute__((unused)) void *dummy)int32_t k;uint16_t dlp;uint16_t *lp; -uint16_t dst_port[MAX_PKT_BURST ]; +uint32_t dst_port[MAX_PKT_BURST ];__m128i dip[MAX_PKT_BURST /FWDSTEP ];uint32_t ipv4_flag[MAX_PKT_BURST /FWDSTEP ];uint16_t pnum[MAX_PKT_BURST +1 ];
examples/load_balancer/runtime.c +1 -2
@@ -524,8 +524,7 @@ app_lcore_worker(for (j =0 ; j < bsz_rd; j ++) {struct rte_mbuf *pkt;struct ipv4_hdr *ipv4_hdr; -uint32_t ipv4_dst, pos; -uint8_t port; +uint32_t ipv4_dst, pos, port;if (likely (j < bsz_rd -1 )) { APP_WORKER_PREFETCH1(rte_pktmbuf_mtod(lp->mbuf_in.array[j+1], unsigned char *));
Signature · 1 line
1.9.1
PATCH 3/3 doc: update release 2.2 after changes in librte_lpm
In reply to Michal JastrzebskiFrom: Michal Kobylinski <[email protected]>
--- doc/guides/rel_notes/release_2_2.rst | 2 ++ 1 file changed, 2 insertions(+)
doc/guides/rel_notes/release_2_2.rst +2 -0
@@ -121,6 +121,8 @@ ABI Changes * librte_cfgfile: Allow longer names and values by increasing the constants CFG_NAME_LEN and CFG_VALUE_LEN to 64 and 256 respectively. + +* librte_lpm: Increase number of next hops for IPv4 to 2^24 Shared Library Versions
Signature · 1 line
1.9.1
Re: [PATCH v1 3/3] doc: update release 2.2 after changes in librte_lpm
Quoted 3 lines · Michal Jastrzebski
From: Michal Kobylinski <[email protected]>
Signed-off-by Michal Kobylinski <[email protected]>
Hi Michal,
for when you do your v2, this doc update should be included in with the relevant changes i.e. in patch 1, not as a separate doc patch.
/Bruce
Quoted 20 lines
--- doc/guides/rel_notes/release_2_2.rst | 2 ++ 1 file changed, 2 insertions(+)doc/guides/rel_notes/release_2_2.rst +2
-0@@ -121,6 +121,8 @@ ABI Changes * librte_cfgfile: Allow longer names and values by increasing the constants CFG_NAME_LEN and CFG_VALUE_LEN to 64 and 256 respectively. + +* librte_lpm: Increase number of next hops for IPv4 to 2^24 Shared Library VersionsSignature · 1 line
1.9.1
Re: [PATCH v1 3/3] doc: update release 2.2 after changes in librte_lpm
Quoted 13 lines
-----Original Message-----
From: Richardson, Bruce
Sent: Friday, October 23, 2015 4:22 PM
To: Jastrzebski, MichalX K
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v1 3/3] doc: update release 2.2 after changes inlibrte_lpmQuoted 3 lines · Michal Jastrzebski
From: Michal Kobylinski <[email protected]>
Signed-off-by Michal Kobylinski <[email protected]>
Quoted 7 lines
Hi Michal,
for when you do your v2, this doc update should be included in with the relevant
changes i.e. in patch 1, not as a separate doc patch./Bruce
Thanks Bruce, we will do that.
The reason it is separated now is that 1st patch is extremely big and difficult to review. I wonder if in v2 we could move changes related with test application to the second patch? This will cause of course that without applying whole patch-set dpdk won't compile.
Quoted 21 lines
Review
Quoted 5 lines
--- doc/guides/rel_notes/release_2_2.rst | 2 ++ 1 file changed, 2 insertions(+)(quoted diff) +0
-0
b/doc/guides/rel_notes/release_2_2.rstQuoted 15 lines
index ab1c25f..3c616ab 100644
doc/guides/rel_notes/release_2_2.rst +2
-1@@ -121,6 +121,8 @@ ABI Changes * librte_cfgfile: Allow longer names and values by increasing the constants CFG_NAME_LEN and CFG_VALUE_LEN to 64 and 256 respectively. + +* librte_lpm: Increase number of next hops for IPv4 to 2^24 Shared Library Versions --1.9.1
Quoted 9 lines · Michal Jastrzebski
From: Michal Kobylinski <[email protected]>
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_tablelibrary 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.
Quoted 8 lines · On Fri, 23 Oct 2015 09:20:33 -0700 Matthew Hall <[email protected]> wrote:
Quoted 7 lines · Michal Jastrzebski
From: Michal Kobylinski <[email protected]>
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.
Quoted 8 lines
Quoted 2 lines
This patchset requires additional change to
rte_tablelibrary 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.
Could you consider rolling in the Brocade/Vyatta changes to LPM structure as well. Would prefer only one ABI change
Quoted 14 lines · Stephen Hemminger
Quoted 11 lines · On Fri, 23 Oct 2015 09:20:33 -0700 Matthew Hall <[email protected]> wrote:
Quoted 9 lines · Michal Jastrzebski
From: Michal Kobylinski <[email protected]>
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_tablelibrary to meet ABI compatibility requirements. A v2 will be sent next week.
Quoted 8 lines
Quoted 5 lines
I also have a patchset for this.
I will send it out as well so we could compare.
Matthew.
Could you consider rolling in the Brocade/Vyatta changes to LPM structure as well. Would prefer only one ABI change
Hi Stephen,
I asked you if you could send me these a while ago but I never heard anything.
That's the only reason I made my own version.
If you have them available also maybe we can consolidate things.
Matthew.
Hi all,
I also have LPM library implementation. Main points:
- First, we don't need two separate structures rte_lpm_tbl8_entry and rte_lpm_tbl24_entry. I think it's better to merge in one rte_lpm_tbl_entry because there is only one difference in name of one bit - valid_group vs ext_entry. Let it's name will be ext_valid.
- Second, I think that 16 bit is more than enough for next-hop index. It's better to use remaining 8 bits for so called forwarding class. It is something like Juniper DCU that can help us to classify traffic based on dst prefix. But after conversation with Bruce Richardson I agree with him that next-hop index and forwarding class can be split from one return value by the application.
- Third, I want to add posibility to lookup AS number (or any other 4 byte) that originate that prefix. It can be defined like:
union rte_lpm_tbl_entry_extend {
#ifdef RTE_LPM_ASNUMuint64_t entry;
#elseuint32_t entry;
#endif
#ifdef RTE_LPM_ASNUM
uint32_t as_num;
#endif
struct{
uint32_t next_hop :24;/**< next hop. */
uint32_t valid :1; /**< Validation flag. */
uint32_t ext_valid :1; /**< External entry. */
uint32_t depth :6; /**< Rule depth. */
};
};- Fourth, extension of next-hop index is done not only for increasing of next-hops but also to increase more specific routes. So I think that should be fixed
+ unsigned tbl8_index = (uint8_t)ip +
+ ((uint8_t)tbl_entry *RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
Regards,
Vladimir
2015-10-23 21:38 GMT+03:00 Matthew Hall <[email protected]>:
Quoted 36 lines · Stephen Hemminger
Quoted 8 lines
Quoted 5 lines · On Fri, 23 Oct 2015 09:20:33 -0700 Matthew Hall <[email protected]> wrote:
Quoted 4 lines · Michal Jastrzebski
From: Michal Kobylinski <[email protected]>
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.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
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_tablelibrary to meet ABI compatibility requirements. A v2 will be sent next week.Quoted 8 lines
Quoted 5 lines
I also have a patchset for this.
I will send it out as well so we could compare.
Matthew.
Could you consider rolling in the Brocade/Vyatta changes to LPM structure as well. Would prefer only one ABI change
Hi Stephen,
I asked you if you could send me these a while ago but I never heard anything.
That's the only reason I made my own version.
If you have them available also maybe we can consolidate things.
Matthew.
From 9efec4571eec4db455a29773b95cf9264c046a03 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <[email protected]>
Date: Fri, 23 Oct 2015 12:55:05 -0700
Subject: [PATCH] lpm: brocade extensions
This is a brute-force merge of the Brocade extension to LPM to current DPDK source tree.
No API/ABI compatibility is expected.
1. Allow arbitrary number of rules
2. Get rid of N^2 search for rule add/delete
3. Add route scope
4. Extend nexthop to 16 bits
5. Extend to allow for more info on delete, (callback and nexthop)
6. Dynamically grow /8 table (requires RCU)
7. Support full /0 and /32 rules
--- lib/librte_lpm/rte_lpm.c | 814 ++++++++++++++++++++++++++--------------------- lib/librte_lpm/rte_lpm.h | 381 +++++++--------------- 2 files changed, 567 insertions(+), 628 deletions(-)
lib/librte_lpm/rte_lpm.c +450 -364
@@ -2,6 +2,7 @@* BSD LICENSE * * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2012-2015 Brocade Communications Systems * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -38,13 +39,15 @@#include <stdio.h> #include <errno.h> #include <sys/queue.h> +#include <bsd/sys/tree.h> #include <rte_log.h> #include <rte_branch_prediction.h> #include <rte_common.h> -#include <rte_memory.h> /* for definition of RTE_CACHE_LINE_SIZE */ +#include <rte_memory.h> /* for definition of RTE_CACHE_LINE_SIZE */ #include <rte_malloc.h> #include <rte_memzone.h> +#include <rte_tailq.h> #include <rte_eal.h> #include <rte_eal_memconfig.h> #include <rte_per_lcore.h>
@@ -52,9 +55,25 @@#include <rte_errno.h> #include <rte_rwlock.h> #include <rte_spinlock.h> +#include <rte_debug.h> #include "rte_lpm.h" +#include <urcu-qsbr.h> + +/** Auto-growth of tbl8 */ +#define RTE_LPM_TBL8_INIT_GROUPS 256/* power of 2 */ +#define RTE_LPM_TBL8_INIT_ENTRIES (RTE_LPM_TBL8_INIT_GROUPS * \ + RTE_LPM_TBL8_GROUP_NUM_ENTRIES) +/** Rule structure. */ +struct rte_lpm_rule { +uint32_t ip;/**< Rule IP address. */ +uint16_t next_hop;/**< Rule next hop. */ +uint8_t scope;/**< Rule scope */ +uint8_t reserved; +RB_ENTRY (rte_lpm_rule) link; +}; +TAILQ_HEAD (rte_lpm_list, rte_tailq_entry);static struct rte_tailq_elem rte_lpm_tailq = {
@@ -71,31 +90,55 @@ enum valid_flag {/* Macro to enable/disable run-time checks. */ #if defined(RTE_LIBRTE_LPM_DEBUG ) -#include <rte_debug.h> -#define VERIFY_DEPTH (depth) do { \ - if ((depth == 0) || (depth > RTE_LPM_MAX_DEPTH)) \ +#define VERIFY_DEPTH (depth) do { \ + if (depth > RTE_LPM_MAX_DEPTH) \ rte_panic("LPM: Invalid depth (%u) at line %d", \ - (unsigned)(depth), __LINE__); \ + (unsigned)(depth), __LINE__); \ } while (0)#else #define VERIFY_DEPTH (depth)#endif +/* Comparison function for red-black tree nodes. +"If the first argument is smaller than the second, the function +returns a value smaller than zero. If they are equal, the function +returns zero. Otherwise, it should return a value greater than zero." +*/ +static inline int rules_cmp (const struct rte_lpm_rule *r1, +const struct rte_lpm_rule *r2) +{ +if (r1->ip < r2->ip) +return -1 ; +else if (r1->ip > r2->ip) +return 1 ; +else +return r1->scope - r2->scope; +} + +/* Satisfy old style attribute in tree.h header */ +#ifndef __unused +#define __unused __attribute__ ((unused)) +#endif + +/* Generate internal functions and make them static. */ +RB_GENERATE_STATIC (rte_lpm_rules_tree, rte_lpm_rule, link, rules_cmp) +/* * Converts a given depth value to its corresponding mask value. * * depth (IN) : range = 1 - 32 -* mask (OUT) : 32bit mask +* mask (OUT) : 32bit mask */static uint32_t __attribute__((pure))depth_to_mask (uint8_t depth) {VERIFY_DEPTH (depth); -/* To calculate a mask start with a 1 on the left hand side and right -* shift while populating the left hand side with 1's -*/ -return (int )0x80000000 >> (depth -1 ); +/* per C std. shift of 32 bits is undefined */ +if (depth ==0 ) +return 0 ; + +return ~0u << (32 - depth); }/*
@@ -113,7 +156,7 @@ depth_to_range(uint8_t depth)return 1 << (MAX_DEPTH_TBL24 - depth);/* Else if depth is greater than 24 */ -return (1 << (RTE_LPM_MAX_DEPTH - depth)); +return 1 << (32 - depth); }/*
@@ -148,31 +191,28 @@ rte_lpm_find_existing(const char *name)* Allocates memory for LPM object */ struct rte_lpm * -rte_lpm_create (const char *name,int socket_id,int max_rules, - __rte_unused int flags) +rte_lpm_create (const char *name,int socket_id) {char mem_name[RTE_LPM_NAMESIZE ];struct rte_lpm *lpm =NULL ;struct rte_tailq_entry *te; -uint32_t mem_size; +unsigned int depth;struct rte_lpm_list *lpm_list; +/* check that we have an initialized tail queue */ lpm_list =RTE_TAILQ_CAST (rte_lpm_tailq.head, rte_lpm_list); -RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl24_entry ) !=2 ); -RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl8_entry ) !=2 ); +RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl24_entry ) !=4 ); +RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl8_entry ) !=4 );/* Check user arguments. */ -if ((name ==NULL ) || (socket_id <-1 ) || (max_rules ==0 )){ +if ((name ==NULL ) || (socket_id <-1 )) { rte_errno =EINVAL ;return NULL ; }snprintf (mem_name,sizeof (mem_name),"LPM_%s" , name); -/* Determine the amount of memory to allocate. */ - mem_size =sizeof (*lpm) + (sizeof (lpm->rules_tbl[0 ]) * max_rules); -rte_rwlock_write_lock (RTE_EAL_TAILQ_RWLOCK );/* guarantee there's no existing */
@@ -192,17 +232,33 @@ rte_lpm_create(const char *name, int socket_id, int max_rules, }/* Allocate memory to store the LPM data structures. */ - lpm = (struct rte_lpm *)rte_zmalloc_socket (mem_name, mem_size, -RTE_CACHE_LINE_SIZE , socket_id); + lpm =rte_zmalloc_socket (mem_name,sizeof (*lpm),RTE_CACHE_LINE_SIZE , + socket_id);if (lpm ==NULL ) {RTE_LOG (ERR ,LPM ,"LPM memory allocation failed\n" ); -rte_free (te); goto exit; }/* Save user arguments. */ - lpm->max_rules = max_rules;snprintf (lpm->name,sizeof (lpm->name),"%s" , name); + lpm->socket_id = socket_id; + +/* Vyatta change to use red-black tree */ +for (depth =0 ; depth <RTE_LPM_MAX_DEPTH ; ++depth) +RB_INIT (&lpm->rules[depth]); + +/* Vyatta change to dynamically grow tbl8 */ + lpm->tbl8_num_groups =RTE_LPM_TBL8_INIT_GROUPS ; + lpm->tbl8_rover =RTE_LPM_TBL8_INIT_GROUPS -1 ; + lpm->tbl8 =rte_calloc_socket (NULL ,RTE_LPM_TBL8_INIT_ENTRIES , +sizeof (struct rte_lpm_tbl8_entry ), +RTE_CACHE_LINE_SIZE , socket_id); +if (lpm->tbl8 ==NULL ) { +RTE_LOG (ERR ,LPM ,"LPM tbl8 group allocation failed\n" ); +rte_free (lpm); + lpm =NULL ; + goto exit; + } te->data = (void *) lpm;
@@ -245,248 +301,237 @@ rte_lpm_free(struct rte_lpm *lpm)rte_rwlock_write_unlock (RTE_EAL_TAILQ_RWLOCK ); +rte_free (lpm->tbl8);rte_free (lpm);rte_free (te); } +/* -* Adds a rule to the rule table. -* -* NOTE: The rule table is split into 32 groups. Each group contains rules that -* apply to a specific prefix depth (i.e. group 1 contains rules that apply to -* prefixes with a depth of 1 etc.). In the following code (depth - 1) is used -* to refer to depth 1 because even though the depth range is 1 - 32, depths -* are stored in the rule table from 0 - 31. -* NOTE: Valid range for depth parameter is 1 .. 32 inclusive. +* Finds a rule in rule table. */ -static inline int32_t -rule_add (struct rte_lpm *lpm,uint32_t ip_masked,uint8_t depth, -uint8_t next_hop) +static struct rte_lpm_rule * +rule_find (struct rte_lpm *lpm,uint32_t ip_masked,uint8_t depth,uint8_t scope) { -uint32_t rule_gindex, rule_index, last_rule; -int i; - -VERIFY_DEPTH (depth); - -/* Scan through rule group to see if rule already exists. */ -if (lpm->rule_info[depth -1 ].used_rules >0 ) { - -/* rule_gindex stands for rule group index. */ - rule_gindex = lpm->rule_info[depth -1 ].first_rule; -/* Initialise rule_index to point to start of rule group. */ - rule_index = rule_gindex; -/* Last rule = Last used rule in this rule group. */ - last_rule = rule_gindex + lpm->rule_info[depth -1 ].used_rules; - -for (; rule_index < last_rule; rule_index++) { +struct rte_lpm_rules_tree *head = &lpm->rules[depth]; +struct rte_lpm_rule k = { + .ip = ip_masked, + .scope = scope, + }; -/* If rule already exists update its next_hop and return. */ -if (lpm->rules_tbl[rule_index].ip == ip_masked) { - lpm->rules_tbl[rule_index].next_hop = next_hop; - -return rule_index; - } - } - -if (rule_index == lpm->max_rules) -return -ENOSPC ; - }else { -/* Calculate the position in which the rule will be stored. */ - rule_index =0 ; +return RB_FIND (rte_lpm_rules_tree, head, &k); +} -for (i = depth -1 ; i >0 ; i--) { -if (lpm->rule_info[i -1 ].used_rules >0 ) { - rule_index = lpm->rule_info[i -1 ].first_rule + lpm->rule_info[i -1 ].used_rules; -break ; - } - } -if (rule_index == lpm->max_rules) -return -ENOSPC ; +/* Finds rule in table in scope order */ +static struct rte_lpm_rule * +rule_find_any (struct rte_lpm *lpm,uint32_t ip_masked,uint8_t depth) +{ +struct rte_lpm_rule *r; +int scope; - lpm->rule_info[depth -1 ].first_rule = rule_index; +for (scope =255 ; scope >=0 ; --scope) { + r =rule_find (lpm, ip_masked, depth, scope); +if (r) +return r; } -/* Make room for the new rule in the array. */ -for (i =RTE_LPM_MAX_DEPTH ; i > depth; i--) { -if (lpm->rule_info[i -1 ].first_rule + lpm->rule_info[i -1 ].used_rules == lpm->max_rules) -return -ENOSPC ; +return NULL ; +} -if (lpm->rule_info[i -1 ].used_rules >0 ) { - lpm->rules_tbl[lpm->rule_info[i -1 ].first_rule + lpm->rule_info[i -1 ].used_rules] - = lpm->rules_tbl[lpm->rule_info[i -1 ].first_rule]; - lpm->rule_info[i -1 ].first_rule++; - } - } +/* +* Adds a rule to the rule table. +* +* NOTE: The rule table is split into 32 groups. Each group contains rules that +* apply to a specific prefix depth (i.e. group 1 contains rules that apply to +* prefixes with a depth of 1 etc.). +* NOTE: Valid range for depth parameter is 0 .. 32 inclusive. +*/ +static struct rte_lpm_rule * +rule_add (struct rte_lpm *lpm,uint32_t ip_masked,uint8_t depth, +uint16_t next_hop,uint8_t scope) +{ +struct rte_lpm_rules_tree *head = &lpm->rules[depth]; +struct rte_lpm_rule *r, *old; -/* Add the new rule. */ - lpm->rules_tbl[rule_index].ip = ip_masked; - lpm->rules_tbl[rule_index].next_hop = next_hop; +/* +* NB: uses regular malloc to avoid chewing up precious +* memory pool space for rules. +*/ + r =malloc (sizeof (*r)); +if (!r) +return NULL ; -/* Increment the used rules counter for this rule group. */ - lpm->rule_info[depth -1 ].used_rules++; + r->ip = ip_masked; + r->next_hop = next_hop; + r->scope = scope; -return rule_index; + old =RB_INSERT (rte_lpm_rules_tree, head, r); +if (!old) +return r; + +/* collision with existing rule */ +free (r); +return old; }/* * Delete a rule from the rule table. * NOTE: Valid range for depth parameter is 1 .. 32 inclusive. */ -static inline void -rule_delete (struct rte_lpm *lpm,int32_t rule_index,uint8_t depth) +static void +rule_delete (struct rte_lpm *lpm,struct rte_lpm_rule *r,uint8_t depth) { -int i; +struct rte_lpm_rules_tree *head = &lpm->rules[depth]; -VERIFY_DEPTH (depth); - - lpm->rules_tbl[rule_index] = lpm->rules_tbl[lpm->rule_info[depth -1 ].first_rule - + lpm->rule_info[depth -1 ].used_rules -1 ]; +RB_REMOVE (rte_lpm_rules_tree, head, r); -for (i = depth; i <RTE_LPM_MAX_DEPTH ; i++) { -if (lpm->rule_info[i].used_rules >0 ) { - lpm->rules_tbl[lpm->rule_info[i].first_rule -1 ] = - lpm->rules_tbl[lpm->rule_info[i].first_rule + lpm->rule_info[i].used_rules -1 ]; - lpm->rule_info[i].first_rule--; - } - } - - lpm->rule_info[depth -1 ].used_rules--; +free (r); }/* -* Finds a rule in rule table. -* NOTE: Valid range for depth parameter is 1 .. 32 inclusive. +* Dynamically increase size of tbl8 */ -static inline int32_t -rule_find (struct rte_lpm *lpm,uint32_t ip_masked,uint8_t depth) +static int +tbl8_grow (struct rte_lpm *lpm) { -uint32_t rule_gindex, last_rule, rule_index; - -VERIFY_DEPTH (depth); +size_t old_size, new_size; +struct rte_lpm_tbl8_entry *new_tbl8; + +/* This should not happen, +* worst case is each /24 can point to one tbl8 */ +if (lpm->tbl8_num_groups >=RTE_LPM_TBL24_NUM_ENTRIES ) +rte_panic ("LPM: tbl8 grow already at %u" , + lpm->tbl8_num_groups); + + old_size = lpm->tbl8_num_groups; + new_size = old_size <<1 ; + new_tbl8 =rte_calloc_socket (NULL , + new_size *RTE_LPM_TBL8_GROUP_NUM_ENTRIES , +sizeof (struct rte_lpm_tbl8_entry ), +RTE_CACHE_LINE_SIZE , + lpm->socket_id); +if (new_tbl8 ==NULL ) { +RTE_LOG (ERR ,LPM ,"LPM tbl8 group expand allocation failed\n" ); +return -ENOMEM ; + } - rule_gindex = lpm->rule_info[depth -1 ].first_rule; - last_rule = rule_gindex + lpm->rule_info[depth -1 ].used_rules; +memcpy (new_tbl8, lpm->tbl8, + old_size *RTE_LPM_TBL8_GROUP_NUM_ENTRIES + *sizeof (struct rte_lpm_tbl8_entry )); -/* Scan used rules at given depth to find rule. */ -for (rule_index = rule_gindex; rule_index < last_rule; rule_index++) { -/* If rule is found return the rule index. */ -if (lpm->rules_tbl[rule_index].ip == ip_masked) -return rule_index; - } +/* swap in new table */ +defer_rcu (rte_free, lpm->tbl8); +rcu_assign_pointer (lpm->tbl8, new_tbl8); + lpm->tbl8_num_groups = new_size; -/* If rule is not found return -EINVAL. */ -return -EINVAL ; +return 0 ; }/* * Find, clean and allocate a tbl8. */ -static inline int32_t -tbl8_alloc (struct rte_lpm_tbl8_entry *tbl8) +static int32_t +tbl8_alloc (struct rte_lpm *lpm) {uint32_t tbl8_gindex;/* tbl8 group index. */ struct rte_lpm_tbl8_entry *tbl8_entry;/* Scan through tbl8 to find a free (i.e. INVALID) tbl8 group. */ -for (tbl8_gindex =0 ; tbl8_gindex <RTE_LPM_TBL8_NUM_GROUPS ; - tbl8_gindex++) { - tbl8_entry = &tbl8[tbl8_gindex * -RTE_LPM_TBL8_GROUP_NUM_ENTRIES ]; +for (tbl8_gindex = (lpm->tbl8_rover +1 ) & (lpm->tbl8_num_groups -1 ); + tbl8_gindex != lpm->tbl8_rover; + tbl8_gindex = (tbl8_gindex +1 ) & (lpm->tbl8_num_groups -1 )) { + tbl8_entry = lpm->tbl8 + + tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES ; +/* If a free tbl8 group is found clean it and set as VALID. */ -if (!tbl8_entry->valid_group) { -memset (&tbl8_entry[0 ],0 , -RTE_LPM_TBL8_GROUP_NUM_ENTRIES * -sizeof (tbl8_entry[0 ])); +if (likely (!tbl8_entry->valid_group)) + goto found; + } - tbl8_entry->valid_group =VALID ; +/* Out of space expand */ + tbl8_gindex = lpm->tbl8_num_groups; +if (tbl8_grow (lpm) <0 ) +return -ENOSPC ; -/* Return group index for allocated tbl8 group. */ -return tbl8_gindex; - } - } + tbl8_entry = lpm->tbl8 + + tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES ; + found: +memset (tbl8_entry,0 , +RTE_LPM_TBL8_GROUP_NUM_ENTRIES *sizeof (tbl8_entry[0 ])); + + tbl8_entry->valid_group =VALID ; -/* If there are no tbl8 groups free then return error. */ -return -ENOSPC ; +/* Remember last slot to start looking there */ + lpm->tbl8_rover = tbl8_gindex; + +/* Return group index for allocated tbl8 group. */ +return tbl8_gindex; }static inline void -tbl8_free (struct rte_lpm_tbl8_entry *tbl8,uint32_t tbl8_group_start) +tbl8_free (struct rte_lpm *lpm,uint32_t tbl8_group_start) {/* Set tbl8 group invalid*/ - tbl8[tbl8_group_start].valid_group =INVALID ; + lpm->tbl8[tbl8_group_start].valid_group =INVALID ; } -static inline int32_t +static void add_depth_small (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t next_hop) +uint16_t next_hop) {uint32_t tbl24_index, tbl24_range, tbl8_index, tbl8_group_end, i, j; +struct rte_lpm_tbl24_entry new_tbl24_entry = { + .valid =VALID , + .ext_entry =0 , + .depth = depth, + { .next_hop = next_hop, } + }; +struct rte_lpm_tbl8_entry new_tbl8_entry = { + .valid_group =VALID , + .valid =VALID , + .depth = depth, + .next_hop = next_hop, + }; + +/* Force compiler to initialize before assignment */ +rte_barrier ();/* Calculate the index into Table24. */ tbl24_index = ip >>8 ; tbl24_range =depth_to_range (depth); -for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++) {/* * For invalid OR valid and non-extended tbl 24 entries set * entry. */ -if (!lpm->tbl24[i].valid || (lpm->tbl24[i].ext_entry ==0 && - lpm->tbl24[i].depth <= depth)) { - -struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .next_hop = next_hop, }, - .valid =VALID , - .ext_entry =0 , - .depth = depth, - }; - -/* Setting tbl24 entry in one go to avoid race -* conditions -*/ - lpm->tbl24[i] = new_tbl24_entry; - +if (!lpm->tbl24[i].valid || lpm->tbl24[i].ext_entry ==0 ) { +if (!lpm->tbl24[i].valid || + lpm->tbl24[i].depth <= depth) + lpm->tbl24[i] = new_tbl24_entry;continue ; } -if (lpm->tbl24[i].ext_entry ==1 ) { -/* If tbl24 entry is valid and extended calculate the -* index into tbl8. -*/ - tbl8_index = lpm->tbl24[i].tbl8_gindex * -RTE_LPM_TBL8_GROUP_NUM_ENTRIES ; - tbl8_group_end = tbl8_index + -RTE_LPM_TBL8_GROUP_NUM_ENTRIES ; - -for (j = tbl8_index; j < tbl8_group_end; j++) { -if (!lpm->tbl8[j].valid || - lpm->tbl8[j].depth <= depth) { -struct rte_lpm_tbl8_entry - new_tbl8_entry = { - .valid =VALID , - .valid_group =VALID , - .depth = depth, - .next_hop = next_hop, - }; - -/* -* Setting tbl8 entry in one go to avoid -* race conditions -*/ - lpm->tbl8[j] = new_tbl8_entry; - -continue ; - } +/* If tbl24 entry is valid and extended calculate the index +* into tbl8. */ + tbl8_index = lpm->tbl24[i].tbl8_gindex + *RTE_LPM_TBL8_GROUP_NUM_ENTRIES ; + tbl8_group_end = tbl8_index +RTE_LPM_TBL8_GROUP_NUM_ENTRIES ; +for (j = tbl8_index; j < tbl8_group_end; j++) { +if (!lpm->tbl8[j].valid || + lpm->tbl8[j].depth <= depth) { +/* +* Setting tbl8 entry in one go to avoid race +* conditions +*/ + lpm->tbl8[j] = new_tbl8_entry; } } } - -return 0 ; } -static inline int32_t +static int32_t add_depth_big (struct rte_lpm *lpm,uint32_t ip_masked,uint8_t depth, -uint8_t next_hop) +uint16_t next_hop) {uint32_t tbl24_index; int32_t tbl8_group_index, tbl8_group_start, tbl8_group_end, tbl8_index,
@@ -497,12 +542,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,if (!lpm->tbl24[tbl24_index].valid) {/* Search for a free tbl8 group. */ - tbl8_group_index =tbl8_alloc (lpm->tbl8); + tbl8_group_index =tbl8_alloc (lpm); -/* Check tbl8 allocation was successful. */ -if (tbl8_group_index <0 ) { +/* Check tbl8 allocation was unsuccessful. */ +if (tbl8_group_index <0 )return tbl8_group_index; - }/* Find index into tbl8 and range. */ tbl8_index = (tbl8_group_index *
@@ -510,35 +554,38 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, (ip_masked &0xFF );/* Set tbl8 entry. */ -for (i = tbl8_index; i < (tbl8_index + tbl8_range); i++) { - lpm->tbl8[i].depth = depth; - lpm->tbl8[i].next_hop = next_hop; - lpm->tbl8[i].valid =VALID ; - } +struct rte_lpm_tbl8_entry new_tbl8_entry = { + .valid_group =VALID , + .valid =VALID , + .depth = depth, + .next_hop = next_hop, + }; + +for (i = tbl8_index; i < (tbl8_index + tbl8_range); i++) + lpm->tbl8[i] = new_tbl8_entry;/* * Update tbl24 entry to point to new tbl8 entry. Note: The * ext_flag and tbl8_index need to be updated simultaneously, * so assign whole structure in one go */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .tbl8_gindex = (uint8_t )tbl8_group_index, }, .valid =VALID , .ext_entry =1 , .depth =0 , + { .tbl8_gindex = tbl8_group_index, } }; +rte_barrier (); lpm->tbl24[tbl24_index] = new_tbl24_entry; - - }/* If valid entry but not extended calculate the index into Table8. */ + } +/* If valid entry but not extended calculate the index into Table8. */ else if (lpm->tbl24[tbl24_index].ext_entry ==0 ) {/* Search for free tbl8 group. */ - tbl8_group_index =tbl8_alloc (lpm->tbl8); + tbl8_group_index =tbl8_alloc (lpm); -if (tbl8_group_index <0 ) { +if (tbl8_group_index <0 )return tbl8_group_index; - } tbl8_group_start = tbl8_group_index *RTE_LPM_TBL8_GROUP_NUM_ENTRIES ;
@@ -546,69 +593,68 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,RTE_LPM_TBL8_GROUP_NUM_ENTRIES ;/* Populate new tbl8 with tbl24 value. */ -for (i = tbl8_group_start; i < tbl8_group_end; i++) { - lpm->tbl8[i].valid =VALID ; - lpm->tbl8[i].depth = lpm->tbl24[tbl24_index].depth; - lpm->tbl8[i].next_hop = - lpm->tbl24[tbl24_index].next_hop; - } +struct rte_lpm_tbl8_entry new_tbl8_entry = { + .valid_group =VALID , + .valid =VALID , + .depth = lpm->tbl24[tbl24_index].depth, + .next_hop = lpm->tbl24[tbl24_index].next_hop, + }; + +for (i = tbl8_group_start; i < tbl8_group_end; i++) + lpm->tbl8[i] = new_tbl8_entry; tbl8_index = tbl8_group_start + (ip_masked &0xFF ); -/* Insert new rule into the tbl8 entry. */ -for (i = tbl8_index; i < tbl8_index + tbl8_range; i++) { -if (!lpm->tbl8[i].valid || - lpm->tbl8[i].depth <= depth) { - lpm->tbl8[i].valid =VALID ; - lpm->tbl8[i].depth = depth; - lpm->tbl8[i].next_hop = next_hop; - -continue ; - } - } +/* Insert new specific rule into the tbl8 entry. */ + new_tbl8_entry.depth = depth; + new_tbl8_entry.next_hop = next_hop; +for (i = tbl8_index; i < tbl8_index + tbl8_range; i++) + lpm->tbl8[i] = new_tbl8_entry;/* * Update tbl24 entry to point to new tbl8 entry. Note: The * ext_flag and tbl8_index need to be updated simultaneously, * so assign whole structure in one go. */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .tbl8_gindex = (uint8_t )tbl8_group_index, }, .valid =VALID , .ext_entry =1 , .depth =0 , + { .tbl8_gindex = tbl8_group_index, } }; +/* +* Ensure compiler isn't doing something completely odd +* like updating tbl24 before tbl8. +*/ +rte_barrier (); lpm->tbl24[tbl24_index] = new_tbl24_entry; - } -else {/* -* If it is valid, extended entry calculate the index into tbl8. -*/ + }else { +/* +* If it is valid, extended entry calculate the index into tbl8. +*/ +struct rte_lpm_tbl8_entry new_tbl8_entry = { + .valid_group =VALID , + .valid =VALID , + .depth = depth, + .next_hop = next_hop, + }; +rte_barrier (); + tbl8_group_index = lpm->tbl24[tbl24_index].tbl8_gindex; tbl8_group_start = tbl8_group_index *RTE_LPM_TBL8_GROUP_NUM_ENTRIES ; tbl8_index = tbl8_group_start + (ip_masked &0xFF );for (i = tbl8_index; i < (tbl8_index + tbl8_range); i++) { -if (!lpm->tbl8[i].valid || - lpm->tbl8[i].depth <= depth) { -struct rte_lpm_tbl8_entry new_tbl8_entry = { - .valid =VALID , - .depth = depth, - .next_hop = next_hop, - .valid_group = lpm->tbl8[i].valid_group, - }; - + lpm->tbl8[i].depth <= depth) {/* * Setting tbl8 entry in one go to avoid race * condition */ lpm->tbl8[i] = new_tbl8_entry; - -continue ; } } }
@@ -621,38 +667,32 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,*/ int rte_lpm_add (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t next_hop) +uint16_t next_hop,uint8_t scope) { -int32_t rule_index, status =0 ; -uint32_t ip_masked; +struct rte_lpm_rule *rule; +uint32_t ip_masked = (ip &depth_to_mask (depth));/* Check user arguments. */ -if ((lpm ==NULL ) || (depth <1 ) || (depth >RTE_LPM_MAX_DEPTH )) +if ((lpm ==NULL ) || (depth >=RTE_LPM_MAX_DEPTH ))return -EINVAL ; - ip_masked = ip &depth_to_mask (depth); -/* Add the rule to the rule table. */ - rule_index =rule_add (lpm, ip_masked, depth, next_hop); + rule =rule_add (lpm, ip_masked, depth, next_hop, scope);/* If the is no space available for new rule return error. */ -if (rule_index <0 ) { -return rule_index; - } - -if (depth <=MAX_DEPTH_TBL24 ) { - status =add_depth_small (lpm, ip_masked, depth, next_hop); - } -else {/* If depth > RTE_LPM_MAX_DEPTH_TBL24 */ - status =add_depth_big (lpm, ip_masked, depth, next_hop); +if (rule ==NULL ) +return -ENOSPC ; +if (depth <=MAX_DEPTH_TBL24 ) +add_depth_small (lpm, ip_masked, depth, next_hop); +else {/* * If add fails due to exhaustion of tbl8 extensions delete * rule that was added to rule table. */ +int status =add_depth_big (lpm, ip_masked, depth, next_hop);if (status <0 ) { -rule_delete (lpm, rule_index, depth); - +rule_delete (lpm, rule, depth);return status; } }
@@ -665,10 +705,10 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,*/ int rte_lpm_is_rule_present (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t *next_hop) +uint16_t *next_hop,uint8_t scope) {uint32_t ip_masked; -int32_t rule_index; +struct rte_lpm_rule *rule;/* Check user arguments. */ if ((lpm == NULL) ||
@@ -678,10 +718,10 @@ uint8_t *next_hop)/* Look for the rule using rule_find. */ ip_masked = ip &depth_to_mask (depth); - rule_index =rule_find (lpm, ip_masked, depth); + rule =rule_find (lpm, ip_masked, depth, scope); -if (rule_index >=0 ) { - *next_hop = lpm->rules_tbl[rule_index].next_hop; +if (rule !=NULL ) { + *next_hop = rule->next_hop;return 1 ; }
@@ -689,30 +729,29 @@ uint8_t *next_hop)return 0 ; } -static inline int32_t -find_previous_rule (struct rte_lpm *lpm,uint32_t ip,uint8_t depth,uint8_t *sub_rule_depth) +static struct rte_lpm_rule * +find_previous_rule (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, +uint8_t *sub_rule_depth) { -int32_t rule_index; +struct rte_lpm_rule *rule;uint32_t ip_masked; -uint8_t prev_depth; +int prev_depth; -for (prev_depth = (uint8_t )(depth -1 ); prev_depth >0 ; prev_depth--) { +for (prev_depth = depth -1 ; prev_depth >=0 ; prev_depth--) { ip_masked = ip &depth_to_mask (prev_depth); - - rule_index =rule_find (lpm, ip_masked, prev_depth); - -if (rule_index >=0 ) { + rule =rule_find_any (lpm, ip_masked, prev_depth); +if (rule) { *sub_rule_depth = prev_depth; -return rule_index; +return rule; } } -return -1 ; +return NULL ; } -static inline int32_t -delete_depth_small (struct rte_lpm *lpm,uint32_t ip_masked, -uint8_t depth,int32_t sub_rule_index,uint8_t sub_rule_depth) +static void +delete_depth_small (struct rte_lpm *lpm,uint32_t ip_masked,uint8_t depth, +struct rte_lpm_rule *sub_rule,uint8_t new_depth) {uint32_t tbl24_range, tbl24_index, tbl8_group_index, tbl8_index, i, j;
@@ -720,28 +759,22 @@ delete_depth_small(struct rte_lpm *lpm, uint32_t ip_masked, tbl24_range =depth_to_range (depth); tbl24_index = (ip_masked >>8 ); -/* -* Firstly check the sub_rule_index. A -1 indicates no replacement rule -* and a positive number indicates a sub_rule_index. -*/ -if (sub_rule_index <0 ) { +/* Firstly check the sub_rule. */ +if (sub_rule ==NULL ) {/* * If no replacement rule exists then invalidate entries * associated with this rule. */ for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++) { - -if (lpm->tbl24[i].ext_entry ==0 && - lpm->tbl24[i].depth <= depth ) { - lpm->tbl24[i].valid =INVALID ; - } -else { +if (lpm->tbl24[i].ext_entry ==0 ) { +if (lpm->tbl24[i].depth <= depth) + lpm->tbl24[i].valid =INVALID ; + }else {/* * If TBL24 entry is extended, then there has * to be a rule with depth >= 25 in the * associated TBL8 group. */ - tbl8_group_index = lpm->tbl24[i].tbl8_gindex; tbl8_index = tbl8_group_index *RTE_LPM_TBL8_GROUP_NUM_ENTRIES ;
@@ -749,60 +782,54 @@ delete_depth_small(struct rte_lpm *lpm, uint32_t ip_masked,for (j = tbl8_index; j < (tbl8_index +RTE_LPM_TBL8_GROUP_NUM_ENTRIES ); j++) { -if (lpm->tbl8[j].depth <= depth) +if (lpm->tbl8[j].valid && + lpm->tbl8[j].depth <= depth) lpm->tbl8[j].valid =INVALID ; } } } - } -else { + }else {/* * If a replacement rule exists then modify entries * associated with this rule. */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - {.next_hop = lpm->rules_tbl[sub_rule_index].next_hop,}, .valid =VALID , .ext_entry =0 , - .depth = sub_rule_depth, + .depth = new_depth, + { .next_hop = sub_rule->next_hop, } };struct rte_lpm_tbl8_entry new_tbl8_entry = { + .valid_group =VALID , .valid =VALID , - .depth = sub_rule_depth, - .next_hop = lpm->rules_tbl - [sub_rule_index].next_hop, + .depth = new_depth, + .next_hop = sub_rule->next_hop, };for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++) { - -if (lpm->tbl24[i].ext_entry ==0 && - lpm->tbl24[i].depth <= depth ) { - lpm->tbl24[i] = new_tbl24_entry; - } -else { +if (lpm->tbl24[i].ext_entry ==0 ) { +if (lpm->tbl24[i].depth <= depth) + lpm->tbl24[i] = new_tbl24_entry; + }else {/* * If TBL24 entry is extended, then there has * to be a rule with depth >= 25 in the * associated TBL8 group. */ - tbl8_group_index = lpm->tbl24[i].tbl8_gindex; tbl8_index = tbl8_group_index *RTE_LPM_TBL8_GROUP_NUM_ENTRIES ;for (j = tbl8_index; j < (tbl8_index +RTE_LPM_TBL8_GROUP_NUM_ENTRIES ); j++) { - -if (lpm->tbl8[j].depth <= depth) +if (!lpm->tbl8[j].valid || + lpm->tbl8[j].depth <= depth) lpm->tbl8[j] = new_tbl8_entry; } } } } - -return 0 ; }/*
@@ -813,8 +840,9 @@ delete_depth_small(struct rte_lpm *lpm, uint32_t ip_masked,* Return of value > -1 means tbl8 is in use but has all the same values and * thus can be recycled */ -static inline int32_t -tbl8_recycle_check (struct rte_lpm_tbl8_entry *tbl8,uint32_t tbl8_group_start) +static int32_t +tbl8_recycle_check (const struct rte_lpm_tbl8_entry *tbl8, +uint32_t tbl8_group_start) {uint32_t tbl8_group_end, i; tbl8_group_end = tbl8_group_start +RTE_LPM_TBL8_GROUP_NUM_ENTRIES ;
@@ -855,13 +883,14 @@ tbl8_recycle_check(struct rte_lpm_tbl8_entry *tbl8, uint32_t tbl8_group_start)if (tbl8[i].valid)return -EEXIST ; } +/* If no valid entries are found then return -EINVAL. */ return -EINVAL ; } -static inline int32_t -delete_depth_big (struct rte_lpm *lpm,uint32_t ip_masked, -uint8_t depth,int32_t sub_rule_index,uint8_t sub_rule_depth) +static void +delete_depth_big (struct rte_lpm *lpm,uint32_t ip_masked,uint8_t depth, +struct rte_lpm_rule *sub_rule,uint8_t new_depth) {uint32_t tbl24_index, tbl8_group_index, tbl8_group_start, tbl8_index, tbl8_range, i;
@@ -879,23 +908,22 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, tbl8_index = tbl8_group_start + (ip_masked &0xFF ); tbl8_range =depth_to_range (depth); -if (sub_rule_index <0 ) { +if (sub_rule ==NULL ) {/* * Loop through the range of entries on tbl8 for which the * rule_to_delete must be removed or modified. */ for (i = tbl8_index; i < (tbl8_index + tbl8_range); i++) { -if (lpm->tbl8[i].depth <= depth) +if (lpm->tbl8[i].valid && lpm->tbl8[i].depth <= depth) lpm->tbl8[i].valid =INVALID ; } - } -else { + }else {/* Set new tbl8 entry. */ struct rte_lpm_tbl8_entry new_tbl8_entry = { + .valid_group =VALID , .valid =VALID , - .depth = sub_rule_depth, - .valid_group = lpm->tbl8[tbl8_group_start].valid_group, - .next_hop = lpm->rules_tbl[sub_rule_index].next_hop, + .depth = new_depth, + .next_hop = sub_rule->next_hop, };/*
@@ -903,7 +931,7 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked,* rule_to_delete must be modified. */ for (i = tbl8_index; i < (tbl8_index + tbl8_range); i++) { -if (lpm->tbl8[i].depth <= depth) +if (!lpm->tbl8[i].valid || lpm->tbl8[i].depth <= depth) lpm->tbl8[i] = new_tbl8_entry; } }
@@ -915,100 +943,158 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked,*/ tbl8_recycle_index =tbl8_recycle_check (lpm->tbl8, tbl8_group_start); - -if (tbl8_recycle_index == -EINVAL ){ +if (tbl8_recycle_index == -EINVAL ) {/* Set tbl24 before freeing tbl8 to avoid race condition. */ lpm->tbl24[tbl24_index].valid =0 ; -tbl8_free (lpm->tbl8, tbl8_group_start); - } -else if (tbl8_recycle_index >-1 ) { +rte_barrier (); +tbl8_free (lpm, tbl8_group_start); + }else if (tbl8_recycle_index >-1 ) {/* Update tbl24 entry. */ struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .next_hop = lpm->tbl8[tbl8_recycle_index].next_hop, }, .valid =VALID , .ext_entry =0 , .depth = lpm->tbl8[tbl8_recycle_index].depth, + { .next_hop = lpm->tbl8[tbl8_recycle_index].next_hop, } };/* Set tbl24 before freeing tbl8 to avoid race condition. */ lpm->tbl24[tbl24_index] = new_tbl24_entry; -tbl8_free (lpm->tbl8, tbl8_group_start); +rte_barrier (); +tbl8_free (lpm, tbl8_group_start); } +} -return 0 ; +/* +* Find rule to replace the just deleted. If there is no rule to +* replace the rule_to_delete we return NULL and invalidate the table +* entries associated with this rule. +*/ +static void rule_replace (struct rte_lpm *lpm,uint32_t ip,uint8_t depth) +{ +uint32_t ip_masked; +struct rte_lpm_rule *sub_rule; +uint8_t sub_depth =0 ; + + ip_masked = ip &depth_to_mask (depth); + sub_rule =find_previous_rule (lpm, ip, depth, &sub_depth); + +/* +* If the input depth value is less than 25 use function +* delete_depth_small otherwise use delete_depth_big. +*/ +if (depth <=MAX_DEPTH_TBL24 ) +delete_depth_small (lpm, ip_masked, depth, sub_rule, sub_depth); +else +delete_depth_big (lpm, ip_masked, depth, sub_rule, sub_depth); }/* * Deletes a rule */ int -rte_lpm_delete (struct rte_lpm *lpm,uint32_t ip,uint8_t depth) +rte_lpm_delete (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, +uint16_t *next_hop,uint8_t scope) { -int32_t rule_to_delete_index, sub_rule_index; +struct rte_lpm_rule *rule;uint32_t ip_masked; -uint8_t sub_rule_depth; +/* * Check input arguments. Note: IP must be a positive integer of 32 * bits in length therefore it need not be checked. */ -if ((lpm ==NULL ) || (depth <1 ) || (depth >RTE_LPM_MAX_DEPTH )) { +if ((lpm ==NULL ) || (depth >=RTE_LPM_MAX_DEPTH ))return -EINVAL ; - } ip_masked = ip &depth_to_mask (depth);/* -* Find the index of the input rule, that needs to be deleted, in the +* Find the input rule, that needs to be deleted, in the * rule table. */ - rule_to_delete_index =rule_find (lpm, ip_masked, depth); + rule =rule_find (lpm, ip_masked, depth, scope);/* * Check if rule_to_delete_index was found. If no rule was found the -* function rule_find returns -EINVAL. +* function rule_find returns -E_RTE_NO_TAILQ. */ -if (rule_to_delete_index <0 ) +if (rule ==NULL )return -EINVAL ; -/* Delete the rule from the rule table. */ -rule_delete (lpm, rule_to_delete_index, depth); -/* -* Find rule to replace the rule_to_delete. If there is no rule to -* replace the rule_to_delete we return -1 and invalidate the table -* entries associated with this rule. +* Return next hop so caller can avoid lookup. */ - sub_rule_depth =0 ; - sub_rule_index =find_previous_rule (lpm, ip, depth, &sub_rule_depth); +if (next_hop) + *next_hop = rule->next_hop; -/* -* If the input depth value is less than 25 use function -* delete_depth_small otherwise use delete_depth_big. -*/ -if (depth <=MAX_DEPTH_TBL24 ) { -return delete_depth_small (lpm, ip_masked, depth, - sub_rule_index, sub_rule_depth); - } -else {/* If depth > MAX_DEPTH_TBL24 */ -return delete_depth_big (lpm, ip_masked, depth, sub_rule_index, sub_rule_depth); - } +/* Delete the rule from the rule table. */ +rule_delete (lpm, rule, depth); + +/* Replace with next level up rule */ +rule_replace (lpm, ip, depth); + +return 0 ; }/* * Delete all rules from the LPM table. */ void -rte_lpm_delete_all (struct rte_lpm *lpm) +rte_lpm_delete_all (struct rte_lpm *lpm,rte_lpm_walk_func_t func,void *arg) { -/* Zero rule information. */ -memset (lpm->rule_info,0 ,sizeof (lpm->rule_info)); +uint8_t depth;/* Zero tbl24. */ memset (lpm->tbl24,0 ,sizeof (lpm->tbl24));/* Zero tbl8. */ -memset (lpm->tbl8,0 ,sizeof (lpm->tbl8)); +memset (lpm->tbl8,0 , + lpm->tbl8_num_groups *RTE_LPM_TBL8_GROUP_NUM_ENTRIES + *sizeof (struct rte_lpm_tbl8_entry )); + lpm->tbl8_rover = lpm->tbl8_num_groups -1 ;/* Delete all rules form the rules table. */ -memset (lpm->rules_tbl,0 ,sizeof (lpm->rules_tbl[0 ]) * lpm->max_rules); +for (depth =0 ; depth <RTE_LPM_MAX_DEPTH ; ++depth) { +struct rte_lpm_rules_tree *head = &lpm->rules[depth]; +struct rte_lpm_rule *r, *n; + + RB_FOREACH_SAFE(r, rte_lpm_rules_tree, head, n) { +if (func) +func (lpm, r->ip, depth, r->scope, + r->next_hop, arg); +rule_delete (lpm, r, depth); + } + } +} + +/* +* Iterate over LPM rules +*/ +void +rte_lpm_walk (struct rte_lpm *lpm,rte_lpm_walk_func_t func,void *arg) +{ +uint8_t depth; + +for (depth =0 ; depth <RTE_LPM_MAX_DEPTH ; depth++) { +struct rte_lpm_rules_tree *head = &lpm->rules[depth]; +struct rte_lpm_rule *r, *n; + + RB_FOREACH_SAFE(r, rte_lpm_rules_tree, head, n) { +func (lpm, r->ip, depth, r->scope, r->next_hop, arg); + } + } +} + +/* Count usage of tbl8 */ +unsigned +rte_lpm_tbl8_count (const struct rte_lpm *lpm) +{ +unsigned i, count =0 ; + +for (i =0 ; i < lpm->tbl8_num_groups; i++) { +const struct rte_lpm_tbl8_entry *tbl8_entry + = lpm->tbl8 + i *RTE_LPM_TBL8_GROUP_NUM_ENTRIES ; +if (tbl8_entry->valid_group) + ++count; + } +return count; }
lib/librte_lpm/rte_lpm.h +117 -264
508 lines not on this page · raw message
Signature · 1 line
2.1.4
Quoted 8 lines · Matthew Hall
Quoted 7 lines · Michal Jastrzebski
From: Michal Kobylinski <[email protected]>
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.
Quoted 8 lines
Quoted 2 lines
This patchset requires additional change to
rte_tablelibrary 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.
Quoted 1 line
From
6a8e3428344ed11af8a1999dcec5c31c10f37c3aMon Sep 17 00:00:00 2001
From: Matthew Hall <[email protected]>
Date: Sat, 27 Jun 2015 22:49:46 +0000
Subject: [PATCH 1/8] rte_lpm.h: use 24 bit extended next hop
--- lib/librte_lpm/rte_lpm.h | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-)
lib/librte_lpm/rte_lpm.h +29 -17
@@ -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 }
Signature · 1 line
1.9.1
Quoted 1 line
From
7ee9f2e9a8853d49a332d971f5b56e79efccd71bMon Sep 17 00:00:00 2001
From: Matthew Hall <[email protected]>
Date: Sat, 27 Jun 2015 22:53:43 +0000
Subject: [PATCH 2/8] rte_lpm.h: disable inlining of rte_lpm lookup functions
--- lib/librte_lpm/rte_lpm.h | 152 ----------------------------------------------- 1 file changed, 152 deletions(-)
lib/librte_lpm/rte_lpm.h +0 -152
170 lines not on this page · raw message
Signature · 1 line
1.9.1
Quoted 1 line
From
e54e01b6edcc820230b7e47de40920a00031b6c1Mon Sep 17 00:00:00 2001
From: Matthew Hall <[email protected]>
Date: Sat, 27 Jun 2015 22:48:07 +0000
Subject: [PATCH 3/8] rte_lpm.c: use 24 bit extended next hop
--- lib/librte_lpm/rte_lpm.c | 184 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 174 insertions(+), 10 deletions(-)
lib/librte_lpm/rte_lpm.c +174 -10
235 lines not on this page · raw message
Signature · 1 line
1.9.1
Quoted 1 line
From
402d1bce8dd05b31fc6e457ca89bcd0b7160aa69Mon Sep 17 00:00:00 2001
From: Matthew Hall <[email protected]>
Date: Sat, 27 Jun 2015 22:54:41 +0000
Subject: [PATCH 4/8] rte_lpm6.{c,h}: use 24 bit extended next hop
--- lib/librte_lpm/rte_lpm6.c | 27 ++++++++++++++------------- lib/librte_lpm/rte_lpm6.h | 8 ++++---- 2 files changed, 18 insertions(+), 17 deletions(-)
lib/librte_lpm/rte_lpm6.c +14 -13
@@ -96,9 +96,9 @@ struct rte_lpm6_tbl_entry {/** Rules tbl entry structure. */ struct rte_lpm6_rule { -uint8_t ip[RTE_LPM6_IPV6_ADDR_SIZE ];/**< Rule IP address. */ -uint8_t next_hop;/**< Rule next hop. */ -uint8_t depth;/**< Rule depth. */ +uint8_t ip[RTE_LPM6_IPV6_ADDR_SIZE ];/**< Rule IP address. */ +uint32_t next_hop :24 ;/**< Rule next hop. */ +uint32_t depth :8 ;/**< Rule depth. */ };/** LPM6 structure. */
@@ -157,7 +157,7 @@ rte_lpm6_create(const char *name, int socket_id, lpm_list =RTE_TAILQ_CAST (rte_lpm6_tailq.head, rte_lpm6_list); -RTE_BUILD_BUG_ON (sizeof (struct rte_lpm6_tbl_entry ) !=sizeof (uint32_t )); +/* RTE_BUILD_BUG_ON(sizeof(struct rte_lpm6_tbl_entry) != sizeof(uint32_t)); */ /* Check user arguments. */ if ((name == NULL) || (socket_id < -1) || (config == NULL) ||
@@ -295,7 +295,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm)* the nexthop if so. Otherwise it adds a new rule if enough space is available. */ static inline int32_t -rule_add (struct rte_lpm6 *lpm,uint8_t *ip,uint8_t next_hop,uint8_t depth) +rule_add (struct rte_lpm6 *lpm,uint8_t *ip,uint32_t next_hop,uint8_t depth) {uint32_t rule_index;
@@ -338,7 +338,7 @@ rule_add(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t next_hop, uint8_t depth)*/ static void expand_rule (struct rte_lpm6 *lpm,uint32_t tbl8_gindex,uint8_t depth, -uint8_t next_hop) +uint32_t next_hop) {uint32_t tbl8_group_end, tbl8_gindex_next, j;
@@ -375,7 +375,7 @@ expand_rule(struct rte_lpm6 *lpm, uint32_t tbl8_gindex, uint8_t depth,static inline int add_step (struct rte_lpm6 *lpm,struct rte_lpm6_tbl_entry *tbl,struct rte_lpm6_tbl_entry **tbl_next,uint8_t *ip,uint8_t bytes, -uint8_t first_byte,uint8_t depth,uint8_t next_hop) +uint8_t first_byte,uint8_t depth,uint32_t next_hop) {uint32_t tbl_index, tbl_range, tbl8_group_start, tbl8_group_end, i;int32_t tbl8_gindex;
@@ -506,7 +506,7 @@ add_step(struct rte_lpm6 *lpm, struct rte_lpm6_tbl_entry *tbl,*/ int rte_lpm6_add (struct rte_lpm6 *lpm,uint8_t *ip,uint8_t depth, -uint8_t next_hop) +uint32_t next_hop) {struct rte_lpm6_tbl_entry *tbl;struct rte_lpm6_tbl_entry *tbl_next;
@@ -567,7 +567,7 @@ rte_lpm6_add(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,static inline int lookup_step (const struct rte_lpm6 *lpm,const struct rte_lpm6_tbl_entry *tbl,const struct rte_lpm6_tbl_entry **tbl_next,uint8_t *ip, -uint8_t first_byte,uint8_t *next_hop) +uint8_t first_byte,uint32_t *next_hop) {uint32_t tbl8_index, tbl_entry;
@@ -596,7 +596,7 @@ lookup_step(const struct rte_lpm6 *lpm, const struct rte_lpm6_tbl_entry *tbl,* Looks up an IP */ int -rte_lpm6_lookup (const struct rte_lpm6 *lpm,uint8_t *ip,uint8_t *next_hop) +rte_lpm6_lookup (const struct rte_lpm6 *lpm,uint8_t *ip,uint32_t *next_hop) {const struct rte_lpm6_tbl_entry *tbl;const struct rte_lpm6_tbl_entry *tbl_next;
@@ -630,13 +630,14 @@ rte_lpm6_lookup(const struct rte_lpm6 *lpm, uint8_t *ip, uint8_t *next_hop)int rte_lpm6_lookup_bulk_func (const struct rte_lpm6 *lpm,uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE ], -int16_t * next_hops,unsigned n) +uint32_t * next_hops,unsigned n) {unsigned i;const struct rte_lpm6_tbl_entry *tbl;const struct rte_lpm6_tbl_entry *tbl_next;uint32_t tbl24_index; -uint8_t first_byte, next_hop; +uint8_t first_byte; +uint32_t next_hop;int status;/* DEBUG: Check user input arguments. */
@@ -697,7 +698,7 @@ rule_find(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth)*/ int rte_lpm6_is_rule_present (struct rte_lpm6 *lpm,uint8_t *ip,uint8_t depth, -uint8_t *next_hop) +uint32_t *next_hop) {uint8_t ip_masked[RTE_LPM6_IPV6_ADDR_SIZE ];int32_t rule_index;
lib/librte_lpm/rte_lpm6.h +4 -4
@@ -121,7 +121,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm);*/ int rte_lpm6_add (struct rte_lpm6 *lpm,uint8_t *ip,uint8_t depth, -uint8_t next_hop); +uint32_t next_hop);/** * Check if a rule is present in the LPM table,
@@ -140,7 +140,7 @@ rte_lpm6_add(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,*/ int rte_lpm6_is_rule_present (struct rte_lpm6 *lpm,uint8_t *ip,uint8_t depth, -uint8_t *next_hop); +uint32_t *next_hop);/** * Delete a rule from the LPM table.
@@ -197,7 +197,7 @@ rte_lpm6_delete_all(struct rte_lpm6 *lpm);* -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit */ int -rte_lpm6_lookup (const struct rte_lpm6 *lpm,uint8_t *ip,uint8_t *next_hop); +rte_lpm6_lookup (const struct rte_lpm6 *lpm,uint8_t *ip,uint32_t *next_hop);/** * Lookup multiple IP addresses in an LPM table.
@@ -218,7 +218,7 @@ rte_lpm6_lookup(const struct rte_lpm6 *lpm, uint8_t *ip, uint8_t *next_hop);int rte_lpm6_lookup_bulk_func (const struct rte_lpm6 *lpm,uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE ], -int16_t * next_hops,unsigned n); +uint32_t * next_hops,unsigned n); #ifdef __cplusplus }
Signature · 1 line
1.9.1
Quoted 1 line
From
e3ebfc026f7871d3014a0b9f8881579623b6592bMon Sep 17 00:00:00 2001
From: Matthew Hall <[email protected]>
Date: Sat, 27 Jun 2015 22:55:20 +0000
Subject: [PATCH 5/8] librte_table: use uint32_t for next hops from librte_lpm
--- lib/librte_table/rte_table_lpm.c | 6 +++--- lib/librte_table/rte_table_lpm_ipv6.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
lib/librte_table/rte_table_lpm.c +3 -3
@@ -202,7 +202,7 @@ rte_table_lpm_entry_add(struct rte_table_lpm_key *ip_prefix = (struct rte_table_lpm_key *) key;uint32_t nht_pos, nht_pos0_valid;int status; -uint8_t nht_pos0 =0 ; +uint32_t nht_pos0 =0 ;/* Check input parameters */ if (lpm ==NULL ) {
@@ -268,7 +268,7 @@ rte_table_lpm_entry_delete( {struct rte_table_lpm *lpm = (struct rte_table_lpm *) table;struct rte_table_lpm_key *ip_prefix = (struct rte_table_lpm_key *) key; -uint8_t nht_pos; +uint32_t nht_pos;int status;/* Check input parameters */
@@ -342,7 +342,7 @@ rte_table_lpm_lookup(uint32_t ip =rte_bswap32 (RTE_MBUF_METADATA_UINT32 (pkt, lpm->offset));int status; -uint8_t nht_pos; +uint32_t nht_pos; status =rte_lpm_lookup (lpm->lpm, ip, &nht_pos);if (status ==0 ) {
lib/librte_table/rte_table_lpm_ipv6.c +3 -3
@@ -213,7 +213,7 @@ rte_table_lpm_ipv6_entry_add( (struct rte_table_lpm_ipv6_key *) key;uint32_t nht_pos, nht_pos0_valid;int status; -uint8_t nht_pos0; +uint32_t nht_pos0;/* Check input parameters */ if (lpm ==NULL ) {
@@ -280,7 +280,7 @@ rte_table_lpm_ipv6_entry_delete(struct rte_table_lpm_ipv6 *lpm = (struct rte_table_lpm_ipv6 *) table;struct rte_table_lpm_ipv6_key *ip_prefix = (struct rte_table_lpm_ipv6_key *) key; -uint8_t nht_pos; +uint32_t nht_pos;int status;/* Check input parameters */
@@ -356,7 +356,7 @@ rte_table_lpm_ipv6_lookup(uint8_t *ip =RTE_MBUF_METADATA_UINT8_PTR (pkt, lpm->offset);int status; -uint8_t nht_pos; +uint32_t nht_pos; status =rte_lpm6_lookup (lpm->lpm, ip, &nht_pos);if (status ==0 ) {
Signature · 1 line
1.9.1
Quoted 1 line
From
e975f935595c6e901522dbaf10be598573276eaaMon Sep 17 00:00:00 2001
From: Matthew Hall <[email protected]>
Date: Sat, 27 Jun 2015 22:34:18 +0000
Subject: [PATCH 6/8] test_lpm*.c: update tests to use 24 bit extended next hop
--- app/test/test_lpm.c | 54 +++++++++++++++----------- app/test/test_lpm6.c | 108 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 95 insertions(+), 67 deletions(-)
app/test/test_lpm.c +32 -22
170 lines not on this page · raw message
app/test/test_lpm6.c +63 -45
300 lines not on this page · raw message
Signature · 1 line
1.9.1
Quoted 1 line
From
cfaf9c28dbff3bec0c867aa4270b01b04bf50276Mon Sep 17 00:00:00 2001
From: Matthew Hall <[email protected]>
Date: Sat, 27 Jun 2015 22:42:42 +0000
Subject: [PATCH 7/8] examples: update examples to use 24 bit extended next hop
--- examples/ip_reassembly/main.c | 3 ++- examples/l3fwd-power/main.c | 2 +- examples/l3fwd-vf/main.c | 2 +- examples/l3fwd/main.c | 16 ++++++++-------- examples/load_balancer/runtime.c | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-)
examples/ip_reassembly/main.c +2 -1
@@ -347,7 +347,8 @@ reassemble(struct rte_mbuf *m, uint8_t portid, uint32_t queue,struct rte_ip_frag_death_row *dr;struct rx_queue *rxq;void *d_addr_bytes; -uint8_t next_hop, dst_port; +uint32_t next_hop; +uint8_t dst_port; rxq = &qconf->rx_queue_list[queue];
examples/l3fwd-power/main.c +1 -1
@@ -631,7 +631,7 @@ static inline uint8_t get_ipv4_dst_port(struct ipv4_hdr *ipv4_hdr, uint8_t portid, lookup_struct_t *ipv4_l3fwd_lookup_struct) { - uint8_t next_hop; + uint32_t next_hop; return (uint8_t) ((rte_lpm_lookup(ipv4_l3fwd_lookup_struct, rte_be_to_cpu_32(ipv4_hdr->dst_addr), &next_hop) == 0)?
examples/l3fwd-vf/main.c +1 -1
@@ -440,7 +440,7 @@ get_dst_port(struct ipv4_hdr *ipv4_hdr, uint8_t portid, lookup_struct_t * l3fwdstatic inline uint8_t get_dst_port (struct ipv4_hdr *ipv4_hdr,uint8_t portid,lookup_struct_t * l3fwd_lookup_struct) { -uint8_t next_hop; +uint32_t next_hop; return (uint8_t) ((rte_lpm_lookup(l3fwd_lookup_struct, rte_be_to_cpu_32(ipv4_hdr->dst_addr), &next_hop) == 0)?
examples/l3fwd/main.c +8 -8
@@ -710,7 +710,7 @@ get_ipv6_dst_port(void *ipv6_hdr, uint8_t portid, lookup_struct_t * ipv6_l3fwd_static inline uint8_t get_ipv4_dst_port (void *ipv4_hdr,uint8_t portid,lookup_struct_t * ipv4_l3fwd_lookup_struct) { -uint8_t next_hop; +uint32_t next_hop; return (uint8_t) ((rte_lpm_lookup(ipv4_l3fwd_lookup_struct, rte_be_to_cpu_32(((struct ipv4_hdr *)ipv4_hdr)->dst_addr),
@@ -720,7 +720,7 @@ get_ipv4_dst_port(void *ipv4_hdr, uint8_t portid, lookup_struct_t * ipv4_l3fwd_static inline uint8_t get_ipv6_dst_port (void *ipv6_hdr,uint8_t portid,lookup6_struct_t * ipv6_l3fwd_lookup_struct) { -uint8_t next_hop; +uint32_t next_hop;return (uint8_t ) ((rte_lpm6_lookup (ipv6_l3fwd_lookup_struct, ((struct ipv6_hdr *)ipv6_hdr)->dst_addr, &next_hop) ==0 )? next_hop : portid);
@@ -1151,7 +1151,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, struct lcore_conf *qcon* to BAD_PORT value. */ static inline __attribute__((always_inline))void -rfc1812_process (struct ipv4_hdr *ipv4_hdr,uint16_t *dp,uint32_t ptype) +rfc1812_process (struct ipv4_hdr *ipv4_hdr,uint32_t *dp,uint32_t ptype) {uint8_t ihl;
@@ -1182,7 +1182,7 @@ static inline __attribute__((always_inline)) uint16_t get_dst_port(const struct lcore_conf *qconf, struct rte_mbuf *pkt, uint32_t dst_ipv4, uint8_t portid) { - uint8_t next_hop; + uint32_t next_hop;struct ipv6_hdr *ipv6_hdr;struct ether_hdr *eth_hdr;
@@ -1205,7 +1205,7 @@ get_dst_port(const struct lcore_conf *qconf, struct rte_mbuf *pkt,static inline void process_packet (struct lcore_conf *qconf,struct rte_mbuf *pkt, -uint16_t *dst_port,uint8_t portid) +uint32_t *dst_port,uint8_t portid) {struct ether_hdr *eth_hdr;struct ipv4_hdr *ipv4_hdr;
@@ -1275,7 +1275,7 @@ processx4_step2(const struct lcore_conf *qconf,uint32_t ipv4_flag, uint8_t portid, struct rte_mbuf *pkt[FWDSTEP], - uint16_t dprt[FWDSTEP]) + uint32_t dprt[FWDSTEP]) { rte_xmm_t dst; const __m128i bswap_mask = _mm_set_epi8(12, 13, 14, 15, 8, 9, 10, 11,
@@ -1301,7 +1301,7 @@ processx4_step2(const struct lcore_conf *qconf,* Perform RFC1812 checks and updates for IPV4 packets. */ static inline void -processx4_step3 (struct rte_mbuf *pkt[FWDSTEP ],uint16_t dst_port[FWDSTEP ]) +processx4_step3 (struct rte_mbuf *pkt[FWDSTEP ],uint32_t dst_port[FWDSTEP ]) {__m128i te[FWDSTEP ];__m128i ve[FWDSTEP ];
@@ -1527,7 +1527,7 @@ main_loop(__attribute__((unused)) void *dummy)int32_t k;uint16_t dlp;uint16_t *lp; -uint16_t dst_port[MAX_PKT_BURST ]; +uint32_t dst_port[MAX_PKT_BURST ];__m128i dip[MAX_PKT_BURST /FWDSTEP ];uint32_t ipv4_flag[MAX_PKT_BURST /FWDSTEP ];uint16_t pnum[MAX_PKT_BURST +1 ];
examples/load_balancer/runtime.c +1 -1
@@ -525,7 +525,7 @@ app_lcore_worker(struct rte_mbuf *pkt;struct ipv4_hdr *ipv4_hdr;uint32_t ipv4_dst, pos; -uint8_t port; +uint32_t port;if (likely (j < bsz_rd -1 )) { APP_WORKER_PREFETCH1(rte_pktmbuf_mtod(lp->mbuf_in.array[j+1], unsigned char *));
Signature · 1 line
1.9.1
Quoted 1 line
From
2ded34ca11f61ed8a3bcfda6d13339e04b0430bfMon Sep 17 00:00:00 2001
From: Matthew Hall <[email protected]>
Date: Sun, 28 Jun 2015 22:52:45 +0000
Subject: [PATCH 8/8] Makefile: add -fno-strict-aliasing due to LPM casting
logic
--- lib/librte_lpm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_lpm/Makefile +1 -1
@@ -35,7 +35,7 @@ include $(RTE_SDK)/mk/rte.vars.mk LIB = librte_lpm.a CFLAGS += -O3 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) +CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -fno-strict-aliasing EXPORT_MAP := rte_lpm_version.map
Signature · 1 line
1.9.1
Hi all,
Here my implementation
--- config/common_bsdapp | 1 + config/common_linuxapp | 1 + lib/librte_lpm/rte_lpm.c | 194 +++++++++++++++++++++++++++++------------------ lib/librte_lpm/rte_lpm.h | 163 +++++++++++++++++++++++---------------- 4 files changed, 219 insertions(+), 140 deletions(-)
config/common_bsdapp +1 -0
@@ -344,6 +344,7 @@ CONFIG_RTE_LIBRTE_JOBSTATS=y # CONFIG_RTE_LIBRTE_LPM=y CONFIG_RTE_LIBRTE_LPM_DEBUG=n +CONFIG_RTE_LIBRTE_LPM_ASNUM=n # # Compile librte_acl
config/common_linuxapp +1 -0
@@ -352,6 +352,7 @@ CONFIG_RTE_LIBRTE_JOBSTATS=y # CONFIG_RTE_LIBRTE_LPM=y CONFIG_RTE_LIBRTE_LPM_DEBUG=n +CONFIG_RTE_LIBRTE_LPM_ASNUM=n # # Compile librte_acl
lib/librte_lpm/rte_lpm.c +0 -0
@@ -159,9 +159,11 @@ rte_lpm_create(const char *name, int socket_id, int
max_rules,
lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
- RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl24_entry) != 2);
- RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl8_entry) != 2);
-
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl_entry) != 8);
+#else
+ RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl_entry) != 4);
+#endif
/* Check user arguments. */
if ((name == NULL) || (socket_id < -1) || (max_rules == 0)){
rte_errno = EINVAL;@@ -261,7 +263,7 @@ rte_lpm_free(struct rte_lpm *lpm)
*/
static inline int32_t
rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,
- uint8_t next_hop)
+ struct rte_lpm_res *res)
{
uint32_t rule_gindex, rule_index, last_rule;
int i;@@ -282,8 +284,11 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,
/* If rule already exists update its next_hop and
return. */
if (lpm->rules_tbl[rule_index].ip == ip_masked) {- lpm->rules_tbl[rule_index].next_hop =next_hop;
-
+ lpm->rules_tbl[rule_index].next_hop =res->next_hop;
+ lpm->rules_tbl[rule_index].fwd_class =res->fwd_class;
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ lpm->rules_tbl[rule_index].as_num =res->as_num;
+#endif
return rule_index;
}
}@@ -320,7 +325,11 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,
/* Add the new rule. */
lpm->rules_tbl[rule_index].ip = ip_masked;
- lpm->rules_tbl[rule_index].next_hop = next_hop;
+ lpm->rules_tbl[rule_index].next_hop = res->next_hop;
+ lpm->rules_tbl[rule_index].fwd_class = res->fwd_class;+#ifdef RTE_LIBRTE_LPM_ASNUM
+ lpm->rules_tbl[rule_index].as_num = res->as_num;
+#endif
/* Increment the used rules counter for this rule group. */
lpm->rule_info[depth - 1].used_rules++;@@ -382,10 +391,10 @@ rule_find(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth)
* Find, clean and allocate a tbl8.
*/
static inline int32_t
-tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) +tbl8_alloc(struct rte_lpm_tbl_entry *tbl8)
{
uint32_t tbl8_gindex; /* tbl8 group index. */- struct rte_lpm_tbl8_entry *tbl8_entry;
+ struct rte_lpm_tbl_entry *tbl8_entry;
/* Scan through tbl8 to find a free (i.e. INVALID) tbl8 group. */
for (tbl8_gindex = 0; tbl8_gindex < RTE_LPM_TBL8_NUM_GROUPS;
@@ -393,12 +402,12 @@ tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8)
tbl8_entry = &tbl8[tbl8_gindex *
RTE_LPM_TBL8_GROUP_NUM_ENTRIES];
/* If a free tbl8 group is found clean it and set as VALID.
*/
- if (!tbl8_entry->valid_group) {
+ if (!tbl8_entry->ext_valid) {
memset(&tbl8_entry[0], 0,
RTE_LPM_TBL8_GROUP_NUM_ENTRIES *
sizeof(tbl8_entry[0]));- tbl8_entry->valid_group = VALID;
+ tbl8_entry->ext_valid = VALID;
/* Return group index for allocated tbl8 group. */
return tbl8_gindex;@@ -410,46 +419,50 @@ tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8)
}
static inline void
-tbl8_free(struct rte_lpm_tbl8_entry *tbl8, uint32_t tbl8_group_start) +tbl8_free(struct rte_lpm_tbl_entry *tbl8, uint32_t tbl8_group_start)
{
/* Set tbl8 group invalid*/- tbl8[tbl8_group_start].valid_group = INVALID;
+ tbl8[tbl8_group_start].ext_valid = INVALID;
}
static inline int32_t
add_depth_small(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,
- uint8_t next_hop)
+ struct rte_lpm_res *res)
{
uint32_t tbl24_index, tbl24_range, tbl8_index, tbl8_group_end, i, j;
/* Calculate the index into Table24. */
tbl24_index = ip >> 8;
tbl24_range = depth_to_range(depth);+ struct rte_lpm_tbl_entry new_tbl_entry = {
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ .as_num = res->as_num,
+#endif
+ .next_hop = res->next_hop, + .fwd_class = res->fwd_class, + .ext_valid = 0, + .depth = depth, + .valid = VALID,
+ };
+
for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++) {
/*
* For invalid OR valid and non-extended tbl 24 entries set
* entry.
*/
- if (!lpm->tbl24[i].valid || (lpm->tbl24[i].ext_entry == 0 &&
+ if (!lpm->tbl24[i].valid || (lpm->tbl24[i].ext_valid == 0 &&
lpm->tbl24[i].depth <= depth)) {- struct rte_lpm_tbl24_entry new_tbl24_entry = {
- { .next_hop = next_hop, },
- .valid = VALID,
- .ext_entry = 0,
- .depth = depth,
- };
-
/* Setting tbl24 entry in one go to avoid race
* conditions
*/- lpm->tbl24[i] = new_tbl24_entry;
+ lpm->tbl24[i] = new_tbl_entry;
continue;
}- if (lpm->tbl24[i].ext_entry == 1) {
+ if (lpm->tbl24[i].ext_valid == 1) {
/* If tbl24 entry is valid and extended calculatethe
* index into tbl8.
*/
@@ -461,19 +474,14 @@ add_depth_small(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,
for (j = tbl8_index; j < tbl8_group_end; j++) {
if (!lpm->tbl8[j].valid ||
lpm->tbl8[j].depth <=
depth) {
- struct rte_lpm_tbl8_entry
- new_tbl8_entry = {
- .valid = VALID,
- .valid_group = VALID,
- .depth = depth,
- .next_hop = next_hop,- };
+
+ new_tbl_entry.ext_valid = VALID;
/*
* Setting tbl8 entry in one go to
avoid
* race conditions
*/
- lpm->tbl8[j] = new_tbl8_entry;
+ lpm->tbl8[j] = new_tbl_entry;
continue;
}@@ -486,7 +494,7 @@ add_depth_small(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,
static inline int32_t
add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,
- uint8_t next_hop)
+ struct rte_lpm_res *res)
{
uint32_t tbl24_index;
int32_t tbl8_group_index, tbl8_group_start, tbl8_group_end,
tbl8_index,
@@ -512,7 +520,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked,
uint8_t depth,
/* Set tbl8 entry. */
for (i = tbl8_index; i < (tbl8_index + tbl8_range); i++) {
lpm->tbl8[i].depth = depth;
- lpm->tbl8[i].next_hop = next_hop;
+ lpm->tbl8[i].next_hop = res->next_hop;
+ lpm->tbl8[i].fwd_class = res->fwd_class;
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ lpm->tbl8[i].as_num = res->as_num;
+#endif
lpm->tbl8[i].valid = VALID;
}@@ -522,17 +534,17 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,
* so assign whole structure in one go */
- struct rte_lpm_tbl24_entry new_tbl24_entry = {
- { .tbl8_gindex = (uint8_t)tbl8_group_index, },
- .valid = VALID,
- .ext_entry = 1,
+ struct rte_lpm_tbl_entry new_tbl24_entry = {
+ .tbl8_gindex = (uint16_t)tbl8_group_index,
.depth = 0,
+ .ext_valid = 1,
+ .valid = VALID,
};
lpm->tbl24[tbl24_index] = new_tbl24_entry;
}/* If valid entry but not extended calculate the index into
Table8. */
- else if (lpm->tbl24[tbl24_index].ext_entry == 0) {
+ else if (lpm->tbl24[tbl24_index].ext_valid == 0) {
/* Search for free tbl8 group. */
tbl8_group_index = tbl8_alloc(lpm->tbl8);@@ -551,6 +563,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,
lpm->tbl8[i].depth = lpm->tbl24[tbl24_index].depth;
lpm->tbl8[i].next_hop =
lpm->tbl24[tbl24_index].next_hop;+ lpm->tbl8[i].fwd_class =
+ lpm->tbl24[tbl24_index].fwd_class;
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ lpm->tbl8[i].as_num =
lpm->tbl24[tbl24_index].as_num;
+#endif
}
tbl8_index = tbl8_group_start + (ip_masked & 0xFF);
@@ -561,7 +578,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked,
uint8_t depth,
lpm->tbl8[i].depth <= depth) {
lpm->tbl8[i].valid = VALID;
lpm->tbl8[i].depth = depth;
- lpm->tbl8[i].next_hop = next_hop;
+ lpm->tbl8[i].next_hop = res->next_hop;
+ lpm->tbl8[i].fwd_class = res->fwd_class;+#ifdef RTE_LIBRTE_LPM_ASNUM
+ lpm->tbl8[i].as_num = res->as_num;
+#endif
continue;
}@@ -573,11 +594,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,
* so assign whole structure in one go. */
- struct rte_lpm_tbl24_entry new_tbl24_entry = {
- { .tbl8_gindex = (uint8_t)tbl8_group_index,
},
- .valid = VALID,
- .ext_entry = 1,
+ struct rte_lpm_tbl_entry new_tbl24_entry = {
+ .tbl8_gindex = (uint16_t)tbl8_group_index,
.depth = 0,
+ .ext_valid = 1,
+ .valid = VALID,
};
lpm->tbl24[tbl24_index] = new_tbl24_entry;@@ -595,11 +616,15 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,
if (!lpm->tbl8[i].valid ||
lpm->tbl8[i].depth <= depth) {- struct rte_lpm_tbl8_entry new_tbl8_entry = {
- .valid = VALID,
+ struct rte_lpm_tbl_entry new_tbl8_entry = {
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ .as_num = res->as_num,
+#endif
+ .next_hop = res->next_hop,
+ .fwd_class = res->fwd_class,
.depth = depth,
- .next_hop = next_hop,
- .valid_group =
lpm->tbl8[i].valid_group,
+ .ext_valid = lpm->tbl8[i].ext_valid,
+ .valid = VALID,
};
/*@@ -621,19 +646,19 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,
*/
int
rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,
- uint8_t next_hop)
+ struct rte_lpm_res *res)
{
int32_t rule_index, status = 0;
uint32_t ip_masked;
/* Check user arguments. */
- if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM_MAX_DEPTH))
+ if ((lpm == NULL) || (res == NULL) || (depth < 1) || (depth >
RTE_LPM_MAX_DEPTH))
return -EINVAL;
ip_masked = ip & depth_to_mask(depth);
/* Add the rule to the rule table. */- rule_index = rule_add(lpm, ip_masked, depth, next_hop);
+ rule_index = rule_add(lpm, ip_masked, depth, res);
/* If the is no space available for new rule return error. */
if (rule_index < 0) {
@@ -641,10 +666,10 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t
depth,
}
if (depth <= MAX_DEPTH_TBL24) {
- status = add_depth_small(lpm, ip_masked, depth, next_hop);
+ status = add_depth_small(lpm, ip_masked, depth, res);
}
else { /* If depth > RTE_LPM_MAX_DEPTH_TBL24 */- status = add_depth_big(lpm, ip_masked, depth, next_hop);
+ status = add_depth_big(lpm, ip_masked, depth, res);
/*
* If add fails due to exhaustion of tbl8 extensions delete
@@ -665,14 +690,14 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,
*/
int
rte_lpm_is_rule_present(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,
-uint8_t *next_hop)
+ struct rte_lpm_res *res)
{
uint32_t ip_masked;
int32_t rule_index;
/* Check user arguments. */
if ((lpm == NULL) ||
- (next_hop == NULL) ||
+ (res == NULL) ||
(depth < 1) || (depth > RTE_LPM_MAX_DEPTH))
return -EINVAL;@@ -681,7 +706,11 @@ uint8_t *next_hop)
rule_index = rule_find(lpm, ip_masked, depth);
if (rule_index >= 0) {
- *next_hop = lpm->rules_tbl[rule_index].next_hop;
+ res->next_hop = lpm->rules_tbl[rule_index].next_hop;
+ res->fwd_class = lpm->rules_tbl[rule_index].fwd_class;
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ res->as_num = lpm->rules_tbl[rule_index].as_num;
+#endif
return 1;
}@@ -731,7 +760,7 @@ delete_depth_small(struct rte_lpm *lpm, uint32_t ip_masked,
*/
for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++){
- if (lpm->tbl24[i].ext_entry == 0 &&
+ if (lpm->tbl24[i].ext_valid == 0 &&
lpm->tbl24[i].depth <= depth ) {
lpm->tbl24[i].valid = INVALID;
}@@ -761,23 +790,30 @@ delete_depth_small(struct rte_lpm *lpm, uint32_t ip_masked,
* associated with this rule.
*/
- struct rte_lpm_tbl24_entry new_tbl24_entry = {
- {.next_hop =
lpm->rules_tbl[sub_rule_index].next_hop,},
- .valid = VALID,
- .ext_entry = 0,
+ struct rte_lpm_tbl_entry new_tbl24_entry = {
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ .as_num = lpm->rules_tbl[sub_rule_index].as_num,
+#endif
+ .next_hop = lpm->rules_tbl[sub_rule_index].next_hop,
+ .fwd_class =
lpm->rules_tbl[sub_rule_index].fwd_class,
.depth = sub_rule_depth,
+ .ext_valid = 0,
+ .valid = VALID,
};
- struct rte_lpm_tbl8_entry new_tbl8_entry = {
- .valid = VALID,
+ struct rte_lpm_tbl_entry new_tbl8_entry = {
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ .as_num = lpm->rules_tbl[sub_rule_index].as_num,
+#endif
+ .next_hop = lpm->rules_tbl[sub_rule_index].next_hop,
+ .fwd_class =
lpm->rules_tbl[sub_rule_index].fwd_class,
.depth = sub_rule_depth,
- .next_hop = lpm->rules_tbl
- [sub_rule_index].next_hop,
+ .valid = VALID,
};
for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++){
- if (lpm->tbl24[i].ext_entry == 0 &&
+ if (lpm->tbl24[i].ext_valid == 0 &&
lpm->tbl24[i].depth <= depth ) {
lpm->tbl24[i] = new_tbl24_entry;
}@@ -814,7 +850,7 @@ delete_depth_small(struct rte_lpm *lpm, uint32_t ip_masked,
* thus can be recycled
*/
static inline int32_t
-tbl8_recycle_check(struct rte_lpm_tbl8_entry *tbl8, uint32_t tbl8_group_start)
+tbl8_recycle_check(struct rte_lpm_tbl_entry *tbl8, uint32_t tbl8_group_start)
{
uint32_t tbl8_group_end, i;
tbl8_group_end = tbl8_group_start + RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
@@ -891,11 +927,15 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,
}
else {
/* Set new tbl8 entry. */
- struct rte_lpm_tbl8_entry new_tbl8_entry = {
- .valid = VALID,
- .depth = sub_rule_depth,
- .valid_group =lpm->tbl8[tbl8_group_start].valid_group,
+ struct rte_lpm_tbl_entry new_tbl8_entry = {
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ .as_num = lpm->rules_tbl[sub_rule_index].as_num,
+#endif
+ .fwd_class =
lpm->rules_tbl[sub_rule_index].fwd_class,
.next_hop = lpm->rules_tbl[sub_rule_index].next_hop,
+ .depth = sub_rule_depth,
+ .ext_valid = lpm->tbl8[tbl8_group_start].ext_valid,
+ .valid = VALID,
};
/*
@@ -923,11 +963,15 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,
}
else if (tbl8_recycle_index > -1) {
/* Update tbl24 entry. */- struct rte_lpm_tbl24_entry new_tbl24_entry = {
- { .next_hop =
lpm->tbl8[tbl8_recycle_index].next_hop, },
- .valid = VALID,
- .ext_entry = 0,
+ struct rte_lpm_tbl_entry new_tbl24_entry = {
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ .as_num = lpm->tbl8[tbl8_recycle_index].as_num,
+#endif
+ .next_hop = lpm->tbl8[tbl8_recycle_index].next_hop,
+ .fwd_class =
lpm->tbl8[tbl8_recycle_index].fwd_class,
.depth = lpm->tbl8[tbl8_recycle_index].depth,
+ .ext_valid = 0,
+ .valid = VALID,
};
/* Set tbl24 before freeing tbl8 to avoid race condition. */lib/librte_lpm/rte_lpm.h +38 -37
104 lines not on this page · raw message
info table. */
/* LPM Tables. */
- struct rte_lpm_tbl24_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] \
+ struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] \
__rte_cache_aligned; /**< LPM tbl24 table. */
- struct rte_lpm_tbl8_entry tbl8[RTE_LPM_TBL8_NUM_ENTRIES] \
+ struct rte_lpm_tbl_entry tbl8[RTE_LPM_TBL8_NUM_ENTRIES] \
__rte_cache_aligned; /**< LPM tbl8 table. */
struct rte_lpm_rule rules_tbl[0] \
__rte_cache_aligned; /**< LPM rules. */@@ -219,7 +220,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, struct rte_lpm_res *res);
/**
* Check if a rule is present in the LPM table,
@@ -238,7 +239,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);
+ struct rte_lpm_res *res);
/**
* Delete a rule from the LPM table.
@@ -277,29 +278,43 @@ rte_lpm_delete_all(struct rte_lpm *lpm);
* -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup
hit
*/
static inline int
-rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint8_t *next_hop) +rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, struct rte_lpm_res *res)
{
unsigned tbl24_index = (ip >> 8);- uint16_t tbl_entry;
-
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ uint64_t tbl_entry;
+#else
+ uint32_t tbl_entry;
+#endif
/* DEBUG: Check user input arguments. */
- RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (next_hop == NULL)),-EINVAL);
+ RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (res == NULL)), -EINVAL);
/* Copy tbl24 entry */
- tbl_entry = *(const uint16_t *)&lpm->tbl24[tbl24_index];
-
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ tbl_entry = *(const uint64_t *)&lpm->tbl24[tbl24_index];
+#else
+ tbl_entry = *(const uint32_t *)&lpm->tbl24[tbl24_index];
+#endif
/* Copy tbl8 entry (only if needed) */
if (unlikely((tbl_entry & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
unsigned tbl8_index = (uint8_t)ip +- ((uint8_t)tbl_entry *RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
+ ((*(struct rte_lpm_tbl_entry
*)&tbl_entry).tbl8_gindex * RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
- tbl_entry = *(const uint16_t *)&lpm->tbl8[tbl8_index];
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ tbl_entry = *(const uint64_t *)&lpm->tbl8[tbl8_index];
+#else
+ tbl_entry = *(const uint32_t *)&lpm->tbl8[tbl8_index];
+#endif
} - - *next_hop = (uint8_t)tbl_entry; + res->next_hop = ((struct rte_lpm_tbl_entry *)&tbl_entry)->next_hop; + res->fwd_class = ((struct rte_lpm_tbl_entry
*)&tbl_entry)->fwd_class;
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ res->as_num = ((struct rte_lpm_tbl_entry
*)&tbl_entry)->as_num;
+#endif
return (tbl_entry & RTE_LPM_LOOKUP_SUCCESS) ? 0 : -ENOENT;
+
}
/**
@@ -322,19 +337,25 @@ rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint8_t *next_hop)
* @return
* -EINVAL for incorrect arguments, otherwise 0
*/
-#define rte_lpm_lookup_bulk(lpm, ips, next_hops, n) \
- rte_lpm_lookup_bulk_func(lpm, ips, next_hops, n)
+#define rte_lpm_lookup_bulk(lpm, ips, res_tbl, n) \
+ rte_lpm_lookup_bulk_func(lpm, ips, res_tbl, n)
static inline int
-rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t * ips,
- uint16_t * next_hops, const unsigned n)
+rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t *ips,
+ struct rte_lpm_res *res_tbl, const unsigned n)
{
unsigned i;+ int ret = 0;
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ uint64_t tbl_entry;
+#else
+ uint32_t tbl_entry;
+#endif
unsigned tbl24_indexes[n];
/* DEBUG: Check user input arguments. */
RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (ips == NULL) ||- (next_hops == NULL)), -EINVAL);
+ (res_tbl == NULL)), -EINVAL);
for (i = 0; i < n; i++) {
tbl24_indexes[i] = ips[i] >> 8;@@ -342,20 +363,32 @@ rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t * ips,
for (i = 0; i < n; i++) {
/* Simply copy tbl24 entry to output */- next_hops[i] = *(const uint16_t
*)&lpm->tbl24[tbl24_indexes[i]];
-
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ tbl_entry = *(const uint64_t
*)&lpm->tbl24[tbl24_indexes[i]];
+#else
+ tbl_entry = *(const uint32_t
*)&lpm->tbl24[tbl24_indexes[i]];
+#endif
/* Overwrite output with tbl8 entry if needed */
- if (unlikely((next_hops[i] &RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
- RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
+ if (unlikely((tbl_entry & RTE_LPM_VALID_EXT_ENTRY_BITMASK)
==
+ RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
unsigned tbl8_index = (uint8_t)ips[i] +
- ((uint8_t)next_hops[i] *
- RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
+ ((*(struct rte_lpm_tbl_entry
*)&tbl_entry).tbl8_gindex * RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
- next_hops[i] = *(const uint16_t
*)&lpm->tbl8[tbl8_index];
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ tbl_entry = *(const uint64_t
*)&lpm->tbl8[tbl8_index];
+#else
+ tbl_entry = *(const uint32_t
*)&lpm->tbl8[tbl8_index];
+#endif
}
+ res_tbl[i].next_hop = ((struct rte_lpm_tbl_entry
*)&tbl_entry)->next_hop;
+ res_tbl[i].fwd_class = ((struct rte_lpm_tbl_entry
*)&tbl_entry)->next_hop;
+#ifdef RTE_LIBRTE_LPM_ASNUM
+ res_tbl[i].as_num = ((struct rte_lpm_tbl_entry
*)&tbl_entry)->as_num;
+#endif
+ ret |= 1 << i;
}- return 0;
+ return ret;
}
/* Mask four results. */
@@ -477,4 +510,4 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, __m128i ip, uint16_t hop[4],
}
#endif
-#endif /* _RTE_LPM_H_ */
+#endif /* _RTE_LPM_EXT_H_ */
2015-10-24 9:09 GMT+03:00 Matthew Hall <[email protected]>:
Quoted 41 lines · Matthew Hall
Quoted 14 lines · Michal Jastrzebski
Quoted 11 lines
From: Michal Kobylinski <[email protected]>
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_tablelibrary to meet ABI compatibility requirements. A v2 will be sent next week.Quoted 6 lines
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_lpmas 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.
A message that is not in the archive (sent off-list or not yet received): 20151026115519.GA7576@MKJASTRX-MOBL
Quoted 878 lines
-----Original Message-----
From: Michal Jastrzebski [mailto:[email protected]]
Sent: Monday, October 26, 2015 12:55 PM
To: Vladimir Medvedkin
Subject: Re: [dpdk-dev] [PATCH v1 0/3] lpm: increase number of next hops for lpm (ipv4)lib/librte_lpm/rte_lpm.c rte_lpm_create(const char *name, int socket_id,
Quoted 42 lines · Vladimir Medvedkin
Hi all,
Here my implementation
Signed-off-by Vladimir Medvedkin <[email protected]>--- config/common_bsdapp | 1 + config/common_linuxapp | 1 + lib/librte_lpm/rte_lpm.c | 194 +++++++++++++++++++++++++++++------------------ lib/librte_lpm/rte_lpm.h | 163 +++++++++++++++++++++++---------------- 4 files changed, 219 insertions(+), 140 deletions(-)config/common_bsdapp +1
-0@@ -344,6 +344,7 @@ CONFIG_RTE_LIBRTE_JOBSTATS=y # CONFIG_RTE_LIBRTE_LPM=y CONFIG_RTE_LIBRTE_LPM_DEBUG=n +CONFIG_RTE_LIBRTE_LPM_ASNUM=n # # Compile librte_aclconfig/common_linuxapp +1
-0@@ -352,6 +352,7 @@ CONFIG_RTE_LIBRTE_JOBSTATS=y # CONFIG_RTE_LIBRTE_LPM=y CONFIG_RTE_LIBRTE_LPM_DEBUG=n +CONFIG_RTE_LIBRTE_LPM_ASNUM=n # # Compile librte_acllib/librte_lpm/rte_lpm.c +0
-0@@ -159,9 +159,11 @@ rte_lpm_create(const char *name, int socket_id,int
lib/librte_lpm/rte_lpm.c rule_add(struct rte_lpm *lpm, uint32_t
Quoted 25 lines
lib/librte_lpm/rte_lpm.c +5
-3max_rules, lpm_list =RTE_TAILQ_CAST (rte_lpm_tailq.head, rte_lpm_list); -RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl24_entry ) !=2 ); -RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl8_entry ) !=2 ); - +#ifdef RTE_LIBRTE_LPM_ASNUM +RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl_entry ) !=8 ); +#else +RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl_entry ) !=4 ); +#endif /* Check user arguments. */ if ((name ==NULL ) || (socket_id <-1 ) || (max_rules ==0 )){rte_errno = EINVAL;lib/librte_lpm/rte_lpm.c +1
-1@@ -261,7 +263,7 @@ rte_lpm_free(struct rte_lpm *lpm)*/ static inline int32_t rule_add (struct rte_lpm *lpm,uint32_t ip_masked,uint8_t depth, -uint8_t next_hop) +struct rte_lpm_res *res) {uint32_t rule_gindex, rule_index, last_rule;int i;@@ -282,8 +284,11 @@ rule_add(struct rte_lpm *lpm, uint32_t
ip_masked,lib/librte_lpm/rte_lpm.c rule_add(struct rte_lpm *lpm, uint32_t
Quoted 20 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth,/* If rule already exists update its next_hop and return. */
if (lpm->rules_tbl[rule_index].ip == ip_masked) {- lpm->rules_tbl[rule_index].next_hop =
next_hop;lib/librte_lpm/rte_lpm.c +1
-1- + lpm->rules_tbl[rule_index].next_hop =
res->next_hop;
+ lpm->rules_tbl[rule_index].fwd_class =res->fwd_class;lib/librte_lpm/rte_lpm.c +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->rules_tbl[rule_index].as_num =
res->as_num;lib/librte_lpm/rte_lpm.c +1
-0+#endif return rule_index; } }@@ -320,7 +325,11 @@ rule_add(struct rte_lpm *lpm, uint32_t
ip_masked,lib/librte_lpm/rte_lpm.c rule_find(struct rte_lpm *lpm, uint32_t
Quoted 14 lines
lib/librte_lpm/rte_lpm.c +5
-1uint8_t depth,/* Add the new rule. */ lpm->rules_tbl[rule_index].ip = ip_masked; - lpm->rules_tbl[rule_index].next_hop = next_hop; + lpm->rules_tbl[rule_index].next_hop = res->next_hop; + lpm->rules_tbl[rule_index].fwd_class = res->fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->rules_tbl[rule_index].as_num = res->as_num; +#endif /* Increment the used rules counter for this rule group. */ lpm->rule_info[depth - 1].used_rules++;lib/librte_lpm/rte_lpm.c +0
-0@@ -382,10 +391,10 @@ rule_find(struct rte_lpm *lpm, uint32_t
ip_masked,lib/librte_lpm/rte_lpm.c add_depth_small(struct rte_lpm *lpm, uint32_t
Quoted 95 lines
lib/librte_lpm/rte_lpm.c +2
-2uint8_t depth) * Find, clean and allocate a tbl8. */ static inline int32_t -tbl8_alloc (struct rte_lpm_tbl8_entry *tbl8) +tbl8_alloc (struct rte_lpm_tbl_entry *tbl8) {uint32_t tbl8_gindex;/* tbl8 group index. */ -struct rte_lpm_tbl8_entry *tbl8_entry; +struct rte_lpm_tbl_entry *tbl8_entry;/* Scan through tbl8 to find a free (i.e. INVALID) tbl8 group. */ for (tbl8_gindex = 0; tbl8_gindex < RTE_LPM_TBL8_NUM_GROUPS;lib/librte_lpm/rte_lpm.c +2
-2@@ -393,12 +402,12 @@ tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) tbl8_entry = &tbl8[tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES ];/* If a free tbl8 group is found clean it and set as VALID. */ -if (!tbl8_entry->valid_group) { +if (!tbl8_entry->ext_valid) {memset (&tbl8_entry[0 ],0 ,RTE_LPM_TBL8_GROUP_NUM_ENTRIES *sizeof (tbl8_entry[0 ])); - tbl8_entry->valid_group =VALID ; + tbl8_entry->ext_valid =VALID ;/* Return group index for allocated tbl8 group. */ return tbl8_gindex;lib/librte_lpm/rte_lpm.c +17
-13@@ -410,46 +419,50 @@ tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) }static inline void -tbl8_free (struct rte_lpm_tbl8_entry *tbl8,uint32_t tbl8_group_start) +tbl8_free (struct rte_lpm_tbl_entry *tbl8,uint32_t tbl8_group_start) {/* Set tbl8 group invalid*/ - tbl8[tbl8_group_start].valid_group =INVALID ; + tbl8[tbl8_group_start].ext_valid =INVALID ; }static inline int32_t add_depth_small (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t next_hop) +struct rte_lpm_res *res) {uint32_t tbl24_index, tbl24_range, tbl8_index, tbl8_group_end, i, j;/* Calculate the index into Table24. */ tbl24_index = ip >>8 ; tbl24_range =depth_to_range (depth); +struct rte_lpm_tbl_entry new_tbl_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = res->as_num, +#endif + .next_hop = res->next_hop, + .fwd_class = res->fwd_class, + .ext_valid =0 , + .depth = depth, + .valid =VALID , + }; +for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++) {/* * For invalid OR valid and non-extended tbl 24 entries set * entry. */ -if (!lpm->tbl24[i].valid || (lpm->tbl24[i].ext_entry ==0 && +if (!lpm->tbl24[i].valid || (lpm->tbl24[i].ext_valid ==0 && lpm->tbl24[i].depth <= depth)) { -struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .next_hop = next_hop, }, - .valid =VALID , - .ext_entry =0 , - .depth = depth, - }; -/* Setting tbl24 entry in one go to avoid race * conditions */ - lpm->tbl24[i] = new_tbl24_entry; + lpm->tbl24[i] = new_tbl_entry;continue ; } -if (lpm->tbl24[i].ext_entry ==1 ) { +if (lpm->tbl24[i].ext_valid ==1 ) {/* If tbl24 entry is valid and extended calculate the
* index into tbl8.
*/lib/librte_lpm/rte_lpm.c +0
-0@@ -461,19 +474,14 @@ add_depth_small(struct rte_lpm *lpm, uint32_tip,
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t
Quoted 37 lines
lib/librte_lpm/rte_lpm.c +2
-7uint8_t depth, for (j = tbl8_index; j < tbl8_group_end; j++) {if (!lpm->tbl8[j].valid || lpm->tbl8[j].depth <= depth) { -struct rte_lpm_tbl8_entry - new_tbl8_entry = { - .valid =VALID , - .valid_group =VALID , - .depth = depth, - .next_hop = next_hop, - }; + + new_tbl_entry.ext_valid =VALID ;/* * Setting tbl8 entry in one go to avoid
* race conditions */lib/librte_lpm/rte_lpm.c +2
-2- lpm->tbl8[j] = new_tbl8_entry; + lpm->tbl8[j] = new_tbl_entry;continue ; }@@ -486,7 +494,7 @@ add_depth_small(struct rte_lpm *lpm, uint32_t ip,uint8_t depth, static inline int32_t add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, - uint8_t next_hop) + struct rte_lpm_res *res) { uint32_t tbl24_index;int32_t tbl8_group_index, tbl8_group_start, tbl8_group_end,
tbl8_index,lib/librte_lpm/rte_lpm.c +0
-0@@ -512,7 +520,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t
Quoted 39 lines
lib/librte_lpm/rte_lpm.c +9
-5uint8_t depth,/* Set tbl8 entry. */ for (i = tbl8_index; i < (tbl8_index + tbl8_range); i++) { lpm->tbl8[i].depth = depth; - lpm->tbl8[i].next_hop = next_hop; + lpm->tbl8[i].next_hop = res->next_hop; + lpm->tbl8[i].fwd_class = res->fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->tbl8[i].as_num = res->as_num; +#endif lpm->tbl8[i].valid =VALID ; }@@ -522,17 +534,17 @@ add_depth_big(struct rte_lpm *lpm, uint32_tip_masked, uint8_t depth, * so assign whole structure in one go */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .tbl8_gindex = (uint8_t )tbl8_group_index, }, - .valid =VALID , - .ext_entry =1 , +struct rte_lpm_tbl_entry new_tbl24_entry = { + .tbl8_gindex = (uint16_t )tbl8_group_index, .depth =0 , + .ext_valid =1 , + .valid =VALID , }; lpm->tbl24[tbl24_index] = new_tbl24_entry; }/* If valid entry but not extended calculate the index into Table8. */
lib/librte_lpm/rte_lpm.c +1
-1-else if (lpm->tbl24[tbl24_index].ext_entry ==0 ) { +else if (lpm->tbl24[tbl24_index].ext_valid ==0 ) {/* Search for free tbl8 group. */ tbl8_group_index =tbl8_alloc (lpm->tbl8);@@ -551,6 +563,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t
Quoted 14 lines
lib/librte_lpm/rte_lpm.c +5
-0uint8_t depth, lpm->tbl8[i].depth = lpm->tbl24[tbl24_index].depth; lpm->tbl8[i].next_hop = lpm->tbl24[tbl24_index].next_hop; + lpm->tbl8[i].fwd_class = + lpm->tbl24[tbl24_index].fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->tbl8[i].as_num = lpm->tbl24[tbl24_index].as_num; +#endif }tbl8_index = tbl8_group_start + (ip_masked & 0xFF);lib/librte_lpm/rte_lpm.c +0
-0@@ -561,7 +578,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,lib/librte_lpm/rte_lpm.c rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
Quoted 79 lines
lib/librte_lpm/rte_lpm.c +5
-1uint8_t depth, lpm->tbl8[i].depth <= depth) { lpm->tbl8[i].valid = VALID; lpm->tbl8[i].depth = depth; - lpm->tbl8[i].next_hop = next_hop; + lpm->tbl8[i].next_hop = res->next_hop; + lpm->tbl8[i].fwd_class = res->fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->tbl8[i].as_num = res->as_num; +#endif continue ;}lib/librte_lpm/rte_lpm.c +4
-4@@ -573,11 +594,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_tip_masked, uint8_t depth, * so assign whole structure in one go. */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .tbl8_gindex = (uint8_t )tbl8_group_index, }, - .valid =VALID , - .ext_entry =1 , +struct rte_lpm_tbl_entry new_tbl24_entry = { + .tbl8_gindex = (uint16_t )tbl8_group_index, .depth =0 , + .ext_valid =1 , + .valid =VALID , };lpm->tbl24[tbl24_index] = new_tbl24_entry;lib/librte_lpm/rte_lpm.c +8
-4@@ -595,11 +616,15 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, if (!lpm->tbl8[i].valid || lpm->tbl8[i].depth <= depth) { -struct rte_lpm_tbl8_entry new_tbl8_entry = { - .valid =VALID , +struct rte_lpm_tbl_entry new_tbl8_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = res->as_num, +#endif + .next_hop = res->next_hop, + .fwd_class = res->fwd_class, .depth = depth, - .next_hop = next_hop, - .valid_group = lpm->tbl8[i].valid_group, + .ext_valid = lpm->tbl8[i].ext_valid, + .valid =VALID , };/*lib/librte_lpm/rte_lpm.c +3
-3@@ -621,19 +646,19 @@ add_depth_big(struct rte_lpm *lpm, uint32_tip_masked, uint8_t depth, */ int rte_lpm_add (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t next_hop) +struct rte_lpm_res *res) {int32_t rule_index, status =0 ;uint32_t ip_masked;/* Check user arguments. */ -if ((lpm ==NULL ) || (depth <1 ) || (depth >RTE_LPM_MAX_DEPTH )) +if ((lpm ==NULL ) || (res ==NULL ) || (depth <1 ) || (depth >RTE_LPM_MAX_DEPTH ))return -EINVAL ; ip_masked = ip &depth_to_mask (depth);/* Add the rule to the rule table. */ - rule_index =rule_add (lpm, ip_masked, depth, next_hop); + rule_index =rule_add (lpm, ip_masked, depth, res);/* If the is no space available for new rule return error. */ if (rule_index < 0) {lib/librte_lpm/rte_lpm.c +0
-0@@ -641,10 +666,10 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
uint8_tlib/librte_lpm/rte_lpm.c rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
Quoted 14 lines
lib/librte_lpm/rte_lpm.c +2
-2depth, }if (depth <=MAX_DEPTH_TBL24 ) { - status =add_depth_small (lpm, ip_masked, depth, next_hop); + status =add_depth_small (lpm, ip_masked, depth, res); }else {/* If depth > RTE_LPM_MAX_DEPTH_TBL24 */ - status =add_depth_big (lpm, ip_masked, depth, next_hop); + status =add_depth_big (lpm, ip_masked, depth, res);/* * If add fails due to exhaustion of tbl8 extensions delete
lib/librte_lpm/rte_lpm.c +0
-0@@ -665,14 +690,14 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
uint8_tlib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm,
Quoted 42 lines
lib/librte_lpm/rte_lpm.c +8
-4depth, */ int rte_lpm_is_rule_present (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t *next_hop) +struct rte_lpm_res *res) {uint32_t ip_masked;int32_t rule_index;/* Check user arguments. */ if ((lpm ==NULL ) || - (next_hop ==NULL ) || + (res ==NULL ) || (depth <1 ) || (depth >RTE_LPM_MAX_DEPTH ))return -EINVAL ;@@ -681,7 +706,11 @@ uint8_t *next_hop) rule_index =rule_find (lpm, ip_masked, depth);if (rule_index >=0 ) { - *next_hop = lpm->rules_tbl[rule_index].next_hop; + res->next_hop = lpm->rules_tbl[rule_index].next_hop; + res->fwd_class = lpm->rules_tbl[rule_index].fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + res->as_num = lpm->rules_tbl[rule_index].as_num; +#endif return 1 ; }@@ -731,7 +760,7 @@ delete_depth_small(struct rte_lpm *lpm, uint32_tip_masked, */ for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++) { -if (lpm->tbl24[i].ext_entry ==0 && +if (lpm->tbl24[i].ext_valid ==0 && lpm->tbl24[i].depth <= depth ) {lpm->tbl24[i].valid = INVALID; }lib/librte_lpm/rte_lpm.c +0
-0@@ -761,23 +790,30 @@ delete_depth_small(struct rte_lpm *lpm,
uint32_tQuoted 53 lines
lib/librte_lpm/rte_lpm.c +17
-10ip_masked, * associated with this rule. */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - {.next_hop = lpm->rules_tbl[sub_rule_index].next_hop,}, - .valid =VALID , - .ext_entry =0 , +struct rte_lpm_tbl_entry new_tbl24_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = lpm->rules_tbl[sub_rule_index].as_num, +#endif + .next_hop = lpm->rules_tbl[sub_rule_index].next_hop, + .fwd_class = lpm->rules_tbl[sub_rule_index].fwd_class, .depth = sub_rule_depth, + .ext_valid =0 , + .valid =VALID , }; -struct rte_lpm_tbl8_entry new_tbl8_entry = { - .valid =VALID , +struct rte_lpm_tbl_entry new_tbl8_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = lpm->rules_tbl[sub_rule_index].as_num, +#endif + .next_hop = lpm->rules_tbl[sub_rule_index].next_hop, + .fwd_class = lpm->rules_tbl[sub_rule_index].fwd_class, .depth = sub_rule_depth, - .next_hop = lpm->rules_tbl - [sub_rule_index].next_hop, + .valid =VALID , };for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++) { -if (lpm->tbl24[i].ext_entry ==0 && +if (lpm->tbl24[i].ext_valid ==0 && lpm->tbl24[i].depth <= depth ) { lpm->tbl24[i] = new_tbl24_entry; }@@ -814,7 +850,7 @@ delete_depth_small(struct rte_lpm *lpm, uint32_tip_masked, * thus can be recycled */ static inline int32_t -tbl8_recycle_check(struct rte_lpm_tbl8_entry *tbl8, uint32_t tbl8_group_start) +tbl8_recycle_check (struct rte_lpm_tbl_entry *tbl8,uint32_t tbl8_group_start)Quoted 3 lines
{
uint32_ttbl8_group_end, i;
tbl8_group_end=tbl8_group_start+
RTE_LPM_TBL8_GROUP_NUM_ENTRIES;Quoted 51 lines
lib/librte_lpm/rte_lpm.c +8
-4@@ -891,11 +927,15 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, }else {/* Set new tbl8 entry. */ -struct rte_lpm_tbl8_entry new_tbl8_entry = { - .valid =VALID , - .depth = sub_rule_depth, - .valid_group = lpm->tbl8[tbl8_group_start].valid_group, + struct rte_lpm_tbl_entry new_tbl8_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = lpm->rules_tbl[sub_rule_index].as_num, +#endif + .fwd_class = lpm->rules_tbl[sub_rule_index].fwd_class, .next_hop = lpm->rules_tbl[sub_rule_index].next_hop, + .depth = sub_rule_depth, + .ext_valid = lpm->tbl8[tbl8_group_start].ext_valid, + .valid = VALID,}; /*lib/librte_lpm/rte_lpm.c +8
-4@@ -923,11 +963,15 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, }else if (tbl8_recycle_index >-1 ) {/* Update tbl24 entry. */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .next_hop = lpm->tbl8[tbl8_recycle_index].next_hop, }, - .valid =VALID , - .ext_entry =0 , + struct rte_lpm_tbl_entry new_tbl24_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = lpm->tbl8[tbl8_recycle_index].as_num, +#endif + .next_hop = lpm->tbl8[tbl8_recycle_index].next_hop, + .fwd_class = lpm->tbl8[tbl8_recycle_index].fwd_class, .depth = lpm->tbl8[tbl8_recycle_index].depth, + .ext_valid =0 , + .valid = VALID,}; /* Set tbl24 before freeing tbl8 to avoid race condition. */lib/librte_lpm/rte_lpm.h +0
-0lib/librte_lpm/rte_lpm.h line 31
Quoted 1 line
lib/librte_lpm/rte_lpm.h +0
-0@@ -31,8 +31,8 @@* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
lib/librte_lpm/rte_lpm.h rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
Quoted 128 lines
lib/librte_lpm/rte_lpm.h +38
-37*/ -#ifndef _RTE_LPM_H_ -#define _RTE_LPM_H_ +#ifndef _RTE_LPM_EXT_H_ +#define _RTE_LPM_EXT_H_/** * @file @@ -81,57 +81,58 @@ extern "C" {#define RTE_LPM_RETURN_IF_TRUE (cond, retval)#endif -/** @internal bitmask with valid and ext_entry/valid_group fields set */ -#define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x0300 +/** @internal bitmask with valid and ext_valid/ext_valid fields set */ +#define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x03/** Bitmask used to indicate successful lookup */ -#define RTE_LPM_LOOKUP_SUCCESS 0x0100 +#define RTE_LPM_LOOKUP_SUCCESS 0x01 + +struct rte_lpm_res { +uint16_t next_hop; +uint8_t fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif +};#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. */ +struct rte_lpm_tbl_entry { +uint8_t valid :1 ; +uint8_t ext_valid :1 ; +uint8_t depth :6 ; +uint8_t fwd_class;union { -uint8_t next_hop; -uint8_t tbl8_gindex; +uint16_t next_hop; +uint16_t tbl8_gindex; }; -/* 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. */ -}; - -/** @internal Tbl8 entry structure. */ -struct rte_lpm_tbl8_entry { -uint8_t next_hop;/**< 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. */ +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif };#else -struct rte_lpm_tbl24_entry { -uint8_t depth :6 ; -uint8_t ext_entry :1 ; -uint8_t valid :1 ; +struct rte_lpm_tbl_entry { +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif union { -uint8_t tbl8_gindex; -uint8_t next_hop; +uint16_t tbl8_gindex; +uint16_t next_hop; }; -}; - -struct rte_lpm_tbl8_entry { -uint8_t depth :6 ; -uint8_t valid_group :1 ; -uint8_t valid :1 ; -uint8_t next_hop; +uint8_t fwd_class; +uint8_t depth :6 ; +uint8_t ext_valid :1 ; +uint8_t valid :1 ; };#endif /** @internal Rule structure. */ struct rte_lpm_rule {uint32_t ip;/**< Rule IP address. */ -uint8_t next_hop;/**< Rule next hop. */ +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif +uint16_t next_hop;/**< Rule next hop. */ +uint8_t fwd_class; };/** @internal Contains metadata about the rules table. */ @@ -148,9 +149,9 @@ struct rte_lpm {struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH ];/**< Rule info table. */
/* LPM Tables. */lib/librte_lpm/rte_lpm.h +3
-3- struct rte_lpm_tbl24_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] \ + struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] \ __rte_cache_aligned;/**< LPM tbl24 table. */ - struct rte_lpm_tbl8_entry tbl8[RTE_LPM_TBL8_NUM_ENTRIES] \ + struct rte_lpm_tbl_entry tbl8[RTE_LPM_TBL8_NUM_ENTRIES] \ __rte_cache_aligned;/**< LPM tbl8 table. */ struct rte_lpm_rule rules_tbl[0] \ __rte_cache_aligned;/**< LPM rules. */ @@ -219,7 +220,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, struct rte_lpm_res *res);/**
* Check if a rule is present in the LPM table,lib/librte_lpm/rte_lpm.h +0
-0@@ -238,7 +239,7 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
uint8_tQuoted 19 lines
lib/librte_lpm/rte_lpm.h +1
-1depth, uint8_t next_hop); */ int rte_lpm_is_rule_present (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t *next_hop); +struct rte_lpm_res *res);/** * Delete a rule from the LPM table.
lib/librte_lpm/rte_lpm.h +0
-0@@ -277,29 +278,43 @@ rte_lpm_delete_all(struct rte_lpm *lpm);* -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit
*/
static inline intlib/librte_lpm/rte_lpm.h +1
-2-rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint8_t *next_hop) +rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, struct rte_lpm_res *res) { unsigned tbl24_index = (ip >> 8); -uint16_t tbl_entry;lib/librte_lpm/rte_lpm.h
Quoted 10 lines
lib/librte_lpm/rte_lpm.h +6
-3- +#ifdef RTE_LIBRTE_LPM_ASNUM +uint64_t tbl_entry; +#else +uint32_t tbl_entry; +#endif /* DEBUG: Check user input arguments. */ -RTE_LPM_RETURN_IF_TRUE (((lpm ==NULL ) || (next_hop ==NULL )), -EINVAL ); + RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (res == NULL)), -EINVAL);
lib/librte_lpm/rte_lpm.h rte_lpm_lookup_bulk_func(const struct rte_lpm
Quoted 73 lines
/* Copy tbl24 entry */lib/librte_lpm/rte_lpm.h +5
-3- tbl_entry = *(const uint16_t *)&lpm->tbl24[tbl24_index]; - +#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t *)&lpm->tbl24[tbl24_index]; +#else + tbl_entry = *(const uint32_t *)&lpm->tbl24[tbl24_index]; +#endif /* Copy tbl8 entry (only if needed) */ if (unlikely ((tbl_entry &RTE_LPM_VALID_EXT_ENTRY_BITMASK ) ==RTE_LPM_VALID_EXT_ENTRY_BITMASK )) { unsigned tbl8_index = (uint8_t)ip + - ((uint8_t)tbl_entry *
RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
+ ((*(structrte_lpm_tbl_entry
*)&tbl_entry).tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES);lib/librte_lpm/rte_lpm.h +7
-3- tbl_entry = *(const uint16_t *)&lpm->tbl8[tbl8_index]; +#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t *)&lpm->tbl8[tbl8_index]; +#else + tbl_entry = *(const uint32_t *)&lpm->tbl8[tbl8_index]; +#endif } - - *next_hop = (uint8_t )tbl_entry; + res->next_hop = ((struct rte_lpm_tbl_entry *)&tbl_entry)->next_hop; + res->fwd_class = ((struct rte_lpm_tbl_entry*)&tbl_entry)->fwd_class;
lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + res->as_num = ((struct rte_lpm_tbl_entry*)&tbl_entry)->as_num;
lib/librte_lpm/rte_lpm.h +13
-5+#endif return (tbl_entry &RTE_LPM_LOOKUP_SUCCESS ) ?0 : -ENOENT ; + }/** @@ -322,19 +337,25 @@ rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip,uint8_t *next_hop) * @return * -EINVAL for incorrect arguments, otherwise 0 */ -#define rte_lpm_lookup_bulk (lpm, ips, next_hops, n) \ - rte_lpm_lookup_bulk_func(lpm, ips, next_hops, n) +#define rte_lpm_lookup_bulk (lpm, ips, res_tbl, n) \ + rte_lpm_lookup_bulk_func(lpm, ips, res_tbl, n)static inline int -rte_lpm_lookup_bulk_func (const struct rte_lpm *lpm,const uint32_t * ips, -uint16_t * next_hops,const unsigned n) +rte_lpm_lookup_bulk_func (const struct rte_lpm *lpm,const uint32_t *ips, +struct rte_lpm_res *res_tbl,const unsigned n) {unsigned i; +int ret =0 ; +#ifdef RTE_LIBRTE_LPM_ASNUM +uint64_t tbl_entry; +#else +uint32_t tbl_entry; +#endif unsigned tbl24_indexes[n];/* DEBUG: Check user input arguments. */ RTE_LPM_RETURN_IF_TRUE (((lpm ==NULL ) || (ips ==NULL ) || - (next_hops ==NULL )), -EINVAL ); + (res_tbl ==NULL )), -EINVAL );for (i =0 ; i < n; i++) {tbl24_indexes[i] = ips[i] >> 8;lib/librte_lpm/rte_lpm.h +0
-0@@ -342,20 +363,32 @@ rte_lpm_lookup_bulk_func(const struct rte_lpm*lpm,
lib/librte_lpm/rte_lpm.h rte_lpm_lookupx4(const struct rte_lpm *lpm,
Quoted 54 lines
lib/librte_lpm/rte_lpm.h +5
-3const uint32_t * ips, for (i = 0; i < n; i++) {/* Simply copy tbl24 entry to output */ - next_hops[i] = *(const uint16_t *)&lpm->tbl24[tbl24_indexes[i]]; - +#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t *)&lpm->tbl24[tbl24_indexes[i]]; +#else + tbl_entry = *(const uint32_t *)&lpm->tbl24[tbl24_indexes[i]]; +#endif /* Overwrite output with tbl8 entry if needed */ - if (unlikely((next_hops[i] &
RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==lib/librte_lpm/rte_lpm.h +1
-1- RTE_LPM_VALID_EXT_ENTRY_BITMASK)) { + if (unlikely((tbl_entry & RTE_LPM_VALID_EXT_ENTRY_BITMASK)==
lib/librte_lpm/rte_lpm.h +2
-2+ RTE_LPM_VALID_EXT_ENTRY_BITMASK)) { unsigned tbl8_index = (uint8_t)ips[i] + - ((uint8_t )next_hops[i] * -RTE_LPM_TBL8_GROUP_NUM_ENTRIES ); + ((*(struct rte_lpm_tbl_entry*)&tbl_entry).tbl8_gindex *
RTE_LPM_TBL8_GROUP_NUM_ENTRIES);- next_hops[i] = *(const
uint16_t
*)&lpm->tbl8[tbl8_index];lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t*)&lpm->tbl8[tbl8_index];
lib/librte_lpm/rte_lpm.h +2
-0+#else + tbl_entry = *(const uint32_t*)&lpm->tbl8[tbl8_index];
lib/librte_lpm/rte_lpm.h +2
-0+#endif } + res_tbl[i].next_hop = ((struct rte_lpm_tbl_entry*)&tbl_entry)->next_hop;
+ res_tbl[i].fwd_class = ((structrte_lpm_tbl_entry
*)&tbl_entry)->next_hop;lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + res_tbl[i].as_num = ((struct rte_lpm_tbl_entry*)&tbl_entry)->as_num;
lib/librte_lpm/rte_lpm.h +3
-1+#endif + ret |=1 << i; } -return 0 ; +return ret; }/* Mask four results. */ @@ -477,4 +510,4 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm,
__m128iip,Quoted 7 lines
lib/librte_lpm/rte_lpm.h +1
-1uint16_t hop[4], }#endif -#endif /* _RTE_LPM_H_ */ +#endif /* _RTE_LPM_EXT_H_ */ Quoted 30 lines
2015-10-24 9:09 GMT+03:00 Matthew Hall <[email protected]>:
Quoted 28 lines · Matthew Hall
Quoted 14 lines · Michal Jastrzebski
Quoted 11 lines
From: Michal Kobylinski <[email protected]>
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_tablelibrary to meet ABI compatibility requirements. A v2 will be sent next week.Quoted 6 lines
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
Quoted 2 lines
Quoted 2 lines
humanly possible.
Quoted 13 lines
Quoted 7 lines
Quoted 7 lines
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_lpmas 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 Iam
Quoted 4 lines
Quoted 4 lines
very very very very very happy about this.
Matthew.
Hi Vladimir,
Thanks for sharing Your implementation.
Could You please clarify what as_num and fwd_class fields represent? The second issue I have is that Your patch doesn’t want to apply on top of current head. Could You check this please?
Best regards
Michal
Hi Michal,
Forwarding class can help us to classify traffic based on dst prefix, it's something like Juniper DCU. For example on Juniper MX I can make policy that install prefix into the FIB with some class and use it on dataplane, for example with ACL.
On Juniper MX I can make something like that:
#show policy-options
policy-statement community-to-class {
term customer {
from community originate-customer;
then destination-class customer;
}
}
community originate-customer members 12345:11111;
# show routing-options
forwarding-table {
export community-to-class;
}
# show forwarding-options
forwarding-options {
family inet {
filter {
output test-filter;
}
}
}
# show firewall family inet filter test-filter
term 1 {
from {
protocol icmp;
destination-class customer;
}
then {
discard;
}
}
announce route 10.10.10.10/32 next-hop 10.10.10.2 community 12345:11111
After than on dataplane we have
NPC1( vty)# show route ip lookup 10.10.10.10
Route Information (10.10.10.10):
interface : xe-1/0/0.0 (328)
Nexthop prefix : -
Nexthop ID : 1048574
MTU : 0
Class ID : 129 <- That is "forwarding class" in my implementation
This construction discards all ICMP traffic that goes to dst prefixes which
was originated with community 12345:11111. With this mechanism we can make
on control plane different sophisticated policy to control traffic on
dataplane.
The same with as_num, we can have on dataplane AS number that has
originated that prefix, or another 4-byte number e.g. geo-id.
What issue do you mean? I think it is because of table/pipeline/test
frameworks that doesen't want to compile due to changing API/ABI. You can
turn it off for LPM testing, if my patch will be applied I will make
changes in above-mentioned frameworks.Regards,
Vladimir
2015-10-26 14:57 GMT+03:00 Jastrzebski, MichalX K < [email protected]>:
Quoted 963 lines
Quoted 69 lines
-----Original Message-----
From: Michal Jastrzebski [mailto:[email protected]]
Sent: Monday, October 26, 2015 12:55 PM
To: Vladimir Medvedkin
Subject: Re: [dpdk-dev] [PATCH v1 0/3] lpm: increase number of next hops for lpm (ipv4)lib/librte_lpm/rte_lpm.c rte_lpm_create(const char *name, int socket_id,
Quoted 42 lines · Vladimir Medvedkin
Hi all,
Here my implementation
Signed-off-by Vladimir Medvedkin <[email protected]>--- config/common_bsdapp | 1 + config/common_linuxapp | 1 + lib/librte_lpm/rte_lpm.c | 194 +++++++++++++++++++++++++++++------------------ lib/librte_lpm/rte_lpm.h | 163 +++++++++++++++++++++++---------------- 4 files changed, 219 insertions(+), 140 deletions(-)config/common_bsdapp +1
-0@@ -344,6 +344,7 @@ CONFIG_RTE_LIBRTE_JOBSTATS=y # CONFIG_RTE_LIBRTE_LPM=y CONFIG_RTE_LIBRTE_LPM_DEBUG=n +CONFIG_RTE_LIBRTE_LPM_ASNUM=n # # Compile librte_aclconfig/common_linuxapp +1
-0@@ -352,6 +352,7 @@ CONFIG_RTE_LIBRTE_JOBSTATS=y # CONFIG_RTE_LIBRTE_LPM=y CONFIG_RTE_LIBRTE_LPM_DEBUG=n +CONFIG_RTE_LIBRTE_LPM_ASNUM=n # # Compile librte_acllib/librte_lpm/rte_lpm.c +0
-0@@ -159,9 +159,11 @@ rte_lpm_create(const char *name, int socket_id,int
Quoted 18 lines
lib/librte_lpm/rte_lpm.c +5
-3max_rules, lpm_list =RTE_TAILQ_CAST (rte_lpm_tailq.head, rte_lpm_list); -RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl24_entry ) !=2 ); -RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl8_entry ) !=2 ); - +#ifdef RTE_LIBRTE_LPM_ASNUM +RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl_entry ) !=8 ); +#else +RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl_entry ) !=4 ); +#endif /* Check user arguments. */ if ((name ==NULL ) || (socket_id <-1 ) || (max_rules ==0 )){rte_errno = EINVAL;lib/librte_lpm/rte_lpm.c +0
-0@@ -261,7 +263,7 @@ rte_lpm_free(struct rte_lpm *lpm)*/ static inline int32_tQuoted 11 lines
lib/librte_lpm/rte_lpm.c rule_add(struct rte_lpm *lpm, uint32_t
Quoted 7 lines
lib/librte_lpm/rte_lpm.c +1
-1rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, - uint8_t next_hop) + struct rte_lpm_res *res) { uint32_t rule_gindex, rule_index, last_rule;int i;@@ -282,8 +284,11 @@ rule_add(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth,/* If rule already exists update its next_hop and
Quoted 2 lines
Quoted 2 lines
return. */
if (lpm->rules_tbl[rule_index].ip ==
ip_masked) {Quoted 42 lines
lib/librte_lpm/rte_lpm.c rule_add(struct rte_lpm *lpm, uint32_t
Quoted 15 lines
- lpm->rules_tbl[rule_index].next_hop =
next_hop;lib/librte_lpm/rte_lpm.c +1
-1- + lpm->rules_tbl[rule_index].next_hop =
res->next_hop;
+ lpm->rules_tbl[rule_index].fwd_class =res->fwd_class;lib/librte_lpm/rte_lpm.c +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->rules_tbl[rule_index].as_num =
res->as_num;lib/librte_lpm/rte_lpm.c +1
-0+#endif return rule_index; } }@@ -320,7 +325,11 @@ rule_add(struct rte_lpm *lpm, uint32_t
ip_masked,lib/librte_lpm/rte_lpm.c rule_find(struct rte_lpm *lpm, uint32_t
Quoted 14 lines
lib/librte_lpm/rte_lpm.c +5
-1uint8_t depth,/* Add the new rule. */ lpm->rules_tbl[rule_index].ip = ip_masked; - lpm->rules_tbl[rule_index].next_hop = next_hop; + lpm->rules_tbl[rule_index].next_hop = res->next_hop; + lpm->rules_tbl[rule_index].fwd_class = res->fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->rules_tbl[rule_index].as_num = res->as_num; +#endif /* Increment the used rules counter for this rule group. */ lpm->rule_info[depth - 1].used_rules++;lib/librte_lpm/rte_lpm.c +0
-0@@ -382,10 +391,10 @@ rule_find(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 11 lines
lib/librte_lpm/rte_lpm.c +2
-2uint8_t depth) * Find, clean and allocate a tbl8. */ static inline int32_t -tbl8_alloc (struct rte_lpm_tbl8_entry *tbl8) +tbl8_alloc (struct rte_lpm_tbl_entry *tbl8) {uint32_t tbl8_gindex;/* tbl8 group index. */ -struct rte_lpm_tbl8_entry *tbl8_entry; +struct rte_lpm_tbl_entry *tbl8_entry;Quoted 1 line
lib/librte_lpm/rte_lpm.c rule_find(struct rte_lpm *lpm, uint32_t · line 400
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-0/* Scan through tbl8 to find a free (i.e. INVALID) tbl8 group. */
Quoted 5 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 404
Quoted 5 lines
for (tbl8_gindex = 0; tbl8_gindex < RTE_LPM_TBL8_NUM_GROUPS;lib/librte_lpm/rte_lpm.c +0
-0@@ -393,12 +402,12 @@ tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) tbl8_entry = &tbl8[tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES ];/* If a free tbl8 group is found clean it and set as VALID.
Quoted 5 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 408
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +1
-1*/ -if (!tbl8_entry->valid_group) { +if (!tbl8_entry->ext_valid) {memset (&tbl8_entry[0 ],0 , RTE_LPM_TBL8_GROUP_NUM_ENTRIES*
Quoted 6 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 413
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +1
-1sizeof(tbl8_entry[0])); - tbl8_entry->valid_group =VALID ; + tbl8_entry->ext_valid =VALID ;/* Return group index for allocated tbl8 group. */
Quoted 13 lines
Quoted 13 lines
return tbl8_gindex;lib/librte_lpm/rte_lpm.c +2
-2@@ -410,46 +419,50 @@ tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) }static inline void -tbl8_free (struct rte_lpm_tbl8_entry *tbl8,uint32_t tbl8_group_start) +tbl8_free (struct rte_lpm_tbl_entry *tbl8,uint32_t tbl8_group_start) {/* Set tbl8 group invalid*/ - tbl8[tbl8_group_start].valid_group =INVALID ; + tbl8[tbl8_group_start].ext_valid =INVALID ; }Quoted 6 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 432
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +1
-1static inline int32_t add_depth_small (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t next_hop) +struct rte_lpm_res *res) { uint32_t tbl24_index, tbl24_range, tbl8_index, tbl8_group_end,i, j;
Quoted 16 lines
Quoted 16 lines
lib/librte_lpm/rte_lpm.c +11
-0/* Calculate the index into Table24. */ tbl24_index = ip >>8 ; tbl24_range =depth_to_range (depth); +struct rte_lpm_tbl_entry new_tbl_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = res->as_num, +#endif + .next_hop = res->next_hop, + .fwd_class = res->fwd_class, + .ext_valid =0 , + .depth = depth, + .valid =VALID , + }; +Quoted 3 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 450
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++) {/* * For invalid OR valid and non-extended tbl 24 entries set
Quoted 3 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 433
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-1* entry. */ - if (!lpm->tbl24[i].valid || (lpm->tbl24[i].ext_entry== 0 &&
Quoted 1 line
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 453
Quoted 1 line
lib/librte_lpm/rte_lpm.c +1
-0+ if (!lpm->tbl24[i].valid || (lpm->tbl24[i].ext_valid== 0 &&
Quoted 15 lines
Quoted 15 lines
lib/librte_lpm/rte_lpm.c +1
-8lpm->tbl24[i].depth <= depth)) { -struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .next_hop = next_hop, }, - .valid =VALID , - .ext_entry =0 , - .depth = depth, - }; -/* Setting tbl24 entry in one go to avoid race * conditions */ - lpm->tbl24[i] = new_tbl24_entry; + lpm->tbl24[i] = new_tbl_entry;Quoted 6 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 465
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +1
-1continue ; } -if (lpm->tbl24[i].ext_entry ==1 ) { +if (lpm->tbl24[i].ext_valid ==1 ) {/* If tbl24 entry is valid and extended calculate
Quoted 19 lines
lib/librte_lpm/rte_lpm.c add_depth_small(struct rte_lpm *lpm, uint32_t
Quoted 4 lines
the
* index into tbl8.
*/lib/librte_lpm/rte_lpm.c +0
-0@@ -461,19 +474,14 @@ add_depth_small(struct rte_lpm *lpm, uint32_tip,
Quoted 14 lines
lib/librte_lpm/rte_lpm.c +2
-7uint8_t depth, for (j = tbl8_index; j < tbl8_group_end; j++) {if (!lpm->tbl8[j].valid || lpm->tbl8[j].depth <= depth) { -struct rte_lpm_tbl8_entry - new_tbl8_entry = { - .valid =VALID , - .valid_group =VALID , - .depth = depth, - .next_hop = next_hop, - }; + + new_tbl_entry.ext_valid =VALID;
Quoted 3 lines
lib/librte_lpm/rte_lpm.c add_depth_small(struct rte_lpm *lpm, uint32_t · line 482
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0/* * Setting tbl8 entry in one go to
Quoted 11 lines
Quoted 11 lines
avoid
* race conditions */lib/librte_lpm/rte_lpm.c +1
-1- lpm->tbl8[j] = new_tbl8_entry; + lpm->tbl8[j] = new_tbl_entry;continue ; }@@ -486,7 +494,7 @@ add_depth_small(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,Quoted 13 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t
Quoted 9 lines
lib/librte_lpm/rte_lpm.c +1
-1static inline int32_t add_depth_big (struct rte_lpm *lpm,uint32_t ip_masked,uint8_t depth, -uint8_t next_hop) +struct rte_lpm_res *res) {uint32_t tbl24_index;int32_t tbl8_group_index, tbl8_group_start, tbl8_group_end,
tbl8_index,lib/librte_lpm/rte_lpm.c +0
-0@@ -512,7 +520,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth,/* Set tbl8 entry. */ for (i = tbl8_index; i < (tbl8_index + tbl8_range);i++) {
Quoted 35 lines
Quoted 35 lines
lib/librte_lpm/rte_lpm.c +9
-5lpm->tbl8[i].depth = depth; - lpm->tbl8[i].next_hop = next_hop; + lpm->tbl8[i].next_hop = res->next_hop; + lpm->tbl8[i].fwd_class = res->fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->tbl8[i].as_num = res->as_num; +#endif lpm->tbl8[i].valid =VALID ; }@@ -522,17 +534,17 @@ add_depth_big(struct rte_lpm *lpm, uint32_tip_masked, uint8_t depth, * so assign whole structure in one go */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .tbl8_gindex = (uint8_t )tbl8_group_index, }, - .valid =VALID , - .ext_entry =1 , +struct rte_lpm_tbl_entry new_tbl24_entry = { + .tbl8_gindex = (uint16_t )tbl8_group_index, .depth =0 , + .ext_valid =1 , + .valid =VALID , }; lpm->tbl24[tbl24_index] = new_tbl24_entry; }/* If valid entry but not extended calculate the index into Table8. */
lib/librte_lpm/rte_lpm.c +1
-1-else if (lpm->tbl24[tbl24_index].ext_entry ==0 ) { +else if (lpm->tbl24[tbl24_index].ext_valid ==0 ) {/* Search for free tbl8 group. */ tbl8_group_index =tbl8_alloc (lpm->tbl8);Quoted 4 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-0@@ -551,6 +563,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth, lpm->tbl8[i].depth =lpm->tbl24[tbl24_index].depth;
Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 566
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-0lpm->tbl8[i].next_hop =lpm->tbl24[tbl24_index].next_hop;
Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 568
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+ lpm->tbl8[i].fwd_class = +lpm->tbl24[tbl24_index].fwd_class;
Quoted 6 lines
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +3
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->tbl8[i].as_num = lpm->tbl24[tbl24_index].as_num; +#endif }Quoted 10 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t
Quoted 2 lines
tbl8_index = tbl8_group_start + (ip_masked & 0xFF);lib/librte_lpm/rte_lpm.c +0
-0@@ -561,7 +578,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 7 lines
lib/librte_lpm/rte_lpm.c +2
-1uint8_t depth, lpm->tbl8[i].depth <= depth) { lpm->tbl8[i].valid = VALID; lpm->tbl8[i].depth = depth; - lpm->tbl8[i].next_hop = next_hop; + lpm->tbl8[i].next_hop = res->next_hop; + lpm->tbl8[i].fwd_class =
res->fwd_class;Quoted 11 lines
Quoted 11 lines
lib/librte_lpm/rte_lpm.c +3
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->tbl8[i].as_num = res->as_num; +#endif continue ;}lib/librte_lpm/rte_lpm.c +0
-0@@ -573,11 +594,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_tip_masked, uint8_t depth, * so assign whole structure in one go. */ Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 578
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-2-struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .tbl8_gindex =(uint8_t)tbl8_group_index,
Quoted 5 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 600
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +2
-2}, - .valid = VALID, - .ext_entry = 1, + struct rte_lpm_tbl_entry new_tbl24_entry = { + .tbl8_gindex =(uint16_t)tbl8_group_index,
Quoted 5 lines
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +2
-0.depth = 0, + .ext_valid = 1, + .valid = VALID, };Quoted 7 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 599
Quoted 7 lines
lpm->tbl24[tbl24_index] = new_tbl24_entry;lib/librte_lpm/rte_lpm.c +0
-1@@ -595,11 +616,15 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, if (!lpm->tbl8[i].valid || lpm->tbl8[i].depth <= depth) { -struct rte_lpm_tbl8_entry
new_tbl8_entry= {Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 620
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +1
-1- .valid = VALID, +struct rte_lpm_tbl_entry
new_tbl8_entry= {Quoted 10 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 628
Quoted 10 lines
lib/librte_lpm/rte_lpm.c +6
-2+#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = res->as_num, +#endif + .next_hop = res->next_hop, + .fwd_class = res->fwd_class, .depth = depth, - .next_hop = next_hop, - .valid_group = lpm->tbl8[i].valid_group, + .ext_valid =lpm->tbl8[i].ext_valid,
Quoted 15 lines
Quoted 15 lines
lib/librte_lpm/rte_lpm.c +1
-0+ .valid = VALID, };/*lib/librte_lpm/rte_lpm.c +1
-1@@ -621,19 +646,19 @@ add_depth_big(struct rte_lpm *lpm, uint32_tip_masked, uint8_t depth, */ int rte_lpm_add (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t next_hop) +struct rte_lpm_res *res) {int32_t rule_index, status =0 ;uint32_t ip_masked;Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 631
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-1/* Check user arguments. */ - if ((lpm == NULL) || (depth < 1) || (depth >
RTE_LPM_MAX_DEPTH))Quoted 6 lines
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +1
-0+if ((lpm ==NULL ) || (res ==NULL ) || (depth <1 ) || (depth >RTE_LPM_MAX_DEPTH ))return -EINVAL ; ip_masked = ip &depth_to_mask (depth);Quoted 13 lines
lib/librte_lpm/rte_lpm.c rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
Quoted 7 lines
lib/librte_lpm/rte_lpm.c +1
-1/* Add the rule to the rule table. */ - rule_index =rule_add (lpm, ip_masked, depth, next_hop); + rule_index =rule_add (lpm, ip_masked, depth, res);/* If the is no space available for new rule return error. */ if (rule_index < 0) {lib/librte_lpm/rte_lpm.c +0
-0@@ -641,10 +666,10 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
uint8_tQuoted 5 lines
lib/librte_lpm/rte_lpm.c +0
-1depth, }if (depth <=MAX_DEPTH_TBL24 ) { - status = add_depth_small(lpm, ip_masked, depth,
next_hop);Quoted 4 lines
lib/librte_lpm/rte_lpm.c rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, · line 648
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +1
-1+ status =add_depth_small (lpm, ip_masked, depth, res); }else {/* If depth > RTE_LPM_MAX_DEPTH_TBL24 */ - status = add_depth_big(lpm, ip_masked, depth,
next_hop);Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +1
-0+ status =add_depth_big (lpm, ip_masked, depth, res);/* * If add fails due to exhaustion of tbl8 extensions
delete
Quoted 6 lines
lib/librte_lpm/rte_lpm.c rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-0@@ -665,14 +690,14 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
uint8_tQuoted 4 lines
lib/librte_lpm/rte_lpm.c +0
-0depth, */ int rte_lpm_is_rule_present(struct rte_lpm *lpm, uint32_t ip, uint8_tdepth,
Quoted 26 lines
Quoted 26 lines
lib/librte_lpm/rte_lpm.c +7
-3-uint8_t *next_hop) + struct rte_lpm_res *res) {uint32_t ip_masked;int32_t rule_index;/* Check user arguments. */ if ((lpm ==NULL ) || - (next_hop ==NULL ) || + (res ==NULL ) || (depth <1 ) || (depth >RTE_LPM_MAX_DEPTH ))return -EINVAL ;@@ -681,7 +706,11 @@ uint8_t *next_hop) rule_index =rule_find (lpm, ip_masked, depth);if (rule_index >=0 ) { - *next_hop = lpm->rules_tbl[rule_index].next_hop; + res->next_hop = lpm->rules_tbl[rule_index].next_hop; + res->fwd_class = lpm->rules_tbl[rule_index].fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + res->as_num = lpm->rules_tbl[rule_index].as_num; +#endif return 1 ; }Quoted 4 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, uint32_t · line 762
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +0
-0@@ -731,7 +760,7 @@ delete_depth_small(struct rte_lpm *lpm, uint32_tip_masked, */ for (i = tbl24_index; i < (tbl24_index + tbl24_range);i++)
Quoted 5 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, uint32_t · line 766
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +1
-1{ -if (lpm->tbl24[i].ext_entry ==0 && +if (lpm->tbl24[i].ext_valid ==0 && lpm->tbl24[i].depth <= depth ){
Quoted 16 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm,
Quoted 3 lines
lpm->tbl24[i].valid = INVALID; }lib/librte_lpm/rte_lpm.c +0
-0@@ -761,23 +790,30 @@ delete_depth_small(struct rte_lpm *lpm,
uint32_tQuoted 12 lines
lib/librte_lpm/rte_lpm.c +3
-4ip_masked, * associated with this rule. */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - {.next_hop = lpm->rules_tbl[sub_rule_index].next_hop,}, - .valid =VALID , - .ext_entry =0 , + struct rte_lpm_tbl_entry new_tbl24_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num =lpm->rules_tbl[sub_rule_index].as_num,
Quoted 2 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 799
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+#endif + .next_hop =lpm->rules_tbl[sub_rule_index].next_hop,
Quoted 7 lines
Quoted 7 lines
lib/librte_lpm/rte_lpm.c +3
-0+ .fwd_class = lpm->rules_tbl[sub_rule_index].fwd_class, .depth = sub_rule_depth, + .ext_valid = 0, + .valid = VALID, };Quoted 5 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 809
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +3
-2-struct rte_lpm_tbl8_entry new_tbl8_entry = { - .valid =VALID , +struct rte_lpm_tbl_entry new_tbl8_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num =lpm->rules_tbl[sub_rule_index].as_num,
Quoted 2 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 811
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+#endif + .next_hop =lpm->rules_tbl[sub_rule_index].next_hop,
Quoted 9 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 818
Quoted 9 lines
lib/librte_lpm/rte_lpm.c +2
-2+ .fwd_class = lpm->rules_tbl[sub_rule_index].fwd_class, .depth = sub_rule_depth, - .next_hop = lpm->rules_tbl - [sub_rule_index].next_hop, + .valid = VALID, }; for (i = tbl24_index; i < (tbl24_index + tbl24_range);i++)
Quoted 5 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm,
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +1
-1{ -if (lpm->tbl24[i].ext_entry ==0 && +if (lpm->tbl24[i].ext_valid ==0 && lpm->tbl24[i].depth <= depth ){
Quoted 15 lines
Quoted 11 lines
lpm->tbl24[i] = new_tbl24_entry; }lib/librte_lpm/rte_lpm.c +1
-1@@ -814,7 +850,7 @@ delete_depth_small(struct rte_lpm *lpm, uint32_tip_masked, * thus can be recycled */ static inline int32_t -tbl8_recycle_check(struct rte_lpm_tbl8_entry *tbl8, uint32_t tbl8_group_start) +tbl8_recycle_check (struct rte_lpm_tbl_entry *tbl8,uint32_t tbl8_group_start)Quoted 3 lines
{
uint32_ttbl8_group_end, i;
tbl8_group_end=tbl8_group_start+
RTE_LPM_TBL8_GROUP_NUM_ENTRIES;Quoted 13 lines
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, uint32_t · line 934
Quoted 13 lines
lib/librte_lpm/rte_lpm.c +3
-4@@ -891,11 +927,15 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, } else { /* Set new tbl8 entry. */ -struct rte_lpm_tbl8_entry new_tbl8_entry = { - .valid =VALID , - .depth = sub_rule_depth, - .valid_group = lpm->tbl8[tbl8_group_start].valid_group, + struct rte_lpm_tbl_entry new_tbl8_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num =lpm->rules_tbl[sub_rule_index].as_num,
Quoted 4 lines
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, uint32_t · line 938
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +2
-0+#endif + .fwd_class = lpm->rules_tbl[sub_rule_index].fwd_class, .next_hop =lpm->rules_tbl[sub_rule_index].next_hop,
Quoted 2 lines
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, uint32_t · line 940
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+ .depth = sub_rule_depth, + .ext_valid =lpm->tbl8[tbl8_group_start].ext_valid,
Quoted 19 lines
Quoted 9 lines
lib/librte_lpm/rte_lpm.c +1
-0+ .valid = VALID,}; /*lib/librte_lpm/rte_lpm.c +0
-0@@ -923,11 +963,15 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, }else if (tbl8_recycle_index >-1 ) {/* Update tbl24 entry. */ lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, uint32_t · line 972
Quoted 10 lines
lib/librte_lpm/rte_lpm.c +5
-4-struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .next_hop = lpm->tbl8[tbl8_recycle_index].next_hop, }, - .valid =VALID , - .ext_entry =0 , +struct rte_lpm_tbl_entry new_tbl24_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = lpm->tbl8[tbl8_recycle_index].as_num, +#endif + .next_hop =lpm->tbl8[tbl8_recycle_index].next_hop,
Quoted 8 lines
Quoted 8 lines
lib/librte_lpm/rte_lpm.c +3
-0+ .fwd_class = lpm->tbl8[tbl8_recycle_index].fwd_class, .depth = lpm->tbl8[tbl8_recycle_index].depth, + .ext_valid = 0, + .valid = VALID,}; /* Set tbl24 before freeing tbl8 to avoid racecondition. */
Quoted 14 lines
lib/librte_lpm/rte_lpm.h line 31
Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0
-0@@ -31,8 +31,8 @@* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Quoted 7 lines
lib/librte_lpm/rte_lpm.h +2
-2*/ -#ifndef _RTE_LPM_H_ -#define _RTE_LPM_H_ +#ifndef _RTE_LPM_EXT_H_ +#define _RTE_LPM_EXT_H_Quoted 7 lines
lib/librte_lpm/rte_lpm.h extern "C" { · line 84
Quoted 7 lines
lib/librte_lpm/rte_lpm.h +0
-1/** * @file @@ -81,57 +81,58 @@ extern "C" {#define RTE_LPM_RETURN_IF_TRUE (cond, retval)#endif -/** @internal bitmask with valid and ext_entry/valid_group fields set */
Quoted 88 lines
Quoted 88 lines
lib/librte_lpm/rte_lpm.h +36
-34-#define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x0300 +/** @internal bitmask with valid and ext_valid/ext_valid fields set */ +#define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x03/** Bitmask used to indicate successful lookup */ -#define RTE_LPM_LOOKUP_SUCCESS 0x0100 +#define RTE_LPM_LOOKUP_SUCCESS 0x01 + +struct rte_lpm_res { +uint16_t next_hop; +uint8_t fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif +};#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. */ +struct rte_lpm_tbl_entry { +uint8_t valid :1 ; +uint8_t ext_valid :1 ; +uint8_t depth :6 ; +uint8_t fwd_class;union { -uint8_t next_hop; -uint8_t tbl8_gindex; +uint16_t next_hop; +uint16_t tbl8_gindex; }; -/* 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. */ -}; - -/** @internal Tbl8 entry structure. */ -struct rte_lpm_tbl8_entry { -uint8_t next_hop;/**< 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. */ +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif };#else -struct rte_lpm_tbl24_entry { -uint8_t depth :6 ; -uint8_t ext_entry :1 ; -uint8_t valid :1 ; +struct rte_lpm_tbl_entry { +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif union { -uint8_t tbl8_gindex; -uint8_t next_hop; +uint16_t tbl8_gindex; +uint16_t next_hop; }; -}; - -struct rte_lpm_tbl8_entry { -uint8_t depth :6 ; -uint8_t valid_group :1 ; -uint8_t valid :1 ; -uint8_t next_hop; +uint8_t fwd_class; +uint8_t depth :6 ; +uint8_t ext_valid :1 ; +uint8_t valid :1 ; };#endif /** @internal Rule structure. */ struct rte_lpm_rule {uint32_t ip;/**< Rule IP address. */ -uint8_t next_hop;/**< Rule next hop. */ +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif +uint16_t next_hop;/**< Rule next hop. */ +uint8_t fwd_class; };Quoted 3 lines
lib/librte_lpm/rte_lpm.h struct rte_lpm { · line 149
Quoted 3 lines
lib/librte_lpm/rte_lpm.h +0
-0/** @internal Contains metadata about the rules table. */ @@ -148,9 +149,9 @@ struct rte_lpm {struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH ];/**< Rule
Quoted 20 lines
Quoted 20 lines
info table. */
/* LPM Tables. */lib/librte_lpm/rte_lpm.h +3
-3- struct rte_lpm_tbl24_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] \ + struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] \ __rte_cache_aligned;/**< LPM tbl24 table. */ - struct rte_lpm_tbl8_entry tbl8[RTE_LPM_TBL8_NUM_ENTRIES] \ + struct rte_lpm_tbl_entry tbl8[RTE_LPM_TBL8_NUM_ENTRIES] \ __rte_cache_aligned;/**< LPM tbl8 table. */ struct rte_lpm_rule rules_tbl[0] \ __rte_cache_aligned;/**< LPM rules. */ @@ -219,7 +220,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, struct rte_lpm_res *res);Quoted 8 lines
lib/librte_lpm/rte_lpm.h rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
Quoted 3 lines
/**
* Check if a rule is present in the LPM table,lib/librte_lpm/rte_lpm.h +0
-0@@ -238,7 +239,7 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
uint8_tQuoted 4 lines
lib/librte_lpm/rte_lpm.h +0
-0depth, uint8_t next_hop); */ int rte_lpm_is_rule_present(struct rte_lpm *lpm, uint32_t ip, uint8_tdepth,
Quoted 7 lines
lib/librte_lpm/rte_lpm.h rte_lpm_delete_all(struct rte_lpm *lpm); · line 278
Quoted 7 lines
lib/librte_lpm/rte_lpm.h +1
-1-uint8_t *next_hop); + struct rte_lpm_res *res);/** * Delete a rule from the LPM table.
lib/librte_lpm/rte_lpm.h +0
-0@@ -277,29 +278,43 @@ rte_lpm_delete_all(struct rte_lpm *lpm);* -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup
Quoted 5 lines
lib/librte_lpm/rte_lpm.h
Quoted 5 lines
hit
*/
static inline intlib/librte_lpm/rte_lpm.h +1
-1-rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint8_t *next_hop) +rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, struct rte_lpm_res*res)
Quoted 33 lines
lib/librte_lpm/rte_lpm.h
Quoted 13 lines
{ unsigned tbl24_index = (ip >> 8);lib/librte_lpm/rte_lpm.h +6
-4-uint16_t tbl_entry; - +#ifdef RTE_LIBRTE_LPM_ASNUM +uint64_t tbl_entry; +#else +uint32_t tbl_entry; +#endif /* DEBUG: Check user input arguments. */ -RTE_LPM_RETURN_IF_TRUE (((lpm ==NULL ) || (next_hop ==NULL )), -EINVAL ); + RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (res == NULL)), -EINVAL);
Quoted 19 lines
/* Copy tbl24 entry */lib/librte_lpm/rte_lpm.h +5
-3- tbl_entry = *(const uint16_t *)&lpm->tbl24[tbl24_index]; - +#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t *)&lpm->tbl24[tbl24_index]; +#else + tbl_entry = *(const uint32_t *)&lpm->tbl24[tbl24_index]; +#endif /* Copy tbl8 entry (only if needed) */ if (unlikely ((tbl_entry &RTE_LPM_VALID_EXT_ENTRY_BITMASK ) ==RTE_LPM_VALID_EXT_ENTRY_BITMASK )) { unsigned tbl8_index = (uint8_t)ip + - ((uint8_t)tbl_entry *
RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
+ ((*(structrte_lpm_tbl_entry
*)&tbl_entry).tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES);Quoted 10 lines
lib/librte_lpm/rte_lpm.h
Quoted 10 lines
lib/librte_lpm/rte_lpm.h +6
-3- tbl_entry = *(const uint16_t *)&lpm->tbl8[tbl8_index]; +#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t *)&lpm->tbl8[tbl8_index]; +#else + tbl_entry = *(const uint32_t *)&lpm->tbl8[tbl8_index]; +#endif } - - *next_hop = (uint8_t )tbl_entry; + res->next_hop = ((struct rte_lpm_tbl_entry*)&tbl_entry)->next_hop;
Quoted 21 lines
Quoted 21 lines
+
res->fwd_class= ((structrte_lpm_tbl_entry
*)&tbl_entry)->fwd_class;lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + res->as_num = ((struct rte_lpm_tbl_entry*)&tbl_entry)->as_num;
lib/librte_lpm/rte_lpm.h +4
-2+#endif return (tbl_entry &RTE_LPM_LOOKUP_SUCCESS ) ?0 : -ENOENT ; + }/** @@ -322,19 +337,25 @@ rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip,uint8_t *next_hop) * @return * -EINVAL for incorrect arguments, otherwise 0 */ -#define rte_lpm_lookup_bulk (lpm, ips, next_hops, n) \ - rte_lpm_lookup_bulk_func(lpm, ips, next_hops, n) +#define rte_lpm_lookup_bulk (lpm, ips, res_tbl, n) \ + rte_lpm_lookup_bulk_func(lpm, ips, res_tbl, n)Quoted 2 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, · line 330
Quoted 2 lines
lib/librte_lpm/rte_lpm.h +0
-1static inline int -rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t *ips,
Quoted 2 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, · line 345
Quoted 2 lines
lib/librte_lpm/rte_lpm.h +1
-1- uint16_t * next_hops, const unsigned n) +rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t*ips,
Quoted 31 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookup_bulk_func(const struct rte_lpm
Quoted 19 lines
lib/librte_lpm/rte_lpm.h +8
-1+ struct rte_lpm_res *res_tbl, const unsigned n) { unsigned i; +int ret =0 ; +#ifdef RTE_LIBRTE_LPM_ASNUM +uint64_t tbl_entry; +#else +uint32_t tbl_entry; +#endif unsigned tbl24_indexes[n];/* DEBUG: Check user input arguments. */ RTE_LPM_RETURN_IF_TRUE (((lpm ==NULL ) || (ips ==NULL ) || - (next_hops ==NULL )), -EINVAL ); + (res_tbl ==NULL )), -EINVAL );for (i =0 ; i < n; i++) {tbl24_indexes[i] = ips[i] >> 8;lib/librte_lpm/rte_lpm.h +0
-0@@ -342,20 +363,32 @@ rte_lpm_lookup_bulk_func(const struct rte_lpm*lpm,
Quoted 11 lines
lib/librte_lpm/rte_lpm.h +3
-2const uint32_t * ips, for (i = 0; i < n; i++) {/* Simply copy tbl24 entry to output */ - next_hops[i] = *(const uint16_t *)&lpm->tbl24[tbl24_indexes[i]]; - +#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t *)&lpm->tbl24[tbl24_indexes[i]]; +#else Quoted 8 lines
lib/librte_lpm/rte_lpm.h
Quoted 8 lines
lib/librte_lpm/rte_lpm.h +2
-1+ tbl_entry = *(const uint32_t *)&lpm->tbl24[tbl24_indexes[i]]; +#endif /* Overwrite output with tbl8 entry if needed */ - if (unlikely((next_hops[i] &
RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==lib/librte_lpm/rte_lpm.h +1
-1- RTE_LPM_VALID_EXT_ENTRY_BITMASK)) { + if (unlikely((tbl_entry &
RTE_LPM_VALID_EXT_ENTRY_BITMASK)Quoted 6 lines
lib/librte_lpm/rte_lpm.h
Quoted 6 lines
==
lib/librte_lpm/rte_lpm.h +1
-2+ RTE_LPM_VALID_EXT_ENTRY_BITMASK)) { unsigned tbl8_index = (uint8_t)ips[i] + - ((uint8_t)next_hops[i] * -
RTE_LPM_TBL8_GROUP_NUM_ENTRIES);Quoted 27 lines
Quoted 27 lines
+ ((*(struct
rte_lpm_tbl_entry
*)&tbl_entry).tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES);- next_hops[i] = *(const
uint16_t
*)&lpm->tbl8[tbl8_index];lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t*)&lpm->tbl8[tbl8_index];
lib/librte_lpm/rte_lpm.h +2
-0+#else + tbl_entry = *(const uint32_t*)&lpm->tbl8[tbl8_index];
lib/librte_lpm/rte_lpm.h +2
-0+#endif } + res_tbl[i].next_hop = ((struct rte_lpm_tbl_entry*)&tbl_entry)->next_hop;
+ res_tbl[i].fwd_class = ((structrte_lpm_tbl_entry
*)&tbl_entry)->next_hop;lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + res_tbl[i].as_num = ((struct rte_lpm_tbl_entry*)&tbl_entry)->as_num;
lib/librte_lpm/rte_lpm.h +3
-1+#endif + ret |=1 << i; } -return 0 ; +return ret; }Quoted 19 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookupx4(const struct rte_lpm *lpm,
Quoted 2 lines
/* Mask four results. */
lib/librte_lpm/rte_lpm.h +0
-0@@ -477,4 +510,4 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm,
__m128iip,Quoted 16 lines
lib/librte_lpm/rte_lpm.h +1
-1uint16_t hop[4], }#endif -#endif /* _RTE_LPM_H_ */ +#endif /* _RTE_LPM_EXT_H_ */ 2015-10-24 9:09 GMT+03:00 Matthew Hall <[email protected]>:
Quoted 7 lines · Matthew Hall
Quoted 6 lines · Michal Jastrzebski
Quoted 4 lines
From: Michal Kobylinski <[email protected]>
The current DPDK implementation for LPM for IPv4 and IPv6 limits
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
number of next hops to 256, as the next hop ID is an 8-bit long
field.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Proposed extension increase number of next hops for IPv4 to 2^24
and
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
also allows 32-bits read/write operations.
This patchset requires additional change to
rte_tablelibrary tomeet
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 2 lines
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
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
part of a job. My patchset is attached to this email.
One possible advantage with my patchset, compared to others, is that
the
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
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
Quoted 4 lines
as
Quoted 3 lines
Quoted 3 lines
humanly possible.
This is because my application code is green-field, so I absolutely
don't
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
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_lpmas some ofthe
Quoted 1 line
Quoted 1 line
Quoted 1 line
full-time guys, but I think with four or five of us in the thread
hammering
Quoted 1 line
Quoted 1 line
Quoted 1 line
out patches we will be able to create something amazing together and
I
Quoted 6 lines
am
Quoted 4 lines
Quoted 4 lines
very very very very very happy about this.
Matthew.
Hi Vladimir,
Thanks for sharing Your implementation.
Could You please clarify whatas_numandfwd_classfields represent? The second issue I have is that Your patch doesn’t want to apply on top of current head. Could You check this please?Best regards
Michal
Quoted 57 lines · Vladimir Medvedkin
Hi Michal,
Forwarding class can help us to classify traffic based on dst prefix, it's something like Juniper DCU. For example on Juniper MX I can make policy that install prefix into the FIB with some class and use it on dataplane, for example with ACL.
On Juniper MX I can make something like that:
#show policy-options
policy-statement community-to-class {term customer { from community originate-customer; then destination-class customer; } } community originate-customer members 12345:11111; # show routing-options forwarding-table { export community-to-class; } # show forwarding-options forwarding-options { family inet { filter { output test-filter; } } } # show firewall family inet filter test-filter term 1 { from { protocol icmp; destination-class customer; } then { discard; } } announce route 10.10.10.10/32 next-hop 10.10.10.2 community 12345:11111 After than on dataplane we have NPC1( vty)# show route ip lookup 10.10.10.10 Route Information (10.10.10.10): interface : xe-1/0/0.0 (328) Nexthop prefix : - Nexthop ID : 1048574 MTU : 0 Class ID : 129 <- That is "forwarding class" in my implementation This construction discards all ICMP traffic that goes to dst prefixes which was originated with community 12345:11111. With this mechanism we can make on control plane different sophisticated policy to control traffic on dataplane. The same with as_num, we can have on dataplane AS number that has originated that prefix, or another 4-byte number e.g. geo-id. What issue do you mean? I think it is because of table/pipeline/test frameworks that doesen't want to compile due to changing API/ABI. You can turn it off for LPM testing, if my patch will be applied I will make changes in above-mentioned frameworks.
Quoted 2 lines
Regards,
Vladimir
Hi Vladimir,
I have an issue with applying Your patch not compilation. This is the error i get:
Checking patch config/common_bsdapp...
Checking patch config/common_linuxapp... Checking patch lib/librte_lpm/rte_lpm.c...
error: while searching for:
lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl24_entry) != 2);
RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl8_entry) != 2);
/* Check user arguments. */
if ((name == NULL) || (socket_id < -1) || (max_rules == 0)){
rte_errno = EINVAL;error: patch failed: lib/librte_lpm/rte_lpm.c:159
error: lib/librte_lpm/rte_lpm.c: patch does not apply Checking patch lib/librte_lpm/rte_lpm.h...
error: while searching for:
#define RTE_LPM_RETURN_IF_TRUE(cond, retval) #endif
/** @internal bitmask with valid and ext_entry/valid_group fields set */ #define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x0300
/** Bitmask used to indicate successful lookup */
#define RTE_LPM_LOOKUP_SUCCESS 0x0100
#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. */
union {
uint8_t next_hop;
uint8_t tbl8_gindex;
};
/* 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. */
};/** @internal Tbl8 entry structure. */
struct rte_lpm_tbl8_entry {
uint8_t next_hop; /**< 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. */
};
#else
struct rte_lpm_tbl24_entry {
uint8_t depth :6;
uint8_t ext_entry :1;
uint8_t valid :1;
union {
uint8_t tbl8_gindex;
uint8_t next_hop;
};
};struct rte_lpm_tbl8_entry {
uint8_t depth :6;
uint8_t valid_group :1;
uint8_t valid :1;
uint8_t next_hop;
};#endif
/** @internal Rule structure. */
struct rte_lpm_rule {
uint32_t ip; /**< Rule IP address. */
uint8_t next_hop; /**< Rule next hop. */
};/** @internal Contains metadata about the rules table. */
error: patch failed: lib/librte_lpm/rte_lpm.h:81
error: lib/librte_lpm/rte_lpm.h: patch does not apply
Quoted 966 lines
2015-10-26 14:57 GMT+03:00 Jastrzebski, MichalX K < [email protected]>:
Quoted 963 lines
Quoted 69 lines
-----Original Message-----
From: Michal Jastrzebski [mailto:[email protected]]
Sent: Monday, October 26, 2015 12:55 PM
To: Vladimir Medvedkin
Subject: Re: [dpdk-dev] [PATCH v1 0/3] lpm: increase number of next hops for lpm (ipv4)lib/librte_lpm/rte_lpm.c rte_lpm_create(const char *name, int socket_id,
Quoted 42 lines · Vladimir Medvedkin
Hi all,
Here my implementation
Signed-off-by Vladimir Medvedkin <[email protected]>--- config/common_bsdapp | 1 + config/common_linuxapp | 1 + lib/librte_lpm/rte_lpm.c | 194 +++++++++++++++++++++++++++++------------------ lib/librte_lpm/rte_lpm.h | 163 +++++++++++++++++++++++---------------- 4 files changed, 219 insertions(+), 140 deletions(-)config/common_bsdapp +1
-0@@ -344,6 +344,7 @@ CONFIG_RTE_LIBRTE_JOBSTATS=y # CONFIG_RTE_LIBRTE_LPM=y CONFIG_RTE_LIBRTE_LPM_DEBUG=n +CONFIG_RTE_LIBRTE_LPM_ASNUM=n # # Compile librte_aclconfig/common_linuxapp +1
-0@@ -352,6 +352,7 @@ CONFIG_RTE_LIBRTE_JOBSTATS=y # CONFIG_RTE_LIBRTE_LPM=y CONFIG_RTE_LIBRTE_LPM_DEBUG=n +CONFIG_RTE_LIBRTE_LPM_ASNUM=n # # Compile librte_acllib/librte_lpm/rte_lpm.c +0
-0@@ -159,9 +159,11 @@ rte_lpm_create(const char *name, int socket_id,int
Quoted 18 lines
lib/librte_lpm/rte_lpm.c +5
-3max_rules, lpm_list =RTE_TAILQ_CAST (rte_lpm_tailq.head, rte_lpm_list); -RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl24_entry ) !=2 ); -RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl8_entry ) !=2 ); - +#ifdef RTE_LIBRTE_LPM_ASNUM +RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl_entry ) !=8 ); +#else +RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl_entry ) !=4 ); +#endif /* Check user arguments. */ if ((name ==NULL ) || (socket_id <-1 ) || (max_rules ==0 )){rte_errno = EINVAL;lib/librte_lpm/rte_lpm.c +0
-0@@ -261,7 +263,7 @@ rte_lpm_free(struct rte_lpm *lpm)*/ static inline int32_tQuoted 11 lines
lib/librte_lpm/rte_lpm.c rule_add(struct rte_lpm *lpm, uint32_t
Quoted 7 lines
lib/librte_lpm/rte_lpm.c +1
-1rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, - uint8_t next_hop) + struct rte_lpm_res *res) { uint32_t rule_gindex, rule_index, last_rule;int i;@@ -282,8 +284,11 @@ rule_add(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth,/* If rule already exists update its next_hop and
Quoted 2 lines
Quoted 2 lines
return. */
if (lpm->rules_tbl[rule_index].ip ==
ip_masked) {Quoted 42 lines
lib/librte_lpm/rte_lpm.c rule_add(struct rte_lpm *lpm, uint32_t
Quoted 15 lines
- lpm->rules_tbl[rule_index].next_hop =
next_hop;lib/librte_lpm/rte_lpm.c +1
-1- + lpm->rules_tbl[rule_index].next_hop =
res->next_hop;
+ lpm->rules_tbl[rule_index].fwd_class =res->fwd_class;lib/librte_lpm/rte_lpm.c +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->rules_tbl[rule_index].as_num =
res->as_num;lib/librte_lpm/rte_lpm.c +1
-0+#endif return rule_index; } }@@ -320,7 +325,11 @@ rule_add(struct rte_lpm *lpm, uint32_t
ip_masked,lib/librte_lpm/rte_lpm.c rule_find(struct rte_lpm *lpm, uint32_t
Quoted 14 lines
lib/librte_lpm/rte_lpm.c +5
-1uint8_t depth,/* Add the new rule. */ lpm->rules_tbl[rule_index].ip = ip_masked; - lpm->rules_tbl[rule_index].next_hop = next_hop; + lpm->rules_tbl[rule_index].next_hop = res->next_hop; + lpm->rules_tbl[rule_index].fwd_class = res->fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->rules_tbl[rule_index].as_num = res->as_num; +#endif /* Increment the used rules counter for this rule group. */ lpm->rule_info[depth - 1].used_rules++;lib/librte_lpm/rte_lpm.c +0
-0@@ -382,10 +391,10 @@ rule_find(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 11 lines
lib/librte_lpm/rte_lpm.c +2
-2uint8_t depth) * Find, clean and allocate a tbl8. */ static inline int32_t -tbl8_alloc (struct rte_lpm_tbl8_entry *tbl8) +tbl8_alloc (struct rte_lpm_tbl_entry *tbl8) {uint32_t tbl8_gindex;/* tbl8 group index. */ -struct rte_lpm_tbl8_entry *tbl8_entry; +struct rte_lpm_tbl_entry *tbl8_entry;Quoted 1 line
lib/librte_lpm/rte_lpm.c rule_find(struct rte_lpm *lpm, uint32_t · line 400
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-0/* Scan through tbl8 to find a free (i.e. INVALID) tbl8 group. */
Quoted 5 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 404
Quoted 5 lines
for (tbl8_gindex = 0; tbl8_gindex < RTE_LPM_TBL8_NUM_GROUPS;lib/librte_lpm/rte_lpm.c +0
-0@@ -393,12 +402,12 @@ tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) tbl8_entry = &tbl8[tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES ];/* If a free tbl8 group is found clean it and set as VALID.
Quoted 5 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 408
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +1
-1*/ -if (!tbl8_entry->valid_group) { +if (!tbl8_entry->ext_valid) {memset (&tbl8_entry[0 ],0 , RTE_LPM_TBL8_GROUP_NUM_ENTRIES*
Quoted 6 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 413
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +1
-1sizeof(tbl8_entry[0])); - tbl8_entry->valid_group =VALID ; + tbl8_entry->ext_valid =VALID ;/* Return group index for allocated tbl8 group. */
Quoted 13 lines
Quoted 13 lines
return tbl8_gindex;lib/librte_lpm/rte_lpm.c +2
-2@@ -410,46 +419,50 @@ tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) }static inline void -tbl8_free (struct rte_lpm_tbl8_entry *tbl8,uint32_t tbl8_group_start) +tbl8_free (struct rte_lpm_tbl_entry *tbl8,uint32_t tbl8_group_start) {/* Set tbl8 group invalid*/ - tbl8[tbl8_group_start].valid_group =INVALID ; + tbl8[tbl8_group_start].ext_valid =INVALID ; }Quoted 6 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 432
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +1
-1static inline int32_t add_depth_small (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t next_hop) +struct rte_lpm_res *res) { uint32_t tbl24_index, tbl24_range, tbl8_index, tbl8_group_end,i, j;
Quoted 16 lines
Quoted 16 lines
lib/librte_lpm/rte_lpm.c +11
-0/* Calculate the index into Table24. */ tbl24_index = ip >>8 ; tbl24_range =depth_to_range (depth); +struct rte_lpm_tbl_entry new_tbl_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = res->as_num, +#endif + .next_hop = res->next_hop, + .fwd_class = res->fwd_class, + .ext_valid =0 , + .depth = depth, + .valid =VALID , + }; +Quoted 3 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 450
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++) {/* * For invalid OR valid and non-extended tbl 24 entries set
Quoted 3 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 433
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-1* entry. */ - if (!lpm->tbl24[i].valid || (lpm->tbl24[i].ext_entry== 0 &&
Quoted 1 line
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 453
Quoted 1 line
lib/librte_lpm/rte_lpm.c +1
-0+ if (!lpm->tbl24[i].valid || (lpm->tbl24[i].ext_valid== 0 &&
Quoted 15 lines
Quoted 15 lines
lib/librte_lpm/rte_lpm.c +1
-8lpm->tbl24[i].depth <= depth)) { -struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .next_hop = next_hop, }, - .valid =VALID , - .ext_entry =0 , - .depth = depth, - }; -/* Setting tbl24 entry in one go to avoid race * conditions */ - lpm->tbl24[i] = new_tbl24_entry; + lpm->tbl24[i] = new_tbl_entry;Quoted 6 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 465
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +1
-1continue ; } -if (lpm->tbl24[i].ext_entry ==1 ) { +if (lpm->tbl24[i].ext_valid ==1 ) {/* If tbl24 entry is valid and extended calculate
Quoted 19 lines
lib/librte_lpm/rte_lpm.c add_depth_small(struct rte_lpm *lpm, uint32_t
Quoted 4 lines
the
* index into tbl8.
*/lib/librte_lpm/rte_lpm.c +0
-0@@ -461,19 +474,14 @@ add_depth_small(struct rte_lpm *lpm, uint32_tip,
Quoted 14 lines
lib/librte_lpm/rte_lpm.c +2
-7uint8_t depth, for (j = tbl8_index; j < tbl8_group_end; j++) {if (!lpm->tbl8[j].valid || lpm->tbl8[j].depth <= depth) { -struct rte_lpm_tbl8_entry - new_tbl8_entry = { - .valid =VALID , - .valid_group =VALID , - .depth = depth, - .next_hop = next_hop, - }; + + new_tbl_entry.ext_valid =VALID;
Quoted 3 lines
lib/librte_lpm/rte_lpm.c add_depth_small(struct rte_lpm *lpm, uint32_t · line 482
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0/* * Setting tbl8 entry in one go to
Quoted 11 lines
Quoted 11 lines
avoid
* race conditions */lib/librte_lpm/rte_lpm.c +1
-1- lpm->tbl8[j] = new_tbl8_entry; + lpm->tbl8[j] = new_tbl_entry;continue ; }@@ -486,7 +494,7 @@ add_depth_small(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,Quoted 13 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t
Quoted 9 lines
lib/librte_lpm/rte_lpm.c +1
-1static inline int32_t add_depth_big (struct rte_lpm *lpm,uint32_t ip_masked,uint8_t depth, -uint8_t next_hop) +struct rte_lpm_res *res) {uint32_t tbl24_index;int32_t tbl8_group_index, tbl8_group_start, tbl8_group_end,
tbl8_index,lib/librte_lpm/rte_lpm.c +0
-0@@ -512,7 +520,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth,/* Set tbl8 entry. */ for (i = tbl8_index; i < (tbl8_index + tbl8_range);i++) {
Quoted 35 lines
Quoted 35 lines
lib/librte_lpm/rte_lpm.c +9
-5lpm->tbl8[i].depth = depth; - lpm->tbl8[i].next_hop = next_hop; + lpm->tbl8[i].next_hop = res->next_hop; + lpm->tbl8[i].fwd_class = res->fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->tbl8[i].as_num = res->as_num; +#endif lpm->tbl8[i].valid =VALID ; }@@ -522,17 +534,17 @@ add_depth_big(struct rte_lpm *lpm, uint32_tip_masked, uint8_t depth, * so assign whole structure in one go */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .tbl8_gindex = (uint8_t )tbl8_group_index, }, - .valid =VALID , - .ext_entry =1 , +struct rte_lpm_tbl_entry new_tbl24_entry = { + .tbl8_gindex = (uint16_t )tbl8_group_index, .depth =0 , + .ext_valid =1 , + .valid =VALID , }; lpm->tbl24[tbl24_index] = new_tbl24_entry; }/* If valid entry but not extended calculate the index into Table8. */
lib/librte_lpm/rte_lpm.c +1
-1-else if (lpm->tbl24[tbl24_index].ext_entry ==0 ) { +else if (lpm->tbl24[tbl24_index].ext_valid ==0 ) {/* Search for free tbl8 group. */ tbl8_group_index =tbl8_alloc (lpm->tbl8);Quoted 4 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-0@@ -551,6 +563,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth, lpm->tbl8[i].depth =lpm->tbl24[tbl24_index].depth;
Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 566
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-0lpm->tbl8[i].next_hop =lpm->tbl24[tbl24_index].next_hop;
Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 568
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+ lpm->tbl8[i].fwd_class = +lpm->tbl24[tbl24_index].fwd_class;
Quoted 6 lines
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +3
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->tbl8[i].as_num = lpm->tbl24[tbl24_index].as_num; +#endif }Quoted 10 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t
Quoted 2 lines
tbl8_index = tbl8_group_start + (ip_masked & 0xFF);lib/librte_lpm/rte_lpm.c +0
-0@@ -561,7 +578,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 7 lines
lib/librte_lpm/rte_lpm.c +2
-1uint8_t depth, lpm->tbl8[i].depth <= depth) { lpm->tbl8[i].valid = VALID; lpm->tbl8[i].depth = depth; - lpm->tbl8[i].next_hop = next_hop; + lpm->tbl8[i].next_hop = res->next_hop; + lpm->tbl8[i].fwd_class =
res->fwd_class;Quoted 11 lines
Quoted 11 lines
lib/librte_lpm/rte_lpm.c +3
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->tbl8[i].as_num = res->as_num; +#endif continue ;}lib/librte_lpm/rte_lpm.c +0
-0@@ -573,11 +594,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_tip_masked, uint8_t depth, * so assign whole structure in one go. */ Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 578
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-2-struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .tbl8_gindex =(uint8_t)tbl8_group_index,
Quoted 5 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 600
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +2
-2}, - .valid = VALID, - .ext_entry = 1, + struct rte_lpm_tbl_entry new_tbl24_entry = { + .tbl8_gindex =(uint16_t)tbl8_group_index,
Quoted 5 lines
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +2
-0.depth = 0, + .ext_valid = 1, + .valid = VALID, };Quoted 7 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 599
Quoted 7 lines
lpm->tbl24[tbl24_index] = new_tbl24_entry;lib/librte_lpm/rte_lpm.c +0
-1@@ -595,11 +616,15 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, if (!lpm->tbl8[i].valid || lpm->tbl8[i].depth <= depth) { -struct rte_lpm_tbl8_entry
new_tbl8_entry= {Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 620
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +1
-1- .valid = VALID, +struct rte_lpm_tbl_entry
new_tbl8_entry= {Quoted 10 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 628
Quoted 10 lines
lib/librte_lpm/rte_lpm.c +6
-2+#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = res->as_num, +#endif + .next_hop = res->next_hop, + .fwd_class = res->fwd_class, .depth = depth, - .next_hop = next_hop, - .valid_group = lpm->tbl8[i].valid_group, + .ext_valid =lpm->tbl8[i].ext_valid,
Quoted 15 lines
Quoted 15 lines
lib/librte_lpm/rte_lpm.c +1
-0+ .valid = VALID, };/*lib/librte_lpm/rte_lpm.c +1
-1@@ -621,19 +646,19 @@ add_depth_big(struct rte_lpm *lpm, uint32_tip_masked, uint8_t depth, */ int rte_lpm_add (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t next_hop) +struct rte_lpm_res *res) {int32_t rule_index, status =0 ;uint32_t ip_masked;Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 631
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-1/* Check user arguments. */ - if ((lpm == NULL) || (depth < 1) || (depth >
RTE_LPM_MAX_DEPTH))Quoted 6 lines
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +1
-0+if ((lpm ==NULL ) || (res ==NULL ) || (depth <1 ) || (depth >RTE_LPM_MAX_DEPTH ))return -EINVAL ; ip_masked = ip &depth_to_mask (depth);Quoted 13 lines
lib/librte_lpm/rte_lpm.c rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
Quoted 7 lines
lib/librte_lpm/rte_lpm.c +1
-1/* Add the rule to the rule table. */ - rule_index =rule_add (lpm, ip_masked, depth, next_hop); + rule_index =rule_add (lpm, ip_masked, depth, res);/* If the is no space available for new rule return error. */ if (rule_index < 0) {lib/librte_lpm/rte_lpm.c +0
-0@@ -641,10 +666,10 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
uint8_tQuoted 5 lines
lib/librte_lpm/rte_lpm.c +0
-1depth, }if (depth <=MAX_DEPTH_TBL24 ) { - status = add_depth_small(lpm, ip_masked, depth,
next_hop);Quoted 4 lines
lib/librte_lpm/rte_lpm.c rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, · line 648
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +1
-1+ status =add_depth_small (lpm, ip_masked, depth, res); }else {/* If depth > RTE_LPM_MAX_DEPTH_TBL24 */ - status = add_depth_big(lpm, ip_masked, depth,
next_hop);Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +1
-0+ status =add_depth_big (lpm, ip_masked, depth, res);/* * If add fails due to exhaustion of tbl8 extensions
delete
Quoted 6 lines
lib/librte_lpm/rte_lpm.c rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-0@@ -665,14 +690,14 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
uint8_tQuoted 4 lines
lib/librte_lpm/rte_lpm.c +0
-0depth, */ int rte_lpm_is_rule_present(struct rte_lpm *lpm, uint32_t ip, uint8_tdepth,
Quoted 26 lines
Quoted 26 lines
lib/librte_lpm/rte_lpm.c +7
-3-uint8_t *next_hop) + struct rte_lpm_res *res) {uint32_t ip_masked;int32_t rule_index;/* Check user arguments. */ if ((lpm ==NULL ) || - (next_hop ==NULL ) || + (res ==NULL ) || (depth <1 ) || (depth >RTE_LPM_MAX_DEPTH ))return -EINVAL ;@@ -681,7 +706,11 @@ uint8_t *next_hop) rule_index =rule_find (lpm, ip_masked, depth);if (rule_index >=0 ) { - *next_hop = lpm->rules_tbl[rule_index].next_hop; + res->next_hop = lpm->rules_tbl[rule_index].next_hop; + res->fwd_class = lpm->rules_tbl[rule_index].fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + res->as_num = lpm->rules_tbl[rule_index].as_num; +#endif return 1 ; }Quoted 4 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, uint32_t · line 762
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +0
-0@@ -731,7 +760,7 @@ delete_depth_small(struct rte_lpm *lpm, uint32_tip_masked, */ for (i = tbl24_index; i < (tbl24_index + tbl24_range);i++)
Quoted 5 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, uint32_t · line 766
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +1
-1{ -if (lpm->tbl24[i].ext_entry ==0 && +if (lpm->tbl24[i].ext_valid ==0 && lpm->tbl24[i].depth <= depth ){
Quoted 16 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm,
Quoted 3 lines
lpm->tbl24[i].valid = INVALID; }lib/librte_lpm/rte_lpm.c +0
-0@@ -761,23 +790,30 @@ delete_depth_small(struct rte_lpm *lpm,
uint32_tQuoted 12 lines
lib/librte_lpm/rte_lpm.c +3
-4ip_masked, * associated with this rule. */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - {.next_hop = lpm->rules_tbl[sub_rule_index].next_hop,}, - .valid =VALID , - .ext_entry =0 , + struct rte_lpm_tbl_entry new_tbl24_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num =lpm->rules_tbl[sub_rule_index].as_num,
Quoted 2 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 799
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+#endif + .next_hop =lpm->rules_tbl[sub_rule_index].next_hop,
Quoted 7 lines
Quoted 7 lines
lib/librte_lpm/rte_lpm.c +3
-0+ .fwd_class = lpm->rules_tbl[sub_rule_index].fwd_class, .depth = sub_rule_depth, + .ext_valid = 0, + .valid = VALID, };Quoted 5 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 809
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +3
-2-struct rte_lpm_tbl8_entry new_tbl8_entry = { - .valid =VALID , +struct rte_lpm_tbl_entry new_tbl8_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num =lpm->rules_tbl[sub_rule_index].as_num,
Quoted 2 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 811
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+#endif + .next_hop =lpm->rules_tbl[sub_rule_index].next_hop,
Quoted 9 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 818
Quoted 9 lines
lib/librte_lpm/rte_lpm.c +2
-2+ .fwd_class = lpm->rules_tbl[sub_rule_index].fwd_class, .depth = sub_rule_depth, - .next_hop = lpm->rules_tbl - [sub_rule_index].next_hop, + .valid = VALID, }; for (i = tbl24_index; i < (tbl24_index + tbl24_range);i++)
Quoted 5 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm,
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +1
-1{ -if (lpm->tbl24[i].ext_entry ==0 && +if (lpm->tbl24[i].ext_valid ==0 && lpm->tbl24[i].depth <= depth ){
Quoted 15 lines
Quoted 11 lines
lpm->tbl24[i] = new_tbl24_entry; }lib/librte_lpm/rte_lpm.c +1
-1@@ -814,7 +850,7 @@ delete_depth_small(struct rte_lpm *lpm, uint32_tip_masked, * thus can be recycled */ static inline int32_t -tbl8_recycle_check(struct rte_lpm_tbl8_entry *tbl8, uint32_t tbl8_group_start) +tbl8_recycle_check (struct rte_lpm_tbl_entry *tbl8,uint32_t tbl8_group_start)Quoted 3 lines
{
uint32_ttbl8_group_end, i;
tbl8_group_end=tbl8_group_start+
RTE_LPM_TBL8_GROUP_NUM_ENTRIES;Quoted 13 lines
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, uint32_t · line 934
Quoted 13 lines
lib/librte_lpm/rte_lpm.c +3
-4@@ -891,11 +927,15 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, } else { /* Set new tbl8 entry. */ -struct rte_lpm_tbl8_entry new_tbl8_entry = { - .valid =VALID , - .depth = sub_rule_depth, - .valid_group = lpm->tbl8[tbl8_group_start].valid_group, + struct rte_lpm_tbl_entry new_tbl8_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num =lpm->rules_tbl[sub_rule_index].as_num,
Quoted 4 lines
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, uint32_t · line 938
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +2
-0+#endif + .fwd_class = lpm->rules_tbl[sub_rule_index].fwd_class, .next_hop =lpm->rules_tbl[sub_rule_index].next_hop,
Quoted 2 lines
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, uint32_t · line 940
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+ .depth = sub_rule_depth, + .ext_valid =lpm->tbl8[tbl8_group_start].ext_valid,
Quoted 19 lines
Quoted 9 lines
lib/librte_lpm/rte_lpm.c +1
-0+ .valid = VALID,}; /*lib/librte_lpm/rte_lpm.c +0
-0@@ -923,11 +963,15 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, }else if (tbl8_recycle_index >-1 ) {/* Update tbl24 entry. */ lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, uint32_t · line 972
Quoted 10 lines
lib/librte_lpm/rte_lpm.c +5
-4-struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .next_hop = lpm->tbl8[tbl8_recycle_index].next_hop, }, - .valid =VALID , - .ext_entry =0 , +struct rte_lpm_tbl_entry new_tbl24_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = lpm->tbl8[tbl8_recycle_index].as_num, +#endif + .next_hop =lpm->tbl8[tbl8_recycle_index].next_hop,
Quoted 8 lines
Quoted 8 lines
lib/librte_lpm/rte_lpm.c +3
-0+ .fwd_class = lpm->tbl8[tbl8_recycle_index].fwd_class, .depth = lpm->tbl8[tbl8_recycle_index].depth, + .ext_valid = 0, + .valid = VALID,}; /* Set tbl24 before freeing tbl8 to avoid racecondition. */
Quoted 14 lines
lib/librte_lpm/rte_lpm.h line 31
Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0
-0@@ -31,8 +31,8 @@* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Quoted 7 lines
lib/librte_lpm/rte_lpm.h +2
-2*/ -#ifndef _RTE_LPM_H_ -#define _RTE_LPM_H_ +#ifndef _RTE_LPM_EXT_H_ +#define _RTE_LPM_EXT_H_Quoted 7 lines
lib/librte_lpm/rte_lpm.h extern "C" { · line 84
Quoted 7 lines
lib/librte_lpm/rte_lpm.h +0
-1/** * @file @@ -81,57 +81,58 @@ extern "C" {#define RTE_LPM_RETURN_IF_TRUE (cond, retval)#endif -/** @internal bitmask with valid and ext_entry/valid_group fields set */
Quoted 88 lines
Quoted 88 lines
lib/librte_lpm/rte_lpm.h +36
-34-#define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x0300 +/** @internal bitmask with valid and ext_valid/ext_valid fields set */ +#define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x03/** Bitmask used to indicate successful lookup */ -#define RTE_LPM_LOOKUP_SUCCESS 0x0100 +#define RTE_LPM_LOOKUP_SUCCESS 0x01 + +struct rte_lpm_res { +uint16_t next_hop; +uint8_t fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif +};#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. */ +struct rte_lpm_tbl_entry { +uint8_t valid :1 ; +uint8_t ext_valid :1 ; +uint8_t depth :6 ; +uint8_t fwd_class;union { -uint8_t next_hop; -uint8_t tbl8_gindex; +uint16_t next_hop; +uint16_t tbl8_gindex; }; -/* 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. */ -}; - -/** @internal Tbl8 entry structure. */ -struct rte_lpm_tbl8_entry { -uint8_t next_hop;/**< 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. */ +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif };#else -struct rte_lpm_tbl24_entry { -uint8_t depth :6 ; -uint8_t ext_entry :1 ; -uint8_t valid :1 ; +struct rte_lpm_tbl_entry { +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif union { -uint8_t tbl8_gindex; -uint8_t next_hop; +uint16_t tbl8_gindex; +uint16_t next_hop; }; -}; - -struct rte_lpm_tbl8_entry { -uint8_t depth :6 ; -uint8_t valid_group :1 ; -uint8_t valid :1 ; -uint8_t next_hop; +uint8_t fwd_class; +uint8_t depth :6 ; +uint8_t ext_valid :1 ; +uint8_t valid :1 ; };#endif /** @internal Rule structure. */ struct rte_lpm_rule {uint32_t ip;/**< Rule IP address. */ -uint8_t next_hop;/**< Rule next hop. */ +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif +uint16_t next_hop;/**< Rule next hop. */ +uint8_t fwd_class; };Quoted 3 lines
lib/librte_lpm/rte_lpm.h struct rte_lpm { · line 149
Quoted 3 lines
lib/librte_lpm/rte_lpm.h +0
-0/** @internal Contains metadata about the rules table. */ @@ -148,9 +149,9 @@ struct rte_lpm {struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH ];/**< Rule
Quoted 20 lines
Quoted 20 lines
info table. */
/* LPM Tables. */lib/librte_lpm/rte_lpm.h +3
-3- struct rte_lpm_tbl24_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] \ + struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] \ __rte_cache_aligned;/**< LPM tbl24 table. */ - struct rte_lpm_tbl8_entry tbl8[RTE_LPM_TBL8_NUM_ENTRIES] \ + struct rte_lpm_tbl_entry tbl8[RTE_LPM_TBL8_NUM_ENTRIES] \ __rte_cache_aligned;/**< LPM tbl8 table. */ struct rte_lpm_rule rules_tbl[0] \ __rte_cache_aligned;/**< LPM rules. */ @@ -219,7 +220,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, struct rte_lpm_res *res);Quoted 8 lines
lib/librte_lpm/rte_lpm.h rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
Quoted 3 lines
/**
* Check if a rule is present in the LPM table,lib/librte_lpm/rte_lpm.h +0
-0@@ -238,7 +239,7 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
uint8_tQuoted 4 lines
lib/librte_lpm/rte_lpm.h +0
-0depth, uint8_t next_hop); */ int rte_lpm_is_rule_present(struct rte_lpm *lpm, uint32_t ip, uint8_tdepth,
Quoted 7 lines
lib/librte_lpm/rte_lpm.h rte_lpm_delete_all(struct rte_lpm *lpm); · line 278
Quoted 7 lines
lib/librte_lpm/rte_lpm.h +1
-1-uint8_t *next_hop); + struct rte_lpm_res *res);/** * Delete a rule from the LPM table.
lib/librte_lpm/rte_lpm.h +0
-0@@ -277,29 +278,43 @@ rte_lpm_delete_all(struct rte_lpm *lpm);* -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup
Quoted 5 lines
lib/librte_lpm/rte_lpm.h
Quoted 5 lines
hit
*/
static inline intlib/librte_lpm/rte_lpm.h +1
-1-rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint8_t *next_hop) +rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, struct rte_lpm_res*res)
Quoted 33 lines
lib/librte_lpm/rte_lpm.h
Quoted 13 lines
{ unsigned tbl24_index = (ip >> 8);lib/librte_lpm/rte_lpm.h +6
-4-uint16_t tbl_entry; - +#ifdef RTE_LIBRTE_LPM_ASNUM +uint64_t tbl_entry; +#else +uint32_t tbl_entry; +#endif /* DEBUG: Check user input arguments. */ -RTE_LPM_RETURN_IF_TRUE (((lpm ==NULL ) || (next_hop ==NULL )), -EINVAL ); + RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (res == NULL)), -EINVAL);
Quoted 19 lines
/* Copy tbl24 entry */lib/librte_lpm/rte_lpm.h +5
-3- tbl_entry = *(const uint16_t *)&lpm->tbl24[tbl24_index]; - +#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t *)&lpm->tbl24[tbl24_index]; +#else + tbl_entry = *(const uint32_t *)&lpm->tbl24[tbl24_index]; +#endif /* Copy tbl8 entry (only if needed) */ if (unlikely ((tbl_entry &RTE_LPM_VALID_EXT_ENTRY_BITMASK ) ==RTE_LPM_VALID_EXT_ENTRY_BITMASK )) { unsigned tbl8_index = (uint8_t)ip + - ((uint8_t)tbl_entry *
RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
+ ((*(structrte_lpm_tbl_entry
*)&tbl_entry).tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES);Quoted 10 lines
lib/librte_lpm/rte_lpm.h
Quoted 10 lines
lib/librte_lpm/rte_lpm.h +6
-3- tbl_entry = *(const uint16_t *)&lpm->tbl8[tbl8_index]; +#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t *)&lpm->tbl8[tbl8_index]; +#else + tbl_entry = *(const uint32_t *)&lpm->tbl8[tbl8_index]; +#endif } - - *next_hop = (uint8_t )tbl_entry; + res->next_hop = ((struct rte_lpm_tbl_entry*)&tbl_entry)->next_hop;
Quoted 21 lines
Quoted 21 lines
+
res->fwd_class= ((structrte_lpm_tbl_entry
*)&tbl_entry)->fwd_class;lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + res->as_num = ((struct rte_lpm_tbl_entry*)&tbl_entry)->as_num;
lib/librte_lpm/rte_lpm.h +4
-2+#endif return (tbl_entry &RTE_LPM_LOOKUP_SUCCESS ) ?0 : -ENOENT ; + }/** @@ -322,19 +337,25 @@ rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip,uint8_t *next_hop) * @return * -EINVAL for incorrect arguments, otherwise 0 */ -#define rte_lpm_lookup_bulk (lpm, ips, next_hops, n) \ - rte_lpm_lookup_bulk_func(lpm, ips, next_hops, n) +#define rte_lpm_lookup_bulk (lpm, ips, res_tbl, n) \ + rte_lpm_lookup_bulk_func(lpm, ips, res_tbl, n)Quoted 2 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, · line 330
Quoted 2 lines
lib/librte_lpm/rte_lpm.h +0
-1static inline int -rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t *ips,
Quoted 2 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, · line 345
Quoted 2 lines
lib/librte_lpm/rte_lpm.h +1
-1- uint16_t * next_hops, const unsigned n) +rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t*ips,
Quoted 31 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookup_bulk_func(const struct rte_lpm
Quoted 19 lines
lib/librte_lpm/rte_lpm.h +8
-1+ struct rte_lpm_res *res_tbl, const unsigned n) { unsigned i; +int ret =0 ; +#ifdef RTE_LIBRTE_LPM_ASNUM +uint64_t tbl_entry; +#else +uint32_t tbl_entry; +#endif unsigned tbl24_indexes[n];/* DEBUG: Check user input arguments. */ RTE_LPM_RETURN_IF_TRUE (((lpm ==NULL ) || (ips ==NULL ) || - (next_hops ==NULL )), -EINVAL ); + (res_tbl ==NULL )), -EINVAL );for (i =0 ; i < n; i++) {tbl24_indexes[i] = ips[i] >> 8;lib/librte_lpm/rte_lpm.h +0
-0@@ -342,20 +363,32 @@ rte_lpm_lookup_bulk_func(const struct rte_lpm*lpm,
Quoted 11 lines
lib/librte_lpm/rte_lpm.h +3
-2const uint32_t * ips, for (i = 0; i < n; i++) {/* Simply copy tbl24 entry to output */ - next_hops[i] = *(const uint16_t *)&lpm->tbl24[tbl24_indexes[i]]; - +#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t *)&lpm->tbl24[tbl24_indexes[i]]; +#else Quoted 8 lines
lib/librte_lpm/rte_lpm.h
Quoted 8 lines
lib/librte_lpm/rte_lpm.h +2
-1+ tbl_entry = *(const uint32_t *)&lpm->tbl24[tbl24_indexes[i]]; +#endif /* Overwrite output with tbl8 entry if needed */ - if (unlikely((next_hops[i] &
RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==lib/librte_lpm/rte_lpm.h +1
-1- RTE_LPM_VALID_EXT_ENTRY_BITMASK)) { + if (unlikely((tbl_entry &
RTE_LPM_VALID_EXT_ENTRY_BITMASK)Quoted 6 lines
lib/librte_lpm/rte_lpm.h
Quoted 6 lines
==
lib/librte_lpm/rte_lpm.h +1
-2+ RTE_LPM_VALID_EXT_ENTRY_BITMASK)) { unsigned tbl8_index = (uint8_t)ips[i] + - ((uint8_t)next_hops[i] * -
RTE_LPM_TBL8_GROUP_NUM_ENTRIES);Quoted 27 lines
Quoted 27 lines
+ ((*(struct
rte_lpm_tbl_entry
*)&tbl_entry).tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES);- next_hops[i] = *(const
uint16_t
*)&lpm->tbl8[tbl8_index];lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t*)&lpm->tbl8[tbl8_index];
lib/librte_lpm/rte_lpm.h +2
-0+#else + tbl_entry = *(const uint32_t*)&lpm->tbl8[tbl8_index];
lib/librte_lpm/rte_lpm.h +2
-0+#endif } + res_tbl[i].next_hop = ((struct rte_lpm_tbl_entry*)&tbl_entry)->next_hop;
+ res_tbl[i].fwd_class = ((structrte_lpm_tbl_entry
*)&tbl_entry)->next_hop;lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + res_tbl[i].as_num = ((struct rte_lpm_tbl_entry*)&tbl_entry)->as_num;
lib/librte_lpm/rte_lpm.h +3
-1+#endif + ret |=1 << i; } -return 0 ; +return ret; }Quoted 19 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookupx4(const struct rte_lpm *lpm,
Quoted 2 lines
/* Mask four results. */
lib/librte_lpm/rte_lpm.h +0
-0@@ -477,4 +510,4 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm,
__m128iip,Quoted 16 lines
lib/librte_lpm/rte_lpm.h +1
-1uint16_t hop[4], }#endif -#endif /* _RTE_LPM_H_ */ +#endif /* _RTE_LPM_EXT_H_ */ 2015-10-24 9:09 GMT+03:00 Matthew Hall <[email protected]>:
Quoted 7 lines · Matthew Hall
Quoted 6 lines · Michal Jastrzebski
Quoted 4 lines
From: Michal Kobylinski <[email protected]>
The current DPDK implementation for LPM for IPv4 and IPv6 limits
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
number of next hops to 256, as the next hop ID is an 8-bit long
field.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Proposed extension increase number of next hops for IPv4 to 2^24
and
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
also allows 32-bits read/write operations.
This patchset requires additional change to
rte_tablelibrary tomeet
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 2 lines
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
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
part of a job. My patchset is attached to this email.
One possible advantage with my patchset, compared to others, is that
the
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
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
Quoted 4 lines
as
Quoted 3 lines
Quoted 3 lines
humanly possible.
This is because my application code is green-field, so I absolutely
don't
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
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_lpmas some ofthe
Quoted 1 line
Quoted 1 line
Quoted 1 line
full-time guys, but I think with four or five of us in the thread
hammering
Quoted 1 line
Quoted 1 line
Quoted 1 line
out patches we will be able to create something amazing together and
I
Quoted 6 lines
am
Quoted 4 lines
Quoted 4 lines
very very very very very happy about this.
Matthew.
Hi Vladimir,
Thanks for sharing Your implementation.
Could You please clarify whatas_numandfwd_classfields represent? The second issue I have is that Your patch doesn’t want to apply on top of current head. Could You check this please?Best regards
Michal
Michal,
Looks strange, you have:
error: while searching for:
lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
...
error: patch failed: lib/librte_lpm/rte_lpm.c:159
but if we look at
http://dpdk.org/browse/dpdk/tree/lib/librte_lpm/rte_lpm.c#n159
patch should apply fine.
Latest commit in my repo is 139debc42dc0a320dad40f5295b74d2e3ab8a7f9
2015-10-26 18:39 GMT+03:00 Michal Jastrzebski <
[email protected]>:
Quoted 1,199 lines
Quoted 3 lines · Vladimir Medvedkin
Hi Michal,
Forwarding class can help us to classify traffic based on dst prefix,
it's
Quoted 36 lines
something like Juniper DCU. For example on Juniper MX I can make policy that install prefix into the FIB with some class and use it on dataplane, for example with ACL.
On Juniper MX I can make something like that:
#show policy-options
policy-statement community-to-class {term customer { from community originate-customer; then destination-class customer; } } community originate-customer members 12345:11111; # show routing-options forwarding-table { export community-to-class; } # show forwarding-options forwarding-options { family inet { filter { output test-filter; } } } # show firewall family inet filter test-filter term 1 { from { protocol icmp; destination-class customer; } then { discard; } } announce route 10.10.10.10/32 next-hop 10.10.10.2 community 12345:11111 After than on dataplane we haveQuoted 8 lines
NPC1( vty)# show route ip lookup 10.10.10.10 Route Information (10.10.10.10): interface : xe-1/0/0.0 (328) Nexthop prefix : - Nexthop ID : 1048574 MTU : 0 Class ID : 129 <- That is "forwarding class" in my implementation This construction discards all ICMP traffic that goes to dst prefixeswhich
Quoted 1 line
was originated with community 12345:11111. With this mechanism we can
make
Quoted 11 lines
on control plane different sophisticated policy to control traffic on dataplane.
The same withas_num, we can have on dataplane AS number that has originated that prefix, or another 4-byte number e.g. geo-id. What issue do you mean? I think it is because of table/pipeline/test frameworks that doesen't want to compile due to changing API/ABI. You can turn it off for LPM testing, if my patch will be applied I will make changes in above-mentioned frameworks.Regards,
VladimirHi Vladimir,
I have an issue with applying Your patch not compilation. This is the error i get:
Checking patch config/common_bsdapp...
Checking patch config/common_linuxapp... Checking patchlib/librte_lpm/rte_lpm.c...
error: while searching for:lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list); RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl24_entry) != 2); RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl8_entry) != 2); /* Check user arguments. */ if ((name == NULL) || (socket_id < -1) || (max_rules == 0)){ rte_errno = EINVAL;error: patch failed:
lib/librte_lpm/rte_lpm.c:159
error:lib/librte_lpm/rte_lpm.c: patch does not apply Checking patchlib/librte_lpm/rte_lpm.h...
error: while searching for:
#defineRTE_LPM_RETURN_IF_TRUE(cond, retval)#endif/** @internal bitmask with valid and ext_entry/valid_group fields set */ #define
RTE_LPM_VALID_EXT_ENTRY_BITMASK0x0300/** Bitmask used to indicate successful lookup */
#defineRTE_LPM_LOOKUP_SUCCESS0x0100#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. */ union { uint8_t next_hop; uint8_t tbl8_gindex; }; /* 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. */ };/** @internal Tbl8 entry structure. */
struct rte_lpm_tbl8_entry { uint8_t next_hop; /**< 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. */ }; #else struct rte_lpm_tbl24_entry { uint8_t depth :6; uint8_t ext_entry :1; uint8_t valid :1; union { uint8_t tbl8_gindex; uint8_t next_hop; }; };struct rte_lpm_tbl8_entry { uint8_t depth :6; uint8_t valid_group :1; uint8_t valid :1; uint8_t next_hop; };#endif
/** @internal Rule structure. */
struct rte_lpm_rule { uint32_t ip; /**< Rule IP address. */ uint8_t next_hop; /**< Rule next hop. */ };/** @internal Contains metadata about the rules table. */
error: patch failed:
lib/librte_lpm/rte_lpm.h:81
error:lib/librte_lpm/rte_lpm.h: patch does not applyQuoted 8 lines
2015-10-26 14:57 GMT+03:00 Jastrzebski, MichalX K < [email protected]>:
Quoted 5 lines
Quoted 5 lines
-----Original Message-----
From: Michal Jastrzebski [mailto:[email protected]]
Sent: Monday, October 26, 2015 12:55 PM
To: Vladimir Medvedkin
Subject: Re: [dpdk-dev] [PATCH v1 0/3] lpm: increase number of nexthops
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
for lpm (ipv4)
Quoted 4 lines · Vladimir Medvedkin
Hi all,
Here my implementation
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Signed-off-by Vladimir Medvedkin <[email protected]>--- config/common_bsdapp | 1 + config/common_linuxapp | 1 + lib/librte_lpm/rte_lpm.c | 194 +++++++++++++++++++++++++++++------------------ lib/librte_lpm/rte_lpm.h | 163+++++++++++++++++++++++----------------
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
4 files changed, 219 insertions(+), 140 deletions(-)config/common_bsdapp +1
-0@@ -344,6 +344,7 @@ CONFIG_RTE_LIBRTE_JOBSTATS=y # CONFIG_RTE_LIBRTE_LPM=y CONFIG_RTE_LIBRTE_LPM_DEBUG=n +CONFIG_RTE_LIBRTE_LPM_ASNUM=n # # Compile librte_aclconfig/common_linuxapp +1
-0@@ -352,6 +352,7 @@ CONFIG_RTE_LIBRTE_JOBSTATS=y # CONFIG_RTE_LIBRTE_LPM=y CONFIG_RTE_LIBRTE_LPM_DEBUG=n +CONFIG_RTE_LIBRTE_LPM_ASNUM=nQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
lib/librte_lpm/rte_lpm.c rte_lpm_create(const char *name, int
Quoted 7 lines
config/common_linuxapp +0
-0# # Compile librte_acllib/librte_lpm/rte_lpm.c +0
-0@@ -159,9 +159,11 @@ rte_lpm_create(const char *name, int
socket_id,Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
int
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0max_rules, lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head,
rte_lpm_list);Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
lib/librte_lpm/rte_lpm.c rte_lpm_create(const char *name, int · line 168
Quoted 11 lines
lib/librte_lpm/rte_lpm.c +5
-3-RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl24_entry ) !=2 ); -RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl8_entry ) !=2 ); - +#ifdef RTE_LIBRTE_LPM_ASNUM +RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl_entry ) !=8 ); +#else +RTE_BUILD_BUG_ON (sizeof (struct rte_lpm_tbl_entry ) !=4 ); +#endif /* Check user arguments. */ if ((name == NULL) || (socket_id < -1) || (max_rules ==0)){
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
lib/librte_lpm/rte_lpm.c rule_add(struct rte_lpm *lpm, uint32_t
Quoted 11 lines
lib/librte_lpm/rte_lpm.c +1
-1rte_errno =EINVAL ;@@ -261,7 +263,7 @@ rte_lpm_free(struct rte_lpm *lpm)*/ static inline int32_t rule_add (struct rte_lpm *lpm,uint32_t ip_masked,uint8_t depth, -uint8_t next_hop) +struct rte_lpm_res *res) {uint32_t rule_gindex, rule_index, last_rule;int i;@@ -282,8 +284,11 @@ rule_add(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.c rule_add(struct rte_lpm *lpm, uint32_t · line 286
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth,/* If rule already exists update its
next_hopQuoted 5 lines
Quoted 5 lines
and
Quoted 2 lines
Quoted 2 lines
return. */
if (lpm->rules_tbl[rule_index].ip ==
ip_masked) {Quoted 1 line
Quoted 1 line
-
lpm->rules_tbl[rule_index].next_hop =
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.c
Quoted 3 lines
next_hop;lib/librte_lpm/rte_lpm.c +1
-1- +lpm->rules_tbl[rule_index].next_hop =
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
res->next_hop;
+lpm->rules_tbl[rule_index].fwd_class =
Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
lib/librte_lpm/rte_lpm.c rule_add(struct rte_lpm *lpm, uint32_t
Quoted 9 lines
res->fwd_class;lib/librte_lpm/rte_lpm.c +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->rules_tbl[rule_index].as_num =
res->as_num;lib/librte_lpm/rte_lpm.c +1
-0+#endif return rule_index; } }@@ -320,7 +325,11 @@ rule_add(struct rte_lpm *lpm, uint32_t
ip_masked,lib/librte_lpm/rte_lpm.c rule_find(struct rte_lpm *lpm, uint32_t
Quoted 14 lines
lib/librte_lpm/rte_lpm.c +5
-1uint8_t depth,/* Add the new rule. */ lpm->rules_tbl[rule_index].ip = ip_masked; - lpm->rules_tbl[rule_index].next_hop = next_hop; + lpm->rules_tbl[rule_index].next_hop = res->next_hop; + lpm->rules_tbl[rule_index].fwd_class = res->fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->rules_tbl[rule_index].as_num = res->as_num; +#endif /* Increment the used rules counter for this rule group. */ lpm->rule_info[depth - 1].used_rules++;lib/librte_lpm/rte_lpm.c +0
-0@@ -382,10 +391,10 @@ rule_find(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 11 lines
lib/librte_lpm/rte_lpm.c +2
-2uint8_t depth) * Find, clean and allocate a tbl8. */ static inline int32_t -tbl8_alloc (struct rte_lpm_tbl8_entry *tbl8) +tbl8_alloc (struct rte_lpm_tbl_entry *tbl8) {uint32_t tbl8_gindex;/* tbl8 group index. */ -struct rte_lpm_tbl8_entry *tbl8_entry; +struct rte_lpm_tbl_entry *tbl8_entry;Quoted 1 line
Quoted 1 line
Quoted 1 line
lib/librte_lpm/rte_lpm.c rule_find(struct rte_lpm *lpm, uint32_t · line 400
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-0/* Scan through tbl8 to find a free (i.e. INVALID) tbl8 group.
Quoted 2 lines
Quoted 2 lines
*/
Quoted 1 line
Quoted 1 line
for (tbl8_gindex = 0; tbl8_gindex <
RTE_LPM_TBL8_NUM_GROUPS;Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 404
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +0
-0@@ -393,12 +402,12 @@ tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) tbl8_entry = &tbl8[tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES ];/* If a free tbl8 group is found clean it and set as
Quoted 6 lines
Quoted 6 lines
VALID.
Quoted 5 lines
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +1
-1*/ -if (!tbl8_entry->valid_group) { +if (!tbl8_entry->ext_valid) { memset(&tbl8_entry[0], 0,
RTE_LPM_TBL8_GROUP_NUM_ENTRIESQuoted 6 lines
Quoted 6 lines
*
Quoted 5 lines
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +1
-1sizeof(tbl8_entry[0])); - tbl8_entry->valid_group =VALID ; + tbl8_entry->ext_valid =VALID ;Quoted 8 lines
Quoted 8 lines
Quoted 1 line
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 413
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-0/* Return group index for allocated tbl8 group. */
Quoted 6 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 413
Quoted 6 lines
return tbl8_gindex;lib/librte_lpm/rte_lpm.c +0
-1@@ -410,46 +419,50 @@ tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) } static inline void -tbl8_free(struct rte_lpm_tbl8_entry *tbl8, uint32_t
tbl8_group_start)Quoted 1 line
Quoted 1 line
Quoted 1 line
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 422
Quoted 1 line
lib/librte_lpm/rte_lpm.c +1
-0+tbl8_free(struct rte_lpm_tbl_entry *tbl8, uint32_t
tbl8_group_start)Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +1
-1{/* Set tbl8 group invalid*/ - tbl8[tbl8_group_start].valid_group =INVALID ; + tbl8[tbl8_group_start].ext_valid =INVALID ; }Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 432
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +1
-1static inline int32_t add_depth_small (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t next_hop) +struct rte_lpm_res *res) { uint32_t tbl24_index, tbl24_range, tbl8_index,
tbl8_group_end,Quoted 17 lines
Quoted 17 lines
i, j;
Quoted 16 lines
Quoted 16 lines
lib/librte_lpm/rte_lpm.c +11
-0/* Calculate the index into Table24. */ tbl24_index = ip >>8 ; tbl24_range =depth_to_range (depth); +struct rte_lpm_tbl_entry new_tbl_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = res->as_num, +#endif + .next_hop = res->next_hop, + .fwd_class = res->fwd_class, + .ext_valid =0 , + .depth = depth, + .valid =VALID , + }; +Quoted 1 line
Quoted 1 line
Quoted 1 line
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 448
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-0for (i = tbl24_index; i < (tbl24_index + tbl24_range);i++) {
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 450
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-0/* * For invalid OR valid and non-extended tbl 24 entries set
Quoted 3 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-1* entry. */ - if (!lpm->tbl24[i].valid ||(lpm->tbl24[i].ext_entry
Quoted 2 lines
Quoted 2 lines
== 0 &&
Quoted 1 line
Quoted 1 line
lib/librte_lpm/rte_lpm.c +1
-0+ if (!lpm->tbl24[i].valid ||(lpm->tbl24[i].ext_valid
Quoted 4 lines
Quoted 4 lines
== 0 &&
Quoted 3 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-1lpm->tbl24[i].depth <= depth)) { -struct rte_lpm_tbl24_entry new_tbl24_entry= {
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
lib/librte_lpm/rte_lpm.c tbl8_alloc(struct rte_lpm_tbl8_entry *tbl8) · line 456
Quoted 7 lines
lib/librte_lpm/rte_lpm.c +0
-6- { .next_hop = next_hop, }, - .valid = VALID, - .ext_entry = 0, - .depth = depth, - }; -/* Setting tbl24 entry in one go to avoid race
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
lib/librte_lpm/rte_lpm.c +2
-2* conditions */ - lpm->tbl24[i] = new_tbl24_entry; + lpm->tbl24[i] = new_tbl_entry;continue ; } -if (lpm->tbl24[i].ext_entry ==1 ) { +if (lpm->tbl24[i].ext_valid ==1 ) {/* If tbl24 entry is valid and extended Quoted 8 lines
Quoted 8 lines
calculate
Quoted 7 lines
lib/librte_lpm/rte_lpm.c add_depth_small(struct rte_lpm *lpm, uint32_t
Quoted 4 lines
the
* index into tbl8.
*/lib/librte_lpm/rte_lpm.c +0
-0@@ -461,19 +474,14 @@ add_depth_small(struct rte_lpm *lpm, uint32_tip,
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth, for (j = tbl8_index; j < tbl8_group_end;j++) {
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_small(struct rte_lpm *lpm, uint32_t · line 477
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-0if (!lpm->tbl8[j].valid || lpm->tbl8[j].depth<=
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
lib/librte_lpm/rte_lpm.c add_depth_small(struct rte_lpm *lpm, uint32_t · line 469
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +0
-4depth) { - struct rte_lpm_tbl8_entry - new_tbl8_entry = { - .valid = VALID, - .valid_group =VALID,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_small(struct rte_lpm *lpm, uint32_t · line 471
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-2- .depth = depth, - .next_hop =
next_hop,Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.c add_depth_small(struct rte_lpm *lpm, uint32_t · line 480
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +2
-1- }; + + new_tbl_entry.ext_valid =VALID;
Quoted 3 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0/* * Setting tbl8 entry in one
Quoted 5 lines
Quoted 5 lines
go to
Quoted 4 lines
Quoted 4 lines
avoid
* race conditions */
- lpm->tbl8[j] =
new_tbl8_entry;Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ lpm->tbl8[j] =
new_tbl_entry;Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.c add_depth_small(struct rte_lpm *lpm, uint32_t
Quoted 4 lines
continue; }lib/librte_lpm/rte_lpm.c +0
-0@@ -486,7 +494,7 @@ add_depth_small(struct rte_lpm *lpm, uint32_tip,
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.c add_depth_small(struct rte_lpm *lpm, uint32_t · line 497
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth, static inline int32_t add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_tdepth,
Quoted 22 lines
Quoted 22 lines
Quoted 11 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t
Quoted 7 lines
lib/librte_lpm/rte_lpm.c +1
-1- uint8_t next_hop) + struct rte_lpm_res *res) {uint32_t tbl24_index;int32_t tbl8_group_index, tbl8_group_start, tbl8_group_end,
tbl8_index,lib/librte_lpm/rte_lpm.c +0
-0@@ -512,7 +520,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth,/* Set tbl8 entry. */ for (i = tbl8_index; i < (tbl8_index + tbl8_range);i++) {
Quoted 10 lines
Quoted 10 lines
lib/librte_lpm/rte_lpm.c +5
-1lpm->tbl8[i].depth = depth; - lpm->tbl8[i].next_hop = next_hop; + lpm->tbl8[i].next_hop = res->next_hop; + lpm->tbl8[i].fwd_class = res->fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->tbl8[i].as_num = res->as_num; +#endif lpm->tbl8[i].valid =VALID ; }Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 527
Quoted 7 lines
lib/librte_lpm/rte_lpm.c +0
-2@@ -522,17 +534,17 @@ add_depth_big(struct rte_lpm *lpm, uint32_tip_masked, uint8_t depth, * so assign whole structure in one go */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .tbl8_gindex =(uint8_t)tbl8_group_index, },
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
lib/librte_lpm/rte_lpm.c +4
-2- .valid = VALID, - .ext_entry = 1, +struct rte_lpm_tbl_entry new_tbl24_entry = { + .tbl8_gindex = (uint16_t )tbl8_group_index, .depth =0 , + .ext_valid =1 , + .valid =VALID , };Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 547
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0lpm->tbl24[tbl24_index] = new_tbl24_entry; }/* If valid entry but not extended calculate the index into
Quoted 23 lines
Quoted 23 lines
Quoted 10 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t
Quoted 7 lines
Table8. */
lib/librte_lpm/rte_lpm.c +1
-1-else if (lpm->tbl24[tbl24_index].ext_entry ==0 ) { +else if (lpm->tbl24[tbl24_index].ext_valid ==0 ) {/* Search for free tbl8 group. */ tbl8_group_index =tbl8_alloc (lpm->tbl8);@@ -551,6 +563,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth, lpm->tbl8[i].depth =lpm->tbl24[tbl24_index].depth;
Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 566
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-0lpm->tbl8[i].next_hop =lpm->tbl24[tbl24_index].next_hop;
Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 568
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+ lpm->tbl8[i].fwd_class = +lpm->tbl24[tbl24_index].fwd_class;
Quoted 6 lines
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +3
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->tbl8[i].as_num = lpm->tbl24[tbl24_index].as_num; +#endif }Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t
Quoted 2 lines
tbl8_index = tbl8_group_start + (ip_masked & 0xFF);lib/librte_lpm/rte_lpm.c +0
-0@@ -561,7 +578,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_t
ip_masked,Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-0uint8_t depth, lpm->tbl8[i].depth <=depth) {
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 582
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +1
-1lpm->tbl8[i].valid =VALID ; lpm->tbl8[i].depth = depth; - lpm->tbl8[i].next_hop = next_hop; + lpm->tbl8[i].next_hop =
res->next_hop;Quoted 27 lines
Quoted 27 lines
Quoted 1 line
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 583
Quoted 1 line
lib/librte_lpm/rte_lpm.c +1
-0+ lpm->tbl8[i].fwd_class =
res->fwd_class;Quoted 11 lines
Quoted 11 lines
lib/librte_lpm/rte_lpm.c +3
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + lpm->tbl8[i].as_num = res->as_num; +#endif continue ;}lib/librte_lpm/rte_lpm.c +0
-0@@ -573,11 +594,11 @@ add_depth_big(struct rte_lpm *lpm, uint32_tip_masked, uint8_t depth, * so assign whole structure in one go. */ Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 578
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-2-struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .tbl8_gindex =(uint8_t)tbl8_group_index,
Quoted 5 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 600
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +2
-2}, - .valid = VALID, - .ext_entry = 1, + struct rte_lpm_tbl_entry new_tbl24_entry = { + .tbl8_gindex =(uint16_t)tbl8_group_index,
Quoted 5 lines
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +2
-0.depth = 0, + .ext_valid = 1, + .valid = VALID, };Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 619
Quoted 6 lines
lpm->tbl24[tbl24_index] = new_tbl24_entry;lib/librte_lpm/rte_lpm.c +0
-0@@ -595,11 +616,15 @@ add_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, if (!lpm->tbl8[i].valid || lpm->tbl8[i].depth <=depth) {
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 599
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-1-struct rte_lpm_tbl8_entry
new_tbl8_entry= {Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 620
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +1
-1- .valid = VALID, +struct rte_lpm_tbl_entry
new_tbl8_entry= {Quoted 5 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 625
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +5
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num = res->as_num, +#endif + .next_hop = res->next_hop, + .fwd_class =
res->fwd_class,Quoted 21 lines
Quoted 21 lines
Quoted 5 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 628
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +1
-2.depth = depth, - .next_hop = next_hop, - .valid_group = lpm->tbl8[i].valid_group, + .ext_valid =lpm->tbl8[i].ext_valid,
Quoted 15 lines
Quoted 15 lines
lib/librte_lpm/rte_lpm.c +1
-0+ .valid = VALID, };/*lib/librte_lpm/rte_lpm.c +1
-1@@ -621,19 +646,19 @@ add_depth_big(struct rte_lpm *lpm, uint32_tip_masked, uint8_t depth, */ int rte_lpm_add (struct rte_lpm *lpm,uint32_t ip,uint8_t depth, -uint8_t next_hop) +struct rte_lpm_res *res) {int32_t rule_index, status =0 ;uint32_t ip_masked;Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
lib/librte_lpm/rte_lpm.c add_depth_big(struct rte_lpm *lpm, uint32_t · line 631
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +0
-1/* Check user arguments. */ - if ((lpm == NULL) || (depth < 1) || (depth >
RTE_LPM_MAX_DEPTH))Quoted 1 line
Quoted 1 line
lib/librte_lpm/rte_lpm.c +1
-0+ if ((lpm == NULL) || (res == NULL) || (depth < 1) ||(depth >
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
lib/librte_lpm/rte_lpm.c +1
-1RTE_LPM_MAX_DEPTH))return -EINVAL ; ip_masked = ip &depth_to_mask (depth);/* Add the rule to the rule table. */ - rule_index =rule_add (lpm, ip_masked, depth, next_hop); + rule_index =rule_add (lpm, ip_masked, depth, res);/* If the is no space available for new rule return error.*/
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
lib/librte_lpm/rte_lpm.c rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
Quoted 2 lines
if (rule_index < 0) {lib/librte_lpm/rte_lpm.c +0
-0@@ -641,10 +666,10 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
uint8_tQuoted 5 lines
lib/librte_lpm/rte_lpm.c +0
-1depth, }if (depth <=MAX_DEPTH_TBL24 ) { - status = add_depth_small(lpm, ip_masked, depth,
next_hop);Quoted 1 line
Quoted 1 line
lib/librte_lpm/rte_lpm.c +1
-0+ status = add_depth_small(lpm, ip_masked, depth,res);
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.c rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, · line 648
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-1}else {/* If depth > RTE_LPM_MAX_DEPTH_TBL24 */ - status = add_depth_big(lpm, ip_masked, depth,
next_hop);Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +1
-0+ status =add_depth_big (lpm, ip_masked, depth, res);/* * If add fails due to exhaustion of tbl8
extensions
Quoted 21 lines
Quoted 21 lines
delete
Quoted 6 lines
lib/librte_lpm/rte_lpm.c rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-0@@ -665,14 +690,14 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
uint8_tQuoted 4 lines
lib/librte_lpm/rte_lpm.c +0
-0depth, */ int rte_lpm_is_rule_present(struct rte_lpm *lpm, uint32_t ip, uint8_tdepth,
Quoted 13 lines
Quoted 13 lines
lib/librte_lpm/rte_lpm.c +2
-2-uint8_t *next_hop) + struct rte_lpm_res *res) {uint32_t ip_masked;int32_t rule_index;/* Check user arguments. */ if ((lpm ==NULL ) || - (next_hop ==NULL ) || + (res ==NULL ) || (depth <1 ) || (depth >RTE_LPM_MAX_DEPTH ))return -EINVAL ;Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_lpm/rte_lpm.c uint8_t *next_hop) · line 709
Quoted 6 lines
lib/librte_lpm/rte_lpm.c +1
-1@@ -681,7 +706,11 @@ uint8_t *next_hop) rule_index =rule_find (lpm, ip_masked, depth);if (rule_index >=0 ) { - *next_hop = lpm->rules_tbl[rule_index].next_hop; + res->next_hop =lpm->rules_tbl[rule_index].next_hop;
Quoted 1 line
Quoted 1 line
Quoted 1 line
lib/librte_lpm/rte_lpm.c uint8_t *next_hop) · line 710
Quoted 1 line
lib/librte_lpm/rte_lpm.c +1
-0+ res->fwd_class =lpm->rules_tbl[rule_index].fwd_class;
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm,
Quoted 7 lines
lib/librte_lpm/rte_lpm.c +3
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + res->as_num = lpm->rules_tbl[rule_index].as_num; +#endif return 1 ; }@@ -731,7 +760,7 @@ delete_depth_small(struct rte_lpm *lpm,
uint32_tQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 762
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +0
-0ip_masked, */ for (i = tbl24_index; i < (tbl24_index +
tbl24_range);Quoted 6 lines
Quoted 6 lines
i++)
Quoted 5 lines
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +1
-1{ - if (lpm->tbl24[i].ext_entry == 0 && + if (lpm->tbl24[i].ext_valid == 0 && lpm->tbl24[i].depth <=depth )
Quoted 45 lines
Quoted 45 lines
{
Quoted 16 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm,
Quoted 3 lines
lpm->tbl24[i].valid = INVALID; }lib/librte_lpm/rte_lpm.c +0
-0@@ -761,23 +790,30 @@ delete_depth_small(struct rte_lpm *lpm,
uint32_tQuoted 12 lines
lib/librte_lpm/rte_lpm.c +3
-4ip_masked, * associated with this rule. */ -struct rte_lpm_tbl24_entry new_tbl24_entry = { - {.next_hop = lpm->rules_tbl[sub_rule_index].next_hop,}, - .valid =VALID , - .ext_entry =0 , + struct rte_lpm_tbl_entry new_tbl24_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num =lpm->rules_tbl[sub_rule_index].as_num,
Quoted 2 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 799
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+#endif + .next_hop =lpm->rules_tbl[sub_rule_index].next_hop,
Quoted 7 lines
Quoted 7 lines
lib/librte_lpm/rte_lpm.c +3
-0+ .fwd_class = lpm->rules_tbl[sub_rule_index].fwd_class, .depth = sub_rule_depth, + .ext_valid = 0, + .valid = VALID, };Quoted 5 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 809
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +3
-2-struct rte_lpm_tbl8_entry new_tbl8_entry = { - .valid =VALID , +struct rte_lpm_tbl_entry new_tbl8_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num =lpm->rules_tbl[sub_rule_index].as_num,
Quoted 2 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 811
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+#endif + .next_hop =lpm->rules_tbl[sub_rule_index].next_hop,
Quoted 8 lines
Quoted 8 lines
lib/librte_lpm/rte_lpm.c +2
-2+ .fwd_class = lpm->rules_tbl[sub_rule_index].fwd_class, .depth = sub_rule_depth, - .next_hop = lpm->rules_tbl - [sub_rule_index].next_hop, + .valid = VALID, };Quoted 1 line
Quoted 1 line
Quoted 1 line
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm, · line 818
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-0for (i = tbl24_index; i < (tbl24_index +
tbl24_range);Quoted 6 lines
Quoted 6 lines
i++)
Quoted 5 lines
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +1
-1{ - if (lpm->tbl24[i].ext_entry == 0 && + if (lpm->tbl24[i].ext_valid == 0 && lpm->tbl24[i].depth <=depth )
Quoted 4 lines
Quoted 4 lines
{
Quoted 3 lines
lib/librte_lpm/rte_lpm.c delete_depth_small(struct rte_lpm *lpm,
Quoted 3 lines
lpm->tbl24[i] = new_tbl24_entry; }lib/librte_lpm/rte_lpm.c +0
-0@@ -814,7 +850,7 @@ delete_depth_small(struct rte_lpm *lpm,
uint32_tQuoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
lib/librte_lpm/rte_lpm.c +1
-1ip_masked, * thus can be recycled */ static inline int32_t -tbl8_recycle_check(struct rte_lpm_tbl8_entry *tbl8, uint32_t tbl8_group_start) +tbl8_recycle_check (struct rte_lpm_tbl_entry *tbl8,uint32_t tbl8_group_start){
uint32_ttbl8_group_end, i;
tbl8_group_end=tbl8_group_start+
RTE_LPM_TBL8_GROUP_NUM_ENTRIES;Quoted 1 line
Quoted 1 line
Quoted 1 line
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm,
Quoted 1 line
lib/librte_lpm/rte_lpm.c +0
-0@@ -891,11 +927,15 @@ delete_depth_big(struct rte_lpm *lpm,
uint32_tQuoted 18 lines
Quoted 18 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +0
-0ip_masked, }else {/* Set new tbl8 entry. */ Quoted 8 lines
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, · line 934
Quoted 8 lines
lib/librte_lpm/rte_lpm.c +3
-4-struct rte_lpm_tbl8_entry new_tbl8_entry = { - .valid =VALID , - .depth = sub_rule_depth, - .valid_group = lpm->tbl8[tbl8_group_start].valid_group, + struct rte_lpm_tbl_entry new_tbl8_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num =lpm->rules_tbl[sub_rule_index].as_num,
Quoted 4 lines
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, · line 938
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +2
-0+#endif + .fwd_class = lpm->rules_tbl[sub_rule_index].fwd_class, .next_hop =lpm->rules_tbl[sub_rule_index].next_hop,
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, · line 940
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+ .depth = sub_rule_depth, + .ext_valid =lpm->tbl8[tbl8_group_start].ext_valid,
Quoted 5 lines
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm,
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +1
-0+ .valid = VALID,}; /*lib/librte_lpm/rte_lpm.c +0
-0@@ -923,11 +963,15 @@ delete_depth_big(struct rte_lpm *lpm,
uint32_tQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.c +0
-0ip_masked, }else if (tbl8_recycle_index >-1 ) {/* Update tbl24 entry. */ Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, · line 970
Quoted 8 lines
lib/librte_lpm/rte_lpm.c +3
-4-struct rte_lpm_tbl24_entry new_tbl24_entry = { - { .next_hop = lpm->tbl8[tbl8_recycle_index].next_hop, }, - .valid =VALID , - .ext_entry =0 , + struct rte_lpm_tbl_entry new_tbl24_entry = { +#ifdef RTE_LIBRTE_LPM_ASNUM + .as_num =lpm->tbl8[tbl8_recycle_index].as_num,
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
lib/librte_lpm/rte_lpm.c delete_depth_big(struct rte_lpm *lpm, · line 972
Quoted 2 lines
lib/librte_lpm/rte_lpm.c +2
-0+#endif + .next_hop =lpm->tbl8[tbl8_recycle_index].next_hop,
Quoted 3 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.c +1
-0+ .fwd_class = lpm->tbl8[tbl8_recycle_index].fwd_class, .depth =lpm->tbl8[tbl8_recycle_index].depth,
Quoted 20 lines
Quoted 20 lines
Quoted 5 lines
Quoted 5 lines
lib/librte_lpm/rte_lpm.c +2
-0+ .ext_valid = 0, + .valid = VALID,}; /* Set tbl24 before freeing tbl8 to avoid racecondition. */
Quoted 14 lines
lib/librte_lpm/rte_lpm.h line 31
Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0
-0@@ -31,8 +31,8 @@* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Quoted 7 lines
lib/librte_lpm/rte_lpm.h +2
-2*/ -#ifndef _RTE_LPM_H_ -#define _RTE_LPM_H_ +#ifndef _RTE_LPM_EXT_H_ +#define _RTE_LPM_EXT_H_Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
lib/librte_lpm/rte_lpm.h extern "C" { · line 84
Quoted 7 lines
lib/librte_lpm/rte_lpm.h +0
-1/** * @file @@ -81,57 +81,58 @@ extern "C" {#define RTE_LPM_RETURN_IF_TRUE (cond, retval)#endif -/** @internal bitmask with valid and ext_entry/valid_group fields set
Quoted 3 lines
Quoted 3 lines
*/
Quoted 2 lines
lib/librte_lpm/rte_lpm.h extern "C" { · line 84
Quoted 2 lines
lib/librte_lpm/rte_lpm.h +1
-1-#define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x0300 +/** @internal bitmask with valid and ext_valid/ext_valid fields set */
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
lib/librte_lpm/rte_lpm.h +10
-1+#define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x03/** Bitmask used to indicate successful lookup */ -#define RTE_LPM_LOOKUP_SUCCESS 0x0100 +#define RTE_LPM_LOOKUP_SUCCESS 0x01 + +struct rte_lpm_res { +uint16_t next_hop; +uint8_t fwd_class; +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif +};Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.h extern "C" {
Quoted 4 lines
lib/librte_lpm/rte_lpm.h +0
-3#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. */
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
lib/librte_lpm/rte_lpm.h +25
-29+struct rte_lpm_tbl_entry { +uint8_t valid :1 ; +uint8_t ext_valid :1 ; +uint8_t depth :6 ; +uint8_t fwd_class;union { -uint8_t next_hop; -uint8_t tbl8_gindex; +uint16_t next_hop; +uint16_t tbl8_gindex; }; -/* 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. */ -}; - -/** @internal Tbl8 entry structure. */ -struct rte_lpm_tbl8_entry { -uint8_t next_hop;/**< 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. */ +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif };#else -struct rte_lpm_tbl24_entry { -uint8_t depth :6 ; -uint8_t ext_entry :1 ; -uint8_t valid :1 ; +struct rte_lpm_tbl_entry { +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif union { -uint8_t tbl8_gindex; -uint8_t next_hop; +uint16_t tbl8_gindex; +uint16_t next_hop; }; -}; - -struct rte_lpm_tbl8_entry { -uint8_t depth :6 ; -uint8_t valid_group :1 ; -uint8_t valid :1 ; -uint8_t next_hop; +uint8_t fwd_class; +uint8_t depth :6 ; +uint8_t ext_valid :1 ; +uint8_t valid :1 ; };#endif /** @internal Rule structure. */ struct rte_lpm_rule {uint32_t ip;/**< Rule IP address. */ -uint8_t next_hop;/**< Rule next hop. */ +#ifdef RTE_LIBRTE_LPM_ASNUM +uint32_t as_num; +#endif +uint16_t next_hop;/**< Rule next hop. */ +uint8_t fwd_class; };Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.h struct rte_lpm { · line 149
Quoted 3 lines
lib/librte_lpm/rte_lpm.h +0
-0/** @internal Contains metadata about the rules table. */ @@ -148,9 +149,9 @@ struct rte_lpm {struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH ];/**< Rule
Quoted 4 lines
Quoted 4 lines
info table. */
/* LPM Tables. */- struct
rte_lpm_tbl24_entrytbl24[RTE_LPM_TBL24_NUM_ENTRIES] \
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+ struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] \ __rte_cache_aligned; /**< LPM tbl24 table.*/
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.h
Quoted 3 lines
lib/librte_lpm/rte_lpm.h +1
-1- struct rte_lpm_tbl8_entry tbl8[RTE_LPM_TBL8_NUM_ENTRIES] \ + struct rte_lpm_tbl_entry tbl8[RTE_LPM_TBL8_NUM_ENTRIES] \ __rte_cache_aligned;/**< LPM tbl8 table. */
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
lib/librte_lpm/rte_lpm.h rte_lpm_free(struct rte_lpm *lpm); · line 222
Quoted 7 lines
struct rte_lpm_rule rules_tbl[0] \ __rte_cache_aligned; /**< LPM rules. */lib/librte_lpm/rte_lpm.h +0
-1@@ -219,7 +220,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_tQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_lpm/rte_lpm.h rte_lpm_free(struct rte_lpm *lpm); · line 224
Quoted 2 lines
lib/librte_lpm/rte_lpm.h +1
-0next_hop); +rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth,struct
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
lib/librte_lpm/rte_lpm.h rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
Quoted 5 lines
lib/librte_lpm/rte_lpm.h +0
-0rte_lpm_res *res);/**
* Check if a rule is present in the LPM table,lib/librte_lpm/rte_lpm.h +0
-0@@ -238,7 +239,7 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip,
uint8_tQuoted 4 lines
lib/librte_lpm/rte_lpm.h +0
-0depth, uint8_t next_hop); */ int rte_lpm_is_rule_present(struct rte_lpm *lpm, uint32_t ip, uint8_tdepth,
Quoted 7 lines
lib/librte_lpm/rte_lpm.h rte_lpm_delete_all(struct rte_lpm *lpm); · line 278
Quoted 7 lines
lib/librte_lpm/rte_lpm.h +1
-1-uint8_t *next_hop); + struct rte_lpm_res *res);/** * Delete a rule from the LPM table.
lib/librte_lpm/rte_lpm.h +0
-0@@ -277,29 +278,43 @@ rte_lpm_delete_all(struct rte_lpm *lpm);* -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
hit
*/
static inline int
-rte_lpm_lookup(structrte_lpm*lpm,uint32_tip,uint8_t
*next_hop)Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+rte_lpm_lookup(struct
rte_lpm*lpm,uint32_tip, struct
rte_lpm_resQuoted 12 lines
Quoted 12 lines
*res)
Quoted 11 lines
lib/librte_lpm/rte_lpm.h
Quoted 11 lines
{ unsigned tbl24_index = (ip >> 8);lib/librte_lpm/rte_lpm.h +5
-3-uint16_t tbl_entry; - +#ifdef RTE_LIBRTE_LPM_ASNUM +uint64_t tbl_entry; +#else +uint32_t tbl_entry; +#endif /* DEBUG: Check user input arguments. */ - RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (next_hop ==NULL)),
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.h
Quoted 2 lines
lib/librte_lpm/rte_lpm.h +1
-1-EINVAL); + RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (res == NULL)), -EINVAL);
Quoted 1 line
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
lib/librte_lpm/rte_lpm.h
Quoted 10 lines
/* Copy tbl24 entry */lib/librte_lpm/rte_lpm.h +5
-2- tbl_entry = *(const uint16_t *)&lpm->tbl24[tbl24_index]; - +#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t *)&lpm->tbl24[tbl24_index]; +#else + tbl_entry = *(const uint32_t *)&lpm->tbl24[tbl24_index]; +#endif /* Copy tbl8 entry (only if needed) */ if (unlikely((tbl_entry & RTE_LPM_VALID_EXT_ENTRY_BITMASK)==
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {unsigned
tbl8_index= (uint8_t)ip +
- ((uint8_t)tbl_entry *RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
+ ((*(structrte_lpm_tbl_entry
*)&tbl_entry).tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES);-
tbl_entry= *(constuint16_t*)&lpm->tbl8[tbl8_index];
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_lpm/rte_lpm.h
Quoted 2 lines
lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t*)&lpm->tbl8[tbl8_index];
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_lpm/rte_lpm.h
Quoted 2 lines
lib/librte_lpm/rte_lpm.h +2
-0+#else + tbl_entry = *(const uint32_t*)&lpm->tbl8[tbl8_index];
Quoted 16 lines
Quoted 16 lines
Quoted 5 lines
lib/librte_lpm/rte_lpm.h
Quoted 5 lines
lib/librte_lpm/rte_lpm.h +2
-2+#endif } - - *next_hop = (uint8_t )tbl_entry; + res->next_hop = ((struct rte_lpm_tbl_entry*)&tbl_entry)->next_hop;
Quoted 10 lines
Quoted 10 lines
+
res->fwd_class= ((structrte_lpm_tbl_entry
*)&tbl_entry)->fwd_class;lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + res->as_num = ((struct rte_lpm_tbl_entry*)&tbl_entry)->as_num;
lib/librte_lpm/rte_lpm.h +2
-0+#endif return (tbl_entry &RTE_LPM_LOOKUP_SUCCESS ) ?0 : -ENOENT ; + }Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookup(struct rte_lpm *lpm, uint32_t
Quoted 2 lines
/**
lib/librte_lpm/rte_lpm.h +0
-0@@ -322,19 +337,25 @@ rte_lpm_lookup(struct rte_lpm *lpm, uint32_tip,
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookup(struct rte_lpm *lpm, uint32_t · line 330
Quoted 11 lines
lib/librte_lpm/rte_lpm.h +2
-3uint8_t *next_hop) * @return * -EINVAL for incorrect arguments, otherwise 0 */ -#define rte_lpm_lookup_bulk (lpm, ips, next_hops, n) \ - rte_lpm_lookup_bulk_func(lpm, ips, next_hops, n) +#define rte_lpm_lookup_bulk (lpm, ips, res_tbl, n) \ + rte_lpm_lookup_bulk_func(lpm, ips, res_tbl, n) static inline int -rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const
uint32_t*Quoted 54 lines
Quoted 54 lines
ips,
Quoted 2 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookup(struct rte_lpm *lpm, uint32_t · line 345
Quoted 2 lines
lib/librte_lpm/rte_lpm.h +1
-1- uint16_t * next_hops, const unsigned n) +rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t*ips,
Quoted 31 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookup_bulk_func(const struct rte_lpm
Quoted 19 lines
lib/librte_lpm/rte_lpm.h +8
-1+ struct rte_lpm_res *res_tbl, const unsigned n) { unsigned i; +int ret =0 ; +#ifdef RTE_LIBRTE_LPM_ASNUM +uint64_t tbl_entry; +#else +uint32_t tbl_entry; +#endif unsigned tbl24_indexes[n];/* DEBUG: Check user input arguments. */ RTE_LPM_RETURN_IF_TRUE (((lpm ==NULL ) || (ips ==NULL ) || - (next_hops ==NULL )), -EINVAL ); + (res_tbl ==NULL )), -EINVAL );for (i =0 ; i < n; i++) {tbl24_indexes[i] = ips[i] >> 8;lib/librte_lpm/rte_lpm.h +0
-0@@ -342,20 +363,32 @@ rte_lpm_lookup_bulk_func(const struct rte_lpm*lpm,
Quoted 11 lines
lib/librte_lpm/rte_lpm.h +3
-2const uint32_t * ips, for (i = 0; i < n; i++) {/* Simply copy tbl24 entry to output */ - next_hops[i] = *(const uint16_t *)&lpm->tbl24[tbl24_indexes[i]]; - +#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t *)&lpm->tbl24[tbl24_indexes[i]]; +#else Quoted 8 lines
lib/librte_lpm/rte_lpm.h
Quoted 8 lines
lib/librte_lpm/rte_lpm.h +2
-1+ tbl_entry = *(const uint32_t *)&lpm->tbl24[tbl24_indexes[i]]; +#endif /* Overwrite output with tbl8 entry if needed */ - if (unlikely((next_hops[i] &
RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==lib/librte_lpm/rte_lpm.h +1
-1- RTE_LPM_VALID_EXT_ENTRY_BITMASK)) { + if (unlikely((tbl_entry &
RTE_LPM_VALID_EXT_ENTRY_BITMASK)Quoted 6 lines
lib/librte_lpm/rte_lpm.h
Quoted 6 lines
==
lib/librte_lpm/rte_lpm.h +1
-2+ RTE_LPM_VALID_EXT_ENTRY_BITMASK)) { unsigned tbl8_index = (uint8_t)ips[i] + - ((uint8_t)next_hops[i] * -
RTE_LPM_TBL8_GROUP_NUM_ENTRIES);Quoted 3 lines
Quoted 3 lines
+ ((*(struct
rte_lpm_tbl_entry
*)&tbl_entry).tbl8_gindex *RTE_LPM_TBL8_GROUP_NUM_ENTRIES);Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
lib/librte_lpm/rte_lpm.h
Quoted 11 lines
- next_hops[i] = *(const
uint16_t
*)&lpm->tbl8[tbl8_index];lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + tbl_entry = *(const uint64_t*)&lpm->tbl8[tbl8_index];
lib/librte_lpm/rte_lpm.h +2
-0+#else + tbl_entry = *(const uint32_t*)&lpm->tbl8[tbl8_index];
lib/librte_lpm/rte_lpm.h +2
-0+#endif } + res_tbl[i].next_hop = ((struct
rte_lpm_tbl_entryQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
*)&tbl_entry)->next_hop;
+ res_tbl[i].fwd_class = ((struct
rte_lpm_tbl_entryQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/librte_lpm/rte_lpm.h
Quoted 3 lines
*)&tbl_entry)->next_hop;
lib/librte_lpm/rte_lpm.h +2
-0+#ifdef RTE_LIBRTE_LPM_ASNUM + res_tbl[i].as_num = ((struct
rte_lpm_tbl_entryQuoted 23 lines
Quoted 23 lines
Quoted 23 lines
lib/librte_lpm/rte_lpm.h rte_lpm_lookupx4(const struct rte_lpm *lpm,
Quoted 10 lines
*)&tbl_entry)->as_num;
lib/librte_lpm/rte_lpm.h +3
-1+#endif + ret |=1 << i; } -return 0 ; +return ret; }/* Mask four results. */ @@ -477,4 +510,4 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm,
__m128iip,Quoted 12 lines
lib/librte_lpm/rte_lpm.h +1
-1uint16_t hop[4], }#endif -#endif /* _RTE_LPM_H_ */ +#endif /* _RTE_LPM_EXT_H_ */ 2015-10-24 9:09 GMT+03:00 Matthew Hall <[email protected]>:
Quoted 3 lines · Matthew Hall
Quoted 2 lines
On Fri, Oct 23, 2015 at 03:51:48PM +0200, Michal Jastrzebski
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
From: Michal Kobylinski <[email protected]>
The current DPDK implementation for LPM for IPv4 and IPv6
limits
Quoted 4 lines
Quoted 4 lines
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
number of next hops to 256, as the next hop ID is an 8-bit long
field.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Proposed extension increase number of next hops for IPv4 to
2^24
Quoted 4 lines
Quoted 4 lines
and
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
also allows 32-bits read/write operations.
This patchset requires additional change to
rte_tablelibraryto
Quoted 4 lines
Quoted 4 lines
meet
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
ABI compatibility requirements. A v2 will be sent next week.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
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
Quoted 4 lines
Quoted 4 lines
as
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
part of a job. My patchset is attached to this email.
One possible advantage with my patchset, compared to others, is
that
Quoted 2 lines
Quoted 2 lines
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
space problem is fixed in both IPV4 and in IPV6, to prevent
asymmetry
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
between these two standards, which is something I try to avoid as
much
Quoted 4 lines
as
Quoted 3 lines
Quoted 3 lines
humanly possible.
This is because my application code is green-field, so I
absolutely
Quoted 2 lines
Quoted 2 lines
don't
Quoted 1 line
Quoted 1 line
Quoted 1 line
want to put any ugly hacks or incompatibilities in this code if
I can
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
possibly avoid it.
Otherwise, I am not necessarily as expert about
rte_lpmas someof
Quoted 4 lines
Quoted 4 lines
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
full-time guys, but I think with four or five of us in the thread
hammering
Quoted 1 line
Quoted 1 line
Quoted 1 line
out patches we will be able to create something amazing together
and
Quoted 4 lines
Quoted 4 lines
I
Quoted 3 lines
am
Quoted 2 lines
Quoted 2 lines
very very very very very happy about this.
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Matthew.
Hi Vladimir,
Thanks for sharing Your implementation.
Could You please clarify whatas_numandfwd_classfields represent? The second issue I have is that Your patch doesn’t want to apply ontop of
Quoted 5 lines
Quoted 5 lines
current head. Could You check this please?
Best regards
Michal
Quoted 38 lines
-----Original Message-----
From: Matthew Hall [mailto:[email protected]]
Sent: Saturday, October 24, 2015 8:10 AM
To: Jastrzebski, MichalX K; Kobylinski, MichalX
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v1 0/3] lpm: increase number of next hops for lpm (ipv4)Quoted 8 lines · Matthew Hall
Quoted 7 lines · Michal Jastrzebski
From: Michal Kobylinski <[email protected]>
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.
Quoted 8 lines
Quoted 2 lines
This patchset requires additional change to
rte_tablelibrary 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.
Quoted 6 lines
Otherwise, I am not necessarily as expert about
rte_lpmas 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.
Hi Matthew,
Thank You for a patch-set.
I can't apply patch 0001-... , could You check it please? I have the following error:
Checking patch lib/librte_lpm/rte_lpm.h...
error: while searching for:
#endif
/** @internal bitmask with valid and ext_entry/valid_group fields set */ #define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x0300
/** Bitmask used to indicate successful lookup */
#define RTE_LPM_LOOKUP_SUCCESS 0x0100
#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. */
union {
uint8_t next_hop;
uint8_t tbl8_gindex;
};
/* 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. */
};/** @internal Tbl8 entry structure. */
struct rte_lpm_tbl8_entry {
uint8_t next_hop; /**< 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. */
};#else
struct rte_lpm_tbl24_entry {
error: patch failed: lib/librte_lpm/rte_lpm.h:82
error: lib/librte_lpm/rte_lpm.h: patch does not apply
Best regards,
Michal
Quoted 1 line
I can't apply patch 0001-... , could You check it please?
I generated it from a rebase of my own copy of DPDK against DPDK upstream master.
So I'm not sure why it would not apply against latest DPDK master.
But I will try it and see what could be the reason.
Matthew.
Hi Michal,
Try patch below. I will send it via git.
Regards,
Vladimir
2015-10-26 21:40 GMT+03:00 Matthew Hall <[email protected]>:
Quoted 11 lines
Quoted 1 line
I can't apply patch 0001-... , could You check it please?
I generated it from a rebase of my own copy of DPDK against DPDK upstream master.
So I'm not sure why it would not apply against latest DPDK master.
But I will try it and see what could be the reason.
Matthew.
cover lpm: increase number of next hops for lpm (ipv4)
--- config/common_bsdapp | 1 + config/common_linuxapp | 1 + lib/librte_lpm/rte_lpm.c | 194 +++++++++++++++++++++++++++++------------------ lib/librte_lpm/rte_lpm.h | 163 +++++++++++++++++++++++---------------- 4 files changed, 219 insertions(+), 140 deletions(-)
config/common_bsdapp +1 -0
@@ -344,6 +344,7 @@ CONFIG_RTE_LIBRTE_JOBSTATS=y # CONFIG_RTE_LIBRTE_LPM=y CONFIG_RTE_LIBRTE_LPM_DEBUG=n +CONFIG_RTE_LIBRTE_LPM_ASNUM=n # # Compile librte_acl
config/common_linuxapp +1 -0
@@ -352,6 +352,7 @@ CONFIG_RTE_LIBRTE_JOBSTATS=y # CONFIG_RTE_LIBRTE_LPM=y CONFIG_RTE_LIBRTE_LPM_DEBUG=n +CONFIG_RTE_LIBRTE_LPM_ASNUM=n # # Compile librte_acl
lib/librte_lpm/rte_lpm.c +119 -75
412 lines not on this page · raw message
lib/librte_lpm/rte_lpm.h +98 -65
258 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Quoted 10 lines · Matthew Hall
Quoted 1 line
I can't apply patch 0001-... , could You check it please?
I generated it from a rebase of my own copy of DPDK against DPDK upstream master.
So I'm not sure why it would not apply against latest DPDK master.
But I will try it and see what could be the reason.
Matthew.
Hello Michal,
I rechecked it.
The patch does apply perfectly to the latest master branch fromgit://dpdk.org/dpdk using git apply.
Can you take a second look? I compile my DPDK with the clang compiler BTW.
Matthew.