Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
[linux/fpc-iii.git] / drivers / scsi / snic / vnic_devcmd.h
blobd81b4f0ceaaa3842eaf6d254fbe54b6af3cee6bf
1 /*
2 * Copyright 2014 Cisco Systems, Inc. All rights reserved.
4 * This program is free software; you may redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15 * SOFTWARE.
18 #ifndef _VNIC_DEVCMD_H_
19 #define _VNIC_DEVCMD_H_
21 #define _CMD_NBITS 14
22 #define _CMD_VTYPEBITS 10
23 #define _CMD_FLAGSBITS 6
24 #define _CMD_DIRBITS 2
26 #define _CMD_NMASK ((1 << _CMD_NBITS)-1)
27 #define _CMD_VTYPEMASK ((1 << _CMD_VTYPEBITS)-1)
28 #define _CMD_FLAGSMASK ((1 << _CMD_FLAGSBITS)-1)
29 #define _CMD_DIRMASK ((1 << _CMD_DIRBITS)-1)
31 #define _CMD_NSHIFT 0
32 #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS)
33 #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS)
34 #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS)
37 * Direction bits (from host perspective).
39 #define _CMD_DIR_NONE 0U
40 #define _CMD_DIR_WRITE 1U
41 #define _CMD_DIR_READ 2U
42 #define _CMD_DIR_RW (_CMD_DIR_WRITE | _CMD_DIR_READ)
45 * Flag bits.
47 #define _CMD_FLAGS_NONE 0U
48 #define _CMD_FLAGS_NOWAIT 1U
51 * vNIC type bits.
53 #define _CMD_VTYPE_NONE 0U
54 #define _CMD_VTYPE_ENET 1U
55 #define _CMD_VTYPE_FC 2U
56 #define _CMD_VTYPE_SCSI 4U
57 #define _CMD_VTYPE_ALL (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI)
60 * Used to create cmds..
62 #define _CMDCF(dir, flags, vtype, nr) \
63 (((dir) << _CMD_DIRSHIFT) | \
64 ((flags) << _CMD_FLAGSSHIFT) | \
65 ((vtype) << _CMD_VTYPESHIFT) | \
66 ((nr) << _CMD_NSHIFT))
67 #define _CMDC(dir, vtype, nr) _CMDCF(dir, 0, vtype, nr)
68 #define _CMDCNW(dir, vtype, nr) _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr)
71 * Used to decode cmds..
73 #define _CMD_DIR(cmd) (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK)
74 #define _CMD_FLAGS(cmd) (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK)
75 #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK)
76 #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK)
78 enum vnic_devcmd_cmd {
79 CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0),
81 /* mcpu fw info in mem: (u64)a0=paddr to struct vnic_devcmd_fw_info */
82 CMD_MCPU_FW_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1),
84 /* dev-specific block member:
85 * in: (u16)a0=offset,(u8)a1=size
86 * out: a0=value */
87 CMD_DEV_SPEC = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2),
89 /* stats clear */
90 CMD_STATS_CLEAR = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3),
92 /* stats dump in mem: (u64)a0=paddr to stats area,
93 * (u16)a1=sizeof stats area */
94 CMD_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 4),
96 /* nic_cfg in (u32)a0 */
97 CMD_NIC_CFG = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
99 /* set struct vnic_devcmd_notify buffer in mem:
100 * in:
101 * (u64)a0=paddr to notify (set paddr=0 to unset)
102 * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify)
103 * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr)
104 * out:
105 * (u32)a1 = effective size
107 CMD_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21),
109 /* initiate open sequence (u32)a0=flags (see CMD_OPENF_*) */
110 CMD_OPEN = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23),
112 /* open status:
113 * out: a0=0 open complete, a0=1 open in progress */
114 CMD_OPEN_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24),
116 /* close vnic */
117 CMD_CLOSE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25),
119 /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
120 CMD_INIT = _CMDCNW(_CMD_DIR_READ, _CMD_VTYPE_ALL, 26),
122 /* enable virtual link */
123 CMD_ENABLE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
125 /* enable virtual link, waiting variant. */
126 CMD_ENABLE_WAIT = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
128 /* disable virtual link */
129 CMD_DISABLE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29),
131 /* stats dump all vnics on uplink in mem: (u64)a0=paddr (u32)a1=uif */
132 CMD_STATS_DUMP_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30),
134 /* init status:
135 * out: a0=0 init complete, a0=1 init in progress
136 * if a0=0, a1=errno */
137 CMD_INIT_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 31),
139 /* undo initialize of virtual link */
140 CMD_DEINIT = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34),
142 /* check fw capability of a cmd:
143 * in: (u32)a0=cmd
144 * out: (u32)a0=errno, 0:valid cmd, a1=supported VNIC_STF_* bits */
145 CMD_CAPABILITY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 36),
148 * Initialization for the devcmd2 interface.
149 * in: (u64) a0=host result buffer physical address
150 * in: (u16) a1=number of entries in result buffer
152 CMD_INITIALIZE_DEVCMD2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 57)
155 /* flags for CMD_OPEN */
156 #define CMD_OPENF_OPROM 0x1 /* open coming from option rom */
158 /* flags for CMD_INIT */
159 #define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */
161 /* flags for CMD_PACKET_FILTER */
162 #define CMD_PFILTER_DIRECTED 0x01
163 #define CMD_PFILTER_MULTICAST 0x02
164 #define CMD_PFILTER_BROADCAST 0x04
165 #define CMD_PFILTER_PROMISCUOUS 0x08
166 #define CMD_PFILTER_ALL_MULTICAST 0x10
168 enum vnic_devcmd_status {
169 STAT_NONE = 0,
170 STAT_BUSY = 1 << 0, /* cmd in progress */
171 STAT_ERROR = 1 << 1, /* last cmd caused error (code in a0) */
174 enum vnic_devcmd_error {
175 ERR_SUCCESS = 0,
176 ERR_EINVAL = 1,
177 ERR_EFAULT = 2,
178 ERR_EPERM = 3,
179 ERR_EBUSY = 4,
180 ERR_ECMDUNKNOWN = 5,
181 ERR_EBADSTATE = 6,
182 ERR_ENOMEM = 7,
183 ERR_ETIMEDOUT = 8,
184 ERR_ELINKDOWN = 9,
187 struct vnic_devcmd_fw_info {
188 char fw_version[32];
189 char fw_build[32];
190 char hw_version[32];
191 char hw_serial_number[32];
194 struct vnic_devcmd_notify {
195 u32 csum; /* checksum over following words */
197 u32 link_state; /* link up == 1 */
198 u32 port_speed; /* effective port speed (rate limit) */
199 u32 mtu; /* MTU */
200 u32 msglvl; /* requested driver msg lvl */
201 u32 uif; /* uplink interface */
202 u32 status; /* status bits (see VNIC_STF_*) */
203 u32 error; /* error code (see ERR_*) for first ERR */
204 u32 link_down_cnt; /* running count of link down transitions */
206 #define VNIC_STF_FATAL_ERR 0x0001 /* fatal fw error */
208 struct vnic_devcmd_provinfo {
209 u8 oui[3];
210 u8 type;
211 u8 data[0];
215 * Writing cmd register causes STAT_BUSY to get set in status register.
216 * When cmd completes, STAT_BUSY will be cleared.
218 * If cmd completed successfully STAT_ERROR will be clear
219 * and args registers contain cmd-specific results.
221 * If cmd error, STAT_ERROR will be set and args[0] contains error code.
223 * status register is read-only. While STAT_BUSY is set,
224 * all other register contents are read-only.
227 /* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */
228 #define VNIC_DEVCMD_NARGS 15
229 struct vnic_devcmd {
230 u32 status; /* RO */
231 u32 cmd; /* RW */
232 u64 args[VNIC_DEVCMD_NARGS]; /* RW cmd args (little-endian) */
237 * Version 2 of the interface.
239 * Some things are carried over, notably the vnic_devcmd_cmd enum.
243 * Flags for vnic_devcmd2.flags
246 #define DEVCMD2_FNORESULT 0x1 /* Don't copy result to host */
248 #define VNIC_DEVCMD2_NARGS VNIC_DEVCMD_NARGS
249 struct vnic_devcmd2 {
250 u16 pad;
251 u16 flags;
252 u32 cmd; /* same command #defines as original */
253 u64 args[VNIC_DEVCMD2_NARGS];
256 #define VNIC_DEVCMD2_NRESULTS VNIC_DEVCMD_NARGS
257 struct devcmd2_result {
258 u64 results[VNIC_DEVCMD2_NRESULTS];
259 u32 pad;
260 u16 completed_index; /* into copy WQ */
261 u8 error; /* same error codes as original */
262 u8 color; /* 0 or 1 as with completion queues */
265 #define DEVCMD2_RING_SIZE 32
266 #define DEVCMD2_DESC_SIZE 128
268 #define DEVCMD2_RESULTS_SIZE_MAX ((1 << 16) - 1)
270 #endif /* _VNIC_DEVCMD_H_ */