1 /*
   2  * Copyright (c) 2008-2015 Solarflare Communications Inc.
   3  * All rights reserved.
   4  *
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions are met:
   7  *
   8  * 1. Redistributions of source code must retain the above copyright notice,
   9  *    this list of conditions and the following disclaimer.
  10  * 2. Redistributions in binary form must reproduce the above copyright notice,
  11  *    this list of conditions and the following disclaimer in the documentation
  12  *    and/or other materials provided with the distribution.
  13  *
  14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  21  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  22  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  23  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25  *
  26  * The views and conclusions contained in the software and documentation are
  27  * those of the authors and should not be interpreted as representing official
  28  * policies, either expressed or implied, of the FreeBSD Project.
  29  */
  30 
  31 #ifndef _SYS_SFXGE_IOC_H
  32 #define _SYS_SFXGE_IOC_H
  33 
  34 #ifdef  __cplusplus
  35 extern "C" {
  36 #endif
  37 
  38 #include <sys/types.h>
  39 
  40 /* Ensure no ambiguity over structure layouts */
  41 #pragma pack(1)
  42 
  43 #define SFXGE_IOC       ('S' << 24 | 'F' << 16 | 'C' << 8)
  44 
  45 #define SFXGE_STOP_IOC  (SFXGE_IOC | 0x01)
  46 #define SFXGE_START_IOC (SFXGE_IOC | 0x02)
  47 
  48 /* MDIO was SFXGE_IOC 0x03 */
  49 
  50 /* I2C was SFXGE_IOC 0x04 */
  51 
  52 /* SPI was SFXGE_IOC 0x05 */
  53 
  54 /* BAR was SFXGE_IOC 0x06 */
  55 
  56 /* PCI was SFXGE_IOC 0x07 */
  57 
  58 /* MAC was SFXGE_IOC 0x08 */
  59 
  60 /* PHY was SFXGE_IOC 0x09 */
  61 
  62 /* SRAM was SFXGE_IOC 0x0a */
  63 
  64 /* TX was SFXGE_IOC 0x0b */
  65 
  66 /* RX was SFXGE_IOC 0x0c */
  67 
  68 /* NVRAM */
  69 
  70 #define SFXGE_NVRAM_IOC (SFXGE_IOC | 0x0d)
  71 
  72 typedef struct sfxge_nvram_ioc_s {
  73         uint32_t        sni_op;
  74         uint32_t        sni_type;
  75         uint32_t        sni_offset;
  76         uint32_t        sni_size;
  77         uint32_t        sni_subtype;
  78         uint16_t        sni_version[4];         /* get/set_ver */
  79         /*
  80          * Streams STRMSGSZ limit (default 64kb)
  81          * See write(2) and I_STR in streamio(7i)
  82          */
  83         uint8_t         sni_data[32*1024];      /* read/write */
  84 } sfxge_nvram_ioc_t;
  85 
  86 #define SFXGE_NVRAM_OP_SIZE             0x00000001
  87 #define SFXGE_NVRAM_OP_READ             0x00000002
  88 #define SFXGE_NVRAM_OP_WRITE            0x00000003
  89 #define SFXGE_NVRAM_OP_ERASE            0x00000004
  90 #define SFXGE_NVRAM_OP_GET_VER          0x00000005
  91 #define SFXGE_NVRAM_OP_SET_VER          0x00000006
  92 
  93 #define SFXGE_NVRAM_TYPE_BOOTROM        0x00000001
  94 #define SFXGE_NVRAM_TYPE_BOOTROM_CFG    0x00000002
  95 #define SFXGE_NVRAM_TYPE_MC             0x00000003
  96 #define SFXGE_NVRAM_TYPE_MC_GOLDEN      0x00000004
  97 #define SFXGE_NVRAM_TYPE_PHY            0x00000005
  98 #define SFXGE_NVRAM_TYPE_NULL_PHY       0x00000006
  99 #define SFXGE_NVRAM_TYPE_FPGA           0x00000007
 100 #define SFXGE_NVRAM_TYPE_FCFW           0x00000008
 101 #define SFXGE_NVRAM_TYPE_CPLD           0x00000009
 102 #define SFXGE_NVRAM_TYPE_FPGA_BACKUP    0x0000000a
 103 #define SFXGE_NVRAM_TYPE_DYNAMIC_CFG    0x0000000b
 104 
 105 
 106 /* PHY BIST was IOC 0x0e */
 107 
 108 /* Legacy IOC for MCDIv1 protocol - do not use in new code */
 109 #define SFXGE_MCDI_IOC  (SFXGE_IOC | 0x0f)
 110 
 111 typedef struct sfxge_mcdi_ioc_s {
 112         uint8_t         smi_payload[256];
 113         uint8_t         smi_cmd;
 114         uint8_t         smi_len; /* In and out */
 115         uint8_t         smi_rc;
 116 } sfxge_mcdi_ioc_t;
 117 
 118 /* Reset the NIC */
 119 
 120 #define SFXGE_NIC_RESET_IOC     (SFXGE_IOC | 0x10)
 121 
 122 /* VPD */
 123 
 124 #define SFXGE_VPD_IOC   (SFXGE_IOC | 0x11)
 125 
 126 #define SFXGE_VPD_MAX_PAYLOAD 0x100
 127 
 128 typedef struct sfxge_vpd_ioc_s {
 129         uint8_t         svi_op;
 130         uint8_t         svi_tag;
 131         uint16_t        svi_keyword;
 132         uint8_t         svi_len; /* In or out */
 133         uint8_t         svi_payload[SFXGE_VPD_MAX_PAYLOAD]; /* In or out */
 134 } sfxge_vpd_ioc_t;
 135 
 136 #define SFXGE_VPD_OP_GET_KEYWORD        0x00000001
 137 #define SFXGE_VPD_OP_SET_KEYWORD        0x00000002
 138 
 139 /* MCDIv2 */
 140 
 141 #define SFXGE_MCDI2_IOC (SFXGE_IOC | 0x12)
 142 
 143 typedef struct sfxge_mcdi2_ioc_s {
 144         uint8_t         smi_payload[1024];
 145         uint32_t        smi_cmd;
 146         uint32_t        smi_len; /* In and out */
 147         uint32_t        smi_rc;
 148 } sfxge_mcdi2_ioc_t;
 149 
 150 
 151 #pragma pack()
 152 
 153 #ifdef  __cplusplus
 154 }
 155 #endif
 156 
 157 #endif  /* _SYS_SFXGE_IOC_H */