Linux Audio

Check our new training course

Loading...
v6.8
  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 reserved
  6 * www.qlogic.com
  7 *
  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_LEN
 19#define KOBJ_NAME_LEN           20
 20#endif
 21
 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 1024
 36#define MAX_FCP_LUN 16384
 37#define BFAD_TARGET_RESET_TMO 60
 38#define BFAD_LUN_RESET_TMO 60
 
 39#define BFA_QUEUE_FULL_RAMP_UP_TIME 120
 40
 41/*
 42 * itnim flags
 43 */
 44#define IO_DONE_BIT			0
 45
 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 of
 49 * 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 structure
100 */
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	char            drv_workq_name[KOBJ_NAME_LEN];
138	struct work_struct	aen_im_notify_work;
139};
140
141#define bfad_get_aen_entry(_drv, _entry) do {				\
142	unsigned long	_flags;						\
143	spin_lock_irqsave(&(_drv)->bfad_aen_spinlock, _flags);		\
144	bfa_q_deq(&(_drv)->free_aen_q, &(_entry));			\
145	if (_entry)							\
146		list_add_tail(&(_entry)->qe, &(_drv)->active_aen_q);	\
147	spin_unlock_irqrestore(&(_drv)->bfad_aen_spinlock, _flags);	\
148} while (0)
149
150/* post fc_host vendor event */
151static inline void bfad_im_post_vendor_event(struct bfa_aen_entry_s *entry,
152					     struct bfad_s *drv, int cnt,
153					     enum bfa_aen_category cat,
154					     int evt)
155{
156	struct timespec64 ts;
157
158	ktime_get_real_ts64(&ts);
159	/*
160	 * 'unsigned long aen_tv_sec' overflows in y2106 on 32-bit
161	 * architectures, or in 2038 if user space interprets it
162	 * as 'signed'.
163	 */
164	entry->aen_tv_sec = ts.tv_sec;
165	entry->aen_tv_usec = ts.tv_nsec / NSEC_PER_USEC;
166	entry->bfad_num = drv->inst_no;
167	entry->seq_num = cnt;
168	entry->aen_category = cat;
169	entry->aen_type = evt;
170	if (drv->bfad_flags & BFAD_FC4_PROBE_DONE)
171		queue_work(drv->im->drv_workq, &drv->im->aen_im_notify_work);
172}
173
174struct Scsi_Host *bfad_scsi_host_alloc(struct bfad_im_port_s *im_port,
175				struct bfad_s *);
176bfa_status_t bfad_thread_workq(struct bfad_s *bfad);
177void bfad_destroy_workq(struct bfad_im_s *im);
178void bfad_fc_host_init(struct bfad_im_port_s *im_port);
179void bfad_scsi_host_free(struct bfad_s *bfad,
180				 struct bfad_im_port_s *im_port);
181void bfad_ramp_up_qdepth(struct bfad_itnim_s *itnim,
182				 struct scsi_device *sdev);
183void bfad_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev);
184struct bfad_itnim_s *bfad_get_itnim(struct bfad_im_port_s *im_port, int id);
185
186extern struct scsi_host_template bfad_im_scsi_host_template;
187extern struct scsi_host_template bfad_im_vport_template;
188extern struct fc_function_template bfad_im_fc_function_template;
189extern struct fc_function_template bfad_im_vport_fc_function_template;
190extern struct scsi_transport_template *bfad_im_scsi_transport_template;
191extern struct scsi_transport_template *bfad_im_scsi_vport_transport_template;
192
193extern const struct attribute_group *bfad_im_host_groups[];
194extern const struct attribute_group *bfad_im_vport_groups[];
195
196irqreturn_t bfad_intx(int irq, void *dev_id);
197
198int bfad_im_bsg_request(struct bsg_job *job);
199int bfad_im_bsg_timeout(struct bsg_job *job);
200
201#endif
v3.1
 
  1/*
  2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
 
  3 * All rights reserved
  4 * www.brocade.com
  5 *
  6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7 *
  8 * This program is free software; you can redistribute it and/or modify it
  9 * under the terms of the GNU General Public License (GPL) Version 2 as
 10 * published by the Free Software Foundation
 11 *
 12 * This program is distributed in the hope that it will be useful, but
 13 * WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15 * General Public License for more details.
 16 */
 17
 18#ifndef __BFAD_IM_H__
 19#define __BFAD_IM_H__
 20
 21#include "bfa_fcs.h"
 22
 23#define FCPI_NAME " fcpim"
 24
 25#ifndef KOBJ_NAME_LEN
 26#define KOBJ_NAME_LEN           20
 27#endif
 28
 29bfa_status_t bfad_im_module_init(void);
 30void bfad_im_module_exit(void);
 31bfa_status_t bfad_im_probe(struct bfad_s *bfad);
 32void bfad_im_probe_undo(struct bfad_s *bfad);
 33bfa_status_t bfad_im_port_new(struct bfad_s *bfad, struct bfad_port_s *port);
 34void bfad_im_port_delete(struct bfad_s *bfad, struct bfad_port_s *port);
 35void bfad_im_port_clean(struct bfad_im_port_s *im_port);
 36int  bfad_im_scsi_host_alloc(struct bfad_s *bfad,
 37		struct bfad_im_port_s *im_port, struct device *dev);
 38void bfad_im_scsi_host_free(struct bfad_s *bfad,
 39				struct bfad_im_port_s *im_port);
 
 40
 41#define MAX_FCP_TARGET 1024
 42#define MAX_FCP_LUN 16384
 43#define BFAD_TARGET_RESET_TMO 60
 44#define BFAD_LUN_RESET_TMO 60
 45#define ScsiResult(host_code, scsi_code) (((host_code) << 16) | scsi_code)
 46#define BFA_QUEUE_FULL_RAMP_UP_TIME 120
 47
 48/*
 49 * itnim flags
 50 */
 51#define IO_DONE_BIT			0
 52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 53struct bfad_itnim_data_s {
 54	struct bfad_itnim_s *itnim;
 55};
 56
 57struct bfad_im_port_s {
 58	struct bfad_s         *bfad;
 59	struct bfad_port_s    *port;
 60	struct work_struct port_delete_work;
 61	int             idr_id;
 62	u16        cur_scsi_id;
 63	u16	flags;
 64	struct list_head binding_list;
 65	struct Scsi_Host *shost;
 66	struct list_head itnim_mapped_list;
 67	struct fc_vport *fc_vport;
 68};
 69
 
 
 
 
 
 
 
 
 
 
 70enum bfad_itnim_state {
 71	ITNIM_STATE_NONE,
 72	ITNIM_STATE_ONLINE,
 73	ITNIM_STATE_OFFLINE_PENDING,
 74	ITNIM_STATE_OFFLINE,
 75	ITNIM_STATE_TIMEOUT,
 76	ITNIM_STATE_FREE,
 77};
 78
 79/*
 80 * Per itnim data structure
 81 */
 82struct bfad_itnim_s {
 83	struct list_head list_entry;
 84	struct bfa_fcs_itnim_s fcs_itnim;
 85	struct work_struct itnim_work;
 86	u32        flags;
 87	enum bfad_itnim_state state;
 88	struct bfad_im_s *im;
 89	struct bfad_im_port_s *im_port;
 90	struct bfad_rport_s *drv_rport;
 91	struct fc_rport *fc_rport;
 92	struct bfa_itnim_s *bfa_itnim;
 93	u16        scsi_tgt_id;
 
 94	u16        queue_work;
 95	unsigned long	last_ramp_up_time;
 96	unsigned long	last_queue_full_time;
 97};
 98
 99enum bfad_binding_type {
100	FCP_PWWN_BINDING = 0x1,
101	FCP_NWWN_BINDING = 0x2,
102	FCP_FCID_BINDING = 0x3,
103};
104
105struct bfad_fcp_binding {
106	struct list_head list_entry;
107	enum bfad_binding_type binding_type;
108	u16        scsi_target_id;
109	u32        fc_id;
110	wwn_t           nwwn;
111	wwn_t           pwwn;
112};
113
114struct bfad_im_s {
115	struct bfad_s         *bfad;
116	struct workqueue_struct *drv_workq;
117	char            drv_workq_name[KOBJ_NAME_LEN];
118	struct work_struct	aen_im_notify_work;
119};
120
121#define bfad_get_aen_entry(_drv, _entry) do {				\
122	unsigned long	_flags;						\
123	spin_lock_irqsave(&(_drv)->bfad_aen_spinlock, _flags);		\
124	bfa_q_deq(&(_drv)->free_aen_q, &(_entry));			\
125	if (_entry)							\
126		list_add_tail(&(_entry)->qe, &(_drv)->active_aen_q);	\
127	spin_unlock_irqrestore(&(_drv)->bfad_aen_spinlock, _flags);	\
128} while (0)
129
130/* post fc_host vendor event */
131#define bfad_im_post_vendor_event(_entry, _drv, _cnt, _cat, _evt) do {	      \
132	do_gettimeofday(&(_entry)->aen_tv);				      \
133	(_entry)->bfad_num = (_drv)->inst_no;				      \
134	(_entry)->seq_num = (_cnt);					      \
135	(_entry)->aen_category = (_cat);				      \
136	(_entry)->aen_type = (_evt);					      \
137	if ((_drv)->bfad_flags & BFAD_FC4_PROBE_DONE)			      \
138		queue_work((_drv)->im->drv_workq,			      \
139			   &(_drv)->im->aen_im_notify_work);		      \
140} while (0)
 
 
 
 
 
 
 
 
 
 
 
 
141
142struct Scsi_Host *bfad_scsi_host_alloc(struct bfad_im_port_s *im_port,
143				struct bfad_s *);
144bfa_status_t bfad_thread_workq(struct bfad_s *bfad);
145void bfad_destroy_workq(struct bfad_im_s *im);
146void bfad_fc_host_init(struct bfad_im_port_s *im_port);
147void bfad_scsi_host_free(struct bfad_s *bfad,
148				 struct bfad_im_port_s *im_port);
149void bfad_ramp_up_qdepth(struct bfad_itnim_s *itnim,
150				 struct scsi_device *sdev);
151void bfad_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev);
152struct bfad_itnim_s *bfad_get_itnim(struct bfad_im_port_s *im_port, int id);
153
154extern struct scsi_host_template bfad_im_scsi_host_template;
155extern struct scsi_host_template bfad_im_vport_template;
156extern struct fc_function_template bfad_im_fc_function_template;
157extern struct fc_function_template bfad_im_vport_fc_function_template;
158extern struct scsi_transport_template *bfad_im_scsi_transport_template;
159extern struct scsi_transport_template *bfad_im_scsi_vport_transport_template;
160
161extern struct device_attribute *bfad_im_host_attrs[];
162extern struct device_attribute *bfad_im_vport_attrs[];
163
164irqreturn_t bfad_intx(int irq, void *dev_id);
165
166int bfad_im_bsg_request(struct fc_bsg_job *job);
167int bfad_im_bsg_timeout(struct fc_bsg_job *job);
168
169#endif