ethdev: change promiscuous callbacks to return status
[dpdk.git] / drivers / net / i40e / i40e_ethdev.c
index bd8a969..79bd3a7 100644 (file)
@@ -223,8 +223,8 @@ static int i40e_dev_start(struct rte_eth_dev *dev);
 static void i40e_dev_stop(struct rte_eth_dev *dev);
 static void i40e_dev_close(struct rte_eth_dev *dev);
 static int  i40e_dev_reset(struct rte_eth_dev *dev);
-static void i40e_dev_promiscuous_enable(struct rte_eth_dev *dev);
-static void i40e_dev_promiscuous_disable(struct rte_eth_dev *dev);
+static int i40e_dev_promiscuous_enable(struct rte_eth_dev *dev);
+static int i40e_dev_promiscuous_disable(struct rte_eth_dev *dev);
 static void i40e_dev_allmulticast_enable(struct rte_eth_dev *dev);
 static void i40e_dev_allmulticast_disable(struct rte_eth_dev *dev);
 static int i40e_dev_set_link_up(struct rte_eth_dev *dev);
@@ -237,14 +237,10 @@ static int i40e_dev_xstats_get_names(struct rte_eth_dev *dev,
                                     struct rte_eth_xstat_name *xstats_names,
                                     unsigned limit);
 static void i40e_dev_stats_reset(struct rte_eth_dev *dev);
-static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
-                                           uint16_t queue_id,
-                                           uint8_t stat_idx,
-                                           uint8_t is_rx);
 static int i40e_fw_version_get(struct rte_eth_dev *dev,
                                char *fw_version, size_t fw_size);
-static void i40e_dev_info_get(struct rte_eth_dev *dev,
-                             struct rte_eth_dev_info *dev_info);
+static int i40e_dev_info_get(struct rte_eth_dev *dev,
+                            struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
                                uint16_t vlan_id,
                                int on);
@@ -457,7 +453,6 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
        .xstats_get_names             = i40e_dev_xstats_get_names,
        .stats_reset                  = i40e_dev_stats_reset,
        .xstats_reset                 = i40e_dev_stats_reset,
-       .queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
        .fw_version_get               = i40e_fw_version_get,
        .dev_infos_get                = i40e_dev_info_get,
        .dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
@@ -701,8 +696,7 @@ static int eth_i40e_pci_remove(struct rte_pci_device *pci_dev)
 
 static struct rte_pci_driver rte_i40e_pmd = {
        .id_table = pci_id_i40e_map,
-       .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
-                    RTE_PCI_DRV_IOVA_AS_VA,
+       .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
        .probe = eth_i40e_pci_probe,
        .remove = eth_i40e_pci_remove,
 };
@@ -1363,6 +1357,10 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)
                PMD_INIT_LOG(ERR, "Failed to init adminq: %d", ret);
                return -EIO;
        }
+       /* Firmware of SFP x722 does not support adminq option */
+       if (hw->device_id == I40E_DEV_ID_SFP_X722)
+               hw->flags &= ~I40E_HW_FLAG_802_1AD_CAPABLE;
+
        PMD_INIT_LOG(INFO, "FW %d.%d API %d.%d NVM %02d.%02d.%02d eetrack %04x",
                     hw->aq.fw_maj_ver, hw->aq.fw_min_ver,
                     hw->aq.api_maj_ver, hw->aq.api_min_ver,
@@ -1600,6 +1598,7 @@ err_init_tunnel_filter_list:
        rte_free(pf->ethertype.hash_map);
 err_init_ethtype_filter_list:
        rte_free(dev->data->mac_addrs);
+       dev->data->mac_addrs = NULL;
 err_mac_alloc:
        i40e_vsi_release(pf->main_vsi);
 err_setup_pf_switch:
@@ -2565,7 +2564,7 @@ i40e_dev_reset(struct rte_eth_dev *dev)
        return ret;
 }
 
-static void
+static int
 i40e_dev_promiscuous_enable(struct rte_eth_dev *dev)
 {
        struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -2575,17 +2574,25 @@ i40e_dev_promiscuous_enable(struct rte_eth_dev *dev)
 
        status = i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid,
                                                     true, NULL, true);
-       if (status != I40E_SUCCESS)
+       if (status != I40E_SUCCESS) {
                PMD_DRV_LOG(ERR, "Failed to enable unicast promiscuous");
+               return -EAGAIN;
+       }
 
        status = i40e_aq_set_vsi_multicast_promiscuous(hw, vsi->seid,
                                                        TRUE, NULL);
-       if (status != I40E_SUCCESS)
+       if (status != I40E_SUCCESS) {
                PMD_DRV_LOG(ERR, "Failed to enable multicast promiscuous");
+               /* Rollback unicast promiscuous mode */
+               i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid,
+                                                   false, NULL, true);
+               return -EAGAIN;
+       }
 
+       return 0;
 }
 
-static void
+static int
 i40e_dev_promiscuous_disable(struct rte_eth_dev *dev)
 {
        struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -2595,17 +2602,26 @@ i40e_dev_promiscuous_disable(struct rte_eth_dev *dev)
 
        status = i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid,
                                                     false, NULL, true);
-       if (status != I40E_SUCCESS)
+       if (status != I40E_SUCCESS) {
                PMD_DRV_LOG(ERR, "Failed to disable unicast promiscuous");
+               return -EAGAIN;
+       }
 
        /* must remain in all_multicast mode */
        if (dev->data->all_multicast == 1)
-               return;
+               return 0;
 
        status = i40e_aq_set_vsi_multicast_promiscuous(hw, vsi->seid,
                                                        false, NULL);
-       if (status != I40E_SUCCESS)
+       if (status != I40E_SUCCESS) {
                PMD_DRV_LOG(ERR, "Failed to disable multicast promiscuous");
+               /* Rollback unicast promiscuous mode */
+               i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid,
+                                                   true, NULL, true);
+               return -EAGAIN;
+       }
+
+       return 0;
 }
 
 static void
@@ -3431,17 +3447,6 @@ i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
        return count;
 }
 
-static int
-i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
-                                __rte_unused uint16_t queue_id,
-                                __rte_unused uint8_t stat_idx,
-                                __rte_unused uint8_t is_rx)
-{
-       PMD_INIT_FUNC_TRACE();
-
-       return -ENOSYS;
-}
-
 static int
 i40e_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
 {
@@ -3495,7 +3500,7 @@ i40e_need_stop_lldp(struct rte_eth_dev *dev)
        return false;
 }
 
-static void
+static int
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
        struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -3632,6 +3637,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        }
        dev_info->default_rxportconf.burst_size = 32;
        dev_info->default_txportconf.burst_size = 32;
+
+       return 0;
 }
 
 static int
@@ -11661,7 +11668,7 @@ i40e_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
                               I40E_PFINT_DYN_CTLN_ITR_INDX_MASK);
 
        I40E_WRITE_FLUSH(hw);
-       rte_intr_enable(&pci_dev->intr_handle);
+       rte_intr_ack(&pci_dev->intr_handle);
 
        return 0;
 }