]>
Commit | Line | Data |
---|---|---|
86641094 | 1 | /* Intel(R) Ethernet Switch Host Interface Driver |
3ee7b3a3 | 2 | * Copyright(c) 2013 - 2017 Intel Corporation. |
0e7b3644 AD |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms and conditions of the GNU General Public License, | |
6 | * version 2, as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope it will be useful, but WITHOUT | |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
11 | * more details. | |
12 | * | |
13 | * The full GNU General Public License is included in this distribution in | |
14 | * the file called "COPYING". | |
15 | * | |
16 | * Contact Information: | |
17 | * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> | |
18 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | |
19 | */ | |
20 | ||
21 | #include "fm10k.h" | |
3abaae42 | 22 | #include <linux/vmalloc.h> |
f174cdbe | 23 | #include <net/udp_tunnel.h> |
3abaae42 AD |
24 | |
25 | /** | |
26 | * fm10k_setup_tx_resources - allocate Tx resources (Descriptors) | |
27 | * @tx_ring: tx descriptor ring (for a specific queue) to setup | |
28 | * | |
29 | * Return 0 on success, negative on failure | |
30 | **/ | |
31 | int fm10k_setup_tx_resources(struct fm10k_ring *tx_ring) | |
32 | { | |
33 | struct device *dev = tx_ring->dev; | |
34 | int size; | |
35 | ||
36 | size = sizeof(struct fm10k_tx_buffer) * tx_ring->count; | |
37 | ||
38 | tx_ring->tx_buffer = vzalloc(size); | |
39 | if (!tx_ring->tx_buffer) | |
40 | goto err; | |
41 | ||
42 | u64_stats_init(&tx_ring->syncp); | |
43 | ||
44 | /* round up to nearest 4K */ | |
45 | tx_ring->size = tx_ring->count * sizeof(struct fm10k_tx_desc); | |
46 | tx_ring->size = ALIGN(tx_ring->size, 4096); | |
47 | ||
48 | tx_ring->desc = dma_alloc_coherent(dev, tx_ring->size, | |
49 | &tx_ring->dma, GFP_KERNEL); | |
50 | if (!tx_ring->desc) | |
51 | goto err; | |
52 | ||
53 | return 0; | |
54 | ||
55 | err: | |
56 | vfree(tx_ring->tx_buffer); | |
57 | tx_ring->tx_buffer = NULL; | |
58 | return -ENOMEM; | |
59 | } | |
60 | ||
61 | /** | |
62 | * fm10k_setup_all_tx_resources - allocate all queues Tx resources | |
63 | * @interface: board private structure | |
64 | * | |
65 | * If this function returns with an error, then it's possible one or | |
66 | * more of the rings is populated (while the rest are not). It is the | |
67 | * callers duty to clean those orphaned rings. | |
68 | * | |
69 | * Return 0 on success, negative on failure | |
70 | **/ | |
71 | static int fm10k_setup_all_tx_resources(struct fm10k_intfc *interface) | |
72 | { | |
73 | int i, err = 0; | |
74 | ||
75 | for (i = 0; i < interface->num_tx_queues; i++) { | |
76 | err = fm10k_setup_tx_resources(interface->tx_ring[i]); | |
77 | if (!err) | |
78 | continue; | |
79 | ||
80 | netif_err(interface, probe, interface->netdev, | |
81 | "Allocation for Tx Queue %u failed\n", i); | |
82 | goto err_setup_tx; | |
83 | } | |
84 | ||
85 | return 0; | |
86 | err_setup_tx: | |
87 | /* rewind the index freeing the rings as we go */ | |
88 | while (i--) | |
89 | fm10k_free_tx_resources(interface->tx_ring[i]); | |
90 | return err; | |
91 | } | |
92 | ||
93 | /** | |
94 | * fm10k_setup_rx_resources - allocate Rx resources (Descriptors) | |
95 | * @rx_ring: rx descriptor ring (for a specific queue) to setup | |
96 | * | |
97 | * Returns 0 on success, negative on failure | |
98 | **/ | |
99 | int fm10k_setup_rx_resources(struct fm10k_ring *rx_ring) | |
100 | { | |
101 | struct device *dev = rx_ring->dev; | |
102 | int size; | |
103 | ||
104 | size = sizeof(struct fm10k_rx_buffer) * rx_ring->count; | |
105 | ||
106 | rx_ring->rx_buffer = vzalloc(size); | |
107 | if (!rx_ring->rx_buffer) | |
108 | goto err; | |
109 | ||
110 | u64_stats_init(&rx_ring->syncp); | |
111 | ||
112 | /* Round up to nearest 4K */ | |
113 | rx_ring->size = rx_ring->count * sizeof(union fm10k_rx_desc); | |
114 | rx_ring->size = ALIGN(rx_ring->size, 4096); | |
115 | ||
116 | rx_ring->desc = dma_alloc_coherent(dev, rx_ring->size, | |
117 | &rx_ring->dma, GFP_KERNEL); | |
118 | if (!rx_ring->desc) | |
119 | goto err; | |
120 | ||
121 | return 0; | |
122 | err: | |
123 | vfree(rx_ring->rx_buffer); | |
124 | rx_ring->rx_buffer = NULL; | |
125 | return -ENOMEM; | |
126 | } | |
127 | ||
128 | /** | |
129 | * fm10k_setup_all_rx_resources - allocate all queues Rx resources | |
130 | * @interface: board private structure | |
131 | * | |
132 | * If this function returns with an error, then it's possible one or | |
133 | * more of the rings is populated (while the rest are not). It is the | |
134 | * callers duty to clean those orphaned rings. | |
135 | * | |
136 | * Return 0 on success, negative on failure | |
137 | **/ | |
138 | static int fm10k_setup_all_rx_resources(struct fm10k_intfc *interface) | |
139 | { | |
140 | int i, err = 0; | |
141 | ||
142 | for (i = 0; i < interface->num_rx_queues; i++) { | |
143 | err = fm10k_setup_rx_resources(interface->rx_ring[i]); | |
144 | if (!err) | |
145 | continue; | |
146 | ||
147 | netif_err(interface, probe, interface->netdev, | |
148 | "Allocation for Rx Queue %u failed\n", i); | |
149 | goto err_setup_rx; | |
150 | } | |
151 | ||
152 | return 0; | |
153 | err_setup_rx: | |
154 | /* rewind the index freeing the rings as we go */ | |
155 | while (i--) | |
156 | fm10k_free_rx_resources(interface->rx_ring[i]); | |
157 | return err; | |
158 | } | |
159 | ||
160 | void fm10k_unmap_and_free_tx_resource(struct fm10k_ring *ring, | |
161 | struct fm10k_tx_buffer *tx_buffer) | |
162 | { | |
163 | if (tx_buffer->skb) { | |
164 | dev_kfree_skb_any(tx_buffer->skb); | |
165 | if (dma_unmap_len(tx_buffer, len)) | |
166 | dma_unmap_single(ring->dev, | |
167 | dma_unmap_addr(tx_buffer, dma), | |
168 | dma_unmap_len(tx_buffer, len), | |
169 | DMA_TO_DEVICE); | |
170 | } else if (dma_unmap_len(tx_buffer, len)) { | |
171 | dma_unmap_page(ring->dev, | |
172 | dma_unmap_addr(tx_buffer, dma), | |
173 | dma_unmap_len(tx_buffer, len), | |
174 | DMA_TO_DEVICE); | |
175 | } | |
176 | tx_buffer->next_to_watch = NULL; | |
177 | tx_buffer->skb = NULL; | |
178 | dma_unmap_len_set(tx_buffer, len, 0); | |
179 | /* tx_buffer must be completely set up in the transmit path */ | |
180 | } | |
181 | ||
182 | /** | |
183 | * fm10k_clean_tx_ring - Free Tx Buffers | |
184 | * @tx_ring: ring to be cleaned | |
185 | **/ | |
186 | static void fm10k_clean_tx_ring(struct fm10k_ring *tx_ring) | |
187 | { | |
188 | struct fm10k_tx_buffer *tx_buffer; | |
189 | unsigned long size; | |
190 | u16 i; | |
191 | ||
192 | /* ring already cleared, nothing to do */ | |
193 | if (!tx_ring->tx_buffer) | |
194 | return; | |
195 | ||
196 | /* Free all the Tx ring sk_buffs */ | |
197 | for (i = 0; i < tx_ring->count; i++) { | |
198 | tx_buffer = &tx_ring->tx_buffer[i]; | |
199 | fm10k_unmap_and_free_tx_resource(tx_ring, tx_buffer); | |
200 | } | |
201 | ||
202 | /* reset BQL values */ | |
203 | netdev_tx_reset_queue(txring_txq(tx_ring)); | |
204 | ||
205 | size = sizeof(struct fm10k_tx_buffer) * tx_ring->count; | |
206 | memset(tx_ring->tx_buffer, 0, size); | |
207 | ||
208 | /* Zero out the descriptor ring */ | |
209 | memset(tx_ring->desc, 0, tx_ring->size); | |
210 | } | |
211 | ||
212 | /** | |
213 | * fm10k_free_tx_resources - Free Tx Resources per Queue | |
214 | * @tx_ring: Tx descriptor ring for a specific queue | |
215 | * | |
216 | * Free all transmit software resources | |
217 | **/ | |
218 | void fm10k_free_tx_resources(struct fm10k_ring *tx_ring) | |
219 | { | |
220 | fm10k_clean_tx_ring(tx_ring); | |
221 | ||
222 | vfree(tx_ring->tx_buffer); | |
223 | tx_ring->tx_buffer = NULL; | |
224 | ||
225 | /* if not set, then don't free */ | |
226 | if (!tx_ring->desc) | |
227 | return; | |
228 | ||
229 | dma_free_coherent(tx_ring->dev, tx_ring->size, | |
230 | tx_ring->desc, tx_ring->dma); | |
231 | tx_ring->desc = NULL; | |
232 | } | |
233 | ||
234 | /** | |
235 | * fm10k_clean_all_tx_rings - Free Tx Buffers for all queues | |
236 | * @interface: board private structure | |
237 | **/ | |
238 | void fm10k_clean_all_tx_rings(struct fm10k_intfc *interface) | |
239 | { | |
240 | int i; | |
241 | ||
242 | for (i = 0; i < interface->num_tx_queues; i++) | |
243 | fm10k_clean_tx_ring(interface->tx_ring[i]); | |
244 | } | |
245 | ||
246 | /** | |
247 | * fm10k_free_all_tx_resources - Free Tx Resources for All Queues | |
248 | * @interface: board private structure | |
249 | * | |
250 | * Free all transmit software resources | |
251 | **/ | |
252 | static void fm10k_free_all_tx_resources(struct fm10k_intfc *interface) | |
253 | { | |
254 | int i = interface->num_tx_queues; | |
255 | ||
256 | while (i--) | |
257 | fm10k_free_tx_resources(interface->tx_ring[i]); | |
258 | } | |
259 | ||
260 | /** | |
261 | * fm10k_clean_rx_ring - Free Rx Buffers per Queue | |
262 | * @rx_ring: ring to free buffers from | |
263 | **/ | |
264 | static void fm10k_clean_rx_ring(struct fm10k_ring *rx_ring) | |
265 | { | |
266 | unsigned long size; | |
267 | u16 i; | |
268 | ||
269 | if (!rx_ring->rx_buffer) | |
270 | return; | |
271 | ||
272 | if (rx_ring->skb) | |
273 | dev_kfree_skb(rx_ring->skb); | |
274 | rx_ring->skb = NULL; | |
275 | ||
276 | /* Free all the Rx ring sk_buffs */ | |
277 | for (i = 0; i < rx_ring->count; i++) { | |
278 | struct fm10k_rx_buffer *buffer = &rx_ring->rx_buffer[i]; | |
279 | /* clean-up will only set page pointer to NULL */ | |
280 | if (!buffer->page) | |
281 | continue; | |
282 | ||
283 | dma_unmap_page(rx_ring->dev, buffer->dma, | |
284 | PAGE_SIZE, DMA_FROM_DEVICE); | |
285 | __free_page(buffer->page); | |
286 | ||
287 | buffer->page = NULL; | |
288 | } | |
289 | ||
290 | size = sizeof(struct fm10k_rx_buffer) * rx_ring->count; | |
291 | memset(rx_ring->rx_buffer, 0, size); | |
292 | ||
293 | /* Zero out the descriptor ring */ | |
294 | memset(rx_ring->desc, 0, rx_ring->size); | |
295 | ||
296 | rx_ring->next_to_alloc = 0; | |
297 | rx_ring->next_to_clean = 0; | |
298 | rx_ring->next_to_use = 0; | |
299 | } | |
300 | ||
301 | /** | |
302 | * fm10k_free_rx_resources - Free Rx Resources | |
303 | * @rx_ring: ring to clean the resources from | |
304 | * | |
305 | * Free all receive software resources | |
306 | **/ | |
307 | void fm10k_free_rx_resources(struct fm10k_ring *rx_ring) | |
308 | { | |
309 | fm10k_clean_rx_ring(rx_ring); | |
310 | ||
311 | vfree(rx_ring->rx_buffer); | |
312 | rx_ring->rx_buffer = NULL; | |
313 | ||
314 | /* if not set, then don't free */ | |
315 | if (!rx_ring->desc) | |
316 | return; | |
317 | ||
318 | dma_free_coherent(rx_ring->dev, rx_ring->size, | |
319 | rx_ring->desc, rx_ring->dma); | |
320 | ||
321 | rx_ring->desc = NULL; | |
322 | } | |
323 | ||
324 | /** | |
325 | * fm10k_clean_all_rx_rings - Free Rx Buffers for all queues | |
326 | * @interface: board private structure | |
327 | **/ | |
328 | void fm10k_clean_all_rx_rings(struct fm10k_intfc *interface) | |
329 | { | |
330 | int i; | |
331 | ||
332 | for (i = 0; i < interface->num_rx_queues; i++) | |
333 | fm10k_clean_rx_ring(interface->rx_ring[i]); | |
334 | } | |
335 | ||
336 | /** | |
337 | * fm10k_free_all_rx_resources - Free Rx Resources for All Queues | |
338 | * @interface: board private structure | |
339 | * | |
340 | * Free all receive software resources | |
341 | **/ | |
342 | static void fm10k_free_all_rx_resources(struct fm10k_intfc *interface) | |
343 | { | |
344 | int i = interface->num_rx_queues; | |
345 | ||
346 | while (i--) | |
347 | fm10k_free_rx_resources(interface->rx_ring[i]); | |
348 | } | |
0e7b3644 | 349 | |
504c5eac AD |
350 | /** |
351 | * fm10k_request_glort_range - Request GLORTs for use in configuring rules | |
352 | * @interface: board private structure | |
353 | * | |
eca32047 | 354 | * This function allocates a range of glorts for this interface to use. |
504c5eac AD |
355 | **/ |
356 | static void fm10k_request_glort_range(struct fm10k_intfc *interface) | |
357 | { | |
358 | struct fm10k_hw *hw = &interface->hw; | |
359 | u16 mask = (~hw->mac.dglort_map) >> FM10K_DGLORTMAP_MASK_SHIFT; | |
360 | ||
361 | /* establish GLORT base */ | |
362 | interface->glort = hw->mac.dglort_map & FM10K_DGLORTMAP_NONE; | |
363 | interface->glort_count = 0; | |
364 | ||
365 | /* nothing we can do until mask is allocated */ | |
366 | if (hw->mac.dglort_map == FM10K_DGLORTMAP_NONE) | |
367 | return; | |
368 | ||
883a9ccb AD |
369 | /* we support 3 possible GLORT configurations. |
370 | * 1: VFs consume all but the last 1 | |
371 | * 2: VFs and PF split glorts with possible gap between | |
372 | * 3: VFs allocated first 64, all others belong to PF | |
373 | */ | |
374 | if (mask <= hw->iov.total_vfs) { | |
375 | interface->glort_count = 1; | |
376 | interface->glort += mask; | |
377 | } else if (mask < 64) { | |
378 | interface->glort_count = (mask + 1) / 2; | |
379 | interface->glort += interface->glort_count; | |
380 | } else { | |
381 | interface->glort_count = mask - 63; | |
382 | interface->glort += 64; | |
383 | } | |
504c5eac AD |
384 | } |
385 | ||
76a540d4 | 386 | /** |
f92e0e48 | 387 | * fm10k_free_udp_port_info |
76a540d4 AD |
388 | * @interface: board private structure |
389 | * | |
1ad78292 | 390 | * This function frees both geneve_port and vxlan_port structures |
76a540d4 | 391 | **/ |
f92e0e48 | 392 | static void fm10k_free_udp_port_info(struct fm10k_intfc *interface) |
76a540d4 | 393 | { |
f92e0e48 JK |
394 | struct fm10k_udp_port *port; |
395 | ||
396 | /* flush all entries from vxlan list */ | |
397 | port = list_first_entry_or_null(&interface->vxlan_port, | |
398 | struct fm10k_udp_port, list); | |
399 | while (port) { | |
400 | list_del(&port->list); | |
401 | kfree(port); | |
402 | port = list_first_entry_or_null(&interface->vxlan_port, | |
403 | struct fm10k_udp_port, | |
404 | list); | |
76a540d4 | 405 | } |
1ad78292 JK |
406 | |
407 | /* flush all entries from geneve list */ | |
408 | port = list_first_entry_or_null(&interface->geneve_port, | |
409 | struct fm10k_udp_port, list); | |
410 | while (port) { | |
411 | list_del(&port->list); | |
412 | kfree(port); | |
413 | port = list_first_entry_or_null(&interface->vxlan_port, | |
414 | struct fm10k_udp_port, | |
415 | list); | |
416 | } | |
76a540d4 AD |
417 | } |
418 | ||
419 | /** | |
f92e0e48 | 420 | * fm10k_restore_udp_port_info |
76a540d4 AD |
421 | * @interface: board private structure |
422 | * | |
f92e0e48 | 423 | * This function restores the value in the tunnel_cfg register(s) after reset |
76a540d4 | 424 | **/ |
f92e0e48 | 425 | static void fm10k_restore_udp_port_info(struct fm10k_intfc *interface) |
76a540d4 AD |
426 | { |
427 | struct fm10k_hw *hw = &interface->hw; | |
f92e0e48 | 428 | struct fm10k_udp_port *port; |
76a540d4 AD |
429 | |
430 | /* only the PF supports configuring tunnels */ | |
431 | if (hw->mac.type != fm10k_mac_pf) | |
432 | return; | |
433 | ||
f92e0e48 JK |
434 | port = list_first_entry_or_null(&interface->vxlan_port, |
435 | struct fm10k_udp_port, list); | |
76a540d4 AD |
436 | |
437 | /* restore tunnel configuration register */ | |
438 | fm10k_write_reg(hw, FM10K_TUNNEL_CFG, | |
f92e0e48 | 439 | (port ? ntohs(port->port) : 0) | |
76a540d4 | 440 | (ETH_P_TEB << FM10K_TUNNEL_CFG_NVGRE_SHIFT)); |
1ad78292 JK |
441 | |
442 | port = list_first_entry_or_null(&interface->geneve_port, | |
443 | struct fm10k_udp_port, list); | |
444 | ||
445 | /* restore Geneve tunnel configuration register */ | |
446 | fm10k_write_reg(hw, FM10K_TUNNEL_CFG_GENEVE, | |
447 | (port ? ntohs(port->port) : 0)); | |
76a540d4 AD |
448 | } |
449 | ||
f92e0e48 JK |
450 | static struct fm10k_udp_port * |
451 | fm10k_remove_tunnel_port(struct list_head *ports, | |
452 | struct udp_tunnel_info *ti) | |
453 | { | |
454 | struct fm10k_udp_port *port; | |
455 | ||
456 | list_for_each_entry(port, ports, list) { | |
457 | if ((port->port == ti->port) && | |
458 | (port->sa_family == ti->sa_family)) { | |
459 | list_del(&port->list); | |
460 | return port; | |
461 | } | |
462 | } | |
463 | ||
464 | return NULL; | |
465 | } | |
466 | ||
467 | static void fm10k_insert_tunnel_port(struct list_head *ports, | |
468 | struct udp_tunnel_info *ti) | |
469 | { | |
470 | struct fm10k_udp_port *port; | |
471 | ||
472 | /* remove existing port entry from the list so that the newest items | |
473 | * are always at the tail of the list. | |
474 | */ | |
475 | port = fm10k_remove_tunnel_port(ports, ti); | |
476 | if (!port) { | |
477 | port = kmalloc(sizeof(*port), GFP_ATOMIC); | |
478 | if (!port) | |
479 | return; | |
480 | port->port = ti->port; | |
481 | port->sa_family = ti->sa_family; | |
482 | } | |
483 | ||
484 | list_add_tail(&port->list, ports); | |
485 | } | |
486 | ||
76a540d4 | 487 | /** |
f92e0e48 | 488 | * fm10k_udp_tunnel_add |
76a540d4 | 489 | * @netdev: network interface device structure |
e5de25dc | 490 | * @ti: Tunnel endpoint information |
76a540d4 | 491 | * |
f92e0e48 | 492 | * This function is called when a new UDP tunnel port has been added. |
1ad78292 JK |
493 | * Due to hardware restrictions, only one port per type can be offloaded at |
494 | * once. | |
76a540d4 | 495 | **/ |
f92e0e48 | 496 | static void fm10k_udp_tunnel_add(struct net_device *dev, |
f174cdbe AD |
497 | struct udp_tunnel_info *ti) |
498 | { | |
76a540d4 | 499 | struct fm10k_intfc *interface = netdev_priv(dev); |
76a540d4 AD |
500 | |
501 | /* only the PF supports configuring tunnels */ | |
502 | if (interface->hw.mac.type != fm10k_mac_pf) | |
503 | return; | |
504 | ||
f92e0e48 JK |
505 | switch (ti->type) { |
506 | case UDP_TUNNEL_TYPE_VXLAN: | |
507 | fm10k_insert_tunnel_port(&interface->vxlan_port, ti); | |
508 | break; | |
1ad78292 JK |
509 | case UDP_TUNNEL_TYPE_GENEVE: |
510 | fm10k_insert_tunnel_port(&interface->geneve_port, ti); | |
511 | break; | |
f92e0e48 | 512 | default: |
76a540d4 | 513 | return; |
f92e0e48 | 514 | } |
76a540d4 | 515 | |
f92e0e48 | 516 | fm10k_restore_udp_port_info(interface); |
76a540d4 AD |
517 | } |
518 | ||
519 | /** | |
f92e0e48 | 520 | * fm10k_udp_tunnel_del |
76a540d4 | 521 | * @netdev: network interface device structure |
e5de25dc | 522 | * @ti: Tunnel endpoint information |
76a540d4 | 523 | * |
f92e0e48 JK |
524 | * This function is called when a new UDP tunnel port is deleted. The freed |
525 | * port will be removed from the list, then we reprogram the offloaded port | |
526 | * based on the head of the list. | |
76a540d4 | 527 | **/ |
f92e0e48 | 528 | static void fm10k_udp_tunnel_del(struct net_device *dev, |
f174cdbe AD |
529 | struct udp_tunnel_info *ti) |
530 | { | |
76a540d4 | 531 | struct fm10k_intfc *interface = netdev_priv(dev); |
f92e0e48 | 532 | struct fm10k_udp_port *port = NULL; |
76a540d4 AD |
533 | |
534 | if (interface->hw.mac.type != fm10k_mac_pf) | |
535 | return; | |
536 | ||
f92e0e48 JK |
537 | switch (ti->type) { |
538 | case UDP_TUNNEL_TYPE_VXLAN: | |
539 | port = fm10k_remove_tunnel_port(&interface->vxlan_port, ti); | |
540 | break; | |
1ad78292 JK |
541 | case UDP_TUNNEL_TYPE_GENEVE: |
542 | port = fm10k_remove_tunnel_port(&interface->geneve_port, ti); | |
543 | break; | |
f92e0e48 JK |
544 | default: |
545 | return; | |
76a540d4 AD |
546 | } |
547 | ||
f92e0e48 JK |
548 | /* if we did remove a port we need to free its memory */ |
549 | kfree(port); | |
550 | ||
551 | fm10k_restore_udp_port_info(interface); | |
76a540d4 AD |
552 | } |
553 | ||
504c5eac AD |
554 | /** |
555 | * fm10k_open - Called when a network interface is made active | |
556 | * @netdev: network interface device structure | |
557 | * | |
558 | * Returns 0 on success, negative value on failure | |
559 | * | |
560 | * The open entry point is called when a network interface is made | |
561 | * active by the system (IFF_UP). At this point all resources needed | |
562 | * for transmit and receive operations are allocated, the interrupt | |
563 | * handler is registered with the OS, the watchdog timer is started, | |
564 | * and the stack is notified that the interface is ready. | |
565 | **/ | |
566 | int fm10k_open(struct net_device *netdev) | |
567 | { | |
568 | struct fm10k_intfc *interface = netdev_priv(netdev); | |
18283cad AD |
569 | int err; |
570 | ||
3abaae42 AD |
571 | /* allocate transmit descriptors */ |
572 | err = fm10k_setup_all_tx_resources(interface); | |
573 | if (err) | |
574 | goto err_setup_tx; | |
575 | ||
576 | /* allocate receive descriptors */ | |
577 | err = fm10k_setup_all_rx_resources(interface); | |
578 | if (err) | |
579 | goto err_setup_rx; | |
580 | ||
18283cad AD |
581 | /* allocate interrupt resources */ |
582 | err = fm10k_qv_request_irq(interface); | |
583 | if (err) | |
584 | goto err_req_irq; | |
504c5eac AD |
585 | |
586 | /* setup GLORT assignment for this port */ | |
587 | fm10k_request_glort_range(interface); | |
588 | ||
e27ef599 | 589 | /* Notify the stack of the actual queue counts */ |
c9d49940 AD |
590 | err = netif_set_real_num_tx_queues(netdev, |
591 | interface->num_tx_queues); | |
592 | if (err) | |
593 | goto err_set_queues; | |
e27ef599 AD |
594 | |
595 | err = netif_set_real_num_rx_queues(netdev, | |
596 | interface->num_rx_queues); | |
597 | if (err) | |
598 | goto err_set_queues; | |
599 | ||
f174cdbe | 600 | udp_tunnel_get_rx_info(netdev); |
0d722ec8 | 601 | |
504c5eac AD |
602 | fm10k_up(interface); |
603 | ||
604 | return 0; | |
18283cad | 605 | |
e27ef599 AD |
606 | err_set_queues: |
607 | fm10k_qv_free_irq(interface); | |
18283cad | 608 | err_req_irq: |
3abaae42 AD |
609 | fm10k_free_all_rx_resources(interface); |
610 | err_setup_rx: | |
611 | fm10k_free_all_tx_resources(interface); | |
612 | err_setup_tx: | |
18283cad | 613 | return err; |
504c5eac AD |
614 | } |
615 | ||
616 | /** | |
617 | * fm10k_close - Disables a network interface | |
618 | * @netdev: network interface device structure | |
619 | * | |
620 | * Returns 0, this is not allowed to fail | |
621 | * | |
622 | * The close entry point is called when an interface is de-activated | |
623 | * by the OS. The hardware is still under the drivers control, but | |
624 | * needs to be disabled. A global MAC reset is issued to stop the | |
625 | * hardware, and all transmit and receive resources are freed. | |
626 | **/ | |
627 | int fm10k_close(struct net_device *netdev) | |
628 | { | |
629 | struct fm10k_intfc *interface = netdev_priv(netdev); | |
630 | ||
631 | fm10k_down(interface); | |
632 | ||
18283cad AD |
633 | fm10k_qv_free_irq(interface); |
634 | ||
f92e0e48 | 635 | fm10k_free_udp_port_info(interface); |
76a540d4 | 636 | |
3abaae42 AD |
637 | fm10k_free_all_tx_resources(interface); |
638 | fm10k_free_all_rx_resources(interface); | |
639 | ||
504c5eac AD |
640 | return 0; |
641 | } | |
642 | ||
0e7b3644 AD |
643 | static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev) |
644 | { | |
b101c962 | 645 | struct fm10k_intfc *interface = netdev_priv(dev); |
c9d49940 | 646 | unsigned int r_idx = skb->queue_mapping; |
b101c962 AD |
647 | int err; |
648 | ||
a4fcad65 | 649 | if ((skb->protocol == htons(ETH_P_8021Q)) && |
df8a39de | 650 | !skb_vlan_tag_present(skb)) { |
b101c962 AD |
651 | /* FM10K only supports hardware tagging, any tags in frame |
652 | * are considered 2nd level or "outer" tags | |
653 | */ | |
654 | struct vlan_hdr *vhdr; | |
655 | __be16 proto; | |
656 | ||
657 | /* make sure skb is not shared */ | |
658 | skb = skb_share_check(skb, GFP_ATOMIC); | |
659 | if (!skb) | |
660 | return NETDEV_TX_OK; | |
661 | ||
662 | /* make sure there is enough room to move the ethernet header */ | |
663 | if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN))) | |
664 | return NETDEV_TX_OK; | |
665 | ||
666 | /* verify the skb head is not shared */ | |
667 | err = skb_cow_head(skb, 0); | |
6f97532e | 668 | if (err) { |
669 | dev_kfree_skb(skb); | |
b101c962 | 670 | return NETDEV_TX_OK; |
6f97532e | 671 | } |
b101c962 | 672 | |
aa502b4a | 673 | /* locate VLAN header */ |
b101c962 AD |
674 | vhdr = (struct vlan_hdr *)(skb->data + ETH_HLEN); |
675 | ||
676 | /* pull the 2 key pieces of data out of it */ | |
677 | __vlan_hwaccel_put_tag(skb, | |
678 | htons(ETH_P_8021Q), | |
679 | ntohs(vhdr->h_vlan_TCI)); | |
680 | proto = vhdr->h_vlan_encapsulated_proto; | |
681 | skb->protocol = (ntohs(proto) >= 1536) ? proto : | |
682 | htons(ETH_P_802_2); | |
683 | ||
684 | /* squash it by moving the ethernet addresses up 4 bytes */ | |
685 | memmove(skb->data + VLAN_HLEN, skb->data, 12); | |
686 | __skb_pull(skb, VLAN_HLEN); | |
687 | skb_reset_mac_header(skb); | |
688 | } | |
689 | ||
690 | /* The minimum packet size for a single buffer is 17B so pad the skb | |
691 | * in order to meet this minimum size requirement. | |
692 | */ | |
693 | if (unlikely(skb->len < 17)) { | |
694 | int pad_len = 17 - skb->len; | |
695 | ||
696 | if (skb_pad(skb, pad_len)) | |
697 | return NETDEV_TX_OK; | |
698 | __skb_put(skb, pad_len); | |
699 | } | |
700 | ||
701 | if (r_idx >= interface->num_tx_queues) | |
702 | r_idx %= interface->num_tx_queues; | |
703 | ||
704 | err = fm10k_xmit_frame_ring(skb, interface->tx_ring[r_idx]); | |
705 | ||
706 | return err; | |
0e7b3644 AD |
707 | } |
708 | ||
b101c962 AD |
709 | /** |
710 | * fm10k_tx_timeout - Respond to a Tx Hang | |
711 | * @netdev: network interface device structure | |
712 | **/ | |
713 | static void fm10k_tx_timeout(struct net_device *netdev) | |
714 | { | |
715 | struct fm10k_intfc *interface = netdev_priv(netdev); | |
716 | bool real_tx_hang = false; | |
717 | int i; | |
718 | ||
719 | #define TX_TIMEO_LIMIT 16000 | |
720 | for (i = 0; i < interface->num_tx_queues; i++) { | |
721 | struct fm10k_ring *tx_ring = interface->tx_ring[i]; | |
722 | ||
723 | if (check_for_tx_hang(tx_ring) && fm10k_check_tx_hang(tx_ring)) | |
724 | real_tx_hang = true; | |
725 | } | |
726 | ||
727 | if (real_tx_hang) { | |
728 | fm10k_tx_timeout_reset(interface); | |
729 | } else { | |
730 | netif_info(interface, drv, netdev, | |
731 | "Fake Tx hang detected with timeout of %d seconds\n", | |
a4fcad65 | 732 | netdev->watchdog_timeo / HZ); |
b101c962 AD |
733 | |
734 | /* fake Tx hang - increase the kernel timeout */ | |
735 | if (netdev->watchdog_timeo < TX_TIMEO_LIMIT) | |
736 | netdev->watchdog_timeo *= 2; | |
737 | } | |
738 | } | |
739 | ||
7d4fe0d1 NMK |
740 | /** |
741 | * fm10k_host_mbx_ready - Check PF interface's mailbox readiness | |
742 | * @interface: board private structure | |
743 | * | |
744 | * This function checks if the PF interface's mailbox is ready before queueing | |
745 | * mailbox messages for transmission. This will prevent filling the TX mailbox | |
746 | * queue when the receiver is not ready. VF interfaces are exempt from this | |
747 | * check since it will block all PF-VF mailbox messages from being sent from | |
748 | * the VF to the PF at initialization. | |
749 | **/ | |
750 | static bool fm10k_host_mbx_ready(struct fm10k_intfc *interface) | |
751 | { | |
752 | struct fm10k_hw *hw = &interface->hw; | |
753 | ||
754 | return (hw->mac.type == fm10k_mac_vf || interface->host_ready); | |
755 | } | |
756 | ||
8f5e20d4 AD |
757 | static int fm10k_uc_vlan_unsync(struct net_device *netdev, |
758 | const unsigned char *uc_addr) | |
759 | { | |
760 | struct fm10k_intfc *interface = netdev_priv(netdev); | |
761 | struct fm10k_hw *hw = &interface->hw; | |
762 | u16 glort = interface->glort; | |
763 | u16 vid = interface->vid; | |
764 | bool set = !!(vid / VLAN_N_VID); | |
7d4fe0d1 | 765 | int err = -EHOSTDOWN; |
8f5e20d4 AD |
766 | |
767 | /* drop any leading bits on the VLAN ID */ | |
768 | vid &= VLAN_N_VID - 1; | |
769 | ||
7d4fe0d1 NMK |
770 | if (fm10k_host_mbx_ready(interface)) |
771 | err = hw->mac.ops.update_uc_addr(hw, glort, uc_addr, | |
772 | vid, set, 0); | |
773 | ||
8f5e20d4 AD |
774 | if (err) |
775 | return err; | |
776 | ||
777 | /* return non-zero value as we are only doing a partial sync/unsync */ | |
778 | return 1; | |
779 | } | |
780 | ||
781 | static int fm10k_mc_vlan_unsync(struct net_device *netdev, | |
782 | const unsigned char *mc_addr) | |
783 | { | |
784 | struct fm10k_intfc *interface = netdev_priv(netdev); | |
785 | struct fm10k_hw *hw = &interface->hw; | |
786 | u16 glort = interface->glort; | |
787 | u16 vid = interface->vid; | |
788 | bool set = !!(vid / VLAN_N_VID); | |
7d4fe0d1 | 789 | int err = -EHOSTDOWN; |
8f5e20d4 AD |
790 | |
791 | /* drop any leading bits on the VLAN ID */ | |
792 | vid &= VLAN_N_VID - 1; | |
793 | ||
7d4fe0d1 NMK |
794 | if (fm10k_host_mbx_ready(interface)) |
795 | err = hw->mac.ops.update_mc_addr(hw, glort, mc_addr, vid, set); | |
796 | ||
8f5e20d4 AD |
797 | if (err) |
798 | return err; | |
799 | ||
800 | /* return non-zero value as we are only doing a partial sync/unsync */ | |
801 | return 1; | |
802 | } | |
803 | ||
804 | static int fm10k_update_vid(struct net_device *netdev, u16 vid, bool set) | |
805 | { | |
806 | struct fm10k_intfc *interface = netdev_priv(netdev); | |
807 | struct fm10k_hw *hw = &interface->hw; | |
808 | s32 err; | |
e71c9318 | 809 | int i; |
8f5e20d4 AD |
810 | |
811 | /* updates do not apply to VLAN 0 */ | |
812 | if (!vid) | |
813 | return 0; | |
814 | ||
815 | if (vid >= VLAN_N_VID) | |
816 | return -EINVAL; | |
817 | ||
818 | /* Verify we have permission to add VLANs */ | |
819 | if (hw->mac.vlan_override) | |
820 | return -EACCES; | |
821 | ||
8f5e20d4 AD |
822 | /* update active_vlans bitmask */ |
823 | set_bit(vid, interface->active_vlans); | |
824 | if (!set) | |
825 | clear_bit(vid, interface->active_vlans); | |
826 | ||
aa502b4a | 827 | /* disable the default VLAN ID on ring if we have an active VLAN */ |
e71c9318 JK |
828 | for (i = 0; i < interface->num_rx_queues; i++) { |
829 | struct fm10k_ring *rx_ring = interface->rx_ring[i]; | |
830 | u16 rx_vid = rx_ring->vid & (VLAN_N_VID - 1); | |
831 | ||
832 | if (test_bit(rx_vid, interface->active_vlans)) | |
833 | rx_ring->vid |= FM10K_VLAN_CLEAR; | |
834 | else | |
835 | rx_ring->vid &= ~FM10K_VLAN_CLEAR; | |
836 | } | |
837 | ||
3d02b3df BA |
838 | /* Do not remove default VLAN ID related entries from VLAN and MAC |
839 | * tables | |
840 | */ | |
56f0569e | 841 | if (!set && vid == hw->mac.default_vid) |
661b2067 JK |
842 | return 0; |
843 | ||
3f0bdb2e JK |
844 | /* Do not throw an error if the interface is down. We will sync once |
845 | * we come up | |
846 | */ | |
46929557 | 847 | if (test_bit(__FM10K_DOWN, interface->state)) |
3f0bdb2e JK |
848 | return 0; |
849 | ||
8f5e20d4 AD |
850 | fm10k_mbx_lock(interface); |
851 | ||
eca32047 | 852 | /* only need to update the VLAN if not in promiscuous mode */ |
8f5e20d4 AD |
853 | if (!(netdev->flags & IFF_PROMISC)) { |
854 | err = hw->mac.ops.update_vlan(hw, vid, 0, set); | |
855 | if (err) | |
13cb2dad | 856 | goto err_out; |
8f5e20d4 AD |
857 | } |
858 | ||
7d4fe0d1 NMK |
859 | /* update our base MAC address if host's mailbox is ready */ |
860 | if (fm10k_host_mbx_ready(interface)) | |
861 | err = hw->mac.ops.update_uc_addr(hw, interface->glort, | |
862 | hw->mac.addr, vid, set, 0); | |
863 | else | |
864 | err = -EHOSTDOWN; | |
865 | ||
8f5e20d4 | 866 | if (err) |
13cb2dad | 867 | goto err_out; |
8f5e20d4 | 868 | |
aa502b4a | 869 | /* set VLAN ID prior to syncing/unsyncing the VLAN */ |
8f5e20d4 AD |
870 | interface->vid = vid + (set ? VLAN_N_VID : 0); |
871 | ||
872 | /* Update the unicast and multicast address list to add/drop VLAN */ | |
873 | __dev_uc_unsync(netdev, fm10k_uc_vlan_unsync); | |
874 | __dev_mc_unsync(netdev, fm10k_mc_vlan_unsync); | |
875 | ||
13cb2dad | 876 | err_out: |
8f5e20d4 AD |
877 | fm10k_mbx_unlock(interface); |
878 | ||
13cb2dad | 879 | return err; |
8f5e20d4 AD |
880 | } |
881 | ||
882 | static int fm10k_vlan_rx_add_vid(struct net_device *netdev, | |
883 | __always_unused __be16 proto, u16 vid) | |
884 | { | |
885 | /* update VLAN and address table based on changes */ | |
886 | return fm10k_update_vid(netdev, vid, true); | |
887 | } | |
888 | ||
889 | static int fm10k_vlan_rx_kill_vid(struct net_device *netdev, | |
890 | __always_unused __be16 proto, u16 vid) | |
891 | { | |
892 | /* update VLAN and address table based on changes */ | |
893 | return fm10k_update_vid(netdev, vid, false); | |
894 | } | |
895 | ||
896 | static u16 fm10k_find_next_vlan(struct fm10k_intfc *interface, u16 vid) | |
897 | { | |
898 | struct fm10k_hw *hw = &interface->hw; | |
899 | u16 default_vid = hw->mac.default_vid; | |
900 | u16 vid_limit = vid < default_vid ? default_vid : VLAN_N_VID; | |
901 | ||
902 | vid = find_next_bit(interface->active_vlans, vid_limit, ++vid); | |
903 | ||
904 | return vid; | |
905 | } | |
906 | ||
907 | static void fm10k_clear_unused_vlans(struct fm10k_intfc *interface) | |
908 | { | |
909 | struct fm10k_hw *hw = &interface->hw; | |
910 | u32 vid, prev_vid; | |
911 | ||
912 | /* loop through and find any gaps in the table */ | |
913 | for (vid = 0, prev_vid = 0; | |
914 | prev_vid < VLAN_N_VID; | |
915 | prev_vid = vid + 1, vid = fm10k_find_next_vlan(interface, vid)) { | |
916 | if (prev_vid == vid) | |
917 | continue; | |
918 | ||
919 | /* send request to clear multiple bits at a time */ | |
920 | prev_vid += (vid - prev_vid - 1) << FM10K_VLAN_LENGTH_SHIFT; | |
921 | hw->mac.ops.update_vlan(hw, prev_vid, 0, false); | |
922 | } | |
923 | } | |
924 | ||
925 | static int __fm10k_uc_sync(struct net_device *dev, | |
926 | const unsigned char *addr, bool sync) | |
927 | { | |
928 | struct fm10k_intfc *interface = netdev_priv(dev); | |
929 | struct fm10k_hw *hw = &interface->hw; | |
930 | u16 vid, glort = interface->glort; | |
931 | s32 err; | |
932 | ||
933 | if (!is_valid_ether_addr(addr)) | |
934 | return -EADDRNOTAVAIL; | |
935 | ||
7d4fe0d1 NMK |
936 | /* update table with current entries if host's mailbox is ready */ |
937 | if (!fm10k_host_mbx_ready(interface)) | |
938 | return -EHOSTDOWN; | |
939 | ||
8998763a | 940 | for (vid = hw->mac.default_vid ? fm10k_find_next_vlan(interface, 0) : 1; |
8f5e20d4 AD |
941 | vid < VLAN_N_VID; |
942 | vid = fm10k_find_next_vlan(interface, vid)) { | |
943 | err = hw->mac.ops.update_uc_addr(hw, glort, addr, | |
7d4fe0d1 | 944 | vid, sync, 0); |
8f5e20d4 AD |
945 | if (err) |
946 | return err; | |
947 | } | |
948 | ||
949 | return 0; | |
950 | } | |
951 | ||
952 | static int fm10k_uc_sync(struct net_device *dev, | |
953 | const unsigned char *addr) | |
954 | { | |
955 | return __fm10k_uc_sync(dev, addr, true); | |
956 | } | |
957 | ||
958 | static int fm10k_uc_unsync(struct net_device *dev, | |
959 | const unsigned char *addr) | |
960 | { | |
961 | return __fm10k_uc_sync(dev, addr, false); | |
962 | } | |
963 | ||
0e7b3644 AD |
964 | static int fm10k_set_mac(struct net_device *dev, void *p) |
965 | { | |
8f5e20d4 AD |
966 | struct fm10k_intfc *interface = netdev_priv(dev); |
967 | struct fm10k_hw *hw = &interface->hw; | |
0e7b3644 AD |
968 | struct sockaddr *addr = p; |
969 | s32 err = 0; | |
970 | ||
971 | if (!is_valid_ether_addr(addr->sa_data)) | |
972 | return -EADDRNOTAVAIL; | |
973 | ||
8f5e20d4 AD |
974 | if (dev->flags & IFF_UP) { |
975 | /* setting MAC address requires mailbox */ | |
976 | fm10k_mbx_lock(interface); | |
977 | ||
978 | err = fm10k_uc_sync(dev, addr->sa_data); | |
979 | if (!err) | |
980 | fm10k_uc_unsync(dev, hw->mac.addr); | |
981 | ||
982 | fm10k_mbx_unlock(interface); | |
983 | } | |
984 | ||
0e7b3644 AD |
985 | if (!err) { |
986 | ether_addr_copy(dev->dev_addr, addr->sa_data); | |
8f5e20d4 | 987 | ether_addr_copy(hw->mac.addr, addr->sa_data); |
0e7b3644 AD |
988 | dev->addr_assign_type &= ~NET_ADDR_RANDOM; |
989 | } | |
990 | ||
8f5e20d4 AD |
991 | /* if we had a mailbox error suggest trying again */ |
992 | return err ? -EAGAIN : 0; | |
993 | } | |
994 | ||
995 | static int __fm10k_mc_sync(struct net_device *dev, | |
996 | const unsigned char *addr, bool sync) | |
997 | { | |
998 | struct fm10k_intfc *interface = netdev_priv(dev); | |
999 | struct fm10k_hw *hw = &interface->hw; | |
1000 | u16 vid, glort = interface->glort; | |
8f5e20d4 | 1001 | |
7d4fe0d1 NMK |
1002 | /* update table with current entries if host's mailbox is ready */ |
1003 | if (!fm10k_host_mbx_ready(interface)) | |
1004 | return 0; | |
1005 | ||
8998763a | 1006 | for (vid = hw->mac.default_vid ? fm10k_find_next_vlan(interface, 0) : 1; |
8f5e20d4 AD |
1007 | vid < VLAN_N_VID; |
1008 | vid = fm10k_find_next_vlan(interface, vid)) { | |
745136a8 | 1009 | hw->mac.ops.update_mc_addr(hw, glort, addr, vid, sync); |
8f5e20d4 AD |
1010 | } |
1011 | ||
1012 | return 0; | |
1013 | } | |
1014 | ||
1015 | static int fm10k_mc_sync(struct net_device *dev, | |
1016 | const unsigned char *addr) | |
1017 | { | |
1018 | return __fm10k_mc_sync(dev, addr, true); | |
1019 | } | |
1020 | ||
1021 | static int fm10k_mc_unsync(struct net_device *dev, | |
1022 | const unsigned char *addr) | |
1023 | { | |
1024 | return __fm10k_mc_sync(dev, addr, false); | |
0e7b3644 AD |
1025 | } |
1026 | ||
1027 | static void fm10k_set_rx_mode(struct net_device *dev) | |
1028 | { | |
8f5e20d4 AD |
1029 | struct fm10k_intfc *interface = netdev_priv(dev); |
1030 | struct fm10k_hw *hw = &interface->hw; | |
1031 | int xcast_mode; | |
1032 | ||
1033 | /* no need to update the harwdare if we are not running */ | |
1034 | if (!(dev->flags & IFF_UP)) | |
1035 | return; | |
1036 | ||
1037 | /* determine new mode based on flags */ | |
1038 | xcast_mode = (dev->flags & IFF_PROMISC) ? FM10K_XCAST_MODE_PROMISC : | |
1039 | (dev->flags & IFF_ALLMULTI) ? FM10K_XCAST_MODE_ALLMULTI : | |
1040 | (dev->flags & (IFF_BROADCAST | IFF_MULTICAST)) ? | |
1041 | FM10K_XCAST_MODE_MULTI : FM10K_XCAST_MODE_NONE; | |
1042 | ||
1043 | fm10k_mbx_lock(interface); | |
1044 | ||
a7731cc8 | 1045 | /* update xcast mode first, but only if it changed */ |
8f5e20d4 AD |
1046 | if (interface->xcast_mode != xcast_mode) { |
1047 | /* update VLAN table */ | |
1048 | if (xcast_mode == FM10K_XCAST_MODE_PROMISC) | |
1049 | hw->mac.ops.update_vlan(hw, FM10K_VLAN_ALL, 0, true); | |
1050 | if (interface->xcast_mode == FM10K_XCAST_MODE_PROMISC) | |
1051 | fm10k_clear_unused_vlans(interface); | |
1052 | ||
7d4fe0d1 NMK |
1053 | /* update xcast mode if host's mailbox is ready */ |
1054 | if (fm10k_host_mbx_ready(interface)) | |
1055 | hw->mac.ops.update_xcast_mode(hw, interface->glort, | |
1056 | xcast_mode); | |
8f5e20d4 AD |
1057 | |
1058 | /* record updated xcast mode state */ | |
1059 | interface->xcast_mode = xcast_mode; | |
1060 | } | |
1061 | ||
a7731cc8 | 1062 | /* synchronize all of the addresses */ |
8998763a NMK |
1063 | __dev_uc_sync(dev, fm10k_uc_sync, fm10k_uc_unsync); |
1064 | __dev_mc_sync(dev, fm10k_mc_sync, fm10k_mc_unsync); | |
a7731cc8 | 1065 | |
8f5e20d4 AD |
1066 | fm10k_mbx_unlock(interface); |
1067 | } | |
1068 | ||
1069 | void fm10k_restore_rx_state(struct fm10k_intfc *interface) | |
1070 | { | |
1071 | struct net_device *netdev = interface->netdev; | |
1072 | struct fm10k_hw *hw = &interface->hw; | |
1073 | int xcast_mode; | |
1074 | u16 vid, glort; | |
1075 | ||
1076 | /* record glort for this interface */ | |
1077 | glort = interface->glort; | |
1078 | ||
1079 | /* convert interface flags to xcast mode */ | |
1080 | if (netdev->flags & IFF_PROMISC) | |
1081 | xcast_mode = FM10K_XCAST_MODE_PROMISC; | |
1082 | else if (netdev->flags & IFF_ALLMULTI) | |
1083 | xcast_mode = FM10K_XCAST_MODE_ALLMULTI; | |
1084 | else if (netdev->flags & (IFF_BROADCAST | IFF_MULTICAST)) | |
1085 | xcast_mode = FM10K_XCAST_MODE_MULTI; | |
1086 | else | |
1087 | xcast_mode = FM10K_XCAST_MODE_NONE; | |
1088 | ||
1089 | fm10k_mbx_lock(interface); | |
1090 | ||
7d4fe0d1 NMK |
1091 | /* Enable logical port if host's mailbox is ready */ |
1092 | if (fm10k_host_mbx_ready(interface)) | |
1093 | hw->mac.ops.update_lport_state(hw, glort, | |
1094 | interface->glort_count, true); | |
8f5e20d4 AD |
1095 | |
1096 | /* update VLAN table */ | |
1097 | hw->mac.ops.update_vlan(hw, FM10K_VLAN_ALL, 0, | |
1098 | xcast_mode == FM10K_XCAST_MODE_PROMISC); | |
1099 | ||
1100 | /* Add filter for VLAN 0 */ | |
1101 | hw->mac.ops.update_vlan(hw, 0, 0, true); | |
1102 | ||
1103 | /* update table with current entries */ | |
8998763a | 1104 | for (vid = hw->mac.default_vid ? fm10k_find_next_vlan(interface, 0) : 1; |
8f5e20d4 AD |
1105 | vid < VLAN_N_VID; |
1106 | vid = fm10k_find_next_vlan(interface, vid)) { | |
1107 | hw->mac.ops.update_vlan(hw, vid, 0, true); | |
7d4fe0d1 NMK |
1108 | |
1109 | /* Update unicast entries if host's mailbox is ready */ | |
1110 | if (fm10k_host_mbx_ready(interface)) | |
1111 | hw->mac.ops.update_uc_addr(hw, glort, hw->mac.addr, | |
1112 | vid, true, 0); | |
8f5e20d4 AD |
1113 | } |
1114 | ||
7d4fe0d1 NMK |
1115 | /* update xcast mode before synchronizing addresses if host's mailbox |
1116 | * is ready | |
1117 | */ | |
1118 | if (fm10k_host_mbx_ready(interface)) | |
1119 | hw->mac.ops.update_xcast_mode(hw, glort, xcast_mode); | |
a7731cc8 | 1120 | |
eca32047 | 1121 | /* synchronize all of the addresses */ |
8998763a NMK |
1122 | __dev_uc_sync(netdev, fm10k_uc_sync, fm10k_uc_unsync); |
1123 | __dev_mc_sync(netdev, fm10k_mc_sync, fm10k_mc_unsync); | |
8f5e20d4 | 1124 | |
8f5e20d4 AD |
1125 | fm10k_mbx_unlock(interface); |
1126 | ||
1127 | /* record updated xcast mode state */ | |
1128 | interface->xcast_mode = xcast_mode; | |
76a540d4 AD |
1129 | |
1130 | /* Restore tunnel configuration */ | |
f92e0e48 | 1131 | fm10k_restore_udp_port_info(interface); |
8f5e20d4 AD |
1132 | } |
1133 | ||
1134 | void fm10k_reset_rx_state(struct fm10k_intfc *interface) | |
1135 | { | |
1136 | struct net_device *netdev = interface->netdev; | |
1137 | struct fm10k_hw *hw = &interface->hw; | |
1138 | ||
1139 | fm10k_mbx_lock(interface); | |
1140 | ||
7d4fe0d1 NMK |
1141 | /* clear the logical port state on lower device if host's mailbox is |
1142 | * ready | |
1143 | */ | |
1144 | if (fm10k_host_mbx_ready(interface)) | |
1145 | hw->mac.ops.update_lport_state(hw, interface->glort, | |
1146 | interface->glort_count, false); | |
8f5e20d4 AD |
1147 | |
1148 | fm10k_mbx_unlock(interface); | |
1149 | ||
1150 | /* reset flags to default state */ | |
1151 | interface->xcast_mode = FM10K_XCAST_MODE_NONE; | |
1152 | ||
1153 | /* clear the sync flag since the lport has been dropped */ | |
1154 | __dev_uc_unsync(netdev, NULL); | |
1155 | __dev_mc_unsync(netdev, NULL); | |
0e7b3644 AD |
1156 | } |
1157 | ||
e27ef599 AD |
1158 | /** |
1159 | * fm10k_get_stats64 - Get System Network Statistics | |
1160 | * @netdev: network interface device structure | |
1161 | * @stats: storage space for 64bit statistics | |
1162 | * | |
02957703 JK |
1163 | * Obtain 64bit statistics in a way that is safe for both 32bit and 64bit |
1164 | * architectures. | |
e27ef599 | 1165 | */ |
bc1f4470 | 1166 | static void fm10k_get_stats64(struct net_device *netdev, |
1167 | struct rtnl_link_stats64 *stats) | |
e27ef599 AD |
1168 | { |
1169 | struct fm10k_intfc *interface = netdev_priv(netdev); | |
1170 | struct fm10k_ring *ring; | |
1171 | unsigned int start, i; | |
1172 | u64 bytes, packets; | |
1173 | ||
1174 | rcu_read_lock(); | |
1175 | ||
1176 | for (i = 0; i < interface->num_rx_queues; i++) { | |
ce4dad2c | 1177 | ring = READ_ONCE(interface->rx_ring[i]); |
e27ef599 AD |
1178 | |
1179 | if (!ring) | |
1180 | continue; | |
1181 | ||
1182 | do { | |
1183 | start = u64_stats_fetch_begin_irq(&ring->syncp); | |
1184 | packets = ring->stats.packets; | |
1185 | bytes = ring->stats.bytes; | |
1186 | } while (u64_stats_fetch_retry_irq(&ring->syncp, start)); | |
1187 | ||
1188 | stats->rx_packets += packets; | |
1189 | stats->rx_bytes += bytes; | |
1190 | } | |
1191 | ||
1192 | for (i = 0; i < interface->num_tx_queues; i++) { | |
ce4dad2c | 1193 | ring = READ_ONCE(interface->tx_ring[i]); |
e27ef599 AD |
1194 | |
1195 | if (!ring) | |
1196 | continue; | |
1197 | ||
1198 | do { | |
1199 | start = u64_stats_fetch_begin_irq(&ring->syncp); | |
1200 | packets = ring->stats.packets; | |
1201 | bytes = ring->stats.bytes; | |
1202 | } while (u64_stats_fetch_retry_irq(&ring->syncp, start)); | |
1203 | ||
1204 | stats->tx_packets += packets; | |
1205 | stats->tx_bytes += bytes; | |
1206 | } | |
1207 | ||
1208 | rcu_read_unlock(); | |
1209 | ||
1210 | /* following stats updated by fm10k_service_task() */ | |
1211 | stats->rx_missed_errors = netdev->stats.rx_missed_errors; | |
e27ef599 AD |
1212 | } |
1213 | ||
aa3ac822 AD |
1214 | int fm10k_setup_tc(struct net_device *dev, u8 tc) |
1215 | { | |
1216 | struct fm10k_intfc *interface = netdev_priv(dev); | |
09f8a82b | 1217 | int err; |
aa3ac822 AD |
1218 | |
1219 | /* Currently only the PF supports priority classes */ | |
1220 | if (tc && (interface->hw.mac.type != fm10k_mac_pf)) | |
1221 | return -EINVAL; | |
1222 | ||
1223 | /* Hardware supports up to 8 traffic classes */ | |
1224 | if (tc > 8) | |
1225 | return -EINVAL; | |
1226 | ||
1227 | /* Hardware has to reinitialize queues to match packet | |
1228 | * buffer alignment. Unfortunately, the hardware is not | |
1229 | * flexible enough to do this dynamically. | |
1230 | */ | |
1231 | if (netif_running(dev)) | |
1232 | fm10k_close(dev); | |
1233 | ||
1234 | fm10k_mbx_free_irq(interface); | |
1235 | ||
1236 | fm10k_clear_queueing_scheme(interface); | |
1237 | ||
1238 | /* we expect the prio_tc map to be repopulated later */ | |
1239 | netdev_reset_tc(dev); | |
1240 | netdev_set_num_tc(dev, tc); | |
1241 | ||
09f8a82b AD |
1242 | err = fm10k_init_queueing_scheme(interface); |
1243 | if (err) | |
1244 | goto err_queueing_scheme; | |
aa3ac822 | 1245 | |
09f8a82b AD |
1246 | err = fm10k_mbx_request_irq(interface); |
1247 | if (err) | |
1248 | goto err_mbx_irq; | |
aa3ac822 | 1249 | |
09f8a82b AD |
1250 | err = netif_running(dev) ? fm10k_open(dev) : 0; |
1251 | if (err) | |
1252 | goto err_open; | |
aa3ac822 AD |
1253 | |
1254 | /* flag to indicate SWPRI has yet to be updated */ | |
3ee7b3a3 | 1255 | set_bit(FM10K_FLAG_SWPRI_CONFIG, interface->flags); |
aa3ac822 AD |
1256 | |
1257 | return 0; | |
09f8a82b AD |
1258 | err_open: |
1259 | fm10k_mbx_free_irq(interface); | |
1260 | err_mbx_irq: | |
1261 | fm10k_clear_queueing_scheme(interface); | |
1262 | err_queueing_scheme: | |
1263 | netif_device_detach(dev); | |
1264 | ||
1265 | return err; | |
aa3ac822 AD |
1266 | } |
1267 | ||
a5fcf8a6 JP |
1268 | static int __fm10k_setup_tc(struct net_device *dev, u32 handle, u32 chain_index, |
1269 | __be16 proto, struct tc_to_netdev *tc) | |
e4c6734e | 1270 | { |
5eb4dce3 | 1271 | if (tc->type != TC_SETUP_MQPRIO) |
e4c6734e JF |
1272 | return -EINVAL; |
1273 | ||
56f36acd AN |
1274 | tc->mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS; |
1275 | ||
1276 | return fm10k_setup_tc(dev, tc->mqprio->num_tc); | |
e4c6734e JF |
1277 | } |
1278 | ||
5cd5e2e9 AD |
1279 | static void fm10k_assign_l2_accel(struct fm10k_intfc *interface, |
1280 | struct fm10k_l2_accel *l2_accel) | |
1281 | { | |
1282 | struct fm10k_ring *ring; | |
1283 | int i; | |
1284 | ||
1285 | for (i = 0; i < interface->num_rx_queues; i++) { | |
1286 | ring = interface->rx_ring[i]; | |
1287 | rcu_assign_pointer(ring->l2_accel, l2_accel); | |
1288 | } | |
1289 | ||
1290 | interface->l2_accel = l2_accel; | |
1291 | } | |
1292 | ||
1293 | static void *fm10k_dfwd_add_station(struct net_device *dev, | |
1294 | struct net_device *sdev) | |
1295 | { | |
1296 | struct fm10k_intfc *interface = netdev_priv(dev); | |
1297 | struct fm10k_l2_accel *l2_accel = interface->l2_accel; | |
1298 | struct fm10k_l2_accel *old_l2_accel = NULL; | |
1299 | struct fm10k_dglort_cfg dglort = { 0 }; | |
1300 | struct fm10k_hw *hw = &interface->hw; | |
1301 | int size = 0, i; | |
1302 | u16 glort; | |
1303 | ||
1304 | /* allocate l2 accel structure if it is not available */ | |
1305 | if (!l2_accel) { | |
1306 | /* verify there is enough free GLORTs to support l2_accel */ | |
1307 | if (interface->glort_count < 7) | |
1308 | return ERR_PTR(-EBUSY); | |
1309 | ||
1310 | size = offsetof(struct fm10k_l2_accel, macvlan[7]); | |
1311 | l2_accel = kzalloc(size, GFP_KERNEL); | |
1312 | if (!l2_accel) | |
1313 | return ERR_PTR(-ENOMEM); | |
1314 | ||
1315 | l2_accel->size = 7; | |
1316 | l2_accel->dglort = interface->glort; | |
1317 | ||
1318 | /* update pointers */ | |
1319 | fm10k_assign_l2_accel(interface, l2_accel); | |
1320 | /* do not expand if we are at our limit */ | |
1321 | } else if ((l2_accel->count == FM10K_MAX_STATIONS) || | |
1322 | (l2_accel->count == (interface->glort_count - 1))) { | |
1323 | return ERR_PTR(-EBUSY); | |
1324 | /* expand if we have hit the size limit */ | |
1325 | } else if (l2_accel->count == l2_accel->size) { | |
1326 | old_l2_accel = l2_accel; | |
1327 | size = offsetof(struct fm10k_l2_accel, | |
1328 | macvlan[(l2_accel->size * 2) + 1]); | |
1329 | l2_accel = kzalloc(size, GFP_KERNEL); | |
1330 | if (!l2_accel) | |
1331 | return ERR_PTR(-ENOMEM); | |
1332 | ||
1333 | memcpy(l2_accel, old_l2_accel, | |
1334 | offsetof(struct fm10k_l2_accel, | |
1335 | macvlan[old_l2_accel->size])); | |
1336 | ||
1337 | l2_accel->size = (old_l2_accel->size * 2) + 1; | |
1338 | ||
1339 | /* update pointers */ | |
1340 | fm10k_assign_l2_accel(interface, l2_accel); | |
1341 | kfree_rcu(old_l2_accel, rcu); | |
1342 | } | |
1343 | ||
1344 | /* add macvlan to accel table, and record GLORT for position */ | |
1345 | for (i = 0; i < l2_accel->size; i++) { | |
1346 | if (!l2_accel->macvlan[i]) | |
1347 | break; | |
1348 | } | |
1349 | ||
1350 | /* record station */ | |
1351 | l2_accel->macvlan[i] = sdev; | |
1352 | l2_accel->count++; | |
1353 | ||
1354 | /* configure default DGLORT mapping for RSS/DCB */ | |
1355 | dglort.idx = fm10k_dglort_pf_rss; | |
1356 | dglort.inner_rss = 1; | |
1357 | dglort.rss_l = fls(interface->ring_feature[RING_F_RSS].mask); | |
1358 | dglort.pc_l = fls(interface->ring_feature[RING_F_QOS].mask); | |
1359 | dglort.glort = interface->glort; | |
1360 | dglort.shared_l = fls(l2_accel->size); | |
1361 | hw->mac.ops.configure_dglort_map(hw, &dglort); | |
1362 | ||
1363 | /* Add rules for this specific dglort to the switch */ | |
1364 | fm10k_mbx_lock(interface); | |
1365 | ||
1366 | glort = l2_accel->dglort + 1 + i; | |
7d4fe0d1 NMK |
1367 | |
1368 | if (fm10k_host_mbx_ready(interface)) { | |
1369 | hw->mac.ops.update_xcast_mode(hw, glort, | |
1370 | FM10K_XCAST_MODE_MULTI); | |
1371 | hw->mac.ops.update_uc_addr(hw, glort, sdev->dev_addr, | |
1372 | 0, true, 0); | |
1373 | } | |
5cd5e2e9 AD |
1374 | |
1375 | fm10k_mbx_unlock(interface); | |
1376 | ||
1377 | return sdev; | |
1378 | } | |
1379 | ||
1380 | static void fm10k_dfwd_del_station(struct net_device *dev, void *priv) | |
1381 | { | |
1382 | struct fm10k_intfc *interface = netdev_priv(dev); | |
ce4dad2c | 1383 | struct fm10k_l2_accel *l2_accel = READ_ONCE(interface->l2_accel); |
5cd5e2e9 AD |
1384 | struct fm10k_dglort_cfg dglort = { 0 }; |
1385 | struct fm10k_hw *hw = &interface->hw; | |
1386 | struct net_device *sdev = priv; | |
1387 | int i; | |
1388 | u16 glort; | |
1389 | ||
1390 | if (!l2_accel) | |
1391 | return; | |
1392 | ||
1393 | /* search table for matching interface */ | |
1394 | for (i = 0; i < l2_accel->size; i++) { | |
1395 | if (l2_accel->macvlan[i] == sdev) | |
1396 | break; | |
1397 | } | |
1398 | ||
1399 | /* exit if macvlan not found */ | |
1400 | if (i == l2_accel->size) | |
1401 | return; | |
1402 | ||
1403 | /* Remove any rules specific to this dglort */ | |
1404 | fm10k_mbx_lock(interface); | |
1405 | ||
1406 | glort = l2_accel->dglort + 1 + i; | |
7d4fe0d1 NMK |
1407 | |
1408 | if (fm10k_host_mbx_ready(interface)) { | |
1409 | hw->mac.ops.update_xcast_mode(hw, glort, | |
1410 | FM10K_XCAST_MODE_NONE); | |
1411 | hw->mac.ops.update_uc_addr(hw, glort, sdev->dev_addr, | |
1412 | 0, false, 0); | |
1413 | } | |
5cd5e2e9 AD |
1414 | |
1415 | fm10k_mbx_unlock(interface); | |
1416 | ||
1417 | /* record removal */ | |
1418 | l2_accel->macvlan[i] = NULL; | |
1419 | l2_accel->count--; | |
1420 | ||
1421 | /* configure default DGLORT mapping for RSS/DCB */ | |
1422 | dglort.idx = fm10k_dglort_pf_rss; | |
1423 | dglort.inner_rss = 1; | |
1424 | dglort.rss_l = fls(interface->ring_feature[RING_F_RSS].mask); | |
1425 | dglort.pc_l = fls(interface->ring_feature[RING_F_QOS].mask); | |
1426 | dglort.glort = interface->glort; | |
f1f3322e | 1427 | dglort.shared_l = fls(l2_accel->size); |
5cd5e2e9 AD |
1428 | hw->mac.ops.configure_dglort_map(hw, &dglort); |
1429 | ||
1430 | /* If table is empty remove it */ | |
1431 | if (l2_accel->count == 0) { | |
1432 | fm10k_assign_l2_accel(interface, NULL); | |
1433 | kfree_rcu(l2_accel, rcu); | |
1434 | } | |
1435 | } | |
1436 | ||
5bf33dc6 MV |
1437 | static netdev_features_t fm10k_features_check(struct sk_buff *skb, |
1438 | struct net_device *dev, | |
1439 | netdev_features_t features) | |
1440 | { | |
1441 | if (!skb->encapsulation || fm10k_tx_encap_offload(skb)) | |
1442 | return features; | |
1443 | ||
a188222b | 1444 | return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); |
5bf33dc6 MV |
1445 | } |
1446 | ||
0e7b3644 | 1447 | static const struct net_device_ops fm10k_netdev_ops = { |
504c5eac AD |
1448 | .ndo_open = fm10k_open, |
1449 | .ndo_stop = fm10k_close, | |
0e7b3644 AD |
1450 | .ndo_validate_addr = eth_validate_addr, |
1451 | .ndo_start_xmit = fm10k_xmit_frame, | |
1452 | .ndo_set_mac_address = fm10k_set_mac, | |
b101c962 | 1453 | .ndo_tx_timeout = fm10k_tx_timeout, |
8f5e20d4 AD |
1454 | .ndo_vlan_rx_add_vid = fm10k_vlan_rx_add_vid, |
1455 | .ndo_vlan_rx_kill_vid = fm10k_vlan_rx_kill_vid, | |
0e7b3644 | 1456 | .ndo_set_rx_mode = fm10k_set_rx_mode, |
e27ef599 | 1457 | .ndo_get_stats64 = fm10k_get_stats64, |
e4c6734e | 1458 | .ndo_setup_tc = __fm10k_setup_tc, |
883a9ccb AD |
1459 | .ndo_set_vf_mac = fm10k_ndo_set_vf_mac, |
1460 | .ndo_set_vf_vlan = fm10k_ndo_set_vf_vlan, | |
1461 | .ndo_set_vf_rate = fm10k_ndo_set_vf_bw, | |
1462 | .ndo_get_vf_config = fm10k_ndo_get_vf_config, | |
f92e0e48 JK |
1463 | .ndo_udp_tunnel_add = fm10k_udp_tunnel_add, |
1464 | .ndo_udp_tunnel_del = fm10k_udp_tunnel_del, | |
5cd5e2e9 AD |
1465 | .ndo_dfwd_add_station = fm10k_dfwd_add_station, |
1466 | .ndo_dfwd_del_station = fm10k_dfwd_del_station, | |
8b4a98c7 JK |
1467 | #ifdef CONFIG_NET_POLL_CONTROLLER |
1468 | .ndo_poll_controller = fm10k_netpoll, | |
1469 | #endif | |
5bf33dc6 | 1470 | .ndo_features_check = fm10k_features_check, |
0e7b3644 AD |
1471 | }; |
1472 | ||
1473 | #define DEFAULT_DEBUG_LEVEL_SHIFT 3 | |
1474 | ||
e0244903 | 1475 | struct net_device *fm10k_alloc_netdev(const struct fm10k_info *info) |
0e7b3644 | 1476 | { |
e0244903 | 1477 | netdev_features_t hw_features; |
0e7b3644 AD |
1478 | struct fm10k_intfc *interface; |
1479 | struct net_device *dev; | |
1480 | ||
e27ef599 | 1481 | dev = alloc_etherdev_mq(sizeof(struct fm10k_intfc), MAX_QUEUES); |
0e7b3644 AD |
1482 | if (!dev) |
1483 | return NULL; | |
1484 | ||
1485 | /* set net device and ethtool ops */ | |
1486 | dev->netdev_ops = &fm10k_netdev_ops; | |
82dd0f7e | 1487 | fm10k_set_ethtool_ops(dev); |
0e7b3644 AD |
1488 | |
1489 | /* configure default debug level */ | |
1490 | interface = netdev_priv(dev); | |
fcdb0a99 | 1491 | interface->msg_enable = BIT(DEFAULT_DEBUG_LEVEL_SHIFT) - 1; |
0e7b3644 AD |
1492 | |
1493 | /* configure default features */ | |
76a540d4 AD |
1494 | dev->features |= NETIF_F_IP_CSUM | |
1495 | NETIF_F_IPV6_CSUM | | |
1496 | NETIF_F_SG | | |
1497 | NETIF_F_TSO | | |
1498 | NETIF_F_TSO6 | | |
1499 | NETIF_F_TSO_ECN | | |
76a540d4 AD |
1500 | NETIF_F_RXHASH | |
1501 | NETIF_F_RXCSUM; | |
0e7b3644 | 1502 | |
e0244903 JK |
1503 | /* Only the PF can support VXLAN and NVGRE tunnel offloads */ |
1504 | if (info->mac == fm10k_mac_pf) { | |
1505 | dev->hw_enc_features = NETIF_F_IP_CSUM | | |
1506 | NETIF_F_TSO | | |
1507 | NETIF_F_TSO6 | | |
1508 | NETIF_F_TSO_ECN | | |
1509 | NETIF_F_GSO_UDP_TUNNEL | | |
1510 | NETIF_F_IPV6_CSUM | | |
1511 | NETIF_F_SG; | |
1512 | ||
1513 | dev->features |= NETIF_F_GSO_UDP_TUNNEL; | |
1514 | } | |
1515 | ||
0e7b3644 | 1516 | /* all features defined to this point should be changeable */ |
e0244903 | 1517 | hw_features = dev->features; |
0e7b3644 | 1518 | |
5cd5e2e9 | 1519 | /* allow user to enable L2 forwarding acceleration */ |
e0244903 | 1520 | hw_features |= NETIF_F_HW_L2FW_DOFFLOAD; |
5cd5e2e9 | 1521 | |
0e7b3644 AD |
1522 | /* configure VLAN features */ |
1523 | dev->vlan_features |= dev->features; | |
1524 | ||
8f5e20d4 AD |
1525 | /* we want to leave these both on as we cannot disable VLAN tag |
1526 | * insertion or stripping on the hardware since it is contained | |
1527 | * in the FTAG and not in the frame itself. | |
1528 | */ | |
1529 | dev->features |= NETIF_F_HW_VLAN_CTAG_TX | | |
1530 | NETIF_F_HW_VLAN_CTAG_RX | | |
1531 | NETIF_F_HW_VLAN_CTAG_FILTER; | |
1532 | ||
1533 | dev->priv_flags |= IFF_UNICAST_FLT; | |
1534 | ||
e0244903 JK |
1535 | dev->hw_features |= hw_features; |
1536 | ||
91c527a5 JW |
1537 | /* MTU range: 68 - 15342 */ |
1538 | dev->min_mtu = ETH_MIN_MTU; | |
1539 | dev->max_mtu = FM10K_MAX_JUMBO_FRAME_SIZE; | |
1540 | ||
0e7b3644 AD |
1541 | return dev; |
1542 | } |