summaryrefslogtreecommitdiff
path: root/package/system/ep80579-drivers/patches/711-3.3-gbe-fixes.patch
blob: 7b2df639849316db679b9202b02d701a8317f7ae (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
--- a/Embedded/src/GbE/kcompat.h
+++ b/Embedded/src/GbE/kcompat.h
@@ -590,6 +590,10 @@ static inline void _kc_synchronize_irq()
 #define ETHTOOL_OPS_COMPAT
 #endif
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+#define HAVE_NETIF_MSG 1
+#endif
+
 #ifndef HAVE_NETIF_MSG
 #define HAVE_NETIF_MSG 1
 enum {
--- a/Embedded/src/GbE/iegbe_main.c
+++ b/Embedded/src/GbE/iegbe_main.c
@@ -159,9 +159,9 @@ static void iegbe_smartspeed(struct iegb
 static inline int iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter,
                           struct sk_buff *skb);
 
-static void iegbe_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
-static void iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
-static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
+static bool iegbe_vlan_used(struct iegbe_adapter *adapter);
+static int iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
+static int iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
 static void iegbe_restore_vlan(struct iegbe_adapter *adapter);
 
 static int iegbe_notify_reboot(struct notifier_block *,
@@ -324,8 +324,8 @@ static void iegbe_update_mng_vlan(struct
         struct net_device *netdev = adapter->netdev;
 	u16 vid = hw->mng_cookie.vlan_id;
         u16 old_vid = adapter->mng_vlan_id;
-        if (adapter->vlgrp) {
-                if (!vlan_group_get_device(adapter->vlgrp, vid)) {
+        if (iegbe_vlan_used(adapter)) {
+                if (!test_bit(old_vid, adapter->active_vlans)) {
 			if (hw->mng_cookie.status &
                                 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
                                 iegbe_vlan_rx_add_vid(netdev, vid);
@@ -335,7 +335,7 @@ static void iegbe_update_mng_vlan(struct
 
                         if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
                                         (vid != old_vid) &&
-                            !vlan_group_get_device(adapter->vlgrp, old_vid))
+                            !test_bit(old_vid, adapter->active_vlans))
                                 iegbe_vlan_rx_kill_vid(netdev, old_vid);
                 } else
                         adapter->mng_vlan_id = vid;
@@ -736,7 +736,6 @@ static const struct net_device_ops iegbe
 	.ndo_do_ioctl		= iegbe_ioctl,
 	.ndo_validate_addr	= eth_validate_addr,
 
-	.ndo_vlan_rx_register	= iegbe_vlan_rx_register,
 	.ndo_vlan_rx_add_vid	= iegbe_vlan_rx_add_vid,
 	.ndo_vlan_rx_kill_vid	= iegbe_vlan_rx_kill_vid,
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -767,7 +766,6 @@ static int __devinit iegbe_probe(struct
 	u16 eeprom_data = 0;
 	u16 eeprom_apme_mask = E1000_EEPROM_APME;
 	int bars; 
-	DECLARE_MAC_BUF(mac);
 
 	bars = pci_select_bars(pdev, IORESOURCE_MEM);
 	err = pci_enable_device(pdev);
@@ -1247,8 +1245,7 @@ static int iegbe_close(struct net_device
 
 	if ((hw->mng_cookie.status &
 			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
-	     !(adapter->vlgrp &&
-	       vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
+	     !test_bit(adapter->mng_vlan_id, adapter->active_vlans)) {
 		iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
 	}
 	return 0;
@@ -2163,11 +2160,13 @@ static void iegbe_set_rx_mode(struct net
 	struct iegbe_hw *hw = &adapter->hw;
 	struct netdev_hw_addr *ha;
 	bool use_uc = false;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 	struct dev_addr_list *mc_ptr;
-	u32 rctl;
 	u32 hash_value;
-	int i, rar_entries = E1000_RAR_ENTRIES;
 int mta_reg_count = E1000_NUM_MTA_REGISTERS;
+#endif
+	u32 rctl;
+	int i, rar_entries = E1000_RAR_ENTRIES;
 
 	/* reserve RAR[14] for LAA over-write work-around */
 	if (hw->mac_type == iegbe_82571)
@@ -2220,6 +2219,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
 
 	WARN_ON(i == rar_entries);
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 	mc_ptr = netdev->mc_list;
 
 	for (; i < rar_entries; i++) {
@@ -2247,6 +2247,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
 		hash_value = iegbe_hash_mc_addr(hw, mc_ptr->da_addr);
 		iegbe_mta_set(hw, hash_value);
 	}
+#endif
 
 	if (hw->mac_type == iegbe_82542_rev2_0)
 		iegbe_leave_82542_rst(adapter);
@@ -2821,14 +2822,14 @@ static int iegbe_tx_map(struct iegbe_ada
              * Avoid terminating buffers within evenly-aligned
              * dwords. */
             if(unlikely(adapter->pcix_82544 &&
-			   !((unsigned long)(frag->page+offset+size-1) & 4) &&
+			   !((unsigned long)(frag->page.p+offset+size-1) & 4) &&
 			   size > 4))
 				size -= 4;
 
             buffer_info->length = size;
             buffer_info->dma =
                 pci_map_page(adapter->pdev,
-                    frag->page,
+                    frag->page.p,
                     offset,
                     size,
                     PCI_DMA_TODEVICE);
@@ -3131,7 +3132,7 @@ static int iegbe_xmit_frame(struct sk_bu
 		}
 	}
 
-	if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
+	if (unlikely(iegbe_vlan_used(adapter) && vlan_tx_tag_present(skb))) {
 		tx_flags |= E1000_TX_FLAGS_VLAN;
 		tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
 	}
@@ -3832,10 +3833,12 @@ static bool iegbe_clean_rx_irq(struct ie
 
 		skb->protocol = eth_type_trans(skb, netdev);
 
-		if (unlikely(adapter->vlgrp &&
+		if (unlikely(iegbe_vlan_used(adapter) &&
 			    (status & E1000_RXD_STAT_VP))) {
-			vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
-						 le16_to_cpu(rx_desc->special));
+			u16 vid;
+
+			vid = le16_to_cpu(rx_desc->special);
+			__vlan_hwaccel_put_tag(skb, vid);
 		} else {
 			netif_receive_skb(skb);
 		}
@@ -3986,9 +3989,10 @@ copydone:
 			   cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
             adapter->rx_hdr_split++;
 
-        if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
-            vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
-				le16_to_cpu(rx_desc->wb.middle.vlan));
+        if(unlikely(iegbe_vlan_used(adapter) && (staterr & E1000_RXD_STAT_VP))) {
+	    u16 vid;
+	    vid = le16_to_cpu(rx_desc->wb.middle.vlan);
+	    __vlan_hwaccel_put_tag(skb, vid);
         } else {
             netif_receive_skb(skb);
         }
@@ -4496,17 +4500,25 @@ iegbe_io_write(struct iegbe_hw *hw, unsi
     outl(value, port);
 }
 
-static void iegbe_vlan_rx_register(struct net_device *netdev,
-				   struct vlan_group *grp)
+static bool iegbe_vlan_used(struct iegbe_adapter *adapter)
+{
+	u16 vid;
+
+	for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+		return true;
+
+	return false;
+}
+
+static void iegbe_vlan_mode(struct net_device *netdev, bool vlan_on)
 {
     struct iegbe_adapter *adapter = netdev_priv(netdev);
     uint32_t ctrl, rctl;
 
 	if (!test_bit(__E1000_DOWN, &adapter->flags))
     iegbe_irq_disable(adapter);
-    adapter->vlgrp = grp;
 
-    if(grp) {
+    if(vlan_on) {
         /* enable VLAN tag insert/strip */
         ctrl = E1000_READ_REG(&adapter->hw, CTRL);
         ctrl |= E1000_CTRL_VME;
@@ -4538,30 +4550,37 @@ static void iegbe_vlan_rx_register(struc
     iegbe_irq_enable(adapter);
 }
 
-static void iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
+static int iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
 {
     struct iegbe_adapter *adapter = netdev_priv(netdev);
     uint32_t vfta, index;
     if((adapter->hw.mng_cookie.status &
         E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
         (vid == adapter->mng_vlan_id)) {
-        return;
+        return 0;
     }
+
+    if (!iegbe_vlan_used(adapter))
+	iegbe_vlan_mode(netdev, true);
+
     /* add VID to filter table */
     index = (vid >> 0x5) & 0x7F;
     vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
     vfta |= (0x1 << (vid & 0x1F));
     iegbe_write_vfta(&adapter->hw, index, vfta);
+
+    set_bit(vid, adapter->active_vlans);
+
+    return 0;
 }
 
-static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
+static int iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
 {
 	struct iegbe_adapter *adapter = netdev_priv(netdev);
 	u32 vfta, index;
 
 	if (!test_bit(__E1000_DOWN, &adapter->flags))
 	iegbe_irq_disable(adapter);
-	vlan_group_set_device(adapter->vlgrp, vid, NULL);
 	if (!test_bit(__E1000_DOWN, &adapter->flags))
 	iegbe_irq_enable(adapter);
 
@@ -4570,21 +4589,26 @@ static void iegbe_vlan_rx_kill_vid(struc
 	vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
 	vfta &= ~(0x1 << (vid & 0x1F));
 	iegbe_write_vfta(&adapter->hw, index, vfta);
+
+	clear_bit(vid, adapter->active_vlans);
+
+	if (!iegbe_vlan_used(adapter))
+		iegbe_vlan_mode(netdev, false);
+
+	return 0;
 }
 
 static void iegbe_restore_vlan(struct iegbe_adapter *adapter)
 {
-	iegbe_vlan_rx_register(adapter->netdev, adapter->vlgrp);
-
-	if (adapter->vlgrp) {
 		u16 vid;
-		for (vid = 0x0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
-			if (!vlan_group_get_device(adapter->vlgrp, vid))
-				continue;
+
+	if (!iegbe_vlan_used(adapter))
+		return;
+
+	iegbe_vlan_mode(adapter->netdev, true);
+	for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
 			iegbe_vlan_rx_add_vid(adapter->netdev, vid);
 		}
-	}
-}
 
 
 int iegbe_set_spd_dplx(struct iegbe_adapter *adapter, u16 spddplx)
@@ -4864,10 +4888,11 @@ iegbe_resume(struct pci_dev *pdev)
     default:
         break;
     }
-#endif
 
     return 0x0;
 }
+#endif
+
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
 /*
--- a/Embedded/src/GbE/iegbe_ethtool.c
+++ b/Embedded/src/GbE/iegbe_ethtool.c
@@ -327,6 +327,7 @@ iegbe_set_pauseparam(struct net_device *
     return 0;
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 static uint32_t
 iegbe_get_rx_csum(struct net_device *netdev)
 {
@@ -392,6 +393,7 @@ iegbe_set_tso(struct net_device *netdev,
     return 0;
 } 
 #endif /* NETIF_F_TSO */
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */
 
 static uint32_t
 iegbe_get_msglevel(struct net_device *netdev)
@@ -807,6 +809,7 @@ err_setup_rx:
             E1000_82542_##R : E1000_##R;                           \
         return 1;         }  }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 static int
 iegbe_reg_test(struct iegbe_adapter *adapter, uint64_t *data)
 {
@@ -1710,6 +1713,7 @@ iegbe_diag_test(struct net_device *netde
     }
     msleep_interruptible(0xfa0);
 }
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */
 
 static void
 iegbe_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
@@ -1812,6 +1816,7 @@ iegbe_set_wol(struct net_device *netdev,
 /* bit defines for adapter->led_status */
 #define E1000_LED_ON        0
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 static void
 iegbe_led_blink_callback(unsigned long data)
 {
@@ -1864,6 +1869,7 @@ iegbe_phys_id(struct net_device *netdev,
 
     return 0;
 }
+#endif
 
 static int
 iegbe_nway_reset(struct net_device *netdev)
@@ -1876,11 +1882,13 @@ iegbe_nway_reset(struct net_device *netd
     return 0;
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
 static int 
 iegbe_get_stats_count(struct net_device *netdev)
 {
     return E1000_STATS_LEN;
 }
+#endif
 
 static void 
 iegbe_get_ethtool_stats(struct net_device *netdev, 
@@ -1936,6 +1944,8 @@ struct ethtool_ops iegbe_ethtool_ops = {
     .set_ringparam          = iegbe_set_ringparam,
     .get_pauseparam        = iegbe_get_pauseparam,
     .set_pauseparam        = iegbe_set_pauseparam,
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
     .get_rx_csum        = iegbe_get_rx_csum,
     .set_rx_csum        = iegbe_set_rx_csum,
     .get_tx_csum            = iegbe_get_tx_csum,
@@ -1946,11 +1956,13 @@ struct ethtool_ops iegbe_ethtool_ops = {
     .get_tso        = ethtool_op_get_tso,
     .set_tso        = iegbe_set_tso,
 #endif
+
     .self_test_count        = iegbe_diag_test_count,
     .self_test              = iegbe_diag_test,
-    .get_strings            = iegbe_get_strings,
     .phys_id                = iegbe_phys_id,
     .get_stats_count        = iegbe_get_stats_count,
+#endif
+    .get_strings            = iegbe_get_strings,
     .get_ethtool_stats      = iegbe_get_ethtool_stats,
 };
 
--- a/Embedded/src/GbE/gcu_main.c
+++ b/Embedded/src/GbE/gcu_main.c
@@ -93,7 +93,7 @@ static struct pci_driver gcu_driver = {
 };
 
 static struct gcu_adapter *global_adapter = 0;
-static spinlock_t global_adapter_spinlock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(global_adapter_spinlock);
 static unsigned long g_intflags = 0;
 
 MODULE_AUTHOR("Intel(R) Corporation");
--- a/Embedded/src/GbE/iegbe.h
+++ b/Embedded/src/GbE/iegbe.h
@@ -257,7 +257,7 @@ struct iegbe_adapter {
 	struct timer_list tx_fifo_stall_timer;
 	struct timer_list watchdog_timer;
 	struct timer_list phy_info_timer;
-	struct vlan_group *vlgrp;
+	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
     	uint16_t mng_vlan_id;
 	uint32_t bd_number;
 	uint32_t rx_buffer_len;