net/hns3: unify multicast MAC address set list
[dpdk.git] / drivers / net / hns3 / hns3_ethdev_vf.c
index 6af55f4..675db44 100644 (file)
@@ -204,72 +204,6 @@ hns3vf_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
        return ret;
 }
 
-static int
-hns3vf_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
-                   __rte_unused uint32_t idx,
-                   __rte_unused uint32_t pool)
-{
-       struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
-       int ret;
-
-       rte_spinlock_lock(&hw->lock);
-
-       /*
-        * In hns3 network engine adding UC and MC mac address with different
-        * commands with firmware. We need to determine whether the input
-        * address is a UC or a MC address to call different commands.
-        * By the way, it is recommended calling the API function named
-        * rte_eth_dev_set_mc_addr_list to set the MC mac address, because
-        * using the rte_eth_dev_mac_addr_add API function to set MC mac address
-        * may affect the specifications of UC mac addresses.
-        */
-       if (rte_is_multicast_ether_addr(mac_addr)) {
-               if (hns3_find_duplicate_mc_addr(hw, mac_addr)) {
-                       rte_spinlock_unlock(&hw->lock);
-                       return -EINVAL;
-               }
-               ret = hw->ops.add_mc_mac_addr(hw, mac_addr);
-       } else {
-               ret = hw->ops.add_uc_mac_addr(hw, mac_addr);
-       }
-
-       rte_spinlock_unlock(&hw->lock);
-       if (ret) {
-               hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-                                     mac_addr);
-               hns3_err(hw, "failed to add mac addr(%s), ret = %d", mac_str,
-                        ret);
-       }
-
-       return ret;
-}
-
-static void
-hns3vf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx)
-{
-       struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       /* index will be checked by upper level rte interface */
-       struct rte_ether_addr *mac_addr = &dev->data->mac_addrs[idx];
-       char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
-       int ret;
-
-       rte_spinlock_lock(&hw->lock);
-
-       if (rte_is_multicast_ether_addr(mac_addr))
-               ret = hw->ops.del_mc_mac_addr(hw, mac_addr);
-       else
-               ret = hw->ops.del_uc_mac_addr(hw, mac_addr);
-
-       rte_spinlock_unlock(&hw->lock);
-       if (ret) {
-               hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-                                     mac_addr);
-               hns3_err(hw, "failed to remove mac addr(%s), ret = %d",
-                        mac_str, ret);
-       }
-}
-
 static int
 hns3vf_set_default_mac_addr(struct rte_eth_dev *dev,
                            struct rte_ether_addr *mac_addr)
@@ -365,118 +299,6 @@ hns3vf_remove_mc_mac_addr(struct hns3_hw *hw,
        return ret;
 }
 
-static int
-hns3vf_set_mc_addr_chk_param(struct hns3_hw *hw,
-                            struct rte_ether_addr *mc_addr_set,
-                            uint32_t nb_mc_addr)
-{
-       char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
-       struct rte_ether_addr *addr;
-       uint32_t i;
-       uint32_t j;
-
-       if (nb_mc_addr > HNS3_MC_MACADDR_NUM) {
-               hns3_err(hw, "failed to set mc mac addr, nb_mc_addr(%u) "
-                        "invalid. valid range: 0~%d",
-                        nb_mc_addr, HNS3_MC_MACADDR_NUM);
-               return -EINVAL;
-       }
-
-       /* Check if input mac addresses are valid */
-       for (i = 0; i < nb_mc_addr; i++) {
-               addr = &mc_addr_set[i];
-               if (!rte_is_multicast_ether_addr(addr)) {
-                       hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-                                             addr);
-                       hns3_err(hw,
-                                "failed to set mc mac addr, addr(%s) invalid.",
-                                mac_str);
-                       return -EINVAL;
-               }
-
-               /* Check if there are duplicate addresses */
-               for (j = i + 1; j < nb_mc_addr; j++) {
-                       if (rte_is_same_ether_addr(addr, &mc_addr_set[j])) {
-                               hns3_ether_format_addr(mac_str,
-                                                     RTE_ETHER_ADDR_FMT_SIZE,
-                                                     addr);
-                               hns3_err(hw, "failed to set mc mac addr, "
-                                        "addrs invalid. two same addrs(%s).",
-                                        mac_str);
-                               return -EINVAL;
-                       }
-               }
-
-               /*
-                * Check if there are duplicate addresses between mac_addrs
-                * and mc_addr_set
-                */
-               for (j = 0; j < HNS3_VF_UC_MACADDR_NUM; j++) {
-                       if (rte_is_same_ether_addr(addr,
-                                                  &hw->data->mac_addrs[j])) {
-                               hns3_ether_format_addr(mac_str,
-                                                     RTE_ETHER_ADDR_FMT_SIZE,
-                                                     addr);
-                               hns3_err(hw, "failed to set mc mac addr, "
-                                        "addrs invalid. addrs(%s) has already "
-                                        "configured in mac_addr add API",
-                                        mac_str);
-                               return -EINVAL;
-                       }
-               }
-       }
-
-       return 0;
-}
-
-static int
-hns3vf_set_mc_mac_addr_list(struct rte_eth_dev *dev,
-                           struct rte_ether_addr *mc_addr_set,
-                           uint32_t nb_mc_addr)
-{
-       struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       struct rte_ether_addr *addr;
-       int cur_addr_num;
-       int set_addr_num;
-       int num;
-       int ret;
-       int i;
-
-       ret = hns3vf_set_mc_addr_chk_param(hw, mc_addr_set, nb_mc_addr);
-       if (ret)
-               return ret;
-
-       rte_spinlock_lock(&hw->lock);
-       cur_addr_num = hw->mc_addrs_num;
-       for (i = 0; i < cur_addr_num; i++) {
-               num = cur_addr_num - i - 1;
-               addr = &hw->mc_addrs[num];
-               ret = hw->ops.del_mc_mac_addr(hw, addr);
-               if (ret) {
-                       rte_spinlock_unlock(&hw->lock);
-                       return ret;
-               }
-
-               hw->mc_addrs_num--;
-       }
-
-       set_addr_num = (int)nb_mc_addr;
-       for (i = 0; i < set_addr_num; i++) {
-               addr = &mc_addr_set[i];
-               ret = hw->ops.add_mc_mac_addr(hw, addr);
-               if (ret) {
-                       rte_spinlock_unlock(&hw->lock);
-                       return ret;
-               }
-
-               rte_ether_addr_copy(addr, &hw->mc_addrs[hw->mc_addrs_num]);
-               hw->mc_addrs_num++;
-       }
-       rte_spinlock_unlock(&hw->lock);
-
-       return 0;
-}
-
 static int
 hns3vf_set_promisc_mode(struct hns3_hw *hw, bool en_bc_pmc,
                        bool en_uc_pmc, bool en_mc_pmc)
@@ -2805,10 +2627,10 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
        .txq_info_get       = hns3_txq_info_get,
        .rx_burst_mode_get  = hns3_rx_burst_mode_get,
        .tx_burst_mode_get  = hns3_tx_burst_mode_get,
-       .mac_addr_add       = hns3vf_add_mac_addr,
-       .mac_addr_remove    = hns3vf_remove_mac_addr,
+       .mac_addr_add       = hns3_add_mac_addr,
+       .mac_addr_remove    = hns3_remove_mac_addr,
        .mac_addr_set       = hns3vf_set_default_mac_addr,
-       .set_mc_addr_list   = hns3vf_set_mc_mac_addr_list,
+       .set_mc_addr_list   = hns3_set_mc_mac_addr_list,
        .link_update        = hns3vf_dev_link_update,
        .rss_hash_update    = hns3_dev_rss_hash_update,
        .rss_hash_conf_get  = hns3_dev_rss_hash_conf_get,