1 /*
   2  * Copyright 2007-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 #include "efsys.h"
  27 #include "efx.h"
  28 #include "efx_types.h"
  29 #include "efx_regs.h"
  30 #include "efx_impl.h"
  31 #include "nullphy.h"
  32 #include "nullphy_impl.h"
  33 
  34 #if EFSYS_OPT_PHY_NULL
  35 
  36         __checkReturn   int
  37 nullphy_reset(
  38         __in            efx_nic_t *enp)
  39 {
  40         _NOTE(ARGUNUSED(enp))
  41 
  42         enp->en_reset_flags |= EFX_RESET_PHY;
  43 
  44         return (0);
  45 }
  46 
  47         __checkReturn   int
  48 nullphy_reconfigure(
  49         __in            efx_nic_t *enp)
  50 {
  51         efx_port_t *epp = &(enp->en_port);
  52         efx_word_t word;
  53         efx_word_t check;
  54         int rc;
  55 
  56         _NOTE(ARGUNUSED(enp))
  57 
  58         EFX_POPULATE_WORD_3(word, HOSTPORT_EQ, 1, PORTSEL, 0, CX4uC_RESET, 1);
  59 
  60         if ((rc = falcon_i2c_send(enp, PCF8575, (caddr_t)&word.ew_byte[0],
  61             sizeof (word.ew_byte) / sizeof (efx_byte_t))) != 0)
  62                 goto fail1;
  63 
  64         if ((rc = falcon_i2c_recv(enp, PCF8575, (caddr_t)&check.ew_byte[0],
  65             sizeof (check.ew_byte) / sizeof (efx_byte_t))) != 0)
  66                 goto fail2;
  67 
  68         if (EFX_WORD_FIELD(check, EFX_WORD_0) !=
  69             EFX_WORD_FIELD(word, EFX_WORD_0)) {
  70                 rc = EFAULT;
  71                 goto fail3;
  72         }
  73 
  74         EFSYS_ASSERT3U(epp->ep_adv_cap_mask, ==, NULLPHY_ADV_CAP_MASK);
  75 
  76         return (0);
  77 
  78 fail3:
  79         EFSYS_PROBE(fail3);
  80 fail2:
  81         EFSYS_PROBE(fail2);
  82 fail1:
  83         EFSYS_PROBE1(fail1, int, rc);
  84 
  85         return (rc);
  86 }
  87 
  88         __checkReturn   int
  89 nullphy_verify(
  90         __in            efx_nic_t *enp)
  91 {
  92         _NOTE(ARGUNUSED(enp))
  93 
  94         return (ENOTSUP);
  95 }
  96 
  97         __checkReturn   int
  98 nullphy_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         efx_port_t *epp = &(enp->en_port);
 105 
 106         *modep = EFX_LINK_10000FDX;
 107         *fcntlp = epp->ep_fcntl;
 108         *lp_cap_maskp = NULLPHY_ADV_CAP_MASK;
 109 
 110         return (0);
 111 }
 112 
 113         __checkReturn   int
 114 nullphy_lp_cap_get(
 115         __in            efx_nic_t *enp,
 116         __out           uint32_t *maskp)
 117 {
 118         _NOTE(ARGUNUSED(enp, maskp))
 119 
 120         return (ENOTSUP);
 121 }
 122 
 123         __checkReturn   int
 124 nullphy_oui_get(
 125         __in            efx_nic_t *enp,
 126         __out           uint32_t *ouip)
 127 {
 128         _NOTE(ARGUNUSED(enp, ouip))
 129 
 130         return (ENOTSUP);
 131 }
 132 
 133 #if EFSYS_OPT_PHY_STATS
 134 
 135         __checkReturn                   int
 136 nullphy_stats_update(
 137         __in                            efx_nic_t *enp,
 138         __in                            efsys_mem_t *esmp,
 139         __out_ecount(EFX_PHY_NSTATS)    uint32_t *stat)
 140 {
 141         _NOTE(ARGUNUSED(enp, esmp, stat))
 142 
 143         return (ENOTSUP);
 144 }
 145 #endif  /* EFSYS_OPT_PHY_STATS */
 146 
 147 #if EFSYS_OPT_PHY_PROPS
 148 
 149 #if EFSYS_OPT_NAMES
 150                 const char __cs *
 151 nullphy_prop_name(
 152         __in    efx_nic_t *enp,
 153         __in    unsigned int id)
 154 {
 155         _NOTE(ARGUNUSED(enp, id))
 156 
 157         EFSYS_ASSERT(B_FALSE);
 158 
 159         return (NULL);
 160 }
 161 #endif  /* EFSYS_OPT_NAMES */
 162 
 163         __checkReturn   int
 164 nullphy_prop_get(
 165         __in            efx_nic_t *enp,
 166         __in            unsigned int id,
 167         __in            uint32_t flags,
 168         __out           uint32_t *valp)
 169 {
 170         _NOTE(ARGUNUSED(enp, id, flags, valp))
 171 
 172         EFSYS_ASSERT(B_FALSE);
 173 
 174         return (ENOTSUP);
 175 }
 176 
 177         __checkReturn   int
 178 nullphy_prop_set(
 179         __in            efx_nic_t *enp,
 180         __in            unsigned int id,
 181         __in            uint32_t val)
 182 {
 183         _NOTE(ARGUNUSED(enp, id, val))
 184 
 185         EFSYS_ASSERT(B_FALSE);
 186 
 187         return (ENOTSUP);
 188 }
 189 #endif  /* EFSYS_OPT_PHY_PROPS */
 190 
 191 #endif  /* EFSYS_OPT_PHY_NULL */