brintos

brintos / linux-shallow public Read only

0
0
Text · 5.5 KiB · 0884af0 Raw
201 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.4 * Copyright (c) 2014- QLogic Corporation.5 * All rights reserved6 * www.qlogic.com7 *8 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.9 */10 11#ifndef __BFAD_IM_H__12#define __BFAD_IM_H__13 14#include "bfa_fcs.h"15 16#define FCPI_NAME " fcpim"17 18#ifndef KOBJ_NAME_LEN19#define KOBJ_NAME_LEN           2020#endif21 22bfa_status_t bfad_im_module_init(void);23void bfad_im_module_exit(void);24bfa_status_t bfad_im_probe(struct bfad_s *bfad);25void bfad_im_probe_undo(struct bfad_s *bfad);26bfa_status_t bfad_im_port_new(struct bfad_s *bfad, struct bfad_port_s *port);27void bfad_im_port_delete(struct bfad_s *bfad, struct bfad_port_s *port);28void bfad_im_port_clean(struct bfad_im_port_s *im_port);29int  bfad_im_scsi_host_alloc(struct bfad_s *bfad,30		struct bfad_im_port_s *im_port, struct device *dev);31void bfad_im_scsi_host_free(struct bfad_s *bfad,32				struct bfad_im_port_s *im_port);33u32 bfad_im_supported_speeds(struct bfa_s *bfa);34 35#define MAX_FCP_TARGET 102436#define MAX_FCP_LUN 1638437#define BFAD_TARGET_RESET_TMO 6038#define BFAD_LUN_RESET_TMO 6039#define BFA_QUEUE_FULL_RAMP_UP_TIME 12040 41/*42 * itnim flags43 */44#define IO_DONE_BIT			045 46/**47 * struct bfad_cmd_priv - private data per SCSI command.48 * @status: Lowest bit represents IO_DONE. The next seven bits hold a value of49 * type enum bfi_tskim_status.50 * @wq: Wait queue used to wait for completion of an operation.51 */52struct bfad_cmd_priv {53	unsigned long status;54	wait_queue_head_t *wq;55};56 57static inline struct bfad_cmd_priv *bfad_priv(struct scsi_cmnd *cmd)58{59	return scsi_cmd_priv(cmd);60}61 62struct bfad_itnim_data_s {63	struct bfad_itnim_s *itnim;64};65 66struct bfad_im_port_s {67	struct bfad_s         *bfad;68	struct bfad_port_s    *port;69	struct work_struct port_delete_work;70	int             idr_id;71	u16        cur_scsi_id;72	u16	flags;73	struct list_head binding_list;74	struct Scsi_Host *shost;75	struct list_head itnim_mapped_list;76	struct fc_vport *fc_vport;77};78 79struct bfad_im_port_pointer {80	struct bfad_im_port_s *p;81};82 83static inline struct bfad_im_port_s *bfad_get_im_port(struct Scsi_Host *host)84{85	struct bfad_im_port_pointer *im_portp = shost_priv(host);86	return im_portp->p;87}88 89enum bfad_itnim_state {90	ITNIM_STATE_NONE,91	ITNIM_STATE_ONLINE,92	ITNIM_STATE_OFFLINE_PENDING,93	ITNIM_STATE_OFFLINE,94	ITNIM_STATE_TIMEOUT,95	ITNIM_STATE_FREE,96};97 98/*99 * Per itnim data structure100 */101struct bfad_itnim_s {102	struct list_head list_entry;103	struct bfa_fcs_itnim_s fcs_itnim;104	struct work_struct itnim_work;105	u32        flags;106	enum bfad_itnim_state state;107	struct bfad_im_s *im;108	struct bfad_im_port_s *im_port;109	struct bfad_rport_s *drv_rport;110	struct fc_rport *fc_rport;111	struct bfa_itnim_s *bfa_itnim;112	u16        scsi_tgt_id;113	u16	   channel;114	u16        queue_work;115	unsigned long	last_ramp_up_time;116	unsigned long	last_queue_full_time;117};118 119enum bfad_binding_type {120	FCP_PWWN_BINDING = 0x1,121	FCP_NWWN_BINDING = 0x2,122	FCP_FCID_BINDING = 0x3,123};124 125struct bfad_fcp_binding {126	struct list_head list_entry;127	enum bfad_binding_type binding_type;128	u16        scsi_target_id;129	u32        fc_id;130	wwn_t           nwwn;131	wwn_t           pwwn;132};133 134struct bfad_im_s {135	struct bfad_s         *bfad;136	struct workqueue_struct *drv_workq;137	struct work_struct	aen_im_notify_work;138};139 140#define bfad_get_aen_entry(_drv, _entry) do {				\141	unsigned long	_flags;						\142	spin_lock_irqsave(&(_drv)->bfad_aen_spinlock, _flags);		\143	bfa_q_deq(&(_drv)->free_aen_q, &(_entry));			\144	if (_entry)							\145		list_add_tail(&(_entry)->qe, &(_drv)->active_aen_q);	\146	spin_unlock_irqrestore(&(_drv)->bfad_aen_spinlock, _flags);	\147} while (0)148 149/* post fc_host vendor event */150static inline void bfad_im_post_vendor_event(struct bfa_aen_entry_s *entry,151					     struct bfad_s *drv, int cnt,152					     enum bfa_aen_category cat,153					     int evt)154{155	struct timespec64 ts;156 157	ktime_get_real_ts64(&ts);158	/*159	 * 'unsigned long aen_tv_sec' overflows in y2106 on 32-bit160	 * architectures, or in 2038 if user space interprets it161	 * as 'signed'.162	 */163	entry->aen_tv_sec = ts.tv_sec;164	entry->aen_tv_usec = ts.tv_nsec / NSEC_PER_USEC;165	entry->bfad_num = drv->inst_no;166	entry->seq_num = cnt;167	entry->aen_category = cat;168	entry->aen_type = evt;169	if (drv->bfad_flags & BFAD_FC4_PROBE_DONE)170		queue_work(drv->im->drv_workq, &drv->im->aen_im_notify_work);171}172 173struct Scsi_Host *bfad_scsi_host_alloc(struct bfad_im_port_s *im_port,174				struct bfad_s *);175bfa_status_t bfad_thread_workq(struct bfad_s *bfad);176void bfad_destroy_workq(struct bfad_im_s *im);177void bfad_fc_host_init(struct bfad_im_port_s *im_port);178void bfad_scsi_host_free(struct bfad_s *bfad,179				 struct bfad_im_port_s *im_port);180void bfad_ramp_up_qdepth(struct bfad_itnim_s *itnim,181				 struct scsi_device *sdev);182void bfad_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev);183struct bfad_itnim_s *bfad_get_itnim(struct bfad_im_port_s *im_port, int id);184 185extern struct scsi_host_template bfad_im_scsi_host_template;186extern struct scsi_host_template bfad_im_vport_template;187extern struct fc_function_template bfad_im_fc_function_template;188extern struct fc_function_template bfad_im_vport_fc_function_template;189extern struct scsi_transport_template *bfad_im_scsi_transport_template;190extern struct scsi_transport_template *bfad_im_scsi_vport_transport_template;191 192extern const struct attribute_group *bfad_im_host_groups[];193extern const struct attribute_group *bfad_im_vport_groups[];194 195irqreturn_t bfad_intx(int irq, void *dev_id);196 197int bfad_im_bsg_request(struct bsg_job *job);198int bfad_im_bsg_timeout(struct bsg_job *job);199 200#endif201