aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/benet/be_ethtool.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/benet/be_ethtool.c')
-rw-r--r--drivers/net/benet/be_ethtool.c63
1 files changed, 60 insertions, 3 deletions
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c
index 5d001c4deac1..09d8899b2de9 100644
--- a/drivers/net/benet/be_ethtool.c
+++ b/drivers/net/benet/be_ethtool.c
@@ -112,6 +112,7 @@ static const char et_self_tests[][ETH_GSTRING_LEN] = {
112 "PHY Loopback test", 112 "PHY Loopback test",
113 "External Loopback test", 113 "External Loopback test",
114 "DDR DMA test" 114 "DDR DMA test"
115 "Link test"
115}; 116};
116 117
117#define ETHTOOL_TESTS_NUM ARRAY_SIZE(et_self_tests) 118#define ETHTOOL_TESTS_NUM ARRAY_SIZE(et_self_tests)
@@ -529,6 +530,9 @@ static void
529be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data) 530be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data)
530{ 531{
531 struct be_adapter *adapter = netdev_priv(netdev); 532 struct be_adapter *adapter = netdev_priv(netdev);
533 bool link_up;
534 u8 mac_speed = 0;
535 u16 qos_link_speed = 0;
532 536
533 memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM); 537 memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM);
534 538
@@ -545,12 +549,20 @@ be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data)
545 &data[2]) != 0) { 549 &data[2]) != 0) {
546 test->flags |= ETH_TEST_FL_FAILED; 550 test->flags |= ETH_TEST_FL_FAILED;
547 } 551 }
552 }
548 553
549 data[3] = be_test_ddr_dma(adapter); 554 if (be_test_ddr_dma(adapter) != 0) {
550 if (data[3] != 0) 555 data[3] = 1;
551 test->flags |= ETH_TEST_FL_FAILED; 556 test->flags |= ETH_TEST_FL_FAILED;
552 } 557 }
553 558
559 if (be_cmd_link_status_query(adapter, &link_up, &mac_speed,
560 &qos_link_speed) != 0) {
561 test->flags |= ETH_TEST_FL_FAILED;
562 data[4] = -1;
563 } else if (mac_speed) {
564 data[4] = 1;
565 }
554} 566}
555 567
556static int 568static int
@@ -567,12 +579,57 @@ be_do_flash(struct net_device *netdev, struct ethtool_flash *efl)
567 return be_load_fw(adapter, file_name); 579 return be_load_fw(adapter, file_name);
568} 580}
569 581
582static int
583be_get_eeprom_len(struct net_device *netdev)
584{
585 return BE_READ_SEEPROM_LEN;
586}
587
588static int
589be_read_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom,
590 uint8_t *data)
591{
592 struct be_adapter *adapter = netdev_priv(netdev);
593 struct be_dma_mem eeprom_cmd;
594 struct be_cmd_resp_seeprom_read *resp;
595 int status;
596
597 if (!eeprom->len)
598 return -EINVAL;
599
600 eeprom->magic = BE_VENDOR_ID | (adapter->pdev->device<<16);
601
602 memset(&eeprom_cmd, 0, sizeof(struct be_dma_mem));
603 eeprom_cmd.size = sizeof(struct be_cmd_req_seeprom_read);
604 eeprom_cmd.va = pci_alloc_consistent(adapter->pdev, eeprom_cmd.size,
605 &eeprom_cmd.dma);
606
607 if (!eeprom_cmd.va) {
608 dev_err(&adapter->pdev->dev,
609 "Memory allocation failure. Could not read eeprom\n");
610 return -ENOMEM;
611 }
612
613 status = be_cmd_get_seeprom_data(adapter, &eeprom_cmd);
614
615 if (!status) {
616 resp = (struct be_cmd_resp_seeprom_read *) eeprom_cmd.va;
617 memcpy(data, resp->seeprom_data, eeprom->len);
618 }
619 pci_free_consistent(adapter->pdev, eeprom_cmd.size, eeprom_cmd.va,
620 eeprom_cmd.dma);
621
622 return status;
623}
624
570const struct ethtool_ops be_ethtool_ops = { 625const struct ethtool_ops be_ethtool_ops = {
571 .get_settings = be_get_settings, 626 .get_settings = be_get_settings,
572 .get_drvinfo = be_get_drvinfo, 627 .get_drvinfo = be_get_drvinfo,
573 .get_wol = be_get_wol, 628 .get_wol = be_get_wol,
574 .set_wol = be_set_wol, 629 .set_wol = be_set_wol,
575 .get_link = ethtool_op_get_link, 630 .get_link = ethtool_op_get_link,
631 .get_eeprom_len = be_get_eeprom_len,
632 .get_eeprom = be_read_eeprom,
576 .get_coalesce = be_get_coalesce, 633 .get_coalesce = be_get_coalesce,
577 .set_coalesce = be_set_coalesce, 634 .set_coalesce = be_set_coalesce,
578 .get_ringparam = be_get_ringparam, 635 .get_ringparam = be_get_ringparam,