Commit 8b5d10e4 authored by David S. Miller's avatar David S. Miller

Merge branch 'net-hns3-refactor-for-MAC-table'

Huazhong Tan says:

====================
net: hns3: refactor for MAC table

This patchset refactors the MAC table management, configure
the MAC address asynchronously, instead of synchronously.
Base on this change, it also refines the handle of promisc
mode and filter table entries restoring after reset.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents d4833896 039ba863
...@@ -45,6 +45,7 @@ enum HCLGE_MBX_OPCODE { ...@@ -45,6 +45,7 @@ enum HCLGE_MBX_OPCODE {
HCLGE_MBX_GET_MEDIA_TYPE, /* (VF -> PF) get media type */ HCLGE_MBX_GET_MEDIA_TYPE, /* (VF -> PF) get media type */
HCLGE_MBX_PUSH_PROMISC_INFO, /* (PF -> VF) push vf promisc info */ HCLGE_MBX_PUSH_PROMISC_INFO, /* (PF -> VF) push vf promisc info */
HCLGE_MBX_VF_UNINIT, /* (VF -> PF) vf is unintializing */ HCLGE_MBX_VF_UNINIT, /* (VF -> PF) vf is unintializing */
HCLGE_MBX_HANDLE_VF_TBL, /* (VF -> PF) store/clear hw table */
HCLGE_MBX_GET_VF_FLR_STATUS = 200, /* (M7 -> PF) get vf flr status */ HCLGE_MBX_GET_VF_FLR_STATUS = 200, /* (M7 -> PF) get vf flr status */
HCLGE_MBX_PUSH_LINK_STATUS, /* (M7 -> PF) get port link status */ HCLGE_MBX_PUSH_LINK_STATUS, /* (M7 -> PF) get port link status */
...@@ -70,6 +71,10 @@ enum hclge_mbx_vlan_cfg_subcode { ...@@ -70,6 +71,10 @@ enum hclge_mbx_vlan_cfg_subcode {
HCLGE_MBX_GET_PORT_BASE_VLAN_STATE, /* get port based vlan state */ HCLGE_MBX_GET_PORT_BASE_VLAN_STATE, /* get port based vlan state */
}; };
enum hclge_mbx_tbl_cfg_subcode {
HCLGE_MBX_VPORT_LIST_CLEAR,
};
#define HCLGE_MBX_MAX_MSG_SIZE 14 #define HCLGE_MBX_MAX_MSG_SIZE 14
#define HCLGE_MBX_MAX_RESP_DATA_SIZE 8U #define HCLGE_MBX_MAX_RESP_DATA_SIZE 8U
#define HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM 4 #define HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM 4
......
...@@ -233,7 +233,6 @@ struct hnae3_ae_dev { ...@@ -233,7 +233,6 @@ struct hnae3_ae_dev {
struct list_head node; struct list_head node;
u32 flag; u32 flag;
unsigned long hw_err_reset_req; unsigned long hw_err_reset_req;
enum hnae3_reset_type reset_type;
void *priv; void *priv;
}; };
...@@ -270,6 +269,8 @@ struct hnae3_ae_dev { ...@@ -270,6 +269,8 @@ struct hnae3_ae_dev {
* Set loopback * Set loopback
* set_promisc_mode * set_promisc_mode
* Set promisc mode * Set promisc mode
* request_update_promisc_mode
* request to hclge(vf) to update promisc mode
* set_mtu() * set_mtu()
* set mtu * set mtu
* get_pauseparam() * get_pauseparam()
...@@ -354,8 +355,6 @@ struct hnae3_ae_dev { ...@@ -354,8 +355,6 @@ struct hnae3_ae_dev {
* Set vlan filter config of Ports * Set vlan filter config of Ports
* set_vf_vlan_filter() * set_vf_vlan_filter()
* Set vlan filter config of vf * Set vlan filter config of vf
* restore_vlan_table()
* Restore vlan filter entries after reset
* enable_hw_strip_rxvtag() * enable_hw_strip_rxvtag()
* Enable/disable hardware strip vlan tag of packets received * Enable/disable hardware strip vlan tag of packets received
* set_gro_en * set_gro_en
...@@ -408,6 +407,7 @@ struct hnae3_ae_ops { ...@@ -408,6 +407,7 @@ struct hnae3_ae_ops {
int (*set_promisc_mode)(struct hnae3_handle *handle, bool en_uc_pmc, int (*set_promisc_mode)(struct hnae3_handle *handle, bool en_uc_pmc,
bool en_mc_pmc); bool en_mc_pmc);
void (*request_update_promisc_mode)(struct hnae3_handle *handle);
int (*set_mtu)(struct hnae3_handle *handle, int new_mtu); int (*set_mtu)(struct hnae3_handle *handle, int new_mtu);
void (*get_pauseparam)(struct hnae3_handle *handle, void (*get_pauseparam)(struct hnae3_handle *handle,
...@@ -525,7 +525,6 @@ struct hnae3_ae_ops { ...@@ -525,7 +525,6 @@ struct hnae3_ae_ops {
struct ethtool_rxnfc *cmd); struct ethtool_rxnfc *cmd);
int (*get_fd_all_rules)(struct hnae3_handle *handle, int (*get_fd_all_rules)(struct hnae3_handle *handle,
struct ethtool_rxnfc *cmd, u32 *rule_locs); struct ethtool_rxnfc *cmd, u32 *rule_locs);
int (*restore_fd_rules)(struct hnae3_handle *handle);
void (*enable_fd)(struct hnae3_handle *handle, bool enable); void (*enable_fd)(struct hnae3_handle *handle, bool enable);
int (*add_arfs_entry)(struct hnae3_handle *handle, u16 queue_id, int (*add_arfs_entry)(struct hnae3_handle *handle, u16 queue_id,
u16 flow_id, struct flow_keys *fkeys); u16 flow_id, struct flow_keys *fkeys);
...@@ -539,7 +538,6 @@ struct hnae3_ae_ops { ...@@ -539,7 +538,6 @@ struct hnae3_ae_ops {
void (*set_timer_task)(struct hnae3_handle *handle, bool enable); void (*set_timer_task)(struct hnae3_handle *handle, bool enable);
int (*mac_connect_phy)(struct hnae3_handle *handle); int (*mac_connect_phy)(struct hnae3_handle *handle);
void (*mac_disconnect_phy)(struct hnae3_handle *handle); void (*mac_disconnect_phy)(struct hnae3_handle *handle);
void (*restore_vlan_table)(struct hnae3_handle *handle);
int (*get_vf_config)(struct hnae3_handle *handle, int vf, int (*get_vf_config)(struct hnae3_handle *handle, int vf,
struct ifla_vf_info *ivf); struct ifla_vf_info *ivf);
int (*set_vf_link_state)(struct hnae3_handle *handle, int vf, int (*set_vf_link_state)(struct hnae3_handle *handle, int vf,
......
...@@ -262,6 +262,8 @@ static void hns3_dbg_help(struct hnae3_handle *h) ...@@ -262,6 +262,8 @@ static void hns3_dbg_help(struct hnae3_handle *h)
dev_info(&h->pdev->dev, "dump mac tnl status\n"); dev_info(&h->pdev->dev, "dump mac tnl status\n");
dev_info(&h->pdev->dev, "dump loopback\n"); dev_info(&h->pdev->dev, "dump loopback\n");
dev_info(&h->pdev->dev, "dump qs shaper [qs id]\n"); dev_info(&h->pdev->dev, "dump qs shaper [qs id]\n");
dev_info(&h->pdev->dev, "dump uc mac list <func id>\n");
dev_info(&h->pdev->dev, "dump mc mac list <func id>\n");
memset(printf_buf, 0, HNS3_DBG_BUF_LEN); memset(printf_buf, 0, HNS3_DBG_BUF_LEN);
strncat(printf_buf, "dump reg [[bios common] [ssu <port_id>]", strncat(printf_buf, "dump reg [[bios common] [ssu <port_id>]",
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
} while (0) } while (0)
static void hns3_clear_all_ring(struct hnae3_handle *h, bool force); static void hns3_clear_all_ring(struct hnae3_handle *h, bool force);
static void hns3_remove_hw_addr(struct net_device *netdev);
static const char hns3_driver_name[] = "hns3"; static const char hns3_driver_name[] = "hns3";
static const char hns3_driver_string[] = static const char hns3_driver_string[] =
...@@ -548,6 +547,13 @@ static int hns3_nic_uc_unsync(struct net_device *netdev, ...@@ -548,6 +547,13 @@ static int hns3_nic_uc_unsync(struct net_device *netdev,
{ {
struct hnae3_handle *h = hns3_get_handle(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
/* need ignore the request of removing device address, because
* we store the device address and other addresses of uc list
* in the function's mac filter list.
*/
if (ether_addr_equal(addr, netdev->dev_addr))
return 0;
if (h->ae_algo->ops->rm_uc_addr) if (h->ae_algo->ops->rm_uc_addr)
return h->ae_algo->ops->rm_uc_addr(h, addr); return h->ae_algo->ops->rm_uc_addr(h, addr);
...@@ -595,34 +601,25 @@ static void hns3_nic_set_rx_mode(struct net_device *netdev) ...@@ -595,34 +601,25 @@ static void hns3_nic_set_rx_mode(struct net_device *netdev)
{ {
struct hnae3_handle *h = hns3_get_handle(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
u8 new_flags; u8 new_flags;
int ret;
new_flags = hns3_get_netdev_flags(netdev); new_flags = hns3_get_netdev_flags(netdev);
ret = __dev_uc_sync(netdev, hns3_nic_uc_sync, hns3_nic_uc_unsync); __dev_uc_sync(netdev, hns3_nic_uc_sync, hns3_nic_uc_unsync);
if (ret) { __dev_mc_sync(netdev, hns3_nic_mc_sync, hns3_nic_mc_unsync);
netdev_err(netdev, "sync uc address fail\n");
if (ret == -ENOSPC)
new_flags |= HNAE3_OVERFLOW_UPE;
}
if (netdev->flags & IFF_MULTICAST) {
ret = __dev_mc_sync(netdev, hns3_nic_mc_sync,
hns3_nic_mc_unsync);
if (ret) {
netdev_err(netdev, "sync mc address fail\n");
if (ret == -ENOSPC)
new_flags |= HNAE3_OVERFLOW_MPE;
}
}
/* User mode Promisc mode enable and vlan filtering is disabled to /* User mode Promisc mode enable and vlan filtering is disabled to
* let all packets in. MAC-VLAN Table overflow Promisc enabled and * let all packets in.
* vlan fitering is enabled
*/ */
hns3_enable_vlan_filter(netdev, new_flags & HNAE3_VLAN_FLTR);
h->netdev_flags = new_flags; h->netdev_flags = new_flags;
hns3_update_promisc_mode(netdev, new_flags); hns3_request_update_promisc_mode(h);
}
void hns3_request_update_promisc_mode(struct hnae3_handle *handle)
{
const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
if (ops->request_update_promisc_mode)
ops->request_update_promisc_mode(handle);
} }
int hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags) int hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags)
...@@ -2105,7 +2102,6 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2105,7 +2102,6 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
ae_dev->pdev = pdev; ae_dev->pdev = pdev;
ae_dev->flag = ent->driver_data; ae_dev->flag = ent->driver_data;
ae_dev->reset_type = HNAE3_NONE_RESET;
hns3_get_dev_capability(pdev, ae_dev); hns3_get_dev_capability(pdev, ae_dev);
pci_set_drvdata(pdev, ae_dev); pci_set_drvdata(pdev, ae_dev);
...@@ -3907,9 +3903,11 @@ static int hns3_init_mac_addr(struct net_device *netdev) ...@@ -3907,9 +3903,11 @@ static int hns3_init_mac_addr(struct net_device *netdev)
eth_hw_addr_random(netdev); eth_hw_addr_random(netdev);
dev_warn(priv->dev, "using random MAC address %pM\n", dev_warn(priv->dev, "using random MAC address %pM\n",
netdev->dev_addr); netdev->dev_addr);
} else { } else if (!ether_addr_equal(netdev->dev_addr, mac_addr_temp)) {
ether_addr_copy(netdev->dev_addr, mac_addr_temp); ether_addr_copy(netdev->dev_addr, mac_addr_temp);
ether_addr_copy(netdev->perm_addr, mac_addr_temp); ether_addr_copy(netdev->perm_addr, mac_addr_temp);
} else {
return 0;
} }
if (h->ae_algo->ops->set_mac_addr) if (h->ae_algo->ops->set_mac_addr)
...@@ -3937,17 +3935,6 @@ static void hns3_uninit_phy(struct net_device *netdev) ...@@ -3937,17 +3935,6 @@ static void hns3_uninit_phy(struct net_device *netdev)
h->ae_algo->ops->mac_disconnect_phy(h); h->ae_algo->ops->mac_disconnect_phy(h);
} }
static int hns3_restore_fd_rules(struct net_device *netdev)
{
struct hnae3_handle *h = hns3_get_handle(netdev);
int ret = 0;
if (h->ae_algo->ops->restore_fd_rules)
ret = h->ae_algo->ops->restore_fd_rules(h);
return ret;
}
static void hns3_del_all_fd_rules(struct net_device *netdev, bool clear_list) static void hns3_del_all_fd_rules(struct net_device *netdev, bool clear_list)
{ {
struct hnae3_handle *h = hns3_get_handle(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
...@@ -4119,8 +4106,6 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset) ...@@ -4119,8 +4106,6 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset)
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hns3_nic_priv *priv = netdev_priv(netdev);
int ret; int ret;
hns3_remove_hw_addr(netdev);
if (netdev->reg_state != NETREG_UNINITIALIZED) if (netdev->reg_state != NETREG_UNINITIALIZED)
unregister_netdev(netdev); unregister_netdev(netdev);
...@@ -4191,56 +4176,6 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc) ...@@ -4191,56 +4176,6 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
return hns3_nic_set_real_num_queue(ndev); return hns3_nic_set_real_num_queue(ndev);
} }
static int hns3_recover_hw_addr(struct net_device *ndev)
{
struct netdev_hw_addr_list *list;
struct netdev_hw_addr *ha, *tmp;
int ret = 0;
netif_addr_lock_bh(ndev);
/* go through and sync uc_addr entries to the device */
list = &ndev->uc;
list_for_each_entry_safe(ha, tmp, &list->list, list) {
ret = hns3_nic_uc_sync(ndev, ha->addr);
if (ret)
goto out;
}
/* go through and sync mc_addr entries to the device */
list = &ndev->mc;
list_for_each_entry_safe(ha, tmp, &list->list, list) {
ret = hns3_nic_mc_sync(ndev, ha->addr);
if (ret)
goto out;
}
out:
netif_addr_unlock_bh(ndev);
return ret;
}
static void hns3_remove_hw_addr(struct net_device *netdev)
{
struct netdev_hw_addr_list *list;
struct netdev_hw_addr *ha, *tmp;
hns3_nic_uc_unsync(netdev, netdev->dev_addr);
netif_addr_lock_bh(netdev);
/* go through and unsync uc_addr entries to the device */
list = &netdev->uc;
list_for_each_entry_safe(ha, tmp, &list->list, list)
hns3_nic_uc_unsync(netdev, ha->addr);
/* go through and unsync mc_addr entries to the device */
list = &netdev->mc;
list_for_each_entry_safe(ha, tmp, &list->list, list)
if (ha->refcount > 1)
hns3_nic_mc_unsync(netdev, ha->addr);
netif_addr_unlock_bh(netdev);
}
static void hns3_clear_tx_ring(struct hns3_enet_ring *ring) static void hns3_clear_tx_ring(struct hns3_enet_ring *ring)
{ {
while (ring->next_to_clean != ring->next_to_use) { while (ring->next_to_clean != ring->next_to_use) {
...@@ -4399,7 +4334,6 @@ static void hns3_restore_coal(struct hns3_nic_priv *priv) ...@@ -4399,7 +4334,6 @@ static void hns3_restore_coal(struct hns3_nic_priv *priv)
static int hns3_reset_notify_down_enet(struct hnae3_handle *handle) static int hns3_reset_notify_down_enet(struct hnae3_handle *handle)
{ {
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
struct hnae3_knic_private_info *kinfo = &handle->kinfo; struct hnae3_knic_private_info *kinfo = &handle->kinfo;
struct net_device *ndev = kinfo->netdev; struct net_device *ndev = kinfo->netdev;
struct hns3_nic_priv *priv = netdev_priv(ndev); struct hns3_nic_priv *priv = netdev_priv(ndev);
...@@ -4407,15 +4341,6 @@ static int hns3_reset_notify_down_enet(struct hnae3_handle *handle) ...@@ -4407,15 +4341,6 @@ static int hns3_reset_notify_down_enet(struct hnae3_handle *handle)
if (test_and_set_bit(HNS3_NIC_STATE_RESETTING, &priv->state)) if (test_and_set_bit(HNS3_NIC_STATE_RESETTING, &priv->state))
return 0; return 0;
/* it is cumbersome for hardware to pick-and-choose entries for deletion
* from table space. Hence, for function reset software intervention is
* required to delete the entries
*/
if (hns3_dev_ongoing_func_reset(ae_dev)) {
hns3_remove_hw_addr(ndev);
hns3_del_all_fd_rules(ndev, false);
}
if (!netif_running(ndev)) if (!netif_running(ndev))
return 0; return 0;
...@@ -4482,6 +4407,9 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle) ...@@ -4482,6 +4407,9 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle)
goto err_init_irq_fail; goto err_init_irq_fail;
} }
if (!hns3_is_phys_func(handle->pdev))
hns3_init_mac_addr(netdev);
ret = hns3_client_start(handle); ret = hns3_client_start(handle);
if (ret) { if (ret) {
dev_err(priv->dev, "hns3_client_start fail! ret=%d\n", ret); dev_err(priv->dev, "hns3_client_start fail! ret=%d\n", ret);
...@@ -4507,33 +4435,6 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle) ...@@ -4507,33 +4435,6 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle)
return ret; return ret;
} }
static int hns3_reset_notify_restore_enet(struct hnae3_handle *handle)
{
struct net_device *netdev = handle->kinfo.netdev;
bool vlan_filter_enable;
int ret;
ret = hns3_init_mac_addr(netdev);
if (ret)
return ret;
ret = hns3_recover_hw_addr(netdev);
if (ret)
return ret;
ret = hns3_update_promisc_mode(netdev, handle->netdev_flags);
if (ret)
return ret;
vlan_filter_enable = netdev->flags & IFF_PROMISC ? false : true;
hns3_enable_vlan_filter(netdev, vlan_filter_enable);
if (handle->ae_algo->ops->restore_vlan_table)
handle->ae_algo->ops->restore_vlan_table(handle);
return hns3_restore_fd_rules(netdev);
}
static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle) static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)
{ {
struct net_device *netdev = handle->kinfo.netdev; struct net_device *netdev = handle->kinfo.netdev;
...@@ -4583,9 +4484,6 @@ static int hns3_reset_notify(struct hnae3_handle *handle, ...@@ -4583,9 +4484,6 @@ static int hns3_reset_notify(struct hnae3_handle *handle,
case HNAE3_UNINIT_CLIENT: case HNAE3_UNINIT_CLIENT:
ret = hns3_reset_notify_uninit_enet(handle); ret = hns3_reset_notify_uninit_enet(handle);
break; break;
case HNAE3_RESTORE_CLIENT:
ret = hns3_reset_notify_restore_enet(handle);
break;
default: default:
break; break;
} }
......
...@@ -576,15 +576,6 @@ static inline void hns3_write_reg(void __iomem *base, u32 reg, u32 value) ...@@ -576,15 +576,6 @@ static inline void hns3_write_reg(void __iomem *base, u32 reg, u32 value)
writel(value, reg_addr + reg); writel(value, reg_addr + reg);
} }
static inline bool hns3_dev_ongoing_func_reset(struct hnae3_ae_dev *ae_dev)
{
return (ae_dev && (ae_dev->reset_type == HNAE3_FUNC_RESET ||
ae_dev->reset_type == HNAE3_FLR_RESET ||
ae_dev->reset_type == HNAE3_VF_FUNC_RESET ||
ae_dev->reset_type == HNAE3_VF_FULL_RESET ||
ae_dev->reset_type == HNAE3_VF_PF_FUNC_RESET));
}
#define hns3_read_dev(a, reg) \ #define hns3_read_dev(a, reg) \
hns3_read_reg((a)->io_base, (reg)) hns3_read_reg((a)->io_base, (reg))
...@@ -658,6 +649,7 @@ void hns3_set_vector_coalesce_rl(struct hns3_enet_tqp_vector *tqp_vector, ...@@ -658,6 +649,7 @@ void hns3_set_vector_coalesce_rl(struct hns3_enet_tqp_vector *tqp_vector,
void hns3_enable_vlan_filter(struct net_device *netdev, bool enable); void hns3_enable_vlan_filter(struct net_device *netdev, bool enable);
int hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags); int hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags);
void hns3_request_update_promisc_mode(struct hnae3_handle *handle);
#ifdef CONFIG_HNS3_DCB #ifdef CONFIG_HNS3_DCB
void hns3_dcbnl_setup(struct hnae3_handle *handle); void hns3_dcbnl_setup(struct hnae3_handle *handle);
......
...@@ -99,7 +99,7 @@ static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop, bool en) ...@@ -99,7 +99,7 @@ static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop, bool en)
h->ae_algo->ops->set_promisc_mode(h, true, true); h->ae_algo->ops->set_promisc_mode(h, true, true);
} else { } else {
/* recover promisc mode before loopback test */ /* recover promisc mode before loopback test */
hns3_update_promisc_mode(ndev, h->netdev_flags); hns3_request_update_promisc_mode(h);
vlan_filter_enable = ndev->flags & IFF_PROMISC ? false : true; vlan_filter_enable = ndev->flags & IFF_PROMISC ? false : true;
hns3_enable_vlan_filter(ndev, vlan_filter_enable); hns3_enable_vlan_filter(ndev, vlan_filter_enable);
} }
......
...@@ -1441,6 +1441,49 @@ static void hclge_dbg_dump_qs_shaper(struct hclge_dev *hdev, ...@@ -1441,6 +1441,49 @@ static void hclge_dbg_dump_qs_shaper(struct hclge_dev *hdev,
hclge_dbg_dump_qs_shaper_single(hdev, qsid); hclge_dbg_dump_qs_shaper_single(hdev, qsid);
} }
static int hclge_dbg_dump_mac_list(struct hclge_dev *hdev, const char *cmd_buf,
bool is_unicast)
{
struct hclge_mac_node *mac_node, *tmp;
struct hclge_vport *vport;
struct list_head *list;
u32 func_id;
int ret;
ret = kstrtouint(cmd_buf, 0, &func_id);
if (ret < 0) {
dev_err(&hdev->pdev->dev,
"dump mac list: bad command string, ret = %d\n", ret);
return -EINVAL;
}
if (func_id >= hdev->num_alloc_vport) {
dev_err(&hdev->pdev->dev,
"function id(%u) is out of range(0-%u)\n", func_id,
hdev->num_alloc_vport - 1);
return -EINVAL;
}
vport = &hdev->vport[func_id];
list = is_unicast ? &vport->uc_mac_list : &vport->mc_mac_list;
dev_info(&hdev->pdev->dev, "vport %u %s mac list:\n",
func_id, is_unicast ? "uc" : "mc");
dev_info(&hdev->pdev->dev, "mac address state\n");
spin_lock_bh(&vport->mac_list_lock);
list_for_each_entry_safe(mac_node, tmp, list, node) {
dev_info(&hdev->pdev->dev, "%pM %d\n",
mac_node->mac_addr, mac_node->state);
}
spin_unlock_bh(&vport->mac_list_lock);
return 0;
}
int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf)
{ {
#define DUMP_REG "dump reg" #define DUMP_REG "dump reg"
...@@ -1485,6 +1528,14 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) ...@@ -1485,6 +1528,14 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf)
} else if (strncmp(cmd_buf, "dump qs shaper", 14) == 0) { } else if (strncmp(cmd_buf, "dump qs shaper", 14) == 0) {
hclge_dbg_dump_qs_shaper(hdev, hclge_dbg_dump_qs_shaper(hdev,
&cmd_buf[sizeof("dump qs shaper")]); &cmd_buf[sizeof("dump qs shaper")]);
} else if (strncmp(cmd_buf, "dump uc mac list", 16) == 0) {
hclge_dbg_dump_mac_list(hdev,
&cmd_buf[sizeof("dump uc mac list")],
true);
} else if (strncmp(cmd_buf, "dump mc mac list", 16) == 0) {
hclge_dbg_dump_mac_list(hdev,
&cmd_buf[sizeof("dump mc mac list")],
false);
} else { } else {
dev_info(&hdev->pdev->dev, "unknown command\n"); dev_info(&hdev->pdev->dev, "unknown command\n");
return -EINVAL; return -EINVAL;
......
...@@ -217,6 +217,7 @@ enum HCLGE_DEV_STATE { ...@@ -217,6 +217,7 @@ enum HCLGE_DEV_STATE {
HCLGE_STATE_STATISTICS_UPDATING, HCLGE_STATE_STATISTICS_UPDATING,
HCLGE_STATE_CMD_DISABLE, HCLGE_STATE_CMD_DISABLE,
HCLGE_STATE_LINK_UPDATING, HCLGE_STATE_LINK_UPDATING,
HCLGE_STATE_PROMISC_CHANGED,
HCLGE_STATE_RST_FAIL, HCLGE_STATE_RST_FAIL,
HCLGE_STATE_MAX HCLGE_STATE_MAX
}; };
...@@ -630,9 +631,15 @@ struct hclge_fd_ad_data { ...@@ -630,9 +631,15 @@ struct hclge_fd_ad_data {
u16 rule_id; u16 rule_id;
}; };
struct hclge_vport_mac_addr_cfg { enum HCLGE_MAC_NODE_STATE {
HCLGE_MAC_TO_ADD,
HCLGE_MAC_TO_DEL,
HCLGE_MAC_ACTIVE
};
struct hclge_mac_node {
struct list_head node; struct list_head node;
int hd_tbl_status; enum HCLGE_MAC_NODE_STATE state;
u8 mac_addr[ETH_ALEN]; u8 mac_addr[ETH_ALEN];
}; };
...@@ -805,6 +812,8 @@ struct hclge_dev { ...@@ -805,6 +812,8 @@ struct hclge_dev {
unsigned long vlan_table[VLAN_N_VID][BITS_TO_LONGS(HCLGE_VPORT_NUM)]; unsigned long vlan_table[VLAN_N_VID][BITS_TO_LONGS(HCLGE_VPORT_NUM)];
unsigned long vf_vlan_full[BITS_TO_LONGS(HCLGE_VPORT_NUM)]; unsigned long vf_vlan_full[BITS_TO_LONGS(HCLGE_VPORT_NUM)];
unsigned long vport_config_block[BITS_TO_LONGS(HCLGE_VPORT_NUM)];
struct hclge_fd_cfg fd_cfg; struct hclge_fd_cfg fd_cfg;
struct hlist_head fd_rule_list; struct hlist_head fd_rule_list;
spinlock_t fd_rule_lock; /* protect fd_rule_list and fd_bmap */ spinlock_t fd_rule_lock; /* protect fd_rule_list and fd_bmap */
...@@ -822,7 +831,6 @@ struct hclge_dev { ...@@ -822,7 +831,6 @@ struct hclge_dev {
u16 priv_umv_size; u16 priv_umv_size;
/* unicast mac vlan space shared by PF and its VFs */ /* unicast mac vlan space shared by PF and its VFs */
u16 share_umv_size; u16 share_umv_size;
struct mutex umv_mutex; /* protect share_umv_size */
DECLARE_KFIFO(mac_tnl_log, struct hclge_mac_tnl_stats, DECLARE_KFIFO(mac_tnl_log, struct hclge_mac_tnl_stats,
HCLGE_MAC_TNL_LOG_SIZE); HCLGE_MAC_TNL_LOG_SIZE);
...@@ -866,6 +874,7 @@ struct hclge_rss_tuple_cfg { ...@@ -866,6 +874,7 @@ struct hclge_rss_tuple_cfg {
enum HCLGE_VPORT_STATE { enum HCLGE_VPORT_STATE {
HCLGE_VPORT_STATE_ALIVE, HCLGE_VPORT_STATE_ALIVE,
HCLGE_VPORT_STATE_MAC_TBL_CHANGE,
HCLGE_VPORT_STATE_MAX HCLGE_VPORT_STATE_MAX
}; };
...@@ -922,6 +931,10 @@ struct hclge_vport { ...@@ -922,6 +931,10 @@ struct hclge_vport {
u32 mps; /* Max packet size */ u32 mps; /* Max packet size */
struct hclge_vf_info vf_info; struct hclge_vf_info vf_info;
u8 overflow_promisc_flags;
u8 last_promisc_flags;
spinlock_t mac_list_lock; /* protect mac address need to add/detele */
struct list_head uc_mac_list; /* Store VF unicast table */ struct list_head uc_mac_list; /* Store VF unicast table */
struct list_head mc_mac_list; /* Store VF multicast table */ struct list_head mc_mac_list; /* Store VF multicast table */
struct list_head vlan_list; /* Store VF vlan table */ struct list_head vlan_list; /* Store VF vlan table */
...@@ -977,16 +990,18 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf); ...@@ -977,16 +990,18 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf);
u16 hclge_covert_handle_qid_global(struct hnae3_handle *handle, u16 queue_id); u16 hclge_covert_handle_qid_global(struct hnae3_handle *handle, u16 queue_id);
int hclge_notify_client(struct hclge_dev *hdev, int hclge_notify_client(struct hclge_dev *hdev,
enum hnae3_reset_notify_type type); enum hnae3_reset_notify_type type);
void hclge_add_vport_mac_table(struct hclge_vport *vport, const u8 *mac_addr, int hclge_update_mac_list(struct hclge_vport *vport,
enum HCLGE_MAC_ADDR_TYPE mac_type); enum HCLGE_MAC_NODE_STATE state,
void hclge_rm_vport_mac_table(struct hclge_vport *vport, const u8 *mac_addr, enum HCLGE_MAC_ADDR_TYPE mac_type,
bool is_write_tbl, const unsigned char *addr);
enum HCLGE_MAC_ADDR_TYPE mac_type); int hclge_update_mac_node_for_dev_addr(struct hclge_vport *vport,
const u8 *old_addr, const u8 *new_addr);
void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list, void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list,
enum HCLGE_MAC_ADDR_TYPE mac_type); enum HCLGE_MAC_ADDR_TYPE mac_type);
void hclge_uninit_vport_mac_table(struct hclge_dev *hdev);
void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list); void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list);
void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev); void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev);
void hclge_restore_mac_table_common(struct hclge_vport *vport);
void hclge_restore_vport_vlan_table(struct hclge_vport *vport);
int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state, int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
struct hclge_vlan_info *vlan_info); struct hclge_vlan_info *vlan_info);
int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid, int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid,
......
...@@ -275,26 +275,17 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport, ...@@ -275,26 +275,17 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport,
if (!is_valid_ether_addr(mac_addr)) if (!is_valid_ether_addr(mac_addr))
return -EINVAL; return -EINVAL;
hclge_rm_uc_addr_common(vport, old_addr); spin_lock_bh(&vport->mac_list_lock);
status = hclge_add_uc_addr_common(vport, mac_addr); status = hclge_update_mac_node_for_dev_addr(vport, old_addr,
if (status) { mac_addr);
hclge_add_uc_addr_common(vport, old_addr); spin_unlock_bh(&vport->mac_list_lock);
} else { hclge_task_schedule(hdev, 0);
hclge_rm_vport_mac_table(vport, mac_addr,
false, HCLGE_MAC_ADDR_UC);
hclge_add_vport_mac_table(vport, mac_addr,
HCLGE_MAC_ADDR_UC);
}
} else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_UC_ADD) { } else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_UC_ADD) {
status = hclge_add_uc_addr_common(vport, mac_addr); status = hclge_update_mac_list(vport, HCLGE_MAC_TO_ADD,
if (!status) HCLGE_MAC_ADDR_UC, mac_addr);
hclge_add_vport_mac_table(vport, mac_addr,
HCLGE_MAC_ADDR_UC);
} else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_UC_REMOVE) { } else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_UC_REMOVE) {
status = hclge_rm_uc_addr_common(vport, mac_addr); status = hclge_update_mac_list(vport, HCLGE_MAC_TO_DEL,
if (!status) HCLGE_MAC_ADDR_UC, mac_addr);
hclge_rm_vport_mac_table(vport, mac_addr,
false, HCLGE_MAC_ADDR_UC);
} else { } else {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"failed to set unicast mac addr, unknown subcode %u\n", "failed to set unicast mac addr, unknown subcode %u\n",
...@@ -310,18 +301,13 @@ static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport, ...@@ -310,18 +301,13 @@ static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport,
{ {
const u8 *mac_addr = (const u8 *)(mbx_req->msg.data); const u8 *mac_addr = (const u8 *)(mbx_req->msg.data);
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
int status;
if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_MC_ADD) { if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_MC_ADD) {
status = hclge_add_mc_addr_common(vport, mac_addr); hclge_update_mac_list(vport, HCLGE_MAC_TO_ADD,
if (!status) HCLGE_MAC_ADDR_MC, mac_addr);
hclge_add_vport_mac_table(vport, mac_addr,
HCLGE_MAC_ADDR_MC);
} else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_MC_REMOVE) { } else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_MC_REMOVE) {
status = hclge_rm_mc_addr_common(vport, mac_addr); hclge_update_mac_list(vport, HCLGE_MAC_TO_DEL,
if (!status) HCLGE_MAC_ADDR_MC, mac_addr);
hclge_rm_vport_mac_table(vport, mac_addr,
false, HCLGE_MAC_ADDR_MC);
} else { } else {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"failed to set mcast mac addr, unknown subcode %u\n", "failed to set mcast mac addr, unknown subcode %u\n",
...@@ -329,7 +315,7 @@ static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport, ...@@ -329,7 +315,7 @@ static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport,
return -EIO; return -EIO;
} }
return status; return 0;
} }
int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid, int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid,
...@@ -643,6 +629,23 @@ static void hclge_handle_ncsi_error(struct hclge_dev *hdev) ...@@ -643,6 +629,23 @@ static void hclge_handle_ncsi_error(struct hclge_dev *hdev)
ae_dev->ops->reset_event(hdev->pdev, NULL); ae_dev->ops->reset_event(hdev->pdev, NULL);
} }
static void hclge_handle_vf_tbl(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req)
{
struct hclge_dev *hdev = vport->back;
struct hclge_vf_vlan_cfg *msg_cmd;
msg_cmd = (struct hclge_vf_vlan_cfg *)&mbx_req->msg;
if (msg_cmd->subcode == HCLGE_MBX_VPORT_LIST_CLEAR) {
hclge_rm_vport_all_mac_table(vport, true, HCLGE_MAC_ADDR_UC);
hclge_rm_vport_all_mac_table(vport, true, HCLGE_MAC_ADDR_MC);
hclge_rm_vport_all_vlan_table(vport, true);
} else {
dev_warn(&hdev->pdev->dev, "Invalid cmd(%u)\n",
msg_cmd->subcode);
}
}
void hclge_mbx_handler(struct hclge_dev *hdev) void hclge_mbx_handler(struct hclge_dev *hdev)
{ {
struct hclge_cmq_ring *crq = &hdev->hw.cmq.crq; struct hclge_cmq_ring *crq = &hdev->hw.cmq.crq;
...@@ -650,6 +653,7 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -650,6 +653,7 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
struct hclge_mbx_vf_to_pf_cmd *req; struct hclge_mbx_vf_to_pf_cmd *req;
struct hclge_vport *vport; struct hclge_vport *vport;
struct hclge_desc *desc; struct hclge_desc *desc;
bool is_del = false;
unsigned int flag; unsigned int flag;
int ret = 0; int ret = 0;
...@@ -767,11 +771,12 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -767,11 +771,12 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
break; break;
case HCLGE_MBX_GET_VF_FLR_STATUS: case HCLGE_MBX_GET_VF_FLR_STATUS:
case HCLGE_MBX_VF_UNINIT: case HCLGE_MBX_VF_UNINIT:
hclge_rm_vport_all_mac_table(vport, true, is_del = req->msg.code == HCLGE_MBX_VF_UNINIT;
hclge_rm_vport_all_mac_table(vport, is_del,
HCLGE_MAC_ADDR_UC); HCLGE_MAC_ADDR_UC);
hclge_rm_vport_all_mac_table(vport, true, hclge_rm_vport_all_mac_table(vport, is_del,
HCLGE_MAC_ADDR_MC); HCLGE_MAC_ADDR_MC);
hclge_rm_vport_all_vlan_table(vport, true); hclge_rm_vport_all_vlan_table(vport, is_del);
break; break;
case HCLGE_MBX_GET_MEDIA_TYPE: case HCLGE_MBX_GET_MEDIA_TYPE:
hclge_get_vf_media_type(vport, &resp_msg); hclge_get_vf_media_type(vport, &resp_msg);
...@@ -785,6 +790,9 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -785,6 +790,9 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
case HCLGE_MBX_NCSI_ERROR: case HCLGE_MBX_NCSI_ERROR:
hclge_handle_ncsi_error(hdev); hclge_handle_ncsi_error(hdev);
break; break;
case HCLGE_MBX_HANDLE_VF_TBL:
hclge_handle_vf_tbl(vport, req);
break;
default: default:
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"un-supported mailbox message, code = %u\n", "un-supported mailbox message, code = %u\n",
......
...@@ -148,6 +148,7 @@ enum hclgevf_states { ...@@ -148,6 +148,7 @@ enum hclgevf_states {
HCLGEVF_STATE_MBX_HANDLING, HCLGEVF_STATE_MBX_HANDLING,
HCLGEVF_STATE_CMD_DISABLE, HCLGEVF_STATE_CMD_DISABLE,
HCLGEVF_STATE_LINK_UPDATING, HCLGEVF_STATE_LINK_UPDATING,
HCLGEVF_STATE_PROMISC_CHANGED,
HCLGEVF_STATE_RST_FAIL, HCLGEVF_STATE_RST_FAIL,
}; };
...@@ -234,6 +235,29 @@ struct hclgevf_rst_stats { ...@@ -234,6 +235,29 @@ struct hclgevf_rst_stats {
u32 rst_fail_cnt; /* the number of VF reset fail */ u32 rst_fail_cnt; /* the number of VF reset fail */
}; };
enum HCLGEVF_MAC_ADDR_TYPE {
HCLGEVF_MAC_ADDR_UC,
HCLGEVF_MAC_ADDR_MC
};
enum HCLGEVF_MAC_NODE_STATE {
HCLGEVF_MAC_TO_ADD,
HCLGEVF_MAC_TO_DEL,
HCLGEVF_MAC_ACTIVE
};
struct hclgevf_mac_addr_node {
struct list_head node;
enum HCLGEVF_MAC_NODE_STATE state;
u8 mac_addr[ETH_ALEN];
};
struct hclgevf_mac_table_cfg {
spinlock_t mac_list_lock; /* protect mac address need to add/detele */
struct list_head uc_mac_list;
struct list_head mc_mac_list;
};
struct hclgevf_dev { struct hclgevf_dev {
struct pci_dev *pdev; struct pci_dev *pdev;
struct hnae3_ae_dev *ae_dev; struct hnae3_ae_dev *ae_dev;
...@@ -282,6 +306,8 @@ struct hclgevf_dev { ...@@ -282,6 +306,8 @@ struct hclgevf_dev {
unsigned long vlan_del_fail_bmap[BITS_TO_LONGS(VLAN_N_VID)]; unsigned long vlan_del_fail_bmap[BITS_TO_LONGS(VLAN_N_VID)];
struct hclgevf_mac_table_cfg mac_table;
bool mbx_event_pending; bool mbx_event_pending;
struct hclgevf_mbx_resp_status mbx_resp; /* mailbox response */ struct hclgevf_mbx_resp_status mbx_resp; /* mailbox response */
struct hclgevf_mbx_arq_ring arq; /* mailbox async rx queue */ struct hclgevf_mbx_arq_ring arq; /* mailbox async rx queue */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment