linux/drivers/scsi/qedf/qedf_main.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  QLogic FCoE Offload Driver
 *  Copyright (c) 2016-2018 Cavium Inc.
 */
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/device.h>
#include <linux/highmem.h>
#include <linux/crc32.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/kthread.h>
#include <linux/phylink.h>
#include <scsi/libfc.h>
#include <scsi/scsi_host.h>
#include <scsi/fc_frame.h>
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/cpu.h>
#include "qedf.h"
#include "qedf_dbg.h"
#include <uapi/linux/pci_regs.h>

const struct qed_fcoe_ops *qed_ops;

static int qedf_probe(struct pci_dev *pdev, const struct pci_device_id *id);
static void qedf_remove(struct pci_dev *pdev);
static void qedf_shutdown(struct pci_dev *pdev);
static void qedf_schedule_recovery_handler(void *dev);
static void qedf_recovery_handler(struct work_struct *work);
static int qedf_suspend(struct pci_dev *pdev, pm_message_t state);

/*
 * Driver module parameters.
 */
static unsigned int qedf_dev_loss_tmo =;
module_param_named(dev_loss_tmo, qedf_dev_loss_tmo, int, S_IRUGO);
MODULE_PARM_DESC();

uint qedf_debug =;
module_param_named(debug, qedf_debug, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC();

static uint qedf_fipvlan_retries =;
module_param_named(fipvlan_retries, qedf_fipvlan_retries, int, S_IRUGO);
MODULE_PARM_DESC();

static uint qedf_fallback_vlan =;
module_param_named(fallback_vlan, qedf_fallback_vlan, int, S_IRUGO);
MODULE_PARM_DESC();

static int qedf_default_prio =;
module_param_named(default_prio, qedf_default_prio, int, S_IRUGO);
MODULE_PARM_DESC();

uint qedf_dump_frames;
module_param_named(dump_frames, qedf_dump_frames, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC();

static uint qedf_queue_depth;
module_param_named(queue_depth, qedf_queue_depth, int, S_IRUGO);
MODULE_PARM_DESC();

uint qedf_io_tracing;
module_param_named(io_tracing, qedf_io_tracing, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC();

static uint qedf_max_lun =;
module_param_named(max_lun, qedf_max_lun, int, S_IRUGO);
MODULE_PARM_DESC();

uint qedf_link_down_tmo;
module_param_named(link_down_tmo, qedf_link_down_tmo, int, S_IRUGO);
MODULE_PARM_DESC();

bool qedf_retry_delay;
module_param_named(retry_delay, qedf_retry_delay, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC();

static bool qedf_dcbx_no_wait;
module_param_named(dcbx_no_wait, qedf_dcbx_no_wait, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC();

static uint qedf_dp_module;
module_param_named(dp_module, qedf_dp_module, uint, S_IRUGO);
MODULE_PARM_DESC();

static uint qedf_dp_level =;
module_param_named(dp_level, qedf_dp_level, uint, S_IRUGO);
MODULE_PARM_DESC();

static bool qedf_enable_recovery =;
module_param_named(enable_recovery, qedf_enable_recovery,
		bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC();

struct workqueue_struct *qedf_io_wq;

static struct fcoe_percpu_s qedf_global;
static DEFINE_SPINLOCK(qedf_global_lock);

static struct kmem_cache *qedf_io_work_cache;

void qedf_set_vlan_id(struct qedf_ctx *qedf, int vlan_id)
{}

/* Returns true if we have a valid vlan, false otherwise */
static bool qedf_initiate_fipvlan_req(struct qedf_ctx *qedf)
{}

static void qedf_handle_link_update(struct work_struct *work)
{}

#define QEDF_FCOE_MAC_METHOD_GRANGED_MAC
#define QEDF_FCOE_MAC_METHOD_FCF_MAP
#define QEDF_FCOE_MAC_METHOD_FCOE_SET_MAC
static void qedf_set_data_src_addr(struct qedf_ctx *qedf, struct fc_frame *fp)
{}

static void qedf_flogi_resp(struct fc_seq *seq, struct fc_frame *fp,
	void *arg)
{}

static struct fc_seq *qedf_elsct_send(struct fc_lport *lport, u32 did,
	struct fc_frame *fp, unsigned int op,
	void (*resp)(struct fc_seq *,
	struct fc_frame *,
	void *),
	void *arg, u32 timeout)
{}

int qedf_send_flogi(struct qedf_ctx *qedf)
{}

/*
 * This function is called if link_down_tmo is in use.  If we get a link up and
 * link_down_tmo has not expired then use just FLOGI/ADISC to recover our
 * sessions with targets.  Otherwise, just call fcoe_ctlr_link_up().
 */
static void qedf_link_recovery(struct work_struct *work)
{}

static void qedf_update_link_speed(struct qedf_ctx *qedf,
	struct qed_link_output *link)
{}

static void qedf_bw_update(void *dev)
{}

static void qedf_link_update(void *dev, struct qed_link_output *link)
{}


static void qedf_dcbx_handler(void *dev, struct qed_dcbx_get *get, u32 mib_type)
{}

static u32 qedf_get_login_failures(void *cookie)
{}

static struct qed_fcoe_cb_ops qedf_cb_ops =;

/*
 * Various transport templates.
 */

static struct scsi_transport_template *qedf_fc_transport_template;
static struct scsi_transport_template *qedf_fc_vport_transport_template;

/*
 * SCSI EH handlers
 */
static int qedf_eh_abort(struct scsi_cmnd *sc_cmd)
{}

static int qedf_eh_target_reset(struct scsi_cmnd *sc_cmd)
{}

static int qedf_eh_device_reset(struct scsi_cmnd *sc_cmd)
{}

bool qedf_wait_for_upload(struct qedf_ctx *qedf)
{}

/* Performs soft reset of qedf_ctx by simulating a link down/up */
void qedf_ctx_soft_reset(struct fc_lport *lport)
{}

/* Reset the host by gracefully logging out and then logging back in */
static int qedf_eh_host_reset(struct scsi_cmnd *sc_cmd)
{}

static int qedf_slave_configure(struct scsi_device *sdev)
{}

static const struct scsi_host_template qedf_host_template =;

static int qedf_get_paged_crc_eof(struct sk_buff *skb, int tlen)
{}

static struct qedf_rport *qedf_fcport_lookup(struct qedf_ctx *qedf, u32 port_id)
{}

/* Transmits an ELS frame over an offloaded session */
static int qedf_xmit_l2_frame(struct qedf_rport *fcport, struct fc_frame *fp)
{}

/*
 * qedf_xmit - qedf FCoE frame transmit function
 */
static int qedf_xmit(struct fc_lport *lport, struct fc_frame *fp)
{}

static int qedf_alloc_sq(struct qedf_ctx *qedf, struct qedf_rport *fcport)
{}

static void qedf_free_sq(struct qedf_ctx *qedf, struct qedf_rport *fcport)
{}

static int qedf_offload_connection(struct qedf_ctx *qedf,
	struct qedf_rport *fcport)
{}

#define QEDF_TERM_BUFF_SIZE
static void qedf_upload_connection(struct qedf_ctx *qedf,
	struct qedf_rport *fcport)
{}

static void qedf_cleanup_fcport(struct qedf_ctx *qedf,
	struct qedf_rport *fcport)
{}

/*
 * This event_callback is called after successful completion of libfc
 * initiated target login. qedf can proceed with initiating the session
 * establishment.
 */
static void qedf_rport_event_handler(struct fc_lport *lport,
				struct fc_rport_priv *rdata,
				enum fc_rport_event event)
{}

static void qedf_abort_io(struct fc_lport *lport)
{}

static void qedf_fcp_cleanup(struct fc_lport *lport)
{}

static struct libfc_function_template qedf_lport_template =;

static void qedf_fcoe_ctlr_setup(struct qedf_ctx *qedf)
{}

static void qedf_setup_fdmi(struct qedf_ctx *qedf)
{}

static int qedf_lport_setup(struct qedf_ctx *qedf)
{}

/*
 * NPIV functions
 */

static int qedf_vport_libfc_config(struct fc_vport *vport,
	struct fc_lport *lport)
{}

static int qedf_vport_create(struct fc_vport *vport, bool disabled)
{}

static int qedf_vport_destroy(struct fc_vport *vport)
{}

static int qedf_vport_disable(struct fc_vport *vport, bool disable)
{}

/*
 * During removal we need to wait for all the vports associated with a port
 * to be destroyed so we avoid a race condition where libfc is still trying
 * to reap vports while the driver remove function has already reaped the
 * driver contexts associated with the physical port.
 */
static void qedf_wait_for_vport_destroy(struct qedf_ctx *qedf)
{}

/**
 * qedf_fcoe_reset - Resets the fcoe
 *
 * @shost: shost the reset is from
 *
 * Returns: always 0
 */
static int qedf_fcoe_reset(struct Scsi_Host *shost)
{}

static void qedf_get_host_port_id(struct Scsi_Host *shost)
{}

static struct fc_host_statistics *qedf_fc_get_host_stats(struct Scsi_Host
	*shost)
{}

static struct fc_function_template qedf_fc_transport_fn =;

static struct fc_function_template qedf_fc_vport_transport_fn =;

static bool qedf_fp_has_work(struct qedf_fastpath *fp)
{}

/*
 * Interrupt handler code.
 */

/* Process completion queue and copy CQE contents for deferred processesing
 *
 * Return true if we should wake the I/O thread, false if not.
 */
static bool qedf_process_completions(struct qedf_fastpath *fp)
{}


/* MSI-X fastpath handler code */
static irqreturn_t qedf_msix_handler(int irq, void *dev_id)
{}

/* simd handler for MSI/INTa */
static void qedf_simd_int_handler(void *cookie)
{}

#define QEDF_SIMD_HANDLER_NUM
static void qedf_sync_free_irqs(struct qedf_ctx *qedf)
{}

static int qedf_request_msix_irq(struct qedf_ctx *qedf)
{}

static int qedf_setup_int(struct qedf_ctx *qedf)
{}

/* Main function for libfc frame reception */
static void qedf_recv_frame(struct qedf_ctx *qedf,
	struct sk_buff *skb)
{}

static void qedf_ll2_process_skb(struct work_struct *work)
{}

static int qedf_ll2_rx(void *cookie, struct sk_buff *skb,
	u32 arg1, u32 arg2)
{}

static struct qed_ll2_cb_ops qedf_ll2_cb_ops =;

/* Main thread to process I/O completions */
void qedf_fp_io_handler(struct work_struct *work)
{}

static int qedf_alloc_and_init_sb(struct qedf_ctx *qedf,
	struct qed_sb_info *sb_info, u16 sb_id)
{}

static void qedf_free_sb(struct qedf_ctx *qedf, struct qed_sb_info *sb_info)
{}

static void qedf_destroy_sb(struct qedf_ctx *qedf)
{}

static int qedf_prepare_sb(struct qedf_ctx *qedf)
{}

void qedf_process_cqe(struct qedf_ctx *qedf, struct fcoe_cqe *cqe)
{}

static void qedf_free_bdq(struct qedf_ctx *qedf)
{}

static void qedf_free_global_queues(struct qedf_ctx *qedf)
{}

static int qedf_alloc_bdq(struct qedf_ctx *qedf)
{}

static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
{}

static int qedf_set_fcoe_pf_param(struct qedf_ctx *qedf)
{}

/* Free DMA coherent memory for array of queue pointers we pass to qed */
static void qedf_free_fcoe_pf_param(struct qedf_ctx *qedf)
{}

/*
 * PCI driver functions
 */

static const struct pci_device_id qedf_pci_tbl[] =;
MODULE_DEVICE_TABLE(pci, qedf_pci_tbl);

static struct pci_driver qedf_pci_driver =;

static int __qedf_probe(struct pci_dev *pdev, int mode)
{}

static int qedf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{}

static void __qedf_remove(struct pci_dev *pdev, int mode)
{}

static void qedf_remove(struct pci_dev *pdev)
{}

void qedf_wq_grcdump(struct work_struct *work)
{}

void qedf_schedule_hw_err_handler(void *dev, enum qed_hw_err_type err_type)
{}

/*
 * Protocol TLV handler
 */
void qedf_get_protocol_tlv_data(void *dev, void *data)
{}

/* Deferred work function to perform soft context reset on STAG change */
void qedf_stag_change_work(struct work_struct *work)
{}

static void qedf_shutdown(struct pci_dev *pdev)
{}

static int qedf_suspend(struct pci_dev *pdev, pm_message_t state)
{}

/*
 * Recovery handler code
 */
static void qedf_schedule_recovery_handler(void *dev)
{}

static void qedf_recovery_handler(struct work_struct *work)
{}

/* Generic TLV data callback */
void qedf_get_generic_tlv_data(void *dev, struct qed_generic_tlvs *data)
{}

/*
 * Module Init/Remove
 */

static int __init qedf_init(void)
{}

static void __exit qedf_cleanup(void)
{}

MODULE_LICENSE();
MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_VERSION();
module_init();
module_exit(qedf_cleanup);