X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fmlx5%2Fmlx5_flow.c;h=ec6d00f21b45f7651841424f8df7dd7e9e6df61f;hb=c9ec2192ffa7e3f5926acc13c6fc6f553d1a59a6;hp=129311d50be188040acf368e5c39266e26dc8412;hpb=6f2f4948b23643d279f38d38f988b122f393270f;p=dpdk.git diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 129311d50b..ec6d00f21b 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -538,7 +538,7 @@ struct ibv_spec_header { }; /** - * Check support for a given item. + * Check item is fully supported by the NIC matching capability. * * @param item[in] * Item specification. @@ -555,60 +555,33 @@ static int mlx5_flow_item_validate(const struct rte_flow_item *item, const uint8_t *mask, unsigned int size) { - if (!item->spec && (item->mask || item->last)) { - rte_errno = EINVAL; - return -rte_errno; - } - if (item->spec && !item->mask) { - unsigned int i; - const uint8_t *spec = item->spec; - - for (i = 0; i < size; ++i) - if ((spec[i] | mask[i]) != mask[i]) { - rte_errno = EINVAL; - return -rte_errno; - } - } - if (item->last && !item->mask) { - unsigned int i; - const uint8_t *spec = item->last; - - for (i = 0; i < size; ++i) - if ((spec[i] | mask[i]) != mask[i]) { - rte_errno = EINVAL; - return -rte_errno; - } - } - if (item->mask) { - unsigned int i; - const uint8_t *spec = item->spec; - - for (i = 0; i < size; ++i) - if ((spec[i] | mask[i]) != mask[i]) { - rte_errno = EINVAL; - return -rte_errno; - } - } - if (item->spec && item->last) { - uint8_t spec[size]; - uint8_t last[size]; - const uint8_t *apply = mask; - unsigned int i; - int ret; + unsigned int i; + const uint8_t *spec = item->spec; + const uint8_t *last = item->last; + const uint8_t *m = item->mask ? item->mask : mask; - if (item->mask) - apply = item->mask; - for (i = 0; i < size; ++i) { - spec[i] = ((const uint8_t *)item->spec)[i] & apply[i]; - last[i] = ((const uint8_t *)item->last)[i] & apply[i]; - } - ret = memcmp(spec, last, size); - if (ret != 0) { - rte_errno = EINVAL; - return -rte_errno; - } + if (!spec && (item->mask || last)) + goto error; + if (!spec) + return 0; + /* + * Single-pass check to make sure that: + * - item->mask is supported, no bits are set outside mask. + * - Both masked item->spec and item->last are equal (no range + * supported). + */ + for (i = 0; i < size; i++) { + if (!m[i]) + continue; + if ((m[i] | mask[i]) != mask[i]) + goto error; + if (last && ((spec[i] & m[i]) != (last[i] & m[i]))) + goto error; } return 0; +error: + rte_errno = ENOTSUP; + return -rte_errno; } /** @@ -2061,7 +2034,7 @@ mlx5_flow_create_action_queue_drop(struct rte_eth_dev *dev, parser->queue[HASH_RXQ_ETH].ibv_attr; if (parser->count) flow->cs = parser->cs; - if (!priv->dev->data->dev_started) + if (!dev->data->dev_started) return 0; parser->queue[HASH_RXQ_ETH].ibv_attr = NULL; flow->frxq[HASH_RXQ_ETH].ibv_flow = @@ -2113,7 +2086,6 @@ mlx5_flow_create_action_queue_rss(struct rte_eth_dev *dev, struct rte_flow *flow, struct rte_flow_error *error) { - struct priv *priv = dev->data->dev_private; unsigned int i; for (i = 0; i != hash_rxq_init_n; ++i) { @@ -2122,7 +2094,7 @@ mlx5_flow_create_action_queue_rss(struct rte_eth_dev *dev, flow->frxq[i].ibv_attr = parser->queue[i].ibv_attr; parser->queue[i].ibv_attr = NULL; flow->frxq[i].hash_fields = parser->queue[i].hash_fields; - if (!priv->dev->data->dev_started) + if (!dev->data->dev_started) continue; flow->frxq[i].hrxq = mlx5_hrxq_get(dev, @@ -2268,7 +2240,7 @@ mlx5_flow_create_action_queue(struct rte_eth_dev *dev, struct rte_flow *flow, struct rte_flow_error *error) { - struct priv *priv = dev->data->dev_private; + struct priv *priv __rte_unused = dev->data->dev_private; int ret; unsigned int i; unsigned int flows_n = 0; @@ -2281,7 +2253,7 @@ mlx5_flow_create_action_queue(struct rte_eth_dev *dev, goto error; if (parser->count) flow->cs = parser->cs; - if (!priv->dev->data->dev_started) + if (!dev->data->dev_started) return 0; for (i = 0; i != hash_rxq_init_n; ++i) { if (!flow->frxq[i].hrxq) @@ -3124,9 +3096,9 @@ mlx5_flow_isolate(struct rte_eth_dev *dev, } priv->isolated = !!enable; if (enable) - priv->dev->dev_ops = &mlx5_dev_ops_isolate; + dev->dev_ops = &mlx5_dev_ops_isolate; else - priv->dev->dev_ops = &mlx5_dev_ops; + dev->dev_ops = &mlx5_dev_ops; return 0; } @@ -3514,11 +3486,10 @@ mlx5_fdir_filter_flush(struct rte_eth_dev *dev) static void mlx5_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir_info *fdir_info) { - struct priv *priv = dev->data->dev_private; struct rte_eth_fdir_masks *mask = - &priv->dev->data->dev_conf.fdir_conf.mask; + &dev->data->dev_conf.fdir_conf.mask; - fdir_info->mode = priv->dev->data->dev_conf.fdir_conf.mode; + fdir_info->mode = dev->data->dev_conf.fdir_conf.mode; fdir_info->guarant_spc = 0; rte_memcpy(&fdir_info->mask, mask, sizeof(fdir_info->mask)); fdir_info->max_flexpayload = 0; @@ -3546,9 +3517,8 @@ static int mlx5_fdir_ctrl_func(struct rte_eth_dev *dev, enum rte_filter_op filter_op, void *arg) { - struct priv *priv = dev->data->dev_private; enum rte_fdir_mode fdir_mode = - priv->dev->data->dev_conf.fdir_conf.mode; + dev->data->dev_conf.fdir_conf.mode; if (filter_op == RTE_ETH_FILTER_NOP) return 0;