1 /* Intel(R) Ethernet Switch Host Interface Driver
2 * Copyright(c) 2013 - 2017 Intel Corporation.
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.
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
13 * The full GNU General Public License is included in this distribution in
14 * the file called "COPYING".
16 * Contact Information:
18 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
22 #include <linux/vmalloc.h>
23 #include <net/udp_tunnel.h>
26 * fm10k_setup_tx_resources - allocate Tx resources (Descriptors)
27 * @tx_ring: tx descriptor ring (for a specific queue) to setup
29 * Return 0 on success, negative on failure
31 int fm10k_setup_tx_resources(struct fm10k_ring *tx_ring)
33 struct device *dev = tx_ring->dev;
36 size = sizeof(struct fm10k_tx_buffer) * tx_ring->count;
38 tx_ring->tx_buffer = vzalloc(size);
39 if (!tx_ring->tx_buffer)
42 u64_stats_init(&tx_ring->syncp);
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);
48 tx_ring->desc = dma_alloc_coherent(dev, tx_ring->size,
49 &tx_ring->dma, GFP_KERNEL);
56 vfree(tx_ring->tx_buffer);
57 tx_ring->tx_buffer = NULL;
62 * fm10k_setup_all_tx_resources - allocate all queues Tx resources
63 * @interface: board private structure
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.
69 * Return 0 on success, negative on failure
71 static int fm10k_setup_all_tx_resources(struct fm10k_intfc *interface)
75 for (i = 0; i < interface->num_tx_queues; i++) {
76 err = fm10k_setup_tx_resources(interface->tx_ring[i]);
80 netif_err(interface, probe, interface->netdev,
81 "Allocation for Tx Queue %u failed\n", i);
87 /* rewind the index freeing the rings as we go */
89 fm10k_free_tx_resources(interface->tx_ring[i]);
94 * fm10k_setup_rx_resources - allocate Rx resources (Descriptors)
95 * @rx_ring: rx descriptor ring (for a specific queue) to setup
97 * Returns 0 on success, negative on failure
99 int fm10k_setup_rx_resources(struct fm10k_ring *rx_ring)
101 struct device *dev = rx_ring->dev;
104 size = sizeof(struct fm10k_rx_buffer) * rx_ring->count;
106 rx_ring->rx_buffer = vzalloc(size);
107 if (!rx_ring->rx_buffer)
110 u64_stats_init(&rx_ring->syncp);
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);
116 rx_ring->desc = dma_alloc_coherent(dev, rx_ring->size,
117 &rx_ring->dma, GFP_KERNEL);
123 vfree(rx_ring->rx_buffer);
124 rx_ring->rx_buffer = NULL;
129 * fm10k_setup_all_rx_resources - allocate all queues Rx resources
130 * @interface: board private structure
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.
136 * Return 0 on success, negative on failure
138 static int fm10k_setup_all_rx_resources(struct fm10k_intfc *interface)
142 for (i = 0; i < interface->num_rx_queues; i++) {
143 err = fm10k_setup_rx_resources(interface->rx_ring[i]);
147 netif_err(interface, probe, interface->netdev,
148 "Allocation for Rx Queue %u failed\n", i);
154 /* rewind the index freeing the rings as we go */
156 fm10k_free_rx_resources(interface->rx_ring[i]);
160 void fm10k_unmap_and_free_tx_resource(struct fm10k_ring *ring,
161 struct fm10k_tx_buffer *tx_buffer)
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),
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),
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 */
183 * fm10k_clean_tx_ring - Free Tx Buffers
184 * @tx_ring: ring to be cleaned
186 static void fm10k_clean_tx_ring(struct fm10k_ring *tx_ring)
188 struct fm10k_tx_buffer *tx_buffer;
192 /* ring already cleared, nothing to do */
193 if (!tx_ring->tx_buffer)
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);
202 /* reset BQL values */
203 netdev_tx_reset_queue(txring_txq(tx_ring));
205 size = sizeof(struct fm10k_tx_buffer) * tx_ring->count;
206 memset(tx_ring->tx_buffer, 0, size);
208 /* Zero out the descriptor ring */
209 memset(tx_ring->desc, 0, tx_ring->size);
213 * fm10k_free_tx_resources - Free Tx Resources per Queue
214 * @tx_ring: Tx descriptor ring for a specific queue
216 * Free all transmit software resources
218 void fm10k_free_tx_resources(struct fm10k_ring *tx_ring)
220 fm10k_clean_tx_ring(tx_ring);
222 vfree(tx_ring->tx_buffer);
223 tx_ring->tx_buffer = NULL;
225 /* if not set, then don't free */
229 dma_free_coherent(tx_ring->dev, tx_ring->size,
230 tx_ring->desc, tx_ring->dma);
231 tx_ring->desc = NULL;
235 * fm10k_clean_all_tx_rings - Free Tx Buffers for all queues
236 * @interface: board private structure
238 void fm10k_clean_all_tx_rings(struct fm10k_intfc *interface)
242 for (i = 0; i < interface->num_tx_queues; i++)
243 fm10k_clean_tx_ring(interface->tx_ring[i]);
247 * fm10k_free_all_tx_resources - Free Tx Resources for All Queues
248 * @interface: board private structure
250 * Free all transmit software resources
252 static void fm10k_free_all_tx_resources(struct fm10k_intfc *interface)
254 int i = interface->num_tx_queues;
257 fm10k_free_tx_resources(interface->tx_ring[i]);
261 * fm10k_clean_rx_ring - Free Rx Buffers per Queue
262 * @rx_ring: ring to free buffers from
264 static void fm10k_clean_rx_ring(struct fm10k_ring *rx_ring)
269 if (!rx_ring->rx_buffer)
273 dev_kfree_skb(rx_ring->skb);
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 */
283 dma_unmap_page(rx_ring->dev, buffer->dma,
284 PAGE_SIZE, DMA_FROM_DEVICE);
285 __free_page(buffer->page);
290 size = sizeof(struct fm10k_rx_buffer) * rx_ring->count;
291 memset(rx_ring->rx_buffer, 0, size);
293 /* Zero out the descriptor ring */
294 memset(rx_ring->desc, 0, rx_ring->size);
296 rx_ring->next_to_alloc = 0;
297 rx_ring->next_to_clean = 0;
298 rx_ring->next_to_use = 0;
302 * fm10k_free_rx_resources - Free Rx Resources
303 * @rx_ring: ring to clean the resources from
305 * Free all receive software resources
307 void fm10k_free_rx_resources(struct fm10k_ring *rx_ring)
309 fm10k_clean_rx_ring(rx_ring);
311 vfree(rx_ring->rx_buffer);
312 rx_ring->rx_buffer = NULL;
314 /* if not set, then don't free */
318 dma_free_coherent(rx_ring->dev, rx_ring->size,
319 rx_ring->desc, rx_ring->dma);
321 rx_ring->desc = NULL;
325 * fm10k_clean_all_rx_rings - Free Rx Buffers for all queues
326 * @interface: board private structure
328 void fm10k_clean_all_rx_rings(struct fm10k_intfc *interface)
332 for (i = 0; i < interface->num_rx_queues; i++)
333 fm10k_clean_rx_ring(interface->rx_ring[i]);
337 * fm10k_free_all_rx_resources - Free Rx Resources for All Queues
338 * @interface: board private structure
340 * Free all receive software resources
342 static void fm10k_free_all_rx_resources(struct fm10k_intfc *interface)
344 int i = interface->num_rx_queues;
347 fm10k_free_rx_resources(interface->rx_ring[i]);
351 * fm10k_request_glort_range - Request GLORTs for use in configuring rules
352 * @interface: board private structure
354 * This function allocates a range of glorts for this interface to use.
356 static void fm10k_request_glort_range(struct fm10k_intfc *interface)
358 struct fm10k_hw *hw = &interface->hw;
359 u16 mask = (~hw->mac.dglort_map) >> FM10K_DGLORTMAP_MASK_SHIFT;
361 /* establish GLORT base */
362 interface->glort = hw->mac.dglort_map & FM10K_DGLORTMAP_NONE;
363 interface->glort_count = 0;
365 /* nothing we can do until mask is allocated */
366 if (hw->mac.dglort_map == FM10K_DGLORTMAP_NONE)
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
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;
381 interface->glort_count = mask - 63;
382 interface->glort += 64;
387 * fm10k_free_udp_port_info
388 * @interface: board private structure
390 * This function frees both geneve_port and vxlan_port structures
392 static void fm10k_free_udp_port_info(struct fm10k_intfc *interface)
394 struct fm10k_udp_port *port;
396 /* flush all entries from vxlan list */
397 port = list_first_entry_or_null(&interface->vxlan_port,
398 struct fm10k_udp_port, list);
400 list_del(&port->list);
402 port = list_first_entry_or_null(&interface->vxlan_port,
403 struct fm10k_udp_port,
407 /* flush all entries from geneve list */
408 port = list_first_entry_or_null(&interface->geneve_port,
409 struct fm10k_udp_port, list);
411 list_del(&port->list);
413 port = list_first_entry_or_null(&interface->vxlan_port,
414 struct fm10k_udp_port,
420 * fm10k_restore_udp_port_info
421 * @interface: board private structure
423 * This function restores the value in the tunnel_cfg register(s) after reset
425 static void fm10k_restore_udp_port_info(struct fm10k_intfc *interface)
427 struct fm10k_hw *hw = &interface->hw;
428 struct fm10k_udp_port *port;
430 /* only the PF supports configuring tunnels */
431 if (hw->mac.type != fm10k_mac_pf)
434 port = list_first_entry_or_null(&interface->vxlan_port,
435 struct fm10k_udp_port, list);
437 /* restore tunnel configuration register */
438 fm10k_write_reg(hw, FM10K_TUNNEL_CFG,
439 (port ? ntohs(port->port) : 0) |
440 (ETH_P_TEB << FM10K_TUNNEL_CFG_NVGRE_SHIFT));
442 port = list_first_entry_or_null(&interface->geneve_port,
443 struct fm10k_udp_port, list);
445 /* restore Geneve tunnel configuration register */
446 fm10k_write_reg(hw, FM10K_TUNNEL_CFG_GENEVE,
447 (port ? ntohs(port->port) : 0));
450 static struct fm10k_udp_port *
451 fm10k_remove_tunnel_port(struct list_head *ports,
452 struct udp_tunnel_info *ti)
454 struct fm10k_udp_port *port;
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);
467 static void fm10k_insert_tunnel_port(struct list_head *ports,
468 struct udp_tunnel_info *ti)
470 struct fm10k_udp_port *port;
472 /* remove existing port entry from the list so that the newest items
473 * are always at the tail of the list.
475 port = fm10k_remove_tunnel_port(ports, ti);
477 port = kmalloc(sizeof(*port), GFP_ATOMIC);
480 port->port = ti->port;
481 port->sa_family = ti->sa_family;
484 list_add_tail(&port->list, ports);
488 * fm10k_udp_tunnel_add
489 * @netdev: network interface device structure
490 * @ti: Tunnel endpoint information
492 * This function is called when a new UDP tunnel port has been added.
493 * Due to hardware restrictions, only one port per type can be offloaded at
496 static void fm10k_udp_tunnel_add(struct net_device *dev,
497 struct udp_tunnel_info *ti)
499 struct fm10k_intfc *interface = netdev_priv(dev);
501 /* only the PF supports configuring tunnels */
502 if (interface->hw.mac.type != fm10k_mac_pf)
506 case UDP_TUNNEL_TYPE_VXLAN:
507 fm10k_insert_tunnel_port(&interface->vxlan_port, ti);
509 case UDP_TUNNEL_TYPE_GENEVE:
510 fm10k_insert_tunnel_port(&interface->geneve_port, ti);
516 fm10k_restore_udp_port_info(interface);
520 * fm10k_udp_tunnel_del
521 * @netdev: network interface device structure
522 * @ti: Tunnel endpoint information
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.
528 static void fm10k_udp_tunnel_del(struct net_device *dev,
529 struct udp_tunnel_info *ti)
531 struct fm10k_intfc *interface = netdev_priv(dev);
532 struct fm10k_udp_port *port = NULL;
534 if (interface->hw.mac.type != fm10k_mac_pf)
538 case UDP_TUNNEL_TYPE_VXLAN:
539 port = fm10k_remove_tunnel_port(&interface->vxlan_port, ti);
541 case UDP_TUNNEL_TYPE_GENEVE:
542 port = fm10k_remove_tunnel_port(&interface->geneve_port, ti);
548 /* if we did remove a port we need to free its memory */
551 fm10k_restore_udp_port_info(interface);
555 * fm10k_open - Called when a network interface is made active
556 * @netdev: network interface device structure
558 * Returns 0 on success, negative value on failure
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.
566 int fm10k_open(struct net_device *netdev)
568 struct fm10k_intfc *interface = netdev_priv(netdev);
571 /* allocate transmit descriptors */
572 err = fm10k_setup_all_tx_resources(interface);
576 /* allocate receive descriptors */
577 err = fm10k_setup_all_rx_resources(interface);
581 /* allocate interrupt resources */
582 err = fm10k_qv_request_irq(interface);
586 /* setup GLORT assignment for this port */
587 fm10k_request_glort_range(interface);
589 /* Notify the stack of the actual queue counts */
590 err = netif_set_real_num_tx_queues(netdev,
591 interface->num_tx_queues);
595 err = netif_set_real_num_rx_queues(netdev,
596 interface->num_rx_queues);
600 udp_tunnel_get_rx_info(netdev);
607 fm10k_qv_free_irq(interface);
609 fm10k_free_all_rx_resources(interface);
611 fm10k_free_all_tx_resources(interface);
617 * fm10k_close - Disables a network interface
618 * @netdev: network interface device structure
620 * Returns 0, this is not allowed to fail
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.
627 int fm10k_close(struct net_device *netdev)
629 struct fm10k_intfc *interface = netdev_priv(netdev);
631 fm10k_down(interface);
633 fm10k_qv_free_irq(interface);
635 fm10k_free_udp_port_info(interface);
637 fm10k_free_all_tx_resources(interface);
638 fm10k_free_all_rx_resources(interface);
643 static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev)
645 struct fm10k_intfc *interface = netdev_priv(dev);
646 int num_tx_queues = READ_ONCE(interface->num_tx_queues);
647 unsigned int r_idx = skb->queue_mapping;
651 return NETDEV_TX_BUSY;
653 if ((skb->protocol == htons(ETH_P_8021Q)) &&
654 !skb_vlan_tag_present(skb)) {
655 /* FM10K only supports hardware tagging, any tags in frame
656 * are considered 2nd level or "outer" tags
658 struct vlan_hdr *vhdr;
661 /* make sure skb is not shared */
662 skb = skb_share_check(skb, GFP_ATOMIC);
666 /* make sure there is enough room to move the ethernet header */
667 if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN)))
670 /* verify the skb head is not shared */
671 err = skb_cow_head(skb, 0);
677 /* locate VLAN header */
678 vhdr = (struct vlan_hdr *)(skb->data + ETH_HLEN);
680 /* pull the 2 key pieces of data out of it */
681 __vlan_hwaccel_put_tag(skb,
683 ntohs(vhdr->h_vlan_TCI));
684 proto = vhdr->h_vlan_encapsulated_proto;
685 skb->protocol = (ntohs(proto) >= 1536) ? proto :
688 /* squash it by moving the ethernet addresses up 4 bytes */
689 memmove(skb->data + VLAN_HLEN, skb->data, 12);
690 __skb_pull(skb, VLAN_HLEN);
691 skb_reset_mac_header(skb);
694 /* The minimum packet size for a single buffer is 17B so pad the skb
695 * in order to meet this minimum size requirement.
697 if (unlikely(skb->len < 17)) {
698 int pad_len = 17 - skb->len;
700 if (skb_pad(skb, pad_len))
702 __skb_put(skb, pad_len);
705 if (r_idx >= num_tx_queues)
706 r_idx %= num_tx_queues;
708 err = fm10k_xmit_frame_ring(skb, interface->tx_ring[r_idx]);
714 * fm10k_tx_timeout - Respond to a Tx Hang
715 * @netdev: network interface device structure
717 static void fm10k_tx_timeout(struct net_device *netdev)
719 struct fm10k_intfc *interface = netdev_priv(netdev);
720 bool real_tx_hang = false;
723 #define TX_TIMEO_LIMIT 16000
724 for (i = 0; i < interface->num_tx_queues; i++) {
725 struct fm10k_ring *tx_ring = interface->tx_ring[i];
727 if (check_for_tx_hang(tx_ring) && fm10k_check_tx_hang(tx_ring))
732 fm10k_tx_timeout_reset(interface);
734 netif_info(interface, drv, netdev,
735 "Fake Tx hang detected with timeout of %d seconds\n",
736 netdev->watchdog_timeo / HZ);
738 /* fake Tx hang - increase the kernel timeout */
739 if (netdev->watchdog_timeo < TX_TIMEO_LIMIT)
740 netdev->watchdog_timeo *= 2;
745 * fm10k_host_mbx_ready - Check PF interface's mailbox readiness
746 * @interface: board private structure
748 * This function checks if the PF interface's mailbox is ready before queueing
749 * mailbox messages for transmission. This will prevent filling the TX mailbox
750 * queue when the receiver is not ready. VF interfaces are exempt from this
751 * check since it will block all PF-VF mailbox messages from being sent from
752 * the VF to the PF at initialization.
754 static bool fm10k_host_mbx_ready(struct fm10k_intfc *interface)
756 struct fm10k_hw *hw = &interface->hw;
758 return (hw->mac.type == fm10k_mac_vf || interface->host_ready);
762 * fm10k_queue_vlan_request - Queue a VLAN update request
763 * @interface: the fm10k interface structure
765 * @vsi: VSI index number
766 * @set: whether to set or clear
768 * This function queues up a VLAN update. For VFs, this must be sent to the
769 * managing PF over the mailbox. For PFs, we'll use the same handling so that
770 * it's similar to the VF. This avoids storming the PF<->VF mailbox with too
771 * many VLAN updates during reset.
773 int fm10k_queue_vlan_request(struct fm10k_intfc *interface,
774 u32 vid, u8 vsi, bool set)
776 struct fm10k_macvlan_request *request;
779 /* This must be atomic since we may be called while the netdev
780 * addr_list_lock is held
782 request = kzalloc(sizeof(*request), GFP_ATOMIC);
786 request->type = FM10K_VLAN_REQUEST;
787 request->vlan.vid = vid;
788 request->vlan.vsi = vsi;
791 spin_lock_irqsave(&interface->macvlan_lock, flags);
792 list_add_tail(&request->list, &interface->macvlan_requests);
793 spin_unlock_irqrestore(&interface->macvlan_lock, flags);
795 fm10k_macvlan_schedule(interface);
801 * fm10k_queue_mac_request - Queue a MAC update request
802 * @interface: the fm10k interface structure
803 * @glort: the target glort for this update
804 * @addr: the address to update
805 * @vid: the vid to update
806 * @sync: whether to add or remove
808 * This function queues up a MAC request for sending to the switch manager.
809 * A separate thread monitors the queue and sends updates to the switch
810 * manager. Return 0 on success, and negative error code on failure.
812 int fm10k_queue_mac_request(struct fm10k_intfc *interface, u16 glort,
813 const unsigned char *addr, u16 vid, bool set)
815 struct fm10k_macvlan_request *request;
818 /* This must be atomic since we may be called while the netdev
819 * addr_list_lock is held
821 request = kzalloc(sizeof(*request), GFP_ATOMIC);
825 if (is_multicast_ether_addr(addr))
826 request->type = FM10K_MC_MAC_REQUEST;
828 request->type = FM10K_UC_MAC_REQUEST;
830 ether_addr_copy(request->mac.addr, addr);
831 request->mac.glort = glort;
832 request->mac.vid = vid;
835 spin_lock_irqsave(&interface->macvlan_lock, flags);
836 list_add_tail(&request->list, &interface->macvlan_requests);
837 spin_unlock_irqrestore(&interface->macvlan_lock, flags);
839 fm10k_macvlan_schedule(interface);
845 * fm10k_clear_macvlan_queue - Cancel pending updates for a given glort
846 * @interface: the fm10k interface structure
847 * @glort: the target glort to clear
848 * @vlans: true to clear VLAN messages, false to ignore them
850 * Cancel any outstanding MAC/VLAN requests for a given glort. This is
851 * expected to be called when a logical port goes down.
853 void fm10k_clear_macvlan_queue(struct fm10k_intfc *interface,
854 u16 glort, bool vlans)
857 struct fm10k_macvlan_request *r, *tmp;
860 spin_lock_irqsave(&interface->macvlan_lock, flags);
862 /* Free any outstanding MAC/VLAN requests for this interface */
863 list_for_each_entry_safe(r, tmp, &interface->macvlan_requests, list) {
865 case FM10K_MC_MAC_REQUEST:
866 case FM10K_UC_MAC_REQUEST:
867 /* Don't free requests for other interfaces */
868 if (r->mac.glort != glort)
871 case FM10K_VLAN_REQUEST:
880 spin_unlock_irqrestore(&interface->macvlan_lock, flags);
883 static int fm10k_uc_vlan_unsync(struct net_device *netdev,
884 const unsigned char *uc_addr)
886 struct fm10k_intfc *interface = netdev_priv(netdev);
887 u16 glort = interface->glort;
888 u16 vid = interface->vid;
889 bool set = !!(vid / VLAN_N_VID);
890 int err = -EHOSTDOWN;
892 /* drop any leading bits on the VLAN ID */
893 vid &= VLAN_N_VID - 1;
895 err = fm10k_queue_mac_request(interface, glort, uc_addr, vid, set);
899 /* return non-zero value as we are only doing a partial sync/unsync */
903 static int fm10k_mc_vlan_unsync(struct net_device *netdev,
904 const unsigned char *mc_addr)
906 struct fm10k_intfc *interface = netdev_priv(netdev);
907 u16 glort = interface->glort;
908 u16 vid = interface->vid;
909 bool set = !!(vid / VLAN_N_VID);
910 int err = -EHOSTDOWN;
912 /* drop any leading bits on the VLAN ID */
913 vid &= VLAN_N_VID - 1;
915 err = fm10k_queue_mac_request(interface, glort, mc_addr, vid, set);
919 /* return non-zero value as we are only doing a partial sync/unsync */
923 static int fm10k_update_vid(struct net_device *netdev, u16 vid, bool set)
925 struct fm10k_intfc *interface = netdev_priv(netdev);
926 struct fm10k_hw *hw = &interface->hw;
930 /* updates do not apply to VLAN 0 */
934 if (vid >= VLAN_N_VID)
937 /* Verify we have permission to add VLANs */
938 if (hw->mac.vlan_override)
941 /* update active_vlans bitmask */
942 set_bit(vid, interface->active_vlans);
944 clear_bit(vid, interface->active_vlans);
946 /* disable the default VLAN ID on ring if we have an active VLAN */
947 for (i = 0; i < interface->num_rx_queues; i++) {
948 struct fm10k_ring *rx_ring = interface->rx_ring[i];
949 u16 rx_vid = rx_ring->vid & (VLAN_N_VID - 1);
951 if (test_bit(rx_vid, interface->active_vlans))
952 rx_ring->vid |= FM10K_VLAN_CLEAR;
954 rx_ring->vid &= ~FM10K_VLAN_CLEAR;
957 /* Do not remove default VLAN ID related entries from VLAN and MAC
960 if (!set && vid == hw->mac.default_vid)
963 /* Do not throw an error if the interface is down. We will sync once
966 if (test_bit(__FM10K_DOWN, interface->state))
969 fm10k_mbx_lock(interface);
971 /* only need to update the VLAN if not in promiscuous mode */
972 if (!(netdev->flags & IFF_PROMISC)) {
973 err = fm10k_queue_vlan_request(interface, vid, 0, set);
978 /* Update our base MAC address */
979 err = fm10k_queue_mac_request(interface, interface->glort,
980 hw->mac.addr, vid, set);
984 /* set VLAN ID prior to syncing/unsyncing the VLAN */
985 interface->vid = vid + (set ? VLAN_N_VID : 0);
987 /* Update the unicast and multicast address list to add/drop VLAN */
988 __dev_uc_unsync(netdev, fm10k_uc_vlan_unsync);
989 __dev_mc_unsync(netdev, fm10k_mc_vlan_unsync);
992 fm10k_mbx_unlock(interface);
997 static int fm10k_vlan_rx_add_vid(struct net_device *netdev,
998 __always_unused __be16 proto, u16 vid)
1000 /* update VLAN and address table based on changes */
1001 return fm10k_update_vid(netdev, vid, true);
1004 static int fm10k_vlan_rx_kill_vid(struct net_device *netdev,
1005 __always_unused __be16 proto, u16 vid)
1007 /* update VLAN and address table based on changes */
1008 return fm10k_update_vid(netdev, vid, false);
1011 static u16 fm10k_find_next_vlan(struct fm10k_intfc *interface, u16 vid)
1013 struct fm10k_hw *hw = &interface->hw;
1014 u16 default_vid = hw->mac.default_vid;
1015 u16 vid_limit = vid < default_vid ? default_vid : VLAN_N_VID;
1017 vid = find_next_bit(interface->active_vlans, vid_limit, ++vid);
1022 static void fm10k_clear_unused_vlans(struct fm10k_intfc *interface)
1026 /* loop through and find any gaps in the table */
1027 for (vid = 0, prev_vid = 0;
1028 prev_vid < VLAN_N_VID;
1029 prev_vid = vid + 1, vid = fm10k_find_next_vlan(interface, vid)) {
1030 if (prev_vid == vid)
1033 /* send request to clear multiple bits at a time */
1034 prev_vid += (vid - prev_vid - 1) << FM10K_VLAN_LENGTH_SHIFT;
1035 fm10k_queue_vlan_request(interface, prev_vid, 0, false);
1039 static int __fm10k_uc_sync(struct net_device *dev,
1040 const unsigned char *addr, bool sync)
1042 struct fm10k_intfc *interface = netdev_priv(dev);
1043 struct fm10k_hw *hw = &interface->hw;
1044 u16 vid, glort = interface->glort;
1047 if (!is_valid_ether_addr(addr))
1048 return -EADDRNOTAVAIL;
1050 for (vid = hw->mac.default_vid ? fm10k_find_next_vlan(interface, 0) : 1;
1052 vid = fm10k_find_next_vlan(interface, vid)) {
1053 err = fm10k_queue_mac_request(interface, glort,
1062 static int fm10k_uc_sync(struct net_device *dev,
1063 const unsigned char *addr)
1065 return __fm10k_uc_sync(dev, addr, true);
1068 static int fm10k_uc_unsync(struct net_device *dev,
1069 const unsigned char *addr)
1071 return __fm10k_uc_sync(dev, addr, false);
1074 static int fm10k_set_mac(struct net_device *dev, void *p)
1076 struct fm10k_intfc *interface = netdev_priv(dev);
1077 struct fm10k_hw *hw = &interface->hw;
1078 struct sockaddr *addr = p;
1081 if (!is_valid_ether_addr(addr->sa_data))
1082 return -EADDRNOTAVAIL;
1084 if (dev->flags & IFF_UP) {
1085 /* setting MAC address requires mailbox */
1086 fm10k_mbx_lock(interface);
1088 err = fm10k_uc_sync(dev, addr->sa_data);
1090 fm10k_uc_unsync(dev, hw->mac.addr);
1092 fm10k_mbx_unlock(interface);
1096 ether_addr_copy(dev->dev_addr, addr->sa_data);
1097 ether_addr_copy(hw->mac.addr, addr->sa_data);
1098 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
1101 /* if we had a mailbox error suggest trying again */
1102 return err ? -EAGAIN : 0;
1105 static int __fm10k_mc_sync(struct net_device *dev,
1106 const unsigned char *addr, bool sync)
1108 struct fm10k_intfc *interface = netdev_priv(dev);
1109 struct fm10k_hw *hw = &interface->hw;
1110 u16 vid, glort = interface->glort;
1113 if (!is_multicast_ether_addr(addr))
1114 return -EADDRNOTAVAIL;
1116 for (vid = hw->mac.default_vid ? fm10k_find_next_vlan(interface, 0) : 1;
1118 vid = fm10k_find_next_vlan(interface, vid)) {
1119 err = fm10k_queue_mac_request(interface, glort,
1128 static int fm10k_mc_sync(struct net_device *dev,
1129 const unsigned char *addr)
1131 return __fm10k_mc_sync(dev, addr, true);
1134 static int fm10k_mc_unsync(struct net_device *dev,
1135 const unsigned char *addr)
1137 return __fm10k_mc_sync(dev, addr, false);
1140 static void fm10k_set_rx_mode(struct net_device *dev)
1142 struct fm10k_intfc *interface = netdev_priv(dev);
1143 struct fm10k_hw *hw = &interface->hw;
1146 /* no need to update the harwdare if we are not running */
1147 if (!(dev->flags & IFF_UP))
1150 /* determine new mode based on flags */
1151 xcast_mode = (dev->flags & IFF_PROMISC) ? FM10K_XCAST_MODE_PROMISC :
1152 (dev->flags & IFF_ALLMULTI) ? FM10K_XCAST_MODE_ALLMULTI :
1153 (dev->flags & (IFF_BROADCAST | IFF_MULTICAST)) ?
1154 FM10K_XCAST_MODE_MULTI : FM10K_XCAST_MODE_NONE;
1156 fm10k_mbx_lock(interface);
1158 /* update xcast mode first, but only if it changed */
1159 if (interface->xcast_mode != xcast_mode) {
1160 /* update VLAN table */
1161 if (xcast_mode == FM10K_XCAST_MODE_PROMISC)
1162 fm10k_queue_vlan_request(interface, FM10K_VLAN_ALL,
1164 if (interface->xcast_mode == FM10K_XCAST_MODE_PROMISC)
1165 fm10k_clear_unused_vlans(interface);
1167 /* update xcast mode if host's mailbox is ready */
1168 if (fm10k_host_mbx_ready(interface))
1169 hw->mac.ops.update_xcast_mode(hw, interface->glort,
1172 /* record updated xcast mode state */
1173 interface->xcast_mode = xcast_mode;
1176 /* synchronize all of the addresses */
1177 __dev_uc_sync(dev, fm10k_uc_sync, fm10k_uc_unsync);
1178 __dev_mc_sync(dev, fm10k_mc_sync, fm10k_mc_unsync);
1180 fm10k_mbx_unlock(interface);
1183 void fm10k_restore_rx_state(struct fm10k_intfc *interface)
1185 struct net_device *netdev = interface->netdev;
1186 struct fm10k_hw *hw = &interface->hw;
1190 /* record glort for this interface */
1191 glort = interface->glort;
1193 /* convert interface flags to xcast mode */
1194 if (netdev->flags & IFF_PROMISC)
1195 xcast_mode = FM10K_XCAST_MODE_PROMISC;
1196 else if (netdev->flags & IFF_ALLMULTI)
1197 xcast_mode = FM10K_XCAST_MODE_ALLMULTI;
1198 else if (netdev->flags & (IFF_BROADCAST | IFF_MULTICAST))
1199 xcast_mode = FM10K_XCAST_MODE_MULTI;
1201 xcast_mode = FM10K_XCAST_MODE_NONE;
1203 fm10k_mbx_lock(interface);
1205 /* Enable logical port if host's mailbox is ready */
1206 if (fm10k_host_mbx_ready(interface))
1207 hw->mac.ops.update_lport_state(hw, glort,
1208 interface->glort_count, true);
1210 /* update VLAN table */
1211 fm10k_queue_vlan_request(interface, FM10K_VLAN_ALL, 0,
1212 xcast_mode == FM10K_XCAST_MODE_PROMISC);
1214 /* Add filter for VLAN 0 */
1215 fm10k_queue_vlan_request(interface, 0, 0, true);
1217 /* update table with current entries */
1218 for (vid = hw->mac.default_vid ? fm10k_find_next_vlan(interface, 0) : 1;
1220 vid = fm10k_find_next_vlan(interface, vid)) {
1221 fm10k_queue_vlan_request(interface, vid, 0, true);
1223 fm10k_queue_mac_request(interface, glort,
1224 hw->mac.addr, vid, true);
1227 /* update xcast mode before synchronizing addresses if host's mailbox
1230 if (fm10k_host_mbx_ready(interface))
1231 hw->mac.ops.update_xcast_mode(hw, glort, xcast_mode);
1233 /* synchronize all of the addresses */
1234 __dev_uc_sync(netdev, fm10k_uc_sync, fm10k_uc_unsync);
1235 __dev_mc_sync(netdev, fm10k_mc_sync, fm10k_mc_unsync);
1237 fm10k_mbx_unlock(interface);
1239 /* record updated xcast mode state */
1240 interface->xcast_mode = xcast_mode;
1242 /* Restore tunnel configuration */
1243 fm10k_restore_udp_port_info(interface);
1246 void fm10k_reset_rx_state(struct fm10k_intfc *interface)
1248 struct net_device *netdev = interface->netdev;
1249 struct fm10k_hw *hw = &interface->hw;
1251 /* Wait for MAC/VLAN work to finish */
1252 while (test_bit(__FM10K_MACVLAN_SCHED, interface->state))
1253 usleep_range(1000, 2000);
1255 /* Cancel pending MAC/VLAN requests */
1256 fm10k_clear_macvlan_queue(interface, interface->glort, true);
1258 fm10k_mbx_lock(interface);
1260 /* clear the logical port state on lower device if host's mailbox is
1263 if (fm10k_host_mbx_ready(interface))
1264 hw->mac.ops.update_lport_state(hw, interface->glort,
1265 interface->glort_count, false);
1267 fm10k_mbx_unlock(interface);
1269 /* reset flags to default state */
1270 interface->xcast_mode = FM10K_XCAST_MODE_NONE;
1272 /* clear the sync flag since the lport has been dropped */
1273 __dev_uc_unsync(netdev, NULL);
1274 __dev_mc_unsync(netdev, NULL);
1278 * fm10k_get_stats64 - Get System Network Statistics
1279 * @netdev: network interface device structure
1280 * @stats: storage space for 64bit statistics
1282 * Obtain 64bit statistics in a way that is safe for both 32bit and 64bit
1285 static void fm10k_get_stats64(struct net_device *netdev,
1286 struct rtnl_link_stats64 *stats)
1288 struct fm10k_intfc *interface = netdev_priv(netdev);
1289 struct fm10k_ring *ring;
1290 unsigned int start, i;
1295 for (i = 0; i < interface->num_rx_queues; i++) {
1296 ring = READ_ONCE(interface->rx_ring[i]);
1302 start = u64_stats_fetch_begin_irq(&ring->syncp);
1303 packets = ring->stats.packets;
1304 bytes = ring->stats.bytes;
1305 } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
1307 stats->rx_packets += packets;
1308 stats->rx_bytes += bytes;
1311 for (i = 0; i < interface->num_tx_queues; i++) {
1312 ring = READ_ONCE(interface->tx_ring[i]);
1318 start = u64_stats_fetch_begin_irq(&ring->syncp);
1319 packets = ring->stats.packets;
1320 bytes = ring->stats.bytes;
1321 } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
1323 stats->tx_packets += packets;
1324 stats->tx_bytes += bytes;
1329 /* following stats updated by fm10k_service_task() */
1330 stats->rx_missed_errors = netdev->stats.rx_missed_errors;
1333 int fm10k_setup_tc(struct net_device *dev, u8 tc)
1335 struct fm10k_intfc *interface = netdev_priv(dev);
1338 /* Currently only the PF supports priority classes */
1339 if (tc && (interface->hw.mac.type != fm10k_mac_pf))
1342 /* Hardware supports up to 8 traffic classes */
1346 /* Hardware has to reinitialize queues to match packet
1347 * buffer alignment. Unfortunately, the hardware is not
1348 * flexible enough to do this dynamically.
1350 if (netif_running(dev))
1353 fm10k_mbx_free_irq(interface);
1355 fm10k_clear_queueing_scheme(interface);
1357 /* we expect the prio_tc map to be repopulated later */
1358 netdev_reset_tc(dev);
1359 netdev_set_num_tc(dev, tc);
1361 err = fm10k_init_queueing_scheme(interface);
1363 goto err_queueing_scheme;
1365 err = fm10k_mbx_request_irq(interface);
1369 err = netif_running(dev) ? fm10k_open(dev) : 0;
1373 /* flag to indicate SWPRI has yet to be updated */
1374 set_bit(FM10K_FLAG_SWPRI_CONFIG, interface->flags);
1378 fm10k_mbx_free_irq(interface);
1380 fm10k_clear_queueing_scheme(interface);
1381 err_queueing_scheme:
1382 netif_device_detach(dev);
1387 static int __fm10k_setup_tc(struct net_device *dev, enum tc_setup_type type,
1390 struct tc_mqprio_qopt *mqprio = type_data;
1392 if (type != TC_SETUP_QDISC_MQPRIO)
1395 mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;
1397 return fm10k_setup_tc(dev, mqprio->num_tc);
1400 static void fm10k_assign_l2_accel(struct fm10k_intfc *interface,
1401 struct fm10k_l2_accel *l2_accel)
1403 struct fm10k_ring *ring;
1406 for (i = 0; i < interface->num_rx_queues; i++) {
1407 ring = interface->rx_ring[i];
1408 rcu_assign_pointer(ring->l2_accel, l2_accel);
1411 interface->l2_accel = l2_accel;
1414 static void *fm10k_dfwd_add_station(struct net_device *dev,
1415 struct net_device *sdev)
1417 struct fm10k_intfc *interface = netdev_priv(dev);
1418 struct fm10k_l2_accel *l2_accel = interface->l2_accel;
1419 struct fm10k_l2_accel *old_l2_accel = NULL;
1420 struct fm10k_dglort_cfg dglort = { 0 };
1421 struct fm10k_hw *hw = &interface->hw;
1425 /* allocate l2 accel structure if it is not available */
1427 /* verify there is enough free GLORTs to support l2_accel */
1428 if (interface->glort_count < 7)
1429 return ERR_PTR(-EBUSY);
1431 size = offsetof(struct fm10k_l2_accel, macvlan[7]);
1432 l2_accel = kzalloc(size, GFP_KERNEL);
1434 return ERR_PTR(-ENOMEM);
1437 l2_accel->dglort = interface->glort;
1439 /* update pointers */
1440 fm10k_assign_l2_accel(interface, l2_accel);
1441 /* do not expand if we are at our limit */
1442 } else if ((l2_accel->count == FM10K_MAX_STATIONS) ||
1443 (l2_accel->count == (interface->glort_count - 1))) {
1444 return ERR_PTR(-EBUSY);
1445 /* expand if we have hit the size limit */
1446 } else if (l2_accel->count == l2_accel->size) {
1447 old_l2_accel = l2_accel;
1448 size = offsetof(struct fm10k_l2_accel,
1449 macvlan[(l2_accel->size * 2) + 1]);
1450 l2_accel = kzalloc(size, GFP_KERNEL);
1452 return ERR_PTR(-ENOMEM);
1454 memcpy(l2_accel, old_l2_accel,
1455 offsetof(struct fm10k_l2_accel,
1456 macvlan[old_l2_accel->size]));
1458 l2_accel->size = (old_l2_accel->size * 2) + 1;
1460 /* update pointers */
1461 fm10k_assign_l2_accel(interface, l2_accel);
1462 kfree_rcu(old_l2_accel, rcu);
1465 /* add macvlan to accel table, and record GLORT for position */
1466 for (i = 0; i < l2_accel->size; i++) {
1467 if (!l2_accel->macvlan[i])
1471 /* record station */
1472 l2_accel->macvlan[i] = sdev;
1475 /* configure default DGLORT mapping for RSS/DCB */
1476 dglort.idx = fm10k_dglort_pf_rss;
1477 dglort.inner_rss = 1;
1478 dglort.rss_l = fls(interface->ring_feature[RING_F_RSS].mask);
1479 dglort.pc_l = fls(interface->ring_feature[RING_F_QOS].mask);
1480 dglort.glort = interface->glort;
1481 dglort.shared_l = fls(l2_accel->size);
1482 hw->mac.ops.configure_dglort_map(hw, &dglort);
1484 /* Add rules for this specific dglort to the switch */
1485 fm10k_mbx_lock(interface);
1487 glort = l2_accel->dglort + 1 + i;
1489 if (fm10k_host_mbx_ready(interface)) {
1490 hw->mac.ops.update_xcast_mode(hw, glort,
1491 FM10K_XCAST_MODE_MULTI);
1492 fm10k_queue_mac_request(interface, glort, sdev->dev_addr,
1496 fm10k_mbx_unlock(interface);
1501 static void fm10k_dfwd_del_station(struct net_device *dev, void *priv)
1503 struct fm10k_intfc *interface = netdev_priv(dev);
1504 struct fm10k_l2_accel *l2_accel = READ_ONCE(interface->l2_accel);
1505 struct fm10k_dglort_cfg dglort = { 0 };
1506 struct fm10k_hw *hw = &interface->hw;
1507 struct net_device *sdev = priv;
1514 /* search table for matching interface */
1515 for (i = 0; i < l2_accel->size; i++) {
1516 if (l2_accel->macvlan[i] == sdev)
1520 /* exit if macvlan not found */
1521 if (i == l2_accel->size)
1524 /* Remove any rules specific to this dglort */
1525 fm10k_mbx_lock(interface);
1527 glort = l2_accel->dglort + 1 + i;
1529 if (fm10k_host_mbx_ready(interface)) {
1530 hw->mac.ops.update_xcast_mode(hw, glort,
1531 FM10K_XCAST_MODE_NONE);
1532 fm10k_queue_mac_request(interface, glort, sdev->dev_addr,
1536 fm10k_mbx_unlock(interface);
1538 /* record removal */
1539 l2_accel->macvlan[i] = NULL;
1542 /* configure default DGLORT mapping for RSS/DCB */
1543 dglort.idx = fm10k_dglort_pf_rss;
1544 dglort.inner_rss = 1;
1545 dglort.rss_l = fls(interface->ring_feature[RING_F_RSS].mask);
1546 dglort.pc_l = fls(interface->ring_feature[RING_F_QOS].mask);
1547 dglort.glort = interface->glort;
1548 dglort.shared_l = fls(l2_accel->size);
1549 hw->mac.ops.configure_dglort_map(hw, &dglort);
1551 /* If table is empty remove it */
1552 if (l2_accel->count == 0) {
1553 fm10k_assign_l2_accel(interface, NULL);
1554 kfree_rcu(l2_accel, rcu);
1558 static netdev_features_t fm10k_features_check(struct sk_buff *skb,
1559 struct net_device *dev,
1560 netdev_features_t features)
1562 if (!skb->encapsulation || fm10k_tx_encap_offload(skb))
1565 return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
1568 static const struct net_device_ops fm10k_netdev_ops = {
1569 .ndo_open = fm10k_open,
1570 .ndo_stop = fm10k_close,
1571 .ndo_validate_addr = eth_validate_addr,
1572 .ndo_start_xmit = fm10k_xmit_frame,
1573 .ndo_set_mac_address = fm10k_set_mac,
1574 .ndo_tx_timeout = fm10k_tx_timeout,
1575 .ndo_vlan_rx_add_vid = fm10k_vlan_rx_add_vid,
1576 .ndo_vlan_rx_kill_vid = fm10k_vlan_rx_kill_vid,
1577 .ndo_set_rx_mode = fm10k_set_rx_mode,
1578 .ndo_get_stats64 = fm10k_get_stats64,
1579 .ndo_setup_tc = __fm10k_setup_tc,
1580 .ndo_set_vf_mac = fm10k_ndo_set_vf_mac,
1581 .ndo_set_vf_vlan = fm10k_ndo_set_vf_vlan,
1582 .ndo_set_vf_rate = fm10k_ndo_set_vf_bw,
1583 .ndo_get_vf_config = fm10k_ndo_get_vf_config,
1584 .ndo_udp_tunnel_add = fm10k_udp_tunnel_add,
1585 .ndo_udp_tunnel_del = fm10k_udp_tunnel_del,
1586 .ndo_dfwd_add_station = fm10k_dfwd_add_station,
1587 .ndo_dfwd_del_station = fm10k_dfwd_del_station,
1588 #ifdef CONFIG_NET_POLL_CONTROLLER
1589 .ndo_poll_controller = fm10k_netpoll,
1591 .ndo_features_check = fm10k_features_check,
1594 #define DEFAULT_DEBUG_LEVEL_SHIFT 3
1596 struct net_device *fm10k_alloc_netdev(const struct fm10k_info *info)
1598 netdev_features_t hw_features;
1599 struct fm10k_intfc *interface;
1600 struct net_device *dev;
1602 dev = alloc_etherdev_mq(sizeof(struct fm10k_intfc), MAX_QUEUES);
1606 /* set net device and ethtool ops */
1607 dev->netdev_ops = &fm10k_netdev_ops;
1608 fm10k_set_ethtool_ops(dev);
1610 /* configure default debug level */
1611 interface = netdev_priv(dev);
1612 interface->msg_enable = BIT(DEFAULT_DEBUG_LEVEL_SHIFT) - 1;
1614 /* configure default features */
1615 dev->features |= NETIF_F_IP_CSUM |
1624 /* Only the PF can support VXLAN and NVGRE tunnel offloads */
1625 if (info->mac == fm10k_mac_pf) {
1626 dev->hw_enc_features = NETIF_F_IP_CSUM |
1630 NETIF_F_GSO_UDP_TUNNEL |
1634 dev->features |= NETIF_F_GSO_UDP_TUNNEL;
1637 /* all features defined to this point should be changeable */
1638 hw_features = dev->features;
1640 /* allow user to enable L2 forwarding acceleration */
1641 hw_features |= NETIF_F_HW_L2FW_DOFFLOAD;
1643 /* configure VLAN features */
1644 dev->vlan_features |= dev->features;
1646 /* we want to leave these both on as we cannot disable VLAN tag
1647 * insertion or stripping on the hardware since it is contained
1648 * in the FTAG and not in the frame itself.
1650 dev->features |= NETIF_F_HW_VLAN_CTAG_TX |
1651 NETIF_F_HW_VLAN_CTAG_RX |
1652 NETIF_F_HW_VLAN_CTAG_FILTER;
1654 dev->priv_flags |= IFF_UNICAST_FLT;
1656 dev->hw_features |= hw_features;
1658 /* MTU range: 68 - 15342 */
1659 dev->min_mtu = ETH_MIN_MTU;
1660 dev->max_mtu = FM10K_MAX_JUMBO_FRAME_SIZE;