Skip to content

Commit 4f4b93a

Browse files
committed
Merge branch 'hns3-next'
Salil Mehta says: ==================== Bug fixes, snall modifications & cleanup for HNS3 driver This patch presents some bug fixes, small modifications and cleanups to the HNS3 VF and PF driver. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents b158992 + ebfefb8 commit 4f4b93a

File tree

9 files changed

+120
-107
lines changed

9 files changed

+120
-107
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ enum hnae3_media_type {
107107
HNAE3_MEDIA_TYPE_FIBER,
108108
HNAE3_MEDIA_TYPE_COPPER,
109109
HNAE3_MEDIA_TYPE_BACKPLANE,
110+
HNAE3_MEDIA_TYPE_NONE,
110111
};
111112

112113
enum hnae3_reset_notify_type {
@@ -410,7 +411,6 @@ struct hnae3_ae_ops {
410411
void (*get_link_mode)(struct hnae3_handle *handle,
411412
unsigned long *supported,
412413
unsigned long *advertising);
413-
void (*get_port_type)(struct hnae3_handle *handle, u8 *port_type);
414414
};
415415

416416
struct hnae3_dcb_ops {

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ static int hns3_map_buffer(struct hns3_enet_ring *ring, struct hns3_desc_cb *cb)
18071807
cb->dma = dma_map_page(ring_to_dev(ring), cb->priv, 0,
18081808
cb->length, ring_to_dma_dir(ring));
18091809

1810-
if (dma_mapping_error(ring_to_dev(ring), cb->dma))
1810+
if (unlikely(dma_mapping_error(ring_to_dev(ring), cb->dma)))
18111811
return -EIO;
18121812

18131813
return 0;
@@ -1973,6 +1973,7 @@ static int is_valid_clean_head(struct hns3_enet_ring *ring, int h)
19731973
void hns3_clean_tx_ring(struct hns3_enet_ring *ring)
19741974
{
19751975
struct net_device *netdev = ring->tqp->handle->kinfo.netdev;
1976+
struct hns3_nic_priv *priv = netdev_priv(netdev);
19761977
struct netdev_queue *dev_queue;
19771978
int bytes, pkts;
19781979
int head;
@@ -2018,7 +2019,8 @@ void hns3_clean_tx_ring(struct hns3_enet_ring *ring)
20182019
* sees the new next_to_clean.
20192020
*/
20202021
smp_mb();
2021-
if (netif_tx_queue_stopped(dev_queue)) {
2022+
if (netif_tx_queue_stopped(dev_queue) &&
2023+
!test_bit(HNS3_NIC_STATE_DOWN, &priv->state)) {
20222024
netif_tx_wake_queue(dev_queue);
20232025
ring->stats.restart_queue++;
20242026
}
@@ -2147,7 +2149,6 @@ static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb,
21472149
hnae3_get_bit(l234info, HNS3_RXD_L4E_B) ||
21482150
hnae3_get_bit(l234info, HNS3_RXD_OL3E_B) ||
21492151
hnae3_get_bit(l234info, HNS3_RXD_OL4E_B))) {
2150-
netdev_err(netdev, "L3/L4 error pkt\n");
21512152
u64_stats_update_begin(&ring->syncp);
21522153
ring->stats.l3l4_csum_err++;
21532154
u64_stats_update_end(&ring->syncp);
@@ -2176,6 +2177,8 @@ static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb,
21762177
l4_type == HNS3_L4_TYPE_SCTP))
21772178
skb->ip_summed = CHECKSUM_UNNECESSARY;
21782179
break;
2180+
default:
2181+
break;
21792182
}
21802183
}
21812184

@@ -2324,8 +2327,6 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,
23242327
}
23252328

23262329
if (unlikely(!hnae3_get_bit(bd_base_info, HNS3_RXD_VLD_B))) {
2327-
netdev_err(netdev, "no valid bd,%016llx,%016llx\n",
2328-
((u64 *)desc)[0], ((u64 *)desc)[1]);
23292330
u64_stats_update_begin(&ring->syncp);
23302331
ring->stats.non_vld_descs++;
23312332
u64_stats_update_end(&ring->syncp);
@@ -2336,7 +2337,6 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,
23362337

23372338
if (unlikely((!desc->rx.pkt_len) ||
23382339
hnae3_get_bit(l234info, HNS3_RXD_TRUNCAT_B))) {
2339-
netdev_err(netdev, "truncated pkt\n");
23402340
u64_stats_update_begin(&ring->syncp);
23412341
ring->stats.err_pkt_len++;
23422342
u64_stats_update_end(&ring->syncp);
@@ -2346,7 +2346,6 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,
23462346
}
23472347

23482348
if (unlikely(hnae3_get_bit(l234info, HNS3_RXD_L2E_B))) {
2349-
netdev_err(netdev, "L2 error pkt\n");
23502349
u64_stats_update_begin(&ring->syncp);
23512350
ring->stats.l2_err++;
23522351
u64_stats_update_end(&ring->syncp);

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

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ struct hns3_stats {
2222
static const struct hns3_stats hns3_txq_stats[] = {
2323
/* Tx per-queue statistics */
2424
HNS3_TQP_STAT("io_err_cnt", io_err_cnt),
25-
HNS3_TQP_STAT("tx_dropped", sw_err_cnt),
25+
HNS3_TQP_STAT("dropped", sw_err_cnt),
2626
HNS3_TQP_STAT("seg_pkt_cnt", seg_pkt_cnt),
2727
HNS3_TQP_STAT("packets", tx_pkts),
2828
HNS3_TQP_STAT("bytes", tx_bytes),
2929
HNS3_TQP_STAT("errors", tx_err_cnt),
30-
HNS3_TQP_STAT("tx_wake", restart_queue),
31-
HNS3_TQP_STAT("tx_busy", tx_busy),
30+
HNS3_TQP_STAT("wake", restart_queue),
31+
HNS3_TQP_STAT("busy", tx_busy),
3232
};
3333

3434
#define HNS3_TXQ_STATS_COUNT ARRAY_SIZE(hns3_txq_stats)
3535

3636
static const struct hns3_stats hns3_rxq_stats[] = {
3737
/* Rx per-queue statistics */
3838
HNS3_TQP_STAT("io_err_cnt", io_err_cnt),
39-
HNS3_TQP_STAT("rx_dropped", sw_err_cnt),
39+
HNS3_TQP_STAT("dropped", sw_err_cnt),
4040
HNS3_TQP_STAT("seg_pkt_cnt", seg_pkt_cnt),
4141
HNS3_TQP_STAT("packets", rx_pkts),
4242
HNS3_TQP_STAT("bytes", rx_bytes),
@@ -351,9 +351,10 @@ static int hns3_get_sset_count(struct net_device *netdev, int stringset)
351351

352352
case ETH_SS_TEST:
353353
return ops->get_sset_count(h, stringset);
354-
}
355354

356-
return 0;
355+
default:
356+
return -EOPNOTSUPP;
357+
}
357358
}
358359

359360
static void *hns3_update_strings(u8 *data, const struct hns3_stats *stats,
@@ -369,7 +370,7 @@ static void *hns3_update_strings(u8 *data, const struct hns3_stats *stats,
369370
data[ETH_GSTRING_LEN - 1] = '\0';
370371

371372
/* first, prepend the prefix string */
372-
n1 = snprintf(data, MAX_PREFIX_SIZE, "%s#%d_",
373+
n1 = snprintf(data, MAX_PREFIX_SIZE, "%s%d_",
373374
prefix, i);
374375
n1 = min_t(uint, n1, MAX_PREFIX_SIZE - 1);
375376
size_left = (ETH_GSTRING_LEN - 1) - n1;
@@ -417,6 +418,8 @@ static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
417418
case ETH_SS_TEST:
418419
ops->get_strings(h, stringset, data);
419420
break;
421+
default:
422+
break;
420423
}
421424
}
422425

@@ -542,55 +545,67 @@ static int hns3_set_pauseparam(struct net_device *netdev,
542545
return -EOPNOTSUPP;
543546
}
544547

548+
static void hns3_get_ksettings(struct hnae3_handle *h,
549+
struct ethtool_link_ksettings *cmd)
550+
{
551+
const struct hnae3_ae_ops *ops = h->ae_algo->ops;
552+
553+
/* 1.auto_neg & speed & duplex from cmd */
554+
if (ops->get_ksettings_an_result)
555+
ops->get_ksettings_an_result(h,
556+
&cmd->base.autoneg,
557+
&cmd->base.speed,
558+
&cmd->base.duplex);
559+
560+
/* 2.get link mode*/
561+
if (ops->get_link_mode)
562+
ops->get_link_mode(h,
563+
cmd->link_modes.supported,
564+
cmd->link_modes.advertising);
565+
566+
/* 3.mdix_ctrl&mdix get from phy reg */
567+
if (ops->get_mdix_mode)
568+
ops->get_mdix_mode(h, &cmd->base.eth_tp_mdix_ctrl,
569+
&cmd->base.eth_tp_mdix);
570+
}
571+
545572
static int hns3_get_link_ksettings(struct net_device *netdev,
546573
struct ethtool_link_ksettings *cmd)
547574
{
548575
struct hnae3_handle *h = hns3_get_handle(netdev);
549576
const struct hnae3_ae_ops *ops;
577+
u8 media_type;
550578
u8 link_stat;
551579

552580
if (!h->ae_algo || !h->ae_algo->ops)
553581
return -EOPNOTSUPP;
554582

555583
ops = h->ae_algo->ops;
556-
if (ops->get_port_type)
557-
ops->get_port_type(h, &cmd->base.port);
584+
if (ops->get_media_type)
585+
ops->get_media_type(h, &media_type);
558586
else
559587
return -EOPNOTSUPP;
560588

561-
switch (cmd->base.port) {
562-
case PORT_FIBRE:
563-
/* 1.auto_neg & speed & duplex from cmd */
564-
if (ops->get_ksettings_an_result)
565-
ops->get_ksettings_an_result(h,
566-
&cmd->base.autoneg,
567-
&cmd->base.speed,
568-
&cmd->base.duplex);
569-
else
570-
return -EOPNOTSUPP;
571-
572-
/* 2.get link mode*/
573-
if (ops->get_link_mode)
574-
ops->get_link_mode(h,
575-
cmd->link_modes.supported,
576-
cmd->link_modes.advertising);
577-
578-
/* 3.mdix_ctrl&mdix get from phy reg */
579-
if (ops->get_mdix_mode)
580-
ops->get_mdix_mode(h, &cmd->base.eth_tp_mdix_ctrl,
581-
&cmd->base.eth_tp_mdix);
582-
589+
switch (media_type) {
590+
case HNAE3_MEDIA_TYPE_NONE:
591+
cmd->base.port = PORT_NONE;
592+
hns3_get_ksettings(h, cmd);
583593
break;
584-
case PORT_TP:
594+
case HNAE3_MEDIA_TYPE_FIBER:
595+
cmd->base.port = PORT_FIBRE;
596+
hns3_get_ksettings(h, cmd);
597+
break;
598+
case HNAE3_MEDIA_TYPE_COPPER:
585599
if (!netdev->phydev)
586600
return -EOPNOTSUPP;
587601

602+
cmd->base.port = PORT_TP;
588603
phy_ethtool_ksettings_get(netdev->phydev, cmd);
589604

590605
break;
591606
default:
592-
netdev_warn(netdev,
593-
"Unknown port type, neither Fibre/Copper detected");
607+
608+
netdev_warn(netdev, "Unknown media type");
594609
return 0;
595610
}
596611

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ static int hclge_ieee_getets(struct hnae3_handle *h, struct ieee_ets *ets)
7373
static int hclge_ets_validate(struct hclge_dev *hdev, struct ieee_ets *ets,
7474
u8 *tc, bool *changed)
7575
{
76+
bool has_ets_tc = false;
7677
u32 total_ets_bw = 0;
7778
u8 max_tc = 0;
7879
u8 i;
@@ -100,13 +101,14 @@ static int hclge_ets_validate(struct hclge_dev *hdev, struct ieee_ets *ets,
100101
*changed = true;
101102

102103
total_ets_bw += ets->tc_tx_bw[i];
103-
break;
104+
has_ets_tc = true;
105+
break;
104106
default:
105107
return -EINVAL;
106108
}
107109
}
108110

109-
if (total_ets_bw != BW_PERCENT)
111+
if (has_ets_tc && total_ets_bw != BW_PERCENT)
110112
return -EINVAL;
111113

112114
*tc = max_tc + 1;

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

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,15 @@ static u8 *hclge_tqps_get_strings(struct hnae3_handle *handle, u8 *data)
354354
for (i = 0; i < kinfo->num_tqps; i++) {
355355
struct hclge_tqp *tqp = container_of(handle->kinfo.tqp[i],
356356
struct hclge_tqp, q);
357-
snprintf(buff, ETH_GSTRING_LEN, "txq#%d_pktnum_rcd",
357+
snprintf(buff, ETH_GSTRING_LEN, "txq%d_pktnum_rcd",
358358
tqp->index);
359359
buff = buff + ETH_GSTRING_LEN;
360360
}
361361

362362
for (i = 0; i < kinfo->num_tqps; i++) {
363363
struct hclge_tqp *tqp = container_of(kinfo->tqp[i],
364364
struct hclge_tqp, q);
365-
snprintf(buff, ETH_GSTRING_LEN, "rxq#%d_pktnum_rcd",
365+
snprintf(buff, ETH_GSTRING_LEN, "rxq%d_pktnum_rcd",
366366
tqp->index);
367367
buff = buff + ETH_GSTRING_LEN;
368368
}
@@ -2224,6 +2224,8 @@ static void hclge_clear_event_cause(struct hclge_dev *hdev, u32 event_type,
22242224
case HCLGE_VECTOR0_EVENT_MBX:
22252225
hclge_write_dev(&hdev->hw, HCLGE_VECTOR0_CMDQ_SRC_REG, regclr);
22262226
break;
2227+
default:
2228+
break;
22272229
}
22282230
}
22292231

@@ -3387,7 +3389,7 @@ static int hclge_set_serdes_loopback(struct hclge_dev *hdev, bool en)
33873389
struct hclge_desc desc;
33883390
int ret, i = 0;
33893391

3390-
req = (struct hclge_serdes_lb_cmd *)&desc.data[0];
3392+
req = (struct hclge_serdes_lb_cmd *)desc.data;
33913393
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_SERDES_LOOPBACK, false);
33923394

33933395
if (en) {
@@ -4634,7 +4636,7 @@ static int hclge_set_vlan_protocol_type(struct hclge_dev *hdev)
46344636

46354637
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MAC_VLAN_INSERT, false);
46364638

4637-
tx_req = (struct hclge_tx_vlan_type_cfg_cmd *)&desc.data;
4639+
tx_req = (struct hclge_tx_vlan_type_cfg_cmd *)desc.data;
46384640
tx_req->ot_vlan_type = cpu_to_le16(hdev->vlan_type_cfg.tx_ot_vlan_type);
46394641
tx_req->in_vlan_type = cpu_to_le16(hdev->vlan_type_cfg.tx_in_vlan_type);
46404642

@@ -5218,6 +5220,10 @@ static int hclge_init_client_instance(struct hnae3_client *client,
52185220

52195221
hnae3_set_client_init_flag(client, ae_dev, 1);
52205222
}
5223+
5224+
break;
5225+
default:
5226+
return -EINVAL;
52215227
}
52225228
}
52235229

@@ -5964,27 +5970,6 @@ static void hclge_get_link_mode(struct hnae3_handle *handle,
59645970
}
59655971
}
59665972

5967-
static void hclge_get_port_type(struct hnae3_handle *handle,
5968-
u8 *port_type)
5969-
{
5970-
struct hclge_vport *vport = hclge_get_vport(handle);
5971-
struct hclge_dev *hdev = vport->back;
5972-
u8 media_type = hdev->hw.mac.media_type;
5973-
5974-
switch (media_type) {
5975-
case HNAE3_MEDIA_TYPE_FIBER:
5976-
*port_type = PORT_FIBRE;
5977-
break;
5978-
case HNAE3_MEDIA_TYPE_COPPER:
5979-
*port_type = PORT_TP;
5980-
break;
5981-
case HNAE3_MEDIA_TYPE_UNKNOWN:
5982-
default:
5983-
*port_type = PORT_OTHER;
5984-
break;
5985-
}
5986-
}
5987-
59885973
static const struct hnae3_ae_ops hclge_ops = {
59895974
.init_ae_dev = hclge_init_ae_dev,
59905975
.uninit_ae_dev = hclge_uninit_ae_dev,
@@ -6042,7 +6027,6 @@ static const struct hnae3_ae_ops hclge_ops = {
60426027
.get_regs = hclge_get_regs,
60436028
.set_led_id = hclge_set_led_id,
60446029
.get_link_mode = hclge_get_link_mode,
6045-
.get_port_type = hclge_get_port_type,
60466030
};
60476031

60486032
static struct hnae3_ae_algo ae_algo = {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static int hclge_pfc_pause_en_cfg(struct hclge_dev *hdev, u8 tx_rx_bitmap,
172172
u8 pfc_bitmap)
173173
{
174174
struct hclge_desc desc;
175-
struct hclge_pfc_en_cmd *pfc = (struct hclge_pfc_en_cmd *)&desc.data;
175+
struct hclge_pfc_en_cmd *pfc = (struct hclge_pfc_en_cmd *)desc.data;
176176

177177
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_PFC_PAUSE_EN, false);
178178

@@ -188,7 +188,7 @@ static int hclge_pause_param_cfg(struct hclge_dev *hdev, const u8 *addr,
188188
struct hclge_cfg_pause_param_cmd *pause_param;
189189
struct hclge_desc desc;
190190

191-
pause_param = (struct hclge_cfg_pause_param_cmd *)&desc.data;
191+
pause_param = (struct hclge_cfg_pause_param_cmd *)desc.data;
192192

193193
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_MAC_PARA, false);
194194

@@ -207,7 +207,7 @@ int hclge_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr)
207207
u8 trans_gap;
208208
int ret;
209209

210-
pause_param = (struct hclge_cfg_pause_param_cmd *)&desc.data;
210+
pause_param = (struct hclge_cfg_pause_param_cmd *)desc.data;
211211

212212
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_MAC_PARA, true);
213213

0 commit comments

Comments
 (0)