blob: 3f41fc0b57120b88ebee7c5143ca2af3420b9392 [file] [log] [blame]
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301/**
Jayamohan Kallickal255fa9a2011-03-25 14:23:57 -07002 * Copyright (C) 2005 - 2011 Emulex
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05303 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
Jayamohan Kallickal255fa9a2011-03-25 14:23:57 -070010 * Written by: Jayamohan Kallickal (jayamohan.kallickal@emulex.com)
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053011 *
12 * Contact Information:
Jayamohan Kallickal255fa9a2011-03-25 14:23:57 -070013 * linux-drivers@emulex.com
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053014 *
Jayamohan Kallickal255fa9a2011-03-25 14:23:57 -070015 * Emulex
16 * 3333 Susan Street
17 * Costa Mesa, CA 92626
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053018 */
19
20#include <scsi/libiscsi.h>
21#include <scsi/scsi_transport_iscsi.h>
22#include <scsi/scsi_transport.h>
23#include <scsi/scsi_cmnd.h>
24#include <scsi/scsi_device.h>
25#include <scsi/scsi_host.h>
Mike Christie0e438952012-04-03 23:41:51 -050026#include <scsi/scsi_netlink.h>
27#include <net/netlink.h>
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053028#include <scsi/scsi.h>
29
30#include "be_iscsi.h"
31
32extern struct iscsi_transport beiscsi_iscsi_transport;
33
34/**
35 * beiscsi_session_create - creates a new iscsi session
36 * @cmds_max: max commands supported
37 * @qdepth: max queue depth supported
38 * @initial_cmdsn: initial iscsi CMDSN
39 */
40struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep,
41 u16 cmds_max,
42 u16 qdepth,
43 u32 initial_cmdsn)
44{
45 struct Scsi_Host *shost;
46 struct beiscsi_endpoint *beiscsi_ep;
47 struct iscsi_cls_session *cls_session;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053048 struct beiscsi_hba *phba;
Jayamohan Kallickalb8b9e1b82009-09-22 08:21:22 +053049 struct iscsi_session *sess;
50 struct beiscsi_session *beiscsi_sess;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053051 struct beiscsi_io_task *io_task;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053052
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053053
54 if (!ep) {
John Soni Jose99bc5d52012-08-20 23:00:18 +053055 printk(KERN_ERR
56 "beiscsi_session_create: invalid ep\n");
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053057 return NULL;
58 }
59 beiscsi_ep = ep->dd_data;
60 phba = beiscsi_ep->phba;
61 shost = phba->shost;
John Soni Jose99bc5d52012-08-20 23:00:18 +053062
63 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
64 "BS_%d : In beiscsi_session_create\n");
65
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053066 if (cmds_max > beiscsi_ep->phba->params.wrbs_per_cxn) {
John Soni Jose99bc5d52012-08-20 23:00:18 +053067 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
68 "BS_%d : Cannot handle %d cmds."
69 "Max cmds per session supported is %d. Using %d."
70 "\n", cmds_max,
71 beiscsi_ep->phba->params.wrbs_per_cxn,
72 beiscsi_ep->phba->params.wrbs_per_cxn);
73
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053074 cmds_max = beiscsi_ep->phba->params.wrbs_per_cxn;
75 }
76
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +053077 cls_session = iscsi_session_setup(&beiscsi_iscsi_transport,
78 shost, cmds_max,
79 sizeof(*beiscsi_sess),
80 sizeof(*io_task),
81 initial_cmdsn, ISCSI_MAX_TARGET);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053082 if (!cls_session)
83 return NULL;
84 sess = cls_session->dd_data;
Jayamohan Kallickal2afc95b2009-09-22 08:22:26 +053085 beiscsi_sess = sess->dd_data;
86 beiscsi_sess->bhs_pool = pci_pool_create("beiscsi_bhs_pool",
87 phba->pcidev,
88 sizeof(struct be_cmd_bhs),
89 64, 0);
90 if (!beiscsi_sess->bhs_pool)
91 goto destroy_sess;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053092
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053093 return cls_session;
Jayamohan Kallickal2afc95b2009-09-22 08:22:26 +053094destroy_sess:
95 iscsi_session_teardown(cls_session);
96 return NULL;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053097}
98
99/**
100 * beiscsi_session_destroy - destroys iscsi session
101 * @cls_session: pointer to iscsi cls session
102 *
103 * Destroys iSCSI session instance and releases
104 * resources allocated for it.
105 */
106void beiscsi_session_destroy(struct iscsi_cls_session *cls_session)
107{
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530108 struct iscsi_session *sess = cls_session->dd_data;
Jayamohan Kallickal2afc95b2009-09-22 08:22:26 +0530109 struct beiscsi_session *beiscsi_sess = sess->dd_data;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530110
John Soni Jose99bc5d52012-08-20 23:00:18 +0530111 printk(KERN_INFO "In beiscsi_session_destroy\n");
Jayamohan Kallickal2afc95b2009-09-22 08:22:26 +0530112 pci_pool_destroy(beiscsi_sess->bhs_pool);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530113 iscsi_session_teardown(cls_session);
114}
115
116/**
117 * beiscsi_conn_create - create an instance of iscsi connection
118 * @cls_session: ptr to iscsi_cls_session
119 * @cid: iscsi cid
120 */
121struct iscsi_cls_conn *
122beiscsi_conn_create(struct iscsi_cls_session *cls_session, u32 cid)
123{
124 struct beiscsi_hba *phba;
125 struct Scsi_Host *shost;
126 struct iscsi_cls_conn *cls_conn;
127 struct beiscsi_conn *beiscsi_conn;
128 struct iscsi_conn *conn;
Jayamohan Kallickal2afc95b2009-09-22 08:22:26 +0530129 struct iscsi_session *sess;
130 struct beiscsi_session *beiscsi_sess;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530131
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530132 shost = iscsi_session_to_shost(cls_session);
133 phba = iscsi_host_priv(shost);
134
John Soni Jose99bc5d52012-08-20 23:00:18 +0530135 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
136 "BS_%d : In beiscsi_conn_create ,cid"
137 "from iscsi layer=%d\n", cid);
138
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530139 cls_conn = iscsi_conn_setup(cls_session, sizeof(*beiscsi_conn), cid);
140 if (!cls_conn)
141 return NULL;
142
143 conn = cls_conn->dd_data;
144 beiscsi_conn = conn->dd_data;
145 beiscsi_conn->ep = NULL;
146 beiscsi_conn->phba = phba;
147 beiscsi_conn->conn = conn;
Jayamohan Kallickal2afc95b2009-09-22 08:22:26 +0530148 sess = cls_session->dd_data;
149 beiscsi_sess = sess->dd_data;
150 beiscsi_conn->beiscsi_sess = beiscsi_sess;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530151 return cls_conn;
152}
153
154/**
155 * beiscsi_bindconn_cid - Bind the beiscsi_conn with phba connection table
156 * @beiscsi_conn: The pointer to beiscsi_conn structure
157 * @phba: The phba instance
158 * @cid: The cid to free
159 */
160static int beiscsi_bindconn_cid(struct beiscsi_hba *phba,
161 struct beiscsi_conn *beiscsi_conn,
162 unsigned int cid)
163{
164 if (phba->conn_table[cid]) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530165 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
166 "BS_%d : Connection table already occupied. Detected clash\n");
167
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530168 return -EINVAL;
169 } else {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530170 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
171 "BS_%d : phba->conn_table[%d]=%p(beiscsi_conn)\n",
172 cid, beiscsi_conn);
173
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530174 phba->conn_table[cid] = beiscsi_conn;
175 }
176 return 0;
177}
178
179/**
180 * beiscsi_conn_bind - Binds iscsi session/connection with TCP connection
181 * @cls_session: pointer to iscsi cls session
182 * @cls_conn: pointer to iscsi cls conn
183 * @transport_fd: EP handle(64 bit)
184 *
185 * This function binds the TCP Conn with iSCSI Connection and Session.
186 */
187int beiscsi_conn_bind(struct iscsi_cls_session *cls_session,
188 struct iscsi_cls_conn *cls_conn,
189 u64 transport_fd, int is_leading)
190{
191 struct iscsi_conn *conn = cls_conn->dd_data;
192 struct beiscsi_conn *beiscsi_conn = conn->dd_data;
Mike Christie3093b042011-07-25 13:48:46 -0500193 struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
194 struct beiscsi_hba *phba = iscsi_host_priv(shost);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530195 struct beiscsi_endpoint *beiscsi_ep;
196 struct iscsi_endpoint *ep;
197
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530198 ep = iscsi_lookup_endpoint(transport_fd);
199 if (!ep)
200 return -EINVAL;
201
202 beiscsi_ep = ep->dd_data;
203
204 if (iscsi_conn_bind(cls_session, cls_conn, is_leading))
205 return -EINVAL;
206
207 if (beiscsi_ep->phba != phba) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530208 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
209 "BS_%d : beiscsi_ep->hba=%p not equal to phba=%p\n",
210 beiscsi_ep->phba, phba);
211
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530212 return -EEXIST;
213 }
214
215 beiscsi_conn->beiscsi_conn_cid = beiscsi_ep->ep_cid;
216 beiscsi_conn->ep = beiscsi_ep;
217 beiscsi_ep->conn = beiscsi_conn;
John Soni Jose99bc5d52012-08-20 23:00:18 +0530218
219 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
220 "BS_%d : beiscsi_conn=%p conn=%p ep_cid=%d\n",
221 beiscsi_conn, conn, beiscsi_ep->ep_cid);
222
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530223 return beiscsi_bindconn_cid(phba, beiscsi_conn, beiscsi_ep->ep_cid);
224}
225
Mike Christie0e438952012-04-03 23:41:51 -0500226static int beiscsi_create_ipv4_iface(struct beiscsi_hba *phba)
227{
228 if (phba->ipv4_iface)
229 return 0;
230
231 phba->ipv4_iface = iscsi_create_iface(phba->shost,
232 &beiscsi_iscsi_transport,
233 ISCSI_IFACE_TYPE_IPV4,
234 0, 0);
235 if (!phba->ipv4_iface) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530236 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
237 "BS_%d : Could not "
238 "create default IPv4 address.\n");
Mike Christie0e438952012-04-03 23:41:51 -0500239 return -ENODEV;
240 }
241
242 return 0;
243}
244
245static int beiscsi_create_ipv6_iface(struct beiscsi_hba *phba)
246{
247 if (phba->ipv6_iface)
248 return 0;
249
250 phba->ipv6_iface = iscsi_create_iface(phba->shost,
251 &beiscsi_iscsi_transport,
252 ISCSI_IFACE_TYPE_IPV6,
253 0, 0);
254 if (!phba->ipv6_iface) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530255 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
256 "BS_%d : Could not "
257 "create default IPv6 address.\n");
Mike Christie0e438952012-04-03 23:41:51 -0500258 return -ENODEV;
259 }
260
261 return 0;
262}
263
264void beiscsi_create_def_ifaces(struct beiscsi_hba *phba)
265{
266 struct be_cmd_get_if_info_resp if_info;
267
268 if (!mgmt_get_if_info(phba, BE2_IPV4, &if_info))
269 beiscsi_create_ipv4_iface(phba);
270
271 if (!mgmt_get_if_info(phba, BE2_IPV6, &if_info))
272 beiscsi_create_ipv6_iface(phba);
273}
274
275void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba)
276{
277 if (phba->ipv6_iface)
278 iscsi_destroy_iface(phba->ipv6_iface);
279 if (phba->ipv4_iface)
280 iscsi_destroy_iface(phba->ipv4_iface);
281}
282
283static int
284beiscsi_set_static_ip(struct Scsi_Host *shost,
285 struct iscsi_iface_param_info *iface_param,
286 void *data, uint32_t dt_len)
287{
288 struct beiscsi_hba *phba = iscsi_host_priv(shost);
289 struct iscsi_iface_param_info *iface_ip = NULL;
290 struct iscsi_iface_param_info *iface_subnet = NULL;
291 struct nlattr *nla;
292 int ret;
293
294
295 switch (iface_param->param) {
296 case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
297 nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_ADDR);
298 if (nla)
299 iface_ip = nla_data(nla);
300
301 nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_SUBNET);
302 if (nla)
303 iface_subnet = nla_data(nla);
304 break;
305 case ISCSI_NET_PARAM_IPV4_ADDR:
306 iface_ip = iface_param;
307 nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_SUBNET);
308 if (nla)
309 iface_subnet = nla_data(nla);
310 break;
311 case ISCSI_NET_PARAM_IPV4_SUBNET:
312 iface_subnet = iface_param;
313 nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_ADDR);
314 if (nla)
315 iface_ip = nla_data(nla);
316 break;
317 default:
John Soni Jose99bc5d52012-08-20 23:00:18 +0530318 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
319 "BS_%d : Unsupported param %d\n",
320 iface_param->param);
Mike Christie0e438952012-04-03 23:41:51 -0500321 }
322
323 if (!iface_ip || !iface_subnet) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530324 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
325 "BS_%d : IP and Subnet Mask required\n");
Mike Christie0e438952012-04-03 23:41:51 -0500326 return -EINVAL;
327 }
328
329 ret = mgmt_set_ip(phba, iface_ip, iface_subnet,
330 ISCSI_BOOTPROTO_STATIC);
331
332 return ret;
333}
334
John Soni Jose6f722382012-08-20 23:00:43 +0530335/**
336 * beiscsi_set_vlan_tag()- Set the VLAN TAG
337 * @shost: Scsi Host for the driver instance
338 * @iface_param: Interface paramters
339 *
340 * Set the VLAN TAG for the adapter or disable
341 * the VLAN config
342 *
343 * returns
344 * Success: 0
345 * Failure: Non-Zero Value
346 **/
347static int
348beiscsi_set_vlan_tag(struct Scsi_Host *shost,
349 struct iscsi_iface_param_info *iface_param)
350{
351 struct beiscsi_hba *phba = iscsi_host_priv(shost);
352 int ret = 0;
353
354 /* Get the Interface Handle */
355 if (mgmt_get_all_if_id(phba)) {
356 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
357 "BS_%d : Getting Interface Handle Failed\n");
358 return -EIO;
359 }
360
361 switch (iface_param->param) {
362 case ISCSI_NET_PARAM_VLAN_ENABLED:
363 if (iface_param->value[0] != ISCSI_VLAN_ENABLE)
364 ret = mgmt_set_vlan(phba, BEISCSI_VLAN_DISABLE);
365 break;
366 case ISCSI_NET_PARAM_VLAN_TAG:
367 ret = mgmt_set_vlan(phba,
368 *((uint16_t *)iface_param->value));
369 break;
370 default:
371 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
372 "BS_%d : Unkown Param Type : %d\n",
373 iface_param->param);
374 return -ENOSYS;
375 }
376 return ret;
377}
378
379
Mike Christie0e438952012-04-03 23:41:51 -0500380static int
381beiscsi_set_ipv4(struct Scsi_Host *shost,
382 struct iscsi_iface_param_info *iface_param,
383 void *data, uint32_t dt_len)
384{
385 struct beiscsi_hba *phba = iscsi_host_priv(shost);
386 int ret = 0;
387
388 /* Check the param */
389 switch (iface_param->param) {
390 case ISCSI_NET_PARAM_IPV4_GW:
391 ret = mgmt_set_gateway(phba, iface_param);
392 break;
393 case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
394 if (iface_param->value[0] == ISCSI_BOOTPROTO_DHCP)
395 ret = mgmt_set_ip(phba, iface_param,
396 NULL, ISCSI_BOOTPROTO_DHCP);
397 else if (iface_param->value[0] == ISCSI_BOOTPROTO_STATIC)
398 ret = beiscsi_set_static_ip(shost, iface_param,
399 data, dt_len);
400 else
John Soni Jose99bc5d52012-08-20 23:00:18 +0530401 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
402 "BS_%d : Invalid BOOTPROTO: %d\n",
403 iface_param->value[0]);
Mike Christie0e438952012-04-03 23:41:51 -0500404 break;
405 case ISCSI_NET_PARAM_IFACE_ENABLE:
406 if (iface_param->value[0] == ISCSI_IFACE_ENABLE)
407 ret = beiscsi_create_ipv4_iface(phba);
408 else
409 iscsi_destroy_iface(phba->ipv4_iface);
410 break;
411 case ISCSI_NET_PARAM_IPV4_SUBNET:
412 case ISCSI_NET_PARAM_IPV4_ADDR:
413 ret = beiscsi_set_static_ip(shost, iface_param,
414 data, dt_len);
415 break;
John Soni Jose6f722382012-08-20 23:00:43 +0530416 case ISCSI_NET_PARAM_VLAN_ENABLED:
417 case ISCSI_NET_PARAM_VLAN_TAG:
418 ret = beiscsi_set_vlan_tag(shost, iface_param);
419 break;
Mike Christie0e438952012-04-03 23:41:51 -0500420 default:
John Soni Jose99bc5d52012-08-20 23:00:18 +0530421 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
422 "BS_%d : Param %d not supported\n",
423 iface_param->param);
Mike Christie0e438952012-04-03 23:41:51 -0500424 }
425
426 return ret;
427}
428
429static int
430beiscsi_set_ipv6(struct Scsi_Host *shost,
431 struct iscsi_iface_param_info *iface_param,
432 void *data, uint32_t dt_len)
433{
434 struct beiscsi_hba *phba = iscsi_host_priv(shost);
435 int ret = 0;
436
437 switch (iface_param->param) {
438 case ISCSI_NET_PARAM_IFACE_ENABLE:
439 if (iface_param->value[0] == ISCSI_IFACE_ENABLE)
440 ret = beiscsi_create_ipv6_iface(phba);
441 else {
442 iscsi_destroy_iface(phba->ipv6_iface);
443 ret = 0;
444 }
445 break;
446 case ISCSI_NET_PARAM_IPV6_ADDR:
447 ret = mgmt_set_ip(phba, iface_param, NULL,
448 ISCSI_BOOTPROTO_STATIC);
449 break;
450 default:
John Soni Jose99bc5d52012-08-20 23:00:18 +0530451 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
452 "BS_%d : Param %d not supported\n",
453 iface_param->param);
Mike Christie0e438952012-04-03 23:41:51 -0500454 }
455
456 return ret;
457}
458
459int be2iscsi_iface_set_param(struct Scsi_Host *shost,
460 void *data, uint32_t dt_len)
461{
462 struct iscsi_iface_param_info *iface_param = NULL;
John Soni Jose99bc5d52012-08-20 23:00:18 +0530463 struct beiscsi_hba *phba = iscsi_host_priv(shost);
Mike Christie0e438952012-04-03 23:41:51 -0500464 struct nlattr *attrib;
465 uint32_t rm_len = dt_len;
466 int ret = 0 ;
467
468 nla_for_each_attr(attrib, data, dt_len, rm_len) {
469 iface_param = nla_data(attrib);
470
471 if (iface_param->param_type != ISCSI_NET_PARAM)
472 continue;
473
474 /*
475 * BE2ISCSI only supports 1 interface
476 */
477 if (iface_param->iface_num) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530478 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
479 "BS_%d : Invalid iface_num %d."
480 "Only iface_num 0 is supported.\n",
481 iface_param->iface_num);
482
Mike Christie0e438952012-04-03 23:41:51 -0500483 return -EINVAL;
484 }
485
486 switch (iface_param->iface_type) {
487 case ISCSI_IFACE_TYPE_IPV4:
488 ret = beiscsi_set_ipv4(shost, iface_param,
489 data, dt_len);
490 break;
491 case ISCSI_IFACE_TYPE_IPV6:
492 ret = beiscsi_set_ipv6(shost, iface_param,
493 data, dt_len);
494 break;
495 default:
John Soni Jose99bc5d52012-08-20 23:00:18 +0530496 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
497 "BS_%d : Invalid iface type :%d passed\n",
498 iface_param->iface_type);
Mike Christie0e438952012-04-03 23:41:51 -0500499 break;
500 }
501
502 if (ret)
503 return ret;
504 }
505
506 return ret;
507}
508
509static int be2iscsi_get_if_param(struct beiscsi_hba *phba,
510 struct iscsi_iface *iface, int param,
511 char *buf)
512{
513 struct be_cmd_get_if_info_resp if_info;
514 int len, ip_type = BE2_IPV4;
515
516 memset(&if_info, 0, sizeof(if_info));
517
518 if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6)
519 ip_type = BE2_IPV6;
520
521 len = mgmt_get_if_info(phba, ip_type, &if_info);
522 if (len)
523 return len;
524
525 switch (param) {
526 case ISCSI_NET_PARAM_IPV4_ADDR:
527 len = sprintf(buf, "%pI4\n", &if_info.ip_addr.addr);
528 break;
529 case ISCSI_NET_PARAM_IPV6_ADDR:
530 len = sprintf(buf, "%pI6\n", &if_info.ip_addr.addr);
531 break;
532 case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
533 if (!if_info.dhcp_state)
John Soni Jose8359c792012-10-20 04:43:03 +0530534 len = sprintf(buf, "static\n");
Mike Christie0e438952012-04-03 23:41:51 -0500535 else
John Soni Jose8359c792012-10-20 04:43:03 +0530536 len = sprintf(buf, "dhcp\n");
Mike Christie0e438952012-04-03 23:41:51 -0500537 break;
538 case ISCSI_NET_PARAM_IPV4_SUBNET:
539 len = sprintf(buf, "%pI4\n", &if_info.ip_addr.subnet_mask);
540 break;
John Soni Jose6f722382012-08-20 23:00:43 +0530541 case ISCSI_NET_PARAM_VLAN_ENABLED:
542 len = sprintf(buf, "%s\n",
543 (if_info.vlan_priority == BEISCSI_VLAN_DISABLE)
John Soni Jose8359c792012-10-20 04:43:03 +0530544 ? "Disabled\n" : "Enabled\n");
John Soni Jose6f722382012-08-20 23:00:43 +0530545 break;
546 case ISCSI_NET_PARAM_VLAN_ID:
547 if (if_info.vlan_priority == BEISCSI_VLAN_DISABLE)
548 return -EINVAL;
549 else
550 len = sprintf(buf, "%d\n",
551 (if_info.vlan_priority &
552 ISCSI_MAX_VLAN_ID));
553 break;
554 case ISCSI_NET_PARAM_VLAN_PRIORITY:
555 if (if_info.vlan_priority == BEISCSI_VLAN_DISABLE)
556 return -EINVAL;
557 else
558 len = sprintf(buf, "%d\n",
559 ((if_info.vlan_priority >> 13) &
560 ISCSI_MAX_VLAN_PRIORITY));
561 break;
Mike Christie0e438952012-04-03 23:41:51 -0500562 default:
563 WARN_ON(1);
564 }
565
566 return len;
567}
568
569int be2iscsi_iface_get_param(struct iscsi_iface *iface,
570 enum iscsi_param_type param_type,
571 int param, char *buf)
572{
573 struct Scsi_Host *shost = iscsi_iface_to_shost(iface);
574 struct beiscsi_hba *phba = iscsi_host_priv(shost);
575 struct be_cmd_get_def_gateway_resp gateway;
576 int len = -ENOSYS;
577
578 switch (param) {
579 case ISCSI_NET_PARAM_IPV4_ADDR:
580 case ISCSI_NET_PARAM_IPV4_SUBNET:
581 case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
582 case ISCSI_NET_PARAM_IPV6_ADDR:
John Soni Jose6f722382012-08-20 23:00:43 +0530583 case ISCSI_NET_PARAM_VLAN_ENABLED:
584 case ISCSI_NET_PARAM_VLAN_ID:
585 case ISCSI_NET_PARAM_VLAN_PRIORITY:
Mike Christie0e438952012-04-03 23:41:51 -0500586 len = be2iscsi_get_if_param(phba, iface, param, buf);
587 break;
588 case ISCSI_NET_PARAM_IFACE_ENABLE:
John Soni Jose8359c792012-10-20 04:43:03 +0530589 len = sprintf(buf, "enabled\n");
Mike Christie0e438952012-04-03 23:41:51 -0500590 break;
591 case ISCSI_NET_PARAM_IPV4_GW:
592 memset(&gateway, 0, sizeof(gateway));
593 len = mgmt_get_gateway(phba, BE2_IPV4, &gateway);
594 if (!len)
595 len = sprintf(buf, "%pI4\n", &gateway.ip_addr.addr);
596 break;
597 default:
598 len = -ENOSYS;
599 }
600
601 return len;
602}
603
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530604/**
Mike Christiec7f7fd52011-02-16 15:04:41 -0600605 * beiscsi_ep_get_param - get the iscsi parameter
606 * @ep: pointer to iscsi ep
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530607 * @param: parameter type identifier
608 * @buf: buffer pointer
609 *
610 * returns iscsi parameter
611 */
Mike Christiec7f7fd52011-02-16 15:04:41 -0600612int beiscsi_ep_get_param(struct iscsi_endpoint *ep,
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530613 enum iscsi_param param, char *buf)
614{
Mike Christiec7f7fd52011-02-16 15:04:41 -0600615 struct beiscsi_endpoint *beiscsi_ep = ep->dd_data;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530616 int len = 0;
617
John Soni Jose99bc5d52012-08-20 23:00:18 +0530618 beiscsi_log(beiscsi_ep->phba, KERN_INFO,
619 BEISCSI_LOG_CONFIG,
620 "BS_%d : In beiscsi_ep_get_param,"
621 " param= %d\n", param);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530622
623 switch (param) {
624 case ISCSI_PARAM_CONN_PORT:
625 len = sprintf(buf, "%hu\n", beiscsi_ep->dst_tcpport);
626 break;
627 case ISCSI_PARAM_CONN_ADDRESS:
628 if (beiscsi_ep->ip_type == BE2_IPV4)
629 len = sprintf(buf, "%pI4\n", &beiscsi_ep->dst_addr);
630 else
631 len = sprintf(buf, "%pI6\n", &beiscsi_ep->dst6_addr);
632 break;
633 default:
Mike Christiec7f7fd52011-02-16 15:04:41 -0600634 return -ENOSYS;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530635 }
636 return len;
637}
638
639int beiscsi_set_param(struct iscsi_cls_conn *cls_conn,
640 enum iscsi_param param, char *buf, int buflen)
641{
642 struct iscsi_conn *conn = cls_conn->dd_data;
643 struct iscsi_session *session = conn->session;
John Soni Jose99bc5d52012-08-20 23:00:18 +0530644 struct beiscsi_hba *phba = NULL;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530645 int ret;
646
John Soni Jose99bc5d52012-08-20 23:00:18 +0530647 phba = ((struct beiscsi_conn *)conn->dd_data)->phba;
648 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
649 "BS_%d : In beiscsi_conn_set_param,"
650 " param= %d\n", param);
651
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530652 ret = iscsi_set_param(cls_conn, param, buf, buflen);
653 if (ret)
654 return ret;
655 /*
656 * If userspace tried to set the value to higher than we can
657 * support override here.
658 */
659 switch (param) {
660 case ISCSI_PARAM_FIRST_BURST:
661 if (session->first_burst > 8192)
662 session->first_burst = 8192;
663 break;
664 case ISCSI_PARAM_MAX_RECV_DLENGTH:
665 if (conn->max_recv_dlength > 65536)
666 conn->max_recv_dlength = 65536;
667 break;
668 case ISCSI_PARAM_MAX_BURST:
Jayamohan Kallickal230dceb2010-01-23 05:36:10 +0530669 if (session->max_burst > 262144)
670 session->max_burst = 262144;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530671 break;
Jayamohan Kallickal42f43c42010-07-22 04:26:45 +0530672 case ISCSI_PARAM_MAX_XMIT_DLENGTH:
673 if ((conn->max_xmit_dlength > 65536) ||
674 (conn->max_xmit_dlength == 0))
675 conn->max_xmit_dlength = 65536;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530676 default:
677 return 0;
678 }
679
680 return 0;
681}
682
683/**
John Soni Jose21771992012-04-03 23:41:49 -0500684 * beiscsi_get_initname - Read Initiator Name from flash
685 * @buf: buffer bointer
686 * @phba: The device priv structure instance
687 *
688 * returns number of bytes
689 */
690static int beiscsi_get_initname(char *buf, struct beiscsi_hba *phba)
691{
692 int rc;
693 unsigned int tag, wrb_num;
694 unsigned short status, extd_status;
695 struct be_mcc_wrb *wrb;
696 struct be_cmd_hba_name *resp;
697 struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
698
699 tag = be_cmd_get_initname(phba);
700 if (!tag) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530701 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
702 "BS_%d : Getting Initiator Name Failed\n");
703
John Soni Jose21771992012-04-03 23:41:49 -0500704 return -EBUSY;
705 } else
706 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
707 phba->ctrl.mcc_numtag[tag]);
708
709 wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16;
710 extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8;
711 status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
712
713 if (status || extd_status) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530714 beiscsi_log(phba, KERN_ERR,
715 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
716 "BS_%d : MailBox Command Failed with "
717 "status = %d extd_status = %d\n",
718 status, extd_status);
719
John Soni Jose21771992012-04-03 23:41:49 -0500720 free_mcc_tag(&phba->ctrl, tag);
721 return -EAGAIN;
722 }
723 wrb = queue_get_wrb(mccq, wrb_num);
724 free_mcc_tag(&phba->ctrl, tag);
725 resp = embedded_payload(wrb);
726 rc = sprintf(buf, "%s\n", resp->initiator_name);
727 return rc;
728}
729
730/**
John Soni Josec62eef02012-04-03 23:41:52 -0500731 * beiscsi_get_port_state - Get the Port State
732 * @shost : pointer to scsi_host structure
733 *
John Soni Josec62eef02012-04-03 23:41:52 -0500734 */
735static void beiscsi_get_port_state(struct Scsi_Host *shost)
736{
737 struct beiscsi_hba *phba = iscsi_host_priv(shost);
738 struct iscsi_cls_host *ihost = shost->shost_data;
739
740 ihost->port_state = (phba->state == BE_ADAPTER_UP) ?
741 ISCSI_PORT_STATE_UP : ISCSI_PORT_STATE_DOWN;
742}
743
744/**
745 * beiscsi_get_port_speed - Get the Port Speed from Adapter
746 * @shost : pointer to scsi_host structure
747 *
748 * returns Success/Failure
749 */
750static int beiscsi_get_port_speed(struct Scsi_Host *shost)
751{
752 unsigned int tag, wrb_num;
753 unsigned short status, extd_status;
754 struct be_mcc_wrb *wrb;
755 struct be_cmd_ntwk_link_status_resp *resp;
756 struct beiscsi_hba *phba = iscsi_host_priv(shost);
757 struct iscsi_cls_host *ihost = shost->shost_data;
758 struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
759
760 tag = be_cmd_get_port_speed(phba);
761 if (!tag) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530762 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
763 "BS_%d : Getting Port Speed Failed\n");
764
John Soni Josec62eef02012-04-03 23:41:52 -0500765 return -EBUSY;
766 } else
767 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
768 phba->ctrl.mcc_numtag[tag]);
769
770 wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16;
771 extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8;
772 status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
773
774 if (status || extd_status) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530775 beiscsi_log(phba, KERN_ERR,
776 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
777 "BS_%d : MailBox Command Failed with "
778 "status = %d extd_status = %d\n",
779 status, extd_status);
780
John Soni Josec62eef02012-04-03 23:41:52 -0500781 free_mcc_tag(&phba->ctrl, tag);
782 return -EAGAIN;
783 }
784 wrb = queue_get_wrb(mccq, wrb_num);
785 free_mcc_tag(&phba->ctrl, tag);
786 resp = embedded_payload(wrb);
787
788 switch (resp->mac_speed) {
789 case BE2ISCSI_LINK_SPEED_10MBPS:
790 ihost->port_speed = ISCSI_PORT_SPEED_10MBPS;
791 break;
792 case BE2ISCSI_LINK_SPEED_100MBPS:
793 ihost->port_speed = BE2ISCSI_LINK_SPEED_100MBPS;
794 break;
795 case BE2ISCSI_LINK_SPEED_1GBPS:
796 ihost->port_speed = ISCSI_PORT_SPEED_1GBPS;
797 break;
798 case BE2ISCSI_LINK_SPEED_10GBPS:
799 ihost->port_speed = ISCSI_PORT_SPEED_10GBPS;
800 break;
801 default:
802 ihost->port_speed = ISCSI_PORT_SPEED_UNKNOWN;
803 }
804 return 0;
805}
806
807/**
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530808 * beiscsi_get_host_param - get the iscsi parameter
809 * @shost: pointer to scsi_host structure
810 * @param: parameter type identifier
811 * @buf: buffer pointer
812 *
813 * returns host parameter
814 */
815int beiscsi_get_host_param(struct Scsi_Host *shost,
816 enum iscsi_host_param param, char *buf)
817{
Mike Christie3093b042011-07-25 13:48:46 -0500818 struct beiscsi_hba *phba = iscsi_host_priv(shost);
Jayamohan Kallickalb15d05b2010-08-12 23:36:06 +0530819 int status = 0;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530820
John Soni Jose99bc5d52012-08-20 23:00:18 +0530821 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
822 "BS_%d : In beiscsi_get_host_param,"
823 " param= %d\n", param);
824
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530825 switch (param) {
826 case ISCSI_HOST_PARAM_HWADDRESS:
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530827 status = beiscsi_get_macaddr(buf, phba);
828 if (status < 0) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530829 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
830 "BS_%d : beiscsi_get_macaddr Failed\n");
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530831 return status;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530832 }
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530833 break;
John Soni Jose21771992012-04-03 23:41:49 -0500834 case ISCSI_HOST_PARAM_INITIATOR_NAME:
835 status = beiscsi_get_initname(buf, phba);
836 if (status < 0) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530837 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
838 "BS_%d : Retreiving Initiator Name Failed\n");
John Soni Jose21771992012-04-03 23:41:49 -0500839 return status;
840 }
841 break;
John Soni Josec62eef02012-04-03 23:41:52 -0500842 case ISCSI_HOST_PARAM_PORT_STATE:
843 beiscsi_get_port_state(shost);
844 status = sprintf(buf, "%s\n", iscsi_get_port_state_name(shost));
845 break;
846 case ISCSI_HOST_PARAM_PORT_SPEED:
847 status = beiscsi_get_port_speed(shost);
848 if (status) {
John Soni Jose99bc5d52012-08-20 23:00:18 +0530849 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
850 "BS_%d : Retreiving Port Speed Failed\n");
John Soni Josec62eef02012-04-03 23:41:52 -0500851 return status;
852 }
853 status = sprintf(buf, "%s\n", iscsi_get_port_speed_name(shost));
854 break;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530855 default:
856 return iscsi_host_get_param(shost, param, buf);
857 }
Jayamohan Kallickalb15d05b2010-08-12 23:36:06 +0530858 return status;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530859}
860
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530861int beiscsi_get_macaddr(char *buf, struct beiscsi_hba *phba)
862{
Mike Christie0e438952012-04-03 23:41:51 -0500863 struct be_cmd_get_nic_conf_resp resp;
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530864 int rc;
865
Mike Christie0e438952012-04-03 23:41:51 -0500866 if (strlen(phba->mac_address))
John Soni Josedf5d0e62012-08-20 23:00:31 +0530867 return sysfs_format_mac(buf, phba->mac_address, ETH_ALEN);
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530868
Mike Christie0e438952012-04-03 23:41:51 -0500869 memset(&resp, 0, sizeof(resp));
870 rc = mgmt_get_nic_conf(phba, &resp);
871 if (rc)
872 return rc;
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530873
Mike Christie0e438952012-04-03 23:41:51 -0500874 memcpy(phba->mac_address, resp.mac_address, ETH_ALEN);
875 return sysfs_format_mac(buf, phba->mac_address, ETH_ALEN);
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530876}
877
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530878/**
879 * beiscsi_conn_get_stats - get the iscsi stats
880 * @cls_conn: pointer to iscsi cls conn
881 * @stats: pointer to iscsi_stats structure
882 *
883 * returns iscsi stats
884 */
885void beiscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn,
886 struct iscsi_stats *stats)
887{
888 struct iscsi_conn *conn = cls_conn->dd_data;
John Soni Jose99bc5d52012-08-20 23:00:18 +0530889 struct beiscsi_hba *phba = NULL;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530890
John Soni Jose99bc5d52012-08-20 23:00:18 +0530891 phba = ((struct beiscsi_conn *)conn->dd_data)->phba;
892 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
893 "BS_%d : In beiscsi_conn_get_stats\n");
894
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530895 stats->txdata_octets = conn->txdata_octets;
896 stats->rxdata_octets = conn->rxdata_octets;
897 stats->dataout_pdus = conn->dataout_pdus_cnt;
898 stats->scsirsp_pdus = conn->scsirsp_pdus_cnt;
899 stats->scsicmd_pdus = conn->scsicmd_pdus_cnt;
900 stats->datain_pdus = conn->datain_pdus_cnt;
901 stats->tmfrsp_pdus = conn->tmfrsp_pdus_cnt;
902 stats->tmfcmd_pdus = conn->tmfcmd_pdus_cnt;
903 stats->r2t_pdus = conn->r2t_pdus_cnt;
904 stats->digest_err = 0;
905 stats->timeout_err = 0;
906 stats->custom_length = 0;
907 strcpy(stats->custom[0].desc, "eh_abort_cnt");
908 stats->custom[0].value = conn->eh_abort_cnt;
909}
910
911/**
912 * beiscsi_set_params_for_offld - get the parameters for offload
913 * @beiscsi_conn: pointer to beiscsi_conn
914 * @params: pointer to offload_params structure
915 */
916static void beiscsi_set_params_for_offld(struct beiscsi_conn *beiscsi_conn,
917 struct beiscsi_offload_params *params)
918{
919 struct iscsi_conn *conn = beiscsi_conn->conn;
920 struct iscsi_session *session = conn->session;
921
922 AMAP_SET_BITS(struct amap_beiscsi_offload_params, max_burst_length,
923 params, session->max_burst);
924 AMAP_SET_BITS(struct amap_beiscsi_offload_params,
925 max_send_data_segment_length, params,
926 conn->max_xmit_dlength);
927 AMAP_SET_BITS(struct amap_beiscsi_offload_params, first_burst_length,
928 params, session->first_burst);
929 AMAP_SET_BITS(struct amap_beiscsi_offload_params, erl, params,
930 session->erl);
931 AMAP_SET_BITS(struct amap_beiscsi_offload_params, dde, params,
932 conn->datadgst_en);
933 AMAP_SET_BITS(struct amap_beiscsi_offload_params, hde, params,
934 conn->hdrdgst_en);
935 AMAP_SET_BITS(struct amap_beiscsi_offload_params, ir2t, params,
936 session->initial_r2t_en);
937 AMAP_SET_BITS(struct amap_beiscsi_offload_params, imd, params,
938 session->imm_data_en);
939 AMAP_SET_BITS(struct amap_beiscsi_offload_params, exp_statsn, params,
940 (conn->exp_statsn - 1));
941}
942
943/**
944 * beiscsi_conn_start - offload of session to chip
945 * @cls_conn: pointer to beiscsi_conn
946 */
947int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn)
948{
949 struct iscsi_conn *conn = cls_conn->dd_data;
950 struct beiscsi_conn *beiscsi_conn = conn->dd_data;
951 struct beiscsi_endpoint *beiscsi_ep;
952 struct beiscsi_offload_params params;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530953
John Soni Jose99bc5d52012-08-20 23:00:18 +0530954 beiscsi_log(beiscsi_conn->phba, KERN_INFO,
955 BEISCSI_LOG_CONFIG,
956 "BS_%d : In beiscsi_conn_start\n");
957
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530958 memset(&params, 0, sizeof(struct beiscsi_offload_params));
959 beiscsi_ep = beiscsi_conn->ep;
960 if (!beiscsi_ep)
John Soni Jose99bc5d52012-08-20 23:00:18 +0530961 beiscsi_log(beiscsi_conn->phba, KERN_ERR,
962 BEISCSI_LOG_CONFIG,
963 "BS_%d : In beiscsi_conn_start , no beiscsi_ep\n");
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530964
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530965 beiscsi_conn->login_in_progress = 0;
966 beiscsi_set_params_for_offld(beiscsi_conn, &params);
967 beiscsi_offload_connection(beiscsi_conn, &params);
968 iscsi_conn_start(cls_conn);
969 return 0;
970}
971
972/**
973 * beiscsi_get_cid - Allocate a cid
974 * @phba: The phba instance
975 */
976static int beiscsi_get_cid(struct beiscsi_hba *phba)
977{
978 unsigned short cid = 0xFFFF;
979
980 if (!phba->avlbl_cids)
981 return cid;
982
983 cid = phba->cid_array[phba->cid_alloc++];
984 if (phba->cid_alloc == phba->params.cxns_per_ctrl)
985 phba->cid_alloc = 0;
986 phba->avlbl_cids--;
987 return cid;
988}
989
990/**
Mike Christiefa95d202010-06-09 03:30:08 -0500991 * beiscsi_put_cid - Free the cid
992 * @phba: The phba for which the cid is being freed
993 * @cid: The cid to free
994 */
995static void beiscsi_put_cid(struct beiscsi_hba *phba, unsigned short cid)
996{
997 phba->avlbl_cids++;
998 phba->cid_array[phba->cid_free++] = cid;
999 if (phba->cid_free == phba->params.cxns_per_ctrl)
1000 phba->cid_free = 0;
1001}
1002
1003/**
1004 * beiscsi_free_ep - free endpoint
1005 * @ep: pointer to iscsi endpoint structure
1006 */
1007static void beiscsi_free_ep(struct beiscsi_endpoint *beiscsi_ep)
1008{
1009 struct beiscsi_hba *phba = beiscsi_ep->phba;
1010
1011 beiscsi_put_cid(phba, beiscsi_ep->ep_cid);
1012 beiscsi_ep->phba = NULL;
1013}
1014
1015/**
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301016 * beiscsi_open_conn - Ask FW to open a TCP connection
1017 * @ep: endpoint to be used
1018 * @src_addr: The source IP address
1019 * @dst_addr: The Destination IP address
1020 *
1021 * Asks the FW to open a TCP connection
1022 */
1023static int beiscsi_open_conn(struct iscsi_endpoint *ep,
1024 struct sockaddr *src_addr,
1025 struct sockaddr *dst_addr, int non_blocking)
1026{
1027 struct beiscsi_endpoint *beiscsi_ep = ep->dd_data;
1028 struct beiscsi_hba *phba = beiscsi_ep->phba;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301029 struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
1030 struct be_mcc_wrb *wrb;
1031 struct tcp_connect_and_offload_out *ptcpcnct_out;
1032 unsigned short status, extd_status;
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +05301033 struct be_dma_mem nonemb_cmd;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301034 unsigned int tag, wrb_num;
Jayamohan Kallickald3ad2bb2010-07-22 04:16:38 +05301035 int ret = -ENOMEM;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301036
John Soni Jose99bc5d52012-08-20 23:00:18 +05301037 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
1038 "BS_%d : In beiscsi_open_conn\n");
1039
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301040 beiscsi_ep->ep_cid = beiscsi_get_cid(phba);
1041 if (beiscsi_ep->ep_cid == 0xFFFF) {
John Soni Jose99bc5d52012-08-20 23:00:18 +05301042 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
1043 "BS_%d : No free cid available\n");
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301044 return ret;
1045 }
John Soni Jose99bc5d52012-08-20 23:00:18 +05301046
1047 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
1048 "BS_%d : In beiscsi_open_conn, ep_cid=%d\n",
1049 beiscsi_ep->ep_cid);
1050
Jayamohan Kallickal7da50872010-01-05 05:04:12 +05301051 phba->ep_array[beiscsi_ep->ep_cid -
1052 phba->fw_config.iscsi_cid_start] = ep;
1053 if (beiscsi_ep->ep_cid > (phba->fw_config.iscsi_cid_start +
1054 phba->params.cxns_per_ctrl * 2)) {
John Soni Jose99bc5d52012-08-20 23:00:18 +05301055
1056 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
1057 "BS_%d : Failed in allocate iscsi cid\n");
Mike Christiefa95d202010-06-09 03:30:08 -05001058 goto free_ep;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301059 }
1060
1061 beiscsi_ep->cid_vld = 0;
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +05301062 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
1063 sizeof(struct tcp_connect_and_offload_in),
1064 &nonemb_cmd.dma);
1065 if (nonemb_cmd.va == NULL) {
John Soni Jose99bc5d52012-08-20 23:00:18 +05301066
1067 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
1068 "BS_%d : Failed to allocate memory for"
1069 " mgmt_open_connection\n");
1070
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +05301071 beiscsi_put_cid(phba, beiscsi_ep->ep_cid);
1072 return -ENOMEM;
1073 }
1074 nonemb_cmd.size = sizeof(struct tcp_connect_and_offload_in);
1075 memset(nonemb_cmd.va, 0, nonemb_cmd.size);
1076 tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep, &nonemb_cmd);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301077 if (!tag) {
John Soni Jose99bc5d52012-08-20 23:00:18 +05301078 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
1079 "BS_%d : mgmt_open_connection Failed for cid=%d\n",
1080 beiscsi_ep->ep_cid);
1081
Jayamohan Kallickal1f926382010-07-22 04:22:27 +05301082 beiscsi_put_cid(phba, beiscsi_ep->ep_cid);
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +05301083 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
1084 nonemb_cmd.va, nonemb_cmd.dma);
Jayamohan Kallickal1f926382010-07-22 04:22:27 +05301085 return -EAGAIN;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301086 } else {
1087 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
1088 phba->ctrl.mcc_numtag[tag]);
1089 }
1090 wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16;
1091 extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8;
1092 status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
1093 if (status || extd_status) {
John Soni Jose99bc5d52012-08-20 23:00:18 +05301094 beiscsi_log(phba, KERN_ERR,
1095 BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
1096 "BS_%d : mgmt_open_connection Failed"
1097 " status = %d extd_status = %d\n",
1098 status, extd_status);
1099
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301100 free_mcc_tag(&phba->ctrl, tag);
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +05301101 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
1102 nonemb_cmd.va, nonemb_cmd.dma);
Mike Christiefa95d202010-06-09 03:30:08 -05001103 goto free_ep;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301104 } else {
1105 wrb = queue_get_wrb(mccq, wrb_num);
1106 free_mcc_tag(&phba->ctrl, tag);
1107
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +05301108 ptcpcnct_out = embedded_payload(wrb);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301109 beiscsi_ep = ep->dd_data;
1110 beiscsi_ep->fw_handle = ptcpcnct_out->connection_handle;
1111 beiscsi_ep->cid_vld = 1;
John Soni Jose99bc5d52012-08-20 23:00:18 +05301112 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
1113 "BS_%d : mgmt_open_connection Success\n");
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301114 }
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +05301115 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
1116 nonemb_cmd.va, nonemb_cmd.dma);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301117 return 0;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301118
Mike Christiefa95d202010-06-09 03:30:08 -05001119free_ep:
1120 beiscsi_free_ep(beiscsi_ep);
Jayamohan Kallickald3ad2bb2010-07-22 04:16:38 +05301121 return -EBUSY;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301122}
1123
1124/**
1125 * beiscsi_ep_connect - Ask chip to create TCP Conn
1126 * @scsi_host: Pointer to scsi_host structure
1127 * @dst_addr: The IP address of Target
1128 * @non_blocking: blocking or non-blocking call
1129 *
1130 * This routines first asks chip to create a connection and then allocates an EP
1131 */
1132struct iscsi_endpoint *
1133beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
1134 int non_blocking)
1135{
1136 struct beiscsi_hba *phba;
1137 struct beiscsi_endpoint *beiscsi_ep;
1138 struct iscsi_endpoint *ep;
1139 int ret;
1140
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301141 if (shost)
1142 phba = iscsi_host_priv(shost);
1143 else {
1144 ret = -ENXIO;
John Soni Jose99bc5d52012-08-20 23:00:18 +05301145 printk(KERN_ERR
1146 "beiscsi_ep_connect shost is NULL\n");
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301147 return ERR_PTR(ret);
1148 }
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +05301149
Jayamohan Kallickal5dc1c412010-01-23 05:36:52 +05301150 if (phba->state != BE_ADAPTER_UP) {
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +05301151 ret = -EBUSY;
John Soni Jose8359c792012-10-20 04:43:03 +05301152 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
1153 "BS_%d : The Adapter Port state is Down!!!\n");
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +05301154 return ERR_PTR(ret);
1155 }
1156
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301157 ep = iscsi_create_endpoint(sizeof(struct beiscsi_endpoint));
1158 if (!ep) {
1159 ret = -ENOMEM;
1160 return ERR_PTR(ret);
1161 }
1162
1163 beiscsi_ep = ep->dd_data;
1164 beiscsi_ep->phba = phba;
Jayamohan Kallickalc2462282010-01-05 05:05:34 +05301165 beiscsi_ep->openiscsi_ep = ep;
Jayamohan Kallickalf5ed7bd2010-07-22 04:18:01 +05301166 ret = beiscsi_open_conn(ep, NULL, dst_addr, non_blocking);
1167 if (ret) {
John Soni Jose99bc5d52012-08-20 23:00:18 +05301168 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
1169 "BS_%d : Failed in beiscsi_open_conn\n");
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301170 goto free_ep;
1171 }
1172
1173 return ep;
1174
1175free_ep:
Mike Christiefa95d202010-06-09 03:30:08 -05001176 iscsi_destroy_endpoint(ep);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301177 return ERR_PTR(ret);
1178}
1179
1180/**
1181 * beiscsi_ep_poll - Poll to see if connection is established
1182 * @ep: endpoint to be used
1183 * @timeout_ms: timeout specified in millisecs
1184 *
1185 * Poll to see if TCP connection established
1186 */
1187int beiscsi_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)
1188{
1189 struct beiscsi_endpoint *beiscsi_ep = ep->dd_data;
1190
John Soni Jose99bc5d52012-08-20 23:00:18 +05301191 beiscsi_log(beiscsi_ep->phba, KERN_INFO, BEISCSI_LOG_CONFIG,
1192 "BS_%d : In beiscsi_ep_poll\n");
1193
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301194 if (beiscsi_ep->cid_vld == 1)
1195 return 1;
1196 else
1197 return 0;
1198}
1199
1200/**
1201 * beiscsi_close_conn - Upload the connection
1202 * @ep: The iscsi endpoint
1203 * @flag: The type of connection closure
1204 */
Jayamohan Kallickalc2462282010-01-05 05:05:34 +05301205static int beiscsi_close_conn(struct beiscsi_endpoint *beiscsi_ep, int flag)
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301206{
1207 int ret = 0;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301208 unsigned int tag;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301209 struct beiscsi_hba *phba = beiscsi_ep->phba;
1210
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301211 tag = mgmt_upload_connection(phba, beiscsi_ep->ep_cid, flag);
1212 if (!tag) {
John Soni Jose99bc5d52012-08-20 23:00:18 +05301213 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
1214 "BS_%d : upload failed for cid 0x%x\n",
1215 beiscsi_ep->ep_cid);
1216
Jayamohan Kallickald3ad2bb2010-07-22 04:16:38 +05301217 ret = -EAGAIN;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301218 } else {
1219 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
1220 phba->ctrl.mcc_numtag[tag]);
1221 free_mcc_tag(&phba->ctrl, tag);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301222 }
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301223 return ret;
1224}
1225
1226/**
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301227 * beiscsi_unbind_conn_to_cid - Unbind the beiscsi_conn from phba conn table
1228 * @phba: The phba instance
1229 * @cid: The cid to free
1230 */
1231static int beiscsi_unbind_conn_to_cid(struct beiscsi_hba *phba,
1232 unsigned int cid)
1233{
1234 if (phba->conn_table[cid])
1235 phba->conn_table[cid] = NULL;
1236 else {
John Soni Jose99bc5d52012-08-20 23:00:18 +05301237 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
1238 "BS_%d : Connection table Not occupied.\n");
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301239 return -EINVAL;
1240 }
1241 return 0;
1242}
1243
1244/**
Mike Christiefa95d202010-06-09 03:30:08 -05001245 * beiscsi_ep_disconnect - Tears down the TCP connection
1246 * @ep: endpoint to be used
1247 *
1248 * Tears down the TCP connection
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301249 */
Mike Christiefa95d202010-06-09 03:30:08 -05001250void beiscsi_ep_disconnect(struct iscsi_endpoint *ep)
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301251{
Mike Christiefa95d202010-06-09 03:30:08 -05001252 struct beiscsi_conn *beiscsi_conn;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301253 struct beiscsi_endpoint *beiscsi_ep;
Mike Christiefa95d202010-06-09 03:30:08 -05001254 struct beiscsi_hba *phba;
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301255 unsigned int tag;
John Soni Jose0a513dd2012-08-20 23:00:55 +05301256 uint8_t mgmt_invalidate_flag, tcp_upload_flag;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301257 unsigned short savecfg_flag = CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH;
1258
Mike Christiefa95d202010-06-09 03:30:08 -05001259 beiscsi_ep = ep->dd_data;
1260 phba = beiscsi_ep->phba;
John Soni Jose99bc5d52012-08-20 23:00:18 +05301261 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
1262 "BS_%d : In beiscsi_ep_disconnect for ep_cid = %d\n",
1263 beiscsi_ep->ep_cid);
Mike Christiefa95d202010-06-09 03:30:08 -05001264
John Soni Jose0a513dd2012-08-20 23:00:55 +05301265 if (beiscsi_ep->conn) {
1266 beiscsi_conn = beiscsi_ep->conn;
1267 iscsi_suspend_queue(beiscsi_conn->conn);
1268 mgmt_invalidate_flag = ~BEISCSI_NO_RST_ISSUE;
1269 tcp_upload_flag = CONNECTION_UPLOAD_GRACEFUL;
1270 } else {
1271 mgmt_invalidate_flag = BEISCSI_NO_RST_ISSUE;
1272 tcp_upload_flag = CONNECTION_UPLOAD_ABORT;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301273 }
Mike Christiefa95d202010-06-09 03:30:08 -05001274
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301275 tag = mgmt_invalidate_connection(phba, beiscsi_ep,
John Soni Jose0a513dd2012-08-20 23:00:55 +05301276 beiscsi_ep->ep_cid,
1277 mgmt_invalidate_flag,
1278 savecfg_flag);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301279 if (!tag) {
John Soni Jose99bc5d52012-08-20 23:00:18 +05301280 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
John Soni Jose0a513dd2012-08-20 23:00:55 +05301281 "BS_%d : mgmt_invalidate_connection Failed for cid=%d\n",
John Soni Jose99bc5d52012-08-20 23:00:18 +05301282 beiscsi_ep->ep_cid);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +05301283 } else {
1284 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
1285 phba->ctrl.mcc_numtag[tag]);
1286 free_mcc_tag(&phba->ctrl, tag);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301287 }
Mike Christiefa95d202010-06-09 03:30:08 -05001288
John Soni Jose0a513dd2012-08-20 23:00:55 +05301289 beiscsi_close_conn(beiscsi_ep, tcp_upload_flag);
Jayamohan Kallickalc2462282010-01-05 05:05:34 +05301290 beiscsi_free_ep(beiscsi_ep);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301291 beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid);
Mike Christiefa95d202010-06-09 03:30:08 -05001292 iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301293}
Mike Christie3128c6c2011-07-25 13:48:42 -05001294
Al Viro587a1f12011-07-23 23:11:19 -04001295umode_t be2iscsi_attr_is_visible(int param_type, int param)
Mike Christie3128c6c2011-07-25 13:48:42 -05001296{
1297 switch (param_type) {
Mike Christie0e438952012-04-03 23:41:51 -05001298 case ISCSI_NET_PARAM:
1299 switch (param) {
1300 case ISCSI_NET_PARAM_IFACE_ENABLE:
1301 case ISCSI_NET_PARAM_IPV4_ADDR:
1302 case ISCSI_NET_PARAM_IPV4_SUBNET:
1303 case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
1304 case ISCSI_NET_PARAM_IPV4_GW:
1305 case ISCSI_NET_PARAM_IPV6_ADDR:
John Soni Jose6f722382012-08-20 23:00:43 +05301306 case ISCSI_NET_PARAM_VLAN_ID:
1307 case ISCSI_NET_PARAM_VLAN_PRIORITY:
1308 case ISCSI_NET_PARAM_VLAN_ENABLED:
Mike Christie0e438952012-04-03 23:41:51 -05001309 return S_IRUGO;
1310 default:
1311 return 0;
1312 }
Mike Christief27fb2e2011-07-25 13:48:45 -05001313 case ISCSI_HOST_PARAM:
1314 switch (param) {
1315 case ISCSI_HOST_PARAM_HWADDRESS:
John Soni Josec62eef02012-04-03 23:41:52 -05001316 case ISCSI_HOST_PARAM_INITIATOR_NAME:
1317 case ISCSI_HOST_PARAM_PORT_STATE:
1318 case ISCSI_HOST_PARAM_PORT_SPEED:
Mike Christief27fb2e2011-07-25 13:48:45 -05001319 return S_IRUGO;
1320 default:
1321 return 0;
1322 }
Mike Christie3128c6c2011-07-25 13:48:42 -05001323 case ISCSI_PARAM:
1324 switch (param) {
1325 case ISCSI_PARAM_MAX_RECV_DLENGTH:
1326 case ISCSI_PARAM_MAX_XMIT_DLENGTH:
1327 case ISCSI_PARAM_HDRDGST_EN:
1328 case ISCSI_PARAM_DATADGST_EN:
1329 case ISCSI_PARAM_CONN_ADDRESS:
1330 case ISCSI_PARAM_CONN_PORT:
1331 case ISCSI_PARAM_EXP_STATSN:
1332 case ISCSI_PARAM_PERSISTENT_ADDRESS:
1333 case ISCSI_PARAM_PERSISTENT_PORT:
1334 case ISCSI_PARAM_PING_TMO:
1335 case ISCSI_PARAM_RECV_TMO:
Mike Christie1d063c12011-07-25 13:48:43 -05001336 case ISCSI_PARAM_INITIAL_R2T_EN:
1337 case ISCSI_PARAM_MAX_R2T:
1338 case ISCSI_PARAM_IMM_DATA_EN:
1339 case ISCSI_PARAM_FIRST_BURST:
1340 case ISCSI_PARAM_MAX_BURST:
1341 case ISCSI_PARAM_PDU_INORDER_EN:
1342 case ISCSI_PARAM_DATASEQ_INORDER_EN:
1343 case ISCSI_PARAM_ERL:
1344 case ISCSI_PARAM_TARGET_NAME:
1345 case ISCSI_PARAM_TPGT:
1346 case ISCSI_PARAM_USERNAME:
1347 case ISCSI_PARAM_PASSWORD:
1348 case ISCSI_PARAM_USERNAME_IN:
1349 case ISCSI_PARAM_PASSWORD_IN:
1350 case ISCSI_PARAM_FAST_ABORT:
1351 case ISCSI_PARAM_ABORT_TMO:
1352 case ISCSI_PARAM_LU_RESET_TMO:
1353 case ISCSI_PARAM_IFACE_NAME:
1354 case ISCSI_PARAM_INITIATOR_NAME:
Mike Christie3128c6c2011-07-25 13:48:42 -05001355 return S_IRUGO;
1356 default:
1357 return 0;
1358 }
1359 }
1360
1361 return 0;
1362}