static int hinic_set_dev_promiscuous(struct hinic_nic_dev *nic_dev, bool enable)
{
- u32 rx_mode_ctrl = nic_dev->rx_mode_status;
+ u32 rx_mode_ctrl;
+ int err;
+
+ err = hinic_mutex_lock(&nic_dev->rx_mode_mutex);
+ if (err)
+ return err;
+
+ rx_mode_ctrl = nic_dev->rx_mode_status;
if (enable)
rx_mode_ctrl |= HINIC_RX_MODE_PROMISC;
else
rx_mode_ctrl &= (~HINIC_RX_MODE_PROMISC);
- return hinic_config_rx_mode(nic_dev, rx_mode_ctrl);
+ err = hinic_config_rx_mode(nic_dev, rx_mode_ctrl);
+
+ (void)hinic_mutex_unlock(&nic_dev->rx_mode_mutex);
+
+ return err;
}
/**
static int hinic_set_dev_allmulticast(struct hinic_nic_dev *nic_dev,
bool enable)
{
- u32 rx_mode_ctrl = nic_dev->rx_mode_status;
+ u32 rx_mode_ctrl;
+ int err;
+
+ err = hinic_mutex_lock(&nic_dev->rx_mode_mutex);
+ if (err)
+ return err;
+
+ rx_mode_ctrl = nic_dev->rx_mode_status;
if (enable)
rx_mode_ctrl |= HINIC_RX_MODE_MC_ALL;
else
rx_mode_ctrl &= (~HINIC_RX_MODE_MC_ALL);
- return hinic_config_rx_mode(nic_dev, rx_mode_ctrl);
+ err = hinic_config_rx_mode(nic_dev, rx_mode_ctrl);
+
+ (void)hinic_mutex_unlock(&nic_dev->rx_mode_mutex);
+
+ return err;
}
/**
}
rte_bit_relaxed_set32(HINIC_DEV_INTR_EN, &nic_dev->dev_status);
+ hinic_mutex_init(&nic_dev->rx_mode_mutex, NULL);
+
/* initialize filter info */
filter_info = &nic_dev->filter;
tcam_info = &nic_dev->tcam;
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
+ hinic_mutex_destroy(&nic_dev->rx_mode_mutex);
+
hinic_dev_close(dev);
dev->dev_ops = NULL;