2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2010 Chelsio Communications, Inc.
6 * Written by: Navdeep Parhar <np@FreeBSD.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #ifndef __T4_OFFLOAD_H__
32 #define __T4_OFFLOAD_H__
33 #include <sys/param.h>
35 #include <sys/condvar.h>
37 #define INIT_ULPTX_WRH(w, wrlen, atomic, tid) do { \
38 (w)->wr_hi = htonl(V_FW_WR_OP(FW_ULPTX_WR) | V_FW_WR_ATOMIC(atomic)); \
39 (w)->wr_mid = htonl(V_FW_WR_LEN16(DIV_ROUND_UP(wrlen, 16)) | \
40 V_FW_WR_FLOWID(tid)); \
41 (w)->wr_lo = cpu_to_be64(0); \
44 #define INIT_ULPTX_WR(w, wrlen, atomic, tid) \
45 INIT_ULPTX_WRH(&((w)->wr), wrlen, atomic, tid)
47 #define INIT_TP_WR(w, tid) do { \
48 (w)->wr.wr_hi = htonl(V_FW_WR_OP(FW_TP_WR) | \
49 V_FW_WR_IMMDLEN(sizeof(*w) - sizeof(w->wr))); \
50 (w)->wr.wr_mid = htonl(V_FW_WR_LEN16(DIV_ROUND_UP(sizeof(*w), 16)) | \
51 V_FW_WR_FLOWID(tid)); \
52 (w)->wr.wr_lo = cpu_to_be64(0); \
55 #define INIT_TP_WR_MIT_CPL(w, cpl, tid) do { \
57 OPCODE_TID(w) = htonl(MK_OPCODE_TID(cpl, tid)); \
60 TAILQ_HEAD(stid_head, stid_region);
64 TAILQ_ENTRY(stid_region) link;
65 u_int used; /* # of stids used by this region */
66 u_int free; /* # of contiguous stids free right after this region */
70 * Max # of ATIDs. The absolute HW max is 14b (enough for 16K) but we reserve
71 * the upper 3b for use as a cookie to demux the reply.
73 #define MAX_ATIDS 2048U
77 union aopen_entry *next;
80 /* cxgbe_rate_tag flags */
82 EO_FLOWC_PENDING = (1 << 0), /* flowc needs to be sent */
83 EO_FLOWC_RPL_PENDING = (1 << 1), /* flowc credits due back */
84 EO_SND_TAG_REF = (1 << 2), /* kernel has a ref on us */
85 EO_FLUSH_RPL_PENDING = (1 << 3), /* credit flush rpl due back */
88 struct cxgbe_rate_tag {
90 struct adapter *adapter;
95 struct mbufq pending_tx, pending_fwack;
97 struct sge_ofld_txq *eo_txq;
101 uint64_t max_rate; /* in bytes/s */
102 uint8_t tx_total; /* total tx WR credits (in 16B units) */
103 uint8_t tx_credits; /* tx WR credits (in 16B units) available */
104 uint8_t tx_nocompl; /* tx WR credits since last compl request */
105 uint8_t ncompl; /* # of completions outstanding. */
108 static inline struct cxgbe_rate_tag *
109 mst_to_crt(struct m_snd_tag *t)
111 return (__containerof(t, struct cxgbe_rate_tag, com));
115 struct cxgbe_rate_tag *cst;
116 union etid_entry *next;
120 * Holds the size, base address, start, end, etc. of various types of TIDs. The
121 * tables themselves are allocated dynamically.
144 struct mtx stid_lock __aligned(CACHE_LINE_SIZE);
145 struct listen_ctx **stid_tab;
147 u_int nstids_free_head; /* # of available stids at the beginning */
148 struct stid_head stids;
150 struct mtx atid_lock __aligned(CACHE_LINE_SIZE);
151 union aopen_entry *atid_tab;
152 union aopen_entry *afree;
155 /* High priority filters and normal filters share the lock and cv. */
156 struct mtx ftid_lock __aligned(CACHE_LINE_SIZE);
158 struct filter_entry *ftid_tab;
159 struct filter_entry *hpftid_tab;
161 u_int hpftids_in_use;
164 * hashfilter and TOE are mutually exclusive and both use ntids and
165 * tids_in_use. The lock and cv are used only by hashfilter.
167 struct mtx hftid_lock __aligned(CACHE_LINE_SIZE);
172 void *hftid_hash_4t; /* LIST_HEAD(, filter_entry) *hftid_hash_4t; */
173 u_long hftid_4t_mask;
174 void *hftid_hash_tid; /* LIST_HEAD(, filter_entry) *hftid_hash_tid; */
175 u_long hftid_tid_mask;
177 struct mtx etid_lock __aligned(CACHE_LINE_SIZE);
178 union etid_entry *etid_tab;
179 union etid_entry *efree;
188 struct t4_virt_res { /* virtualized HW resources */
190 struct t4_range iscsi;
191 struct t4_range stag;
212 SLIST_ENTRY(uld_info) link;
215 int (*activate)(struct adapter *);
216 int (*deactivate)(struct adapter *);
217 void (*async_event)(struct adapter *);
220 struct tom_tunables {
228 int cop_managed_offloading;
230 int update_hc_on_pmtu_change;
234 /* iWARP driver tunables */
239 struct tls_tunables {
245 int t4_register_uld(struct uld_info *);
246 int t4_unregister_uld(struct uld_info *);
247 int t4_activate_uld(struct adapter *, int);
248 int t4_deactivate_uld(struct adapter *, int);
249 int uld_active(struct adapter *, int);