dpdk/drivers/net/bnxt/tf_core/ll.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: BSD-3-Clause
   2 * Copyright(c) 2019-2021 Broadcom
   3 * All rights reserved.
   4 */
   5
   6/* Linked List Header File */
   7
   8#ifndef _LL_H_
   9#define _LL_H_
  10
  11#include <stdint.h>
  12
  13/* linked list entry */
  14struct ll_entry {
  15        struct ll_entry *prev;
  16        struct ll_entry *next;
  17};
  18
  19/* linked list */
  20struct ll {
  21        struct ll_entry *head;
  22        struct ll_entry *tail;
  23        uint32_t cnt;
  24};
  25
  26/**
  27 * Linked list initialization.
  28 *
  29 * [in] ll, linked list to be initialized
  30 */
  31void ll_init(struct ll *ll);
  32
  33/**
  34 * Linked list insert head
  35 *
  36 * [in] ll, linked list where element is inserted
  37 * [in] entry, entry to be added
  38 */
  39void ll_insert(struct ll *ll, struct ll_entry *entry);
  40
  41/**
  42 * Linked list delete
  43 *
  44 * [in] ll, linked list where element is removed
  45 * [in] entry, entry to be deleted
  46 */
  47void ll_delete(struct ll *ll, struct ll_entry *entry);
  48
  49/**
  50 * Linked list return next entry without deleting it
  51 *
  52 * Useful in performing search
  53 *
  54 * [in] Entry in the list
  55 */
  56static inline struct ll_entry *ll_next(struct ll_entry *entry)
  57{
  58        return entry->next;
  59}
  60
  61/**
  62 * Linked list return the head of the list without removing it
  63 *
  64 * Useful in performing search
  65 *
  66 * [in] ll, linked list
  67 */
  68static inline struct ll_entry *ll_head(struct ll *ll)
  69{
  70        return ll->head;
  71}
  72
  73/**
  74 * Linked list return the tail of the list without removing it
  75 *
  76 * Useful in performing search
  77 *
  78 * [in] ll, linked list
  79 */
  80static inline struct ll_entry *ll_tail(struct ll *ll)
  81{
  82        return ll->tail;
  83}
  84
  85/**
  86 * Linked list return the number of entries in the list
  87 *
  88 * [in] ll, linked list
  89 */
  90static inline uint32_t ll_cnt(struct ll *ll)
  91{
  92        return ll->cnt;
  93}
  94#endif /* _LL_H_ */
  95