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

dport.h (1869B)


      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  * The diag shell port mapping functions are located in the SOC layer
      8  * for historical reasons, but the mappings are not used internally
      9  * in either the SOC layer or the BCM layer.
     10  */
     11 
     12 #ifndef __DIAG_DPORT_H__
     13 #define __DIAG_DPORT_H__
     14 
     15 #include <sal/types.h>
     16 
     17 #include <soc/dport.h>
     18 
     19 #include <bcm_int/api_xlate_port.h>
     20 
     21 #ifdef INCLUDE_BCM_API_XLATE_PORT
     22 #define XLATE_P2A(_u,_p) BCM_API_XLATE_PORT_P2A(_u,&_p) == 0
     23 #else
     24 #define XLATE_P2A(_u,_p) 1
     25 #endif
     26 
     27 /* Iterate over BCM port bitmap in user port order */
     28 #define DPORT_BCM_PBMP_ITER(_u,_pbm,_dport,_p) \
     29         for ((_dport) = 0, (_p) = -1; (_dport) < SOC_DPORT_MAX; (_dport)++) \
     30                 if (((_p) = soc_dport_to_port(_u,_dport)) >= 0 && \
     31                     XLATE_P2A(_u,_p) && SOC_PBMP_MEMBER((_pbm),(_p)))
     32 
     33 /* Iterate over (SOC) port bitmap in user port order */
     34 #define DPORT_SOC_PBMP_ITER(_unit,_pbm,_dport,_port) \
     35     SOC_DPORT_PBMP_ITER(_unit,_pbm,_dport,_port)
     36 
     37 /* Tranalate user port number to internal port number */
     38 #define DPORT_TO_PORT(_unit,_dport) \
     39     soc_dport_to_port(_unit,_dport)
     40 
     41 /* Tranalate internal port number to user port number */
     42 #define DPORT_FROM_PORT(_unit,_port) \
     43     soc_dport_from_port(_unit,_port)
     44 
     45 /* Get user port number or port index based on currrent configuration */
     46 #define DPORT_FROM_DPORT_INDEX(_unit,_dport,_i) \
     47     soc_dport_from_dport_idx(_unit,_dport,_i)
     48 
     49 /* Map a user port number to an internal port number */
     50 #define DPORT_MAP_PORT(_unit,_dport,_port) \
     51     soc_dport_map_port(_unit,_dport,_port)
     52 
     53 /* Update dport mappings and port names */
     54 #define DPORT_MAP_UPDATE(_unit) \
     55     soc_dport_map_update(_unit)
     56 
     57 #endif /* __DIAG_DPORT_H__ */