1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /* Copyright (c) 2019-2021 Marvell International Ltd. All rights reserved. */
4 #ifndef _PRESTERA_ROUTER_HW_H_
5 #define _PRESTERA_ROUTER_HW_H_
8 struct list_head router_node;
10 u32 tb_id; /* key (kernel fib table id) */
11 u16 hw_vr_id; /* virtual router ID */
15 struct prestera_rif_entry {
16 struct prestera_rif_entry_key {
17 struct prestera_iface iface;
19 struct prestera_vr *vr;
20 unsigned char addr[ETH_ALEN];
21 u16 hw_id; /* rif_id */
22 struct list_head router_node; /* ht */
25 struct prestera_ip_addr {
36 struct prestera_fib_key {
37 struct prestera_ip_addr addr;
42 struct prestera_fib_info {
43 struct prestera_vr *vr;
44 struct list_head vr_node;
45 enum prestera_fib_type {
46 PRESTERA_FIB_TYPE_INVALID = 0,
47 /* It can be connected route
48 * and will be overlapped with neighbours
50 PRESTERA_FIB_TYPE_TRAP,
51 PRESTERA_FIB_TYPE_DROP
55 struct prestera_fib_node {
56 struct rhash_head ht_node; /* node of prestera_vr */
57 struct prestera_fib_key key;
58 struct prestera_fib_info info; /* action related info */
61 struct prestera_rif_entry *
62 prestera_rif_entry_find(const struct prestera_switch *sw,
63 const struct prestera_rif_entry_key *k);
64 void prestera_rif_entry_destroy(struct prestera_switch *sw,
65 struct prestera_rif_entry *e);
66 struct prestera_rif_entry *
67 prestera_rif_entry_create(struct prestera_switch *sw,
68 struct prestera_rif_entry_key *k,
69 u32 tb_id, const unsigned char *addr);
70 struct prestera_fib_node *prestera_fib_node_find(struct prestera_switch *sw,
71 struct prestera_fib_key *key);
72 void prestera_fib_node_destroy(struct prestera_switch *sw,
73 struct prestera_fib_node *fib_node);
74 struct prestera_fib_node *
75 prestera_fib_node_create(struct prestera_switch *sw,
76 struct prestera_fib_key *key,
77 enum prestera_fib_type fib_type);
78 int prestera_router_hw_init(struct prestera_switch *sw);
79 void prestera_router_hw_fini(struct prestera_switch *sw);
81 #endif /* _PRESTERA_ROUTER_HW_H_ */