* Perform basic sanity checks on a pattern item. * * @param[in] item * Item specification. * @param[in] proc * Associated item-processing object. * @param[out] error * Perform verbose error reporting if not NULL. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */
| 527 | * 0 on success, a negative errno value otherwise and rte_errno is set. |
| 528 | */ |
| 529 | static int |
| 530 | mlx4_flow_item_check(const struct rte_flow_item *item, |
| 531 | const struct mlx4_flow_proc_item *proc, |
| 532 | struct rte_flow_error *error) |
| 533 | { |
| 534 | const uint8_t *mask; |
| 535 | unsigned int i; |
| 536 | |
| 537 | /* item->last and item->mask cannot exist without item->spec. */ |
| 538 | if (!item->spec && (item->mask || item->last)) |
| 539 | return rte_flow_error_set |
| 540 | (error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 541 | "\"mask\" or \"last\" field provided without a" |
| 542 | " corresponding \"spec\""); |
| 543 | /* No spec, no mask, no problem. */ |
| 544 | if (!item->spec) |
| 545 | return 0; |
| 546 | mask = item->mask ? |
| 547 | (const uint8_t *)item->mask : |
| 548 | (const uint8_t *)proc->mask_default; |
| 549 | MLX4_ASSERT(mask); |
| 550 | /* |
| 551 | * Single-pass check to make sure that: |
| 552 | * - Mask is supported, no bits are set outside proc->mask_support. |
| 553 | * - Both item->spec and item->last are included in mask. |
| 554 | */ |
| 555 | for (i = 0; i != proc->mask_sz; ++i) { |
| 556 | if (!mask[i]) |
| 557 | continue; |
| 558 | if ((mask[i] | ((const uint8_t *)proc->mask_support)[i]) != |
| 559 | ((const uint8_t *)proc->mask_support)[i]) |
| 560 | return rte_flow_error_set |
| 561 | (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, |
| 562 | item, "unsupported field found in \"mask\""); |
| 563 | if (item->last && |
| 564 | (((const uint8_t *)item->spec)[i] & mask[i]) != |
| 565 | (((const uint8_t *)item->last)[i] & mask[i])) |
| 566 | return rte_flow_error_set |
| 567 | (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, |
| 568 | item, |
| 569 | "range between \"spec\" and \"last\"" |
| 570 | " is larger than \"mask\""); |
| 571 | } |
| 572 | return 0; |
| 573 | } |
| 574 | |
| 575 | /** Graph of supported items and associated actions. */ |
| 576 | static const struct mlx4_flow_proc_item mlx4_flow_proc_item_list[] = { |
no test coverage detected