2
* Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
6
* Linux driver for Brocade Fibre Channel Host Bus Adapter.
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
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.
19
* bfa_cb_ioim_macros.h BFA IOIM driver interface macros.
22
#ifndef __BFA_HCB_IOIM_MACROS_H__
23
#define __BFA_HCB_IOIM_MACROS_H__
25
#include <bfa_os_inc.h>
27
* #include <linux/dma-mapping.h>
29
* #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> #include
30
* <scsi/scsi_device.h> #include <scsi/scsi_host.h>
32
#include "bfad_im_compat.h"
35
* task attribute values in FCP-2 FCP_CMND IU
44
bfad_int_to_lun(u32 luno)
52
lun.scsi_lun[0] = bfa_os_htons(luno);
58
* Get LUN for the I/O request
60
#define bfa_cb_ioim_get_lun(__dio) \
61
bfad_int_to_lun(((struct scsi_cmnd *)__dio)->device->lun)
64
* Get CDB for the I/O request
67
bfa_cb_ioim_get_cdb(struct bfad_ioim_s *dio)
69
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
71
return (u8 *) cmnd->cmnd;
75
* Get I/O direction (read/write) for the I/O request
77
static inline enum fcp_iodir
78
bfa_cb_ioim_get_iodir(struct bfad_ioim_s *dio)
80
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
81
enum dma_data_direction dmadir;
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;
89
return FCP_IODIR_NONE;
93
* Get IO size in bytes for the I/O request
96
bfa_cb_ioim_get_size(struct bfad_ioim_s *dio)
98
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
100
return scsi_bufflen(cmnd);
104
* Get timeout for the I/O request
107
bfa_cb_ioim_get_timeout(struct bfad_ioim_s *dio)
109
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
111
* TBD: need a timeout for scsi passthru
113
if (cmnd->device->host == NULL)
120
* Get SG element for the I/O request given the SG element index
122
static inline union bfi_addr_u
123
bfa_cb_ioim_get_sgaddr(struct bfad_ioim_s *dio, int sgeid)
125
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
126
struct scatterlist *sge;
129
sge = (struct scatterlist *)scsi_sglist(cmnd) + sgeid;
130
addr = (u64) sg_dma_address(sge);
132
return *((union bfi_addr_u *) &addr);
136
bfa_cb_ioim_get_sglen(struct bfad_ioim_s *dio, int sgeid)
138
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
139
struct scatterlist *sge;
142
sge = (struct scatterlist *)scsi_sglist(cmnd) + sgeid;
143
len = sg_dma_len(sge);
149
* Get Command Reference Number for the I/O request. 0 if none.
152
bfa_cb_ioim_get_crn(struct bfad_ioim_s *dio)
158
* Get SAM-3 priority for the I/O request. 0 is default.
161
bfa_cb_ioim_get_priority(struct bfad_ioim_s *dio)
167
* Get task attributes for the I/O request. Default is FCP_TASK_ATTR_SIMPLE(0).
170
bfa_cb_ioim_get_taskattr(struct bfad_ioim_s *dio)
172
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
173
u8 task_attr = UNTAGGED;
175
if (cmnd->device->tagged_supported) {
177
case HEAD_OF_QUEUE_TAG:
178
task_attr = HEAD_OF_Q;
180
case ORDERED_QUEUE_TAG:
181
task_attr = ORDERED_Q;
184
task_attr = SIMPLE_Q;
193
* Get CDB length in bytes for the I/O request. Default is FCP_CMND_CDB_LEN(16).
196
bfa_cb_ioim_get_cdblen(struct bfad_ioim_s *dio)
198
struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
200
return cmnd->cmd_len;
205
#endif /* __BFA_HCB_IOIM_MACROS_H__ */