Skip to content

Commit 2dc3bd7

Browse files
committed
Merge branch 'hns3-fixes'
Huazhong Tan says: ==================== net: hns3: fixes for -net There are some bugfixes for the HNS3 ethernet driver. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents b0a4227 + fac24df commit 2dc3bd7

File tree

5 files changed

+38
-41
lines changed

5 files changed

+38
-41
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
((ring)->p = ((ring)->p - 1 + (ring)->desc_num) % (ring)->desc_num)
7878

7979
enum hns_desc_type {
80+
DESC_TYPE_UNKNOWN,
8081
DESC_TYPE_SKB,
8182
DESC_TYPE_FRAGLIST_SKB,
8283
DESC_TYPE_PAGE,

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,12 +1118,12 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
11181118
return -ENOMEM;
11191119
}
11201120

1121+
desc_cb->priv = priv;
11211122
desc_cb->length = size;
1123+
desc_cb->dma = dma;
1124+
desc_cb->type = type;
11221125

11231126
if (likely(size <= HNS3_MAX_BD_SIZE)) {
1124-
desc_cb->priv = priv;
1125-
desc_cb->dma = dma;
1126-
desc_cb->type = type;
11271127
desc->addr = cpu_to_le64(dma);
11281128
desc->tx.send_size = cpu_to_le16(size);
11291129
desc->tx.bdtp_fe_sc_vld_ra_ri =
@@ -1135,18 +1135,11 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
11351135
}
11361136

11371137
frag_buf_num = hns3_tx_bd_count(size);
1138-
sizeoflast = size & HNS3_TX_LAST_SIZE_M;
1138+
sizeoflast = size % HNS3_MAX_BD_SIZE;
11391139
sizeoflast = sizeoflast ? sizeoflast : HNS3_MAX_BD_SIZE;
11401140

11411141
/* When frag size is bigger than hardware limit, split this frag */
11421142
for (k = 0; k < frag_buf_num; k++) {
1143-
/* The txbd's baseinfo of DESC_TYPE_PAGE & DESC_TYPE_SKB */
1144-
desc_cb->priv = priv;
1145-
desc_cb->dma = dma + HNS3_MAX_BD_SIZE * k;
1146-
desc_cb->type = ((type == DESC_TYPE_FRAGLIST_SKB ||
1147-
type == DESC_TYPE_SKB) && !k) ?
1148-
type : DESC_TYPE_PAGE;
1149-
11501143
/* now, fill the descriptor */
11511144
desc->addr = cpu_to_le64(dma + HNS3_MAX_BD_SIZE * k);
11521145
desc->tx.send_size = cpu_to_le16((k == frag_buf_num - 1) ?
@@ -1158,7 +1151,6 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
11581151
/* move ring pointer to next */
11591152
ring_ptr_move_fw(ring, next_to_use);
11601153

1161-
desc_cb = &ring->desc_cb[ring->next_to_use];
11621154
desc = &ring->desc[ring->next_to_use];
11631155
}
11641156

@@ -1346,13 +1338,20 @@ static void hns3_clear_desc(struct hns3_enet_ring *ring, int next_to_use_orig)
13461338
unsigned int i;
13471339

13481340
for (i = 0; i < ring->desc_num; i++) {
1341+
struct hns3_desc *desc = &ring->desc[ring->next_to_use];
1342+
1343+
memset(desc, 0, sizeof(*desc));
1344+
13491345
/* check if this is where we started */
13501346
if (ring->next_to_use == next_to_use_orig)
13511347
break;
13521348

13531349
/* rollback one */
13541350
ring_ptr_move_bw(ring, next_to_use);
13551351

1352+
if (!ring->desc_cb[ring->next_to_use].dma)
1353+
continue;
1354+
13561355
/* unmap the descriptor dma address */
13571356
if (ring->desc_cb[ring->next_to_use].type == DESC_TYPE_SKB ||
13581357
ring->desc_cb[ring->next_to_use].type ==
@@ -1369,6 +1368,7 @@ static void hns3_clear_desc(struct hns3_enet_ring *ring, int next_to_use_orig)
13691368

13701369
ring->desc_cb[ring->next_to_use].length = 0;
13711370
ring->desc_cb[ring->next_to_use].dma = 0;
1371+
ring->desc_cb[ring->next_to_use].type = DESC_TYPE_UNKNOWN;
13721372
}
13731373
}
13741374

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ enum hns3_nic_state {
165165
#define HNS3_TXD_MSS_S 0
166166
#define HNS3_TXD_MSS_M (0x3fff << HNS3_TXD_MSS_S)
167167

168-
#define HNS3_TX_LAST_SIZE_M 0xffff
169-
170168
#define HNS3_VECTOR_TX_IRQ BIT_ULL(0)
171169
#define HNS3_VECTOR_RX_IRQ BIT_ULL(1)
172170

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

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,11 +2673,10 @@ void hclge_task_schedule(struct hclge_dev *hdev, unsigned long delay_time)
26732673
delay_time);
26742674
}
26752675

2676-
static int hclge_get_mac_link_status(struct hclge_dev *hdev)
2676+
static int hclge_get_mac_link_status(struct hclge_dev *hdev, int *link_status)
26772677
{
26782678
struct hclge_link_status_cmd *req;
26792679
struct hclge_desc desc;
2680-
int link_status;
26812680
int ret;
26822681

26832682
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_QUERY_LINK_STATUS, true);
@@ -2689,33 +2688,25 @@ static int hclge_get_mac_link_status(struct hclge_dev *hdev)
26892688
}
26902689

26912690
req = (struct hclge_link_status_cmd *)desc.data;
2692-
link_status = req->status & HCLGE_LINK_STATUS_UP_M;
2691+
*link_status = (req->status & HCLGE_LINK_STATUS_UP_M) > 0 ?
2692+
HCLGE_LINK_STATUS_UP : HCLGE_LINK_STATUS_DOWN;
26932693

2694-
return !!link_status;
2694+
return 0;
26952695
}
26962696

2697-
static int hclge_get_mac_phy_link(struct hclge_dev *hdev)
2697+
static int hclge_get_mac_phy_link(struct hclge_dev *hdev, int *link_status)
26982698
{
2699-
unsigned int mac_state;
2700-
int link_stat;
2699+
struct phy_device *phydev = hdev->hw.mac.phydev;
2700+
2701+
*link_status = HCLGE_LINK_STATUS_DOWN;
27012702

27022703
if (test_bit(HCLGE_STATE_DOWN, &hdev->state))
27032704
return 0;
27042705

2705-
mac_state = hclge_get_mac_link_status(hdev);
2706-
2707-
if (hdev->hw.mac.phydev) {
2708-
if (hdev->hw.mac.phydev->state == PHY_RUNNING)
2709-
link_stat = mac_state &
2710-
hdev->hw.mac.phydev->link;
2711-
else
2712-
link_stat = 0;
2713-
2714-
} else {
2715-
link_stat = mac_state;
2716-
}
2706+
if (phydev && (phydev->state != PHY_RUNNING || !phydev->link))
2707+
return 0;
27172708

2718-
return !!link_stat;
2709+
return hclge_get_mac_link_status(hdev, link_status);
27192710
}
27202711

27212712
static void hclge_update_link_status(struct hclge_dev *hdev)
@@ -2725,6 +2716,7 @@ static void hclge_update_link_status(struct hclge_dev *hdev)
27252716
struct hnae3_handle *rhandle;
27262717
struct hnae3_handle *handle;
27272718
int state;
2719+
int ret;
27282720
int i;
27292721

27302722
if (!client)
@@ -2733,7 +2725,12 @@ static void hclge_update_link_status(struct hclge_dev *hdev)
27332725
if (test_and_set_bit(HCLGE_STATE_LINK_UPDATING, &hdev->state))
27342726
return;
27352727

2736-
state = hclge_get_mac_phy_link(hdev);
2728+
ret = hclge_get_mac_phy_link(hdev, &state);
2729+
if (ret) {
2730+
clear_bit(HCLGE_STATE_LINK_UPDATING, &hdev->state);
2731+
return;
2732+
}
2733+
27372734
if (state != hdev->hw.mac.link) {
27382735
for (i = 0; i < hdev->num_vmdq_vport + 1; i++) {
27392736
handle = &hdev->vport[i].nic;
@@ -6524,14 +6521,15 @@ static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret)
65246521
{
65256522
#define HCLGE_MAC_LINK_STATUS_NUM 100
65266523

6524+
int link_status;
65276525
int i = 0;
65286526
int ret;
65296527

65306528
do {
6531-
ret = hclge_get_mac_link_status(hdev);
6532-
if (ret < 0)
6529+
ret = hclge_get_mac_link_status(hdev, &link_status);
6530+
if (ret)
65336531
return ret;
6534-
else if (ret == link_ret)
6532+
if (link_status == link_ret)
65356533
return 0;
65366534

65376535
msleep(HCLGE_LINK_STATUS_MS);
@@ -6542,9 +6540,6 @@ static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret)
65426540
static int hclge_mac_phy_link_status_wait(struct hclge_dev *hdev, bool en,
65436541
bool is_phy)
65446542
{
6545-
#define HCLGE_LINK_STATUS_DOWN 0
6546-
#define HCLGE_LINK_STATUS_UP 1
6547-
65486543
int link_ret;
65496544

65506545
link_ret = en ? HCLGE_LINK_STATUS_UP : HCLGE_LINK_STATUS_DOWN;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ enum hclge_link_fail_code {
317317
HCLGE_LF_XSFP_ABSENT,
318318
};
319319

320+
#define HCLGE_LINK_STATUS_DOWN 0
321+
#define HCLGE_LINK_STATUS_UP 1
322+
320323
#define HCLGE_PG_NUM 4
321324
#define HCLGE_SCH_MODE_SP 0
322325
#define HCLGE_SCH_MODE_DWRR 1

0 commit comments

Comments
 (0)