CNDP  22.08.0
ibroker.h File Reference
#include <cne_atomic.h>
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Macros

#define IBROKER_NAME_SIZE   64
 
#define IBROKER_MAX_SERVICES   64
 
#define IBROKER_MAX_COUNT   128
 

Typedefs

typedef int32_t broker_id_t
 
typedef int32_t service_id_t
 
typedef int(* ibroker_walk_t) (broker_id_t bid, void *arg)
 
typedef int(* ibroker_func_t) (int vector, void *arg)
 

Functions

IBROKER_API broker_id_t ibroker_create (const char *name)
 
IBROKER_API void ibroker_destroy (broker_id_t bid)
 
IBROKER_API const char * ibroker_get_name (broker_id_t id)
 
IBROKER_API service_id_t ibroker_add_service (broker_id_t id, const char *service, int vector, ibroker_func_t func, void *arg)
 
IBROKER_API int ibroker_del_service (broker_id_t bid, service_id_t sid)
 
IBROKER_API int ibroker_send (broker_id_t bid, service_id_t sid)
 
IBROKER_API broker_id_t ibroker_find (const char *name)
 
IBROKER_API service_id_t ibroker_find_service (broker_id_t bid, const char *name)
 
IBROKER_API int ibroker_register_sender (broker_id_t bid, service_id_t sid)
 
IBROKER_API int ibroker_service_fd (broker_id_t bid, service_id_t sid)
 
IBROKER_API const char * ibroker_service_name (broker_id_t bid, service_id_t sid)
 
IBROKER_API int ibroker_walk (ibroker_walk_t func, void *arg)
 
IBROKER_API int ibroker_id_list (broker_id_t *ids, int len)
 
IBROKER_API int ibroker_info (broker_id_t bid, ibroker_info_t *info)
 

Detailed Description

CNE UIPI Broker or Interrupt Broker(ibroker)

This library provides a simple interface to use UIPI features. The implementation will abstract as much as possible to give the developer an opportunity to use UIPI features.

Giving the developer an easy to use interface to the UIPI or interrupt based services.

Definition in file ibroker.h.

Macro Definition Documentation

◆ IBROKER_NAME_SIZE

#define IBROKER_NAME_SIZE   64

Max size of the broker instance name or service

Definition at line 29 of file ibroker.h.

◆ IBROKER_MAX_SERVICES

#define IBROKER_MAX_SERVICES   64

Total number of services

Examples
examples/ibroker/main.c, and examples/ibroker/parse-args.c.

Definition at line 30 of file ibroker.h.

◆ IBROKER_MAX_COUNT

#define IBROKER_MAX_COUNT   128

Max number of ibrokers allowed

Examples
examples/ibroker/parse-args.c.

Definition at line 31 of file ibroker.h.

Typedef Documentation

◆ broker_id_t

typedef int32_t broker_id_t

Broker ID

Definition at line 33 of file ibroker.h.

◆ service_id_t

typedef int32_t service_id_t

Service ID

Definition at line 34 of file ibroker.h.

◆ ibroker_walk_t

typedef int(* ibroker_walk_t) (broker_id_t bid, void *arg)

Function prototype for ibroker walk callback

Definition at line 39 of file ibroker.h.

◆ ibroker_func_t

typedef int(* ibroker_func_t) (int vector, void *arg)

Function prototype for service callback.

Definition at line 44 of file ibroker.h.

Function Documentation

◆ ibroker_create()

IBROKER_API broker_id_t ibroker_create ( const char *  name)

Create a broker instance for the given name.

Parameters
nameName of the broker instance.
Returns
-1 if error or broker ID value.
Examples
examples/ibroker/main.c.

◆ ibroker_destroy()

IBROKER_API void ibroker_destroy ( broker_id_t  bid)

Destroy a ibroker instance.

This function uses the per thread ibroker value.

Parameters
bidThe broker ID value to destroy

◆ ibroker_get_name()

IBROKER_API const char* ibroker_get_name ( broker_id_t  id)

Return the ibroker instance name.

Parameters
idThe ibroker id to retrieve the name from, if -1 use current name.
Returns
Pointer to the name or NULL on error.

◆ ibroker_add_service()

IBROKER_API service_id_t ibroker_add_service ( broker_id_t  id,
const char *  service,
int  vector,
ibroker_func_t  func,
void *  arg 
)

Add a service to a broker

Parameters
idThe broker ID value
serviceThe name of the service to add
vectorThe vector number to initialize
funcThe function to callback when the UIPI service is interrupted
argThe function callback argument from the caller.
Returns
service_id_t on success or -1 on error
Examples
examples/ibroker/main.c.

◆ ibroker_del_service()

IBROKER_API int ibroker_del_service ( broker_id_t  bid,
service_id_t  sid 
)

Delete the given service in the broker defined by broker ID

Parameters
bidThe broker ID to use for the delete operation
sidThe service id to delete
Returns
0 on success or -1 on error
Examples
examples/ibroker/main.c.

◆ ibroker_send()

IBROKER_API int ibroker_send ( broker_id_t  bid,
service_id_t  sid 
)

Send a UIPI interrupt to the given broker and vector

Parameters
bidThe broker ID to use for the senduipi() operation
sidThe service ID to send the interrupt
Returns
0 on success or -1 on error
Examples
examples/ibroker/main.c.

◆ ibroker_find()

IBROKER_API broker_id_t ibroker_find ( const char *  name)

Find the ibroker by name.

Parameters
nameThe ibroker name pointer
Returns
-1 if not found or broker ID value

◆ ibroker_find_service()

IBROKER_API service_id_t ibroker_find_service ( broker_id_t  bid,
const char *  name 
)

Find a service in a given broker by name

Parameters
bidThe broker ID to use for the senduipi() operation, if -1 then search all brokers.
nameThe service name to find in the given broker
Returns
-1 on error or the service ID value

◆ ibroker_register_sender()

IBROKER_API int ibroker_register_sender ( broker_id_t  bid,
service_id_t  sid 
)

Register sender with the given broker

Parameters
bidThe broker ID to search
sidThe vector ID value for the service
Returns
0 on success or -1 on error
Examples
examples/ibroker/main.c.

◆ ibroker_service_fd()

IBROKER_API int ibroker_service_fd ( broker_id_t  bid,
service_id_t  sid 
)

Find a service FD in a broker with its service ID value

Parameters
bidThe broker ID value
sidThe server ID value to use for selecting the correct service
Returns
-1 on error or the server uintr_fd value

◆ ibroker_service_name()

IBROKER_API const char* ibroker_service_name ( broker_id_t  bid,
service_id_t  sid 
)

Return the service name given the broker and service ID

Parameters
bidThe broker_id_t value
sidThe service_id_t value
Returns
NULL on error or not found or it returns a pointer the service name
Examples
examples/ibroker/main.c.

◆ ibroker_walk()

IBROKER_API int ibroker_walk ( ibroker_walk_t  func,
void *  arg 
)

Walk the list of ibroker instances and call a function with argument.

Parameters
funcThe ibroker_walk_t function pointer to call
argThe user defined pointer to be passed to the function.
Returns
0 on success or -1 on error
Examples
examples/ibroker/main.c.

◆ ibroker_id_list()

IBROKER_API int ibroker_id_list ( broker_id_t ids,
int  len 
)

Get a list of broker IDs

Parameters
idsArray to place the broker_id_t IDs, if NULL then return the number of brokers
lenThe length of the broker ids array, but be able to hold all broker ids or error is returned.
Returns
-1 on error or the number to broker IDs in the ids array.
Examples
examples/ibroker/main.c.

◆ ibroker_info()

IBROKER_API int ibroker_info ( broker_id_t  bid,
ibroker_info_t *  info 
)

Return information about a broker

Parameters
bidThe broker ID value
infoThe broker_info_t structure pointer.
Returns
0 on success or -1 on error.
Examples
examples/ibroker/main.c.