root/drivers/net/ethernet/pasemi/pasemi_mac_ethtool.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. pasemi_mac_ethtool_get_msglevel
  2. pasemi_mac_ethtool_set_msglevel
  3. pasemi_mac_ethtool_get_ringparam
  4. pasemi_mac_get_sset_count
  5. pasemi_mac_get_ethtool_stats
  6. pasemi_mac_get_strings

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  * Copyright (C) 2006-2008 PA Semi, Inc
   4  *
   5  * Ethtool hooks for the PA Semi PWRficient onchip 1G/10G Ethernet MACs
   6  */
   7 
   8 
   9 #include <linux/netdevice.h>
  10 #include <linux/ethtool.h>
  11 #include <linux/pci.h>
  12 
  13 #include <asm/pasemi_dma.h>
  14 #include "pasemi_mac.h"
  15 
  16 static struct {
  17         const char str[ETH_GSTRING_LEN];
  18 } ethtool_stats_keys[] = {
  19         { "rx-drops" },
  20         { "rx-bytes" },
  21         { "rx-packets" },
  22         { "rx-broadcast-packets" },
  23         { "rx-multicast-packets" },
  24         { "rx-crc-errors" },
  25         { "rx-undersize-errors" },
  26         { "rx-oversize-errors" },
  27         { "rx-short-fragment-errors" },
  28         { "rx-jabber-errors" },
  29         { "rx-64-byte-packets" },
  30         { "rx-65-127-byte-packets" },
  31         { "rx-128-255-byte-packets" },
  32         { "rx-256-511-byte-packets" },
  33         { "rx-512-1023-byte-packets" },
  34         { "rx-1024-1518-byte-packets" },
  35         { "rx-pause-frames" },
  36         { "tx-bytes" },
  37         { "tx-packets" },
  38         { "tx-broadcast-packets" },
  39         { "tx-multicast-packets" },
  40         { "tx-collisions" },
  41         { "tx-late-collisions" },
  42         { "tx-excessive-collisions" },
  43         { "tx-crc-errors" },
  44         { "tx-undersize-errors" },
  45         { "tx-oversize-errors" },
  46         { "tx-64-byte-packets" },
  47         { "tx-65-127-byte-packets" },
  48         { "tx-128-255-byte-packets" },
  49         { "tx-256-511-byte-packets" },
  50         { "tx-512-1023-byte-packets" },
  51         { "tx-1024-1518-byte-packets" },
  52 };
  53 
  54 static u32
  55 pasemi_mac_ethtool_get_msglevel(struct net_device *netdev)
  56 {
  57         struct pasemi_mac *mac = netdev_priv(netdev);
  58         return mac->msg_enable;
  59 }
  60 
  61 static void
  62 pasemi_mac_ethtool_set_msglevel(struct net_device *netdev,
  63                                 u32 level)
  64 {
  65         struct pasemi_mac *mac = netdev_priv(netdev);
  66         mac->msg_enable = level;
  67 }
  68 
  69 
  70 static void
  71 pasemi_mac_ethtool_get_ringparam(struct net_device *netdev,
  72                                  struct ethtool_ringparam *ering)
  73 {
  74         struct pasemi_mac *mac = netdev_priv(netdev);
  75 
  76         ering->tx_max_pending = TX_RING_SIZE/2;
  77         ering->tx_pending = RING_USED(mac->tx)/2;
  78         ering->rx_max_pending = RX_RING_SIZE/4;
  79         ering->rx_pending = RING_USED(mac->rx)/4;
  80 }
  81 
  82 static int pasemi_mac_get_sset_count(struct net_device *netdev, int sset)
  83 {
  84         switch (sset) {
  85         case ETH_SS_STATS:
  86                 return ARRAY_SIZE(ethtool_stats_keys);
  87         default:
  88                 return -EOPNOTSUPP;
  89         }
  90 }
  91 
  92 static void pasemi_mac_get_ethtool_stats(struct net_device *netdev,
  93                 struct ethtool_stats *stats, u64 *data)
  94 {
  95         struct pasemi_mac *mac = netdev_priv(netdev);
  96         int i;
  97 
  98         data[0] = pasemi_read_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if))
  99                         >> PAS_DMA_RXINT_RCMDSTA_DROPS_S;
 100         for (i = 0; i < 32; i++)
 101                 data[1+i] = pasemi_read_mac_reg(mac->dma_if, PAS_MAC_RMON(i));
 102 }
 103 
 104 static void pasemi_mac_get_strings(struct net_device *netdev, u32 stringset,
 105                                    u8 *data)
 106 {
 107         memcpy(data, ethtool_stats_keys, sizeof(ethtool_stats_keys));
 108 }
 109 
 110 const struct ethtool_ops pasemi_mac_ethtool_ops = {
 111         .get_msglevel           = pasemi_mac_ethtool_get_msglevel,
 112         .set_msglevel           = pasemi_mac_ethtool_set_msglevel,
 113         .get_link               = ethtool_op_get_link,
 114         .get_ringparam          = pasemi_mac_ethtool_get_ringparam,
 115         .get_strings            = pasemi_mac_get_strings,
 116         .get_sset_count         = pasemi_mac_get_sset_count,
 117         .get_ethtool_stats      = pasemi_mac_get_ethtool_stats,
 118         .get_link_ksettings     = phy_ethtool_get_link_ksettings,
 119         .set_link_ksettings     = phy_ethtool_set_link_ksettings,
 120 };
 121 

/* [<][>][^][v][top][bottom][index][help] */