1 // SPDX-License-Identifier: GPL-2.0-only
3 * This file is part of the Emulex Linux Device Driver for Enterprise iSCSI
4 * Host Bus Adapters. Refer to the README file included with this package
5 * for driver version and adapter compatibility.
7 * Copyright (c) 2018 Broadcom. All Rights Reserved.
8 * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
10 * Contact Information:
11 * linux-drivers@broadcom.com
14 #include <scsi/libiscsi.h>
15 #include <scsi/scsi_transport_iscsi.h>
16 #include <scsi/scsi_transport.h>
17 #include <scsi/scsi_cmnd.h>
18 #include <scsi/scsi_device.h>
19 #include <scsi/scsi_host.h>
20 #include <scsi/scsi_netlink.h>
21 #include <net/netlink.h>
22 #include <scsi/scsi.h>
26 extern struct iscsi_transport beiscsi_iscsi_transport
;
29 * beiscsi_session_create - creates a new iscsi session
30 * @ep: pointer to iscsi ep
31 * @cmds_max: max commands supported
32 * @qdepth: max queue depth supported
33 * @initial_cmdsn: initial iscsi CMDSN
35 struct iscsi_cls_session
*beiscsi_session_create(struct iscsi_endpoint
*ep
,
40 struct Scsi_Host
*shost
;
41 struct beiscsi_endpoint
*beiscsi_ep
;
42 struct iscsi_cls_session
*cls_session
;
43 struct beiscsi_hba
*phba
;
44 struct iscsi_session
*sess
;
45 struct beiscsi_session
*beiscsi_sess
;
46 struct beiscsi_io_task
*io_task
;
50 pr_err("beiscsi_session_create: invalid ep\n");
53 beiscsi_ep
= ep
->dd_data
;
54 phba
= beiscsi_ep
->phba
;
56 if (!beiscsi_hba_is_online(phba
)) {
57 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
58 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
62 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
63 "BS_%d : In beiscsi_session_create\n");
64 if (cmds_max
> beiscsi_ep
->phba
->params
.wrbs_per_cxn
) {
65 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
66 "BS_%d : Cannot handle %d cmds."
67 "Max cmds per session supported is %d. Using %d."
69 beiscsi_ep
->phba
->params
.wrbs_per_cxn
,
70 beiscsi_ep
->phba
->params
.wrbs_per_cxn
);
72 cmds_max
= beiscsi_ep
->phba
->params
.wrbs_per_cxn
;
76 cls_session
= iscsi_session_setup(&beiscsi_iscsi_transport
,
78 sizeof(*beiscsi_sess
),
80 initial_cmdsn
, ISCSI_MAX_TARGET
);
83 sess
= cls_session
->dd_data
;
84 beiscsi_sess
= sess
->dd_data
;
85 beiscsi_sess
->bhs_pool
= dma_pool_create("beiscsi_bhs_pool",
87 sizeof(struct be_cmd_bhs
),
89 if (!beiscsi_sess
->bhs_pool
)
94 iscsi_session_teardown(cls_session
);
99 * beiscsi_session_destroy - destroys iscsi session
100 * @cls_session: pointer to iscsi cls session
102 * Destroys iSCSI session instance and releases
103 * resources allocated for it.
105 void beiscsi_session_destroy(struct iscsi_cls_session
*cls_session
)
107 struct iscsi_session
*sess
= cls_session
->dd_data
;
108 struct beiscsi_session
*beiscsi_sess
= sess
->dd_data
;
110 printk(KERN_INFO
"In beiscsi_session_destroy\n");
111 dma_pool_destroy(beiscsi_sess
->bhs_pool
);
112 iscsi_session_teardown(cls_session
);
116 * beiscsi_session_fail(): Closing session with appropriate error
117 * @cls_session: ptr to session
119 void beiscsi_session_fail(struct iscsi_cls_session
*cls_session
)
121 iscsi_session_failure(cls_session
->dd_data
, ISCSI_ERR_CONN_FAILED
);
126 * beiscsi_conn_create - create an instance of iscsi connection
127 * @cls_session: ptr to iscsi_cls_session
130 struct iscsi_cls_conn
*
131 beiscsi_conn_create(struct iscsi_cls_session
*cls_session
, u32 cid
)
133 struct beiscsi_hba
*phba
;
134 struct Scsi_Host
*shost
;
135 struct iscsi_cls_conn
*cls_conn
;
136 struct beiscsi_conn
*beiscsi_conn
;
137 struct iscsi_conn
*conn
;
138 struct iscsi_session
*sess
;
139 struct beiscsi_session
*beiscsi_sess
;
141 shost
= iscsi_session_to_shost(cls_session
);
142 phba
= iscsi_host_priv(shost
);
144 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
145 "BS_%d : In beiscsi_conn_create ,cid"
146 "from iscsi layer=%d\n", cid
);
148 cls_conn
= iscsi_conn_setup(cls_session
, sizeof(*beiscsi_conn
), cid
);
152 conn
= cls_conn
->dd_data
;
153 beiscsi_conn
= conn
->dd_data
;
154 beiscsi_conn
->ep
= NULL
;
155 beiscsi_conn
->phba
= phba
;
156 beiscsi_conn
->conn
= conn
;
157 sess
= cls_session
->dd_data
;
158 beiscsi_sess
= sess
->dd_data
;
159 beiscsi_conn
->beiscsi_sess
= beiscsi_sess
;
164 * beiscsi_conn_bind - Binds iscsi session/connection with TCP connection
165 * @cls_session: pointer to iscsi cls session
166 * @cls_conn: pointer to iscsi cls conn
167 * @transport_fd: EP handle(64 bit)
168 * @is_leading: indicate if this is the session leading connection (MCS)
170 * This function binds the TCP Conn with iSCSI Connection and Session.
172 int beiscsi_conn_bind(struct iscsi_cls_session
*cls_session
,
173 struct iscsi_cls_conn
*cls_conn
,
174 u64 transport_fd
, int is_leading
)
176 struct iscsi_conn
*conn
= cls_conn
->dd_data
;
177 struct beiscsi_conn
*beiscsi_conn
= conn
->dd_data
;
178 struct Scsi_Host
*shost
= iscsi_session_to_shost(cls_session
);
179 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
180 struct hwi_controller
*phwi_ctrlr
= phba
->phwi_ctrlr
;
181 struct hwi_wrb_context
*pwrb_context
;
182 struct beiscsi_endpoint
*beiscsi_ep
;
183 struct iscsi_endpoint
*ep
;
187 ep
= iscsi_lookup_endpoint(transport_fd
);
191 beiscsi_ep
= ep
->dd_data
;
193 if (iscsi_conn_bind(cls_session
, cls_conn
, is_leading
)) {
198 if (beiscsi_ep
->phba
!= phba
) {
199 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
200 "BS_%d : beiscsi_ep->hba=%p not equal to phba=%p\n",
201 beiscsi_ep
->phba
, phba
);
205 cri_index
= BE_GET_CRI_FROM_CID(beiscsi_ep
->ep_cid
);
206 if (phba
->conn_table
[cri_index
]) {
207 if (beiscsi_conn
!= phba
->conn_table
[cri_index
] ||
208 beiscsi_ep
!= phba
->conn_table
[cri_index
]->ep
) {
209 __beiscsi_log(phba
, KERN_ERR
,
210 "BS_%d : conn_table not empty at %u: cid %u conn %p:%p\n",
214 phba
->conn_table
[cri_index
]);
220 beiscsi_conn
->beiscsi_conn_cid
= beiscsi_ep
->ep_cid
;
221 beiscsi_conn
->ep
= beiscsi_ep
;
222 beiscsi_ep
->conn
= beiscsi_conn
;
224 * Each connection is associated with a WRBQ kept in wrb_context.
225 * Store doorbell offset for transmit path.
227 pwrb_context
= &phwi_ctrlr
->wrb_context
[cri_index
];
228 beiscsi_conn
->doorbell_offset
= pwrb_context
->doorbell_offset
;
229 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
230 "BS_%d : cid %d phba->conn_table[%u]=%p\n",
231 beiscsi_ep
->ep_cid
, cri_index
, beiscsi_conn
);
232 phba
->conn_table
[cri_index
] = beiscsi_conn
;
235 iscsi_put_endpoint(ep
);
239 static int beiscsi_iface_create_ipv4(struct beiscsi_hba
*phba
)
241 if (phba
->ipv4_iface
)
244 phba
->ipv4_iface
= iscsi_create_iface(phba
->shost
,
245 &beiscsi_iscsi_transport
,
246 ISCSI_IFACE_TYPE_IPV4
,
248 if (!phba
->ipv4_iface
) {
249 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
251 "create default IPv4 address.\n");
258 static int beiscsi_iface_create_ipv6(struct beiscsi_hba
*phba
)
260 if (phba
->ipv6_iface
)
263 phba
->ipv6_iface
= iscsi_create_iface(phba
->shost
,
264 &beiscsi_iscsi_transport
,
265 ISCSI_IFACE_TYPE_IPV6
,
267 if (!phba
->ipv6_iface
) {
268 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
270 "create default IPv6 address.\n");
277 void beiscsi_iface_create_default(struct beiscsi_hba
*phba
)
279 struct be_cmd_get_if_info_resp
*if_info
;
281 if (!beiscsi_if_get_info(phba
, BEISCSI_IP_TYPE_V4
, &if_info
)) {
282 beiscsi_iface_create_ipv4(phba
);
286 if (!beiscsi_if_get_info(phba
, BEISCSI_IP_TYPE_V6
, &if_info
)) {
287 beiscsi_iface_create_ipv6(phba
);
292 void beiscsi_iface_destroy_default(struct beiscsi_hba
*phba
)
294 if (phba
->ipv6_iface
) {
295 iscsi_destroy_iface(phba
->ipv6_iface
);
296 phba
->ipv6_iface
= NULL
;
298 if (phba
->ipv4_iface
) {
299 iscsi_destroy_iface(phba
->ipv4_iface
);
300 phba
->ipv4_iface
= NULL
;
305 * beiscsi_iface_config_vlan()- Set the VLAN TAG
306 * @shost: Scsi Host for the driver instance
307 * @iface_param: Interface paramters
309 * Set the VLAN TAG for the adapter or disable
314 * Failure: Non-Zero Value
317 beiscsi_iface_config_vlan(struct Scsi_Host
*shost
,
318 struct iscsi_iface_param_info
*iface_param
)
320 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
323 switch (iface_param
->param
) {
324 case ISCSI_NET_PARAM_VLAN_ENABLED
:
326 if (iface_param
->value
[0] != ISCSI_VLAN_ENABLE
)
327 ret
= beiscsi_if_set_vlan(phba
, BEISCSI_VLAN_DISABLE
);
329 case ISCSI_NET_PARAM_VLAN_TAG
:
330 ret
= beiscsi_if_set_vlan(phba
,
331 *((uint16_t *)iface_param
->value
));
339 beiscsi_iface_config_ipv4(struct Scsi_Host
*shost
,
340 struct iscsi_iface_param_info
*info
,
341 void *data
, uint32_t dt_len
)
343 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
344 u8
*ip
= NULL
, *subnet
= NULL
, *gw
;
348 /* Check the param */
349 switch (info
->param
) {
350 case ISCSI_NET_PARAM_IFACE_ENABLE
:
351 if (info
->value
[0] == ISCSI_IFACE_ENABLE
)
352 ret
= beiscsi_iface_create_ipv4(phba
);
354 iscsi_destroy_iface(phba
->ipv4_iface
);
355 phba
->ipv4_iface
= NULL
;
358 case ISCSI_NET_PARAM_IPV4_GW
:
360 ret
= beiscsi_if_set_gw(phba
, BEISCSI_IP_TYPE_V4
, gw
);
362 case ISCSI_NET_PARAM_IPV4_BOOTPROTO
:
363 if (info
->value
[0] == ISCSI_BOOTPROTO_DHCP
)
364 ret
= beiscsi_if_en_dhcp(phba
, BEISCSI_IP_TYPE_V4
);
365 else if (info
->value
[0] == ISCSI_BOOTPROTO_STATIC
)
366 /* release DHCP IP address */
367 ret
= beiscsi_if_en_static(phba
, BEISCSI_IP_TYPE_V4
,
370 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
371 "BS_%d : Invalid BOOTPROTO: %d\n",
374 case ISCSI_NET_PARAM_IPV4_ADDR
:
376 nla
= nla_find(data
, dt_len
, ISCSI_NET_PARAM_IPV4_SUBNET
);
378 info
= nla_data(nla
);
379 subnet
= info
->value
;
381 ret
= beiscsi_if_en_static(phba
, BEISCSI_IP_TYPE_V4
,
384 case ISCSI_NET_PARAM_IPV4_SUBNET
:
386 * OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR ioctl needs IP
387 * and subnet both. Find IP to be applied for this subnet.
389 subnet
= info
->value
;
390 nla
= nla_find(data
, dt_len
, ISCSI_NET_PARAM_IPV4_ADDR
);
392 info
= nla_data(nla
);
395 ret
= beiscsi_if_en_static(phba
, BEISCSI_IP_TYPE_V4
,
404 beiscsi_iface_config_ipv6(struct Scsi_Host
*shost
,
405 struct iscsi_iface_param_info
*iface_param
,
406 void *data
, uint32_t dt_len
)
408 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
411 switch (iface_param
->param
) {
412 case ISCSI_NET_PARAM_IFACE_ENABLE
:
413 if (iface_param
->value
[0] == ISCSI_IFACE_ENABLE
)
414 ret
= beiscsi_iface_create_ipv6(phba
);
416 iscsi_destroy_iface(phba
->ipv6_iface
);
417 phba
->ipv6_iface
= NULL
;
420 case ISCSI_NET_PARAM_IPV6_ADDR
:
421 ret
= beiscsi_if_en_static(phba
, BEISCSI_IP_TYPE_V6
,
422 iface_param
->value
, NULL
);
429 int beiscsi_iface_set_param(struct Scsi_Host
*shost
,
430 void *data
, uint32_t dt_len
)
432 struct iscsi_iface_param_info
*iface_param
= NULL
;
433 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
434 struct nlattr
*attrib
;
435 uint32_t rm_len
= dt_len
;
438 if (!beiscsi_hba_is_online(phba
)) {
439 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
440 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
444 /* update interface_handle */
445 ret
= beiscsi_if_get_handle(phba
);
447 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
448 "BS_%d : Getting Interface Handle Failed\n");
452 nla_for_each_attr(attrib
, data
, dt_len
, rm_len
) {
453 /* ignore nla_type as it is never used */
454 if (nla_len(attrib
) < sizeof(*iface_param
))
457 iface_param
= nla_data(attrib
);
459 if (iface_param
->param_type
!= ISCSI_NET_PARAM
)
463 * BE2ISCSI only supports 1 interface
465 if (iface_param
->iface_num
) {
466 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
467 "BS_%d : Invalid iface_num %d."
468 "Only iface_num 0 is supported.\n",
469 iface_param
->iface_num
);
474 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
475 "BS_%d : %s.0 set param %d",
476 (iface_param
->iface_type
== ISCSI_IFACE_TYPE_IPV4
) ?
477 "ipv4" : "ipv6", iface_param
->param
);
480 switch (iface_param
->param
) {
481 case ISCSI_NET_PARAM_VLAN_ENABLED
:
482 case ISCSI_NET_PARAM_VLAN_TAG
:
483 ret
= beiscsi_iface_config_vlan(shost
, iface_param
);
486 switch (iface_param
->iface_type
) {
487 case ISCSI_IFACE_TYPE_IPV4
:
488 ret
= beiscsi_iface_config_ipv4(shost
,
492 case ISCSI_IFACE_TYPE_IPV6
:
493 ret
= beiscsi_iface_config_ipv6(shost
,
501 __beiscsi_log(phba
, KERN_ERR
,
502 "BS_%d : %s.0 set param %d not permitted",
503 (iface_param
->iface_type
==
504 ISCSI_IFACE_TYPE_IPV4
) ? "ipv4" : "ipv6",
515 static int __beiscsi_iface_get_param(struct beiscsi_hba
*phba
,
516 struct iscsi_iface
*iface
,
517 int param
, char *buf
)
519 struct be_cmd_get_if_info_resp
*if_info
;
520 int len
, ip_type
= BEISCSI_IP_TYPE_V4
;
522 if (iface
->iface_type
== ISCSI_IFACE_TYPE_IPV6
)
523 ip_type
= BEISCSI_IP_TYPE_V6
;
525 len
= beiscsi_if_get_info(phba
, ip_type
, &if_info
);
530 case ISCSI_NET_PARAM_IPV4_ADDR
:
531 len
= sprintf(buf
, "%pI4\n", if_info
->ip_addr
.addr
);
533 case ISCSI_NET_PARAM_IPV6_ADDR
:
534 len
= sprintf(buf
, "%pI6\n", if_info
->ip_addr
.addr
);
536 case ISCSI_NET_PARAM_IPV4_BOOTPROTO
:
537 if (!if_info
->dhcp_state
)
538 len
= sprintf(buf
, "static\n");
540 len
= sprintf(buf
, "dhcp\n");
542 case ISCSI_NET_PARAM_IPV4_SUBNET
:
543 len
= sprintf(buf
, "%pI4\n", if_info
->ip_addr
.subnet_mask
);
545 case ISCSI_NET_PARAM_VLAN_ENABLED
:
546 len
= sprintf(buf
, "%s\n",
547 (if_info
->vlan_priority
== BEISCSI_VLAN_DISABLE
) ?
548 "disable" : "enable");
550 case ISCSI_NET_PARAM_VLAN_ID
:
551 if (if_info
->vlan_priority
== BEISCSI_VLAN_DISABLE
)
554 len
= sprintf(buf
, "%d\n",
555 (if_info
->vlan_priority
&
558 case ISCSI_NET_PARAM_VLAN_PRIORITY
:
559 if (if_info
->vlan_priority
== BEISCSI_VLAN_DISABLE
)
562 len
= sprintf(buf
, "%d\n",
563 ((if_info
->vlan_priority
>> 13) &
564 ISCSI_MAX_VLAN_PRIORITY
));
574 int beiscsi_iface_get_param(struct iscsi_iface
*iface
,
575 enum iscsi_param_type param_type
,
576 int param
, char *buf
)
578 struct Scsi_Host
*shost
= iscsi_iface_to_shost(iface
);
579 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
580 struct be_cmd_get_def_gateway_resp gateway
;
583 if (param_type
!= ISCSI_NET_PARAM
)
585 if (!beiscsi_hba_is_online(phba
)) {
586 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
587 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
592 case ISCSI_NET_PARAM_IPV4_ADDR
:
593 case ISCSI_NET_PARAM_IPV4_SUBNET
:
594 case ISCSI_NET_PARAM_IPV4_BOOTPROTO
:
595 case ISCSI_NET_PARAM_IPV6_ADDR
:
596 case ISCSI_NET_PARAM_VLAN_ENABLED
:
597 case ISCSI_NET_PARAM_VLAN_ID
:
598 case ISCSI_NET_PARAM_VLAN_PRIORITY
:
599 len
= __beiscsi_iface_get_param(phba
, iface
, param
, buf
);
601 case ISCSI_NET_PARAM_IFACE_ENABLE
:
602 if (iface
->iface_type
== ISCSI_IFACE_TYPE_IPV4
)
603 len
= sprintf(buf
, "%s\n",
604 phba
->ipv4_iface
? "enable" : "disable");
605 else if (iface
->iface_type
== ISCSI_IFACE_TYPE_IPV6
)
606 len
= sprintf(buf
, "%s\n",
607 phba
->ipv6_iface
? "enable" : "disable");
609 case ISCSI_NET_PARAM_IPV4_GW
:
610 memset(&gateway
, 0, sizeof(gateway
));
611 len
= beiscsi_if_get_gw(phba
, BEISCSI_IP_TYPE_V4
, &gateway
);
613 len
= sprintf(buf
, "%pI4\n", &gateway
.ip_addr
.addr
);
621 * beiscsi_ep_get_param - get the iscsi parameter
622 * @ep: pointer to iscsi ep
623 * @param: parameter type identifier
624 * @buf: buffer pointer
626 * returns iscsi parameter
628 int beiscsi_ep_get_param(struct iscsi_endpoint
*ep
,
629 enum iscsi_param param
, char *buf
)
631 struct beiscsi_endpoint
*beiscsi_ep
= ep
->dd_data
;
634 beiscsi_log(beiscsi_ep
->phba
, KERN_INFO
,
636 "BS_%d : In beiscsi_ep_get_param,"
637 " param= %d\n", param
);
640 case ISCSI_PARAM_CONN_PORT
:
641 len
= sprintf(buf
, "%hu\n", beiscsi_ep
->dst_tcpport
);
643 case ISCSI_PARAM_CONN_ADDRESS
:
644 if (beiscsi_ep
->ip_type
== BEISCSI_IP_TYPE_V4
)
645 len
= sprintf(buf
, "%pI4\n", &beiscsi_ep
->dst_addr
);
647 len
= sprintf(buf
, "%pI6\n", &beiscsi_ep
->dst6_addr
);
655 int beiscsi_set_param(struct iscsi_cls_conn
*cls_conn
,
656 enum iscsi_param param
, char *buf
, int buflen
)
658 struct iscsi_conn
*conn
= cls_conn
->dd_data
;
659 struct iscsi_session
*session
= conn
->session
;
660 struct beiscsi_hba
*phba
= NULL
;
663 phba
= ((struct beiscsi_conn
*)conn
->dd_data
)->phba
;
664 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
665 "BS_%d : In beiscsi_conn_set_param,"
666 " param= %d\n", param
);
668 ret
= iscsi_set_param(cls_conn
, param
, buf
, buflen
);
672 * If userspace tried to set the value to higher than we can
673 * support override here.
676 case ISCSI_PARAM_FIRST_BURST
:
677 if (session
->first_burst
> 8192)
678 session
->first_burst
= 8192;
680 case ISCSI_PARAM_MAX_RECV_DLENGTH
:
681 if (conn
->max_recv_dlength
> 65536)
682 conn
->max_recv_dlength
= 65536;
684 case ISCSI_PARAM_MAX_BURST
:
685 if (session
->max_burst
> 262144)
686 session
->max_burst
= 262144;
688 case ISCSI_PARAM_MAX_XMIT_DLENGTH
:
689 if (conn
->max_xmit_dlength
> 65536)
690 conn
->max_xmit_dlength
= 65536;
700 * beiscsi_get_port_state - Get the Port State
701 * @shost : pointer to scsi_host structure
704 static void beiscsi_get_port_state(struct Scsi_Host
*shost
)
706 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
707 struct iscsi_cls_host
*ihost
= shost
->shost_data
;
709 ihost
->port_state
= test_bit(BEISCSI_HBA_LINK_UP
, &phba
->state
) ?
710 ISCSI_PORT_STATE_UP
: ISCSI_PORT_STATE_DOWN
;
714 * beiscsi_get_port_speed - Get the Port Speed from Adapter
715 * @shost : pointer to scsi_host structure
718 static void beiscsi_get_port_speed(struct Scsi_Host
*shost
)
720 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
721 struct iscsi_cls_host
*ihost
= shost
->shost_data
;
723 switch (phba
->port_speed
) {
724 case BE2ISCSI_LINK_SPEED_10MBPS
:
725 ihost
->port_speed
= ISCSI_PORT_SPEED_10MBPS
;
727 case BE2ISCSI_LINK_SPEED_100MBPS
:
728 ihost
->port_speed
= ISCSI_PORT_SPEED_100MBPS
;
730 case BE2ISCSI_LINK_SPEED_1GBPS
:
731 ihost
->port_speed
= ISCSI_PORT_SPEED_1GBPS
;
733 case BE2ISCSI_LINK_SPEED_10GBPS
:
734 ihost
->port_speed
= ISCSI_PORT_SPEED_10GBPS
;
736 case BE2ISCSI_LINK_SPEED_25GBPS
:
737 ihost
->port_speed
= ISCSI_PORT_SPEED_25GBPS
;
739 case BE2ISCSI_LINK_SPEED_40GBPS
:
740 ihost
->port_speed
= ISCSI_PORT_SPEED_40GBPS
;
743 ihost
->port_speed
= ISCSI_PORT_SPEED_UNKNOWN
;
748 * beiscsi_get_host_param - get the iscsi parameter
749 * @shost: pointer to scsi_host structure
750 * @param: parameter type identifier
751 * @buf: buffer pointer
754 int beiscsi_get_host_param(struct Scsi_Host
*shost
,
755 enum iscsi_host_param param
, char *buf
)
757 struct beiscsi_hba
*phba
= iscsi_host_priv(shost
);
760 if (!beiscsi_hba_is_online(phba
)) {
761 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
762 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
765 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
766 "BS_%d : In beiscsi_get_host_param, param = %d\n", param
);
769 case ISCSI_HOST_PARAM_HWADDRESS
:
770 status
= beiscsi_get_macaddr(buf
, phba
);
772 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
773 "BS_%d : beiscsi_get_macaddr Failed\n");
777 case ISCSI_HOST_PARAM_INITIATOR_NAME
:
778 /* try fetching user configured name first */
779 status
= beiscsi_get_initiator_name(phba
, buf
, true);
781 status
= beiscsi_get_initiator_name(phba
, buf
, false);
783 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
784 "BS_%d : Retrieving Initiator Name Failed\n");
789 case ISCSI_HOST_PARAM_PORT_STATE
:
790 beiscsi_get_port_state(shost
);
791 status
= sprintf(buf
, "%s\n", iscsi_get_port_state_name(shost
));
793 case ISCSI_HOST_PARAM_PORT_SPEED
:
794 beiscsi_get_port_speed(shost
);
795 status
= sprintf(buf
, "%s\n", iscsi_get_port_speed_name(shost
));
798 return iscsi_host_get_param(shost
, param
, buf
);
803 int beiscsi_get_macaddr(char *buf
, struct beiscsi_hba
*phba
)
805 struct be_cmd_get_nic_conf_resp resp
;
808 if (phba
->mac_addr_set
)
809 return sysfs_format_mac(buf
, phba
->mac_address
, ETH_ALEN
);
811 memset(&resp
, 0, sizeof(resp
));
812 rc
= mgmt_get_nic_conf(phba
, &resp
);
816 phba
->mac_addr_set
= true;
817 memcpy(phba
->mac_address
, resp
.mac_address
, ETH_ALEN
);
818 return sysfs_format_mac(buf
, phba
->mac_address
, ETH_ALEN
);
822 * beiscsi_conn_get_stats - get the iscsi stats
823 * @cls_conn: pointer to iscsi cls conn
824 * @stats: pointer to iscsi_stats structure
826 * returns iscsi stats
828 void beiscsi_conn_get_stats(struct iscsi_cls_conn
*cls_conn
,
829 struct iscsi_stats
*stats
)
831 struct iscsi_conn
*conn
= cls_conn
->dd_data
;
832 struct beiscsi_hba
*phba
= NULL
;
834 phba
= ((struct beiscsi_conn
*)conn
->dd_data
)->phba
;
835 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
836 "BS_%d : In beiscsi_conn_get_stats\n");
838 stats
->txdata_octets
= conn
->txdata_octets
;
839 stats
->rxdata_octets
= conn
->rxdata_octets
;
840 stats
->dataout_pdus
= conn
->dataout_pdus_cnt
;
841 stats
->scsirsp_pdus
= conn
->scsirsp_pdus_cnt
;
842 stats
->scsicmd_pdus
= conn
->scsicmd_pdus_cnt
;
843 stats
->datain_pdus
= conn
->datain_pdus_cnt
;
844 stats
->tmfrsp_pdus
= conn
->tmfrsp_pdus_cnt
;
845 stats
->tmfcmd_pdus
= conn
->tmfcmd_pdus_cnt
;
846 stats
->r2t_pdus
= conn
->r2t_pdus_cnt
;
847 stats
->digest_err
= 0;
848 stats
->timeout_err
= 0;
849 stats
->custom_length
= 1;
850 strcpy(stats
->custom
[0].desc
, "eh_abort_cnt");
851 stats
->custom
[0].value
= conn
->eh_abort_cnt
;
855 * beiscsi_set_params_for_offld - get the parameters for offload
856 * @beiscsi_conn: pointer to beiscsi_conn
857 * @params: pointer to offload_params structure
859 static void beiscsi_set_params_for_offld(struct beiscsi_conn
*beiscsi_conn
,
860 struct beiscsi_offload_params
*params
)
862 struct iscsi_conn
*conn
= beiscsi_conn
->conn
;
863 struct iscsi_session
*session
= conn
->session
;
865 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, max_burst_length
,
866 params
, session
->max_burst
);
867 AMAP_SET_BITS(struct amap_beiscsi_offload_params
,
868 max_send_data_segment_length
, params
,
869 conn
->max_xmit_dlength
);
870 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, first_burst_length
,
871 params
, session
->first_burst
);
872 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, erl
, params
,
874 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, dde
, params
,
876 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, hde
, params
,
878 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, ir2t
, params
,
879 session
->initial_r2t_en
);
880 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, imd
, params
,
881 session
->imm_data_en
);
882 AMAP_SET_BITS(struct amap_beiscsi_offload_params
,
883 data_seq_inorder
, params
,
884 session
->dataseq_inorder_en
);
885 AMAP_SET_BITS(struct amap_beiscsi_offload_params
,
886 pdu_seq_inorder
, params
,
887 session
->pdu_inorder_en
);
888 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, max_r2t
, params
,
890 AMAP_SET_BITS(struct amap_beiscsi_offload_params
, exp_statsn
, params
,
891 (conn
->exp_statsn
- 1));
892 AMAP_SET_BITS(struct amap_beiscsi_offload_params
,
893 max_recv_data_segment_length
, params
,
894 conn
->max_recv_dlength
);
899 * beiscsi_conn_start - offload of session to chip
900 * @cls_conn: pointer to beiscsi_conn
902 int beiscsi_conn_start(struct iscsi_cls_conn
*cls_conn
)
904 struct iscsi_conn
*conn
= cls_conn
->dd_data
;
905 struct beiscsi_conn
*beiscsi_conn
= conn
->dd_data
;
906 struct beiscsi_endpoint
*beiscsi_ep
;
907 struct beiscsi_offload_params params
;
908 struct beiscsi_hba
*phba
;
910 phba
= ((struct beiscsi_conn
*)conn
->dd_data
)->phba
;
912 if (!beiscsi_hba_is_online(phba
)) {
913 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
914 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
917 beiscsi_log(beiscsi_conn
->phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
918 "BS_%d : In beiscsi_conn_start\n");
920 memset(¶ms
, 0, sizeof(struct beiscsi_offload_params
));
921 beiscsi_ep
= beiscsi_conn
->ep
;
923 beiscsi_log(beiscsi_conn
->phba
, KERN_ERR
,
925 "BS_%d : In beiscsi_conn_start , no beiscsi_ep\n");
927 beiscsi_conn
->login_in_progress
= 0;
928 beiscsi_set_params_for_offld(beiscsi_conn
, ¶ms
);
929 beiscsi_offload_connection(beiscsi_conn
, ¶ms
);
930 iscsi_conn_start(cls_conn
);
935 * beiscsi_get_cid - Allocate a cid
936 * @phba: The phba instance
938 static int beiscsi_get_cid(struct beiscsi_hba
*phba
)
940 uint16_t cid_avlbl_ulp0
, cid_avlbl_ulp1
;
941 unsigned short cid
, cid_from_ulp
;
942 struct ulp_cid_info
*cid_info
;
944 /* Find the ULP which has more CID available */
945 cid_avlbl_ulp0
= (phba
->cid_array_info
[BEISCSI_ULP0
]) ?
946 BEISCSI_ULP0_AVLBL_CID(phba
) : 0;
947 cid_avlbl_ulp1
= (phba
->cid_array_info
[BEISCSI_ULP1
]) ?
948 BEISCSI_ULP1_AVLBL_CID(phba
) : 0;
949 cid_from_ulp
= (cid_avlbl_ulp0
> cid_avlbl_ulp1
) ?
950 BEISCSI_ULP0
: BEISCSI_ULP1
;
952 * If iSCSI protocol is loaded only on ULP 0, and when cid_avlbl_ulp
953 * is ZERO for both, ULP 1 is returned.
954 * Check if ULP is loaded before getting new CID.
956 if (!test_bit(cid_from_ulp
, (void *)&phba
->fw_config
.ulp_supported
))
957 return BE_INVALID_CID
;
959 cid_info
= phba
->cid_array_info
[cid_from_ulp
];
960 cid
= cid_info
->cid_array
[cid_info
->cid_alloc
];
961 if (!cid_info
->avlbl_cids
|| cid
== BE_INVALID_CID
) {
962 __beiscsi_log(phba
, KERN_ERR
,
963 "BS_%d : failed to get cid: available %u:%u\n",
964 cid_info
->avlbl_cids
, cid_info
->cid_free
);
965 return BE_INVALID_CID
;
968 cid_info
->cid_array
[cid_info
->cid_alloc
++] = BE_INVALID_CID
;
969 if (cid_info
->cid_alloc
== BEISCSI_GET_CID_COUNT(phba
, cid_from_ulp
))
970 cid_info
->cid_alloc
= 0;
971 cid_info
->avlbl_cids
--;
976 * beiscsi_put_cid - Free the cid
977 * @phba: The phba for which the cid is being freed
978 * @cid: The cid to free
980 static void beiscsi_put_cid(struct beiscsi_hba
*phba
, unsigned short cid
)
982 uint16_t cri_index
= BE_GET_CRI_FROM_CID(cid
);
983 struct hwi_wrb_context
*pwrb_context
;
984 struct hwi_controller
*phwi_ctrlr
;
985 struct ulp_cid_info
*cid_info
;
986 uint16_t cid_post_ulp
;
988 phwi_ctrlr
= phba
->phwi_ctrlr
;
989 pwrb_context
= &phwi_ctrlr
->wrb_context
[cri_index
];
990 cid_post_ulp
= pwrb_context
->ulp_num
;
992 cid_info
= phba
->cid_array_info
[cid_post_ulp
];
993 /* fill only in empty slot */
994 if (cid_info
->cid_array
[cid_info
->cid_free
] != BE_INVALID_CID
) {
995 __beiscsi_log(phba
, KERN_ERR
,
996 "BS_%d : failed to put cid %u: available %u:%u\n",
997 cid
, cid_info
->avlbl_cids
, cid_info
->cid_free
);
1000 cid_info
->cid_array
[cid_info
->cid_free
++] = cid
;
1001 if (cid_info
->cid_free
== BEISCSI_GET_CID_COUNT(phba
, cid_post_ulp
))
1002 cid_info
->cid_free
= 0;
1003 cid_info
->avlbl_cids
++;
1007 * beiscsi_free_ep - free endpoint
1008 * @beiscsi_ep: pointer to device endpoint struct
1010 static void beiscsi_free_ep(struct beiscsi_endpoint
*beiscsi_ep
)
1012 struct beiscsi_hba
*phba
= beiscsi_ep
->phba
;
1013 struct beiscsi_conn
*beiscsi_conn
;
1015 beiscsi_put_cid(phba
, beiscsi_ep
->ep_cid
);
1016 beiscsi_ep
->phba
= NULL
;
1017 /* clear this to track freeing in beiscsi_ep_disconnect */
1018 phba
->ep_array
[BE_GET_CRI_FROM_CID(beiscsi_ep
->ep_cid
)] = NULL
;
1021 * Check if any connection resource allocated by driver
1022 * is to be freed.This case occurs when target redirection
1023 * or connection retry is done.
1025 if (!beiscsi_ep
->conn
)
1028 beiscsi_conn
= beiscsi_ep
->conn
;
1030 * Break ep->conn link here so that completions after
1033 beiscsi_ep
->conn
= NULL
;
1034 if (beiscsi_conn
->login_in_progress
) {
1035 beiscsi_free_mgmt_task_handles(beiscsi_conn
,
1036 beiscsi_conn
->task
);
1037 beiscsi_conn
->login_in_progress
= 0;
1042 * beiscsi_open_conn - Ask FW to open a TCP connection
1043 * @ep: pointer to device endpoint struct
1044 * @src_addr: The source IP address
1045 * @dst_addr: The Destination IP address
1046 * @non_blocking: blocking or non-blocking call
1048 * Asks the FW to open a TCP connection
1050 static int beiscsi_open_conn(struct iscsi_endpoint
*ep
,
1051 struct sockaddr
*src_addr
,
1052 struct sockaddr
*dst_addr
, int non_blocking
)
1054 struct beiscsi_endpoint
*beiscsi_ep
= ep
->dd_data
;
1055 struct beiscsi_hba
*phba
= beiscsi_ep
->phba
;
1056 struct tcp_connect_and_offload_out
*ptcpcnct_out
;
1057 struct be_dma_mem nonemb_cmd
;
1058 unsigned int tag
, req_memsize
;
1061 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1062 "BS_%d : In beiscsi_open_conn\n");
1064 beiscsi_ep
->ep_cid
= beiscsi_get_cid(phba
);
1065 if (beiscsi_ep
->ep_cid
== BE_INVALID_CID
) {
1066 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
1067 "BS_%d : No free cid available\n");
1071 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1072 "BS_%d : In beiscsi_open_conn, ep_cid=%d\n",
1073 beiscsi_ep
->ep_cid
);
1075 phba
->ep_array
[BE_GET_CRI_FROM_CID
1076 (beiscsi_ep
->ep_cid
)] = ep
;
1078 beiscsi_ep
->cid_vld
= 0;
1080 if (is_chip_be2_be3r(phba
))
1081 req_memsize
= sizeof(struct tcp_connect_and_offload_in
);
1083 req_memsize
= sizeof(struct tcp_connect_and_offload_in_v1
);
1085 nonemb_cmd
.va
= dma_alloc_coherent(&phba
->ctrl
.pdev
->dev
,
1087 &nonemb_cmd
.dma
, GFP_KERNEL
);
1088 if (nonemb_cmd
.va
== NULL
) {
1090 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
1091 "BS_%d : Failed to allocate memory for"
1092 " mgmt_open_connection\n");
1094 beiscsi_free_ep(beiscsi_ep
);
1097 nonemb_cmd
.size
= req_memsize
;
1098 memset(nonemb_cmd
.va
, 0, nonemb_cmd
.size
);
1099 tag
= mgmt_open_connection(phba
, dst_addr
, beiscsi_ep
, &nonemb_cmd
);
1101 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
1102 "BS_%d : mgmt_open_connection Failed for cid=%d\n",
1103 beiscsi_ep
->ep_cid
);
1105 dma_free_coherent(&phba
->ctrl
.pdev
->dev
, nonemb_cmd
.size
,
1106 nonemb_cmd
.va
, nonemb_cmd
.dma
);
1107 beiscsi_free_ep(beiscsi_ep
);
1111 ret
= beiscsi_mccq_compl_wait(phba
, tag
, NULL
, &nonemb_cmd
);
1113 beiscsi_log(phba
, KERN_ERR
,
1114 BEISCSI_LOG_CONFIG
| BEISCSI_LOG_MBOX
,
1115 "BS_%d : mgmt_open_connection Failed");
1118 dma_free_coherent(&phba
->ctrl
.pdev
->dev
,
1119 nonemb_cmd
.size
, nonemb_cmd
.va
,
1122 beiscsi_free_ep(beiscsi_ep
);
1126 ptcpcnct_out
= (struct tcp_connect_and_offload_out
*)nonemb_cmd
.va
;
1127 beiscsi_ep
= ep
->dd_data
;
1128 beiscsi_ep
->fw_handle
= ptcpcnct_out
->connection_handle
;
1129 beiscsi_ep
->cid_vld
= 1;
1130 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1131 "BS_%d : mgmt_open_connection Success\n");
1133 dma_free_coherent(&phba
->ctrl
.pdev
->dev
, nonemb_cmd
.size
,
1134 nonemb_cmd
.va
, nonemb_cmd
.dma
);
1139 * beiscsi_ep_connect - Ask chip to create TCP Conn
1140 * @shost: Pointer to scsi_host structure
1141 * @dst_addr: The IP address of Target
1142 * @non_blocking: blocking or non-blocking call
1144 * This routines first asks chip to create a connection and then allocates an EP
1146 struct iscsi_endpoint
*
1147 beiscsi_ep_connect(struct Scsi_Host
*shost
, struct sockaddr
*dst_addr
,
1150 struct beiscsi_hba
*phba
;
1151 struct beiscsi_endpoint
*beiscsi_ep
;
1152 struct iscsi_endpoint
*ep
;
1157 pr_err("beiscsi_ep_connect shost is NULL\n");
1158 return ERR_PTR(ret
);
1161 phba
= iscsi_host_priv(shost
);
1162 if (!beiscsi_hba_is_online(phba
)) {
1164 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1165 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
1166 return ERR_PTR(ret
);
1168 if (!test_bit(BEISCSI_HBA_LINK_UP
, &phba
->state
)) {
1170 beiscsi_log(phba
, KERN_WARNING
, BEISCSI_LOG_CONFIG
,
1171 "BS_%d : The Adapter Port state is Down!!!\n");
1172 return ERR_PTR(ret
);
1175 ep
= iscsi_create_endpoint(sizeof(struct beiscsi_endpoint
));
1178 return ERR_PTR(ret
);
1181 beiscsi_ep
= ep
->dd_data
;
1182 beiscsi_ep
->phba
= phba
;
1183 beiscsi_ep
->openiscsi_ep
= ep
;
1184 ret
= beiscsi_open_conn(ep
, NULL
, dst_addr
, non_blocking
);
1186 beiscsi_log(phba
, KERN_ERR
, BEISCSI_LOG_CONFIG
,
1187 "BS_%d : Failed in beiscsi_open_conn\n");
1194 iscsi_destroy_endpoint(ep
);
1195 return ERR_PTR(ret
);
1199 * beiscsi_ep_poll - Poll to see if connection is established
1200 * @ep: endpoint to be used
1201 * @timeout_ms: timeout specified in millisecs
1203 * Poll to see if TCP connection established
1205 int beiscsi_ep_poll(struct iscsi_endpoint
*ep
, int timeout_ms
)
1207 struct beiscsi_endpoint
*beiscsi_ep
= ep
->dd_data
;
1209 beiscsi_log(beiscsi_ep
->phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1210 "BS_%d : In beiscsi_ep_poll\n");
1212 if (beiscsi_ep
->cid_vld
== 1)
1219 * beiscsi_flush_cq()- Flush the CQ created.
1220 * @phba: ptr device priv structure.
1222 * Before the connection resource are freed flush
1223 * all the CQ enteries
1225 static void beiscsi_flush_cq(struct beiscsi_hba
*phba
)
1228 struct be_eq_obj
*pbe_eq
;
1229 struct hwi_controller
*phwi_ctrlr
;
1230 struct hwi_context_memory
*phwi_context
;
1232 phwi_ctrlr
= phba
->phwi_ctrlr
;
1233 phwi_context
= phwi_ctrlr
->phwi_ctxt
;
1235 for (i
= 0; i
< phba
->num_cpus
; i
++) {
1236 pbe_eq
= &phwi_context
->be_eq
[i
];
1237 irq_poll_disable(&pbe_eq
->iopoll
);
1238 beiscsi_process_cq(pbe_eq
, BE2_MAX_NUM_CQ_PROC
);
1239 irq_poll_enable(&pbe_eq
->iopoll
);
1244 * beiscsi_conn_close - Invalidate and upload connection
1245 * @beiscsi_ep: pointer to device endpoint struct
1247 * Returns 0 on success, -1 on failure.
1249 static int beiscsi_conn_close(struct beiscsi_endpoint
*beiscsi_ep
)
1251 struct beiscsi_hba
*phba
= beiscsi_ep
->phba
;
1252 unsigned int tag
, attempts
;
1256 * Without successfully invalidating and uploading connection
1257 * driver can't reuse the CID so attempt more than once.
1260 while (attempts
++ < 3) {
1261 tag
= beiscsi_invalidate_cxn(phba
, beiscsi_ep
);
1263 ret
= beiscsi_mccq_compl_wait(phba
, tag
, NULL
, NULL
);
1266 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1267 "BS_%d : invalidate conn failed cid %d\n",
1268 beiscsi_ep
->ep_cid
);
1272 /* wait for all completions to arrive, then process them */
1274 /* flush CQ entries */
1275 beiscsi_flush_cq(phba
);
1281 while (attempts
++ < 3) {
1282 tag
= beiscsi_upload_cxn(phba
, beiscsi_ep
);
1284 ret
= beiscsi_mccq_compl_wait(phba
, tag
, NULL
, NULL
);
1287 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1288 "BS_%d : upload conn failed cid %d\n",
1289 beiscsi_ep
->ep_cid
);
1299 * beiscsi_ep_disconnect - Tears down the TCP connection
1300 * @ep: endpoint to be used
1302 * Tears down the TCP connection
1304 void beiscsi_ep_disconnect(struct iscsi_endpoint
*ep
)
1306 struct beiscsi_endpoint
*beiscsi_ep
;
1307 struct beiscsi_hba
*phba
;
1310 beiscsi_ep
= ep
->dd_data
;
1311 phba
= beiscsi_ep
->phba
;
1312 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1313 "BS_%d : In beiscsi_ep_disconnect for ep_cid = %u\n",
1314 beiscsi_ep
->ep_cid
);
1316 cri_index
= BE_GET_CRI_FROM_CID(beiscsi_ep
->ep_cid
);
1317 if (!phba
->ep_array
[cri_index
]) {
1318 __beiscsi_log(phba
, KERN_ERR
,
1319 "BS_%d : ep_array at %u cid %u empty\n",
1321 beiscsi_ep
->ep_cid
);
1325 if (!beiscsi_hba_is_online(phba
)) {
1326 beiscsi_log(phba
, KERN_INFO
, BEISCSI_LOG_CONFIG
,
1327 "BS_%d : HBA in error 0x%lx\n", phba
->state
);
1330 * Make CID available even if close fails.
1331 * If not freed, FW might fail open using the CID.
1333 if (beiscsi_conn_close(beiscsi_ep
) < 0)
1334 __beiscsi_log(phba
, KERN_ERR
,
1335 "BS_%d : close conn failed cid %d\n",
1336 beiscsi_ep
->ep_cid
);
1339 beiscsi_free_ep(beiscsi_ep
);
1340 if (!phba
->conn_table
[cri_index
])
1341 __beiscsi_log(phba
, KERN_ERR
,
1342 "BS_%d : conn_table empty at %u: cid %u\n",
1343 cri_index
, beiscsi_ep
->ep_cid
);
1344 phba
->conn_table
[cri_index
] = NULL
;
1345 iscsi_destroy_endpoint(beiscsi_ep
->openiscsi_ep
);
1348 umode_t
beiscsi_attr_is_visible(int param_type
, int param
)
1350 switch (param_type
) {
1351 case ISCSI_NET_PARAM
:
1353 case ISCSI_NET_PARAM_IFACE_ENABLE
:
1354 case ISCSI_NET_PARAM_IPV4_ADDR
:
1355 case ISCSI_NET_PARAM_IPV4_SUBNET
:
1356 case ISCSI_NET_PARAM_IPV4_BOOTPROTO
:
1357 case ISCSI_NET_PARAM_IPV4_GW
:
1358 case ISCSI_NET_PARAM_IPV6_ADDR
:
1359 case ISCSI_NET_PARAM_VLAN_ID
:
1360 case ISCSI_NET_PARAM_VLAN_PRIORITY
:
1361 case ISCSI_NET_PARAM_VLAN_ENABLED
:
1366 case ISCSI_HOST_PARAM
:
1368 case ISCSI_HOST_PARAM_HWADDRESS
:
1369 case ISCSI_HOST_PARAM_INITIATOR_NAME
:
1370 case ISCSI_HOST_PARAM_PORT_STATE
:
1371 case ISCSI_HOST_PARAM_PORT_SPEED
:
1378 case ISCSI_PARAM_MAX_RECV_DLENGTH
:
1379 case ISCSI_PARAM_MAX_XMIT_DLENGTH
:
1380 case ISCSI_PARAM_HDRDGST_EN
:
1381 case ISCSI_PARAM_DATADGST_EN
:
1382 case ISCSI_PARAM_CONN_ADDRESS
:
1383 case ISCSI_PARAM_CONN_PORT
:
1384 case ISCSI_PARAM_EXP_STATSN
:
1385 case ISCSI_PARAM_PERSISTENT_ADDRESS
:
1386 case ISCSI_PARAM_PERSISTENT_PORT
:
1387 case ISCSI_PARAM_PING_TMO
:
1388 case ISCSI_PARAM_RECV_TMO
:
1389 case ISCSI_PARAM_INITIAL_R2T_EN
:
1390 case ISCSI_PARAM_MAX_R2T
:
1391 case ISCSI_PARAM_IMM_DATA_EN
:
1392 case ISCSI_PARAM_FIRST_BURST
:
1393 case ISCSI_PARAM_MAX_BURST
:
1394 case ISCSI_PARAM_PDU_INORDER_EN
:
1395 case ISCSI_PARAM_DATASEQ_INORDER_EN
:
1396 case ISCSI_PARAM_ERL
:
1397 case ISCSI_PARAM_TARGET_NAME
:
1398 case ISCSI_PARAM_TPGT
:
1399 case ISCSI_PARAM_USERNAME
:
1400 case ISCSI_PARAM_PASSWORD
:
1401 case ISCSI_PARAM_USERNAME_IN
:
1402 case ISCSI_PARAM_PASSWORD_IN
:
1403 case ISCSI_PARAM_FAST_ABORT
:
1404 case ISCSI_PARAM_ABORT_TMO
:
1405 case ISCSI_PARAM_LU_RESET_TMO
:
1406 case ISCSI_PARAM_IFACE_NAME
:
1407 case ISCSI_PARAM_INITIATOR_NAME
: