Skip to content

Commit 7344bea

Browse files
Jakub Kicinskidavem330
authored andcommitted
nfp: store pointer to MAC statistics in nfp_port
Store pointer to device memory containing MAC statistics in nfp_port. This simplifies representor code and will be used to dump those statistics in ethtool as well. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 325945e commit 7344bea

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

drivers/net/ethernet/netronome/nfp/nfp_net_repr.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,10 @@ void nfp_repr_inc_rx_stats(struct net_device *netdev, unsigned int len)
7878
}
7979

8080
static void
81-
nfp_repr_phy_port_get_stats64(const struct nfp_app *app, u8 phy_port,
81+
nfp_repr_phy_port_get_stats64(struct nfp_port *port,
8282
struct rtnl_link_stats64 *stats)
8383
{
84-
u8 __iomem *mem;
85-
86-
mem = app->pf->mac_stats_mem + phy_port * NFP_MAC_STATS_SIZE;
84+
u8 __iomem *mem = port->eth_stats;
8785

8886
/* TX and RX stats are flipped as we are returning the stats as seen
8987
* at the switch port corresponding to the phys port.
@@ -141,18 +139,16 @@ static void
141139
nfp_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
142140
{
143141
struct nfp_repr *repr = netdev_priv(netdev);
144-
struct nfp_eth_table_port *eth_port;
145142
struct nfp_app *app = repr->app;
146143

147144
if (WARN_ON(!repr->port))
148145
return;
149146

150147
switch (repr->port->type) {
151148
case NFP_PORT_PHYS_PORT:
152-
eth_port = __nfp_port_get_eth_port(repr->port);
153-
if (!eth_port)
149+
if (!__nfp_port_get_eth_port(repr->port))
154150
break;
155-
nfp_repr_phy_port_get_stats64(app, eth_port->index, stats);
151+
nfp_repr_phy_port_get_stats64(repr->port, stats);
156152
break;
157153
case NFP_PORT_PF_PORT:
158154
nfp_repr_pf_get_stats64(app, repr->port->pf_id, stats);

drivers/net/ethernet/netronome/nfp/nfp_port.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ int nfp_port_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
225225

226226
port->eth_port = &pf->eth_tbl->ports[id];
227227
port->eth_id = pf->eth_tbl->ports[id].index;
228+
if (pf->mac_stats_mem)
229+
port->eth_stats =
230+
pf->mac_stats_mem + port->eth_id * NFP_MAC_STATS_SIZE;
228231

229232
return 0;
230233
}

drivers/net/ethernet/netronome/nfp/nfp_port.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ enum nfp_port_flags {
7676
* @dl_port: devlink port structure
7777
* @eth_id: for %NFP_PORT_PHYS_PORT port ID in NFP enumeration scheme
7878
* @eth_port: for %NFP_PORT_PHYS_PORT translated ETH Table port entry
79+
* @eth_stats: for %NFP_PORT_PHYS_PORT MAC stats if available
7980
* @pf_id: for %NFP_PORT_PF_PORT, %NFP_PORT_VF_PORT ID of the PCI PF (0-3)
8081
* @vf_id: for %NFP_PORT_VF_PORT ID of the PCI VF within @pf_id
8182
* @port_list: entry on pf's list of ports
@@ -95,6 +96,7 @@ struct nfp_port {
9596
struct {
9697
unsigned int eth_id;
9798
struct nfp_eth_table_port *eth_port;
99+
u8 __iomem *eth_stats;
98100
};
99101
/* NFP_PORT_PF_PORT, NFP_PORT_VF_PORT */
100102
struct {

0 commit comments

Comments
 (0)