Skip to content

Commit ef0ec67

Browse files
Jakub Kicinskidavem330
authored andcommitted
nfp: add pointer to vNIC config memory to nfp_port structure
Simplify the statistics handling code by keeping pointer to vNIC's config memory in nfp_port. Note that this is referring to the representor side of vNICs, vNIC side has the pointer in nfp_net. 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 098ce84 commit ef0ec67

File tree

3 files changed

+18
-37
lines changed

3 files changed

+18
-37
lines changed

drivers/net/ethernet/netronome/nfp/flower/main.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,18 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app,
159159
goto err_reprs_clean;
160160
}
161161

162+
/* For now we only support 1 PF */
163+
WARN_ON(repr_type == NFP_REPR_TYPE_PF && i);
164+
162165
port = nfp_port_alloc(app, port_type, reprs->reprs[i]);
163166
if (repr_type == NFP_REPR_TYPE_PF) {
164167
port->pf_id = i;
168+
port->vnic = priv->nn->dp.ctrl_bar;
165169
} else {
166-
port->pf_id = 0; /* For now we only support 1 PF */
170+
port->pf_id = 0;
167171
port->vf_id = i;
172+
port->vnic =
173+
app->pf->vf_cfg_mem + i * NFP_NET_CFG_BAR_SZ;
168174
}
169175

170176
eth_hw_addr_random(reprs->reprs[i]);

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

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -96,50 +96,25 @@ nfp_repr_phy_port_get_stats64(struct nfp_port *port,
9696
}
9797

9898
static void
99-
nfp_repr_vf_get_stats64(const struct nfp_app *app, u8 vf,
100-
struct rtnl_link_stats64 *stats)
99+
nfp_repr_vnic_get_stats64(struct nfp_port *port,
100+
struct rtnl_link_stats64 *stats)
101101
{
102-
u8 __iomem *mem;
103-
104-
mem = app->pf->vf_cfg_mem + vf * NFP_NET_CFG_BAR_SZ;
105-
106102
/* TX and RX stats are flipped as we are returning the stats as seen
107103
* at the switch port corresponding to the VF.
108104
*/
109-
stats->tx_packets = readq(mem + NFP_NET_CFG_STATS_RX_FRAMES);
110-
stats->tx_bytes = readq(mem + NFP_NET_CFG_STATS_RX_OCTETS);
111-
stats->tx_dropped = readq(mem + NFP_NET_CFG_STATS_RX_DISCARDS);
105+
stats->tx_packets = readq(port->vnic + NFP_NET_CFG_STATS_RX_FRAMES);
106+
stats->tx_bytes = readq(port->vnic + NFP_NET_CFG_STATS_RX_OCTETS);
107+
stats->tx_dropped = readq(port->vnic + NFP_NET_CFG_STATS_RX_DISCARDS);
112108

113-
stats->rx_packets = readq(mem + NFP_NET_CFG_STATS_TX_FRAMES);
114-
stats->rx_bytes = readq(mem + NFP_NET_CFG_STATS_TX_OCTETS);
115-
stats->rx_dropped = readq(mem + NFP_NET_CFG_STATS_TX_DISCARDS);
116-
}
117-
118-
static void
119-
nfp_repr_pf_get_stats64(const struct nfp_app *app, u8 pf,
120-
struct rtnl_link_stats64 *stats)
121-
{
122-
u8 __iomem *mem;
123-
124-
if (pf)
125-
return;
126-
127-
mem = nfp_cpp_area_iomem(app->pf->data_vnic_bar);
128-
129-
stats->tx_packets = readq(mem + NFP_NET_CFG_STATS_RX_FRAMES);
130-
stats->tx_bytes = readq(mem + NFP_NET_CFG_STATS_RX_OCTETS);
131-
stats->tx_dropped = readq(mem + NFP_NET_CFG_STATS_RX_DISCARDS);
132-
133-
stats->rx_packets = readq(mem + NFP_NET_CFG_STATS_TX_FRAMES);
134-
stats->rx_bytes = readq(mem + NFP_NET_CFG_STATS_TX_OCTETS);
135-
stats->rx_dropped = readq(mem + NFP_NET_CFG_STATS_TX_DISCARDS);
109+
stats->rx_packets = readq(port->vnic + NFP_NET_CFG_STATS_TX_FRAMES);
110+
stats->rx_bytes = readq(port->vnic + NFP_NET_CFG_STATS_TX_OCTETS);
111+
stats->rx_dropped = readq(port->vnic + NFP_NET_CFG_STATS_TX_DISCARDS);
136112
}
137113

138114
static void
139115
nfp_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
140116
{
141117
struct nfp_repr *repr = netdev_priv(netdev);
142-
struct nfp_app *app = repr->app;
143118

144119
if (WARN_ON(!repr->port))
145120
return;
@@ -151,10 +126,8 @@ nfp_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
151126
nfp_repr_phy_port_get_stats64(repr->port, stats);
152127
break;
153128
case NFP_PORT_PF_PORT:
154-
nfp_repr_pf_get_stats64(app, repr->port->pf_id, stats);
155-
break;
156129
case NFP_PORT_VF_PORT:
157-
nfp_repr_vf_get_stats64(app, repr->port->vf_id, stats);
130+
nfp_repr_vnic_get_stats64(repr->port, stats);
158131
default:
159132
break;
160133
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ enum nfp_port_flags {
7979
* @eth_stats: for %NFP_PORT_PHYS_PORT MAC stats if available
8080
* @pf_id: for %NFP_PORT_PF_PORT, %NFP_PORT_VF_PORT ID of the PCI PF (0-3)
8181
* @vf_id: for %NFP_PORT_VF_PORT ID of the PCI VF within @pf_id
82+
* @vnic: for %NFP_PORT_PF_PORT, %NFP_PORT_VF_PORT vNIC ctrl memory
8283
* @port_list: entry on pf's list of ports
8384
*/
8485
struct nfp_port {
@@ -102,6 +103,7 @@ struct nfp_port {
102103
struct {
103104
unsigned int pf_id;
104105
unsigned int vf_id;
106+
u8 __iomem *vnic;
105107
};
106108
};
107109

0 commit comments

Comments
 (0)