1*9e39c5baSBill Taylor /* 2*9e39c5baSBill Taylor * CDDL HEADER START 3*9e39c5baSBill Taylor * 4*9e39c5baSBill Taylor * The contents of this file are subject to the terms of the 5*9e39c5baSBill Taylor * Common Development and Distribution License (the "License"). 6*9e39c5baSBill Taylor * You may not use this file except in compliance with the License. 7*9e39c5baSBill Taylor * 8*9e39c5baSBill Taylor * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*9e39c5baSBill Taylor * or http://www.opensolaris.org/os/licensing. 10*9e39c5baSBill Taylor * See the License for the specific language governing permissions 11*9e39c5baSBill Taylor * and limitations under the License. 12*9e39c5baSBill Taylor * 13*9e39c5baSBill Taylor * When distributing Covered Code, include this CDDL HEADER in each 14*9e39c5baSBill Taylor * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*9e39c5baSBill Taylor * If applicable, add the following below this CDDL HEADER, with the 16*9e39c5baSBill Taylor * fields enclosed by brackets "[]" replaced with your own identifying 17*9e39c5baSBill Taylor * information: Portions Copyright [yyyy] [name of copyright owner] 18*9e39c5baSBill Taylor * 19*9e39c5baSBill Taylor * CDDL HEADER END 20*9e39c5baSBill Taylor */ 21*9e39c5baSBill Taylor 22*9e39c5baSBill Taylor /* 23*9e39c5baSBill Taylor * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24*9e39c5baSBill Taylor * Use is subject to license terms. 25*9e39c5baSBill Taylor */ 26*9e39c5baSBill Taylor 27*9e39c5baSBill Taylor #ifndef _SYS_IB_ADAPTERS_HERMON_IOCTL_H 28*9e39c5baSBill Taylor #define _SYS_IB_ADAPTERS_HERMON_IOCTL_H 29*9e39c5baSBill Taylor 30*9e39c5baSBill Taylor #include <sys/cred.h> 31*9e39c5baSBill Taylor 32*9e39c5baSBill Taylor /* 33*9e39c5baSBill Taylor * hermon_ioctl.h 34*9e39c5baSBill Taylor * Contains all of the prototypes, #defines, and structures necessary 35*9e39c5baSBill Taylor * for all ioctl access into the driver. This includes everything 36*9e39c5baSBill Taylor * necessary for updating firmware, accessing the hermon flash device, 37*9e39c5baSBill Taylor * providing interfaces for VTS. 38*9e39c5baSBill Taylor */ 39*9e39c5baSBill Taylor 40*9e39c5baSBill Taylor #ifdef __cplusplus 41*9e39c5baSBill Taylor extern "C" { 42*9e39c5baSBill Taylor #endif 43*9e39c5baSBill Taylor 44*9e39c5baSBill Taylor int hermon_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, 45*9e39c5baSBill Taylor int *rvalp); 46*9e39c5baSBill Taylor 47*9e39c5baSBill Taylor /* 48*9e39c5baSBill Taylor * Enumerated type for the Hermon ioctl() interface types 49*9e39c5baSBill Taylor */ 50*9e39c5baSBill Taylor /* 51*9e39c5baSBill Taylor * originally, to make a unique set of IOCTLs but now share the actual 52*9e39c5baSBill Taylor * value w/ tavor & arbel (memfree) to make VTS consistent & simpler 53*9e39c5baSBill Taylor * 54*9e39c5baSBill Taylor * #define HERMON_IOCTL ('h' << 8) 55*9e39c5baSBill Taylor */ 56*9e39c5baSBill Taylor #define HERMON_IOCTL ('t' << 8) 57*9e39c5baSBill Taylor 58*9e39c5baSBill Taylor #ifdef DEBUG 59*9e39c5baSBill Taylor typedef enum { 60*9e39c5baSBill Taylor HERMON_IOCTL_FLASH_READ = HERMON_IOCTL | 0x00, 61*9e39c5baSBill Taylor HERMON_IOCTL_FLASH_WRITE = HERMON_IOCTL | 0x01, 62*9e39c5baSBill Taylor HERMON_IOCTL_FLASH_ERASE = HERMON_IOCTL | 0x02, 63*9e39c5baSBill Taylor HERMON_IOCTL_FLASH_INIT = HERMON_IOCTL | 0x03, 64*9e39c5baSBill Taylor HERMON_IOCTL_FLASH_FINI = HERMON_IOCTL | 0x04, 65*9e39c5baSBill Taylor HERMON_IOCTL_REG_WRITE = HERMON_IOCTL | 0x10, 66*9e39c5baSBill Taylor HERMON_IOCTL_REG_READ = HERMON_IOCTL | 0x11, 67*9e39c5baSBill Taylor HERMON_IOCTL_LOOPBACK = HERMON_IOCTL | 0x20, 68*9e39c5baSBill Taylor HERMON_IOCTL_INFO = HERMON_IOCTL | 0x21, 69*9e39c5baSBill Taylor HERMON_IOCTL_PORTS = HERMON_IOCTL | 0x22, 70*9e39c5baSBill Taylor HERMON_IOCTL_DDR_READ = HERMON_IOCTL | 0x23, 71*9e39c5baSBill Taylor HERMON_IOCTL_WRITE_BOOT_ADDR = HERMON_IOCTL | 0x24 72*9e39c5baSBill Taylor } hermon_ioctl_enum_t; 73*9e39c5baSBill Taylor #else 74*9e39c5baSBill Taylor typedef enum { 75*9e39c5baSBill Taylor HERMON_IOCTL_FLASH_READ = HERMON_IOCTL | 0x00, 76*9e39c5baSBill Taylor HERMON_IOCTL_FLASH_WRITE = HERMON_IOCTL | 0x01, 77*9e39c5baSBill Taylor HERMON_IOCTL_FLASH_ERASE = HERMON_IOCTL | 0x02, 78*9e39c5baSBill Taylor HERMON_IOCTL_FLASH_INIT = HERMON_IOCTL | 0x03, 79*9e39c5baSBill Taylor HERMON_IOCTL_FLASH_FINI = HERMON_IOCTL | 0x04, 80*9e39c5baSBill Taylor HERMON_IOCTL_LOOPBACK = HERMON_IOCTL | 0x20, 81*9e39c5baSBill Taylor HERMON_IOCTL_INFO = HERMON_IOCTL | 0x21, 82*9e39c5baSBill Taylor HERMON_IOCTL_PORTS = HERMON_IOCTL | 0x22, 83*9e39c5baSBill Taylor HERMON_IOCTL_DDR_READ = HERMON_IOCTL | 0x23, 84*9e39c5baSBill Taylor HERMON_IOCTL_WRITE_BOOT_ADDR = HERMON_IOCTL | 0x24 85*9e39c5baSBill Taylor } hermon_ioctl_enum_t; 86*9e39c5baSBill Taylor #endif /* DEBUG */ 87*9e39c5baSBill Taylor 88*9e39c5baSBill Taylor /* 89*9e39c5baSBill Taylor * Specific operations for each of the flash ioctl interfaces 90*9e39c5baSBill Taylor */ 91*9e39c5baSBill Taylor #define HERMON_FLASH_READ_SECTOR 0x01 92*9e39c5baSBill Taylor #define HERMON_FLASH_READ_QUADLET 0x02 93*9e39c5baSBill Taylor #define HERMON_FLASH_WRITE_SECTOR 0x01 94*9e39c5baSBill Taylor #define HERMON_FLASH_WRITE_BYTE 0x02 95*9e39c5baSBill Taylor #define HERMON_FLASH_ERASE_SECTOR 0x01 96*9e39c5baSBill Taylor #define HERMON_FLASH_ERASE_CHIP 0x02 97*9e39c5baSBill Taylor 98*9e39c5baSBill Taylor /* 99*9e39c5baSBill Taylor * Default values for the flash (overridden by CFI info, if available) 100*9e39c5baSBill Taylor */ 101*9e39c5baSBill Taylor #define HERMON_FLASH_SECTOR_SZ_DEFAULT 0x10000 102*9e39c5baSBill Taylor #define HERMON_FLASH_DEVICE_SZ_DEFAULT 0x400000 103*9e39c5baSBill Taylor #define HERMON_FLASH_SPI_LOG_SECTOR_SIZE 0x10 104*9e39c5baSBill Taylor #define HERMON_FLASH_SPI_SECTOR_SIZE 0x10000 105*9e39c5baSBill Taylor #define HERMON_FLASH_SPI_DEVICE_SIZE 0x200000 106*9e39c5baSBill Taylor 107*9e39c5baSBill Taylor /* 108*9e39c5baSBill Taylor * CFI (Common Flash Interface) initialization 109*9e39c5baSBill Taylor */ 110*9e39c5baSBill Taylor #define HERMON_FLASH_CFI_INIT 0x98 111*9e39c5baSBill Taylor 112*9e39c5baSBill Taylor /* For compatability */ 113*9e39c5baSBill Taylor #define HERMON_FLASH_CFI_SIZE 0x4C 114*9e39c5baSBill Taylor #define HERMON_FLASH_CFI_SIZE_QUADLET HERMON_FLASH_CFI_SIZE >> 2 115*9e39c5baSBill Taylor 116*9e39c5baSBill Taylor /* 117*9e39c5baSBill Taylor * Expand CFI data size to support the Intel Expanded Command Set. 118*9e39c5baSBill Taylor */ 119*9e39c5baSBill Taylor #define HERMON_CFI_INFO_SIZE 0x100 120*9e39c5baSBill Taylor #define HERMON_CFI_INFO_QSIZE HERMON_CFI_INFO_SIZE >> 2 121*9e39c5baSBill Taylor 122*9e39c5baSBill Taylor /* 123*9e39c5baSBill Taylor * Mellanox uses two different parallel Flash devices for Hermon 124*9e39c5baSBill Taylor * HCAs: the AMD AM29LV033C and the Intel 28F320J3C. The AM29LV033C 125*9e39c5baSBill Taylor * utilizes the AMD Standard CFI command set while the 28F320J3C 126*9e39c5baSBill Taylor * utliizes the Intel Extended CFI command set. Additionally, serial 127*9e39c5baSBill Taylor * SPI flash is supported, such as the STMicroelectronics M25Pxx family 128*9e39c5baSBill Taylor * of SPI Flash parts. 129*9e39c5baSBill Taylor */ 130*9e39c5baSBill Taylor #define HERMON_FLASH_INTEL_CMDSET 0x0001 131*9e39c5baSBill Taylor #define HERMON_FLASH_AMD_CMDSET 0x0002 132*9e39c5baSBill Taylor #define HERMON_FLASH_SPI_CMDSET 0x0003 133*9e39c5baSBill Taylor #define HERMON_FLASH_UNKNOWN_CMDSET 0XFFFF 134*9e39c5baSBill Taylor 135*9e39c5baSBill Taylor /* 136*9e39c5baSBill Taylor * The firmware version structure used in HERMON_IOCTL_INFO and 137*9e39c5baSBill Taylor * HERMON_IOCTL_FLASH_INIT interfaces. The structure consists of major, 138*9e39c5baSBill Taylor * minor and subminor portions for firmware revision number. 139*9e39c5baSBill Taylor */ 140*9e39c5baSBill Taylor typedef struct hermon_fw_info_ioctl_s { 141*9e39c5baSBill Taylor uint32_t afi_maj; 142*9e39c5baSBill Taylor uint32_t afi_min; 143*9e39c5baSBill Taylor uint32_t afi_sub; 144*9e39c5baSBill Taylor } hermon_fw_info_ioctl_t; 145*9e39c5baSBill Taylor 146*9e39c5baSBill Taylor /* 147*9e39c5baSBill Taylor * structure used for read, write, and erase flash routines 148*9e39c5baSBill Taylor * Supported fields for each type: 149*9e39c5baSBill Taylor * read_sector: af_type, af_sector, af_sector_num 150*9e39c5baSBill Taylor * read_quadlet: af_type, af_addr, af_quadlet 151*9e39c5baSBill Taylor * write_sector: af_type, af_sector, af_sector_num 152*9e39c5baSBill Taylor * write_byte: af_type, af_addr, af_byte 153*9e39c5baSBill Taylor * erase_sector: af_type, af_sector_num 154*9e39c5baSBill Taylor * erase_chip: af_type 155*9e39c5baSBill Taylor * 156*9e39c5baSBill Taylor * The 'tf_sector' field must point to a sector sized portion of memory, as 157*9e39c5baSBill Taylor * all sector read/write ioctl calls are done as one complete sector only. 158*9e39c5baSBill Taylor */ 159*9e39c5baSBill Taylor typedef struct hermon_flash_ioctl_s { 160*9e39c5baSBill Taylor uint32_t af_type; 161*9e39c5baSBill Taylor caddr_t af_sector; 162*9e39c5baSBill Taylor uint32_t af_sector_num; 163*9e39c5baSBill Taylor uint32_t af_addr; 164*9e39c5baSBill Taylor uint32_t af_quadlet; 165*9e39c5baSBill Taylor uint8_t af_byte; 166*9e39c5baSBill Taylor } hermon_flash_ioctl_t; 167*9e39c5baSBill Taylor 168*9e39c5baSBill Taylor /* Structure used for flash init interface */ 169*9e39c5baSBill Taylor typedef struct hermon_flash_init_ioctl_s { 170*9e39c5baSBill Taylor uint32_t af_hwrev; 171*9e39c5baSBill Taylor hermon_fw_info_ioctl_t af_fwrev; 172*9e39c5baSBill Taylor uint32_t af_cfi_info[HERMON_FLASH_CFI_SIZE_QUADLET]; 173*9e39c5baSBill Taylor char af_hwpn[64]; 174*9e39c5baSBill Taylor int af_pn_len; 175*9e39c5baSBill Taylor } hermon_flash_init_ioctl_t; 176*9e39c5baSBill Taylor 177*9e39c5baSBill Taylor /* 178*9e39c5baSBill Taylor * The structure used for Hermon register read/write interface. 179*9e39c5baSBill Taylor * The "trg_reg_set" field indicates the register set (the BAR) from which 180*9e39c5baSBill Taylor * the access is desired (HERMON_CMD_BAR, HERMON_UAR_BAR, or HERMON_DDR_BAR). 181*9e39c5baSBill Taylor * The "trg_offset" and "trg_data" fields indicate the register and either 182*9e39c5baSBill Taylor * the destination or source of the data to be read/written. 183*9e39c5baSBill Taylor */ 184*9e39c5baSBill Taylor typedef struct hermon_reg_ioctl_s { 185*9e39c5baSBill Taylor uint_t arg_reg_set; 186*9e39c5baSBill Taylor uint_t arg_offset; 187*9e39c5baSBill Taylor uint32_t arg_data; 188*9e39c5baSBill Taylor } hermon_reg_ioctl_t; 189*9e39c5baSBill Taylor 190*9e39c5baSBill Taylor 191*9e39c5baSBill Taylor /* 192*9e39c5baSBill Taylor * Hermon VTS IOCTL revision number. This revision number is currently 193*9e39c5baSBill Taylor * expected to be passed in all Hermon VTS ioctl interfaces. 194*9e39c5baSBill Taylor */ 195*9e39c5baSBill Taylor #define HERMON_VTS_IOCTL_REVISION 1 196*9e39c5baSBill Taylor 197*9e39c5baSBill Taylor /* 198*9e39c5baSBill Taylor * The port structure used in HERMON_IOCTL_PORTS interface. 199*9e39c5baSBill Taylor * Each port has an associated guid, port number, and IBA-defined 200*9e39c5baSBill Taylor * logical port state. 201*9e39c5baSBill Taylor */ 202*9e39c5baSBill Taylor typedef struct hermon_stat_port_ioctl_s { 203*9e39c5baSBill Taylor uint64_t asp_guid; 204*9e39c5baSBill Taylor uint32_t asp_port_num; 205*9e39c5baSBill Taylor uint32_t asp_state; 206*9e39c5baSBill Taylor } hermon_stat_port_ioctl_t; 207*9e39c5baSBill Taylor 208*9e39c5baSBill Taylor /* 209*9e39c5baSBill Taylor * The structure used for the HERMON_IOCTL_PORTS interface. 210*9e39c5baSBill Taylor * The number of ports and a buffer large enough for 256 211*9e39c5baSBill Taylor * port structures will be supplied by the caller. The 212*9e39c5baSBill Taylor * revision should be set to HERMON_VTS_IOCTL_REVISION. The 213*9e39c5baSBill Taylor * number of ports ("tp_num_ports") is always returned, 214*9e39c5baSBill Taylor * regardless of success or failure otherwise. 215*9e39c5baSBill Taylor */ 216*9e39c5baSBill Taylor typedef struct hermon_ports_ioctl_s { 217*9e39c5baSBill Taylor uint_t ap_revision; 218*9e39c5baSBill Taylor hermon_stat_port_ioctl_t *ap_ports; 219*9e39c5baSBill Taylor uint8_t ap_num_ports; 220*9e39c5baSBill Taylor } hermon_ports_ioctl_t; 221*9e39c5baSBill Taylor 222*9e39c5baSBill Taylor /* 223*9e39c5baSBill Taylor * These are the status codes that can be returned by the 224*9e39c5baSBill Taylor * HERMON_IOCTL_LOOPBACK test. They are returned as part of 225*9e39c5baSBill Taylor * the hermon_loopback_ioctl_t struct (below). 226*9e39c5baSBill Taylor */ 227*9e39c5baSBill Taylor typedef enum { 228*9e39c5baSBill Taylor HERMON_LOOPBACK_SUCCESS, 229*9e39c5baSBill Taylor HERMON_LOOPBACK_INVALID_REVISION, 230*9e39c5baSBill Taylor HERMON_LOOPBACK_INVALID_PORT, 231*9e39c5baSBill Taylor HERMON_LOOPBACK_PROT_DOMAIN_ALLOC_FAIL, 232*9e39c5baSBill Taylor HERMON_LOOPBACK_SEND_BUF_INVALID, 233*9e39c5baSBill Taylor HERMON_LOOPBACK_SEND_BUF_MEM_REGION_ALLOC_FAIL, 234*9e39c5baSBill Taylor HERMON_LOOPBACK_SEND_BUF_COPY_FAIL, 235*9e39c5baSBill Taylor HERMON_LOOPBACK_RECV_BUF_MEM_REGION_ALLOC_FAIL, 236*9e39c5baSBill Taylor HERMON_LOOPBACK_XMIT_SEND_CQ_ALLOC_FAIL, 237*9e39c5baSBill Taylor HERMON_LOOPBACK_XMIT_RECV_CQ_ALLOC_FAIL, 238*9e39c5baSBill Taylor HERMON_LOOPBACK_XMIT_QP_ALLOC_FAIL, 239*9e39c5baSBill Taylor HERMON_LOOPBACK_RECV_SEND_CQ_ALLOC_FAIL, 240*9e39c5baSBill Taylor HERMON_LOOPBACK_RECV_RECV_CQ_ALLOC_FAIL, 241*9e39c5baSBill Taylor HERMON_LOOPBACK_RECV_QP_ALLOC_FAIL, 242*9e39c5baSBill Taylor HERMON_LOOPBACK_XMIT_QP_INIT_FAIL, 243*9e39c5baSBill Taylor HERMON_LOOPBACK_XMIT_QP_RTR_FAIL, 244*9e39c5baSBill Taylor HERMON_LOOPBACK_XMIT_QP_RTS_FAIL, 245*9e39c5baSBill Taylor HERMON_LOOPBACK_RECV_QP_INIT_FAIL, 246*9e39c5baSBill Taylor HERMON_LOOPBACK_RECV_QP_RTR_FAIL, 247*9e39c5baSBill Taylor HERMON_LOOPBACK_RECV_QP_RTS_FAIL, 248*9e39c5baSBill Taylor HERMON_LOOPBACK_WQE_POST_FAIL, 249*9e39c5baSBill Taylor HERMON_LOOPBACK_CQ_POLL_FAIL, 250*9e39c5baSBill Taylor HERMON_LOOPBACK_SEND_RECV_COMPARE_FAIL 251*9e39c5baSBill Taylor } hermon_loopback_error_t; 252*9e39c5baSBill Taylor 253*9e39c5baSBill Taylor /* 254*9e39c5baSBill Taylor * The structure used for HERMON_IOCTL_LOOPBACK interface. 255*9e39c5baSBill Taylor * It defines the port number, number of iterations, wait duration, 256*9e39c5baSBill Taylor * number of retries and the data pattern to be sent. Upon return, 257*9e39c5baSBill Taylor * the driver will supply the number of iterations succesfully 258*9e39c5baSBill Taylor * completed, and the kind of failure (if any, along with the failing 259*9e39c5baSBill Taylor * data pattern). 260*9e39c5baSBill Taylor */ 261*9e39c5baSBill Taylor typedef struct hermon_loopback_ioctl_s { 262*9e39c5baSBill Taylor uint_t alb_revision; 263*9e39c5baSBill Taylor caddr_t alb_send_buf; 264*9e39c5baSBill Taylor caddr_t alb_fail_buf; 265*9e39c5baSBill Taylor uint_t alb_buf_sz; 266*9e39c5baSBill Taylor uint_t alb_num_iter; 267*9e39c5baSBill Taylor uint_t alb_pass_done; 268*9e39c5baSBill Taylor uint_t alb_timeout; 269*9e39c5baSBill Taylor hermon_loopback_error_t alb_error_type; 270*9e39c5baSBill Taylor uint8_t alb_port_num; 271*9e39c5baSBill Taylor uint8_t alb_num_retry; 272*9e39c5baSBill Taylor } hermon_loopback_ioctl_t; 273*9e39c5baSBill Taylor 274*9e39c5baSBill Taylor /* 275*9e39c5baSBill Taylor * The structure used for the HERMON_IOCTL_INFO interface. It 276*9e39c5baSBill Taylor * includes firmware version, hardware version, accessable 277*9e39c5baSBill Taylor * range of adapter DDR memory, and adapter flash memory size. 278*9e39c5baSBill Taylor */ 279*9e39c5baSBill Taylor typedef struct hermon_info_ioctl_s { 280*9e39c5baSBill Taylor uint_t ai_revision; 281*9e39c5baSBill Taylor hermon_fw_info_ioctl_t ai_fw_rev; 282*9e39c5baSBill Taylor uint32_t ai_hw_rev; 283*9e39c5baSBill Taylor uint_t ai_flash_sz; 284*9e39c5baSBill Taylor uint_t rsvd1; /* DDR start */ 285*9e39c5baSBill Taylor uint_t rsvd2; /* DDR end */ 286*9e39c5baSBill Taylor } hermon_info_ioctl_t; 287*9e39c5baSBill Taylor 288*9e39c5baSBill Taylor 289*9e39c5baSBill Taylor #ifdef __cplusplus 290*9e39c5baSBill Taylor } 291*9e39c5baSBill Taylor #endif 292*9e39c5baSBill Taylor 293*9e39c5baSBill Taylor #endif /* _SYS_IB_ADAPTERS_HERMON_IOCTL_H */ 294