xref: /f-stack/dpdk/drivers/net/cxgbe/mps_tcam.h (revision 4418919f)
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 };
21 
22 struct mps_tcam_entry {
23 	u8 state;
24 	u16 idx;
25 
26 	/* add data here which uniquely defines an entry */
27 	u8 eth_addr[RTE_ETHER_ADDR_LEN];
28 	u8 mask[RTE_ETHER_ADDR_LEN];
29 
30 	struct mpstcam_table *mpstcam; /* backptr */
31 	rte_atomic32_t refcnt;
32 };
33 
34 struct mpstcam_table {
35 	u16 size;
36 	rte_rwlock_t lock;
37 	u16 free_idx;	/* next free index */
38 	bool full;	/* since free index can be present
39 			 * anywhere in the table, size and
40 			 * free_idx cannot alone determine
41 			 * if the table is full
42 			 */
43 	struct mps_tcam_entry entry[0];
44 };
45 
46 struct mpstcam_table *t4_init_mpstcam(struct adapter *adap);
47 void t4_cleanup_mpstcam(struct adapter *adap);
48 int cxgbe_mpstcam_alloc(struct port_info *pi, const u8 *mac, const u8 *mask);
49 int cxgbe_mpstcam_remove(struct port_info *pi, u16 idx);
50 int cxgbe_mpstcam_modify(struct port_info *pi, int idx, const u8 *addr);
51 
52 #endif /* _CXGBE_MPSTCAM_H_ */
53