Currently, when promiscuous mode is enabled, it is just allowed to
accept all the unicast and broadcast packets in hns3 PF PMD driver. It
should also be able to receive multicast packets.
Fixes:
19a3ca4c99cf ("net/hns3: add start/stop and configure operations")
Cc: stable@dpdk.org
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
ret = hns3_cmd_send(hw, &desc, 1);
if (ret)
ret = hns3_cmd_send(hw, &desc, 1);
if (ret)
- PMD_INIT_LOG(ERR, "Set promisc mode fail, status is %d", ret);
+ PMD_INIT_LOG(ERR, "Set promisc mode fail, ret = %d", ret);
{
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
{
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
- bool en_mc_pmc = (dev->data->all_multicast == 1) ? true : false;
int ret;
rte_spinlock_lock(&hw->lock);
int ret;
rte_spinlock_lock(&hw->lock);
- ret = hns3_set_promisc_mode(hw, true, en_mc_pmc);
+ ret = hns3_set_promisc_mode(hw, true, true);
rte_spinlock_unlock(&hw->lock);
if (ret)
rte_spinlock_unlock(&hw->lock);
if (ret)
- hns3_err(hw, "Failed to enable promiscuous mode: %d", ret);
+ hns3_err(hw, "Failed to enable promiscuous mode, ret = %d",
+ ret);
static int
hns3_dev_promiscuous_disable(struct rte_eth_dev *dev)
{
static int
hns3_dev_promiscuous_disable(struct rte_eth_dev *dev)
{
+ bool allmulti = dev->data->all_multicast ? true : false;
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
- bool en_mc_pmc = (dev->data->all_multicast == 1) ? true : false;
int ret;
/* If now in all_multicast mode, must remain in all_multicast mode. */
rte_spinlock_lock(&hw->lock);
int ret;
/* If now in all_multicast mode, must remain in all_multicast mode. */
rte_spinlock_lock(&hw->lock);
- ret = hns3_set_promisc_mode(hw, false, en_mc_pmc);
+ ret = hns3_set_promisc_mode(hw, false, allmulti);
rte_spinlock_unlock(&hw->lock);
if (ret)
rte_spinlock_unlock(&hw->lock);
if (ret)
- hns3_err(hw, "Failed to disable promiscuous mode: %d", ret);
+ hns3_err(hw, "Failed to disable promiscuous mode, ret = %d",
+ ret);
{
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
{
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
- bool en_uc_pmc = (dev->data->promiscuous == 1) ? true : false;
+ if (dev->data->promiscuous)
+ return 0;
+
rte_spinlock_lock(&hw->lock);
rte_spinlock_lock(&hw->lock);
- ret = hns3_set_promisc_mode(hw, en_uc_pmc, true);
+ ret = hns3_set_promisc_mode(hw, false, true);
rte_spinlock_unlock(&hw->lock);
if (ret)
rte_spinlock_unlock(&hw->lock);
if (ret)
- hns3_err(hw, "Failed to enable allmulticast mode: %d", ret);
+ hns3_err(hw, "Failed to enable allmulticast mode, ret = %d",
+ ret);
{
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
{
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
- bool en_uc_pmc = (dev->data->promiscuous == 1) ? true : false;
int ret;
/* If now in promiscuous mode, must remain in all_multicast mode. */
int ret;
/* If now in promiscuous mode, must remain in all_multicast mode. */
- if (dev->data->promiscuous == 1)
+ if (dev->data->promiscuous)
return 0;
rte_spinlock_lock(&hw->lock);
return 0;
rte_spinlock_lock(&hw->lock);
- ret = hns3_set_promisc_mode(hw, en_uc_pmc, false);
+ ret = hns3_set_promisc_mode(hw, false, false);
rte_spinlock_unlock(&hw->lock);
if (ret)
rte_spinlock_unlock(&hw->lock);
if (ret)
- hns3_err(hw, "Failed to disable allmulticast mode: %d", ret);
+ hns3_err(hw, "Failed to disable allmulticast mode, ret = %d",
+ ret);
hns3_dev_promisc_restore(struct hns3_adapter *hns)
{
struct hns3_hw *hw = &hns->hw;
hns3_dev_promisc_restore(struct hns3_adapter *hns)
{
struct hns3_hw *hw = &hns->hw;
- bool en_mc_pmc;
- bool en_uc_pmc;
+ bool allmulti = hw->data->all_multicast ? true : false;
- en_uc_pmc = (hw->data->promiscuous == 1) ? true : false;
- en_mc_pmc = (hw->data->all_multicast == 1) ? true : false;
+ if (hw->data->promiscuous)
+ return hns3_set_promisc_mode(hw, true, true);
- return hns3_set_promisc_mode(hw, en_uc_pmc, en_mc_pmc);
+ return hns3_set_promisc_mode(hw, false, allmulti);