linux/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c

/*
 * Copyright (c) 2003-2008 Chelsio, Inc. All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directory of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and/or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
#include <linux/mdio.h>
#include <linux/sockios.h>
#include <linux/workqueue.h>
#include <linux/proc_fs.h>
#include <linux/rtnetlink.h>
#include <linux/firmware.h>
#include <linux/log2.h>
#include <linux/stringify.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/nospec.h>

#include "common.h"
#include "cxgb3_ioctl.h"
#include "regs.h"
#include "cxgb3_offload.h"
#include "version.h"

#include "cxgb3_ctl_defs.h"
#include "t3_cpl.h"
#include "firmware_exports.h"

enum {};

#define PORT_MASK

#define DFLT_MSG_ENABLE

#define EEPROM_MAGIC

#define CH_DEVICE(devid, idx)

static const struct pci_device_id cxgb3_pci_tbl[] =;

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();
MODULE_DEVICE_TABLE(pci, cxgb3_pci_tbl);

static int dflt_msg_enable =;

module_param(dflt_msg_enable, int, 0644);
MODULE_PARM_DESC();

/*
 * The driver uses the best interrupt scheme available on a platform in the
 * order MSI-X, MSI, legacy pin interrupts.  This parameter determines which
 * of these schemes the driver may consider as follows:
 *
 * msi = 2: choose from among all three options
 * msi = 1: only consider MSI and pin interrupts
 * msi = 0: force pin interrupts
 */
static int msi =;

module_param(msi, int, 0644);
MODULE_PARM_DESC();

/*
 * The driver enables offload as a default.
 * To disable it, use ofld_disable = 1.
 */

static int ofld_disable =;

module_param(ofld_disable, int, 0644);
MODULE_PARM_DESC();

/*
 * We have work elements that we need to cancel when an interface is taken
 * down.  Normally the work elements would be executed by keventd but that
 * can deadlock because of linkwatch.  If our close method takes the rtnl
 * lock and linkwatch is ahead of our work elements in keventd, linkwatch
 * will block keventd as it needs the rtnl lock, and we'll deadlock waiting
 * for our work to complete.  Get our own work queue to solve this.
 */
struct workqueue_struct *cxgb3_wq;

/**
 *	link_report - show link status and link speed/duplex
 *	@dev: the port whose settings are to be reported
 *
 *	Shows the link status, speed, and duplex of a port.
 */
static void link_report(struct net_device *dev)
{}

static void enable_tx_fifo_drain(struct adapter *adapter,
				 struct port_info *pi)
{}

static void disable_tx_fifo_drain(struct adapter *adapter,
				  struct port_info *pi)
{}

void t3_os_link_fault(struct adapter *adap, int port_id, int state)
{}

/**
 *	t3_os_link_changed - handle link status changes
 *	@adapter: the adapter associated with the link change
 *	@port_id: the port index whose limk status has changed
 *	@link_stat: the new status of the link
 *	@speed: the new speed setting
 *	@duplex: the new duplex setting
 *	@pause: the new flow-control setting
 *
 *	This is the OS-dependent handler for link status changes.  The OS
 *	neutral handler takes care of most of the processing for these events,
 *	then calls this handler for any OS-specific processing.
 */
void t3_os_link_changed(struct adapter *adapter, int port_id, int link_stat,
			int speed, int duplex, int pause)
{}

/**
 *	t3_os_phymod_changed - handle PHY module changes
 *	@adap: the adapter associated with the link change
 *	@port_id: the port index whose limk status has changed
 *
 *	This is the OS-dependent handler for PHY module changes.  It is
 *	invoked when a PHY module is removed or inserted for any OS-specific
 *	processing.
 */
void t3_os_phymod_changed(struct adapter *adap, int port_id)
{}

static void cxgb_set_rxmode(struct net_device *dev)
{}

/**
 *	link_start - enable a port
 *	@dev: the device to enable
 *
 *	Performs the MAC and PHY actions needed to enable a port.
 */
static void link_start(struct net_device *dev)
{}

static inline void cxgb_disable_msi(struct adapter *adapter)
{}

/*
 * Interrupt handler for asynchronous events used with MSI-X.
 */
static irqreturn_t t3_async_intr_handler(int irq, void *cookie)
{}

/*
 * Name the MSI-X interrupts.
 */
static void name_msix_vecs(struct adapter *adap)
{}

static int request_msix_data_irqs(struct adapter *adap)
{}

static void free_irq_resources(struct adapter *adapter)
{}

static int await_mgmt_replies(struct adapter *adap, unsigned long init_cnt,
			      unsigned long n)
{}

static int init_tp_parity(struct adapter *adap)
{}

/**
 *	setup_rss - configure RSS
 *	@adap: the adapter
 *
 *	Sets up RSS to distribute packets to multiple receive queues.  We
 *	configure the RSS CPU lookup table to distribute to the number of HW
 *	receive queues, and the response queue lookup table to narrow that
 *	down to the response queues actually configured for each port.
 *	We always configure the RSS mapping for two ports since the mapping
 *	table has plenty of entries.
 */
static void setup_rss(struct adapter *adap)
{}

static void ring_dbs(struct adapter *adap)
{}

static void init_napi(struct adapter *adap)
{}

/*
 * Wait until all NAPI handlers are descheduled.  This includes the handlers of
 * both netdevices representing interfaces and the dummy ones for the extra
 * queues.
 */
static void quiesce_rx(struct adapter *adap)
{}

static void enable_all_napi(struct adapter *adap)
{}

/**
 *	setup_sge_qsets - configure SGE Tx/Rx/response queues
 *	@adap: the adapter
 *
 *	Determines how many sets of SGE queues to use and initializes them.
 *	We support multiple queue sets per port if we have MSI-X, otherwise
 *	just one queue set per port.
 */
static int setup_sge_qsets(struct adapter *adap)
{}

static ssize_t attr_show(struct device *d, char *buf,
			 ssize_t(*format) (struct net_device *, char *))
{}

static ssize_t attr_store(struct device *d,
			  const char *buf, size_t len,
			  ssize_t(*set) (struct net_device *, unsigned int),
			  unsigned int min_val, unsigned int max_val)
{}

#define CXGB3_SHOW(name, val_expr)

static ssize_t set_nfilters(struct net_device *dev, unsigned int val)
{}

static ssize_t store_nfilters(struct device *d, struct device_attribute *attr,
			      const char *buf, size_t len)
{}

static ssize_t set_nservers(struct net_device *dev, unsigned int val)
{}

static ssize_t store_nservers(struct device *d, struct device_attribute *attr,
			      const char *buf, size_t len)
{}

#define CXGB3_ATTR_R(name, val_expr)

#define CXGB3_ATTR_RW(name, val_expr, store_method)

CXGB3_ATTR_R();
CXGB3_ATTR_RW();
CXGB3_ATTR_RW();

static struct attribute *cxgb3_attrs[] =;

static const struct attribute_group cxgb3_attr_group =;

static ssize_t tm_attr_show(struct device *d,
			    char *buf, int sched)
{}

static ssize_t tm_attr_store(struct device *d,
			     const char *buf, size_t len, int sched)
{}

#define TM_ATTR(name, sched)

TM_ATTR();
TM_ATTR();
TM_ATTR();
TM_ATTR();
TM_ATTR();
TM_ATTR();
TM_ATTR();
TM_ATTR();

static struct attribute *offload_attrs[] =;

static const struct attribute_group offload_attr_group =;

/*
 * Sends an sk_buff to an offload queue driver
 * after dealing with any active network taps.
 */
static inline int offload_tx(struct t3cdev *tdev, struct sk_buff *skb)
{}

static int write_smt_entry(struct adapter *adapter, int idx)
{}

static int init_smt(struct adapter *adapter)
{}

static void init_port_mtus(struct adapter *adapter)
{}

static int send_pktsched_cmd(struct adapter *adap, int sched, int qidx, int lo,
			      int hi, int port)
{}

static int bind_qsets(struct adapter *adap)
{}

#define FW_VERSION
#define FW_FNAME
#define TPSRAM_VERSION
#define TPSRAM_NAME
#define AEL2005_OPT_EDC_NAME
#define AEL2005_TWX_EDC_NAME
#define AEL2020_TWX_EDC_NAME
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();

static inline const char *get_edc_fw_name(int edc_idx)
{}

int t3_get_edc_fw(struct cphy *phy, int edc_idx, int size)
{}

static int upgrade_fw(struct adapter *adap)
{}

static inline char t3rev2char(struct adapter *adapter)
{}

static int update_tpsram(struct adapter *adap)
{}

/**
 * t3_synchronize_rx - wait for current Rx processing on a port to complete
 * @adap: the adapter
 * @p: the port
 *
 * Ensures that current Rx processing on any of the queues associated with
 * the given port completes before returning.  We do this by acquiring and
 * releasing the locks of the response queues associated with the port.
 */
static void t3_synchronize_rx(struct adapter *adap, const struct port_info *p)
{}

static void cxgb_vlan_mode(struct net_device *dev, netdev_features_t features)
{}

/**
 *	cxgb_up - enable the adapter
 *	@adap: adapter being enabled
 *
 *	Called when the first port is enabled, this function performs the
 *	actions necessary to make an adapter operational, such as completing
 *	the initialization of HW modules, and enabling interrupts.
 *
 *	Must be called with the rtnl lock held.
 */
static int cxgb_up(struct adapter *adap)
{}

/*
 * Release resources when all the ports and offloading have been stopped.
 */
static void cxgb_down(struct adapter *adapter, int on_wq)
{}

static void schedule_chk_task(struct adapter *adap)
{}

static int offload_open(struct net_device *dev)
{}

static int offload_close(struct t3cdev *tdev)
{}

static int cxgb_open(struct net_device *dev)
{}

static int __cxgb_close(struct net_device *dev, int on_wq)
{}

static int cxgb_close(struct net_device *dev)
{}

static struct net_device_stats *cxgb_get_stats(struct net_device *dev)
{}

static u32 get_msglevel(struct net_device *dev)
{}

static void set_msglevel(struct net_device *dev, u32 val)
{}

static const char stats_strings[][ETH_GSTRING_LEN] =;

static int get_sset_count(struct net_device *dev, int sset)
{}

#define T3_REGMAP_SIZE

static int get_regs_len(struct net_device *dev)
{}

static int get_eeprom_len(struct net_device *dev)
{}

static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{}

static void get_strings(struct net_device *dev, u32 stringset, u8 * data)
{}

static unsigned long collect_sge_port_stats(struct adapter *adapter,
					    struct port_info *p, int idx)
{}

static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
		      u64 *data)
{}

static inline void reg_block_dump(struct adapter *ap, void *buf,
				  unsigned int start, unsigned int end)
{}

static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
		     void *buf)
{}

static int restart_autoneg(struct net_device *dev)
{}

static int set_phys_id(struct net_device *dev,
		       enum ethtool_phys_id_state state)
{}

static int get_link_ksettings(struct net_device *dev,
			      struct ethtool_link_ksettings *cmd)
{}

static int speed_duplex_to_caps(int speed, int duplex)
{}

#define ADVERTISED_MASK

static int set_link_ksettings(struct net_device *dev,
			      const struct ethtool_link_ksettings *cmd)
{}

static void get_pauseparam(struct net_device *dev,
			   struct ethtool_pauseparam *epause)
{}

static int set_pauseparam(struct net_device *dev,
			  struct ethtool_pauseparam *epause)
{}

static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e,
			  struct kernel_ethtool_ringparam *kernel_e,
			  struct netlink_ext_ack *extack)
{}

static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e,
			 struct kernel_ethtool_ringparam *kernel_e,
			 struct netlink_ext_ack *extack)
{}

static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c,
			struct kernel_ethtool_coalesce *kernel_coal,
			struct netlink_ext_ack *extack)
{}

static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c,
			struct kernel_ethtool_coalesce *kernel_coal,
			struct netlink_ext_ack *extack)
{}

static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e,
		      u8 * data)
{}

static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
		      u8 * data)
{}

static void get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{}

static const struct ethtool_ops cxgb_ethtool_ops =;

static int cxgb_in_range(int val, int lo, int hi)
{}

static int cxgb_siocdevprivate(struct net_device *dev,
			       struct ifreq *ifreq,
			       void __user *useraddr,
			       int cmd)
{}

static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
{}

static int cxgb_change_mtu(struct net_device *dev, int new_mtu)
{}

static int cxgb_set_mac_addr(struct net_device *dev, void *p)
{}

static netdev_features_t cxgb_fix_features(struct net_device *dev,
	netdev_features_t features)
{}

static int cxgb_set_features(struct net_device *dev, netdev_features_t features)
{}

#ifdef CONFIG_NET_POLL_CONTROLLER
static void cxgb_netpoll(struct net_device *dev)
{}
#endif

/*
 * Periodic accumulation of MAC statistics.
 */
static void mac_stats_update(struct adapter *adapter)
{}

static void check_link_status(struct adapter *adapter)
{}

static void check_t3b2_mac(struct adapter *adapter)
{}


static void t3_adap_check_task(struct work_struct *work)
{}

static void db_full_task(struct work_struct *work)
{}

static void db_empty_task(struct work_struct *work)
{}

static void db_drop_task(struct work_struct *work)
{}

/*
 * Processes external (PHY) interrupts in process context.
 */
static void ext_intr_task(struct work_struct *work)
{}

/*
 * Interrupt-context handler for external (PHY) interrupts.
 */
void t3_os_ext_intr_handler(struct adapter *adapter)
{}

void t3_os_link_fault_handler(struct adapter *adapter, int port_id)
{}

static int t3_adapter_error(struct adapter *adapter, int reset, int on_wq)
{}

static int t3_reenable_adapter(struct adapter *adapter)
{}

static void t3_resume_ports(struct adapter *adapter)
{}

/*
 * processes a fatal error.
 * Bring the ports down, reset the chip, bring the ports back up.
 */
static void fatal_error_task(struct work_struct *work)
{}

void t3_fatal_err(struct adapter *adapter)
{}

/**
 * t3_io_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 t3_io_error_detected(struct pci_dev *pdev,
					     pci_channel_state_t state)
{}

/**
 * t3_io_slot_reset - called after the pci bus has been reset.
 * @pdev: Pointer to PCI device
 *
 * Restart the card from scratch, as if from a cold-boot.
 */
static pci_ers_result_t t3_io_slot_reset(struct pci_dev *pdev)
{}

/**
 * t3_io_resume - called when traffic can start flowing again.
 * @pdev: Pointer to PCI device
 *
 * This callback is called when the error recovery driver tells us that
 * its OK to resume normal operation.
 */
static void t3_io_resume(struct pci_dev *pdev)
{}

static const struct pci_error_handlers t3_err_handler =;

/*
 * Set the number of qsets based on the number of CPUs and the number of ports,
 * not to exceed the number of available qsets, assuming there are enough qsets
 * per port in HW.
 */
static void set_nqsets(struct adapter *adap)
{}

static int cxgb_enable_msix(struct adapter *adap)
{}

static void print_port_info(struct adapter *adap, const struct adapter_info *ai)
{}

static const struct net_device_ops cxgb_netdev_ops =;

static void cxgb3_init_iscsi_mac(struct net_device *dev)
{}

#define TSO_FLAGS
#define VLAN_FEAT
static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{}

static void remove_one(struct pci_dev *pdev)
{}

static struct pci_driver driver =;

static int __init cxgb3_init_module(void)
{}

static void __exit cxgb3_cleanup_module(void)
{}

module_init();
module_exit(cxgb3_cleanup_module);