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