Skip to content

Commit 1e513b6

Browse files
committed
Merge branch 'hns3-bug-fixes'
Salil Mehta says: ==================== Bug fixes for the HNS3 Ethernet Driver for Hip08 SoC This patch set presents some bug fixes for the HNS3 Ethernet driver identified during internal testing & stabilization efforts. Change Log: Patch V2: Resolved comments from Leon Romanovsky Patch V1: Initial Submit ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 930651a + 90f7b11 commit 1e513b6

File tree

4 files changed

+35
-43
lines changed

4 files changed

+35
-43
lines changed

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

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,15 @@ static bool hnae3_client_match(enum hnae3_client_type client_type,
3737
}
3838

3939
static int hnae3_match_n_instantiate(struct hnae3_client *client,
40-
struct hnae3_ae_dev *ae_dev,
41-
bool is_reg, bool *matched)
40+
struct hnae3_ae_dev *ae_dev, bool is_reg)
4241
{
4342
int ret;
4443

45-
*matched = false;
46-
4744
/* check if this client matches the type of ae_dev */
4845
if (!(hnae3_client_match(client->type, ae_dev->dev_type) &&
4946
hnae_get_bit(ae_dev->flag, HNAE3_DEV_INITED_B))) {
5047
return 0;
5148
}
52-
/* there is a match of client and dev */
53-
*matched = true;
5449

5550
/* now, (un-)instantiate client by calling lower layer */
5651
if (is_reg) {
@@ -69,7 +64,6 @@ int hnae3_register_client(struct hnae3_client *client)
6964
{
7065
struct hnae3_client *client_tmp;
7166
struct hnae3_ae_dev *ae_dev;
72-
bool matched;
7367
int ret = 0;
7468

7569
mutex_lock(&hnae3_common_lock);
@@ -86,7 +80,7 @@ int hnae3_register_client(struct hnae3_client *client)
8680
/* if the client could not be initialized on current port, for
8781
* any error reasons, move on to next available port
8882
*/
89-
ret = hnae3_match_n_instantiate(client, ae_dev, true, &matched);
83+
ret = hnae3_match_n_instantiate(client, ae_dev, true);
9084
if (ret)
9185
dev_err(&ae_dev->pdev->dev,
9286
"match and instantiation failed for port\n");
@@ -102,12 +96,11 @@ EXPORT_SYMBOL(hnae3_register_client);
10296
void hnae3_unregister_client(struct hnae3_client *client)
10397
{
10498
struct hnae3_ae_dev *ae_dev;
105-
bool matched;
10699

107100
mutex_lock(&hnae3_common_lock);
108101
/* un-initialize the client on every matched port */
109102
list_for_each_entry(ae_dev, &hnae3_ae_dev_list, node) {
110-
hnae3_match_n_instantiate(client, ae_dev, false, &matched);
103+
hnae3_match_n_instantiate(client, ae_dev, false);
111104
}
112105

113106
list_del(&client->node);
@@ -124,7 +117,6 @@ int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo)
124117
const struct pci_device_id *id;
125118
struct hnae3_ae_dev *ae_dev;
126119
struct hnae3_client *client;
127-
bool matched;
128120
int ret = 0;
129121

130122
mutex_lock(&hnae3_common_lock);
@@ -151,13 +143,10 @@ int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo)
151143
* initialize the figure out client instance
152144
*/
153145
list_for_each_entry(client, &hnae3_client_list, node) {
154-
ret = hnae3_match_n_instantiate(client, ae_dev, true,
155-
&matched);
146+
ret = hnae3_match_n_instantiate(client, ae_dev, true);
156147
if (ret)
157148
dev_err(&ae_dev->pdev->dev,
158149
"match and instantiation failed\n");
159-
if (matched)
160-
break;
161150
}
162151
}
163152

@@ -175,7 +164,6 @@ void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo)
175164
const struct pci_device_id *id;
176165
struct hnae3_ae_dev *ae_dev;
177166
struct hnae3_client *client;
178-
bool matched;
179167

180168
mutex_lock(&hnae3_common_lock);
181169
/* Check if there are matched ae_dev */
@@ -187,12 +175,8 @@ void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo)
187175
/* check the client list for the match with this ae_dev type and
188176
* un-initialize the figure out client instance
189177
*/
190-
list_for_each_entry(client, &hnae3_client_list, node) {
191-
hnae3_match_n_instantiate(client, ae_dev, false,
192-
&matched);
193-
if (matched)
194-
break;
195-
}
178+
list_for_each_entry(client, &hnae3_client_list, node)
179+
hnae3_match_n_instantiate(client, ae_dev, false);
196180

197181
ae_algo->ops->uninit_ae_dev(ae_dev);
198182
hnae_set_bit(ae_dev->flag, HNAE3_DEV_INITED_B, 0);
@@ -212,7 +196,6 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
212196
const struct pci_device_id *id;
213197
struct hnae3_ae_algo *ae_algo;
214198
struct hnae3_client *client;
215-
bool matched;
216199
int ret = 0;
217200

218201
mutex_lock(&hnae3_common_lock);
@@ -246,13 +229,10 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
246229
* initialize the figure out client instance
247230
*/
248231
list_for_each_entry(client, &hnae3_client_list, node) {
249-
ret = hnae3_match_n_instantiate(client, ae_dev, true,
250-
&matched);
232+
ret = hnae3_match_n_instantiate(client, ae_dev, true);
251233
if (ret)
252234
dev_err(&ae_dev->pdev->dev,
253235
"match and instantiation failed\n");
254-
if (matched)
255-
break;
256236
}
257237

258238
out_err:
@@ -270,7 +250,6 @@ void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev)
270250
const struct pci_device_id *id;
271251
struct hnae3_ae_algo *ae_algo;
272252
struct hnae3_client *client;
273-
bool matched;
274253

275254
mutex_lock(&hnae3_common_lock);
276255
/* Check if there are matched ae_algo */
@@ -279,12 +258,8 @@ void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev)
279258
if (!id)
280259
continue;
281260

282-
list_for_each_entry(client, &hnae3_client_list, node) {
283-
hnae3_match_n_instantiate(client, ae_dev, false,
284-
&matched);
285-
if (matched)
286-
break;
287-
}
261+
list_for_each_entry(client, &hnae3_client_list, node)
262+
hnae3_match_n_instantiate(client, ae_dev, false);
288263

289264
ae_algo->ops->uninit_ae_dev(ae_dev);
290265
hnae_set_bit(ae_dev->flag, HNAE3_DEV_INITED_B, 0);

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ struct hclge_tqp_map {
238238
u8 rsv[18];
239239
};
240240

241-
#define HCLGE_VECTOR_ELEMENTS_PER_CMD 11
241+
#define HCLGE_VECTOR_ELEMENTS_PER_CMD 10
242242

243243
enum hclge_int_type {
244244
HCLGE_INT_TX,
@@ -252,8 +252,12 @@ struct hclge_ctrl_vector_chain {
252252
#define HCLGE_INT_TYPE_S 0
253253
#define HCLGE_INT_TYPE_M 0x3
254254
#define HCLGE_TQP_ID_S 2
255-
#define HCLGE_TQP_ID_M (0x3fff << HCLGE_TQP_ID_S)
255+
#define HCLGE_TQP_ID_M (0x7ff << HCLGE_TQP_ID_S)
256+
#define HCLGE_INT_GL_IDX_S 13
257+
#define HCLGE_INT_GL_IDX_M (0x3 << HCLGE_INT_GL_IDX_S)
256258
__le16 tqp_type_and_id[HCLGE_VECTOR_ELEMENTS_PER_CMD];
259+
u8 vfid;
260+
u8 rsv;
257261
};
258262

259263
#define HCLGE_TC_NUM 8

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,9 +1063,9 @@ static int hclge_configure(struct hclge_dev *hdev)
10631063
hdev->base_tqp_pid = 0;
10641064
hdev->rss_size_max = 1;
10651065
hdev->rx_buf_len = cfg.rx_buf_len;
1066-
for (i = 0; i < ETH_ALEN; i++)
1067-
hdev->hw.mac.mac_addr[i] = cfg.mac_addr[i];
1066+
ether_addr_copy(hdev->hw.mac.mac_addr, cfg.mac_addr);
10681067
hdev->hw.mac.media_type = cfg.media_type;
1068+
hdev->hw.mac.phy_addr = cfg.phy_addr;
10691069
hdev->num_desc = cfg.tqp_desc_num;
10701070
hdev->tm_info.num_pg = 1;
10711071
hdev->tm_info.num_tc = cfg.tc_num;
@@ -2679,7 +2679,11 @@ int hclge_map_vport_ring_to_vector(struct hclge_vport *vport, int vector_id,
26792679
hnae_get_bit(node->flag, HNAE3_RING_TYPE_B));
26802680
hnae_set_field(req->tqp_type_and_id[i], HCLGE_TQP_ID_M,
26812681
HCLGE_TQP_ID_S, node->tqp_index);
2682+
hnae_set_field(req->tqp_type_and_id[i], HCLGE_INT_GL_IDX_M,
2683+
HCLGE_INT_GL_IDX_S,
2684+
hnae_get_bit(node->flag, HNAE3_RING_TYPE_B));
26822685
req->tqp_type_and_id[i] = cpu_to_le16(req->tqp_type_and_id[i]);
2686+
req->vfid = vport->vport_id;
26832687

26842688
if (++i >= HCLGE_VECTOR_ELEMENTS_PER_CMD) {
26852689
req->int_cause_num = HCLGE_VECTOR_ELEMENTS_PER_CMD;
@@ -2763,8 +2767,12 @@ static int hclge_unmap_ring_from_vector(
27632767
hnae_get_bit(node->flag, HNAE3_RING_TYPE_B));
27642768
hnae_set_field(req->tqp_type_and_id[i], HCLGE_TQP_ID_M,
27652769
HCLGE_TQP_ID_S, node->tqp_index);
2770+
hnae_set_field(req->tqp_type_and_id[i], HCLGE_INT_GL_IDX_M,
2771+
HCLGE_INT_GL_IDX_S,
2772+
hnae_get_bit(node->flag, HNAE3_RING_TYPE_B));
27662773

27672774
req->tqp_type_and_id[i] = cpu_to_le16(req->tqp_type_and_id[i]);
2775+
req->vfid = vport->vport_id;
27682776

27692777
if (++i >= HCLGE_VECTOR_ELEMENTS_PER_CMD) {
27702778
req->int_cause_num = HCLGE_VECTOR_ELEMENTS_PER_CMD;
@@ -2778,7 +2786,7 @@ static int hclge_unmap_ring_from_vector(
27782786
}
27792787
i = 0;
27802788
hclge_cmd_setup_basic_desc(&desc,
2781-
HCLGE_OPC_ADD_RING_TO_VECTOR,
2789+
HCLGE_OPC_DEL_RING_TO_VECTOR,
27822790
false);
27832791
req->int_vector_id = vector_id;
27842792
}
@@ -3665,6 +3673,7 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)
36653673
{
36663674
#define HCLGE_VLAN_TYPE_VF_TABLE 0
36673675
#define HCLGE_VLAN_TYPE_PORT_TABLE 1
3676+
struct hnae3_handle *handle;
36683677
int ret;
36693678

36703679
ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_VLAN_TYPE_VF_TABLE,
@@ -3674,8 +3683,11 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)
36743683

36753684
ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_VLAN_TYPE_PORT_TABLE,
36763685
true);
3686+
if (ret)
3687+
return ret;
36773688

3678-
return ret;
3689+
handle = &hdev->vport[0].nic;
3690+
return hclge_set_port_vlan_filter(handle, htons(ETH_P_8021Q), 0, false);
36793691
}
36803692

36813693
static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,10 +2705,11 @@ static void hns3_init_mac_addr(struct net_device *netdev)
27052705
eth_hw_addr_random(netdev);
27062706
dev_warn(priv->dev, "using random MAC address %pM\n",
27072707
netdev->dev_addr);
2708-
/* Also copy this new MAC address into hdev */
2709-
if (h->ae_algo->ops->set_mac_addr)
2710-
h->ae_algo->ops->set_mac_addr(h, netdev->dev_addr);
27112708
}
2709+
2710+
if (h->ae_algo->ops->set_mac_addr)
2711+
h->ae_algo->ops->set_mac_addr(h, netdev->dev_addr);
2712+
27122713
}
27132714

27142715
static void hns3_nic_set_priv_ops(struct net_device *netdev)

0 commit comments

Comments
 (0)