Thomas Gleixner | 25763b3 | 2019-05-28 10:10:09 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Jitendra Bhivare | 942b765 | 2017-03-24 14:11:48 +0530 | [diff] [blame] | 2 | /* |
Ketan Mukadam | 9458321 | 2018-06-07 13:54:43 +0530 | [diff] [blame] | 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. |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 6 | * |
Ketan Mukadam | 9458321 | 2018-06-07 13:54:43 +0530 | [diff] [blame] | 7 | * Copyright (c) 2018 Broadcom. All Rights Reserved. |
| 8 | * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. |
| 9 | * |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 10 | * Contact Information: |
Jitendra Bhivare | 60f36e0 | 2016-08-19 15:20:24 +0530 | [diff] [blame] | 11 | * linux-drivers@broadcom.com |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 12 | */ |
| 13 | |
| 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> |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 20 | #include <scsi/scsi_netlink.h> |
| 21 | #include <net/netlink.h> |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 22 | #include <scsi/scsi.h> |
| 23 | |
| 24 | #include "be_iscsi.h" |
| 25 | |
| 26 | extern struct iscsi_transport beiscsi_iscsi_transport; |
| 27 | |
| 28 | /** |
| 29 | * beiscsi_session_create - creates a new iscsi session |
| 30 | * @cmds_max: max commands supported |
| 31 | * @qdepth: max queue depth supported |
| 32 | * @initial_cmdsn: initial iscsi CMDSN |
| 33 | */ |
| 34 | struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep, |
| 35 | u16 cmds_max, |
| 36 | u16 qdepth, |
| 37 | u32 initial_cmdsn) |
| 38 | { |
| 39 | struct Scsi_Host *shost; |
| 40 | struct beiscsi_endpoint *beiscsi_ep; |
| 41 | struct iscsi_cls_session *cls_session; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 42 | struct beiscsi_hba *phba; |
Jayamohan Kallickal | b8b9e1b8 | 2009-09-22 08:21:22 +0530 | [diff] [blame] | 43 | struct iscsi_session *sess; |
| 44 | struct beiscsi_session *beiscsi_sess; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 45 | struct beiscsi_io_task *io_task; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 46 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 47 | |
| 48 | if (!ep) { |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 49 | pr_err("beiscsi_session_create: invalid ep\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 50 | return NULL; |
| 51 | } |
| 52 | beiscsi_ep = ep->dd_data; |
| 53 | phba = beiscsi_ep->phba; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 54 | |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 55 | if (!beiscsi_hba_is_online(phba)) { |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 56 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 57 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
| 58 | return NULL; |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 59 | } |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 60 | |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 61 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 62 | "BS_%d : In beiscsi_session_create\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 63 | if (cmds_max > beiscsi_ep->phba->params.wrbs_per_cxn) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 64 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 65 | "BS_%d : Cannot handle %d cmds." |
| 66 | "Max cmds per session supported is %d. Using %d." |
| 67 | "\n", cmds_max, |
| 68 | beiscsi_ep->phba->params.wrbs_per_cxn, |
| 69 | beiscsi_ep->phba->params.wrbs_per_cxn); |
| 70 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 71 | cmds_max = beiscsi_ep->phba->params.wrbs_per_cxn; |
| 72 | } |
| 73 | |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 74 | shost = phba->shost; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 75 | cls_session = iscsi_session_setup(&beiscsi_iscsi_transport, |
| 76 | shost, cmds_max, |
| 77 | sizeof(*beiscsi_sess), |
| 78 | sizeof(*io_task), |
| 79 | initial_cmdsn, ISCSI_MAX_TARGET); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 80 | if (!cls_session) |
| 81 | return NULL; |
| 82 | sess = cls_session->dd_data; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 83 | beiscsi_sess = sess->dd_data; |
Romain Perier | af007b0 | 2017-07-06 10:13:03 +0200 | [diff] [blame] | 84 | beiscsi_sess->bhs_pool = dma_pool_create("beiscsi_bhs_pool", |
| 85 | &phba->pcidev->dev, |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 86 | sizeof(struct be_cmd_bhs), |
| 87 | 64, 0); |
| 88 | if (!beiscsi_sess->bhs_pool) |
| 89 | goto destroy_sess; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 90 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 91 | return cls_session; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 92 | destroy_sess: |
| 93 | iscsi_session_teardown(cls_session); |
| 94 | return NULL; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | /** |
| 98 | * beiscsi_session_destroy - destroys iscsi session |
| 99 | * @cls_session: pointer to iscsi cls session |
| 100 | * |
| 101 | * Destroys iSCSI session instance and releases |
| 102 | * resources allocated for it. |
| 103 | */ |
| 104 | void beiscsi_session_destroy(struct iscsi_cls_session *cls_session) |
| 105 | { |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 106 | struct iscsi_session *sess = cls_session->dd_data; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 107 | struct beiscsi_session *beiscsi_sess = sess->dd_data; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 108 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 109 | printk(KERN_INFO "In beiscsi_session_destroy\n"); |
Romain Perier | af007b0 | 2017-07-06 10:13:03 +0200 | [diff] [blame] | 110 | dma_pool_destroy(beiscsi_sess->bhs_pool); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 111 | iscsi_session_teardown(cls_session); |
| 112 | } |
| 113 | |
| 114 | /** |
Jitendra Bhivare | 480195c | 2016-08-19 15:20:15 +0530 | [diff] [blame] | 115 | * beiscsi_session_fail(): Closing session with appropriate error |
| 116 | * @cls_session: ptr to session |
| 117 | **/ |
| 118 | void beiscsi_session_fail(struct iscsi_cls_session *cls_session) |
| 119 | { |
| 120 | iscsi_session_failure(cls_session->dd_data, ISCSI_ERR_CONN_FAILED); |
| 121 | } |
| 122 | |
| 123 | |
| 124 | /** |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 125 | * beiscsi_conn_create - create an instance of iscsi connection |
| 126 | * @cls_session: ptr to iscsi_cls_session |
| 127 | * @cid: iscsi cid |
| 128 | */ |
| 129 | struct iscsi_cls_conn * |
| 130 | beiscsi_conn_create(struct iscsi_cls_session *cls_session, u32 cid) |
| 131 | { |
| 132 | struct beiscsi_hba *phba; |
| 133 | struct Scsi_Host *shost; |
| 134 | struct iscsi_cls_conn *cls_conn; |
| 135 | struct beiscsi_conn *beiscsi_conn; |
| 136 | struct iscsi_conn *conn; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 137 | struct iscsi_session *sess; |
| 138 | struct beiscsi_session *beiscsi_sess; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 139 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 140 | shost = iscsi_session_to_shost(cls_session); |
| 141 | phba = iscsi_host_priv(shost); |
| 142 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 143 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 144 | "BS_%d : In beiscsi_conn_create ,cid" |
| 145 | "from iscsi layer=%d\n", cid); |
| 146 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 147 | cls_conn = iscsi_conn_setup(cls_session, sizeof(*beiscsi_conn), cid); |
| 148 | if (!cls_conn) |
| 149 | return NULL; |
| 150 | |
| 151 | conn = cls_conn->dd_data; |
| 152 | beiscsi_conn = conn->dd_data; |
| 153 | beiscsi_conn->ep = NULL; |
| 154 | beiscsi_conn->phba = phba; |
| 155 | beiscsi_conn->conn = conn; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 156 | sess = cls_session->dd_data; |
| 157 | beiscsi_sess = sess->dd_data; |
| 158 | beiscsi_conn->beiscsi_sess = beiscsi_sess; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 159 | return cls_conn; |
| 160 | } |
| 161 | |
| 162 | /** |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 163 | * beiscsi_conn_bind - Binds iscsi session/connection with TCP connection |
| 164 | * @cls_session: pointer to iscsi cls session |
| 165 | * @cls_conn: pointer to iscsi cls conn |
| 166 | * @transport_fd: EP handle(64 bit) |
| 167 | * |
| 168 | * This function binds the TCP Conn with iSCSI Connection and Session. |
| 169 | */ |
| 170 | int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, |
| 171 | struct iscsi_cls_conn *cls_conn, |
| 172 | u64 transport_fd, int is_leading) |
| 173 | { |
| 174 | struct iscsi_conn *conn = cls_conn->dd_data; |
| 175 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; |
Mike Christie | 3093b04 | 2011-07-25 13:48:46 -0500 | [diff] [blame] | 176 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); |
| 177 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jayamohan Kallickal | 1e4be6f | 2013-09-28 15:35:50 -0700 | [diff] [blame] | 178 | struct hwi_controller *phwi_ctrlr = phba->phwi_ctrlr; |
| 179 | struct hwi_wrb_context *pwrb_context; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 180 | struct beiscsi_endpoint *beiscsi_ep; |
| 181 | struct iscsi_endpoint *ep; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 182 | uint16_t cri_index; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 183 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 184 | ep = iscsi_lookup_endpoint(transport_fd); |
| 185 | if (!ep) |
| 186 | return -EINVAL; |
| 187 | |
| 188 | beiscsi_ep = ep->dd_data; |
| 189 | |
| 190 | if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) |
| 191 | return -EINVAL; |
| 192 | |
| 193 | if (beiscsi_ep->phba != phba) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 194 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 195 | "BS_%d : beiscsi_ep->hba=%p not equal to phba=%p\n", |
| 196 | beiscsi_ep->phba, phba); |
| 197 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 198 | return -EEXIST; |
| 199 | } |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 200 | cri_index = BE_GET_CRI_FROM_CID(beiscsi_ep->ep_cid); |
| 201 | if (phba->conn_table[cri_index]) { |
| 202 | if (beiscsi_conn != phba->conn_table[cri_index] || |
| 203 | beiscsi_ep != phba->conn_table[cri_index]->ep) { |
| 204 | __beiscsi_log(phba, KERN_ERR, |
| 205 | "BS_%d : conn_table not empty at %u: cid %u conn %p:%p\n", |
| 206 | cri_index, |
| 207 | beiscsi_ep->ep_cid, |
| 208 | beiscsi_conn, |
| 209 | phba->conn_table[cri_index]); |
| 210 | return -EINVAL; |
| 211 | } |
| 212 | } |
Jayamohan Kallickal | 1e4be6f | 2013-09-28 15:35:50 -0700 | [diff] [blame] | 213 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 214 | beiscsi_conn->beiscsi_conn_cid = beiscsi_ep->ep_cid; |
| 215 | beiscsi_conn->ep = beiscsi_ep; |
| 216 | beiscsi_ep->conn = beiscsi_conn; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 217 | /** |
| 218 | * Each connection is associated with a WRBQ kept in wrb_context. |
| 219 | * Store doorbell offset for transmit path. |
| 220 | */ |
| 221 | pwrb_context = &phwi_ctrlr->wrb_context[cri_index]; |
Jayamohan Kallickal | 1e4be6f | 2013-09-28 15:35:50 -0700 | [diff] [blame] | 222 | beiscsi_conn->doorbell_offset = pwrb_context->doorbell_offset; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 223 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 224 | "BS_%d : cid %d phba->conn_table[%u]=%p\n", |
| 225 | beiscsi_ep->ep_cid, cri_index, beiscsi_conn); |
| 226 | phba->conn_table[cri_index] = beiscsi_conn; |
| 227 | return 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 228 | } |
| 229 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 230 | static int beiscsi_iface_create_ipv4(struct beiscsi_hba *phba) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 231 | { |
| 232 | if (phba->ipv4_iface) |
| 233 | return 0; |
| 234 | |
| 235 | phba->ipv4_iface = iscsi_create_iface(phba->shost, |
| 236 | &beiscsi_iscsi_transport, |
| 237 | ISCSI_IFACE_TYPE_IPV4, |
| 238 | 0, 0); |
| 239 | if (!phba->ipv4_iface) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 240 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 241 | "BS_%d : Could not " |
| 242 | "create default IPv4 address.\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 243 | return -ENODEV; |
| 244 | } |
| 245 | |
| 246 | return 0; |
| 247 | } |
| 248 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 249 | static int beiscsi_iface_create_ipv6(struct beiscsi_hba *phba) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 250 | { |
| 251 | if (phba->ipv6_iface) |
| 252 | return 0; |
| 253 | |
| 254 | phba->ipv6_iface = iscsi_create_iface(phba->shost, |
| 255 | &beiscsi_iscsi_transport, |
| 256 | ISCSI_IFACE_TYPE_IPV6, |
| 257 | 0, 0); |
| 258 | if (!phba->ipv6_iface) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 259 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 260 | "BS_%d : Could not " |
| 261 | "create default IPv6 address.\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 262 | return -ENODEV; |
| 263 | } |
| 264 | |
| 265 | return 0; |
| 266 | } |
| 267 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 268 | void beiscsi_iface_create_default(struct beiscsi_hba *phba) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 269 | { |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 270 | struct be_cmd_get_if_info_resp *if_info; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 271 | |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 272 | if (!beiscsi_if_get_info(phba, BEISCSI_IP_TYPE_V4, &if_info)) { |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 273 | beiscsi_iface_create_ipv4(phba); |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 274 | kfree(if_info); |
| 275 | } |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 276 | |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 277 | if (!beiscsi_if_get_info(phba, BEISCSI_IP_TYPE_V6, &if_info)) { |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 278 | beiscsi_iface_create_ipv6(phba); |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 279 | kfree(if_info); |
| 280 | } |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 281 | } |
| 282 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 283 | void beiscsi_iface_destroy_default(struct beiscsi_hba *phba) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 284 | { |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 285 | if (phba->ipv6_iface) { |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 286 | iscsi_destroy_iface(phba->ipv6_iface); |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 287 | phba->ipv6_iface = NULL; |
| 288 | } |
| 289 | if (phba->ipv4_iface) { |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 290 | iscsi_destroy_iface(phba->ipv4_iface); |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 291 | phba->ipv4_iface = NULL; |
| 292 | } |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 293 | } |
| 294 | |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 295 | /** |
| 296 | * beiscsi_set_vlan_tag()- Set the VLAN TAG |
| 297 | * @shost: Scsi Host for the driver instance |
| 298 | * @iface_param: Interface paramters |
| 299 | * |
| 300 | * Set the VLAN TAG for the adapter or disable |
| 301 | * the VLAN config |
| 302 | * |
| 303 | * returns |
| 304 | * Success: 0 |
| 305 | * Failure: Non-Zero Value |
| 306 | **/ |
| 307 | static int |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 308 | beiscsi_iface_config_vlan(struct Scsi_Host *shost, |
| 309 | struct iscsi_iface_param_info *iface_param) |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 310 | { |
| 311 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 312 | int ret = -EPERM; |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 313 | |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 314 | switch (iface_param->param) { |
| 315 | case ISCSI_NET_PARAM_VLAN_ENABLED: |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 316 | ret = 0; |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 317 | if (iface_param->value[0] != ISCSI_VLAN_ENABLE) |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 318 | ret = beiscsi_if_set_vlan(phba, BEISCSI_VLAN_DISABLE); |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 319 | break; |
| 320 | case ISCSI_NET_PARAM_VLAN_TAG: |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 321 | ret = beiscsi_if_set_vlan(phba, |
| 322 | *((uint16_t *)iface_param->value)); |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 323 | break; |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 324 | } |
| 325 | return ret; |
| 326 | } |
| 327 | |
| 328 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 329 | static int |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 330 | beiscsi_iface_config_ipv4(struct Scsi_Host *shost, |
| 331 | struct iscsi_iface_param_info *info, |
| 332 | void *data, uint32_t dt_len) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 333 | { |
| 334 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 335 | u8 *ip = NULL, *subnet = NULL, *gw; |
| 336 | struct nlattr *nla; |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 337 | int ret = -EPERM; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 338 | |
| 339 | /* Check the param */ |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 340 | switch (info->param) { |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 341 | case ISCSI_NET_PARAM_IFACE_ENABLE: |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 342 | if (info->value[0] == ISCSI_IFACE_ENABLE) |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 343 | ret = beiscsi_iface_create_ipv4(phba); |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 344 | else { |
| 345 | iscsi_destroy_iface(phba->ipv4_iface); |
| 346 | phba->ipv4_iface = NULL; |
| 347 | } |
| 348 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 349 | case ISCSI_NET_PARAM_IPV4_GW: |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 350 | gw = info->value; |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 351 | ret = beiscsi_if_set_gw(phba, BEISCSI_IP_TYPE_V4, gw); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 352 | break; |
| 353 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 354 | if (info->value[0] == ISCSI_BOOTPROTO_DHCP) |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 355 | ret = beiscsi_if_en_dhcp(phba, BEISCSI_IP_TYPE_V4); |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 356 | else if (info->value[0] == ISCSI_BOOTPROTO_STATIC) |
| 357 | /* release DHCP IP address */ |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 358 | ret = beiscsi_if_en_static(phba, BEISCSI_IP_TYPE_V4, |
| 359 | NULL, NULL); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 360 | else |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 361 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 362 | "BS_%d : Invalid BOOTPROTO: %d\n", |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 363 | info->value[0]); |
| 364 | break; |
| 365 | case ISCSI_NET_PARAM_IPV4_ADDR: |
| 366 | ip = info->value; |
| 367 | nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_SUBNET); |
| 368 | if (nla) { |
| 369 | info = nla_data(nla); |
| 370 | subnet = info->value; |
| 371 | } |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 372 | ret = beiscsi_if_en_static(phba, BEISCSI_IP_TYPE_V4, |
| 373 | ip, subnet); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 374 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 375 | case ISCSI_NET_PARAM_IPV4_SUBNET: |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 376 | /* |
| 377 | * OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR ioctl needs IP |
| 378 | * and subnet both. Find IP to be applied for this subnet. |
| 379 | */ |
| 380 | subnet = info->value; |
| 381 | nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_ADDR); |
| 382 | if (nla) { |
| 383 | info = nla_data(nla); |
| 384 | ip = info->value; |
| 385 | } |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 386 | ret = beiscsi_if_en_static(phba, BEISCSI_IP_TYPE_V4, |
| 387 | ip, subnet); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 388 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | return ret; |
| 392 | } |
| 393 | |
| 394 | static int |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 395 | beiscsi_iface_config_ipv6(struct Scsi_Host *shost, |
| 396 | struct iscsi_iface_param_info *iface_param, |
| 397 | void *data, uint32_t dt_len) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 398 | { |
| 399 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 400 | int ret = -EPERM; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 401 | |
| 402 | switch (iface_param->param) { |
| 403 | case ISCSI_NET_PARAM_IFACE_ENABLE: |
| 404 | if (iface_param->value[0] == ISCSI_IFACE_ENABLE) |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 405 | ret = beiscsi_iface_create_ipv6(phba); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 406 | else { |
| 407 | iscsi_destroy_iface(phba->ipv6_iface); |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 408 | phba->ipv6_iface = NULL; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 409 | } |
| 410 | break; |
| 411 | case ISCSI_NET_PARAM_IPV6_ADDR: |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 412 | ret = beiscsi_if_en_static(phba, BEISCSI_IP_TYPE_V6, |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 413 | iface_param->value, NULL); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 414 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | return ret; |
| 418 | } |
| 419 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 420 | int beiscsi_iface_set_param(struct Scsi_Host *shost, |
| 421 | void *data, uint32_t dt_len) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 422 | { |
| 423 | struct iscsi_iface_param_info *iface_param = NULL; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 424 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 425 | struct nlattr *attrib; |
| 426 | uint32_t rm_len = dt_len; |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 427 | int ret; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 428 | |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 429 | if (!beiscsi_hba_is_online(phba)) { |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 430 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 431 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 432 | return -EBUSY; |
| 433 | } |
| 434 | |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 435 | /* update interface_handle */ |
| 436 | ret = beiscsi_if_get_handle(phba); |
| 437 | if (ret) { |
| 438 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 439 | "BS_%d : Getting Interface Handle Failed\n"); |
| 440 | return ret; |
| 441 | } |
| 442 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 443 | nla_for_each_attr(attrib, data, dt_len, rm_len) { |
| 444 | iface_param = nla_data(attrib); |
| 445 | |
| 446 | if (iface_param->param_type != ISCSI_NET_PARAM) |
| 447 | continue; |
| 448 | |
| 449 | /* |
| 450 | * BE2ISCSI only supports 1 interface |
| 451 | */ |
| 452 | if (iface_param->iface_num) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 453 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 454 | "BS_%d : Invalid iface_num %d." |
| 455 | "Only iface_num 0 is supported.\n", |
| 456 | iface_param->iface_num); |
| 457 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 458 | return -EINVAL; |
| 459 | } |
| 460 | |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 461 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 462 | "BS_%d : %s.0 set param %d", |
| 463 | (iface_param->iface_type == ISCSI_IFACE_TYPE_IPV4) ? |
| 464 | "ipv4" : "ipv6", iface_param->param); |
| 465 | |
| 466 | ret = -EPERM; |
| 467 | switch (iface_param->param) { |
| 468 | case ISCSI_NET_PARAM_VLAN_ENABLED: |
| 469 | case ISCSI_NET_PARAM_VLAN_TAG: |
| 470 | ret = beiscsi_iface_config_vlan(shost, iface_param); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 471 | break; |
| 472 | default: |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 473 | switch (iface_param->iface_type) { |
| 474 | case ISCSI_IFACE_TYPE_IPV4: |
| 475 | ret = beiscsi_iface_config_ipv4(shost, |
| 476 | iface_param, |
| 477 | data, dt_len); |
| 478 | break; |
| 479 | case ISCSI_IFACE_TYPE_IPV6: |
| 480 | ret = beiscsi_iface_config_ipv6(shost, |
| 481 | iface_param, |
| 482 | data, dt_len); |
| 483 | break; |
| 484 | } |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 485 | } |
| 486 | |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 487 | if (ret == -EPERM) { |
| 488 | __beiscsi_log(phba, KERN_ERR, |
| 489 | "BS_%d : %s.0 set param %d not permitted", |
| 490 | (iface_param->iface_type == |
| 491 | ISCSI_IFACE_TYPE_IPV4) ? "ipv4" : "ipv6", |
| 492 | iface_param->param); |
| 493 | ret = 0; |
| 494 | } |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 495 | if (ret) |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 496 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | return ret; |
| 500 | } |
| 501 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 502 | static int __beiscsi_iface_get_param(struct beiscsi_hba *phba, |
| 503 | struct iscsi_iface *iface, |
| 504 | int param, char *buf) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 505 | { |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 506 | struct be_cmd_get_if_info_resp *if_info; |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 507 | int len, ip_type = BEISCSI_IP_TYPE_V4; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 508 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 509 | if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6) |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 510 | ip_type = BEISCSI_IP_TYPE_V6; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 511 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 512 | len = beiscsi_if_get_info(phba, ip_type, &if_info); |
Geyslan G. Bem | 0e7c60c | 2013-11-18 16:42:57 -0300 | [diff] [blame] | 513 | if (len) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 514 | return len; |
| 515 | |
| 516 | switch (param) { |
| 517 | case ISCSI_NET_PARAM_IPV4_ADDR: |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 518 | len = sprintf(buf, "%pI4\n", if_info->ip_addr.addr); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 519 | break; |
| 520 | case ISCSI_NET_PARAM_IPV6_ADDR: |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 521 | len = sprintf(buf, "%pI6\n", if_info->ip_addr.addr); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 522 | break; |
| 523 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 524 | if (!if_info->dhcp_state) |
John Soni Jose | 8359c79 | 2012-10-20 04:43:03 +0530 | [diff] [blame] | 525 | len = sprintf(buf, "static\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 526 | else |
John Soni Jose | 8359c79 | 2012-10-20 04:43:03 +0530 | [diff] [blame] | 527 | len = sprintf(buf, "dhcp\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 528 | break; |
| 529 | case ISCSI_NET_PARAM_IPV4_SUBNET: |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 530 | len = sprintf(buf, "%pI4\n", if_info->ip_addr.subnet_mask); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 531 | break; |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 532 | case ISCSI_NET_PARAM_VLAN_ENABLED: |
| 533 | len = sprintf(buf, "%s\n", |
Jitendra Bhivare | ea89604 | 2016-08-19 15:19:58 +0530 | [diff] [blame] | 534 | (if_info->vlan_priority == BEISCSI_VLAN_DISABLE) ? |
| 535 | "disable" : "enable"); |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 536 | break; |
| 537 | case ISCSI_NET_PARAM_VLAN_ID: |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 538 | if (if_info->vlan_priority == BEISCSI_VLAN_DISABLE) |
Geyslan G. Bem | 0e7c60c | 2013-11-18 16:42:57 -0300 | [diff] [blame] | 539 | len = -EINVAL; |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 540 | else |
| 541 | len = sprintf(buf, "%d\n", |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 542 | (if_info->vlan_priority & |
| 543 | ISCSI_MAX_VLAN_ID)); |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 544 | break; |
| 545 | case ISCSI_NET_PARAM_VLAN_PRIORITY: |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 546 | if (if_info->vlan_priority == BEISCSI_VLAN_DISABLE) |
Geyslan G. Bem | 0e7c60c | 2013-11-18 16:42:57 -0300 | [diff] [blame] | 547 | len = -EINVAL; |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 548 | else |
| 549 | len = sprintf(buf, "%d\n", |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 550 | ((if_info->vlan_priority >> 13) & |
| 551 | ISCSI_MAX_VLAN_PRIORITY)); |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 552 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 553 | default: |
| 554 | WARN_ON(1); |
| 555 | } |
| 556 | |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 557 | kfree(if_info); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 558 | return len; |
| 559 | } |
| 560 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 561 | int beiscsi_iface_get_param(struct iscsi_iface *iface, |
| 562 | enum iscsi_param_type param_type, |
| 563 | int param, char *buf) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 564 | { |
| 565 | struct Scsi_Host *shost = iscsi_iface_to_shost(iface); |
| 566 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 567 | struct be_cmd_get_def_gateway_resp gateway; |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 568 | int len = -EPERM; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 569 | |
Jitendra Bhivare | d8383b3 | 2016-08-19 15:20:07 +0530 | [diff] [blame] | 570 | if (param_type != ISCSI_NET_PARAM) |
| 571 | return 0; |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 572 | if (!beiscsi_hba_is_online(phba)) { |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 573 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 574 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 575 | return -EBUSY; |
| 576 | } |
| 577 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 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 Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 583 | case ISCSI_NET_PARAM_VLAN_ENABLED: |
| 584 | case ISCSI_NET_PARAM_VLAN_ID: |
| 585 | case ISCSI_NET_PARAM_VLAN_PRIORITY: |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 586 | len = __beiscsi_iface_get_param(phba, iface, param, buf); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 587 | break; |
| 588 | case ISCSI_NET_PARAM_IFACE_ENABLE: |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 589 | if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) |
| 590 | len = sprintf(buf, "%s\n", |
| 591 | phba->ipv4_iface ? "enable" : "disable"); |
| 592 | else if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6) |
| 593 | len = sprintf(buf, "%s\n", |
| 594 | phba->ipv6_iface ? "enable" : "disable"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 595 | break; |
| 596 | case ISCSI_NET_PARAM_IPV4_GW: |
| 597 | memset(&gateway, 0, sizeof(gateway)); |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 598 | len = beiscsi_if_get_gw(phba, BEISCSI_IP_TYPE_V4, &gateway); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 599 | if (!len) |
| 600 | len = sprintf(buf, "%pI4\n", &gateway.ip_addr.addr); |
| 601 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | return len; |
| 605 | } |
| 606 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 607 | /** |
Mike Christie | c7f7fd5 | 2011-02-16 15:04:41 -0600 | [diff] [blame] | 608 | * beiscsi_ep_get_param - get the iscsi parameter |
| 609 | * @ep: pointer to iscsi ep |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 610 | * @param: parameter type identifier |
| 611 | * @buf: buffer pointer |
| 612 | * |
| 613 | * returns iscsi parameter |
| 614 | */ |
Mike Christie | c7f7fd5 | 2011-02-16 15:04:41 -0600 | [diff] [blame] | 615 | int beiscsi_ep_get_param(struct iscsi_endpoint *ep, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 616 | enum iscsi_param param, char *buf) |
| 617 | { |
Mike Christie | c7f7fd5 | 2011-02-16 15:04:41 -0600 | [diff] [blame] | 618 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 619 | int len; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 620 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 621 | beiscsi_log(beiscsi_ep->phba, KERN_INFO, |
| 622 | BEISCSI_LOG_CONFIG, |
| 623 | "BS_%d : In beiscsi_ep_get_param," |
| 624 | " param= %d\n", param); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 625 | |
| 626 | switch (param) { |
| 627 | case ISCSI_PARAM_CONN_PORT: |
| 628 | len = sprintf(buf, "%hu\n", beiscsi_ep->dst_tcpport); |
| 629 | break; |
| 630 | case ISCSI_PARAM_CONN_ADDRESS: |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 631 | if (beiscsi_ep->ip_type == BEISCSI_IP_TYPE_V4) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 632 | len = sprintf(buf, "%pI4\n", &beiscsi_ep->dst_addr); |
| 633 | else |
| 634 | len = sprintf(buf, "%pI6\n", &beiscsi_ep->dst6_addr); |
| 635 | break; |
| 636 | default: |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 637 | len = -EPERM; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 638 | } |
| 639 | return len; |
| 640 | } |
| 641 | |
| 642 | int beiscsi_set_param(struct iscsi_cls_conn *cls_conn, |
| 643 | enum iscsi_param param, char *buf, int buflen) |
| 644 | { |
| 645 | struct iscsi_conn *conn = cls_conn->dd_data; |
| 646 | struct iscsi_session *session = conn->session; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 647 | struct beiscsi_hba *phba = NULL; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 648 | int ret; |
| 649 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 650 | phba = ((struct beiscsi_conn *)conn->dd_data)->phba; |
| 651 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 652 | "BS_%d : In beiscsi_conn_set_param," |
| 653 | " param= %d\n", param); |
| 654 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 655 | ret = iscsi_set_param(cls_conn, param, buf, buflen); |
| 656 | if (ret) |
| 657 | return ret; |
| 658 | /* |
| 659 | * If userspace tried to set the value to higher than we can |
| 660 | * support override here. |
| 661 | */ |
| 662 | switch (param) { |
| 663 | case ISCSI_PARAM_FIRST_BURST: |
| 664 | if (session->first_burst > 8192) |
| 665 | session->first_burst = 8192; |
| 666 | break; |
| 667 | case ISCSI_PARAM_MAX_RECV_DLENGTH: |
| 668 | if (conn->max_recv_dlength > 65536) |
| 669 | conn->max_recv_dlength = 65536; |
| 670 | break; |
| 671 | case ISCSI_PARAM_MAX_BURST: |
Jayamohan Kallickal | 230dceb | 2010-01-23 05:36:10 +0530 | [diff] [blame] | 672 | if (session->max_burst > 262144) |
| 673 | session->max_burst = 262144; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 674 | break; |
Jayamohan Kallickal | 42f43c4 | 2010-07-22 04:26:45 +0530 | [diff] [blame] | 675 | case ISCSI_PARAM_MAX_XMIT_DLENGTH: |
Jayamohan Kallickal | 7331613 | 2013-09-28 15:35:41 -0700 | [diff] [blame] | 676 | if (conn->max_xmit_dlength > 65536) |
Jayamohan Kallickal | 42f43c4 | 2010-07-22 04:26:45 +0530 | [diff] [blame] | 677 | conn->max_xmit_dlength = 65536; |
Gustavo A. R. Silva | 6a29edc | 2018-11-26 11:46:20 -0600 | [diff] [blame] | 678 | /* fall through */ |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 679 | default: |
| 680 | return 0; |
| 681 | } |
| 682 | |
| 683 | return 0; |
| 684 | } |
| 685 | |
| 686 | /** |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 687 | * beiscsi_get_port_state - Get the Port State |
| 688 | * @shost : pointer to scsi_host structure |
| 689 | * |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 690 | */ |
| 691 | static void beiscsi_get_port_state(struct Scsi_Host *shost) |
| 692 | { |
| 693 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 694 | struct iscsi_cls_host *ihost = shost->shost_data; |
| 695 | |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 696 | ihost->port_state = test_bit(BEISCSI_HBA_LINK_UP, &phba->state) ? |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 697 | ISCSI_PORT_STATE_UP : ISCSI_PORT_STATE_DOWN; |
| 698 | } |
| 699 | |
| 700 | /** |
| 701 | * beiscsi_get_port_speed - Get the Port Speed from Adapter |
| 702 | * @shost : pointer to scsi_host structure |
| 703 | * |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 704 | */ |
Jitendra Bhivare | 048084c | 2016-01-20 14:10:58 +0530 | [diff] [blame] | 705 | static void beiscsi_get_port_speed(struct Scsi_Host *shost) |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 706 | { |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 707 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 708 | struct iscsi_cls_host *ihost = shost->shost_data; |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 709 | |
Jitendra Bhivare | 048084c | 2016-01-20 14:10:58 +0530 | [diff] [blame] | 710 | switch (phba->port_speed) { |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 711 | case BE2ISCSI_LINK_SPEED_10MBPS: |
| 712 | ihost->port_speed = ISCSI_PORT_SPEED_10MBPS; |
| 713 | break; |
| 714 | case BE2ISCSI_LINK_SPEED_100MBPS: |
Jayamohan Kallickal | 3e39317 | 2014-01-29 02:16:40 -0500 | [diff] [blame] | 715 | ihost->port_speed = ISCSI_PORT_SPEED_100MBPS; |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 716 | break; |
| 717 | case BE2ISCSI_LINK_SPEED_1GBPS: |
| 718 | ihost->port_speed = ISCSI_PORT_SPEED_1GBPS; |
| 719 | break; |
| 720 | case BE2ISCSI_LINK_SPEED_10GBPS: |
| 721 | ihost->port_speed = ISCSI_PORT_SPEED_10GBPS; |
| 722 | break; |
Jitendra Bhivare | 048084c | 2016-01-20 14:10:58 +0530 | [diff] [blame] | 723 | case BE2ISCSI_LINK_SPEED_25GBPS: |
| 724 | ihost->port_speed = ISCSI_PORT_SPEED_25GBPS; |
| 725 | break; |
| 726 | case BE2ISCSI_LINK_SPEED_40GBPS: |
| 727 | ihost->port_speed = ISCSI_PORT_SPEED_40GBPS; |
| 728 | break; |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 729 | default: |
| 730 | ihost->port_speed = ISCSI_PORT_SPEED_UNKNOWN; |
| 731 | } |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 732 | } |
| 733 | |
| 734 | /** |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 735 | * beiscsi_get_host_param - get the iscsi parameter |
| 736 | * @shost: pointer to scsi_host structure |
| 737 | * @param: parameter type identifier |
| 738 | * @buf: buffer pointer |
| 739 | * |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 740 | */ |
| 741 | int beiscsi_get_host_param(struct Scsi_Host *shost, |
| 742 | enum iscsi_host_param param, char *buf) |
| 743 | { |
Mike Christie | 3093b04 | 2011-07-25 13:48:46 -0500 | [diff] [blame] | 744 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jayamohan Kallickal | b15d05b | 2010-08-12 23:36:06 +0530 | [diff] [blame] | 745 | int status = 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 746 | |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 747 | if (!beiscsi_hba_is_online(phba)) { |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 748 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 749 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
Jitendra Bhivare | c5905bf | 2017-10-10 16:18:15 +0530 | [diff] [blame] | 750 | return 0; |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 751 | } |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 752 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 753 | "BS_%d : In beiscsi_get_host_param, param = %d\n", param); |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 754 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 755 | switch (param) { |
| 756 | case ISCSI_HOST_PARAM_HWADDRESS: |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 757 | status = beiscsi_get_macaddr(buf, phba); |
| 758 | if (status < 0) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 759 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 760 | "BS_%d : beiscsi_get_macaddr Failed\n"); |
Jitendra Bhivare | c5905bf | 2017-10-10 16:18:15 +0530 | [diff] [blame] | 761 | return 0; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 762 | } |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 763 | break; |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 764 | case ISCSI_HOST_PARAM_INITIATOR_NAME: |
Jitendra Bhivare | 4788e73 | 2017-10-10 16:18:16 +0530 | [diff] [blame] | 765 | /* try fetching user configured name first */ |
| 766 | status = beiscsi_get_initiator_name(phba, buf, true); |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 767 | if (status < 0) { |
Jitendra Bhivare | 4788e73 | 2017-10-10 16:18:16 +0530 | [diff] [blame] | 768 | status = beiscsi_get_initiator_name(phba, buf, false); |
| 769 | if (status < 0) { |
| 770 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
Colin Ian King | fd13f05 | 2018-10-16 18:46:32 +0100 | [diff] [blame] | 771 | "BS_%d : Retrieving Initiator Name Failed\n"); |
Jitendra Bhivare | 4788e73 | 2017-10-10 16:18:16 +0530 | [diff] [blame] | 772 | status = 0; |
| 773 | } |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 774 | } |
| 775 | break; |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 776 | case ISCSI_HOST_PARAM_PORT_STATE: |
| 777 | beiscsi_get_port_state(shost); |
| 778 | status = sprintf(buf, "%s\n", iscsi_get_port_state_name(shost)); |
| 779 | break; |
| 780 | case ISCSI_HOST_PARAM_PORT_SPEED: |
Jitendra Bhivare | 048084c | 2016-01-20 14:10:58 +0530 | [diff] [blame] | 781 | beiscsi_get_port_speed(shost); |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 782 | status = sprintf(buf, "%s\n", iscsi_get_port_speed_name(shost)); |
| 783 | break; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 784 | default: |
| 785 | return iscsi_host_get_param(shost, param, buf); |
| 786 | } |
Jayamohan Kallickal | b15d05b | 2010-08-12 23:36:06 +0530 | [diff] [blame] | 787 | return status; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 788 | } |
| 789 | |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 790 | int beiscsi_get_macaddr(char *buf, struct beiscsi_hba *phba) |
| 791 | { |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 792 | struct be_cmd_get_nic_conf_resp resp; |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 793 | int rc; |
| 794 | |
Jayamohan Kallickal | 6c83185 | 2013-09-28 15:35:40 -0700 | [diff] [blame] | 795 | if (phba->mac_addr_set) |
John Soni Jose | df5d0e6 | 2012-08-20 23:00:31 +0530 | [diff] [blame] | 796 | return sysfs_format_mac(buf, phba->mac_address, ETH_ALEN); |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 797 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 798 | memset(&resp, 0, sizeof(resp)); |
| 799 | rc = mgmt_get_nic_conf(phba, &resp); |
| 800 | if (rc) |
| 801 | return rc; |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 802 | |
Jayamohan Kallickal | 6c83185 | 2013-09-28 15:35:40 -0700 | [diff] [blame] | 803 | phba->mac_addr_set = true; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 804 | memcpy(phba->mac_address, resp.mac_address, ETH_ALEN); |
| 805 | return sysfs_format_mac(buf, phba->mac_address, ETH_ALEN); |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 806 | } |
| 807 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 808 | /** |
| 809 | * beiscsi_conn_get_stats - get the iscsi stats |
| 810 | * @cls_conn: pointer to iscsi cls conn |
| 811 | * @stats: pointer to iscsi_stats structure |
| 812 | * |
| 813 | * returns iscsi stats |
| 814 | */ |
| 815 | void beiscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, |
| 816 | struct iscsi_stats *stats) |
| 817 | { |
| 818 | struct iscsi_conn *conn = cls_conn->dd_data; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 819 | struct beiscsi_hba *phba = NULL; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 820 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 821 | phba = ((struct beiscsi_conn *)conn->dd_data)->phba; |
| 822 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 823 | "BS_%d : In beiscsi_conn_get_stats\n"); |
| 824 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 825 | stats->txdata_octets = conn->txdata_octets; |
| 826 | stats->rxdata_octets = conn->rxdata_octets; |
| 827 | stats->dataout_pdus = conn->dataout_pdus_cnt; |
| 828 | stats->scsirsp_pdus = conn->scsirsp_pdus_cnt; |
| 829 | stats->scsicmd_pdus = conn->scsicmd_pdus_cnt; |
| 830 | stats->datain_pdus = conn->datain_pdus_cnt; |
| 831 | stats->tmfrsp_pdus = conn->tmfrsp_pdus_cnt; |
| 832 | stats->tmfcmd_pdus = conn->tmfcmd_pdus_cnt; |
| 833 | stats->r2t_pdus = conn->r2t_pdus_cnt; |
| 834 | stats->digest_err = 0; |
| 835 | stats->timeout_err = 0; |
Mike Christie | 915aafd | 2014-07-01 11:24:38 -0500 | [diff] [blame] | 836 | stats->custom_length = 1; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 837 | strcpy(stats->custom[0].desc, "eh_abort_cnt"); |
| 838 | stats->custom[0].value = conn->eh_abort_cnt; |
| 839 | } |
| 840 | |
| 841 | /** |
| 842 | * beiscsi_set_params_for_offld - get the parameters for offload |
| 843 | * @beiscsi_conn: pointer to beiscsi_conn |
| 844 | * @params: pointer to offload_params structure |
| 845 | */ |
| 846 | static void beiscsi_set_params_for_offld(struct beiscsi_conn *beiscsi_conn, |
| 847 | struct beiscsi_offload_params *params) |
| 848 | { |
| 849 | struct iscsi_conn *conn = beiscsi_conn->conn; |
| 850 | struct iscsi_session *session = conn->session; |
| 851 | |
| 852 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, max_burst_length, |
| 853 | params, session->max_burst); |
| 854 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, |
| 855 | max_send_data_segment_length, params, |
| 856 | conn->max_xmit_dlength); |
| 857 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, first_burst_length, |
| 858 | params, session->first_burst); |
| 859 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, erl, params, |
| 860 | session->erl); |
| 861 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, dde, params, |
| 862 | conn->datadgst_en); |
| 863 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, hde, params, |
| 864 | conn->hdrdgst_en); |
| 865 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, ir2t, params, |
| 866 | session->initial_r2t_en); |
| 867 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, imd, params, |
| 868 | session->imm_data_en); |
John Soni Jose | acb9693 | 2012-10-20 04:44:35 +0530 | [diff] [blame] | 869 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, |
| 870 | data_seq_inorder, params, |
| 871 | session->dataseq_inorder_en); |
| 872 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, |
| 873 | pdu_seq_inorder, params, |
| 874 | session->pdu_inorder_en); |
| 875 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, max_r2t, params, |
| 876 | session->max_r2t); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 877 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, exp_statsn, params, |
| 878 | (conn->exp_statsn - 1)); |
Jayamohan Kallickal | 7331613 | 2013-09-28 15:35:41 -0700 | [diff] [blame] | 879 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, |
| 880 | max_recv_data_segment_length, params, |
| 881 | conn->max_recv_dlength); |
| 882 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 883 | } |
| 884 | |
| 885 | /** |
| 886 | * beiscsi_conn_start - offload of session to chip |
| 887 | * @cls_conn: pointer to beiscsi_conn |
| 888 | */ |
| 889 | int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn) |
| 890 | { |
| 891 | struct iscsi_conn *conn = cls_conn->dd_data; |
| 892 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; |
| 893 | struct beiscsi_endpoint *beiscsi_ep; |
| 894 | struct beiscsi_offload_params params; |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 895 | struct beiscsi_hba *phba; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 896 | |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 897 | phba = ((struct beiscsi_conn *)conn->dd_data)->phba; |
| 898 | |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 899 | if (!beiscsi_hba_is_online(phba)) { |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 900 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 901 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 902 | return -EBUSY; |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 903 | } |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 904 | beiscsi_log(beiscsi_conn->phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 905 | "BS_%d : In beiscsi_conn_start\n"); |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 906 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 907 | memset(¶ms, 0, sizeof(struct beiscsi_offload_params)); |
| 908 | beiscsi_ep = beiscsi_conn->ep; |
| 909 | if (!beiscsi_ep) |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 910 | beiscsi_log(beiscsi_conn->phba, KERN_ERR, |
| 911 | BEISCSI_LOG_CONFIG, |
| 912 | "BS_%d : In beiscsi_conn_start , no beiscsi_ep\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 913 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 914 | beiscsi_conn->login_in_progress = 0; |
| 915 | beiscsi_set_params_for_offld(beiscsi_conn, ¶ms); |
| 916 | beiscsi_offload_connection(beiscsi_conn, ¶ms); |
| 917 | iscsi_conn_start(cls_conn); |
| 918 | return 0; |
| 919 | } |
| 920 | |
| 921 | /** |
| 922 | * beiscsi_get_cid - Allocate a cid |
| 923 | * @phba: The phba instance |
| 924 | */ |
| 925 | static int beiscsi_get_cid(struct beiscsi_hba *phba) |
| 926 | { |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 927 | uint16_t cid_avlbl_ulp0, cid_avlbl_ulp1; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 928 | unsigned short cid, cid_from_ulp; |
| 929 | struct ulp_cid_info *cid_info; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 930 | |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 931 | /* Find the ULP which has more CID available */ |
| 932 | cid_avlbl_ulp0 = (phba->cid_array_info[BEISCSI_ULP0]) ? |
| 933 | BEISCSI_ULP0_AVLBL_CID(phba) : 0; |
| 934 | cid_avlbl_ulp1 = (phba->cid_array_info[BEISCSI_ULP1]) ? |
| 935 | BEISCSI_ULP1_AVLBL_CID(phba) : 0; |
| 936 | cid_from_ulp = (cid_avlbl_ulp0 > cid_avlbl_ulp1) ? |
| 937 | BEISCSI_ULP0 : BEISCSI_ULP1; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 938 | /** |
| 939 | * If iSCSI protocol is loaded only on ULP 0, and when cid_avlbl_ulp |
| 940 | * is ZERO for both, ULP 1 is returned. |
| 941 | * Check if ULP is loaded before getting new CID. |
| 942 | */ |
| 943 | if (!test_bit(cid_from_ulp, (void *)&phba->fw_config.ulp_supported)) |
| 944 | return BE_INVALID_CID; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 945 | |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 946 | cid_info = phba->cid_array_info[cid_from_ulp]; |
| 947 | cid = cid_info->cid_array[cid_info->cid_alloc]; |
| 948 | if (!cid_info->avlbl_cids || cid == BE_INVALID_CID) { |
| 949 | __beiscsi_log(phba, KERN_ERR, |
| 950 | "BS_%d : failed to get cid: available %u:%u\n", |
| 951 | cid_info->avlbl_cids, cid_info->cid_free); |
| 952 | return BE_INVALID_CID; |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 953 | } |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 954 | /* empty the slot */ |
| 955 | cid_info->cid_array[cid_info->cid_alloc++] = BE_INVALID_CID; |
| 956 | if (cid_info->cid_alloc == BEISCSI_GET_CID_COUNT(phba, cid_from_ulp)) |
| 957 | cid_info->cid_alloc = 0; |
| 958 | cid_info->avlbl_cids--; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 959 | return cid; |
| 960 | } |
| 961 | |
| 962 | /** |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 963 | * beiscsi_put_cid - Free the cid |
| 964 | * @phba: The phba for which the cid is being freed |
| 965 | * @cid: The cid to free |
| 966 | */ |
| 967 | static void beiscsi_put_cid(struct beiscsi_hba *phba, unsigned short cid) |
| 968 | { |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 969 | uint16_t cri_index = BE_GET_CRI_FROM_CID(cid); |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 970 | struct hwi_wrb_context *pwrb_context; |
| 971 | struct hwi_controller *phwi_ctrlr; |
| 972 | struct ulp_cid_info *cid_info; |
| 973 | uint16_t cid_post_ulp; |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 974 | |
| 975 | phwi_ctrlr = phba->phwi_ctrlr; |
| 976 | pwrb_context = &phwi_ctrlr->wrb_context[cri_index]; |
| 977 | cid_post_ulp = pwrb_context->ulp_num; |
| 978 | |
| 979 | cid_info = phba->cid_array_info[cid_post_ulp]; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 980 | /* fill only in empty slot */ |
| 981 | if (cid_info->cid_array[cid_info->cid_free] != BE_INVALID_CID) { |
| 982 | __beiscsi_log(phba, KERN_ERR, |
| 983 | "BS_%d : failed to put cid %u: available %u:%u\n", |
| 984 | cid, cid_info->avlbl_cids, cid_info->cid_free); |
| 985 | return; |
| 986 | } |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 987 | cid_info->cid_array[cid_info->cid_free++] = cid; |
| 988 | if (cid_info->cid_free == BEISCSI_GET_CID_COUNT(phba, cid_post_ulp)) |
| 989 | cid_info->cid_free = 0; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 990 | cid_info->avlbl_cids++; |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 991 | } |
| 992 | |
| 993 | /** |
| 994 | * beiscsi_free_ep - free endpoint |
| 995 | * @ep: pointer to iscsi endpoint structure |
| 996 | */ |
| 997 | static void beiscsi_free_ep(struct beiscsi_endpoint *beiscsi_ep) |
| 998 | { |
| 999 | struct beiscsi_hba *phba = beiscsi_ep->phba; |
Jayamohan Kallickal | 43f388b | 2013-04-05 20:38:25 -0700 | [diff] [blame] | 1000 | struct beiscsi_conn *beiscsi_conn; |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1001 | |
| 1002 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); |
| 1003 | beiscsi_ep->phba = NULL; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1004 | /* clear this to track freeing in beiscsi_ep_disconnect */ |
| 1005 | phba->ep_array[BE_GET_CRI_FROM_CID(beiscsi_ep->ep_cid)] = NULL; |
Jayamohan Kallickal | 43f388b | 2013-04-05 20:38:25 -0700 | [diff] [blame] | 1006 | |
| 1007 | /** |
| 1008 | * Check if any connection resource allocated by driver |
| 1009 | * is to be freed.This case occurs when target redirection |
| 1010 | * or connection retry is done. |
| 1011 | **/ |
| 1012 | if (!beiscsi_ep->conn) |
| 1013 | return; |
| 1014 | |
| 1015 | beiscsi_conn = beiscsi_ep->conn; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1016 | /** |
| 1017 | * Break ep->conn link here so that completions after |
| 1018 | * this are ignored. |
| 1019 | */ |
| 1020 | beiscsi_ep->conn = NULL; |
Jayamohan Kallickal | 43f388b | 2013-04-05 20:38:25 -0700 | [diff] [blame] | 1021 | if (beiscsi_conn->login_in_progress) { |
Jayamohan Kallickal | 4a4a11b | 2013-04-05 20:38:31 -0700 | [diff] [blame] | 1022 | beiscsi_free_mgmt_task_handles(beiscsi_conn, |
| 1023 | beiscsi_conn->task); |
Jayamohan Kallickal | 43f388b | 2013-04-05 20:38:25 -0700 | [diff] [blame] | 1024 | beiscsi_conn->login_in_progress = 0; |
| 1025 | } |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1026 | } |
| 1027 | |
| 1028 | /** |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1029 | * beiscsi_open_conn - Ask FW to open a TCP connection |
| 1030 | * @ep: endpoint to be used |
| 1031 | * @src_addr: The source IP address |
| 1032 | * @dst_addr: The Destination IP address |
| 1033 | * |
| 1034 | * Asks the FW to open a TCP connection |
| 1035 | */ |
| 1036 | static int beiscsi_open_conn(struct iscsi_endpoint *ep, |
| 1037 | struct sockaddr *src_addr, |
| 1038 | struct sockaddr *dst_addr, int non_blocking) |
| 1039 | { |
| 1040 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; |
| 1041 | struct beiscsi_hba *phba = beiscsi_ep->phba; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1042 | struct tcp_connect_and_offload_out *ptcpcnct_out; |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1043 | struct be_dma_mem nonemb_cmd; |
Jayamohan Kallickal | b3c202d | 2014-05-05 21:41:27 -0400 | [diff] [blame] | 1044 | unsigned int tag, req_memsize; |
Jayamohan Kallickal | d3ad2bb | 2010-07-22 04:16:38 +0530 | [diff] [blame] | 1045 | int ret = -ENOMEM; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1046 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1047 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1048 | "BS_%d : In beiscsi_open_conn\n"); |
| 1049 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1050 | beiscsi_ep->ep_cid = beiscsi_get_cid(phba); |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1051 | if (beiscsi_ep->ep_cid == BE_INVALID_CID) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1052 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 1053 | "BS_%d : No free cid available\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1054 | return ret; |
| 1055 | } |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1056 | |
| 1057 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1058 | "BS_%d : In beiscsi_open_conn, ep_cid=%d\n", |
| 1059 | beiscsi_ep->ep_cid); |
| 1060 | |
Jayamohan Kallickal | a7909b3 | 2013-04-05 20:38:32 -0700 | [diff] [blame] | 1061 | phba->ep_array[BE_GET_CRI_FROM_CID |
| 1062 | (beiscsi_ep->ep_cid)] = ep; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1063 | |
| 1064 | beiscsi_ep->cid_vld = 0; |
Jayamohan Kallickal | b3c202d | 2014-05-05 21:41:27 -0400 | [diff] [blame] | 1065 | |
| 1066 | if (is_chip_be2_be3r(phba)) |
| 1067 | req_memsize = sizeof(struct tcp_connect_and_offload_in); |
| 1068 | else |
| 1069 | req_memsize = sizeof(struct tcp_connect_and_offload_in_v1); |
| 1070 | |
Christoph Hellwig | 26a4c99 | 2018-10-10 18:22:24 +0200 | [diff] [blame] | 1071 | nonemb_cmd.va = dma_alloc_coherent(&phba->ctrl.pdev->dev, |
Jayamohan Kallickal | b3c202d | 2014-05-05 21:41:27 -0400 | [diff] [blame] | 1072 | req_memsize, |
Christoph Hellwig | 26a4c99 | 2018-10-10 18:22:24 +0200 | [diff] [blame] | 1073 | &nonemb_cmd.dma, GFP_KERNEL); |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1074 | if (nonemb_cmd.va == NULL) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1075 | |
| 1076 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 1077 | "BS_%d : Failed to allocate memory for" |
| 1078 | " mgmt_open_connection\n"); |
| 1079 | |
Jayamohan Kallickal | a7909b3 | 2013-04-05 20:38:32 -0700 | [diff] [blame] | 1080 | beiscsi_free_ep(beiscsi_ep); |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1081 | return -ENOMEM; |
| 1082 | } |
Jayamohan Kallickal | b3c202d | 2014-05-05 21:41:27 -0400 | [diff] [blame] | 1083 | nonemb_cmd.size = req_memsize; |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1084 | memset(nonemb_cmd.va, 0, nonemb_cmd.size); |
| 1085 | tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep, &nonemb_cmd); |
Jitendra Bhivare | fa1261c | 2016-12-13 15:56:01 +0530 | [diff] [blame] | 1086 | if (!tag) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1087 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 1088 | "BS_%d : mgmt_open_connection Failed for cid=%d\n", |
| 1089 | beiscsi_ep->ep_cid); |
| 1090 | |
Christoph Hellwig | 26a4c99 | 2018-10-10 18:22:24 +0200 | [diff] [blame] | 1091 | dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size, |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1092 | nonemb_cmd.va, nonemb_cmd.dma); |
Jayamohan Kallickal | a7909b3 | 2013-04-05 20:38:32 -0700 | [diff] [blame] | 1093 | beiscsi_free_ep(beiscsi_ep); |
Jayamohan Kallickal | 1f92638 | 2010-07-22 04:22:27 +0530 | [diff] [blame] | 1094 | return -EAGAIN; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1095 | } |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1096 | |
Jitendra Bhivare | 8884033 | 2016-02-04 15:49:12 +0530 | [diff] [blame] | 1097 | ret = beiscsi_mccq_compl_wait(phba, tag, NULL, &nonemb_cmd); |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1098 | if (ret) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1099 | beiscsi_log(phba, KERN_ERR, |
| 1100 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1101 | "BS_%d : mgmt_open_connection Failed"); |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1102 | |
Jayamohan Kallickal | 1957aa7 | 2014-01-29 02:16:39 -0500 | [diff] [blame] | 1103 | if (ret != -EBUSY) |
Christoph Hellwig | 26a4c99 | 2018-10-10 18:22:24 +0200 | [diff] [blame] | 1104 | dma_free_coherent(&phba->ctrl.pdev->dev, |
| 1105 | nonemb_cmd.size, nonemb_cmd.va, |
| 1106 | nonemb_cmd.dma); |
Jayamohan Kallickal | 1957aa7 | 2014-01-29 02:16:39 -0500 | [diff] [blame] | 1107 | |
Jayamohan Kallickal | a7909b3 | 2013-04-05 20:38:32 -0700 | [diff] [blame] | 1108 | beiscsi_free_ep(beiscsi_ep); |
Jayamohan Kallickal | 1957aa7 | 2014-01-29 02:16:39 -0500 | [diff] [blame] | 1109 | return ret; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1110 | } |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1111 | |
Jayamohan Kallickal | 1e234bb | 2013-04-05 20:38:23 -0700 | [diff] [blame] | 1112 | ptcpcnct_out = (struct tcp_connect_and_offload_out *)nonemb_cmd.va; |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1113 | beiscsi_ep = ep->dd_data; |
| 1114 | beiscsi_ep->fw_handle = ptcpcnct_out->connection_handle; |
| 1115 | beiscsi_ep->cid_vld = 1; |
| 1116 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1117 | "BS_%d : mgmt_open_connection Success\n"); |
| 1118 | |
Christoph Hellwig | 26a4c99 | 2018-10-10 18:22:24 +0200 | [diff] [blame] | 1119 | dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size, |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1120 | nonemb_cmd.va, nonemb_cmd.dma); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1121 | return 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1122 | } |
| 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 | */ |
| 1132 | struct iscsi_endpoint * |
| 1133 | beiscsi_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 | |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 1141 | if (!shost) { |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1142 | ret = -ENXIO; |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 1143 | pr_err("beiscsi_ep_connect shost is NULL\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1144 | return ERR_PTR(ret); |
| 1145 | } |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 1146 | |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 1147 | phba = iscsi_host_priv(shost); |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 1148 | if (!beiscsi_hba_is_online(phba)) { |
Jayamohan Kallickal | cf6e3c6 | 2013-04-05 20:38:33 -0700 | [diff] [blame] | 1149 | ret = -EIO; |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 1150 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1151 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
Jayamohan Kallickal | cf6e3c6 | 2013-04-05 20:38:33 -0700 | [diff] [blame] | 1152 | return ERR_PTR(ret); |
| 1153 | } |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 1154 | if (!test_bit(BEISCSI_HBA_LINK_UP, &phba->state)) { |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 1155 | ret = -EBUSY; |
John Soni Jose | 8359c79 | 2012-10-20 04:43:03 +0530 | [diff] [blame] | 1156 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, |
| 1157 | "BS_%d : The Adapter Port state is Down!!!\n"); |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 1158 | return ERR_PTR(ret); |
| 1159 | } |
| 1160 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1161 | ep = iscsi_create_endpoint(sizeof(struct beiscsi_endpoint)); |
| 1162 | if (!ep) { |
| 1163 | ret = -ENOMEM; |
| 1164 | return ERR_PTR(ret); |
| 1165 | } |
| 1166 | |
| 1167 | beiscsi_ep = ep->dd_data; |
| 1168 | beiscsi_ep->phba = phba; |
Jayamohan Kallickal | c2462288 | 2010-01-05 05:05:34 +0530 | [diff] [blame] | 1169 | beiscsi_ep->openiscsi_ep = ep; |
Jayamohan Kallickal | f5ed7bd | 2010-07-22 04:18:01 +0530 | [diff] [blame] | 1170 | ret = beiscsi_open_conn(ep, NULL, dst_addr, non_blocking); |
| 1171 | if (ret) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1172 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 1173 | "BS_%d : Failed in beiscsi_open_conn\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1174 | goto free_ep; |
| 1175 | } |
| 1176 | |
| 1177 | return ep; |
| 1178 | |
| 1179 | free_ep: |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1180 | iscsi_destroy_endpoint(ep); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1181 | return ERR_PTR(ret); |
| 1182 | } |
| 1183 | |
| 1184 | /** |
| 1185 | * beiscsi_ep_poll - Poll to see if connection is established |
| 1186 | * @ep: endpoint to be used |
| 1187 | * @timeout_ms: timeout specified in millisecs |
| 1188 | * |
| 1189 | * Poll to see if TCP connection established |
| 1190 | */ |
| 1191 | int beiscsi_ep_poll(struct iscsi_endpoint *ep, int timeout_ms) |
| 1192 | { |
| 1193 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; |
| 1194 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1195 | beiscsi_log(beiscsi_ep->phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1196 | "BS_%d : In beiscsi_ep_poll\n"); |
| 1197 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1198 | if (beiscsi_ep->cid_vld == 1) |
| 1199 | return 1; |
| 1200 | else |
| 1201 | return 0; |
| 1202 | } |
| 1203 | |
| 1204 | /** |
Jayamohan Kallickal | b7ab35b | 2014-08-08 01:00:01 -0400 | [diff] [blame] | 1205 | * beiscsi_flush_cq()- Flush the CQ created. |
| 1206 | * @phba: ptr device priv structure. |
| 1207 | * |
| 1208 | * Before the connection resource are freed flush |
| 1209 | * all the CQ enteries |
| 1210 | **/ |
| 1211 | static void beiscsi_flush_cq(struct beiscsi_hba *phba) |
| 1212 | { |
| 1213 | uint16_t i; |
| 1214 | struct be_eq_obj *pbe_eq; |
| 1215 | struct hwi_controller *phwi_ctrlr; |
| 1216 | struct hwi_context_memory *phwi_context; |
| 1217 | |
| 1218 | phwi_ctrlr = phba->phwi_ctrlr; |
| 1219 | phwi_context = phwi_ctrlr->phwi_ctxt; |
| 1220 | |
| 1221 | for (i = 0; i < phba->num_cpus; i++) { |
| 1222 | pbe_eq = &phwi_context->be_eq[i]; |
Christoph Hellwig | 511cbce | 2015-11-10 14:56:14 +0100 | [diff] [blame] | 1223 | irq_poll_disable(&pbe_eq->iopoll); |
Jitendra Bhivare | 1094cf6 | 2016-01-20 14:10:56 +0530 | [diff] [blame] | 1224 | beiscsi_process_cq(pbe_eq, BE2_MAX_NUM_CQ_PROC); |
Christoph Hellwig | 511cbce | 2015-11-10 14:56:14 +0100 | [diff] [blame] | 1225 | irq_poll_enable(&pbe_eq->iopoll); |
Jayamohan Kallickal | b7ab35b | 2014-08-08 01:00:01 -0400 | [diff] [blame] | 1226 | } |
| 1227 | } |
| 1228 | |
| 1229 | /** |
Jitendra Bhivare | 49fc515 | 2017-03-24 14:11:41 +0530 | [diff] [blame] | 1230 | * beiscsi_conn_close - Invalidate and upload connection |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1231 | * @ep: The iscsi endpoint |
Jitendra Bhivare | 49fc515 | 2017-03-24 14:11:41 +0530 | [diff] [blame] | 1232 | * |
| 1233 | * Returns 0 on success, -1 on failure. |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1234 | */ |
Jitendra Bhivare | 49fc515 | 2017-03-24 14:11:41 +0530 | [diff] [blame] | 1235 | static int beiscsi_conn_close(struct beiscsi_endpoint *beiscsi_ep) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1236 | { |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1237 | struct beiscsi_hba *phba = beiscsi_ep->phba; |
Jitendra Bhivare | 49fc515 | 2017-03-24 14:11:41 +0530 | [diff] [blame] | 1238 | unsigned int tag, attempts; |
| 1239 | int ret; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1240 | |
Jitendra Bhivare | 49fc515 | 2017-03-24 14:11:41 +0530 | [diff] [blame] | 1241 | /** |
| 1242 | * Without successfully invalidating and uploading connection |
| 1243 | * driver can't reuse the CID so attempt more than once. |
| 1244 | */ |
| 1245 | attempts = 0; |
| 1246 | while (attempts++ < 3) { |
| 1247 | tag = beiscsi_invalidate_cxn(phba, beiscsi_ep); |
| 1248 | if (tag) { |
| 1249 | ret = beiscsi_mccq_compl_wait(phba, tag, NULL, NULL); |
| 1250 | if (!ret) |
| 1251 | break; |
| 1252 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1253 | "BS_%d : invalidate conn failed cid %d\n", |
| 1254 | beiscsi_ep->ep_cid); |
| 1255 | } |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1256 | } |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1257 | |
Jitendra Bhivare | 49fc515 | 2017-03-24 14:11:41 +0530 | [diff] [blame] | 1258 | /* wait for all completions to arrive, then process them */ |
| 1259 | msleep(250); |
| 1260 | /* flush CQ entries */ |
Jayamohan Kallickal | b7ab35b | 2014-08-08 01:00:01 -0400 | [diff] [blame] | 1261 | beiscsi_flush_cq(phba); |
| 1262 | |
Jitendra Bhivare | 49fc515 | 2017-03-24 14:11:41 +0530 | [diff] [blame] | 1263 | if (attempts > 3) |
| 1264 | return -1; |
| 1265 | |
| 1266 | attempts = 0; |
| 1267 | while (attempts++ < 3) { |
| 1268 | tag = beiscsi_upload_cxn(phba, beiscsi_ep); |
| 1269 | if (tag) { |
| 1270 | ret = beiscsi_mccq_compl_wait(phba, tag, NULL, NULL); |
| 1271 | if (!ret) |
| 1272 | break; |
| 1273 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1274 | "BS_%d : upload conn failed cid %d\n", |
| 1275 | beiscsi_ep->ep_cid); |
| 1276 | } |
| 1277 | } |
| 1278 | if (attempts > 3) |
| 1279 | return -1; |
| 1280 | |
| 1281 | return 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1282 | } |
| 1283 | |
| 1284 | /** |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1285 | * beiscsi_ep_disconnect - Tears down the TCP connection |
| 1286 | * @ep: endpoint to be used |
| 1287 | * |
| 1288 | * Tears down the TCP connection |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1289 | */ |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1290 | void beiscsi_ep_disconnect(struct iscsi_endpoint *ep) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1291 | { |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1292 | struct beiscsi_endpoint *beiscsi_ep; |
Jitendra Bhivare | 49fc515 | 2017-03-24 14:11:41 +0530 | [diff] [blame] | 1293 | struct beiscsi_conn *beiscsi_conn; |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1294 | struct beiscsi_hba *phba; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1295 | uint16_t cri_index; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1296 | |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1297 | beiscsi_ep = ep->dd_data; |
| 1298 | phba = beiscsi_ep->phba; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1299 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1300 | "BS_%d : In beiscsi_ep_disconnect for ep_cid = %u\n", |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1301 | beiscsi_ep->ep_cid); |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1302 | |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1303 | cri_index = BE_GET_CRI_FROM_CID(beiscsi_ep->ep_cid); |
| 1304 | if (!phba->ep_array[cri_index]) { |
| 1305 | __beiscsi_log(phba, KERN_ERR, |
| 1306 | "BS_%d : ep_array at %u cid %u empty\n", |
| 1307 | cri_index, |
| 1308 | beiscsi_ep->ep_cid); |
| 1309 | return; |
| 1310 | } |
| 1311 | |
John Soni Jose | 0a513dd | 2012-08-20 23:00:55 +0530 | [diff] [blame] | 1312 | if (beiscsi_ep->conn) { |
| 1313 | beiscsi_conn = beiscsi_ep->conn; |
| 1314 | iscsi_suspend_queue(beiscsi_conn->conn); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1315 | } |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1316 | |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 1317 | if (!beiscsi_hba_is_online(phba)) { |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 1318 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1319 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
Jitendra Bhivare | 49fc515 | 2017-03-24 14:11:41 +0530 | [diff] [blame] | 1320 | } else { |
| 1321 | /** |
| 1322 | * Make CID available even if close fails. |
| 1323 | * If not freed, FW might fail open using the CID. |
| 1324 | */ |
| 1325 | if (beiscsi_conn_close(beiscsi_ep) < 0) |
| 1326 | __beiscsi_log(phba, KERN_ERR, |
| 1327 | "BS_%d : close conn failed cid %d\n", |
| 1328 | beiscsi_ep->ep_cid); |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 1329 | } |
| 1330 | |
Jayamohan Kallickal | c2462288 | 2010-01-05 05:05:34 +0530 | [diff] [blame] | 1331 | beiscsi_free_ep(beiscsi_ep); |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1332 | if (!phba->conn_table[cri_index]) |
| 1333 | __beiscsi_log(phba, KERN_ERR, |
Jitendra Bhivare | 49fc515 | 2017-03-24 14:11:41 +0530 | [diff] [blame] | 1334 | "BS_%d : conn_table empty at %u: cid %u\n", |
| 1335 | cri_index, beiscsi_ep->ep_cid); |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1336 | phba->conn_table[cri_index] = NULL; |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1337 | iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1338 | } |
Mike Christie | 3128c6c | 2011-07-25 13:48:42 -0500 | [diff] [blame] | 1339 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 1340 | umode_t beiscsi_attr_is_visible(int param_type, int param) |
Mike Christie | 3128c6c | 2011-07-25 13:48:42 -0500 | [diff] [blame] | 1341 | { |
| 1342 | switch (param_type) { |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 1343 | case ISCSI_NET_PARAM: |
| 1344 | switch (param) { |
| 1345 | case ISCSI_NET_PARAM_IFACE_ENABLE: |
| 1346 | case ISCSI_NET_PARAM_IPV4_ADDR: |
| 1347 | case ISCSI_NET_PARAM_IPV4_SUBNET: |
| 1348 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: |
| 1349 | case ISCSI_NET_PARAM_IPV4_GW: |
| 1350 | case ISCSI_NET_PARAM_IPV6_ADDR: |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 1351 | case ISCSI_NET_PARAM_VLAN_ID: |
| 1352 | case ISCSI_NET_PARAM_VLAN_PRIORITY: |
| 1353 | case ISCSI_NET_PARAM_VLAN_ENABLED: |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 1354 | return S_IRUGO; |
| 1355 | default: |
| 1356 | return 0; |
| 1357 | } |
Mike Christie | f27fb2e | 2011-07-25 13:48:45 -0500 | [diff] [blame] | 1358 | case ISCSI_HOST_PARAM: |
| 1359 | switch (param) { |
| 1360 | case ISCSI_HOST_PARAM_HWADDRESS: |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 1361 | case ISCSI_HOST_PARAM_INITIATOR_NAME: |
| 1362 | case ISCSI_HOST_PARAM_PORT_STATE: |
| 1363 | case ISCSI_HOST_PARAM_PORT_SPEED: |
Mike Christie | f27fb2e | 2011-07-25 13:48:45 -0500 | [diff] [blame] | 1364 | return S_IRUGO; |
| 1365 | default: |
| 1366 | return 0; |
| 1367 | } |
Mike Christie | 3128c6c | 2011-07-25 13:48:42 -0500 | [diff] [blame] | 1368 | case ISCSI_PARAM: |
| 1369 | switch (param) { |
| 1370 | case ISCSI_PARAM_MAX_RECV_DLENGTH: |
| 1371 | case ISCSI_PARAM_MAX_XMIT_DLENGTH: |
| 1372 | case ISCSI_PARAM_HDRDGST_EN: |
| 1373 | case ISCSI_PARAM_DATADGST_EN: |
| 1374 | case ISCSI_PARAM_CONN_ADDRESS: |
| 1375 | case ISCSI_PARAM_CONN_PORT: |
| 1376 | case ISCSI_PARAM_EXP_STATSN: |
| 1377 | case ISCSI_PARAM_PERSISTENT_ADDRESS: |
| 1378 | case ISCSI_PARAM_PERSISTENT_PORT: |
| 1379 | case ISCSI_PARAM_PING_TMO: |
| 1380 | case ISCSI_PARAM_RECV_TMO: |
Mike Christie | 1d063c1 | 2011-07-25 13:48:43 -0500 | [diff] [blame] | 1381 | case ISCSI_PARAM_INITIAL_R2T_EN: |
| 1382 | case ISCSI_PARAM_MAX_R2T: |
| 1383 | case ISCSI_PARAM_IMM_DATA_EN: |
| 1384 | case ISCSI_PARAM_FIRST_BURST: |
| 1385 | case ISCSI_PARAM_MAX_BURST: |
| 1386 | case ISCSI_PARAM_PDU_INORDER_EN: |
| 1387 | case ISCSI_PARAM_DATASEQ_INORDER_EN: |
| 1388 | case ISCSI_PARAM_ERL: |
| 1389 | case ISCSI_PARAM_TARGET_NAME: |
| 1390 | case ISCSI_PARAM_TPGT: |
| 1391 | case ISCSI_PARAM_USERNAME: |
| 1392 | case ISCSI_PARAM_PASSWORD: |
| 1393 | case ISCSI_PARAM_USERNAME_IN: |
| 1394 | case ISCSI_PARAM_PASSWORD_IN: |
| 1395 | case ISCSI_PARAM_FAST_ABORT: |
| 1396 | case ISCSI_PARAM_ABORT_TMO: |
| 1397 | case ISCSI_PARAM_LU_RESET_TMO: |
| 1398 | case ISCSI_PARAM_IFACE_NAME: |
| 1399 | case ISCSI_PARAM_INITIATOR_NAME: |
Mike Christie | 3128c6c | 2011-07-25 13:48:42 -0500 | [diff] [blame] | 1400 | return S_IRUGO; |
| 1401 | default: |
| 1402 | return 0; |
| 1403 | } |
| 1404 | } |
| 1405 | |
| 1406 | return 0; |
| 1407 | } |