NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
doca_buf_inventory.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_INVENTORY_H_
26 #define DOCA_BUF_INVENTORY_H_
27 
28 #include <stddef.h>
29 #include <stdint.h>
30 
31 #include <doca_compat.h>
32 #include <doca_error.h>
33 #include <doca_types.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /*******************************************************************************
40  * DOCA Inventory
41  ******************************************************************************/
42 
43 struct doca_buf;
44 struct doca_mmap;
45 
49 struct doca_buf_inventory;
50 
71 doca_error_t doca_buf_inventory_create(size_t num_elements, struct doca_buf_inventory **inventory);
72 
90 doca_error_t doca_buf_inventory_destroy(struct doca_buf_inventory *inventory);
91 
114 doca_error_t doca_buf_inventory_start(struct doca_buf_inventory *inventory);
115 
132 doca_error_t doca_buf_inventory_stop(struct doca_buf_inventory *inventory);
133 
134 /*******************************************************************************
135  * DOCA buffer, inventory and mmap
136  ******************************************************************************/
137 
167 doca_error_t doca_buf_inventory_buf_get_by_args(struct doca_buf_inventory *inventory,
168  struct doca_mmap *mmap,
169  void *addr,
170  size_t len,
171  void *data,
172  size_t data_len,
173  struct doca_buf **buf);
174 
197 static inline doca_error_t doca_buf_inventory_buf_get_by_addr(struct doca_buf_inventory *inventory,
198  struct doca_mmap *mmap,
199  void *addr,
200  size_t len,
201  struct doca_buf **buf)
202 {
203  return doca_buf_inventory_buf_get_by_args(inventory, mmap, addr, len, addr, 0, buf);
204 }
205 
228 static inline doca_error_t doca_buf_inventory_buf_get_by_data(struct doca_buf_inventory *inventory,
229  struct doca_mmap *mmap,
230  void *data,
231  size_t data_len,
232  struct doca_buf **buf)
233 {
234  return doca_buf_inventory_buf_get_by_args(inventory, mmap, data, data_len, data, data_len, buf);
235 }
236 
258 doca_error_t doca_buf_inventory_buf_dup(struct doca_buf_inventory *inventory,
259  const struct doca_buf *src_buf,
260  struct doca_buf **dst_buf);
261 
262 /*******************************************************************************
263  * DOCA Buffer Inventory properties
264  ******************************************************************************/
265 
281 doca_error_t doca_buf_inventory_set_user_data(struct doca_buf_inventory *inventory, union doca_data user_data);
282 
299 doca_error_t doca_buf_inventory_get_num_elements(const struct doca_buf_inventory *inventory, uint32_t *num_of_elements);
300 
317 doca_error_t doca_buf_inventory_get_num_free_elements(const struct doca_buf_inventory *inventory,
318  uint32_t *num_of_free_elements);
319 
336 doca_error_t doca_buf_inventory_get_user_data(const struct doca_buf_inventory *inventory, union doca_data *user_data);
337 
355 doca_error_t doca_buf_inventory_expand(struct doca_buf_inventory *inventory, uint32_t num_elements);
356 #ifdef __cplusplus
357 }
358 #endif
359 
362 #endif /* DOCA_BUF_INVENTORY_H_ */
uintptr_t addr
doca_dpa_dev_mmap_t mmap
uint64_t len
DOCA_STABLE doca_error_t doca_buf_inventory_get_user_data(const struct doca_buf_inventory *inventory, union doca_data *user_data)
Get the user_data of a DOCA Buffer Inventory.
DOCA_STABLE doca_error_t doca_buf_inventory_set_user_data(struct doca_buf_inventory *inventory, union doca_data user_data)
Set user_data for a DOCA Buffer Inventory.
DOCA_EXPERIMENTAL doca_error_t doca_buf_inventory_expand(struct doca_buf_inventory *inventory, uint32_t num_elements)
Expand the inventory.
DOCA_STABLE doca_error_t doca_buf_inventory_get_num_free_elements(const struct doca_buf_inventory *inventory, uint32_t *num_of_free_elements)
Get the total number of free elements in a DOCA Buffer Inventory.
DOCA_STABLE doca_error_t doca_buf_inventory_destroy(struct doca_buf_inventory *inventory)
Destroy buffer inventory structure.
DOCA_STABLE doca_error_t doca_buf_inventory_get_num_elements(const struct doca_buf_inventory *inventory, uint32_t *num_of_elements)
Read the total number of elements in a DOCA Buffer Inventory.
DOCA_STABLE doca_error_t doca_buf_inventory_buf_get_by_args(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *addr, size_t len, void *data, size_t data_len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by addr,...
DOCA_STABLE doca_error_t doca_buf_inventory_buf_dup(struct doca_buf_inventory *inventory, const struct doca_buf *src_buf, struct doca_buf **dst_buf)
Duplicates content of the buf argument into element allocated from buffer inventory....
static doca_error_t doca_buf_inventory_buf_get_by_addr(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *addr, size_t len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by addr & len argume...
static doca_error_t doca_buf_inventory_buf_get_by_data(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *data, size_t data_len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by data & data_len a...
DOCA_STABLE doca_error_t doca_buf_inventory_start(struct doca_buf_inventory *inventory)
Start element retrieval from inventory.
DOCA_STABLE doca_error_t doca_buf_inventory_create(size_t num_elements, struct doca_buf_inventory **inventory)
Allocates buffer inventory with default/unset attributes.
DOCA_STABLE doca_error_t doca_buf_inventory_stop(struct doca_buf_inventory *inventory)
Stop element retrieval from inventory.
#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.
Convenience type for representing opaque data.
Definition: doca_types.h:56