2009-09-24 08:46:15 +08:00
|
|
|
/*
|
2015-11-26 16:54:45 +08:00
|
|
|
* Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
|
|
|
|
* Copyright (c) 2014- QLogic Corporation.
|
2009-09-24 08:46:15 +08:00
|
|
|
* All rights reserved
|
2015-11-26 16:54:45 +08:00
|
|
|
* www.qlogic.com
|
2009-09-24 08:46:15 +08:00
|
|
|
*
|
2015-11-26 16:54:46 +08:00
|
|
|
* Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
|
2009-09-24 08:46:15 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License (GPL) Version 2 as
|
|
|
|
* published by the Free Software Foundation
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2010-10-19 08:15:55 +08:00
|
|
|
/*
|
2009-09-24 08:46:15 +08:00
|
|
|
* Contains base driver definitions.
|
|
|
|
*/
|
|
|
|
|
2010-10-19 08:15:55 +08:00
|
|
|
/*
|
2009-09-24 08:46:15 +08:00
|
|
|
* bfa_drv.h Linux driver data structures.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __BFAD_DRV_H__
|
|
|
|
#define __BFAD_DRV_H__
|
|
|
|
|
2010-12-10 11:12:32 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/idr.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/cdev.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/bitops.h>
|
2012-08-23 10:52:02 +08:00
|
|
|
#include <linux/aer.h>
|
2010-12-10 11:12:32 +08:00
|
|
|
#include <scsi/scsi.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <scsi/scsi_tcq.h>
|
|
|
|
#include <scsi/scsi_transport_fc.h>
|
|
|
|
#include <scsi/scsi_transport.h>
|
2011-06-14 06:55:11 +08:00
|
|
|
#include <scsi/scsi_bsg_fc.h>
|
2011-12-21 10:58:32 +08:00
|
|
|
#include <scsi/scsi_devinfo.h>
|
2009-09-24 08:46:15 +08:00
|
|
|
|
2010-09-16 02:50:55 +08:00
|
|
|
#include "bfa_modules.h"
|
|
|
|
#include "bfa_fcs.h"
|
|
|
|
#include "bfa_defs_fcs.h"
|
|
|
|
|
|
|
|
#include "bfa_plog.h"
|
|
|
|
#include "bfa_cs.h"
|
|
|
|
|
|
|
|
#define BFAD_DRIVER_NAME "bfa"
|
2009-09-24 08:46:15 +08:00
|
|
|
#ifdef BFA_DRIVER_VERSION
|
|
|
|
#define BFAD_DRIVER_VERSION BFA_DRIVER_VERSION
|
|
|
|
#else
|
scsi: bfa: Increase requested firmware version to 3.2.5.1
bna & bfa firmware version 3.2.5.1 was submitted to linux-firmware on
Feb 17 19:10:20 2015 -0500 in 0ab54ff1dc ("linux-firmware: Add QLogic BR
Series Adapter Firmware").
bna was updated to use the newer firmware on Feb 19 16:02:32 2015 -0500 in
3f307c3d70 ("bna: Update the Driver and Firmware Version")
bfa was not updated. I presume this was an oversight but it broke support
for bfa+bna cards such as the following
04:00.0 Fibre Channel [0c04]: Brocade Communications Systems, Inc.
1010/1020/1007/1741 10Gbps CNA [1657:0014] (rev 01)
04:00.1 Fibre Channel [0c04]: Brocade Communications Systems, Inc.
1010/1020/1007/1741 10Gbps CNA [1657:0014] (rev 01)
04:00.2 Ethernet controller [0200]: Brocade Communications Systems,
Inc. 1010/1020/1007/1741 10Gbps CNA [1657:0014] (rev 01)
04:00.3 Ethernet controller [0200]: Brocade Communications Systems,
Inc. 1010/1020/1007/1741 10Gbps CNA [1657:0014] (rev 01)
Currently, if the bfa module is loaded first, bna fails to probe the
respective devices with
[ 215.026787] bna: QLogic BR-series 10G Ethernet driver - version: 3.2.25.1
[ 215.043707] bna 0000:04:00.2: bar0 mapped to ffffc90001fc0000, len 262144
[ 215.060656] bna 0000:04:00.2: initialization failed err=1
[ 215.073893] bna 0000:04:00.3: bar0 mapped to ffffc90002040000, len 262144
[ 215.090644] bna 0000:04:00.3: initialization failed err=1
Whereas if bna is loaded first, bfa fails with
[ 249.592109] QLogic BR-series BFA FC/FCOE SCSI driver - version: 3.2.25.0
[ 249.610738] bfa 0000:04:00.0: Running firmware version is incompatible with the driver version
[ 249.833513] bfa 0000:04:00.0: bfa init failed
[ 249.833919] scsi host6: QLogic BR-series FC/FCOE Adapter, hwpath: 0000:04:00.0 driver: 3.2.25.0
[ 249.841446] bfa 0000:04:00.1: Running firmware version is incompatible with the driver version
[ 250.045449] bfa 0000:04:00.1: bfa init failed
[ 250.045962] scsi host7: QLogic BR-series FC/FCOE Adapter, hwpath: 0000:04:00.1 driver: 3.2.25.0
Increase bfa's requested firmware version. Also increase the driver
version. I only tested that all of the devices probe without error.
Reported-by: Tim Ehlers <tehlers@gwdg.de>
Signed-off-by: Benjamin Poirier <bpoirier@suse.com>
Acked-by: Rasesh Mody <rasesh.mody@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-12-24 12:40:19 +08:00
|
|
|
#define BFAD_DRIVER_VERSION "3.2.25.1"
|
2009-09-24 08:46:15 +08:00
|
|
|
#endif
|
|
|
|
|
2010-09-16 02:50:55 +08:00
|
|
|
#define BFAD_PROTO_NAME FCPI_NAME
|
2009-09-24 08:46:15 +08:00
|
|
|
#define BFAD_IRQ_FLAGS IRQF_SHARED
|
|
|
|
|
2010-09-16 02:50:55 +08:00
|
|
|
#ifndef FC_PORTSPEED_8GBIT
|
|
|
|
#define FC_PORTSPEED_8GBIT 0x10
|
|
|
|
#endif
|
|
|
|
|
2009-09-24 08:46:15 +08:00
|
|
|
/*
|
|
|
|
* BFAD flags
|
|
|
|
*/
|
|
|
|
#define BFAD_MSIX_ON 0x00000001
|
|
|
|
#define BFAD_HAL_INIT_DONE 0x00000002
|
|
|
|
#define BFAD_DRV_INIT_DONE 0x00000004
|
|
|
|
#define BFAD_CFG_PPORT_DONE 0x00000008
|
|
|
|
#define BFAD_HAL_START_DONE 0x00000010
|
|
|
|
#define BFAD_PORT_ONLINE 0x00000020
|
|
|
|
#define BFAD_RPORT_ONLINE 0x00000040
|
2010-09-16 02:50:55 +08:00
|
|
|
#define BFAD_FCS_INIT_DONE 0x00000080
|
|
|
|
#define BFAD_HAL_INIT_FAIL 0x00000100
|
|
|
|
#define BFAD_FC4_PROBE_DONE 0x00000200
|
2009-09-24 08:46:15 +08:00
|
|
|
#define BFAD_PORT_DELETE 0x00000001
|
2011-06-25 11:29:07 +08:00
|
|
|
#define BFAD_INTX_ON 0x00000400
|
2012-08-23 10:52:02 +08:00
|
|
|
#define BFAD_EEH_BUSY 0x00000800
|
|
|
|
#define BFAD_EEH_PCI_CHANNEL_IO_PERM_FAILURE 0x00001000
|
2009-09-24 08:46:15 +08:00
|
|
|
/*
|
|
|
|
* BFAD related definition
|
|
|
|
*/
|
|
|
|
#define SCSI_SCAN_DELAY HZ
|
|
|
|
#define BFAD_STOP_TIMEOUT 30
|
|
|
|
#define BFAD_SUSPEND_TIMEOUT BFAD_STOP_TIMEOUT
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BFAD configuration parameter default values
|
|
|
|
*/
|
2010-09-16 02:50:55 +08:00
|
|
|
#define BFAD_LUN_QUEUE_DEPTH 32
|
|
|
|
#define BFAD_IO_MAX_SGE SG_ALL
|
2011-06-25 11:29:07 +08:00
|
|
|
#define BFAD_MIN_SECTORS 128 /* 64k */
|
|
|
|
#define BFAD_MAX_SECTORS 0xFFFF /* 32 MB */
|
2009-09-24 08:46:15 +08:00
|
|
|
|
|
|
|
#define bfad_isr_t irq_handler_t
|
|
|
|
|
|
|
|
#define MAX_MSIX_ENTRY 22
|
|
|
|
|
|
|
|
struct bfad_msix_s {
|
|
|
|
struct bfad_s *bfad;
|
|
|
|
struct msix_entry msix;
|
2010-09-16 02:50:55 +08:00
|
|
|
char name[32];
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only append to the enums defined here to avoid any versioning
|
|
|
|
* needed between trace utility and driver version
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
BFA_TRC_LDRV_BFAD = 1,
|
|
|
|
BFA_TRC_LDRV_IM = 2,
|
2011-06-14 06:55:11 +08:00
|
|
|
BFA_TRC_LDRV_BSG = 3,
|
2009-09-24 08:46:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum bfad_port_pvb_type {
|
|
|
|
BFAD_PORT_PHYS_BASE = 0,
|
|
|
|
BFAD_PORT_PHYS_VPORT = 1,
|
|
|
|
BFAD_PORT_VF_BASE = 2,
|
|
|
|
BFAD_PORT_VF_VPORT = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PORT data structure
|
|
|
|
*/
|
|
|
|
struct bfad_port_s {
|
|
|
|
struct list_head list_entry;
|
2010-09-16 02:50:55 +08:00
|
|
|
struct bfad_s *bfad;
|
|
|
|
struct bfa_fcs_lport_s *fcs_port;
|
|
|
|
u32 roles;
|
|
|
|
s32 flags;
|
|
|
|
u32 supported_fc4s;
|
2009-09-24 08:46:15 +08:00
|
|
|
enum bfad_port_pvb_type pvb_type;
|
|
|
|
struct bfad_im_port_s *im_port; /* IM specific data */
|
2010-07-09 11:02:55 +08:00
|
|
|
/* port debugfs specific data */
|
|
|
|
struct dentry *port_debugfs_root;
|
2009-09-24 08:46:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VPORT data structure
|
|
|
|
*/
|
|
|
|
struct bfad_vport_s {
|
|
|
|
struct bfad_port_s drv_port;
|
|
|
|
struct bfa_fcs_vport_s fcs_vport;
|
|
|
|
struct completion *comp_del;
|
2010-07-09 10:46:26 +08:00
|
|
|
struct list_head list_entry;
|
2009-09-24 08:46:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VF data structure
|
|
|
|
*/
|
|
|
|
struct bfad_vf_s {
|
|
|
|
bfa_fcs_vf_t fcs_vf;
|
|
|
|
struct bfad_port_s base_port; /* base port for vf */
|
|
|
|
struct bfad_s *bfad;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bfad_cfg_param_s {
|
2010-09-16 02:50:55 +08:00
|
|
|
u32 rport_del_timeout;
|
|
|
|
u32 ioc_queue_depth;
|
|
|
|
u32 lun_queue_depth;
|
|
|
|
u32 io_max_sge;
|
|
|
|
u32 binding_method;
|
|
|
|
};
|
|
|
|
|
|
|
|
union bfad_tmp_buf {
|
|
|
|
/* From struct bfa_adapter_attr_s */
|
|
|
|
char manufacturer[BFA_ADAPTER_MFG_NAME_LEN];
|
|
|
|
char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
|
|
|
|
char model[BFA_ADAPTER_MODEL_NAME_LEN];
|
|
|
|
char fw_ver[BFA_VERSION_LEN];
|
|
|
|
char optrom_ver[BFA_VERSION_LEN];
|
|
|
|
|
|
|
|
/* From struct bfa_ioc_pci_attr_s */
|
|
|
|
u8 chip_rev[BFA_IOC_CHIP_REV_LEN]; /* chip revision */
|
|
|
|
|
|
|
|
wwn_t wwn[BFA_FCS_MAX_LPORTS];
|
2009-09-24 08:46:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BFAD (PCI function) data structure
|
|
|
|
*/
|
|
|
|
struct bfad_s {
|
2010-09-16 02:50:55 +08:00
|
|
|
bfa_sm_t sm; /* state machine */
|
2009-09-24 08:46:15 +08:00
|
|
|
struct list_head list_entry;
|
2010-09-16 02:50:55 +08:00
|
|
|
struct bfa_s bfa;
|
|
|
|
struct bfa_fcs_s bfa_fcs;
|
2009-09-24 08:46:15 +08:00
|
|
|
struct pci_dev *pcidev;
|
|
|
|
const char *pci_name;
|
|
|
|
struct bfa_pcidev_s hal_pcidev;
|
|
|
|
struct bfa_ioc_pci_attr_s pci_attr;
|
|
|
|
void __iomem *pci_bar0_kva;
|
2011-06-14 06:50:35 +08:00
|
|
|
void __iomem *pci_bar2_kva;
|
2009-09-24 08:46:15 +08:00
|
|
|
struct completion comp;
|
|
|
|
struct completion suspend;
|
2011-06-25 11:25:15 +08:00
|
|
|
struct completion enable_comp;
|
2009-09-24 08:46:15 +08:00
|
|
|
struct completion disable_comp;
|
|
|
|
bfa_boolean_t disable_active;
|
|
|
|
struct bfad_port_s pport; /* physical port of the BFAD */
|
|
|
|
struct bfa_meminfo_s meminfo;
|
|
|
|
struct bfa_iocfc_cfg_s ioc_cfg;
|
2010-09-16 02:50:55 +08:00
|
|
|
u32 inst_no; /* BFAD instance number */
|
|
|
|
u32 bfad_flags;
|
2009-09-24 08:46:15 +08:00
|
|
|
spinlock_t bfad_lock;
|
2010-03-04 09:44:02 +08:00
|
|
|
struct task_struct *bfad_tsk;
|
2009-09-24 08:46:15 +08:00
|
|
|
struct bfad_cfg_param_s cfg_data;
|
|
|
|
struct bfad_msix_s msix_tab[MAX_MSIX_ENTRY];
|
2010-09-16 02:50:55 +08:00
|
|
|
int nvec;
|
|
|
|
char adapter_name[BFA_ADAPTER_SYM_NAME_LEN];
|
|
|
|
char port_name[BFA_ADAPTER_SYM_NAME_LEN];
|
2009-09-24 08:46:15 +08:00
|
|
|
struct timer_list hal_tmo;
|
|
|
|
unsigned long hs_start;
|
|
|
|
struct bfad_im_s *im; /* IM specific data */
|
|
|
|
struct bfa_trc_mod_s *trcmod;
|
|
|
|
struct bfa_plog_s plog_buf;
|
2010-09-16 02:50:55 +08:00
|
|
|
int ref_count;
|
|
|
|
union bfad_tmp_buf tmp_buf;
|
2009-09-24 08:46:15 +08:00
|
|
|
struct fc_host_statistics link_stats;
|
2010-09-16 02:50:55 +08:00
|
|
|
struct list_head pbc_vport_list;
|
2010-07-09 11:02:55 +08:00
|
|
|
/* debugfs specific data */
|
|
|
|
char *regdata;
|
|
|
|
u32 reglen;
|
|
|
|
struct dentry *bfad_dentry_files[5];
|
2011-07-21 07:59:13 +08:00
|
|
|
struct list_head free_aen_q;
|
|
|
|
struct list_head active_aen_q;
|
|
|
|
struct bfa_aen_entry_s aen_list[BFA_AEN_MAX_ENTRY];
|
|
|
|
spinlock_t bfad_aen_spinlock;
|
2011-12-21 10:58:32 +08:00
|
|
|
struct list_head vport_list;
|
2010-07-09 10:46:26 +08:00
|
|
|
};
|
|
|
|
|
2010-09-16 02:50:55 +08:00
|
|
|
/* BFAD state machine events */
|
|
|
|
enum bfad_sm_event {
|
|
|
|
BFAD_E_CREATE = 1,
|
|
|
|
BFAD_E_KTHREAD_CREATE_FAILED = 2,
|
|
|
|
BFAD_E_INIT = 3,
|
|
|
|
BFAD_E_INIT_SUCCESS = 4,
|
2013-11-21 17:37:33 +08:00
|
|
|
BFAD_E_HAL_INIT_FAILED = 5,
|
|
|
|
BFAD_E_INIT_FAILED = 6,
|
2010-09-16 02:50:55 +08:00
|
|
|
BFAD_E_FCS_EXIT_COMP = 7,
|
|
|
|
BFAD_E_EXIT_COMP = 8,
|
|
|
|
BFAD_E_STOP = 9
|
2009-09-24 08:46:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RPORT data structure
|
|
|
|
*/
|
|
|
|
struct bfad_rport_s {
|
|
|
|
struct bfa_fcs_rport_s fcs_rport;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bfad_buf_info {
|
2010-09-16 02:50:55 +08:00
|
|
|
void *virt;
|
2009-09-24 08:46:15 +08:00
|
|
|
dma_addr_t phys;
|
2010-09-16 02:50:55 +08:00
|
|
|
u32 size;
|
2009-09-24 08:46:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct bfad_fcxp {
|
|
|
|
struct bfad_port_s *port;
|
|
|
|
struct bfa_rport_s *bfa_rport;
|
|
|
|
bfa_status_t req_status;
|
2010-09-16 02:50:55 +08:00
|
|
|
u16 tag;
|
|
|
|
u16 rsp_len;
|
|
|
|
u16 rsp_maxlen;
|
|
|
|
u8 use_ireqbuf;
|
|
|
|
u8 use_irspbuf;
|
|
|
|
u32 num_req_sgles;
|
|
|
|
u32 num_rsp_sgles;
|
|
|
|
struct fchs_s fchs;
|
|
|
|
void *reqbuf_info;
|
|
|
|
void *rspbuf_info;
|
2009-09-24 08:46:15 +08:00
|
|
|
struct bfa_sge_s *req_sge;
|
|
|
|
struct bfa_sge_s *rsp_sge;
|
|
|
|
fcxp_send_cb_t send_cbfn;
|
2010-09-16 02:50:55 +08:00
|
|
|
void *send_cbarg;
|
|
|
|
void *bfa_fcxp;
|
2009-09-24 08:46:15 +08:00
|
|
|
struct completion comp;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bfad_hal_comp {
|
|
|
|
bfa_status_t status;
|
|
|
|
struct completion comp;
|
|
|
|
};
|
|
|
|
|
2010-12-10 11:12:32 +08:00
|
|
|
#define BFA_LOG(level, bfad, mask, fmt, arg...) \
|
|
|
|
do { \
|
|
|
|
if (((mask) == 4) || (level[1] <= '4')) \
|
|
|
|
dev_printk(level, &((bfad)->pcidev)->dev, fmt, ##arg); \
|
2010-09-16 02:50:55 +08:00
|
|
|
} while (0)
|
2009-09-24 08:46:15 +08:00
|
|
|
|
2010-09-16 02:50:55 +08:00
|
|
|
bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id,
|
|
|
|
struct bfa_lport_cfg_s *port_cfg,
|
|
|
|
struct device *dev);
|
|
|
|
bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id,
|
|
|
|
struct bfa_lport_cfg_s *port_cfg);
|
|
|
|
bfa_status_t bfad_cfg_pport(struct bfad_s *bfad, enum bfa_lport_role role);
|
|
|
|
bfa_status_t bfad_drv_init(struct bfad_s *bfad);
|
|
|
|
bfa_status_t bfad_start_ops(struct bfad_s *bfad);
|
|
|
|
void bfad_drv_start(struct bfad_s *bfad);
|
|
|
|
void bfad_uncfg_pport(struct bfad_s *bfad);
|
|
|
|
void bfad_stop(struct bfad_s *bfad);
|
|
|
|
void bfad_fcs_stop(struct bfad_s *bfad);
|
|
|
|
void bfad_remove_intr(struct bfad_s *bfad);
|
|
|
|
void bfad_hal_mem_release(struct bfad_s *bfad);
|
|
|
|
void bfad_hcb_comp(void *arg, bfa_status_t status);
|
|
|
|
|
|
|
|
int bfad_setup_intr(struct bfad_s *bfad);
|
|
|
|
void bfad_remove_intr(struct bfad_s *bfad);
|
2009-09-24 08:46:15 +08:00
|
|
|
void bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg);
|
|
|
|
bfa_status_t bfad_hal_mem_alloc(struct bfad_s *bfad);
|
treewide: setup_timer() -> timer_setup()
This converts all remaining cases of the old setup_timer() API into using
timer_setup(), where the callback argument is the structure already
holding the struct timer_list. These should have no behavioral changes,
since they just change which pointer is passed into the callback with
the same available pointers after conversion. It handles the following
examples, in addition to some other variations.
Casting from unsigned long:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
setup_timer(&ptr->my_timer, my_callback, ptr);
and forced object casts:
void my_callback(struct something *ptr)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, (unsigned long)ptr);
become:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
Direct function assignments:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
ptr->my_timer.function = my_callback;
have a temporary cast added, along with converting the args:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
ptr->my_timer.function = (TIMER_FUNC_TYPE)my_callback;
And finally, callbacks without a data assignment:
void my_callback(unsigned long data)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, 0);
have their argument renamed to verify they're unused during conversion:
void my_callback(struct timer_list *unused)
{
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
The conversion is done with the following Coccinelle script:
spatch --very-quiet --all-includes --include-headers \
-I ./arch/x86/include -I ./arch/x86/include/generated \
-I ./include -I ./arch/x86/include/uapi \
-I ./arch/x86/include/generated/uapi -I ./include/uapi \
-I ./include/generated/uapi --include ./include/linux/kconfig.h \
--dir . \
--cocci-file ~/src/data/timer_setup.cocci
@fix_address_of@
expression e;
@@
setup_timer(
-&(e)
+&e
, ...)
// Update any raw setup_timer() usages that have a NULL callback, but
// would otherwise match change_timer_function_usage, since the latter
// will update all function assignments done in the face of a NULL
// function initialization in setup_timer().
@change_timer_function_usage_NULL@
expression _E;
identifier _timer;
type _cast_data;
@@
(
-setup_timer(&_E->_timer, NULL, _E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E->_timer, NULL, (_cast_data)_E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, &_E);
+timer_setup(&_E._timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, (_cast_data)&_E);
+timer_setup(&_E._timer, NULL, 0);
)
@change_timer_function_usage@
expression _E;
identifier _timer;
struct timer_list _stl;
identifier _callback;
type _cast_func, _cast_data;
@@
(
-setup_timer(&_E->_timer, _callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
_E->_timer@_stl.function = _callback;
|
_E->_timer@_stl.function = &_callback;
|
_E->_timer@_stl.function = (_cast_func)_callback;
|
_E->_timer@_stl.function = (_cast_func)&_callback;
|
_E._timer@_stl.function = _callback;
|
_E._timer@_stl.function = &_callback;
|
_E._timer@_stl.function = (_cast_func)_callback;
|
_E._timer@_stl.function = (_cast_func)&_callback;
)
// callback(unsigned long arg)
@change_callback_handle_cast
depends on change_timer_function_usage@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
identifier _handle;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
(
... when != _origarg
_handletype *_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
)
}
// callback(unsigned long arg) without existing variable
@change_callback_handle_cast_no_arg
depends on change_timer_function_usage &&
!change_callback_handle_cast@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
+ _handletype *_origarg = from_timer(_origarg, t, _timer);
+
... when != _origarg
- (_handletype *)_origarg
+ _origarg
... when != _origarg
}
// Avoid already converted callbacks.
@match_callback_converted
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier t;
@@
void _callback(struct timer_list *t)
{ ... }
// callback(struct something *handle)
@change_callback_handle_arg
depends on change_timer_function_usage &&
!match_callback_converted &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
@@
void _callback(
-_handletype *_handle
+struct timer_list *t
)
{
+ _handletype *_handle = from_timer(_handle, t, _timer);
...
}
// If change_callback_handle_arg ran on an empty function, remove
// the added handler.
@unchange_callback_handle_arg
depends on change_timer_function_usage &&
change_callback_handle_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
identifier t;
@@
void _callback(struct timer_list *t)
{
- _handletype *_handle = from_timer(_handle, t, _timer);
}
// We only want to refactor the setup_timer() data argument if we've found
// the matching callback. This undoes changes in change_timer_function_usage.
@unchange_timer_function_usage
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg &&
!change_callback_handle_arg@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type change_timer_function_usage._cast_data;
@@
(
-timer_setup(&_E->_timer, _callback, 0);
+setup_timer(&_E->_timer, _callback, (_cast_data)_E);
|
-timer_setup(&_E._timer, _callback, 0);
+setup_timer(&_E._timer, _callback, (_cast_data)&_E);
)
// If we fixed a callback from a .function assignment, fix the
// assignment cast now.
@change_timer_function_assignment
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_func;
typedef TIMER_FUNC_TYPE;
@@
(
_E->_timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-&_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
)
// Sometimes timer functions are called directly. Replace matched args.
@change_timer_function_calls
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression _E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_data;
@@
_callback(
(
-(_cast_data)_E
+&_E->_timer
|
-(_cast_data)&_E
+&_E._timer
|
-_E
+&_E->_timer
)
)
// If a timer has been configured without a data argument, it can be
// converted without regard to the callback argument, since it is unused.
@match_timer_function_unused_data@
expression _E;
identifier _timer;
identifier _callback;
@@
(
-setup_timer(&_E->_timer, _callback, 0);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0L);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0UL);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0L);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0UL);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0L);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0UL);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0L);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0UL);
+timer_setup(_timer, _callback, 0);
)
@change_callback_unused_data
depends on match_timer_function_unused_data@
identifier match_timer_function_unused_data._callback;
type _origtype;
identifier _origarg;
@@
void _callback(
-_origtype _origarg
+struct timer_list *unused
)
{
... when != _origarg
}
Signed-off-by: Kees Cook <keescook@chromium.org>
2017-10-17 05:43:17 +08:00
|
|
|
void bfad_bfa_tmo(struct timer_list *t);
|
2009-09-24 08:46:15 +08:00
|
|
|
void bfad_init_timer(struct bfad_s *bfad);
|
|
|
|
int bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad);
|
|
|
|
void bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad);
|
|
|
|
void bfad_drv_uninit(struct bfad_s *bfad);
|
2010-07-09 11:02:55 +08:00
|
|
|
int bfad_worker(void *ptr);
|
|
|
|
void bfad_debugfs_init(struct bfad_port_s *port);
|
|
|
|
void bfad_debugfs_exit(struct bfad_port_s *port);
|
2010-03-04 09:44:02 +08:00
|
|
|
|
2009-09-24 08:46:15 +08:00
|
|
|
void bfad_pci_remove(struct pci_dev *pdev);
|
|
|
|
int bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid);
|
2010-12-10 11:12:32 +08:00
|
|
|
void bfad_rport_online_wait(struct bfad_s *bfad);
|
|
|
|
int bfad_get_linkup_delay(struct bfad_s *bfad);
|
2009-09-24 08:46:15 +08:00
|
|
|
int bfad_install_msix_handler(struct bfad_s *bfad);
|
|
|
|
|
|
|
|
extern struct idr bfad_im_port_index;
|
2010-09-16 02:50:55 +08:00
|
|
|
extern struct pci_device_id bfad_id_table[];
|
2009-09-24 08:46:15 +08:00
|
|
|
extern struct list_head bfad_list;
|
2010-09-16 02:50:55 +08:00
|
|
|
extern char *os_name;
|
|
|
|
extern char *os_patch;
|
|
|
|
extern char *host_name;
|
|
|
|
extern int num_rports;
|
|
|
|
extern int num_ios;
|
|
|
|
extern int num_tms;
|
|
|
|
extern int num_fcxps;
|
|
|
|
extern int num_ufbufs;
|
|
|
|
extern int reqq_size;
|
|
|
|
extern int rspq_size;
|
|
|
|
extern int num_sgpgs;
|
|
|
|
extern int rport_del_timeout;
|
|
|
|
extern int bfa_lun_queue_depth;
|
|
|
|
extern int bfa_io_max_sge;
|
2010-12-10 09:11:53 +08:00
|
|
|
extern int bfa_log_level;
|
2010-09-16 02:50:55 +08:00
|
|
|
extern int ioc_auto_recover;
|
|
|
|
extern int bfa_linkup_delay;
|
|
|
|
extern int msix_disable_cb;
|
|
|
|
extern int msix_disable_ct;
|
|
|
|
extern int fdmi_enable;
|
|
|
|
extern int supported_fc4s;
|
|
|
|
extern int pcie_max_read_reqsz;
|
2011-06-25 11:29:07 +08:00
|
|
|
extern int max_xfer_size;
|
2010-07-09 11:02:55 +08:00
|
|
|
extern int bfa_debugfs_enable;
|
2010-03-20 02:07:09 +08:00
|
|
|
extern struct mutex bfad_mutex;
|
2009-09-24 08:46:15 +08:00
|
|
|
|
|
|
|
#endif /* __BFAD_DRV_H__ */
|