xref: /dpdk/lib/table/rte_table_lpm_ipv6.h (revision e1a06e391ba74f9c4d46a6ecef6d8ee084f4229e)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #ifndef __INCLUDE_RTE_TABLE_LPM_IPV6_H__
6 #define __INCLUDE_RTE_TABLE_LPM_IPV6_H__
7 
8 /**
9  * @file
10  * RTE Table LPM for IPv6
11  *
12  * This table uses the Longest Prefix Match (LPM) algorithm to uniquely
13  * associate data to lookup keys.
14  *
15  * Use-case: IP routing table. Routes that are added to the table associate a
16  * next hop to an IP prefix. The IP prefix is specified as IP address and depth
17  * and cover for a multitude of lookup keys (i.e. destination IP addresses)
18  * that all share the same data (i.e. next hop). The next hop information
19  * typically contains the output interface ID, the IP address of the next hop
20  * station (which is part of the same IP network the output interface is
21  * connected to) and other flags and counters.
22  *
23  * The LPM primitive only allows associating an 8-bit number (next hop ID) to
24  * an IP prefix, while a routing table can potentially contain thousands of
25  * routes or even more. This means that the same next hop ID (and next hop
26  * information) has to be shared by multiple routes, which makes sense, as
27  * multiple remote networks could be reached through the same next hop.
28  * Therefore, when a route is added or updated, the LPM table has to check
29  * whether the same next hop is already in use before using a new next hop ID
30  * for this route.
31  *
32  * The comparison between different next hops is done for the first
33  * “entry_unique_size” bytes of the next hop information (configurable
34  * parameter), which have to uniquely identify the next hop, therefore the user
35  * has to carefully manage the format of the LPM table entry (i.e.  the next
36  * hop information) so that any next hop data that changes value during
37  * run-time (e.g. counters) is placed outside of this area.
38  */
39 
40 #include <stdint.h>
41 
42 #include <rte_common.h>
43 #include <rte_ip6.h>
44 
45 #include "rte_table.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 #define RTE_LPM_IPV6_ADDR_SIZE (RTE_DEPRECATED(RTE_LPM_IPV6_ADDR_SIZE) RTE_IPV6_ADDR_SIZE)
52 
53 /** LPM table parameters */
54 struct rte_table_lpm_ipv6_params {
55 	/** Table name */
56 	const char *name;
57 
58 	/** Maximum number of LPM rules (i.e. IP routes) */
59 	uint32_t n_rules;
60 
61 	uint32_t number_tbl8s;
62 
63 	/** Number of bytes at the start of the table entry that uniquely
64 	identify the entry. Cannot be bigger than table entry size. */
65 	uint32_t entry_unique_size;
66 
67 	/** Byte offset within input packet meta-data where lookup key (i.e.
68 	the destination IP address) is located. */
69 	uint32_t offset;
70 };
71 
72 /** LPM table rule (i.e. route), specified as IP prefix. While the key used by
73 the lookup operation is the destination IP address (read from the input packet
74 meta-data), the entry add and entry delete operations work with LPM rules, with
75 each rule covering for a multitude of lookup keys (destination IP addresses)
76 that share the same data (next hop). */
77 struct rte_table_lpm_ipv6_key {
78 	/** IP address */
79 	struct rte_ipv6_addr ip;
80 
81 	/** IP address depth. The most significant "depth" bits of the IP
82 	address specify the network part of the IP address, while the rest of
83 	the bits specify the host part of the address and are ignored for the
84 	purpose of route specification. */
85 	uint8_t depth;
86 };
87 
88 /** LPM table operations */
89 extern struct rte_table_ops rte_table_lpm_ipv6_ops;
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 
95 #endif
96