2 * Copyright (C) 2005 - 2016 Broadcom
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.
10 * Written by: Jayamohan Kallickal (jayamohan.kallickal@broadcom.com)
12 * Contact Information:
13 * linux-drivers@broadcom.com
17 * Costa Mesa, CA 92626
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>
26 #include <scsi/scsi_netlink.h>
27 #include <net/netlink.h>
28 #include <scsi/scsi.h>
32 extern struct iscsi_transport beiscsi_iscsi_transport
;
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
40 struct iscsi_cls_session
*beiscsi_session_create(struct iscsi_endpoint
*ep
,
45 struct Scsi_Host
*shost
;
46 struct beiscsi_endpoint
*beiscsi_ep
;
47 struct iscsi_cls_session
*cls_session
;
48 struct beiscsi_hba
*phba
;
49 struct iscsi_session
*sess
;
50 struct beiscsi_session
*beiscsi_sess
;
51 struct beiscsi_io_task
*io_task
;
55 pr_err("beiscsi_session_create: invalid ep\n");
58 beiscsi_ep
= ep
->dd_data
;
59 phba
= beiscsi_ep
->phba
;
61 if (!beiscsi_hba_is_online(phba
)) {
62 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
63 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
67 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
68 "BS_%d : In beiscsi_session_create\n");
69 if (cmds_max
> beiscsi_ep
->phba
->params
.wrbs_per_cxn
) {
70 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
71 "BS_%d : Cannot handle %d cmds."
72 "Max cmds per session supported is %d. Using %d."
74 beiscsi_ep
->phba
->params
.wrbs_per_cxn
,
75 beiscsi_ep
->phba
->params
.wrbs_per_cxn
);
77 cmds_max
= beiscsi_ep
->phba
->params
.wrbs_per_cxn
;
81 cls_session
= iscsi_session_setup(&beiscsi_iscsi_transport
,
83 sizeof(*beiscsi_sess
),
85 initial_cmdsn
, ISCSI_MAX_TARGET
);
88 sess
= cls_session
->dd_data
;
89 beiscsi_sess
= sess
->dd_data
;
90 beiscsi_sess
->bhs_pool
= pci_pool_create("beiscsi_bhs_pool",
92 sizeof(struct be_cmd_bhs
),
94 if (!beiscsi_sess
->bhs_pool
)
99 iscsi_session_teardown(cls_session
);
104 * beiscsi_session_destroy - destroys iscsi session
105 * @cls_session: pointer to iscsi cls session
107 * Destroys iSCSI session instance and releases
108 * resources allocated for it.
110 void beiscsi_session_destroy(struct iscsi_cls_session
*cls_session
)
112 struct iscsi_session
*sess
= cls_session
->dd_data
;
113 struct beiscsi_session
*beiscsi_sess
= sess
->dd_data
;
115 printk(KERN_INFO
"In beiscsi_session_destroy\n");
116 pci_pool_destroy(beiscsi_sess
->bhs_pool
);
117 iscsi_session_teardown(cls_session
);
121 * beiscsi_session_fail(): Closing session with appropriate error
122 * @cls_session: ptr to session
124 void beiscsi_session_fail(struct iscsi_cls_session
*cls_session
)
126 iscsi_session_failure(cls_session
->dd_data
, ISCSI_ERR_CONN_FAILED
);
131 * beiscsi_conn_create - create an instance of iscsi connection
132 * @cls_session: ptr to iscsi_cls_session
135 struct iscsi_cls_conn
*
136 beiscsi_conn_create(struct iscsi_cls_session
*cls_session
, u32 cid
)
138 struct beiscsi_hba
*phba
;
139 struct Scsi_Host
*shost
;
140 struct iscsi_cls_conn
*cls_conn
;
141 struct beiscsi_conn
*beiscsi_conn
;
142 struct iscsi_conn
*conn
;
143 struct iscsi_session
*sess
;
144 struct beiscsi_session
*beiscsi_sess
;
146 shost
= iscsi_session_to_shost(cls_session
);
147 phba
= iscsi_host_priv(shost
);
149 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
150 "BS_%d : In beiscsi_conn_create ,cid"
151 "from iscsi layer=%d\n", cid
);
153 cls_conn
= iscsi_conn_setup(cls_session
, sizeof(*beiscsi_conn
), cid
);
157 conn
= cls_conn
->dd_data
;
158 beiscsi_conn
= conn
->dd_data
;
159 beiscsi_conn
->ep
= NULL
;
160 beiscsi_conn
->phba
= phba
;
161 beiscsi_conn
->conn
= conn
;
162 sess
= cls_session
->dd_data
;
163 beiscsi_sess
= sess
->dd_data
;
164 beiscsi_conn
->beiscsi_sess
= beiscsi_sess
;
169 * beiscsi_bindconn_cid - Bind the beiscsi_conn with phba connection table
170 * @beiscsi_conn: The pointer to beiscsi_conn structure
171 * @phba: The phba instance
172 * @cid: The cid to free
174 static int beiscsi_bindconn_cid(struct beiscsi_hba
*phba
,
175 struct beiscsi_conn
*beiscsi_conn
,
178 uint16_t cri_index
= BE_GET_CRI_FROM_CID(cid
);
180 if (phba
->conn_table
[cri_index
]) {
181 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
182 "BS_%d : Connection table already occupied. Detected clash\n");
186 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
187 "BS_%d : phba->conn_table[%d]=%p(beiscsi_conn)\n",
188 cri_index
, beiscsi_conn
);
190 phba
->conn_table
[cri_index
] = beiscsi_conn
;
196 * beiscsi_conn_bind - Binds iscsi session/connection with TCP connection
197 * @cls_session: pointer to iscsi cls session
198 * @cls_conn: pointer to iscsi cls conn
199 * @transport_fd: EP handle(64 bit)
201 * This function binds the TCP Conn with iSCSI Connection and Session.
203 int beiscsi_conn_bind(struct iscsi_cls_session
*cls_session
,
204 struct iscsi_cls_conn
*cls_conn
,
205 u64 transport_fd
, int is_leading
)
207 struct iscsi_conn
*conn
= cls_conn
->dd_data
;
208 struct beiscsi_conn
*beiscsi_conn
= conn
->dd_data
;
209 struct Scsi_Host
*shost
= iscsi_session_to_shost(cls_session
);
210 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
211 struct hwi_controller
*phwi_ctrlr
= phba
->phwi_ctrlr
;
212 struct hwi_wrb_context
*pwrb_context
;
213 struct beiscsi_endpoint
*beiscsi_ep
;
214 struct iscsi_endpoint
*ep
;
216 ep
= iscsi_lookup_endpoint(transport_fd
);
220 beiscsi_ep
= ep
->dd_data
;
222 if (iscsi_conn_bind(cls_session
, cls_conn
, is_leading
))
225 if (beiscsi_ep
->phba
!= phba
) {
226 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
227 "BS_%d : beiscsi_ep->hba=%p not equal to phba=%p\n",
228 beiscsi_ep
->phba
, phba
);
233 pwrb_context
= &phwi_ctrlr
->wrb_context
[BE_GET_CRI_FROM_CID(
234 beiscsi_ep
->ep_cid
)];
236 beiscsi_conn
->beiscsi_conn_cid
= beiscsi_ep
->ep_cid
;
237 beiscsi_conn
->ep
= beiscsi_ep
;
238 beiscsi_ep
->conn
= beiscsi_conn
;
239 beiscsi_conn
->doorbell_offset
= pwrb_context
->doorbell_offset
;
241 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
242 "BS_%d : beiscsi_conn=%p conn=%p ep_cid=%d\n",
243 beiscsi_conn
, conn
, beiscsi_ep
->ep_cid
);
245 return beiscsi_bindconn_cid(phba
, beiscsi_conn
, beiscsi_ep
->ep_cid
);
248 static int beiscsi_iface_create_ipv4(struct beiscsi_hba
*phba
)
250 if (phba
->ipv4_iface
)
253 phba
->ipv4_iface
= iscsi_create_iface(phba
->shost
,
254 &beiscsi_iscsi_transport
,
255 ISCSI_IFACE_TYPE_IPV4
,
257 if (!phba
->ipv4_iface
) {
258 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
260 "create default IPv4 address.\n");
267 static int beiscsi_iface_create_ipv6(struct beiscsi_hba
*phba
)
269 if (phba
->ipv6_iface
)
272 phba
->ipv6_iface
= iscsi_create_iface(phba
->shost
,
273 &beiscsi_iscsi_transport
,
274 ISCSI_IFACE_TYPE_IPV6
,
276 if (!phba
->ipv6_iface
) {
277 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
279 "create default IPv6 address.\n");
286 void beiscsi_iface_create_default(struct beiscsi_hba
*phba
)
288 struct be_cmd_get_if_info_resp
*if_info
;
290 if (!beiscsi_if_get_info(phba
, BEISCSI_IP_TYPE_V4
, &if_info
)) {
291 beiscsi_iface_create_ipv4(phba
);
295 if (!beiscsi_if_get_info(phba
, BEISCSI_IP_TYPE_V6
, &if_info
)) {
296 beiscsi_iface_create_ipv6(phba
);
301 void beiscsi_iface_destroy_default(struct beiscsi_hba
*phba
)
303 if (phba
->ipv6_iface
) {
304 iscsi_destroy_iface(phba
->ipv6_iface
);
305 phba
->ipv6_iface
= NULL
;
307 if (phba
->ipv4_iface
) {
308 iscsi_destroy_iface(phba
->ipv4_iface
);
309 phba
->ipv4_iface
= NULL
;
314 * beiscsi_set_vlan_tag()- Set the VLAN TAG
315 * @shost: Scsi Host for the driver instance
316 * @iface_param: Interface paramters
318 * Set the VLAN TAG for the adapter or disable
323 * Failure: Non-Zero Value
326 beiscsi_iface_config_vlan(struct Scsi_Host
*shost
,
327 struct iscsi_iface_param_info
*iface_param
)
329 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
332 switch (iface_param
->param
) {
333 case ISCSI_NET_PARAM_VLAN_ENABLED
:
335 if (iface_param
->value
[0] != ISCSI_VLAN_ENABLE
)
336 ret
= beiscsi_if_set_vlan(phba
, BEISCSI_VLAN_DISABLE
);
338 case ISCSI_NET_PARAM_VLAN_TAG
:
339 ret
= beiscsi_if_set_vlan(phba
,
340 *((uint16_t *)iface_param
->value
));
348 beiscsi_iface_config_ipv4(struct Scsi_Host
*shost
,
349 struct iscsi_iface_param_info
*info
,
350 void *data
, uint32_t dt_len
)
352 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
353 u8
*ip
= NULL
, *subnet
= NULL
, *gw
;
357 /* Check the param */
358 switch (info
->param
) {
359 case ISCSI_NET_PARAM_IFACE_ENABLE
:
360 if (info
->value
[0] == ISCSI_IFACE_ENABLE
)
361 ret
= beiscsi_iface_create_ipv4(phba
);
363 iscsi_destroy_iface(phba
->ipv4_iface
);
364 phba
->ipv4_iface
= NULL
;
367 case ISCSI_NET_PARAM_IPV4_GW
:
369 ret
= beiscsi_if_set_gw(phba
, BEISCSI_IP_TYPE_V4
, gw
);
371 case ISCSI_NET_PARAM_IPV4_BOOTPROTO
:
372 if (info
->value
[0] == ISCSI_BOOTPROTO_DHCP
)
373 ret
= beiscsi_if_en_dhcp(phba
, BEISCSI_IP_TYPE_V4
);
374 else if (info
->value
[0] == ISCSI_BOOTPROTO_STATIC
)
375 /* release DHCP IP address */
376 ret
= beiscsi_if_en_static(phba
, BEISCSI_IP_TYPE_V4
,
379 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
380 "BS_%d : Invalid BOOTPROTO: %d\n",
383 case ISCSI_NET_PARAM_IPV4_ADDR
:
385 nla
= nla_find(data
, dt_len
, ISCSI_NET_PARAM_IPV4_SUBNET
);
387 info
= nla_data(nla
);
388 subnet
= info
->value
;
390 ret
= beiscsi_if_en_static(phba
, BEISCSI_IP_TYPE_V4
,
393 case ISCSI_NET_PARAM_IPV4_SUBNET
:
395 * OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR ioctl needs IP
396 * and subnet both. Find IP to be applied for this subnet.
398 subnet
= info
->value
;
399 nla
= nla_find(data
, dt_len
, ISCSI_NET_PARAM_IPV4_ADDR
);
401 info
= nla_data(nla
);
404 ret
= beiscsi_if_en_static(phba
, BEISCSI_IP_TYPE_V4
,
413 beiscsi_iface_config_ipv6(struct Scsi_Host
*shost
,
414 struct iscsi_iface_param_info
*iface_param
,
415 void *data
, uint32_t dt_len
)
417 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
420 switch (iface_param
->param
) {
421 case ISCSI_NET_PARAM_IFACE_ENABLE
:
422 if (iface_param
->value
[0] == ISCSI_IFACE_ENABLE
)
423 ret
= beiscsi_iface_create_ipv6(phba
);
425 iscsi_destroy_iface(phba
->ipv6_iface
);
426 phba
->ipv6_iface
= NULL
;
429 case ISCSI_NET_PARAM_IPV6_ADDR
:
430 ret
= beiscsi_if_en_static(phba
, BEISCSI_IP_TYPE_V6
,
431 iface_param
->value
, NULL
);
438 int beiscsi_iface_set_param(struct Scsi_Host
*shost
,
439 void *data
, uint32_t dt_len
)
441 struct iscsi_iface_param_info
*iface_param
= NULL
;
442 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
443 struct nlattr
*attrib
;
444 uint32_t rm_len
= dt_len
;
447 if (!beiscsi_hba_is_online(phba
)) {
448 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
449 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
453 /* update interface_handle */
454 ret
= beiscsi_if_get_handle(phba
);
456 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
457 "BS_%d : Getting Interface Handle Failed\n");
461 nla_for_each_attr(attrib
, data
, dt_len
, rm_len
) {
462 iface_param
= nla_data(attrib
);
464 if (iface_param
->param_type
!= ISCSI_NET_PARAM
)
468 * BE2ISCSI only supports 1 interface
470 if (iface_param
->iface_num
) {
471 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
472 "BS_%d : Invalid iface_num %d."
473 "Only iface_num 0 is supported.\n",
474 iface_param
->iface_num
);
479 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
480 "BS_%d : %s.0 set param %d",
481 (iface_param
->iface_type
== ISCSI_IFACE_TYPE_IPV4
) ?
482 "ipv4" : "ipv6", iface_param
->param
);
485 switch (iface_param
->param
) {
486 case ISCSI_NET_PARAM_VLAN_ENABLED
:
487 case ISCSI_NET_PARAM_VLAN_TAG
:
488 ret
= beiscsi_iface_config_vlan(shost
, iface_param
);
491 switch (iface_param
->iface_type
) {
492 case ISCSI_IFACE_TYPE_IPV4
:
493 ret
= beiscsi_iface_config_ipv4(shost
,
497 case ISCSI_IFACE_TYPE_IPV6
:
498 ret
= beiscsi_iface_config_ipv6(shost
,
506 __beiscsi_log(phba
, KERN_ERR
,
507 "BS_%d : %s.0 set param %d not permitted",
508 (iface_param
->iface_type
==
509 ISCSI_IFACE_TYPE_IPV4
) ? "ipv4" : "ipv6",
520 static int __beiscsi_iface_get_param(struct beiscsi_hba
*phba
,
521 struct iscsi_iface
*iface
,
522 int param
, char *buf
)
524 struct be_cmd_get_if_info_resp
*if_info
;
525 int len
, ip_type
= BEISCSI_IP_TYPE_V4
;
527 if (iface
->iface_type
== ISCSI_IFACE_TYPE_IPV6
)
528 ip_type
= BEISCSI_IP_TYPE_V6
;
530 len
= beiscsi_if_get_info(phba
, ip_type
, &if_info
);
535 case ISCSI_NET_PARAM_IPV4_ADDR
:
536 len
= sprintf(buf
, "%pI4\n", if_info
->ip_addr
.addr
);
538 case ISCSI_NET_PARAM_IPV6_ADDR
:
539 len
= sprintf(buf
, "%pI6\n", if_info
->ip_addr
.addr
);
541 case ISCSI_NET_PARAM_IPV4_BOOTPROTO
:
542 if (!if_info
->dhcp_state
)
543 len
= sprintf(buf
, "static\n");
545 len
= sprintf(buf
, "dhcp\n");
547 case ISCSI_NET_PARAM_IPV4_SUBNET
:
548 len
= sprintf(buf
, "%pI4\n", if_info
->ip_addr
.subnet_mask
);
550 case ISCSI_NET_PARAM_VLAN_ENABLED
:
551 len
= sprintf(buf
, "%s\n",
552 (if_info
->vlan_priority
== BEISCSI_VLAN_DISABLE
) ?
553 "disable" : "enable");
555 case ISCSI_NET_PARAM_VLAN_ID
:
556 if (if_info
->vlan_priority
== BEISCSI_VLAN_DISABLE
)
559 len
= sprintf(buf
, "%d\n",
560 (if_info
->vlan_priority
&
563 case ISCSI_NET_PARAM_VLAN_PRIORITY
:
564 if (if_info
->vlan_priority
== BEISCSI_VLAN_DISABLE
)
567 len
= sprintf(buf
, "%d\n",
568 ((if_info
->vlan_priority
>> 13) &
569 ISCSI_MAX_VLAN_PRIORITY
));
579 int beiscsi_iface_get_param(struct iscsi_iface
*iface
,
580 enum iscsi_param_type param_type
,
581 int param
, char *buf
)
583 struct Scsi_Host
*shost
= iscsi_iface_to_shost(iface
);
584 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
585 struct be_cmd_get_def_gateway_resp gateway
;
588 if (param_type
!= ISCSI_NET_PARAM
)
590 if (!beiscsi_hba_is_online(phba
)) {
591 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
592 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
597 case ISCSI_NET_PARAM_IPV4_ADDR
:
598 case ISCSI_NET_PARAM_IPV4_SUBNET
:
599 case ISCSI_NET_PARAM_IPV4_BOOTPROTO
:
600 case ISCSI_NET_PARAM_IPV6_ADDR
:
601 case ISCSI_NET_PARAM_VLAN_ENABLED
:
602 case ISCSI_NET_PARAM_VLAN_ID
:
603 case ISCSI_NET_PARAM_VLAN_PRIORITY
:
604 len
= __beiscsi_iface_get_param(phba
, iface
, param
, buf
);
606 case ISCSI_NET_PARAM_IFACE_ENABLE
:
607 if (iface
->iface_type
== ISCSI_IFACE_TYPE_IPV4
)
608 len
= sprintf(buf
, "%s\n",
609 phba
->ipv4_iface
? "enable" : "disable");
610 else if (iface
->iface_type
== ISCSI_IFACE_TYPE_IPV6
)
611 len
= sprintf(buf
, "%s\n",
612 phba
->ipv6_iface
? "enable" : "disable");
614 case ISCSI_NET_PARAM_IPV4_GW
:
615 memset(&gateway
, 0, sizeof(gateway
));
616 len
= beiscsi_if_get_gw(phba
, BEISCSI_IP_TYPE_V4
, &gateway
);
618 len
= sprintf(buf
, "%pI4\n", &gateway
.ip_addr
.addr
);
626 * beiscsi_ep_get_param - get the iscsi parameter
627 * @ep: pointer to iscsi ep
628 * @param: parameter type identifier
629 * @buf: buffer pointer
631 * returns iscsi parameter
633 int beiscsi_ep_get_param(struct iscsi_endpoint
*ep
,
634 enum iscsi_param param
, char *buf
)
636 struct beiscsi_endpoint
*beiscsi_ep
= ep
->dd_data
;
639 beiscsi_log(beiscsi_ep
->phba
, KERN_INFO
,
641 "BS_%d : In beiscsi_ep_get_param,"
642 " param= %d\n", param
);
645 case ISCSI_PARAM_CONN_PORT
:
646 len
= sprintf(buf
, "%hu\n", beiscsi_ep
->dst_tcpport
);
648 case ISCSI_PARAM_CONN_ADDRESS
:
649 if (beiscsi_ep
->ip_type
== BEISCSI_IP_TYPE_V4
)
650 len
= sprintf(buf
, "%pI4\n", &beiscsi_ep
->dst_addr
);
652 len
= sprintf(buf
, "%pI6\n", &beiscsi_ep
->dst6_addr
);
660 int beiscsi_set_param(struct iscsi_cls_conn
*cls_conn
,
661 enum iscsi_param param
, char *buf
, int buflen
)
663 struct iscsi_conn
*conn
= cls_conn
->dd_data
;
664 struct iscsi_session
*session
= conn
->session
;
665 struct beiscsi_hba
*phba
= NULL
;
668 phba
= ((struct beiscsi_conn
*)conn
->dd_data
)->phba
;
669 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
670 "BS_%d : In beiscsi_conn_set_param,"
671 " param= %d\n", param
);
673 ret
= iscsi_set_param(cls_conn
, param
, buf
, buflen
);
677 * If userspace tried to set the value to higher than we can
678 * support override here.
681 case ISCSI_PARAM_FIRST_BURST
:
682 if (session
->first_burst
> 8192)
683 session
->first_burst
= 8192;
685 case ISCSI_PARAM_MAX_RECV_DLENGTH
:
686 if (conn
->max_recv_dlength
> 65536)
687 conn
->max_recv_dlength
= 65536;
689 case ISCSI_PARAM_MAX_BURST
:
690 if (session
->max_burst
> 262144)
691 session
->max_burst
= 262144;
693 case ISCSI_PARAM_MAX_XMIT_DLENGTH
:
694 if (conn
->max_xmit_dlength
> 65536)
695 conn
->max_xmit_dlength
= 65536;
704 * beiscsi_get_initname - Read Initiator Name from flash
705 * @buf: buffer bointer
706 * @phba: The device priv structure instance
708 * returns number of bytes
710 static int beiscsi_get_initname(char *buf
, struct beiscsi_hba
*phba
)
714 struct be_mcc_wrb
*wrb
;
715 struct be_cmd_hba_name
*resp
;
717 tag
= be_cmd_get_initname(phba
);
719 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
720 "BS_%d : Getting Initiator Name Failed\n");
725 rc
= beiscsi_mccq_compl_wait(phba
, tag
, &wrb
, NULL
);
727 beiscsi_log(phba
, KERN_ERR
,
728 BEISCSI_LOG_CONFIG
| BEISCSI_LOG_MBOX
,
729 "BS_%d : Initiator Name MBX Failed\n");
733 resp
= embedded_payload(wrb
);
734 rc
= sprintf(buf
, "%s\n", resp
->initiator_name
);
739 * beiscsi_get_port_state - Get the Port State
740 * @shost : pointer to scsi_host structure
743 static void beiscsi_get_port_state(struct Scsi_Host
*shost
)
745 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
746 struct iscsi_cls_host
*ihost
= shost
->shost_data
;
748 ihost
->port_state
= test_bit(BEISCSI_HBA_LINK_UP
, &phba
->state
) ?
749 ISCSI_PORT_STATE_UP
: ISCSI_PORT_STATE_DOWN
;
753 * beiscsi_get_port_speed - Get the Port Speed from Adapter
754 * @shost : pointer to scsi_host structure
757 static void beiscsi_get_port_speed(struct Scsi_Host
*shost
)
759 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
760 struct iscsi_cls_host
*ihost
= shost
->shost_data
;
762 switch (phba
->port_speed
) {
763 case BE2ISCSI_LINK_SPEED_10MBPS
:
764 ihost
->port_speed
= ISCSI_PORT_SPEED_10MBPS
;
766 case BE2ISCSI_LINK_SPEED_100MBPS
:
767 ihost
->port_speed
= ISCSI_PORT_SPEED_100MBPS
;
769 case BE2ISCSI_LINK_SPEED_1GBPS
:
770 ihost
->port_speed
= ISCSI_PORT_SPEED_1GBPS
;
772 case BE2ISCSI_LINK_SPEED_10GBPS
:
773 ihost
->port_speed
= ISCSI_PORT_SPEED_10GBPS
;
775 case BE2ISCSI_LINK_SPEED_25GBPS
:
776 ihost
->port_speed
= ISCSI_PORT_SPEED_25GBPS
;
778 case BE2ISCSI_LINK_SPEED_40GBPS
:
779 ihost
->port_speed
= ISCSI_PORT_SPEED_40GBPS
;
782 ihost
->port_speed
= ISCSI_PORT_SPEED_UNKNOWN
;
787 * beiscsi_get_host_param - get the iscsi parameter
788 * @shost: pointer to scsi_host structure
789 * @param: parameter type identifier
790 * @buf: buffer pointer
792 * returns host parameter
794 int beiscsi_get_host_param(struct Scsi_Host
*shost
,
795 enum iscsi_host_param param
, char *buf
)
797 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
800 if (!beiscsi_hba_is_online(phba
)) {
801 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
802 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
805 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
806 "BS_%d : In beiscsi_get_host_param, param = %d\n", param
);
809 case ISCSI_HOST_PARAM_HWADDRESS
:
810 status
= beiscsi_get_macaddr(buf
, phba
);
812 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
813 "BS_%d : beiscsi_get_macaddr Failed\n");
817 case ISCSI_HOST_PARAM_INITIATOR_NAME
:
818 status
= beiscsi_get_initname(buf
, phba
);
820 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
821 "BS_%d : Retreiving Initiator Name Failed\n");
825 case ISCSI_HOST_PARAM_PORT_STATE
:
826 beiscsi_get_port_state(shost
);
827 status
= sprintf(buf
, "%s\n", iscsi_get_port_state_name(shost
));
829 case ISCSI_HOST_PARAM_PORT_SPEED
:
830 beiscsi_get_port_speed(shost
);
831 status
= sprintf(buf
, "%s\n", iscsi_get_port_speed_name(shost
));
834 return iscsi_host_get_param(shost
, param
, buf
);
839 int beiscsi_get_macaddr(char *buf
, struct beiscsi_hba
*phba
)
841 struct be_cmd_get_nic_conf_resp resp
;
844 if (phba
->mac_addr_set
)
845 return sysfs_format_mac(buf
, phba
->mac_address
, ETH_ALEN
);
847 memset(&resp
, 0, sizeof(resp
));
848 rc
= mgmt_get_nic_conf(phba
, &resp
);
852 phba
->mac_addr_set
= true;
853 memcpy(phba
->mac_address
, resp
.mac_address
, ETH_ALEN
);
854 return sysfs_format_mac(buf
, phba
->mac_address
, ETH_ALEN
);
858 * beiscsi_conn_get_stats - get the iscsi stats
859 * @cls_conn: pointer to iscsi cls conn
860 * @stats: pointer to iscsi_stats structure
862 * returns iscsi stats
864 void beiscsi_conn_get_stats(struct iscsi_cls_conn
*cls_conn
,
865 struct iscsi_stats
*stats
)
867 struct iscsi_conn
*conn
= cls_conn
->dd_data
;
868 struct beiscsi_hba
*phba
= NULL
;
870 phba
= ((struct beiscsi_conn
*)conn
->dd_data
)->phba
;
871 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
872 "BS_%d : In beiscsi_conn_get_stats\n");
874 stats
->txdata_octets
= conn
->txdata_octets
;
875 stats
->rxdata_octets
= conn
->rxdata_octets
;
876 stats
->dataout_pdus
= conn
->dataout_pdus_cnt
;
877 stats
->scsirsp_pdus
= conn
->scsirsp_pdus_cnt
;
878 stats
->scsicmd_pdus
= conn
->scsicmd_pdus_cnt
;
879 stats
->datain_pdus
= conn
->datain_pdus_cnt
;
880 stats
->tmfrsp_pdus
= conn
->tmfrsp_pdus_cnt
;
881 stats
->tmfcmd_pdus
= conn
->tmfcmd_pdus_cnt
;
882 stats
->r2t_pdus
= conn
->r2t_pdus_cnt
;
883 stats
->digest_err
= 0;
884 stats
->timeout_err
= 0;
885 stats
->custom_length
= 1;
886 strcpy(stats
->custom
[0].desc
, "eh_abort_cnt");
887 stats
->custom
[0].value
= conn
->eh_abort_cnt
;
891 * beiscsi_set_params_for_offld - get the parameters for offload
892 * @beiscsi_conn: pointer to beiscsi_conn
893 * @params: pointer to offload_params structure
895 static void beiscsi_set_params_for_offld(struct beiscsi_conn
*beiscsi_conn
,
896 struct beiscsi_offload_params
*params
)
898 struct iscsi_conn
*conn
= beiscsi_conn
->conn
;
899 struct iscsi_session
*session
= conn
->session
;
901 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, max_burst_length
,
902 params
, session
->max_burst
);
903 AMAP_SET_BITS(struct amap_beiscsi_offload_params
,
904 max_send_data_segment_length
, params
,
905 conn
->max_xmit_dlength
);
906 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, first_burst_length
,
907 params
, session
->first_burst
);
908 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, erl
, params
,
910 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, dde
, params
,
912 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, hde
, params
,
914 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, ir2t
, params
,
915 session
->initial_r2t_en
);
916 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, imd
, params
,
917 session
->imm_data_en
);
918 AMAP_SET_BITS(struct amap_beiscsi_offload_params
,
919 data_seq_inorder
, params
,
920 session
->dataseq_inorder_en
);
921 AMAP_SET_BITS(struct amap_beiscsi_offload_params
,
922 pdu_seq_inorder
, params
,
923 session
->pdu_inorder_en
);
924 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, max_r2t
, params
,
926 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, exp_statsn
, params
,
927 (conn
->exp_statsn
- 1));
928 AMAP_SET_BITS(struct amap_beiscsi_offload_params
,
929 max_recv_data_segment_length
, params
,
930 conn
->max_recv_dlength
);
935 * beiscsi_conn_start - offload of session to chip
936 * @cls_conn: pointer to beiscsi_conn
938 int beiscsi_conn_start(struct iscsi_cls_conn
*cls_conn
)
940 struct iscsi_conn
*conn
= cls_conn
->dd_data
;
941 struct beiscsi_conn
*beiscsi_conn
= conn
->dd_data
;
942 struct beiscsi_endpoint
*beiscsi_ep
;
943 struct beiscsi_offload_params params
;
944 struct beiscsi_hba
*phba
;
946 phba
= ((struct beiscsi_conn
*)conn
->dd_data
)->phba
;
948 if (!beiscsi_hba_is_online(phba
)) {
949 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
950 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
953 beiscsi_log(beiscsi_conn
->phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
954 "BS_%d : In beiscsi_conn_start\n");
956 memset(¶ms
, 0, sizeof(struct beiscsi_offload_params
));
957 beiscsi_ep
= beiscsi_conn
->ep
;
959 beiscsi_log(beiscsi_conn
->phba
, KERN_ERR
,
961 "BS_%d : In beiscsi_conn_start , no beiscsi_ep\n");
963 beiscsi_conn
->login_in_progress
= 0;
964 beiscsi_set_params_for_offld(beiscsi_conn
, ¶ms
);
965 beiscsi_offload_connection(beiscsi_conn
, ¶ms
);
966 iscsi_conn_start(cls_conn
);
971 * beiscsi_get_cid - Allocate a cid
972 * @phba: The phba instance
974 static int beiscsi_get_cid(struct beiscsi_hba
*phba
)
976 unsigned short cid
= 0xFFFF, cid_from_ulp
;
977 struct ulp_cid_info
*cid_info
= NULL
;
978 uint16_t cid_avlbl_ulp0
, cid_avlbl_ulp1
;
980 /* Find the ULP which has more CID available */
981 cid_avlbl_ulp0
= (phba
->cid_array_info
[BEISCSI_ULP0
]) ?
982 BEISCSI_ULP0_AVLBL_CID(phba
) : 0;
983 cid_avlbl_ulp1
= (phba
->cid_array_info
[BEISCSI_ULP1
]) ?
984 BEISCSI_ULP1_AVLBL_CID(phba
) : 0;
985 cid_from_ulp
= (cid_avlbl_ulp0
> cid_avlbl_ulp1
) ?
986 BEISCSI_ULP0
: BEISCSI_ULP1
;
988 if (test_bit(cid_from_ulp
, (void *)&phba
->fw_config
.ulp_supported
)) {
989 cid_info
= phba
->cid_array_info
[cid_from_ulp
];
990 if (!cid_info
->avlbl_cids
)
993 cid
= cid_info
->cid_array
[cid_info
->cid_alloc
++];
995 if (cid_info
->cid_alloc
== BEISCSI_GET_CID_COUNT(
997 cid_info
->cid_alloc
= 0;
999 cid_info
->avlbl_cids
--;
1005 * beiscsi_put_cid - Free the cid
1006 * @phba: The phba for which the cid is being freed
1007 * @cid: The cid to free
1009 static void beiscsi_put_cid(struct beiscsi_hba
*phba
, unsigned short cid
)
1011 uint16_t cid_post_ulp
;
1012 struct hwi_controller
*phwi_ctrlr
;
1013 struct hwi_wrb_context
*pwrb_context
;
1014 struct ulp_cid_info
*cid_info
= NULL
;
1015 uint16_t cri_index
= BE_GET_CRI_FROM_CID(cid
);
1017 phwi_ctrlr
= phba
->phwi_ctrlr
;
1018 pwrb_context
= &phwi_ctrlr
->wrb_context
[cri_index
];
1019 cid_post_ulp
= pwrb_context
->ulp_num
;
1021 cid_info
= phba
->cid_array_info
[cid_post_ulp
];
1022 cid_info
->avlbl_cids
++;
1024 cid_info
->cid_array
[cid_info
->cid_free
++] = cid
;
1025 if (cid_info
->cid_free
== BEISCSI_GET_CID_COUNT(phba
, cid_post_ulp
))
1026 cid_info
->cid_free
= 0;
1030 * beiscsi_free_ep - free endpoint
1031 * @ep: pointer to iscsi endpoint structure
1033 static void beiscsi_free_ep(struct beiscsi_endpoint
*beiscsi_ep
)
1035 struct beiscsi_hba
*phba
= beiscsi_ep
->phba
;
1036 struct beiscsi_conn
*beiscsi_conn
;
1038 beiscsi_put_cid(phba
, beiscsi_ep
->ep_cid
);
1039 beiscsi_ep
->phba
= NULL
;
1040 phba
->ep_array
[BE_GET_CRI_FROM_CID
1041 (beiscsi_ep
->ep_cid
)] = NULL
;
1044 * Check if any connection resource allocated by driver
1045 * is to be freed.This case occurs when target redirection
1046 * or connection retry is done.
1048 if (!beiscsi_ep
->conn
)
1051 beiscsi_conn
= beiscsi_ep
->conn
;
1052 if (beiscsi_conn
->login_in_progress
) {
1053 beiscsi_free_mgmt_task_handles(beiscsi_conn
,
1054 beiscsi_conn
->task
);
1055 beiscsi_conn
->login_in_progress
= 0;
1060 * beiscsi_open_conn - Ask FW to open a TCP connection
1061 * @ep: endpoint to be used
1062 * @src_addr: The source IP address
1063 * @dst_addr: The Destination IP address
1065 * Asks the FW to open a TCP connection
1067 static int beiscsi_open_conn(struct iscsi_endpoint
*ep
,
1068 struct sockaddr
*src_addr
,
1069 struct sockaddr
*dst_addr
, int non_blocking
)
1071 struct beiscsi_endpoint
*beiscsi_ep
= ep
->dd_data
;
1072 struct beiscsi_hba
*phba
= beiscsi_ep
->phba
;
1073 struct tcp_connect_and_offload_out
*ptcpcnct_out
;
1074 struct be_dma_mem nonemb_cmd
;
1075 unsigned int tag
, req_memsize
;
1078 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1079 "BS_%d : In beiscsi_open_conn\n");
1081 beiscsi_ep
->ep_cid
= beiscsi_get_cid(phba
);
1082 if (beiscsi_ep
->ep_cid
== 0xFFFF) {
1083 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
1084 "BS_%d : No free cid available\n");
1088 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1089 "BS_%d : In beiscsi_open_conn, ep_cid=%d\n",
1090 beiscsi_ep
->ep_cid
);
1092 phba
->ep_array
[BE_GET_CRI_FROM_CID
1093 (beiscsi_ep
->ep_cid
)] = ep
;
1095 beiscsi_ep
->cid_vld
= 0;
1097 if (is_chip_be2_be3r(phba
))
1098 req_memsize
= sizeof(struct tcp_connect_and_offload_in
);
1100 req_memsize
= sizeof(struct tcp_connect_and_offload_in_v1
);
1102 nonemb_cmd
.va
= pci_alloc_consistent(phba
->ctrl
.pdev
,
1105 if (nonemb_cmd
.va
== NULL
) {
1107 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
1108 "BS_%d : Failed to allocate memory for"
1109 " mgmt_open_connection\n");
1111 beiscsi_free_ep(beiscsi_ep
);
1114 nonemb_cmd
.size
= req_memsize
;
1115 memset(nonemb_cmd
.va
, 0, nonemb_cmd
.size
);
1116 tag
= mgmt_open_connection(phba
, dst_addr
, beiscsi_ep
, &nonemb_cmd
);
1118 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
1119 "BS_%d : mgmt_open_connection Failed for cid=%d\n",
1120 beiscsi_ep
->ep_cid
);
1122 pci_free_consistent(phba
->ctrl
.pdev
, nonemb_cmd
.size
,
1123 nonemb_cmd
.va
, nonemb_cmd
.dma
);
1124 beiscsi_free_ep(beiscsi_ep
);
1128 ret
= beiscsi_mccq_compl_wait(phba
, tag
, NULL
, &nonemb_cmd
);
1130 beiscsi_log(phba
, KERN_ERR
,
1131 BEISCSI_LOG_CONFIG
| BEISCSI_LOG_MBOX
,
1132 "BS_%d : mgmt_open_connection Failed");
1135 pci_free_consistent(phba
->ctrl
.pdev
, nonemb_cmd
.size
,
1136 nonemb_cmd
.va
, nonemb_cmd
.dma
);
1138 beiscsi_free_ep(beiscsi_ep
);
1142 ptcpcnct_out
= (struct tcp_connect_and_offload_out
*)nonemb_cmd
.va
;
1143 beiscsi_ep
= ep
->dd_data
;
1144 beiscsi_ep
->fw_handle
= ptcpcnct_out
->connection_handle
;
1145 beiscsi_ep
->cid_vld
= 1;
1146 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1147 "BS_%d : mgmt_open_connection Success\n");
1149 pci_free_consistent(phba
->ctrl
.pdev
, nonemb_cmd
.size
,
1150 nonemb_cmd
.va
, nonemb_cmd
.dma
);
1155 * beiscsi_ep_connect - Ask chip to create TCP Conn
1156 * @scsi_host: Pointer to scsi_host structure
1157 * @dst_addr: The IP address of Target
1158 * @non_blocking: blocking or non-blocking call
1160 * This routines first asks chip to create a connection and then allocates an EP
1162 struct iscsi_endpoint
*
1163 beiscsi_ep_connect(struct Scsi_Host
*shost
, struct sockaddr
*dst_addr
,
1166 struct beiscsi_hba
*phba
;
1167 struct beiscsi_endpoint
*beiscsi_ep
;
1168 struct iscsi_endpoint
*ep
;
1173 pr_err("beiscsi_ep_connect shost is NULL\n");
1174 return ERR_PTR(ret
);
1177 phba
= iscsi_host_priv(shost
);
1178 if (!beiscsi_hba_is_online(phba
)) {
1180 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1181 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
1182 return ERR_PTR(ret
);
1184 if (!test_bit(BEISCSI_HBA_LINK_UP
, &phba
->state
)) {
1186 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
1187 "BS_%d : The Adapter Port state is Down!!!\n");
1188 return ERR_PTR(ret
);
1191 ep
= iscsi_create_endpoint(sizeof(struct beiscsi_endpoint
));
1194 return ERR_PTR(ret
);
1197 beiscsi_ep
= ep
->dd_data
;
1198 beiscsi_ep
->phba
= phba
;
1199 beiscsi_ep
->openiscsi_ep
= ep
;
1200 ret
= beiscsi_open_conn(ep
, NULL
, dst_addr
, non_blocking
);
1202 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
1203 "BS_%d : Failed in beiscsi_open_conn\n");
1210 iscsi_destroy_endpoint(ep
);
1211 return ERR_PTR(ret
);
1215 * beiscsi_ep_poll - Poll to see if connection is established
1216 * @ep: endpoint to be used
1217 * @timeout_ms: timeout specified in millisecs
1219 * Poll to see if TCP connection established
1221 int beiscsi_ep_poll(struct iscsi_endpoint
*ep
, int timeout_ms
)
1223 struct beiscsi_endpoint
*beiscsi_ep
= ep
->dd_data
;
1225 beiscsi_log(beiscsi_ep
->phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1226 "BS_%d : In beiscsi_ep_poll\n");
1228 if (beiscsi_ep
->cid_vld
== 1)
1235 * beiscsi_flush_cq()- Flush the CQ created.
1236 * @phba: ptr device priv structure.
1238 * Before the connection resource are freed flush
1239 * all the CQ enteries
1241 static void beiscsi_flush_cq(struct beiscsi_hba
*phba
)
1244 struct be_eq_obj
*pbe_eq
;
1245 struct hwi_controller
*phwi_ctrlr
;
1246 struct hwi_context_memory
*phwi_context
;
1248 phwi_ctrlr
= phba
->phwi_ctrlr
;
1249 phwi_context
= phwi_ctrlr
->phwi_ctxt
;
1251 for (i
= 0; i
< phba
->num_cpus
; i
++) {
1252 pbe_eq
= &phwi_context
->be_eq
[i
];
1253 irq_poll_disable(&pbe_eq
->iopoll
);
1254 beiscsi_process_cq(pbe_eq
, BE2_MAX_NUM_CQ_PROC
);
1255 irq_poll_enable(&pbe_eq
->iopoll
);
1260 * beiscsi_close_conn - Upload the connection
1261 * @ep: The iscsi endpoint
1262 * @flag: The type of connection closure
1264 static int beiscsi_close_conn(struct beiscsi_endpoint
*beiscsi_ep
, int flag
)
1268 struct beiscsi_hba
*phba
= beiscsi_ep
->phba
;
1270 tag
= mgmt_upload_connection(phba
, beiscsi_ep
->ep_cid
, flag
);
1272 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1273 "BS_%d : upload failed for cid 0x%x\n",
1274 beiscsi_ep
->ep_cid
);
1279 ret
= beiscsi_mccq_compl_wait(phba
, tag
, NULL
, NULL
);
1281 /* Flush the CQ entries */
1282 beiscsi_flush_cq(phba
);
1288 * beiscsi_unbind_conn_to_cid - Unbind the beiscsi_conn from phba conn table
1289 * @phba: The phba instance
1290 * @cid: The cid to free
1292 static int beiscsi_unbind_conn_to_cid(struct beiscsi_hba
*phba
,
1295 uint16_t cri_index
= BE_GET_CRI_FROM_CID(cid
);
1297 if (phba
->conn_table
[cri_index
])
1298 phba
->conn_table
[cri_index
] = NULL
;
1300 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1301 "BS_%d : Connection table Not occupied.\n");
1308 * beiscsi_ep_disconnect - Tears down the TCP connection
1309 * @ep: endpoint to be used
1311 * Tears down the TCP connection
1313 void beiscsi_ep_disconnect(struct iscsi_endpoint
*ep
)
1315 struct beiscsi_conn
*beiscsi_conn
;
1316 struct beiscsi_endpoint
*beiscsi_ep
;
1317 struct beiscsi_hba
*phba
;
1319 uint8_t mgmt_invalidate_flag
, tcp_upload_flag
;
1320 unsigned short savecfg_flag
= CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH
;
1322 beiscsi_ep
= ep
->dd_data
;
1323 phba
= beiscsi_ep
->phba
;
1324 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1325 "BS_%d : In beiscsi_ep_disconnect for ep_cid = %d\n",
1326 beiscsi_ep
->ep_cid
);
1328 if (beiscsi_ep
->conn
) {
1329 beiscsi_conn
= beiscsi_ep
->conn
;
1330 iscsi_suspend_queue(beiscsi_conn
->conn
);
1331 mgmt_invalidate_flag
= ~BEISCSI_NO_RST_ISSUE
;
1332 tcp_upload_flag
= CONNECTION_UPLOAD_GRACEFUL
;
1334 mgmt_invalidate_flag
= BEISCSI_NO_RST_ISSUE
;
1335 tcp_upload_flag
= CONNECTION_UPLOAD_ABORT
;
1338 if (!beiscsi_hba_is_online(phba
)) {
1339 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1340 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
1344 tag
= mgmt_invalidate_connection(phba
, beiscsi_ep
,
1346 mgmt_invalidate_flag
,
1349 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
1350 "BS_%d : mgmt_invalidate_connection Failed for cid=%d\n",
1351 beiscsi_ep
->ep_cid
);
1354 beiscsi_mccq_compl_wait(phba
, tag
, NULL
, NULL
);
1355 beiscsi_close_conn(beiscsi_ep
, tcp_upload_flag
);
1357 msleep(BEISCSI_LOGOUT_SYNC_DELAY
);
1358 beiscsi_free_ep(beiscsi_ep
);
1359 beiscsi_unbind_conn_to_cid(phba
, beiscsi_ep
->ep_cid
);
1360 iscsi_destroy_endpoint(beiscsi_ep
->openiscsi_ep
);
1363 umode_t
beiscsi_attr_is_visible(int param_type
, int param
)
1365 switch (param_type
) {
1366 case ISCSI_NET_PARAM
:
1368 case ISCSI_NET_PARAM_IFACE_ENABLE
:
1369 case ISCSI_NET_PARAM_IPV4_ADDR
:
1370 case ISCSI_NET_PARAM_IPV4_SUBNET
:
1371 case ISCSI_NET_PARAM_IPV4_BOOTPROTO
:
1372 case ISCSI_NET_PARAM_IPV4_GW
:
1373 case ISCSI_NET_PARAM_IPV6_ADDR
:
1374 case ISCSI_NET_PARAM_VLAN_ID
:
1375 case ISCSI_NET_PARAM_VLAN_PRIORITY
:
1376 case ISCSI_NET_PARAM_VLAN_ENABLED
:
1381 case ISCSI_HOST_PARAM
:
1383 case ISCSI_HOST_PARAM_HWADDRESS
:
1384 case ISCSI_HOST_PARAM_INITIATOR_NAME
:
1385 case ISCSI_HOST_PARAM_PORT_STATE
:
1386 case ISCSI_HOST_PARAM_PORT_SPEED
:
1393 case ISCSI_PARAM_MAX_RECV_DLENGTH
:
1394 case ISCSI_PARAM_MAX_XMIT_DLENGTH
:
1395 case ISCSI_PARAM_HDRDGST_EN
:
1396 case ISCSI_PARAM_DATADGST_EN
:
1397 case ISCSI_PARAM_CONN_ADDRESS
:
1398 case ISCSI_PARAM_CONN_PORT
:
1399 case ISCSI_PARAM_EXP_STATSN
:
1400 case ISCSI_PARAM_PERSISTENT_ADDRESS
:
1401 case ISCSI_PARAM_PERSISTENT_PORT
:
1402 case ISCSI_PARAM_PING_TMO
:
1403 case ISCSI_PARAM_RECV_TMO
:
1404 case ISCSI_PARAM_INITIAL_R2T_EN
:
1405 case ISCSI_PARAM_MAX_R2T
:
1406 case ISCSI_PARAM_IMM_DATA_EN
:
1407 case ISCSI_PARAM_FIRST_BURST
:
1408 case ISCSI_PARAM_MAX_BURST
:
1409 case ISCSI_PARAM_PDU_INORDER_EN
:
1410 case ISCSI_PARAM_DATASEQ_INORDER_EN
:
1411 case ISCSI_PARAM_ERL
:
1412 case ISCSI_PARAM_TARGET_NAME
:
1413 case ISCSI_PARAM_TPGT
:
1414 case ISCSI_PARAM_USERNAME
:
1415 case ISCSI_PARAM_PASSWORD
:
1416 case ISCSI_PARAM_USERNAME_IN
:
1417 case ISCSI_PARAM_PASSWORD_IN
:
1418 case ISCSI_PARAM_FAST_ABORT
:
1419 case ISCSI_PARAM_ABORT_TMO
:
1420 case ISCSI_PARAM_LU_RESET_TMO
:
1421 case ISCSI_PARAM_IFACE_NAME
:
1422 case ISCSI_PARAM_INITIATOR_NAME
: