net/bnxt: support 58818 chip family
[dpdk.git] / drivers / net / i40e / i40e_ethdev_vf.c
index 53154c3..dc076ae 100644 (file)
@@ -260,7 +260,7 @@ i40evf_read_pfmsg(struct rte_eth_dev *dev, struct i40evf_arq_msg_info *data)
                case VIRTCHNL_EVENT_RESET_IMPENDING:
                        vf->vf_reset = true;
                        vf->pend_msg |= PFMSG_RESET_IMPENDING;
-                       PMD_DRV_LOG(INFO, "vf is reseting");
+                       PMD_DRV_LOG(INFO, "VF is resetting");
                        break;
                case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
                        vf->dev_closed = true;
@@ -314,7 +314,7 @@ _atomic_set_cmd(struct i40e_vf *vf, enum virtchnl_ops ops)
 #define ASQ_DELAY_MS  10
 
 static int
-i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
+_i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
 {
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
@@ -405,6 +405,19 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
        return err | vf->cmd_retval;
 }
 
+static int
+i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
+{
+       struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+       int err;
+
+       while (!rte_spinlock_trylock(&vf->cmd_send_lock))
+               rte_delay_us_sleep(50);
+       err = _i40evf_execute_vf_cmd(dev, args);
+       rte_spinlock_unlock(&vf->cmd_send_lock);
+       return err;
+}
+
 /*
  * Check API version with sync wait until version read or fail from admin queue
  */
@@ -1065,8 +1078,18 @@ i40evf_add_vlan(struct rte_eth_dev *dev, uint16_t vlanid)
        args.out_buffer = vf->aq_resp;
        args.out_size = I40E_AQ_BUF_SZ;
        err = i40evf_execute_vf_cmd(dev, &args);
-       if (err)
+       if (err) {
                PMD_DRV_LOG(ERR, "fail to execute command OP_ADD_VLAN");
+               return err;
+       }
+       /**
+        * In linux kernel driver on receiving ADD_VLAN it enables
+        * VLAN_STRIP by default. So reconfigure the vlan_offload
+        * as it was done by the app earlier.
+        */
+       err = i40evf_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK);
+       if (err)
+               PMD_DRV_LOG(ERR, "fail to set vlan_strip");
 
        return err;
 }
@@ -1246,6 +1269,7 @@ i40evf_init_vf(struct rte_eth_dev *dev)
 
        vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
        vf->dev_data = dev->data;
+       rte_spinlock_init(&vf->cmd_send_lock);
        err = i40e_set_mac_type(hw);
        if (err) {
                PMD_INIT_LOG(ERR, "set_mac_type failed: %d", err);
@@ -2392,6 +2416,7 @@ i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
                stats->imissed = pstats->rx_discards;
                stats->oerrors = pstats->tx_errors + pstats->tx_discards;
                stats->ibytes = pstats->rx_bytes;
+               stats->ibytes -= stats->ipackets * RTE_ETHER_CRC_LEN;
                stats->obytes = pstats->tx_bytes;
        } else {
                PMD_DRV_LOG(ERR, "Get statistics failed");