1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2020 Marvell International Ltd.
5 #ifndef __NODE_PRIVATE_H__
6 #define __NODE_PRIVATE_H__
8 #include <rte_common.h>
11 #include <rte_mbuf_dyn.h>
13 extern int rte_node_logtype;
14 #define NODE_LOG(level, node_name, ...) \
15 rte_log(RTE_LOG_##level, rte_node_logtype, \
16 RTE_FMT("NODE %s: %s():%u " RTE_FMT_HEAD(__VA_ARGS__, ) "\n", \
17 node_name, __func__, __LINE__, \
18 RTE_FMT_TAIL(__VA_ARGS__, )))
20 #define node_err(node_name, ...) NODE_LOG(ERR, node_name, __VA_ARGS__)
21 #define node_info(node_name, ...) NODE_LOG(INFO, node_name, __VA_ARGS__)
22 #define node_dbg(node_name, ...) NODE_LOG(DEBUG, node_name, __VA_ARGS__)
25 * Node mbuf private data to store next hop, ttl and checksum.
27 struct node_mbuf_priv1 {
40 static const struct rte_mbuf_dynfield node_mbuf_priv1_dynfield_desc = {
41 .name = "rte_node_dynfield_priv1",
42 .size = sizeof(struct node_mbuf_priv1),
43 .align = __alignof__(struct node_mbuf_priv1),
45 extern int node_mbuf_priv1_dynfield_offset;
48 * Node mbuf private area 2.
50 struct node_mbuf_priv2 {
52 } __rte_cache_aligned;
54 #define NODE_MBUF_PRIV2_SIZE sizeof(struct node_mbuf_priv2)
56 #define OBJS_PER_CLINE (RTE_CACHE_LINE_SIZE / sizeof(void *))
59 * Get mbuf_priv1 pointer from rte_mbuf.
62 * Pointer to the rte_mbuf.
65 * Pointer to the mbuf_priv1.
67 static __rte_always_inline struct node_mbuf_priv1 *
68 node_mbuf_priv1(struct rte_mbuf *m, const int offset)
70 return RTE_MBUF_DYNFIELD(m, offset, struct node_mbuf_priv1 *);
74 * Get mbuf_priv2 pointer from rte_mbuf.
77 * Pointer to the rte_mbuf.
80 * Pointer to the mbuf_priv2.
82 static __rte_always_inline struct node_mbuf_priv2 *
83 node_mbuf_priv2(struct rte_mbuf *m)
85 return (struct node_mbuf_priv2 *)rte_mbuf_to_priv(m);
88 #endif /* __NODE_PRIVATE_H__ */