Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7344bea1 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller
Browse files

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: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 325945ed
Loading
Loading
Loading
Loading
+4 −8
Original line number Original line Diff line number Diff line
@@ -78,12 +78,10 @@ void nfp_repr_inc_rx_stats(struct net_device *netdev, unsigned int len)
}
}


static void
static void
nfp_repr_phy_port_get_stats64(const struct nfp_app *app, u8 phy_port,
nfp_repr_phy_port_get_stats64(struct nfp_port *port,
			      struct rtnl_link_stats64 *stats)
			      struct rtnl_link_stats64 *stats)
{
{
	u8 __iomem *mem;
	u8 __iomem *mem = port->eth_stats;

	mem = app->pf->mac_stats_mem + phy_port * NFP_MAC_STATS_SIZE;


	/* TX and RX stats are flipped as we are returning the stats as seen
	/* TX and RX stats are flipped as we are returning the stats as seen
	 * at the switch port corresponding to the phys port.
	 * at the switch port corresponding to the phys port.
@@ -141,7 +139,6 @@ static void
nfp_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
nfp_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
{
{
	struct nfp_repr *repr = netdev_priv(netdev);
	struct nfp_repr *repr = netdev_priv(netdev);
	struct nfp_eth_table_port *eth_port;
	struct nfp_app *app = repr->app;
	struct nfp_app *app = repr->app;


	if (WARN_ON(!repr->port))
	if (WARN_ON(!repr->port))
@@ -149,10 +146,9 @@ nfp_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)


	switch (repr->port->type) {
	switch (repr->port->type) {
	case NFP_PORT_PHYS_PORT:
	case NFP_PORT_PHYS_PORT:
		eth_port = __nfp_port_get_eth_port(repr->port);
		if (!__nfp_port_get_eth_port(repr->port))
		if (!eth_port)
			break;
			break;
		nfp_repr_phy_port_get_stats64(app, eth_port->index, stats);
		nfp_repr_phy_port_get_stats64(repr->port, stats);
		break;
		break;
	case NFP_PORT_PF_PORT:
	case NFP_PORT_PF_PORT:
		nfp_repr_pf_get_stats64(app, repr->port->pf_id, stats);
		nfp_repr_pf_get_stats64(app, repr->port->pf_id, stats);
+3 −0
Original line number Original line Diff line number Diff line
@@ -225,6 +225,9 @@ int nfp_port_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,


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


	return 0;
	return 0;
}
}
+2 −0
Original line number Original line Diff line number Diff line
@@ -76,6 +76,7 @@ enum nfp_port_flags {
 * @dl_port:	devlink port structure
 * @dl_port:	devlink port structure
 * @eth_id:	for %NFP_PORT_PHYS_PORT port ID in NFP enumeration scheme
 * @eth_id:	for %NFP_PORT_PHYS_PORT port ID in NFP enumeration scheme
 * @eth_port:	for %NFP_PORT_PHYS_PORT translated ETH Table port entry
 * @eth_port:	for %NFP_PORT_PHYS_PORT translated ETH Table port entry
 * @eth_stats:	for %NFP_PORT_PHYS_PORT MAC stats if available
 * @pf_id:	for %NFP_PORT_PF_PORT, %NFP_PORT_VF_PORT ID of the PCI PF (0-3)
 * @pf_id:	for %NFP_PORT_PF_PORT, %NFP_PORT_VF_PORT ID of the PCI PF (0-3)
 * @vf_id:	for %NFP_PORT_VF_PORT ID of the PCI VF within @pf_id
 * @vf_id:	for %NFP_PORT_VF_PORT ID of the PCI VF within @pf_id
 * @port_list:	entry on pf's list of ports
 * @port_list:	entry on pf's list of ports
@@ -95,6 +96,7 @@ struct nfp_port {
		struct {
		struct {
			unsigned int eth_id;
			unsigned int eth_id;
			struct nfp_eth_table_port *eth_port;
			struct nfp_eth_table_port *eth_port;
			u8 __iomem *eth_stats;
		};
		};
		/* NFP_PORT_PF_PORT, NFP_PORT_VF_PORT */
		/* NFP_PORT_PF_PORT, NFP_PORT_VF_PORT */
		struct {
		struct {