Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(c) 2018 Chelsio Communications. 3 : : * All rights reserved. 4 : : */ 5 : : 6 : : #ifndef _CXGBE_OFLD_H_ 7 : : #define _CXGBE_OFLD_H_ 8 : : 9 : : #include <rte_bitmap.h> 10 : : 11 : : #include "cxgbe_filter.h" 12 : : 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); \ 20 : : } while (0) 21 : : 22 : : #define INIT_TP_WR_MIT_CPL(w, cpl, tid) do { \ 23 : : INIT_TP_WR(w, tid); \ 24 : : OPCODE_TID(w) = cpu_to_be32(MK_OPCODE_TID(cpl, tid)); \ 25 : : } while (0) 26 : : 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); \ 33 : : } while (0) 34 : : 35 : : /* 36 : : * Max # of ATIDs. The absolute HW max is 16K but we keep it lower. 37 : : */ 38 : : #define MAX_ATIDS 8192U 39 : : 40 : : union aopen_entry { 41 : : void *data; 42 : : union aopen_entry *next; 43 : : }; 44 : : 45 : : /* 46 : : * Holds the size, base address, free list start, etc of filter TID. 47 : : * The tables themselves are allocated dynamically. 48 : : */ 49 : : struct tid_info { 50 : : void **tid_tab; 51 : : unsigned int ntids; 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; 58 : : 59 : : union aopen_entry *afree; 60 : : unsigned int atids_in_use; 61 : : 62 : : /* TIDs in the TCAM */ 63 : : RTE_ATOMIC(u32) tids_in_use; 64 : : /* TIDs in the HASH */ 65 : : RTE_ATOMIC(u32) hash_tids_in_use; 66 : : RTE_ATOMIC(u32) conns_in_use; 67 : : 68 : : alignas(RTE_CACHE_LINE_SIZE) rte_spinlock_t atid_lock; 69 : : rte_spinlock_t ftid_lock; 70 : : }; 71 : : 72 : : static inline void *lookup_tid(const struct tid_info *t, unsigned int tid) 73 : : { 74 [ # # # # : 0 : return tid < t->ntids ? t->tid_tab[tid] : NULL; # # # # ] 75 : : } 76 : : 77 : : static inline void *lookup_atid(const struct tid_info *t, unsigned int atid) 78 : : { 79 [ # # # # ]: 0 : return atid < t->natids ? t->atid_tab[atid].data : NULL; 80 : : } 81 : : 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); 88 : : 89 : : #endif /* _CXGBE_OFLD_H_ */