spider_net_ethtool.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Network device driver for Cell Processor-Based Blade
  3. *
  4. * (C) Copyright IBM Corp. 2005
  5. *
  6. * Authors : Utz Bacher <utz.bacher@de.ibm.com>
  7. * Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2, or (at your option)
  12. * any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. */
  23. #include <linux/netdevice.h>
  24. #include <linux/ethtool.h>
  25. #include <linux/pci.h>
  26. #include "spider_net.h"
  27. static int
  28. spider_net_ethtool_get_settings(struct net_device *netdev,
  29. struct ethtool_cmd *cmd)
  30. {
  31. struct spider_net_card *card;
  32. card = netdev_priv(netdev);
  33. cmd->supported = (SUPPORTED_1000baseT_Full |
  34. SUPPORTED_FIBRE);
  35. cmd->advertising = (ADVERTISED_1000baseT_Full |
  36. ADVERTISED_FIBRE);
  37. cmd->port = PORT_FIBRE;
  38. cmd->speed = card->phy.speed;
  39. cmd->duplex = DUPLEX_FULL;
  40. return 0;
  41. }
  42. static void
  43. spider_net_ethtool_get_drvinfo(struct net_device *netdev,
  44. struct ethtool_drvinfo *drvinfo)
  45. {
  46. struct spider_net_card *card;
  47. card = netdev_priv(netdev);
  48. /* clear and fill out info */
  49. memset(drvinfo, 0, sizeof(struct ethtool_drvinfo));
  50. strncpy(drvinfo->driver, spider_net_driver_name, 32);
  51. strncpy(drvinfo->version, "0.1", 32);
  52. strcpy(drvinfo->fw_version, "no information");
  53. strncpy(drvinfo->bus_info, pci_name(card->pdev), 32);
  54. }
  55. static void
  56. spider_net_ethtool_get_wol(struct net_device *netdev,
  57. struct ethtool_wolinfo *wolinfo)
  58. {
  59. /* no support for wol */
  60. wolinfo->supported = 0;
  61. wolinfo->wolopts = 0;
  62. }
  63. static u32
  64. spider_net_ethtool_get_msglevel(struct net_device *netdev)
  65. {
  66. struct spider_net_card *card;
  67. card = netdev_priv(netdev);
  68. return card->msg_enable;
  69. }
  70. static void
  71. spider_net_ethtool_set_msglevel(struct net_device *netdev,
  72. u32 level)
  73. {
  74. struct spider_net_card *card;
  75. card = netdev_priv(netdev);
  76. card->msg_enable = level;
  77. }
  78. static int
  79. spider_net_ethtool_nway_reset(struct net_device *netdev)
  80. {
  81. if (netif_running(netdev)) {
  82. spider_net_stop(netdev);
  83. spider_net_open(netdev);
  84. }
  85. return 0;
  86. }
  87. static u32
  88. spider_net_ethtool_get_rx_csum(struct net_device *netdev)
  89. {
  90. struct spider_net_card *card = netdev->priv;
  91. return card->options.rx_csum;
  92. }
  93. static int
  94. spider_net_ethtool_set_rx_csum(struct net_device *netdev, u32 n)
  95. {
  96. struct spider_net_card *card = netdev->priv;
  97. card->options.rx_csum = n;
  98. return 0;
  99. }
  100. static uint32_t
  101. spider_net_ethtool_get_tx_csum(struct net_device *netdev)
  102. {
  103. return (netdev->features & NETIF_F_HW_CSUM) != 0;
  104. }
  105. static int
  106. spider_net_ethtool_set_tx_csum(struct net_device *netdev, uint32_t data)
  107. {
  108. if (data)
  109. netdev->features |= NETIF_F_HW_CSUM;
  110. else
  111. netdev->features &= ~NETIF_F_HW_CSUM;
  112. return 0;
  113. }
  114. struct ethtool_ops spider_net_ethtool_ops = {
  115. .get_settings = spider_net_ethtool_get_settings,
  116. .get_drvinfo = spider_net_ethtool_get_drvinfo,
  117. .get_wol = spider_net_ethtool_get_wol,
  118. .get_msglevel = spider_net_ethtool_get_msglevel,
  119. .set_msglevel = spider_net_ethtool_set_msglevel,
  120. .nway_reset = spider_net_ethtool_nway_reset,
  121. .get_rx_csum = spider_net_ethtool_get_rx_csum,
  122. .set_rx_csum = spider_net_ethtool_set_rx_csum,
  123. .get_tx_csum = spider_net_ethtool_get_tx_csum,
  124. .set_tx_csum = spider_net_ethtool_set_tx_csum,
  125. };