xref: /dpdk/drivers/net/cxgbe/mps_tcam.h (revision e12a0166c80f65e35408f4715b2f3a60763c3741)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Chelsio Communications.
3  * All rights reserved.
4  */
5 
6 #ifndef _CXGBE_MPSTCAM_H_
7 #define _CXGBE_MPSTCAM_H_
8 
9 #include "base/common.h"
10 
11 enum {
12 	MPS_ENTRY_UNUSED,	/* Keep this first so memset 0 renders
13 				 * the correct state. Other states can
14 				 * be added in future like MPS_ENTRY_BUSY
15 				 * to reduce contention while mboxing
16 				 * the request to f/w or to denote attributes
17 				 * for a specific entry
18 				 */
19 	MPS_ENTRY_USED,
20 	MPS_ENTRY_RAWF, /* Reserved for RAW MAC Filters */
21 };
22 
23 struct mps_tcam_entry {
24 	u8 state;
25 	u16 idx;
26 
27 	/* add data here which uniquely defines an entry */
28 	u8 eth_addr[RTE_ETHER_ADDR_LEN];
29 	u8 mask[RTE_ETHER_ADDR_LEN];
30 
31 	struct mpstcam_table *mpstcam; /* backptr */
32 	RTE_ATOMIC(u32) refcnt;
33 };
34 
35 struct mpstcam_table {
36 	u16 size;
37 	rte_rwlock_t lock;
38 	u16 free_idx;	/* next free index */
39 	bool full;	/* since free index can be present
40 			 * anywhere in the table, size and
41 			 * free_idx cannot alone determine
42 			 * if the table is full
43 			 */
44 	struct mps_tcam_entry entry[];
45 };
46 
47 struct mpstcam_table *t4_init_mpstcam(struct adapter *adap);
48 void t4_cleanup_mpstcam(struct adapter *adap);
49 int cxgbe_mpstcam_alloc(struct port_info *pi, const u8 *mac, const u8 *mask);
50 int cxgbe_mpstcam_remove(struct port_info *pi, u16 idx);
51 int cxgbe_mpstcam_modify(struct port_info *pi, int idx, const u8 *addr);
52 int cxgbe_mpstcam_rawf_enable(struct port_info *pi);
53 int cxgbe_mpstcam_rawf_disable(struct port_info *pi);
54 #endif /* _CXGBE_MPSTCAM_H_ */
55