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