Skip to content

Commit 9c3c5f8

Browse files
Eli Cohendledford
authored andcommitted
IB/ipoib: Add ndo operations for configuring VFs
Add ndo operations to the network driver that enables configuring the following operations: ipoib_set_vf_link_state - configure the VF link policy ipoib_get_vf_config - get link state configuration ipoib_set_vf_guid - set a VF port or node GUID ipoib_get_vf_stats - get statistics of a VF Signed-off-by: Eli Cohen <eli@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 50174a7 commit 9c3c5f8

File tree

1 file changed

+63
-2
lines changed

1 file changed

+63
-2
lines changed

drivers/infiniband/ulp/ipoib/ipoib_main.c

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <net/addrconf.h>
5252
#include <linux/inetdevice.h>
5353
#include <rdma/ib_cache.h>
54+
#include <linux/pci.h>
5455

5556
#define DRV_VERSION "1.0.0"
5657

@@ -1590,11 +1591,67 @@ void ipoib_dev_cleanup(struct net_device *dev)
15901591
priv->tx_ring = NULL;
15911592
}
15921593

1594+
static int ipoib_set_vf_link_state(struct net_device *dev, int vf, int link_state)
1595+
{
1596+
struct ipoib_dev_priv *priv = netdev_priv(dev);
1597+
1598+
return ib_set_vf_link_state(priv->ca, vf, priv->port, link_state);
1599+
}
1600+
1601+
static int ipoib_get_vf_config(struct net_device *dev, int vf,
1602+
struct ifla_vf_info *ivf)
1603+
{
1604+
struct ipoib_dev_priv *priv = netdev_priv(dev);
1605+
int err;
1606+
1607+
err = ib_get_vf_config(priv->ca, vf, priv->port, ivf);
1608+
if (err)
1609+
return err;
1610+
1611+
ivf->vf = vf;
1612+
1613+
return 0;
1614+
}
1615+
1616+
static int ipoib_set_vf_guid(struct net_device *dev, int vf, u64 guid, int type)
1617+
{
1618+
struct ipoib_dev_priv *priv = netdev_priv(dev);
1619+
1620+
if (type != IFLA_VF_IB_NODE_GUID && type != IFLA_VF_IB_PORT_GUID)
1621+
return -EINVAL;
1622+
1623+
return ib_set_vf_guid(priv->ca, vf, priv->port, guid, type);
1624+
}
1625+
1626+
static int ipoib_get_vf_stats(struct net_device *dev, int vf,
1627+
struct ifla_vf_stats *vf_stats)
1628+
{
1629+
struct ipoib_dev_priv *priv = netdev_priv(dev);
1630+
1631+
return ib_get_vf_stats(priv->ca, vf, priv->port, vf_stats);
1632+
}
1633+
15931634
static const struct header_ops ipoib_header_ops = {
15941635
.create = ipoib_hard_header,
15951636
};
15961637

1597-
static const struct net_device_ops ipoib_netdev_ops = {
1638+
static const struct net_device_ops ipoib_netdev_ops_pf = {
1639+
.ndo_uninit = ipoib_uninit,
1640+
.ndo_open = ipoib_open,
1641+
.ndo_stop = ipoib_stop,
1642+
.ndo_change_mtu = ipoib_change_mtu,
1643+
.ndo_fix_features = ipoib_fix_features,
1644+
.ndo_start_xmit = ipoib_start_xmit,
1645+
.ndo_tx_timeout = ipoib_timeout,
1646+
.ndo_set_rx_mode = ipoib_set_mcast_list,
1647+
.ndo_get_iflink = ipoib_get_iflink,
1648+
.ndo_set_vf_link_state = ipoib_set_vf_link_state,
1649+
.ndo_get_vf_config = ipoib_get_vf_config,
1650+
.ndo_get_vf_stats = ipoib_get_vf_stats,
1651+
.ndo_set_vf_guid = ipoib_set_vf_guid,
1652+
};
1653+
1654+
static const struct net_device_ops ipoib_netdev_ops_vf = {
15981655
.ndo_uninit = ipoib_uninit,
15991656
.ndo_open = ipoib_open,
16001657
.ndo_stop = ipoib_stop,
@@ -1610,7 +1667,11 @@ void ipoib_setup(struct net_device *dev)
16101667
{
16111668
struct ipoib_dev_priv *priv = netdev_priv(dev);
16121669

1613-
dev->netdev_ops = &ipoib_netdev_ops;
1670+
if (priv->hca_caps & IB_DEVICE_VIRTUAL_FUNCTION)
1671+
dev->netdev_ops = &ipoib_netdev_ops_vf;
1672+
else
1673+
dev->netdev_ops = &ipoib_netdev_ops_pf;
1674+
16141675
dev->header_ops = &ipoib_header_ops;
16151676

16161677
ipoib_set_ethtool_ops(dev);

0 commit comments

Comments
 (0)