Skip to content

Commit 5194947

Browse files
leitaorleon
authored andcommitted
IB/hfi1: Do not use custom stat allocator
With commit 34d21de ("net: Move {l,t,d}stats allocation to core and convert veth & vrf"), stats allocation could be done on net core instead of in this driver. With this new approach, the driver doesn't have to bother with error handling (allocation failure checking, making sure free happens in the right spot, etc). This is core responsibility now. Remove the allocation in the hfi1 driver and leverage the network core allocation instead. Signed-off-by: Breno Leitao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 8f3b710 commit 5194947

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

drivers/infiniband/hw/hfi1/ipoib_main.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,25 @@ static int hfi1_ipoib_dev_init(struct net_device *dev)
2121
struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev);
2222
int ret;
2323

24-
dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
25-
if (!dev->tstats)
26-
return -ENOMEM;
27-
2824
ret = priv->netdev_ops->ndo_init(dev);
2925
if (ret)
30-
goto out_ret;
26+
return ret;
3127

3228
ret = hfi1_netdev_add_data(priv->dd,
3329
qpn_from_mac(priv->netdev->dev_addr),
3430
dev);
3531
if (ret < 0) {
3632
priv->netdev_ops->ndo_uninit(dev);
37-
goto out_ret;
33+
return ret;
3834
}
3935

4036
return 0;
41-
out_ret:
42-
free_percpu(dev->tstats);
43-
dev->tstats = NULL;
44-
return ret;
4537
}
4638

4739
static void hfi1_ipoib_dev_uninit(struct net_device *dev)
4840
{
4941
struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev);
5042

51-
free_percpu(dev->tstats);
52-
dev->tstats = NULL;
53-
5443
hfi1_netdev_remove_data(priv->dd, qpn_from_mac(priv->netdev->dev_addr));
5544

5645
priv->netdev_ops->ndo_uninit(dev);
@@ -173,9 +162,6 @@ static void hfi1_ipoib_netdev_dtor(struct net_device *dev)
173162

174163
hfi1_ipoib_txreq_deinit(priv);
175164
hfi1_ipoib_rxq_deinit(priv->netdev);
176-
177-
free_percpu(dev->tstats);
178-
dev->tstats = NULL;
179165
}
180166

181167
static void hfi1_ipoib_set_id(struct net_device *dev, int id)
@@ -234,6 +220,7 @@ static int hfi1_ipoib_setup_rn(struct ib_device *device,
234220

235221
netdev->priv_destructor = hfi1_ipoib_netdev_dtor;
236222
netdev->needs_free_netdev = true;
223+
netdev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
237224

238225
return 0;
239226
}

0 commit comments

Comments
 (0)