Skip to content

Commit e239d0c

Browse files
Geetha sowjanyadavem330
authored andcommitted
octeontx2-pf: Add ndo_get_stats64
Added ndo_get_stats64 which returns stats maintained by HW. Signed-off-by: Geetha sowjanya <[email protected]> Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 86d7476 commit e239d0c

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,53 @@
1616
#include "otx2_common.h"
1717
#include "otx2_struct.h"
1818

19+
void otx2_get_dev_stats(struct otx2_nic *pfvf)
20+
{
21+
struct otx2_dev_stats *dev_stats = &pfvf->hw.dev_stats;
22+
23+
#define OTX2_GET_RX_STATS(reg) \
24+
otx2_read64(pfvf, NIX_LF_RX_STATX(reg))
25+
#define OTX2_GET_TX_STATS(reg) \
26+
otx2_read64(pfvf, NIX_LF_TX_STATX(reg))
27+
28+
dev_stats->rx_bytes = OTX2_GET_RX_STATS(RX_OCTS);
29+
dev_stats->rx_drops = OTX2_GET_RX_STATS(RX_DROP);
30+
dev_stats->rx_bcast_frames = OTX2_GET_RX_STATS(RX_BCAST);
31+
dev_stats->rx_mcast_frames = OTX2_GET_RX_STATS(RX_MCAST);
32+
dev_stats->rx_ucast_frames = OTX2_GET_RX_STATS(RX_UCAST);
33+
dev_stats->rx_frames = dev_stats->rx_bcast_frames +
34+
dev_stats->rx_mcast_frames +
35+
dev_stats->rx_ucast_frames;
36+
37+
dev_stats->tx_bytes = OTX2_GET_TX_STATS(TX_OCTS);
38+
dev_stats->tx_drops = OTX2_GET_TX_STATS(TX_DROP);
39+
dev_stats->tx_bcast_frames = OTX2_GET_TX_STATS(TX_BCAST);
40+
dev_stats->tx_mcast_frames = OTX2_GET_TX_STATS(TX_MCAST);
41+
dev_stats->tx_ucast_frames = OTX2_GET_TX_STATS(TX_UCAST);
42+
dev_stats->tx_frames = dev_stats->tx_bcast_frames +
43+
dev_stats->tx_mcast_frames +
44+
dev_stats->tx_ucast_frames;
45+
}
46+
47+
void otx2_get_stats64(struct net_device *netdev,
48+
struct rtnl_link_stats64 *stats)
49+
{
50+
struct otx2_nic *pfvf = netdev_priv(netdev);
51+
struct otx2_dev_stats *dev_stats;
52+
53+
otx2_get_dev_stats(pfvf);
54+
55+
dev_stats = &pfvf->hw.dev_stats;
56+
stats->rx_bytes = dev_stats->rx_bytes;
57+
stats->rx_packets = dev_stats->rx_frames;
58+
stats->rx_dropped = dev_stats->rx_drops;
59+
stats->multicast = dev_stats->rx_mcast_frames;
60+
61+
stats->tx_bytes = dev_stats->tx_bytes;
62+
stats->tx_packets = dev_stats->tx_frames;
63+
stats->tx_dropped = dev_stats->tx_drops;
64+
}
65+
1966
/* Sync MAC address with RVU AF */
2067
static int otx2_hw_set_mac_addr(struct otx2_nic *pfvf, u8 *mac)
2168
{

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,49 @@ enum otx2_errcodes_re {
8181
ERRCODE_IL4_CSUM = 0x22,
8282
};
8383

84+
/* NIX TX stats */
85+
enum nix_stat_lf_tx {
86+
TX_UCAST = 0x0,
87+
TX_BCAST = 0x1,
88+
TX_MCAST = 0x2,
89+
TX_DROP = 0x3,
90+
TX_OCTS = 0x4,
91+
TX_STATS_ENUM_LAST,
92+
};
93+
94+
/* NIX RX stats */
95+
enum nix_stat_lf_rx {
96+
RX_OCTS = 0x0,
97+
RX_UCAST = 0x1,
98+
RX_BCAST = 0x2,
99+
RX_MCAST = 0x3,
100+
RX_DROP = 0x4,
101+
RX_DROP_OCTS = 0x5,
102+
RX_FCS = 0x6,
103+
RX_ERR = 0x7,
104+
RX_DRP_BCAST = 0x8,
105+
RX_DRP_MCAST = 0x9,
106+
RX_DRP_L3BCAST = 0xa,
107+
RX_DRP_L3MCAST = 0xb,
108+
RX_STATS_ENUM_LAST,
109+
};
110+
111+
struct otx2_dev_stats {
112+
u64 rx_bytes;
113+
u64 rx_frames;
114+
u64 rx_ucast_frames;
115+
u64 rx_bcast_frames;
116+
u64 rx_mcast_frames;
117+
u64 rx_drops;
118+
119+
u64 tx_bytes;
120+
u64 tx_frames;
121+
u64 tx_ucast_frames;
122+
u64 tx_bcast_frames;
123+
u64 tx_mcast_frames;
124+
u64 tx_drops;
125+
};
126+
84127
/* Driver counted stats */
85128
struct otx2_drv_stats {
86129
atomic_t rx_fcs_errs;
@@ -142,6 +185,7 @@ struct otx2_hw {
142185
cpumask_var_t *affinity_mask;
143186

144187
/* Stats */
188+
struct otx2_dev_stats dev_stats;
145189
struct otx2_drv_stats drv_stats;
146190
};
147191

@@ -545,6 +589,11 @@ void mbox_handler_nix_lf_alloc(struct otx2_nic *pfvf,
545589
void mbox_handler_nix_txsch_alloc(struct otx2_nic *pf,
546590
struct nix_txsch_alloc_rsp *rsp);
547591

592+
/* Device stats APIs */
593+
void otx2_get_dev_stats(struct otx2_nic *pfvf);
594+
void otx2_get_stats64(struct net_device *netdev,
595+
struct rtnl_link_stats64 *stats);
596+
548597
int otx2_open(struct net_device *netdev);
549598
int otx2_stop(struct net_device *netdev);
550599
#endif /* OTX2_COMMON_H */

drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,7 @@ static const struct net_device_ops otx2_netdev_ops = {
10731073
.ndo_set_rx_mode = otx2_set_rx_mode,
10741074
.ndo_set_features = otx2_set_features,
10751075
.ndo_tx_timeout = otx2_tx_timeout,
1076+
.ndo_get_stats64 = otx2_get_stats64,
10761077
};
10771078

10781079
static int otx2_check_pf_usable(struct otx2_nic *nic)

0 commit comments

Comments
 (0)