xref: /freebsd/sys/dev/cxgb/cxgb_offload.h (revision 2008043f386721d58158e37e0d7e50df8095942d)
1 /**************************************************************************
2 SPDX-License-Identifier: BSD-2-Clause
3 
4 Copyright (c) 2007-2008, Chelsio Inc.
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10  1. Redistributions of source code must retain the above copyright notice,
11     this list of conditions and the following disclaimer.
12 
13  2. Neither the name of the Chelsio Corporation nor the names of its
14     contributors may be used to endorse or promote products derived from
15     this software without specific prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND 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 COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
28 
29 ***************************************************************************/
30 
31 #ifndef _CXGB_OFFLOAD_H
32 #define _CXGB_OFFLOAD_H
33 
34 #ifdef TCP_OFFLOAD
35 enum {
36 	ULD_TOM = 1,
37 	ULD_IWARP = 2,
38 };
39 
40 struct adapter;
41 struct uld_info {
42 	SLIST_ENTRY(uld_info) link;
43 	int refcount;
44 	int uld_id;
45 	int (*activate)(struct adapter *);
46 	int (*deactivate)(struct adapter *);
47 };
48 
49 struct tom_tunables {
50 	int sndbuf;
51 	int ddp;
52 	int indsz;
53 	int ddp_thres;
54 };
55 
56 /* CPL message priority levels */
57 enum {
58 	CPL_PRIORITY_DATA = 0,     /* data messages */
59 	CPL_PRIORITY_CONTROL = 1   /* offload control messages */
60 };
61 
62 #define S_HDR_NDESC	0
63 #define M_HDR_NDESC	0xf
64 #define V_HDR_NDESC(x)	((x) << S_HDR_NDESC)
65 #define G_HDR_NDESC(x)	(((x) >> S_HDR_NDESC) & M_HDR_NDESC)
66 
67 #define S_HDR_QSET	4
68 #define M_HDR_QSET	0xf
69 #define V_HDR_QSET(x)	((x) << S_HDR_QSET)
70 #define G_HDR_QSET(x)	(((x) >> S_HDR_QSET) & M_HDR_QSET)
71 
72 #define S_HDR_CTRL	8
73 #define V_HDR_CTRL(x)	((x) << S_HDR_CTRL)
74 #define F_HDR_CTRL	V_HDR_CTRL(1U)
75 
76 #define S_HDR_DF	9
77 #define V_HDR_DF(x)	((x) << S_HDR_DF)
78 #define F_HDR_DF	V_HDR_DF(1U)
79 
80 #define S_HDR_SGL	10
81 #define V_HDR_SGL(x)	((x) << S_HDR_SGL)
82 #define F_HDR_SGL	V_HDR_SGL(1U)
83 
84 struct ofld_hdr
85 {
86 	void *sgl;	/* SGL, if F_HDR_SGL set in flags */
87 	int plen;	/* amount of payload (in bytes) */
88 	int flags;
89 };
90 
91 /*
92  * Convenience function for fixed size CPLs that fit in 1 desc.
93  */
94 #define M_GETHDR_OFLD(qset, ctrl, cpl) \
95     m_gethdr_ofld(qset, ctrl, sizeof(*cpl), (void **)&cpl)
96 static inline struct mbuf *
97 m_gethdr_ofld(int qset, int ctrl, int cpllen, void **cpl)
98 {
99 	struct mbuf *m;
100 	struct ofld_hdr *oh;
101 
102 	m = m_gethdr(M_NOWAIT, MT_DATA);
103 	if (m == NULL)
104 		return (NULL);
105 
106 	oh = mtod(m, struct ofld_hdr *);
107 	oh->flags = V_HDR_NDESC(1) | V_HDR_QSET(qset) | V_HDR_CTRL(ctrl);
108 	*cpl = (void *)(oh + 1);
109 	m->m_pkthdr.len = m->m_len = sizeof(*oh) + cpllen;
110 
111 	return (m);
112 }
113 
114 int t3_register_uld(struct uld_info *);
115 int t3_unregister_uld(struct uld_info *);
116 int t3_activate_uld(struct adapter *, int);
117 int t3_deactivate_uld(struct adapter *, int);
118 #endif	/* TCP_OFFLOAD */
119 
120 #define CXGB_UNIMPLEMENTED() \
121     panic("IMPLEMENT: %s:%s:%d", __FUNCTION__, __FILE__, __LINE__)
122 
123 #endif
124