1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168
|
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2017 Intel Corporation
*/
#ifndef _RTE_BBDEV_H_
#define _RTE_BBDEV_H_
/**
* @file rte_bbdev.h
*
* Wireless base band device abstraction APIs.
*
* This API allows an application to discover, configure and use a device to
* process operations. An asynchronous API (enqueue, followed by later dequeue)
* is used for processing operations.
*
* The functions in this API are not thread-safe when called on the same
* target object (a device, or a queue on a device), with the exception that
* one thread can enqueue operations to a queue while another thread dequeues
* from the same queue.
*/
#include <stdint.h>
#include <stdbool.h>
#include <rte_compat.h>
#include <rte_cpuflags.h>
#include "rte_bbdev_op.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "rte_bbdev_trace_fp.h"
#ifndef RTE_BBDEV_MAX_DEVS
#define RTE_BBDEV_MAX_DEVS 128 /**< Max number of devices */
#endif
/*
* Maximum size to be used to manage the enum rte_bbdev_enqueue_status
* including padding for future enum insertion.
* The enum values must be explicitly kept smaller or equal to this padded maximum size.
*/
#define RTE_BBDEV_ENQ_STATUS_SIZE_MAX 6
/** Flags indicate current state of BBDEV device */
enum rte_bbdev_state {
RTE_BBDEV_UNUSED,
RTE_BBDEV_INITIALIZED
};
/**
* Get the total number of devices that have been successfully initialised.
*
* @return
* The total number of usable devices.
*/
uint16_t
rte_bbdev_count(void);
/**
* Check if a device is valid.
*
* @param dev_id
* The identifier of the device.
*
* @return
* true if device ID is valid and device is attached, false otherwise.
*/
bool
rte_bbdev_is_valid(uint16_t dev_id);
/**
* Get the next enabled device.
*
* @param dev_id
* The current device
*
* @return
* - The next device, or
* - RTE_BBDEV_MAX_DEVS if none found
*/
uint16_t
rte_bbdev_find_next(uint16_t dev_id);
/** Iterate through all enabled devices */
#define RTE_BBDEV_FOREACH(i) for (i = rte_bbdev_find_next(-1); \
i < RTE_BBDEV_MAX_DEVS; \
i = rte_bbdev_find_next(i))
/**
* Setup up device queues.
* This function must be called on a device before setting up the queues and
* starting the device. It can also be called when a device is in the stopped
* state. If any device queues have been configured their configuration will be
* cleared by a call to this function.
*
* @param dev_id
* The identifier of the device.
* @param num_queues
* Number of queues to configure on device.
* @param socket_id
* ID of a socket which will be used to allocate memory.
*
* @return
* - 0 on success
* - -ENODEV if dev_id is invalid or the device is corrupted
* - -EINVAL if num_queues is invalid, 0 or greater than maximum
* - -EBUSY if the identified device has already started
* - -ENOMEM if unable to allocate memory
*/
int
rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id);
/**
* Enable interrupts.
* This function may be called before starting the device to enable the
* interrupts if they are available.
*
* @param dev_id
* The identifier of the device.
*
* @return
* - 0 on success
* - -ENODEV if dev_id is invalid or the device is corrupted
* - -EBUSY if the identified device has already started
* - -ENOTSUP if the interrupts are not supported by the device
*/
int
rte_bbdev_intr_enable(uint16_t dev_id);
/** Device queue configuration structure */
struct rte_bbdev_queue_conf {
int socket; /**< NUMA socket used for memory allocation */
uint32_t queue_size; /**< Size of queue */
uint8_t priority; /**< Queue priority */
bool deferred_start; /**< Do not start queue when device is started. */
enum rte_bbdev_op_type op_type; /**< Operation type */
};
/**
* Configure a queue on a device.
* This function can be called after device configuration, and before starting.
* It can also be called when the device or the queue is in the stopped state.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param conf
* The queue configuration. If NULL, a default configuration will be used.
*
* @return
* - 0 on success
* - EINVAL if the identified queue size or priority are invalid
* - EBUSY if the identified queue or its device have already started
*/
int
rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
const struct rte_bbdev_queue_conf *conf);
/**
* Start a device.
* This is the last step needed before enqueueing operations is possible.
*
* @param dev_id
* The identifier of the device.
*
* @return
* - 0 on success
* - negative value on failure - as returned from PMD
*/
int
rte_bbdev_start(uint16_t dev_id);
/**
* Stop a device.
* The device can be reconfigured, and restarted after being stopped.
*
* @param dev_id
* The identifier of the device.
*
* @return
* - 0 on success
*/
int
rte_bbdev_stop(uint16_t dev_id);
/**
* Close a device.
* The device cannot be restarted without reconfiguration!
*
* @param dev_id
* The identifier of the device.
*
* @return
* - 0 on success
*/
int
rte_bbdev_close(uint16_t dev_id);
/**
* Start a specified queue on a device.
* This is only needed if the queue has been stopped, or if the deferred_start
* flag has been set when configuring the queue.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
*
* @return
* - 0 on success
* - negative value on failure - as returned from PMD
*/
int
rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id);
/**
* Stop a specified queue on a device, to allow re configuration.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
*
* @return
* - 0 on success
* - negative value on failure - as returned from PMD
*/
int
rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id);
/**
* Flags to indicate the reason why a previous enqueue may not have
* consumed all requested operations.
* In case of multiple reasons the latter supersedes a previous one.
* The related macro RTE_BBDEV_ENQ_STATUS_SIZE_MAX can be used
* as an absolute maximum for notably sizing array
* while allowing for future enumeration insertion.
*/
enum rte_bbdev_enqueue_status {
RTE_BBDEV_ENQ_STATUS_NONE, /**< Nothing to report. */
RTE_BBDEV_ENQ_STATUS_QUEUE_FULL, /**< Not enough room in queue. */
RTE_BBDEV_ENQ_STATUS_RING_FULL, /**< Not enough room in ring. */
RTE_BBDEV_ENQ_STATUS_INVALID_OP, /**< Operation was rejected as invalid. */
/* Note: RTE_BBDEV_ENQ_STATUS_SIZE_MAX must be larger or equal to maximum enum value. */
};
/**
* Flags to indicate the status of the device.
*/
enum rte_bbdev_device_status {
RTE_BBDEV_DEV_NOSTATUS, /**< Nothing being reported. */
RTE_BBDEV_DEV_NOT_SUPPORTED, /**< Device status is not supported on the PMD. */
RTE_BBDEV_DEV_RESET, /**< Device in reset and un-configured state. */
RTE_BBDEV_DEV_CONFIGURED, /**< Device is configured and ready to use. */
RTE_BBDEV_DEV_ACTIVE, /**< Device is configured and VF is being used. */
RTE_BBDEV_DEV_FATAL_ERR, /**< Device has hit a fatal uncorrectable error. */
RTE_BBDEV_DEV_RESTART_REQ, /**< Device requires application to restart. */
RTE_BBDEV_DEV_RECONFIG_REQ, /**< Device requires application to reconfigure queues. */
RTE_BBDEV_DEV_CORRECT_ERR, /**< Warning of a correctable error event happened. */
};
/** Device statistics. */
struct rte_bbdev_stats {
uint64_t enqueued_count; /**< Count of all operations enqueued */
uint64_t dequeued_count; /**< Count of all operations dequeued */
/** Total error count on operations enqueued */
uint64_t enqueue_err_count;
/** Total error count on operations dequeued */
uint64_t dequeue_err_count;
/** Total warning count on operations enqueued. */
uint64_t enqueue_warn_count;
/** Total warning count on operations dequeued. */
uint64_t dequeue_warn_count;
/** Total enqueue status count based on *rte_bbdev_enqueue_status* enum. */
uint64_t enqueue_status_count[RTE_BBDEV_ENQ_STATUS_SIZE_MAX];
/** CPU cycles consumed by the (HW/SW) accelerator device to offload
* the enqueue request to its internal queues.
* - For a HW device this is the cycles consumed in MMIO write
* - For a SW (vdev) device, this is the processing time of the
* bbdev operation
*/
uint64_t acc_offload_cycles;
/** Available number of enqueue batch on that queue. */
uint16_t enqueue_depth_avail;
};
/**
* Retrieve the general I/O statistics of a device.
*
* @param dev_id
* The identifier of the device.
* @param stats
* Pointer to structure to where statistics will be copied. On error, this
* location may or may not have been modified.
*
* @return
* - 0 on success
* - EINVAL if invalid parameter pointer is provided
*/
int
rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats);
/**
* Reset the statistics of a device.
*
* @param dev_id
* The identifier of the device.
* @return
* - 0 on success
*/
int
rte_bbdev_stats_reset(uint16_t dev_id);
/** Device information supplied by the device's driver */
/* Structure rte_bbdev_driver_info 8< */
struct rte_bbdev_driver_info {
/** Driver name */
const char *driver_name;
/** Maximum number of queues supported by the device */
unsigned int max_num_queues;
/** Maximum number of queues supported per operation type */
unsigned int num_queues[RTE_BBDEV_OP_TYPE_SIZE_MAX];
/** Priority level supported per operation type */
unsigned int queue_priority[RTE_BBDEV_OP_TYPE_SIZE_MAX];
/** Queue size limit (queue size must also be power of 2) */
uint32_t queue_size_lim;
/** Set if device off-loads operation to hardware */
bool hardware_accelerated;
/** Max value supported by queue priority for DL */
uint8_t max_dl_queue_priority;
/** Max value supported by queue priority for UL */
uint8_t max_ul_queue_priority;
/** Set if device supports per-queue interrupts */
bool queue_intr_supported;
/** Device Status */
enum rte_bbdev_device_status device_status;
/** HARQ memory available in kB */
uint32_t harq_buffer_size;
/** Minimum alignment of buffers, in bytes */
uint16_t min_alignment;
/** Byte endianness (RTE_BIG_ENDIAN/RTE_LITTLE_ENDIAN) supported
* for input/output data
*/
uint8_t data_endianness;
/** Default queue configuration used if none is supplied */
struct rte_bbdev_queue_conf default_queue_conf;
/** Device operation capabilities */
const struct rte_bbdev_op_cap *capabilities;
/** Device cpu_flag requirements */
const enum rte_cpu_flag_t *cpu_flag_reqs;
/** FFT windowing width for 2048 FFT - size defined in capability. */
uint16_t *fft_window_width;
};
/* >8 End of structure rte_bbdev_driver_info. */
/** Macro used at end of bbdev PMD list */
#define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
{ RTE_BBDEV_OP_NONE }
/**
* Device information structure used by an application to discover a devices
* capabilities and current configuration
*/
/* Structure rte_bbdev_info 8< */
struct rte_bbdev_info {
int socket_id; /**< NUMA socket that device is on */
const char *dev_name; /**< Unique device name */
const struct rte_device *device; /**< Device Information */
uint16_t num_queues; /**< Number of queues currently configured */
bool started; /**< Set if device is currently started */
struct rte_bbdev_driver_info drv; /**< Info from device driver */
};
/* >8 End of structure rte_bbdev_info. */
/**
* Retrieve information about a device.
*
* @param dev_id
* The identifier of the device.
* @param dev_info
* Pointer to structure to where information will be copied. On error, this
* location may or may not have been modified.
*
* @return
* - 0 on success
* - EINVAL if invalid parameter pointer is provided
*/
int
rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
/** Queue information */
struct rte_bbdev_queue_info {
/** Current device configuration */
struct rte_bbdev_queue_conf conf;
/** Set if queue is currently started */
bool started;
};
/**
* Retrieve information about a specific queue on a device.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param queue_info
* Pointer to structure to where information will be copied. On error, this
* location may or may not have been modified.
*
* @return
* - 0 on success
* - EINVAL if invalid parameter pointer is provided
*/
int
rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_queue_info *queue_info);
/** @internal The data structure associated with each queue of a device. */
struct rte_bbdev_queue_data {
void *queue_private; /**< Driver-specific per-queue data */
struct rte_bbdev_queue_conf conf; /**< Current configuration */
struct rte_bbdev_stats queue_stats; /**< Queue statistics */
enum rte_bbdev_enqueue_status enqueue_status; /**< Enqueue status when op is rejected */
bool started; /**< Queue state */
};
/** @internal Enqueue encode operations for processing on queue of a device. */
typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
struct rte_bbdev_queue_data *q_data,
struct rte_bbdev_enc_op **ops,
uint16_t num);
/** @internal Enqueue decode operations for processing on queue of a device. */
typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
struct rte_bbdev_queue_data *q_data,
struct rte_bbdev_dec_op **ops,
uint16_t num);
/** @internal Enqueue FFT operations for processing on queue of a device. */
typedef uint16_t (*rte_bbdev_enqueue_fft_ops_t)(
struct rte_bbdev_queue_data *q_data,
struct rte_bbdev_fft_op **ops,
uint16_t num);
/** @internal Enqueue MLD-TS operations for processing on queue of a device. */
typedef uint16_t (*rte_bbdev_enqueue_mldts_ops_t)(
struct rte_bbdev_queue_data *q_data,
struct rte_bbdev_mldts_op **ops,
uint16_t num);
/** @internal Dequeue encode operations from a queue of a device. */
typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
struct rte_bbdev_queue_data *q_data,
struct rte_bbdev_enc_op **ops, uint16_t num);
/** @internal Dequeue decode operations from a queue of a device. */
typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
struct rte_bbdev_queue_data *q_data,
struct rte_bbdev_dec_op **ops, uint16_t num);
/** @internal Dequeue FFT operations from a queue of a device. */
typedef uint16_t (*rte_bbdev_dequeue_fft_ops_t)(
struct rte_bbdev_queue_data *q_data,
struct rte_bbdev_fft_op **ops, uint16_t num);
/** @internal Dequeue MLDTS operations from a queue of a device. */
typedef uint16_t (*rte_bbdev_dequeue_mldts_ops_t)(
struct rte_bbdev_queue_data *q_data,
struct rte_bbdev_mldts_op **ops, uint16_t num);
#define RTE_BBDEV_NAME_MAX_LEN 64 /**< Max length of device name */
/**
* @internal The data associated with a device, with no function pointers.
* This structure is safe to place in shared memory to be common among
* different processes in a multi-process configuration. Drivers can access
* these fields, but should never write to them!
*/
struct rte_bbdev_data {
char name[RTE_BBDEV_NAME_MAX_LEN]; /**< Unique identifier name */
void *dev_private; /**< Driver-specific private data */
uint16_t num_queues; /**< Number of currently configured queues */
struct rte_bbdev_queue_data *queues; /**< Queue structures */
uint16_t dev_id; /**< Device ID */
int socket_id; /**< NUMA socket that device is on */
bool started; /**< Device run-time state */
RTE_ATOMIC(uint16_t) process_cnt; /** Counter of processes using the device */
};
/* Forward declarations */
struct rte_bbdev_ops;
struct rte_bbdev_callback;
struct rte_intr_handle;
/** Structure to keep track of registered callbacks */
RTE_TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
/**
* @internal The data structure associated with a device. Drivers can access
* these fields, but should only write to the *_ops fields.
*/
struct __rte_cache_aligned rte_bbdev {
/** Enqueue encode function */
rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
/** Enqueue decode function */
rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
/** Dequeue encode function */
rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
/** Dequeue decode function */
rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
/** Enqueue encode function */
rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops;
/** Enqueue decode function */
rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops;
/** Dequeue encode function */
rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops;
/** Dequeue decode function */
rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops;
/** Enqueue FFT function */
rte_bbdev_enqueue_fft_ops_t enqueue_fft_ops;
/** Dequeue FFT function */
rte_bbdev_dequeue_fft_ops_t dequeue_fft_ops;
const struct rte_bbdev_ops *dev_ops; /**< Functions exported by PMD */
struct rte_bbdev_data *data; /**< Pointer to device data */
enum rte_bbdev_state state; /**< If device is currently used or not */
struct rte_device *device; /**< Backing device */
/** User application callback for interrupts if present */
struct rte_bbdev_cb_list list_cbs;
struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
/** Enqueue MLD-TS function */
rte_bbdev_enqueue_mldts_ops_t enqueue_mldts_ops;
/** Dequeue MLD-TS function */
rte_bbdev_dequeue_mldts_ops_t dequeue_mldts_ops;
};
/** @internal array of all devices */
extern struct rte_bbdev rte_bbdev_devices[];
/**
* Enqueue a burst of processed encode operations to a queue of the device.
* This functions only enqueues as many operations as currently possible and
* does not block until @p num_ops entries in the queue are available.
* This function does not provide any error notification to avoid the
* corresponding overhead.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param ops
* Pointer array containing operations to be enqueued Must have at least
* @p num_ops entries
* @param num_ops
* The maximum number of operations to enqueue.
*
* @return
* The number of operations actually enqueued (this is the number of processed
* entries in the @p ops array).
*/
static inline uint16_t
rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_enc_op **ops, uint16_t num_ops)
{
struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
rte_bbdev_trace_enqueue(dev_id, queue_id, (void **)ops, num_ops,
rte_bbdev_op_type_str(RTE_BBDEV_OP_TURBO_DEC));
return dev->enqueue_enc_ops(q_data, ops, num_ops);
}
/**
* Enqueue a burst of processed decode operations to a queue of the device.
* This functions only enqueues as many operations as currently possible and
* does not block until @p num_ops entries in the queue are available.
* This function does not provide any error notification to avoid the
* corresponding overhead.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param ops
* Pointer array containing operations to be enqueued Must have at least
* @p num_ops entries
* @param num_ops
* The maximum number of operations to enqueue.
*
* @return
* The number of operations actually enqueued (this is the number of processed
* entries in the @p ops array).
*/
static inline uint16_t
rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_dec_op **ops, uint16_t num_ops)
{
struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
rte_bbdev_trace_enqueue(dev_id, queue_id, (void **)ops, num_ops,
rte_bbdev_op_type_str(RTE_BBDEV_OP_TURBO_ENC));
return dev->enqueue_dec_ops(q_data, ops, num_ops);
}
/**
* Enqueue a burst of processed encode operations to a queue of the device.
* This functions only enqueues as many operations as currently possible and
* does not block until @p num_ops entries in the queue are available.
* This function does not provide any error notification to avoid the
* corresponding overhead.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param ops
* Pointer array containing operations to be enqueued Must have at least
* @p num_ops entries
* @param num_ops
* The maximum number of operations to enqueue.
*
* @return
* The number of operations actually enqueued (this is the number of processed
* entries in the @p ops array).
*/
static inline uint16_t
rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_enc_op **ops, uint16_t num_ops)
{
struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
rte_bbdev_trace_enqueue(dev_id, queue_id, (void **)ops, num_ops,
rte_bbdev_op_type_str(RTE_BBDEV_OP_LDPC_ENC));
return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops);
}
/**
* Enqueue a burst of processed decode operations to a queue of the device.
* This functions only enqueues as many operations as currently possible and
* does not block until @p num_ops entries in the queue are available.
* This function does not provide any error notification to avoid the
* corresponding overhead.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param ops
* Pointer array containing operations to be enqueued Must have at least
* @p num_ops entries
* @param num_ops
* The maximum number of operations to enqueue.
*
* @return
* The number of operations actually enqueued (this is the number of processed
* entries in the @p ops array).
*/
static inline uint16_t
rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_dec_op **ops, uint16_t num_ops)
{
struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
rte_bbdev_trace_enqueue(dev_id, queue_id, (void **)ops, num_ops,
rte_bbdev_op_type_str(RTE_BBDEV_OP_LDPC_DEC));
return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops);
}
/**
* Enqueue a burst of FFT operations to a queue of the device.
* This functions only enqueues as many operations as currently possible and
* does not block until @p num_ops entries in the queue are available.
* This function does not provide any error notification to avoid the
* corresponding overhead.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param ops
* Pointer array containing operations to be enqueued.
* Must have at least @p num_ops entries.
* @param num_ops
* The maximum number of operations to enqueue.
*
* @return
* The number of operations actually enqueued.
* (This is the number of processed entries in the @p ops array.)
*/
static inline uint16_t
rte_bbdev_enqueue_fft_ops(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_fft_op **ops, uint16_t num_ops)
{
struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
rte_bbdev_trace_enqueue(dev_id, queue_id, (void **)ops, num_ops,
rte_bbdev_op_type_str(RTE_BBDEV_OP_FFT));
return dev->enqueue_fft_ops(q_data, ops, num_ops);
}
/**
* Enqueue a burst of MLDTS operations to a queue of the device.
* This functions only enqueues as many operations as currently possible and
* does not block until @p num_ops entries in the queue are available.
* This function does not provide any error notification to avoid the
* corresponding overhead.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param ops
* Pointer array containing operations to be enqueued Must have at least
* @p num_ops entries
* @param num_ops
* The maximum number of operations to enqueue.
*
* @return
* The number of operations actually enqueued (this is the number of processed
* entries in the @p ops array).
*/
static inline uint16_t
rte_bbdev_enqueue_mldts_ops(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_mldts_op **ops, uint16_t num_ops)
{
struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
rte_bbdev_trace_enqueue(dev_id, queue_id, (void **)ops, num_ops,
rte_bbdev_op_type_str(RTE_BBDEV_OP_MLDTS));
return dev->enqueue_mldts_ops(q_data, ops, num_ops);
}
/**
* Dequeue a burst of processed encode operations from a queue of the device.
* This functions returns only the current contents of the queue,
* and does not block until @ num_ops is available.
* This function does not provide any error notification to avoid the
* corresponding overhead.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param ops
* Pointer array where operations will be dequeued to.
* Must have at least @p num_ops entries, i.e.
* a pointer to a table of void * pointers (ops) that will be filled.
* @param num_ops
* The maximum number of operations to dequeue.
*
* @return
* The number of operations actually dequeued.
* (This is the number of entries copied into the @p ops array.)
*/
static inline uint16_t
rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_enc_op **ops, uint16_t num_ops)
{
struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
uint16_t num_ops_dequeued = dev->dequeue_enc_ops(q_data, ops, num_ops);
if (num_ops_dequeued > 0)
rte_bbdev_trace_dequeue(dev_id, queue_id, (void **)ops, num_ops,
num_ops_dequeued, rte_bbdev_op_type_str(RTE_BBDEV_OP_TURBO_ENC));
return num_ops_dequeued;
}
/**
* Dequeue a burst of processed decode operations from a queue of the device.
* This functions returns only the current contents of the queue, and does not
* block until @ num_ops is available.
* This function does not provide any error notification to avoid the
* corresponding overhead.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param ops
* Pointer array where operations will be dequeued to. Must have at least
* @p num_ops entries
* ie. A pointer to a table of void * pointers (ops) that will be filled.
* @param num_ops
* The maximum number of operations to dequeue.
*
* @return
* The number of operations actually dequeued (this is the number of entries
* copied into the @p ops array).
*/
static inline uint16_t
rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_dec_op **ops, uint16_t num_ops)
{
struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
uint16_t num_ops_dequeued = dev->dequeue_dec_ops(q_data, ops, num_ops);
if (num_ops_dequeued > 0)
rte_bbdev_trace_dequeue(dev_id, queue_id, (void **)ops, num_ops,
num_ops_dequeued, rte_bbdev_op_type_str(RTE_BBDEV_OP_TURBO_DEC));
return num_ops_dequeued;
}
/**
* Dequeue a burst of processed encode operations from a queue of the device.
* This functions returns only the current contents of the queue, and does not
* block until @ num_ops is available.
* This function does not provide any error notification to avoid the
* corresponding overhead.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param ops
* Pointer array where operations will be dequeued to. Must have at least
* @p num_ops entries
* @param num_ops
* The maximum number of operations to dequeue.
*
* @return
* The number of operations actually dequeued (this is the number of entries
* copied into the @p ops array).
*/
static inline uint16_t
rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_enc_op **ops, uint16_t num_ops)
{
struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
uint16_t num_ops_dequeued = dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);
if (num_ops_dequeued > 0)
rte_bbdev_trace_dequeue(dev_id, queue_id, (void **)ops, num_ops,
num_ops_dequeued, rte_bbdev_op_type_str(RTE_BBDEV_OP_LDPC_ENC));
return num_ops_dequeued;
}
/**
* Dequeue a burst of processed decode operations from a queue of the device.
* This functions returns only the current contents of the queue, and does not
* block until @ num_ops is available.
* This function does not provide any error notification to avoid the
* corresponding overhead.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param ops
* Pointer array where operations will be dequeued to. Must have at least
* @p num_ops entries
* @param num_ops
* The maximum number of operations to dequeue.
*
* @return
* The number of operations actually dequeued (this is the number of entries
* copied into the @p ops array).
*/
static inline uint16_t
rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_dec_op **ops, uint16_t num_ops)
{
struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
uint16_t num_ops_dequeued = dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops);
if (num_ops_dequeued > 0)
rte_bbdev_trace_dequeue(dev_id, queue_id, (void **)ops, num_ops,
num_ops_dequeued, rte_bbdev_op_type_str(RTE_BBDEV_OP_LDPC_DEC));
return num_ops_dequeued;
}
/**
* Dequeue a burst of FFT operations from a queue of the device.
* This functions returns only the current contents of the queue, and does not
* block until @ num_ops is available.
* This function does not provide any error notification to avoid the
* corresponding overhead.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param ops
* Pointer array where operations will be dequeued to. Must have at least
* @p num_ops entries
* @param num_ops
* The maximum number of operations to dequeue.
*
* @return
* The number of operations actually dequeued (this is the number of entries
* copied into the @p ops array).
*/
static inline uint16_t
rte_bbdev_dequeue_fft_ops(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_fft_op **ops, uint16_t num_ops)
{
struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
uint16_t num_ops_dequeued = dev->dequeue_fft_ops(q_data, ops, num_ops);
if (num_ops_dequeued > 0)
rte_bbdev_trace_dequeue(dev_id, queue_id, (void **)ops, num_ops,
num_ops_dequeued, rte_bbdev_op_type_str(RTE_BBDEV_OP_FFT));
return num_ops_dequeued;
}
/**
* Dequeue a burst of MLDTS operations from a queue of the device.
* This functions returns only the current contents of the queue, and does not
* block until @p num_ops is available.
* This function does not provide any error notification to avoid the
* corresponding overhead.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the queue.
* @param ops
* Pointer array where operations will be dequeued to. Must have at least
* @p num_ops entries
* @param num_ops
* The maximum number of operations to dequeue.
*
* @return
* The number of operations actually dequeued (this is the number of entries
* copied into the @p ops array).
*/
static inline uint16_t
rte_bbdev_dequeue_mldts_ops(uint16_t dev_id, uint16_t queue_id,
struct rte_bbdev_mldts_op **ops, uint16_t num_ops)
{
struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
uint16_t num_ops_dequeued = dev->dequeue_mldts_ops(q_data, ops, num_ops);
if (num_ops_dequeued > 0)
rte_bbdev_trace_dequeue(dev_id, queue_id, (void **)ops, num_ops,
num_ops_dequeued, rte_bbdev_op_type_str(RTE_BBDEV_OP_MLDTS));
return num_ops_dequeued;
}
/** Definitions of device event types */
enum rte_bbdev_event_type {
RTE_BBDEV_EVENT_UNKNOWN, /**< unknown event type */
RTE_BBDEV_EVENT_ERROR, /**< error interrupt event */
RTE_BBDEV_EVENT_DEQUEUE, /**< dequeue event */
RTE_BBDEV_EVENT_MAX /**< max value of this enum */
};
/**
* Typedef for application callback function registered by application
* software for notification of device events
*
* @param dev_id
* Device identifier
* @param event
* Device event to register for notification of.
* @param cb_arg
* User specified parameter to be passed to user's callback function.
* @param ret_param
* To pass data back to user application.
*/
typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
enum rte_bbdev_event_type event, void *cb_arg,
void *ret_param);
/**
* Register a callback function for specific device id. Multiple callbacks can
* be added and will be called in the order they are added when an event is
* triggered. Callbacks are called in a separate thread created by the DPDK EAL.
*
* @param dev_id
* Device id.
* @param event
* The event that the callback will be registered for.
* @param cb_fn
* User supplied callback function to be called.
* @param cb_arg
* Pointer to parameter that will be passed to the callback.
*
* @return
* Zero on success, negative value on failure.
*/
int
rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
rte_bbdev_cb_fn cb_fn, void *cb_arg);
/**
* Unregister a callback function for specific device id.
*
* @param dev_id
* The device identifier.
* @param event
* The event that the callback will be unregistered for.
* @param cb_fn
* User supplied callback function to be unregistered.
* @param cb_arg
* Pointer to the parameter supplied when registering the callback.
* (void *)-1 means to remove all registered callbacks with the specified
* function address.
*
* @return
* - 0 on success
* - EINVAL if invalid parameter pointer is provided
* - EAGAIN if the provided callback pointer does not exist
*/
int
rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
rte_bbdev_cb_fn cb_fn, void *cb_arg);
/**
* Enable a one-shot interrupt on the next operation enqueued to a particular
* queue. The interrupt will be triggered when the operation is ready to be
* dequeued. To handle the interrupt, an epoll file descriptor must be
* registered using rte_bbdev_queue_intr_ctl(), and then an application
* thread/lcore can wait for the interrupt using rte_epoll_wait().
*
* @param dev_id
* The device identifier.
* @param queue_id
* The index of the queue.
*
* @return
* - 0 on success
* - negative value on failure - as returned from PMD
*/
int
rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
/**
* Disable a one-shot interrupt on the next operation enqueued to a particular
* queue (if it has been enabled).
*
* @param dev_id
* The device identifier.
* @param queue_id
* The index of the queue.
*
* @return
* - 0 on success
* - negative value on failure - as returned from PMD
*/
int
rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
/**
* Control interface for per-queue interrupts.
*
* @param dev_id
* The device identifier.
* @param queue_id
* The index of the queue.
* @param epfd
* Epoll file descriptor that will be associated with the interrupt source.
* If the special value RTE_EPOLL_PER_THREAD is provided, a per thread epoll
* file descriptor created by the EAL is used (RTE_EPOLL_PER_THREAD can also
* be used when calling rte_epoll_wait()).
* @param op
* The operation be performed for the vector.RTE_INTR_EVENT_ADD or
* RTE_INTR_EVENT_DEL.
* @param data
* User context, that will be returned in the epdata.data field of the
* rte_epoll_event structure filled in by rte_epoll_wait().
*
* @return
* - 0 on success
* - ENOTSUP if interrupts are not supported by the identified device
* - negative value on failure - as returned from PMD
*/
int
rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
void *data);
/**
* Convert device status from enum to string.
*
* @param status
* Device status as enum.
*
* @returns
* Device status as string or NULL if invalid.
*/
const char*
rte_bbdev_device_status_str(enum rte_bbdev_device_status status);
/**
* Convert queue status from enum to string.
*
* @param status
* Queue status as enum.
*
* @returns
* Queue status as string or NULL if op_type is invalid.
*/
const char*
rte_bbdev_enqueue_status_str(enum rte_bbdev_enqueue_status status);
/**
* Dump operations info from device to a file.
* This API is used for debugging provided input operations, not a dataplane API.
*
* @param dev_id
* The device identifier.
*
* @param queue_index
* Index of queue.
*
* @param file
* A pointer to a file for output.
*
* @returns
* - 0 on success
* - ENOTSUP if interrupts are not supported by the identified device
* - negative value on failure - as returned from PMD
*
*/
__rte_experimental
int
rte_bbdev_queue_ops_dump(uint16_t dev_id, uint16_t queue_index, FILE *file);
/**
* String of parameters related to the parameters of an operation of a given type.
*
* @param op
* Pointer to an operation.
*
* @param op_type
* Operation type enum.
*
* @param str
* String being describing the operations.
*
* @param len
* Size of the string buffer.
*
* @returns
* String describing the provided operation.
*
*/
__rte_experimental
char *
rte_bbdev_ops_param_string(void *op, enum rte_bbdev_op_type op_type, char *str, uint32_t len);
/**
* Add a trace with detail of operation.
*
* @param op
* Pointer to an operation.
*
* @param op_type
* Operation type enum.
*
*/
__rte_experimental
void
rte_bbdev_ops_trace(void *op, enum rte_bbdev_op_type op_type);
#ifdef __cplusplus
}
#endif
#endif /* _RTE_BBDEV_H_ */
|