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

Function nfp_mask_id_alloc

dpdk/drivers/net/nfp/nfp_flow.c:158–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158static int
159nfp_mask_id_alloc(struct nfp_flow_priv *priv,
160 uint8_t *mask_id)
161{
162 uint8_t temp_id;
163 uint8_t freed_id;
164 struct circ_buf *ring;
165
166 /* Checking for unallocated entries first. */
167 if (priv->mask_ids.init_unallocated > 0) {
168 *mask_id = priv->mask_ids.init_unallocated;
169 priv->mask_ids.init_unallocated--;
170 return 0;
171 }
172
173 /* Checking if buffer is empty. */
174 freed_id = NFP_FLOWER_MASK_ENTRY_RS - 1;
175 ring = &priv->mask_ids.free_list;
176 if (ring->head == ring->tail) {
177 *mask_id = freed_id;
178 return -ENOENT;
179 }
180
181 rte_memcpy(&temp_id, &ring->buf[ring->tail], NFP_FLOWER_MASK_ELEMENT_RS);
182 *mask_id = temp_id;
183
184 rte_memcpy(&ring->buf[ring->tail], &freed_id, NFP_FLOWER_MASK_ELEMENT_RS);
185 ring->tail = (ring->tail + NFP_FLOWER_MASK_ELEMENT_RS) %
186 (NFP_FLOWER_MASK_ENTRY_RS * NFP_FLOWER_MASK_ELEMENT_RS);
187
188 return 0;
189}
190
191static int
192nfp_mask_id_free(struct nfp_flow_priv *priv,

Callers 1

nfp_mask_table_addFunction · 0.85

Calls 1

rte_memcpyFunction · 0.50

Tested by

no test coverage detected