1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright 2008 Cisco Systems, Inc. All rights reserved. 4 * Copyright 2007 Nuova Systems, Inc. All rights reserved. 5 */ 6 #ifndef _VNIC_DEVCMD_H_ 7 #define _VNIC_DEVCMD_H_ 8 9 #define _CMD_NBITS 14 10 #define _CMD_VTYPEBITS 10 11 #define _CMD_FLAGSBITS 6 12 #define _CMD_DIRBITS 2 13 14 #define _CMD_NMASK ((1 << _CMD_NBITS)-1) 15 #define _CMD_VTYPEMASK ((1 << _CMD_VTYPEBITS)-1) 16 #define _CMD_FLAGSMASK ((1 << _CMD_FLAGSBITS)-1) 17 #define _CMD_DIRMASK ((1 << _CMD_DIRBITS)-1) 18 19 #define _CMD_NSHIFT 0 20 #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS) 21 #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS) 22 #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS) 23 24 /* 25 * Direction bits (from host perspective). 26 */ 27 #define _CMD_DIR_NONE 0U 28 #define _CMD_DIR_WRITE 1U 29 #define _CMD_DIR_READ 2U 30 #define _CMD_DIR_RW (_CMD_DIR_WRITE | _CMD_DIR_READ) 31 32 /* 33 * Flag bits. 34 */ 35 #define _CMD_FLAGS_NONE 0U 36 #define _CMD_FLAGS_NOWAIT 1U 37 38 /* 39 * vNIC type bits. 40 */ 41 #define _CMD_VTYPE_NONE 0U 42 #define _CMD_VTYPE_ENET 1U 43 #define _CMD_VTYPE_FC 2U 44 #define _CMD_VTYPE_SCSI 4U 45 #define _CMD_VTYPE_ALL (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI) 46 47 /* 48 * Used to create cmds.. 49 */ 50 #define _CMDCF(dir, flags, vtype, nr) \ 51 (((dir) << _CMD_DIRSHIFT) | \ 52 ((flags) << _CMD_FLAGSSHIFT) | \ 53 ((vtype) << _CMD_VTYPESHIFT) | \ 54 ((nr) << _CMD_NSHIFT)) 55 #define _CMDC(dir, vtype, nr) _CMDCF(dir, 0, vtype, nr) 56 #define _CMDCNW(dir, vtype, nr) _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr) 57 58 /* 59 * Used to decode cmds.. 60 */ 61 #define _CMD_DIR(cmd) (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK) 62 #define _CMD_FLAGS(cmd) (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK) 63 #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK) 64 #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK) 65 66 enum vnic_devcmd_cmd { 67 CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0), 68 69 /* mcpu fw info in mem: (u64)a0=paddr to struct vnic_devcmd_fw_info */ 70 CMD_MCPU_FW_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1), 71 72 /* dev-specific block member: 73 * in: (u16)a0=offset,(u8)a1=size 74 * out: a0=value */ 75 CMD_DEV_SPEC = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2), 76 77 /* stats clear */ 78 CMD_STATS_CLEAR = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3), 79 80 /* stats dump in mem: (u64)a0=paddr to stats area, 81 * (u16)a1=sizeof stats area */ 82 CMD_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 4), 83 84 /* set Rx packet filter: (u32)a0=filters (see CMD_PFILTER_*) */ 85 CMD_PACKET_FILTER = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 7), 86 87 /* hang detection notification */ 88 CMD_HANG_NOTIFY = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 8), 89 90 /* MAC address in (u48)a0 */ 91 CMD_MAC_ADDR = _CMDC(_CMD_DIR_READ, 92 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 9), 93 94 /* disable/enable promisc mode: (u8)a0=0/1 */ 95 /***** XXX DEPRECATED *****/ 96 CMD_PROMISC_MODE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 10), 97 98 /* disable/enable all-multi mode: (u8)a0=0/1 */ 99 /***** XXX DEPRECATED *****/ 100 CMD_ALLMULTI_MODE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 11), 101 102 /* add addr from (u48)a0 */ 103 CMD_ADDR_ADD = _CMDCNW(_CMD_DIR_WRITE, 104 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 12), 105 106 /* del addr from (u48)a0 */ 107 CMD_ADDR_DEL = _CMDCNW(_CMD_DIR_WRITE, 108 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 13), 109 110 /* add VLAN id in (u16)a0 */ 111 CMD_VLAN_ADD = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 14), 112 113 /* del VLAN id in (u16)a0 */ 114 CMD_VLAN_DEL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 15), 115 116 /* nic_cfg in (u32)a0 */ 117 CMD_NIC_CFG = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16), 118 119 /* union vnic_rss_key in mem: (u64)a0=paddr, (u16)a1=len */ 120 CMD_RSS_KEY = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 17), 121 122 /* union vnic_rss_cpu in mem: (u64)a0=paddr, (u16)a1=len */ 123 CMD_RSS_CPU = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 18), 124 125 /* initiate softreset */ 126 CMD_SOFT_RESET = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 19), 127 128 /* softreset status: 129 * out: a0=0 reset complete, a0=1 reset in progress */ 130 CMD_SOFT_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 20), 131 132 /* set struct vnic_devcmd_notify buffer in mem: 133 * in: 134 * (u64)a0=paddr to notify (set paddr=0 to unset) 135 * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify) 136 * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr) 137 * out: 138 * (u32)a1 = effective size 139 */ 140 CMD_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21), 141 142 /* UNDI API: (u64)a0=paddr to s_PXENV_UNDI_ struct, 143 * (u8)a1=PXENV_UNDI_xxx */ 144 CMD_UNDI = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 22), 145 146 /* initiate open sequence (u32)a0=flags (see CMD_OPENF_*) */ 147 CMD_OPEN = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23), 148 149 /* open status: 150 * out: a0=0 open complete, a0=1 open in progress */ 151 CMD_OPEN_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24), 152 153 /* close vnic */ 154 CMD_CLOSE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25), 155 156 /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */ 157 CMD_INIT = _CMDCNW(_CMD_DIR_READ, _CMD_VTYPE_ALL, 26), 158 159 /* variant of CMD_INIT, with provisioning info 160 * (u64)a0=paddr of vnic_devcmd_provinfo 161 * (u32)a1=sizeof provision info 162 */ 163 CMD_INIT_PROV_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 27), 164 165 /* enable virtual link */ 166 CMD_ENABLE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28), 167 168 /* disable virtual link */ 169 CMD_DISABLE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29), 170 171 /* stats dump all vnics on uplink in mem: (u64)a0=paddr (u32)a1=uif */ 172 CMD_STATS_DUMP_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30), 173 174 /* init status: 175 * out: a0=0 init complete, a0=1 init in progress 176 * if a0=0, a1=errno */ 177 CMD_INIT_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 31), 178 179 /* INT13 API: (u64)a0=paddr to vnic_int13_params struct 180 * (u8)a1=INT13_CMD_xxx */ 181 CMD_INT13 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_FC, 32), 182 183 /* logical uplink enable/disable: (u64)a0: 0/1=disable/enable */ 184 CMD_LOGICAL_UPLINK = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 33), 185 186 /* undo initialize of virtual link */ 187 CMD_DEINIT = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34), 188 189 /* check fw capability of a cmd: 190 * in: (u32)a0=cmd 191 * out: (u32)a0=errno, 0:valid cmd, a1=supported VNIC_STF_* bits */ 192 CMD_CAPABILITY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 36), 193 194 /* persistent binding info 195 * in: (u64)a0=paddr of arg 196 * (u32)a1=CMD_PERBI_XXX */ 197 CMD_PERBI = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_FC, 37), 198 199 /* Interrupt Assert Register functionality 200 * in: (u16)a0=interrupt number to assert 201 */ 202 CMD_IAR = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 38), 203 204 /* initiate hangreset, like softreset after hang detected */ 205 CMD_HANG_RESET = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 39), 206 207 /* hangreset status: 208 * out: a0=0 reset complete, a0=1 reset in progress */ 209 CMD_HANG_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 40), 210 211 /* 212 * Set hw ingress packet vlan rewrite mode: 213 * in: (u32)a0=new vlan rewrite mode 214 * out: (u32)a0=old vlan rewrite mode */ 215 CMD_IG_VLAN_REWRITE_MODE = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 41), 216 217 /* 218 * in: (u16)a0=bdf of target vnic 219 * (u32)a1=cmd to proxy 220 * a2-a15=args to cmd in a1 221 * out: (u32)a0=status of proxied cmd 222 * a1-a15=out args of proxied cmd */ 223 CMD_PROXY_BY_BDF = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 42), 224 225 /* 226 * As for BY_BDF except a0 is index of hvnlink subordinate vnic 227 * or SR-IOV virtual vnic 228 */ 229 CMD_PROXY_BY_INDEX = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 43), 230 231 /* 232 * For HPP toggle: 233 * adapter-info-get 234 * in: (u64)a0=phsical address of buffer passed in from caller. 235 * (u16)a1=size of buffer specified in a0. 236 * out: (u64)a0=phsical address of buffer passed in from caller. 237 * (u16)a1=actual bytes from VIF-CONFIG-INFO TLV, or 238 * 0 if no VIF-CONFIG-INFO TLV was ever received. */ 239 CMD_CONFIG_INFO_GET = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 44), 240 241 /* 242 * INT13 API: (u64)a0=paddr to vnic_int13_params struct 243 * (u32)a1=INT13_CMD_xxx 244 */ 245 CMD_INT13_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 45), 246 247 /* 248 * Set default vlan: 249 * in: (u16)a0=new default vlan 250 * (u16)a1=zero for overriding vlan with param a0, 251 * non-zero for resetting vlan to the default 252 * out: (u16)a0=old default vlan 253 */ 254 CMD_SET_DEFAULT_VLAN = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 46), 255 256 /* init_prov_info2: 257 * Variant of CMD_INIT_PROV_INFO, where it will not try to enable 258 * the vnic until CMD_ENABLE2 is issued. 259 * (u64)a0=paddr of vnic_devcmd_provinfo 260 * (u32)a1=sizeof provision info 261 */ 262 CMD_INIT_PROV_INFO2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 47), 263 264 /* enable2: 265 * (u32)a0=0 ==> standby 266 * =CMD_ENABLE2_ACTIVE ==> active 267 */ 268 CMD_ENABLE2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 48), 269 270 /* 271 * cmd_status: 272 * Returns the status of the specified command 273 * Input: 274 * a0 = command for which status is being queried. 275 * Possible values are: 276 * CMD_SOFT_RESET 277 * CMD_HANG_RESET 278 * CMD_OPEN 279 * CMD_INIT 280 * CMD_INIT_PROV_INFO 281 * CMD_DEINIT 282 * CMD_INIT_PROV_INFO2 283 * CMD_ENABLE2 284 * Output: 285 * if status == STAT_ERROR 286 * a0 = ERR_ENOTSUPPORTED - status for command in a0 is 287 * not supported 288 * if status == STAT_NONE 289 * a0 = status of the devcmd specified in a0 as follows. 290 * ERR_SUCCESS - command in a0 completed successfully 291 * ERR_EINPROGRESS - command in a0 is still in progress 292 */ 293 CMD_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 49), 294 295 /* 296 * Returns interrupt coalescing timer conversion factors. 297 * After calling this devcmd, ENIC driver can convert 298 * interrupt coalescing timer in usec into CPU cycles as follows: 299 * 300 * intr_timer_cycles = intr_timer_usec * multiplier / divisor 301 * 302 * Interrupt coalescing timer in usecs can be be converted/obtained 303 * from CPU cycles as follows: 304 * 305 * intr_timer_usec = intr_timer_cycles * divisor / multiplier 306 * 307 * in: none 308 * out: (u32)a0 = multiplier 309 * (u32)a1 = divisor 310 * (u32)a2 = maximum timer value in usec 311 */ 312 CMD_INTR_COAL_CONVERT = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 50), 313 314 /* 315 * ISCSI DUMP API: 316 * in: (u64)a0=paddr of the param or param itself 317 * (u32)a1=ISCSI_CMD_xxx 318 */ 319 CMD_ISCSI_DUMP_REQ = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 51), 320 321 /* 322 * ISCSI DUMP STATUS API: 323 * in: (u32)a0=cmd tag 324 * in: (u32)a1=ISCSI_CMD_xxx 325 * out: (u32)a0=cmd status 326 */ 327 CMD_ISCSI_DUMP_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 52), 328 329 /* 330 * Subvnic migration from MQ <--> VF. 331 * Enable the LIF migration from MQ to VF and vice versa. MQ and VF 332 * indexes are statically bound at the time of initialization. 333 * Based on the 334 * direction of migration, the resources of either MQ or the VF shall 335 * be attached to the LIF. 336 * in: (u32)a0=Direction of Migration 337 * 0=> Migrate to VF 338 * 1=> Migrate to MQ 339 * (u32)a1=VF index (MQ index) 340 */ 341 CMD_MIGRATE_SUBVNIC = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 53), 342 343 /* 344 * Register / Deregister the notification block for MQ subvnics 345 * in: 346 * (u64)a0=paddr to notify (set paddr=0 to unset) 347 * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify) 348 * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr) 349 * out: 350 * (u32)a1 = effective size 351 */ 352 CMD_SUBVNIC_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 54), 353 354 /* 355 * Set the predefined mac address as default 356 * in: 357 * (u48)a0=mac addr 358 */ 359 CMD_SET_MAC_ADDR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 55), 360 361 /* Update the provisioning info of the given VIF 362 * (u64)a0=paddr of vnic_devcmd_provinfo 363 * (u32)a1=sizeof provision info 364 */ 365 CMD_PROV_INFO_UPDATE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 56), 366 367 /* 368 * Initialization for the devcmd2 interface. 369 * in: (u64) a0=host result buffer physical address 370 * in: (u16) a1=number of entries in result buffer 371 */ 372 CMD_INITIALIZE_DEVCMD2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 57) 373 }; 374 375 /* flags for CMD_OPEN */ 376 #define CMD_OPENF_OPROM 0x1 /* open coming from option rom */ 377 378 #define CMD_OPENF_RQ_ENABLE_THEN_POST 0x2 379 380 /* flags for CMD_INIT */ 381 #define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */ 382 383 /* flags for CMD_PACKET_FILTER */ 384 #define CMD_PFILTER_DIRECTED 0x01 385 #define CMD_PFILTER_MULTICAST 0x02 386 #define CMD_PFILTER_BROADCAST 0x04 387 #define CMD_PFILTER_PROMISCUOUS 0x08 388 #define CMD_PFILTER_ALL_MULTICAST 0x10 389 390 enum vnic_devcmd_status { 391 STAT_NONE = 0, 392 STAT_BUSY = 1 << 0, /* cmd in progress */ 393 STAT_ERROR = 1 << 1, /* last cmd caused error (code in a0) */ 394 }; 395 396 enum vnic_devcmd_error { 397 ERR_SUCCESS = 0, 398 ERR_EINVAL = 1, 399 ERR_EFAULT = 2, 400 ERR_EPERM = 3, 401 ERR_EBUSY = 4, 402 ERR_ECMDUNKNOWN = 5, 403 ERR_EBADSTATE = 6, 404 ERR_ENOMEM = 7, 405 ERR_ETIMEDOUT = 8, 406 ERR_ELINKDOWN = 9, 407 }; 408 409 struct vnic_devcmd_fw_info { 410 char fw_version[32]; 411 char fw_build[32]; 412 char hw_version[32]; 413 char hw_serial_number[32]; 414 }; 415 416 struct vnic_devcmd_notify { 417 u32 csum; /* checksum over following words */ 418 419 u32 link_state; /* link up == 1 */ 420 u32 port_speed; /* effective port speed (rate limit) */ 421 u32 mtu; /* MTU */ 422 u32 msglvl; /* requested driver msg lvl */ 423 u32 uif; /* uplink interface */ 424 u32 status; /* status bits (see VNIC_STF_*) */ 425 u32 error; /* error code (see ERR_*) for first ERR */ 426 u32 link_down_cnt; /* running count of link down transitions */ 427 }; 428 #define VNIC_STF_FATAL_ERR 0x0001 /* fatal fw error */ 429 430 struct vnic_devcmd_provinfo { 431 u8 oui[3]; 432 u8 type; 433 u8 data[]; 434 }; 435 436 /* 437 * Writing cmd register causes STAT_BUSY to get set in status register. 438 * When cmd completes, STAT_BUSY will be cleared. 439 * 440 * If cmd completed successfully STAT_ERROR will be clear 441 * and args registers contain cmd-specific results. 442 * 443 * If cmd error, STAT_ERROR will be set and args[0] contains error code. 444 * 445 * status register is read-only. While STAT_BUSY is set, 446 * all other register contents are read-only. 447 */ 448 449 /* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */ 450 #define VNIC_DEVCMD_NARGS 15 451 struct vnic_devcmd { 452 u32 status; /* RO */ 453 u32 cmd; /* RW */ 454 u64 args[VNIC_DEVCMD_NARGS]; /* RW cmd args (little-endian) */ 455 }; 456 457 /* 458 * Version 2 of the interface. 459 * 460 * Some things are carried over, notably the vnic_devcmd_cmd enum. 461 */ 462 463 /* 464 * Flags for vnic_devcmd2.flags 465 */ 466 467 #define DEVCMD2_FNORESULT 0x1 /* Don't copy result to host */ 468 469 #define VNIC_DEVCMD2_NARGS VNIC_DEVCMD_NARGS 470 471 struct vnic_devcmd2 { 472 u16 pad; 473 u16 flags; 474 u32 cmd; /* same command #defines as original */ 475 u64 args[VNIC_DEVCMD2_NARGS]; 476 }; 477 478 #define VNIC_DEVCMD2_NRESULTS VNIC_DEVCMD_NARGS 479 struct devcmd2_result { 480 u64 results[VNIC_DEVCMD2_NRESULTS]; 481 u32 pad; 482 u16 completed_index; /* into copy WQ */ 483 u8 error; /* same error codes as original */ 484 u8 color; /* 0 or 1 as with completion queues */ 485 }; 486 487 #define DEVCMD2_RING_SIZE 32 488 #define DEVCMD2_DESC_SIZE 128 489 490 #define DEVCMD2_RESULTS_SIZE_MAX ((1 << 16) - 1) 491 492 #endif /* _VNIC_DEVCMD_H_ */ 493