Commit d129a45b authored by David S. Miller's avatar David S. Miller

Merge branch 'hns3-next'

Peng Li says:

====================
net: hns3: code optimizations & bugfixes for HNS3 driver

This patchset includes bugfixes and code optimizations for the HNS3
ethernet controller driver
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 754d5da6 1154bb26
...@@ -461,6 +461,7 @@ struct hnae3_ae_ops { ...@@ -461,6 +461,7 @@ struct hnae3_ae_ops {
unsigned long (*ae_dev_reset_cnt)(struct hnae3_handle *handle); unsigned long (*ae_dev_reset_cnt)(struct hnae3_handle *handle);
int (*set_gro_en)(struct hnae3_handle *handle, int enable); int (*set_gro_en)(struct hnae3_handle *handle, int enable);
u16 (*get_global_queue_id)(struct hnae3_handle *handle, u16 queue_id); u16 (*get_global_queue_id)(struct hnae3_handle *handle, u16 queue_id);
void (*set_timer_task)(struct hnae3_handle *handle, bool enable);
}; };
struct hnae3_dcb_ops { struct hnae3_dcb_ops {
......
...@@ -379,6 +379,7 @@ static int hns3_nic_net_up(struct net_device *netdev) ...@@ -379,6 +379,7 @@ static int hns3_nic_net_up(struct net_device *netdev)
static int hns3_nic_net_open(struct net_device *netdev) static int hns3_nic_net_open(struct net_device *netdev)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev);
struct hnae3_handle *h = hns3_get_handle(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_knic_private_info *kinfo; struct hnae3_knic_private_info *kinfo;
int i, ret; int i, ret;
...@@ -405,6 +406,9 @@ static int hns3_nic_net_open(struct net_device *netdev) ...@@ -405,6 +406,9 @@ static int hns3_nic_net_open(struct net_device *netdev)
kinfo->prio_tc[i]); kinfo->prio_tc[i]);
} }
if (h->ae_algo->ops->set_timer_task)
h->ae_algo->ops->set_timer_task(priv->ae_handle, true);
return 0; return 0;
} }
...@@ -437,10 +441,14 @@ static void hns3_nic_net_down(struct net_device *netdev) ...@@ -437,10 +441,14 @@ static void hns3_nic_net_down(struct net_device *netdev)
static int hns3_nic_net_stop(struct net_device *netdev) static int hns3_nic_net_stop(struct net_device *netdev)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hns3_nic_priv *priv = netdev_priv(netdev);
struct hnae3_handle *h = hns3_get_handle(netdev);
if (test_and_set_bit(HNS3_NIC_STATE_DOWN, &priv->state)) if (test_and_set_bit(HNS3_NIC_STATE_DOWN, &priv->state))
return 0; return 0;
if (h->ae_algo->ops->set_timer_task)
h->ae_algo->ops->set_timer_task(priv->ae_handle, false);
netif_tx_stop_all_queues(netdev); netif_tx_stop_all_queues(netdev);
netif_carrier_off(netdev); netif_carrier_off(netdev);
...@@ -2542,9 +2550,16 @@ static void hns3_set_gro_param(struct sk_buff *skb, u32 l234info, ...@@ -2542,9 +2550,16 @@ static void hns3_set_gro_param(struct sk_buff *skb, u32 l234info,
static void hns3_set_rx_skb_rss_type(struct hns3_enet_ring *ring, static void hns3_set_rx_skb_rss_type(struct hns3_enet_ring *ring,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct hns3_desc *desc = &ring->desc[ring->next_to_clean];
struct hnae3_handle *handle = ring->tqp->handle; struct hnae3_handle *handle = ring->tqp->handle;
enum pkt_hash_types rss_type; enum pkt_hash_types rss_type;
struct hns3_desc *desc;
int last_bd;
/* When driver handle the rss type, ring->next_to_clean indicates the
* first descriptor of next packet, need -1 here.
*/
last_bd = (ring->next_to_clean - 1 + ring->desc_num) % ring->desc_num;
desc = &ring->desc[last_bd];
if (le32_to_cpu(desc->rx.rss_hash)) if (le32_to_cpu(desc->rx.rss_hash))
rss_type = handle->kinfo.rss_type; rss_type = handle->kinfo.rss_type;
...@@ -3110,6 +3125,8 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv) ...@@ -3110,6 +3125,8 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv)
static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv) static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv)
{ {
#define HNS3_VECTOR_PF_MAX_NUM 64
struct hnae3_handle *h = priv->ae_handle; struct hnae3_handle *h = priv->ae_handle;
struct hns3_enet_tqp_vector *tqp_vector; struct hns3_enet_tqp_vector *tqp_vector;
struct hnae3_vector_info *vector; struct hnae3_vector_info *vector;
...@@ -3122,6 +3139,8 @@ static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv) ...@@ -3122,6 +3139,8 @@ static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv)
/* RSS size, cpu online and vector_num should be the same */ /* RSS size, cpu online and vector_num should be the same */
/* Should consider 2p/4p later */ /* Should consider 2p/4p later */
vector_num = min_t(u16, num_online_cpus(), tqp_num); vector_num = min_t(u16, num_online_cpus(), tqp_num);
vector_num = min_t(u16, vector_num, HNS3_VECTOR_PF_MAX_NUM);
vector = devm_kcalloc(&pdev->dev, vector_num, sizeof(*vector), vector = devm_kcalloc(&pdev->dev, vector_num, sizeof(*vector),
GFP_KERNEL); GFP_KERNEL);
if (!vector) if (!vector)
......
...@@ -960,7 +960,7 @@ static int hclge_configure(struct hclge_dev *hdev) ...@@ -960,7 +960,7 @@ static int hclge_configure(struct hclge_dev *hdev)
hdev->pfc_max = hdev->tc_max; hdev->pfc_max = hdev->tc_max;
} }
hdev->tm_info.num_tc = hdev->tc_max; hdev->tm_info.num_tc = 1;
/* Currently not support uncontiuous tc */ /* Currently not support uncontiuous tc */
for (i = 0; i < hdev->tm_info.num_tc; i++) for (i = 0; i < hdev->tm_info.num_tc; i++)
...@@ -4677,6 +4677,13 @@ static int hclge_add_fd_entry(struct hnae3_handle *handle, ...@@ -4677,6 +4677,13 @@ static int hclge_add_fd_entry(struct hnae3_handle *handle,
u8 vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie); u8 vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie);
u16 tqps; u16 tqps;
if (vf > hdev->num_req_vfs) {
dev_err(&hdev->pdev->dev,
"Error: vf id (%d) > max vf num (%d)\n",
vf, hdev->num_req_vfs);
return -EINVAL;
}
dst_vport_id = vf ? hdev->vport[vf].vport_id : vport->vport_id; dst_vport_id = vf ? hdev->vport[vf].vport_id : vport->vport_id;
tqps = vf ? hdev->vport[vf].alloc_tqps : vport->alloc_tqps; tqps = vf ? hdev->vport[vf].alloc_tqps : vport->alloc_tqps;
...@@ -4687,13 +4694,6 @@ static int hclge_add_fd_entry(struct hnae3_handle *handle, ...@@ -4687,13 +4694,6 @@ static int hclge_add_fd_entry(struct hnae3_handle *handle,
return -EINVAL; return -EINVAL;
} }
if (vf > hdev->num_req_vfs) {
dev_err(&hdev->pdev->dev,
"Error: vf id (%d) > max vf num (%d)\n",
vf, hdev->num_req_vfs);
return -EINVAL;
}
action = HCLGE_FD_ACTION_ACCEPT_PACKET; action = HCLGE_FD_ACTION_ACCEPT_PACKET;
q_index = ring; q_index = ring;
} }
...@@ -4808,6 +4808,10 @@ static int hclge_restore_fd_entries(struct hnae3_handle *handle) ...@@ -4808,6 +4808,10 @@ static int hclge_restore_fd_entries(struct hnae3_handle *handle)
if (!hnae3_dev_fd_supported(hdev)) if (!hnae3_dev_fd_supported(hdev))
return 0; return 0;
/* if fd is disabled, should not restore it when reset */
if (!hdev->fd_cfg.fd_en)
return 0;
hlist_for_each_entry_safe(rule, node, &hdev->fd_rule_list, rule_node) { hlist_for_each_entry_safe(rule, node, &hdev->fd_rule_list, rule_node) {
ret = hclge_config_action(hdev, HCLGE_FD_STAGE_1, rule); ret = hclge_config_action(hdev, HCLGE_FD_STAGE_1, rule);
if (!ret) if (!ret)
...@@ -5295,6 +5299,20 @@ static void hclge_reset_tqp_stats(struct hnae3_handle *handle) ...@@ -5295,6 +5299,20 @@ static void hclge_reset_tqp_stats(struct hnae3_handle *handle)
} }
} }
static void hclge_set_timer_task(struct hnae3_handle *handle, bool enable)
{
struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back;
if (enable) {
mod_timer(&hdev->service_timer, jiffies + HZ);
} else {
del_timer_sync(&hdev->service_timer);
cancel_work_sync(&hdev->service_task);
clear_bit(HCLGE_STATE_SERVICE_SCHED, &hdev->state);
}
}
static int hclge_ae_start(struct hnae3_handle *handle) static int hclge_ae_start(struct hnae3_handle *handle)
{ {
struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_vport *vport = hclge_get_vport(handle);
...@@ -5303,7 +5321,6 @@ static int hclge_ae_start(struct hnae3_handle *handle) ...@@ -5303,7 +5321,6 @@ static int hclge_ae_start(struct hnae3_handle *handle)
/* mac enable */ /* mac enable */
hclge_cfg_mac_mode(hdev, true); hclge_cfg_mac_mode(hdev, true);
clear_bit(HCLGE_STATE_DOWN, &hdev->state); clear_bit(HCLGE_STATE_DOWN, &hdev->state);
mod_timer(&hdev->service_timer, jiffies + HZ);
hdev->hw.mac.link = 0; hdev->hw.mac.link = 0;
/* reset tqp stats */ /* reset tqp stats */
...@@ -5318,13 +5335,10 @@ static void hclge_ae_stop(struct hnae3_handle *handle) ...@@ -5318,13 +5335,10 @@ static void hclge_ae_stop(struct hnae3_handle *handle)
{ {
struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
int i;
set_bit(HCLGE_STATE_DOWN, &hdev->state); set_bit(HCLGE_STATE_DOWN, &hdev->state);
del_timer_sync(&hdev->service_timer);
cancel_work_sync(&hdev->service_task);
clear_bit(HCLGE_STATE_SERVICE_SCHED, &hdev->state);
/* If it is not PF reset, the firmware will disable the MAC, /* If it is not PF reset, the firmware will disable the MAC,
* so it only need to stop phy here. * so it only need to stop phy here.
*/ */
...@@ -5334,6 +5348,9 @@ static void hclge_ae_stop(struct hnae3_handle *handle) ...@@ -5334,6 +5348,9 @@ static void hclge_ae_stop(struct hnae3_handle *handle)
return; return;
} }
for (i = 0; i < handle->kinfo.num_tqps; i++)
hclge_reset_tqp(handle, i);
/* Mac disable */ /* Mac disable */
hclge_cfg_mac_mode(hdev, false); hclge_cfg_mac_mode(hdev, false);
...@@ -5341,8 +5358,6 @@ static void hclge_ae_stop(struct hnae3_handle *handle) ...@@ -5341,8 +5358,6 @@ static void hclge_ae_stop(struct hnae3_handle *handle)
/* reset tqp stats */ /* reset tqp stats */
hclge_reset_tqp_stats(handle); hclge_reset_tqp_stats(handle);
del_timer_sync(&hdev->service_timer);
cancel_work_sync(&hdev->service_task);
hclge_update_link_status(hdev); hclge_update_link_status(hdev);
} }
...@@ -7996,6 +8011,7 @@ static const struct hnae3_ae_ops hclge_ops = { ...@@ -7996,6 +8011,7 @@ static const struct hnae3_ae_ops hclge_ops = {
.ae_dev_reset_cnt = hclge_ae_dev_reset_cnt, .ae_dev_reset_cnt = hclge_ae_dev_reset_cnt,
.set_gro_en = hclge_gro_en, .set_gro_en = hclge_gro_en,
.get_global_queue_id = hclge_covert_handle_qid_global, .get_global_queue_id = hclge_covert_handle_qid_global,
.set_timer_task = hclge_set_timer_task,
}; };
static struct hnae3_ae_algo ae_algo = { static struct hnae3_ae_algo ae_algo = {
......
...@@ -1721,7 +1721,7 @@ static int hclgevf_configure(struct hclgevf_dev *hdev) ...@@ -1721,7 +1721,7 @@ static int hclgevf_configure(struct hclgevf_dev *hdev)
static int hclgevf_alloc_hdev(struct hnae3_ae_dev *ae_dev) static int hclgevf_alloc_hdev(struct hnae3_ae_dev *ae_dev)
{ {
struct pci_dev *pdev = ae_dev->pdev; struct pci_dev *pdev = ae_dev->pdev;
struct hclgevf_dev *hdev = ae_dev->priv; struct hclgevf_dev *hdev;
hdev = devm_kzalloc(&pdev->dev, sizeof(*hdev), GFP_KERNEL); hdev = devm_kzalloc(&pdev->dev, sizeof(*hdev), GFP_KERNEL);
if (!hdev) if (!hdev)
...@@ -1840,6 +1840,19 @@ static int hclgevf_init_vlan_config(struct hclgevf_dev *hdev) ...@@ -1840,6 +1840,19 @@ static int hclgevf_init_vlan_config(struct hclgevf_dev *hdev)
false); false);
} }
static void hclgevf_set_timer_task(struct hnae3_handle *handle, bool enable)
{
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
if (enable) {
mod_timer(&hdev->service_timer, jiffies + HZ);
} else {
del_timer_sync(&hdev->service_timer);
cancel_work_sync(&hdev->service_task);
clear_bit(HCLGEVF_STATE_SERVICE_SCHED, &hdev->state);
}
}
static int hclgevf_ae_start(struct hnae3_handle *handle) static int hclgevf_ae_start(struct hnae3_handle *handle)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
...@@ -1850,7 +1863,6 @@ static int hclgevf_ae_start(struct hnae3_handle *handle) ...@@ -1850,7 +1863,6 @@ static int hclgevf_ae_start(struct hnae3_handle *handle)
hclgevf_request_link_info(hdev); hclgevf_request_link_info(hdev);
clear_bit(HCLGEVF_STATE_DOWN, &hdev->state); clear_bit(HCLGEVF_STATE_DOWN, &hdev->state);
mod_timer(&hdev->service_timer, jiffies + HZ);
return 0; return 0;
} }
...@@ -1858,14 +1870,15 @@ static int hclgevf_ae_start(struct hnae3_handle *handle) ...@@ -1858,14 +1870,15 @@ static int hclgevf_ae_start(struct hnae3_handle *handle)
static void hclgevf_ae_stop(struct hnae3_handle *handle) static void hclgevf_ae_stop(struct hnae3_handle *handle)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
int i;
set_bit(HCLGEVF_STATE_DOWN, &hdev->state); set_bit(HCLGEVF_STATE_DOWN, &hdev->state);
for (i = 0; i < handle->kinfo.num_tqps; i++)
hclgevf_reset_tqp(handle, i);
/* reset tqp stats */ /* reset tqp stats */
hclgevf_reset_tqp_stats(handle); hclgevf_reset_tqp_stats(handle);
del_timer_sync(&hdev->service_timer);
cancel_work_sync(&hdev->service_task);
clear_bit(HCLGEVF_STATE_SERVICE_SCHED, &hdev->state);
hclgevf_update_link_status(hdev, 0); hclgevf_update_link_status(hdev, 0);
} }
...@@ -2663,6 +2676,7 @@ static const struct hnae3_ae_ops hclgevf_ops = { ...@@ -2663,6 +2676,7 @@ static const struct hnae3_ae_ops hclgevf_ops = {
.set_gro_en = hclgevf_gro_en, .set_gro_en = hclgevf_gro_en,
.set_mtu = hclgevf_set_mtu, .set_mtu = hclgevf_set_mtu,
.get_global_queue_id = hclgevf_get_qid_global, .get_global_queue_id = hclgevf_get_qid_global,
.set_timer_task = hclgevf_set_timer_task,
}; };
static struct hnae3_ae_algo ae_algovf = { static struct hnae3_ae_algo ae_algovf = {
......
...@@ -26,7 +26,7 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1, ...@@ -26,7 +26,7 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1,
u8 *resp_data, u16 resp_len) u8 *resp_data, u16 resp_len)
{ {
#define HCLGEVF_MAX_TRY_TIMES 500 #define HCLGEVF_MAX_TRY_TIMES 500
#define HCLGEVF_SLEEP_USCOEND 1000 #define HCLGEVF_SLEEP_USECOND 1000
struct hclgevf_mbx_resp_status *mbx_resp; struct hclgevf_mbx_resp_status *mbx_resp;
u16 r_code0, r_code1; u16 r_code0, r_code1;
int i = 0; int i = 0;
...@@ -43,7 +43,7 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1, ...@@ -43,7 +43,7 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1,
if (test_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state)) if (test_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state))
return -EIO; return -EIO;
udelay(HCLGEVF_SLEEP_USCOEND); usleep_range(HCLGEVF_SLEEP_USECOND, HCLGEVF_SLEEP_USECOND * 2);
i++; i++;
} }
......
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