Skip to content

Commit 7725ccf

Browse files
Jing HuangJames Bottomley
authored andcommitted
[SCSI] bfa: Brocade BFA FC SCSI driver
Add new driver for Brocade Hardware Signed-off-by: Jing Huang <huangj@brocade.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent 5415907 commit 7725ccf

File tree

198 files changed

+49189
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+49189
-0
lines changed

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,13 @@ L: netdev@vger.kernel.org
12111211
S: Supported
12121212
F: drivers/net/tg3.*
12131213

1214+
BROCADE BFA FC SCSI DRIVER
1215+
P: Jing Huang
1216+
M: huangj@brocade.com
1217+
L: linux-scsi@vger.kernel.org
1218+
S: Supported
1219+
F: drivers/scsi/bfa/
1220+
12141221
BSG (block layer generic sg v4 driver)
12151222
M: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
12161223
L: linux-scsi@vger.kernel.org

drivers/scsi/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,16 @@ config SCSI_SRP
18271827
To compile this driver as a module, choose M here: the
18281828
module will be called libsrp.
18291829

1830+
config SCSI_BFA_FC
1831+
tristate "Brocade BFA Fibre Channel Support"
1832+
depends on PCI && SCSI
1833+
select SCSI_FC_ATTRS
1834+
help
1835+
This bfa driver supports all Brocade PCIe FC/FCOE host adapters.
1836+
1837+
To compile this driver as a module, choose M here. The module will
1838+
be called bfa.
1839+
18301840
endif # SCSI_LOWLEVEL
18311841

18321842
source "drivers/scsi/pcmcia/Kconfig"

drivers/scsi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o
8686
obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx/
8787
obj-$(CONFIG_SCSI_QLA_ISCSI) += qla4xxx/
8888
obj-$(CONFIG_SCSI_LPFC) += lpfc/
89+
obj-$(CONFIG_SCSI_BFA_FC) += bfa/
8990
obj-$(CONFIG_SCSI_PAS16) += pas16.o
9091
obj-$(CONFIG_SCSI_T128) += t128.o
9192
obj-$(CONFIG_SCSI_DMX3191D) += dmx3191d.o

drivers/scsi/bfa/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
obj-$(CONFIG_SCSI_BFA_FC) := bfa.o
2+
3+
bfa-y := bfad.o bfad_intr.o bfad_os.o bfad_im.o bfad_attr.o bfad_fwimg.o
4+
5+
bfa-y += bfa_core.o bfa_ioc.o bfa_iocfc.o bfa_fcxp.o bfa_lps.o
6+
bfa-y += bfa_hw_cb.o bfa_hw_ct.o bfa_intr.o bfa_timer.o bfa_rport.o
7+
bfa-y += bfa_fcport.o bfa_port.o bfa_uf.o bfa_sgpg.o bfa_module.o bfa_ioim.o
8+
bfa-y += bfa_itnim.o bfa_fcpim.o bfa_tskim.o bfa_log.o bfa_log_module.o
9+
bfa-y += bfa_csdebug.o bfa_sm.o plog.o
10+
11+
bfa-y += fcbuild.o fabric.o fcpim.o vfapi.o fcptm.o bfa_fcs.o bfa_fcs_port.o
12+
bfa-y += bfa_fcs_uf.o bfa_fcs_lport.o fab.o fdmi.o ms.o ns.o scn.o loop.o
13+
bfa-y += lport_api.o n2n.o rport.o rport_api.o rport_ftrs.o vport.o
14+
15+
ccflags-y := -I$(obj) -I$(obj)/include -I$(obj)/include/cna
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2005-2009 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 __BFA_CALLBACK_PRIV_H__
19+
#define __BFA_CALLBACK_PRIV_H__
20+
21+
#include <cs/bfa_q.h>
22+
23+
typedef void (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete);
24+
25+
/**
26+
* Generic BFA callback element.
27+
*/
28+
struct bfa_cb_qe_s {
29+
struct list_head qe;
30+
bfa_cb_cbfn_t cbfn;
31+
bfa_boolean_t once;
32+
u32 rsvd;
33+
void *cbarg;
34+
};
35+
36+
#define bfa_cb_queue(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
37+
(__hcb_qe)->cbfn = (__cbfn); \
38+
(__hcb_qe)->cbarg = (__cbarg); \
39+
list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q); \
40+
} while (0)
41+
42+
#define bfa_cb_dequeue(__hcb_qe) list_del(&(__hcb_qe)->qe)
43+
44+
#define bfa_cb_queue_once(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
45+
(__hcb_qe)->cbfn = (__cbfn); \
46+
(__hcb_qe)->cbarg = (__cbarg); \
47+
if (!(__hcb_qe)->once) { \
48+
list_add_tail((__hcb_qe), &(__bfa)->comp_q); \
49+
(__hcb_qe)->once = BFA_TRUE; \
50+
} \
51+
} while (0)
52+
53+
#define bfa_cb_queue_done(__hcb_qe) do { \
54+
(__hcb_qe)->once = BFA_FALSE; \
55+
} while (0)
56+
57+
#endif /* __BFA_CALLBACK_PRIV_H__ */
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
/*
2+
* Copyright (c) 2005-2009 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+
/**
19+
* bfa_cb_ioim_macros.h BFA IOIM driver interface macros.
20+
*/
21+
22+
#ifndef __BFA_HCB_IOIM_MACROS_H__
23+
#define __BFA_HCB_IOIM_MACROS_H__
24+
25+
#include <bfa_os_inc.h>
26+
/*
27+
* #include <linux/dma-mapping.h>
28+
*
29+
* #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> #include
30+
* <scsi/scsi_device.h> #include <scsi/scsi_host.h>
31+
*/
32+
#include "bfad_im_compat.h"
33+
34+
/*
35+
* task attribute values in FCP-2 FCP_CMND IU
36+
*/
37+
#define SIMPLE_Q 0
38+
#define HEAD_OF_Q 1
39+
#define ORDERED_Q 2
40+
#define ACA_Q 4
41+
#define UNTAGGED 5
42+
43+
static inline lun_t
44+
bfad_int_to_lun(u32 luno)
45+
{
46+
union {
47+
u16 scsi_lun[4];
48+
lun_t bfa_lun;
49+
} lun;
50+
51+
lun.bfa_lun = 0;
52+
lun.scsi_lun[0] = bfa_os_htons(luno);
53+
54+
return (lun.bfa_lun);
55+
}
56+
57+
/**
58+
* Get LUN for the I/O request
59+
*/
60+
#define bfa_cb_ioim_get_lun(__dio) \
61+
bfad_int_to_lun(((struct scsi_cmnd *)__dio)->device->lun)
62+
63+
/**
64+
* Get CDB for the I/O request
65+
*/
66+
static inline u8 *
67+
bfa_cb_ioim_get_cdb(struct bfad_ioim_s *dio)
68+
{
69+
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
70+
71+
return ((u8 *) cmnd->cmnd);
72+
}
73+
74+
/**
75+
* Get I/O direction (read/write) for the I/O request
76+
*/
77+
static inline enum fcp_iodir
78+
bfa_cb_ioim_get_iodir(struct bfad_ioim_s *dio)
79+
{
80+
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
81+
enum dma_data_direction dmadir;
82+
83+
dmadir = cmnd->sc_data_direction;
84+
if (dmadir == DMA_TO_DEVICE)
85+
return FCP_IODIR_WRITE;
86+
else if (dmadir == DMA_FROM_DEVICE)
87+
return FCP_IODIR_READ;
88+
else
89+
return FCP_IODIR_NONE;
90+
}
91+
92+
/**
93+
* Get IO size in bytes for the I/O request
94+
*/
95+
static inline u32
96+
bfa_cb_ioim_get_size(struct bfad_ioim_s *dio)
97+
{
98+
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
99+
100+
return (scsi_bufflen(cmnd));
101+
}
102+
103+
/**
104+
* Get timeout for the I/O request
105+
*/
106+
static inline u8
107+
bfa_cb_ioim_get_timeout(struct bfad_ioim_s *dio)
108+
{
109+
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
110+
/*
111+
* TBD: need a timeout for scsi passthru
112+
*/
113+
if (cmnd->device->host == NULL)
114+
return 4;
115+
116+
return 0;
117+
}
118+
119+
/**
120+
* Get SG element for the I/O request given the SG element index
121+
*/
122+
static inline union bfi_addr_u
123+
bfa_cb_ioim_get_sgaddr(struct bfad_ioim_s *dio, int sgeid)
124+
{
125+
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
126+
struct scatterlist *sge;
127+
u64 addr;
128+
129+
sge = (struct scatterlist *)scsi_sglist(cmnd) + sgeid;
130+
addr = (u64) sg_dma_address(sge);
131+
132+
return (*(union bfi_addr_u *) &addr);
133+
}
134+
135+
static inline u32
136+
bfa_cb_ioim_get_sglen(struct bfad_ioim_s *dio, int sgeid)
137+
{
138+
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
139+
struct scatterlist *sge;
140+
u32 len;
141+
142+
sge = (struct scatterlist *)scsi_sglist(cmnd) + sgeid;
143+
len = sg_dma_len(sge);
144+
145+
return len;
146+
}
147+
148+
/**
149+
* Get Command Reference Number for the I/O request. 0 if none.
150+
*/
151+
static inline u8
152+
bfa_cb_ioim_get_crn(struct bfad_ioim_s *dio)
153+
{
154+
return 0;
155+
}
156+
157+
/**
158+
* Get SAM-3 priority for the I/O request. 0 is default.
159+
*/
160+
static inline u8
161+
bfa_cb_ioim_get_priority(struct bfad_ioim_s *dio)
162+
{
163+
return 0;
164+
}
165+
166+
/**
167+
* Get task attributes for the I/O request. Default is FCP_TASK_ATTR_SIMPLE(0).
168+
*/
169+
static inline u8
170+
bfa_cb_ioim_get_taskattr(struct bfad_ioim_s *dio)
171+
{
172+
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
173+
u8 task_attr = UNTAGGED;
174+
175+
if (cmnd->device->tagged_supported) {
176+
switch (cmnd->tag) {
177+
case HEAD_OF_QUEUE_TAG:
178+
task_attr = HEAD_OF_Q;
179+
break;
180+
case ORDERED_QUEUE_TAG:
181+
task_attr = ORDERED_Q;
182+
break;
183+
default:
184+
task_attr = SIMPLE_Q;
185+
break;
186+
}
187+
}
188+
189+
return task_attr;
190+
}
191+
192+
/**
193+
* Get CDB length in bytes for the I/O request. Default is FCP_CMND_CDB_LEN(16).
194+
*/
195+
static inline u8
196+
bfa_cb_ioim_get_cdblen(struct bfad_ioim_s *dio)
197+
{
198+
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
199+
200+
return (cmnd->cmd_len);
201+
}
202+
203+
204+
205+
#endif /* __BFA_HCB_IOIM_MACROS_H__ */

0 commit comments

Comments
 (0)