ethdev: increase port id range
[dpdk.git] / drivers / net / ixgbe / ixgbe_ethdev.c
index 31793cc..a7d7acc 100644 (file)
@@ -169,6 +169,7 @@ static void ixgbe_dev_stop(struct rte_eth_dev *dev);
 static int  ixgbe_dev_set_link_up(struct rte_eth_dev *dev);
 static int  ixgbe_dev_set_link_down(struct rte_eth_dev *dev);
 static void ixgbe_dev_close(struct rte_eth_dev *dev);
+static int  ixgbe_dev_reset(struct rte_eth_dev *dev);
 static void ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
 static void ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
 static void ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev);
@@ -265,6 +266,7 @@ static int ixgbevf_dev_link_update(struct rte_eth_dev *dev,
                                   int wait_to_complete);
 static void ixgbevf_dev_stop(struct rte_eth_dev *dev);
 static void ixgbevf_dev_close(struct rte_eth_dev *dev);
+static int  ixgbevf_dev_reset(struct rte_eth_dev *dev);
 static void ixgbevf_intr_disable(struct ixgbe_hw *hw);
 static void ixgbevf_intr_enable(struct ixgbe_hw *hw);
 static void ixgbevf_dev_stats_get(struct rte_eth_dev *dev,
@@ -442,13 +444,8 @@ static const struct rte_pci_id pci_id_ixgbe_map[] = {
        { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4_MEZZ) },
        { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KR) },
        { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_COMBO_BACKPLANE) },
-       { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_KX4_KR_MEZZ) },
        { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_CX4) },
        { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP) },
-       { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_SFP) },
-       { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_RNDC) },
-       { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_560FLR) },
-       { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_ECNA_DP) },
        { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BACKPLANE_FCOE) },
        { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_FCOE) },
        { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_EM) },
@@ -523,6 +520,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
        .dev_set_link_up    = ixgbe_dev_set_link_up,
        .dev_set_link_down  = ixgbe_dev_set_link_down,
        .dev_close            = ixgbe_dev_close,
+       .dev_reset            = ixgbe_dev_reset,
        .promiscuous_enable   = ixgbe_dev_promiscuous_enable,
        .promiscuous_disable  = ixgbe_dev_promiscuous_disable,
        .allmulticast_enable  = ixgbe_dev_allmulticast_enable,
@@ -613,6 +611,7 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
        .xstats_reset         = ixgbevf_dev_stats_reset,
        .xstats_get_names     = ixgbevf_dev_xstats_get_names,
        .dev_close            = ixgbevf_dev_close,
+       .dev_reset            = ixgbevf_dev_reset,
        .allmulticast_enable  = ixgbevf_dev_allmulticast_enable,
        .allmulticast_disable = ixgbevf_dev_allmulticast_disable,
        .dev_infos_get        = ixgbevf_dev_info_get,
@@ -1337,12 +1336,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
        /* initialize l2 tunnel filter list & hash */
        ixgbe_l2_tn_filter_init(eth_dev);
 
-       TAILQ_INIT(&filter_ntuple_list);
-       TAILQ_INIT(&filter_ethertype_list);
-       TAILQ_INIT(&filter_syn_list);
-       TAILQ_INIT(&filter_fdir_list);
-       TAILQ_INIT(&filter_l2_tunnel_list);
-       TAILQ_INIT(&ixgbe_flow_list);
+       /* initialize flow filter lists */
+       ixgbe_filterlist_init();
 
        /* initialize bandwidth configuration info */
        memset(bw_conf, 0, sizeof(struct ixgbe_bw_conf));
@@ -2509,8 +2504,9 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
        *    - fixed speed: TODO implement
        */
        if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
-               PMD_INIT_LOG(ERR, "Invalid link_speeds for port %hhu; fix speed not supported",
-                            dev->data->port_id);
+               PMD_INIT_LOG(ERR,
+               "Invalid link_speeds for port %u, fix speed not supported",
+                               dev->data->port_id);
                return -EINVAL;
        }
 
@@ -2647,9 +2643,22 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 
        speed = 0x0;
        if (*link_speeds == ETH_LINK_SPEED_AUTONEG) {
-               speed = (hw->mac.type != ixgbe_mac_82598EB) ?
-                               IXGBE_LINK_SPEED_82599_AUTONEG :
-                               IXGBE_LINK_SPEED_82598_AUTONEG;
+               switch (hw->mac.type) {
+               case ixgbe_mac_82598EB:
+                       speed = IXGBE_LINK_SPEED_82598_AUTONEG;
+                       break;
+               case ixgbe_mac_82599EB:
+               case ixgbe_mac_X540:
+                       speed = IXGBE_LINK_SPEED_82599_AUTONEG;
+                       break;
+               case ixgbe_mac_X550:
+               case ixgbe_mac_X550EM_x:
+               case ixgbe_mac_X550EM_a:
+                       speed = IXGBE_LINK_SPEED_X550_AUTONEG;
+                       break;
+               default:
+                       speed = IXGBE_LINK_SPEED_82599_AUTONEG;
+               }
        } else {
                if (*link_speeds & ETH_LINK_SPEED_10G)
                        speed |= IXGBE_LINK_SPEED_10GB_FULL;
@@ -2693,7 +2702,7 @@ skip_link_setup:
        ixgbe_l2_tunnel_conf(dev);
        ixgbe_filter_restore(dev);
 
-       if (!tm_conf->committed)
+       if (tm_conf->root && !tm_conf->committed)
                PMD_DRV_LOG(WARNING,
                            "please call hierarchy_commit() "
                            "before starting the port");
@@ -2834,7 +2843,7 @@ ixgbe_dev_set_link_down(struct rte_eth_dev *dev)
 }
 
 /*
- * Reest and stop device.
+ * Reset and stop device.
  */
 static void
 ixgbe_dev_close(struct rte_eth_dev *dev)
@@ -2857,6 +2866,32 @@ ixgbe_dev_close(struct rte_eth_dev *dev)
        ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
 }
 
+/*
+ * Reset PF device.
+ */
+static int
+ixgbe_dev_reset(struct rte_eth_dev *dev)
+{
+       int ret;
+
+       /* When a DPDK PMD PF begin to reset PF port, it should notify all
+        * its VF to make them align with it. The detailed notification
+        * mechanism is PMD specific. As to ixgbe PF, it is rather complex.
+        * To avoid unexpected behavior in VF, currently reset of PF with
+        * SR-IOV activation is not supported. It might be supported later.
+        */
+       if (dev->data->sriov.active)
+               return -ENOTSUP;
+
+       ret = eth_ixgbe_dev_uninit(dev);
+       if (ret)
+               return ret;
+
+       ret = eth_ixgbe_dev_init(dev);
+
+       return ret;
+}
+
 static void
 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
                           struct ixgbe_hw_stats *hw_stats,
@@ -3693,6 +3728,10 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
            hw->mac.type == ixgbe_mac_X550_vf) {
                dev_info->speed_capa |= ETH_LINK_SPEED_100M;
        }
+       if (hw->mac.type == ixgbe_mac_X550) {
+               dev_info->speed_capa |= ETH_LINK_SPEED_2_5G;
+               dev_info->speed_capa |= ETH_LINK_SPEED_5G;
+       }
 }
 
 static const uint32_t *
@@ -3972,6 +4011,14 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
                link.link_speed = ETH_SPEED_NUM_1G;
                break;
 
+       case IXGBE_LINK_SPEED_2_5GB_FULL:
+               link.link_speed = ETH_SPEED_NUM_2_5G;
+               break;
+
+       case IXGBE_LINK_SPEED_5GB_FULL:
+               link.link_speed = ETH_SPEED_NUM_5G;
+               break;
+
        case IXGBE_LINK_SPEED_10GB_FULL:
                link.link_speed = ETH_SPEED_NUM_10G;
                break;
@@ -5058,6 +5105,23 @@ ixgbevf_dev_close(struct rte_eth_dev *dev)
        ixgbevf_remove_mac_addr(dev, 0);
 }
 
+/*
+ * Reset VF device
+ */
+static int
+ixgbevf_dev_reset(struct rte_eth_dev *dev)
+{
+       int ret;
+
+       ret = eth_ixgbevf_dev_uninit(dev);
+       if (ret)
+               return ret;
+
+       ret = eth_ixgbevf_dev_init(dev);
+
+       return ret;
+}
+
 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 {
        struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -5430,13 +5494,13 @@ ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
        IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
 
        /* write pool mirrror control  register */
-       if (mirror_conf->rule_type == ETH_MIRROR_VIRTUAL_POOL_UP) {
+       if (mirror_conf->rule_type & ETH_MIRROR_VIRTUAL_POOL_UP) {
                IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), mp_lsb);
                IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset),
                                mp_msb);
        }
        /* write VLAN mirrror control  register */
-       if (mirror_conf->rule_type == ETH_MIRROR_VLAN) {
+       if (mirror_conf->rule_type & ETH_MIRROR_VLAN) {
                IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), mv_lsb);
                IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset),
                                mv_msb);
@@ -5461,6 +5525,9 @@ ixgbe_mirror_rule_reset(struct rte_eth_dev *dev, uint8_t rule_id)
        if (ixgbe_vt_check(hw) < 0)
                return -ENOTSUP;
 
+       if (rule_id >= IXGBE_MAX_MIRROR_RULES)
+               return -EINVAL;
+
        memset(&mr_info->mr_conf[rule_id], 0,
               sizeof(struct rte_eth_mirror_conf));
 
@@ -5618,7 +5685,8 @@ ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
                tmp |= (msix_vector << (8 * (queue & 0x3)));
                IXGBE_WRITE_REG(hw, IXGBE_IVAR(idx), tmp);
        } else if ((hw->mac.type == ixgbe_mac_82599EB) ||
-                       (hw->mac.type == ixgbe_mac_X540)) {
+                       (hw->mac.type == ixgbe_mac_X540) ||
+                       (hw->mac.type == ixgbe_mac_X550)) {
                if (direction == -1) {
                        /* other causes */
                        idx = ((queue & 1) * 8);
@@ -5726,6 +5794,7 @@ ixgbe_configure_msix(struct rte_eth_dev *dev)
                break;
        case ixgbe_mac_82599EB:
        case ixgbe_mac_X540:
+       case ixgbe_mac_X550:
                ixgbe_set_ivar_map(hw, -1, 1, IXGBE_MISC_VEC_ID);
                break;
        default:
@@ -6288,7 +6357,7 @@ ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
                                sizeof(struct ixgbe_5tuple_filter), 0);
                if (filter == NULL)
                        return -ENOMEM;
-               (void)rte_memcpy(&filter->filter_info,
+               rte_memcpy(&filter->filter_info,
                                 &filter_5tuple,
                                 sizeof(struct ixgbe_5tuple_filter_info));
                filter->queue = ntuple_filter->queue;
@@ -7504,7 +7573,7 @@ ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
                if (!node)
                        return -ENOMEM;
 
-               (void)rte_memcpy(&node->key,
+               rte_memcpy(&node->key,
                                 &key,
                                 sizeof(struct ixgbe_l2_tn_key));
                node->pool = l2_tunnel->pool;