Message ID | 1515147504-86802-7-git-send-email-lipeng321@huawei.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
Series | add some new features and fix some bugs for HNS3 driver | expand |
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c > @@ -1126,6 +1126,7 @@ static int hns3_nic_set_features(struct net_device *netdev, > { > struct hns3_nic_priv *priv = netdev_priv(netdev); > int queue_num = priv->ae_handle->kinfo.num_tqps; > + struct hnae3_handle *handle = priv->ae_handle; > struct hns3_enet_ring *ring; > unsigned int start; > unsigned int idx; > @@ -1134,6 +1135,8 @@ static int hns3_nic_set_features(struct net_device *netdev, > u64 tx_pkts = 0; > u64 rx_pkts = 0; > > + handle->ae_algo->ops->update_stats(handle, &netdev->stats); > + > for (idx = 0; idx < queue_num; idx++) { > /* fetch the tx stats */ > ring = priv->ring_data[idx].ring; There is something odd going on with patch here. Notice how it says hns3_nic_set_features(). This is not the function being patched, it is actually the next one, hns3_nic_get_stats64(), which makes a lot more sense. Is it because the static void is on the previous line? It would be nice if the function was correctly reported. It makes it easier to review the patch. Andrew
On 2018/1/5 22:54, Andrew Lunn wrote: >> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c >> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c >> @@ -1126,6 +1126,7 @@ static int hns3_nic_set_features(struct net_device *netdev, >> { >> struct hns3_nic_priv *priv = netdev_priv(netdev); >> int queue_num = priv->ae_handle->kinfo.num_tqps; >> + struct hnae3_handle *handle = priv->ae_handle; >> struct hns3_enet_ring *ring; >> unsigned int start; >> unsigned int idx; >> @@ -1134,6 +1135,8 @@ static int hns3_nic_set_features(struct net_device *netdev, >> u64 tx_pkts = 0; >> u64 rx_pkts = 0; >> >> + handle->ae_algo->ops->update_stats(handle, &netdev->stats); >> + >> for (idx = 0; idx < queue_num; idx++) { >> /* fetch the tx stats */ >> ring = priv->ring_data[idx].ring; > There is something odd going on with patch here. Notice how it says > hns3_nic_set_features(). This is not the function being patched, it is > actually the next one, hns3_nic_get_stats64(), which makes a lot more > sense. > > Is it because the static void is on the previous line? Yes, it is because the static void is on the previous line. I can add one patch to fix the previous line , and this patch will correct automatically. do it need V2 patchset? or push a new patch after this patchset? > > It would be nice if the function was correctly reported. It makes it > easier to review the patch. > > Andrew > > . >
> >Is it because the static void is on the previous line? > Yes, it is because the static void is on the previous line. > > I can add one patch to fix the previous line , and this patch will correct > automatically. > > do it need V2 patchset? or push a new patch after this patchset? Thanks for looking into this. This actually seems like a patch bug, but i think the consensus is to have the function type on the same line as the function name within Linux. No need for a v2. Just send followup patches. Andrew
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 565d85d..79c5daa 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1126,6 +1126,7 @@ static int hns3_nic_set_features(struct net_device *netdev, { struct hns3_nic_priv *priv = netdev_priv(netdev); int queue_num = priv->ae_handle->kinfo.num_tqps; + struct hnae3_handle *handle = priv->ae_handle; struct hns3_enet_ring *ring; unsigned int start; unsigned int idx; @@ -1134,6 +1135,8 @@ static int hns3_nic_set_features(struct net_device *netdev, u64 tx_pkts = 0; u64 rx_pkts = 0; + handle->ae_algo->ops->update_stats(handle, &netdev->stats); + for (idx = 0; idx < queue_num; idx++) { /* fetch the tx stats */ ring = priv->ring_data[idx].ring; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 2cca37c..20ec791 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -698,6 +698,9 @@ static void hclge_update_stats(struct hnae3_handle *handle, struct hclge_hw_stats *hw_stats = &hdev->hw_stats; int status; + if (test_and_set_bit(HCLGE_STATE_STATISTICS_UPDATING, &hdev->state)) + return; + status = hclge_mac_update_stats(hdev); if (status) dev_err(&hdev->pdev->dev, @@ -723,6 +726,8 @@ static void hclge_update_stats(struct hnae3_handle *handle, status); hclge_update_netstat(hw_stats, net_stats); + + clear_bit(HCLGE_STATE_STATISTICS_UPDATING, &hdev->state); } static int hclge_get_sset_count(struct hnae3_handle *handle, int stringset) @@ -2380,6 +2385,7 @@ static void hclge_service_timer(struct timer_list *t) struct hclge_dev *hdev = from_timer(hdev, t, service_timer); mod_timer(&hdev->service_timer, jiffies + HZ); + hdev->hw_stats.stats_timer++; hclge_task_schedule(hdev); } @@ -2779,9 +2785,13 @@ static void hclge_service_task(struct work_struct *work) struct hclge_dev *hdev = container_of(work, struct hclge_dev, service_task); + if (hdev->hw_stats.stats_timer >= HCLGE_STATS_TIMER_INTERVAL) { + hclge_update_stats_for_all(hdev); + hdev->hw_stats.stats_timer = 0; + } + hclge_update_speed_duplex(hdev); hclge_update_link_status(hdev); - hclge_update_stats_for_all(hdev); hclge_service_complete(hdev); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 15ca95f..50ae13a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -112,6 +112,7 @@ enum HCLGE_DEV_STATE { HCLGE_STATE_RST_HANDLING, HCLGE_STATE_MBX_SERVICE_SCHED, HCLGE_STATE_MBX_HANDLING, + HCLGE_STATE_STATISTICS_UPDATING, HCLGE_STATE_MAX }; @@ -422,10 +423,12 @@ struct hclge_mac_stats { u64 mac_rx_send_app_bad_pkt_num; }; +#define HCLGE_STATS_TIMER_INTERVAL (60 * 5) struct hclge_hw_stats { struct hclge_mac_stats mac_stats; struct hclge_64_bit_stats all_64_bit_stats; struct hclge_32_bit_stats all_32_bit_stats; + u32 stats_timer; }; struct hclge_vlan_type_cfg {