Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ib_srpt.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006 - 2009 Mellanox Technology Inc. All rights reserved.
3  * Copyright (C) 2009 - 2010 Bart Van Assche <[email protected]>.
4  *
5  * This software is available to you under a choice of one of two
6  * licenses. You may choose to be licensed under the terms of the GNU
7  * General Public License (GPL) Version 2, available from the file
8  * COPYING in the main directory of this source tree, or the
9  * OpenIB.org BSD license below:
10  *
11  * Redistribution and use in source and binary forms, with or
12  * without modification, are permitted provided that the following
13  * conditions are met:
14  *
15  * - Redistributions of source code must retain the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer.
18  *
19  * - Redistributions in binary form must reproduce the above
20  * copyright notice, this list of conditions and the following
21  * disclaimer in the documentation and/or other materials
22  * provided with the distribution.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31  * SOFTWARE.
32  *
33  */
34 
35 #ifndef IB_SRPT_H
36 #define IB_SRPT_H
37 
38 #include <linux/types.h>
39 #include <linux/list.h>
40 #include <linux/wait.h>
41 
42 #include <rdma/ib_verbs.h>
43 #include <rdma/ib_sa.h>
44 #include <rdma/ib_cm.h>
45 
46 #include <scsi/srp.h>
47 
48 #include "ib_dm_mad.h"
49 
50 /*
51  * The prefix the ServiceName field must start with in the device management
52  * ServiceEntries attribute pair. See also the SRP specification.
53  */
54 #define SRP_SERVICE_NAME_PREFIX "SRP.T10:"
55 
56 enum {
57  /*
58  * SRP IOControllerProfile attributes for SRP target ports that have
59  * not been defined in <scsi/srp.h>. Source: section B.7, table B.7
60  * in the SRP specification.
61  */
62  SRP_PROTOCOL = 0x0108,
64  SRP_IO_SUBCLASS = 0x609e,
69 
70  /*
71  * srp_login_cmd.req_flags bitmasks. See also table 9 in the SRP
72  * specification.
73  */
74  SRP_MTCH_ACTION = 0x03, /* MULTI-CHANNEL ACTION */
75  SRP_LOSOLNT = 0x10, /* logout solicited notification */
76  SRP_CRSOLNT = 0x20, /* credit request solicited notification */
77  SRP_AESOLNT = 0x40, /* asynchronous event solicited notification */
78 
79  /*
80  * srp_cmd.sol_nt / srp_tsk_mgmt.sol_not bitmasks. See also tables
81  * 18 and 20 in the SRP specification.
82  */
83  SRP_SCSOLNT = 0x02, /* SCSOLNT = successful solicited notification */
84  SRP_UCSOLNT = 0x04, /* UCSOLNT = unsuccessful solicited notification */
85 
86  /*
87  * srp_rsp.sol_not / srp_t_logout.sol_not bitmasks. See also tables
88  * 16 and 22 in the SRP specification.
89  */
90  SRP_SOLNT = 0x01, /* SOLNT = solicited notification */
91 
92  /* See also table 24 in the SRP specification. */
96 
97  /* See also table 21 in the SRP specification. */
101  SRP_CMD_ACA = 0x4,
102 
106 
109 
118 
121  = sizeof(struct srp_cmd)/*48*/
123  + 128 * sizeof(struct srp_direct_buf)/*16*/,
124 
125  MIN_MAX_RSP_SIZE = sizeof(struct srp_rsp)/*36*/ + 4,
126  DEFAULT_MAX_RSP_SIZE = 256, /* leaves 220 bytes for sense data */
127 
129 };
130 
138 };
139 
140 static inline u64 encode_wr_id(u8 opcode, u32 idx)
141 {
142  return ((u64)opcode << 32) | idx;
143 }
144 static inline enum srpt_opcode opcode_from_wr_id(u64 wr_id)
145 {
146  return wr_id >> 32;
147 }
148 static inline u32 idx_from_wr_id(u64 wr_id)
149 {
150  return (u32)wr_id;
151 }
152 
153 struct rdma_iu {
156  struct ib_sge *sge;
158  int mem_id;
159 };
160 
183 };
184 
191 struct srpt_ioctx {
192  void *buf;
195 };
196 
205 };
206 
230  struct srpt_rdma_ch *ch;
231  struct kref kref;
232  struct rdma_iu *rdma_ius;
235  struct scatterlist *sg;
240  struct se_cmd cmd;
243  int sg_cnt;
250 };
251 
268 };
269 
303 struct srpt_rdma_ch {
306  struct ib_cm_id *cm_id;
307  struct ib_qp *qp;
308  struct ib_cq *cq;
309  int rq_size;
312  struct srpt_port *sport;
322  struct ib_wc wc[16];
323  struct list_head list;
325  struct se_session *sess;
329 };
330 
341 };
342 
359 struct srpt_port {
360  struct srpt_device *sdev;
362  bool enabled;
367  union ib_gid gid;
371  struct se_wwn port_wwn;
374 };
375 
394 struct srpt_device {
395  struct ib_device *device;
396  struct ib_pd *pd;
397  struct ib_mr *mr;
398  struct ib_srq *srq;
399  struct ib_cm_id *cm_id;
401  int srq_size;
406  struct srpt_port port[2];
408  struct list_head list;
409 };
410 
420  struct srpt_port *sport;
422  struct list_head list;
423 };
424 
425 /*
426  * SRP-releated SCSI persistent reservation definitions.
427  *
428  * See also SPC4r28, section 7.6.1 (Protocol specific parameters introduction).
429  * See also SPC4r28, section 7.6.4.5 (TransportID for initiator ports using
430  * SCSI over an RDMA interface).
431  */
432 
433 enum {
435 };
436 
441 };
442 
443 #endif /* IB_SRPT_H */