portmod_defs.h (5827B)
1 /* 2 * 3 * 4 * 5 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 6 * 7 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 8 */ 9 10 #ifndef _PORTMOD_DEFS_H__H_ 11 #define _PORTMOD_DEFS_H__H_ 12 13 #include <soc/debug.h> 14 #include <soc/portmode.h> 15 #include <soc/port_ability.h> 16 #include <soc/timesync.h> 17 #include <soc/mcm/allenum.h> 18 19 #ifdef PHYMOD_SUPPORT 20 #include <phymod/phymod.h> 21 #endif /* PHYMOD_SUPPORT */ 22 23 24 #define MAX_LANES_PER_PORT (24) 25 #define MAX_PHYN (3) 26 /* ILKN PM doesn't manage phymod objects directly, 27 instead it take over other PMs and control them using portmod APIs. 28 Each ILKN PM controls up to 6 PM*/ 29 #define PORTMOD_MAX_ILKN_AGGREGATED_PMS (6) 30 31 #define MAX_NUM_CORES PORTMOD_MAX_ILKN_AGGREGATED_PMS 32 33 typedef int ilkn_retransmit_config_t; 34 typedef int phymod_firmware_mode_t; 35 typedef soc_port_ability_t portmod_port_ability_t; 36 typedef soc_port_if_t portmod_port_if_t; 37 typedef soc_port_mode_t portmod_port_mode_t; 38 39 typedef unsigned int portmod_pa_encap_t; 40 41 42 typedef struct portmod_lanes_assign_info_s{ 43 uint32 valid_entries; 44 uint32 lane_assign[MAX_LANES_PER_PORT]; 45 }portmod_lanes_assign_info_t; 46 47 48 #if (defined BCM_ESW_SUPPORT) && (512 > _SHR_PBMP_PORT_MAX) 49 #define PORTMOD_PBMP_PORT_MAX 512 50 #else 51 #define PORTMOD_PBMP_PORT_MAX _SHR_PBMP_PORT_MAX 52 #endif 53 54 #define PORTMOD_PBMP_WORD_MAX \ 55 ((PORTMOD_PBMP_PORT_MAX + _SHR_PBMP_WORD_WIDTH-1) / _SHR_PBMP_WORD_WIDTH) 56 57 typedef struct portmod_pbmp { 58 uint32 pbits[PORTMOD_PBMP_WORD_MAX]; 59 } portmod_pbmp_t; 60 61 extern int portmod_pbmp_bmnull(portmod_pbmp_t *bmp); 62 extern int portmod_pbmp_bmeq(portmod_pbmp_t *bmp1, portmod_pbmp_t *bmp2); 63 64 #define PORTMOD_PBMP_WORDS(bm) \ 65 (sizeof((bm).pbits) / sizeof((bm).pbits[0])) 66 67 #define PORTMOD_PBMP_COUNT(bm, count) \ 68 do { \ 69 int _w; \ 70 count = 0; \ 71 for (_w = 0; _w < PORTMOD_PBMP_WORD_MAX; _w++) { \ 72 count += _shr_popcount(_SHR_PBMP_WORD_GET(bm, _w)); \ 73 } \ 74 } while(0) 75 76 #define PORTMOD_PBMP_BMOP(bma, bmb, op) \ 77 do { \ 78 int _w, _l; \ 79 _l = ((PORTMOD_PBMP_WORDS(bma) < PORTMOD_PBMP_WORDS(bmb)) ? \ 80 PORTMOD_PBMP_WORDS(bma) : PORTMOD_PBMP_WORDS(bmb)); \ 81 for (_w = 0; _w < _l; _w++) { \ 82 _SHR_PBMP_WORD_GET(bma, _w) op _SHR_PBMP_WORD_GET(bmb, _w); \ 83 } \ 84 } while (0) 85 86 #define PORTMOD_PBMP_CLEAR(bm) \ 87 do { \ 88 int _w; \ 89 for (_w = 0; _w < PORTMOD_PBMP_WORD_MAX; _w++) { \ 90 _SHR_PBMP_WORD_GET(bm, _w) = 0; \ 91 } \ 92 } while (0) 93 94 95 96 #define PORTMOD_PBMP_ITER(bm, port) \ 97 for ((port) = 0; (port) < PORTMOD_PBMP_PORT_MAX; (port)++) \ 98 if (PORTMOD_PBMP_MEMBER((bm), (port))) 99 100 #define PORTMOD_PBMP_IS_NULL(bm) (portmod_pbmp_bmnull(&bm)) 101 #define PORTMOD_PBMP_NOT_NULL(bm) (!portmod_pbmp_bmnull(&bm)) 102 #define PORTMOD_PBMP_EQ(bma, bmb) (portmod_pbmp_bmeq(&bma, &bmb)) 103 #define PORTMOD_PBMP_NEQ(bma, bmb) (!portmod_pbmp_bmeq(&bma, &bmb)) 104 /* Assignment operators */ 105 #define PORTMOD_PBMP_ASSIGN(dst, src) (dst) = (src) 106 #define PORTMOD_PBMP_AND(bma, bmb) PORTMOD_PBMP_BMOP(bma, bmb, &=) 107 #define PORTMOD_PBMP_OR(bma, bmb) PORTMOD_PBMP_BMOP(bma, bmb, |=) 108 #define PORTMOD_PBMP_XOR(bma, bmb) PORTMOD_PBMP_BMOP(bma, bmb, ^=) 109 #define PORTMOD_PBMP_REMOVE(bma, bmb) PORTMOD_PBMP_BMOP(bma, bmb, &= ~) 110 #define PORTMOD_PBMP_NEGATE(bma, bmb) PORTMOD_PBMP_BMOP(bma, bmb, = ~) 111 /* Port PBMP operators */ 112 #define PORTMOD_PBMP_MEMBER(bm, port) \ 113 ((_SHR_PBMP_ENTRY(bm, port) & _SHR_PBMP_WBIT(port)) != 0) 114 #define PORTMOD_PBMP_PORT_SET(bm, port) do { \ 115 PORTMOD_PBMP_CLEAR(bm); \ 116 PORTMOD_PBMP_PORT_ADD(bm, port); \ 117 } while(0) 118 #define PORTMOD_PBMP_PORT_ADD(bm, port) \ 119 (_SHR_PBMP_ENTRY(bm, port) |= _SHR_PBMP_WBIT(port)) 120 #define PORTMOD_PBMP_PORT_REMOVE(bm, port) \ 121 (_SHR_PBMP_ENTRY(bm, port) &= ~_SHR_PBMP_WBIT(port)) 122 #define PORTMOD_PBMP_PORT_FLIP(bm, port) \ 123 (_SHR_PBMP_ENTRY(bm, port) ^= _SHR_PBMP_WBIT(port)) 124 #define PORTMOD_PBMP_PORTS_RANGE_ADD(bm, first_port, range) \ 125 do {\ 126 uint32 _mask_;\ 127 int _first_port_, _range_;\ 128 _first_port_ = first_port; _range_ = range;\ 129 while (_range_ > 0) {\ 130 _mask_ = ~0;\ 131 if (_range_ < _SHR_PBMP_WORD_WIDTH) _mask_ >>= (_SHR_PBMP_WORD_WIDTH - _range_);\ 132 _mask_ <<= (_first_port_ % _SHR_PBMP_WORD_WIDTH);\ 133 _SHR_PBMP_ENTRY(bm, _first_port_) |= _mask_; \ 134 _range_ += (_first_port_ % _SHR_PBMP_WORD_WIDTH) - _SHR_PBMP_WORD_WIDTH;\ 135 _first_port_ += _SHR_PBMP_WORD_WIDTH - (_first_port_ % _SHR_PBMP_WORD_WIDTH);\ 136 }\ 137 } while (0); 138 139 140 #define PORTMOD_VSD_PBMP_WORD_WIDTH 32 /* 32 bits */ 141 #define PORTMOD_VSD_PBMP_WORD_GET(bm,word) (bm[(word)]) 142 #define PORTMOD_VSD_PBMP_WENT(idx) ((idx)/PORTMOD_VSD_PBMP_WORD_WIDTH) 143 #define PORTMOD_VSD_PBMP_WBIT(idx) \ 144 (1U << ((idx) % PORTMOD_VSD_PBMP_WORD_WIDTH)) 145 146 #define PORTMOD_VSD_PBMP_WORD_ENTRY(bm, idx) \ 147 (PORTMOD_VSD_PBMP_WORD_GET(bm,PORTMOD_VSD_PBMP_WENT(idx))) 148 149 #define PORTMOD_VSD_PBMP_GROUP_ACTIVE(bm, idx) \ 150 ((PORTMOD_VSD_PBMP_WORD_ENTRY(bm, idx) & PORTMOD_VSD_PBMP_WBIT(idx)) != 0) 151 152 #define PORTMOD_VSD_PBMP_GROUP_SET(bm, idx) \ 153 ( PORTMOD_VSD_PBMP_WORD_ENTRY(bm, idx) |= PORTMOD_VSD_PBMP_WBIT(idx)) 154 155 #define PORTMOD_VSD_PBMP_GROUP_CLEAR(bm, idx) \ 156 ( PORTMOD_VSD_PBMP_WORD_ENTRY(bm, idx) &= ~PORTMOD_VSD_PBMP_WBIT(idx)) 157 158 159 160 #endif /*_PORTMOD_DEFS_H__H_*/