提交 aa0616a9 编写于 作者: H Heiner Kallweit 提交者: Jakub Kicinski

IB/hfi1: switch to core handling of rx/tx byte/packet counters

Use netdev->tstats instead of a member of hfi1_ipoib_dev_priv for storing
a pointer to the per-cpu counters. This allows us to use core
functionality for statistics handling.
Signed-off-by: NHeiner Kallweit <hkallweit1@gmail.com>
Acked-by: NJason Gunthorpe <jgg@nvidia.com>
Signed-off-by: NJakub Kicinski <kuba@kernel.org>
上级 c9f64d1f
...@@ -1686,7 +1686,6 @@ static void hfi1_ipoib_ib_rcv(struct hfi1_packet *packet) ...@@ -1686,7 +1686,6 @@ static void hfi1_ipoib_ib_rcv(struct hfi1_packet *packet)
u32 extra_bytes; u32 extra_bytes;
u32 tlen, qpnum; u32 tlen, qpnum;
bool do_work, do_cnp; bool do_work, do_cnp;
struct hfi1_ipoib_dev_priv *priv;
trace_hfi1_rcvhdr(packet); trace_hfi1_rcvhdr(packet);
...@@ -1734,8 +1733,7 @@ static void hfi1_ipoib_ib_rcv(struct hfi1_packet *packet) ...@@ -1734,8 +1733,7 @@ static void hfi1_ipoib_ib_rcv(struct hfi1_packet *packet)
if (unlikely(!skb)) if (unlikely(!skb))
goto drop; goto drop;
priv = hfi1_ipoib_priv(netdev); dev_sw_netstats_rx_add(netdev, skb->len);
hfi1_ipoib_update_rx_netstats(priv, 1, skb->len);
skb->dev = netdev; skb->dev = netdev;
skb->pkt_type = PACKET_HOST; skb->pkt_type = PACKET_HOST;
......
...@@ -110,7 +110,6 @@ struct hfi1_ipoib_dev_priv { ...@@ -110,7 +110,6 @@ struct hfi1_ipoib_dev_priv {
const struct net_device_ops *netdev_ops; const struct net_device_ops *netdev_ops;
struct rvt_qp *qp; struct rvt_qp *qp;
struct pcpu_sw_netstats __percpu *netstats;
}; };
/* hfi1 ipoib rdma netdev's private data structure */ /* hfi1 ipoib rdma netdev's private data structure */
...@@ -126,32 +125,6 @@ hfi1_ipoib_priv(const struct net_device *dev) ...@@ -126,32 +125,6 @@ hfi1_ipoib_priv(const struct net_device *dev)
return &((struct hfi1_ipoib_rdma_netdev *)netdev_priv(dev))->dev_priv; return &((struct hfi1_ipoib_rdma_netdev *)netdev_priv(dev))->dev_priv;
} }
static inline void
hfi1_ipoib_update_rx_netstats(struct hfi1_ipoib_dev_priv *priv,
u64 packets,
u64 bytes)
{
struct pcpu_sw_netstats *netstats = this_cpu_ptr(priv->netstats);
u64_stats_update_begin(&netstats->syncp);
netstats->rx_packets += packets;
netstats->rx_bytes += bytes;
u64_stats_update_end(&netstats->syncp);
}
static inline void
hfi1_ipoib_update_tx_netstats(struct hfi1_ipoib_dev_priv *priv,
u64 packets,
u64 bytes)
{
struct pcpu_sw_netstats *netstats = this_cpu_ptr(priv->netstats);
u64_stats_update_begin(&netstats->syncp);
netstats->tx_packets += packets;
netstats->tx_bytes += bytes;
u64_stats_update_end(&netstats->syncp);
}
int hfi1_ipoib_send_dma(struct net_device *dev, int hfi1_ipoib_send_dma(struct net_device *dev,
struct sk_buff *skb, struct sk_buff *skb,
struct ib_ah *address, struct ib_ah *address,
......
...@@ -21,7 +21,7 @@ static int hfi1_ipoib_dev_init(struct net_device *dev) ...@@ -21,7 +21,7 @@ static int hfi1_ipoib_dev_init(struct net_device *dev)
struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev); struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev);
int ret; int ret;
priv->netstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
ret = priv->netdev_ops->ndo_init(dev); ret = priv->netdev_ops->ndo_init(dev);
if (ret) if (ret)
...@@ -93,21 +93,12 @@ static int hfi1_ipoib_dev_stop(struct net_device *dev) ...@@ -93,21 +93,12 @@ static int hfi1_ipoib_dev_stop(struct net_device *dev)
return priv->netdev_ops->ndo_stop(dev); return priv->netdev_ops->ndo_stop(dev);
} }
static void hfi1_ipoib_dev_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *storage)
{
struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev);
netdev_stats_to_stats64(storage, &dev->stats);
dev_fetch_sw_netstats(storage, priv->netstats);
}
static const struct net_device_ops hfi1_ipoib_netdev_ops = { static const struct net_device_ops hfi1_ipoib_netdev_ops = {
.ndo_init = hfi1_ipoib_dev_init, .ndo_init = hfi1_ipoib_dev_init,
.ndo_uninit = hfi1_ipoib_dev_uninit, .ndo_uninit = hfi1_ipoib_dev_uninit,
.ndo_open = hfi1_ipoib_dev_open, .ndo_open = hfi1_ipoib_dev_open,
.ndo_stop = hfi1_ipoib_dev_stop, .ndo_stop = hfi1_ipoib_dev_stop,
.ndo_get_stats64 = hfi1_ipoib_dev_get_stats64, .ndo_get_stats64 = dev_get_tstats64,
}; };
static int hfi1_ipoib_send(struct net_device *dev, static int hfi1_ipoib_send(struct net_device *dev,
...@@ -182,7 +173,7 @@ static void hfi1_ipoib_netdev_dtor(struct net_device *dev) ...@@ -182,7 +173,7 @@ static void hfi1_ipoib_netdev_dtor(struct net_device *dev)
hfi1_ipoib_txreq_deinit(priv); hfi1_ipoib_txreq_deinit(priv);
hfi1_ipoib_rxq_deinit(priv->netdev); hfi1_ipoib_rxq_deinit(priv->netdev);
free_percpu(priv->netstats); free_percpu(dev->tstats);
} }
static void hfi1_ipoib_free_rdma_netdev(struct net_device *dev) static void hfi1_ipoib_free_rdma_netdev(struct net_device *dev)
......
...@@ -121,7 +121,7 @@ static void hfi1_ipoib_free_tx(struct ipoib_txreq *tx, int budget) ...@@ -121,7 +121,7 @@ static void hfi1_ipoib_free_tx(struct ipoib_txreq *tx, int budget)
struct hfi1_ipoib_dev_priv *priv = tx->priv; struct hfi1_ipoib_dev_priv *priv = tx->priv;
if (likely(!tx->sdma_status)) { if (likely(!tx->sdma_status)) {
hfi1_ipoib_update_tx_netstats(priv, 1, tx->skb->len); dev_sw_netstats_tx_add(priv->netdev, 1, tx->skb->len);
} else { } else {
++priv->netdev->stats.tx_errors; ++priv->netdev->stats.tx_errors;
dd_dev_warn(priv->dd, dd_dev_warn(priv->dd,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册