1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Chelsio Communications.
9 #include <rte_bitmap.h>
11 #include "cxgbe_filter.h"
13 #define INIT_TP_WR(w, tid) do { \
14 (w)->wr.wr_hi = cpu_to_be32(V_FW_WR_OP(FW_TP_WR) | \
15 V_FW_WR_IMMDLEN(sizeof(*w) - sizeof(w->wr))); \
16 (w)->wr.wr_mid = cpu_to_be32( \
17 V_FW_WR_LEN16(DIV_ROUND_UP(sizeof(*w), 16)) | \
18 V_FW_WR_FLOWID(tid)); \
19 (w)->wr.wr_lo = cpu_to_be64(0); \
22 #define INIT_TP_WR_MIT_CPL(w, cpl, tid) do { \
24 OPCODE_TID(w) = cpu_to_be32(MK_OPCODE_TID(cpl, tid)); \
27 #define INIT_ULPTX_WR(w, wrlen, atomic, tid) do { \
28 (w)->wr.wr_hi = cpu_to_be32(V_FW_WR_OP(FW_ULPTX_WR) | \
29 V_FW_WR_ATOMIC(atomic)); \
30 (w)->wr.wr_mid = cpu_to_be32(V_FW_WR_LEN16(DIV_ROUND_UP(wrlen, 16)) | \
31 V_FW_WR_FLOWID(tid)); \
32 (w)->wr.wr_lo = cpu_to_be64(0); \
36 * Max # of ATIDs. The absolute HW max is 16K but we keep it lower.
38 #define MAX_ATIDS 8192U
42 union aopen_entry *next;
46 * Holds the size, base address, free list start, etc of filter TID.
47 * The tables themselves are allocated dynamically.
52 struct filter_entry *ftid_tab; /* Normal filters */
53 union aopen_entry *atid_tab;
54 struct rte_bitmap *ftid_bmap;
55 uint8_t *ftid_bmap_array;
56 unsigned int nftids, natids;
57 unsigned int ftid_base, hash_base;
59 union aopen_entry *afree;
60 unsigned int atids_in_use;
62 /* TIDs in the TCAM */
64 /* TIDs in the HASH */
68 rte_spinlock_t atid_lock __rte_cache_aligned;
69 rte_spinlock_t ftid_lock;
72 static inline void *lookup_tid(const struct tid_info *t, unsigned int tid)
74 return tid < t->ntids ? t->tid_tab[tid] : NULL;
77 static inline void *lookup_atid(const struct tid_info *t, unsigned int atid)
79 return atid < t->natids ? t->atid_tab[atid].data : NULL;
82 int cxgbe_alloc_atid(struct tid_info *t, void *data);
83 void cxgbe_free_atid(struct tid_info *t, unsigned int atid);
84 void cxgbe_remove_tid(struct tid_info *t, unsigned int qid, unsigned int tid,
85 unsigned short family);
86 void cxgbe_insert_tid(struct tid_info *t, void *data, unsigned int tid,
87 unsigned short family);
89 #endif /* _CXGBE_OFLD_H_ */