Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ibmvfc.h
Go to the documentation of this file.
1 /*
2  * ibmvfc.h -- driver for IBM Power Virtual Fibre Channel Adapter
3  *
4  * Written By: Brian King <[email protected]>, IBM Corporation
5  *
6  * Copyright (C) IBM Corporation, 2008
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  */
23 
24 #ifndef _IBMVFC_H
25 #define _IBMVFC_H
26 
27 #include <linux/list.h>
28 #include <linux/types.h>
29 #include "viosrp.h"
30 
31 #define IBMVFC_NAME "ibmvfc"
32 #define IBMVFC_DRIVER_VERSION "1.0.10"
33 #define IBMVFC_DRIVER_DATE "(August 24, 2012)"
34 
35 #define IBMVFC_DEFAULT_TIMEOUT 60
36 #define IBMVFC_ADISC_CANCEL_TIMEOUT 45
37 #define IBMVFC_ADISC_TIMEOUT 15
38 #define IBMVFC_ADISC_PLUS_CANCEL_TIMEOUT \
39  (IBMVFC_ADISC_TIMEOUT + IBMVFC_ADISC_CANCEL_TIMEOUT)
40 #define IBMVFC_INIT_TIMEOUT 120
41 #define IBMVFC_ABORT_TIMEOUT 8
42 #define IBMVFC_ABORT_WAIT_TIMEOUT 40
43 #define IBMVFC_MAX_REQUESTS_DEFAULT 100
44 
45 #define IBMVFC_DEBUG 0
46 #define IBMVFC_MAX_TARGETS 1024
47 #define IBMVFC_MAX_LUN 0xffffffff
48 #define IBMVFC_MAX_SECTORS 0xffffu
49 #define IBMVFC_MAX_DISC_THREADS 4
50 #define IBMVFC_TGT_MEMPOOL_SZ 64
51 #define IBMVFC_MAX_CMDS_PER_LUN 64
52 #define IBMVFC_MAX_HOST_INIT_RETRIES 6
53 #define IBMVFC_MAX_TGT_INIT_RETRIES 3
54 #define IBMVFC_DEV_LOSS_TMO (5 * 60)
55 #define IBMVFC_DEFAULT_LOG_LEVEL 2
56 #define IBMVFC_MAX_CDB_LEN 16
57 
58 /*
59  * Ensure we have resources for ERP and initialization:
60  * 1 for ERP
61  * 1 for initialization
62  * 1 for NPIV Logout
63  * 2 for BSG passthru
64  * 2 for each discovery thread
65  */
66 #define IBMVFC_NUM_INTERNAL_REQ (1 + 1 + 1 + 2 + (disc_threads * 2))
67 
68 #define IBMVFC_MAD_SUCCESS 0x00
69 #define IBMVFC_MAD_NOT_SUPPORTED 0xF1
70 #define IBMVFC_MAD_FAILED 0xF7
71 #define IBMVFC_MAD_DRIVER_FAILED 0xEE
72 #define IBMVFC_MAD_CRQ_ERROR 0xEF
73 
78 };
79 
84 };
85 
93 };
94 
99  IBMVFC_ENETDOWN = 0x0004,
110 };
111 
123 };
124 
132  IBMVFC_PASSTHRU = 0x0200,
133  IBMVFC_TMF_MAD = 0x0100,
135 };
136 
144 }__attribute__((packed, aligned (8)));
149 }__attribute__((packed, aligned (8)));
153 }__attribute__((packed, aligned (8)));
154 
155 #define IBMVFC_MAX_NAME 256
156 
159 #define IBMVFC_OS_LINUX 0x02
168 #define IBMVFC_CLIENT_MIGRATED 0x01
169 #define IBMVFC_FLUSH_ON_HALT 0x02
172 #define IBMVFC_CAN_MIGRATE 0x01
179 }__attribute__((packed, aligned (8)));
185  u16 bb_rcv_sz; /* upper nibble is BB_SC_N */
188 }__attribute__((packed, aligned (4)));
203 }__attribute__((packed, aligned (4)));
204 
210 #define IBMVFC_NATIVE_FC 0x01
211 #define IBMVFC_CAN_FLUSH_ON_HALT 0x08
214 #define IBMVFC_CAN_FLUSH_ON_HALT 0x08
228 }__attribute__((packed, aligned (8)));
229 
233 }__attribute__((packed, aligned (8)));
237 #define IBMVFC_DISC_TGT_SCSI_ID_MASK 0x00ffffff
238 };
250 }__attribute__((packed, aligned (8)));
251 
264 };
265 
273 };
274 
277 };
278 
287  u16 error; /* also fc_reason */
294 }__attribute__((packed, aligned (8)));
295 
298 #define IBMVFC_SCSI_FCP_TYPE 0x08
301 #define IBMVFC_PRLI_ORIG_PA_VALID 0x8000
302 #define IBMVFC_PRLI_RESP_PA_VALID 0x4000
303 #define IBMVFC_PRLI_EST_IMG_PAIR 0x2000
307 #define IBMVFC_PRLI_TASK_RETRY 0x00000200
308 #define IBMVFC_PRLI_RETRY 0x00000100
309 #define IBMVFC_PRLI_DATA_OVERLAY 0x00000040
310 #define IBMVFC_PRLI_INITIATOR_FUNC 0x00000020
311 #define IBMVFC_PRLI_TARGET_FUNC 0x00000010
312 #define IBMVFC_PRLI_READ_FCP_XFER_RDY_DISABLED 0x00000002
313 #define IBMVFC_PRLI_WR_FCP_XFER_RDY_DISABLED 0x00000001
314 }__attribute__((packed, aligned (4)));
322  u16 error; /* also fc_reason */
325 }__attribute__((packed, aligned (8)));
336 }__attribute__((packed, aligned (8)));
337 
342 }__attribute__((packed, aligned (8)));
343 
344 struct ibmvfc_tmf {
347  struct scsi_lun lun;
349 #define IBMVFC_TMF_ABORT_TASK 0x02
350 #define IBMVFC_TMF_ABORT_TASK_SET 0x04
351 #define IBMVFC_TMF_LUN_RESET 0x10
352 #define IBMVFC_TMF_TGT_RESET 0x20
353 #define IBMVFC_TMF_LUA_VALID 0x40
358 }__attribute__((packed, aligned (8)));
359 
365 };
371 }__attribute__((packed, aligned (2)));
372 
374  FCP_BIDI_RSP = 0x80,
377  FCP_CONF_REQ = 0x10,
382 };
383 
387 }__attribute__((packed, aligned (8)));
398 }__attribute__((packed, aligned (8)));
399 
403  IBMVFC_READ = 0x0004,
404  IBMVFC_WRITE = 0x0008,
405  IBMVFC_TMF = 0x0080,
407 };
408 
414 };
415 
420 };
421 
423  struct scsi_lun lun;
428 #define IBMVFC_RDDATA 0x02
429 #define IBMVFC_WRDATA 0x01
432 }__attribute__((packed, aligned (4)));
433 
434 struct ibmvfc_cmd {
444 #define IBMVFC_ADAPTER_RESID_VALID 0x01
456 }__attribute__((packed, aligned (8)));
460 #define IBMVFC_ADISC 0x52000000
462 };
463 
471 #define IBMVFC_FC_ELS 0x01
472 #define IBMVFC_FC_CT_IU 0x02
474 #define IBMVFC_PASSTHRU_CANCEL_KEY 0x80000000
475 #define IBMVFC_INTERNAL_CANCEL_KEY 0x80000001
483 }__attribute__((packed, aligned (8)));
484 
490 }__attribute__((packed, aligned (8)));
494 }__attribute__((packed));
495 
503 }__attribute__((packed));
504 
506  struct ibmvfc_event *evt;
514 #define IBMVFC_TRC_START 0x00
515 #define IBMVFC_TRC_END 0xff
516  union {
519  } u;
520 }__attribute__((packed, aligned (8)));
526 };
527 
539  IBMVFC_AE_HALT = 0x0400,
542 };
543 
545  const char *desc;
548 };
549 
550 struct ibmvfc_crq {
551  volatile u8 valid;
552  volatile u8 format;
554  volatile u64 ioba;
555 }__attribute__((packed, aligned (8)));
558  struct ibmvfc_crq *msgs;
559  int size, cur;
561 };
562 
568 };
569 
571  volatile u8 valid;
573  u8 pad[2];
575  volatile u64 event;
576  volatile u64 scsi_id;
577  volatile u64 wwpn;
578  volatile u64 node_name;
580 }__attribute__((packed, aligned (8)));
581 
584  int size, cur;
586 };
587 
588 union ibmvfc_iu {
597  struct ibmvfc_tmf tmf;
598  struct ibmvfc_cmd cmd;
600 }__attribute__((packed, aligned (8)));
608 };
611  struct list_head queue;
615  struct fc_rport *rport;
626  void (*job_step) (struct ibmvfc_target *);
628  struct kref kref;
629 };
630 
631 /* a unit of work for the hosting partition */
632 struct ibmvfc_event {
633  struct list_head queue;
636  struct scsi_cmnd *cmnd;
639  void (*done) (struct ibmvfc_event *);
640  struct ibmvfc_crq crq;
641  union ibmvfc_iu iu;
645  struct completion comp;
648 };
649 
650 /* a pool of event structs for use */
656 };
657 
672 };
673 
682 };
683 
684 struct ibmvfc_host {
685  char name[8];
686  struct list_head queue;
687  struct Scsi_Host *host;
690 #define IBMVFC_NUM_TRACE_INDEX_BITS 8
691 #define IBMVFC_NUM_TRACE_ENTRIES (1 << IBMVFC_NUM_TRACE_INDEX_BITS)
692 #define IBMVFC_TRACE_SIZE (sizeof(struct ibmvfc_trace_entry) * IBMVFC_NUM_TRACE_ENTRIES)
697  struct list_head sent;
698  struct list_head free;
699  struct device *dev;
701  struct dma_pool *sg_pool;
712  int task_set;
717  int reinit;
723 #define IBMVFC_AE_LINKUP 0x0001
724 #define IBMVFC_AE_LINKDOWN 0x0002
725 #define IBMVFC_AE_RSCN 0x0004
727  unsigned int partition_number;
728  char partition_name[97];
729  void (*job_step) (struct ibmvfc_host *);
735 };
736 
737 #define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0)
738 
739 #define tgt_dbg(t, fmt, ...) \
740  DBG_CMD(dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__))
741 
742 #define tgt_info(t, fmt, ...) \
743  dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
744 
745 #define tgt_err(t, fmt, ...) \
746  dev_err((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
747 
748 #define tgt_log(t, level, fmt, ...) \
749  do { \
750  if ((t)->vhost->log_level >= level) \
751  tgt_err(t, fmt, ##__VA_ARGS__); \
752  } while (0)
753 
754 #define ibmvfc_dbg(vhost, ...) \
755  DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__))
756 
757 #define ibmvfc_log(vhost, level, ...) \
758  do { \
759  if ((vhost)->log_level >= level) \
760  dev_err((vhost)->dev, ##__VA_ARGS__); \
761  } while (0)
762 
763 #define ENTER DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Entering %s\n", __func__))
764 #define LEAVE DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Leaving %s\n", __func__))
765 
766 #ifdef CONFIG_SCSI_IBMVFC_TRACE
767 #define ibmvfc_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
768 #define ibmvfc_remove_trace_file(kobj, attr) sysfs_remove_bin_file(kobj, attr)
769 #else
770 #define ibmvfc_create_trace_file(kobj, attr) 0
771 #define ibmvfc_remove_trace_file(kobj, attr) do { } while (0)
772 #endif
773 
774 #endif