| 156 | } |
| 157 | |
| 158 | static int |
| 159 | nfp_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 | |
| 191 | static int |
| 192 | nfp_mask_id_free(struct nfp_flow_priv *priv, |
no test coverage detected