Skip to content

Commit d8dec30

Browse files
Geetha sowjanyadavem330
authored andcommitted
octeontx2-pf: Implement offload stats ndo for representors
Implement the offload stat ndo by fetching the HW stats of rx/tx queues attached to the representor. Signed-off-by: Geetha sowjanya <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9ed0343 commit d8dec30

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ int otx2_update_rq_stats(struct otx2_nic *pfvf, int qidx)
8383
otx2_nix_rq_op_stats(&rq->stats, pfvf, qidx);
8484
return 1;
8585
}
86+
EXPORT_SYMBOL(otx2_update_rq_stats);
8687

8788
int otx2_update_sq_stats(struct otx2_nic *pfvf, int qidx)
8889
{
@@ -99,6 +100,7 @@ int otx2_update_sq_stats(struct otx2_nic *pfvf, int qidx)
99100
otx2_nix_sq_op_stats(&sq->stats, pfvf, qidx);
100101
return 1;
101102
}
103+
EXPORT_SYMBOL(otx2_update_sq_stats);
102104

103105
void otx2_get_dev_stats(struct otx2_nic *pfvf)
104106
{

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,45 @@ MODULE_DEVICE_TABLE(pci, rvu_rep_id_table);
3131
static int rvu_rep_notify_pfvf(struct otx2_nic *priv, u16 event,
3232
struct rep_event *data);
3333

34+
static int
35+
rvu_rep_sp_stats64(const struct net_device *dev,
36+
struct rtnl_link_stats64 *stats)
37+
{
38+
struct rep_dev *rep = netdev_priv(dev);
39+
struct otx2_nic *priv = rep->mdev;
40+
struct otx2_rcv_queue *rq;
41+
struct otx2_snd_queue *sq;
42+
u16 qidx = rep->rep_id;
43+
44+
otx2_update_rq_stats(priv, qidx);
45+
rq = &priv->qset.rq[qidx];
46+
47+
otx2_update_sq_stats(priv, qidx);
48+
sq = &priv->qset.sq[qidx];
49+
50+
stats->tx_bytes = sq->stats.bytes;
51+
stats->tx_packets = sq->stats.pkts;
52+
stats->rx_bytes = rq->stats.bytes;
53+
stats->rx_packets = rq->stats.pkts;
54+
return 0;
55+
}
56+
57+
static bool
58+
rvu_rep_has_offload_stats(const struct net_device *dev, int attr_id)
59+
{
60+
return attr_id == IFLA_OFFLOAD_XSTATS_CPU_HIT;
61+
}
62+
63+
static int
64+
rvu_rep_get_offload_stats(int attr_id, const struct net_device *dev,
65+
void *sp)
66+
{
67+
if (attr_id == IFLA_OFFLOAD_XSTATS_CPU_HIT)
68+
return rvu_rep_sp_stats64(dev, (struct rtnl_link_stats64 *)sp);
69+
70+
return -EINVAL;
71+
}
72+
3473
static int rvu_rep_dl_port_fn_hw_addr_get(struct devlink_port *port,
3574
u8 *hw_addr, int *hw_addr_len,
3675
struct netlink_ext_ack *extack)
@@ -326,6 +365,8 @@ static const struct net_device_ops rvu_rep_netdev_ops = {
326365
.ndo_start_xmit = rvu_rep_xmit,
327366
.ndo_get_stats64 = rvu_rep_get_stats64,
328367
.ndo_change_mtu = rvu_rep_change_mtu,
368+
.ndo_has_offload_stats = rvu_rep_has_offload_stats,
369+
.ndo_get_offload_stats = rvu_rep_get_offload_stats,
329370
};
330371

331372
static int rvu_rep_napi_init(struct otx2_nic *priv,

0 commit comments

Comments
 (0)