1 /* 2 * Copyright (c) 2014-2015 Hisilicon Limited. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 */ 9 10 #include <linux/etherdevice.h> 11 #include <linux/interrupt.h> 12 #include <linux/module.h> 13 #include <linux/platform_device.h> 14 #include "hns_enet.h" 15 16 #define HNS_PHY_PAGE_MDIX 0 17 #define HNS_PHY_PAGE_LED 3 18 #define HNS_PHY_PAGE_COPPER 0 19 20 #define HNS_PHY_PAGE_REG 22 /* Page Selection Reg. */ 21 #define HNS_PHY_CSC_REG 16 /* Copper Specific Control Register */ 22 #define HNS_PHY_CSS_REG 17 /* Copper Specific Status Register */ 23 #define HNS_LED_FC_REG 16 /* LED Function Control Reg. */ 24 #define HNS_LED_PC_REG 17 /* LED Polarity Control Reg. */ 25 26 #define HNS_LED_FORCE_ON 9 27 #define HNS_LED_FORCE_OFF 8 28 29 #define HNS_CHIP_VERSION 660 30 #define HNS_NET_STATS_CNT 26 31 32 #define PHY_MDIX_CTRL_S (5) 33 #define PHY_MDIX_CTRL_M (3 << PHY_MDIX_CTRL_S) 34 35 #define PHY_MDIX_STATUS_B (6) 36 #define PHY_SPEED_DUP_RESOLVE_B (11) 37 38 /** 39 *hns_nic_get_link - get current link status 40 *@net_dev: net_device 41 *retuen 0 - success , negative --fail 42 */ 43 static u32 hns_nic_get_link(struct net_device *net_dev) 44 { 45 struct hns_nic_priv *priv = netdev_priv(net_dev); 46 u32 link_stat = priv->link; 47 struct hnae_handle *h; 48 49 h = priv->ae_handle; 50 51 if (net_dev->phydev) { 52 if (!genphy_read_status(net_dev->phydev)) 53 link_stat = net_dev->phydev->link; 54 else 55 link_stat = 0; 56 } 57 58 if (h->dev && h->dev->ops && h->dev->ops->get_status) 59 link_stat = link_stat && h->dev->ops->get_status(h); 60 else 61 link_stat = 0; 62 63 return link_stat; 64 } 65 66 static void hns_get_mdix_mode(struct net_device *net_dev, 67 struct ethtool_link_ksettings *cmd) 68 { 69 int mdix_ctrl, mdix, retval, is_resolved; 70 struct phy_device *phy_dev = net_dev->phydev; 71 72 if (!phy_dev || !phy_dev->mdio.bus) { 73 cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_INVALID; 74 cmd->base.eth_tp_mdix = ETH_TP_MDI_INVALID; 75 return; 76 } 77 78 phy_write(phy_dev, HNS_PHY_PAGE_REG, HNS_PHY_PAGE_MDIX); 79 80 retval = phy_read(phy_dev, HNS_PHY_CSC_REG); 81 mdix_ctrl = hnae_get_field(retval, PHY_MDIX_CTRL_M, PHY_MDIX_CTRL_S); 82 83 retval = phy_read(phy_dev, HNS_PHY_CSS_REG); 84 mdix = hnae_get_bit(retval, PHY_MDIX_STATUS_B); 85 is_resolved = hnae_get_bit(retval, PHY_SPEED_DUP_RESOLVE_B); 86 87 phy_write(phy_dev, HNS_PHY_PAGE_REG, HNS_PHY_PAGE_COPPER); 88 89 switch (mdix_ctrl) { 90 case 0x0: 91 cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI; 92 break; 93 case 0x1: 94 cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_X; 95 break; 96 case 0x3: 97 cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO; 98 break; 99 default: 100 cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_INVALID; 101 break; 102 } 103 104 if (!is_resolved) 105 cmd->base.eth_tp_mdix = ETH_TP_MDI_INVALID; 106 else if (mdix) 107 cmd->base.eth_tp_mdix = ETH_TP_MDI_X; 108 else 109 cmd->base.eth_tp_mdix = ETH_TP_MDI; 110 } 111 112 /** 113 *hns_nic_get_link_ksettings - implement ethtool get link ksettings 114 *@net_dev: net_device 115 *@cmd: ethtool_link_ksettings 116 *retuen 0 - success , negative --fail 117 */ 118 static int hns_nic_get_link_ksettings(struct net_device *net_dev, 119 struct ethtool_link_ksettings *cmd) 120 { 121 struct hns_nic_priv *priv = netdev_priv(net_dev); 122 struct hnae_handle *h; 123 u32 link_stat; 124 int ret; 125 u8 duplex; 126 u16 speed; 127 u32 supported, advertising; 128 129 if (!priv || !priv->ae_handle) 130 return -ESRCH; 131 132 h = priv->ae_handle; 133 if (!h->dev || !h->dev->ops || !h->dev->ops->get_info) 134 return -ESRCH; 135 136 ret = h->dev->ops->get_info(h, NULL, &speed, &duplex); 137 if (ret < 0) { 138 netdev_err(net_dev, "%s get_info error!\n", __func__); 139 return -EINVAL; 140 } 141 142 ethtool_convert_link_mode_to_legacy_u32(&supported, 143 cmd->link_modes.supported); 144 ethtool_convert_link_mode_to_legacy_u32(&advertising, 145 cmd->link_modes.advertising); 146 147 /* When there is no phy, autoneg is off. */ 148 cmd->base.autoneg = false; 149 cmd->base.speed = speed; 150 cmd->base.duplex = duplex; 151 152 if (net_dev->phydev) 153 phy_ethtool_ksettings_get(net_dev->phydev, cmd); 154 155 link_stat = hns_nic_get_link(net_dev); 156 if (!link_stat) { 157 cmd->base.speed = (u32)SPEED_UNKNOWN; 158 cmd->base.duplex = DUPLEX_UNKNOWN; 159 } 160 161 if (cmd->base.autoneg) 162 advertising |= ADVERTISED_Autoneg; 163 164 supported |= h->if_support; 165 if (h->phy_if == PHY_INTERFACE_MODE_SGMII) { 166 supported |= SUPPORTED_TP; 167 advertising |= ADVERTISED_1000baseT_Full; 168 } else if (h->phy_if == PHY_INTERFACE_MODE_XGMII) { 169 supported |= SUPPORTED_FIBRE; 170 advertising |= ADVERTISED_10000baseKR_Full; 171 } 172 173 switch (h->media_type) { 174 case HNAE_MEDIA_TYPE_FIBER: 175 cmd->base.port = PORT_FIBRE; 176 break; 177 case HNAE_MEDIA_TYPE_COPPER: 178 cmd->base.port = PORT_TP; 179 break; 180 case HNAE_MEDIA_TYPE_UNKNOWN: 181 default: 182 break; 183 } 184 185 if (!(AE_IS_VER1(priv->enet_ver) && h->port_type == HNAE_PORT_DEBUG)) 186 supported |= SUPPORTED_Pause; 187 188 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, 189 supported); 190 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, 191 advertising); 192 193 cmd->base.mdio_support = ETH_MDIO_SUPPORTS_C45 | ETH_MDIO_SUPPORTS_C22; 194 hns_get_mdix_mode(net_dev, cmd); 195 196 return 0; 197 } 198 199 /** 200 *hns_nic_set_link_settings - implement ethtool set link ksettings 201 *@net_dev: net_device 202 *@cmd: ethtool_link_ksettings 203 *retuen 0 - success , negative --fail 204 */ 205 static int hns_nic_set_link_ksettings(struct net_device *net_dev, 206 const struct ethtool_link_ksettings *cmd) 207 { 208 struct hns_nic_priv *priv = netdev_priv(net_dev); 209 struct hnae_handle *h; 210 u32 speed; 211 212 if (!netif_running(net_dev)) 213 return -ESRCH; 214 215 if (!priv || !priv->ae_handle || !priv->ae_handle->dev || 216 !priv->ae_handle->dev->ops) 217 return -ENODEV; 218 219 h = priv->ae_handle; 220 speed = cmd->base.speed; 221 222 if (h->phy_if == PHY_INTERFACE_MODE_XGMII) { 223 if (cmd->base.autoneg == AUTONEG_ENABLE || 224 speed != SPEED_10000 || 225 cmd->base.duplex != DUPLEX_FULL) 226 return -EINVAL; 227 } else if (h->phy_if == PHY_INTERFACE_MODE_SGMII) { 228 if (!net_dev->phydev && cmd->base.autoneg == AUTONEG_ENABLE) 229 return -EINVAL; 230 231 if (speed == SPEED_1000 && cmd->base.duplex == DUPLEX_HALF) 232 return -EINVAL; 233 if (net_dev->phydev) 234 return phy_ethtool_ksettings_set(net_dev->phydev, cmd); 235 236 if ((speed != SPEED_10 && speed != SPEED_100 && 237 speed != SPEED_1000) || (cmd->base.duplex != DUPLEX_HALF && 238 cmd->base.duplex != DUPLEX_FULL)) 239 return -EINVAL; 240 } else { 241 netdev_err(net_dev, "Not supported!"); 242 return -ENOTSUPP; 243 } 244 245 if (h->dev->ops->adjust_link) { 246 h->dev->ops->adjust_link(h, (int)speed, cmd->base.duplex); 247 return 0; 248 } 249 250 netdev_err(net_dev, "Not supported!"); 251 return -ENOTSUPP; 252 } 253 254 static const char hns_nic_test_strs[][ETH_GSTRING_LEN] = { 255 "Mac Loopback test", 256 "Serdes Loopback test", 257 "Phy Loopback test" 258 }; 259 260 static int hns_nic_config_phy_loopback(struct phy_device *phy_dev, u8 en) 261 { 262 int err; 263 264 if (en) { 265 /* Doing phy loopback in offline state, phy resuming is 266 * needed to power up the device. 267 */ 268 err = phy_resume(phy_dev); 269 if (err) 270 goto out; 271 272 err = phy_loopback(phy_dev, true); 273 } else { 274 err = phy_loopback(phy_dev, false); 275 if (err) 276 goto out; 277 278 err = phy_suspend(phy_dev); 279 } 280 281 out: 282 return err; 283 } 284 285 static int __lb_setup(struct net_device *ndev, 286 enum hnae_loop loop) 287 { 288 int ret = 0; 289 struct hns_nic_priv *priv = netdev_priv(ndev); 290 struct phy_device *phy_dev = ndev->phydev; 291 struct hnae_handle *h = priv->ae_handle; 292 293 switch (loop) { 294 case MAC_INTERNALLOOP_PHY: 295 ret = hns_nic_config_phy_loopback(phy_dev, 0x1); 296 if (!ret) 297 ret = h->dev->ops->set_loopback(h, loop, 0x1); 298 break; 299 case MAC_INTERNALLOOP_MAC: 300 if ((h->dev->ops->set_loopback) && 301 (priv->ae_handle->phy_if != PHY_INTERFACE_MODE_XGMII)) 302 ret = h->dev->ops->set_loopback(h, loop, 0x1); 303 break; 304 case MAC_INTERNALLOOP_SERDES: 305 if (h->dev->ops->set_loopback) 306 ret = h->dev->ops->set_loopback(h, loop, 0x1); 307 break; 308 case MAC_LOOP_PHY_NONE: 309 ret = hns_nic_config_phy_loopback(phy_dev, 0x0); 310 case MAC_LOOP_NONE: 311 if (!ret && h->dev->ops->set_loopback) { 312 if (priv->ae_handle->phy_if != PHY_INTERFACE_MODE_XGMII) 313 ret = h->dev->ops->set_loopback(h, 314 MAC_INTERNALLOOP_MAC, 0x0); 315 316 if (!ret) 317 ret = h->dev->ops->set_loopback(h, 318 MAC_INTERNALLOOP_SERDES, 0x0); 319 } 320 break; 321 default: 322 ret = -EINVAL; 323 break; 324 } 325 326 if (!ret) { 327 if (loop == MAC_LOOP_NONE) 328 h->dev->ops->set_promisc_mode( 329 h, ndev->flags & IFF_PROMISC); 330 else 331 h->dev->ops->set_promisc_mode(h, 1); 332 } 333 return ret; 334 } 335 336 static int __lb_up(struct net_device *ndev, 337 enum hnae_loop loop_mode) 338 { 339 struct hns_nic_priv *priv = netdev_priv(ndev); 340 struct hnae_handle *h = priv->ae_handle; 341 int speed, duplex; 342 int ret; 343 344 hns_nic_net_reset(ndev); 345 346 ret = __lb_setup(ndev, loop_mode); 347 if (ret) 348 return ret; 349 350 msleep(200); 351 352 ret = h->dev->ops->start ? h->dev->ops->start(h) : 0; 353 if (ret) 354 return ret; 355 356 /* link adjust duplex*/ 357 if (priv->ae_handle->phy_if != PHY_INTERFACE_MODE_XGMII) 358 speed = 1000; 359 else 360 speed = 10000; 361 duplex = 1; 362 363 h->dev->ops->adjust_link(h, speed, duplex); 364 365 return 0; 366 } 367 368 static void __lb_other_process(struct hns_nic_ring_data *ring_data, 369 struct sk_buff *skb) 370 { 371 struct net_device *ndev; 372 struct hns_nic_priv *priv; 373 struct hnae_ring *ring; 374 struct netdev_queue *dev_queue; 375 struct sk_buff *new_skb; 376 unsigned int frame_size; 377 int check_ok; 378 u32 i; 379 char buff[33]; /* 32B data and the last character '\0' */ 380 381 if (!ring_data) { /* Just for doing create frame*/ 382 ndev = skb->dev; 383 priv = netdev_priv(ndev); 384 385 frame_size = skb->len; 386 memset(skb->data, 0xFF, frame_size); 387 if ((!AE_IS_VER1(priv->enet_ver)) && 388 (priv->ae_handle->port_type == HNAE_PORT_SERVICE)) { 389 memcpy(skb->data, ndev->dev_addr, 6); 390 skb->data[5] += 0x1f; 391 } 392 393 frame_size &= ~1ul; 394 memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1); 395 memset(&skb->data[frame_size / 2 + 10], 0xBE, 396 frame_size / 2 - 11); 397 memset(&skb->data[frame_size / 2 + 12], 0xAF, 398 frame_size / 2 - 13); 399 return; 400 } 401 402 ring = ring_data->ring; 403 ndev = ring_data->napi.dev; 404 if (is_tx_ring(ring)) { /* for tx queue reset*/ 405 dev_queue = netdev_get_tx_queue(ndev, ring_data->queue_index); 406 netdev_tx_reset_queue(dev_queue); 407 return; 408 } 409 410 frame_size = skb->len; 411 frame_size &= ~1ul; 412 /* for mutl buffer*/ 413 new_skb = skb_copy(skb, GFP_ATOMIC); 414 dev_kfree_skb_any(skb); 415 skb = new_skb; 416 417 check_ok = 0; 418 if (*(skb->data + 10) == 0xFF) { /* for rx check frame*/ 419 if ((*(skb->data + frame_size / 2 + 10) == 0xBE) && 420 (*(skb->data + frame_size / 2 + 12) == 0xAF)) 421 check_ok = 1; 422 } 423 424 if (check_ok) { 425 ndev->stats.rx_packets++; 426 ndev->stats.rx_bytes += skb->len; 427 } else { 428 ndev->stats.rx_frame_errors++; 429 for (i = 0; i < skb->len; i++) { 430 snprintf(buff + i % 16 * 2, 3, /* tailing \0*/ 431 "%02x", *(skb->data + i)); 432 if ((i % 16 == 15) || (i == skb->len - 1)) 433 pr_info("%s\n", buff); 434 } 435 } 436 dev_kfree_skb_any(skb); 437 } 438 439 static int __lb_clean_rings(struct hns_nic_priv *priv, 440 int ringid0, int ringid1, int budget) 441 { 442 int i, ret; 443 struct hns_nic_ring_data *ring_data; 444 struct net_device *ndev = priv->netdev; 445 unsigned long rx_packets = ndev->stats.rx_packets; 446 unsigned long rx_bytes = ndev->stats.rx_bytes; 447 unsigned long rx_frame_errors = ndev->stats.rx_frame_errors; 448 449 for (i = ringid0; i <= ringid1; i++) { 450 ring_data = &priv->ring_data[i]; 451 (void)ring_data->poll_one(ring_data, 452 budget, __lb_other_process); 453 } 454 ret = (int)(ndev->stats.rx_packets - rx_packets); 455 ndev->stats.rx_packets = rx_packets; 456 ndev->stats.rx_bytes = rx_bytes; 457 ndev->stats.rx_frame_errors = rx_frame_errors; 458 return ret; 459 } 460 461 /** 462 * nic_run_loopback_test - run loopback test 463 * @nic_dev: net device 464 * @loopback_type: loopback type 465 */ 466 static int __lb_run_test(struct net_device *ndev, 467 enum hnae_loop loop_mode) 468 { 469 #define NIC_LB_TEST_PKT_NUM_PER_CYCLE 1 470 #define NIC_LB_TEST_RING_ID 0 471 #define NIC_LB_TEST_FRAME_SIZE 128 472 /* nic loopback test err */ 473 #define NIC_LB_TEST_NO_MEM_ERR 1 474 #define NIC_LB_TEST_TX_CNT_ERR 2 475 #define NIC_LB_TEST_RX_CNT_ERR 3 476 #define NIC_LB_TEST_RX_PKG_ERR 4 477 struct hns_nic_priv *priv = netdev_priv(ndev); 478 struct hnae_handle *h = priv->ae_handle; 479 int i, j, lc, good_cnt, ret_val = 0; 480 unsigned int size; 481 netdev_tx_t tx_ret_val; 482 struct sk_buff *skb; 483 484 size = NIC_LB_TEST_FRAME_SIZE; 485 /* allocate test skb */ 486 skb = alloc_skb(size, GFP_KERNEL); 487 if (!skb) 488 return NIC_LB_TEST_NO_MEM_ERR; 489 490 /* place data into test skb */ 491 (void)skb_put(skb, size); 492 skb->dev = ndev; 493 __lb_other_process(NULL, skb); 494 skb->queue_mapping = NIC_LB_TEST_RING_ID; 495 496 lc = 1; 497 for (j = 0; j < lc; j++) { 498 /* reset count of good packets */ 499 good_cnt = 0; 500 /* place 64 packets on the transmit queue*/ 501 for (i = 0; i < NIC_LB_TEST_PKT_NUM_PER_CYCLE; i++) { 502 (void)skb_get(skb); 503 504 tx_ret_val = (netdev_tx_t)hns_nic_net_xmit_hw( 505 ndev, skb, 506 &tx_ring_data(priv, skb->queue_mapping)); 507 if (tx_ret_val == NETDEV_TX_OK) 508 good_cnt++; 509 else 510 break; 511 } 512 if (good_cnt != NIC_LB_TEST_PKT_NUM_PER_CYCLE) { 513 ret_val = NIC_LB_TEST_TX_CNT_ERR; 514 dev_err(priv->dev, "%s sent fail, cnt=0x%x, budget=0x%x\n", 515 hns_nic_test_strs[loop_mode], good_cnt, 516 NIC_LB_TEST_PKT_NUM_PER_CYCLE); 517 break; 518 } 519 520 /* allow 100 milliseconds for packets to go from Tx to Rx */ 521 msleep(100); 522 523 good_cnt = __lb_clean_rings(priv, 524 h->q_num, h->q_num * 2 - 1, 525 NIC_LB_TEST_PKT_NUM_PER_CYCLE); 526 if (good_cnt != NIC_LB_TEST_PKT_NUM_PER_CYCLE) { 527 ret_val = NIC_LB_TEST_RX_CNT_ERR; 528 dev_err(priv->dev, "%s recv fail, cnt=0x%x, budget=0x%x\n", 529 hns_nic_test_strs[loop_mode], good_cnt, 530 NIC_LB_TEST_PKT_NUM_PER_CYCLE); 531 break; 532 } 533 (void)__lb_clean_rings(priv, 534 NIC_LB_TEST_RING_ID, NIC_LB_TEST_RING_ID, 535 NIC_LB_TEST_PKT_NUM_PER_CYCLE); 536 } 537 538 /* free the original skb */ 539 kfree_skb(skb); 540 541 return ret_val; 542 } 543 544 static int __lb_down(struct net_device *ndev, enum hnae_loop loop) 545 { 546 struct hns_nic_priv *priv = netdev_priv(ndev); 547 struct hnae_handle *h = priv->ae_handle; 548 int ret; 549 550 if (loop == MAC_INTERNALLOOP_PHY) 551 ret = __lb_setup(ndev, MAC_LOOP_PHY_NONE); 552 else 553 ret = __lb_setup(ndev, MAC_LOOP_NONE); 554 if (ret) 555 netdev_err(ndev, "%s: __lb_setup return error(%d)!\n", 556 __func__, 557 ret); 558 559 if (h->dev->ops->stop) 560 h->dev->ops->stop(h); 561 562 usleep_range(10000, 20000); 563 (void)__lb_clean_rings(priv, 0, h->q_num - 1, 256); 564 565 hns_nic_net_reset(ndev); 566 567 return 0; 568 } 569 570 /** 571 * hns_nic_self_test - self test 572 * @dev: net device 573 * @eth_test: test cmd 574 * @data: test result 575 */ 576 static void hns_nic_self_test(struct net_device *ndev, 577 struct ethtool_test *eth_test, u64 *data) 578 { 579 struct hns_nic_priv *priv = netdev_priv(ndev); 580 bool if_running = netif_running(ndev); 581 #define SELF_TEST_TPYE_NUM 3 582 int st_param[SELF_TEST_TPYE_NUM][2]; 583 int i; 584 int test_index = 0; 585 586 st_param[0][0] = MAC_INTERNALLOOP_MAC; /* XGE not supported lb */ 587 st_param[0][1] = (priv->ae_handle->phy_if != PHY_INTERFACE_MODE_XGMII); 588 st_param[1][0] = MAC_INTERNALLOOP_SERDES; 589 st_param[1][1] = 1; /*serdes must exist*/ 590 st_param[2][0] = MAC_INTERNALLOOP_PHY; /* only supporte phy node*/ 591 st_param[2][1] = ((!!(priv->ae_handle->phy_dev)) && 592 (priv->ae_handle->phy_if != PHY_INTERFACE_MODE_XGMII)); 593 594 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { 595 set_bit(NIC_STATE_TESTING, &priv->state); 596 597 if (if_running) 598 dev_close(ndev); 599 600 for (i = 0; i < SELF_TEST_TPYE_NUM; i++) { 601 if (!st_param[i][1]) 602 continue; /* NEXT testing */ 603 604 data[test_index] = __lb_up(ndev, 605 (enum hnae_loop)st_param[i][0]); 606 if (!data[test_index]) { 607 data[test_index] = __lb_run_test( 608 ndev, (enum hnae_loop)st_param[i][0]); 609 (void)__lb_down(ndev, 610 (enum hnae_loop)st_param[i][0]); 611 } 612 613 if (data[test_index]) 614 eth_test->flags |= ETH_TEST_FL_FAILED; 615 616 test_index++; 617 } 618 619 hns_nic_net_reset(priv->netdev); 620 621 clear_bit(NIC_STATE_TESTING, &priv->state); 622 623 if (if_running) 624 (void)dev_open(ndev); 625 } 626 /* Online tests aren't run; pass by default */ 627 628 (void)msleep_interruptible(4 * 1000); 629 } 630 631 /** 632 * hns_nic_get_drvinfo - get net driver info 633 * @dev: net device 634 * @drvinfo: driver info 635 */ 636 static void hns_nic_get_drvinfo(struct net_device *net_dev, 637 struct ethtool_drvinfo *drvinfo) 638 { 639 struct hns_nic_priv *priv = netdev_priv(net_dev); 640 641 strncpy(drvinfo->version, HNAE_DRIVER_VERSION, 642 sizeof(drvinfo->version)); 643 drvinfo->version[sizeof(drvinfo->version) - 1] = '\0'; 644 645 strncpy(drvinfo->driver, HNAE_DRIVER_NAME, sizeof(drvinfo->driver)); 646 drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0'; 647 648 strncpy(drvinfo->bus_info, priv->dev->bus->name, 649 sizeof(drvinfo->bus_info)); 650 drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0'; 651 652 strncpy(drvinfo->fw_version, "N/A", ETHTOOL_FWVERS_LEN); 653 drvinfo->eedump_len = 0; 654 } 655 656 /** 657 * hns_get_ringparam - get ring parameter 658 * @dev: net device 659 * @param: ethtool parameter 660 */ 661 void hns_get_ringparam(struct net_device *net_dev, 662 struct ethtool_ringparam *param) 663 { 664 struct hns_nic_priv *priv = netdev_priv(net_dev); 665 struct hnae_ae_ops *ops; 666 struct hnae_queue *queue; 667 u32 uplimit = 0; 668 669 queue = priv->ae_handle->qs[0]; 670 ops = priv->ae_handle->dev->ops; 671 672 if (ops->get_ring_bdnum_limit) 673 ops->get_ring_bdnum_limit(queue, &uplimit); 674 675 param->rx_max_pending = uplimit; 676 param->tx_max_pending = uplimit; 677 param->rx_pending = queue->rx_ring.desc_num; 678 param->tx_pending = queue->tx_ring.desc_num; 679 } 680 681 /** 682 * hns_get_pauseparam - get pause parameter 683 * @dev: net device 684 * @param: pause parameter 685 */ 686 static void hns_get_pauseparam(struct net_device *net_dev, 687 struct ethtool_pauseparam *param) 688 { 689 struct hns_nic_priv *priv = netdev_priv(net_dev); 690 struct hnae_ae_ops *ops; 691 692 ops = priv->ae_handle->dev->ops; 693 694 if (ops->get_pauseparam) 695 ops->get_pauseparam(priv->ae_handle, ¶m->autoneg, 696 ¶m->rx_pause, ¶m->tx_pause); 697 } 698 699 /** 700 * hns_set_pauseparam - set pause parameter 701 * @dev: net device 702 * @param: pause parameter 703 * 704 * Return 0 on success, negative on failure 705 */ 706 static int hns_set_pauseparam(struct net_device *net_dev, 707 struct ethtool_pauseparam *param) 708 { 709 struct hns_nic_priv *priv = netdev_priv(net_dev); 710 struct hnae_handle *h; 711 struct hnae_ae_ops *ops; 712 713 h = priv->ae_handle; 714 ops = h->dev->ops; 715 716 if (!ops->set_pauseparam) 717 return -ESRCH; 718 719 return ops->set_pauseparam(priv->ae_handle, param->autoneg, 720 param->rx_pause, param->tx_pause); 721 } 722 723 /** 724 * hns_get_coalesce - get coalesce info. 725 * @dev: net device 726 * @ec: coalesce info. 727 * 728 * Return 0 on success, negative on failure. 729 */ 730 static int hns_get_coalesce(struct net_device *net_dev, 731 struct ethtool_coalesce *ec) 732 { 733 struct hns_nic_priv *priv = netdev_priv(net_dev); 734 struct hnae_ae_ops *ops; 735 736 ops = priv->ae_handle->dev->ops; 737 738 ec->use_adaptive_rx_coalesce = priv->ae_handle->coal_adapt_en; 739 ec->use_adaptive_tx_coalesce = priv->ae_handle->coal_adapt_en; 740 741 if ((!ops->get_coalesce_usecs) || 742 (!ops->get_max_coalesced_frames)) 743 return -ESRCH; 744 745 ops->get_coalesce_usecs(priv->ae_handle, 746 &ec->tx_coalesce_usecs, 747 &ec->rx_coalesce_usecs); 748 749 ops->get_max_coalesced_frames( 750 priv->ae_handle, 751 &ec->tx_max_coalesced_frames, 752 &ec->rx_max_coalesced_frames); 753 754 ops->get_coalesce_range(priv->ae_handle, 755 &ec->tx_max_coalesced_frames_low, 756 &ec->rx_max_coalesced_frames_low, 757 &ec->tx_max_coalesced_frames_high, 758 &ec->rx_max_coalesced_frames_high, 759 &ec->tx_coalesce_usecs_low, 760 &ec->rx_coalesce_usecs_low, 761 &ec->tx_coalesce_usecs_high, 762 &ec->rx_coalesce_usecs_high); 763 764 return 0; 765 } 766 767 /** 768 * hns_set_coalesce - set coalesce info. 769 * @dev: net device 770 * @ec: coalesce info. 771 * 772 * Return 0 on success, negative on failure. 773 */ 774 static int hns_set_coalesce(struct net_device *net_dev, 775 struct ethtool_coalesce *ec) 776 { 777 struct hns_nic_priv *priv = netdev_priv(net_dev); 778 struct hnae_ae_ops *ops; 779 int rc1, rc2; 780 781 ops = priv->ae_handle->dev->ops; 782 783 if (ec->tx_coalesce_usecs != ec->rx_coalesce_usecs) 784 return -EINVAL; 785 786 if ((!ops->set_coalesce_usecs) || 787 (!ops->set_coalesce_frames)) 788 return -ESRCH; 789 790 if (ec->use_adaptive_rx_coalesce != priv->ae_handle->coal_adapt_en) 791 priv->ae_handle->coal_adapt_en = ec->use_adaptive_rx_coalesce; 792 793 rc1 = ops->set_coalesce_usecs(priv->ae_handle, 794 ec->rx_coalesce_usecs); 795 796 rc2 = ops->set_coalesce_frames(priv->ae_handle, 797 ec->tx_max_coalesced_frames, 798 ec->rx_max_coalesced_frames); 799 800 if (rc1 || rc2) 801 return -EINVAL; 802 803 return 0; 804 } 805 806 /** 807 * hns_get_channels - get channel info. 808 * @dev: net device 809 * @ch: channel info. 810 */ 811 void hns_get_channels(struct net_device *net_dev, struct ethtool_channels *ch) 812 { 813 struct hns_nic_priv *priv = netdev_priv(net_dev); 814 815 ch->max_rx = priv->ae_handle->q_num; 816 ch->max_tx = priv->ae_handle->q_num; 817 818 ch->rx_count = priv->ae_handle->q_num; 819 ch->tx_count = priv->ae_handle->q_num; 820 } 821 822 /** 823 * get_ethtool_stats - get detail statistics. 824 * @dev: net device 825 * @stats: statistics info. 826 * @data: statistics data. 827 */ 828 void hns_get_ethtool_stats(struct net_device *netdev, 829 struct ethtool_stats *stats, u64 *data) 830 { 831 u64 *p = data; 832 struct hns_nic_priv *priv = netdev_priv(netdev); 833 struct hnae_handle *h = priv->ae_handle; 834 const struct rtnl_link_stats64 *net_stats; 835 struct rtnl_link_stats64 temp; 836 837 if (!h->dev->ops->get_stats || !h->dev->ops->update_stats) { 838 netdev_err(netdev, "get_stats or update_stats is null!\n"); 839 return; 840 } 841 842 h->dev->ops->update_stats(h, &netdev->stats); 843 844 net_stats = dev_get_stats(netdev, &temp); 845 846 /* get netdev statistics */ 847 p[0] = net_stats->rx_packets; 848 p[1] = net_stats->tx_packets; 849 p[2] = net_stats->rx_bytes; 850 p[3] = net_stats->tx_bytes; 851 p[4] = net_stats->rx_errors; 852 p[5] = net_stats->tx_errors; 853 p[6] = net_stats->rx_dropped; 854 p[7] = net_stats->tx_dropped; 855 p[8] = net_stats->multicast; 856 p[9] = net_stats->collisions; 857 p[10] = net_stats->rx_over_errors; 858 p[11] = net_stats->rx_crc_errors; 859 p[12] = net_stats->rx_frame_errors; 860 p[13] = net_stats->rx_fifo_errors; 861 p[14] = net_stats->rx_missed_errors; 862 p[15] = net_stats->tx_aborted_errors; 863 p[16] = net_stats->tx_carrier_errors; 864 p[17] = net_stats->tx_fifo_errors; 865 p[18] = net_stats->tx_heartbeat_errors; 866 p[19] = net_stats->rx_length_errors; 867 p[20] = net_stats->tx_window_errors; 868 p[21] = net_stats->rx_compressed; 869 p[22] = net_stats->tx_compressed; 870 871 p[23] = netdev->rx_dropped.counter; 872 p[24] = netdev->tx_dropped.counter; 873 874 p[25] = priv->tx_timeout_count; 875 876 /* get driver statistics */ 877 h->dev->ops->get_stats(h, &p[26]); 878 } 879 880 /** 881 * get_strings: Return a set of strings that describe the requested objects 882 * @dev: net device 883 * @stats: string set ID. 884 * @data: objects data. 885 */ 886 void hns_get_strings(struct net_device *netdev, u32 stringset, u8 *data) 887 { 888 struct hns_nic_priv *priv = netdev_priv(netdev); 889 struct hnae_handle *h = priv->ae_handle; 890 char *buff = (char *)data; 891 892 if (!h->dev->ops->get_strings) { 893 netdev_err(netdev, "h->dev->ops->get_strings is null!\n"); 894 return; 895 } 896 897 if (stringset == ETH_SS_TEST) { 898 if (priv->ae_handle->phy_if != PHY_INTERFACE_MODE_XGMII) { 899 memcpy(buff, hns_nic_test_strs[MAC_INTERNALLOOP_MAC], 900 ETH_GSTRING_LEN); 901 buff += ETH_GSTRING_LEN; 902 } 903 memcpy(buff, hns_nic_test_strs[MAC_INTERNALLOOP_SERDES], 904 ETH_GSTRING_LEN); 905 buff += ETH_GSTRING_LEN; 906 if ((netdev->phydev) && (!netdev->phydev->is_c45)) 907 memcpy(buff, hns_nic_test_strs[MAC_INTERNALLOOP_PHY], 908 ETH_GSTRING_LEN); 909 910 } else { 911 snprintf(buff, ETH_GSTRING_LEN, "rx_packets"); 912 buff = buff + ETH_GSTRING_LEN; 913 snprintf(buff, ETH_GSTRING_LEN, "tx_packets"); 914 buff = buff + ETH_GSTRING_LEN; 915 snprintf(buff, ETH_GSTRING_LEN, "rx_bytes"); 916 buff = buff + ETH_GSTRING_LEN; 917 snprintf(buff, ETH_GSTRING_LEN, "tx_bytes"); 918 buff = buff + ETH_GSTRING_LEN; 919 snprintf(buff, ETH_GSTRING_LEN, "rx_errors"); 920 buff = buff + ETH_GSTRING_LEN; 921 snprintf(buff, ETH_GSTRING_LEN, "tx_errors"); 922 buff = buff + ETH_GSTRING_LEN; 923 snprintf(buff, ETH_GSTRING_LEN, "rx_dropped"); 924 buff = buff + ETH_GSTRING_LEN; 925 snprintf(buff, ETH_GSTRING_LEN, "tx_dropped"); 926 buff = buff + ETH_GSTRING_LEN; 927 snprintf(buff, ETH_GSTRING_LEN, "multicast"); 928 buff = buff + ETH_GSTRING_LEN; 929 snprintf(buff, ETH_GSTRING_LEN, "collisions"); 930 buff = buff + ETH_GSTRING_LEN; 931 snprintf(buff, ETH_GSTRING_LEN, "rx_over_errors"); 932 buff = buff + ETH_GSTRING_LEN; 933 snprintf(buff, ETH_GSTRING_LEN, "rx_crc_errors"); 934 buff = buff + ETH_GSTRING_LEN; 935 snprintf(buff, ETH_GSTRING_LEN, "rx_frame_errors"); 936 buff = buff + ETH_GSTRING_LEN; 937 snprintf(buff, ETH_GSTRING_LEN, "rx_fifo_errors"); 938 buff = buff + ETH_GSTRING_LEN; 939 snprintf(buff, ETH_GSTRING_LEN, "rx_missed_errors"); 940 buff = buff + ETH_GSTRING_LEN; 941 snprintf(buff, ETH_GSTRING_LEN, "tx_aborted_errors"); 942 buff = buff + ETH_GSTRING_LEN; 943 snprintf(buff, ETH_GSTRING_LEN, "tx_carrier_errors"); 944 buff = buff + ETH_GSTRING_LEN; 945 snprintf(buff, ETH_GSTRING_LEN, "tx_fifo_errors"); 946 buff = buff + ETH_GSTRING_LEN; 947 snprintf(buff, ETH_GSTRING_LEN, "tx_heartbeat_errors"); 948 buff = buff + ETH_GSTRING_LEN; 949 snprintf(buff, ETH_GSTRING_LEN, "rx_length_errors"); 950 buff = buff + ETH_GSTRING_LEN; 951 snprintf(buff, ETH_GSTRING_LEN, "tx_window_errors"); 952 buff = buff + ETH_GSTRING_LEN; 953 snprintf(buff, ETH_GSTRING_LEN, "rx_compressed"); 954 buff = buff + ETH_GSTRING_LEN; 955 snprintf(buff, ETH_GSTRING_LEN, "tx_compressed"); 956 buff = buff + ETH_GSTRING_LEN; 957 snprintf(buff, ETH_GSTRING_LEN, "netdev_rx_dropped"); 958 buff = buff + ETH_GSTRING_LEN; 959 snprintf(buff, ETH_GSTRING_LEN, "netdev_tx_dropped"); 960 buff = buff + ETH_GSTRING_LEN; 961 962 snprintf(buff, ETH_GSTRING_LEN, "netdev_tx_timeout"); 963 buff = buff + ETH_GSTRING_LEN; 964 965 h->dev->ops->get_strings(h, stringset, (u8 *)buff); 966 } 967 } 968 969 /** 970 * nic_get_sset_count - get string set count witch returned by nic_get_strings. 971 * @dev: net device 972 * @stringset: string set index, 0: self test string; 1: statistics string. 973 * 974 * Return string set count. 975 */ 976 int hns_get_sset_count(struct net_device *netdev, int stringset) 977 { 978 struct hns_nic_priv *priv = netdev_priv(netdev); 979 struct hnae_handle *h = priv->ae_handle; 980 struct hnae_ae_ops *ops = h->dev->ops; 981 982 if (!ops->get_sset_count) { 983 netdev_err(netdev, "get_sset_count is null!\n"); 984 return -EOPNOTSUPP; 985 } 986 if (stringset == ETH_SS_TEST) { 987 u32 cnt = (sizeof(hns_nic_test_strs) / ETH_GSTRING_LEN); 988 989 if (priv->ae_handle->phy_if == PHY_INTERFACE_MODE_XGMII) 990 cnt--; 991 992 if ((!netdev->phydev) || (netdev->phydev->is_c45)) 993 cnt--; 994 995 return cnt; 996 } else if (stringset == ETH_SS_STATS) { 997 return (HNS_NET_STATS_CNT + ops->get_sset_count(h, stringset)); 998 } else { 999 return -EOPNOTSUPP; 1000 } 1001 } 1002 1003 /** 1004 * hns_phy_led_set - set phy LED status. 1005 * @dev: net device 1006 * @value: LED state. 1007 * 1008 * Return 0 on success, negative on failure. 1009 */ 1010 int hns_phy_led_set(struct net_device *netdev, int value) 1011 { 1012 int retval; 1013 struct phy_device *phy_dev = netdev->phydev; 1014 1015 retval = phy_write(phy_dev, HNS_PHY_PAGE_REG, HNS_PHY_PAGE_LED); 1016 retval |= phy_write(phy_dev, HNS_LED_FC_REG, value); 1017 retval |= phy_write(phy_dev, HNS_PHY_PAGE_REG, HNS_PHY_PAGE_COPPER); 1018 if (retval) { 1019 netdev_err(netdev, "mdiobus_write fail !\n"); 1020 return retval; 1021 } 1022 return 0; 1023 } 1024 1025 /** 1026 * nic_set_phys_id - set phy identify LED. 1027 * @dev: net device 1028 * @state: LED state. 1029 * 1030 * Return 0 on success, negative on failure. 1031 */ 1032 int hns_set_phys_id(struct net_device *netdev, enum ethtool_phys_id_state state) 1033 { 1034 struct hns_nic_priv *priv = netdev_priv(netdev); 1035 struct hnae_handle *h = priv->ae_handle; 1036 struct phy_device *phy_dev = netdev->phydev; 1037 int ret; 1038 1039 if (phy_dev) 1040 switch (state) { 1041 case ETHTOOL_ID_ACTIVE: 1042 ret = phy_write(phy_dev, HNS_PHY_PAGE_REG, 1043 HNS_PHY_PAGE_LED); 1044 if (ret) 1045 return ret; 1046 1047 priv->phy_led_val = phy_read(phy_dev, HNS_LED_FC_REG); 1048 1049 ret = phy_write(phy_dev, HNS_PHY_PAGE_REG, 1050 HNS_PHY_PAGE_COPPER); 1051 if (ret) 1052 return ret; 1053 return 2; 1054 case ETHTOOL_ID_ON: 1055 ret = hns_phy_led_set(netdev, HNS_LED_FORCE_ON); 1056 if (ret) 1057 return ret; 1058 break; 1059 case ETHTOOL_ID_OFF: 1060 ret = hns_phy_led_set(netdev, HNS_LED_FORCE_OFF); 1061 if (ret) 1062 return ret; 1063 break; 1064 case ETHTOOL_ID_INACTIVE: 1065 ret = phy_write(phy_dev, HNS_PHY_PAGE_REG, 1066 HNS_PHY_PAGE_LED); 1067 if (ret) 1068 return ret; 1069 1070 ret = phy_write(phy_dev, HNS_LED_FC_REG, 1071 priv->phy_led_val); 1072 if (ret) 1073 return ret; 1074 1075 ret = phy_write(phy_dev, HNS_PHY_PAGE_REG, 1076 HNS_PHY_PAGE_COPPER); 1077 if (ret) 1078 return ret; 1079 break; 1080 default: 1081 return -EINVAL; 1082 } 1083 else 1084 switch (state) { 1085 case ETHTOOL_ID_ACTIVE: 1086 return h->dev->ops->set_led_id(h, HNAE_LED_ACTIVE); 1087 case ETHTOOL_ID_ON: 1088 return h->dev->ops->set_led_id(h, HNAE_LED_ON); 1089 case ETHTOOL_ID_OFF: 1090 return h->dev->ops->set_led_id(h, HNAE_LED_OFF); 1091 case ETHTOOL_ID_INACTIVE: 1092 return h->dev->ops->set_led_id(h, HNAE_LED_INACTIVE); 1093 default: 1094 return -EINVAL; 1095 } 1096 1097 return 0; 1098 } 1099 1100 /** 1101 * hns_get_regs - get net device register 1102 * @dev: net device 1103 * @cmd: ethtool cmd 1104 * @date: register data 1105 */ 1106 void hns_get_regs(struct net_device *net_dev, struct ethtool_regs *cmd, 1107 void *data) 1108 { 1109 struct hns_nic_priv *priv = netdev_priv(net_dev); 1110 struct hnae_ae_ops *ops; 1111 1112 ops = priv->ae_handle->dev->ops; 1113 1114 cmd->version = HNS_CHIP_VERSION; 1115 if (!ops->get_regs) { 1116 netdev_err(net_dev, "ops->get_regs is null!\n"); 1117 return; 1118 } 1119 ops->get_regs(priv->ae_handle, data); 1120 } 1121 1122 /** 1123 * nic_get_regs_len - get total register len. 1124 * @dev: net device 1125 * 1126 * Return total register len. 1127 */ 1128 static int hns_get_regs_len(struct net_device *net_dev) 1129 { 1130 u32 reg_num; 1131 struct hns_nic_priv *priv = netdev_priv(net_dev); 1132 struct hnae_ae_ops *ops; 1133 1134 ops = priv->ae_handle->dev->ops; 1135 if (!ops->get_regs_len) { 1136 netdev_err(net_dev, "ops->get_regs_len is null!\n"); 1137 return -EOPNOTSUPP; 1138 } 1139 1140 reg_num = ops->get_regs_len(priv->ae_handle); 1141 if (reg_num > 0) 1142 return reg_num * sizeof(u32); 1143 else 1144 return reg_num; /* error code */ 1145 } 1146 1147 /** 1148 * hns_nic_nway_reset - nway reset 1149 * @dev: net device 1150 * 1151 * Return 0 on success, negative on failure 1152 */ 1153 static int hns_nic_nway_reset(struct net_device *netdev) 1154 { 1155 int ret = 0; 1156 struct phy_device *phy = netdev->phydev; 1157 1158 if (netif_running(netdev)) { 1159 /* if autoneg is disabled, don't restart auto-negotiation */ 1160 if (phy && phy->autoneg == AUTONEG_ENABLE) 1161 ret = genphy_restart_aneg(phy); 1162 } 1163 1164 return ret; 1165 } 1166 1167 static u32 1168 hns_get_rss_key_size(struct net_device *netdev) 1169 { 1170 struct hns_nic_priv *priv = netdev_priv(netdev); 1171 struct hnae_ae_ops *ops; 1172 1173 if (AE_IS_VER1(priv->enet_ver)) { 1174 netdev_err(netdev, 1175 "RSS feature is not supported on this hardware\n"); 1176 return 0; 1177 } 1178 1179 ops = priv->ae_handle->dev->ops; 1180 return ops->get_rss_key_size(priv->ae_handle); 1181 } 1182 1183 static u32 1184 hns_get_rss_indir_size(struct net_device *netdev) 1185 { 1186 struct hns_nic_priv *priv = netdev_priv(netdev); 1187 struct hnae_ae_ops *ops; 1188 1189 if (AE_IS_VER1(priv->enet_ver)) { 1190 netdev_err(netdev, 1191 "RSS feature is not supported on this hardware\n"); 1192 return 0; 1193 } 1194 1195 ops = priv->ae_handle->dev->ops; 1196 return ops->get_rss_indir_size(priv->ae_handle); 1197 } 1198 1199 static int 1200 hns_get_rss(struct net_device *netdev, u32 *indir, u8 *key, u8 *hfunc) 1201 { 1202 struct hns_nic_priv *priv = netdev_priv(netdev); 1203 struct hnae_ae_ops *ops; 1204 1205 if (AE_IS_VER1(priv->enet_ver)) { 1206 netdev_err(netdev, 1207 "RSS feature is not supported on this hardware\n"); 1208 return -EOPNOTSUPP; 1209 } 1210 1211 ops = priv->ae_handle->dev->ops; 1212 1213 if (!indir) 1214 return 0; 1215 1216 return ops->get_rss(priv->ae_handle, indir, key, hfunc); 1217 } 1218 1219 static int 1220 hns_set_rss(struct net_device *netdev, const u32 *indir, const u8 *key, 1221 const u8 hfunc) 1222 { 1223 struct hns_nic_priv *priv = netdev_priv(netdev); 1224 struct hnae_ae_ops *ops; 1225 1226 if (AE_IS_VER1(priv->enet_ver)) { 1227 netdev_err(netdev, 1228 "RSS feature is not supported on this hardware\n"); 1229 return -EOPNOTSUPP; 1230 } 1231 1232 ops = priv->ae_handle->dev->ops; 1233 1234 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP) { 1235 netdev_err(netdev, "Invalid hfunc!\n"); 1236 return -EOPNOTSUPP; 1237 } 1238 1239 return ops->set_rss(priv->ae_handle, indir, key, hfunc); 1240 } 1241 1242 static int hns_get_rxnfc(struct net_device *netdev, 1243 struct ethtool_rxnfc *cmd, 1244 u32 *rule_locs) 1245 { 1246 struct hns_nic_priv *priv = netdev_priv(netdev); 1247 1248 switch (cmd->cmd) { 1249 case ETHTOOL_GRXRINGS: 1250 cmd->data = priv->ae_handle->q_num; 1251 break; 1252 default: 1253 return -EOPNOTSUPP; 1254 } 1255 1256 return 0; 1257 } 1258 1259 static const struct ethtool_ops hns_ethtool_ops = { 1260 .get_drvinfo = hns_nic_get_drvinfo, 1261 .get_link = hns_nic_get_link, 1262 .get_ringparam = hns_get_ringparam, 1263 .get_pauseparam = hns_get_pauseparam, 1264 .set_pauseparam = hns_set_pauseparam, 1265 .get_coalesce = hns_get_coalesce, 1266 .set_coalesce = hns_set_coalesce, 1267 .get_channels = hns_get_channels, 1268 .self_test = hns_nic_self_test, 1269 .get_strings = hns_get_strings, 1270 .get_sset_count = hns_get_sset_count, 1271 .get_ethtool_stats = hns_get_ethtool_stats, 1272 .set_phys_id = hns_set_phys_id, 1273 .get_regs_len = hns_get_regs_len, 1274 .get_regs = hns_get_regs, 1275 .nway_reset = hns_nic_nway_reset, 1276 .get_rxfh_key_size = hns_get_rss_key_size, 1277 .get_rxfh_indir_size = hns_get_rss_indir_size, 1278 .get_rxfh = hns_get_rss, 1279 .set_rxfh = hns_set_rss, 1280 .get_rxnfc = hns_get_rxnfc, 1281 .get_link_ksettings = hns_nic_get_link_ksettings, 1282 .set_link_ksettings = hns_nic_set_link_ksettings, 1283 }; 1284 1285 void hns_ethtool_set_ops(struct net_device *ndev) 1286 { 1287 ndev->ethtool_ops = &hns_ethtool_ops; 1288 } 1289