Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
0002 /* Copyright (c) 2019-2021 Marvell International Ltd. All rights reserved. */
0003 
0004 #ifndef _PRESTERA_ROUTER_HW_H_
0005 #define _PRESTERA_ROUTER_HW_H_
0006 
0007 struct prestera_vr {
0008     struct list_head router_node;
0009     refcount_t refcount;
0010     u32 tb_id;          /* key (kernel fib table id) */
0011     u16 hw_vr_id;           /* virtual router ID */
0012     u8 __pad[2];
0013 };
0014 
0015 struct prestera_rif_entry {
0016     struct prestera_rif_entry_key {
0017         struct prestera_iface iface;
0018     } key;
0019     struct prestera_vr *vr;
0020     unsigned char addr[ETH_ALEN];
0021     u16 hw_id; /* rif_id */
0022     struct list_head router_node; /* ht */
0023 };
0024 
0025 struct prestera_ip_addr {
0026     union {
0027         __be32 ipv4;
0028         struct in6_addr ipv6;
0029     } u;
0030     enum {
0031         PRESTERA_IPV4 = 0,
0032         PRESTERA_IPV6
0033     } v;
0034 };
0035 
0036 struct prestera_fib_key {
0037     struct prestera_ip_addr addr;
0038     u32 prefix_len;
0039     u32 tb_id;
0040 };
0041 
0042 struct prestera_fib_info {
0043     struct prestera_vr *vr;
0044     struct list_head vr_node;
0045     enum prestera_fib_type {
0046         PRESTERA_FIB_TYPE_INVALID = 0,
0047         /* It can be connected route
0048          * and will be overlapped with neighbours
0049          */
0050         PRESTERA_FIB_TYPE_TRAP,
0051         PRESTERA_FIB_TYPE_DROP
0052     } type;
0053 };
0054 
0055 struct prestera_fib_node {
0056     struct rhash_head ht_node; /* node of prestera_vr */
0057     struct prestera_fib_key key;
0058     struct prestera_fib_info info; /* action related info */
0059 };
0060 
0061 struct prestera_rif_entry *
0062 prestera_rif_entry_find(const struct prestera_switch *sw,
0063             const struct prestera_rif_entry_key *k);
0064 void prestera_rif_entry_destroy(struct prestera_switch *sw,
0065                 struct prestera_rif_entry *e);
0066 struct prestera_rif_entry *
0067 prestera_rif_entry_create(struct prestera_switch *sw,
0068               struct prestera_rif_entry_key *k,
0069               u32 tb_id, const unsigned char *addr);
0070 struct prestera_fib_node *prestera_fib_node_find(struct prestera_switch *sw,
0071                          struct prestera_fib_key *key);
0072 void prestera_fib_node_destroy(struct prestera_switch *sw,
0073                    struct prestera_fib_node *fib_node);
0074 struct prestera_fib_node *
0075 prestera_fib_node_create(struct prestera_switch *sw,
0076              struct prestera_fib_key *key,
0077              enum prestera_fib_type fib_type);
0078 int prestera_router_hw_init(struct prestera_switch *sw);
0079 void prestera_router_hw_fini(struct prestera_switch *sw);
0080 
0081 #endif /* _PRESTERA_ROUTER_HW_H_ */