openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

physim.c (18597B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * File:        physim.c
      8  * Purpose:     Dummy phy driver for simulation
      9  * Requires:    
     10  */
     11 
     12 #if defined(INCLUDE_PHY_SIMUL)
     13 
     14 #include <soc/drv.h>
     15 #include <soc/debug.h>
     16 #include <soc/error.h>
     17 #include <soc/phyreg.h>
     18 
     19 #include <soc/phy.h>
     20 #include <soc/phy/phyctrl.h>
     21 #include <soc/phy/drv.h>
     22 
     23 #include "physim.h"
     24 
     25 /*
     26  * Variable:	phy_simul
     27  * Purpose:	Phy driver callouts for SIMUL interface
     28  */
     29 phy_driver_t phy_simul = {
     30     "Simulation PHY Driver",
     31     phy_simul_init, 
     32     phy_simul_reset,
     33     phy_simul_link_get, 
     34     phy_simul_enable_set, 
     35     phy_simul_enable_get, 
     36     phy_simul_duplex_set, 
     37     phy_simul_duplex_get, 
     38     phy_simul_speed_set, 
     39     phy_simul_speed_get, 
     40     phy_simul_master_set,
     41     phy_simul_master_get,
     42     phy_simul_an_set, 
     43     phy_simul_an_get, 
     44     phy_simul_adv_local_set,
     45     phy_simul_adv_local_get, 
     46     phy_simul_adv_remote_get,
     47     phy_simul_lb_set,
     48     phy_simul_lb_get,
     49     phy_simul_interface_set, 
     50     phy_simul_interface_get, 
     51     phy_simul_ability_get,
     52     NULL,
     53     NULL,
     54     phy_simul_mdix_set,          /* phy_mdix_set */
     55     phy_simul_mdix_get,          /* phy_mdix_get */
     56     phy_simul_mdix_status_get,   /* phy_mdix_status_get */
     57     NULL,
     58     NULL,
     59     phy_simul_medium_get,
     60     NULL,                       /* phy_cable_diag  */
     61     NULL,                       /* phy_link_change */
     62     NULL,                       /* phy_control_set */
     63     NULL,                       /* phy_control_get */
     64     NULL,                       /* phy_reg_read */
     65     NULL,                       /* phy_reg_write */
     66     NULL                        /* phy_reg_modify */
     67 };
     68 
     69 struct _bcm_sim_data_s {
     70     int enable;
     71     int link;  /* When CMIC_LINK_STAT not used */
     72     int duplex;
     73     int speed;
     74     int master;
     75     int an;
     76     soc_port_mode_t adv_local;
     77     soc_port_mode_t adv_remote;
     78     int lb; /* loopback */
     79     soc_port_if_t pif;
     80     soc_port_mdix_t mdix;
     81 } *_bcm_sim_data[SOC_MAX_NUM_DEVICES][SOC_MAX_NUM_PORTS];
     82 
     83 
     84 #define SIMUL_PARAM_CHECK(unit, port) \
     85     if ((unit < 0) || (port < 0) || (unit >= SOC_MAX_NUM_DEVICES) || \
     86             (port >= SOC_MAX_NUM_PORTS) || (_bcm_sim_data[unit][port] == NULL)) \
     87         return SOC_E_PARAM
     88 
     89 
     90 /*
     91  * Function: 	
     92  *	phy_simul_init
     93  *
     94  * Purpose:	
     95  *	Initialize the SIMUL to a known good state.
     96  *
     97  * Parameters:
     98  *	unit - StrataSwitch unit #.
     99  *	port - StrataSwitch port #. 
    100  *
    101  * Returns:	
    102  *	SOC_E_XXXX
    103  *
    104  * Notes: 
    105  *	No synchronization performed at this level.
    106  */
    107 
    108 int
    109 phy_simul_init(int unit, soc_port_t port)
    110 {
    111     soc_port_mode_t mode;
    112 
    113     if ((unit < 0) || (port < 0) || (unit >= SOC_MAX_NUM_DEVICES) || \
    114             (port >= SOC_MAX_NUM_PORTS)) {
    115         return SOC_E_PARAM;
    116     }
    117 
    118     /* Allocate and init simulation structure here */
    119     if (_bcm_sim_data[unit][port] == NULL) {
    120         _bcm_sim_data[unit][port] =
    121             sal_alloc(sizeof(*_bcm_sim_data[unit][port]), "phy_simul");
    122     }
    123     if (_bcm_sim_data[unit][port] == NULL) {
    124         return SOC_E_MEMORY;
    125     }
    126 
    127     _bcm_sim_data[unit][port]->link = TRUE;
    128     _bcm_sim_data[unit][port]->enable = FALSE;
    129     _bcm_sim_data[unit][port]->pif = SOC_PORT_IF_NOCXN;
    130     _bcm_sim_data[unit][port]->duplex = TRUE;
    131     _bcm_sim_data[unit][port]->speed = 0; /* max */
    132     _bcm_sim_data[unit][port]->master = SOC_PORT_MS_NONE;
    133     _bcm_sim_data[unit][port]->an = 0;
    134     _bcm_sim_data[unit][port]->adv_local = 0;
    135     _bcm_sim_data[unit][port]->lb = 0;
    136     _bcm_sim_data[unit][port]->mdix = SOC_PORT_MDIX_NORMAL;
    137 
    138     if (IS_HG_PORT(unit, port) || IS_XE_PORT(unit, port)) {
    139         mode = SOC_PM_10GB_FD | SOC_PM_XGMII;
    140     } else if (IS_GE_PORT(unit, port)) {
    141         mode = SOC_PM_1000MB_FD | SOC_PM_GMII;
    142     } else {
    143         mode = SOC_PM_100MB_FD | SOC_PM_MII;
    144     }
    145     _bcm_sim_data[unit][port]->adv_remote = mode;
    146 
    147     return SOC_E_NONE;
    148 }
    149 
    150 /*
    151  * Function: 	
    152  *	phy_simul_reset
    153  *
    154  * Purpose:	
    155  *	Initialize the SIMUL hardware to a known good state.
    156  *
    157  * Parameters:
    158  *	unit - StrataSwitch unit #.
    159  *	port - StrataSwitch port #. 
    160  *
    161  * Returns:	
    162  *	SOC_E_XXXX
    163  *
    164  * Notes: 
    165  *	No synchronization performed at this level.
    166  */
    167 
    168 int
    169 phy_simul_reset(int unit, soc_port_t port, void *user_arg)
    170 {
    171     COMPILER_REFERENCE(user_arg);
    172 
    173     return phy_simul_init(unit, port);
    174 }
    175 
    176 /*
    177  * Function: 	
    178  *	phy_simul_enable_set
    179  *
    180  * Purpose:	
    181  *	Enable or disable the physical interface.
    182  *
    183  * Parameters:
    184  *	unit - StrataSwitch unit #.
    185  *	port - StrataSwitch port #. 
    186  *	enable - Boolean, true = enable PHY, false = disable.
    187  *
    188  * Returns:	
    189  *	SOC_E_XXXX
    190  */
    191 int
    192 phy_simul_enable_set(int unit, soc_port_t port, int enable)
    193 {
    194     SIMUL_PARAM_CHECK(unit, port);
    195 
    196     _bcm_sim_data[unit][port]->enable = enable;
    197 
    198     return SOC_E_NONE;
    199 }
    200 
    201 /*
    202  * Function: 	
    203  *	phy_simul_enable_get
    204  *
    205  * Purpose:	
    206  *	Enable or disable the physical interface for a SIMUL device.
    207  *
    208  * Parameters:
    209  *	unit - StrataSwitch unit #.
    210  *	port - StrataSwitch port #. 
    211  *	enable - (OUT) Boolean, true = enable PHY, false = disable.
    212  *
    213  * Returns:	
    214  *	SOC_E_XXXX
    215  */
    216 int
    217 phy_simul_enable_get(int unit, soc_port_t port, int *enable)
    218 {
    219     SIMUL_PARAM_CHECK(unit, port);
    220 
    221     *enable = _bcm_sim_data[unit][port]->enable;
    222 
    223     return SOC_E_NONE;
    224 }
    225 
    226 /*
    227  * Function: 	
    228  *	phy_simul_link_get
    229  *
    230  * Purpose:	
    231  *	Always sets link to true
    232  *
    233  * Parameters:
    234  *	unit - StrataSwitch unit #.
    235  *	port - StrataSwitch port #. 
    236  *	link - (OUT) Boolean, true indicates link established.
    237  *
    238  * Returns:	
    239  *	SOC_E_XXXX
    240  */
    241 int
    242 phy_simul_link_get(int unit, soc_port_t port, int *link)
    243 {
    244     SIMUL_PARAM_CHECK(unit, port);
    245 
    246 #if !defined(SIM_CMIC_LINK_STAT)
    247     *link = _bcm_sim_data[unit][port]->link;
    248 #else
    249     {
    250         uint32 link_bmp;
    251 
    252         link_bmp = soc_pci_read(unit, CMIC_LINK_STAT);
    253         *link = ((link_bmp & (1 << port)) != 0);
    254     }
    255     
    256 #endif
    257 
    258     return SOC_E_NONE;
    259 }
    260 
    261 
    262 /*
    263  * Function: 	
    264  *	phy_simul_duplex_set
    265  *
    266  * Purpose:	
    267  *	Set the current duplex mode (forced).
    268  *
    269  * Parameters:
    270  *	unit - StrataSwitch unit #.
    271  *	port - StrataSwitch port #. 
    272  *	duplex -Boolean, true indicates full duplex, false indicates half.
    273  *
    274  * Returns:	
    275  *	SOC_E_NONE
    276  *	SOC_E_UNAVAIL - Half duplex requested, and not supported.
    277  *
    278  * Notes: 
    279  *	Only full duplex supported (?)
    280  */
    281 int
    282 phy_simul_duplex_set(int unit, soc_port_t port, int duplex)
    283 {
    284     SIMUL_PARAM_CHECK(unit, port);
    285 
    286     _bcm_sim_data[unit][port]->duplex = duplex;
    287 
    288     return SOC_E_NONE;
    289 }
    290 
    291 /*
    292  * Function: 	
    293  *	phy_simul_duplex_get
    294  *
    295  * Purpose:	
    296  *	Only full duplex supported
    297  *
    298  * Parameters:
    299  *	unit - StrataSwitch unit #.
    300  *	port - StrataSwitch port #. 
    301  *	duplex - (OUT) Boolean, true indicates full duplex, false 
    302  *		indicates half.
    303  *
    304  * Returns:	
    305  *	SOC_E_NONE
    306  *
    307  * Notes: 
    308  *	No synchronization performed at this level. Autonegotiation is 
    309  *	not manipulated. 
    310  */
    311 int
    312 phy_simul_duplex_get(int unit, soc_port_t port, int *duplex)
    313 {
    314     SIMUL_PARAM_CHECK(unit, port);
    315 
    316     *duplex = _bcm_sim_data[unit][port]->duplex;
    317 
    318     return SOC_E_NONE;
    319 }
    320 
    321 /*
    322  * Function: 	
    323  *	phy_simul_speed_set
    324  *
    325  * Purpose:	
    326  *	Set the current operating speed (forced).
    327  *
    328  * Parameters:
    329  *	unit - StrataSwitch unit #.
    330  *	port - StrataSwitch port #. 
    331  *	speed - Requested speed, only 1000 supported.
    332  *
    333  * Returns:	
    334  *	SOC_E_XXXX
    335  */
    336 int
    337 phy_simul_speed_set(int unit, soc_port_t port, int speed)
    338 {
    339     SIMUL_PARAM_CHECK(unit, port);
    340 
    341     /* Should check port type here */
    342     _bcm_sim_data[unit][port]->speed = speed;
    343 #if 0
    344     if (IS_FE_PORT(unit, port)) {
    345         if ((speed != 10) && (speed = 100)) {
    346             /* What needs to happen here? */
    347             return  SOC_E_NONE;
    348         }
    349     } else {
    350         if ((speed == 1000)||(speed == 10000)) {
    351             /* What needs to happen here? */
    352             return  SOC_E_NONE;
    353         }
    354     }
    355     return SOC_E_CONFIG;
    356 #endif
    357 
    358     return  SOC_E_NONE;
    359 }
    360 
    361 /*
    362  * Function: 	
    363  *	phy_simul_speed_get
    364  *
    365  * Purpose:	
    366  *	Get the current operating speed for a SIMUL device.
    367  *
    368  * Parameters:
    369  *	unit - StrataSwitch unit #.
    370  *	port - StrataSwitch port #. 
    371  *	duplex - (OUT) Boolean, true indicates full duplex, false 
    372  *		indicates half.
    373  *
    374  * Returns:	
    375  *	SOC_E_NONE
    376  */
    377 int
    378 phy_simul_speed_get(int unit, soc_port_t port, int *speed)
    379 {
    380     SIMUL_PARAM_CHECK(unit, port);
    381 
    382     *speed = _bcm_sim_data[unit][port]->speed;
    383     if (*speed == 0) { /* Max speed for the port */
    384         if (IS_HG_PORT(unit, port) || IS_XE_PORT(unit, port)) {
    385             *speed = 10000;
    386         } else if (IS_GE_PORT(unit, port)) {
    387             *speed = 1000;
    388         } else {
    389             *speed = 100;
    390         }
    391     }
    392 
    393     return SOC_E_NONE;
    394 }
    395 
    396 /*
    397  * Function: 	
    398  *	phy_simul_master_set
    399  *
    400  * Purpose:	
    401  *	Set the current master mode
    402  *
    403  * Parameters:
    404  *	unit - StrataSwitch unit #.
    405  *	port - StrataSwitch port #. 
    406  *	master - SOC_PORT_MS_*
    407  *
    408  * Returns:	
    409  *	SOC_E_XXXX
    410  */
    411 int
    412 phy_simul_master_set(int unit, soc_port_t port, int master)
    413 {
    414     SIMUL_PARAM_CHECK(unit, port);
    415 
    416     _bcm_sim_data[unit][port]->master = master;
    417 
    418     return SOC_E_NONE;
    419 }
    420 
    421 /*
    422  * Function: 	
    423  *	phy_simul_master_get
    424  *
    425  * Purpose:	
    426  *	Get the current master mode for a SIMUL device.
    427  *
    428  * Parameters:
    429  *	unit - StrataSwitch unit #.
    430  *	port - StrataSwitch port #. 
    431  *	master - (OUT) SOC_PORT_MS_*
    432  *
    433  * Returns:	
    434  *	SOC_E_NONE
    435  */
    436 int
    437 phy_simul_master_get(int unit, soc_port_t port, int *master)
    438 {
    439     SIMUL_PARAM_CHECK(unit, port);
    440 
    441     *master = _bcm_sim_data[unit][port]->master;
    442 
    443     return SOC_E_NONE;
    444 }
    445 
    446 /*
    447  * Function: 	
    448  *	phy_simul_an_set
    449  *
    450  * Purpose:	
    451  *	Enable or disabled auto-negotiation on the specified port for a 
    452  *	SIMUL device.
    453  *
    454  * Parameters:
    455  *	unit - StrataSwitch unit #.
    456  *	port - StrataSwitch port #. 
    457  *	an   - Boolean, if true, auto-negotiation is enabled 
    458  *		(and/or restarted). If false, autonegotiation is disabled.
    459  *
    460  * Returns:	
    461  *	SOC_E_XXXX0 - success
    462  */
    463 int
    464 phy_simul_an_set(int unit, soc_port_t port, int an)
    465 {
    466     SIMUL_PARAM_CHECK(unit, port);
    467 
    468     _bcm_sim_data[unit][port]->an = an;
    469 
    470     return SOC_E_NONE;
    471 }
    472 
    473 /*
    474  * Function: 	
    475  *	phy_simul_an_get
    476  *
    477  * Purpose:	
    478  *	Get the current auto-negotiation status (enabled/busy)
    479  *
    480  * Parameters:
    481  *	unit - StrataSwitch unit #.
    482  *	port - StrataSwitch port #. 
    483  *	an   - (OUT) if true, auto-negotiation is enabled.
    484  *	an_done - (OUT) if true, auto-negotioation is complete. This
    485  *	     	value is undefined if an == false.
    486  *
    487  * Returns:	
    488  *	SOC_E_XXXX
    489  */
    490 int
    491 phy_simul_an_get(int unit, soc_port_t port, int *an, int *an_done)
    492 {
    493     SIMUL_PARAM_CHECK(unit, port);
    494 
    495     *an = _bcm_sim_data[unit][port]->an;
    496 
    497     return SOC_E_NONE;
    498 }
    499 
    500 /*
    501  * Function: 	
    502  *	phy_simul_adv_local_set
    503  *
    504  * Purpose:	
    505  *	Set the current advertisement for auto-negotiation.
    506  *
    507  * Parameters:
    508  *	unit - StrataSwitch unit #.
    509  *	port - StrataSwitch port #. 
    510  *	mode - Port mode mask indicating supported options/speeds.
    511  *
    512  * Returns:	
    513  *	SOC_E_XXXX
    514  *
    515  * Notes: 
    516  *	No synchronization performed at this level. The only options
    517  *	that are supported are pause and FD/HD. Although this routine
    518  *	supports FD/HD, in reality, the MAC only supports FULL so we
    519  *	should never really see it.
    520  */
    521 int 
    522 phy_simul_adv_local_set(int unit, soc_port_t port, soc_port_mode_t mode)
    523 {
    524     SIMUL_PARAM_CHECK(unit, port);
    525 
    526     _bcm_sim_data[unit][port]->adv_local = mode;
    527 
    528     return SOC_E_NONE;
    529 }
    530 
    531 /*
    532  * Function: 	
    533  *	phy_simul_adv_local_get
    534  *
    535  * Purpose:	
    536  *	Get the current advertisement for auto-negotiation.
    537  *
    538  * Parameters:
    539  *	unit - StrataSwitch unit #.
    540  *	port - StrataSwitch port #. 
    541  *	mode - (OUT) Port mode mask indicating supported options/speeds.
    542  *
    543  * Returns:	
    544  *	SOC_E_XXXX
    545  *
    546  * Notes: 
    547  *	No synchronization performed at this level.
    548  */
    549 int
    550 phy_simul_adv_local_get(int unit, soc_port_t port, soc_port_mode_t *mode)
    551 {
    552     SIMUL_PARAM_CHECK(unit, port);
    553 
    554     *mode = _bcm_sim_data[unit][port]->adv_local;
    555 
    556     return SOC_E_NONE;
    557 }
    558 
    559 /*
    560  * Function: 	
    561  *	phy_simul_adv_remote_get
    562  *
    563  * Purpose:	
    564  *	Get partners current advertisement for auto-negotiation.
    565  *
    566  * Parameters:
    567  *	unit - StrataSwitch unit #.
    568  *	port - StrataSwitch port #. 
    569  *	mode - (OUT) Port mode mask indicating supported options/speeds.
    570  *
    571  * Returns:	
    572  *	SOC_E_XXXX
    573  *
    574  * Notes: 
    575  *	No synchronization performed at this level. If Autonegotiation is
    576  *	disabled or in progress, this routine will return an error.
    577  */
    578 int
    579 phy_simul_adv_remote_get(int unit, soc_port_t port, soc_port_mode_t *mode)
    580 {
    581     SIMUL_PARAM_CHECK(unit, port);
    582 
    583     /* Need to figure this out based on port type and ?config? */
    584     /* For now, return static value from simul data */
    585 
    586     *mode = _bcm_sim_data[unit][port]->adv_remote;
    587 
    588     return SOC_E_NONE;
    589 }
    590 
    591 /*
    592  * Function: 	
    593  *	phy_simul_lb_set
    594  *
    595  * Purpose:	
    596  *	Set the local PHY loopback mode.
    597  *
    598  * Parameters:
    599  *	unit - StrataSwitch unit #.
    600  *	port - StrataSwitch port #. 
    601  *	loopback - Boolean: true = enable loopback, false = disable.
    602  *
    603  * Returns:	
    604  *	SOC_E_XXXX
    605  *
    606  * Notes: 
    607  *	No synchronization performed at this level.
    608  */
    609 int
    610 phy_simul_lb_set(int unit, soc_port_t port, int enable)
    611 {
    612     SIMUL_PARAM_CHECK(unit, port);
    613 
    614     _bcm_sim_data[unit][port]->lb = enable;
    615 
    616     return SOC_E_NONE;
    617 }
    618 
    619 /*
    620  * Function: 	
    621  *	phy_simul_lb_get
    622  *
    623  * Purpose:	
    624  *	Get the local SIMUL loopback mode.
    625  *
    626  * Parameters:
    627  *	unit - StrataSwitch unit #.
    628  *	port - StrataSwitch port #. 
    629  *	loopback - (OUT) Boolean: true = enable loopback, false = disable.
    630  *
    631  * Returns:	
    632  *	SOC_E_XXXX
    633  */
    634 int
    635 phy_simul_lb_get(int unit, soc_port_t port, int *enable)
    636 {
    637     SIMUL_PARAM_CHECK(unit, port);
    638 
    639     *enable = _bcm_sim_data[unit][port]->lb;
    640 
    641     return SOC_E_NONE;
    642 }
    643 
    644 /*
    645  * Function:
    646  *	phy_simul_interface_set
    647  *
    648  * Purpose:
    649  *	Set the current operating mode of the PHY (TBI or MII/GMII) for
    650  *	the SIMUL device.
    651  *
    652  * Parameters:
    653  *	unit - StrataSwitch unit #.
    654  *	port - StrataSwitch port #. 
    655  *	pif - one of SOC_PORT_IF_*
    656  *
    657  * Returns:
    658  *	SOC_E_XXXX
    659  */
    660 int
    661 phy_simul_interface_set(int unit, soc_port_t port, soc_port_if_t pif)
    662 {
    663     SIMUL_PARAM_CHECK(unit, port);
    664 
    665     /* This should check port type is compatible w/ IF. */
    666     _bcm_sim_data[unit][port]->pif = pif;
    667 
    668     return SOC_E_NONE;
    669 }
    670 
    671 /*
    672  * Function:
    673  *	phy_simul_interface_get
    674  *
    675  * Purpose:
    676  *	Get the current operating mode of the PHY (TBI or MII/GMII)
    677  *	for SIMUL device.
    678  *
    679  * Parameters:
    680  *	unit - StrataSwitch unit #.
    681  *	port - StrataSwitch port #. 
    682  *	pif - (OUT) one of SOC_PORT_IF_*
    683  *
    684  * Returns:
    685  *	SOC_E_XXXX
    686  */
    687 int
    688 phy_simul_interface_get(int unit, soc_port_t port, soc_port_if_t *pif)
    689 {
    690     SIMUL_PARAM_CHECK(unit, port);
    691 
    692     /* Should check set has been called */
    693     *pif = _bcm_sim_data[unit][port]->pif;
    694 
    695     return SOC_E_NONE;
    696 }
    697 
    698 /*
    699  * Function: 	
    700  *	phy_simul_ability_get
    701  *
    702  * Purpose:	
    703  *	Get the abilities of the local gigabit phy.
    704  *
    705  * Parameters:
    706  *	unit - StrataSwitch unit #.
    707  *	port - StrataSwitch port #. 
    708  *	mode - (OUT) Port mode mask indicating supported options/speeds.
    709  *
    710  * Returns:	
    711  *	SOC_E_NONE
    712  */
    713 int 
    714 phy_simul_ability_get(int unit, soc_port_t port, soc_port_mode_t *mode)
    715 {
    716     COMPILER_REFERENCE(unit);
    717 
    718     if (IS_FE_PORT(unit, port)) {
    719         *mode = SOC_PM_PAUSE_TX | SOC_PM_PAUSE_RX |
    720           SOC_PM_10MB_FD | SOC_PM_100MB_FD;
    721     } else if (IS_HG_PORT(unit, port)) {
    722 	*mode = (SOC_PM_10GB_FD | SOC_PM_MII | SOC_PM_XGMII |SOC_PM_LB_MAC |
    723 		 SOC_PM_PAUSE | SOC_PM_PAUSE_ASYMM);
    724     }  else {
    725         *mode = SOC_PM_PAUSE_TX | SOC_PM_PAUSE_RX | SOC_PM_1000MB_FD;
    726     }
    727 
    728     return SOC_E_NONE;
    729 }
    730 
    731 /*
    732  * Function:
    733  *	phy_simul_mdix_set
    734  * Description:
    735  *	Set the Auto-MDIX mode of a port/PHY
    736  * Parameters:
    737  *	unit - Device number
    738  *	port - Port number
    739  *	mode - One of:
    740  *	        BCM_PORT_MDIX_AUTO
    741  *			Enable auto-MDIX when autonegotiation is enabled
    742  *	        BCM_PORT_MDIX_FORCE_AUTO
    743  *			Enable auto-MDIX always
    744  *		BCM_PORT_MDIX_NORMAL
    745  *			Disable auto-MDIX
    746  *		BCM_PORT_MDIX_XOVER
    747  *			Disable auto-MDIX, and swap cable pairs
    748  * Return Value:
    749  *	SOC_E_UNAVAIL - feature unsupported by hardware
    750  *	SOC_E_XXX - other error
    751  */
    752 int
    753 phy_simul_mdix_set(int unit, soc_port_t port, soc_port_mdix_t mode)
    754 {
    755     SIMUL_PARAM_CHECK(unit, port);
    756 
    757     /* Should check set has been called */
    758     _bcm_sim_data[unit][port]->mdix = mode;
    759 
    760     return SOC_E_NONE;
    761 }    
    762 
    763 /*
    764  * Function:
    765  *	phy_simul_mdix_get
    766  * Description:
    767  *	Get the Auto-MDIX mode of a port/PHY
    768  * Parameters:
    769  *	unit - Device number
    770  *	port - Port number
    771  *	mode - (Out) One of:
    772  *	        BCM_PORT_MDIX_AUTO
    773  *			Enable auto-MDIX when autonegotiation is enabled
    774  *	        BCM_PORT_MDIX_FORCE_AUTO
    775  *			Enable auto-MDIX always
    776  *		BCM_PORT_MDIX_NORMAL
    777  *			Disable auto-MDIX
    778  *		BCM_PORT_MDIX_XOVER
    779  *			Disable auto-MDIX, and swap cable pairs
    780  * Return Value:
    781  *	SOC_E_UNAVAIL - feature unsupported by hardware
    782  *	SOC_E_XXX - other error
    783  */
    784 int
    785 phy_simul_mdix_get(int unit, soc_port_t port, soc_port_mdix_t *mode)
    786 {
    787     SIMUL_PARAM_CHECK(unit, port);
    788 
    789     *mode = _bcm_sim_data[unit][port]->mdix;
    790 
    791     return SOC_E_NONE;
    792 }    
    793 
    794 /*
    795  * Function:
    796  *	phy_simul_mdix_status_get
    797  * Description:
    798  *	Get the current MDIX status on a port/PHY
    799  * Parameters:
    800  *	unit    - Device number
    801  *	port    - Port number
    802  *	status  - (OUT) One of:
    803  *	        BCM_PORT_MDIX_STATUS_NORMAL
    804  *			Straight connection
    805  *	        BCM_PORT_MDIX_STATUS_XOVER
    806  *			Crossover has been performed
    807  * Return Value:
    808  *	SOC_E_UNAVAIL - feature unsupported by hardware
    809  *	SOC_E_XXX - other error
    810  */
    811 int
    812 phy_simul_mdix_status_get(int unit, soc_port_t port, 
    813                           soc_port_mdix_status_t *status)
    814 {
    815     COMPILER_REFERENCE(unit);
    816     COMPILER_REFERENCE(port);
    817 
    818     if (status == NULL) {
    819         return SOC_E_PARAM;
    820     }
    821 
    822     *status = SOC_PORT_MDIX_STATUS_NORMAL;
    823 
    824     return SOC_E_NONE;
    825 }    
    826 
    827 /*
    828  * Function:
    829  *      phy_simul_medium_get
    830  * Description:
    831  *      Get the currently chosen medium for the dual-medium PHY
    832  * Parameters:
    833  *      unit    -- Device number
    834  *      port    -- Port number
    835  *      medium  -- (Out) One of
    836  *                 SOC_PORT_MEDIUM_NONE  
    837  *                 SOC_PORT_MEDIUM_COPPER
    838  *                 SOC_PORT_MEDIUM_FIBER
    839  *
    840  * Return value:
    841  *      SOC_E_NONE
    842  *      SOC_E_PARAM
    843  *      SOC_E_UNAVAIL
    844  */
    845 int
    846 phy_simul_medium_get(int unit, soc_port_t port,
    847                      soc_port_medium_t *medium)
    848 {
    849     int rv;
    850 
    851     COMPILER_REFERENCE(unit);
    852     COMPILER_REFERENCE(port);
    853 
    854     if (medium != NULL) {
    855         *medium = SOC_PORT_MEDIUM_NONE;
    856         rv = SOC_E_NONE;
    857     } else {    
    858         rv = SOC_E_PARAM;
    859     }
    860     
    861     return (rv);
    862 }
    863 
    864 #endif /* INCLUDE_PHY_SIMUL */
    865 
    866 int _soc_phy_simul_not_empty;