History

eth: fbnic: Add pause stats support

Add support to read pause stats for fbnic. Unlike FEC and PCS stats, pause stats won't wrap, do not fetch them under the service task. Since, they are exclusively accessed via the ethtool API, don't include them in fbnic_get_hw_stats(). ]# ethtool -I -a eth0 Pause parameters for eth0: Autonegotiate: on RX: off TX: off Statistics: tx_pause_frames: 0 rx_pause_frames: 0

Mohsin Bashir committed 1 year ago

Commit e9faf4d1 parent 33c49376 files · +42 −0Browse files

Unified · Split

6 files
  1. drivers/net/ethernet/meta/fbnic/fbnic_csr.h +4 −0
  2. drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +17 −0
  3. drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +1 −0
  4. drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h +7 −0
  5. drivers/net/ethernet/meta/fbnic/fbnic_mac.c +11 −0
  6. drivers/net/ethernet/meta/fbnic/fbnic_mac.h +2 −0
drivers/net/ethernet/meta/fbnic/fbnic_csr.h+4−0
@@ -844,6 +844,10 @@ enum { · 843 unmodified lines
844844 #define FBNIC_CSR_END_SIG 0x1184e /* CSR section delimiter */
845845
846846 #define FBNIC_CSR_START_MAC_STAT 0x11a00
847+#define FBNIC_MAC_STAT_RX_XOFF_STB_L 0x11a00 /* 0x46800 */
848+#define FBNIC_MAC_STAT_RX_XOFF_STB_H 0x11a01 /* 0x46804 */
849+#define FBNIC_MAC_STAT_TX_XOFF_STB_L 0x11a04 /* 0x46810 */
850+#define FBNIC_MAC_STAT_TX_XOFF_STB_H 0x11a05 /* 0x46814 */
847851 #define FBNIC_MAC_STAT_RX_BYTE_COUNT_L 0x11a08 /* 0x46820 */
848852 #define FBNIC_MAC_STAT_RX_BYTE_COUNT_H 0x11a09 /* 0x46824 */
849853 #define FBNIC_MAC_STAT_RX_ALIGN_ERROR_L 0x11a0a /* 0x46828 */
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c+17−0
@@ -1641,6 +1641,22 @@ static void fbnic_set_counter(u64 *stat, struct fbnic_stat_counter *counter) · 1640 unmodified lines
16411641 *stat = counter->value;
16421642 }
16431643
1644+static void
1645+fbnic_get_pause_stats(struct net_device *netdev,
1646+ struct ethtool_pause_stats *pause_stats)
1647+{
1648+ struct fbnic_net *fbn = netdev_priv(netdev);
1649+ struct fbnic_mac_stats *mac_stats;
1650+ struct fbnic_dev *fbd = fbn->fbd;
1651+
1652+ mac_stats = &fbd->hw_stats.mac;
1653+
1654+ fbd->mac->get_pause_stats(fbd, false, &mac_stats->pause);
1655+
1656+ pause_stats->tx_pause_frames = mac_stats->pause.tx_pause_frames.value;
1657+ pause_stats->rx_pause_frames = mac_stats->pause.rx_pause_frames.value;
1658+}
1659+
16441660 static void
16451661 fbnic_get_fec_stats(struct net_device *netdev,
16461662 struct ethtool_fec_stats *fec_stats)
@@ -1801,6 +1817,7 @@ static const struct ethtool_ops fbnic_ethtool_ops = { · 154 unmodified lines
18011817 .set_coalesce = fbnic_set_coalesce,
18021818 .get_ringparam = fbnic_get_ringparam,
18031819 .set_ringparam = fbnic_set_ringparam,
1820+ .get_pause_stats = fbnic_get_pause_stats,
18041821 .get_pauseparam = fbnic_phylink_get_pauseparam,
18051822 .set_pauseparam = fbnic_phylink_set_pauseparam,
18061823 .get_strings = fbnic_get_strings,
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c+1−0
@@ -536,6 +536,7 @@ static void fbnic_reset_hw_mac_stats(struct fbnic_dev *fbd, · 535 unmodified lines
536536 const struct fbnic_mac *mac = fbd->mac;
537537
538538 mac->get_eth_mac_stats(fbd, true, &mac_stats->eth_mac);
539+ mac->get_pause_stats(fbd, true, &mac_stats->pause);
539540 mac->get_eth_ctrl_stats(fbd, true, &mac_stats->eth_ctrl);
540541 mac->get_rmon_stats(fbd, true, &mac_stats->rmon);
541542 }
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h+7−0
@@ -50,6 +50,12 @@ struct fbnic_rmon_stats { · 49 unmodified lines
5050 struct fbnic_stat_counter hist_tx[ETHTOOL_RMON_HIST_MAX];
5151 };
5252
53+/* Note: not updated by fbnic_get_hw_stats() */
54+struct fbnic_pause_stats {
55+ struct fbnic_stat_counter tx_pause_frames;
56+ struct fbnic_stat_counter rx_pause_frames;
57+};
58+
5359 struct fbnic_eth_mac_stats {
5460 struct fbnic_stat_counter FramesTransmittedOK;
5561 struct fbnic_stat_counter FramesReceivedOK;
@@ -73,6 +79,7 @@ struct fbnic_phy_stats { · 17 unmodified lines
7379
7480 struct fbnic_mac_stats {
7581 struct fbnic_eth_mac_stats eth_mac;
82+ struct fbnic_pause_stats pause;
7683 struct fbnic_eth_ctrl_stats eth_ctrl;
7784 struct fbnic_rmon_stats rmon;
7885 };
drivers/net/ethernet/meta/fbnic/fbnic_mac.c+11−0
@@ -709,6 +709,16 @@ fbnic_mac_get_eth_mac_stats(struct fbnic_dev *fbd, bool reset, · 708 unmodified lines
709709 MAC_STAT_TX_BROADCAST);
710710 }
711711
712+static void
713+fbnic_mac_get_pause_stats(struct fbnic_dev *fbd, bool reset,
714+ struct fbnic_pause_stats *pause_stats)
715+{
716+ fbnic_mac_stat_rd64(fbd, reset, pause_stats->tx_pause_frames,
717+ MAC_STAT_TX_XOFF_STB);
718+ fbnic_mac_stat_rd64(fbd, reset, pause_stats->rx_pause_frames,
719+ MAC_STAT_RX_XOFF_STB);
720+}
721+
712722 static void
713723 fbnic_mac_get_eth_ctrl_stats(struct fbnic_dev *fbd, bool reset,
714724 struct fbnic_eth_ctrl_stats *ctrl_stats)
@@ -856,6 +866,7 @@ static const struct fbnic_mac fbnic_mac_asic = { · 141 unmodified lines
856866 .get_fec_stats = fbnic_mac_get_fec_stats,
857867 .get_pcs_stats = fbnic_mac_get_pcs_stats,
858868 .get_eth_mac_stats = fbnic_mac_get_eth_mac_stats,
869+ .get_pause_stats = fbnic_mac_get_pause_stats,
859870 .get_eth_ctrl_stats = fbnic_mac_get_eth_ctrl_stats,
860871 .get_rmon_stats = fbnic_mac_get_rmon_stats,
861872 .link_down = fbnic_mac_link_down_asic,
drivers/net/ethernet/meta/fbnic/fbnic_mac.h+2−0
@@ -85,6 +85,8 @@ struct fbnic_mac { · 84 unmodified lines
8585 struct fbnic_pcs_stats *pcs_stats);
8686 void (*get_eth_mac_stats)(struct fbnic_dev *fbd, bool reset,
8787 struct fbnic_eth_mac_stats *mac_stats);
88+ void (*get_pause_stats)(struct fbnic_dev *fbd, bool reset,
89+ struct fbnic_pause_stats *pause_stats);
8890 void (*get_eth_ctrl_stats)(struct fbnic_dev *fbd, bool reset,
8991 struct fbnic_eth_ctrl_stats *ctrl_stats);
9092 void (*get_rmon_stats)(struct fbnic_dev *fbd, bool reset,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t