OpenNSL API Guide and Reference Manual
Data Structures | Macros | Typedefs | Functions
pbmp.h File Reference
#include <sal/types.h>

Go to the source code of this file.

Data Structures

struct  _shr_pbmp
 

Macros

#define _SHR_DEFINE_PBMP_FUNCTIONS
 
#define _SHR_PBMP_AND(bma, bmb)   _SHR_PBMP_BMOP(bma, bmb, &=)
 
#define _SHR_PBMP_ASSIGN(dst, src)   (dst) = (src)
 
#define _SHR_PBMP_BMCLEAR(bm)
 
#define _SHR_PBMP_BMEQ(bma, bmb)   (_shr_pbmp_bmeq(&bma, &bmb))
 
#define _SHR_PBMP_BMNULL(bm)   (_shr_pbmp_bmnull(&bm))
 
#define _SHR_PBMP_BMOP(bma, bmb, op)
 
#define _SHR_PBMP_CLEAR(bm)   _SHR_PBMP_BMCLEAR(bm)
 
#define _SHR_PBMP_COUNT(bm, count)
 
#define _SHR_PBMP_ENTRY(bm, port)   (_SHR_PBMP_WORD_GET(bm,_SHR_PBMP_WENT(port)))
 
#define _SHR_PBMP_EQ(bma, bmb)   (_SHR_PBMP_BMEQ(bma, bmb))
 
#define _SHR_PBMP_FIRST(bm, first_port)
 
#define _SHR_PBMP_FMT(bm, buf)   _shr_pbmp_format(bm, buf)
 
#define _SHR_PBMP_FMT_LEN   ((_SHR_PBMP_WORD_MAX*8)+3)
 
#define _SHR_PBMP_IS_NULL(bm)   (_SHR_PBMP_BMNULL(bm))
 
#define _SHR_PBMP_ITER(bm, port)
 
#define _SHR_PBMP_LAST(bm, last_port)
 
#define _SHR_PBMP_MEMBER(bm, port)   ((_SHR_PBMP_ENTRY(bm, port) & _SHR_PBMP_WBIT(port)) != 0)
 
#define _SHR_PBMP_NEGATE(bma, bmb)   _SHR_PBMP_BMOP(bma, bmb, = ~)
 
#define _SHR_PBMP_NEQ(bma, bmb)   (!_SHR_PBMP_BMEQ(bma, bmb))
 
#define _SHR_PBMP_NOT_NULL(bm)   (!_SHR_PBMP_BMNULL(bm))
 
#define _SHR_PBMP_OR(bma, bmb)   _SHR_PBMP_BMOP(bma, bmb, |=)
 
#define _SHR_PBMP_PORT_ADD(bm, port)   (_SHR_PBMP_ENTRY(bm, port) |= _SHR_PBMP_WBIT(port))
 
#define _SHR_PBMP_PORT_FLIP(bm, port)   (_SHR_PBMP_ENTRY(bm, port) ^= _SHR_PBMP_WBIT(port))
 
#define _SHR_PBMP_PORT_MAX   256
 
#define _SHR_PBMP_PORT_REMOVE(bm, port)   (_SHR_PBMP_ENTRY(bm, port) &= ~_SHR_PBMP_WBIT(port))
 
#define _SHR_PBMP_PORT_SET(bm, port)
 
#define _SHR_PBMP_PORT_VALID(p)   ((p) >= 0 && (p) < _SHR_PBMP_PORT_MAX)
 
#define _SHR_PBMP_REMOVE(bma, bmb)   _SHR_PBMP_BMOP(bma, bmb, &= ~)
 
#define _SHR_PBMP_REVERSE_ITER(bm, port)
 
#define _SHR_PBMP_WBIT(port)   (1U<<((port) % _SHR_PBMP_WORD_WIDTH))
 
#define _SHR_PBMP_WENT(port)   ((port)/_SHR_PBMP_WORD_WIDTH)
 
#define _SHR_PBMP_WIDTH   (((_SHR_PBMP_PORT_MAX + 32 - 1)/32)*32)
 
#define _SHR_PBMP_WORD_GET(bm, word)   ((bm).pbits[(word)])
 
#define _SHR_PBMP_WORD_MAX   ((_SHR_PBMP_WIDTH + _SHR_PBMP_WORD_WIDTH-1) / _SHR_PBMP_WORD_WIDTH)
 
#define _SHR_PBMP_WORD_SET(bm, word, val)   ((bm).pbits[(word)] = (val))
 
#define _SHR_PBMP_WORD_WIDTH   32
 
#define _SHR_PBMP_XOR(bma, bmb)   _SHR_PBMP_BMOP(bma, bmb, ^=)
 

Typedefs

typedef struct _shr_pbmp _shr_pbmp_t
 

Functions

int _shr_pbmp_bmeq (_shr_pbmp_t *, _shr_pbmp_t *)
 
int _shr_pbmp_bmnull (_shr_pbmp_t *)
 
char * _shr_pbmp_format (_shr_pbmp_t, char *)
 

Macro Definition Documentation

#define _SHR_DEFINE_PBMP_FUNCTIONS

Definition at line 220 of file pbmp.h.

#define _SHR_PBMP_AND (   bma,
  bmb 
)    _SHR_PBMP_BMOP(bma, bmb, &=)

Definition at line 272 of file pbmp.h.

#define _SHR_PBMP_ASSIGN (   dst,
  src 
)    (dst) = (src)

Definition at line 271 of file pbmp.h.

#define _SHR_PBMP_BMCLEAR (   bm)
Value:
do { \
int _w; \
for (_w = 0; _w < _SHR_PBMP_WORD_MAX; _w++) { \
_SHR_PBMP_WORD_GET(bm, _w) = 0; \
} \
} while (0)

Definition at line 228 of file pbmp.h.

#define _SHR_PBMP_BMEQ (   bma,
  bmb 
)    (_shr_pbmp_bmeq(&bma, &bmb))

Definition at line 236 of file pbmp.h.

#define _SHR_PBMP_BMNULL (   bm)    (_shr_pbmp_bmnull(&bm))

Definition at line 235 of file pbmp.h.

#define _SHR_PBMP_BMOP (   bma,
  bmb,
  op 
)
Value:
do { \
int _w; \
for (_w = 0; _w < _SHR_PBMP_WORD_MAX; _w++) { \
_SHR_PBMP_WORD_GET(bma, _w) op _SHR_PBMP_WORD_GET(bmb, _w); \
} \
} while (0)

Definition at line 237 of file pbmp.h.

#define _SHR_PBMP_CLEAR (   bm)    _SHR_PBMP_BMCLEAR(bm)

Definition at line 256 of file pbmp.h.

#define _SHR_PBMP_COUNT (   bm,
  count 
)
Value:
do { \
int _w; \
count = 0; \
for (_w = 0; _w < _SHR_PBMP_WORD_MAX; _w++) { \
count += _shr_popcount(_SHR_PBMP_WORD_GET(bm, _w)); \
} \
} while(0)

Definition at line 244 of file pbmp.h.

#define _SHR_PBMP_ENTRY (   bm,
  port 
)    (_SHR_PBMP_WORD_GET(bm,_SHR_PBMP_WENT(port)))

Definition at line 293 of file pbmp.h.

#define _SHR_PBMP_EQ (   bma,
  bmb 
)    (_SHR_PBMP_BMEQ(bma, bmb))

Definition at line 267 of file pbmp.h.

#define _SHR_PBMP_FIRST (   bm,
  first_port 
)
Value:
do {\
_SHR_PBMP_ITER(bm, first_port) {break;} \
if (first_port == _SHR_PBMP_PORT_MAX) first_port = -1; \
} while(0)

Definition at line 279 of file pbmp.h.

#define _SHR_PBMP_FMT (   bm,
  buf 
)    _shr_pbmp_format(bm, buf)

Definition at line 309 of file pbmp.h.

#define _SHR_PBMP_FMT_LEN   ((_SHR_PBMP_WORD_MAX*8)+3)

Definition at line 310 of file pbmp.h.

#define _SHR_PBMP_IS_NULL (   bm)    (_SHR_PBMP_BMNULL(bm))

Definition at line 265 of file pbmp.h.

#define _SHR_PBMP_ITER (   bm,
  port 
)
Value:
for ((port) = 0; (port) < _SHR_PBMP_PORT_MAX; (port)++) \
if (_SHR_PBMP_MEMBER((bm), (port)))

Definition at line 257 of file pbmp.h.

#define _SHR_PBMP_LAST (   bm,
  last_port 
)
Value:
do {\
_SHR_PBMP_REVERSE_ITER(bm, last_port) {break;} \
} while(0)

Definition at line 286 of file pbmp.h.

#define _SHR_PBMP_MEMBER (   bm,
  port 
)    ((_SHR_PBMP_ENTRY(bm, port) & _SHR_PBMP_WBIT(port)) != 0)

Definition at line 295 of file pbmp.h.

#define _SHR_PBMP_NEGATE (   bma,
  bmb 
)    _SHR_PBMP_BMOP(bma, bmb, = ~)

Definition at line 276 of file pbmp.h.

#define _SHR_PBMP_NEQ (   bma,
  bmb 
)    (!_SHR_PBMP_BMEQ(bma, bmb))

Definition at line 268 of file pbmp.h.

#define _SHR_PBMP_NOT_NULL (   bm)    (!_SHR_PBMP_BMNULL(bm))

Definition at line 266 of file pbmp.h.

#define _SHR_PBMP_OR (   bma,
  bmb 
)    _SHR_PBMP_BMOP(bma, bmb, |=)

Definition at line 273 of file pbmp.h.

#define _SHR_PBMP_PORT_ADD (   bm,
  port 
)    (_SHR_PBMP_ENTRY(bm, port) |= _SHR_PBMP_WBIT(port))

Definition at line 302 of file pbmp.h.

#define _SHR_PBMP_PORT_FLIP (   bm,
  port 
)    (_SHR_PBMP_ENTRY(bm, port) ^= _SHR_PBMP_WBIT(port))

Definition at line 306 of file pbmp.h.

#define _SHR_PBMP_PORT_MAX   256

Definition at line 95 of file pbmp.h.

#define _SHR_PBMP_PORT_REMOVE (   bm,
  port 
)    (_SHR_PBMP_ENTRY(bm, port) &= ~_SHR_PBMP_WBIT(port))

Definition at line 304 of file pbmp.h.

#define _SHR_PBMP_PORT_SET (   bm,
  port 
)
Value:
do { \
_SHR_PBMP_CLEAR(bm); \
_SHR_PBMP_PORT_ADD(bm, port); \
} while(0)

Definition at line 297 of file pbmp.h.

#define _SHR_PBMP_PORT_VALID (   p)    ((p) >= 0 && (p) < _SHR_PBMP_PORT_MAX)

Definition at line 312 of file pbmp.h.

#define _SHR_PBMP_REMOVE (   bma,
  bmb 
)    _SHR_PBMP_BMOP(bma, bmb, &= ~)

Definition at line 275 of file pbmp.h.

#define _SHR_PBMP_REVERSE_ITER (   bm,
  port 
)
Value:
for ((port) = _SHR_PBMP_PORT_MAX - 1; (port) > -1; (port)--) \
if (_SHR_PBMP_MEMBER((bm), (port)))

Definition at line 261 of file pbmp.h.

#define _SHR_PBMP_WBIT (   port)    (1U<<((port) % _SHR_PBMP_WORD_WIDTH))

Definition at line 226 of file pbmp.h.

#define _SHR_PBMP_WENT (   port)    ((port)/_SHR_PBMP_WORD_WIDTH)

Definition at line 225 of file pbmp.h.

#define _SHR_PBMP_WIDTH   (((_SHR_PBMP_PORT_MAX + 32 - 1)/32)*32)

Definition at line 100 of file pbmp.h.

#define _SHR_PBMP_WORD_GET (   bm,
  word 
)    ((bm).pbits[(word)])

Definition at line 115 of file pbmp.h.

#define _SHR_PBMP_WORD_MAX   ((_SHR_PBMP_WIDTH + _SHR_PBMP_WORD_WIDTH-1) / _SHR_PBMP_WORD_WIDTH)

Definition at line 107 of file pbmp.h.

#define _SHR_PBMP_WORD_SET (   bm,
  word,
  val 
)    ((bm).pbits[(word)] = (val))

Definition at line 116 of file pbmp.h.

#define _SHR_PBMP_WORD_WIDTH   32

Definition at line 106 of file pbmp.h.

#define _SHR_PBMP_XOR (   bma,
  bmb 
)    _SHR_PBMP_BMOP(bma, bmb, ^=)

Definition at line 274 of file pbmp.h.

Typedef Documentation

typedef struct _shr_pbmp _shr_pbmp_t

Function Documentation

int _shr_pbmp_bmeq ( _shr_pbmp_t ,
_shr_pbmp_t  
)
int _shr_pbmp_bmnull ( _shr_pbmp_t )
char* _shr_pbmp_format ( _shr_pbmp_t  ,
char *   
)