MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mlx4_alloc_verbs_buf

Function mlx4_alloc_verbs_buf

dpdk/drivers/net/mlx4/mlx4.c:148–171  ·  view source on GitHub ↗

* Verbs callback to allocate a memory. This function should allocate the space * according to the size provided residing inside a huge page. * Please note that all allocation must respect the alignment from libmlx4 * (i.e. currently sysconf(_SC_PAGESIZE)). * * @param[in] size * The size in bytes of the memory to allocate. * @param[in] data * A pointer to the callback data. * * @retur

Source from the content-addressed store, hash-verified

146 * Allocated buffer, NULL otherwise and rte_errno is set.
147 */
148static void *
149mlx4_alloc_verbs_buf(size_t size, void *data)
150{
151 struct mlx4_priv *priv = data;
152 void *ret;
153 size_t alignment = sysconf(_SC_PAGESIZE);
154 unsigned int socket = SOCKET_ID_ANY;
155
156 if (priv->verbs_alloc_ctx.type == MLX4_VERBS_ALLOC_TYPE_TX_QUEUE) {
157 const struct txq *txq = priv->verbs_alloc_ctx.obj;
158
159 socket = txq->socket;
160 } else if (priv->verbs_alloc_ctx.type ==
161 MLX4_VERBS_ALLOC_TYPE_RX_QUEUE) {
162 const struct rxq *rxq = priv->verbs_alloc_ctx.obj;
163
164 socket = rxq->socket;
165 }
166 MLX4_ASSERT(data != NULL);
167 ret = rte_malloc_socket(__func__, size, alignment, socket);
168 if (!ret && size)
169 rte_errno = ENOMEM;
170 return ret;
171}
172
173/**
174 * Verbs callback to free a memory.

Callers

nothing calls this directly

Calls 1

rte_malloc_socketFunction · 0.85

Tested by

no test coverage detected