Skip to content

Commit 89fd905

Browse files
author
Paolo Abeni
committed
Merge branch 'there-are-some-bugfix-for-the-hns3-ethernet-driver'
Jijie Shao says: ==================== There are some bugfix for the HNS3 ethernet driver v1: https://lore.kernel.org/all/[email protected]/ ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 897e860 + 49ade86 commit 89fd905

File tree

5 files changed

+61
-23
lines changed

5 files changed

+61
-23
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/irq.h>
1212
#include <linux/ip.h>
1313
#include <linux/ipv6.h>
14+
#include <linux/iommu.h>
1415
#include <linux/module.h>
1516
#include <linux/pci.h>
1617
#include <linux/skbuff.h>
@@ -1039,6 +1040,8 @@ static bool hns3_can_use_tx_sgl(struct hns3_enet_ring *ring,
10391040
static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring)
10401041
{
10411042
u32 alloc_size = ring->tqp->handle->kinfo.tx_spare_buf_size;
1043+
struct net_device *netdev = ring_to_netdev(ring);
1044+
struct hns3_nic_priv *priv = netdev_priv(netdev);
10421045
struct hns3_tx_spare *tx_spare;
10431046
struct page *page;
10441047
dma_addr_t dma;
@@ -1080,6 +1083,7 @@ static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring)
10801083
tx_spare->buf = page_address(page);
10811084
tx_spare->len = PAGE_SIZE << order;
10821085
ring->tx_spare = tx_spare;
1086+
ring->tx_copybreak = priv->tx_copybreak;
10831087
return;
10841088

10851089
dma_mapping_error:
@@ -4874,6 +4878,30 @@ static void hns3_nic_dealloc_vector_data(struct hns3_nic_priv *priv)
48744878
devm_kfree(&pdev->dev, priv->tqp_vector);
48754879
}
48764880

4881+
static void hns3_update_tx_spare_buf_config(struct hns3_nic_priv *priv)
4882+
{
4883+
#define HNS3_MIN_SPARE_BUF_SIZE (2 * 1024 * 1024)
4884+
#define HNS3_MAX_PACKET_SIZE (64 * 1024)
4885+
4886+
struct iommu_domain *domain = iommu_get_domain_for_dev(priv->dev);
4887+
struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(priv->ae_handle);
4888+
struct hnae3_handle *handle = priv->ae_handle;
4889+
4890+
if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V3)
4891+
return;
4892+
4893+
if (!(domain && iommu_is_dma_domain(domain)))
4894+
return;
4895+
4896+
priv->min_tx_copybreak = HNS3_MAX_PACKET_SIZE;
4897+
priv->min_tx_spare_buf_size = HNS3_MIN_SPARE_BUF_SIZE;
4898+
4899+
if (priv->tx_copybreak < priv->min_tx_copybreak)
4900+
priv->tx_copybreak = priv->min_tx_copybreak;
4901+
if (handle->kinfo.tx_spare_buf_size < priv->min_tx_spare_buf_size)
4902+
handle->kinfo.tx_spare_buf_size = priv->min_tx_spare_buf_size;
4903+
}
4904+
48774905
static void hns3_ring_get_cfg(struct hnae3_queue *q, struct hns3_nic_priv *priv,
48784906
unsigned int ring_type)
48794907
{
@@ -5107,6 +5135,7 @@ int hns3_init_all_ring(struct hns3_nic_priv *priv)
51075135
int i, j;
51085136
int ret;
51095137

5138+
hns3_update_tx_spare_buf_config(priv);
51105139
for (i = 0; i < ring_num; i++) {
51115140
ret = hns3_alloc_ring_memory(&priv->ring[i]);
51125141
if (ret) {
@@ -5311,6 +5340,8 @@ static int hns3_client_init(struct hnae3_handle *handle)
53115340
priv->ae_handle = handle;
53125341
priv->tx_timeout_count = 0;
53135342
priv->max_non_tso_bd_num = ae_dev->dev_specs.max_non_tso_bd_num;
5343+
priv->min_tx_copybreak = 0;
5344+
priv->min_tx_spare_buf_size = 0;
53145345
set_bit(HNS3_NIC_STATE_DOWN, &priv->state);
53155346

53165347
handle->msg_enable = netif_msg_init(debug, DEFAULT_MSG_LEVEL);

drivers/net/ethernet/hisilicon/hns3/hns3_enet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,8 @@ struct hns3_nic_priv {
596596
struct hns3_enet_coalesce rx_coal;
597597
u32 tx_copybreak;
598598
u32 rx_copybreak;
599+
u32 min_tx_copybreak;
600+
u32 min_tx_spare_buf_size;
599601
};
600602

601603
union l3_hdr_info {

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9576,33 +9576,36 @@ static bool hclge_need_enable_vport_vlan_filter(struct hclge_vport *vport)
95769576
return false;
95779577
}
95789578

9579-
int hclge_enable_vport_vlan_filter(struct hclge_vport *vport, bool request_en)
9579+
static int __hclge_enable_vport_vlan_filter(struct hclge_vport *vport,
9580+
bool request_en)
95809581
{
9581-
struct hclge_dev *hdev = vport->back;
95829582
bool need_en;
95839583
int ret;
95849584

9585-
mutex_lock(&hdev->vport_lock);
9586-
9587-
vport->req_vlan_fltr_en = request_en;
9588-
95899585
need_en = hclge_need_enable_vport_vlan_filter(vport);
9590-
if (need_en == vport->cur_vlan_fltr_en) {
9591-
mutex_unlock(&hdev->vport_lock);
9586+
if (need_en == vport->cur_vlan_fltr_en)
95929587
return 0;
9593-
}
95949588

95959589
ret = hclge_set_vport_vlan_filter(vport, need_en);
9596-
if (ret) {
9597-
mutex_unlock(&hdev->vport_lock);
9590+
if (ret)
95989591
return ret;
9599-
}
96009592

96019593
vport->cur_vlan_fltr_en = need_en;
96029594

9595+
return 0;
9596+
}
9597+
9598+
int hclge_enable_vport_vlan_filter(struct hclge_vport *vport, bool request_en)
9599+
{
9600+
struct hclge_dev *hdev = vport->back;
9601+
int ret;
9602+
9603+
mutex_lock(&hdev->vport_lock);
9604+
vport->req_vlan_fltr_en = request_en;
9605+
ret = __hclge_enable_vport_vlan_filter(vport, request_en);
96039606
mutex_unlock(&hdev->vport_lock);
96049607

9605-
return 0;
9608+
return ret;
96069609
}
96079610

96089611
static int hclge_enable_vlan_filter(struct hnae3_handle *handle, bool enable)
@@ -10623,16 +10626,19 @@ static void hclge_sync_vlan_fltr_state(struct hclge_dev *hdev)
1062310626
&vport->state))
1062410627
continue;
1062510628

10626-
ret = hclge_enable_vport_vlan_filter(vport,
10627-
vport->req_vlan_fltr_en);
10629+
mutex_lock(&hdev->vport_lock);
10630+
ret = __hclge_enable_vport_vlan_filter(vport,
10631+
vport->req_vlan_fltr_en);
1062810632
if (ret) {
1062910633
dev_err(&hdev->pdev->dev,
1063010634
"failed to sync vlan filter state for vport%u, ret = %d\n",
1063110635
vport->vport_id, ret);
1063210636
set_bit(HCLGE_VPORT_STATE_VLAN_FLTR_CHANGE,
1063310637
&vport->state);
10638+
mutex_unlock(&hdev->vport_lock);
1063410639
return;
1063510640
}
10641+
mutex_unlock(&hdev->vport_lock);
1063610642
}
1063710643
}
1063810644

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,29 +497,32 @@ int hclge_ptp_init(struct hclge_dev *hdev)
497497
if (ret) {
498498
dev_err(&hdev->pdev->dev,
499499
"failed to init freq, ret = %d\n", ret);
500-
goto out;
500+
goto out_clear_int;
501501
}
502502

503503
ret = hclge_ptp_set_ts_mode(hdev, &hdev->ptp->ts_cfg);
504504
if (ret) {
505505
dev_err(&hdev->pdev->dev,
506506
"failed to init ts mode, ret = %d\n", ret);
507-
goto out;
507+
goto out_clear_int;
508508
}
509509

510510
ktime_get_real_ts64(&ts);
511511
ret = hclge_ptp_settime(&hdev->ptp->info, &ts);
512512
if (ret) {
513513
dev_err(&hdev->pdev->dev,
514514
"failed to init ts time, ret = %d\n", ret);
515-
goto out;
515+
goto out_clear_int;
516516
}
517517

518518
set_bit(HCLGE_STATE_PTP_EN, &hdev->state);
519519
dev_info(&hdev->pdev->dev, "phc initializes ok!\n");
520520

521521
return 0;
522522

523+
out_clear_int:
524+
clear_bit(HCLGE_PTP_FLAG_EN, &hdev->ptp->flags);
525+
hclge_ptp_int_en(hdev, false);
523526
out:
524527
hclge_ptp_destroy_clock(hdev);
525528

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3094,11 +3094,7 @@ static void hclgevf_uninit_ae_dev(struct hnae3_ae_dev *ae_dev)
30943094

30953095
static u32 hclgevf_get_max_channels(struct hclgevf_dev *hdev)
30963096
{
3097-
struct hnae3_handle *nic = &hdev->nic;
3098-
struct hnae3_knic_private_info *kinfo = &nic->kinfo;
3099-
3100-
return min_t(u32, hdev->rss_size_max,
3101-
hdev->num_tqps / kinfo->tc_info.num_tc);
3097+
return min(hdev->rss_size_max, hdev->num_tqps);
31023098
}
31033099

31043100
/**

0 commit comments

Comments
 (0)