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

il.c (12826B)


      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  * XMAC driver
      8  */
      9 
     10 #if defined(BCM_ESW_SUPPORT) || defined(BCM_SAND_SUPPORT)
     11 
     12 #include <sal/core/libc.h>
     13 #include <sal/core/spl.h>
     14 #include <sal/core/boot.h>
     15 
     16 #include <soc/drv.h>
     17 #include <soc/error.h>
     18 #include <soc/cmic.h>
     19 #include <soc/portmode.h>
     20 #include <soc/ll.h>
     21 #include <soc/counter.h>
     22 #include <soc/phyctrl.h>
     23 #include <soc/debug.h>
     24 
     25 
     26 #define JUMBO_MAXSZ              0x3fe8 /* Max legal value (per regsfile) */
     27 
     28 /*
     29  * Function:
     30  *      mac_il_init
     31  * Purpose:
     32  *      Initialize Xmac into a known good state.
     33  * Parameters:
     34  *      unit - XGS unit #.
     35  *      port - Port number on unit.
     36  * Returns:
     37  *      SOC_E_XXX
     38  * Notes:
     39  */
     40 STATIC int
     41 mac_il_init(int unit, soc_port_t port)
     42 {
     43     return SOC_E_NONE;
     44 }
     45 
     46 /*
     47  * Function:
     48  *      mac_il_enable_set
     49  * Purpose:
     50  *      Enable or disable MAC
     51  * Parameters:
     52  *      unit - XGS unit #.
     53  *      port - Port number on unit.
     54  *      enable - TRUE to enable, FALSE to disable
     55  * Returns:
     56  *      SOC_E_XXX
     57  */
     58 STATIC int
     59 mac_il_enable_set(int unit, soc_port_t port, int enable)
     60 {
     61     return SOC_E_NONE;
     62 }
     63 
     64 /*
     65  * Function:
     66  *      mac_il_enable_get
     67  * Purpose:
     68  *      Get MAC enable state
     69  * Parameters:
     70  *      unit - XGS unit #.
     71  *      port - Port number on unit.
     72  *      enable - (OUT) TRUE if enabled, FALSE if disabled
     73  * Returns:
     74  *      SOC_E_XXX
     75  */
     76 STATIC int
     77 mac_il_enable_get(int unit, soc_port_t port, int *enable)
     78 {
     79     return SOC_E_NONE;
     80 }
     81 
     82 /*
     83  * Function:
     84  *      mac_il_duplex_set
     85  * Purpose:
     86  *      Set  XMAC in the specified duplex mode.
     87  * Parameters:
     88  *      unit - XGS unit #.
     89  *      port - XGS port # on unit.
     90  *      duplex - Boolean: true --> full duplex, false --> half duplex.
     91  * Returns:
     92  *      SOC_E_XXX
     93  * Notes:
     94  */
     95 STATIC int
     96 mac_il_duplex_set(int unit, soc_port_t port, int duplex)
     97 {
     98     return SOC_E_NONE;
     99 }
    100 
    101 /*
    102  * Function:
    103  *      mac_il_duplex_get
    104  * Purpose:
    105  *      Get XMAC duplex mode.
    106  * Parameters:
    107  *      unit - XGS unit #.
    108  *      duplex - (OUT) Boolean: true --> full duplex, false --> half duplex.
    109  * Returns:
    110  *      SOC_E_XXX
    111  */
    112 STATIC int
    113 mac_il_duplex_get(int unit, soc_port_t port, int *duplex)
    114 {
    115     return SOC_E_NONE;
    116 }
    117 
    118 /*
    119  * Function:
    120  *      mac_il_pause_set
    121  * Purpose:
    122  *      Configure XMAC to transmit/receive pause frames.
    123  * Parameters:
    124  *      unit - XGS unit #.
    125  *      port - XGS port # on unit.
    126  *      pause_tx - Boolean: transmit pause or -1 (don't change)
    127  *      pause_rx - Boolean: receive pause or -1 (don't change)
    128  * Returns:
    129  *      SOC_E_XXX
    130  */
    131 STATIC int
    132 mac_il_pause_set(int unit, soc_port_t port, int pause_tx, int pause_rx)
    133 {
    134     return SOC_E_NONE;
    135 }
    136 
    137 /*
    138  * Function:
    139  *      mac_il_pause_get
    140  * Purpose:
    141  *      Return the pause ability of XMAC
    142  * Parameters:
    143  *      unit - XGS unit #.
    144  *      port - XGS port # on unit.
    145  *      pause_tx - Boolean: transmit pause
    146  *      pause_rx - Boolean: receive pause
    147  *      pause_mac - MAC address used for pause transmission.
    148  * Returns:
    149  *      SOC_E_XXX
    150  */
    151 STATIC int
    152 mac_il_pause_get(int unit, soc_port_t port, int *pause_tx, int *pause_rx)
    153 {
    154     return SOC_E_NONE;
    155 }
    156 
    157 /*
    158  * Function:
    159  *      mac_il_speed_set
    160  * Purpose:
    161  *      Set XMAC in the specified speed.
    162  * Parameters:
    163  *      unit - XGS unit #.
    164  *      port - XGS port # on unit.
    165  *      speed - 2500, 3000, 10000, 12000 for speed.
    166  * Returns:
    167  *      SOC_E_XXX
    168  */
    169 STATIC int
    170 mac_il_speed_set(int unit, soc_port_t port, int speed)
    171 {
    172     SOC_IF_ERROR_RETURN(soc_phyctrl_notify(unit, port, phyEventSpeed, speed));
    173 
    174     return SOC_E_NONE;
    175 }
    176 
    177 /*
    178  * Function:
    179  *      mac_il_speed_get
    180  * Purpose:
    181  *      Get XMAC speed
    182  * Parameters:
    183  *      unit - XGS unit #.
    184  *      port - XGS port # on unit.
    185  *      speed - (OUT) speed in Mb (2500/3000/10000/12000)
    186  * Returns:
    187  *      SOC_E_XXX
    188  */
    189 STATIC int
    190 mac_il_speed_get(int unit, soc_port_t port, int *speed)
    191 {
    192     *speed = 50000;
    193 
    194     return SOC_E_NONE;
    195 }
    196 
    197 /*
    198  * Function:
    199  *      mac_il_loopback_set
    200  * Purpose:
    201  *      Set a XMAC into/out-of loopback mode
    202  * Parameters:
    203  *      unit - XGS unit #.
    204  *      port - XGS unit # on unit.
    205  *      loopback - Boolean: true -> loopback mode, false -> normal operation
    206  * Note:
    207  *      On Xmac, when setting loopback, we enable the TX/RX function also.
    208  *      Note that to test the PHY, we use the remote loopback facility.
    209  * Returns:
    210  *      SOC_E_XXX
    211  */
    212 STATIC int
    213 mac_il_loopback_set(int unit, soc_port_t port, int lb)
    214 {
    215 
    216   return SOC_E_NONE;
    217 }
    218 
    219 /*
    220  * Function:
    221  *      mac_il_loopback_get
    222  * Purpose:
    223  *      Get current XMAC loopback mode setting.
    224  * Parameters:
    225  *      unit - XGS unit #.
    226  *      port - XGS port # on unit.
    227  *      loopback - (OUT) Boolean: true = loopback, false = normal
    228  * Returns:
    229  *      SOC_E_XXX
    230  */
    231 STATIC int
    232 mac_il_loopback_get(int unit, soc_port_t port, int *lb)
    233 {
    234 
    235   return SOC_E_NONE;
    236 }
    237 
    238 /*
    239  * Function:
    240  *      mac_il_pause_addr_set
    241  * Purpose:
    242  *      Configure PAUSE frame source address.
    243  * Parameters:
    244  *      unit - XGS unit #.
    245  *      port - XGS port # on unit.
    246  *      pause_mac - (OUT) MAC address used for pause transmission.
    247  * Returns:
    248  *      SOC_E_XXX
    249  */
    250 STATIC int
    251 mac_il_pause_addr_set(int unit, soc_port_t port, sal_mac_addr_t m)
    252 {
    253     return SOC_E_NONE;
    254 }
    255 
    256 /*
    257  * Function:
    258  *      mac_il_pause_addr_get
    259  * Purpose:
    260  *      Retrieve PAUSE frame source address.
    261  * Parameters:
    262  *      unit - XGS unit #.
    263  *      port - XGS port # on unit.
    264  *      pause_mac - (OUT) MAC address used for pause transmission.
    265  * Returns:
    266  *      SOC_E_XXX
    267  * NOTE: We always write the same thing to TX & RX SA
    268  *       so, we just return the contects on RXMACSA.
    269  */
    270 STATIC int
    271 mac_il_pause_addr_get(int unit, soc_port_t port, sal_mac_addr_t m)
    272 {
    273     return SOC_E_NONE;
    274 }
    275 
    276 /*
    277  * Function:
    278  *      mac_il_interface_set
    279  * Purpose:
    280  *      Set a XMAC interface type
    281  * Parameters:
    282  *      unit - XGS unit #.
    283  *      port - XGS port # on unit.
    284  *      pif - one of SOC_PORT_IF_*
    285  * Returns:
    286  *      SOC_E_NONE
    287  *      SOC_E_UNAVAIL - requested mode not supported.
    288  * Notes:
    289  */
    290 STATIC int
    291 mac_il_interface_set(int unit, soc_port_t port, soc_port_if_t pif)
    292 {
    293     return SOC_E_NONE;
    294 }
    295 
    296 /*
    297  * Function:
    298  *      mac_il_interface_get
    299  * Purpose:
    300  *      Retrieve XMAC interface type
    301  * Parameters:
    302  *      unit - XGS unit #.
    303  *      port - XGS port # on unit.
    304  *      pif - (OUT) one of SOC_PORT_IF_*
    305  * Returns:
    306  *      SOC_E_NONE
    307  */
    308 STATIC int
    309 mac_il_interface_get(int unit, soc_port_t port, soc_port_if_t *pif)
    310 {
    311     COMPILER_REFERENCE(unit);
    312     COMPILER_REFERENCE(port);
    313 
    314     *pif = SOC_PORT_IF_MII;
    315 
    316     return SOC_E_NONE;
    317 }
    318 
    319 /*
    320  * Function:
    321  *      mac_il_frame_max_set
    322  * Description:
    323  *      Set the maximum receive frame size for the port
    324  * Parameters:
    325  *      unit - Device number
    326  *      port - Port number
    327  *      size - Maximum frame size in bytes
    328  * Return Value:
    329  *      BCM_E_XXX
    330  */
    331 STATIC int
    332 mac_il_frame_max_set(int unit, soc_port_t port, int size)
    333 {
    334     return SOC_E_NONE;
    335 }
    336 
    337 /*
    338  * Function:
    339  *      mac_il_frame_max_get
    340  * Description:
    341  *      Set the maximum receive frame size for the port
    342  * Parameters:
    343  *      unit - Device number
    344  *      port - Port number
    345  *      size - Maximum frame size in bytes
    346  * Return Value:
    347  *      BCM_E_XXX
    348  */
    349 STATIC int
    350 mac_il_frame_max_get(int unit, soc_port_t port, int *size)
    351 {
    352     return SOC_E_NONE;
    353 }
    354 
    355 /*
    356  * Function:
    357  *      mac_il_ifg_set
    358  * Description:
    359  *      Sets the new ifg (Inter-frame gap) value
    360  * Parameters:
    361  *      unit   - Device number
    362  *      port   - Port number
    363  *      speed  - the speed for which the IFG is being set
    364  *      duplex - the duplex for which the IFG is being set
    365  *      ifg - number of bits to use for average inter-frame gap
    366  * Return Value:
    367  *      BCM_E_XXX
    368  * Notes:
    369  *      The function makes sure the IFG value makes sense and updates the
    370  *      IPG register in case the speed/duplex match the current settings
    371  */
    372 STATIC int
    373 mac_il_ifg_set(int unit, soc_port_t port, int speed,
    374                 soc_port_duplex_t duplex, int ifg)
    375 {
    376     return SOC_E_NONE;
    377 }
    378 
    379 /*
    380  * Function:
    381  *      mac_il_ifg_get
    382  * Description:
    383  *      Sets the new ifg (Inter-frame gap) value
    384  * Parameters:
    385  *      unit   - Device number
    386  *      port   - Port number
    387  *      speed  - the speed for which the IFG is being set
    388  *      duplex - the duplex for which the IFG is being set
    389  *      size - Maximum frame size in bytes
    390  * Return Value:
    391  *      BCM_E_XXX
    392  * Notes:
    393  *      The function makes sure the IFG value makes sense and updates the
    394  *      IPG register in case the speed/duplex match the current settings
    395  */
    396 STATIC int
    397 mac_il_ifg_get(int unit, soc_port_t port, int speed,
    398                 soc_port_duplex_t duplex, int *ifg)
    399 {
    400     return SOC_E_NONE;
    401 }
    402 
    403 /*
    404  * Function:
    405  *      mac_il_loopback_remote_set
    406  * Purpose:
    407  *      Set the XMAC into remote-loopback state.
    408  * Parameters:
    409  *      unit - XGS unit #.
    410  *      port - XGS port # on unit.
    411  *      mode - (INT) loopback enable state
    412  * Returns:
    413  *      SOC_E_XXX
    414  */
    415 int
    416 mac_il_loopback_remote_set(int unit, soc_port_t port, int lb)
    417 {
    418     return SOC_E_NONE;
    419 }
    420 
    421 /*
    422  * Function:
    423  *      mac_il_encap_set
    424  * Purpose:
    425  *      Set the XMAC port encapsulation mode.
    426  * Parameters:
    427  *      unit - XGS unit #.
    428  *      port - XGS port # on unit.
    429  *      mode - (IN) encap bits (defined above)
    430  * Returns:
    431  *      SOC_E_XXX
    432  */
    433 STATIC int
    434 mac_il_encap_set(int unit, soc_port_t port, int mode)
    435 {
    436     return SOC_E_NONE;
    437 }
    438 
    439 /*
    440  * Function:
    441  *      mac_il_encap_get
    442  * Purpose:
    443  *      Get the XMAC port encapsulation mode.
    444  * Parameters:
    445  *      unit - XGS unit #.
    446  *      port - XGS port # on unit.
    447  *      mode - (INT) encap bits (defined above)
    448  * Returns:
    449  *      SOC_E_XXX
    450  */
    451 STATIC int
    452 mac_il_encap_get(int unit, soc_port_t port, int *mode)
    453 {
    454     return SOC_E_NONE;
    455 }
    456 
    457 /*
    458  * Function:
    459  *      mac_il_control_set
    460  * Purpose:
    461  *      To configure MAC control properties.
    462  * Parameters:
    463  *      unit - XGS unit #.
    464  *      port - XGS port # on unit.
    465  *      type - MAC control property to set.
    466  *      int  - New setting for MAC control.
    467  * Returns:
    468  *      SOC_E_XXX
    469  */
    470 STATIC int
    471 mac_il_control_set(int unit, soc_port_t port, soc_mac_control_t type,
    472                   int value)
    473 {
    474     return SOC_E_NONE;
    475 }
    476 
    477 /*
    478  * Function:
    479  *      mac_il_control_get
    480  * Purpose:
    481  *      To get current MAC control setting.
    482  * Parameters:
    483  *      unit - XGS unit #.
    484  *      port - XGS port # on unit.
    485  *      type - MAC control property to set.
    486  *      int  - New setting for MAC control.
    487  * Returns:
    488  *      SOC_E_XXX
    489  */
    490 STATIC int
    491 mac_il_control_get(int unit, soc_port_t port, soc_mac_control_t type,
    492                   int *value)
    493 {
    494     return SOC_E_NONE;
    495 }
    496 
    497 /*
    498  * Function:
    499  *      mac_il_ability_local_get
    500  * Purpose:
    501  *      Return the abilities of XMAC
    502  * Parameters:
    503  *      unit - XGS unit #.
    504  *      port - XGS port # on unit.
    505  *      mode - (OUT) Supported operating modes as a mask of abilities.
    506  * Returns:
    507  *      SOC_E_XXX
    508  */
    509 STATIC int
    510 mac_il_ability_local_get(int unit, soc_port_t port,
    511                           soc_port_ability_t *ability)
    512 {
    513     return SOC_E_NONE;
    514 }
    515 
    516 /* Exported XMAC driver structure */
    517 mac_driver_t soc_mac_il = {
    518     "Interlaken Driver",           /* drv_name */
    519     mac_il_init,                   /* md_init  */
    520     mac_il_enable_set,             /* md_enable_set */
    521     mac_il_enable_get,             /* md_enable_get */
    522     mac_il_duplex_set,             /* md_duplex_set */
    523     mac_il_duplex_get,             /* md_duplex_get */
    524     mac_il_speed_set,              /* md_speed_set */
    525     mac_il_speed_get,              /* md_speed_get */
    526     mac_il_pause_set,              /* md_pause_set */
    527     mac_il_pause_get,              /* md_pause_get */
    528     mac_il_pause_addr_set,         /* md_pause_addr_set */
    529     mac_il_pause_addr_get,         /* md_pause_addr_get */
    530     mac_il_loopback_set,           /* md_lb_set */
    531     mac_il_loopback_get,           /* md_lb_get */
    532     mac_il_interface_set,          /* md_interface_set */
    533     mac_il_interface_get,          /* md_interface_get */
    534     NULL,                         /* md_ability_get - Deprecated */
    535     mac_il_frame_max_set,          /* md_frame_max_set */
    536     mac_il_frame_max_get,          /* md_frame_max_get */
    537     mac_il_ifg_set,                /* md_ifg_set */
    538     mac_il_ifg_get,                /* md_ifg_get */
    539     mac_il_encap_set,              /* md_encap_set */
    540     mac_il_encap_get,              /* md_encap_get */
    541     mac_il_control_set,            /* md_control_set */
    542     mac_il_control_get,            /* md_control_get */
    543     mac_il_ability_local_get,      /* md_ability_local_get */
    544     NULL                           /* md_timesync_tx_info_get */
    545  };
    546 
    547 #endif /* defined(BCM_ESW_SUPPORT) || defined(BCM_SAND_SUPPORT) */