Skip to content

Commit d45d897

Browse files
Christina Jacobdavem330
authored andcommitted
octeontx2-pf: Add basic ethtool support
This patch adds ethtool support for - Driver stats, Tx/Rx perqueue and CGX LMAC stats - Set/show Rx/Tx queue count - Set/show Rx/Tx ring sizes - Set/show IRQ coalescing parameters Signed-off-by: Christina Jacob <[email protected]> Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e239d0c commit d45d897

File tree

6 files changed

+525
-4
lines changed

6 files changed

+525
-4
lines changed

drivers/net/ethernet/marvell/octeontx2/nic/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55

66
obj-$(CONFIG_OCTEONTX2_PF) += octeontx2_nicpf.o
77

8-
octeontx2_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o
8+
octeontx2_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o
99

1010
ccflags-y += -I$(srctree)/drivers/net/ethernet/marvell/octeontx2/af

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

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,72 @@
1616
#include "otx2_common.h"
1717
#include "otx2_struct.h"
1818

19+
static void otx2_nix_rq_op_stats(struct queue_stats *stats,
20+
struct otx2_nic *pfvf, int qidx)
21+
{
22+
u64 incr = (u64)qidx << 32;
23+
u64 *ptr;
24+
25+
ptr = (u64 *)otx2_get_regaddr(pfvf, NIX_LF_RQ_OP_OCTS);
26+
stats->bytes = otx2_atomic64_add(incr, ptr);
27+
28+
ptr = (u64 *)otx2_get_regaddr(pfvf, NIX_LF_RQ_OP_PKTS);
29+
stats->pkts = otx2_atomic64_add(incr, ptr);
30+
}
31+
32+
static void otx2_nix_sq_op_stats(struct queue_stats *stats,
33+
struct otx2_nic *pfvf, int qidx)
34+
{
35+
u64 incr = (u64)qidx << 32;
36+
u64 *ptr;
37+
38+
ptr = (u64 *)otx2_get_regaddr(pfvf, NIX_LF_SQ_OP_OCTS);
39+
stats->bytes = otx2_atomic64_add(incr, ptr);
40+
41+
ptr = (u64 *)otx2_get_regaddr(pfvf, NIX_LF_SQ_OP_PKTS);
42+
stats->pkts = otx2_atomic64_add(incr, ptr);
43+
}
44+
45+
void otx2_update_lmac_stats(struct otx2_nic *pfvf)
46+
{
47+
struct msg_req *req;
48+
49+
if (!netif_running(pfvf->netdev))
50+
return;
51+
52+
otx2_mbox_lock(&pfvf->mbox);
53+
req = otx2_mbox_alloc_msg_cgx_stats(&pfvf->mbox);
54+
if (!req) {
55+
otx2_mbox_unlock(&pfvf->mbox);
56+
return;
57+
}
58+
59+
otx2_sync_mbox_msg(&pfvf->mbox);
60+
otx2_mbox_unlock(&pfvf->mbox);
61+
}
62+
63+
int otx2_update_rq_stats(struct otx2_nic *pfvf, int qidx)
64+
{
65+
struct otx2_rcv_queue *rq = &pfvf->qset.rq[qidx];
66+
67+
if (!pfvf->qset.rq)
68+
return 0;
69+
70+
otx2_nix_rq_op_stats(&rq->stats, pfvf, qidx);
71+
return 1;
72+
}
73+
74+
int otx2_update_sq_stats(struct otx2_nic *pfvf, int qidx)
75+
{
76+
struct otx2_snd_queue *sq = &pfvf->qset.sq[qidx];
77+
78+
if (!pfvf->qset.sq)
79+
return 0;
80+
81+
otx2_nix_sq_op_stats(&sq->stats, pfvf, qidx);
82+
return 1;
83+
}
84+
1985
void otx2_get_dev_stats(struct otx2_nic *pfvf)
2086
{
2187
struct otx2_dev_stats *dev_stats = &pfvf->hw.dev_stats;
@@ -590,6 +656,9 @@ static int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)
590656
sq->lmt_addr = (__force u64 *)(pfvf->reg_base + LMT_LF_LMTLINEX(qidx));
591657
sq->io_addr = (__force u64)otx2_get_regaddr(pfvf, NIX_LF_OP_SENDX(0));
592658

659+
sq->stats.bytes = 0;
660+
sq->stats.pkts = 0;
661+
593662
/* Get memory to put this msg */
594663
aq = otx2_mbox_alloc_msg_nix_aq_enq(&pfvf->mbox);
595664
if (!aq)
@@ -1238,6 +1307,18 @@ void otx2_ctx_disable(struct mbox *mbox, int type, bool npa)
12381307
otx2_mbox_unlock(mbox);
12391308
}
12401309

1310+
/* Mbox message handlers */
1311+
void mbox_handler_cgx_stats(struct otx2_nic *pfvf,
1312+
struct cgx_stats_rsp *rsp)
1313+
{
1314+
int id;
1315+
1316+
for (id = 0; id < CGX_RX_STATS_COUNT; id++)
1317+
pfvf->hw.cgx_rx_stats[id] = rsp->rx_stats[id];
1318+
for (id = 0; id < CGX_TX_STATS_COUNT; id++)
1319+
pfvf->hw.cgx_tx_stats[id] = rsp->tx_stats[id];
1320+
}
1321+
12411322
void mbox_handler_nix_txsch_alloc(struct otx2_nic *pf,
12421323
struct nix_txsch_alloc_rsp *rsp)
12431324
{
@@ -1250,7 +1331,6 @@ void mbox_handler_nix_txsch_alloc(struct otx2_nic *pf,
12501331
rsp->schq_list[lvl][schq];
12511332
}
12521333

1253-
/* Mbox message handlers */
12541334
void mbox_handler_npa_lf_alloc(struct otx2_nic *pfvf,
12551335
struct npa_lf_alloc_rsp *rsp)
12561336
{

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ struct otx2_hw {
187187
/* Stats */
188188
struct otx2_dev_stats dev_stats;
189189
struct otx2_drv_stats drv_stats;
190+
u64 cgx_rx_stats[CGX_RX_STATS_COUNT];
191+
u64 cgx_tx_stats[CGX_TX_STATS_COUNT];
190192
};
191193

192194
struct refill_work {
@@ -588,12 +590,20 @@ void mbox_handler_nix_lf_alloc(struct otx2_nic *pfvf,
588590
struct nix_lf_alloc_rsp *rsp);
589591
void mbox_handler_nix_txsch_alloc(struct otx2_nic *pf,
590592
struct nix_txsch_alloc_rsp *rsp);
593+
void mbox_handler_cgx_stats(struct otx2_nic *pfvf,
594+
struct cgx_stats_rsp *rsp);
591595

592596
/* Device stats APIs */
593597
void otx2_get_dev_stats(struct otx2_nic *pfvf);
594598
void otx2_get_stats64(struct net_device *netdev,
595599
struct rtnl_link_stats64 *stats);
600+
void otx2_update_lmac_stats(struct otx2_nic *pfvf);
601+
int otx2_update_rq_stats(struct otx2_nic *pfvf, int qidx);
602+
int otx2_update_sq_stats(struct otx2_nic *pfvf, int qidx);
603+
void otx2_set_ethtool_ops(struct net_device *netdev);
596604

597605
int otx2_open(struct net_device *netdev);
598606
int otx2_stop(struct net_device *netdev);
607+
int otx2_set_real_num_queues(struct net_device *netdev,
608+
int tx_queues, int rx_queues);
599609
#endif /* OTX2_COMMON_H */

0 commit comments

Comments
 (0)