mptbase.h 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  1. /*
  2. * linux/drivers/message/fusion/mptbase.h
  3. * High performance SCSI + LAN / Fibre Channel device drivers.
  4. * For use with PCI chip/adapter(s):
  5. * LSIFC9xx/LSI409xx Fibre Channel
  6. * running LSI Logic Fusion MPT (Message Passing Technology) firmware.
  7. *
  8. * Copyright (c) 1999-2005 LSI Logic Corporation
  9. * (mailto:mpt_linux_developer@lsil.com)
  10. *
  11. */
  12. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  13. /*
  14. This program is free software; you can redistribute it and/or modify
  15. it under the terms of the GNU General Public License as published by
  16. the Free Software Foundation; version 2 of the License.
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. GNU General Public License for more details.
  21. NO WARRANTY
  22. THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
  23. CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
  24. LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
  25. MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
  26. solely responsible for determining the appropriateness of using and
  27. distributing the Program and assumes all risks associated with its
  28. exercise of rights under this Agreement, including but not limited to
  29. the risks and costs of program errors, damage to or loss of data,
  30. programs or equipment, and unavailability or interruption of operations.
  31. DISCLAIMER OF LIABILITY
  32. NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
  33. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  34. DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
  35. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  36. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  37. USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
  38. HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
  39. You should have received a copy of the GNU General Public License
  40. along with this program; if not, write to the Free Software
  41. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  42. */
  43. #ifndef MPTBASE_H_INCLUDED
  44. #define MPTBASE_H_INCLUDED
  45. /*{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  46. #include <linux/version.h>
  47. #include <linux/config.h>
  48. #include <linux/kernel.h>
  49. #include <linux/pci.h>
  50. #include "lsi/mpi_type.h"
  51. #include "lsi/mpi.h" /* Fusion MPI(nterface) basic defs */
  52. #include "lsi/mpi_ioc.h" /* Fusion MPT IOC(ontroller) defs */
  53. #include "lsi/mpi_cnfg.h" /* IOC configuration support */
  54. #include "lsi/mpi_init.h" /* SCSI Host (initiator) protocol support */
  55. #include "lsi/mpi_lan.h" /* LAN over FC protocol support */
  56. #include "lsi/mpi_raid.h" /* Integrated Mirroring support */
  57. #include "lsi/mpi_fc.h" /* Fibre Channel (lowlevel) support */
  58. #include "lsi/mpi_targ.h" /* SCSI/FCP Target protcol support */
  59. #include "lsi/mpi_tool.h" /* Tools support */
  60. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  61. #ifndef MODULEAUTHOR
  62. #define MODULEAUTHOR "LSI Logic Corporation"
  63. #endif
  64. #ifndef COPYRIGHT
  65. #define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR
  66. #endif
  67. #define MPT_LINUX_VERSION_COMMON "3.03.02"
  68. #define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.02"
  69. #define WHAT_MAGIC_STRING "@" "(" "#" ")"
  70. #define show_mptmod_ver(s,ver) \
  71. printk(KERN_INFO "%s %s\n", s, ver);
  72. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  73. /*
  74. * Fusion MPT(linux) driver configurable stuff...
  75. */
  76. #define MPT_MAX_ADAPTERS 18
  77. #define MPT_MAX_PROTOCOL_DRIVERS 16
  78. #define MPT_MAX_BUS 1 /* Do not change */
  79. #define MPT_MAX_FC_DEVICES 255
  80. #define MPT_MAX_SCSI_DEVICES 16
  81. #define MPT_LAST_LUN 255
  82. #define MPT_SENSE_BUFFER_ALLOC 64
  83. /* allow for 256 max sense alloc, but only 255 max request */
  84. #if MPT_SENSE_BUFFER_ALLOC >= 256
  85. # undef MPT_SENSE_BUFFER_ALLOC
  86. # define MPT_SENSE_BUFFER_ALLOC 256
  87. # define MPT_SENSE_BUFFER_SIZE 255
  88. #else
  89. # define MPT_SENSE_BUFFER_SIZE MPT_SENSE_BUFFER_ALLOC
  90. #endif
  91. #define MPT_NAME_LENGTH 32
  92. #define MPT_PROCFS_MPTBASEDIR "mpt"
  93. /* chg it to "driver/fusion" ? */
  94. #define MPT_PROCFS_SUMMARY_ALL_NODE MPT_PROCFS_MPTBASEDIR "/summary"
  95. #define MPT_PROCFS_SUMMARY_ALL_PATHNAME "/proc/" MPT_PROCFS_SUMMARY_ALL_NODE
  96. #define MPT_FW_REV_MAGIC_ID_STRING "FwRev="
  97. #define MPT_MAX_REQ_DEPTH 1023
  98. #define MPT_DEFAULT_REQ_DEPTH 256
  99. #define MPT_MIN_REQ_DEPTH 128
  100. #define MPT_MAX_REPLY_DEPTH MPT_MAX_REQ_DEPTH
  101. #define MPT_DEFAULT_REPLY_DEPTH 128
  102. #define MPT_MIN_REPLY_DEPTH 8
  103. #define MPT_MAX_REPLIES_PER_ISR 32
  104. #define MPT_MAX_FRAME_SIZE 128
  105. #define MPT_DEFAULT_FRAME_SIZE 128
  106. #define MPT_REPLY_FRAME_SIZE 0x40 /* Must be a multiple of 8 */
  107. #define MPT_SG_REQ_128_SCALE 1
  108. #define MPT_SG_REQ_96_SCALE 2
  109. #define MPT_SG_REQ_64_SCALE 4
  110. #define CAN_SLEEP 1
  111. #define NO_SLEEP 0
  112. #define MPT_COALESCING_TIMEOUT 0x10
  113. /*
  114. * SCSI transfer rate defines.
  115. */
  116. #define MPT_ULTRA320 0x08
  117. #define MPT_ULTRA160 0x09
  118. #define MPT_ULTRA2 0x0A
  119. #define MPT_ULTRA 0x0C
  120. #define MPT_FAST 0x19
  121. #define MPT_SCSI 0x32
  122. #define MPT_ASYNC 0xFF
  123. #define MPT_NARROW 0
  124. #define MPT_WIDE 1
  125. #define C0_1030 0x08
  126. #define XL_929 0x01
  127. /*
  128. * Try to keep these at 2^N-1
  129. */
  130. #define MPT_FC_CAN_QUEUE 127
  131. #define MPT_SCSI_CAN_QUEUE 127
  132. /*
  133. * Set the MAX_SGE value based on user input.
  134. */
  135. #ifdef CONFIG_FUSION_MAX_SGE
  136. #if CONFIG_FUSION_MAX_SGE < 16
  137. #define MPT_SCSI_SG_DEPTH 16
  138. #elif CONFIG_FUSION_MAX_SGE > 128
  139. #define MPT_SCSI_SG_DEPTH 128
  140. #else
  141. #define MPT_SCSI_SG_DEPTH CONFIG_FUSION_MAX_SGE
  142. #endif
  143. #else
  144. #define MPT_SCSI_SG_DEPTH 40
  145. #endif
  146. #ifdef __KERNEL__ /* { */
  147. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  148. #include <linux/proc_fs.h>
  149. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  150. /*
  151. * Attempt semi-consistent error & warning msgs across
  152. * MPT drivers. NOTE: Users of these macro defs must
  153. * themselves define their own MYNAM.
  154. */
  155. #define MYIOC_s_INFO_FMT KERN_INFO MYNAM ": %s: "
  156. #define MYIOC_s_NOTE_FMT KERN_NOTICE MYNAM ": %s: "
  157. #define MYIOC_s_WARN_FMT KERN_WARNING MYNAM ": %s: WARNING - "
  158. #define MYIOC_s_ERR_FMT KERN_ERR MYNAM ": %s: ERROR - "
  159. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  160. /*
  161. * MPT protocol driver defs...
  162. */
  163. typedef enum {
  164. MPTBASE_DRIVER, /* MPT base class */
  165. MPTCTL_DRIVER, /* MPT ioctl class */
  166. MPTSPI_DRIVER, /* MPT SPI host class */
  167. MPTFC_DRIVER, /* MPT FC host class */
  168. MPTSAS_DRIVER, /* MPT SAS host class */
  169. MPTLAN_DRIVER, /* MPT LAN class */
  170. MPTSTM_DRIVER, /* MPT SCSI target mode class */
  171. MPTUNKNOWN_DRIVER
  172. } MPT_DRIVER_CLASS;
  173. struct mpt_pci_driver{
  174. int (*probe) (struct pci_dev *dev, const struct pci_device_id *id);
  175. void (*remove) (struct pci_dev *dev);
  176. };
  177. /*
  178. * MPT adapter / port / bus / device info structures...
  179. */
  180. typedef union _MPT_FRAME_TRACKER {
  181. struct {
  182. struct list_head list;
  183. u32 arg1;
  184. u32 pad;
  185. void *argp1;
  186. } linkage;
  187. /*
  188. * NOTE: When request frames are free, on the linkage structure
  189. * contets are valid. All other values are invalid.
  190. * In particular, do NOT reply on offset [2]
  191. * (in words) being the * message context.
  192. * The message context must be reset (computed via base address
  193. * + an offset) prior to issuing any command.
  194. *
  195. * NOTE2: On non-32-bit systems, where pointers are LARGE,
  196. * using the linkage pointers destroys our sacred MsgContext
  197. * field contents. But we don't care anymore because these
  198. * are now reset in mpt_put_msg_frame() just prior to sending
  199. * a request off to the IOC.
  200. */
  201. struct {
  202. u32 __hdr[2];
  203. /*
  204. * The following _MUST_ match the location of the
  205. * MsgContext field in the MPT message headers.
  206. */
  207. union {
  208. u32 MsgContext;
  209. struct {
  210. u16 req_idx; /* Request index */
  211. u8 cb_idx; /* callback function index */
  212. u8 rsvd;
  213. } fld;
  214. } msgctxu;
  215. } hwhdr;
  216. /*
  217. * Remark: 32 bit identifier:
  218. * 31-24: reserved
  219. * 23-16: call back index
  220. * 15-0 : request index
  221. */
  222. } MPT_FRAME_TRACKER;
  223. /*
  224. * We might want to view/access a frame as:
  225. * 1) generic request header
  226. * 2) SCSIIORequest
  227. * 3) SCSIIOReply
  228. * 4) MPIDefaultReply
  229. * 5) frame tracker
  230. */
  231. typedef struct _MPT_FRAME_HDR {
  232. union {
  233. MPIHeader_t hdr;
  234. SCSIIORequest_t scsireq;
  235. SCSIIOReply_t sreply;
  236. ConfigReply_t configreply;
  237. MPIDefaultReply_t reply;
  238. MPT_FRAME_TRACKER frame;
  239. } u;
  240. } MPT_FRAME_HDR;
  241. #define MPT_REQ_MSGFLAGS_DROPME 0x80
  242. typedef struct _MPT_SGL_HDR {
  243. SGESimple32_t sge[1];
  244. } MPT_SGL_HDR;
  245. typedef struct _MPT_SGL64_HDR {
  246. SGESimple64_t sge[1];
  247. } MPT_SGL64_HDR;
  248. /*
  249. * System interface register set
  250. */
  251. typedef struct _SYSIF_REGS
  252. {
  253. u32 Doorbell; /* 00 System<->IOC Doorbell reg */
  254. u32 WriteSequence; /* 04 Write Sequence register */
  255. u32 Diagnostic; /* 08 Diagnostic register */
  256. u32 TestBase; /* 0C Test Base Address */
  257. u32 DiagRwData; /* 10 Read Write Data (fw download) */
  258. u32 DiagRwAddress; /* 14 Read Write Address (fw download)*/
  259. u32 Reserved1[6]; /* 18-2F reserved for future use */
  260. u32 IntStatus; /* 30 Interrupt Status */
  261. u32 IntMask; /* 34 Interrupt Mask */
  262. u32 Reserved2[2]; /* 38-3F reserved for future use */
  263. u32 RequestFifo; /* 40 Request Post/Free FIFO */
  264. u32 ReplyFifo; /* 44 Reply Post/Free FIFO */
  265. u32 Reserved3[2]; /* 48-4F reserved for future use */
  266. u32 HostIndex; /* 50 Host Index register */
  267. u32 Reserved4[15]; /* 54-8F */
  268. u32 Fubar; /* 90 For Fubar usage */
  269. u32 Reserved5[27]; /* 94-FF */
  270. } SYSIF_REGS;
  271. /*
  272. * NOTE: Use MPI_{DOORBELL,WRITESEQ,DIAG}_xxx defs in lsi/mpi.h
  273. * in conjunction with SYSIF_REGS accesses!
  274. */
  275. /*
  276. * Dynamic Multi-Pathing specific stuff...
  277. */
  278. /* VirtDevice negoFlags field */
  279. #define MPT_TARGET_NO_NEGO_WIDE 0x01
  280. #define MPT_TARGET_NO_NEGO_SYNC 0x02
  281. #define MPT_TARGET_NO_NEGO_QAS 0x04
  282. #define MPT_TAPE_NEGO_IDP 0x08
  283. /*
  284. * VirtDevice - FC LUN device or SCSI target device
  285. */
  286. typedef struct _VirtDevice {
  287. struct scsi_device *device;
  288. u8 tflags;
  289. u8 ioc_id;
  290. u8 target_id;
  291. u8 bus_id;
  292. u8 minSyncFactor; /* 0xFF is async */
  293. u8 maxOffset; /* 0 if async */
  294. u8 maxWidth; /* 0 if narrow, 1 if wide */
  295. u8 negoFlags; /* bit field, see above */
  296. u8 raidVolume; /* set, if RAID Volume */
  297. u8 type; /* byte 0 of Inquiry data */
  298. u8 cflags; /* controller flags */
  299. u8 rsvd1raid;
  300. u16 fc_phys_lun;
  301. u16 fc_xlat_lun;
  302. u32 num_luns;
  303. u32 luns[8]; /* Max LUNs is 256 */
  304. u8 pad[4];
  305. u8 inq_data[8];
  306. /* IEEE Registered Extended Identifier
  307. obtained via INQUIRY VPD page 0x83 */
  308. /* NOTE: Do not separate uniq_prepad and uniq_data
  309. as they are treateed as a single entity in the code */
  310. u8 uniq_prepad[8];
  311. u8 uniq_data[20];
  312. u8 pad2[4];
  313. } VirtDevice;
  314. /*
  315. * Fibre Channel (SCSI) target device and associated defines...
  316. */
  317. #define MPT_TARGET_DEFAULT_DV_STATUS 0x00
  318. #define MPT_TARGET_FLAGS_VALID_NEGO 0x01
  319. #define MPT_TARGET_FLAGS_VALID_INQUIRY 0x02
  320. #define MPT_TARGET_FLAGS_Q_YES 0x08
  321. #define MPT_TARGET_FLAGS_VALID_56 0x10
  322. #define MPT_TARGET_FLAGS_SAF_TE_ISSUED 0x20
  323. /*
  324. * /proc/mpt interface
  325. */
  326. typedef struct {
  327. const char *name;
  328. mode_t mode;
  329. int pad;
  330. read_proc_t *read_proc;
  331. write_proc_t *write_proc;
  332. } mpt_proc_entry_t;
  333. #define MPT_PROC_READ_RETURN(buf,start,offset,request,eof,len) \
  334. do { \
  335. len -= offset; \
  336. if (len < request) { \
  337. *eof = 1; \
  338. if (len <= 0) \
  339. return 0; \
  340. } else \
  341. len = request; \
  342. *start = buf + offset; \
  343. return len; \
  344. } while (0)
  345. /*
  346. * IOCTL structure and associated defines
  347. */
  348. #define MPT_IOCTL_STATUS_DID_IOCRESET 0x01 /* IOC Reset occurred on the current*/
  349. #define MPT_IOCTL_STATUS_RF_VALID 0x02 /* The Reply Frame is VALID */
  350. #define MPT_IOCTL_STATUS_TIMER_ACTIVE 0x04 /* The timer is running */
  351. #define MPT_IOCTL_STATUS_SENSE_VALID 0x08 /* Sense data is valid */
  352. #define MPT_IOCTL_STATUS_COMMAND_GOOD 0x10 /* Command Status GOOD */
  353. #define MPT_IOCTL_STATUS_TMTIMER_ACTIVE 0x20 /* The TM timer is running */
  354. #define MPT_IOCTL_STATUS_TM_FAILED 0x40 /* User TM request failed */
  355. #define MPTCTL_RESET_OK 0x01 /* Issue Bus Reset */
  356. typedef struct _MPT_IOCTL {
  357. struct _MPT_ADAPTER *ioc;
  358. u8 ReplyFrame[MPT_DEFAULT_FRAME_SIZE]; /* reply frame data */
  359. u8 sense[MPT_SENSE_BUFFER_ALLOC];
  360. int wait_done; /* wake-up value for this ioc */
  361. u8 rsvd;
  362. u8 status; /* current command status */
  363. u8 reset; /* 1 if bus reset allowed */
  364. u8 target; /* target for reset */
  365. struct semaphore sem_ioc;
  366. } MPT_IOCTL;
  367. /*
  368. * Event Structure and define
  369. */
  370. #define MPTCTL_EVENT_LOG_SIZE (0x0000000A)
  371. typedef struct _mpt_ioctl_events {
  372. u32 event; /* Specified by define above */
  373. u32 eventContext; /* Index or counter */
  374. int data[2]; /* First 8 bytes of Event Data */
  375. } MPT_IOCTL_EVENTS;
  376. /*
  377. * CONFIGPARM status defines
  378. */
  379. #define MPT_CONFIG_GOOD MPI_IOCSTATUS_SUCCESS
  380. #define MPT_CONFIG_ERROR 0x002F
  381. /*
  382. * Substructure to store SCSI specific configuration page data
  383. */
  384. /* dvStatus defines: */
  385. #define MPT_SCSICFG_NEGOTIATE 0x01 /* Negotiate on next IO */
  386. #define MPT_SCSICFG_NEED_DV 0x02 /* Schedule DV */
  387. #define MPT_SCSICFG_DV_PENDING 0x04 /* DV on this physical id pending */
  388. #define MPT_SCSICFG_DV_NOT_DONE 0x08 /* DV has not been performed */
  389. #define MPT_SCSICFG_BLK_NEGO 0x10 /* WriteSDP1 with WDTR and SDTR disabled */
  390. #define MPT_SCSICFG_RELOAD_IOC_PG3 0x20 /* IOC Pg 3 data is obsolete */
  391. /* Args passed to writeSDP1: */
  392. #define MPT_SCSICFG_USE_NVRAM 0x01 /* WriteSDP1 using NVRAM */
  393. #define MPT_SCSICFG_ALL_IDS 0x02 /* WriteSDP1 to all IDS */
  394. /* #define MPT_SCSICFG_BLK_NEGO 0x10 WriteSDP1 with WDTR and SDTR disabled */
  395. typedef struct _ScsiCfgData {
  396. u32 PortFlags;
  397. int *nvram; /* table of device NVRAM values */
  398. IOCPage2_t *pIocPg2; /* table of Raid Volumes */
  399. IOCPage3_t *pIocPg3; /* table of physical disks */
  400. IOCPage4_t *pIocPg4; /* SEP devices addressing */
  401. dma_addr_t IocPg4_dma; /* Phys Addr of IOCPage4 data */
  402. int IocPg4Sz; /* IOCPage4 size */
  403. u8 dvStatus[MPT_MAX_SCSI_DEVICES];
  404. int isRaid; /* bit field, 1 if RAID */
  405. u8 minSyncFactor; /* 0xFF if async */
  406. u8 maxSyncOffset; /* 0 if async */
  407. u8 maxBusWidth; /* 0 if narrow, 1 if wide */
  408. u8 busType; /* SE, LVD, HD */
  409. u8 sdp1version; /* SDP1 version */
  410. u8 sdp1length; /* SDP1 length */
  411. u8 sdp0version; /* SDP0 version */
  412. u8 sdp0length; /* SDP0 length */
  413. u8 dvScheduled; /* 1 if scheduled */
  414. u8 forceDv; /* 1 to force DV scheduling */
  415. u8 noQas; /* Disable QAS for this adapter */
  416. u8 Saf_Te; /* 1 to force all Processors as SAF-TE if Inquiry data length is too short to check for SAF-TE */
  417. u8 mpt_dv; /* command line option: enhanced=1, basic=0 */
  418. u8 rsvd[1];
  419. } ScsiCfgData;
  420. /*
  421. * Adapter Structure - pci_dev specific. Maximum: MPT_MAX_ADAPTERS
  422. */
  423. typedef struct _MPT_ADAPTER
  424. {
  425. int id; /* Unique adapter id N {0,1,2,...} */
  426. int pci_irq; /* This irq */
  427. char name[MPT_NAME_LENGTH]; /* "iocN" */
  428. char *prod_name; /* "LSIFC9x9" */
  429. SYSIF_REGS __iomem *chip; /* == c8817000 (mmap) */
  430. SYSIF_REGS __iomem *pio_chip; /* Programmed IO (downloadboot) */
  431. u8 bus_type;
  432. u32 mem_phys; /* == f4020000 (mmap) */
  433. u32 pio_mem_phys; /* Programmed IO (downloadboot) */
  434. int mem_size; /* mmap memory size */
  435. int alloc_total;
  436. u32 last_state;
  437. int active;
  438. u8 *alloc; /* frames alloc ptr */
  439. dma_addr_t alloc_dma;
  440. u32 alloc_sz;
  441. MPT_FRAME_HDR *reply_frames; /* Reply msg frames - rounded up! */
  442. u32 reply_frames_low_dma;
  443. int reply_depth; /* Num Allocated reply frames */
  444. int reply_sz; /* Reply frame size */
  445. int num_chain; /* Number of chain buffers */
  446. /* Pool of buffers for chaining. ReqToChain
  447. * and ChainToChain track index of chain buffers.
  448. * ChainBuffer (DMA) virt/phys addresses.
  449. * FreeChainQ (lock) locking mechanisms.
  450. */
  451. int *ReqToChain;
  452. int *RequestNB;
  453. int *ChainToChain;
  454. u8 *ChainBuffer;
  455. dma_addr_t ChainBufferDMA;
  456. struct list_head FreeChainQ;
  457. spinlock_t FreeChainQlock;
  458. /* We (host driver) get to manage our own RequestQueue! */
  459. dma_addr_t req_frames_dma;
  460. MPT_FRAME_HDR *req_frames; /* Request msg frames - rounded up! */
  461. u32 req_frames_low_dma;
  462. int req_depth; /* Number of request frames */
  463. int req_sz; /* Request frame size (bytes) */
  464. spinlock_t FreeQlock;
  465. struct list_head FreeQ;
  466. /* Pool of SCSI sense buffers for commands coming from
  467. * the SCSI mid-layer. We have one 256 byte sense buffer
  468. * for each REQ entry.
  469. */
  470. u8 *sense_buf_pool;
  471. dma_addr_t sense_buf_pool_dma;
  472. u32 sense_buf_low_dma;
  473. int mtrr_reg;
  474. struct pci_dev *pcidev; /* struct pci_dev pointer */
  475. u8 __iomem *memmap; /* mmap address */
  476. struct Scsi_Host *sh; /* Scsi Host pointer */
  477. ScsiCfgData spi_data; /* Scsi config. data */
  478. MPT_IOCTL *ioctl; /* ioctl data pointer */
  479. struct proc_dir_entry *ioc_dentry;
  480. struct _MPT_ADAPTER *alt_ioc; /* ptr to 929 bound adapter port */
  481. spinlock_t diagLock; /* diagnostic reset lock */
  482. int diagPending;
  483. u32 biosVersion; /* BIOS version from IO Unit Page 2 */
  484. int eventTypes; /* Event logging parameters */
  485. int eventContext; /* Next event context */
  486. int eventLogSize; /* Max number of cached events */
  487. struct _mpt_ioctl_events *events; /* pointer to event log */
  488. u8 *cached_fw; /* Pointer to FW */
  489. dma_addr_t cached_fw_dma;
  490. struct list_head configQ; /* linked list of config. requests */
  491. int hs_reply_idx;
  492. #ifndef MFCNT
  493. u32 pad0;
  494. #else
  495. u32 mfcnt;
  496. #endif
  497. u32 NB_for_64_byte_frame;
  498. u32 hs_req[MPT_MAX_FRAME_SIZE/sizeof(u32)];
  499. u16 hs_reply[MPT_MAX_FRAME_SIZE/sizeof(u16)];
  500. IOCFactsReply_t facts;
  501. PortFactsReply_t pfacts[2];
  502. FCPortPage0_t fc_port_page0[2];
  503. LANPage0_t lan_cnfg_page0;
  504. LANPage1_t lan_cnfg_page1;
  505. /*
  506. * Description: errata_flag_1064
  507. * If a PCIX read occurs within 1 or 2 cycles after the chip receives
  508. * a split completion for a read data, an internal address pointer incorrectly
  509. * increments by 32 bytes
  510. */
  511. int errata_flag_1064;
  512. u8 FirstWhoInit;
  513. u8 upload_fw; /* If set, do a fw upload */
  514. u8 reload_fw; /* Force a FW Reload on next reset */
  515. u8 NBShiftFactor; /* NB Shift Factor based on Block Size (Facts) */
  516. u8 pad1[4];
  517. int DoneCtx;
  518. int TaskCtx;
  519. int InternalCtx;
  520. struct list_head list;
  521. struct net_device *netdev;
  522. } MPT_ADAPTER;
  523. /*
  524. * New return value convention:
  525. * 1 = Ok to free associated request frame
  526. * 0 = not Ok ...
  527. */
  528. typedef int (*MPT_CALLBACK)(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply);
  529. typedef int (*MPT_EVHANDLER)(MPT_ADAPTER *ioc, EventNotificationReply_t *evReply);
  530. typedef int (*MPT_RESETHANDLER)(MPT_ADAPTER *ioc, int reset_phase);
  531. /* reset_phase defs */
  532. #define MPT_IOC_PRE_RESET 0
  533. #define MPT_IOC_POST_RESET 1
  534. #define MPT_IOC_SETUP_RESET 2
  535. /*
  536. * Invent MPT host event (super-set of MPI Events)
  537. * Fitted to 1030's 64-byte [max] request frame size
  538. */
  539. typedef struct _MPT_HOST_EVENT {
  540. EventNotificationReply_t MpiEvent; /* 8 32-bit words! */
  541. u32 pad[6];
  542. void *next;
  543. } MPT_HOST_EVENT;
  544. #define MPT_HOSTEVENT_IOC_BRINGUP 0x91
  545. #define MPT_HOSTEVENT_IOC_RECOVER 0x92
  546. /* Define the generic types based on the size
  547. * of the dma_addr_t type.
  548. */
  549. typedef struct _mpt_sge {
  550. u32 FlagsLength;
  551. dma_addr_t Address;
  552. } MptSge_t;
  553. #define mpt_addr_size() \
  554. ((sizeof(dma_addr_t) == sizeof(u64)) ? MPI_SGE_FLAGS_64_BIT_ADDRESSING : \
  555. MPI_SGE_FLAGS_32_BIT_ADDRESSING)
  556. #define mpt_msg_flags() \
  557. ((sizeof(dma_addr_t) == sizeof(u64)) ? MPI_SCSIIO_MSGFLGS_SENSE_WIDTH_64 : \
  558. MPI_SCSIIO_MSGFLGS_SENSE_WIDTH_32)
  559. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  560. /*
  561. * Funky (private) macros...
  562. */
  563. #ifdef MPT_DEBUG
  564. #define dprintk(x) printk x
  565. #else
  566. #define dprintk(x)
  567. #endif
  568. #ifdef MPT_DEBUG_INIT
  569. #define dinitprintk(x) printk x
  570. #define DBG_DUMP_FW_REQUEST_FRAME(mfp) \
  571. { int i, n = 10; \
  572. u32 *m = (u32 *)(mfp); \
  573. printk(KERN_INFO " "); \
  574. for (i=0; i<n; i++) \
  575. printk(" %08x", le32_to_cpu(m[i])); \
  576. printk("\n"); \
  577. }
  578. #else
  579. #define dinitprintk(x)
  580. #define DBG_DUMP_FW_REQUEST_FRAME(mfp)
  581. #endif
  582. #ifdef MPT_DEBUG_EXIT
  583. #define dexitprintk(x) printk x
  584. #else
  585. #define dexitprintk(x)
  586. #endif
  587. #if defined MPT_DEBUG_FAIL || defined (MPT_DEBUG_SG)
  588. #define dfailprintk(x) printk x
  589. #else
  590. #define dfailprintk(x)
  591. #endif
  592. #ifdef MPT_DEBUG_HANDSHAKE
  593. #define dhsprintk(x) printk x
  594. #else
  595. #define dhsprintk(x)
  596. #endif
  597. #ifdef MPT_DEBUG_EVENTS
  598. #define devtprintk(x) printk x
  599. #else
  600. #define devtprintk(x)
  601. #endif
  602. #ifdef MPT_DEBUG_RESET
  603. #define drsprintk(x) printk x
  604. #else
  605. #define drsprintk(x)
  606. #endif
  607. //#if defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME)
  608. #if defined(MPT_DEBUG_MSG_FRAME)
  609. #define dmfprintk(x) printk x
  610. #define DBG_DUMP_REQUEST_FRAME(mfp) \
  611. { int i, n = 24; \
  612. u32 *m = (u32 *)(mfp); \
  613. for (i=0; i<n; i++) { \
  614. if (i && ((i%8)==0)) \
  615. printk("\n"); \
  616. printk("%08x ", le32_to_cpu(m[i])); \
  617. } \
  618. printk("\n"); \
  619. }
  620. #else
  621. #define dmfprintk(x)
  622. #define DBG_DUMP_REQUEST_FRAME(mfp)
  623. #endif
  624. #ifdef MPT_DEBUG_IRQ
  625. #define dirqprintk(x) printk x
  626. #else
  627. #define dirqprintk(x)
  628. #endif
  629. #ifdef MPT_DEBUG_SG
  630. #define dsgprintk(x) printk x
  631. #else
  632. #define dsgprintk(x)
  633. #endif
  634. #if defined(MPT_DEBUG_DL) || defined(MPT_DEBUG)
  635. #define ddlprintk(x) printk x
  636. #else
  637. #define ddlprintk(x)
  638. #endif
  639. #ifdef MPT_DEBUG_DV
  640. #define ddvprintk(x) printk x
  641. #else
  642. #define ddvprintk(x)
  643. #endif
  644. #ifdef MPT_DEBUG_NEGO
  645. #define dnegoprintk(x) printk x
  646. #else
  647. #define dnegoprintk(x)
  648. #endif
  649. #if defined(MPT_DEBUG_DV) || defined(MPT_DEBUG_DV_TINY)
  650. #define ddvtprintk(x) printk x
  651. #else
  652. #define ddvtprintk(x)
  653. #endif
  654. #ifdef MPT_DEBUG_IOCTL
  655. #define dctlprintk(x) printk x
  656. #else
  657. #define dctlprintk(x)
  658. #endif
  659. #ifdef MPT_DEBUG_REPLY
  660. #define dreplyprintk(x) printk x
  661. #else
  662. #define dreplyprintk(x)
  663. #endif
  664. #ifdef MPT_DEBUG_TM
  665. #define dtmprintk(x) printk x
  666. #define DBG_DUMP_TM_REQUEST_FRAME(mfp) \
  667. { u32 *m = (u32 *)(mfp); \
  668. int i, n = 13; \
  669. printk("TM_REQUEST:\n"); \
  670. for (i=0; i<n; i++) { \
  671. if (i && ((i%8)==0)) \
  672. printk("\n"); \
  673. printk("%08x ", le32_to_cpu(m[i])); \
  674. } \
  675. printk("\n"); \
  676. }
  677. #define DBG_DUMP_TM_REPLY_FRAME(mfp) \
  678. { u32 *m = (u32 *)(mfp); \
  679. int i, n = (le32_to_cpu(m[0]) & 0x00FF0000) >> 16; \
  680. printk("TM_REPLY MessageLength=%d:\n", n); \
  681. for (i=0; i<n; i++) { \
  682. if (i && ((i%8)==0)) \
  683. printk("\n"); \
  684. printk(" %08x", le32_to_cpu(m[i])); \
  685. } \
  686. printk("\n"); \
  687. }
  688. #else
  689. #define dtmprintk(x)
  690. #define DBG_DUMP_TM_REQUEST_FRAME(mfp)
  691. #define DBG_DUMP_TM_REPLY_FRAME(mfp)
  692. #endif
  693. #if defined(MPT_DEBUG_CONFIG) || defined(MPT_DEBUG)
  694. #define dcprintk(x) printk x
  695. #else
  696. #define dcprintk(x)
  697. #endif
  698. #if defined(MPT_DEBUG_SCSI) || defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME)
  699. #define dsprintk(x) printk x
  700. #else
  701. #define dsprintk(x)
  702. #endif
  703. #define MPT_INDEX_2_MFPTR(ioc,idx) \
  704. (MPT_FRAME_HDR*)( (u8*)(ioc)->req_frames + (ioc)->req_sz * (idx) )
  705. #define MFPTR_2_MPT_INDEX(ioc,mf) \
  706. (int)( ((u8*)mf - (u8*)(ioc)->req_frames) / (ioc)->req_sz )
  707. #define MPT_INDEX_2_RFPTR(ioc,idx) \
  708. (MPT_FRAME_HDR*)( (u8*)(ioc)->reply_frames + (ioc)->req_sz * (idx) )
  709. #if defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME)
  710. #define DBG_DUMP_REPLY_FRAME(mfp) \
  711. { u32 *m = (u32 *)(mfp); \
  712. int i, n = (le32_to_cpu(m[0]) & 0x00FF0000) >> 16; \
  713. printk(KERN_INFO " "); \
  714. for (i=0; i<n; i++) \
  715. printk(" %08x", le32_to_cpu(m[i])); \
  716. printk("\n"); \
  717. }
  718. #define DBG_DUMP_REQUEST_FRAME_HDR(mfp) \
  719. { int i, n = 3; \
  720. u32 *m = (u32 *)(mfp); \
  721. printk(KERN_INFO " "); \
  722. for (i=0; i<n; i++) \
  723. printk(" %08x", le32_to_cpu(m[i])); \
  724. printk("\n"); \
  725. }
  726. #else
  727. #define DBG_DUMP_REPLY_FRAME(mfp)
  728. #define DBG_DUMP_REQUEST_FRAME_HDR(mfp)
  729. #endif
  730. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  731. #define SCSI_STD_SENSE_BYTES 18
  732. #define SCSI_STD_INQUIRY_BYTES 36
  733. #define SCSI_MAX_INQUIRY_BYTES 96
  734. /*
  735. * MPT_SCSI_HOST defines - Used by the IOCTL and the SCSI drivers
  736. * Private to the driver.
  737. */
  738. /* LOCAL structure and fields used when processing
  739. * internally generated commands. These include:
  740. * bus scan, dv and config requests.
  741. */
  742. typedef struct _MPT_LOCAL_REPLY {
  743. ConfigPageHeader_t header;
  744. int completion;
  745. u8 sense[SCSI_STD_SENSE_BYTES];
  746. u8 scsiStatus;
  747. u8 skip;
  748. u32 pad;
  749. } MPT_LOCAL_REPLY;
  750. #define MPT_HOST_BUS_UNKNOWN (0xFF)
  751. #define MPT_HOST_TOO_MANY_TM (0x05)
  752. #define MPT_HOST_NVRAM_INVALID (0xFFFFFFFF)
  753. #define MPT_HOST_NO_CHAIN (0xFFFFFFFF)
  754. #define MPT_NVRAM_MASK_TIMEOUT (0x000000FF)
  755. #define MPT_NVRAM_SYNC_MASK (0x0000FF00)
  756. #define MPT_NVRAM_SYNC_SHIFT (8)
  757. #define MPT_NVRAM_DISCONNECT_ENABLE (0x00010000)
  758. #define MPT_NVRAM_ID_SCAN_ENABLE (0x00020000)
  759. #define MPT_NVRAM_LUN_SCAN_ENABLE (0x00040000)
  760. #define MPT_NVRAM_TAG_QUEUE_ENABLE (0x00080000)
  761. #define MPT_NVRAM_WIDE_DISABLE (0x00100000)
  762. #define MPT_NVRAM_BOOT_CHOICE (0x00200000)
  763. /* The TM_STATE variable is used to provide strict single threading of TM
  764. * requests as well as communicate TM error conditions.
  765. */
  766. #define TM_STATE_NONE (0)
  767. #define TM_STATE_IN_PROGRESS (1)
  768. #define TM_STATE_ERROR (2)
  769. typedef enum {
  770. FC,
  771. SCSI,
  772. SAS
  773. } BUS_TYPE;
  774. typedef struct _MPT_SCSI_HOST {
  775. MPT_ADAPTER *ioc;
  776. int port;
  777. u32 pad0;
  778. struct scsi_cmnd **ScsiLookup;
  779. VirtDevice **Targets;
  780. MPT_LOCAL_REPLY *pLocal; /* used for internal commands */
  781. struct timer_list timer;
  782. /* Pool of memory for holding SCpnts before doing
  783. * OS callbacks. freeQ is the free pool.
  784. */
  785. u8 tmPending;
  786. u8 resetPending;
  787. u8 negoNvram; /* DV disabled, nego NVRAM */
  788. u8 pad1;
  789. u8 tmState;
  790. u8 rsvd[2];
  791. MPT_FRAME_HDR *cmdPtr; /* Ptr to nonOS request */
  792. struct scsi_cmnd *abortSCpnt;
  793. MPT_LOCAL_REPLY localReply; /* internal cmd reply struct */
  794. unsigned long hard_resets; /* driver forced bus resets count */
  795. unsigned long soft_resets; /* fw/external bus resets count */
  796. unsigned long timeouts; /* cmd timeouts */
  797. ushort sel_timeout[MPT_MAX_FC_DEVICES];
  798. char *info_kbuf;
  799. wait_queue_head_t scandv_waitq;
  800. int scandv_wait_done;
  801. long last_queue_full;
  802. u8 mpt_pq_filter;
  803. } MPT_SCSI_HOST;
  804. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  805. /*
  806. * More Dynamic Multi-Pathing stuff...
  807. */
  808. /* Forward decl, a strange C thing, to prevent gcc compiler warnings */
  809. struct scsi_cmnd;
  810. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  811. /*
  812. * Generic structure passed to the base mpt_config function.
  813. */
  814. typedef struct _x_config_parms {
  815. struct list_head linkage; /* linked list */
  816. struct timer_list timer; /* timer function for this request */
  817. union {
  818. ConfigExtendedPageHeader_t *ehdr;
  819. ConfigPageHeader_t *hdr;
  820. } cfghdr;
  821. dma_addr_t physAddr;
  822. int wait_done; /* wait for this request */
  823. u32 pageAddr; /* properly formatted */
  824. u8 action;
  825. u8 dir;
  826. u8 timeout; /* seconds */
  827. u8 pad1;
  828. u16 status;
  829. u16 pad2;
  830. } CONFIGPARMS;
  831. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  832. /*
  833. * Public entry points...
  834. */
  835. extern int mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id);
  836. extern void mpt_detach(struct pci_dev *pdev);
  837. #ifdef CONFIG_PM
  838. extern int mpt_suspend(struct pci_dev *pdev, pm_message_t state);
  839. extern int mpt_resume(struct pci_dev *pdev);
  840. #endif
  841. extern int mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass);
  842. extern void mpt_deregister(int cb_idx);
  843. extern int mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc);
  844. extern void mpt_event_deregister(int cb_idx);
  845. extern int mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func);
  846. extern void mpt_reset_deregister(int cb_idx);
  847. extern int mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx);
  848. extern void mpt_device_driver_deregister(int cb_idx);
  849. extern MPT_FRAME_HDR *mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc);
  850. extern void mpt_free_msg_frame(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);
  851. extern void mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);
  852. extern void mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr);
  853. extern int mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag);
  854. extern int mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp);
  855. extern u32 mpt_GetIocState(MPT_ADAPTER *ioc, int cooked);
  856. extern void mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buf, int *size, int len, int showlan);
  857. extern int mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag);
  858. extern int mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *cfg);
  859. extern int mpt_toolbox(MPT_ADAPTER *ioc, CONFIGPARMS *cfg);
  860. extern void mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size);
  861. extern void mpt_free_fw_memory(MPT_ADAPTER *ioc);
  862. extern int mpt_findImVolumes(MPT_ADAPTER *ioc);
  863. extern int mpt_read_ioc_pg_3(MPT_ADAPTER *ioc);
  864. /*
  865. * Public data decl's...
  866. */
  867. extern struct list_head ioc_list;
  868. extern struct proc_dir_entry *mpt_proc_root_dir;
  869. extern int mpt_lan_index; /* needed by mptlan.c */
  870. extern int mpt_stm_index; /* needed by mptstm.c */
  871. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  872. #endif /* } __KERNEL__ */
  873. #if defined(__alpha__) || defined(__sparc_v9__) || defined(__ia64__) || defined(__x86_64__)
  874. #define CAST_U32_TO_PTR(x) ((void *)(u64)x)
  875. #define CAST_PTR_TO_U32(x) ((u32)(u64)x)
  876. #else
  877. #define CAST_U32_TO_PTR(x) ((void *)x)
  878. #define CAST_PTR_TO_U32(x) ((u32)x)
  879. #endif
  880. #define MPT_PROTOCOL_FLAGS_c_c_c_c(pflags) \
  881. ((pflags) & MPI_PORTFACTS_PROTOCOL_INITIATOR) ? 'I' : 'i', \
  882. ((pflags) & MPI_PORTFACTS_PROTOCOL_TARGET) ? 'T' : 't', \
  883. ((pflags) & MPI_PORTFACTS_PROTOCOL_LAN) ? 'L' : 'l', \
  884. ((pflags) & MPI_PORTFACTS_PROTOCOL_LOGBUSADDR) ? 'B' : 'b'
  885. /*
  886. * Shifted SGE Defines - Use in SGE with FlagsLength member.
  887. * Otherwise, use MPI_xxx defines (refer to "lsi/mpi.h" header).
  888. * Defaults: 32 bit SGE, SYSTEM_ADDRESS if direction bit is 0, read
  889. */
  890. #define MPT_TRANSFER_IOC_TO_HOST (0x00000000)
  891. #define MPT_TRANSFER_HOST_TO_IOC (0x04000000)
  892. #define MPT_SGE_FLAGS_LAST_ELEMENT (0x80000000)
  893. #define MPT_SGE_FLAGS_END_OF_BUFFER (0x40000000)
  894. #define MPT_SGE_FLAGS_LOCAL_ADDRESS (0x08000000)
  895. #define MPT_SGE_FLAGS_DIRECTION (0x04000000)
  896. #define MPT_SGE_FLAGS_ADDRESSING (mpt_addr_size() << MPI_SGE_FLAGS_SHIFT)
  897. #define MPT_SGE_FLAGS_END_OF_LIST (0x01000000)
  898. #define MPT_SGE_FLAGS_TRANSACTION_ELEMENT (0x00000000)
  899. #define MPT_SGE_FLAGS_SIMPLE_ELEMENT (0x10000000)
  900. #define MPT_SGE_FLAGS_CHAIN_ELEMENT (0x30000000)
  901. #define MPT_SGE_FLAGS_ELEMENT_MASK (0x30000000)
  902. #define MPT_SGE_FLAGS_SSIMPLE_READ \
  903. (MPT_SGE_FLAGS_LAST_ELEMENT | \
  904. MPT_SGE_FLAGS_END_OF_BUFFER | \
  905. MPT_SGE_FLAGS_END_OF_LIST | \
  906. MPT_SGE_FLAGS_SIMPLE_ELEMENT | \
  907. MPT_SGE_FLAGS_ADDRESSING | \
  908. MPT_TRANSFER_IOC_TO_HOST)
  909. #define MPT_SGE_FLAGS_SSIMPLE_WRITE \
  910. (MPT_SGE_FLAGS_LAST_ELEMENT | \
  911. MPT_SGE_FLAGS_END_OF_BUFFER | \
  912. MPT_SGE_FLAGS_END_OF_LIST | \
  913. MPT_SGE_FLAGS_SIMPLE_ELEMENT | \
  914. MPT_SGE_FLAGS_ADDRESSING | \
  915. MPT_TRANSFER_HOST_TO_IOC)
  916. /*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  917. #endif