net/hns3: extract common interface to check duplicates
Extract a common interface for PF and VF to check whether the configured multicast MAC address from rte_eth_dev_mac_addr_add() is the same as the multicast MAC address from rte_eth_dev_set_mc_addr_list(). Signed-off-by: Huisong Li <lihuisong@huawei.com> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
This commit is contained in:
parent
3e7984b5d8
commit
3d491e5531
@ -1609,27 +1609,38 @@ hns3_add_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
hns3_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
|
||||
bool
|
||||
hns3_find_duplicate_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mc_addr)
|
||||
{
|
||||
char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
|
||||
struct rte_ether_addr *addr;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < hw->mc_addrs_num; i++) {
|
||||
addr = &hw->mc_addrs[i];
|
||||
/* Check if there are duplicate addresses */
|
||||
if (rte_is_same_ether_addr(addr, mac_addr)) {
|
||||
/* Check if there are duplicate addresses in mc_addrs[] */
|
||||
if (rte_is_same_ether_addr(addr, mc_addr)) {
|
||||
hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
|
||||
addr);
|
||||
addr);
|
||||
hns3_err(hw, "failed to add mc mac addr, same addrs"
|
||||
"(%s) is added by the set_mc_mac_addr_list "
|
||||
"API", mac_str);
|
||||
return -EINVAL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int
|
||||
hns3_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
|
||||
{
|
||||
char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
|
||||
int ret;
|
||||
|
||||
if (hns3_find_duplicate_mc_addr(hw, mac_addr))
|
||||
return -EINVAL;
|
||||
|
||||
ret = hns3_add_mc_mac_addr(hw, mac_addr);
|
||||
if (ret) {
|
||||
hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
|
||||
|
@ -1048,6 +1048,10 @@ void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status,
|
||||
uint32_t link_speed, uint8_t link_duplex);
|
||||
void hns3_parse_devargs(struct rte_eth_dev *dev);
|
||||
void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported);
|
||||
|
||||
bool hns3_find_duplicate_mc_addr(struct hns3_hw *hw,
|
||||
struct rte_ether_addr *mc_addr);
|
||||
|
||||
int hns3_restore_ptp(struct hns3_adapter *hns);
|
||||
int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev,
|
||||
struct rte_eth_conf *conf);
|
||||
|
@ -208,22 +208,10 @@ static int
|
||||
hns3vf_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
|
||||
{
|
||||
char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
|
||||
struct rte_ether_addr *addr;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < hw->mc_addrs_num; i++) {
|
||||
addr = &hw->mc_addrs[i];
|
||||
/* Check if there are duplicate addresses */
|
||||
if (rte_is_same_ether_addr(addr, mac_addr)) {
|
||||
hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
|
||||
addr);
|
||||
hns3_err(hw, "failed to add mc mac addr, same addrs"
|
||||
"(%s) is added by the set_mc_mac_addr_list "
|
||||
"API", mac_str);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
if (hns3_find_duplicate_mc_addr(hw, mac_addr))
|
||||
return -EINVAL;
|
||||
|
||||
ret = hns3vf_add_mc_mac_addr(hw, mac_addr);
|
||||
if (ret) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user