51
51
#include <net/addrconf.h>
52
52
#include <linux/inetdevice.h>
53
53
#include <rdma/ib_cache.h>
54
+ #include <linux/pci.h>
54
55
55
56
#define DRV_VERSION "1.0.0"
56
57
@@ -1590,11 +1591,67 @@ void ipoib_dev_cleanup(struct net_device *dev)
1590
1591
priv -> tx_ring = NULL ;
1591
1592
}
1592
1593
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
+
1593
1634
static const struct header_ops ipoib_header_ops = {
1594
1635
.create = ipoib_hard_header ,
1595
1636
};
1596
1637
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 = {
1598
1655
.ndo_uninit = ipoib_uninit ,
1599
1656
.ndo_open = ipoib_open ,
1600
1657
.ndo_stop = ipoib_stop ,
@@ -1610,7 +1667,11 @@ void ipoib_setup(struct net_device *dev)
1610
1667
{
1611
1668
struct ipoib_dev_priv * priv = netdev_priv (dev );
1612
1669
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
+
1614
1675
dev -> header_ops = & ipoib_header_ops ;
1615
1676
1616
1677
ipoib_set_ethtool_ops (dev );
0 commit comments