![]() |
CAM API Documentation
|
A cam_arg handle is passed to bcam_create(), vbcam_create(), stcam_create() or tcam_create(). cam_arg contains all the configuration parameters. First cam_arg_create() is called to allocate memory for the cam_arg. cam_arg_create() returns the cam_arg_handle(). The handle is used for all the set and force functions, which sets the parameters. Once all parameters are set, one of bcam_create(), vbcam_create, stcam_create() or tcam_create() is called. The cam_arg is copied by these functions, so cam_arg_destroy() can be called immediately after. VBCAMs and BCAMs support optional arguments. These arguments contains additional control information. These options can be set using the cam_options_set_** functions.
Macros | |
| #define | CAM_DEBUG_NONE |
| #define | CAM_OPTIMIZE_NONE |
Functions | |
| int | cam_arg_create (cam_arg_t **out_cam_arg) |
| void | cam_arg_init (cam_arg_t *out_cam_arg) |
| size_t | cam_arg_size (void) |
| void | cam_arg_destroy (cam_arg_t *cam_arg) |
| int | cam_arg_set_format (cam_arg_t *cam_arg, char *format) |
| void | cam_arg_set_inst_ctx (cam_arg_t *cam_arg, void *inst_ctx) |
| void | cam_arg_set_hw_write_function (cam_arg_t *cam_arg, void(*hw_write_function)(void *, uint32_t, uint32_t)) |
| void | cam_arg_set_hw_read_function (cam_arg_t *cam_arg, void(*hw_read_function)(void *, uint32_t, uint32_t *)) |
| int | cam_arg_set_hw_io (cam_arg_t *cam_arg, unsigned hw_block, void(*hw_write_function)(void *, uint32_t, uint32_t), void(*hw_read_function)(void *, uint32_t, uint32_t *)) |
| void | cam_arg_set_num_entries (cam_arg_t *cam_arg, uint32_t num_entries) |
| void | cam_arg_set_engine_lookup_rate (struct cam_arg_t *cam_arg, float lookup_rate) |
| void | cam_arg_set_lookup_interface_freq (struct cam_arg_t *cam_arg, float freq) |
| void | cam_arg_set_ram_freq (struct cam_arg_t *cam_arg, float freq) |
| void | cam_arg_set_response_width (struct cam_arg_t *cam_arg, uint16_t response_width) |
| void | cam_arg_force_prio_width (struct cam_arg_t *cam_arg, uint8_t prio_width) |
| void | cam_arg_set_key_width (struct cam_arg_t *cam_arg, uint16_t key_width) |
| void | cam_arg_set_fingerprint_width (struct cam_arg_t *cam_arg, uint16_t fingerprint_width) |
| void | cam_arg_set_num_masks (struct cam_arg_t *cam_arg, uint8_t num_masks) |
| void | cam_arg_force_num_units (struct cam_arg_t *cam_arg, uint16_t num_units) |
| void | cam_arg_force_mem_type (struct cam_arg_t *cam_arg, bool uram) |
| void | cam_arg_set_max_num_brams (struct cam_arg_t *cam_arg, uint16_t max_num_brams) |
| void | cam_arg_set_max_num_urams (struct cam_arg_t *cam_arg, uint16_t max_num_urams) |
| void | cam_arg_set_max_macro_height (struct cam_arg_t *cam_arg, uint8_t max_macro_height) |
| void | cam_arg_set_device_arch (struct cam_arg_t *cam_arg, bool versal) |
| void | cam_arg_force_hbm (struct cam_arg_t *cam_arg) |
| void | cam_arg_set_narrow_key_width (struct cam_arg_t *cam_arg, uint16_t narrow_key_width) |
| void | cam_arg_set_max_hw_writes (struct cam_arg_t *cam_arg, uint16_t max_hw_writes) |
| void | cam_arg_set_flow_control (struct cam_arg_t *cam_arg, bool flow_control) |
| void | cam_arg_set_aging (struct cam_arg_t *cam_arg, bool aging) |
| void | cam_arg_set_default_response (struct cam_arg_t *cam_arg, const uint8_t *default_response) |
| void | cam_arg_set_narrow_default_response (struct cam_arg_t *cam_arg, const uint8_t *narrow_default_response) |
| void | cam_arg_set_vcid (struct cam_arg_t *cam_arg, uint8_t vcid) |
| void | cam_arg_set_seg (struct cam_arg_t *cam_arg, uint16_t segment_id) |
| void | cam_arg_set_hw_write_sequence_functions (cam_arg_t *cam_arg, void(*start_function)(void *), void(*end_function)(void *)) |
| void | cam_arg_set_debug_flags (cam_arg_t *cam_arg, uint32_t debug_flags) |
| void | cam_arg_set_optimization_flags (cam_arg_t *cam_arg, uint32_t optimization_flags) |
| void | cam_arg_enable_options (cam_arg_t *cam_arg) |
| void | cam_arg_force_asic_ram (struct cam_arg_t *cam_arg) |
| void | cam_arg_force_dram (struct cam_arg_t *cam_arg) |
| void | cam_arg_set_ram_size (struct cam_arg_t *cam_arg, uint32_t size) |
| void | cam_arg_set_hash_function (struct cam_arg_t *cam_arg, uint8_t function) |
| void | cam_arg_set_siphash_key (struct cam_arg_t *cam_arg, uint64_t k0, uint64_t k1) |
| void | cam_arg_set_num_banks (struct cam_arg_t *cam_arg, uint8_t num_banks) |
| void | cam_arg_set_channel_width (struct cam_arg_t *cam_arg, uint16_t width) |
| void | cam_arg_set_generation_number_granularity (struct cam_arg_t *cam_arg, uint16_t granularity) |
| void | cam_arg_calc_heap_size (struct cam_arg_t *cam_arg, bool calculate) |
| void | cam_arg_set_error_print_function (struct cam_arg_t *cam_arg, void(*error_print_function)(void *, char *)) |
| void | cam_arg_set_info_print_function (struct cam_arg_t *cam_arg, void(*info_print_function)(void *, char *)) |
| void | cam_arg_set_malloc_function (struct cam_arg_t *cam_arg, void *(*malloc_function)(size_t size)) |
| void | cam_arg_set_posix_memalign_function (struct cam_arg_t *cam_arg, int(*posix_memalign_function)(void **ptr, size_t align_size, size_t num)) |
| void | cam_arg_set_realloc_function (struct cam_arg_t *cam_arg, void *(*realloc_function)(void *ptr, size_t size)) |
| void | cam_arg_set_calloc_function (struct cam_arg_t *cam_arg, void *(*calloc_function)(size_t num, size_t size)) |
| void | cam_arg_set_free_function (struct cam_arg_t *cam_arg, void(*free_function)(void *ptr)) |
| const char * | cam_error_string (int error_code) |
| void | cam_print_error (int error_code) |
| int | cam_options_create (cam_options_t **out_cam_options) |
| size_t | cam_options_size (void) |
| void | cam_options_init (cam_options_t *out_options) |
| void | cam_options_destroy (cam_options_t *cam_options) |
| void | cam_options_set_narrow_key (struct cam_options_t *cam_options, bool narrow) |
| void | cam_options_set_precomputed_hash_value (struct cam_options_t *cam_options, uint8_t hash_value[32]) |
| void | cam_options_clear_precomputed_hash_value (struct cam_options_t *cam_options) |
| void | cam_options_set_single_segment_search (struct cam_options_t *options, uint8_t segment) |
| void | cam_options_clear_single_segment_search (struct cam_options_t *options) |
| void | cam_options_set_debug_flags (struct cam_options_t *options, uint32_t debug_flags) |
| void | cam_options_clear_debug_flags (struct cam_options_t *options) |
| #define CAM_DEBUG_NONE |
Debug flags to enable debug printouts and hardware verification.
| #define CAM_OPTIMIZE_NONE |
Optimization flags
| enum cam_errnos |
Error numbers.
These are the return codes from the bcam, tcam and stcam API functions. If zero is returned, the function call was successful.
Similar CCAM_ERROR_* constants are used by the hardware managed CAMs; they are identically numbered.
| int cam_arg_create | ( | cam_arg_t ** | out_cam_arg | ) |
Creates cam_arg which is used to pass arguments during the creation of a vbcam, bcam, tcam or stcam instance. If the function is successful, 0 is returned. If the function fails an error code is returned. The function uses malloc to allocate memory. The malloc can not be replaced by the function specified by cam_arg_set_malloc_function. If malloc must be replaced use cam_arg_size and cam_arg_init instead of cam_arg_create.
| [out] | out_cam_arg | The newly created cam_arg. If successful memory was allocated. If unsuccessful, no memory was allocated and out_cam_arg is left unchanged. |
| void cam_arg_init | ( | cam_arg_t * | out_cam_arg | ) |
This function should only be used if cam_arg_create should be replaced. This would be the case if the standard malloc used by cam_arg_create needs to be replaced. The function sets the same default values to cam_arg as cam_arg_create. out_cam_arg is allocated outside of the function.
| [out] | out_cam_arg | Pointer to cam_arg |
| size_t cam_arg_size | ( | void | ) |
This function should only be used if cam_arg_create should be replaced.
| void cam_arg_destroy | ( | cam_arg_t * | cam_arg | ) |
Destroy cam_arg. The memory allocated by cam_arg_create is released. The stdlib free function is used. The free function is not replaced by the function specified by the cam_arg_set_free_function.
| [in] | cam_arg | Pointer to cam_arg. |
| int cam_arg_set_format | ( | cam_arg_t * | cam_arg, |
| char * | format | ||
| ) |
The function is only used for tcam. This function shall not be called for bcam or stcam. The format string is used to specify the location and size of range fields, since ternary matching hardware is replaced by range matching hardware for these fields. Furthermore the format string is used to determine key width and to guide the tcam API software. The key width can not be more than 991 bits. In addition, 2 x key width + response width + priority width + 1 can not exceed 1472/1984 (BRAM/URAM) bits. Sets the format string of cam_arg. If the cam_arg_set_format is unsuccessful, the format is not set. The default format of cam_arg is "/0".
| [in] | cam_arg | Pointer to cam_arg |
| [in] | format | String describing the format of all entries of a tcam instance. An entry consists of several fields. Fields are separated by ':'. The string is read left to right. The first field will correspond to the least significant bits of the key. The key is specified as little-endian. Each field is specified as: <field len> <field type>. The following field types and lengths are supported. There are no alignment restrictions for the fields.
|
For example, the format "16r:16r:64p:64p:48b:48b" contains 2 x 16 bit range fields for port numbers, 2 x 64 bit prefix fields for IPv6 addresses and 2 x 48 bit fields for MAC addresses. The 16r field is located in the 16 least significant bits of the key
| void cam_arg_set_inst_ctx | ( | cam_arg_t * | cam_arg, |
| void * | inst_ctx | ||
| ) |
Sets the instance context pointer of cam_arg. The context is user-defined and will always be passed when the following functions are invoked: hw write, hw read, hw_write_sequence_start, hw_write_sequence_end, info print and error print. An example of usage of context could be for addressing multiple cam instances. Each instance would be given a unique base address using cam_arg_set_inst_ctx. The hw read/write functions would then add the base address from the context before accessing the hardware.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | inst_ctx | Pointer to the instance context. |
| void cam_arg_set_hw_write_function | ( | cam_arg_t * | cam_arg, |
| void(*)(void *, uint32_t, uint32_t) | hw_write_function | ||
| ) |
Sets the hardware write function of cam_arg. The hw write function will be called by the cam instance to write to the HW
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | hw_write_function | Pointer to the hw write function. This function is provided by the user |
| void cam_arg_set_hw_read_function | ( | cam_arg_t * | cam_arg, |
| void(*)(void *, uint32_t, uint32_t *) | hw_read_function | ||
| ) |
Sets the hardware read function of cam_arg. The hw read function will be called by the cam instance to read from the HW
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | hw_read_function | Pointer to the hw read function. This function is provided by the user |
| int cam_arg_set_hw_io | ( | cam_arg_t * | cam_arg, |
| unsigned | hw_block, | ||
| void(*)(void *, uint32_t, uint32_t) | hw_write_function, | ||
| void(*)(void *, uint32_t, uint32_t *) | hw_read_function | ||
| ) |
Sets a pair of hardware read/write functions. This variant is used by drivers which communicate with multiple hardware blocks. Calling this function with hw_block == 0 is equivalent to calling cam_arg_set_hw_write_function() and cam_arg_set_hw_read_function().
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | hw_block | Index of the hardware block (refer to driver documentation). |
| [in] | hw_write_function | Pointer to the hw write function. |
| [in] | hw_read_function | Pointer to the hw read function. This function is provided by the user |
CAM_ERROR_INVALID_ARG if the value of 'hw_block' is out of range.
| void cam_arg_set_num_entries | ( | cam_arg_t * | cam_arg, |
| uint32_t | num_entries | ||
| ) |
Sets the supported number of entries to cam_arg. This is the number of entries the cam instance supports.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | num_entries | The number of supported entries the instance can store before it becomes full |
| void cam_arg_set_engine_lookup_rate | ( | struct cam_arg_t * | cam_arg, |
| float | lookup_rate | ||
| ) |
Sets the lookup rate of the instance to cam_arg. This is the supported lookup rate of the instance. In order to save resources it is important not to set the lookup rate higher than required.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | lookup_rate | The lookup rate of the instance expressed in Mlookups/s |
| void cam_arg_set_lookup_interface_freq | ( | struct cam_arg_t * | cam_arg, |
| float | freq | ||
| ) |
This function should not be used for dram. Sets the frequency of the lookup interface to cam_arg. This is the clock frequency of the lookup request and response interfaces. The frequency of the lookup interface must be at least as high as the lookup rate. Sometimes a higher frequency is used, for example: Lookup interface frequency == Lookup rate (A lookup can be issued every clock cycle) Lookup interface frequency == 2 * Lookup rate (A lookup can be issued every second cycle)
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | freq | The frequency of the instance expressed in MHz |
| void cam_arg_set_ram_freq | ( | struct cam_arg_t * | cam_arg, |
| float | freq | ||
| ) |
This function should not be used for dram. Sets the RAM clock frequency of the instance to cam_arg.
The RAM clock defines the clock frequency of the memories and the internal data path. A high RAM clock frequency enables time division of the hardware resources, leading to significant savings. The amount of time division possible is calculated as: RAM clock frequency / lookup rate, rounded downwards to the nearest power of two.
Example: Lookup rate = 150, Lookup interface frequency = 330 RAM frequency = 600 -> Time division = 600 / 150 = 4
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | freq | The RAM clock frequency expressed in MHz. |
| void cam_arg_set_response_width | ( | struct cam_arg_t * | cam_arg, |
| uint16_t | response_width | ||
| ) |
Sets the response width of the instance to cam_arg. This is the supported width of response.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | response_width | The response width expressed in number of bits (1-1024). The following limitations apply: For vbcam/bcam, key width + response width + 1 cannot exceed 1024/1536/2048 (dram/bram/uram) bits. For cbcam, key width + response width + 1 cannot exceed 1536/1024 (bram/uram) bits. For stcam, key width + response width + priority width + 1 cannot exceed 1536/2048 (bram/uram) bits. For tcam, 2*key width + response width + priority width + 1 cannot exceed 1472/1984 (bram/uram) bits. |
| void cam_arg_force_prio_width | ( | struct cam_arg_t * | cam_arg, |
| uint8_t | prio_width | ||
| ) |
Forces a narrower priority width of the instance to cam_arg. This function is not applicable for vbcam/bcam instances. The default value is a priority width corresponding to the number of entries for tcam and the number of masks for stcam. In some scenarios a narrower priority width is sufficient.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | prio_width | The prio width is expressed in number of bits (0-32). The priority is used to determine the winning match when multiple matches occurs. To represent the priority value a certain priority width is required. The following limitations apply: For stcam, key width + response width + priority width + 1 cannot exceed 1536/2048 (bram/uram) bits. For tcam, 2*key width + response width + priority width + 1 cannot exceed 1472/1984 (bram/uram) bits. |
| void cam_arg_set_key_width | ( | struct cam_arg_t * | cam_arg, |
| uint16_t | key_width | ||
| ) |
This function is only used for vbcam, bcam and stcam. For tcam the format string should be used instead.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | key_width | The key width expressed in number of bits (10-992). The following limitations apply: For bcam/vbcam, key width + response width + 1 cannot exceed 1024/1536/2048 (dram/bram/uram) bits. For cbcam, key width + response width + 1 cannot exceed 1536/1024 (bram/uram) bits. For stcam, key width + response width + priority width + 1 cannot exceed 1536/2048 (bram/uram) bits. |
| void cam_arg_set_fingerprint_width | ( | struct cam_arg_t * | cam_arg, |
| uint16_t | fingerprint_width | ||
| ) |
Set fingerprint width (DRAM BCAM only). Defaults to zero (fingerprints disabled).
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | fingerprint_width | The fingerprint width expressed in number of bits (0-16). |
| void cam_arg_set_num_masks | ( | struct cam_arg_t * | cam_arg, |
| uint8_t | num_masks | ||
| ) |
This function is only used for stcam. An stcam is dimensioned to support a specific number of unique masks and a specific number of entries. The dimensioning is based on a worst case scenario. The stcam memory management algorithm allocates memory dynamically for each unique mask. All entries can use the same mask or entries can use different masks. The memory dimensioning guarantees that the specified number of masks and the specified number of entries will fit in the memory simultaneously.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | num_masks | The number of unique masks. |
| void cam_arg_force_num_units | ( | struct cam_arg_t * | cam_arg, |
| uint16_t | num_units | ||
| ) |
This function is not used for dram. Overrides the automatic memory dimensioning. A cam consists of a number of memory units. The automatic memory dimensioning calculates the number of required memory units to store all entries and masks. This function is used to override the automatic dimensioning and forces the number of memory units to a specified value. This function can be used for optimization in certain cases when the automatic dimensioning provides too much headroom.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | num_units | The number of memory units (1-256). |
| void cam_arg_force_mem_type | ( | struct cam_arg_t * | cam_arg, |
| bool | uram | ||
| ) |
This function is not used for dram. Forces the instance to use either URAM or BRAM. Based on the cam_arg parameters an optimal solution in terms of hardware resources is calculated. This solution is an instance using either BRAM or URAM. In some scenarios the usage of a certain memory type might be constrained and then the solution can be forced to use a certain memory type even though it is not the optimal solution.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | uram | If true uram is forced to be used. If false bram is forced to be used. |
| void cam_arg_set_max_num_brams | ( | struct cam_arg_t * | cam_arg, |
| uint16_t | max_num_brams | ||
| ) |
Set the maximum number of BRAMs available in the chosen target device.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | max_num_brams | Maximum number of BRAMs in the device. |
| void cam_arg_set_max_num_urams | ( | struct cam_arg_t * | cam_arg, |
| uint16_t | max_num_urams | ||
| ) |
Set the maximum number of URAMs available in the chosen target device.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | max_num_urams | Maximum number of URAMs in the device. |
| void cam_arg_set_max_macro_height | ( | struct cam_arg_t * | cam_arg, |
| uint8_t | max_macro_height | ||
| ) |
Set the maximum height of placement macro (RAM column), measured in clock regions. The maximum RAM column height varies depending on the chosen target devices. This parameter provides control over RAM column height versus number of required RAM columns.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | max_macro_height | Maximum height of placement macro (1-device limit), measured in clock regions. |
| void cam_arg_set_device_arch | ( | struct cam_arg_t * | cam_arg, |
| bool | versal | ||
| ) |
Set the target device architecure.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | versal | Target Versal if true. Target UltraScale if false. |
| void cam_arg_force_hbm | ( | struct cam_arg_t * | cam_arg | ) |
This function is only used for a vbcam/bcam using HBM. If this function is called, the bcam uses HBM instead of URAM/BRAM or DDR-DRAM. Both DDR-DRAM and HBM can not be forced.
| [in] | cam_arg | Pointer to cam_arg. |
| void cam_arg_set_narrow_key_width | ( | struct cam_arg_t * | cam_arg, |
| uint16_t | narrow_key_width | ||
| ) |
This function can only be used for a vbcam/bcam using dram. This function activates mixed mode. In mixed mode, wide and narrow entries are efficiently stored together in the same memory. The wide entry is 1024 or 512 bits wide. The narrow entry is half the width of the wide entry. key_width + response_width + 2 is rounded upwards to 512 or 1024 bits for the wide entry. narrow_key_width + response_width + 2 is rounded upwards to 256 or 512 bits for the narrow entry. Both these conditions must be fulfilled: 1: key_width >= narrow_key_width and 2: narrow entry width = wide entry width / 2 . This function sets the key width of the narrow entry. The key width of the wide entry is specified using cam_arg_set_key_width.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | narrow_key_width | The key width for the narrow entry |
| void cam_arg_set_max_hw_writes | ( | struct cam_arg_t * | cam_arg, |
| uint16_t | max_hw_writes | ||
| ) |
This function can only be used for vbcam/bcam. Sets the maximum number of allowed hw writes for the bcam_insert/vbcam_insert function. A hw write occurs every time the hw write function is called. Sometimes the transport method between the driver and the hw requires that all writes are stored in a packet of limited size. This function can be used to limit the number of hw writes so they fit in a single packet. Limiting the number of allowed HW writes may cause the cam to become full earlier than expected. When the cam becomes full due to the hw writes limit, it might still be possible to insert another entry successfully. If this function is called, the number of hw writes is limited. If this function is not called or called with max_hw_writes = 0, no such hw write limitation exists.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | max_hw_writes | Maximum number of allowed hw writes |
| void cam_arg_set_flow_control | ( | struct cam_arg_t * | cam_arg, |
| bool | flow_control | ||
| ) |
Sets the lookup response flow control configuration.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | flow_control | False = Response flow control off (fixed lookup rate & latency) True = Response flow control on (variable lookup rate & latency) |
| void cam_arg_set_aging | ( | struct cam_arg_t * | cam_arg, |
| bool | aging | ||
| ) |
Sets the aging configuration (only used for cbcam and cstcam).
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | aging | False = Aging disabled (entries can only be removed by deleting them) True = Aging enabled (old entries are invalidated or overwritten) |
| void cam_arg_set_default_response | ( | struct cam_arg_t * | cam_arg, |
| const uint8_t * | default_response | ||
| ) |
Sets the default response. When a key is looked up in the data plane and there is no match, the default response is output together with a no match indication. If the default response is not set all bits are cleared as default. The width of the default response is specified by the cam_arg_set_response_width function. cam_arg_set_response_width must be called prior to this function otherwise the number of bits t copy from the input argument is unknown and zero bytes will be copied.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | default_response | The default response |
| void cam_arg_set_narrow_default_response | ( | struct cam_arg_t * | cam_arg, |
| const uint8_t * | narrow_default_response | ||
| ) |
This function is only used if mixed mode is activated, see cam_arg_set_narrow_key_width. This function sets the narrow default response. When a narrow key is looked up in the data plane and there is a no match, the narrow default response is output together with a no match indication. If the narrow default response is not set, that is if this function is not called, all bits are cleared as default. The width of the narrow default response is specified by the cam_arg_set_response_width function. cam_arg_set_response_width must be called prior to this function otherwise the number of bits to copy from the input argument is unknown and zero bytes will be copied.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | narrow_default_response | The narrow default response |
| void cam_arg_set_vcid | ( | struct cam_arg_t * | cam_arg, |
| uint8_t | vcid | ||
| ) |
This function can only be used for a vbcam. Sets a uniquie identifer (vcid) for each virtualised bcam (vbcam)
| [in] | cam_arg | Pointer to cam_arg |
| [in] | vcid | The unique identifier of the vbcam |
| void cam_arg_set_seg | ( | struct cam_arg_t * | cam_arg, |
| uint16_t | segment_id | ||
| ) |
This function can only be used for a vbcam. Each vbcam uses one or multiple address segments. This function should be called multiple times if many segments should be used for the vbcam. A segment can only be used by one vbcam at a time otherwise the behavior is undefined. This needs to be enforced by the user.
| [in] | cam_arg | Pointer to cam_arg |
| [in] | segment_id | segment num (0-255) allocated to the vbcam |
| void cam_arg_set_hw_write_sequence_functions | ( | cam_arg_t * | cam_arg, |
| void(*)(void *) | start_function, | ||
| void(*)(void *) | end_function | ||
| ) |
This function is only applicable for vbcam. Sets the start and end functions for the hw write sequence. The hw registers use indirect addressing since the hw bus is narrow. For this reason, key and response updates require a sequence of multiple hw writes to finish. If the cam is used by multiple threads as would be the typical use case for vbcams, the write sequence must be protected from being interrupted by another thread's write sequence. The start_function and end_function arguments are called when the sequence is started and ended. These functions can for instance be used to lock and unlock a mutex common for all threads. The argument to the start_function and end_function is the context as specified by the cam_arg_set_inst_ctx.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | start_function | Pointer to the start function. This function is provided by the user |
| [in] | end_function | Pointer to the end function. This function is provided by the user |
| void cam_arg_set_debug_flags | ( | cam_arg_t * | cam_arg, |
| uint32_t | debug_flags | ||
| ) |
Sets the debug flags of cam_arg. The debug flags control how much information is displayed for information, warning and error purposes.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | debug_flags | Bit mask value, every bit corresponds to a class of debug messages. |
| void cam_arg_set_optimization_flags | ( | cam_arg_t * | cam_arg, |
| uint32_t | optimization_flags | ||
| ) |
Sets the optimization flags of cam_arg. The optimization flags specifies how the hardware is optimized. E.g. optimized to reduce either logic or memory
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | optimization_flags | Bit mask value. |
| void cam_arg_enable_options | ( | cam_arg_t * | cam_arg | ) |
Enable options for bcam. This function is only applicable for bcam. The bcam functions are variadic C functions. If options is enabled, the bcam expects one additional argument containing the options
| [in] | cam_arg | Pointer to cam_arg. |
| void cam_arg_force_asic_ram | ( | struct cam_arg_t * | cam_arg | ) |
This function is only used for stcam/bcam using asic ram. The size of the asic ram is set by cam_arg_set_ram_size
| [in] | cam_arg | Pointer to cam_arg. |
| void cam_arg_force_dram | ( | struct cam_arg_t * | cam_arg | ) |
This function is only used for a vbcam/bcam using DDR-DRAM. If this function is called, the bcam uses DDR-DRAM instead of URAM/BRAM. Both DDR-DRAM and HBM can not be forced.
| [in] | cam_arg | Pointer to cam_arg. |
| void cam_arg_set_ram_size | ( | struct cam_arg_t * | cam_arg, |
| uint32_t | size | ||
| ) |
This function is used to specify the size of the ddr-dram in KB or the size of the asic ram in number of addresses per ram.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | size | Memory size. The unit is different depending on if it is ddr-dram or asic ram. E.g. size = 1024 = 1MB of dram for ddr-dram. size = 512 corresponds to 512 addresses per ram for asic ram. In both cases the size must be a power of 2. |
| void cam_arg_set_hash_function | ( | struct cam_arg_t * | cam_arg, |
| uint8_t | function | ||
| ) |
This function is only used for dram bcam. The default hash function is Murmur3. The hash function can be changed by using this function.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | function | The hash function |
| void cam_arg_set_siphash_key | ( | struct cam_arg_t * | cam_arg, |
| uint64_t | k0, | ||
| uint64_t | k1 | ||
| ) |
Set the SipHash key. Using a secret value for this key offers some protection against hash flooding attacks.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | k0 | Least significant 64 bits of key. |
| [in] | k1 | Most significant 64 bits of key. |
| void cam_arg_set_num_banks | ( | struct cam_arg_t * | cam_arg, |
| uint8_t | num_banks | ||
| ) |
Only valid for ddr-dram BCAMs. This function is used to specify the number of banks the bcam uses. Default is 8 banks
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | num_banks | Only 8 and 4 are allowed |
| void cam_arg_set_channel_width | ( | struct cam_arg_t * | cam_arg, |
| uint16_t | width | ||
| ) |
Only valid for ddr-dram BCAMs. This function is used to specify the amount of data (in bits) that are transferred on the dram channel using a single read/write access. The value is the product of the burst length and physical data width. Default is 512 bits.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | width | Only 256 and 512 are allowed. |
| void cam_arg_set_generation_number_granularity | ( | struct cam_arg_t * | cam_arg, |
| uint16_t | granularity | ||
| ) |
This function is only used for dram-bcam. The DRAM controller can not support atomicity for wider data than its transaction size. This function creates atomicity with generation numbers per transaction size or narrower.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | granularity | default is 0. Supported values 0 and 256 |
| void cam_arg_calc_heap_size | ( | struct cam_arg_t * | cam_arg, |
| bool | calculate | ||
| ) |
This function is used to let the create function calculate the heap size before allocating it. Instead of creating the driver, the create function calculates the maximum heap size it will use during its lifetime. When a CAM driver is created, all heap allocations are performed by the create function except for the TCAM which performs allocations in other functions as well. For the TCAM, the returned heap size also includes heap size which will be allocated in other functions. The create function returns an error code or the calculated heap size. If it is an error code or the heap size that is returned is determined by comparing with CAM_ERROR_FATAL_BASE_END. If the return code has a greater value, it is the heap size that is returned. The returned heap size is in Bytes.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | calculate | default is false |
| void cam_arg_set_error_print_function | ( | struct cam_arg_t * | cam_arg, |
| void(*)(void *, char *) | error_print_function | ||
| ) |
Sets the error print function of cam_arg. The error print function will be called by the cam instance to print error messages. The default error print function is printing to stderr.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | error_print_function | Pointer to the error print function. This function is provided by the user |
| void cam_arg_set_info_print_function | ( | struct cam_arg_t * | cam_arg, |
| void(*)(void *, char *) | info_print_function | ||
| ) |
Sets the info print function of cam_arg. The info print function will be called by the cam instance to print informational messages. The default info print function is printing to stdout.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | info_print_function | Pointer to the info print function. This function is provided by the user |
| void cam_arg_set_malloc_function | ( | struct cam_arg_t * | cam_arg, |
| void *(*)(size_t size) | malloc_function | ||
| ) |
Sets the malloc function of cam_arg. The malloc function will be called by the cam instance to allocate memory on the heap of size bytes. It returns a pointer to this memory. The default malloc is stdlib malloc
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | malloc_function | Pointer to the malloc function. This function is provided by the user |
| void cam_arg_set_posix_memalign_function | ( | struct cam_arg_t * | cam_arg, |
| int(*)(void **ptr, size_t align_size, size_t num) | posix_memalign_function | ||
| ) |
Sets the posix_memalign function of cam_arg. The posix_memalaign function will be called by the cam instance to allocate memory on the heap of size bytes aligned to 64 Bytes which corresponds to a cache line. This might improve the performance of the shadow memory. It returns a result code. If the posix_memalign function is not set, the calloc function will be used instead.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | posix_memalign_function | Pointer to the posix_memalign function. This function is provided by the user |
| void cam_arg_set_realloc_function | ( | struct cam_arg_t * | cam_arg, |
| void *(*)(void *ptr, size_t size) | realloc_function | ||
| ) |
Sets the realloc function of cam_arg. The realloc function will be called by the cam instance to re-allocate memory on the heap of size bytes. It returns a pointer to this memory. The default realloc is stdlib realloc. Realloc is only used by tcam instances
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | realloc_function | Pointer to the realloc function. This function is provided by the user |
| void cam_arg_set_calloc_function | ( | struct cam_arg_t * | cam_arg, |
| void *(*)(size_t num, size_t size) | calloc_function | ||
| ) |
Sets the calloc function of cam_arg. The calloc function will be called by the cam instance to allocate memory for an array of num elements of size bytes each and returns a pointer to the allocated memory on the heap. The memory is also set to zero and a pointer to this memory is returned. The default calloc is stdlib calloc
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | calloc_function | Pointer to the calloc function. This function is provided by the user |
| void cam_arg_set_free_function | ( | struct cam_arg_t * | cam_arg, |
| void(*)(void *ptr) | free_function | ||
| ) |
Sets the free function of cam_arg. This will be called by the cam instance to free up heap memory that was allocated by the malloc and calloc functions. The default free is stdlib free.
| [in] | cam_arg | Pointer to cam_arg. |
| [in] | free_function | Pointer to the free function. This function is provided by the user |
| const char* cam_error_string | ( | int | error_code | ) |
This function is only for debug purposes and returns the error code as a string.
| [in] | error_code | error code to print. The error code is returned from the API functions |
| void cam_print_error | ( | int | error_code | ) |
This function is only for debug purposes and prints the error code on stderr.
| [in] | error_code | error code to print. The error code is returned from the API functions |
| int cam_options_create | ( | cam_options_t ** | out_cam_options | ) |
Creates cam_options which is used to pass additional arguments to insert, delete, update etc. If the function was successful, 0 is returned. If the function fails an error code is returned. The function uses malloc to allocate memory. The malloc can not be replaced by the function specified by cam_arg_set_malloc_function. If malloc must be replaced use cam_options_size and cam_options_init instead of cam_options_create. Options can only be used for dram bcam/vbcam
| [out] | out_cam_options | The newly created cam_options. If successful memory was allocated. If unsuccessful, no memory was allocated and out_cam_options is left unchanged. |
| size_t cam_options_size | ( | void | ) |
Gets the byte size of cam_options_t. This is useful if it it is preferred to allocate memory for cam_options_t using something else than the malloc used inside cam_options_create. E.g. alloca. cam_options_create can be replaced by using cam_options_size, alloca/malloc and cam _options_init. Options can only be used for dram bcam/vbcam
| void cam_options_init | ( | cam_options_t * | out_options | ) |
Initializes options by setting default values. This function is used together with cam_options_size. out_options is allocated outside of the function. Options can only be used for dram bcam/vbcam
| [out] | out_options | A pointer to options is passed. The function will modify the content pointed to by the pointer. The content is set to the same default values as if cam_options_create would have been used. |
| void cam_options_destroy | ( | cam_options_t * | cam_options | ) |
Destroy cam_options. The memory allocated by cam_options_create is released. The stdlib free function is used. The free function is not replaced by the function specified by the cam_arg_set_free_function. Options can only be used for dram bcam/vbcam
| [in] | cam_options | Pointer to cam_options. |
| void cam_options_set_narrow_key | ( | struct cam_options_t * | cam_options, |
| bool | narrow | ||
| ) |
This function sets if it is a wide or narrow key. The key is either wide or narrow. Default is wide. Options can only be used for dram bcam/vbcam
| [in] | cam_options | Pointer to cam_options. |
| [in] | narrow | If true, the key is narrow. If false, the key is wide. |
| void cam_options_set_precomputed_hash_value | ( | struct cam_options_t * | cam_options, |
| uint8_t | hash_value[32] | ||
| ) |
This function sets the pre-computed hash value. When a pre-computed hash-value is passed, a new computation of the hash value is not made thus saving processor cycles.Default is not to use pre-computed hash values. If a key is passed with a non-matching hash value, the behavior is undefined. This function is meant to be used for dram bcams in order to serialize access to segments.
| [in] | cam_options | Pointer to cam_options. |
| [in] | hash_value | A 256 bit wide hash value. Little-endian is used. |
| void cam_options_clear_precomputed_hash_value | ( | struct cam_options_t * | cam_options | ) |
This function clears pre-computed hash value. A pre-computed hash-value is not used and a new computation of the hash value will take place.
| [in] | cam_options | Pointer to cam_options. |
| void cam_options_set_single_segment_search | ( | struct cam_options_t * | options, |
| uint8_t | segment | ||
| ) |
This function is only used for dram vbcams' and provides an option to vbcam_get_by_response. The function specifies a single segment to be searched, instead of searching all segments which is the default behavior. The option provides flexibility in how mutex locking can be performed in a multi-threaded environment. Searching only one segment at a time allows for sequentially locking and releasing segments one at a time instead of locking all segments of the dram vbcam upfront.
| [in] | options | Pointer to cam_options. |
| [in] | segment | The single segment to be searched |
| void cam_options_clear_single_segment_search | ( | struct cam_options_t * | options | ) |
This function clears searching a single segment. The default behavior is restored. That is, vbcam_get_by_response searches all segments.
| [in] | options | Pointer to cam_options. |
| void cam_options_set_debug_flags | ( | struct cam_options_t * | options, |
| uint32_t | debug_flags | ||
| ) |
The debug flags can be sent as an option. The debug flags passed in the options argument overrides the default debug flags which were passed in cam_arg when the cam instance was created. The debug flags passed as an option argument are only valid for the specific function call. When the function returns, the debug flags are restored to the default debug flags. By default passing debug flags in the options argument is disabled/cleared. Options can only be used for dram bcam/vbcam
| [in] | options | Pointer to cam_options. |
| [in] | debug_flags | The debug flags. |
| void cam_options_clear_debug_flags | ( | struct cam_options_t * | options | ) |
Disables the use of the debug flags in the options argument.
| [in] | options | Pointer to cam_options. |