* Verify the @p item specifications (spec, last, mask) are compatible with the * NIC capabilities. * * @param[in] item * Item specification. * @param[in] mask * @p item->mask or flow default bit-masks. * @param[in] nic_mask * Bit-masks covering supported fields by the NIC to compare with user mask. * @param[in] size * Bit-masks size in bytes. * @param[in] range_accepted * Tru
| 1556 | * 0 on success, a negative errno value otherwise and rte_errno is set. |
| 1557 | */ |
| 1558 | int |
| 1559 | mlx5_flow_item_acceptable(const struct rte_flow_item *item, |
| 1560 | const uint8_t *mask, |
| 1561 | const uint8_t *nic_mask, |
| 1562 | unsigned int size, |
| 1563 | bool range_accepted, |
| 1564 | struct rte_flow_error *error) |
| 1565 | { |
| 1566 | unsigned int i; |
| 1567 | |
| 1568 | MLX5_ASSERT(nic_mask); |
| 1569 | for (i = 0; i < size; ++i) |
| 1570 | if ((nic_mask[i] | mask[i]) != nic_mask[i]) |
| 1571 | return rte_flow_error_set(error, ENOTSUP, |
| 1572 | RTE_FLOW_ERROR_TYPE_ITEM, |
| 1573 | item, |
| 1574 | "mask enables non supported" |
| 1575 | " bits"); |
| 1576 | if (!item->spec && (item->mask || item->last)) |
| 1577 | return rte_flow_error_set(error, EINVAL, |
| 1578 | RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 1579 | "mask/last without a spec is not" |
| 1580 | " supported"); |
| 1581 | if (item->spec && item->last && !range_accepted) { |
| 1582 | uint8_t spec[size]; |
| 1583 | uint8_t last[size]; |
| 1584 | unsigned int i; |
| 1585 | int ret; |
| 1586 | |
| 1587 | for (i = 0; i < size; ++i) { |
| 1588 | spec[i] = ((const uint8_t *)item->spec)[i] & mask[i]; |
| 1589 | last[i] = ((const uint8_t *)item->last)[i] & mask[i]; |
| 1590 | } |
| 1591 | ret = memcmp(spec, last, size); |
| 1592 | if (ret != 0) |
| 1593 | return rte_flow_error_set(error, EINVAL, |
| 1594 | RTE_FLOW_ERROR_TYPE_ITEM, |
| 1595 | item, |
| 1596 | "range is not valid"); |
| 1597 | } |
| 1598 | return 0; |
| 1599 | } |
| 1600 | |
| 1601 | /** |
| 1602 | * Adjust the hash fields according to the @p flow information. |
no test coverage detected