NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
doca_buf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES, ALL RIGHTS RESERVED.
3  *
4  * This software product is a proprietary product of NVIDIA CORPORATION &
5  * AFFILIATES (the "Company") and all right, title, and interest in and to the
6  * software product, including all associated intellectual property rights, are
7  * and shall remain exclusively with the Company.
8  *
9  * This software product is governed by the End User License Agreement
10  * provided with the software product.
11  *
12  */
13 
25 #ifndef DOCA_BUF_H_
26 #define DOCA_BUF_H_
27 
28 #include <stdint.h>
29 #include <stddef.h>
30 
31 #include <doca_compat.h>
32 #include <doca_error.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /*******************************************************************************
39  * DOCA Buffer element
40  ******************************************************************************/
41 
71 struct doca_buf;
72 
91 doca_error_t doca_buf_inc_refcount(struct doca_buf *buf, uint16_t *refcount);
92 
113 doca_error_t doca_buf_dec_refcount(struct doca_buf *buf, uint16_t *refcount);
114 
127 doca_error_t doca_buf_get_refcount(const struct doca_buf *buf, uint16_t *refcount);
128 
129 /*******************************************************************************
130  * DOCA Buffer: Data placement
131  *******************************************************************************/
132 
145 doca_error_t doca_buf_get_len(const struct doca_buf *buf, size_t *len);
146 
159 doca_error_t doca_buf_get_head(const struct doca_buf *buf, void **head);
160 
173 doca_error_t doca_buf_get_data_len(const struct doca_buf *buf, size_t *data_len);
174 
187 doca_error_t doca_buf_get_data(const struct doca_buf *buf, void **data);
188 
220 doca_error_t doca_buf_set_data(struct doca_buf *buf, void *data, size_t data_len);
221 
254 doca_error_t doca_buf_set_data_len(struct doca_buf *buf, size_t data_len);
255 
286 doca_error_t doca_buf_reset_data_len(struct doca_buf *buf);
287 
301 doca_error_t doca_buf_get_next_in_list(struct doca_buf *buf, struct doca_buf **next_buf);
302 
318 doca_error_t doca_buf_get_last_in_list(struct doca_buf *buf, struct doca_buf **last_buf);
319 
333 doca_error_t doca_buf_is_last_in_list(const struct doca_buf *buf, uint8_t *is_last);
334 
348 doca_error_t doca_buf_is_first_in_list(const struct doca_buf *buf, uint8_t *is_first);
349 
363 doca_error_t doca_buf_is_in_list(const struct doca_buf *buf, uint8_t *is_in_list);
364 
381 doca_error_t doca_buf_get_list_len(const struct doca_buf *buf, uint32_t *num_elements);
382 
419 doca_error_t doca_buf_chain_list(struct doca_buf *list1, struct doca_buf *list2);
420 
460 doca_error_t doca_buf_chain_list_tail(struct doca_buf *list1_head, struct doca_buf *list1_tail, struct doca_buf *list2);
461 
498 doca_error_t doca_buf_unchain_list(struct doca_buf *list1, struct doca_buf *list2);
499 
500 #ifdef __cplusplus
501 }
502 #endif
503 
506 #endif /* DOCA_BUF_H_ */
uint64_t len
DOCA_STABLE doca_error_t doca_buf_inc_refcount(struct doca_buf *buf, uint16_t *refcount)
Increase the object reference count by 1.
DOCA_STABLE doca_error_t doca_buf_dec_refcount(struct doca_buf *buf, uint16_t *refcount)
Decrease the object reference count by 1, if 0 reached, return the element back to the inventory.
DOCA_STABLE doca_error_t doca_buf_get_list_len(const struct doca_buf *buf, uint32_t *num_elements)
Get the number of the elements in list.
DOCA_STABLE doca_error_t doca_buf_is_first_in_list(const struct doca_buf *buf, uint8_t *is_first)
Check if provided DOCA Buf is the first element in a linked list.
DOCA_STABLE doca_error_t doca_buf_get_len(const struct doca_buf *buf, size_t *len)
Get the buffer's length.
DOCA_STABLE doca_error_t doca_buf_unchain_list(struct doca_buf *list1, struct doca_buf *list2)
Separate list2 from list1.
DOCA_STABLE doca_error_t doca_buf_get_last_in_list(struct doca_buf *buf, struct doca_buf **last_buf)
Get last DOCA Buf in linked list.
DOCA_STABLE doca_error_t doca_buf_is_last_in_list(const struct doca_buf *buf, uint8_t *is_last)
Check if provided DOCA Buf is the last element in a linked list.
DOCA_STABLE doca_error_t doca_buf_is_in_list(const struct doca_buf *buf, uint8_t *is_in_list)
Check if provided DOCA Buf is a linked list.
DOCA_STABLE doca_error_t doca_buf_chain_list(struct doca_buf *list1, struct doca_buf *list2)
Append list2 to list1.
DOCA_STABLE doca_error_t doca_buf_set_data_len(struct doca_buf *buf, size_t data_len)
DOCA_STABLE doca_error_t doca_buf_get_next_in_list(struct doca_buf *buf, struct doca_buf **next_buf)
Get next DOCA Buf in linked list.
DOCA_STABLE doca_error_t doca_buf_get_data(const struct doca_buf *buf, void **data)
Get the buffer's data.
DOCA_EXPERIMENTAL doca_error_t doca_buf_chain_list_tail(struct doca_buf *list1_head, struct doca_buf *list1_tail, struct doca_buf *list2)
Append list2 to list1.
DOCA_STABLE doca_error_t doca_buf_get_data_len(const struct doca_buf *buf, size_t *data_len)
Get buffer's data length.
DOCA_STABLE doca_error_t doca_buf_get_head(const struct doca_buf *buf, void **head)
Get the buffer's head.
DOCA_STABLE doca_error_t doca_buf_reset_data_len(struct doca_buf *buf)
DOCA_STABLE doca_error_t doca_buf_set_data(struct doca_buf *buf, void *data, size_t data_len)
DOCA_STABLE doca_error_t doca_buf_get_refcount(const struct doca_buf *buf, uint16_t *refcount)
Get the reference count of the object.
#define DOCA_EXPERIMENTAL
To set a Symbol (or specifically a function) as experimental.
Definition: doca_compat.h:103
#define DOCA_STABLE
To set a Symbol (or specifically a function) as stable API, i.e. it won't be changed.
Definition: doca_compat.h:96
enum doca_error doca_error_t
DOCA API return codes.