net/ice/base: group function prototypes together
[dpdk.git] / drivers / net / ice / base / ice_osdep.h
index 45b9f36..360e435 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2018 Intel Corporation
+ * Copyright(c) 2018-2020 Intel Corporation
  */
 
 #ifndef _ICE_OSDEP_H_
@@ -24,6 +24,8 @@
 #include <rte_random.h>
 #include <rte_io.h>
 
+#include "ice_alloc.h"
+
 #include "../ice_logs.h"
 
 #ifndef __INTEL_NET_BASE_OSDEP__
@@ -76,6 +78,7 @@ typedef uint64_t        s64;
 #define CPU_TO_BE16(o) rte_cpu_to_be_16(o)
 #define CPU_TO_BE32(o) rte_cpu_to_be_32(o)
 #define CPU_TO_BE64(o) rte_cpu_to_be_64(o)
+#define BE16_TO_CPU(o) rte_be_to_cpu_16(o)
 
 #define NTOHS(a) rte_be_to_cpu_16(a)
 #define NTOHL(a) rte_be_to_cpu_32(a)
@@ -120,13 +123,13 @@ writeq(uint64_t value, volatile void *addr)
 #endif /* __INTEL_NET_BASE_OSDEP__ */
 
 #ifndef __always_unused
-#define __always_unused  __attribute__((unused))
+#define __always_unused  __rte_unused
 #endif
 #ifndef __maybe_unused
-#define __maybe_unused  __attribute__((unused))
+#define __maybe_unused  __rte_unused
 #endif
 #ifndef __packed
-#define __packed  __attribute__((packed))
+#define __packed  __rte_packed
 #endif
 
 #ifndef BIT_ULL
@@ -180,12 +183,12 @@ struct ice_dma_mem {
        u64 pa;
        u32 size;
        const void *zone;
-} __attribute__((packed));
+} __rte_packed;
 
 struct ice_virt_mem {
        void *va;
        u32 size;
-} __attribute__((packed));
+} __rte_packed;
 
 #define ice_malloc(h, s)    rte_zmalloc(NULL, s, 0)
 #define ice_calloc(h, c, s) rte_zmalloc(NULL, (c) * (s), 0)
@@ -193,7 +196,6 @@ struct ice_virt_mem {
 
 #define ice_memset(a, b, c, d) memset((a), (b), (c))
 #define ice_memcpy(a, b, c, d) rte_memcpy((a), (b), (c))
-#define ice_memdup(a, b, c, d) rte_memcpy(ice_malloc(a, c), b, c)
 
 /* SW spinlock */
 struct ice_lock {
@@ -219,14 +221,27 @@ ice_release_lock(struct ice_lock *sp)
 }
 
 static inline void
-ice_destroy_lock(__attribute__((unused)) struct ice_lock *sp)
+ice_destroy_lock(__rte_unused struct ice_lock *sp)
 {
 }
 
 struct ice_hw;
 
+static __rte_always_inline void *
+ice_memdup(__rte_unused struct ice_hw *hw, const void *src, size_t size,
+          __rte_unused enum ice_memcpy_type dir)
+{
+       void *p;
+
+       p = ice_malloc(hw, size);
+       if (p)
+               rte_memcpy(p, src, size);
+
+       return p;
+}
+
 static inline void *
-ice_alloc_dma_mem(__attribute__((unused)) struct ice_hw *hw,
+ice_alloc_dma_mem(__rte_unused struct ice_hw *hw,
                  struct ice_dma_mem *mem, u64 size)
 {
        const struct rte_memzone *mz = NULL;
@@ -252,7 +267,7 @@ ice_alloc_dma_mem(__attribute__((unused)) struct ice_hw *hw,
 }
 
 static inline void
-ice_free_dma_mem(__attribute__((unused)) struct ice_hw *hw,
+ice_free_dma_mem(__rte_unused struct ice_hw *hw,
                 struct ice_dma_mem *mem)
 {
        PMD_DRV_LOG(DEBUG, "memzone %s to be freed with physical address: "
@@ -345,6 +360,21 @@ static inline void list_add_tail(struct ice_list_entry *entry,
                                  member) :                                    \
                     0)
 
+#define LIST_FOR_EACH_ENTRY_SAFE(pos, tmp, head, type, member)                \
+       for ((pos) = (head)->lh_first ?                                        \
+                    container_of((head)->lh_first, struct type, member) :     \
+                    0,                                                        \
+                    (tmp) = (pos) == 0 ? 0 : ((pos)->member.next.le_next ?    \
+                    container_of((pos)->member.next.le_next, struct type,     \
+                                 member) :                                    \
+                    0);                                                       \
+            (pos);                                                            \
+            (pos) = (tmp),                                                    \
+            (tmp) = (pos) == 0 ? 0 : ((tmp)->member.next.le_next ?            \
+                    container_of((pos)->member.next.le_next, struct type,     \
+                                 member) :                                    \
+                    0))
+
 #define LIST_REPLACE_INIT(list_head, head) do {                                \
        (head)->lh_first = (list_head)->lh_first;                       \
        INIT_LIST_HEAD(list_head);                                      \
@@ -358,8 +388,6 @@ static inline void list_add_tail(struct ice_list_entry *entry,
 #define HLIST_DEL(entry)                       LIST_DEL(entry)
 #define HLIST_FOR_EACH_ENTRY(pos, head, type, member) \
        LIST_FOR_EACH_ENTRY(pos, head, type, member)
-#define LIST_FOR_EACH_ENTRY_SAFE(pos, tmp, head, type, member) \
-       LIST_FOR_EACH_ENTRY(pos, head, type, member)
 
 #ifndef ICE_DBG_TRACE
 #define ICE_DBG_TRACE          BIT_ULL(0)