summaryrefslogtreecommitdiff
path: root/patches/collateral-evolutions/network/0043-ndo_set_vf_rate/igb.patch
blob: daa85b539d44f059ecfa92ae21e1d50580a4236b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -177,7 +177,11 @@ static void igb_restore_vf_multicasts(st
 static int igb_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac);
 static int igb_ndo_set_vf_vlan(struct net_device *netdev,
 			       int vf, u16 vlan, u8 qos);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
 static int igb_ndo_set_vf_bw(struct net_device *, int, int, int);
+#else
+static int igb_ndo_set_vf_bw(struct net_device *, int, int);
+#endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
 static int igb_ndo_set_vf_spoofchk(struct net_device *netdev, int vf,
 				   bool setting);
@@ -2104,7 +2108,11 @@ static const struct net_device_ops igb_n
 	.ndo_vlan_rx_kill_vid	= igb_vlan_rx_kill_vid,
 	.ndo_set_vf_mac		= igb_ndo_set_vf_mac,
 	.ndo_set_vf_vlan	= igb_ndo_set_vf_vlan,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
 	.ndo_set_vf_rate	= igb_ndo_set_vf_bw,
+#else
+	.ndo_set_vf_tx_rate	= igb_ndo_set_vf_bw,
+#endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
 	.ndo_set_vf_spoofchk	= igb_ndo_set_vf_spoofchk,
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */
@@ -7931,8 +7939,12 @@ static void igb_check_vf_rate_limit(stru
 	}
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
 static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf,
 			     int min_tx_rate, int max_tx_rate)
+#else
+static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate)
+#endif
 {
 	struct igb_adapter *adapter = netdev_priv(netdev);
 	struct e1000_hw *hw = &adapter->hw;
@@ -7941,6 +7953,7 @@ static int igb_ndo_set_vf_bw(struct net_
 	if (hw->mac.type != e1000_82576)
 		return -EOPNOTSUPP;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
 	if (min_tx_rate)
 		return -EINVAL;
 
@@ -7954,7 +7967,17 @@ static int igb_ndo_set_vf_bw(struct net_
 	adapter->vf_rate_link_speed = actual_link_speed;
 	adapter->vf_data[vf].tx_rate = (u16)max_tx_rate;
 	igb_set_vf_rate_limit(hw, vf, max_tx_rate, actual_link_speed);
+#else
+	actual_link_speed = igb_link_mbps(adapter->link_speed);
+	if ((vf >= adapter->vfs_allocated_count) ||
+	    (!(rd32(E1000_STATUS) & E1000_STATUS_LU)) ||
+	    (tx_rate < 0) || (tx_rate > actual_link_speed))
+		return -EINVAL;
 
+	adapter->vf_rate_link_speed = actual_link_speed;
+	adapter->vf_data[vf].tx_rate = (u16)tx_rate;
+	igb_set_vf_rate_limit(hw, vf, tx_rate, actual_link_speed);
+#endif
 	return 0;
 }
 
@@ -7995,8 +8018,12 @@ static int igb_ndo_get_vf_config(struct
 		return -EINVAL;
 	ivi->vf = vf;
 	memcpy(&ivi->mac, adapter->vf_data[vf].vf_mac_addresses, ETH_ALEN);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
 	ivi->max_tx_rate = adapter->vf_data[vf].tx_rate;
 	ivi->min_tx_rate = 0;
+#else
+	ivi->tx_rate = adapter->vf_data[vf].tx_rate;
+#endif
 	ivi->vlan = adapter->vf_data[vf].pf_vlan;
 	ivi->qos = adapter->vf_data[vf].pf_qos;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)