Commit 3238b250 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: make the representor get stats app-independent

Thanks to the fact that all representors will now have an nfp_port,
we can depend on information there to provide a app-independent
.ndo_get_stats64().
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 38edbf6f
...@@ -104,20 +104,6 @@ nfp_flower_repr_get(struct nfp_app *app, u32 port_id) ...@@ -104,20 +104,6 @@ nfp_flower_repr_get(struct nfp_app *app, u32 port_id)
return reprs->reprs[port]; return reprs->reprs[port];
} }
static void
nfp_flower_repr_netdev_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *stats)
{
struct nfp_repr *repr = netdev_priv(netdev);
enum nfp_repr_type type;
u32 port_id;
u8 port = 0;
port_id = repr->dst->u.port_info.port_id;
type = nfp_flower_repr_get_type_and_port(repr->app, port_id, &port);
nfp_repr_get_stats64(repr->app, type, port, stats);
}
static int nfp_flower_repr_netdev_open(struct net_device *netdev) static int nfp_flower_repr_netdev_open(struct net_device *netdev)
{ {
int err; int err;
...@@ -144,7 +130,7 @@ static const struct net_device_ops nfp_flower_repr_netdev_ops = { ...@@ -144,7 +130,7 @@ static const struct net_device_ops nfp_flower_repr_netdev_ops = {
.ndo_open = nfp_flower_repr_netdev_open, .ndo_open = nfp_flower_repr_netdev_open,
.ndo_stop = nfp_flower_repr_netdev_stop, .ndo_stop = nfp_flower_repr_netdev_stop,
.ndo_start_xmit = nfp_repr_xmit, .ndo_start_xmit = nfp_repr_xmit,
.ndo_get_stats64 = nfp_flower_repr_netdev_get_stats64, .ndo_get_stats64 = nfp_repr_get_stats64,
.ndo_has_offload_stats = nfp_repr_has_offload_stats, .ndo_has_offload_stats = nfp_repr_has_offload_stats,
.ndo_get_offload_stats = nfp_repr_get_offload_stats, .ndo_get_offload_stats = nfp_repr_get_offload_stats,
}; };
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <net/dst_metadata.h> #include <net/dst_metadata.h>
#include "nfpcore/nfp_cpp.h" #include "nfpcore/nfp_cpp.h"
#include "nfpcore/nfp_nsp.h"
#include "nfp_app.h" #include "nfp_app.h"
#include "nfp_main.h" #include "nfp_main.h"
#include "nfp_net_ctrl.h" #include "nfp_net_ctrl.h"
...@@ -136,18 +137,27 @@ nfp_repr_pf_get_stats64(const struct nfp_app *app, u8 pf, ...@@ -136,18 +137,27 @@ nfp_repr_pf_get_stats64(const struct nfp_app *app, u8 pf,
} }
void void
nfp_repr_get_stats64(const struct nfp_app *app, enum nfp_repr_type type, nfp_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
u8 port, struct rtnl_link_stats64 *stats)
{ {
switch (type) { struct nfp_repr *repr = netdev_priv(netdev);
case NFP_REPR_TYPE_PHYS_PORT: struct nfp_eth_table_port *eth_port;
nfp_repr_phy_port_get_stats64(app, port, stats); struct nfp_app *app = repr->app;
if (WARN_ON(!repr->port))
return;
switch (repr->port->type) {
case NFP_PORT_PHYS_PORT:
eth_port = __nfp_port_get_eth_port(repr->port);
if (!eth_port)
break;
nfp_repr_phy_port_get_stats64(app, eth_port->index, stats);
break; break;
case NFP_REPR_TYPE_PF: case NFP_PORT_PF_PORT:
nfp_repr_pf_get_stats64(app, port, stats); nfp_repr_pf_get_stats64(app, repr->port->pf_id, stats);
break; break;
case NFP_REPR_TYPE_VF: case NFP_PORT_VF_PORT:
nfp_repr_vf_get_stats64(app, port, stats); nfp_repr_vf_get_stats64(app, repr->port->vf_id, stats);
default: default:
break; break;
} }
......
...@@ -99,8 +99,8 @@ enum nfp_repr_type { ...@@ -99,8 +99,8 @@ enum nfp_repr_type {
void nfp_repr_inc_rx_stats(struct net_device *netdev, unsigned int len); void nfp_repr_inc_rx_stats(struct net_device *netdev, unsigned int len);
void void
nfp_repr_get_stats64(const struct nfp_app *app, enum nfp_repr_type type, nfp_repr_get_stats64(struct net_device *netdev,
u8 port, struct rtnl_link_stats64 *stats); struct rtnl_link_stats64 *stats);
bool nfp_repr_has_offload_stats(const struct net_device *dev, int attr_id); bool nfp_repr_has_offload_stats(const struct net_device *dev, int attr_id);
int nfp_repr_get_offload_stats(int attr_id, const struct net_device *dev, int nfp_repr_get_offload_stats(int attr_id, const struct net_device *dev,
void *stats); void *stats);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment