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