8d5e48033604e21ef5023846ef0b7fd6a62cc019
[vpp.git] / src / svm / svm_fifo.h
1 /*
2  * Copyright (c) 2016-2019 Cisco and/or its affiliates.
3  * Copyright (c) 2019 Arm Limited
4  * Copyright (c) 2010-2017 Intel Corporation and/or its affiliates.
5  * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org
6  * Inspired from DPDK rte_ring.h (SPSC only) (derived from freebsd bufring.h).
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at:
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 #ifndef __included_ssvm_fifo_h__
20 #define __included_ssvm_fifo_h__
21
22 #include <vppinfra/clib.h>
23 #include <vppinfra/vec.h>
24 #include <vppinfra/pool.h>
25 #include <vppinfra/format.h>
26 #include <svm/fifo_types.h>
27
28 #define OOO_SEGMENT_INVALID_INDEX       ((u32)~0)
29 #define SVM_FIFO_INVALID_SESSION_INDEX  ((u32)~0)
30 #define SVM_FIFO_INVALID_INDEX          ((u32)~0)
31
32 typedef enum svm_fifo_deq_ntf_
33 {
34   SVM_FIFO_NO_DEQ_NOTIF = 0,            /**< No notification requested */
35   SVM_FIFO_WANT_DEQ_NOTIF = 1,          /**< Notify on dequeue */
36   SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL = 2,  /**< Notify on transition from full */
37   SVM_FIFO_WANT_DEQ_NOTIF_IF_EMPTY = 4, /**< Notify on transition to empty */
38 } svm_fifo_deq_ntf_t;
39
40 typedef enum svm_fifo_flag_
41 {
42   SVM_FIFO_F_LL_TRACKED = 1 << 0,
43 } svm_fifo_flag_t;
44
45 typedef enum
46 {
47   SVM_FIFO_EFULL = -2,
48   SVM_FIFO_EEMPTY = -3,
49   SVM_FIFO_EGROW = -4,
50 } svm_fifo_err_t;
51
52 typedef struct svm_fifo_seg_
53 {
54   u8 *data;
55   u32 len;
56 } svm_fifo_seg_t;
57
58 #if SVM_FIFO_TRACE
59 #define svm_fifo_trace_add(_f, _s, _l, _t)              \
60 {                                                       \
61   svm_fifo_trace_elem_t *trace_elt;                     \
62   vec_add2(_f->trace, trace_elt, 1);                    \
63   trace_elt->offset = _s;                               \
64   trace_elt->len = _l;                                  \
65   trace_elt->action = _t;                               \
66 }
67 #else
68 #define svm_fifo_trace_add(_f, _s, _l, _t)
69 #endif
70
71 u8 *svm_fifo_dump_trace (u8 * s, svm_fifo_t * f);
72 u8 *svm_fifo_replay (u8 * s, svm_fifo_t * f, u8 no_read, u8 verbose);
73
74 /**
75  * Load head and tail optimized for consumer
76  *
77  * Internal function.
78  */
79 static inline void
80 f_load_head_tail_cons (svm_fifo_t * f, u32 * head, u32 * tail)
81 {
82   /* load-relaxed: consumer owned index */
83   *head = f->head;
84   /* load-acq: consumer foreign index (paired with store-rel in producer) */
85   *tail = clib_atomic_load_acq_n (&f->tail);
86 }
87
88 /** Load head and tail optimized for producer
89  *
90  * Internal function
91  */
92 static inline void
93 f_load_head_tail_prod (svm_fifo_t * f, u32 * head, u32 * tail)
94 {
95   /* load relaxed: producer owned index */
96   *tail = f->tail;
97   /* load-acq: producer foreign index (paired with store-rel in consumer) */
98   *head = clib_atomic_load_acq_n (&f->head);
99 }
100
101 /**
102  * Load head and tail independent of producer/consumer role
103  *
104  * Internal function.
105  */
106 static inline void
107 f_load_head_tail_all_acq (svm_fifo_t * f, u32 * head, u32 * tail)
108 {
109   /* load-acq : consumer foreign index (paired with store-rel) */
110   *tail = clib_atomic_load_acq_n (&f->tail);
111   /* load-acq : producer foriegn index (paired with store-rel) */
112   *head = clib_atomic_load_acq_n (&f->head);
113 }
114
115 /**
116  * Fifo current size, i.e., number of bytes enqueued
117  *
118  * Internal function.
119  */
120 static inline u32
121 f_cursize (svm_fifo_t * f, u32 head, u32 tail)
122 {
123   return tail - head;
124 }
125
126 /**
127  * Fifo free bytes, i.e., number of free bytes
128  *
129  * Internal function
130  */
131 static inline u32
132 f_free_count (svm_fifo_t * f, u32 head, u32 tail)
133 {
134   return (f->size - f_cursize (f, head, tail));
135 }
136
137 always_inline u32
138 f_chunk_end (svm_fifo_chunk_t * c)
139 {
140   return c->start_byte + c->length;
141 }
142
143 always_inline int
144 f_pos_lt (u32 a, u32 b)
145 {
146   return ((i32) (a - b) < 0);
147 }
148
149 always_inline int
150 f_pos_leq (u32 a, u32 b)
151 {
152   return ((i32) (a - b) <= 0);
153 }
154
155 always_inline int
156 f_pos_gt (u32 a, u32 b)
157 {
158   return ((i32) (a - b) > 0);
159 }
160
161 always_inline int
162 f_pos_geq (u32 a, u32 b)
163 {
164   return ((i32) (a - b) >= 0);
165 }
166
167 always_inline u8
168 f_chunk_includes_pos (svm_fifo_chunk_t * c, u32 pos)
169 {
170   return (f_pos_geq (pos, c->start_byte)
171           && f_pos_lt (pos, c->start_byte + c->length));
172 }
173
174 /**
175  * Create fifo of requested size
176  *
177  * Allocates fifo on current heap.
178  *
179  * @param size          data size in bytes for fifo to be allocated. Will be
180  *                      rounded to the next highest power-of-two value.
181  * @return              pointer to new fifo
182  */
183 svm_fifo_t *svm_fifo_alloc (u32 size);
184 /**
185  * Initialize fifo
186  *
187  * @param f             fifo
188  * @param size          size for fifo
189  */
190 void svm_fifo_init (svm_fifo_t * f, u32 size);
191 /**
192  * Allocate a fifo chunk on heap
193  *
194  * If the chunk is allocated on a fifo segment, this should be called
195  * with the segment's heap pushed.
196  *
197  * @param size  chunk size in bytes. Will be rounded to the next highest
198  *              power-of-two
199  * @return      new chunk or 0 if alloc failed
200  */
201 svm_fifo_chunk_t *svm_fifo_chunk_alloc (u32 size);
202 /**
203  * Grow fifo size by adding chunk to chunk list
204  *
205  * If fifos are allocated on a segment, this should be called with
206  * the segment's heap pushed.
207  *
208  * @param f     fifo to be extended
209  * @param c     chunk or linked list of chunks to be added
210  */
211 void svm_fifo_add_chunk (svm_fifo_t * f, svm_fifo_chunk_t * c);
212 int svm_fifo_fill_chunk_list (svm_fifo_t * f);
213 void svm_fifo_init_ooo_lookup (svm_fifo_t * f, u8 ooo_type);
214 /**
215  * Free fifo and associated state
216  *
217  * @param f     fifo
218  */
219 void svm_fifo_free (svm_fifo_t * f);
220 /**
221  * Cleanup fifo chunk lookup rb tree
222  *
223  * The rb tree is allocated in segment heap so this should be called
224  * with it pushed.
225  *
226  * @param f     fifo to cleanup
227  */
228 void svm_fifo_free_chunk_lookup (svm_fifo_t * f);
229 /**
230  * Cleanup fifo ooo data
231  *
232  * The ooo data is allocated in producer process memory. The fifo
233  * segment heap should not be pushed.
234  *
235  * @param f     fifo to cleanup
236  */
237 void svm_fifo_free_ooo_data (svm_fifo_t * f);
238 /**
239  * Init fifo head and tail
240  *
241  * @param f     fifo
242  * @param head  head value that will be matched to a chunk
243  * @param tail  tail value that will be matched to a chunk
244  */
245 void svm_fifo_init_pointers (svm_fifo_t * f, u32 head, u32 tail);
246 /**
247  * Clone fifo
248  *
249  * Clones single/default chunk fifo. It does not work for fifos with
250  * multiple chunks.
251  */
252 void svm_fifo_clone (svm_fifo_t * df, svm_fifo_t * sf);
253 /**
254  * Enqueue data to fifo
255  *
256  * Data is enqueued and tail pointer is updated atomically. If the new data
257  * enqueued partly overlaps or "touches" an out-of-order segment, said segment
258  * is "consumed" and the number of bytes returned is appropriately updated.
259  *
260  * @param f     fifo
261  * @param len   length of data to copy
262  * @param src   buffer from where to copy the data
263  * @return      number of contiguous bytes that can be consumed or error
264  */
265 int svm_fifo_enqueue (svm_fifo_t * f, u32 len, const u8 * src);
266 /**
267  * Enqueue data to fifo with offset
268  *
269  * Data is enqueued without updating tail pointer. Instead, an out-of-order
270  * list of segments is generated and maintained. Fifo takes care of coalescing
271  * contiguous or overlapping segments.
272  *
273  * @param f             fifo
274  * @param offset        offset at which to copy the data
275  * @param len           len of data to copy
276  * @param src           buffer from where to copy the data
277  * @return              0 if enqueue was successful, error otherwise
278  */
279 int svm_fifo_enqueue_with_offset (svm_fifo_t * f, u32 offset, u32 len,
280                                   u8 * src);
281
282 /**
283  * Advance tail pointer
284  *
285  * Useful for moving tail pointer after external enqueue.
286  *
287  * @param f             fifo
288  * @param len           number of bytes to add to tail
289  */
290 void svm_fifo_enqueue_nocopy (svm_fifo_t * f, u32 len);
291 /**
292  * Overwrite fifo head with new data
293  *
294  * This should be typically used by dgram transport protocols that need
295  * to update the dgram header after dequeueing a chunk of data. It assumes
296  * that the dgram header is at most spread over two chunks.
297  *
298  * @param f             fifo
299  * @param src           src of new data
300  * @param len           length of new data
301  */
302 void svm_fifo_overwrite_head (svm_fifo_t * f, u8 * src, u32 len);
303 /**
304  * Dequeue data from fifo
305  *
306  * Data is dequeued to consumer provided buffer and head is atomically
307  * updated.
308  *
309  * @param f             fifo
310  * @param len           length of data to dequeue
311  * @param dst           buffer to where to dequeue the data
312  * @return              number of bytes dequeued or error
313  */
314 int svm_fifo_dequeue (svm_fifo_t * f, u32 len, u8 * dst);
315 /**
316  * Peek data from fifo
317  *
318  * Data is copied from requested offset into provided dst buffer. Head is
319  * not updated.
320  *
321  * @param f             fifo
322  * @param offset        offset from which to copy the data
323  * @param len           length of data to copy
324  * @param dst           buffer to where to dequeue the data
325  * @return              number of bytes peeked
326  */
327 int svm_fifo_peek (svm_fifo_t * f, u32 offset, u32 len, u8 * dst);
328 /**
329  * Dequeue and drop bytes from fifo
330  *
331  * Advances fifo head by requested amount of bytes.
332  *
333  * @param f             fifo
334  * @param len           number of bytes to drop
335  * @return              number of bytes dropped
336  */
337 int svm_fifo_dequeue_drop (svm_fifo_t * f, u32 len);
338 /**
339  * Dequeue and drop all bytes from fifo
340  *
341  * Advances head to tail position.
342  *
343  * @param f             fifo
344  */
345 void svm_fifo_dequeue_drop_all (svm_fifo_t * f);
346 int svm_fifo_segments (svm_fifo_t * f, svm_fifo_seg_t * fs);
347 void svm_fifo_segments_free (svm_fifo_t * f, svm_fifo_seg_t * fs);
348 /**
349  * Add io events subscriber to list
350  *
351  * @param f     fifo
352  * @param sub   subscriber opaque index (typically app worker index)
353  */
354 void svm_fifo_add_subscriber (svm_fifo_t * f, u8 sub);
355 /**
356  * Remove io events subscriber form list
357  *
358  * @param f     fifo
359  * @param sub   subscriber index to be removed
360  */
361 void svm_fifo_del_subscriber (svm_fifo_t * f, u8 subscriber);
362 /**
363  * Number of out-of-order segments for fifo
364  *
365  * @param f     fifo
366  * @return      number of out of order segments
367  */
368 u32 svm_fifo_n_ooo_segments (svm_fifo_t * f);
369 /**
370  * First out-of-order segment for fifo
371  *
372  * @param f     fifo
373  * @return      first out-of-order segment for fifo
374  */
375 ooo_segment_t *svm_fifo_first_ooo_segment (svm_fifo_t * f);
376 /**
377  * Check if fifo is sane. Debug only.
378  *
379  * @param f     fifo
380  * @return      1 if sane, 0 otherwise
381  */
382 u8 svm_fifo_is_sane (svm_fifo_t * f);
383 u32 svm_fifo_n_chunks (svm_fifo_t * f);
384 format_function_t format_svm_fifo;
385
386 /**
387  * Fifo max bytes to dequeue optimized for consumer
388  *
389  * @param f     fifo
390  * @return      max number of bytes that can be dequeued
391  */
392 static inline u32
393 svm_fifo_max_dequeue_cons (svm_fifo_t * f)
394 {
395   u32 tail, head;
396   f_load_head_tail_cons (f, &head, &tail);
397   return f_cursize (f, head, tail);
398 }
399
400 /**
401  * Fifo max bytes to dequeue optimized for producer
402  *
403  * @param f     fifo
404  * @return      max number of bytes that can be dequeued
405  */
406 static inline u32
407 svm_fifo_max_dequeue_prod (svm_fifo_t * f)
408 {
409   u32 tail, head;
410   f_load_head_tail_prod (f, &head, &tail);
411   return f_cursize (f, head, tail);
412 }
413
414 /**
415  * Fifo max bytes to dequeue
416  *
417  * Note: use producer or consumer specific functions for performance:
418  * @ref svm_fifo_max_dequeue_cons (svm_fifo_t *f)
419  * @ref svm_fifo_max_dequeue_prod (svm_fifo_t *f)
420  */
421 static inline u32
422 svm_fifo_max_dequeue (svm_fifo_t * f)
423 {
424   u32 tail, head;
425   f_load_head_tail_all_acq (f, &head, &tail);
426   return f_cursize (f, head, tail);
427 }
428
429 /**
430  * Check if fifo is full optimized for producer
431  *
432  * @param f     fifo
433  * @return      1 if fifo is full 0 otherwise
434  */
435 static inline int
436 svm_fifo_is_full_prod (svm_fifo_t * f)
437 {
438   return (svm_fifo_max_dequeue_prod (f) == f->size);
439 }
440
441 /* Check if fifo is full.
442  *
443  * Note: use producer or consumer specific functions for performance.
444  * @ref svm_fifo_is_full_prod (svm_fifo_t * f)
445  * add cons version if needed
446  */
447 static inline int
448 svm_fifo_is_full (svm_fifo_t * f)
449 {
450   return (svm_fifo_max_dequeue (f) == f->size);
451 }
452
453 /**
454  * Check if fifo is empty optimized for consumer
455  *
456  * @param f     fifo
457  * @return      1 if fifo is empty 0 otherwise
458  */
459 static inline int
460 svm_fifo_is_empty_cons (svm_fifo_t * f)
461 {
462   return (svm_fifo_max_dequeue_cons (f) == 0);
463 }
464
465 /**
466  * Check if fifo is empty optimized for producer
467  *
468  * @param f     fifo
469  * @return      1 if fifo is empty 0 otherwise
470  */
471 static inline int
472 svm_fifo_is_empty_prod (svm_fifo_t * f)
473 {
474   return (svm_fifo_max_dequeue_prod (f) == 0);
475 }
476
477 /**
478  * Check if fifo is empty
479  *
480  * Note: use producer or consumer specific functions for perfomance.
481  * @ref svm_fifo_is_empty_cons (svm_fifo_t * f)
482  * @ref svm_fifo_is_empty_prod (svm_fifo_t * f)
483  */
484 static inline int
485 svm_fifo_is_empty (svm_fifo_t * f)
486 {
487   return (svm_fifo_max_dequeue (f) == 0);
488 }
489
490 /**
491  * Check if fifo is wrapped
492  *
493  * @param f     fifo
494  * @return      1 if 'normalized' head is ahead of tail
495  */
496 static inline u8
497 svm_fifo_is_wrapped (svm_fifo_t * f)
498 {
499   u32 head, tail;
500   f_load_head_tail_all_acq (f, &head, &tail);
501   return head > tail;
502 }
503
504 /**
505  * Maximum number of bytes that can be enqueued into fifo
506  *
507  * Optimized for producer
508  *
509  * @param f     fifo
510  * @return      max number of bytes that can be enqueued into fifo
511  */
512 static inline u32
513 svm_fifo_max_enqueue_prod (svm_fifo_t * f)
514 {
515   u32 head, tail;
516   f_load_head_tail_prod (f, &head, &tail);
517   return f_free_count (f, head, tail);
518 }
519
520 /* Maximum number of bytes that can be enqueued into fifo
521  *
522  * Note: use producer or consumer specific functions for performance.
523  * @ref svm_fifo_max_enqueue_prod (svm_fifo_t *f)
524  * add consumer specific version if needed.
525  */
526 static inline u32
527 svm_fifo_max_enqueue (svm_fifo_t * f)
528 {
529   u32 head, tail;
530   f_load_head_tail_all_acq (f, &head, &tail);
531   return f_free_count (f, head, tail);
532 }
533
534 /**
535  * Max contiguous chunk of data that can be read.
536  *
537  * Should only be called by consumers.
538  */
539 u32 svm_fifo_max_read_chunk (svm_fifo_t * f);
540
541 /**
542  * Max contiguous chunk of data that can be written
543  *
544  * Should only be called by producers
545  */
546 u32 svm_fifo_max_write_chunk (svm_fifo_t * f);
547
548 static inline svm_fifo_chunk_t *
549 svm_fifo_head_chunk (svm_fifo_t * f)
550 {
551   return f->head_chunk;
552 }
553
554 static inline u8 *
555 svm_fifo_head (svm_fifo_t * f)
556 {
557   if (!f->head_chunk)
558     return 0;
559   /* load-relaxed: consumer owned index */
560   return (f->head_chunk->data + (f->head - f->head_chunk->start_byte));
561 }
562
563 static inline svm_fifo_chunk_t *
564 svm_fifo_tail_chunk (svm_fifo_t * f)
565 {
566   return f->tail_chunk;
567 }
568
569 static inline u8 *
570 svm_fifo_tail (svm_fifo_t * f)
571 {
572   /* load-relaxed: producer owned index */
573   return (f->tail_chunk->data + (f->tail - f->tail_chunk->start_byte));
574 }
575
576 static inline u8
577 svm_fifo_n_subscribers (svm_fifo_t * f)
578 {
579   return f->n_subscribers;
580 }
581
582 /**
583  * Check if fifo has out-of-order data
584  *
585  * @param f     fifo
586  * @return      1 if fifo has ooo data, 0 otherwise
587  */
588 static inline u8
589 svm_fifo_has_ooo_data (svm_fifo_t * f)
590 {
591   return f->ooos_list_head != OOO_SEGMENT_INVALID_INDEX;
592 }
593
594 static inline ooo_segment_t *
595 svm_fifo_newest_ooo_segment (svm_fifo_t * f)
596 {
597   if (f->ooos_newest == OOO_SEGMENT_INVALID_INDEX)
598     return 0;
599   return pool_elt_at_index (f->ooo_segments, f->ooos_newest);
600 }
601
602 static inline void
603 svm_fifo_newest_ooo_segment_reset (svm_fifo_t * f)
604 {
605   f->ooos_newest = OOO_SEGMENT_INVALID_INDEX;
606 }
607
608 static inline u32
609 ooo_segment_offset_prod (svm_fifo_t * f, ooo_segment_t * s)
610 {
611   u32 tail;
612   /* load-relaxed: producer owned index */
613   tail = f->tail;
614
615   return (s->start - tail);
616 }
617
618 static inline u32
619 ooo_segment_length (svm_fifo_t * f, ooo_segment_t * s)
620 {
621   return s->length;
622 }
623
624 static inline u32
625 svm_fifo_size (svm_fifo_t * f)
626 {
627   return f->size;
628 }
629
630 static inline void
631 svm_fifo_set_size (svm_fifo_t * f, u32 size)
632 {
633   f->size = size;
634 }
635
636 /**
637  * Check if fifo has io event
638  *
639  * @param f     fifo
640  * @return      1 if fifo has event, 0 otherwise
641  */
642 static inline int
643 svm_fifo_has_event (svm_fifo_t * f)
644 {
645   return f->has_event;
646 }
647
648 /**
649  * Set fifo event flag.
650  *
651  * Forces release semantics.
652  *
653  * @param f     fifo
654  * @return      1 if flag was not set, 0 otherwise
655  */
656 always_inline u8
657 svm_fifo_set_event (svm_fifo_t * f)
658 {
659   return !clib_atomic_swap_rel_n (&f->has_event, 1);
660 }
661
662 /**
663  * Unset fifo event flag.
664  *
665  * Forces acquire semantics
666  *
667  * @param f     fifo
668  */
669 always_inline void
670 svm_fifo_unset_event (svm_fifo_t * f)
671 {
672   clib_atomic_swap_acq_n (&f->has_event, 0);
673 }
674
675 /**
676  * Set specific want notification flag
677  *
678  * For list of flags see @ref svm_fifo_deq_ntf_t
679  *
680  * @param f             fifo
681  * @param ntf_type      type of notification requested
682  */
683 static inline void
684 svm_fifo_add_want_deq_ntf (svm_fifo_t * f, u8 ntf_type)
685 {
686   f->want_deq_ntf |= ntf_type;
687 }
688
689 /**
690  * Clear specific want notification flag
691  *
692  * For list of flags see @ref svm_fifo_ntf_t
693  *
694  * @param f             fifo
695  * @param ntf_type      type of notification to be cleared
696  */
697 static inline void
698 svm_fifo_del_want_deq_ntf (svm_fifo_t * f, u8 ntf_type)
699 {
700   f->want_deq_ntf &= ~ntf_type;
701 }
702
703 /**
704  * Clear the want notification flag and set has notification
705  *
706  * Should be used after enqueuing an event. This clears the
707  * SVM_FIFO_WANT_NOTIF flag but it does not clear
708  * SVM_FIFO_WANT_NOTIF_IF_FULL. If the latter was set, has_ntf is
709  * set to avoid enqueueing events for for all dequeue operations until
710  * it is manually cleared.
711  *
712  * @param f     fifo
713  */
714 static inline void
715 svm_fifo_clear_deq_ntf (svm_fifo_t * f)
716 {
717   /* Set the flag if want_notif_if_full was the only ntf requested */
718   f->has_deq_ntf = f->want_deq_ntf == SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL;
719   svm_fifo_del_want_deq_ntf (f, SVM_FIFO_WANT_DEQ_NOTIF);
720 }
721
722 /**
723  * Clear has notification flag
724  *
725  * The fifo generates only one event per SVM_FIFO_WANT_NOTIF_IF_FULL
726  * request and sets has_ntf. To received new events the flag must be
727  * cleared using this function.
728  *
729  * @param f     fifo
730  */
731 static inline void
732 svm_fifo_reset_has_deq_ntf (svm_fifo_t * f)
733 {
734   f->has_deq_ntf = 0;
735 }
736
737 /**
738  * Check if fifo needs dequeue notification
739  *
740  * Determines based on notification request flags and state of the fifo if
741  * an event should be generated.
742  *
743  * @param f             fifo
744  * @param n_last_deq    number of bytes last dequeued
745  * @return              1 if event should be generated, 0 otherwise
746  */
747 static inline u8
748 svm_fifo_needs_deq_ntf (svm_fifo_t * f, u32 n_last_deq)
749 {
750   u8 want_ntf = f->want_deq_ntf;
751
752   if (PREDICT_TRUE (want_ntf == SVM_FIFO_NO_DEQ_NOTIF))
753     return 0;
754   else if (want_ntf & SVM_FIFO_WANT_DEQ_NOTIF)
755     return 1;
756   if (want_ntf & SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL)
757     {
758       u32 max_deq = svm_fifo_max_dequeue_cons (f);
759       u32 size = f->size;
760       if (!f->has_deq_ntf && max_deq < size && max_deq + n_last_deq >= size)
761         return 1;
762     }
763   if (want_ntf & SVM_FIFO_WANT_DEQ_NOTIF_IF_EMPTY)
764     {
765       if (!f->has_deq_ntf && svm_fifo_is_empty (f))
766         return 1;
767     }
768   return 0;
769 }
770
771 #endif /* __included_ssvm_fifo_h__ */
772
773 /*
774  * fd.io coding-style-patch-verification: ON
775  *
776  * Local Variables:
777  * eval: (c-set-style "gnu")
778  * End:
779  */