lport.h (2032B)
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: lport.h 8 * Purpose: BCMX Internal Logical and User Port definitions 9 */ 10 11 #ifndef _BCMX_INT_LPORT_H_ 12 #define _BCMX_INT_LPORT_H_ 13 14 #include <bcm/types.h> 15 #include <bcmx/types.h> 16 17 typedef struct _bcmx_port_s _bcmx_port_t; 18 typedef struct _bcmx_uport_hash_s _bcmx_uport_hash_t; 19 20 /* BCMX Logical Port */ 21 struct _bcmx_port_s { 22 int bcm_unit; /* Unit port belongs to */ 23 bcm_port_t bcm_port; /* Port number relative to bcm unit */ 24 bcmx_uport_t uport; /* Cookie for application lport */ 25 uint32 flags; /* Flags BCMX_PORT_F_xxx */ 26 int modid; /* Module id for this lport */ 27 bcm_port_t modport; /* Module relative port (0..31) */ 28 }; 29 30 /* Hash is allocated on BCMX initialization */ 31 struct _bcmx_uport_hash_s { 32 bcmx_uport_t uport; 33 bcmx_lport_t lport; 34 _bcmx_uport_hash_t *next; 35 _bcmx_uport_hash_t *prev; 36 }; 37 38 /* 39 * BCMX application logical port definitions. 40 * 41 * The mapping: "application port -> BCMX logical port" is currently a 42 * hash + doubly linked list. It is assumed that adding/removing ports is 43 * a relatively rare occurrance and that an allocation/free call is 44 * acceptable during this process. 45 * 46 * Alternatively: 47 * 48 * ((((PTR_TO_INT(uport)) >> 16) ^ ((PTR_TO_INT(uport)) & 0xffff)) % \ 49 * BCMX_UPORT_HASH_COUNT) 50 */ 51 #define BCMX_UPORT_HASH_COUNT 73 /* Prime */ 52 #define BCMX_UPORT_HASH(uport) ((PTR_TO_INT(uport)) % BCMX_UPORT_HASH_COUNT) 53 extern _bcmx_uport_hash_t *_bcmx_uport_hash[BCMX_UPORT_HASH_COUNT]; 54 55 56 /* 57 * Deprecated - No longer supported. 58 */ 59 extern int bcmx_lport_max; /* Set to 0 */ 60 extern bcmx_lport_t _bcmx_lport_first; 61 extern bcmx_uport_t _bcmx_uport_invalid; 62 extern _bcmx_port_t *_bcmx_port; 63 64 #endif /* _BCMX_INT_LPORT_H_ */