X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_rawdev%2Frte_rawdev.h;h=7a1f3213e97d997a0478fbaacf0d9460331e8327;hb=c843fca96c849bd85204707e791accb57adb9e59;hp=76a533e067f3820ca4169c05b41b38c51c88ca34;hpb=c88b3f2558ed09738d29913169bb865531dcb067;p=dpdk.git diff --git a/lib/librte_rawdev/rte_rawdev.h b/lib/librte_rawdev/rte_rawdev.h index 76a533e067..7a1f3213e9 100644 --- a/lib/librte_rawdev/rte_rawdev.h +++ b/lib/librte_rawdev/rte_rawdev.h @@ -12,9 +12,6 @@ * * This API allow applications to configure and use generic devices having * no specific type already available in DPDK. - * - * @warning - * @b EXPERIMENTAL: this API may change without prior notice */ #ifdef __cplusplus @@ -25,7 +22,7 @@ extern "C" { #include #include -/* Rawdevice object - essentially a void to be typecasted by implementation */ +/* Rawdevice object - essentially a void to be typecast by implementation */ typedef void *rte_rawdev_obj_t; /** @@ -35,7 +32,7 @@ typedef void *rte_rawdev_obj_t; * @return * The total number of usable raw devices. */ -uint8_t __rte_experimental +uint8_t rte_rawdev_count(void); /** @@ -48,7 +45,7 @@ rte_rawdev_count(void); * Returns raw device identifier on success. * - <0: Failure to find named raw device. */ -uint16_t __rte_experimental +uint16_t rte_rawdev_get_dev_id(const char *name); /** @@ -61,7 +58,7 @@ rte_rawdev_get_dev_id(const char *name); * a default of zero if the socket could not be determined. * -(-EINVAL) dev_id value is out of range. */ -int __rte_experimental +int rte_rawdev_socket_id(uint16_t dev_id); /** @@ -84,7 +81,7 @@ struct rte_rawdev_info; * - <0: Error code returned by the driver info get function. * */ -int __rte_experimental +int rte_rawdev_info_get(uint16_t dev_id, struct rte_rawdev_info *dev_info); /** @@ -111,7 +108,7 @@ rte_rawdev_info_get(uint16_t dev_id, struct rte_rawdev_info *dev_info); * - 0: Success, device configured. * - <0: Error code returned by the driver configuration function. */ -int __rte_experimental +int rte_rawdev_configure(uint16_t dev_id, struct rte_rawdev_info *dev_conf); @@ -137,7 +134,7 @@ rte_rawdev_configure(uint16_t dev_id, struct rte_rawdev_info *dev_conf); * @see rte_raw_queue_setup() * */ -int __rte_experimental +int rte_rawdev_queue_conf_get(uint16_t dev_id, uint16_t queue_id, rte_rawdev_obj_t queue_conf); @@ -160,7 +157,7 @@ rte_rawdev_queue_conf_get(uint16_t dev_id, * - 0: Success, raw queue correctly set up. * - <0: raw queue configuration failed */ -int __rte_experimental +int rte_rawdev_queue_setup(uint16_t dev_id, uint16_t queue_id, rte_rawdev_obj_t queue_conf); @@ -180,8 +177,9 @@ rte_rawdev_queue_setup(uint16_t dev_id, * - 0: Success, raw queue released. * - <0: raw queue configuration failed */ -int __rte_experimental +int rte_rawdev_queue_release(uint16_t dev_id, uint16_t queue_id); + /** * Get the number of raw queues on a specific raw device * @@ -190,7 +188,7 @@ rte_rawdev_queue_release(uint16_t dev_id, uint16_t queue_id); * @return * - The number of configured raw queues */ -uint16_t __rte_experimental +uint16_t rte_rawdev_queue_count(uint16_t dev_id); /** @@ -208,7 +206,7 @@ rte_rawdev_queue_count(uint16_t dev_id); * - 0: Success, device started. * < 0: Failure */ -int __rte_experimental +int rte_rawdev_start(uint16_t dev_id); /** @@ -218,7 +216,7 @@ rte_rawdev_start(uint16_t dev_id); * @param dev_id * Raw device identifier. */ -void __rte_experimental +void rte_rawdev_stop(uint16_t dev_id); /** @@ -232,7 +230,7 @@ rte_rawdev_stop(uint16_t dev_id); * - <0 on failure to close device * - (-EAGAIN) if device is busy */ -int __rte_experimental +int rte_rawdev_close(uint16_t dev_id); /** @@ -243,10 +241,10 @@ rte_rawdev_close(uint16_t dev_id); * @param dev_id * Raw device identifiers * @return - * 0 for sucessful reset, + * 0 for successful reset, * !0 for failure in resetting */ -int __rte_experimental +int rte_rawdev_reset(uint16_t dev_id); #define RTE_RAWDEV_NAME_MAX_LEN (64) @@ -316,9 +314,292 @@ struct rte_rawdev_buf { * - 0: on success * - <0: on failure. */ -int __rte_experimental +int rte_rawdev_dump(uint16_t dev_id, FILE *f); +/** + * Get an attribute value from implementation. + * Attribute is an opaque handle agreed upon between application and PMD. + * + * Implementations are expected to maintain an array of attribute-value pairs + * based on application calls. Memory management for this structure is + * shared responsibility of implementation and application. + * + * @param dev_id + * The identifier of the device to configure. + * @param attr_name + * Opaque object representing an attribute in implementation. + * @param attr_value [out] + * Opaque response to the attribute value. In case of error, this remains + * untouched. This is double pointer of void type. + * @return + * 0 for success + * !0 Error; attr_value remains untouched in case of error. + */ +int +rte_rawdev_get_attr(uint16_t dev_id, + const char *attr_name, + uint64_t *attr_value); + +/** + * Set an attribute value. + * Attribute is an opaque handle agreed upon between application and PMD. + * + * @param dev_id + * The identifier of the device to configure. + * @param attr_name + * Opaque object representing an attribute in implementation. + * @param attr_value + * Value of the attribute represented by attr_name + * @return + * 0 for success + * !0 Error + */ +int +rte_rawdev_set_attr(uint16_t dev_id, + const char *attr_name, + const uint64_t attr_value); + +/** + * Enqueue a stream of buffers to the device. + * + * Rather than specifying a queue, this API passes along an opaque object + * to the driver implementation. That object can be a queue or any other + * contextual information necessary for the device to enqueue buffers. + * + * @param dev_id + * The identifier of the device to configure. + * @param buffers + * Collection of buffers for enqueuing + * @param count + * Count of buffers to enqueue + * @param context + * Opaque context information. + * @return + * >=0 for buffers enqueued + * !0 for failure. + * Whether partial enqueue is failure or success is defined between app + * and driver implementation. + */ +int +rte_rawdev_enqueue_buffers(uint16_t dev_id, + struct rte_rawdev_buf **buffers, + unsigned int count, + rte_rawdev_obj_t context); + +/** + * Dequeue a stream of buffers from the device. + * + * Rather than specifying a queue, this API passes along an opaque object + * to the driver implementation. That object can be a queue or any other + * contextual information necessary for the device to dequeue buffers. + * + * Application should have allocated enough space to store `count` response + * buffers. + * Releasing buffers dequeued is responsibility of the application. + * + * @param dev_id + * The identifier of the device to configure. + * @param buffers + * Collection of buffers dequeued + * @param count + * Max buffers expected to be dequeued + * @param context + * Opaque context information. + * @return + * >=0 for buffers dequeued + * !0 for failure. + * Whether partial enqueue is failure or success is defined between app + * and driver implementation. + */ +int +rte_rawdev_dequeue_buffers(uint16_t dev_id, + struct rte_rawdev_buf **buffers, + unsigned int count, + rte_rawdev_obj_t context); + +/** Maximum name length for extended statistics counters */ +#define RTE_RAW_DEV_XSTATS_NAME_SIZE 64 + +/** + * A name-key lookup element for extended statistics. + * + * This structure is used to map between names and ID numbers + * for extended ethdev statistics. + */ +struct rte_rawdev_xstats_name { + char name[RTE_RAW_DEV_XSTATS_NAME_SIZE]; +}; + +/** + * Retrieve names of extended statistics of a raw device. + * + * @param dev_id + * The identifier of the raw device. + * @param[out] xstats_names + * Block of memory to insert names into. Must be at least size in capacity. + * If set to NULL, function returns required capacity. + * @param size + * Capacity of xstats_names (number of names). + * @return + * - positive value lower or equal to size: success. The return value + * is the number of entries filled in the stats table. + * - positive value higher than size: error, the given statistics table + * is too small. The return value corresponds to the size that should + * be given to succeed. The entries in the table are not valid and + * shall not be used by the caller. + * - negative value on error: + * -ENODEV for invalid *dev_id* + * -ENOTSUP if the device doesn't support this function. + */ +int +rte_rawdev_xstats_names_get(uint16_t dev_id, + struct rte_rawdev_xstats_name *xstats_names, + unsigned int size); + +/** + * Retrieve extended statistics of a raw device. + * + * @param dev_id + * The identifier of the device. + * @param ids + * The id numbers of the stats to get. The ids can be got from the stat + * position in the stat list from rte_rawdev_get_xstats_names(), or + * by using rte_rawdev_get_xstats_by_name() + * @param[out] values + * The values for each stats request by ID. + * @param n + * The number of stats requested + * @return + * - positive value: number of stat entries filled into the values array + * - negative value on error: + * -ENODEV for invalid *dev_id* + * -ENOTSUP if the device doesn't support this function. + */ +int +rte_rawdev_xstats_get(uint16_t dev_id, + const unsigned int ids[], + uint64_t values[], + unsigned int n); + +/** + * Retrieve the value of a single stat by requesting it by name. + * + * @param dev_id + * The identifier of the device + * @param name + * The stat name to retrieve + * @param[out] id + * If non-NULL, the numerical id of the stat will be returned, so that further + * requests for the stat can be got using rte_rawdev_xstats_get, which will + * be faster as it doesn't need to scan a list of names for the stat. + * If the stat cannot be found, the id returned will be (unsigned)-1. + * @return + * - positive value or zero: the stat value + * - negative value: -EINVAL if stat not found, -ENOTSUP if not supported. + */ +uint64_t +rte_rawdev_xstats_by_name_get(uint16_t dev_id, + const char *name, + unsigned int *id); + +/** + * Reset the values of the xstats of the selected component in the device. + * + * @param dev_id + * The identifier of the device + * @param ids + * Selects specific statistics to be reset. When NULL, all statistics + * will be reset. If non-NULL, must point to array of at least + * *nb_ids* size. + * @param nb_ids + * The number of ids available from the *ids* array. Ignored when ids is NULL. + * @return + * - zero: successfully reset the statistics to zero + * - negative value: -EINVAL invalid parameters, -ENOTSUP if not supported. + */ +int +rte_rawdev_xstats_reset(uint16_t dev_id, + const uint32_t ids[], + uint32_t nb_ids); + +/** + * Get Firmware status of the device.. + * Returns a memory allocated by driver/implementation containing status + * information block. It is responsibility of caller to release the buffer. + * + * @param dev_id + * Raw device identifier + * @param status_info + * Pointer to status information area. Caller is responsible for releasing + * the memory associated. + * @return + * 0 for success, + * !0 for failure, `status_info` argument state is undefined + */ +int +rte_rawdev_firmware_status_get(uint16_t dev_id, + rte_rawdev_obj_t status_info); + +/** + * Get Firmware version of the device. + * Returns a memory allocated by driver/implementation containing version + * information block. It is responsibility of caller to release the buffer. + * + * @param dev_id + * Raw device identifier + * @param version_info + * Pointer to version information area. Caller is responsible for releasing + * the memory associated. + * @return + * 0 for success, + * !0 for failure, `version_info` argument state is undefined + */ +int +rte_rawdev_firmware_version_get(uint16_t dev_id, + rte_rawdev_obj_t version_info); + +/** + * Load firmware on the device. + * TODO: In future, methods like directly flashing from file too can be + * supported. + * + * @param dev_id + * Raw device identifier + * @param firmware_image + * Pointer to buffer containing image binary data + * @return + * 0 for successful load + * !0 for failure to load the provided image, or image incorrect. + */ +int +rte_rawdev_firmware_load(uint16_t dev_id, rte_rawdev_obj_t firmware_image); + +/** + * Unload firmware from the device. + * + * @param dev_id + * Raw device identifiers + * @return + * 0 for successful Unload + * !0 for failure in unloading + */ +int +rte_rawdev_firmware_unload(uint16_t dev_id); + +/** + * Trigger the rawdev self test. + * + * @param dev_id + * The identifier of the device + * @return + * - 0: Selftest successful + * - -ENOTSUP if the device doesn't support selftest + * - other values < 0 on failure. + */ +int +rte_rawdev_selftest(uint16_t dev_id); + #ifdef __cplusplus } #endif