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

proxy.c (4467B)


      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:        proxy.c
      8  * Purpose:     BCMX Proxy API
      9  */
     10 
     11 #ifdef  INCLUDE_L3
     12 
     13 #include <sal/core/libc.h>
     14 
     15 #include <bcm/types.h>
     16 
     17 #include <bcmx/lport.h>
     18 #include <bcmx/bcmx.h>
     19 #include <bcmx/lplist.h>
     20 #include "bcmx_int.h"
     21 
     22 #include <bcmx/proxy.h>
     23 
     24 #define BCMX_PROXY_INIT_CHECK    BCMX_READY_CHECK
     25 
     26 #define BCMX_PROXY_ERROR_CHECK(_unit, _check, _rv)    \
     27     BCMX_ERROR_CHECK(_unit, _check, _rv)
     28 
     29 
     30 /*
     31  * Function:
     32  *      bcmx_proxy_client_set
     33  * Purpose:
     34  *      Enables redirection for a certain traffic type using either 
     35  *      FFP or FP rule
     36  * Parameters:
     37  *      client_lport -  Logical port (Ingress)for which redirection is applied
     38  *      proto_type   -  Packet type to classify for redirection
     39  *      server_lport -  Logical Port where redirected packets are 
     40  *                      destined to
     41  *      enable       -  toggle to enable or disable redirection
     42  * Returns:
     43  *      BCM_E_XXX
     44  */
     45 int
     46 bcmx_proxy_client_set(bcmx_lport_t client_lport, 
     47                       bcm_proxy_proto_type_t proto_type,
     48                       bcmx_lport_t server_lport, int enable)
     49 {
     50     bcm_port_t client_port, server_port;
     51     int unit;
     52     bcm_module_t server_modid;
     53 
     54     BCMX_PROXY_INIT_CHECK;
     55 
     56     BCM_IF_ERROR_RETURN
     57         (_bcmx_dest_to_unit_port(client_lport,
     58                                  &unit, &client_port,
     59                                  BCMX_DEST_CONVERT_DEFAULT));
     60 
     61     BCM_IF_ERROR_RETURN
     62         (_bcmx_dest_to_modid_port(server_lport,
     63                                   &server_modid, &server_port,
     64                                   BCMX_DEST_CONVERT_DEFAULT));
     65 
     66     return (bcm_proxy_client_set(unit, client_port, proto_type,
     67                                  server_modid, server_port, enable));
     68 }
     69                    
     70 /*
     71  * Function:
     72  *      bcmx_proxy_server_set
     73  * Purpose:
     74  *      Enables various kinds of lookups for packets coming from remote
     75  *      (proxy client) devices
     76  * Parameters:
     77  *      server_lport -  Logical Port to which packets are redirected to
     78  *      mode         -  Indicates lookup type
     79  *      enable       -  TRUE to enable lookups
     80  *                      FALSE to disable lookups
     81  * Returns:
     82  *      BCM_E_XXX
     83  */
     84 int
     85 bcmx_proxy_server_set(bcmx_lport_t server_lport, bcm_proxy_mode_t mode,
     86                       int enable)
     87 {                       
     88     int unit;
     89     bcm_port_t server_port;
     90 
     91     BCMX_PROXY_INIT_CHECK;
     92 
     93     BCM_IF_ERROR_RETURN
     94         (_bcmx_dest_to_unit_port(server_lport, &unit, &server_port,
     95                                  BCMX_DEST_CONVERT_DEFAULT));
     96 
     97     return (bcm_proxy_server_set(unit, server_port, mode, enable));
     98 }
     99 
    100 /*
    101  * Function:
    102  *      bcmx_proxy_server_get
    103  * Purpose:
    104  *      Get the lookup mode of XGS3 device.
    105  * Parameters:
    106  *      server_lport -  Logical port to which packets are redirected to
    107  *      status      -  (OUT) lookup mode
    108  * Returns:
    109  *      BCM_E_XXX
    110  */
    111 int
    112 bcmx_proxy_server_get(bcmx_lport_t server_lport, bcm_proxy_mode_t mode, 
    113                       int *enable)
    114 {
    115     int unit;
    116     bcm_port_t server_port;
    117 
    118     BCMX_PROXY_INIT_CHECK;
    119 
    120     BCMX_PARAM_NULL_CHECK(enable);
    121 
    122     BCM_IF_ERROR_RETURN
    123         (_bcmx_dest_to_unit_port(server_lport, &unit, &server_port,
    124                                  BCMX_DEST_CONVERT_DEFAULT));
    125 
    126     return (bcm_proxy_server_get(unit, server_port, mode, enable));
    127 }
    128 
    129 /*
    130  * Function:
    131  *      bcmx_proxy_init
    132  * Purpose:
    133  *      Initialize Proxy module system-wide
    134  * Parameters:
    135  *      None
    136  * Returns:
    137  *      BCM_E_XXX
    138  */
    139 int
    140 bcmx_proxy_init(void)
    141 {
    142     int rv = BCM_E_UNAVAIL, tmp_rv;
    143     int i, bcm_unit;
    144 
    145     BCMX_PROXY_INIT_CHECK;
    146 
    147     BCMX_UNIT_ITER(bcm_unit, i) {
    148         tmp_rv = bcm_proxy_init(bcm_unit);
    149         BCM_IF_ERROR_RETURN(BCMX_PROXY_ERROR_CHECK(bcm_unit, tmp_rv, &rv));
    150     }
    151 
    152     return rv;
    153 }
    154 
    155 /*
    156  * Function:
    157  *     bcmx_proxy_cleanup
    158  * Purpose:
    159  *     Disable Proxy system-wide
    160  * Parameters:
    161  *     None
    162  * Returns:
    163  *     BCM_E_XXX
    164  */
    165 int
    166 bcmx_proxy_cleanup(void)
    167 {
    168     int rv = BCM_E_UNAVAIL, tmp_rv;
    169     int i, bcm_unit;
    170 
    171     BCMX_PROXY_INIT_CHECK;
    172 
    173     BCMX_UNIT_ITER(bcm_unit, i) {
    174         tmp_rv = bcm_proxy_cleanup(bcm_unit);
    175         BCM_IF_ERROR_RETURN(BCMX_PROXY_ERROR_CHECK(bcm_unit, tmp_rv, &rv));
    176     }
    177 
    178     return rv;
    179 }
    180 
    181 
    182 
    183 #endif  /* INCLUDE_L3 */
    184 
    185 int _bcmx_proxy_not_empty;