1d30ea906Sjfb8856606 /* SPDX-License-Identifier: BSD-3-Clause 2d30ea906Sjfb8856606 * Copyright 2017 NXP 3d30ea906Sjfb8856606 */ 4d30ea906Sjfb8856606 5d30ea906Sjfb8856606 #ifndef _RTE_RAWDEV_H_ 6d30ea906Sjfb8856606 #define _RTE_RAWDEV_H_ 7d30ea906Sjfb8856606 8d30ea906Sjfb8856606 /** 9d30ea906Sjfb8856606 * @file rte_rawdev.h 10d30ea906Sjfb8856606 * 11d30ea906Sjfb8856606 * Generic device abstraction APIs. 12d30ea906Sjfb8856606 * 13d30ea906Sjfb8856606 * This API allow applications to configure and use generic devices having 14d30ea906Sjfb8856606 * no specific type already available in DPDK. 15d30ea906Sjfb8856606 */ 16d30ea906Sjfb8856606 17d30ea906Sjfb8856606 #ifdef __cplusplus 18d30ea906Sjfb8856606 extern "C" { 19d30ea906Sjfb8856606 #endif 20d30ea906Sjfb8856606 21d30ea906Sjfb8856606 #include <rte_common.h> 22d30ea906Sjfb8856606 #include <rte_memory.h> 23d30ea906Sjfb8856606 #include <rte_errno.h> 24d30ea906Sjfb8856606 251646932aSjfb8856606 /* Rawdevice object - essentially a void to be typecast by implementation */ 26d30ea906Sjfb8856606 typedef void *rte_rawdev_obj_t; 27d30ea906Sjfb8856606 28d30ea906Sjfb8856606 /** 29d30ea906Sjfb8856606 * Get the total number of raw devices that have been successfully 30d30ea906Sjfb8856606 * initialised. 31d30ea906Sjfb8856606 * 32d30ea906Sjfb8856606 * @return 33d30ea906Sjfb8856606 * The total number of usable raw devices. 34d30ea906Sjfb8856606 */ 35d30ea906Sjfb8856606 uint8_t 36d30ea906Sjfb8856606 rte_rawdev_count(void); 37d30ea906Sjfb8856606 38d30ea906Sjfb8856606 /** 39d30ea906Sjfb8856606 * Get the device identifier for the named raw device. 40d30ea906Sjfb8856606 * 41d30ea906Sjfb8856606 * @param name 42d30ea906Sjfb8856606 * Raw device name to select the raw device identifier. 43d30ea906Sjfb8856606 * 44d30ea906Sjfb8856606 * @return 45d30ea906Sjfb8856606 * Returns raw device identifier on success. 46d30ea906Sjfb8856606 * - <0: Failure to find named raw device. 47d30ea906Sjfb8856606 */ 48d30ea906Sjfb8856606 uint16_t 49d30ea906Sjfb8856606 rte_rawdev_get_dev_id(const char *name); 50d30ea906Sjfb8856606 51d30ea906Sjfb8856606 /** 52d30ea906Sjfb8856606 * Return the NUMA socket to which a device is connected. 53d30ea906Sjfb8856606 * 54d30ea906Sjfb8856606 * @param dev_id 55d30ea906Sjfb8856606 * The identifier of the device. 56d30ea906Sjfb8856606 * @return 57d30ea906Sjfb8856606 * The NUMA socket id to which the device is connected or 58d30ea906Sjfb8856606 * a default of zero if the socket could not be determined. 59d30ea906Sjfb8856606 * -(-EINVAL) dev_id value is out of range. 60d30ea906Sjfb8856606 */ 61d30ea906Sjfb8856606 int 62d30ea906Sjfb8856606 rte_rawdev_socket_id(uint16_t dev_id); 63d30ea906Sjfb8856606 64d30ea906Sjfb8856606 /** 65d30ea906Sjfb8856606 * Raw device information forward declaration 66d30ea906Sjfb8856606 */ 67d30ea906Sjfb8856606 struct rte_rawdev_info; 68d30ea906Sjfb8856606 69d30ea906Sjfb8856606 /** 70d30ea906Sjfb8856606 * Retrieve the contextual information of a raw device. 71d30ea906Sjfb8856606 * 72d30ea906Sjfb8856606 * @param dev_id 73d30ea906Sjfb8856606 * The identifier of the device. 74d30ea906Sjfb8856606 * 75d30ea906Sjfb8856606 * @param[out] dev_info 76d30ea906Sjfb8856606 * A pointer to a structure of type *rte_rawdev_info* to be filled with the 770c6bd470Sfengbojiang * contextual information of the device. The dev_info->dev_private field 780c6bd470Sfengbojiang * should point to an appropriate buffer space for holding the device- 790c6bd470Sfengbojiang * specific info for that hardware. 800c6bd470Sfengbojiang * If the dev_private field is set to NULL, then the device-specific info 810c6bd470Sfengbojiang * function will not be called and only basic information about the device 820c6bd470Sfengbojiang * will be returned. This can be used to safely query the type of a rawdev 830c6bd470Sfengbojiang * instance without needing to know the size of the private data to return. 84d30ea906Sjfb8856606 * 85*2d9fd380Sjfb8856606 * @param dev_private_size 86*2d9fd380Sjfb8856606 * The length of the memory space pointed to by dev_private in dev_info. 87*2d9fd380Sjfb8856606 * This should be set to the size of the expected private structure to be 88*2d9fd380Sjfb8856606 * returned, and may be checked by drivers to ensure the expected struct 89*2d9fd380Sjfb8856606 * type is provided. 90*2d9fd380Sjfb8856606 * 91d30ea906Sjfb8856606 * @return 92d30ea906Sjfb8856606 * - 0: Success, driver updates the contextual information of the raw device 93d30ea906Sjfb8856606 * - <0: Error code returned by the driver info get function. 94d30ea906Sjfb8856606 * 95d30ea906Sjfb8856606 */ 96d30ea906Sjfb8856606 int 97*2d9fd380Sjfb8856606 rte_rawdev_info_get(uint16_t dev_id, struct rte_rawdev_info *dev_info, 98*2d9fd380Sjfb8856606 size_t dev_private_size); 99d30ea906Sjfb8856606 100d30ea906Sjfb8856606 /** 101d30ea906Sjfb8856606 * Configure a raw device. 102d30ea906Sjfb8856606 * 103d30ea906Sjfb8856606 * This function must be invoked first before any other function in the 104d30ea906Sjfb8856606 * API. This function can also be re-invoked when a device is in the 105d30ea906Sjfb8856606 * stopped state. 106d30ea906Sjfb8856606 * 107d30ea906Sjfb8856606 * The caller may use rte_rawdev_info_get() to get the capability of each 108d30ea906Sjfb8856606 * resources available for this raw device. 109d30ea906Sjfb8856606 * 110d30ea906Sjfb8856606 * @param dev_id 111d30ea906Sjfb8856606 * The identifier of the device to configure. 112d30ea906Sjfb8856606 * @param dev_conf 113d30ea906Sjfb8856606 * The raw device configuration structure encapsulated into rte_rawdev_info 114d30ea906Sjfb8856606 * object. 115d30ea906Sjfb8856606 * It is assumed that the opaque object has enough information which the 116d30ea906Sjfb8856606 * driver/implementation can use to configure the device. It is also assumed 117d30ea906Sjfb8856606 * that once the configuration is done, a `queue_id` type field can be used 118d30ea906Sjfb8856606 * to refer to some arbitrary internal representation of a queue. 119*2d9fd380Sjfb8856606 * @param dev_private_size 120*2d9fd380Sjfb8856606 * The length of the memory space pointed to by dev_private in dev_info. 121*2d9fd380Sjfb8856606 * This should be set to the size of the expected private structure to be 122*2d9fd380Sjfb8856606 * used by the driver, and may be checked by drivers to ensure the expected 123*2d9fd380Sjfb8856606 * struct type is provided. 124d30ea906Sjfb8856606 * 125d30ea906Sjfb8856606 * @return 126d30ea906Sjfb8856606 * - 0: Success, device configured. 127d30ea906Sjfb8856606 * - <0: Error code returned by the driver configuration function. 128d30ea906Sjfb8856606 */ 129d30ea906Sjfb8856606 int 130*2d9fd380Sjfb8856606 rte_rawdev_configure(uint16_t dev_id, struct rte_rawdev_info *dev_conf, 131*2d9fd380Sjfb8856606 size_t dev_private_size); 132d30ea906Sjfb8856606 133d30ea906Sjfb8856606 134d30ea906Sjfb8856606 /** 135d30ea906Sjfb8856606 * Retrieve the current configuration information of a raw queue designated 136d30ea906Sjfb8856606 * by its *queue_id* from the raw driver for a raw device. 137d30ea906Sjfb8856606 * 138d30ea906Sjfb8856606 * This function intended to be used in conjunction with rte_raw_queue_setup() 139d30ea906Sjfb8856606 * where caller needs to set up the queue by overriding few default values. 140d30ea906Sjfb8856606 * 141d30ea906Sjfb8856606 * @param dev_id 142d30ea906Sjfb8856606 * The identifier of the device. 143d30ea906Sjfb8856606 * @param queue_id 144d30ea906Sjfb8856606 * The index of the raw queue to get the configuration information. 145d30ea906Sjfb8856606 * The value must be in the range [0, nb_raw_queues - 1] 146d30ea906Sjfb8856606 * previously supplied to rte_rawdev_configure(). 147d30ea906Sjfb8856606 * @param[out] queue_conf 148d30ea906Sjfb8856606 * The pointer to the default raw queue configuration data. 149*2d9fd380Sjfb8856606 * @param queue_conf_size 150*2d9fd380Sjfb8856606 * The size of the structure pointed to by queue_conf 151d30ea906Sjfb8856606 * @return 152d30ea906Sjfb8856606 * - 0: Success, driver updates the default raw queue configuration data. 153d30ea906Sjfb8856606 * - <0: Error code returned by the driver info get function. 154d30ea906Sjfb8856606 * 155d30ea906Sjfb8856606 * @see rte_raw_queue_setup() 156d30ea906Sjfb8856606 * 157d30ea906Sjfb8856606 */ 158d30ea906Sjfb8856606 int 159d30ea906Sjfb8856606 rte_rawdev_queue_conf_get(uint16_t dev_id, 160d30ea906Sjfb8856606 uint16_t queue_id, 161*2d9fd380Sjfb8856606 rte_rawdev_obj_t queue_conf, 162*2d9fd380Sjfb8856606 size_t queue_conf_size); 163d30ea906Sjfb8856606 164d30ea906Sjfb8856606 /** 165d30ea906Sjfb8856606 * Allocate and set up a raw queue for a raw device. 166d30ea906Sjfb8856606 * 167d30ea906Sjfb8856606 * @param dev_id 168d30ea906Sjfb8856606 * The identifier of the device. 169d30ea906Sjfb8856606 * @param queue_id 170d30ea906Sjfb8856606 * The index of the raw queue to setup. The value must be in the range 171d30ea906Sjfb8856606 * [0, nb_raw_queues - 1] previously supplied to rte_rawdev_configure(). 172d30ea906Sjfb8856606 * @param queue_conf 173d30ea906Sjfb8856606 * The pointer to the configuration data to be used for the raw queue. 174d30ea906Sjfb8856606 * NULL value is allowed, in which case default configuration used. 175*2d9fd380Sjfb8856606 * @param queue_conf_size 176*2d9fd380Sjfb8856606 * The size of the structure pointed to by queue_conf 177d30ea906Sjfb8856606 * 178d30ea906Sjfb8856606 * @see rte_rawdev_queue_conf_get() 179d30ea906Sjfb8856606 * 180d30ea906Sjfb8856606 * @return 181d30ea906Sjfb8856606 * - 0: Success, raw queue correctly set up. 182d30ea906Sjfb8856606 * - <0: raw queue configuration failed 183d30ea906Sjfb8856606 */ 184d30ea906Sjfb8856606 int 185d30ea906Sjfb8856606 rte_rawdev_queue_setup(uint16_t dev_id, 186d30ea906Sjfb8856606 uint16_t queue_id, 187*2d9fd380Sjfb8856606 rte_rawdev_obj_t queue_conf, 188*2d9fd380Sjfb8856606 size_t queue_conf_size); 189d30ea906Sjfb8856606 190d30ea906Sjfb8856606 /** 191d30ea906Sjfb8856606 * Release and deallocate a raw queue from a raw device. 192d30ea906Sjfb8856606 * 193d30ea906Sjfb8856606 * @param dev_id 194d30ea906Sjfb8856606 * The identifier of the device. 195d30ea906Sjfb8856606 * @param queue_id 196d30ea906Sjfb8856606 * The index of the raw queue to release. The value must be in the range 197d30ea906Sjfb8856606 * [0, nb_raw_queues - 1] previously supplied to rte_rawdev_configure(). 198d30ea906Sjfb8856606 * 199d30ea906Sjfb8856606 * @see rte_rawdev_queue_conf_get() 200d30ea906Sjfb8856606 * 201d30ea906Sjfb8856606 * @return 202d30ea906Sjfb8856606 * - 0: Success, raw queue released. 203d30ea906Sjfb8856606 * - <0: raw queue configuration failed 204d30ea906Sjfb8856606 */ 205d30ea906Sjfb8856606 int 206d30ea906Sjfb8856606 rte_rawdev_queue_release(uint16_t dev_id, uint16_t queue_id); 207d30ea906Sjfb8856606 208d30ea906Sjfb8856606 /** 209d30ea906Sjfb8856606 * Get the number of raw queues on a specific raw device 210d30ea906Sjfb8856606 * 211d30ea906Sjfb8856606 * @param dev_id 212d30ea906Sjfb8856606 * Raw device identifier. 213d30ea906Sjfb8856606 * @return 214d30ea906Sjfb8856606 * - The number of configured raw queues 215d30ea906Sjfb8856606 */ 216d30ea906Sjfb8856606 uint16_t 217d30ea906Sjfb8856606 rte_rawdev_queue_count(uint16_t dev_id); 218d30ea906Sjfb8856606 219d30ea906Sjfb8856606 /** 220d30ea906Sjfb8856606 * Start a raw device. 221d30ea906Sjfb8856606 * 222d30ea906Sjfb8856606 * The device start step is the last one and consists of setting the raw 223d30ea906Sjfb8856606 * queues to start accepting the raws and schedules to raw ports. 224d30ea906Sjfb8856606 * 225d30ea906Sjfb8856606 * On success, all basic functions exported by the API (raw enqueue, 226d30ea906Sjfb8856606 * raw dequeue and so on) can be invoked. 227d30ea906Sjfb8856606 * 228d30ea906Sjfb8856606 * @param dev_id 229d30ea906Sjfb8856606 * Raw device identifier 230d30ea906Sjfb8856606 * @return 231d30ea906Sjfb8856606 * - 0: Success, device started. 232d30ea906Sjfb8856606 * < 0: Failure 233d30ea906Sjfb8856606 */ 234d30ea906Sjfb8856606 int 235d30ea906Sjfb8856606 rte_rawdev_start(uint16_t dev_id); 236d30ea906Sjfb8856606 237d30ea906Sjfb8856606 /** 238d30ea906Sjfb8856606 * Stop a raw device. The device can be restarted with a call to 239d30ea906Sjfb8856606 * rte_rawdev_start() 240d30ea906Sjfb8856606 * 241d30ea906Sjfb8856606 * @param dev_id 242d30ea906Sjfb8856606 * Raw device identifier. 243d30ea906Sjfb8856606 */ 244d30ea906Sjfb8856606 void 245d30ea906Sjfb8856606 rte_rawdev_stop(uint16_t dev_id); 246d30ea906Sjfb8856606 247d30ea906Sjfb8856606 /** 248d30ea906Sjfb8856606 * Close a raw device. The device cannot be restarted after this call. 249d30ea906Sjfb8856606 * 250d30ea906Sjfb8856606 * @param dev_id 251d30ea906Sjfb8856606 * Raw device identifier 252d30ea906Sjfb8856606 * 253d30ea906Sjfb8856606 * @return 254d30ea906Sjfb8856606 * - 0 on successfully closing device 255d30ea906Sjfb8856606 * - <0 on failure to close device 256d30ea906Sjfb8856606 * - (-EAGAIN) if device is busy 257d30ea906Sjfb8856606 */ 258d30ea906Sjfb8856606 int 259d30ea906Sjfb8856606 rte_rawdev_close(uint16_t dev_id); 260d30ea906Sjfb8856606 261d30ea906Sjfb8856606 /** 262d30ea906Sjfb8856606 * Reset a raw device. 263d30ea906Sjfb8856606 * This is different from cycle of rte_rawdev_start->rte_rawdev_stop in the 264d30ea906Sjfb8856606 * sense similar to hard or soft reset. 265d30ea906Sjfb8856606 * 266d30ea906Sjfb8856606 * @param dev_id 267d30ea906Sjfb8856606 * Raw device identifiers 268d30ea906Sjfb8856606 * @return 2691646932aSjfb8856606 * 0 for successful reset, 270d30ea906Sjfb8856606 * !0 for failure in resetting 271d30ea906Sjfb8856606 */ 272d30ea906Sjfb8856606 int 273d30ea906Sjfb8856606 rte_rawdev_reset(uint16_t dev_id); 274d30ea906Sjfb8856606 275d30ea906Sjfb8856606 #define RTE_RAWDEV_NAME_MAX_LEN (64) 276d30ea906Sjfb8856606 /**< @internal Max length of name of raw PMD */ 277d30ea906Sjfb8856606 278d30ea906Sjfb8856606 279d30ea906Sjfb8856606 280d30ea906Sjfb8856606 /** @internal 281d30ea906Sjfb8856606 * The data structure associated with each raw device. 282d30ea906Sjfb8856606 * It is a placeholder for PMD specific data, encapsulating only information 283d30ea906Sjfb8856606 * related to framework. 284d30ea906Sjfb8856606 */ 285d30ea906Sjfb8856606 struct rte_rawdev { 286d30ea906Sjfb8856606 /**< Socket ID where memory is allocated */ 287d30ea906Sjfb8856606 int socket_id; 288d30ea906Sjfb8856606 /**< Device ID for this instance */ 289d30ea906Sjfb8856606 uint16_t dev_id; 290d30ea906Sjfb8856606 /**< Functions exported by PMD */ 291d30ea906Sjfb8856606 const struct rte_rawdev_ops *dev_ops; 292d30ea906Sjfb8856606 /**< Device info. supplied during device initialization */ 293d30ea906Sjfb8856606 struct rte_device *device; 294d30ea906Sjfb8856606 /**< Driver info. supplied by probing */ 295d30ea906Sjfb8856606 const char *driver_name; 296d30ea906Sjfb8856606 297d30ea906Sjfb8856606 RTE_STD_C11 298d30ea906Sjfb8856606 /**< Flag indicating the device is attached */ 299d30ea906Sjfb8856606 uint8_t attached : 1; 300d30ea906Sjfb8856606 /**< Device state: STARTED(1)/STOPPED(0) */ 301d30ea906Sjfb8856606 uint8_t started : 1; 302d30ea906Sjfb8856606 303d30ea906Sjfb8856606 /**< PMD-specific private data */ 304d30ea906Sjfb8856606 rte_rawdev_obj_t dev_private; 305d30ea906Sjfb8856606 /**< Device name */ 306d30ea906Sjfb8856606 char name[RTE_RAWDEV_NAME_MAX_LEN]; 307d30ea906Sjfb8856606 } __rte_cache_aligned; 308d30ea906Sjfb8856606 309d30ea906Sjfb8856606 /** @internal The pool of rte_rawdev structures. */ 310d30ea906Sjfb8856606 extern struct rte_rawdev *rte_rawdevs; 311d30ea906Sjfb8856606 312d30ea906Sjfb8856606 313d30ea906Sjfb8856606 struct rte_rawdev_info { 314d30ea906Sjfb8856606 /**< Name of driver handling this device */ 315d30ea906Sjfb8856606 const char *driver_name; 316d30ea906Sjfb8856606 /**< Device encapsulation */ 317d30ea906Sjfb8856606 struct rte_device *device; 318d30ea906Sjfb8856606 /**< Socket ID where memory is allocated */ 319d30ea906Sjfb8856606 int socket_id; 320d30ea906Sjfb8856606 /**< PMD-specific private data */ 321d30ea906Sjfb8856606 rte_rawdev_obj_t dev_private; 322d30ea906Sjfb8856606 }; 323d30ea906Sjfb8856606 324d30ea906Sjfb8856606 struct rte_rawdev_buf { 325d30ea906Sjfb8856606 /**< Opaque buffer reference */ 326d30ea906Sjfb8856606 void *buf_addr; 327d30ea906Sjfb8856606 }; 328d30ea906Sjfb8856606 329d30ea906Sjfb8856606 /** 330d30ea906Sjfb8856606 * Dump internal information about *dev_id* to the FILE* provided in *f*. 331d30ea906Sjfb8856606 * 332d30ea906Sjfb8856606 * @param dev_id 333d30ea906Sjfb8856606 * The identifier of the device. 334d30ea906Sjfb8856606 * 335d30ea906Sjfb8856606 * @param f 336d30ea906Sjfb8856606 * A pointer to a file for output 337d30ea906Sjfb8856606 * 338d30ea906Sjfb8856606 * @return 339d30ea906Sjfb8856606 * - 0: on success 340d30ea906Sjfb8856606 * - <0: on failure. 341d30ea906Sjfb8856606 */ 342d30ea906Sjfb8856606 int 343d30ea906Sjfb8856606 rte_rawdev_dump(uint16_t dev_id, FILE *f); 344d30ea906Sjfb8856606 345d30ea906Sjfb8856606 /** 346d30ea906Sjfb8856606 * Get an attribute value from implementation. 347d30ea906Sjfb8856606 * Attribute is an opaque handle agreed upon between application and PMD. 348d30ea906Sjfb8856606 * 349d30ea906Sjfb8856606 * Implementations are expected to maintain an array of attribute-value pairs 350d30ea906Sjfb8856606 * based on application calls. Memory management for this structure is 351d30ea906Sjfb8856606 * shared responsibility of implementation and application. 352d30ea906Sjfb8856606 * 353d30ea906Sjfb8856606 * @param dev_id 354d30ea906Sjfb8856606 * The identifier of the device to configure. 355d30ea906Sjfb8856606 * @param attr_name 356d30ea906Sjfb8856606 * Opaque object representing an attribute in implementation. 357d30ea906Sjfb8856606 * @param attr_value [out] 358d30ea906Sjfb8856606 * Opaque response to the attribute value. In case of error, this remains 359d30ea906Sjfb8856606 * untouched. This is double pointer of void type. 360d30ea906Sjfb8856606 * @return 361d30ea906Sjfb8856606 * 0 for success 362d30ea906Sjfb8856606 * !0 Error; attr_value remains untouched in case of error. 363d30ea906Sjfb8856606 */ 364d30ea906Sjfb8856606 int 365d30ea906Sjfb8856606 rte_rawdev_get_attr(uint16_t dev_id, 366d30ea906Sjfb8856606 const char *attr_name, 367d30ea906Sjfb8856606 uint64_t *attr_value); 368d30ea906Sjfb8856606 369d30ea906Sjfb8856606 /** 370d30ea906Sjfb8856606 * Set an attribute value. 371d30ea906Sjfb8856606 * Attribute is an opaque handle agreed upon between application and PMD. 372d30ea906Sjfb8856606 * 373d30ea906Sjfb8856606 * @param dev_id 374d30ea906Sjfb8856606 * The identifier of the device to configure. 375d30ea906Sjfb8856606 * @param attr_name 376d30ea906Sjfb8856606 * Opaque object representing an attribute in implementation. 377d30ea906Sjfb8856606 * @param attr_value 378d30ea906Sjfb8856606 * Value of the attribute represented by attr_name 379d30ea906Sjfb8856606 * @return 380d30ea906Sjfb8856606 * 0 for success 381d30ea906Sjfb8856606 * !0 Error 382d30ea906Sjfb8856606 */ 383d30ea906Sjfb8856606 int 384d30ea906Sjfb8856606 rte_rawdev_set_attr(uint16_t dev_id, 385d30ea906Sjfb8856606 const char *attr_name, 386d30ea906Sjfb8856606 const uint64_t attr_value); 387d30ea906Sjfb8856606 388d30ea906Sjfb8856606 /** 389d30ea906Sjfb8856606 * Enqueue a stream of buffers to the device. 390d30ea906Sjfb8856606 * 391d30ea906Sjfb8856606 * Rather than specifying a queue, this API passes along an opaque object 392d30ea906Sjfb8856606 * to the driver implementation. That object can be a queue or any other 393d30ea906Sjfb8856606 * contextual information necessary for the device to enqueue buffers. 394d30ea906Sjfb8856606 * 395d30ea906Sjfb8856606 * @param dev_id 396d30ea906Sjfb8856606 * The identifier of the device to configure. 397d30ea906Sjfb8856606 * @param buffers 3981646932aSjfb8856606 * Collection of buffers for enqueuing 399d30ea906Sjfb8856606 * @param count 400d30ea906Sjfb8856606 * Count of buffers to enqueue 401d30ea906Sjfb8856606 * @param context 402d30ea906Sjfb8856606 * Opaque context information. 403d30ea906Sjfb8856606 * @return 404d30ea906Sjfb8856606 * >=0 for buffers enqueued 405d30ea906Sjfb8856606 * !0 for failure. 406d30ea906Sjfb8856606 * Whether partial enqueue is failure or success is defined between app 407d30ea906Sjfb8856606 * and driver implementation. 408d30ea906Sjfb8856606 */ 409d30ea906Sjfb8856606 int 410d30ea906Sjfb8856606 rte_rawdev_enqueue_buffers(uint16_t dev_id, 411d30ea906Sjfb8856606 struct rte_rawdev_buf **buffers, 412d30ea906Sjfb8856606 unsigned int count, 413d30ea906Sjfb8856606 rte_rawdev_obj_t context); 414d30ea906Sjfb8856606 415d30ea906Sjfb8856606 /** 416d30ea906Sjfb8856606 * Dequeue a stream of buffers from the device. 417d30ea906Sjfb8856606 * 418d30ea906Sjfb8856606 * Rather than specifying a queue, this API passes along an opaque object 419d30ea906Sjfb8856606 * to the driver implementation. That object can be a queue or any other 420d30ea906Sjfb8856606 * contextual information necessary for the device to dequeue buffers. 421d30ea906Sjfb8856606 * 422d30ea906Sjfb8856606 * Application should have allocated enough space to store `count` response 423d30ea906Sjfb8856606 * buffers. 424d30ea906Sjfb8856606 * Releasing buffers dequeued is responsibility of the application. 425d30ea906Sjfb8856606 * 426d30ea906Sjfb8856606 * @param dev_id 427d30ea906Sjfb8856606 * The identifier of the device to configure. 428d30ea906Sjfb8856606 * @param buffers 429d30ea906Sjfb8856606 * Collection of buffers dequeued 430d30ea906Sjfb8856606 * @param count 431d30ea906Sjfb8856606 * Max buffers expected to be dequeued 432d30ea906Sjfb8856606 * @param context 433d30ea906Sjfb8856606 * Opaque context information. 434d30ea906Sjfb8856606 * @return 435d30ea906Sjfb8856606 * >=0 for buffers dequeued 436d30ea906Sjfb8856606 * !0 for failure. 437d30ea906Sjfb8856606 * Whether partial enqueue is failure or success is defined between app 438d30ea906Sjfb8856606 * and driver implementation. 439d30ea906Sjfb8856606 */ 440d30ea906Sjfb8856606 int 441d30ea906Sjfb8856606 rte_rawdev_dequeue_buffers(uint16_t dev_id, 442d30ea906Sjfb8856606 struct rte_rawdev_buf **buffers, 443d30ea906Sjfb8856606 unsigned int count, 444d30ea906Sjfb8856606 rte_rawdev_obj_t context); 445d30ea906Sjfb8856606 446d30ea906Sjfb8856606 /** Maximum name length for extended statistics counters */ 447d30ea906Sjfb8856606 #define RTE_RAW_DEV_XSTATS_NAME_SIZE 64 448d30ea906Sjfb8856606 449d30ea906Sjfb8856606 /** 450d30ea906Sjfb8856606 * A name-key lookup element for extended statistics. 451d30ea906Sjfb8856606 * 452d30ea906Sjfb8856606 * This structure is used to map between names and ID numbers 453d30ea906Sjfb8856606 * for extended ethdev statistics. 454d30ea906Sjfb8856606 */ 455d30ea906Sjfb8856606 struct rte_rawdev_xstats_name { 456d30ea906Sjfb8856606 char name[RTE_RAW_DEV_XSTATS_NAME_SIZE]; 457d30ea906Sjfb8856606 }; 458d30ea906Sjfb8856606 459d30ea906Sjfb8856606 /** 460d30ea906Sjfb8856606 * Retrieve names of extended statistics of a raw device. 461d30ea906Sjfb8856606 * 462d30ea906Sjfb8856606 * @param dev_id 463d30ea906Sjfb8856606 * The identifier of the raw device. 464d30ea906Sjfb8856606 * @param[out] xstats_names 465d30ea906Sjfb8856606 * Block of memory to insert names into. Must be at least size in capacity. 466d30ea906Sjfb8856606 * If set to NULL, function returns required capacity. 467d30ea906Sjfb8856606 * @param size 468d30ea906Sjfb8856606 * Capacity of xstats_names (number of names). 469d30ea906Sjfb8856606 * @return 470d30ea906Sjfb8856606 * - positive value lower or equal to size: success. The return value 471d30ea906Sjfb8856606 * is the number of entries filled in the stats table. 472d30ea906Sjfb8856606 * - positive value higher than size: error, the given statistics table 473d30ea906Sjfb8856606 * is too small. The return value corresponds to the size that should 474d30ea906Sjfb8856606 * be given to succeed. The entries in the table are not valid and 475d30ea906Sjfb8856606 * shall not be used by the caller. 476d30ea906Sjfb8856606 * - negative value on error: 477d30ea906Sjfb8856606 * -ENODEV for invalid *dev_id* 478d30ea906Sjfb8856606 * -ENOTSUP if the device doesn't support this function. 479d30ea906Sjfb8856606 */ 480d30ea906Sjfb8856606 int 481d30ea906Sjfb8856606 rte_rawdev_xstats_names_get(uint16_t dev_id, 482d30ea906Sjfb8856606 struct rte_rawdev_xstats_name *xstats_names, 483d30ea906Sjfb8856606 unsigned int size); 484d30ea906Sjfb8856606 485d30ea906Sjfb8856606 /** 486d30ea906Sjfb8856606 * Retrieve extended statistics of a raw device. 487d30ea906Sjfb8856606 * 488d30ea906Sjfb8856606 * @param dev_id 489d30ea906Sjfb8856606 * The identifier of the device. 490d30ea906Sjfb8856606 * @param ids 491d30ea906Sjfb8856606 * The id numbers of the stats to get. The ids can be got from the stat 492d30ea906Sjfb8856606 * position in the stat list from rte_rawdev_get_xstats_names(), or 493d30ea906Sjfb8856606 * by using rte_rawdev_get_xstats_by_name() 494d30ea906Sjfb8856606 * @param[out] values 495d30ea906Sjfb8856606 * The values for each stats request by ID. 496d30ea906Sjfb8856606 * @param n 497d30ea906Sjfb8856606 * The number of stats requested 498d30ea906Sjfb8856606 * @return 499d30ea906Sjfb8856606 * - positive value: number of stat entries filled into the values array 500d30ea906Sjfb8856606 * - negative value on error: 501d30ea906Sjfb8856606 * -ENODEV for invalid *dev_id* 502d30ea906Sjfb8856606 * -ENOTSUP if the device doesn't support this function. 503d30ea906Sjfb8856606 */ 504d30ea906Sjfb8856606 int 505d30ea906Sjfb8856606 rte_rawdev_xstats_get(uint16_t dev_id, 506d30ea906Sjfb8856606 const unsigned int ids[], 507d30ea906Sjfb8856606 uint64_t values[], 508d30ea906Sjfb8856606 unsigned int n); 509d30ea906Sjfb8856606 510d30ea906Sjfb8856606 /** 511d30ea906Sjfb8856606 * Retrieve the value of a single stat by requesting it by name. 512d30ea906Sjfb8856606 * 513d30ea906Sjfb8856606 * @param dev_id 514d30ea906Sjfb8856606 * The identifier of the device 515d30ea906Sjfb8856606 * @param name 516d30ea906Sjfb8856606 * The stat name to retrieve 517d30ea906Sjfb8856606 * @param[out] id 518d30ea906Sjfb8856606 * If non-NULL, the numerical id of the stat will be returned, so that further 519d30ea906Sjfb8856606 * requests for the stat can be got using rte_rawdev_xstats_get, which will 520d30ea906Sjfb8856606 * be faster as it doesn't need to scan a list of names for the stat. 521d30ea906Sjfb8856606 * If the stat cannot be found, the id returned will be (unsigned)-1. 522d30ea906Sjfb8856606 * @return 523d30ea906Sjfb8856606 * - positive value or zero: the stat value 524d30ea906Sjfb8856606 * - negative value: -EINVAL if stat not found, -ENOTSUP if not supported. 525d30ea906Sjfb8856606 */ 526d30ea906Sjfb8856606 uint64_t 527d30ea906Sjfb8856606 rte_rawdev_xstats_by_name_get(uint16_t dev_id, 528d30ea906Sjfb8856606 const char *name, 529d30ea906Sjfb8856606 unsigned int *id); 530d30ea906Sjfb8856606 531d30ea906Sjfb8856606 /** 532d30ea906Sjfb8856606 * Reset the values of the xstats of the selected component in the device. 533d30ea906Sjfb8856606 * 534d30ea906Sjfb8856606 * @param dev_id 535d30ea906Sjfb8856606 * The identifier of the device 536d30ea906Sjfb8856606 * @param ids 537d30ea906Sjfb8856606 * Selects specific statistics to be reset. When NULL, all statistics 538d30ea906Sjfb8856606 * will be reset. If non-NULL, must point to array of at least 539d30ea906Sjfb8856606 * *nb_ids* size. 540d30ea906Sjfb8856606 * @param nb_ids 541d30ea906Sjfb8856606 * The number of ids available from the *ids* array. Ignored when ids is NULL. 542d30ea906Sjfb8856606 * @return 543d30ea906Sjfb8856606 * - zero: successfully reset the statistics to zero 544d30ea906Sjfb8856606 * - negative value: -EINVAL invalid parameters, -ENOTSUP if not supported. 545d30ea906Sjfb8856606 */ 546d30ea906Sjfb8856606 int 547d30ea906Sjfb8856606 rte_rawdev_xstats_reset(uint16_t dev_id, 548d30ea906Sjfb8856606 const uint32_t ids[], 549d30ea906Sjfb8856606 uint32_t nb_ids); 550d30ea906Sjfb8856606 551d30ea906Sjfb8856606 /** 552d30ea906Sjfb8856606 * Get Firmware status of the device.. 553d30ea906Sjfb8856606 * Returns a memory allocated by driver/implementation containing status 554d30ea906Sjfb8856606 * information block. It is responsibility of caller to release the buffer. 555d30ea906Sjfb8856606 * 556d30ea906Sjfb8856606 * @param dev_id 557d30ea906Sjfb8856606 * Raw device identifier 558d30ea906Sjfb8856606 * @param status_info 559d30ea906Sjfb8856606 * Pointer to status information area. Caller is responsible for releasing 560d30ea906Sjfb8856606 * the memory associated. 561d30ea906Sjfb8856606 * @return 562d30ea906Sjfb8856606 * 0 for success, 563d30ea906Sjfb8856606 * !0 for failure, `status_info` argument state is undefined 564d30ea906Sjfb8856606 */ 565d30ea906Sjfb8856606 int 566d30ea906Sjfb8856606 rte_rawdev_firmware_status_get(uint16_t dev_id, 567d30ea906Sjfb8856606 rte_rawdev_obj_t status_info); 568d30ea906Sjfb8856606 569d30ea906Sjfb8856606 /** 570d30ea906Sjfb8856606 * Get Firmware version of the device. 571d30ea906Sjfb8856606 * Returns a memory allocated by driver/implementation containing version 572d30ea906Sjfb8856606 * information block. It is responsibility of caller to release the buffer. 573d30ea906Sjfb8856606 * 574d30ea906Sjfb8856606 * @param dev_id 575d30ea906Sjfb8856606 * Raw device identifier 576d30ea906Sjfb8856606 * @param version_info 577d30ea906Sjfb8856606 * Pointer to version information area. Caller is responsible for releasing 578d30ea906Sjfb8856606 * the memory associated. 579d30ea906Sjfb8856606 * @return 580d30ea906Sjfb8856606 * 0 for success, 581d30ea906Sjfb8856606 * !0 for failure, `version_info` argument state is undefined 582d30ea906Sjfb8856606 */ 583d30ea906Sjfb8856606 int 584d30ea906Sjfb8856606 rte_rawdev_firmware_version_get(uint16_t dev_id, 585d30ea906Sjfb8856606 rte_rawdev_obj_t version_info); 586d30ea906Sjfb8856606 587d30ea906Sjfb8856606 /** 588d30ea906Sjfb8856606 * Load firmware on the device. 589d30ea906Sjfb8856606 * TODO: In future, methods like directly flashing from file too can be 590d30ea906Sjfb8856606 * supported. 591d30ea906Sjfb8856606 * 592d30ea906Sjfb8856606 * @param dev_id 593d30ea906Sjfb8856606 * Raw device identifier 594d30ea906Sjfb8856606 * @param firmware_image 595d30ea906Sjfb8856606 * Pointer to buffer containing image binary data 596d30ea906Sjfb8856606 * @return 597d30ea906Sjfb8856606 * 0 for successful load 598d30ea906Sjfb8856606 * !0 for failure to load the provided image, or image incorrect. 599d30ea906Sjfb8856606 */ 600d30ea906Sjfb8856606 int 601d30ea906Sjfb8856606 rte_rawdev_firmware_load(uint16_t dev_id, rte_rawdev_obj_t firmware_image); 602d30ea906Sjfb8856606 603d30ea906Sjfb8856606 /** 604d30ea906Sjfb8856606 * Unload firmware from the device. 605d30ea906Sjfb8856606 * 606d30ea906Sjfb8856606 * @param dev_id 607d30ea906Sjfb8856606 * Raw device identifiers 608d30ea906Sjfb8856606 * @return 609d30ea906Sjfb8856606 * 0 for successful Unload 610d30ea906Sjfb8856606 * !0 for failure in unloading 611d30ea906Sjfb8856606 */ 612d30ea906Sjfb8856606 int 613d30ea906Sjfb8856606 rte_rawdev_firmware_unload(uint16_t dev_id); 614d30ea906Sjfb8856606 615d30ea906Sjfb8856606 /** 616d30ea906Sjfb8856606 * Trigger the rawdev self test. 617d30ea906Sjfb8856606 * 618d30ea906Sjfb8856606 * @param dev_id 619d30ea906Sjfb8856606 * The identifier of the device 620d30ea906Sjfb8856606 * @return 621d30ea906Sjfb8856606 * - 0: Selftest successful 622d30ea906Sjfb8856606 * - -ENOTSUP if the device doesn't support selftest 623d30ea906Sjfb8856606 * - other values < 0 on failure. 624d30ea906Sjfb8856606 */ 625d30ea906Sjfb8856606 int 626d30ea906Sjfb8856606 rte_rawdev_selftest(uint16_t dev_id); 627d30ea906Sjfb8856606 628d30ea906Sjfb8856606 #ifdef __cplusplus 629d30ea906Sjfb8856606 } 630d30ea906Sjfb8856606 #endif 631d30ea906Sjfb8856606 632d30ea906Sjfb8856606 #endif /* _RTE_RAWDEV_H_ */ 633