* Internal preparation function. Allocate mlx5_flow with the required size. * The required size is calculate based on the actions and items. This function * also returns the detected actions and items for later use. * * @param[in] dev * Pointer to Ethernet device. * @param[in] attr * Pointer to the flow attributes. * @param[in] items * Pointer to the list of items. * @param[in] act
| 1717 | * is set. |
| 1718 | */ |
| 1719 | static struct mlx5_flow * |
| 1720 | flow_verbs_prepare(struct rte_eth_dev *dev, |
| 1721 | const struct rte_flow_attr *attr __rte_unused, |
| 1722 | const struct rte_flow_item items[], |
| 1723 | const struct rte_flow_action actions[], |
| 1724 | struct rte_flow_error *error) |
| 1725 | { |
| 1726 | size_t size = 0; |
| 1727 | uint32_t handle_idx = 0; |
| 1728 | struct mlx5_flow *dev_flow; |
| 1729 | struct mlx5_flow_handle *dev_handle; |
| 1730 | struct mlx5_priv *priv = dev->data->dev_private; |
| 1731 | struct mlx5_flow_workspace *wks = mlx5_flow_get_thread_workspace(); |
| 1732 | |
| 1733 | MLX5_ASSERT(wks); |
| 1734 | size += flow_verbs_get_actions_size(actions); |
| 1735 | size += flow_verbs_get_items_size(items); |
| 1736 | if (size > MLX5_VERBS_MAX_SPEC_ACT_SIZE) { |
| 1737 | rte_flow_error_set(error, E2BIG, |
| 1738 | RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, |
| 1739 | "Verbs spec/action size too large"); |
| 1740 | return NULL; |
| 1741 | } |
| 1742 | /* In case of corrupting the memory. */ |
| 1743 | if (wks->flow_idx >= MLX5_NUM_MAX_DEV_FLOWS) { |
| 1744 | rte_flow_error_set(error, ENOSPC, |
| 1745 | RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, |
| 1746 | "not free temporary device flow"); |
| 1747 | return NULL; |
| 1748 | } |
| 1749 | dev_handle = mlx5_ipool_zmalloc(priv->sh->ipool[MLX5_IPOOL_MLX5_FLOW], |
| 1750 | &handle_idx); |
| 1751 | if (!dev_handle) { |
| 1752 | rte_flow_error_set(error, ENOMEM, |
| 1753 | RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, |
| 1754 | "not enough memory to create flow handle"); |
| 1755 | return NULL; |
| 1756 | } |
| 1757 | MLX5_ASSERT(wks->flow_idx + 1 < RTE_DIM(wks->flows)); |
| 1758 | dev_flow = &wks->flows[wks->flow_idx++]; |
| 1759 | dev_flow->handle = dev_handle; |
| 1760 | dev_flow->handle_idx = handle_idx; |
| 1761 | /* Memcpy is used, only size needs to be cleared to 0. */ |
| 1762 | dev_flow->verbs.size = 0; |
| 1763 | dev_flow->verbs.attr.num_of_specs = 0; |
| 1764 | dev_flow->ingress = attr->ingress; |
| 1765 | dev_flow->hash_fields = 0; |
| 1766 | /* Need to set transfer attribute: not supported in Verbs mode. */ |
| 1767 | return dev_flow; |
| 1768 | } |
| 1769 | |
| 1770 | /** |
| 1771 | * Fill the flow with verb spec. |
nothing calls this directly
no test coverage detected