1 /*-
   2  * Copyright 2008-2013 Solarflare Communications Inc.  All rights reserved.
   3  *
   4  * Redistribution and use in source and binary forms, with or without
   5  * modification, are permitted provided that the following conditions
   6  * are met:
   7  * 1. Redistributions of source code must retain the above copyright
   8  *    notice, this list of conditions and the following disclaimer.
   9  * 2. Redistributions in binary form must reproduce the above copyright
  10  *    notice, this list of conditions and the following disclaimer in the
  11  *    documentation and/or other materials provided with the distribution.
  12  *
  13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS AND
  14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23  * SUCH DAMAGE.
  24  */
  25 
  26 #ifndef _SYS_SFT9001_H
  27 #define _SYS_SFT9001_H
  28 
  29 #include "efx.h"
  30 
  31 #ifdef  __cplusplus
  32 extern "C" {
  33 #endif
  34 
  35 #if EFSYS_OPT_PHY_SFT9001
  36 
  37 #define SFT9001_10G_LOOPBACK_MASK                                       \
  38             ((1 << EFX_LOOPBACK_PHY_XS) |                         \
  39             (1 << EFX_LOOPBACK_PCS) |                                     \
  40             (1 << EFX_LOOPBACK_PMA_PMD) |                         \
  41             FALCON_XMAC_LOOPBACK_MASK)
  42 
  43 #define SFT9001_1G_LOOPBACK_MASK                                        \
  44             ((1 << EFX_LOOPBACK_GPHY) |                                   \
  45             FALCON_GMAC_LOOPBACK_MASK)
  46 
  47 #define SFT9001_LED_MASK                                                \
  48             ((1 << EFX_PHY_LED_OFF) |                                     \
  49             (1 << EFX_PHY_LED_ON) |                                       \
  50             (1 << EFX_PHY_LED_FLASH))
  51 
  52 /* START MKCONFIG GENERATED Sft9001PhyHeaderPropsBlock 9b100228a7cfe533 */
  53 typedef enum sft9001_prop_e {
  54         SFT9001_SHORT_REACH,
  55         SFT9001_ROBUST,
  56         SFT9001_NPROPS
  57 } sft9001_prop_t;
  58 
  59 /* END MKCONFIG GENERATED Sft9001PhyHeaderPropsBlock */
  60 
  61 #define SFT9001_ADV_CAP_MASK                                            \
  62             ((1 << EFX_PHY_CAP_AN) |                                      \
  63             (1 << EFX_PHY_CAP_10000FDX) |                         \
  64             (1 << EFX_PHY_CAP_1000FDX) |                          \
  65             (1 << EFX_PHY_CAP_100FDX) |                                   \
  66             (1 << EFX_PHY_CAP_PAUSE))
  67 
  68 #define SFT9001_ADV_CAP_PERM                                            \
  69             ((1 << EFX_PHY_CAP_10000FDX) |                                \
  70             (1 << EFX_PHY_CAP_1000FDX) |                          \
  71             (1 << EFX_PHY_CAP_100FDX) |                                   \
  72             (1 << EFX_PHY_CAP_100HDX) |                                   \
  73             (1 << EFX_PHY_CAP_PAUSE) |                                    \
  74             (1 << EFX_PHY_CAP_ASYM))
  75 
  76 #define SFT9001_BIST_MASK                                               \
  77             ((1 << EFX_PHY_BIST_TYPE_CABLE_SHORT) |                       \
  78             (1 << EFX_PHY_BIST_TYPE_CABLE_LONG))
  79 
  80 extern  __checkReturn   int
  81 sft9001_reset(
  82         __in            efx_nic_t *enp);
  83 
  84 extern  __checkReturn   int
  85 sft9001_reconfigure(
  86         __in            efx_nic_t *enp);
  87 
  88 extern  __checkReturn   int
  89 sft9001_verify(
  90         __in            efx_nic_t *enp);
  91 
  92 extern  __checkReturn   int
  93 sft9001_uplink_check(
  94         __in            efx_nic_t *enp,
  95         __out           boolean_t *upp);
  96 
  97 extern  __checkReturn   int
  98 sft9001_downlink_check(
  99         __in            efx_nic_t *enp,
 100         __out           efx_link_mode_t *modep,
 101         __out           unsigned int *fcntlp,
 102         __out           uint32_t *lp_cap_maskp);
 103 
 104 extern __checkReturn    int
 105 sft9001_oui_get(
 106         __in            efx_nic_t *enp,
 107         __out           uint32_t *ouip);
 108 
 109 #if EFSYS_OPT_PHY_STATS
 110 
 111 /* START MKCONFIG GENERATED Sft9001PhyHeaderStatsMask 06818b95754126e3 */
 112 #define SFT9001_STAT_MASK \
 113         (1ULL << EFX_PHY_STAT_OUI) | \
 114         (1ULL << EFX_PHY_STAT_PMA_PMD_LINK_UP) | \
 115         (1ULL << EFX_PHY_STAT_PMA_PMD_RX_FAULT) | \
 116         (1ULL << EFX_PHY_STAT_PMA_PMD_TX_FAULT) | \
 117         (1ULL << EFX_PHY_STAT_PMA_PMD_REV_A) | \
 118         (1ULL << EFX_PHY_STAT_PMA_PMD_REV_B) | \
 119         (1ULL << EFX_PHY_STAT_PMA_PMD_REV_C) | \
 120         (1ULL << EFX_PHY_STAT_PMA_PMD_REV_D) | \
 121         (1ULL << EFX_PHY_STAT_PCS_LINK_UP) | \
 122         (1ULL << EFX_PHY_STAT_PCS_RX_FAULT) | \
 123         (1ULL << EFX_PHY_STAT_PCS_TX_FAULT) | \
 124         (1ULL << EFX_PHY_STAT_PCS_BER) | \
 125         (1ULL << EFX_PHY_STAT_PCS_BLOCK_ERRORS) | \
 126         (1ULL << EFX_PHY_STAT_PHY_XS_LINK_UP) | \
 127         (1ULL << EFX_PHY_STAT_PHY_XS_RX_FAULT) | \
 128         (1ULL << EFX_PHY_STAT_PHY_XS_TX_FAULT) | \
 129         (1ULL << EFX_PHY_STAT_PHY_XS_ALIGN) | \
 130         (1ULL << EFX_PHY_STAT_PHY_XS_SYNC_A) | \
 131         (1ULL << EFX_PHY_STAT_PHY_XS_SYNC_B) | \
 132         (1ULL << EFX_PHY_STAT_PHY_XS_SYNC_C) | \
 133         (1ULL << EFX_PHY_STAT_PHY_XS_SYNC_D) | \
 134         (1ULL << EFX_PHY_STAT_AN_LINK_UP) | \
 135         (1ULL << EFX_PHY_STAT_AN_MASTER) | \
 136         (1ULL << EFX_PHY_STAT_AN_LOCAL_RX_OK) | \
 137         (1ULL << EFX_PHY_STAT_AN_REMOTE_RX_OK) | \
 138         (1ULL << EFX_PHY_STAT_CL22EXT_LINK_UP) | \
 139         (1ULL << EFX_PHY_STAT_SNR_A) | \
 140         (1ULL << EFX_PHY_STAT_SNR_B) | \
 141         (1ULL << EFX_PHY_STAT_SNR_C) | \
 142         (1ULL << EFX_PHY_STAT_SNR_D)
 143 
 144 /* END MKCONFIG GENERATED Sft9001PhyHeaderStatsMask */
 145 
 146 extern  __checkReturn                   int
 147 sft9001_stats_update(
 148         __in                            efx_nic_t *enp,
 149         __in                            efsys_mem_t *esmp,
 150         __out_ecount(EFX_PHY_NSTATS)    uint32_t *stat);
 151 
 152 #endif  /* EFSYS_OPT_PHY_STATS */
 153 
 154 #if EFSYS_OPT_PHY_PROPS
 155 
 156 #if EFSYS_OPT_NAMES
 157 
 158 extern          const char __cs *
 159 sft9001_prop_name(
 160         __in    efx_nic_t *enp,
 161         __in    unsigned int id);
 162 
 163 #endif  /* EFSYS_OPT_NAMES */
 164 
 165 extern  __checkReturn   int
 166 sft9001_prop_get(
 167         __in            efx_nic_t *enp,
 168         __in            unsigned int id,
 169         __in            uint32_t flags,
 170         __out           uint32_t *valp);
 171 
 172 extern  __checkReturn   int
 173 sft9001_prop_set(
 174         __in            efx_nic_t *enp,
 175         __in            unsigned int id,
 176         __in            uint32_t val);
 177 
 178 #endif  /* EFSYS_OPT_PHY_PROPS */
 179 
 180 #if EFSYS_OPT_NVRAM_SFT9001
 181 
 182 extern  __checkReturn           int
 183 sft9001_nvram_size(
 184         __in                    efx_nic_t *enp,
 185         __out                   size_t *sizep);
 186 
 187 extern  __checkReturn           int
 188 sft9001_nvram_get_version(
 189         __in                    efx_nic_t *enp,
 190         __out                   uint32_t *subtypep,
 191         __out_ecount(4)         uint16_t version[4]);
 192 
 193 extern  __checkReturn           int
 194 sft9001_nvram_rw_start(
 195         __in                    efx_nic_t *enp,
 196         __out                   size_t *block_sizep);
 197 
 198 extern  __checkReturn           int
 199 sft9001_nvram_read_chunk(
 200         __in                    efx_nic_t *enp,
 201         __in                    unsigned int offset,
 202         __out_bcount(size)      caddr_t data,
 203         __in                    size_t size);
 204 
 205 extern  __checkReturn           int
 206 sft9001_nvram_erase(
 207         __in                    efx_nic_t *enp);
 208 
 209 extern  __checkReturn           int
 210 sft9001_nvram_write_chunk(
 211         __in                    efx_nic_t *enp,
 212         __in                    unsigned int offset,
 213         __in_bcount(size)       caddr_t data,
 214         __in                    size_t size);
 215 
 216 extern                          void
 217 sft9001_nvram_rw_finish(
 218         __in                    efx_nic_t *enp);
 219 
 220 extern const uint8_t * const sft9001_loader;
 221 extern const size_t sft9001_loader_size;
 222 
 223 #pragma pack(1)
 224 
 225 typedef struct sft9001_firmware_header_s {
 226         efx_dword_t code_length;
 227         efx_dword_t destination_address;
 228         efx_word_t code_checksum;
 229         efx_word_t boot_config;
 230         efx_word_t header_csum;
 231         efx_byte_t reserved[18];
 232 } sft9001_firmware_header_t;
 233 
 234 #pragma pack()
 235 
 236 #endif  /* EFSYS_OPT_NVRAM_SFT9001 */
 237 
 238 #if EFSYS_OPT_PHY_BIST
 239 
 240 extern  __checkReturn           int
 241 sft9001_bist_start(
 242         __in                    efx_nic_t *enp,
 243         __in                    efx_phy_bist_type_t type);
 244 
 245 extern  __checkReturn           int
 246 sft9001_bist_poll(
 247         __in                    efx_nic_t *enp,
 248         __in                    efx_phy_bist_type_t type,
 249         __out                   efx_phy_bist_result_t *resultp,
 250         __out_opt               uint32_t *value_maskp,
 251         __out_ecount_opt(count) unsigned long *valuesp,
 252         __in                    size_t count);
 253 
 254 extern                          void
 255 sft9001_bist_stop(
 256         __in                    efx_nic_t *enp,
 257         __in                    efx_phy_bist_type_t type);
 258 
 259 #endif  /* EFSYS_OPT_PHY_BIST */
 260 
 261 #endif  /* EFSYS_OPT_SFT9001 */
 262 
 263 #ifdef  __cplusplus
 264 }
 265 #endif
 266 
 267 #endif  /* _SYS_SFT9001_H */