net/mlx5: fix Rx VLAN stripping capability check
authorAdrien Mazarguil <adrien.mazarguil@6wind.com>
Wed, 8 Jun 2016 09:43:28 +0000 (11:43 +0200)
committerBruce Richardson <bruce.richardson@intel.com>
Mon, 20 Jun 2016 15:21:49 +0000 (17:21 +0200)
A hardware capability check is missing before enabling RX VLAN stripping
during queue setup.

Also, while dev_conf.rxmode.hw_vlan_strip is currently a single bit that
can be stored in priv->hw_vlan_strip directly, it should be interpreted as
a boolean value for safety.

Fixes: f3db9489188a ("mlx5: support Rx VLAN stripping")

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
drivers/net/mlx5/mlx5_rxq.c
drivers/net/mlx5/mlx5_vlan.c

index 469ba98..0bcf55b 100644 (file)
@@ -1222,7 +1222,8 @@ rxq_setup(struct rte_eth_dev *dev, struct rxq *rxq, uint16_t desc,
        DEBUG("priv->device_attr.max_sge is %d",
              priv->device_attr.max_sge);
        /* Configure VLAN stripping. */
        DEBUG("priv->device_attr.max_sge is %d",
              priv->device_attr.max_sge);
        /* Configure VLAN stripping. */
-       tmpl.vlan_strip = dev->data->dev_conf.rxmode.hw_vlan_strip;
+       tmpl.vlan_strip = (priv->hw_vlan_strip &&
+                          !!dev->data->dev_conf.rxmode.hw_vlan_strip);
        attr.wq = (struct ibv_exp_wq_init_attr){
                .wq_context = NULL, /* Could be useful in the future. */
                .wq_type = IBV_EXP_WQT_RQ,
        attr.wq = (struct ibv_exp_wq_init_attr){
                .wq_context = NULL, /* Could be useful in the future. */
                .wq_type = IBV_EXP_WQT_RQ,
index ea7af1e..ff40538 100644 (file)
@@ -218,7 +218,7 @@ mlx5_vlan_offload_set(struct rte_eth_dev *dev, int mask)
        unsigned int i;
 
        if (mask & ETH_VLAN_STRIP_MASK) {
        unsigned int i;
 
        if (mask & ETH_VLAN_STRIP_MASK) {
-               int hw_vlan_strip = dev->data->dev_conf.rxmode.hw_vlan_strip;
+               int hw_vlan_strip = !!dev->data->dev_conf.rxmode.hw_vlan_strip;
 
                if (!priv->hw_vlan_strip) {
                        ERROR("VLAN stripping is not supported");
 
                if (!priv->hw_vlan_strip) {
                        ERROR("VLAN stripping is not supported");