// SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2013 - 2019 Intel Corporation. */ #include "fm10k.h" #include <linux/vmalloc.h> #include <net/udp_tunnel.h> #include <linux/if_macvlan.h> /** * fm10k_setup_tx_resources - allocate Tx resources (Descriptors) * @tx_ring: tx descriptor ring (for a specific queue) to setup * * Return 0 on success, negative on failure **/ int fm10k_setup_tx_resources(struct fm10k_ring *tx_ring) { … } /** * fm10k_setup_all_tx_resources - allocate all queues Tx resources * @interface: board private structure * * If this function returns with an error, then it's possible one or * more of the rings is populated (while the rest are not). It is the * callers duty to clean those orphaned rings. * * Return 0 on success, negative on failure **/ static int fm10k_setup_all_tx_resources(struct fm10k_intfc *interface) { … } /** * fm10k_setup_rx_resources - allocate Rx resources (Descriptors) * @rx_ring: rx descriptor ring (for a specific queue) to setup * * Returns 0 on success, negative on failure **/ int fm10k_setup_rx_resources(struct fm10k_ring *rx_ring) { … } /** * fm10k_setup_all_rx_resources - allocate all queues Rx resources * @interface: board private structure * * If this function returns with an error, then it's possible one or * more of the rings is populated (while the rest are not). It is the * callers duty to clean those orphaned rings. * * Return 0 on success, negative on failure **/ static int fm10k_setup_all_rx_resources(struct fm10k_intfc *interface) { … } void fm10k_unmap_and_free_tx_resource(struct fm10k_ring *ring, struct fm10k_tx_buffer *tx_buffer) { … } /** * fm10k_clean_tx_ring - Free Tx Buffers * @tx_ring: ring to be cleaned **/ static void fm10k_clean_tx_ring(struct fm10k_ring *tx_ring) { … } /** * fm10k_free_tx_resources - Free Tx Resources per Queue * @tx_ring: Tx descriptor ring for a specific queue * * Free all transmit software resources **/ void fm10k_free_tx_resources(struct fm10k_ring *tx_ring) { … } /** * fm10k_clean_all_tx_rings - Free Tx Buffers for all queues * @interface: board private structure **/ void fm10k_clean_all_tx_rings(struct fm10k_intfc *interface) { … } /** * fm10k_free_all_tx_resources - Free Tx Resources for All Queues * @interface: board private structure * * Free all transmit software resources **/ static void fm10k_free_all_tx_resources(struct fm10k_intfc *interface) { … } /** * fm10k_clean_rx_ring - Free Rx Buffers per Queue * @rx_ring: ring to free buffers from **/ static void fm10k_clean_rx_ring(struct fm10k_ring *rx_ring) { … } /** * fm10k_free_rx_resources - Free Rx Resources * @rx_ring: ring to clean the resources from * * Free all receive software resources **/ void fm10k_free_rx_resources(struct fm10k_ring *rx_ring) { … } /** * fm10k_clean_all_rx_rings - Free Rx Buffers for all queues * @interface: board private structure **/ void fm10k_clean_all_rx_rings(struct fm10k_intfc *interface) { … } /** * fm10k_free_all_rx_resources - Free Rx Resources for All Queues * @interface: board private structure * * Free all receive software resources **/ static void fm10k_free_all_rx_resources(struct fm10k_intfc *interface) { … } /** * fm10k_request_glort_range - Request GLORTs for use in configuring rules * @interface: board private structure * * This function allocates a range of glorts for this interface to use. **/ static void fm10k_request_glort_range(struct fm10k_intfc *interface) { … } /** * fm10k_restore_udp_port_info * @interface: board private structure * * This function restores the value in the tunnel_cfg register(s) after reset **/ static void fm10k_restore_udp_port_info(struct fm10k_intfc *interface) { … } /** * fm10k_udp_tunnel_sync - Called when UDP tunnel ports change * @dev: network interface device structure * @table: Tunnel table (according to tables of @fm10k_udp_tunnels) * * This function is called when a new UDP tunnel port is added or deleted. * Due to hardware restrictions, only one port per type can be offloaded at * once. Core will send to the driver a port of its choice. **/ static int fm10k_udp_tunnel_sync(struct net_device *dev, unsigned int table) { … } static const struct udp_tunnel_nic_info fm10k_udp_tunnels = …; /** * fm10k_open - Called when a network interface is made active * @netdev: network interface device structure * * Returns 0 on success, negative value on failure * * The open entry point is called when a network interface is made * active by the system (IFF_UP). At this point all resources needed * for transmit and receive operations are allocated, the interrupt * handler is registered with the OS, the watchdog timer is started, * and the stack is notified that the interface is ready. **/ int fm10k_open(struct net_device *netdev) { … } /** * fm10k_close - Disables a network interface * @netdev: network interface device structure * * Returns 0, this is not allowed to fail * * The close entry point is called when an interface is de-activated * by the OS. The hardware is still under the drivers control, but * needs to be disabled. A global MAC reset is issued to stop the * hardware, and all transmit and receive resources are freed. **/ int fm10k_close(struct net_device *netdev) { … } static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev) { … } /** * fm10k_tx_timeout - Respond to a Tx Hang * @netdev: network interface device structure * @txqueue: the index of the Tx queue that timed out **/ static void fm10k_tx_timeout(struct net_device *netdev, unsigned int txqueue) { … } /** * fm10k_host_mbx_ready - Check PF interface's mailbox readiness * @interface: board private structure * * This function checks if the PF interface's mailbox is ready before queueing * mailbox messages for transmission. This will prevent filling the TX mailbox * queue when the receiver is not ready. VF interfaces are exempt from this * check since it will block all PF-VF mailbox messages from being sent from * the VF to the PF at initialization. **/ static bool fm10k_host_mbx_ready(struct fm10k_intfc *interface) { … } /** * fm10k_queue_vlan_request - Queue a VLAN update request * @interface: the fm10k interface structure * @vid: the VLAN vid * @vsi: VSI index number * @set: whether to set or clear * * This function queues up a VLAN update. For VFs, this must be sent to the * managing PF over the mailbox. For PFs, we'll use the same handling so that * it's similar to the VF. This avoids storming the PF<->VF mailbox with too * many VLAN updates during reset. */ int fm10k_queue_vlan_request(struct fm10k_intfc *interface, u32 vid, u8 vsi, bool set) { … } /** * fm10k_queue_mac_request - Queue a MAC update request * @interface: the fm10k interface structure * @glort: the target glort for this update * @addr: the address to update * @vid: the vid to update * @set: whether to add or remove * * This function queues up a MAC request for sending to the switch manager. * A separate thread monitors the queue and sends updates to the switch * manager. Return 0 on success, and negative error code on failure. **/ int fm10k_queue_mac_request(struct fm10k_intfc *interface, u16 glort, const unsigned char *addr, u16 vid, bool set) { … } /** * fm10k_clear_macvlan_queue - Cancel pending updates for a given glort * @interface: the fm10k interface structure * @glort: the target glort to clear * @vlans: true to clear VLAN messages, false to ignore them * * Cancel any outstanding MAC/VLAN requests for a given glort. This is * expected to be called when a logical port goes down. **/ void fm10k_clear_macvlan_queue(struct fm10k_intfc *interface, u16 glort, bool vlans) { … } static int fm10k_uc_vlan_unsync(struct net_device *netdev, const unsigned char *uc_addr) { … } static int fm10k_mc_vlan_unsync(struct net_device *netdev, const unsigned char *mc_addr) { … } static int fm10k_update_vid(struct net_device *netdev, u16 vid, bool set) { … } static int fm10k_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto, u16 vid) { … } static int fm10k_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto, u16 vid) { … } static u16 fm10k_find_next_vlan(struct fm10k_intfc *interface, u16 vid) { … } static void fm10k_clear_unused_vlans(struct fm10k_intfc *interface) { … } static int __fm10k_uc_sync(struct net_device *dev, const unsigned char *addr, bool sync) { … } static int fm10k_uc_sync(struct net_device *dev, const unsigned char *addr) { … } static int fm10k_uc_unsync(struct net_device *dev, const unsigned char *addr) { … } static int fm10k_set_mac(struct net_device *dev, void *p) { … } static int __fm10k_mc_sync(struct net_device *dev, const unsigned char *addr, bool sync) { … } static int fm10k_mc_sync(struct net_device *dev, const unsigned char *addr) { … } static int fm10k_mc_unsync(struct net_device *dev, const unsigned char *addr) { … } static void fm10k_set_rx_mode(struct net_device *dev) { … } void fm10k_restore_rx_state(struct fm10k_intfc *interface) { … } void fm10k_reset_rx_state(struct fm10k_intfc *interface) { … } /** * fm10k_get_stats64 - Get System Network Statistics * @netdev: network interface device structure * @stats: storage space for 64bit statistics * * Obtain 64bit statistics in a way that is safe for both 32bit and 64bit * architectures. */ static void fm10k_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) { … } int fm10k_setup_tc(struct net_device *dev, u8 tc) { … } static int __fm10k_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data) { … } static void fm10k_assign_l2_accel(struct fm10k_intfc *interface, struct fm10k_l2_accel *l2_accel) { … } static void *fm10k_dfwd_add_station(struct net_device *dev, struct net_device *sdev) { … } static void fm10k_dfwd_del_station(struct net_device *dev, void *priv) { … } static netdev_features_t fm10k_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t features) { … } static const struct net_device_ops fm10k_netdev_ops = …; #define DEFAULT_DEBUG_LEVEL_SHIFT … struct net_device *fm10k_alloc_netdev(const struct fm10k_info *info) { … }