ONLP
Open Network Linux Platform APIs
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables

Data Structures

struct  onlp_sfp_info_t
 

Macros

#define ONLP_SFP_BLOCK_DATA_SIZE   256
 
#define ONLP_SFP_CONTROL_STRINGS
 
#define ONLP_SFP_CONTROL_VALID(_e)   ( (0 <= (_e)) && ((_e) <= ONLP_SFP_CONTROL_POWER_OVERRIDE))
 
#define ONLP_SFP_CONTROL_FLAG_VALID(_e)   (onlp_sfp_control_flag_valid((_e)))
 
#define ONLP_SFP_TYPE_STRINGS
 
#define ONLP_SFP_TYPE_VALID(_e)   ( (0 <= (_e)) && ((_e) <= ONLP_SFP_TYPE_QSFP28))
 

Typedefs

typedef enum onlp_sfp_control_e onlp_sfp_control_t
 
typedef enum onlp_sfp_control_flag_e onlp_sfp_control_flag_t
 
typedef enum onlp_sfp_type_e onlp_sfp_type_t
 
typedef struct onlp_sfp_info_t onlp_sfp_info_t
 
typedef aim_bitmap256_t onlp_sfp_bitmap_t
 

Enumerations

enum  onlp_sfp_control_e {
  ONLP_SFP_CONTROL_RESET,
  ONLP_SFP_CONTROL_RESET_STATE,
  ONLP_SFP_CONTROL_RX_LOS,
  ONLP_SFP_CONTROL_TX_FAULT,
  ONLP_SFP_CONTROL_TX_DISABLE,
  ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL,
  ONLP_SFP_CONTROL_LP_MODE,
  ONLP_SFP_CONTROL_POWER_OVERRIDE,
  ONLP_SFP_CONTROL_LAST = ONLP_SFP_CONTROL_POWER_OVERRIDE,
  ONLP_SFP_CONTROL_COUNT,
  ONLP_SFP_CONTROL_INVALID = -1
}
 
enum  onlp_sfp_control_flag_e {
  ONLP_SFP_CONTROL_FLAG_RESET = (1 << 0),
  ONLP_SFP_CONTROL_FLAG_RESET_STATE = (1 << 1),
  ONLP_SFP_CONTROL_FLAG_RX_LOS = (1 << 2),
  ONLP_SFP_CONTROL_FLAG_TX_FAULT = (1 << 3),
  ONLP_SFP_CONTROL_FLAG_TX_DISABLE = (1 << 4),
  ONLP_SFP_CONTROL_FLAG_TX_DISABLE_CHANNEL = (1 << 5),
  ONLP_SFP_CONTROL_FLAG_LP_MODE = (1 << 6),
  ONLP_SFP_CONTROL_FLAG_POWER_OVERRIDE = (1 << 7)
}
 
enum  onlp_sfp_type_e {
  ONLP_SFP_TYPE_SFP,
  ONLP_SFP_TYPE_QSFP,
  ONLP_SFP_TYPE_SFP28,
  ONLP_SFP_TYPE_QSFP28,
  ONLP_SFP_TYPE_LAST = ONLP_SFP_TYPE_QSFP28,
  ONLP_SFP_TYPE_COUNT,
  ONLP_SFP_TYPE_INVALID = -1
}
 

Functions

int onlp_sfp_sw_init (void)
 Software initialization of the SFP module.
 
int onlp_sfp_hw_init (uint32_t flags)
 Hardware initialization of the SFP module. More...
 
int onlp_sfp_sw_denit (void)
 Deinitialize the sfp software module. More...
 
void onlp_sfp_bitmap_t_init (onlp_sfp_bitmap_t *bmap)
 
int onlp_sfp_bitmap_get (onlp_sfp_bitmap_t *bmap)
 Get the set of valid SFP ports. More...
 
int onlp_sfp_info_get (onlp_oid_t port, onlp_sfp_info_t *info)
 Get the SFP information structure. More...
 
int onlp_sfp_info_dom_get (onlp_oid_t port, onlp_sfp_info_t *info)
 Get the SFP information structure (including DOM) More...
 
int onlp_sfp_hdr_get (onlp_oid_t port, onlp_oid_hdr_t *rv)
 Get the SFP's oid header. More...
 
int onlp_sfp_port_valid (onlp_oid_t port)
 Determine if a given port number is a valid SFP port. More...
 
int onlp_sfp_type_get (onlp_oid_t port, onlp_sfp_type_t *rtype)
 Determine the SFP Connector type. More...
 
int onlp_sfp_is_present (onlp_oid_t port)
 Determine if an SFP is currently plugged in. More...
 
int onlp_sfp_presence_bitmap_get (onlp_sfp_bitmap_t *dst)
 Return the presence bitmap for all ports. More...
 
int onlp_sfp_rx_los_bitmap_get (onlp_sfp_bitmap_t *dst)
 Get the RX_LOS bitmap for all ports. More...
 
int onlp_sfp_dev_read (onlp_oid_t port, int devaddr, int addr, uint8_t *dst, int count)
 Read bytes from the target device on the given SFP port. More...
 
int onlp_sfp_dev_alloc_read (onlp_oid_t port, int devaddr, int addr, int count, uint8_t **rv)
 Read bytes from the target device on the given SFP port. More...
 
int onlp_sfp_dev_write (onlp_oid_t port, int devaddr, int addr, uint8_t *src, int count)
 Write bytes to the target device on the given SFP port. More...
 
int onlp_sfp_dev_readb (onlp_oid_t port, int devaddr, int addr)
 Read a byte from the target device on the given SFP port. More...
 
int onlp_sfp_dev_writeb (onlp_oid_t port, int devaddr, int addr, uint8_t value)
 Write a byte to the target device on the given SFP port. More...
 
int onlp_sfp_dev_readw (onlp_oid_t port, int devaddr, int addr)
 Read a word from the target device on the given SFP port. More...
 
int onlp_sfp_dev_writew (onlp_oid_t port, int devaddr, int addr, uint16_t value)
 Write a word to the target device on the given SFP port. More...
 
int onlp_sfp_post_insert (onlp_oid_t port, sff_info_t *info)
 Perform any actions required after an SFP is inserted. More...
 
int onlp_sfp_control_set (onlp_oid_t port, onlp_sfp_control_t control, int value)
 Set an SFP control. More...
 
int onlp_sfp_control_get (onlp_oid_t port, onlp_sfp_control_t control, int *value)
 Get an SFP control. More...
 
int onlp_sfp_control_flags_get (onlp_oid_t port, uint32_t *flags)
 Get the value of all SFP controls. More...
 
int onlp_sfp_info_to_user_json (onlp_sfp_info_t *info, cJSON **rv, uint32_t flags)
 Convert an SFP info structure to user JSON. More...
 
int onlp_sfp_info_to_json (onlp_sfp_info_t *info, cJSON **rv, uint32_t flags)
 Convert an SFP info structure to JSON. More...
 
int onlp_sfp_info_from_json (cJSON *cj, onlp_sfp_info_t *info)
 Convert a JSON object to an SFP info structure. More...
 
int onlp_sfp_hw_denit (void)
 Hardware deinitialize the SFP subsystem.
 
int onlp_sfp_inventory_show (aim_pvs_t *pvs)
 Show the current SFP inventory.
 
const char * onlp_sfp_control_name (onlp_sfp_control_t e)
 
int onlp_sfp_control_value (const char *str, onlp_sfp_control_t *e, int substr)
 
const char * onlp_sfp_control_desc (onlp_sfp_control_t e)
 
const char * onlp_sfp_control_flag_name (onlp_sfp_control_flag_t e)
 
int onlp_sfp_control_flag_value (const char *str, onlp_sfp_control_flag_t *e, int substr)
 
const char * onlp_sfp_control_flag_desc (onlp_sfp_control_flag_t e)
 
int onlp_sfp_control_flag_valid (onlp_sfp_control_flag_t e)
 
const char * onlp_sfp_type_name (onlp_sfp_type_t e)
 
int onlp_sfp_type_value (const char *str, onlp_sfp_type_t *e, int substr)
 
const char * onlp_sfp_type_desc (onlp_sfp_type_t e)
 

Variables

aim_map_si_t onlp_sfp_control_map []
 
aim_map_si_t onlp_sfp_control_desc_map []
 
aim_map_si_t onlp_sfp_control_flag_map []
 
aim_map_si_t onlp_sfp_control_flag_desc_map []
 
aim_map_si_t onlp_sfp_type_map []
 
aim_map_si_t onlp_sfp_type_desc_map []
 

Detailed Description

Macro Definition Documentation

◆ ONLP_SFP_BLOCK_DATA_SIZE

#define ONLP_SFP_BLOCK_DATA_SIZE   256

SFP Block Data Size

◆ ONLP_SFP_CONTROL_FLAG_VALID

#define ONLP_SFP_CONTROL_FLAG_VALID (   _e)    (onlp_sfp_control_flag_valid((_e)))

validator

◆ ONLP_SFP_CONTROL_STRINGS

#define ONLP_SFP_CONTROL_STRINGS
Value:
{\
"RESET", \
"RESET_STATE", \
"RX_LOS", \
"TX_FAULT", \
"TX_DISABLE", \
"TX_DISABLE_CHANNEL", \
"LP_MODE", \
"POWER_OVERRIDE", \
}

Strings macro.

◆ ONLP_SFP_CONTROL_VALID

#define ONLP_SFP_CONTROL_VALID (   _e)    ( (0 <= (_e)) && ((_e) <= ONLP_SFP_CONTROL_POWER_OVERRIDE))

validator

◆ ONLP_SFP_TYPE_STRINGS

#define ONLP_SFP_TYPE_STRINGS
Value:
{\
"SFP", \
"QSFP", \
"SFP28", \
"QSFP28", \
}

Strings macro.

◆ ONLP_SFP_TYPE_VALID

#define ONLP_SFP_TYPE_VALID (   _e)    ( (0 <= (_e)) && ((_e) <= ONLP_SFP_TYPE_QSFP28))

validator

Typedef Documentation

◆ onlp_sfp_bitmap_t

typedef aim_bitmap256_t onlp_sfp_bitmap_t

Valid SFP Port bitmaps are communicated using this type.

◆ onlp_sfp_control_flag_t

onlp_sfp_control_flag

◆ onlp_sfp_control_t

onlp_sfp_control

◆ onlp_sfp_info_t

SFP Information Structure.

◆ onlp_sfp_type_t

onlp_sfp_type

Enumeration Type Documentation

◆ onlp_sfp_control_e

onlp_sfp_control

41  {
42  ONLP_SFP_CONTROL_RESET,
43  ONLP_SFP_CONTROL_RESET_STATE,
44  ONLP_SFP_CONTROL_RX_LOS,
45  ONLP_SFP_CONTROL_TX_FAULT,
46  ONLP_SFP_CONTROL_TX_DISABLE,
47  ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL,
48  ONLP_SFP_CONTROL_LP_MODE,
49  ONLP_SFP_CONTROL_POWER_OVERRIDE,
50  ONLP_SFP_CONTROL_LAST = ONLP_SFP_CONTROL_POWER_OVERRIDE,
51  ONLP_SFP_CONTROL_COUNT,
52  ONLP_SFP_CONTROL_INVALID = -1,
enum onlp_sfp_control_e onlp_sfp_control_t

◆ onlp_sfp_control_flag_e

onlp_sfp_control_flag

58  {
59  ONLP_SFP_CONTROL_FLAG_RESET = (1 << 0),
60  ONLP_SFP_CONTROL_FLAG_RESET_STATE = (1 << 1),
61  ONLP_SFP_CONTROL_FLAG_RX_LOS = (1 << 2),
62  ONLP_SFP_CONTROL_FLAG_TX_FAULT = (1 << 3),
63  ONLP_SFP_CONTROL_FLAG_TX_DISABLE = (1 << 4),
64  ONLP_SFP_CONTROL_FLAG_TX_DISABLE_CHANNEL = (1 << 5),
65  ONLP_SFP_CONTROL_FLAG_LP_MODE = (1 << 6),
66  ONLP_SFP_CONTROL_FLAG_POWER_OVERRIDE = (1 << 7),
enum onlp_sfp_control_flag_e onlp_sfp_control_flag_t

◆ onlp_sfp_type_e

onlp_sfp_type

70  {
71  ONLP_SFP_TYPE_SFP,
72  ONLP_SFP_TYPE_QSFP,
73  ONLP_SFP_TYPE_SFP28,
74  ONLP_SFP_TYPE_QSFP28,
75  ONLP_SFP_TYPE_LAST = ONLP_SFP_TYPE_QSFP28,
76  ONLP_SFP_TYPE_COUNT,
77  ONLP_SFP_TYPE_INVALID = -1,
enum onlp_sfp_type_e onlp_sfp_type_t

Function Documentation

◆ onlp_sfp_bitmap_get()

int onlp_sfp_bitmap_get ( onlp_sfp_bitmap_t bmap)

Get the set of valid SFP ports.

Parameters
bmapReturns the valid set of SFP-capable port numbers.

◆ onlp_sfp_bitmap_t_init()

void onlp_sfp_bitmap_t_init ( onlp_sfp_bitmap_t bmap)

Convenience function for initializing SFP bitmaps.

Parameters
bmapThe address of the bitmap to initialize.

◆ onlp_sfp_control_desc()

const char* onlp_sfp_control_desc ( onlp_sfp_control_t  e)

Enum descriptions.

◆ onlp_sfp_control_flag_desc()

const char* onlp_sfp_control_flag_desc ( onlp_sfp_control_flag_t  e)

Enum descriptions.

◆ onlp_sfp_control_flag_name()

const char* onlp_sfp_control_flag_name ( onlp_sfp_control_flag_t  e)

Enum names.

◆ onlp_sfp_control_flag_valid()

int onlp_sfp_control_flag_valid ( onlp_sfp_control_flag_t  e)

Enum validator.

◆ onlp_sfp_control_flag_value()

int onlp_sfp_control_flag_value ( const char *  str,
onlp_sfp_control_flag_t e,
int  substr 
)

Enum values.

◆ onlp_sfp_control_flags_get()

int onlp_sfp_control_flags_get ( onlp_oid_t  port,
uint32_t *  flags 
)

Get the value of all SFP controls.

Parameters
portThe port.
flagsReceives the control flag values. See onlp_sfp_control_flags_t

◆ onlp_sfp_control_get()

int onlp_sfp_control_get ( onlp_oid_t  port,
onlp_sfp_control_t  control,
int *  value 
)

Get an SFP control.

Parameters
portThe SFP Port ID.
controlThe control
[out]valueReceives the current value.

◆ onlp_sfp_control_name()

const char* onlp_sfp_control_name ( onlp_sfp_control_t  e)

Enum names.

◆ onlp_sfp_control_set()

int onlp_sfp_control_set ( onlp_oid_t  port,
onlp_sfp_control_t  control,
int  value 
)

Set an SFP control.

Parameters
portThe SFP Port ID.
controlThe control.
valueThe value.

◆ onlp_sfp_control_value()

int onlp_sfp_control_value ( const char *  str,
onlp_sfp_control_t e,
int  substr 
)

Enum values.

◆ onlp_sfp_dev_alloc_read()

int onlp_sfp_dev_alloc_read ( onlp_oid_t  port,
int  devaddr,
int  addr,
int  count,
uint8_t **  rv 
)

Read bytes from the target device on the given SFP port.

Parameters
portThe SFP OID or Port ID.
devaddrThe device address.
addrThe start target address.
countThe number of bytes to read.
[out]rvReceives the allocated buffer.
Note
The returned buffer must be freed after use.

◆ onlp_sfp_dev_read()

int onlp_sfp_dev_read ( onlp_oid_t  port,
int  devaddr,
int  addr,
uint8_t *  dst,
int  count 
)

Read bytes from the target device on the given SFP port.

Parameters
portThe SFP OID or Port ID.
devaddrThe device address.
addrThe address to read.
dstReceives the data.
countThe read length.
Returns
The number of bytes read or ONLP_STATUS_E_* no error.

◆ onlp_sfp_dev_readb()

int onlp_sfp_dev_readb ( onlp_oid_t  port,
int  devaddr,
int  addr 
)

Read a byte from the target device on the given SFP port.

Parameters
portThe SFP Port ID.
devaddrThe device address.
addrThe read address.
Returns
The byte on success or ONLP_STATUS_E* on error.

◆ onlp_sfp_dev_readw()

int onlp_sfp_dev_readw ( onlp_oid_t  port,
int  devaddr,
int  addr 
)

Read a word from the target device on the given SFP port.

Parameters
portThe SFP Port ID.
devaddrThe device address.
addrThe read address.
Returns
The word if successful, ONLP_STATUS_E* on error.

◆ onlp_sfp_dev_write()

int onlp_sfp_dev_write ( onlp_oid_t  port,
int  devaddr,
int  addr,
uint8_t *  src,
int  count 
)

Write bytes to the target device on the given SFP port.

Parameters
portThe SFP OID or Port ID.
devaddrThe device address.
addrThe address to write.
srcThe source data.
countThe write length.

◆ onlp_sfp_dev_writeb()

int onlp_sfp_dev_writeb ( onlp_oid_t  port,
int  devaddr,
int  addr,
uint8_t  value 
)

Write a byte to the target device on the given SFP port.

Parameters
portThe SFP Port ID.
devaddrThe device address.
addrThe write address.
valueThe write value.

◆ onlp_sfp_dev_writew()

int onlp_sfp_dev_writew ( onlp_oid_t  port,
int  devaddr,
int  addr,
uint16_t  value 
)

Write a word to the target device on the given SFP port.

Parameters
portThe SFP Port ID.
devaddrThe device address.
addrThe write address.
valueThe write value.

◆ onlp_sfp_hdr_get()

int onlp_sfp_hdr_get ( onlp_oid_t  port,
onlp_oid_hdr_t rv 
)

Get the SFP's oid header.

Parameters
portThe SFP OID.
[out]rvReceives the header.

◆ onlp_sfp_hw_init()

int onlp_sfp_hw_init ( uint32_t  flags)

Hardware initialization of the SFP module.

Parameters
flagsThe hardware initialization flags.

◆ onlp_sfp_info_dom_get()

int onlp_sfp_info_dom_get ( onlp_oid_t  port,
onlp_sfp_info_t info 
)

Get the SFP information structure (including DOM)

Parameters
portThe SFP OID or Port ID.
[out]infoReceives the information structure.

◆ onlp_sfp_info_from_json()

int onlp_sfp_info_from_json ( cJSON *  cj,
onlp_sfp_info_t info 
)

Convert a JSON object to an SFP info structure.

Parameters
cjThe JSON object.
[out]infoReceives the SFP info structure.

◆ onlp_sfp_info_get()

int onlp_sfp_info_get ( onlp_oid_t  port,
onlp_sfp_info_t info 
)

Get the SFP information structure.

Parameters
portThe SFP OID or Port ID.
[out]infoReceives the information structure.

◆ onlp_sfp_info_to_json()

int onlp_sfp_info_to_json ( onlp_sfp_info_t info,
cJSON **  rv,
uint32_t  flags 
)

Convert an SFP info structure to JSON.

Parameters
infoThe SFP info structure.
[out]rvReceives the JSON object.
flagsThe JSON format flags.

◆ onlp_sfp_info_to_user_json()

int onlp_sfp_info_to_user_json ( onlp_sfp_info_t info,
cJSON **  rv,
uint32_t  flags 
)

Convert an SFP info structure to user JSON.

Parameters
infoThe SFP info structure.
[out]rvReceives the JSON object.
flagsThe JSON format flags.

◆ onlp_sfp_is_present()

int onlp_sfp_is_present ( onlp_oid_t  port)

Determine if an SFP is currently plugged in.

Parameters
portThe SFP port number.
Returns
1 if an SFP is present.
0 if an SFP is not present.
<0 on error.

◆ onlp_sfp_port_valid()

int onlp_sfp_port_valid ( onlp_oid_t  port)

Determine if a given port number is a valid SFP port.

Parameters
portThe port number.

◆ onlp_sfp_post_insert()

int onlp_sfp_post_insert ( onlp_oid_t  port,
sff_info_t *  info 
)

Perform any actions required after an SFP is inserted.

Parameters
portThe SFP Port ID.
infoThe SFF Module information structure.
Note
This function is optional. If your platform must adjust equalizer or preemphasis settings internally then this function should be implemented as the trigger.

◆ onlp_sfp_presence_bitmap_get()

int onlp_sfp_presence_bitmap_get ( onlp_sfp_bitmap_t dst)

Return the presence bitmap for all ports.

Parameters
dstThe receives the presence bitmap for all ports.
Note
This function can return Unsupported. It will not be emulated if the SFPI driver does not support batch collection of the SFP presence.

◆ onlp_sfp_rx_los_bitmap_get()

int onlp_sfp_rx_los_bitmap_get ( onlp_sfp_bitmap_t dst)

Get the RX_LOS bitmap for all ports.

Parameters
dstReceives the RX_LOS bitmap for all ports.
Note
This function can return Unsupported. It will not be emulated if the SFPI driver does not support batch collection of the rx_los status.

◆ onlp_sfp_sw_denit()

int onlp_sfp_sw_denit ( void  )

Deinitialize the sfp software module.

Software deinitialize the SFP subsystem.

Note
The primary purpose of this API is to properly deallocate any resources used by the module in order faciliate detection of real resouce leaks.

◆ onlp_sfp_type_desc()

const char* onlp_sfp_type_desc ( onlp_sfp_type_t  e)

Enum descriptions.

◆ onlp_sfp_type_get()

int onlp_sfp_type_get ( onlp_oid_t  port,
onlp_sfp_type_t rtype 
)

Determine the SFP Connector type.

Parameters
portThe port number.
[out]rtypeReceives the type.

◆ onlp_sfp_type_name()

const char* onlp_sfp_type_name ( onlp_sfp_type_t  e)

Enum names.

◆ onlp_sfp_type_value()

int onlp_sfp_type_value ( const char *  str,
onlp_sfp_type_t e,
int  substr 
)

Enum values.

Variable Documentation

◆ onlp_sfp_control_desc_map

aim_map_si_t onlp_sfp_control_desc_map[]

onlp_sfp_control_desc_map table.

◆ onlp_sfp_control_flag_desc_map

aim_map_si_t onlp_sfp_control_flag_desc_map[]

onlp_sfp_control_flag_desc_map table.

◆ onlp_sfp_control_flag_map

aim_map_si_t onlp_sfp_control_flag_map[]

onlp_sfp_control_flag_map table.

◆ onlp_sfp_control_map

aim_map_si_t onlp_sfp_control_map[]

onlp_sfp_control_map table.

◆ onlp_sfp_type_desc_map

aim_map_si_t onlp_sfp_type_desc_map[]

onlp_sfp_type_desc_map table.

◆ onlp_sfp_type_map

aim_map_si_t onlp_sfp_type_map[]

onlp_sfp_type_map table.