/
rte_eventdev.h
2030 lines (1926 loc) · 75.9 KB
/
rte_eventdev.h
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
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2016 Cavium, Inc.
* Copyright(c) 2016-2018 Intel Corporation.
* Copyright 2016 NXP
* All rights reserved.
*/
#ifndef _RTE_EVENTDEV_H_
#define _RTE_EVENTDEV_H_
/**
* @file
*
* RTE Event Device API
*
* In a polling model, lcores poll ethdev ports and associated rx queues
* directly to look for packet. In an event driven model, by contrast, lcores
* call the scheduler that selects packets for them based on programmer
* specified criteria. Eventdev library adds support for event driven
* programming model, which offer applications automatic multicore scaling,
* dynamic load balancing, pipelining, packet ingress order maintenance and
* synchronization services to simplify application packet processing.
*
* The Event Device API is composed of two parts:
*
* - The application-oriented Event API that includes functions to setup
* an event device (configure it, setup its queues, ports and start it), to
* establish the link between queues to port and to receive events, and so on.
*
* - The driver-oriented Event API that exports a function allowing
* an event poll Mode Driver (PMD) to simultaneously register itself as
* an event device driver.
*
* Event device components:
*
* +-----------------+
* | +-------------+ |
* +-------+ | | flow 0 | |
* |Packet | | +-------------+ |
* |event | | +-------------+ |
* | | | | flow 1 | |port_link(port0, queue0)
* +-------+ | +-------------+ | | +--------+
* +-------+ | +-------------+ o-----v-----o |dequeue +------+
* |Crypto | | | flow n | | | event +------->|Core 0|
* |work | | +-------------+ o----+ | port 0 | | |
* |done ev| | event queue 0 | | +--------+ +------+
* +-------+ +-----------------+ |
* +-------+ |
* |Timer | +-----------------+ | +--------+
* |expiry | | +-------------+ | +------o |dequeue +------+
* |event | | | flow 0 | o-----------o event +------->|Core 1|
* +-------+ | +-------------+ | +----o port 1 | | |
* Event enqueue | +-------------+ | | +--------+ +------+
* o-------------> | | flow 1 | | |
* enqueue( | +-------------+ | |
* queue_id, | | | +--------+ +------+
* flow_id, | +-------------+ | | | |dequeue |Core 2|
* sched_type, | | flow n | o-----------o event +------->| |
* event_type, | +-------------+ | | | port 2 | +------+
* subev_type, | event queue 1 | | +--------+
* event) +-----------------+ | +--------+
* | | |dequeue +------+
* +-------+ +-----------------+ | | event +------->|Core n|
* |Core | | +-------------+ o-----------o port n | | |
* |(SW) | | | flow 0 | | | +--------+ +--+---+
* |event | | +-------------+ | | |
* +-------+ | +-------------+ | | |
* ^ | | flow 1 | | | |
* | | +-------------+ o------+ |
* | | +-------------+ | |
* | | | flow n | | |
* | | +-------------+ | |
* | | event queue n | |
* | +-----------------+ |
* | |
* +-----------------------------------------------------------+
*
* Event device: A hardware or software-based event scheduler.
*
* Event: A unit of scheduling that encapsulates a packet or other datatype
* like SW generated event from the CPU, Crypto work completion notification,
* Timer expiry event notification etc as well as metadata.
* The metadata includes flow ID, scheduling type, event priority, event_type,
* sub_event_type etc.
*
* Event queue: A queue containing events that are scheduled by the event dev.
* An event queue contains events of different flows associated with scheduling
* types, such as atomic, ordered, or parallel.
*
* Event port: An application's interface into the event dev for enqueue and
* dequeue operations. Each event port can be linked with one or more
* event queues for dequeue operations.
*
* By default, all the functions of the Event Device API exported by a PMD
* are lock-free functions which assume to not be invoked in parallel on
* different logical cores to work on the same target object. For instance,
* the dequeue function of a PMD cannot be invoked in parallel on two logical
* cores to operates on same event port. Of course, this function
* can be invoked in parallel by different logical cores on different ports.
* It is the responsibility of the upper level application to enforce this rule.
*
* In all functions of the Event API, the Event device is
* designated by an integer >= 0 named the device identifier *dev_id*
*
* At the Event driver level, Event devices are represented by a generic
* data structure of type *rte_event_dev*.
*
* Event devices are dynamically registered during the PCI/SoC device probing
* phase performed at EAL initialization time.
* When an Event device is being probed, a *rte_event_dev* structure and
* a new device identifier are allocated for that device. Then, the
* event_dev_init() function supplied by the Event driver matching the probed
* device is invoked to properly initialize the device.
*
* The role of the device init function consists of resetting the hardware or
* software event driver implementations.
*
* If the device init operation is successful, the correspondence between
* the device identifier assigned to the new device and its associated
* *rte_event_dev* structure is effectively registered.
* Otherwise, both the *rte_event_dev* structure and the device identifier are
* freed.
*
* The functions exported by the application Event API to setup a device
* designated by its device identifier must be invoked in the following order:
* - rte_event_dev_configure()
* - rte_event_queue_setup()
* - rte_event_port_setup()
* - rte_event_port_link()
* - rte_event_dev_start()
*
* Then, the application can invoke, in any order, the functions
* exported by the Event API to schedule events, dequeue events, enqueue events,
* change event queue(s) to event port [un]link establishment and so on.
*
* Application may use rte_event_[queue/port]_default_conf_get() to get the
* default configuration to set up an event queue or event port by
* overriding few default values.
*
* If the application wants to change the configuration (i.e. call
* rte_event_dev_configure(), rte_event_queue_setup(), or
* rte_event_port_setup()), it must call rte_event_dev_stop() first to stop the
* device and then do the reconfiguration before calling rte_event_dev_start()
* again. The schedule, enqueue and dequeue functions should not be invoked
* when the device is stopped.
*
* Finally, an application can close an Event device by invoking the
* rte_event_dev_close() function.
*
* Each function of the application Event API invokes a specific function
* of the PMD that controls the target device designated by its device
* identifier.
*
* For this purpose, all device-specific functions of an Event driver are
* supplied through a set of pointers contained in a generic structure of type
* *event_dev_ops*.
* The address of the *event_dev_ops* structure is stored in the *rte_event_dev*
* structure by the device init function of the Event driver, which is
* invoked during the PCI/SoC device probing phase, as explained earlier.
*
* In other words, each function of the Event API simply retrieves the
* *rte_event_dev* structure associated with the device identifier and
* performs an indirect invocation of the corresponding driver function
* supplied in the *event_dev_ops* structure of the *rte_event_dev* structure.
*
* For performance reasons, the address of the fast-path functions of the
* Event driver is not contained in the *event_dev_ops* structure.
* Instead, they are directly stored at the beginning of the *rte_event_dev*
* structure to avoid an extra indirect memory access during their invocation.
*
* RTE event device drivers do not use interrupts for enqueue or dequeue
* operation. Instead, Event drivers export Poll-Mode enqueue and dequeue
* functions to applications.
*
* The events are injected to event device through *enqueue* operation by
* event producers in the system. The typical event producers are ethdev
* subsystem for generating packet events, CPU(SW) for generating events based
* on different stages of application processing, cryptodev for generating
* crypto work completion notification etc
*
* The *dequeue* operation gets one or more events from the event ports.
* The application process the events and send to downstream event queue through
* rte_event_enqueue_burst() if it is an intermediate stage of event processing,
* on the final stage, the application may use Tx adapter API for maintaining
* the ingress order and then send the packet/event on the wire.
*
* The point at which events are scheduled to ports depends on the device.
* For hardware devices, scheduling occurs asynchronously without any software
* intervention. Software schedulers can either be distributed
* (each worker thread schedules events to its own port) or centralized
* (a dedicated thread schedules to all ports). Distributed software schedulers
* perform the scheduling in rte_event_dequeue_burst(), whereas centralized
* scheduler logic need a dedicated service core for scheduling.
* The RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED capability flag is not set
* indicates the device is centralized and thus needs a dedicated scheduling
* thread that repeatedly calls software specific scheduling function.
*
* An event driven worker thread has following typical workflow on fastpath:
* \code{.c}
* while (1) {
* rte_event_dequeue_burst(...);
* (event processing)
* rte_event_enqueue_burst(...);
* }
* \endcode
*
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <rte_common.h>
#include <rte_config.h>
#include <rte_memory.h>
#include <rte_errno.h>
#include "rte_eventdev_trace_fp.h"
struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
struct rte_event;
/* Event device capability bitmap flags */
#define RTE_EVENT_DEV_CAP_QUEUE_QOS (1ULL << 0)
/**< Event scheduling prioritization is based on the priority associated with
* each event queue.
*
* @see rte_event_queue_setup()
*/
#define RTE_EVENT_DEV_CAP_EVENT_QOS (1ULL << 1)
/**< Event scheduling prioritization is based on the priority associated with
* each event. Priority of each event is supplied in *rte_event* structure
* on each enqueue operation.
*
* @see rte_event_enqueue_burst()
*/
#define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED (1ULL << 2)
/**< Event device operates in distributed scheduling mode.
* In distributed scheduling mode, event scheduling happens in HW or
* rte_event_dequeue_burst() or the combination of these two.
* If the flag is not set then eventdev is centralized and thus needs a
* dedicated service core that acts as a scheduling thread .
*
* @see rte_event_dequeue_burst()
*/
#define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES (1ULL << 3)
/**< Event device is capable of enqueuing events of any type to any queue.
* If this capability is not set, the queue only supports events of the
* *RTE_SCHED_TYPE_* type that it was created with.
*
* @see RTE_SCHED_TYPE_* values
*/
#define RTE_EVENT_DEV_CAP_BURST_MODE (1ULL << 4)
/**< Event device is capable of operating in burst mode for enqueue(forward,
* release) and dequeue operation. If this capability is not set, application
* still uses the rte_event_dequeue_burst() and rte_event_enqueue_burst() but
* PMD accepts only one event at a time.
*
* @see rte_event_dequeue_burst() rte_event_enqueue_burst()
*/
#define RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE (1ULL << 5)
/**< Event device ports support disabling the implicit release feature, in
* which the port will release all unreleased events in its dequeue operation.
* If this capability is set and the port is configured with implicit release
* disabled, the application is responsible for explicitly releasing events
* using either the RTE_EVENT_OP_FORWARD or the RTE_EVENT_OP_RELEASE event
* enqueue operations.
*
* @see rte_event_dequeue_burst() rte_event_enqueue_burst()
*/
#define RTE_EVENT_DEV_CAP_NONSEQ_MODE (1ULL << 6)
/**< Event device is capable of operating in none sequential mode. The path
* of the event is not necessary to be sequential. Application can change
* the path of event at runtime. If the flag is not set, then event each event
* will follow a path from queue 0 to queue 1 to queue 2 etc. If the flag is
* set, events may be sent to queues in any order. If the flag is not set, the
* eventdev will return an error when the application enqueues an event for a
* qid which is not the next in the sequence.
*/
#define RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK (1ULL << 7)
/**< Event device is capable of configuring the queue/port link at runtime.
* If the flag is not set, the eventdev queue/port link is only can be
* configured during initialization.
*/
#define RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT (1ULL << 8)
/**< Event device is capable of setting up the link between multiple queue
* with single port. If the flag is not set, the eventdev can only map a
* single queue to each port or map a single queue to many port.
*/
#define RTE_EVENT_DEV_CAP_CARRY_FLOW_ID (1ULL << 9)
/**< Event device preserves the flow ID from the enqueued
* event to the dequeued event if the flag is set. Otherwise,
* the content of this field is implementation dependent.
*/
/* Event device priority levels */
#define RTE_EVENT_DEV_PRIORITY_HIGHEST 0
/**< Highest priority expressed across eventdev subsystem
* @see rte_event_queue_setup(), rte_event_enqueue_burst()
* @see rte_event_port_link()
*/
#define RTE_EVENT_DEV_PRIORITY_NORMAL 128
/**< Normal priority expressed across eventdev subsystem
* @see rte_event_queue_setup(), rte_event_enqueue_burst()
* @see rte_event_port_link()
*/
#define RTE_EVENT_DEV_PRIORITY_LOWEST 255
/**< Lowest priority expressed across eventdev subsystem
* @see rte_event_queue_setup(), rte_event_enqueue_burst()
* @see rte_event_port_link()
*/
/**
* Get the total number of event devices that have been successfully
* initialised.
*
* @return
* The total number of usable event devices.
*/
uint8_t
rte_event_dev_count(void);
/**
* Get the device identifier for the named event device.
*
* @param name
* Event device name to select the event device identifier.
*
* @return
* Returns event device identifier on success.
* - <0: Failure to find named event device.
*/
int
rte_event_dev_get_dev_id(const char *name);
/**
* Return the NUMA socket to which a device is connected.
*
* @param dev_id
* The identifier of the device.
* @return
* The NUMA socket id to which the device is connected or
* a default of zero if the socket could not be determined.
* -(-EINVAL) dev_id value is out of range.
*/
int
rte_event_dev_socket_id(uint8_t dev_id);
/**
* Event device information
*/
struct rte_event_dev_info {
const char *driver_name; /**< Event driver name */
struct rte_device *dev; /**< Device information */
uint32_t min_dequeue_timeout_ns;
/**< Minimum supported global dequeue timeout(ns) by this device */
uint32_t max_dequeue_timeout_ns;
/**< Maximum supported global dequeue timeout(ns) by this device */
uint32_t dequeue_timeout_ns;
/**< Configured global dequeue timeout(ns) for this device */
uint8_t max_event_queues;
/**< Maximum event_queues supported by this device */
uint32_t max_event_queue_flows;
/**< Maximum supported flows in an event queue by this device*/
uint8_t max_event_queue_priority_levels;
/**< Maximum number of event queue priority levels by this device.
* Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
*/
uint8_t max_event_priority_levels;
/**< Maximum number of event priority levels by this device.
* Valid when the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability
*/
uint8_t max_event_ports;
/**< Maximum number of event ports supported by this device */
uint8_t max_event_port_dequeue_depth;
/**< Maximum number of events can be dequeued at a time from an
* event port by this device.
* A device that does not support bulk dequeue will set this as 1.
*/
uint32_t max_event_port_enqueue_depth;
/**< Maximum number of events can be enqueued at a time from an
* event port by this device.
* A device that does not support bulk enqueue will set this as 1.
*/
uint8_t max_event_port_links;
/**< Maximum number of queues that can be linked to a single event
* port by this device.
*/
int32_t max_num_events;
/**< A *closed system* event dev has a limit on the number of events it
* can manage at a time. An *open system* event dev does not have a
* limit and will specify this as -1.
*/
uint32_t event_dev_cap;
/**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
uint8_t max_single_link_event_port_queue_pairs;
/**< Maximum number of event ports and queues that are optimized for
* (and only capable of) single-link configurations supported by this
* device. These ports and queues are not accounted for in
* max_event_ports or max_event_queues.
*/
};
/**
* Retrieve the contextual information of an event device.
*
* @param dev_id
* The identifier of the device.
*
* @param[out] dev_info
* A pointer to a structure of type *rte_event_dev_info* to be filled with the
* contextual information of the device.
*
* @return
* - 0: Success, driver updates the contextual information of the event device
* - <0: Error code returned by the driver info get function.
*
*/
int
rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info);
/**
* The count of ports.
*/
#define RTE_EVENT_DEV_ATTR_PORT_COUNT 0
/**
* The count of queues.
*/
#define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1
/**
* The status of the device, zero for stopped, non-zero for started.
*/
#define RTE_EVENT_DEV_ATTR_STARTED 2
/**
* Get an attribute from a device.
*
* @param dev_id Eventdev id
* @param attr_id The attribute ID to retrieve
* @param[out] attr_value A pointer that will be filled in with the attribute
* value if successful.
*
* @return
* - 0: Successfully retrieved attribute value
* - -EINVAL: Invalid device or *attr_id* provided, or *attr_value* is NULL
*/
int
rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
uint32_t *attr_value);
/* Event device configuration bitmap flags */
#define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0)
/**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns.
* @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst()
*/
/** Event device configuration structure */
struct rte_event_dev_config {
uint32_t dequeue_timeout_ns;
/**< rte_event_dequeue_burst() timeout on this device.
* This value should be in the range of *min_dequeue_timeout_ns* and
* *max_dequeue_timeout_ns* which previously provided in
* rte_event_dev_info_get()
* The value 0 is allowed, in which case, default dequeue timeout used.
* @see RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT
*/
int32_t nb_events_limit;
/**< In a *closed system* this field is the limit on maximum number of
* events that can be inflight in the eventdev at a given time. The
* limit is required to ensure that the finite space in a closed system
* is not overwhelmed. The value cannot exceed the *max_num_events*
* as provided by rte_event_dev_info_get().
* This value should be set to -1 for *open system*.
*/
uint8_t nb_event_queues;
/**< Number of event queues to configure on this device.
* This value cannot exceed the *max_event_queues* which previously
* provided in rte_event_dev_info_get()
*/
uint8_t nb_event_ports;
/**< Number of event ports to configure on this device.
* This value cannot exceed the *max_event_ports* which previously
* provided in rte_event_dev_info_get()
*/
uint32_t nb_event_queue_flows;
/**< Number of flows for any event queue on this device.
* This value cannot exceed the *max_event_queue_flows* which previously
* provided in rte_event_dev_info_get()
*/
uint32_t nb_event_port_dequeue_depth;
/**< Maximum number of events can be dequeued at a time from an
* event port by this device.
* This value cannot exceed the *max_event_port_dequeue_depth*
* which previously provided in rte_event_dev_info_get().
* Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
* @see rte_event_port_setup()
*/
uint32_t nb_event_port_enqueue_depth;
/**< Maximum number of events can be enqueued at a time from an
* event port by this device.
* This value cannot exceed the *max_event_port_enqueue_depth*
* which previously provided in rte_event_dev_info_get().
* Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
* @see rte_event_port_setup()
*/
uint32_t event_dev_cfg;
/**< Event device config flags(RTE_EVENT_DEV_CFG_)*/
uint8_t nb_single_link_event_port_queues;
/**< Number of event ports and queues that will be singly-linked to
* each other. These are a subset of the overall event ports and
* queues; this value cannot exceed *nb_event_ports* or
* *nb_event_queues*. If the device has ports and queues that are
* optimized for single-link usage, this field is a hint for how many
* to allocate; otherwise, regular event ports and queues can be used.
*/
};
/**
* Configure an event device.
*
* This function must be invoked first before any other function in the
* API. This function can also be re-invoked when a device is in the
* stopped state.
*
* The caller may use rte_event_dev_info_get() to get the capability of each
* resources available for this event device.
*
* @param dev_id
* The identifier of the device to configure.
* @param dev_conf
* The event device configuration structure.
*
* @return
* - 0: Success, device configured.
* - <0: Error code returned by the driver configuration function.
*/
int
rte_event_dev_configure(uint8_t dev_id,
const struct rte_event_dev_config *dev_conf);
/* Event queue specific APIs */
/* Event queue configuration bitmap flags */
#define RTE_EVENT_QUEUE_CFG_ALL_TYPES (1ULL << 0)
/**< Allow ATOMIC,ORDERED,PARALLEL schedule type enqueue
*
* @see RTE_SCHED_TYPE_ORDERED, RTE_SCHED_TYPE_ATOMIC, RTE_SCHED_TYPE_PARALLEL
* @see rte_event_enqueue_burst()
*/
#define RTE_EVENT_QUEUE_CFG_SINGLE_LINK (1ULL << 1)
/**< This event queue links only to a single event port.
*
* @see rte_event_port_setup(), rte_event_port_link()
*/
/** Event queue configuration structure */
struct rte_event_queue_conf {
uint32_t nb_atomic_flows;
/**< The maximum number of active flows this queue can track at any
* given time. If the queue is configured for atomic scheduling (by
* applying the RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg
* or RTE_SCHED_TYPE_ATOMIC flag to schedule_type), then the
* value must be in the range of [1, nb_event_queue_flows], which was
* previously provided in rte_event_dev_configure().
*/
uint32_t nb_atomic_order_sequences;
/**< The maximum number of outstanding events waiting to be
* reordered by this queue. In other words, the number of entries in
* this queue’s reorder buffer.When the number of events in the
* reorder buffer reaches to *nb_atomic_order_sequences* then the
* scheduler cannot schedule the events from this queue and invalid
* event will be returned from dequeue until one or more entries are
* freed up/released.
* If the queue is configured for ordered scheduling (by applying the
* RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg or
* RTE_SCHED_TYPE_ORDERED flag to schedule_type), then the value must
* be in the range of [1, nb_event_queue_flows], which was
* previously supplied to rte_event_dev_configure().
*/
uint32_t event_queue_cfg;
/**< Queue cfg flags(EVENT_QUEUE_CFG_) */
uint8_t schedule_type;
/**< Queue schedule type(RTE_SCHED_TYPE_*).
* Valid when RTE_EVENT_QUEUE_CFG_ALL_TYPES bit is not set in
* event_queue_cfg.
*/
uint8_t priority;
/**< Priority for this event queue relative to other event queues.
* The requested priority should in the range of
* [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST].
* The implementation shall normalize the requested priority to
* event device supported priority value.
* Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability
*/
};
/**
* Retrieve the default configuration information of an event queue designated
* by its *queue_id* from the event driver for an event device.
*
* This function intended to be used in conjunction with rte_event_queue_setup()
* where caller needs to set up the queue by overriding few default values.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the event queue to get the configuration information.
* The value must be in the range [0, nb_event_queues - 1]
* previously supplied to rte_event_dev_configure().
* @param[out] queue_conf
* The pointer to the default event queue configuration data.
* @return
* - 0: Success, driver updates the default event queue configuration data.
* - <0: Error code returned by the driver info get function.
*
* @see rte_event_queue_setup()
*
*/
int
rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
struct rte_event_queue_conf *queue_conf);
/**
* Allocate and set up an event queue for an event device.
*
* @param dev_id
* The identifier of the device.
* @param queue_id
* The index of the event queue to setup. The value must be in the range
* [0, nb_event_queues - 1] previously supplied to rte_event_dev_configure().
* @param queue_conf
* The pointer to the configuration data to be used for the event queue.
* NULL value is allowed, in which case default configuration used.
*
* @see rte_event_queue_default_conf_get()
*
* @return
* - 0: Success, event queue correctly set up.
* - <0: event queue configuration failed
*/
int
rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
const struct rte_event_queue_conf *queue_conf);
/**
* The priority of the queue.
*/
#define RTE_EVENT_QUEUE_ATTR_PRIORITY 0
/**
* The number of atomic flows configured for the queue.
*/
#define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS 1
/**
* The number of atomic order sequences configured for the queue.
*/
#define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES 2
/**
* The cfg flags for the queue.
*/
#define RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG 3
/**
* The schedule type of the queue.
*/
#define RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE 4
/**
* Get an attribute from a queue.
*
* @param dev_id
* Eventdev id
* @param queue_id
* Eventdev queue id
* @param attr_id
* The attribute ID to retrieve
* @param[out] attr_value
* A pointer that will be filled in with the attribute value if successful
*
* @return
* - 0: Successfully returned value
* - -EINVAL: invalid device, queue or attr_id provided, or attr_value was
* NULL
* - -EOVERFLOW: returned when attr_id is set to
* RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE and event_queue_cfg is set to
* RTE_EVENT_QUEUE_CFG_ALL_TYPES
*/
int
rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
uint32_t *attr_value);
/* Event port specific APIs */
/* Event port configuration bitmap flags */
#define RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL (1ULL << 0)
/**< Configure the port not to release outstanding events in
* rte_event_dev_dequeue_burst(). If set, all events received through
* the port must be explicitly released with RTE_EVENT_OP_RELEASE or
* RTE_EVENT_OP_FORWARD. Must be unset if the device is not
* RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE capable.
*/
#define RTE_EVENT_PORT_CFG_SINGLE_LINK (1ULL << 1)
/**< This event port links only to a single event queue.
*
* @see rte_event_port_setup(), rte_event_port_link()
*/
/** Event port configuration structure */
struct rte_event_port_conf {
int32_t new_event_threshold;
/**< A backpressure threshold for new event enqueues on this port.
* Use for *closed system* event dev where event capacity is limited,
* and cannot exceed the capacity of the event dev.
* Configuring ports with different thresholds can make higher priority
* traffic less likely to be backpressured.
* For example, a port used to inject NIC Rx packets into the event dev
* can have a lower threshold so as not to overwhelm the device,
* while ports used for worker pools can have a higher threshold.
* This value cannot exceed the *nb_events_limit*
* which was previously supplied to rte_event_dev_configure().
* This should be set to '-1' for *open system*.
*/
uint16_t dequeue_depth;
/**< Configure number of bulk dequeues for this event port.
* This value cannot exceed the *nb_event_port_dequeue_depth*
* which previously supplied to rte_event_dev_configure().
* Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
*/
uint16_t enqueue_depth;
/**< Configure number of bulk enqueues for this event port.
* This value cannot exceed the *nb_event_port_enqueue_depth*
* which previously supplied to rte_event_dev_configure().
* Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable.
*/
uint32_t event_port_cfg; /**< Port cfg flags(EVENT_PORT_CFG_) */
};
/**
* Retrieve the default configuration information of an event port designated
* by its *port_id* from the event driver for an event device.
*
* This function intended to be used in conjunction with rte_event_port_setup()
* where caller needs to set up the port by overriding few default values.
*
* @param dev_id
* The identifier of the device.
* @param port_id
* The index of the event port to get the configuration information.
* The value must be in the range [0, nb_event_ports - 1]
* previously supplied to rte_event_dev_configure().
* @param[out] port_conf
* The pointer to the default event port configuration data
* @return
* - 0: Success, driver updates the default event port configuration data.
* - <0: Error code returned by the driver info get function.
*
* @see rte_event_port_setup()
*
*/
int
rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
struct rte_event_port_conf *port_conf);
/**
* Allocate and set up an event port for an event device.
*
* @param dev_id
* The identifier of the device.
* @param port_id
* The index of the event port to setup. The value must be in the range
* [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure().
* @param port_conf
* The pointer to the configuration data to be used for the queue.
* NULL value is allowed, in which case default configuration used.
*
* @see rte_event_port_default_conf_get()
*
* @return
* - 0: Success, event port correctly set up.
* - <0: Port configuration failed
* - (-EDQUOT) Quota exceeded(Application tried to link the queue configured
* with RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports)
*/
int
rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
const struct rte_event_port_conf *port_conf);
/**
* The queue depth of the port on the enqueue side
*/
#define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0
/**
* The queue depth of the port on the dequeue side
*/
#define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1
/**
* The new event threshold of the port
*/
#define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2
/**
* The implicit release disable attribute of the port
*/
#define RTE_EVENT_PORT_ATTR_IMPLICIT_RELEASE_DISABLE 3
/**
* Get an attribute from a port.
*
* @param dev_id
* Eventdev id
* @param port_id
* Eventdev port id
* @param attr_id
* The attribute ID to retrieve
* @param[out] attr_value
* A pointer that will be filled in with the attribute value if successful
*
* @return
* - 0: Successfully returned value
* - (-EINVAL) Invalid device, port or attr_id, or attr_value was NULL
*/
int
rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
uint32_t *attr_value);
/**
* Start an event device.
*
* The device start step is the last one and consists of setting the event
* queues to start accepting the events and schedules to event ports.
*
* On success, all basic functions exported by the API (event enqueue,
* event dequeue and so on) can be invoked.
*
* @param dev_id
* Event device identifier
* @return
* - 0: Success, device started.
* - -ESTALE : Not all ports of the device are configured
* - -ENOLINK: Not all queues are linked, which could lead to deadlock.
*/
int
rte_event_dev_start(uint8_t dev_id);
/**
* Stop an event device.
*
* This function causes all queued events to be drained, including those
* residing in event ports. While draining events out of the device, this
* function calls the user-provided flush callback (if one was registered) once
* per event.
*
* The device can be restarted with a call to rte_event_dev_start(). Threads
* that continue to enqueue/dequeue while the device is stopped, or being
* stopped, will result in undefined behavior. This includes event adapters,
* which must be stopped prior to stopping the eventdev.
*
* @param dev_id
* Event device identifier.
*
* @see rte_event_dev_stop_flush_callback_register()
*/
void
rte_event_dev_stop(uint8_t dev_id);
typedef void (*eventdev_stop_flush_t)(uint8_t dev_id, struct rte_event event,
void *arg);
/**< Callback function called during rte_event_dev_stop(), invoked once per
* flushed event.
*/
/**
* Registers a callback function to be invoked during rte_event_dev_stop() for
* each flushed event. This function can be used to properly dispose of queued
* events, for example events containing memory pointers.
*
* The callback function is only registered for the calling process. The
* callback function must be registered in every process that can call
* rte_event_dev_stop().
*
* To unregister a callback, call this function with a NULL callback pointer.
*
* @param dev_id
* The identifier of the device.
* @param callback
* Callback function invoked once per flushed event.
* @param userdata
* Argument supplied to callback.
*
* @return
* - 0 on success.
* - -EINVAL if *dev_id* is invalid
*
* @see rte_event_dev_stop()
*/
int
rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
eventdev_stop_flush_t callback, void *userdata);
/**
* Close an event device. The device cannot be restarted!
*
* @param dev_id
* Event device identifier
*
* @return
* - 0 on successfully closing device
* - <0 on failure to close device
* - (-EAGAIN) if device is busy
*/
int
rte_event_dev_close(uint8_t dev_id);
/* Scheduler type definitions */
#define RTE_SCHED_TYPE_ORDERED 0
/**< Ordered scheduling
*
* Events from an ordered flow of an event queue can be scheduled to multiple
* ports for concurrent processing while maintaining the original event order.
* This scheme enables the user to achieve high single flow throughput by
* avoiding SW synchronization for ordering between ports which bound to cores.
*
* The source flow ordering from an event queue is maintained when events are
* enqueued to their destination queue within the same ordered flow context.
* An event port holds the context until application call
* rte_event_dequeue_burst() from the same port, which implicitly releases
* the context.
* User may allow the scheduler to release the context earlier than that
* by invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE operation.
*
* Events from the source queue appear in their original order when dequeued
* from a destination queue.
* Event ordering is based on the received event(s), but also other
* (newly allocated or stored) events are ordered when enqueued within the same
* ordered context. Events not enqueued (e.g. released or stored) within the
* context are considered missing from reordering and are skipped at this time
* (but can be ordered again within another context).
*
* @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
*/
#define RTE_SCHED_TYPE_ATOMIC 1
/**< Atomic scheduling
*
* Events from an atomic flow of an event queue can be scheduled only to a
* single port at a time. The port is guaranteed to have exclusive (atomic)
* access to the associated flow context, which enables the user to avoid SW
* synchronization. Atomic flows also help to maintain event ordering
* since only one port at a time can process events from a flow of an
* event queue.
*
* The atomic queue synchronization context is dedicated to the port until
* application call rte_event_dequeue_burst() from the same port,
* which implicitly releases the context. User may allow the scheduler to
* release the context earlier than that by invoking rte_event_enqueue_burst()
* with RTE_EVENT_OP_RELEASE operation.
*
* @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE
*/
#define RTE_SCHED_TYPE_PARALLEL 2
/**< Parallel scheduling
*
* The scheduler performs priority scheduling, load balancing, etc. functions
* but does not provide additional event synchronization or ordering.
* It is free to schedule events from a single parallel flow of an event queue
* to multiple events ports for concurrent processing.
* The application is responsible for flow context synchronization and
* event ordering (SW synchronization).
*
* @see rte_event_queue_setup(), rte_event_dequeue_burst()
*/
/* Event types to classify the event source */
#define RTE_EVENT_TYPE_ETHDEV 0x0
/**< The event generated from ethdev subsystem */
#define RTE_EVENT_TYPE_CRYPTODEV 0x1
/**< The event generated from crypodev subsystem */
#define RTE_EVENT_TYPE_TIMER 0x2
/**< The event generated from event timer adapter */
#define RTE_EVENT_TYPE_CPU 0x3
/**< The event generated from cpu for pipelining.
* Application may use *sub_event_type* to further classify the event
*/
#define RTE_EVENT_TYPE_ETH_RX_ADAPTER 0x4
/**< The event generated from event eth Rx adapter */
#define RTE_EVENT_TYPE_MAX 0x10
/**< Maximum number of event types */
/* Event enqueue operations */
#define RTE_EVENT_OP_NEW 0
/**< The event producers use this operation to inject a new event to the
* event device.
*/
#define RTE_EVENT_OP_FORWARD 1
/**< The CPU use this operation to forward the event to different event queue or
* change to new application specific flow or schedule type to enable
* pipelining.