| 208 | } |
| 209 | |
| 210 | static int |
| 211 | nfp_mask_table_add(struct nfp_flow_priv *priv, |
| 212 | char *mask_data, |
| 213 | uint32_t mask_len, |
| 214 | uint8_t *id) |
| 215 | { |
| 216 | int ret; |
| 217 | uint8_t mask_id; |
| 218 | uint32_t hash_key; |
| 219 | struct nfp_mask_id_entry *mask_entry; |
| 220 | |
| 221 | mask_entry = rte_zmalloc("mask_entry", sizeof(struct nfp_mask_id_entry), 0); |
| 222 | if (mask_entry == NULL) { |
| 223 | ret = -ENOMEM; |
| 224 | goto exit; |
| 225 | } |
| 226 | |
| 227 | ret = nfp_mask_id_alloc(priv, &mask_id); |
| 228 | if (ret != 0) |
| 229 | goto mask_entry_free; |
| 230 | |
| 231 | hash_key = rte_jhash(mask_data, mask_len, priv->hash_seed); |
| 232 | mask_entry->mask_id = mask_id; |
| 233 | mask_entry->hash_key = hash_key; |
| 234 | mask_entry->ref_cnt = 1; |
| 235 | PMD_DRV_LOG(DEBUG, "hash_key=%#x id=%u ref=%u", hash_key, |
| 236 | mask_id, mask_entry->ref_cnt); |
| 237 | |
| 238 | ret = rte_hash_add_key_data(priv->mask_table, &hash_key, mask_entry); |
| 239 | if (ret != 0) { |
| 240 | PMD_DRV_LOG(ERR, "Add to mask table failed."); |
| 241 | goto mask_id_free; |
| 242 | } |
| 243 | |
| 244 | *id = mask_id; |
| 245 | return 0; |
| 246 | |
| 247 | mask_id_free: |
| 248 | nfp_mask_id_free(priv, mask_id); |
| 249 | mask_entry_free: |
| 250 | rte_free(mask_entry); |
| 251 | exit: |
| 252 | return ret; |
| 253 | } |
| 254 | |
| 255 | static int |
| 256 | nfp_mask_table_del(struct nfp_flow_priv *priv, |
no test coverage detected