/********************************************************************** * Author: Cavium, Inc. * * Contact: [email protected] * Please include "LiquidIO" in the subject. * * Copyright (c) 2003-2016 Cavium, Inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. * * This file is distributed in the hope that it will be useful, but * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * NONINFRINGEMENT. See the GNU General Public License for more details. ***********************************************************************/ #include <linux/module.h> #include <linux/interrupt.h> #include <linux/pci.h> #include <net/vxlan.h> #include "liquidio_common.h" #include "octeon_droq.h" #include "octeon_iq.h" #include "response_manager.h" #include "octeon_device.h" #include "octeon_nic.h" #include "octeon_main.h" #include "octeon_network.h" #include "cn23xx_vf_device.h" MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …; static int debug = …; module_param(debug, int, 0644); MODULE_PARM_DESC(…) …; #define DEFAULT_MSG_ENABLE … struct oct_timestamp_resp { … }; tx_info; #define OCTNIC_GSO_MAX_HEADER_SIZE … #define OCTNIC_GSO_MAX_SIZE … static int liquidio_vf_probe(struct pci_dev *pdev, const struct pci_device_id *ent); static void liquidio_vf_remove(struct pci_dev *pdev); static int octeon_device_init(struct octeon_device *oct); static int liquidio_stop(struct net_device *netdev); static int lio_wait_for_oq_pkts(struct octeon_device *oct) { … } /** * pcierror_quiesce_device - Cause device to go quiet so it can be safely removed/reset/etc * @oct: Pointer to Octeon device */ static void pcierror_quiesce_device(struct octeon_device *oct) { … } /** * cleanup_aer_uncorrect_error_status - Cleanup PCI AER uncorrectable error status * @dev: Pointer to PCI device */ static void cleanup_aer_uncorrect_error_status(struct pci_dev *dev) { … } /** * stop_pci_io - Stop all PCI IO to a given device * @oct: Pointer to Octeon device */ static void stop_pci_io(struct octeon_device *oct) { … } /** * liquidio_pcie_error_detected - called when PCI error is detected * @pdev: Pointer to PCI device * @state: The current pci connection state * * This function is called after a PCI bus error affecting * this device has been detected. */ static pci_ers_result_t liquidio_pcie_error_detected(struct pci_dev *pdev, pci_channel_state_t state) { … } /* For PCI-E Advanced Error Recovery (AER) Interface */ static const struct pci_error_handlers liquidio_vf_err_handler = …; static const struct pci_device_id liquidio_vf_pci_tbl[] = …; MODULE_DEVICE_TABLE(pci, liquidio_vf_pci_tbl); static struct pci_driver liquidio_vf_pci_driver = …; /** * print_link_info - Print link information * @netdev: network device */ static void print_link_info(struct net_device *netdev) { … } /** * octnet_link_status_change - Routine to notify MTU change * @work: work_struct data structure */ static void octnet_link_status_change(struct work_struct *work) { … } /** * setup_link_status_change_wq - Sets up the mtu status change work * @netdev: network device */ static int setup_link_status_change_wq(struct net_device *netdev) { … } static void cleanup_link_status_change_wq(struct net_device *netdev) { … } /** * update_link_status - Update link status * @netdev: network device * @ls: link status structure * * Called on receipt of a link status response from the core application to * update each interface's link status. */ static void update_link_status(struct net_device *netdev, union oct_link_status *ls) { … } /** * liquidio_vf_probe - PCI probe handler * @pdev: PCI device structure * @ent: unused */ static int liquidio_vf_probe(struct pci_dev *pdev, const struct pci_device_id __maybe_unused *ent) { … } /** * octeon_pci_flr - PCI FLR for each Octeon device. * @oct: octeon device */ static void octeon_pci_flr(struct octeon_device *oct) { … } /** * octeon_destroy_resources - Destroy resources associated with octeon device * @oct: octeon device */ static void octeon_destroy_resources(struct octeon_device *oct) { … } /** * send_rx_ctrl_cmd - Send Rx control command * @lio: per-network private data * @start_stop: whether to start or stop */ static int send_rx_ctrl_cmd(struct lio *lio, int start_stop) { … } /** * liquidio_destroy_nic_device - Destroy NIC device interface * @oct: octeon device * @ifidx: which interface to destroy * * Cleanup associated with each interface for an Octeon device when NIC * module is being unloaded or if initialization fails during load. */ static void liquidio_destroy_nic_device(struct octeon_device *oct, int ifidx) { … } /** * liquidio_stop_nic_module - Stop complete NIC functionality * @oct: octeon device */ static int liquidio_stop_nic_module(struct octeon_device *oct) { … } /** * liquidio_vf_remove - Cleans up resources at unload time * @pdev: PCI device structure */ static void liquidio_vf_remove(struct pci_dev *pdev) { … } /** * octeon_pci_os_setup - PCI initialization for each Octeon device. * @oct: octeon device */ static int octeon_pci_os_setup(struct octeon_device *oct) { … } /** * free_netbuf - Unmap and free network buffer * @buf: buffer */ static void free_netbuf(void *buf) { … } /** * free_netsgbuf - Unmap and free gather buffer * @buf: buffer */ static void free_netsgbuf(void *buf) { … } /** * free_netsgbuf_with_resp - Unmap and free gather buffer with response * @buf: buffer */ static void free_netsgbuf_with_resp(void *buf) { … } /** * liquidio_open - Net device open for LiquidIO * @netdev: network device */ static int liquidio_open(struct net_device *netdev) { … } /** * liquidio_stop - jNet device stop for LiquidIO * @netdev: network device */ static int liquidio_stop(struct net_device *netdev) { … } /** * get_new_flags - Converts a mask based on net device flags * @netdev: network device * * This routine generates a octnet_ifflags mask from the net device flags * received from the OS. */ static enum octnet_ifflags get_new_flags(struct net_device *netdev) { … } static void liquidio_set_uc_list(struct net_device *netdev) { … } /** * liquidio_set_mcast_list - Net device set_multicast_list * @netdev: network device */ static void liquidio_set_mcast_list(struct net_device *netdev) { … } /** * liquidio_set_mac - Net device set_mac_address * @netdev: network device * @p: opaque pointer to sockaddr */ static int liquidio_set_mac(struct net_device *netdev, void *p) { … } static void liquidio_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *lstats) { … } /** * hwtstamp_ioctl - Handler for SIOCSHWTSTAMP ioctl * @netdev: network device * @ifr: interface request */ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr) { … } /** * liquidio_ioctl - ioctl handler * @netdev: network device * @ifr: interface request * @cmd: command */ static int liquidio_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) { … } static void handle_timestamp(struct octeon_device *oct, u32 status, void *buf) { … } /* send_nic_timestamp_pkt - Send a data packet that will be timestamped * @oct: octeon device * @ndata: pointer to network data * @finfo: pointer to private network data */ static int send_nic_timestamp_pkt(struct octeon_device *oct, struct octnic_data_pkt *ndata, struct octnet_buf_free_info *finfo, int xmit_more) { … } /** * liquidio_xmit - Transmit networks packets to the Octeon interface * @skb: skbuff struct to be passed to network layer. * @netdev: pointer to network device * @returns whether the packet was transmitted to the device okay or not * (NETDEV_TX_OK or NETDEV_TX_BUSY) */ static netdev_tx_t liquidio_xmit(struct sk_buff *skb, struct net_device *netdev) { … } /** * liquidio_tx_timeout - Network device Tx timeout * @netdev: pointer to network device * @txqueue: index of the hung transmit queue */ static void liquidio_tx_timeout(struct net_device *netdev, unsigned int txqueue) { … } static int liquidio_vlan_rx_add_vid(struct net_device *netdev, __be16 proto __attribute__((unused)), u16 vid) { … } static int liquidio_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto __attribute__((unused)), u16 vid) { … } /** Sending command to enable/disable RX checksum offload * @param netdev pointer to network device * @param command OCTNET_CMD_TNL_RX_CSUM_CTL * @param rx_cmd_bit OCTNET_CMD_RXCSUM_ENABLE/ * OCTNET_CMD_RXCSUM_DISABLE * @returns SUCCESS or FAILURE */ static int liquidio_set_rxcsum_command(struct net_device *netdev, int command, u8 rx_cmd) { … } /** Sending command to add/delete VxLAN UDP port to firmware * @param netdev pointer to network device * @param command OCTNET_CMD_VXLAN_PORT_CONFIG * @param vxlan_port VxLAN port to be added or deleted * @param vxlan_cmd_bit OCTNET_CMD_VXLAN_PORT_ADD, * OCTNET_CMD_VXLAN_PORT_DEL * @returns SUCCESS or FAILURE */ static int liquidio_vxlan_port_command(struct net_device *netdev, int command, u16 vxlan_port, u8 vxlan_cmd_bit) { … } static int liquidio_udp_tunnel_set_port(struct net_device *netdev, unsigned int table, unsigned int entry, struct udp_tunnel_info *ti) { … } static int liquidio_udp_tunnel_unset_port(struct net_device *netdev, unsigned int table, unsigned int entry, struct udp_tunnel_info *ti) { … } static const struct udp_tunnel_nic_info liquidio_udp_tunnels = …; /** \brief Net device fix features * @param netdev pointer to network device * @param request features requested * @returns updated features list */ static netdev_features_t liquidio_fix_features(struct net_device *netdev, netdev_features_t request) { … } /** \brief Net device set features * @param netdev pointer to network device * @param features features to enable/disable */ static int liquidio_set_features(struct net_device *netdev, netdev_features_t features) { … } static const struct net_device_ops lionetdevops = …; static int lio_nic_info(struct octeon_recv_info *recv_info, void *buf) { … } /** * setup_nic_devices - Setup network interfaces * @octeon_dev: octeon device * * Called during init time for each device. It assumes the NIC * is already up and running. The link information for each * interface is passed in link_info. */ static int setup_nic_devices(struct octeon_device *octeon_dev) { … } /** * liquidio_init_nic_module - initialize the NIC * @oct: octeon device * * This initialization routine is called once the Octeon device application is * up and running */ static int liquidio_init_nic_module(struct octeon_device *oct) { … } /** * octeon_device_init - Device initialization for each Octeon device that is probed * @oct: octeon device */ static int octeon_device_init(struct octeon_device *oct) { … } static int __init liquidio_vf_init(void) { … } static void __exit liquidio_vf_exit(void) { … } module_init(…) …; module_exit(liquidio_vf_exit);