nx_config_query() subroutine
Purpose
Returns the configuration information about a specific accelerator type.
Syntax
#include <sys/nx.h>
int nx_config_query(nx_accel_type_t accel_type,
uint32_t flags,
void * buf_address,
uint32_t buf_size);
NX_GZIP_TYPE
is the only accelerator type that is supported. You
must specify NX_GZIP_TYPE
in the accel_type parameter.Description
The nx_config_query subroutine copies the configuration data from the requested type of accelerator into the memory buffer that is defined by the buf_address and buf_size variables.
If you want the applications to control the credits information for the various units of the type of accelerator, the nx_config_query subroutine can return the configuration data for each accelerator unit.
struct nx_config_com {
uint32_t ncc_version; /* version number */
uint32_t ncc_res1; /* Reserved - padding */
uint64_t ncc_gencount; /* Generation count */
#ifdef __64BIT__
nx_accel_unit_t *ncc_accel_buf_addr; /* unit info array address */
#else
uint32_t ncc_res2; /* Not used - must be 0 */
nx_accel_unit_t *ncc_accel_buf_addr; /* unit info array address */
#endif
uint32_t ncc_accel_buf_size; /* unit info array size in bytes */
uint32_t ncc_avail_for_use_credits; /* Total number of credits the *
* caller can potentially access *
* to send work to the accel. */
uint32_t ncc_avail_for_res_credits; /* Max number of credits the *
* caller can reserve for *
* exclusive use. *
* (0 for non-privileged callers)*/
uint32_t ncc_total_num_units; /* Total number of accelerator units */
uint32_t ncc_num_units_in_buf; /* # of units described in buffer */
uint32_t ncc_res3[17]; /* Reserved for future extension */
};
For
GZIP accelerator, this structure is embedded into a GZIP-specific data
structure:typedef struct nx_gzip_config {
struct nx_config_com ngc_com; /* Common with other accel types */
#define NX_GZIP_CONFIG_VER0 0x455A0000
#define NX_GZIP_CONFIG_VER NX_GZIP_CONFIG_VER0
uint64_t ngc_max_processed_bytes; /* Max number of bytes processed *
* per request */
uint64_t ngc_comp_rec_min_bytes; /* Compress Recommended Min Bytes */
uint64_t ngc_decomp_rec_min_bytes; /* Decompress Recomm. Min Bytes */
uint64_t ngc_res1[8]; /* Reserved for future extensions */
} nx_gzip_config_t;
The
<sys/nx.h> header file defines the following fields to facilitate access to
the ngc_com
structure that is embedded in the nx_gzip_config
structure:#define ngc_version ngc_com.ncc_version
#define ngc_gencount ngc_com.ncc_gencount
#define ngc_accel_buf_addr ngc_com.ncc_accel_buf_addr
#define ngc_accel_buf_size ngc_com.ncc_accel_buf_size
#define ngc_total_num_units ngc_com.ncc_total_num_units
#define ngc_num_units_in_buf ngc_com.ncc_num_units_in_buf
#define ngc_avail_for_use_credits ngc_com.ncc_avail_for_use_credits
#define ngc_avail_for_res_credits ngc_com.ncc_avail_for_res_credits
The
application thread must initialize the ngc_gencount,
ngc_accel_buf_addr, and ngc_accel_buf_size fields in the
following ways:- The ngc_gencount field must be set to 0 or to the value returned by a previous call to the nx_config_query subroutine.
- The ngc_accel_buf_addr field must be set to NULL or the effective address of a memory buffer.
- The ngc_accel_buf_size field must be set to 0 or the size of the memory buffer that is referenced by the ngc_accel_buf_addr field.
nx_accel_unit_t
structures at the address that is passed to the
ngc_accel_buf_addr field. The nx_accel_unit_t
structure is
listed as
follows:typedef struct nx_accel_unit {
nx_unit_id_t na_id; /* HW accelerator unit ID */
uint32_t na_sradid; /* Accelerator unit's SRAD ID */
uint32_t na_avail_for_use_credits; /* Total number of credits the *
* caller can potentially access *
* to send work to the accel unit */
uint32_t na_avail_for_res_credits; /* Max number of credits the *
* caller can reserve for *
* exclusive use on this unit *
* (0 for non-privileged callers) */
uint32_t na_res1[3]; /* reserved */
} nx_accel_unit_t;
The
ngc_num_units_in_buf field contains the number of elements in the accelerator
unit array. This number can be less than the ngc_total_num_units value if the
ngc_accel_buf_size value is not sufficient for all the data.In any structure, the avail_for_res credit value represents the number of quality of service (QoS) credits that a privileged application can reserve for exclusive use. These values (at the accelerator type and accelerator unit level) are 0 if the calling application is not a privileged application. The avail_for_use credit value represents the number of credits that the calling application can access. If the calling application is a privileged application and contains reserved credits for exclusive use, the avail_for_use credit value is the number of QoS credits in the exclusive pool of the caller application. Otherwise, the avail_for_use credit value is the sum of all the default credits and the balance of the QoS credits in the shared pool that is not reserved for exclusive access.
Return values
- 0
- The configuration of the accelerator has changed and the configuration data is copied to the memory buffer.
- 1
- The configuration of the accelerator has not changed and the configuration data is not copied to the memory buffer.
- -1
- An error is detected. The
errno
variable is set to indicate the type of error:ENOTSUP
: Nest accelerators are not available to the logical partition.EINVAL
: Invalid accelerator type or invalid flags.ENOMEM
: System call cannot allocate kernel memory.EFAULT
: Invalid buffer address (buf_address or ngc_accel_buf_addr values).