xref: /freebsd/sys/dev/cxgb/cxgb_ioctl.h (revision f0a75d274af375d15b97b830966b99a02b7db911)
1 /**************************************************************************
2 
3 Copyright (c) 2007, 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. Redistributions in binary form must reproduce the above copyright
13     notice, this list of conditions and the following disclaimer in the
14     documentation and/or other materials provided with the distribution.
15 
16  3. Neither the name of the Chelsio Corporation nor the names of its
17     contributors may be used to endorse or promote products derived from
18     this software without specific prior written permission.
19 
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31 
32 $FreeBSD$
33 
34 ***************************************************************************/
35 #ifndef __CHIOCTL_H__
36 #define __CHIOCTL_H__
37 
38 /*
39  * Ioctl commands specific to this driver.
40  */
41 enum {
42 	CH_SETREG = 0x40,
43 	CH_GETREG,
44 	CH_SETTPI,
45 	CH_GETTPI,
46 	CH_DEVUP,
47 	CH_GETMTUTAB,
48 	CH_SETMTUTAB,
49 	CH_GETMTU,
50 	CH_SET_PM,
51 	CH_GET_PM,
52 	CH_GET_TCAM,
53 	CH_SET_TCAM,
54 	CH_GET_TCB,
55 	CH_READ_TCAM_WORD,
56 	CH_GET_MEM,
57 	CH_GET_SGE_CONTEXT,
58 	CH_GET_SGE_DESC,
59 	CH_LOAD_FW,
60 	CH_GET_PROTO,
61 	CH_SET_PROTO,
62 	CH_SET_TRACE_FILTER,
63 	CH_SET_QSET_PARAMS,
64 	CH_GET_QSET_PARAMS,
65 	CH_SET_QSET_NUM,
66 	CH_GET_QSET_NUM,
67 	CH_SET_PKTSCHED,
68 	CH_IFCONF_GETREGS,
69 	CH_GETMIIREGS,
70 	CH_SETMIIREGS,
71 
72 };
73 
74 struct ch_reg {
75 	uint32_t addr;
76 	uint32_t val;
77 };
78 
79 struct ch_cntxt {
80 	uint32_t cntxt_type;
81 	uint32_t cntxt_id;
82 	uint32_t data[4];
83 };
84 
85 /* context types */
86 enum { CNTXT_TYPE_EGRESS, CNTXT_TYPE_FL, CNTXT_TYPE_RSP, CNTXT_TYPE_CQ };
87 
88 struct ch_desc {
89 	uint32_t cmd;
90 	uint32_t queue_num;
91 	uint32_t idx;
92 	uint32_t size;
93 	uint8_t  data[128];
94 };
95 
96 struct ch_mem_range {
97 	uint32_t cmd;
98 	uint32_t mem_id;
99 	uint32_t addr;
100 	uint32_t len;
101 	uint32_t version;
102 	uint8_t  *buf;
103 };
104 
105 struct ch_qset_params {
106 	uint32_t qset_idx;
107 	int32_t  txq_size[3];
108 	int32_t  rspq_size;
109 	int32_t  fl_size[2];
110 	int32_t  intr_lat;
111 	int32_t  polling;
112 	int32_t  cong_thres;
113 	int32_t  vector;
114 	int32_t  qnum;
115 };
116 
117 struct ch_pktsched_params {
118 	uint32_t cmd;
119 	uint8_t  sched;
120 	uint8_t  idx;
121 	uint8_t  min;
122 	uint8_t  max;
123 	uint8_t  binding;
124 };
125 
126 struct ch_hw_sched {
127 	uint32_t cmd;
128 	uint8_t  sched;
129 	int8_t   mode;
130 	int8_t   channel;
131 	int32_t  kbps;        /* rate in Kbps */
132 	int32_t  class_ipg;   /* tenths of nanoseconds */
133 	int32_t  flow_ipg;    /* usec */
134 };
135 
136 #ifndef TCB_SIZE
137 # define TCB_SIZE   128
138 #endif
139 
140 /* TCB size in 32-bit words */
141 #define TCB_WORDS (TCB_SIZE / 4)
142 
143 enum { MEM_CM, MEM_PMRX, MEM_PMTX };   /* ch_mem_range.mem_id values */
144 
145 struct ch_mtus {
146 	uint32_t cmd;
147 	uint32_t nmtus;
148 	uint16_t mtus[NMTUS];
149 };
150 
151 struct ch_pm {
152 	uint32_t cmd;
153 	uint32_t tx_pg_sz;
154 	uint32_t tx_num_pg;
155 	uint32_t rx_pg_sz;
156 	uint32_t rx_num_pg;
157 	uint32_t pm_total;
158 };
159 
160 struct ch_tcam {
161 	uint32_t cmd;
162 	uint32_t tcam_size;
163 	uint32_t nservers;
164 	uint32_t nroutes;
165 	uint32_t nfilters;
166 };
167 
168 struct ch_tcb {
169 	uint32_t cmd;
170 	uint32_t tcb_index;
171 	uint32_t tcb_data[TCB_WORDS];
172 };
173 
174 struct ch_tcam_word {
175 	uint32_t cmd;
176 	uint32_t addr;
177 	uint32_t buf[3];
178 };
179 
180 struct ch_trace {
181 	uint32_t cmd;
182 	uint32_t sip;
183 	uint32_t sip_mask;
184 	uint32_t dip;
185 	uint32_t dip_mask;
186 	uint16_t sport;
187 	uint16_t sport_mask;
188 	uint16_t dport;
189 	uint16_t dport_mask;
190 	uint32_t vlan:12,
191 		vlan_mask:12,
192 		intf:4,
193 		intf_mask:4;
194 	uint8_t  proto;
195 	uint8_t  proto_mask;
196 	uint8_t  invert_match:1,
197 		config_tx:1,
198 		config_rx:1,
199 		trace_tx:1,
200 		trace_rx:1;
201 };
202 
203 #define REGDUMP_SIZE  (4 * 1024)
204 
205 struct ifconf_regs {
206 	uint32_t  version;
207 	uint32_t  len; /* bytes */
208 	uint8_t   *data;
209 };
210 
211 struct mii_data {
212 	uint32_t phy_id;
213 	uint32_t reg_num;
214 	uint32_t val_in;
215 	uint32_t val_out;
216 };
217 
218 #define CHELSIO_SETREG              _IOW('f', CH_SETREG, struct ch_reg)
219 #define CHELSIO_GETREG              _IOWR('f', CH_GETREG, struct ch_reg)
220 #define CHELSIO_GET_MEM             _IOWR('f', CH_GET_MEM, struct ch_mem_range)
221 #define CHELSIO_GET_SGE_CONTEXT     _IOWR('f', CH_GET_SGE_CONTEXT, struct ch_cntxt)
222 #define CHELSIO_GET_SGE_DESC        _IOWR('f', CH_GET_SGE_DESC, struct ch_desc)
223 #define CHELSIO_GET_QSET_PARAMS     _IOWR('f', CH_GET_QSET_PARAMS, struct ch_qset_params)
224 #define CHELSIO_SET_QSET_PARAMS     _IOW('f', CH_SET_QSET_PARAMS, struct ch_qset_params)
225 #define CHELSIO_GET_QSET_NUM        _IOWR('f', CH_GET_QSET_NUM, struct ch_reg)
226 #define CHELSIO_SET_QSET_NUM        _IOW('f', CH_SET_QSET_NUM, struct ch_reg)
227 
228 
229 #define CHELSIO_SET_TRACE_FILTER    _IOW('f', CH_SET_TRACE_FILTER, struct ch_trace)
230 #define CHELSIO_SET_PKTSCHED        _IOW('f', CH_SET_PKTSCHED, struct ch_pktsched_params)
231 #define CHELSIO_IFCONF_GETREGS      _IOWR('f', CH_IFCONF_GETREGS, struct ifconf_regs)
232 #define SIOCGMIIREG                 _IOWR('f', CH_GETMIIREGS, struct mii_data)
233 #define SIOCSMIIREG                 _IOWR('f', CH_SETMIIREGS, struct mii_data)
234 #endif
235