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

switch.c (3452B)


      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  * BCMX Switch Control
      8  */
      9 
     10 #include <bcm/types.h>
     11 
     12 #include <bcmx/switch.h>
     13 #include <bcmx/bcmx.h>
     14 
     15 #include "bcmx_int.h"
     16 
     17 #define BCMX_SWITCH_INIT_CHECK    BCMX_READY_CHECK
     18 
     19 #define BCMX_SWITCH_SET_ERROR_CHECK(_unit, _check, _rv)    \
     20     BCMX_SET_ERROR_CHECK(_unit, _check, _rv)
     21 
     22 #define BCMX_SWITCH_GET_IS_VALID(_unit, _rv)    \
     23     BCMX_ERROR_IS_VALID(_unit, _rv)
     24 
     25 
     26 int
     27 bcmx_switch_control_set(bcm_switch_control_t type, int arg)
     28 {
     29     int rv = BCM_E_UNAVAIL, tmp_rv;
     30     int i, bcm_unit;
     31 
     32     BCMX_SWITCH_INIT_CHECK;
     33 
     34     BCMX_UNIT_ITER(bcm_unit, i) {
     35         tmp_rv = bcm_switch_control_set(bcm_unit, type, arg);
     36         BCM_IF_ERROR_RETURN(BCMX_SWITCH_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv));
     37     }
     38 
     39     return rv;
     40 }
     41 
     42 int
     43 bcmx_switch_control_get(bcm_switch_control_t type, int *arg)
     44 {
     45     int rv;
     46     int i, bcm_unit;
     47 
     48     BCMX_SWITCH_INIT_CHECK;
     49 
     50     BCMX_PARAM_NULL_CHECK(arg);
     51 
     52     BCMX_UNIT_ITER(bcm_unit, i) {
     53         rv = bcm_switch_control_get(bcm_unit, type, arg);
     54         if (BCMX_SWITCH_GET_IS_VALID(bcm_unit, rv)) {
     55             return rv;
     56         }
     57     }
     58 
     59     return BCM_E_UNAVAIL;
     60 }
     61 
     62 
     63 int
     64 bcmx_switch_control_port_set(bcmx_lport_t port, bcm_switch_control_t type,
     65                              int arg)
     66 {
     67     int         bcm_unit;
     68     bcm_port_t  bcm_port;
     69 
     70     BCMX_SWITCH_INIT_CHECK;
     71 
     72     BCM_IF_ERROR_RETURN
     73         (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port,
     74                                  BCMX_DEST_CONVERT_DEFAULT));
     75 
     76     return bcm_switch_control_port_set(bcm_unit, bcm_port,
     77                                        type, arg);
     78 }
     79 
     80 
     81 
     82 int
     83 bcmx_switch_control_port_get(bcmx_lport_t port, bcm_switch_control_t type,
     84                              int *arg)
     85 {
     86     int         bcm_unit;
     87     bcm_port_t  bcm_port;
     88 
     89     BCMX_SWITCH_INIT_CHECK;
     90 
     91     BCMX_PARAM_NULL_CHECK(arg);
     92 
     93     BCM_IF_ERROR_RETURN
     94         (_bcmx_dest_to_unit_port(port, &bcm_unit, &bcm_port,
     95                                  BCMX_DEST_CONVERT_DEFAULT));
     96 
     97     return bcm_switch_control_port_get(bcm_unit, bcm_port,
     98                                        type, arg);
     99 }
    100 
    101 
    102 int
    103 bcmx_switch_rcpu_encap_priority_map_set(uint32 flags, 
    104                                         int internal_cpu_pri, int encap_pri)
    105 {
    106     int rv = BCM_E_UNAVAIL, tmp_rv;
    107     int i, bcm_unit;
    108 
    109     BCMX_SWITCH_INIT_CHECK;
    110 
    111     BCMX_UNIT_ITER(bcm_unit, i) {
    112         tmp_rv = bcm_switch_rcpu_encap_priority_map_set(bcm_unit, flags,
    113                                                         internal_cpu_pri,
    114                                                         encap_pri);
    115         BCM_IF_ERROR_RETURN(BCMX_SWITCH_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv));
    116     }
    117 
    118     return rv;
    119 }
    120 
    121 int
    122 bcmx_switch_rcpu_encap_priority_map_get(uint32 flags,
    123                                         int internal_cpu_pri, int *encap_pri)
    124 {
    125     int rv;
    126     int i, bcm_unit;
    127 
    128     BCMX_SWITCH_INIT_CHECK;
    129 
    130     BCMX_PARAM_NULL_CHECK(encap_pri);
    131 
    132     BCMX_UNIT_ITER(bcm_unit, i) {
    133         rv = bcm_switch_rcpu_encap_priority_map_get(bcm_unit, flags,
    134                                                     internal_cpu_pri,
    135                                                     encap_pri);
    136         if (BCMX_SWITCH_GET_IS_VALID(bcm_unit, rv)) {
    137             return rv;
    138         }
    139     }
    140 
    141     return BCM_E_UNAVAIL;
    142 }