Blame view

drivers/scsi/bfa/bfad_im.h 5.07 KB
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
1
  /*
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
2
   * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
   * All rights reserved
   * www.brocade.com
   *
   * Linux driver for Brocade Fibre Channel Host Bus Adapter.
   *
   * 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.
   */
  
  #ifndef __BFAD_IM_H__
  #define __BFAD_IM_H__
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
20
  #include "bfa_fcs.h"
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
21
22
  
  #define FCPI_NAME " fcpim"
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
23
24
25
  #ifndef KOBJ_NAME_LEN
  #define KOBJ_NAME_LEN           20
  #endif
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
26
27
28
29
  bfa_status_t bfad_im_module_init(void);
  void bfad_im_module_exit(void);
  bfa_status_t bfad_im_probe(struct bfad_s *bfad);
  void bfad_im_probe_undo(struct bfad_s *bfad);
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
30
31
  bfa_status_t bfad_im_port_new(struct bfad_s *bfad, struct bfad_port_s *port);
  void bfad_im_port_delete(struct bfad_s *bfad, struct bfad_port_s *port);
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
32
33
  void bfad_im_port_clean(struct bfad_im_port_s *im_port);
  int  bfad_im_scsi_host_alloc(struct bfad_s *bfad,
b504293fe   Jing Huang   [SCSI] bfa: add f...
34
  		struct bfad_im_port_s *im_port, struct device *dev);
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
35
36
37
38
39
40
41
42
43
  void bfad_im_scsi_host_free(struct bfad_s *bfad,
  				struct bfad_im_port_s *im_port);
  
  #define MAX_FCP_TARGET 1024
  #define MAX_FCP_LUN 16384
  #define BFAD_TARGET_RESET_TMO 60
  #define BFAD_LUN_RESET_TMO 60
  #define ScsiResult(host_code, scsi_code) (((host_code) << 16) | scsi_code)
  #define BFA_QUEUE_FULL_RAMP_UP_TIME 120
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
44
45
46
47
  
  /*
   * itnim flags
   */
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
48
49
50
51
52
53
54
55
56
57
58
59
  #define IO_DONE_BIT			0
  
  struct bfad_itnim_data_s {
  	struct bfad_itnim_s *itnim;
  };
  
  struct bfad_im_port_s {
  	struct bfad_s         *bfad;
  	struct bfad_port_s    *port;
  	struct work_struct port_delete_work;
  	int             idr_id;
  	u16        cur_scsi_id;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
60
  	u16	flags;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
61
62
63
  	struct list_head binding_list;
  	struct Scsi_Host *shost;
  	struct list_head itnim_mapped_list;
b504293fe   Jing Huang   [SCSI] bfa: add f...
64
  	struct fc_vport *fc_vport;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
  };
  
  enum bfad_itnim_state {
  	ITNIM_STATE_NONE,
  	ITNIM_STATE_ONLINE,
  	ITNIM_STATE_OFFLINE_PENDING,
  	ITNIM_STATE_OFFLINE,
  	ITNIM_STATE_TIMEOUT,
  	ITNIM_STATE_FREE,
  };
  
  /*
   * Per itnim data structure
   */
  struct bfad_itnim_s {
  	struct list_head list_entry;
  	struct bfa_fcs_itnim_s fcs_itnim;
  	struct work_struct itnim_work;
  	u32        flags;
  	enum bfad_itnim_state state;
  	struct bfad_im_s *im;
  	struct bfad_im_port_s *im_port;
  	struct bfad_rport_s *drv_rport;
  	struct fc_rport *fc_rport;
  	struct bfa_itnim_s *bfa_itnim;
  	u16        scsi_tgt_id;
  	u16        queue_work;
  	unsigned long	last_ramp_up_time;
  	unsigned long	last_queue_full_time;
  };
  
  enum bfad_binding_type {
  	FCP_PWWN_BINDING = 0x1,
  	FCP_NWWN_BINDING = 0x2,
  	FCP_FCID_BINDING = 0x3,
  };
  
  struct bfad_fcp_binding {
  	struct list_head list_entry;
  	enum bfad_binding_type binding_type;
  	u16        scsi_target_id;
  	u32        fc_id;
  	wwn_t           nwwn;
  	wwn_t           pwwn;
  };
  
  struct bfad_im_s {
  	struct bfad_s         *bfad;
  	struct workqueue_struct *drv_workq;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
114
  	char            drv_workq_name[KOBJ_NAME_LEN];
7826f304b   Krishna Gudipati   [SCSI] bfa: Add F...
115
  	struct work_struct	aen_im_notify_work;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
116
  };
7826f304b   Krishna Gudipati   [SCSI] bfa: Add F...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
  #define bfad_get_aen_entry(_drv, _entry) do {				\
  	unsigned long	_flags;						\
  	spin_lock_irqsave(&(_drv)->bfad_aen_spinlock, _flags);		\
  	bfa_q_deq(&(_drv)->free_aen_q, &(_entry));			\
  	if (_entry)							\
  		list_add_tail(&(_entry)->qe, &(_drv)->active_aen_q);	\
  	spin_unlock_irqrestore(&(_drv)->bfad_aen_spinlock, _flags);	\
  } while (0)
  
  /* post fc_host vendor event */
  #define bfad_im_post_vendor_event(_entry, _drv, _cnt, _cat, _evt) do {	      \
  	do_gettimeofday(&(_entry)->aen_tv);				      \
  	(_entry)->bfad_num = (_drv)->inst_no;				      \
  	(_entry)->seq_num = (_cnt);					      \
  	(_entry)->aen_category = (_cat);				      \
  	(_entry)->aen_type = (_evt);					      \
  	if ((_drv)->bfad_flags & BFAD_FC4_PROBE_DONE)			      \
  		queue_work((_drv)->im->drv_workq,			      \
  			   &(_drv)->im->aen_im_notify_work);		      \
  } while (0)
f16a17507   Maggie Zhang   [SCSI] bfa: remov...
137
  struct Scsi_Host *bfad_scsi_host_alloc(struct bfad_im_port_s *im_port,
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
138
  				struct bfad_s *);
f16a17507   Maggie Zhang   [SCSI] bfa: remov...
139
140
141
142
  bfa_status_t bfad_thread_workq(struct bfad_s *bfad);
  void bfad_destroy_workq(struct bfad_im_s *im);
  void bfad_fc_host_init(struct bfad_im_port_s *im_port);
  void bfad_scsi_host_free(struct bfad_s *bfad,
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
143
  				 struct bfad_im_port_s *im_port);
f16a17507   Maggie Zhang   [SCSI] bfa: remov...
144
  void bfad_ramp_up_qdepth(struct bfad_itnim_s *itnim,
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
145
  				 struct scsi_device *sdev);
f16a17507   Maggie Zhang   [SCSI] bfa: remov...
146
147
  void bfad_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev);
  struct bfad_itnim_s *bfad_get_itnim(struct bfad_im_port_s *im_port, int id);
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
148
149
150
151
  
  extern struct scsi_host_template bfad_im_scsi_host_template;
  extern struct scsi_host_template bfad_im_vport_template;
  extern struct fc_function_template bfad_im_fc_function_template;
b504293fe   Jing Huang   [SCSI] bfa: add f...
152
  extern struct fc_function_template bfad_im_vport_fc_function_template;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
153
  extern struct scsi_transport_template *bfad_im_scsi_transport_template;
b504293fe   Jing Huang   [SCSI] bfa: add f...
154
  extern struct scsi_transport_template *bfad_im_scsi_vport_transport_template;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
155

a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
156
157
158
159
  extern struct device_attribute *bfad_im_host_attrs[];
  extern struct device_attribute *bfad_im_vport_attrs[];
  
  irqreturn_t bfad_intx(int irq, void *dev_id);
b85daafe4   Krishna Gudipati   [SCSI] bfa: Add B...
160
161
  int bfad_im_bsg_request(struct fc_bsg_job *job);
  int bfad_im_bsg_timeout(struct fc_bsg_job *job);
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
162
  #endif