Print this page
10089 phy_check() is bitwise, should be streetwise


   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*




  27  * mii - MII/PHY support for MAC drivers
  28  *
  29  * Utility module to provide a consistent interface to a MAC driver accross
  30  * different implementations of PHY devices
  31  */
  32 
  33 #include <sys/types.h>
  34 #include <sys/debug.h>
  35 #include <sys/errno.h>
  36 #include <sys/param.h>
  37 #include <sys/kmem.h>
  38 #include <sys/conf.h>
  39 #include <sys/ddi.h>
  40 #include <sys/sunddi.h>
  41 #include <sys/modctl.h>
  42 #include <sys/cmn_err.h>
  43 #include <sys/policy.h>
  44 #include <sys/note.h>
  45 #include <sys/strsun.h>
  46 #include <sys/miiregs.h>


1502                 ph->phy_lp_100_hdx = B_FALSE;
1503                 ph->phy_lp_100_fdx = B_FALSE;
1504                 ph->phy_lp_1000_hdx = B_FALSE;
1505                 ph->phy_lp_1000_fdx = B_FALSE;
1506                 ph->phy_lp_pause = B_FALSE;
1507                 ph->phy_lp_asmpause = B_FALSE;
1508                 ph->phy_speed = 0;
1509                 ph->phy_duplex = LINK_DUPLEX_UNKNOWN;
1510                 return (DDI_SUCCESS);
1511 
1512         } else {
1513                 ph->phy_lp_aneg = !!(anexp & MII_AN_EXP_LPCANAN);
1514 
1515                 /*
1516                  * Note: If the peer doesn't support autonegotiation, then
1517                  * according to clause 28.5.4.5, the link partner ability
1518                  * register will still have the right bits set.  However,
1519                  * gigabit modes cannot use legacy parallel detection.
1520                  */
1521 
1522                 if ((ph->phy_type == XCVR_1000T) &
1523                     (anexp & MII_AN_EXP_LPCANAN)) {
1524 
1525                         /* check for gige */
1526                         msstat = phy_read(ph, MII_MSSTATUS);
1527 
1528                         ph->phy_lp_1000_hdx =
1529                             !!(msstat & MII_MSSTATUS_LP1000T);
1530 
1531                         ph->phy_lp_1000_fdx =
1532                             !!(msstat & MII_MSSTATUS_LP1000T_FD);
1533                 }
1534 
1535                 ph->phy_lp_100_fdx = !!(lpar & MII_ABILITY_100BASE_TX_FD);
1536                 ph->phy_lp_100_hdx = !!(lpar & MII_ABILITY_100BASE_TX);
1537                 ph->phy_lp_100_t4 = !!(lpar & MII_ABILITY_100BASE_T4);
1538                 ph->phy_lp_10_fdx = !!(lpar & MII_ABILITY_10BASE_T_FD);
1539                 ph->phy_lp_10_hdx = !!(lpar & MII_ABILITY_10BASE_T);
1540                 ph->phy_lp_pause = !!(lpar & MII_ABILITY_PAUSE);
1541                 ph->phy_lp_asmpause = !!(lpar & MII_ABILITY_ASMPAUSE);
1542         }




   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2018, Joyent, Inc.
  28  */
  29 
  30 /*
  31  * mii - MII/PHY support for MAC drivers
  32  *
  33  * Utility module to provide a consistent interface to a MAC driver accross
  34  * different implementations of PHY devices
  35  */
  36 
  37 #include <sys/types.h>
  38 #include <sys/debug.h>
  39 #include <sys/errno.h>
  40 #include <sys/param.h>
  41 #include <sys/kmem.h>
  42 #include <sys/conf.h>
  43 #include <sys/ddi.h>
  44 #include <sys/sunddi.h>
  45 #include <sys/modctl.h>
  46 #include <sys/cmn_err.h>
  47 #include <sys/policy.h>
  48 #include <sys/note.h>
  49 #include <sys/strsun.h>
  50 #include <sys/miiregs.h>


1506                 ph->phy_lp_100_hdx = B_FALSE;
1507                 ph->phy_lp_100_fdx = B_FALSE;
1508                 ph->phy_lp_1000_hdx = B_FALSE;
1509                 ph->phy_lp_1000_fdx = B_FALSE;
1510                 ph->phy_lp_pause = B_FALSE;
1511                 ph->phy_lp_asmpause = B_FALSE;
1512                 ph->phy_speed = 0;
1513                 ph->phy_duplex = LINK_DUPLEX_UNKNOWN;
1514                 return (DDI_SUCCESS);
1515 
1516         } else {
1517                 ph->phy_lp_aneg = !!(anexp & MII_AN_EXP_LPCANAN);
1518 
1519                 /*
1520                  * Note: If the peer doesn't support autonegotiation, then
1521                  * according to clause 28.5.4.5, the link partner ability
1522                  * register will still have the right bits set.  However,
1523                  * gigabit modes cannot use legacy parallel detection.
1524                  */
1525 
1526                 if ((ph->phy_type == XCVR_1000T) &&
1527                     (anexp & MII_AN_EXP_LPCANAN)) {
1528 
1529                         /* check for gige */
1530                         msstat = phy_read(ph, MII_MSSTATUS);
1531 
1532                         ph->phy_lp_1000_hdx =
1533                             !!(msstat & MII_MSSTATUS_LP1000T);
1534 
1535                         ph->phy_lp_1000_fdx =
1536                             !!(msstat & MII_MSSTATUS_LP1000T_FD);
1537                 }
1538 
1539                 ph->phy_lp_100_fdx = !!(lpar & MII_ABILITY_100BASE_TX_FD);
1540                 ph->phy_lp_100_hdx = !!(lpar & MII_ABILITY_100BASE_TX);
1541                 ph->phy_lp_100_t4 = !!(lpar & MII_ABILITY_100BASE_T4);
1542                 ph->phy_lp_10_fdx = !!(lpar & MII_ABILITY_10BASE_T_FD);
1543                 ph->phy_lp_10_hdx = !!(lpar & MII_ABILITY_10BASE_T);
1544                 ph->phy_lp_pause = !!(lpar & MII_ABILITY_PAUSE);
1545                 ph->phy_lp_asmpause = !!(lpar & MII_ABILITY_ASMPAUSE);
1546         }