aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-02-16 15:30:29 -0500
committerDavid S. Miller <davem@davemloft.net>2016-02-16 15:30:29 -0500
commit31d035a0d323d34acbab1b9cc250b443c5c02297 (patch)
treeee6bf17571a85541998327bae47bc83d2ed45033
parent9a14b1c26140492550d694c012fbe70530a4216b (diff)
parentbf456abb9b82d5376e7189cca00b528dd86d1559 (diff)
Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue
Jeff Kirsher says: ==================== 1GbE Intel Wired LAN Driver Updates 2016-02-15 This series contains updates to igb only. Shota Suzuki cleans up unnecessary flag setting for 82576 in igb_set_flag_queue_pairs() since the default block already sets IGB_FLAG_QUEUE_PAIRS to the correct value anyways, so the e1000_82576 code block is not necessary and we can simply fall through. Then fixes an issue where IGB_FLAG_QUEUE_PAIRS can now be set by using "ethtool -L" option but is never cleared unless the driver is reloaded, so clear the queue pairing if the pairing becomes unnecessary as a result of "ethtool -L". Mitch fixes the igbvf from giving up if it fails to get the hardware mailbox lock. This can happen when the PF-VF communication channel is heavily loaded and causes complete communications failure between the PF and VF drivers, so add a counter and a delay so that the driver will now retry ten times before giving up on getting the mailbox lock. The remaining patches in the series are from Alex Duyck, starting with the cleaning up code that sets the MAC address. Then refactors the VFTA and VLVF configuration, to simplify and update to similar setups in the ixgbe driver. Fixed an issue were VLANs headers size was being added to the value programmed into the RLPML registers, yet these registers already take into account the size of the VLAN headers when determining the maximum packet length, so we can drop the code that adds the size to the RLPML registers. Cleaned up the configuration of the VF port based VLAN configuration. Also fixed the igb driver so that we can fully support SR-IOV or the recently added NTUPLE filtering while allowing support for VLAN promiscuous mode. Also added the ability to use the bridge utility to add a FDB entry for the PF to an igb port. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_82575.c39
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_defines.h3
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_hw.h2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_mac.c213
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_mac.h5
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_mbx.c18
-rw-r--r--drivers/net/ethernet/intel/igb/igb.h2
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c774
-rw-r--r--drivers/net/ethernet/intel/igbvf/mbx.c20
9 files changed, 637 insertions, 439 deletions
diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
index adb33e2a0137..9a1a9c7b0748 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -34,6 +34,7 @@
34#include "e1000_mac.h" 34#include "e1000_mac.h"
35#include "e1000_82575.h" 35#include "e1000_82575.h"
36#include "e1000_i210.h" 36#include "e1000_i210.h"
37#include "igb.h"
37 38
38static s32 igb_get_invariants_82575(struct e1000_hw *); 39static s32 igb_get_invariants_82575(struct e1000_hw *);
39static s32 igb_acquire_phy_82575(struct e1000_hw *); 40static s32 igb_acquire_phy_82575(struct e1000_hw *);
@@ -71,6 +72,32 @@ static s32 igb_update_nvm_checksum_i350(struct e1000_hw *hw);
71static const u16 e1000_82580_rxpbs_table[] = { 72static const u16 e1000_82580_rxpbs_table[] = {
72 36, 72, 144, 1, 2, 4, 8, 16, 35, 70, 140 }; 73 36, 72, 144, 1, 2, 4, 8, 16, 35, 70, 140 };
73 74
75/* Due to a hw errata, if the host tries to configure the VFTA register
76 * while performing queries from the BMC or DMA, then the VFTA in some
77 * cases won't be written.
78 */
79
80/**
81 * igb_write_vfta_i350 - Write value to VLAN filter table
82 * @hw: pointer to the HW structure
83 * @offset: register offset in VLAN filter table
84 * @value: register value written to VLAN filter table
85 *
86 * Writes value at the given offset in the register array which stores
87 * the VLAN filter table.
88 **/
89static void igb_write_vfta_i350(struct e1000_hw *hw, u32 offset, u32 value)
90{
91 struct igb_adapter *adapter = hw->back;
92 int i;
93
94 for (i = 10; i--;)
95 array_wr32(E1000_VFTA, offset, value);
96
97 wrfl();
98 adapter->shadow_vfta[offset] = value;
99}
100
74/** 101/**
75 * igb_sgmii_uses_mdio_82575 - Determine if I2C pins are for external MDIO 102 * igb_sgmii_uses_mdio_82575 - Determine if I2C pins are for external MDIO
76 * @hw: pointer to the HW structure 103 * @hw: pointer to the HW structure
@@ -398,6 +425,8 @@ static s32 igb_init_mac_params_82575(struct e1000_hw *hw)
398 425
399 /* Set mta register count */ 426 /* Set mta register count */
400 mac->mta_reg_count = 128; 427 mac->mta_reg_count = 128;
428 /* Set uta register count */
429 mac->uta_reg_count = (hw->mac.type == e1000_82575) ? 0 : 128;
401 /* Set rar entry count */ 430 /* Set rar entry count */
402 switch (mac->type) { 431 switch (mac->type) {
403 case e1000_82576: 432 case e1000_82576:
@@ -429,6 +458,11 @@ static s32 igb_init_mac_params_82575(struct e1000_hw *hw)
429 mac->ops.release_swfw_sync = igb_release_swfw_sync_82575; 458 mac->ops.release_swfw_sync = igb_release_swfw_sync_82575;
430 } 459 }
431 460
461 if ((hw->mac.type == e1000_i350) || (hw->mac.type == e1000_i354))
462 mac->ops.write_vfta = igb_write_vfta_i350;
463 else
464 mac->ops.write_vfta = igb_write_vfta;
465
432 /* Set if part includes ASF firmware */ 466 /* Set if part includes ASF firmware */
433 mac->asf_firmware_present = true; 467 mac->asf_firmware_present = true;
434 /* Set if manageability features are enabled. */ 468 /* Set if manageability features are enabled. */
@@ -1517,10 +1551,7 @@ static s32 igb_init_hw_82575(struct e1000_hw *hw)
1517 1551
1518 /* Disabling VLAN filtering */ 1552 /* Disabling VLAN filtering */
1519 hw_dbg("Initializing the IEEE VLAN\n"); 1553 hw_dbg("Initializing the IEEE VLAN\n");
1520 if ((hw->mac.type == e1000_i350) || (hw->mac.type == e1000_i354)) 1554 igb_clear_vfta(hw);
1521 igb_clear_vfta_i350(hw);
1522 else
1523 igb_clear_vfta(hw);
1524 1555
1525 /* Setup the receive address */ 1556 /* Setup the receive address */
1526 igb_init_rx_addrs(hw, rar_count); 1557 igb_init_rx_addrs(hw, rar_count);
diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h
index c3c598c347a9..e9f23ee8f15e 100644
--- a/drivers/net/ethernet/intel/igb/e1000_defines.h
+++ b/drivers/net/ethernet/intel/igb/e1000_defines.h
@@ -356,7 +356,8 @@
356/* Ethertype field values */ 356/* Ethertype field values */
357#define ETHERNET_IEEE_VLAN_TYPE 0x8100 /* 802.3ac packet */ 357#define ETHERNET_IEEE_VLAN_TYPE 0x8100 /* 802.3ac packet */
358 358
359#define MAX_JUMBO_FRAME_SIZE 0x3F00 359/* As per the EAS the maximum supported size is 9.5KB (9728 bytes) */
360#define MAX_JUMBO_FRAME_SIZE 0x2600
360 361
361/* PBA constants */ 362/* PBA constants */
362#define E1000_PBA_34K 0x0022 363#define E1000_PBA_34K 0x0022
diff --git a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h
index 4034207eb5cc..f0c416e21d2c 100644
--- a/drivers/net/ethernet/intel/igb/e1000_hw.h
+++ b/drivers/net/ethernet/intel/igb/e1000_hw.h
@@ -325,7 +325,7 @@ struct e1000_mac_operations {
325 s32 (*get_thermal_sensor_data)(struct e1000_hw *); 325 s32 (*get_thermal_sensor_data)(struct e1000_hw *);
326 s32 (*init_thermal_sensor_thresh)(struct e1000_hw *); 326 s32 (*init_thermal_sensor_thresh)(struct e1000_hw *);
327#endif 327#endif
328 328 void (*write_vfta)(struct e1000_hw *, u32, u32);
329}; 329};
330 330
331struct e1000_phy_operations { 331struct e1000_phy_operations {
diff --git a/drivers/net/ethernet/intel/igb/e1000_mac.c b/drivers/net/ethernet/intel/igb/e1000_mac.c
index 2a88595f956c..07cf4fe58338 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mac.c
+++ b/drivers/net/ethernet/intel/igb/e1000_mac.c
@@ -92,10 +92,8 @@ void igb_clear_vfta(struct e1000_hw *hw)
92{ 92{
93 u32 offset; 93 u32 offset;
94 94
95 for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) { 95 for (offset = E1000_VLAN_FILTER_TBL_SIZE; offset--;)
96 array_wr32(E1000_VFTA, offset, 0); 96 hw->mac.ops.write_vfta(hw, offset, 0);
97 wrfl();
98 }
99} 97}
100 98
101/** 99/**
@@ -107,54 +105,14 @@ void igb_clear_vfta(struct e1000_hw *hw)
107 * Writes value at the given offset in the register array which stores 105 * Writes value at the given offset in the register array which stores
108 * the VLAN filter table. 106 * the VLAN filter table.
109 **/ 107 **/
110static void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value) 108void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
111{ 109{
110 struct igb_adapter *adapter = hw->back;
111
112 array_wr32(E1000_VFTA, offset, value); 112 array_wr32(E1000_VFTA, offset, value);
113 wrfl(); 113 wrfl();
114}
115
116/* Due to a hw errata, if the host tries to configure the VFTA register
117 * while performing queries from the BMC or DMA, then the VFTA in some
118 * cases won't be written.
119 */
120 114
121/** 115 adapter->shadow_vfta[offset] = value;
122 * igb_clear_vfta_i350 - Clear VLAN filter table
123 * @hw: pointer to the HW structure
124 *
125 * Clears the register array which contains the VLAN filter table by
126 * setting all the values to 0.
127 **/
128void igb_clear_vfta_i350(struct e1000_hw *hw)
129{
130 u32 offset;
131 int i;
132
133 for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
134 for (i = 0; i < 10; i++)
135 array_wr32(E1000_VFTA, offset, 0);
136
137 wrfl();
138 }
139}
140
141/**
142 * igb_write_vfta_i350 - Write value to VLAN filter table
143 * @hw: pointer to the HW structure
144 * @offset: register offset in VLAN filter table
145 * @value: register value written to VLAN filter table
146 *
147 * Writes value at the given offset in the register array which stores
148 * the VLAN filter table.
149 **/
150static void igb_write_vfta_i350(struct e1000_hw *hw, u32 offset, u32 value)
151{
152 int i;
153
154 for (i = 0; i < 10; i++)
155 array_wr32(E1000_VFTA, offset, value);
156
157 wrfl();
158} 116}
159 117
160/** 118/**
@@ -183,40 +141,155 @@ void igb_init_rx_addrs(struct e1000_hw *hw, u16 rar_count)
183} 141}
184 142
185/** 143/**
144 * igb_find_vlvf_slot - find the VLAN id or the first empty slot
145 * @hw: pointer to hardware structure
146 * @vlan: VLAN id to write to VLAN filter
147 * @vlvf_bypass: skip VLVF if no match is found
148 *
149 * return the VLVF index where this VLAN id should be placed
150 *
151 **/
152static s32 igb_find_vlvf_slot(struct e1000_hw *hw, u32 vlan, bool vlvf_bypass)
153{
154 s32 regindex, first_empty_slot;
155 u32 bits;
156
157 /* short cut the special case */
158 if (vlan == 0)
159 return 0;
160
161 /* if vlvf_bypass is set we don't want to use an empty slot, we
162 * will simply bypass the VLVF if there are no entries present in the
163 * VLVF that contain our VLAN
164 */
165 first_empty_slot = vlvf_bypass ? -E1000_ERR_NO_SPACE : 0;
166
167 /* Search for the VLAN id in the VLVF entries. Save off the first empty
168 * slot found along the way.
169 *
170 * pre-decrement loop covering (IXGBE_VLVF_ENTRIES - 1) .. 1
171 */
172 for (regindex = E1000_VLVF_ARRAY_SIZE; --regindex > 0;) {
173 bits = rd32(E1000_VLVF(regindex)) & E1000_VLVF_VLANID_MASK;
174 if (bits == vlan)
175 return regindex;
176 if (!first_empty_slot && !bits)
177 first_empty_slot = regindex;
178 }
179
180 return first_empty_slot ? : -E1000_ERR_NO_SPACE;
181}
182
183/**
186 * igb_vfta_set - enable or disable vlan in VLAN filter table 184 * igb_vfta_set - enable or disable vlan in VLAN filter table
187 * @hw: pointer to the HW structure 185 * @hw: pointer to the HW structure
188 * @vid: VLAN id to add or remove 186 * @vlan: VLAN id to add or remove
189 * @add: if true add filter, if false remove 187 * @vind: VMDq output index that maps queue to VLAN id
188 * @vlan_on: if true add filter, if false remove
190 * 189 *
191 * Sets or clears a bit in the VLAN filter table array based on VLAN id 190 * Sets or clears a bit in the VLAN filter table array based on VLAN id
192 * and if we are adding or removing the filter 191 * and if we are adding or removing the filter
193 **/ 192 **/
194s32 igb_vfta_set(struct e1000_hw *hw, u32 vid, bool add) 193s32 igb_vfta_set(struct e1000_hw *hw, u32 vlan, u32 vind,
194 bool vlan_on, bool vlvf_bypass)
195{ 195{
196 u32 index = (vid >> E1000_VFTA_ENTRY_SHIFT) & E1000_VFTA_ENTRY_MASK;
197 u32 mask = 1 << (vid & E1000_VFTA_ENTRY_BIT_SHIFT_MASK);
198 u32 vfta;
199 struct igb_adapter *adapter = hw->back; 196 struct igb_adapter *adapter = hw->back;
200 s32 ret_val = 0; 197 u32 regidx, vfta_delta, vfta, bits;
198 s32 vlvf_index;
201 199
202 vfta = adapter->shadow_vfta[index]; 200 if ((vlan > 4095) || (vind > 7))
201 return -E1000_ERR_PARAM;
203 202
204 /* bit was set/cleared before we started */ 203 /* this is a 2 part operation - first the VFTA, then the
205 if ((!!(vfta & mask)) == add) { 204 * VLVF and VLVFB if VT Mode is set
206 ret_val = -E1000_ERR_CONFIG; 205 * We don't write the VFTA until we know the VLVF part succeeded.
207 } else { 206 */
208 if (add) 207
209 vfta |= mask; 208 /* Part 1
210 else 209 * The VFTA is a bitstring made up of 128 32-bit registers
211 vfta &= ~mask; 210 * that enable the particular VLAN id, much like the MTA:
211 * bits[11-5]: which register
212 * bits[4-0]: which bit in the register
213 */
214 regidx = vlan / 32;
215 vfta_delta = 1 << (vlan % 32);
216 vfta = adapter->shadow_vfta[regidx];
217
218 /* vfta_delta represents the difference between the current value
219 * of vfta and the value we want in the register. Since the diff
220 * is an XOR mask we can just update vfta using an XOR.
221 */
222 vfta_delta &= vlan_on ? ~vfta : vfta;
223 vfta ^= vfta_delta;
224
225 /* Part 2
226 * If VT Mode is set
227 * Either vlan_on
228 * make sure the VLAN is in VLVF
229 * set the vind bit in the matching VLVFB
230 * Or !vlan_on
231 * clear the pool bit and possibly the vind
232 */
233 if (!adapter->vfs_allocated_count)
234 goto vfta_update;
235
236 vlvf_index = igb_find_vlvf_slot(hw, vlan, vlvf_bypass);
237 if (vlvf_index < 0) {
238 if (vlvf_bypass)
239 goto vfta_update;
240 return vlvf_index;
212 } 241 }
213 if ((hw->mac.type == e1000_i350) || (hw->mac.type == e1000_i354))
214 igb_write_vfta_i350(hw, index, vfta);
215 else
216 igb_write_vfta(hw, index, vfta);
217 adapter->shadow_vfta[index] = vfta;
218 242
219 return ret_val; 243 bits = rd32(E1000_VLVF(vlvf_index));
244
245 /* set the pool bit */
246 bits |= 1 << (E1000_VLVF_POOLSEL_SHIFT + vind);
247 if (vlan_on)
248 goto vlvf_update;
249
250 /* clear the pool bit */
251 bits ^= 1 << (E1000_VLVF_POOLSEL_SHIFT + vind);
252
253 if (!(bits & E1000_VLVF_POOLSEL_MASK)) {
254 /* Clear VFTA first, then disable VLVF. Otherwise
255 * we run the risk of stray packets leaking into
256 * the PF via the default pool
257 */
258 if (vfta_delta)
259 hw->mac.ops.write_vfta(hw, regidx, vfta);
260
261 /* disable VLVF and clear remaining bit from pool */
262 wr32(E1000_VLVF(vlvf_index), 0);
263
264 return 0;
265 }
266
267 /* If there are still bits set in the VLVFB registers
268 * for the VLAN ID indicated we need to see if the
269 * caller is requesting that we clear the VFTA entry bit.
270 * If the caller has requested that we clear the VFTA
271 * entry bit but there are still pools/VFs using this VLAN
272 * ID entry then ignore the request. We're not worried
273 * about the case where we're turning the VFTA VLAN ID
274 * entry bit on, only when requested to turn it off as
275 * there may be multiple pools and/or VFs using the
276 * VLAN ID entry. In that case we cannot clear the
277 * VFTA bit until all pools/VFs using that VLAN ID have also
278 * been cleared. This will be indicated by "bits" being
279 * zero.
280 */
281 vfta_delta = 0;
282
283vlvf_update:
284 /* record pool change and enable VLAN ID if not already enabled */
285 wr32(E1000_VLVF(vlvf_index), bits | vlan | E1000_VLVF_VLANID_ENABLE);
286
287vfta_update:
288 /* bit was set/cleared before we started */
289 if (vfta_delta)
290 hw->mac.ops.write_vfta(hw, regidx, vfta);
291
292 return 0;
220} 293}
221 294
222/** 295/**
diff --git a/drivers/net/ethernet/intel/igb/e1000_mac.h b/drivers/net/ethernet/intel/igb/e1000_mac.h
index ea24961b0d70..90c8893c3eed 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mac.h
+++ b/drivers/net/ethernet/intel/igb/e1000_mac.h
@@ -56,8 +56,9 @@ s32 igb_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg,
56 56
57void igb_clear_hw_cntrs_base(struct e1000_hw *hw); 57void igb_clear_hw_cntrs_base(struct e1000_hw *hw);
58void igb_clear_vfta(struct e1000_hw *hw); 58void igb_clear_vfta(struct e1000_hw *hw);
59void igb_clear_vfta_i350(struct e1000_hw *hw); 59void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value);
60s32 igb_vfta_set(struct e1000_hw *hw, u32 vid, bool add); 60s32 igb_vfta_set(struct e1000_hw *hw, u32 vid, u32 vind,
61 bool vlan_on, bool vlvf_bypass);
61void igb_config_collision_dist(struct e1000_hw *hw); 62void igb_config_collision_dist(struct e1000_hw *hw);
62void igb_init_rx_addrs(struct e1000_hw *hw, u16 rar_count); 63void igb_init_rx_addrs(struct e1000_hw *hw, u16 rar_count);
63void igb_mta_set(struct e1000_hw *hw, u32 hash_value); 64void igb_mta_set(struct e1000_hw *hw, u32 hash_value);
diff --git a/drivers/net/ethernet/intel/igb/e1000_mbx.c b/drivers/net/ethernet/intel/igb/e1000_mbx.c
index 162cc49345d0..10f5c9e016a9 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mbx.c
+++ b/drivers/net/ethernet/intel/igb/e1000_mbx.c
@@ -322,14 +322,20 @@ static s32 igb_obtain_mbx_lock_pf(struct e1000_hw *hw, u16 vf_number)
322{ 322{
323 s32 ret_val = -E1000_ERR_MBX; 323 s32 ret_val = -E1000_ERR_MBX;
324 u32 p2v_mailbox; 324 u32 p2v_mailbox;
325 int count = 10;
325 326
326 /* Take ownership of the buffer */ 327 do {
327 wr32(E1000_P2VMAILBOX(vf_number), E1000_P2VMAILBOX_PFU); 328 /* Take ownership of the buffer */
329 wr32(E1000_P2VMAILBOX(vf_number), E1000_P2VMAILBOX_PFU);
328 330
329 /* reserve mailbox for vf use */ 331 /* reserve mailbox for vf use */
330 p2v_mailbox = rd32(E1000_P2VMAILBOX(vf_number)); 332 p2v_mailbox = rd32(E1000_P2VMAILBOX(vf_number));
331 if (p2v_mailbox & E1000_P2VMAILBOX_PFU) 333 if (p2v_mailbox & E1000_P2VMAILBOX_PFU) {
332 ret_val = 0; 334 ret_val = 0;
335 break;
336 }
337 udelay(1000);
338 } while (count-- > 0);
333 339
334 return ret_val; 340 return ret_val;
335} 341}
diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
index e3cb93bdb21a..707ae5c297ea 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -95,7 +95,6 @@ struct vf_data_storage {
95 unsigned char vf_mac_addresses[ETH_ALEN]; 95 unsigned char vf_mac_addresses[ETH_ALEN];
96 u16 vf_mc_hashes[IGB_MAX_VF_MC_ENTRIES]; 96 u16 vf_mc_hashes[IGB_MAX_VF_MC_ENTRIES];
97 u16 num_vf_mc_hashes; 97 u16 num_vf_mc_hashes;
98 u16 vlans_enabled;
99 u32 flags; 98 u32 flags;
100 unsigned long last_nack; 99 unsigned long last_nack;
101 u16 pf_vlan; /* When set, guest VLAN config not allowed. */ 100 u16 pf_vlan; /* When set, guest VLAN config not allowed. */
@@ -482,6 +481,7 @@ struct igb_adapter {
482#define IGB_FLAG_MAS_ENABLE (1 << 12) 481#define IGB_FLAG_MAS_ENABLE (1 << 12)
483#define IGB_FLAG_HAS_MSIX (1 << 13) 482#define IGB_FLAG_HAS_MSIX (1 << 13)
484#define IGB_FLAG_EEE (1 << 14) 483#define IGB_FLAG_EEE (1 << 14)
484#define IGB_FLAG_VLAN_PROMISC BIT(15)
485 485
486/* Media Auto Sense */ 486/* Media Auto Sense */
487#define IGB_MAS_ENABLE_0 0X0001 487#define IGB_MAS_ENABLE_0 0X0001
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 31e5f3942839..af46fcf8a50e 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -140,7 +140,7 @@ static struct rtnl_link_stats64 *igb_get_stats64(struct net_device *dev,
140 struct rtnl_link_stats64 *stats); 140 struct rtnl_link_stats64 *stats);
141static int igb_change_mtu(struct net_device *, int); 141static int igb_change_mtu(struct net_device *, int);
142static int igb_set_mac(struct net_device *, void *); 142static int igb_set_mac(struct net_device *, void *);
143static void igb_set_uta(struct igb_adapter *adapter); 143static void igb_set_uta(struct igb_adapter *adapter, bool set);
144static irqreturn_t igb_intr(int irq, void *); 144static irqreturn_t igb_intr(int irq, void *);
145static irqreturn_t igb_intr_msi(int irq, void *); 145static irqreturn_t igb_intr_msi(int irq, void *);
146static irqreturn_t igb_msix_other(int irq, void *); 146static irqreturn_t igb_msix_other(int irq, void *);
@@ -1534,12 +1534,13 @@ static void igb_irq_enable(struct igb_adapter *adapter)
1534static void igb_update_mng_vlan(struct igb_adapter *adapter) 1534static void igb_update_mng_vlan(struct igb_adapter *adapter)
1535{ 1535{
1536 struct e1000_hw *hw = &adapter->hw; 1536 struct e1000_hw *hw = &adapter->hw;
1537 u16 pf_id = adapter->vfs_allocated_count;
1537 u16 vid = adapter->hw.mng_cookie.vlan_id; 1538 u16 vid = adapter->hw.mng_cookie.vlan_id;
1538 u16 old_vid = adapter->mng_vlan_id; 1539 u16 old_vid = adapter->mng_vlan_id;
1539 1540
1540 if (hw->mng_cookie.status & E1000_MNG_DHCP_COOKIE_STATUS_VLAN) { 1541 if (hw->mng_cookie.status & E1000_MNG_DHCP_COOKIE_STATUS_VLAN) {
1541 /* add VID to filter table */ 1542 /* add VID to filter table */
1542 igb_vfta_set(hw, vid, true); 1543 igb_vfta_set(hw, vid, pf_id, true, true);
1543 adapter->mng_vlan_id = vid; 1544 adapter->mng_vlan_id = vid;
1544 } else { 1545 } else {
1545 adapter->mng_vlan_id = IGB_MNG_VLAN_NONE; 1546 adapter->mng_vlan_id = IGB_MNG_VLAN_NONE;
@@ -1549,7 +1550,7 @@ static void igb_update_mng_vlan(struct igb_adapter *adapter)
1549 (vid != old_vid) && 1550 (vid != old_vid) &&
1550 !test_bit(old_vid, adapter->active_vlans)) { 1551 !test_bit(old_vid, adapter->active_vlans)) {
1551 /* remove VID from filter table */ 1552 /* remove VID from filter table */
1552 igb_vfta_set(hw, old_vid, false); 1553 igb_vfta_set(hw, vid, pf_id, false, true);
1553 } 1554 }
1554} 1555}
1555 1556
@@ -1818,6 +1819,10 @@ void igb_down(struct igb_adapter *adapter)
1818 1819
1819 if (!pci_channel_offline(adapter->pdev)) 1820 if (!pci_channel_offline(adapter->pdev))
1820 igb_reset(adapter); 1821 igb_reset(adapter);
1822
1823 /* clear VLAN promisc flag so VFTA will be updated if necessary */
1824 adapter->flags &= ~IGB_FLAG_VLAN_PROMISC;
1825
1821 igb_clean_all_tx_rings(adapter); 1826 igb_clean_all_tx_rings(adapter);
1822 igb_clean_all_rx_rings(adapter); 1827 igb_clean_all_rx_rings(adapter);
1823#ifdef CONFIG_IGB_DCA 1828#ifdef CONFIG_IGB_DCA
@@ -1862,7 +1867,7 @@ void igb_reset(struct igb_adapter *adapter)
1862 struct e1000_hw *hw = &adapter->hw; 1867 struct e1000_hw *hw = &adapter->hw;
1863 struct e1000_mac_info *mac = &hw->mac; 1868 struct e1000_mac_info *mac = &hw->mac;
1864 struct e1000_fc_info *fc = &hw->fc; 1869 struct e1000_fc_info *fc = &hw->fc;
1865 u32 pba = 0, tx_space, min_tx_space, min_rx_space, hwm; 1870 u32 pba, hwm;
1866 1871
1867 /* Repartition Pba for greater than 9k mtu 1872 /* Repartition Pba for greater than 9k mtu
1868 * To take effect CTRL.RST is required. 1873 * To take effect CTRL.RST is required.
@@ -1886,9 +1891,10 @@ void igb_reset(struct igb_adapter *adapter)
1886 break; 1891 break;
1887 } 1892 }
1888 1893
1889 if ((adapter->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) && 1894 if (mac->type == e1000_82575) {
1890 (mac->type < e1000_82576)) { 1895 u32 min_rx_space, min_tx_space, needed_tx_space;
1891 /* adjust PBA for jumbo frames */ 1896
1897 /* write Rx PBA so that hardware can report correct Tx PBA */
1892 wr32(E1000_PBA, pba); 1898 wr32(E1000_PBA, pba);
1893 1899
1894 /* To maintain wire speed transmits, the Tx FIFO should be 1900 /* To maintain wire speed transmits, the Tx FIFO should be
@@ -1898,31 +1904,26 @@ void igb_reset(struct igb_adapter *adapter)
1898 * one full receive packet and is similarly rounded up and 1904 * one full receive packet and is similarly rounded up and
1899 * expressed in KB. 1905 * expressed in KB.
1900 */ 1906 */
1901 pba = rd32(E1000_PBA); 1907 min_rx_space = DIV_ROUND_UP(MAX_JUMBO_FRAME_SIZE, 1024);
1902 /* upper 16 bits has Tx packet buffer allocation size in KB */ 1908
1903 tx_space = pba >> 16; 1909 /* The Tx FIFO also stores 16 bytes of information about the Tx
1904 /* lower 16 bits has Rx packet buffer allocation size in KB */ 1910 * but don't include Ethernet FCS because hardware appends it.
1905 pba &= 0xffff; 1911 * We only need to round down to the nearest 512 byte block
1906 /* the Tx fifo also stores 16 bytes of information about the Tx 1912 * count since the value we care about is 2 frames, not 1.
1907 * but don't include ethernet FCS because hardware appends it
1908 */ 1913 */
1909 min_tx_space = (adapter->max_frame_size + 1914 min_tx_space = adapter->max_frame_size;
1910 sizeof(union e1000_adv_tx_desc) - 1915 min_tx_space += sizeof(union e1000_adv_tx_desc) - ETH_FCS_LEN;
1911 ETH_FCS_LEN) * 2; 1916 min_tx_space = DIV_ROUND_UP(min_tx_space, 512);
1912 min_tx_space = ALIGN(min_tx_space, 1024); 1917
1913 min_tx_space >>= 10; 1918 /* upper 16 bits has Tx packet buffer allocation size in KB */
1914 /* software strips receive CRC, so leave room for it */ 1919 needed_tx_space = min_tx_space - (rd32(E1000_PBA) >> 16);
1915 min_rx_space = adapter->max_frame_size;
1916 min_rx_space = ALIGN(min_rx_space, 1024);
1917 min_rx_space >>= 10;
1918 1920
1919 /* If current Tx allocation is less than the min Tx FIFO size, 1921 /* If current Tx allocation is less than the min Tx FIFO size,
1920 * and the min Tx FIFO size is less than the current Rx FIFO 1922 * and the min Tx FIFO size is less than the current Rx FIFO
1921 * allocation, take space away from current Rx allocation 1923 * allocation, take space away from current Rx allocation.
1922 */ 1924 */
1923 if (tx_space < min_tx_space && 1925 if (needed_tx_space < pba) {
1924 ((min_tx_space - tx_space) < pba)) { 1926 pba -= needed_tx_space;
1925 pba = pba - (min_tx_space - tx_space);
1926 1927
1927 /* if short on Rx space, Rx wins and must trump Tx 1928 /* if short on Rx space, Rx wins and must trump Tx
1928 * adjustment 1929 * adjustment
@@ -1930,18 +1931,20 @@ void igb_reset(struct igb_adapter *adapter)
1930 if (pba < min_rx_space) 1931 if (pba < min_rx_space)
1931 pba = min_rx_space; 1932 pba = min_rx_space;
1932 } 1933 }
1934
1935 /* adjust PBA for jumbo frames */
1933 wr32(E1000_PBA, pba); 1936 wr32(E1000_PBA, pba);
1934 } 1937 }
1935 1938
1936 /* flow control settings */ 1939 /* flow control settings
1937 /* The high water mark must be low enough to fit one full frame 1940 * The high water mark must be low enough to fit one full frame
1938 * (or the size used for early receive) above it in the Rx FIFO. 1941 * after transmitting the pause frame. As such we must have enough
1939 * Set it to the lower of: 1942 * space to allow for us to complete our current transmit and then
1940 * - 90% of the Rx FIFO size, or 1943 * receive the frame that is in progress from the link partner.
1941 * - the full Rx FIFO size minus one full frame 1944 * Set it to:
1945 * - the full Rx FIFO size minus one full Tx plus one full Rx frame
1942 */ 1946 */
1943 hwm = min(((pba << 10) * 9 / 10), 1947 hwm = (pba << 10) - (adapter->max_frame_size + MAX_JUMBO_FRAME_SIZE);
1944 ((pba << 10) - 2 * adapter->max_frame_size));
1945 1948
1946 fc->high_water = hwm & 0xFFFFFFF0; /* 16-byte granularity */ 1949 fc->high_water = hwm & 0xFFFFFFF0; /* 16-byte granularity */
1947 fc->low_water = fc->high_water - 16; 1950 fc->low_water = fc->high_water - 16;
@@ -2051,7 +2054,7 @@ static int igb_set_features(struct net_device *netdev,
2051 if (changed & NETIF_F_HW_VLAN_CTAG_RX) 2054 if (changed & NETIF_F_HW_VLAN_CTAG_RX)
2052 igb_vlan_mode(netdev, features); 2055 igb_vlan_mode(netdev, features);
2053 2056
2054 if (!(changed & NETIF_F_RXALL)) 2057 if (!(changed & (NETIF_F_RXALL | NETIF_F_NTUPLE)))
2055 return 0; 2058 return 0;
2056 2059
2057 netdev->features = features; 2060 netdev->features = features;
@@ -2064,6 +2067,25 @@ static int igb_set_features(struct net_device *netdev,
2064 return 0; 2067 return 0;
2065} 2068}
2066 2069
2070static int igb_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
2071 struct net_device *dev,
2072 const unsigned char *addr, u16 vid,
2073 u16 flags)
2074{
2075 /* guarantee we can provide a unique filter for the unicast address */
2076 if (is_unicast_ether_addr(addr) || is_link_local_ether_addr(addr)) {
2077 struct igb_adapter *adapter = netdev_priv(dev);
2078 struct e1000_hw *hw = &adapter->hw;
2079 int vfn = adapter->vfs_allocated_count;
2080 int rar_entries = hw->mac.rar_entry_count - (vfn + 1);
2081
2082 if (netdev_uc_count(dev) >= rar_entries)
2083 return -ENOMEM;
2084 }
2085
2086 return ndo_dflt_fdb_add(ndm, tb, dev, addr, vid, flags);
2087}
2088
2067static const struct net_device_ops igb_netdev_ops = { 2089static const struct net_device_ops igb_netdev_ops = {
2068 .ndo_open = igb_open, 2090 .ndo_open = igb_open,
2069 .ndo_stop = igb_close, 2091 .ndo_stop = igb_close,
@@ -2087,6 +2109,7 @@ static const struct net_device_ops igb_netdev_ops = {
2087#endif 2109#endif
2088 .ndo_fix_features = igb_fix_features, 2110 .ndo_fix_features = igb_fix_features,
2089 .ndo_set_features = igb_set_features, 2111 .ndo_set_features = igb_set_features,
2112 .ndo_fdb_add = igb_ndo_fdb_add,
2090 .ndo_features_check = passthru_features_check, 2113 .ndo_features_check = passthru_features_check,
2091}; 2114};
2092 2115
@@ -2921,14 +2944,6 @@ void igb_set_flag_queue_pairs(struct igb_adapter *adapter,
2921 /* Device supports enough interrupts without queue pairing. */ 2944 /* Device supports enough interrupts without queue pairing. */
2922 break; 2945 break;
2923 case e1000_82576: 2946 case e1000_82576:
2924 /* If VFs are going to be allocated with RSS queues then we
2925 * should pair the queues in order to conserve interrupts due
2926 * to limited supply.
2927 */
2928 if ((adapter->rss_queues > 1) &&
2929 (adapter->vfs_allocated_count > 6))
2930 adapter->flags |= IGB_FLAG_QUEUE_PAIRS;
2931 /* fall through */
2932 case e1000_82580: 2947 case e1000_82580:
2933 case e1000_i350: 2948 case e1000_i350:
2934 case e1000_i354: 2949 case e1000_i354:
@@ -2939,6 +2954,8 @@ void igb_set_flag_queue_pairs(struct igb_adapter *adapter,
2939 */ 2954 */
2940 if (adapter->rss_queues > (max_rss_queues / 2)) 2955 if (adapter->rss_queues > (max_rss_queues / 2))
2941 adapter->flags |= IGB_FLAG_QUEUE_PAIRS; 2956 adapter->flags |= IGB_FLAG_QUEUE_PAIRS;
2957 else
2958 adapter->flags &= ~IGB_FLAG_QUEUE_PAIRS;
2942 break; 2959 break;
2943 } 2960 }
2944} 2961}
@@ -3498,7 +3515,7 @@ void igb_setup_rctl(struct igb_adapter *adapter)
3498 /* disable store bad packets and clear size bits. */ 3515 /* disable store bad packets and clear size bits. */
3499 rctl &= ~(E1000_RCTL_SBP | E1000_RCTL_SZ_256); 3516 rctl &= ~(E1000_RCTL_SBP | E1000_RCTL_SZ_256);
3500 3517
3501 /* enable LPE to prevent packets larger than max_frame_size */ 3518 /* enable LPE to allow for reception of jumbo frames */
3502 rctl |= E1000_RCTL_LPE; 3519 rctl |= E1000_RCTL_LPE;
3503 3520
3504 /* disable queue 0 to prevent tail write w/o re-config */ 3521 /* disable queue 0 to prevent tail write w/o re-config */
@@ -3522,8 +3539,7 @@ void igb_setup_rctl(struct igb_adapter *adapter)
3522 E1000_RCTL_BAM | /* RX All Bcast Pkts */ 3539 E1000_RCTL_BAM | /* RX All Bcast Pkts */
3523 E1000_RCTL_PMCF); /* RX All MAC Ctrl Pkts */ 3540 E1000_RCTL_PMCF); /* RX All MAC Ctrl Pkts */
3524 3541
3525 rctl &= ~(E1000_RCTL_VFE | /* Disable VLAN filter */ 3542 rctl &= ~(E1000_RCTL_DPF | /* Allow filtered pause */
3526 E1000_RCTL_DPF | /* Allow filtered pause */
3527 E1000_RCTL_CFIEN); /* Dis VLAN CFIEN Filter */ 3543 E1000_RCTL_CFIEN); /* Dis VLAN CFIEN Filter */
3528 /* Do not mess with E1000_CTRL_VME, it affects transmit as well, 3544 /* Do not mess with E1000_CTRL_VME, it affects transmit as well,
3529 * and that breaks VLANs. 3545 * and that breaks VLANs.
@@ -3539,12 +3555,8 @@ static inline int igb_set_vf_rlpml(struct igb_adapter *adapter, int size,
3539 struct e1000_hw *hw = &adapter->hw; 3555 struct e1000_hw *hw = &adapter->hw;
3540 u32 vmolr; 3556 u32 vmolr;
3541 3557
3542 /* if it isn't the PF check to see if VFs are enabled and 3558 if (size > MAX_JUMBO_FRAME_SIZE)
3543 * increase the size to support vlan tags 3559 size = MAX_JUMBO_FRAME_SIZE;
3544 */
3545 if (vfn < adapter->vfs_allocated_count &&
3546 adapter->vf_data[vfn].vlans_enabled)
3547 size += VLAN_TAG_SIZE;
3548 3560
3549 vmolr = rd32(E1000_VMOLR(vfn)); 3561 vmolr = rd32(E1000_VMOLR(vfn));
3550 vmolr &= ~E1000_VMOLR_RLPML_MASK; 3562 vmolr &= ~E1000_VMOLR_RLPML_MASK;
@@ -3554,32 +3566,6 @@ static inline int igb_set_vf_rlpml(struct igb_adapter *adapter, int size,
3554 return 0; 3566 return 0;
3555} 3567}
3556 3568
3557/**
3558 * igb_rlpml_set - set maximum receive packet size
3559 * @adapter: board private structure
3560 *
3561 * Configure maximum receivable packet size.
3562 **/
3563static void igb_rlpml_set(struct igb_adapter *adapter)
3564{
3565 u32 max_frame_size = adapter->max_frame_size;
3566 struct e1000_hw *hw = &adapter->hw;
3567 u16 pf_id = adapter->vfs_allocated_count;
3568
3569 if (pf_id) {
3570 igb_set_vf_rlpml(adapter, max_frame_size, pf_id);
3571 /* If we're in VMDQ or SR-IOV mode, then set global RLPML
3572 * to our max jumbo frame size, in case we need to enable
3573 * jumbo frames on one of the rings later.
3574 * This will not pass over-length frames into the default
3575 * queue because it's gated by the VMOLR.RLPML.
3576 */
3577 max_frame_size = MAX_JUMBO_FRAME_SIZE;
3578 }
3579
3580 wr32(E1000_RLPML, max_frame_size);
3581}
3582
3583static inline void igb_set_vmolr(struct igb_adapter *adapter, 3569static inline void igb_set_vmolr(struct igb_adapter *adapter,
3584 int vfn, bool aupe) 3570 int vfn, bool aupe)
3585{ 3571{
@@ -3684,9 +3670,6 @@ static void igb_configure_rx(struct igb_adapter *adapter)
3684{ 3670{
3685 int i; 3671 int i;
3686 3672
3687 /* set UTA to appropriate mode */
3688 igb_set_uta(adapter);
3689
3690 /* set the correct pool for the PF default MAC address in entry 0 */ 3673 /* set the correct pool for the PF default MAC address in entry 0 */
3691 igb_rar_set_qsel(adapter, adapter->hw.mac.addr, 0, 3674 igb_rar_set_qsel(adapter, adapter->hw.mac.addr, 0,
3692 adapter->vfs_allocated_count); 3675 adapter->vfs_allocated_count);
@@ -4004,6 +3987,130 @@ static int igb_write_uc_addr_list(struct net_device *netdev)
4004 return count; 3987 return count;
4005} 3988}
4006 3989
3990static int igb_vlan_promisc_enable(struct igb_adapter *adapter)
3991{
3992 struct e1000_hw *hw = &adapter->hw;
3993 u32 i, pf_id;
3994
3995 switch (hw->mac.type) {
3996 case e1000_i210:
3997 case e1000_i211:
3998 case e1000_i350:
3999 /* VLAN filtering needed for VLAN prio filter */
4000 if (adapter->netdev->features & NETIF_F_NTUPLE)
4001 break;
4002 /* fall through */
4003 case e1000_82576:
4004 case e1000_82580:
4005 case e1000_i354:
4006 /* VLAN filtering needed for pool filtering */
4007 if (adapter->vfs_allocated_count)
4008 break;
4009 /* fall through */
4010 default:
4011 return 1;
4012 }
4013
4014 /* We are already in VLAN promisc, nothing to do */
4015 if (adapter->flags & IGB_FLAG_VLAN_PROMISC)
4016 return 0;
4017
4018 if (!adapter->vfs_allocated_count)
4019 goto set_vfta;
4020
4021 /* Add PF to all active pools */
4022 pf_id = adapter->vfs_allocated_count + E1000_VLVF_POOLSEL_SHIFT;
4023
4024 for (i = E1000_VLVF_ARRAY_SIZE; --i;) {
4025 u32 vlvf = rd32(E1000_VLVF(i));
4026
4027 vlvf |= 1 << pf_id;
4028 wr32(E1000_VLVF(i), vlvf);
4029 }
4030
4031set_vfta:
4032 /* Set all bits in the VLAN filter table array */
4033 for (i = E1000_VLAN_FILTER_TBL_SIZE; i--;)
4034 hw->mac.ops.write_vfta(hw, i, ~0U);
4035
4036 /* Set flag so we don't redo unnecessary work */
4037 adapter->flags |= IGB_FLAG_VLAN_PROMISC;
4038
4039 return 0;
4040}
4041
4042#define VFTA_BLOCK_SIZE 8
4043static void igb_scrub_vfta(struct igb_adapter *adapter, u32 vfta_offset)
4044{
4045 struct e1000_hw *hw = &adapter->hw;
4046 u32 vfta[VFTA_BLOCK_SIZE] = { 0 };
4047 u32 vid_start = vfta_offset * 32;
4048 u32 vid_end = vid_start + (VFTA_BLOCK_SIZE * 32);
4049 u32 i, vid, word, bits, pf_id;
4050
4051 /* guarantee that we don't scrub out management VLAN */
4052 vid = adapter->mng_vlan_id;
4053 if (vid >= vid_start && vid < vid_end)
4054 vfta[(vid - vid_start) / 32] |= 1 << (vid % 32);
4055
4056 if (!adapter->vfs_allocated_count)
4057 goto set_vfta;
4058
4059 pf_id = adapter->vfs_allocated_count + E1000_VLVF_POOLSEL_SHIFT;
4060
4061 for (i = E1000_VLVF_ARRAY_SIZE; --i;) {
4062 u32 vlvf = rd32(E1000_VLVF(i));
4063
4064 /* pull VLAN ID from VLVF */
4065 vid = vlvf & VLAN_VID_MASK;
4066
4067 /* only concern ourselves with a certain range */
4068 if (vid < vid_start || vid >= vid_end)
4069 continue;
4070
4071 if (vlvf & E1000_VLVF_VLANID_ENABLE) {
4072 /* record VLAN ID in VFTA */
4073 vfta[(vid - vid_start) / 32] |= 1 << (vid % 32);
4074
4075 /* if PF is part of this then continue */
4076 if (test_bit(vid, adapter->active_vlans))
4077 continue;
4078 }
4079
4080 /* remove PF from the pool */
4081 bits = ~(1 << pf_id);
4082 bits &= rd32(E1000_VLVF(i));
4083 wr32(E1000_VLVF(i), bits);
4084 }
4085
4086set_vfta:
4087 /* extract values from active_vlans and write back to VFTA */
4088 for (i = VFTA_BLOCK_SIZE; i--;) {
4089 vid = (vfta_offset + i) * 32;
4090 word = vid / BITS_PER_LONG;
4091 bits = vid % BITS_PER_LONG;
4092
4093 vfta[i] |= adapter->active_vlans[word] >> bits;
4094
4095 hw->mac.ops.write_vfta(hw, vfta_offset + i, vfta[i]);
4096 }
4097}
4098
4099static void igb_vlan_promisc_disable(struct igb_adapter *adapter)
4100{
4101 u32 i;
4102
4103 /* We are not in VLAN promisc, nothing to do */
4104 if (!(adapter->flags & IGB_FLAG_VLAN_PROMISC))
4105 return;
4106
4107 /* Set flag so we don't redo unnecessary work */
4108 adapter->flags &= ~IGB_FLAG_VLAN_PROMISC;
4109
4110 for (i = 0; i < E1000_VLAN_FILTER_TBL_SIZE; i += VFTA_BLOCK_SIZE)
4111 igb_scrub_vfta(adapter, i);
4112}
4113
4007/** 4114/**
4008 * igb_set_rx_mode - Secondary Unicast, Multicast and Promiscuous mode set 4115 * igb_set_rx_mode - Secondary Unicast, Multicast and Promiscuous mode set
4009 * @netdev: network interface device structure 4116 * @netdev: network interface device structure
@@ -4018,21 +4125,17 @@ static void igb_set_rx_mode(struct net_device *netdev)
4018 struct igb_adapter *adapter = netdev_priv(netdev); 4125 struct igb_adapter *adapter = netdev_priv(netdev);
4019 struct e1000_hw *hw = &adapter->hw; 4126 struct e1000_hw *hw = &adapter->hw;
4020 unsigned int vfn = adapter->vfs_allocated_count; 4127 unsigned int vfn = adapter->vfs_allocated_count;
4021 u32 rctl, vmolr = 0; 4128 u32 rctl = 0, vmolr = 0;
4022 int count; 4129 int count;
4023 4130
4024 /* Check for Promiscuous and All Multicast modes */ 4131 /* Check for Promiscuous and All Multicast modes */
4025 rctl = rd32(E1000_RCTL);
4026
4027 /* clear the effected bits */
4028 rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE | E1000_RCTL_VFE);
4029
4030 if (netdev->flags & IFF_PROMISC) { 4132 if (netdev->flags & IFF_PROMISC) {
4031 /* retain VLAN HW filtering if in VT mode */ 4133 rctl |= E1000_RCTL_UPE | E1000_RCTL_MPE;
4032 if (adapter->vfs_allocated_count) 4134 vmolr |= E1000_VMOLR_MPME;
4033 rctl |= E1000_RCTL_VFE; 4135
4034 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); 4136 /* enable use of UTA filter to force packets to default pool */
4035 vmolr |= (E1000_VMOLR_ROPE | E1000_VMOLR_MPME); 4137 if (hw->mac.type == e1000_82576)
4138 vmolr |= E1000_VMOLR_ROPE;
4036 } else { 4139 } else {
4037 if (netdev->flags & IFF_ALLMULTI) { 4140 if (netdev->flags & IFF_ALLMULTI) {
4038 rctl |= E1000_RCTL_MPE; 4141 rctl |= E1000_RCTL_MPE;
@@ -4050,17 +4153,34 @@ static void igb_set_rx_mode(struct net_device *netdev)
4050 vmolr |= E1000_VMOLR_ROMPE; 4153 vmolr |= E1000_VMOLR_ROMPE;
4051 } 4154 }
4052 } 4155 }
4053 /* Write addresses to available RAR registers, if there is not
4054 * sufficient space to store all the addresses then enable
4055 * unicast promiscuous mode
4056 */
4057 count = igb_write_uc_addr_list(netdev);
4058 if (count < 0) {
4059 rctl |= E1000_RCTL_UPE;
4060 vmolr |= E1000_VMOLR_ROPE;
4061 }
4062 rctl |= E1000_RCTL_VFE;
4063 } 4156 }
4157
4158 /* Write addresses to available RAR registers, if there is not
4159 * sufficient space to store all the addresses then enable
4160 * unicast promiscuous mode
4161 */
4162 count = igb_write_uc_addr_list(netdev);
4163 if (count < 0) {
4164 rctl |= E1000_RCTL_UPE;
4165 vmolr |= E1000_VMOLR_ROPE;
4166 }
4167
4168 /* enable VLAN filtering by default */
4169 rctl |= E1000_RCTL_VFE;
4170
4171 /* disable VLAN filtering for modes that require it */
4172 if ((netdev->flags & IFF_PROMISC) ||
4173 (netdev->features & NETIF_F_RXALL)) {
4174 /* if we fail to set all rules then just clear VFE */
4175 if (igb_vlan_promisc_enable(adapter))
4176 rctl &= ~E1000_RCTL_VFE;
4177 } else {
4178 igb_vlan_promisc_disable(adapter);
4179 }
4180
4181 /* update state of unicast, multicast, and VLAN filtering modes */
4182 rctl |= rd32(E1000_RCTL) & ~(E1000_RCTL_UPE | E1000_RCTL_MPE |
4183 E1000_RCTL_VFE);
4064 wr32(E1000_RCTL, rctl); 4184 wr32(E1000_RCTL, rctl);
4065 4185
4066 /* In order to support SR-IOV and eventually VMDq it is necessary to set 4186 /* In order to support SR-IOV and eventually VMDq it is necessary to set
@@ -4071,9 +4191,19 @@ static void igb_set_rx_mode(struct net_device *netdev)
4071 if ((hw->mac.type < e1000_82576) || (hw->mac.type > e1000_i350)) 4191 if ((hw->mac.type < e1000_82576) || (hw->mac.type > e1000_i350))
4072 return; 4192 return;
4073 4193
4194 /* set UTA to appropriate mode */
4195 igb_set_uta(adapter, !!(vmolr & E1000_VMOLR_ROPE));
4196
4074 vmolr |= rd32(E1000_VMOLR(vfn)) & 4197 vmolr |= rd32(E1000_VMOLR(vfn)) &
4075 ~(E1000_VMOLR_ROPE | E1000_VMOLR_MPME | E1000_VMOLR_ROMPE); 4198 ~(E1000_VMOLR_ROPE | E1000_VMOLR_MPME | E1000_VMOLR_ROMPE);
4199
4200 /* enable Rx jumbo frames, no need for restriction */
4201 vmolr &= ~E1000_VMOLR_RLPML_MASK;
4202 vmolr |= MAX_JUMBO_FRAME_SIZE | E1000_VMOLR_LPE;
4203
4076 wr32(E1000_VMOLR(vfn), vmolr); 4204 wr32(E1000_VMOLR(vfn), vmolr);
4205 wr32(E1000_RLPML, MAX_JUMBO_FRAME_SIZE);
4206
4077 igb_restore_vf_multicasts(adapter); 4207 igb_restore_vf_multicasts(adapter);
4078} 4208}
4079 4209
@@ -5088,16 +5218,6 @@ static netdev_tx_t igb_xmit_frame(struct sk_buff *skb,
5088{ 5218{
5089 struct igb_adapter *adapter = netdev_priv(netdev); 5219 struct igb_adapter *adapter = netdev_priv(netdev);
5090 5220
5091 if (test_bit(__IGB_DOWN, &adapter->state)) {
5092 dev_kfree_skb_any(skb);
5093 return NETDEV_TX_OK;
5094 }
5095
5096 if (skb->len <= 0) {
5097 dev_kfree_skb_any(skb);
5098 return NETDEV_TX_OK;
5099 }
5100
5101 /* The minimum packet size with TCTL.PSP set is 17 so pad the skb 5221 /* The minimum packet size with TCTL.PSP set is 17 so pad the skb
5102 * in order to meet this minimum size requirement. 5222 * in order to meet this minimum size requirement.
5103 */ 5223 */
@@ -5792,125 +5912,132 @@ static void igb_restore_vf_multicasts(struct igb_adapter *adapter)
5792static void igb_clear_vf_vfta(struct igb_adapter *adapter, u32 vf) 5912static void igb_clear_vf_vfta(struct igb_adapter *adapter, u32 vf)
5793{ 5913{
5794 struct e1000_hw *hw = &adapter->hw; 5914 struct e1000_hw *hw = &adapter->hw;
5795 u32 pool_mask, reg, vid; 5915 u32 pool_mask, vlvf_mask, i;
5796 int i;
5797 5916
5798 pool_mask = 1 << (E1000_VLVF_POOLSEL_SHIFT + vf); 5917 /* create mask for VF and other pools */
5918 pool_mask = E1000_VLVF_POOLSEL_MASK;
5919 vlvf_mask = 1 << (E1000_VLVF_POOLSEL_SHIFT + vf);
5920
5921 /* drop PF from pool bits */
5922 pool_mask &= ~(1 << (E1000_VLVF_POOLSEL_SHIFT +
5923 adapter->vfs_allocated_count));
5799 5924
5800 /* Find the vlan filter for this id */ 5925 /* Find the vlan filter for this id */
5801 for (i = 0; i < E1000_VLVF_ARRAY_SIZE; i++) { 5926 for (i = E1000_VLVF_ARRAY_SIZE; i--;) {
5802 reg = rd32(E1000_VLVF(i)); 5927 u32 vlvf = rd32(E1000_VLVF(i));
5928 u32 vfta_mask, vid, vfta;
5803 5929
5804 /* remove the vf from the pool */ 5930 /* remove the vf from the pool */
5805 reg &= ~pool_mask; 5931 if (!(vlvf & vlvf_mask))
5806 5932 continue;
5807 /* if pool is empty then remove entry from vfta */ 5933
5808 if (!(reg & E1000_VLVF_POOLSEL_MASK) && 5934 /* clear out bit from VLVF */
5809 (reg & E1000_VLVF_VLANID_ENABLE)) { 5935 vlvf ^= vlvf_mask;
5810 reg = 0; 5936
5811 vid = reg & E1000_VLVF_VLANID_MASK; 5937 /* if other pools are present, just remove ourselves */
5812 igb_vfta_set(hw, vid, false); 5938 if (vlvf & pool_mask)
5813 } 5939 goto update_vlvfb;
5940
5941 /* if PF is present, leave VFTA */
5942 if (vlvf & E1000_VLVF_POOLSEL_MASK)
5943 goto update_vlvf;
5944
5945 vid = vlvf & E1000_VLVF_VLANID_MASK;
5946 vfta_mask = 1 << (vid % 32);
5814 5947
5815 wr32(E1000_VLVF(i), reg); 5948 /* clear bit from VFTA */
5949 vfta = adapter->shadow_vfta[vid / 32];
5950 if (vfta & vfta_mask)
5951 hw->mac.ops.write_vfta(hw, vid / 32, vfta ^ vfta_mask);
5952update_vlvf:
5953 /* clear pool selection enable */
5954 if (adapter->flags & IGB_FLAG_VLAN_PROMISC)
5955 vlvf &= E1000_VLVF_POOLSEL_MASK;
5956 else
5957 vlvf = 0;
5958update_vlvfb:
5959 /* clear pool bits */
5960 wr32(E1000_VLVF(i), vlvf);
5816 } 5961 }
5962}
5963
5964static int igb_find_vlvf_entry(struct e1000_hw *hw, u32 vlan)
5965{
5966 u32 vlvf;
5967 int idx;
5817 5968
5818 adapter->vf_data[vf].vlans_enabled = 0; 5969 /* short cut the special case */
5970 if (vlan == 0)
5971 return 0;
5972
5973 /* Search for the VLAN id in the VLVF entries */
5974 for (idx = E1000_VLVF_ARRAY_SIZE; --idx;) {
5975 vlvf = rd32(E1000_VLVF(idx));
5976 if ((vlvf & VLAN_VID_MASK) == vlan)
5977 break;
5978 }
5979
5980 return idx;
5819} 5981}
5820 5982
5821static s32 igb_vlvf_set(struct igb_adapter *adapter, u32 vid, bool add, u32 vf) 5983void igb_update_pf_vlvf(struct igb_adapter *adapter, u32 vid)
5822{ 5984{
5823 struct e1000_hw *hw = &adapter->hw; 5985 struct e1000_hw *hw = &adapter->hw;
5824 u32 reg, i; 5986 u32 bits, pf_id;
5825 5987 int idx;
5826 /* The vlvf table only exists on 82576 hardware and newer */
5827 if (hw->mac.type < e1000_82576)
5828 return -1;
5829 5988
5830 /* we only need to do this if VMDq is enabled */ 5989 idx = igb_find_vlvf_entry(hw, vid);
5831 if (!adapter->vfs_allocated_count) 5990 if (!idx)
5832 return -1; 5991 return;
5833 5992
5834 /* Find the vlan filter for this id */ 5993 /* See if any other pools are set for this VLAN filter
5835 for (i = 0; i < E1000_VLVF_ARRAY_SIZE; i++) { 5994 * entry other than the PF.
5836 reg = rd32(E1000_VLVF(i)); 5995 */
5837 if ((reg & E1000_VLVF_VLANID_ENABLE) && 5996 pf_id = adapter->vfs_allocated_count + E1000_VLVF_POOLSEL_SHIFT;
5838 vid == (reg & E1000_VLVF_VLANID_MASK)) 5997 bits = ~(1 << pf_id) & E1000_VLVF_POOLSEL_MASK;
5839 break; 5998 bits &= rd32(E1000_VLVF(idx));
5999
6000 /* Disable the filter so this falls into the default pool. */
6001 if (!bits) {
6002 if (adapter->flags & IGB_FLAG_VLAN_PROMISC)
6003 wr32(E1000_VLVF(idx), 1 << pf_id);
6004 else
6005 wr32(E1000_VLVF(idx), 0);
5840 } 6006 }
6007}
5841 6008
5842 if (add) { 6009static s32 igb_set_vf_vlan(struct igb_adapter *adapter, u32 vid,
5843 if (i == E1000_VLVF_ARRAY_SIZE) { 6010 bool add, u32 vf)
5844 /* Did not find a matching VLAN ID entry that was 6011{
5845 * enabled. Search for a free filter entry, i.e. 6012 int pf_id = adapter->vfs_allocated_count;
5846 * one without the enable bit set 6013 struct e1000_hw *hw = &adapter->hw;
5847 */ 6014 int err;
5848 for (i = 0; i < E1000_VLVF_ARRAY_SIZE; i++) {
5849 reg = rd32(E1000_VLVF(i));
5850 if (!(reg & E1000_VLVF_VLANID_ENABLE))
5851 break;
5852 }
5853 }
5854 if (i < E1000_VLVF_ARRAY_SIZE) {
5855 /* Found an enabled/available entry */
5856 reg |= 1 << (E1000_VLVF_POOLSEL_SHIFT + vf);
5857
5858 /* if !enabled we need to set this up in vfta */
5859 if (!(reg & E1000_VLVF_VLANID_ENABLE)) {
5860 /* add VID to filter table */
5861 igb_vfta_set(hw, vid, true);
5862 reg |= E1000_VLVF_VLANID_ENABLE;
5863 }
5864 reg &= ~E1000_VLVF_VLANID_MASK;
5865 reg |= vid;
5866 wr32(E1000_VLVF(i), reg);
5867
5868 /* do not modify RLPML for PF devices */
5869 if (vf >= adapter->vfs_allocated_count)
5870 return 0;
5871
5872 if (!adapter->vf_data[vf].vlans_enabled) {
5873 u32 size;
5874
5875 reg = rd32(E1000_VMOLR(vf));
5876 size = reg & E1000_VMOLR_RLPML_MASK;
5877 size += 4;
5878 reg &= ~E1000_VMOLR_RLPML_MASK;
5879 reg |= size;
5880 wr32(E1000_VMOLR(vf), reg);
5881 }
5882 6015
5883 adapter->vf_data[vf].vlans_enabled++; 6016 /* If VLAN overlaps with one the PF is currently monitoring make
5884 } 6017 * sure that we are able to allocate a VLVF entry. This may be
5885 } else { 6018 * redundant but it guarantees PF will maintain visibility to
5886 if (i < E1000_VLVF_ARRAY_SIZE) { 6019 * the VLAN.
5887 /* remove vf from the pool */ 6020 */
5888 reg &= ~(1 << (E1000_VLVF_POOLSEL_SHIFT + vf)); 6021 if (add && test_bit(vid, adapter->active_vlans)) {
5889 /* if pool is empty then remove entry from vfta */ 6022 err = igb_vfta_set(hw, vid, pf_id, true, false);
5890 if (!(reg & E1000_VLVF_POOLSEL_MASK)) { 6023 if (err)
5891 reg = 0; 6024 return err;
5892 igb_vfta_set(hw, vid, false);
5893 }
5894 wr32(E1000_VLVF(i), reg);
5895
5896 /* do not modify RLPML for PF devices */
5897 if (vf >= adapter->vfs_allocated_count)
5898 return 0;
5899
5900 adapter->vf_data[vf].vlans_enabled--;
5901 if (!adapter->vf_data[vf].vlans_enabled) {
5902 u32 size;
5903
5904 reg = rd32(E1000_VMOLR(vf));
5905 size = reg & E1000_VMOLR_RLPML_MASK;
5906 size -= 4;
5907 reg &= ~E1000_VMOLR_RLPML_MASK;
5908 reg |= size;
5909 wr32(E1000_VMOLR(vf), reg);
5910 }
5911 }
5912 } 6025 }
5913 return 0; 6026
6027 err = igb_vfta_set(hw, vid, vf, add, false);
6028
6029 if (add && !err)
6030 return err;
6031
6032 /* If we failed to add the VF VLAN or we are removing the VF VLAN
6033 * we may need to drop the PF pool bit in order to allow us to free
6034 * up the VLVF resources.
6035 */
6036 if (test_bit(vid, adapter->active_vlans) ||
6037 (adapter->flags & IGB_FLAG_VLAN_PROMISC))
6038 igb_update_pf_vlvf(adapter, vid);
6039
6040 return err;
5914} 6041}
5915 6042
5916static void igb_set_vmvir(struct igb_adapter *adapter, u32 vid, u32 vf) 6043static void igb_set_vmvir(struct igb_adapter *adapter, u32 vid, u32 vf)
@@ -5923,130 +6050,97 @@ static void igb_set_vmvir(struct igb_adapter *adapter, u32 vid, u32 vf)
5923 wr32(E1000_VMVIR(vf), 0); 6050 wr32(E1000_VMVIR(vf), 0);
5924} 6051}
5925 6052
5926static int igb_ndo_set_vf_vlan(struct net_device *netdev, 6053static int igb_enable_port_vlan(struct igb_adapter *adapter, int vf,
5927 int vf, u16 vlan, u8 qos) 6054 u16 vlan, u8 qos)
5928{ 6055{
5929 int err = 0; 6056 int err;
5930 struct igb_adapter *adapter = netdev_priv(netdev);
5931 6057
5932 if ((vf >= adapter->vfs_allocated_count) || (vlan > 4095) || (qos > 7)) 6058 err = igb_set_vf_vlan(adapter, vlan, true, vf);
5933 return -EINVAL; 6059 if (err)
5934 if (vlan || qos) { 6060 return err;
5935 err = igb_vlvf_set(adapter, vlan, !!vlan, vf); 6061
5936 if (err) 6062 igb_set_vmvir(adapter, vlan | (qos << VLAN_PRIO_SHIFT), vf);
5937 goto out; 6063 igb_set_vmolr(adapter, vf, !vlan);
5938 igb_set_vmvir(adapter, vlan | (qos << VLAN_PRIO_SHIFT), vf); 6064
5939 igb_set_vmolr(adapter, vf, !vlan); 6065 /* revoke access to previous VLAN */
5940 adapter->vf_data[vf].pf_vlan = vlan; 6066 if (vlan != adapter->vf_data[vf].pf_vlan)
5941 adapter->vf_data[vf].pf_qos = qos; 6067 igb_set_vf_vlan(adapter, adapter->vf_data[vf].pf_vlan,
5942 dev_info(&adapter->pdev->dev, 6068 false, vf);
5943 "Setting VLAN %d, QOS 0x%x on VF %d\n", vlan, qos, vf); 6069
5944 if (test_bit(__IGB_DOWN, &adapter->state)) { 6070 adapter->vf_data[vf].pf_vlan = vlan;
5945 dev_warn(&adapter->pdev->dev, 6071 adapter->vf_data[vf].pf_qos = qos;
5946 "The VF VLAN has been set, but the PF device is not up.\n"); 6072 dev_info(&adapter->pdev->dev,
5947 dev_warn(&adapter->pdev->dev, 6073 "Setting VLAN %d, QOS 0x%x on VF %d\n", vlan, qos, vf);
5948 "Bring the PF device up before attempting to use the VF device.\n"); 6074 if (test_bit(__IGB_DOWN, &adapter->state)) {
5949 } 6075 dev_warn(&adapter->pdev->dev,
5950 } else { 6076 "The VF VLAN has been set, but the PF device is not up.\n");
5951 igb_vlvf_set(adapter, adapter->vf_data[vf].pf_vlan, 6077 dev_warn(&adapter->pdev->dev,
5952 false, vf); 6078 "Bring the PF device up before attempting to use the VF device.\n");
5953 igb_set_vmvir(adapter, vlan, vf);
5954 igb_set_vmolr(adapter, vf, true);
5955 adapter->vf_data[vf].pf_vlan = 0;
5956 adapter->vf_data[vf].pf_qos = 0;
5957 } 6079 }
5958out: 6080
5959 return err; 6081 return err;
5960} 6082}
5961 6083
5962static int igb_find_vlvf_entry(struct igb_adapter *adapter, int vid) 6084static int igb_disable_port_vlan(struct igb_adapter *adapter, int vf)
5963{ 6085{
5964 struct e1000_hw *hw = &adapter->hw; 6086 /* Restore tagless access via VLAN 0 */
5965 int i; 6087 igb_set_vf_vlan(adapter, 0, true, vf);
5966 u32 reg;
5967 6088
5968 /* Find the vlan filter for this id */ 6089 igb_set_vmvir(adapter, 0, vf);
5969 for (i = 0; i < E1000_VLVF_ARRAY_SIZE; i++) { 6090 igb_set_vmolr(adapter, vf, true);
5970 reg = rd32(E1000_VLVF(i));
5971 if ((reg & E1000_VLVF_VLANID_ENABLE) &&
5972 vid == (reg & E1000_VLVF_VLANID_MASK))
5973 break;
5974 }
5975 6091
5976 if (i >= E1000_VLVF_ARRAY_SIZE) 6092 /* Remove any PF assigned VLAN */
5977 i = -1; 6093 if (adapter->vf_data[vf].pf_vlan)
6094 igb_set_vf_vlan(adapter, adapter->vf_data[vf].pf_vlan,
6095 false, vf);
6096
6097 adapter->vf_data[vf].pf_vlan = 0;
6098 adapter->vf_data[vf].pf_qos = 0;
5978 6099
5979 return i; 6100 return 0;
5980} 6101}
5981 6102
5982static int igb_set_vf_vlan(struct igb_adapter *adapter, u32 *msgbuf, u32 vf) 6103static int igb_ndo_set_vf_vlan(struct net_device *netdev,
6104 int vf, u16 vlan, u8 qos)
5983{ 6105{
5984 struct e1000_hw *hw = &adapter->hw; 6106 struct igb_adapter *adapter = netdev_priv(netdev);
5985 int add = (msgbuf[0] & E1000_VT_MSGINFO_MASK) >> E1000_VT_MSGINFO_SHIFT;
5986 int vid = (msgbuf[1] & E1000_VLVF_VLANID_MASK);
5987 int err = 0;
5988 6107
5989 /* If in promiscuous mode we need to make sure the PF also has 6108 if ((vf >= adapter->vfs_allocated_count) || (vlan > 4095) || (qos > 7))
5990 * the VLAN filter set. 6109 return -EINVAL;
5991 */
5992 if (add && (adapter->netdev->flags & IFF_PROMISC))
5993 err = igb_vlvf_set(adapter, vid, add,
5994 adapter->vfs_allocated_count);
5995 if (err)
5996 goto out;
5997 6110
5998 err = igb_vlvf_set(adapter, vid, add, vf); 6111 return (vlan || qos) ? igb_enable_port_vlan(adapter, vf, vlan, qos) :
6112 igb_disable_port_vlan(adapter, vf);
6113}
5999 6114
6000 if (err) 6115static int igb_set_vf_vlan_msg(struct igb_adapter *adapter, u32 *msgbuf, u32 vf)
6001 goto out; 6116{
6117 int add = (msgbuf[0] & E1000_VT_MSGINFO_MASK) >> E1000_VT_MSGINFO_SHIFT;
6118 int vid = (msgbuf[1] & E1000_VLVF_VLANID_MASK);
6002 6119
6003 /* Go through all the checks to see if the VLAN filter should 6120 if (adapter->vf_data[vf].pf_vlan)
6004 * be wiped completely. 6121 return -1;
6005 */
6006 if (!add && (adapter->netdev->flags & IFF_PROMISC)) {
6007 u32 vlvf, bits;
6008 int regndx = igb_find_vlvf_entry(adapter, vid);
6009
6010 if (regndx < 0)
6011 goto out;
6012 /* See if any other pools are set for this VLAN filter
6013 * entry other than the PF.
6014 */
6015 vlvf = bits = rd32(E1000_VLVF(regndx));
6016 bits &= 1 << (E1000_VLVF_POOLSEL_SHIFT +
6017 adapter->vfs_allocated_count);
6018 /* If the filter was removed then ensure PF pool bit
6019 * is cleared if the PF only added itself to the pool
6020 * because the PF is in promiscuous mode.
6021 */
6022 if ((vlvf & VLAN_VID_MASK) == vid &&
6023 !test_bit(vid, adapter->active_vlans) &&
6024 !bits)
6025 igb_vlvf_set(adapter, vid, add,
6026 adapter->vfs_allocated_count);
6027 }
6028 6122
6029out: 6123 /* VLAN 0 is a special case, don't allow it to be removed */
6030 return err; 6124 if (!vid && !add)
6125 return 0;
6126
6127 return igb_set_vf_vlan(adapter, vid, !!add, vf);
6031} 6128}
6032 6129
6033static inline void igb_vf_reset(struct igb_adapter *adapter, u32 vf) 6130static inline void igb_vf_reset(struct igb_adapter *adapter, u32 vf)
6034{ 6131{
6035 /* clear flags - except flag that indicates PF has set the MAC */ 6132 struct vf_data_storage *vf_data = &adapter->vf_data[vf];
6036 adapter->vf_data[vf].flags &= IGB_VF_FLAG_PF_SET_MAC;
6037 adapter->vf_data[vf].last_nack = jiffies;
6038 6133
6039 /* reset offloads to defaults */ 6134 /* clear flags - except flag that indicates PF has set the MAC */
6040 igb_set_vmolr(adapter, vf, true); 6135 vf_data->flags &= IGB_VF_FLAG_PF_SET_MAC;
6136 vf_data->last_nack = jiffies;
6041 6137
6042 /* reset vlans for device */ 6138 /* reset vlans for device */
6043 igb_clear_vf_vfta(adapter, vf); 6139 igb_clear_vf_vfta(adapter, vf);
6044 if (adapter->vf_data[vf].pf_vlan) 6140 igb_set_vf_vlan(adapter, vf_data->pf_vlan, true, vf);
6045 igb_ndo_set_vf_vlan(adapter->netdev, vf, 6141 igb_set_vmvir(adapter, vf_data->pf_vlan |
6046 adapter->vf_data[vf].pf_vlan, 6142 (vf_data->pf_qos << VLAN_PRIO_SHIFT), vf);
6047 adapter->vf_data[vf].pf_qos); 6143 igb_set_vmolr(adapter, vf, !vf_data->pf_vlan);
6048 else
6049 igb_clear_vf_vfta(adapter, vf);
6050 6144
6051 /* reset multicast table array for vf */ 6145 /* reset multicast table array for vf */
6052 adapter->vf_data[vf].num_vf_mc_hashes = 0; 6146 adapter->vf_data[vf].num_vf_mc_hashes = 0;
@@ -6191,7 +6285,7 @@ static void igb_rcv_msg_from_vf(struct igb_adapter *adapter, u32 vf)
6191 "VF %d attempted to override administratively set VLAN tag\nReload the VF driver to resume operations\n", 6285 "VF %d attempted to override administratively set VLAN tag\nReload the VF driver to resume operations\n",
6192 vf); 6286 vf);
6193 else 6287 else
6194 retval = igb_set_vf_vlan(adapter, msgbuf, vf); 6288 retval = igb_set_vf_vlan_msg(adapter, msgbuf, vf);
6195 break; 6289 break;
6196 default: 6290 default:
6197 dev_err(&pdev->dev, "Unhandled Msg %08x\n", msgbuf[0]); 6291 dev_err(&pdev->dev, "Unhandled Msg %08x\n", msgbuf[0]);
@@ -6233,6 +6327,7 @@ static void igb_msg_task(struct igb_adapter *adapter)
6233/** 6327/**
6234 * igb_set_uta - Set unicast filter table address 6328 * igb_set_uta - Set unicast filter table address
6235 * @adapter: board private structure 6329 * @adapter: board private structure
6330 * @set: boolean indicating if we are setting or clearing bits
6236 * 6331 *
6237 * The unicast table address is a register array of 32-bit registers. 6332 * The unicast table address is a register array of 32-bit registers.
6238 * The table is meant to be used in a way similar to how the MTA is used 6333 * The table is meant to be used in a way similar to how the MTA is used
@@ -6240,21 +6335,18 @@ static void igb_msg_task(struct igb_adapter *adapter)
6240 * set all the hash bits to 1 and use the VMOLR ROPE bit as a promiscuous 6335 * set all the hash bits to 1 and use the VMOLR ROPE bit as a promiscuous
6241 * enable bit to allow vlan tag stripping when promiscuous mode is enabled 6336 * enable bit to allow vlan tag stripping when promiscuous mode is enabled
6242 **/ 6337 **/
6243static void igb_set_uta(struct igb_adapter *adapter) 6338static void igb_set_uta(struct igb_adapter *adapter, bool set)
6244{ 6339{
6245 struct e1000_hw *hw = &adapter->hw; 6340 struct e1000_hw *hw = &adapter->hw;
6341 u32 uta = set ? ~0 : 0;
6246 int i; 6342 int i;
6247 6343
6248 /* The UTA table only exists on 82576 hardware and newer */
6249 if (hw->mac.type < e1000_82576)
6250 return;
6251
6252 /* we only need to do this if VMDq is enabled */ 6344 /* we only need to do this if VMDq is enabled */
6253 if (!adapter->vfs_allocated_count) 6345 if (!adapter->vfs_allocated_count)
6254 return; 6346 return;
6255 6347
6256 for (i = 0; i < hw->mac.uta_reg_count; i++) 6348 for (i = hw->mac.uta_reg_count; i--;)
6257 array_wr32(E1000_UTA, i, ~0); 6349 array_wr32(E1000_UTA, i, uta);
6258} 6350}
6259 6351
6260/** 6352/**
@@ -7201,8 +7293,6 @@ static void igb_vlan_mode(struct net_device *netdev, netdev_features_t features)
7201 ctrl &= ~E1000_CTRL_VME; 7293 ctrl &= ~E1000_CTRL_VME;
7202 wr32(E1000_CTRL, ctrl); 7294 wr32(E1000_CTRL, ctrl);
7203 } 7295 }
7204
7205 igb_rlpml_set(adapter);
7206} 7296}
7207 7297
7208static int igb_vlan_rx_add_vid(struct net_device *netdev, 7298static int igb_vlan_rx_add_vid(struct net_device *netdev,
@@ -7212,11 +7302,9 @@ static int igb_vlan_rx_add_vid(struct net_device *netdev,
7212 struct e1000_hw *hw = &adapter->hw; 7302 struct e1000_hw *hw = &adapter->hw;
7213 int pf_id = adapter->vfs_allocated_count; 7303 int pf_id = adapter->vfs_allocated_count;
7214 7304
7215 /* attempt to add filter to vlvf array */
7216 igb_vlvf_set(adapter, vid, true, pf_id);
7217
7218 /* add the filter since PF can receive vlans w/o entry in vlvf */ 7305 /* add the filter since PF can receive vlans w/o entry in vlvf */
7219 igb_vfta_set(hw, vid, true); 7306 if (!vid || !(adapter->flags & IGB_FLAG_VLAN_PROMISC))
7307 igb_vfta_set(hw, vid, pf_id, true, !!vid);
7220 7308
7221 set_bit(vid, adapter->active_vlans); 7309 set_bit(vid, adapter->active_vlans);
7222 7310
@@ -7227,16 +7315,12 @@ static int igb_vlan_rx_kill_vid(struct net_device *netdev,
7227 __be16 proto, u16 vid) 7315 __be16 proto, u16 vid)
7228{ 7316{
7229 struct igb_adapter *adapter = netdev_priv(netdev); 7317 struct igb_adapter *adapter = netdev_priv(netdev);
7230 struct e1000_hw *hw = &adapter->hw;
7231 int pf_id = adapter->vfs_allocated_count; 7318 int pf_id = adapter->vfs_allocated_count;
7232 s32 err; 7319 struct e1000_hw *hw = &adapter->hw;
7233
7234 /* remove vlan from VLVF table array */
7235 err = igb_vlvf_set(adapter, vid, false, pf_id);
7236 7320
7237 /* if vid was not present in VLVF just remove it from table */ 7321 /* remove VID from filter table */
7238 if (err) 7322 if (vid && !(adapter->flags & IGB_FLAG_VLAN_PROMISC))
7239 igb_vfta_set(hw, vid, false); 7323 igb_vfta_set(hw, vid, pf_id, false, true);
7240 7324
7241 clear_bit(vid, adapter->active_vlans); 7325 clear_bit(vid, adapter->active_vlans);
7242 7326
@@ -7245,11 +7329,12 @@ static int igb_vlan_rx_kill_vid(struct net_device *netdev,
7245 7329
7246static void igb_restore_vlan(struct igb_adapter *adapter) 7330static void igb_restore_vlan(struct igb_adapter *adapter)
7247{ 7331{
7248 u16 vid; 7332 u16 vid = 1;
7249 7333
7250 igb_vlan_mode(adapter->netdev, adapter->netdev->features); 7334 igb_vlan_mode(adapter->netdev, adapter->netdev->features);
7335 igb_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), 0);
7251 7336
7252 for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID) 7337 for_each_set_bit_from(vid, adapter->active_vlans, VLAN_N_VID)
7253 igb_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), vid); 7338 igb_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), vid);
7254} 7339}
7255 7340
@@ -7704,15 +7789,14 @@ static void igb_io_resume(struct pci_dev *pdev)
7704static void igb_rar_set_qsel(struct igb_adapter *adapter, u8 *addr, u32 index, 7789static void igb_rar_set_qsel(struct igb_adapter *adapter, u8 *addr, u32 index,
7705 u8 qsel) 7790 u8 qsel)
7706{ 7791{
7707 u32 rar_low, rar_high;
7708 struct e1000_hw *hw = &adapter->hw; 7792 struct e1000_hw *hw = &adapter->hw;
7793 u32 rar_low, rar_high;
7709 7794
7710 /* HW expects these in little endian so we reverse the byte order 7795 /* HW expects these in little endian so we reverse the byte order
7711 * from network order (big endian) to little endian 7796 * from network order (big endian) to CPU endian
7712 */ 7797 */
7713 rar_low = ((u32) addr[0] | ((u32) addr[1] << 8) | 7798 rar_low = le32_to_cpup((__be32 *)(addr));
7714 ((u32) addr[2] << 16) | ((u32) addr[3] << 24)); 7799 rar_high = le16_to_cpup((__be16 *)(addr + 4));
7715 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
7716 7800
7717 /* Indicate to hardware the Address is Valid. */ 7801 /* Indicate to hardware the Address is Valid. */
7718 rar_high |= E1000_RAH_AV; 7802 rar_high |= E1000_RAH_AV;
@@ -7959,9 +8043,7 @@ static void igb_init_dmac(struct igb_adapter *adapter, u32 pba)
7959 * than the Rx threshold. Set hwm to PBA - max frame 8043 * than the Rx threshold. Set hwm to PBA - max frame
7960 * size in 16B units, capping it at PBA - 6KB. 8044 * size in 16B units, capping it at PBA - 6KB.
7961 */ 8045 */
7962 hwm = 64 * pba - adapter->max_frame_size / 16; 8046 hwm = 64 * (pba - 6);
7963 if (hwm < 64 * (pba - 6))
7964 hwm = 64 * (pba - 6);
7965 reg = rd32(E1000_FCRTC); 8047 reg = rd32(E1000_FCRTC);
7966 reg &= ~E1000_FCRTC_RTH_COAL_MASK; 8048 reg &= ~E1000_FCRTC_RTH_COAL_MASK;
7967 reg |= ((hwm << E1000_FCRTC_RTH_COAL_SHIFT) 8049 reg |= ((hwm << E1000_FCRTC_RTH_COAL_SHIFT)
@@ -7971,9 +8053,7 @@ static void igb_init_dmac(struct igb_adapter *adapter, u32 pba)
7971 /* Set the DMA Coalescing Rx threshold to PBA - 2 * max 8053 /* Set the DMA Coalescing Rx threshold to PBA - 2 * max
7972 * frame size, capping it at PBA - 10KB. 8054 * frame size, capping it at PBA - 10KB.
7973 */ 8055 */
7974 dmac_thr = pba - adapter->max_frame_size / 512; 8056 dmac_thr = pba - 10;
7975 if (dmac_thr < pba - 10)
7976 dmac_thr = pba - 10;
7977 reg = rd32(E1000_DMACR); 8057 reg = rd32(E1000_DMACR);
7978 reg &= ~E1000_DMACR_DMACTHR_MASK; 8058 reg &= ~E1000_DMACR_DMACTHR_MASK;
7979 reg |= ((dmac_thr << E1000_DMACR_DMACTHR_SHIFT) 8059 reg |= ((dmac_thr << E1000_DMACR_DMACTHR_SHIFT)
diff --git a/drivers/net/ethernet/intel/igbvf/mbx.c b/drivers/net/ethernet/intel/igbvf/mbx.c
index 7b6cb4c3764c..01752f44ace2 100644
--- a/drivers/net/ethernet/intel/igbvf/mbx.c
+++ b/drivers/net/ethernet/intel/igbvf/mbx.c
@@ -234,13 +234,19 @@ static s32 e1000_check_for_rst_vf(struct e1000_hw *hw)
234static s32 e1000_obtain_mbx_lock_vf(struct e1000_hw *hw) 234static s32 e1000_obtain_mbx_lock_vf(struct e1000_hw *hw)
235{ 235{
236 s32 ret_val = -E1000_ERR_MBX; 236 s32 ret_val = -E1000_ERR_MBX;
237 237 int count = 10;
238 /* Take ownership of the buffer */ 238
239 ew32(V2PMAILBOX(0), E1000_V2PMAILBOX_VFU); 239 do {
240 240 /* Take ownership of the buffer */
241 /* reserve mailbox for VF use */ 241 ew32(V2PMAILBOX(0), E1000_V2PMAILBOX_VFU);
242 if (e1000_read_v2p_mailbox(hw) & E1000_V2PMAILBOX_VFU) 242
243 ret_val = E1000_SUCCESS; 243 /* reserve mailbox for VF use */
244 if (e1000_read_v2p_mailbox(hw) & E1000_V2PMAILBOX_VFU) {
245 ret_val = 0;
246 break;
247 }
248 udelay(1000);
249 } while (count-- > 0);
244 250
245 return ret_val; 251 return ret_val;
246} 252}