Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1 | /** |
Jayamohan Kallickal | 255fa9a | 2011-03-25 14:23:57 -0700 | [diff] [blame] | 2 | * Copyright (C) 2005 - 2011 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 | |
| 53 | SE_DEBUG(DBG_LVL_8, "In beiscsi_session_create\n"); |
| 54 | |
| 55 | if (!ep) { |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 56 | SE_DEBUG(DBG_LVL_1, "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; |
| 62 | if (cmds_max > beiscsi_ep->phba->params.wrbs_per_cxn) { |
| 63 | shost_printk(KERN_ERR, shost, "Cannot handle %d cmds." |
| 64 | "Max cmds per session supported is %d. Using %d. " |
| 65 | "\n", cmds_max, |
| 66 | beiscsi_ep->phba->params.wrbs_per_cxn, |
| 67 | beiscsi_ep->phba->params.wrbs_per_cxn); |
| 68 | cmds_max = beiscsi_ep->phba->params.wrbs_per_cxn; |
| 69 | } |
| 70 | |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 71 | cls_session = iscsi_session_setup(&beiscsi_iscsi_transport, |
| 72 | shost, cmds_max, |
| 73 | sizeof(*beiscsi_sess), |
| 74 | sizeof(*io_task), |
| 75 | initial_cmdsn, ISCSI_MAX_TARGET); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 76 | if (!cls_session) |
| 77 | return NULL; |
| 78 | sess = cls_session->dd_data; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 79 | beiscsi_sess = sess->dd_data; |
| 80 | beiscsi_sess->bhs_pool = pci_pool_create("beiscsi_bhs_pool", |
| 81 | phba->pcidev, |
| 82 | sizeof(struct be_cmd_bhs), |
| 83 | 64, 0); |
| 84 | if (!beiscsi_sess->bhs_pool) |
| 85 | goto destroy_sess; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 86 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 87 | return cls_session; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 88 | destroy_sess: |
| 89 | iscsi_session_teardown(cls_session); |
| 90 | return NULL; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | /** |
| 94 | * beiscsi_session_destroy - destroys iscsi session |
| 95 | * @cls_session: pointer to iscsi cls session |
| 96 | * |
| 97 | * Destroys iSCSI session instance and releases |
| 98 | * resources allocated for it. |
| 99 | */ |
| 100 | void beiscsi_session_destroy(struct iscsi_cls_session *cls_session) |
| 101 | { |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 102 | struct iscsi_session *sess = cls_session->dd_data; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 103 | struct beiscsi_session *beiscsi_sess = sess->dd_data; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 104 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 105 | SE_DEBUG(DBG_LVL_8, "In beiscsi_session_destroy\n"); |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 106 | pci_pool_destroy(beiscsi_sess->bhs_pool); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 107 | iscsi_session_teardown(cls_session); |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * beiscsi_conn_create - create an instance of iscsi connection |
| 112 | * @cls_session: ptr to iscsi_cls_session |
| 113 | * @cid: iscsi cid |
| 114 | */ |
| 115 | struct iscsi_cls_conn * |
| 116 | beiscsi_conn_create(struct iscsi_cls_session *cls_session, u32 cid) |
| 117 | { |
| 118 | struct beiscsi_hba *phba; |
| 119 | struct Scsi_Host *shost; |
| 120 | struct iscsi_cls_conn *cls_conn; |
| 121 | struct beiscsi_conn *beiscsi_conn; |
| 122 | struct iscsi_conn *conn; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 123 | struct iscsi_session *sess; |
| 124 | struct beiscsi_session *beiscsi_sess; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 125 | |
| 126 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_create ,cid" |
| 127 | "from iscsi layer=%d\n", cid); |
| 128 | shost = iscsi_session_to_shost(cls_session); |
| 129 | phba = iscsi_host_priv(shost); |
| 130 | |
| 131 | cls_conn = iscsi_conn_setup(cls_session, sizeof(*beiscsi_conn), cid); |
| 132 | if (!cls_conn) |
| 133 | return NULL; |
| 134 | |
| 135 | conn = cls_conn->dd_data; |
| 136 | beiscsi_conn = conn->dd_data; |
| 137 | beiscsi_conn->ep = NULL; |
| 138 | beiscsi_conn->phba = phba; |
| 139 | beiscsi_conn->conn = conn; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 140 | sess = cls_session->dd_data; |
| 141 | beiscsi_sess = sess->dd_data; |
| 142 | beiscsi_conn->beiscsi_sess = beiscsi_sess; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 143 | return cls_conn; |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * beiscsi_bindconn_cid - Bind the beiscsi_conn with phba connection table |
| 148 | * @beiscsi_conn: The pointer to beiscsi_conn structure |
| 149 | * @phba: The phba instance |
| 150 | * @cid: The cid to free |
| 151 | */ |
| 152 | static int beiscsi_bindconn_cid(struct beiscsi_hba *phba, |
| 153 | struct beiscsi_conn *beiscsi_conn, |
| 154 | unsigned int cid) |
| 155 | { |
| 156 | if (phba->conn_table[cid]) { |
| 157 | SE_DEBUG(DBG_LVL_1, |
| 158 | "Connection table already occupied. Detected clash\n"); |
| 159 | return -EINVAL; |
| 160 | } else { |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 161 | SE_DEBUG(DBG_LVL_8, "phba->conn_table[%d]=%p(beiscsi_conn)\n", |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 162 | cid, beiscsi_conn); |
| 163 | phba->conn_table[cid] = beiscsi_conn; |
| 164 | } |
| 165 | return 0; |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * beiscsi_conn_bind - Binds iscsi session/connection with TCP connection |
| 170 | * @cls_session: pointer to iscsi cls session |
| 171 | * @cls_conn: pointer to iscsi cls conn |
| 172 | * @transport_fd: EP handle(64 bit) |
| 173 | * |
| 174 | * This function binds the TCP Conn with iSCSI Connection and Session. |
| 175 | */ |
| 176 | int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, |
| 177 | struct iscsi_cls_conn *cls_conn, |
| 178 | u64 transport_fd, int is_leading) |
| 179 | { |
| 180 | struct iscsi_conn *conn = cls_conn->dd_data; |
| 181 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; |
Mike Christie | 3093b04 | 2011-07-25 13:48:46 -0500 | [diff] [blame] | 182 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); |
| 183 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 184 | struct beiscsi_endpoint *beiscsi_ep; |
| 185 | struct iscsi_endpoint *ep; |
| 186 | |
| 187 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_bind\n"); |
| 188 | ep = iscsi_lookup_endpoint(transport_fd); |
| 189 | if (!ep) |
| 190 | return -EINVAL; |
| 191 | |
| 192 | beiscsi_ep = ep->dd_data; |
| 193 | |
| 194 | if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) |
| 195 | return -EINVAL; |
| 196 | |
| 197 | if (beiscsi_ep->phba != phba) { |
| 198 | SE_DEBUG(DBG_LVL_8, |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 199 | "beiscsi_ep->hba=%p not equal to phba=%p\n", |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 200 | beiscsi_ep->phba, phba); |
| 201 | return -EEXIST; |
| 202 | } |
| 203 | |
| 204 | beiscsi_conn->beiscsi_conn_cid = beiscsi_ep->ep_cid; |
| 205 | beiscsi_conn->ep = beiscsi_ep; |
| 206 | beiscsi_ep->conn = beiscsi_conn; |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 207 | SE_DEBUG(DBG_LVL_8, "beiscsi_conn=%p conn=%p ep_cid=%d\n", |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 208 | beiscsi_conn, conn, beiscsi_ep->ep_cid); |
| 209 | return beiscsi_bindconn_cid(phba, beiscsi_conn, beiscsi_ep->ep_cid); |
| 210 | } |
| 211 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame^] | 212 | static int beiscsi_create_ipv4_iface(struct beiscsi_hba *phba) |
| 213 | { |
| 214 | if (phba->ipv4_iface) |
| 215 | return 0; |
| 216 | |
| 217 | phba->ipv4_iface = iscsi_create_iface(phba->shost, |
| 218 | &beiscsi_iscsi_transport, |
| 219 | ISCSI_IFACE_TYPE_IPV4, |
| 220 | 0, 0); |
| 221 | if (!phba->ipv4_iface) { |
| 222 | shost_printk(KERN_ERR, phba->shost, "Could not " |
| 223 | "create default IPv4 address.\n"); |
| 224 | return -ENODEV; |
| 225 | } |
| 226 | |
| 227 | return 0; |
| 228 | } |
| 229 | |
| 230 | static int beiscsi_create_ipv6_iface(struct beiscsi_hba *phba) |
| 231 | { |
| 232 | if (phba->ipv6_iface) |
| 233 | return 0; |
| 234 | |
| 235 | phba->ipv6_iface = iscsi_create_iface(phba->shost, |
| 236 | &beiscsi_iscsi_transport, |
| 237 | ISCSI_IFACE_TYPE_IPV6, |
| 238 | 0, 0); |
| 239 | if (!phba->ipv6_iface) { |
| 240 | shost_printk(KERN_ERR, phba->shost, "Could not " |
| 241 | "create default IPv6 address.\n"); |
| 242 | return -ENODEV; |
| 243 | } |
| 244 | |
| 245 | return 0; |
| 246 | } |
| 247 | |
| 248 | void beiscsi_create_def_ifaces(struct beiscsi_hba *phba) |
| 249 | { |
| 250 | struct be_cmd_get_if_info_resp if_info; |
| 251 | |
| 252 | if (!mgmt_get_if_info(phba, BE2_IPV4, &if_info)) |
| 253 | beiscsi_create_ipv4_iface(phba); |
| 254 | |
| 255 | if (!mgmt_get_if_info(phba, BE2_IPV6, &if_info)) |
| 256 | beiscsi_create_ipv6_iface(phba); |
| 257 | } |
| 258 | |
| 259 | void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba) |
| 260 | { |
| 261 | if (phba->ipv6_iface) |
| 262 | iscsi_destroy_iface(phba->ipv6_iface); |
| 263 | if (phba->ipv4_iface) |
| 264 | iscsi_destroy_iface(phba->ipv4_iface); |
| 265 | } |
| 266 | |
| 267 | static int |
| 268 | beiscsi_set_static_ip(struct Scsi_Host *shost, |
| 269 | struct iscsi_iface_param_info *iface_param, |
| 270 | void *data, uint32_t dt_len) |
| 271 | { |
| 272 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 273 | struct iscsi_iface_param_info *iface_ip = NULL; |
| 274 | struct iscsi_iface_param_info *iface_subnet = NULL; |
| 275 | struct nlattr *nla; |
| 276 | int ret; |
| 277 | |
| 278 | |
| 279 | switch (iface_param->param) { |
| 280 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: |
| 281 | nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_ADDR); |
| 282 | if (nla) |
| 283 | iface_ip = nla_data(nla); |
| 284 | |
| 285 | nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_SUBNET); |
| 286 | if (nla) |
| 287 | iface_subnet = nla_data(nla); |
| 288 | break; |
| 289 | case ISCSI_NET_PARAM_IPV4_ADDR: |
| 290 | iface_ip = iface_param; |
| 291 | nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_SUBNET); |
| 292 | if (nla) |
| 293 | iface_subnet = nla_data(nla); |
| 294 | break; |
| 295 | case ISCSI_NET_PARAM_IPV4_SUBNET: |
| 296 | iface_subnet = iface_param; |
| 297 | nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_ADDR); |
| 298 | if (nla) |
| 299 | iface_ip = nla_data(nla); |
| 300 | break; |
| 301 | default: |
| 302 | shost_printk(KERN_ERR, shost, "Unsupported param %d\n", |
| 303 | iface_param->param); |
| 304 | } |
| 305 | |
| 306 | if (!iface_ip || !iface_subnet) { |
| 307 | shost_printk(KERN_ERR, shost, "IP and Subnet Mask required\n"); |
| 308 | return -EINVAL; |
| 309 | } |
| 310 | |
| 311 | ret = mgmt_set_ip(phba, iface_ip, iface_subnet, |
| 312 | ISCSI_BOOTPROTO_STATIC); |
| 313 | |
| 314 | return ret; |
| 315 | } |
| 316 | |
| 317 | static int |
| 318 | beiscsi_set_ipv4(struct Scsi_Host *shost, |
| 319 | struct iscsi_iface_param_info *iface_param, |
| 320 | void *data, uint32_t dt_len) |
| 321 | { |
| 322 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 323 | int ret = 0; |
| 324 | |
| 325 | /* Check the param */ |
| 326 | switch (iface_param->param) { |
| 327 | case ISCSI_NET_PARAM_IPV4_GW: |
| 328 | ret = mgmt_set_gateway(phba, iface_param); |
| 329 | break; |
| 330 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: |
| 331 | if (iface_param->value[0] == ISCSI_BOOTPROTO_DHCP) |
| 332 | ret = mgmt_set_ip(phba, iface_param, |
| 333 | NULL, ISCSI_BOOTPROTO_DHCP); |
| 334 | else if (iface_param->value[0] == ISCSI_BOOTPROTO_STATIC) |
| 335 | ret = beiscsi_set_static_ip(shost, iface_param, |
| 336 | data, dt_len); |
| 337 | else |
| 338 | shost_printk(KERN_ERR, shost, "Invalid BOOTPROTO: %d\n", |
| 339 | iface_param->value[0]); |
| 340 | break; |
| 341 | case ISCSI_NET_PARAM_IFACE_ENABLE: |
| 342 | if (iface_param->value[0] == ISCSI_IFACE_ENABLE) |
| 343 | ret = beiscsi_create_ipv4_iface(phba); |
| 344 | else |
| 345 | iscsi_destroy_iface(phba->ipv4_iface); |
| 346 | break; |
| 347 | case ISCSI_NET_PARAM_IPV4_SUBNET: |
| 348 | case ISCSI_NET_PARAM_IPV4_ADDR: |
| 349 | ret = beiscsi_set_static_ip(shost, iface_param, |
| 350 | data, dt_len); |
| 351 | break; |
| 352 | default: |
| 353 | shost_printk(KERN_ERR, shost, "Param %d not supported\n", |
| 354 | iface_param->param); |
| 355 | } |
| 356 | |
| 357 | return ret; |
| 358 | } |
| 359 | |
| 360 | static int |
| 361 | beiscsi_set_ipv6(struct Scsi_Host *shost, |
| 362 | struct iscsi_iface_param_info *iface_param, |
| 363 | void *data, uint32_t dt_len) |
| 364 | { |
| 365 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 366 | int ret = 0; |
| 367 | |
| 368 | switch (iface_param->param) { |
| 369 | case ISCSI_NET_PARAM_IFACE_ENABLE: |
| 370 | if (iface_param->value[0] == ISCSI_IFACE_ENABLE) |
| 371 | ret = beiscsi_create_ipv6_iface(phba); |
| 372 | else { |
| 373 | iscsi_destroy_iface(phba->ipv6_iface); |
| 374 | ret = 0; |
| 375 | } |
| 376 | break; |
| 377 | case ISCSI_NET_PARAM_IPV6_ADDR: |
| 378 | ret = mgmt_set_ip(phba, iface_param, NULL, |
| 379 | ISCSI_BOOTPROTO_STATIC); |
| 380 | break; |
| 381 | default: |
| 382 | shost_printk(KERN_ERR, shost, "Param %d not supported\n", |
| 383 | iface_param->param); |
| 384 | } |
| 385 | |
| 386 | return ret; |
| 387 | } |
| 388 | |
| 389 | int be2iscsi_iface_set_param(struct Scsi_Host *shost, |
| 390 | void *data, uint32_t dt_len) |
| 391 | { |
| 392 | struct iscsi_iface_param_info *iface_param = NULL; |
| 393 | struct nlattr *attrib; |
| 394 | uint32_t rm_len = dt_len; |
| 395 | int ret = 0 ; |
| 396 | |
| 397 | nla_for_each_attr(attrib, data, dt_len, rm_len) { |
| 398 | iface_param = nla_data(attrib); |
| 399 | |
| 400 | if (iface_param->param_type != ISCSI_NET_PARAM) |
| 401 | continue; |
| 402 | |
| 403 | /* |
| 404 | * BE2ISCSI only supports 1 interface |
| 405 | */ |
| 406 | if (iface_param->iface_num) { |
| 407 | shost_printk(KERN_ERR, shost, "Invalid iface_num %d." |
| 408 | "Only iface_num 0 is supported.\n", |
| 409 | iface_param->iface_num); |
| 410 | return -EINVAL; |
| 411 | } |
| 412 | |
| 413 | switch (iface_param->iface_type) { |
| 414 | case ISCSI_IFACE_TYPE_IPV4: |
| 415 | ret = beiscsi_set_ipv4(shost, iface_param, |
| 416 | data, dt_len); |
| 417 | break; |
| 418 | case ISCSI_IFACE_TYPE_IPV6: |
| 419 | ret = beiscsi_set_ipv6(shost, iface_param, |
| 420 | data, dt_len); |
| 421 | break; |
| 422 | default: |
| 423 | shost_printk(KERN_ERR, shost, |
| 424 | "Invalid iface type :%d passed\n", |
| 425 | iface_param->iface_type); |
| 426 | break; |
| 427 | } |
| 428 | |
| 429 | if (ret) |
| 430 | return ret; |
| 431 | } |
| 432 | |
| 433 | return ret; |
| 434 | } |
| 435 | |
| 436 | static int be2iscsi_get_if_param(struct beiscsi_hba *phba, |
| 437 | struct iscsi_iface *iface, int param, |
| 438 | char *buf) |
| 439 | { |
| 440 | struct be_cmd_get_if_info_resp if_info; |
| 441 | int len, ip_type = BE2_IPV4; |
| 442 | |
| 443 | memset(&if_info, 0, sizeof(if_info)); |
| 444 | |
| 445 | if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6) |
| 446 | ip_type = BE2_IPV6; |
| 447 | |
| 448 | len = mgmt_get_if_info(phba, ip_type, &if_info); |
| 449 | if (len) |
| 450 | return len; |
| 451 | |
| 452 | switch (param) { |
| 453 | case ISCSI_NET_PARAM_IPV4_ADDR: |
| 454 | len = sprintf(buf, "%pI4\n", &if_info.ip_addr.addr); |
| 455 | break; |
| 456 | case ISCSI_NET_PARAM_IPV6_ADDR: |
| 457 | len = sprintf(buf, "%pI6\n", &if_info.ip_addr.addr); |
| 458 | break; |
| 459 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: |
| 460 | if (!if_info.dhcp_state) |
| 461 | len = sprintf(buf, "static"); |
| 462 | else |
| 463 | len = sprintf(buf, "dhcp"); |
| 464 | break; |
| 465 | case ISCSI_NET_PARAM_IPV4_SUBNET: |
| 466 | len = sprintf(buf, "%pI4\n", &if_info.ip_addr.subnet_mask); |
| 467 | break; |
| 468 | default: |
| 469 | WARN_ON(1); |
| 470 | } |
| 471 | |
| 472 | return len; |
| 473 | } |
| 474 | |
| 475 | int be2iscsi_iface_get_param(struct iscsi_iface *iface, |
| 476 | enum iscsi_param_type param_type, |
| 477 | int param, char *buf) |
| 478 | { |
| 479 | struct Scsi_Host *shost = iscsi_iface_to_shost(iface); |
| 480 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 481 | struct be_cmd_get_def_gateway_resp gateway; |
| 482 | int len = -ENOSYS; |
| 483 | |
| 484 | switch (param) { |
| 485 | case ISCSI_NET_PARAM_IPV4_ADDR: |
| 486 | case ISCSI_NET_PARAM_IPV4_SUBNET: |
| 487 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: |
| 488 | case ISCSI_NET_PARAM_IPV6_ADDR: |
| 489 | len = be2iscsi_get_if_param(phba, iface, param, buf); |
| 490 | break; |
| 491 | case ISCSI_NET_PARAM_IFACE_ENABLE: |
| 492 | len = sprintf(buf, "enabled"); |
| 493 | break; |
| 494 | case ISCSI_NET_PARAM_IPV4_GW: |
| 495 | memset(&gateway, 0, sizeof(gateway)); |
| 496 | len = mgmt_get_gateway(phba, BE2_IPV4, &gateway); |
| 497 | if (!len) |
| 498 | len = sprintf(buf, "%pI4\n", &gateway.ip_addr.addr); |
| 499 | break; |
| 500 | default: |
| 501 | len = -ENOSYS; |
| 502 | } |
| 503 | |
| 504 | return len; |
| 505 | } |
| 506 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 507 | /** |
Mike Christie | c7f7fd5 | 2011-02-16 15:04:41 -0600 | [diff] [blame] | 508 | * beiscsi_ep_get_param - get the iscsi parameter |
| 509 | * @ep: pointer to iscsi ep |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 510 | * @param: parameter type identifier |
| 511 | * @buf: buffer pointer |
| 512 | * |
| 513 | * returns iscsi parameter |
| 514 | */ |
Mike Christie | c7f7fd5 | 2011-02-16 15:04:41 -0600 | [diff] [blame] | 515 | int beiscsi_ep_get_param(struct iscsi_endpoint *ep, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 516 | enum iscsi_param param, char *buf) |
| 517 | { |
Mike Christie | c7f7fd5 | 2011-02-16 15:04:41 -0600 | [diff] [blame] | 518 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 519 | int len = 0; |
| 520 | |
Jayamohan Kallickal | b5b9323 | 2012-04-03 23:41:40 -0500 | [diff] [blame] | 521 | SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_get_param, param= %d\n", param); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 522 | |
| 523 | switch (param) { |
| 524 | case ISCSI_PARAM_CONN_PORT: |
| 525 | len = sprintf(buf, "%hu\n", beiscsi_ep->dst_tcpport); |
| 526 | break; |
| 527 | case ISCSI_PARAM_CONN_ADDRESS: |
| 528 | if (beiscsi_ep->ip_type == BE2_IPV4) |
| 529 | len = sprintf(buf, "%pI4\n", &beiscsi_ep->dst_addr); |
| 530 | else |
| 531 | len = sprintf(buf, "%pI6\n", &beiscsi_ep->dst6_addr); |
| 532 | break; |
| 533 | default: |
Mike Christie | c7f7fd5 | 2011-02-16 15:04:41 -0600 | [diff] [blame] | 534 | return -ENOSYS; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 535 | } |
| 536 | return len; |
| 537 | } |
| 538 | |
| 539 | int beiscsi_set_param(struct iscsi_cls_conn *cls_conn, |
| 540 | enum iscsi_param param, char *buf, int buflen) |
| 541 | { |
| 542 | struct iscsi_conn *conn = cls_conn->dd_data; |
| 543 | struct iscsi_session *session = conn->session; |
| 544 | int ret; |
| 545 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 546 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_set_param, param= %d\n", param); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 547 | ret = iscsi_set_param(cls_conn, param, buf, buflen); |
| 548 | if (ret) |
| 549 | return ret; |
| 550 | /* |
| 551 | * If userspace tried to set the value to higher than we can |
| 552 | * support override here. |
| 553 | */ |
| 554 | switch (param) { |
| 555 | case ISCSI_PARAM_FIRST_BURST: |
| 556 | if (session->first_burst > 8192) |
| 557 | session->first_burst = 8192; |
| 558 | break; |
| 559 | case ISCSI_PARAM_MAX_RECV_DLENGTH: |
| 560 | if (conn->max_recv_dlength > 65536) |
| 561 | conn->max_recv_dlength = 65536; |
| 562 | break; |
| 563 | case ISCSI_PARAM_MAX_BURST: |
Jayamohan Kallickal | 230dceb | 2010-01-23 05:36:10 +0530 | [diff] [blame] | 564 | if (session->max_burst > 262144) |
| 565 | session->max_burst = 262144; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 566 | break; |
Jayamohan Kallickal | 42f43c4 | 2010-07-22 04:26:45 +0530 | [diff] [blame] | 567 | case ISCSI_PARAM_MAX_XMIT_DLENGTH: |
| 568 | if ((conn->max_xmit_dlength > 65536) || |
| 569 | (conn->max_xmit_dlength == 0)) |
| 570 | conn->max_xmit_dlength = 65536; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 571 | default: |
| 572 | return 0; |
| 573 | } |
| 574 | |
| 575 | return 0; |
| 576 | } |
| 577 | |
| 578 | /** |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 579 | * beiscsi_get_initname - Read Initiator Name from flash |
| 580 | * @buf: buffer bointer |
| 581 | * @phba: The device priv structure instance |
| 582 | * |
| 583 | * returns number of bytes |
| 584 | */ |
| 585 | static int beiscsi_get_initname(char *buf, struct beiscsi_hba *phba) |
| 586 | { |
| 587 | int rc; |
| 588 | unsigned int tag, wrb_num; |
| 589 | unsigned short status, extd_status; |
| 590 | struct be_mcc_wrb *wrb; |
| 591 | struct be_cmd_hba_name *resp; |
| 592 | struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; |
| 593 | |
| 594 | tag = be_cmd_get_initname(phba); |
| 595 | if (!tag) { |
| 596 | SE_DEBUG(DBG_LVL_1, "Getting Initiator Name Failed\n"); |
| 597 | return -EBUSY; |
| 598 | } else |
| 599 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], |
| 600 | phba->ctrl.mcc_numtag[tag]); |
| 601 | |
| 602 | wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16; |
| 603 | extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8; |
| 604 | status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; |
| 605 | |
| 606 | if (status || extd_status) { |
| 607 | SE_DEBUG(DBG_LVL_1, "MailBox Command Failed with " |
| 608 | "status = %d extd_status = %d\n", |
| 609 | status, extd_status); |
| 610 | free_mcc_tag(&phba->ctrl, tag); |
| 611 | return -EAGAIN; |
| 612 | } |
| 613 | wrb = queue_get_wrb(mccq, wrb_num); |
| 614 | free_mcc_tag(&phba->ctrl, tag); |
| 615 | resp = embedded_payload(wrb); |
| 616 | rc = sprintf(buf, "%s\n", resp->initiator_name); |
| 617 | return rc; |
| 618 | } |
| 619 | |
| 620 | /** |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 621 | * beiscsi_get_host_param - get the iscsi parameter |
| 622 | * @shost: pointer to scsi_host structure |
| 623 | * @param: parameter type identifier |
| 624 | * @buf: buffer pointer |
| 625 | * |
| 626 | * returns host parameter |
| 627 | */ |
| 628 | int beiscsi_get_host_param(struct Scsi_Host *shost, |
| 629 | enum iscsi_host_param param, char *buf) |
| 630 | { |
Mike Christie | 3093b04 | 2011-07-25 13:48:46 -0500 | [diff] [blame] | 631 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jayamohan Kallickal | b15d05b | 2010-08-12 23:36:06 +0530 | [diff] [blame] | 632 | int status = 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 633 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 634 | SE_DEBUG(DBG_LVL_8, "In beiscsi_get_host_param, param= %d\n", param); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 635 | switch (param) { |
| 636 | case ISCSI_HOST_PARAM_HWADDRESS: |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 637 | status = beiscsi_get_macaddr(buf, phba); |
| 638 | if (status < 0) { |
| 639 | SE_DEBUG(DBG_LVL_1, "beiscsi_get_macaddr Failed\n"); |
| 640 | return status; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 641 | } |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 642 | break; |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 643 | case ISCSI_HOST_PARAM_INITIATOR_NAME: |
| 644 | status = beiscsi_get_initname(buf, phba); |
| 645 | if (status < 0) { |
| 646 | SE_DEBUG(DBG_LVL_1, |
| 647 | "Retreiving Initiator Name Failed\n"); |
| 648 | return status; |
| 649 | } |
| 650 | break; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 651 | default: |
| 652 | return iscsi_host_get_param(shost, param, buf); |
| 653 | } |
Jayamohan Kallickal | b15d05b | 2010-08-12 23:36:06 +0530 | [diff] [blame] | 654 | return status; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 655 | } |
| 656 | |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 657 | int beiscsi_get_macaddr(char *buf, struct beiscsi_hba *phba) |
| 658 | { |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame^] | 659 | struct be_cmd_get_nic_conf_resp resp; |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 660 | int rc; |
| 661 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame^] | 662 | if (strlen(phba->mac_address)) |
| 663 | return strlcpy(buf, phba->mac_address, PAGE_SIZE); |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 664 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame^] | 665 | memset(&resp, 0, sizeof(resp)); |
| 666 | rc = mgmt_get_nic_conf(phba, &resp); |
| 667 | if (rc) |
| 668 | return rc; |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 669 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame^] | 670 | memcpy(phba->mac_address, resp.mac_address, ETH_ALEN); |
| 671 | return sysfs_format_mac(buf, phba->mac_address, ETH_ALEN); |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 672 | } |
| 673 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 674 | /** |
| 675 | * beiscsi_conn_get_stats - get the iscsi stats |
| 676 | * @cls_conn: pointer to iscsi cls conn |
| 677 | * @stats: pointer to iscsi_stats structure |
| 678 | * |
| 679 | * returns iscsi stats |
| 680 | */ |
| 681 | void beiscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, |
| 682 | struct iscsi_stats *stats) |
| 683 | { |
| 684 | struct iscsi_conn *conn = cls_conn->dd_data; |
| 685 | |
| 686 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_get_stats\n"); |
| 687 | stats->txdata_octets = conn->txdata_octets; |
| 688 | stats->rxdata_octets = conn->rxdata_octets; |
| 689 | stats->dataout_pdus = conn->dataout_pdus_cnt; |
| 690 | stats->scsirsp_pdus = conn->scsirsp_pdus_cnt; |
| 691 | stats->scsicmd_pdus = conn->scsicmd_pdus_cnt; |
| 692 | stats->datain_pdus = conn->datain_pdus_cnt; |
| 693 | stats->tmfrsp_pdus = conn->tmfrsp_pdus_cnt; |
| 694 | stats->tmfcmd_pdus = conn->tmfcmd_pdus_cnt; |
| 695 | stats->r2t_pdus = conn->r2t_pdus_cnt; |
| 696 | stats->digest_err = 0; |
| 697 | stats->timeout_err = 0; |
| 698 | stats->custom_length = 0; |
| 699 | strcpy(stats->custom[0].desc, "eh_abort_cnt"); |
| 700 | stats->custom[0].value = conn->eh_abort_cnt; |
| 701 | } |
| 702 | |
| 703 | /** |
| 704 | * beiscsi_set_params_for_offld - get the parameters for offload |
| 705 | * @beiscsi_conn: pointer to beiscsi_conn |
| 706 | * @params: pointer to offload_params structure |
| 707 | */ |
| 708 | static void beiscsi_set_params_for_offld(struct beiscsi_conn *beiscsi_conn, |
| 709 | struct beiscsi_offload_params *params) |
| 710 | { |
| 711 | struct iscsi_conn *conn = beiscsi_conn->conn; |
| 712 | struct iscsi_session *session = conn->session; |
| 713 | |
| 714 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, max_burst_length, |
| 715 | params, session->max_burst); |
| 716 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, |
| 717 | max_send_data_segment_length, params, |
| 718 | conn->max_xmit_dlength); |
| 719 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, first_burst_length, |
| 720 | params, session->first_burst); |
| 721 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, erl, params, |
| 722 | session->erl); |
| 723 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, dde, params, |
| 724 | conn->datadgst_en); |
| 725 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, hde, params, |
| 726 | conn->hdrdgst_en); |
| 727 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, ir2t, params, |
| 728 | session->initial_r2t_en); |
| 729 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, imd, params, |
| 730 | session->imm_data_en); |
| 731 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, exp_statsn, params, |
| 732 | (conn->exp_statsn - 1)); |
| 733 | } |
| 734 | |
| 735 | /** |
| 736 | * beiscsi_conn_start - offload of session to chip |
| 737 | * @cls_conn: pointer to beiscsi_conn |
| 738 | */ |
| 739 | int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn) |
| 740 | { |
| 741 | struct iscsi_conn *conn = cls_conn->dd_data; |
| 742 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; |
| 743 | struct beiscsi_endpoint *beiscsi_ep; |
| 744 | struct beiscsi_offload_params params; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 745 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 746 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_start\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 747 | memset(¶ms, 0, sizeof(struct beiscsi_offload_params)); |
| 748 | beiscsi_ep = beiscsi_conn->ep; |
| 749 | if (!beiscsi_ep) |
| 750 | SE_DEBUG(DBG_LVL_1, "In beiscsi_conn_start , no beiscsi_ep\n"); |
| 751 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 752 | beiscsi_conn->login_in_progress = 0; |
| 753 | beiscsi_set_params_for_offld(beiscsi_conn, ¶ms); |
| 754 | beiscsi_offload_connection(beiscsi_conn, ¶ms); |
| 755 | iscsi_conn_start(cls_conn); |
| 756 | return 0; |
| 757 | } |
| 758 | |
| 759 | /** |
| 760 | * beiscsi_get_cid - Allocate a cid |
| 761 | * @phba: The phba instance |
| 762 | */ |
| 763 | static int beiscsi_get_cid(struct beiscsi_hba *phba) |
| 764 | { |
| 765 | unsigned short cid = 0xFFFF; |
| 766 | |
| 767 | if (!phba->avlbl_cids) |
| 768 | return cid; |
| 769 | |
| 770 | cid = phba->cid_array[phba->cid_alloc++]; |
| 771 | if (phba->cid_alloc == phba->params.cxns_per_ctrl) |
| 772 | phba->cid_alloc = 0; |
| 773 | phba->avlbl_cids--; |
| 774 | return cid; |
| 775 | } |
| 776 | |
| 777 | /** |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 778 | * beiscsi_put_cid - Free the cid |
| 779 | * @phba: The phba for which the cid is being freed |
| 780 | * @cid: The cid to free |
| 781 | */ |
| 782 | static void beiscsi_put_cid(struct beiscsi_hba *phba, unsigned short cid) |
| 783 | { |
| 784 | phba->avlbl_cids++; |
| 785 | phba->cid_array[phba->cid_free++] = cid; |
| 786 | if (phba->cid_free == phba->params.cxns_per_ctrl) |
| 787 | phba->cid_free = 0; |
| 788 | } |
| 789 | |
| 790 | /** |
| 791 | * beiscsi_free_ep - free endpoint |
| 792 | * @ep: pointer to iscsi endpoint structure |
| 793 | */ |
| 794 | static void beiscsi_free_ep(struct beiscsi_endpoint *beiscsi_ep) |
| 795 | { |
| 796 | struct beiscsi_hba *phba = beiscsi_ep->phba; |
| 797 | |
| 798 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); |
| 799 | beiscsi_ep->phba = NULL; |
| 800 | } |
| 801 | |
| 802 | /** |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 803 | * beiscsi_open_conn - Ask FW to open a TCP connection |
| 804 | * @ep: endpoint to be used |
| 805 | * @src_addr: The source IP address |
| 806 | * @dst_addr: The Destination IP address |
| 807 | * |
| 808 | * Asks the FW to open a TCP connection |
| 809 | */ |
| 810 | static int beiscsi_open_conn(struct iscsi_endpoint *ep, |
| 811 | struct sockaddr *src_addr, |
| 812 | struct sockaddr *dst_addr, int non_blocking) |
| 813 | { |
| 814 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; |
| 815 | struct beiscsi_hba *phba = beiscsi_ep->phba; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 816 | struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; |
| 817 | struct be_mcc_wrb *wrb; |
| 818 | struct tcp_connect_and_offload_out *ptcpcnct_out; |
| 819 | unsigned short status, extd_status; |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 820 | struct be_dma_mem nonemb_cmd; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 821 | unsigned int tag, wrb_num; |
Jayamohan Kallickal | d3ad2bb | 2010-07-22 04:16:38 +0530 | [diff] [blame] | 822 | int ret = -ENOMEM; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 823 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 824 | SE_DEBUG(DBG_LVL_8, "In beiscsi_open_conn\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 825 | beiscsi_ep->ep_cid = beiscsi_get_cid(phba); |
| 826 | if (beiscsi_ep->ep_cid == 0xFFFF) { |
| 827 | SE_DEBUG(DBG_LVL_1, "No free cid available\n"); |
| 828 | return ret; |
| 829 | } |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 830 | SE_DEBUG(DBG_LVL_8, "In beiscsi_open_conn, ep_cid=%d\n", |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 831 | beiscsi_ep->ep_cid); |
Jayamohan Kallickal | 7da5087 | 2010-01-05 05:04:12 +0530 | [diff] [blame] | 832 | phba->ep_array[beiscsi_ep->ep_cid - |
| 833 | phba->fw_config.iscsi_cid_start] = ep; |
| 834 | if (beiscsi_ep->ep_cid > (phba->fw_config.iscsi_cid_start + |
| 835 | phba->params.cxns_per_ctrl * 2)) { |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 836 | SE_DEBUG(DBG_LVL_1, "Failed in allocate iscsi cid\n"); |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 837 | goto free_ep; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | beiscsi_ep->cid_vld = 0; |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 841 | nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, |
| 842 | sizeof(struct tcp_connect_and_offload_in), |
| 843 | &nonemb_cmd.dma); |
| 844 | if (nonemb_cmd.va == NULL) { |
| 845 | SE_DEBUG(DBG_LVL_1, |
| 846 | "Failed to allocate memory for mgmt_open_connection" |
| 847 | "\n"); |
| 848 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); |
| 849 | return -ENOMEM; |
| 850 | } |
| 851 | nonemb_cmd.size = sizeof(struct tcp_connect_and_offload_in); |
| 852 | memset(nonemb_cmd.va, 0, nonemb_cmd.size); |
| 853 | tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep, &nonemb_cmd); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 854 | if (!tag) { |
| 855 | SE_DEBUG(DBG_LVL_1, |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 856 | "mgmt_open_connection Failed for cid=%d\n", |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 857 | beiscsi_ep->ep_cid); |
Jayamohan Kallickal | 1f92638 | 2010-07-22 04:22:27 +0530 | [diff] [blame] | 858 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 859 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
| 860 | nonemb_cmd.va, nonemb_cmd.dma); |
Jayamohan Kallickal | 1f92638 | 2010-07-22 04:22:27 +0530 | [diff] [blame] | 861 | return -EAGAIN; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 862 | } else { |
| 863 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], |
| 864 | phba->ctrl.mcc_numtag[tag]); |
| 865 | } |
| 866 | wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16; |
| 867 | extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8; |
| 868 | status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; |
| 869 | if (status || extd_status) { |
| 870 | SE_DEBUG(DBG_LVL_1, "mgmt_open_connection Failed" |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 871 | " status = %d extd_status = %d\n", |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 872 | status, extd_status); |
| 873 | free_mcc_tag(&phba->ctrl, tag); |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 874 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
| 875 | nonemb_cmd.va, nonemb_cmd.dma); |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 876 | goto free_ep; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 877 | } else { |
| 878 | wrb = queue_get_wrb(mccq, wrb_num); |
| 879 | free_mcc_tag(&phba->ctrl, tag); |
| 880 | |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 881 | ptcpcnct_out = embedded_payload(wrb); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 882 | beiscsi_ep = ep->dd_data; |
| 883 | beiscsi_ep->fw_handle = ptcpcnct_out->connection_handle; |
| 884 | beiscsi_ep->cid_vld = 1; |
| 885 | SE_DEBUG(DBG_LVL_8, "mgmt_open_connection Success\n"); |
| 886 | } |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 887 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
| 888 | nonemb_cmd.va, nonemb_cmd.dma); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 889 | return 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 890 | |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 891 | free_ep: |
| 892 | beiscsi_free_ep(beiscsi_ep); |
Jayamohan Kallickal | d3ad2bb | 2010-07-22 04:16:38 +0530 | [diff] [blame] | 893 | return -EBUSY; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 894 | } |
| 895 | |
| 896 | /** |
| 897 | * beiscsi_ep_connect - Ask chip to create TCP Conn |
| 898 | * @scsi_host: Pointer to scsi_host structure |
| 899 | * @dst_addr: The IP address of Target |
| 900 | * @non_blocking: blocking or non-blocking call |
| 901 | * |
| 902 | * This routines first asks chip to create a connection and then allocates an EP |
| 903 | */ |
| 904 | struct iscsi_endpoint * |
| 905 | beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr, |
| 906 | int non_blocking) |
| 907 | { |
| 908 | struct beiscsi_hba *phba; |
| 909 | struct beiscsi_endpoint *beiscsi_ep; |
| 910 | struct iscsi_endpoint *ep; |
| 911 | int ret; |
| 912 | |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 913 | SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_connect\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 914 | if (shost) |
| 915 | phba = iscsi_host_priv(shost); |
| 916 | else { |
| 917 | ret = -ENXIO; |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 918 | SE_DEBUG(DBG_LVL_1, "shost is NULL\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 919 | return ERR_PTR(ret); |
| 920 | } |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 921 | |
Jayamohan Kallickal | 5dc1c41 | 2010-01-23 05:36:52 +0530 | [diff] [blame] | 922 | if (phba->state != BE_ADAPTER_UP) { |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 923 | ret = -EBUSY; |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 924 | SE_DEBUG(DBG_LVL_1, "The Adapter state is Not UP\n"); |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 925 | return ERR_PTR(ret); |
| 926 | } |
| 927 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 928 | ep = iscsi_create_endpoint(sizeof(struct beiscsi_endpoint)); |
| 929 | if (!ep) { |
| 930 | ret = -ENOMEM; |
| 931 | return ERR_PTR(ret); |
| 932 | } |
| 933 | |
| 934 | beiscsi_ep = ep->dd_data; |
| 935 | beiscsi_ep->phba = phba; |
Jayamohan Kallickal | c246228 | 2010-01-05 05:05:34 +0530 | [diff] [blame] | 936 | beiscsi_ep->openiscsi_ep = ep; |
Jayamohan Kallickal | f5ed7bd | 2010-07-22 04:18:01 +0530 | [diff] [blame] | 937 | ret = beiscsi_open_conn(ep, NULL, dst_addr, non_blocking); |
| 938 | if (ret) { |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 939 | SE_DEBUG(DBG_LVL_1, "Failed in beiscsi_open_conn\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 940 | goto free_ep; |
| 941 | } |
| 942 | |
| 943 | return ep; |
| 944 | |
| 945 | free_ep: |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 946 | iscsi_destroy_endpoint(ep); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 947 | return ERR_PTR(ret); |
| 948 | } |
| 949 | |
| 950 | /** |
| 951 | * beiscsi_ep_poll - Poll to see if connection is established |
| 952 | * @ep: endpoint to be used |
| 953 | * @timeout_ms: timeout specified in millisecs |
| 954 | * |
| 955 | * Poll to see if TCP connection established |
| 956 | */ |
| 957 | int beiscsi_ep_poll(struct iscsi_endpoint *ep, int timeout_ms) |
| 958 | { |
| 959 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; |
| 960 | |
| 961 | SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_poll\n"); |
| 962 | if (beiscsi_ep->cid_vld == 1) |
| 963 | return 1; |
| 964 | else |
| 965 | return 0; |
| 966 | } |
| 967 | |
| 968 | /** |
| 969 | * beiscsi_close_conn - Upload the connection |
| 970 | * @ep: The iscsi endpoint |
| 971 | * @flag: The type of connection closure |
| 972 | */ |
Jayamohan Kallickal | c246228 | 2010-01-05 05:05:34 +0530 | [diff] [blame] | 973 | static int beiscsi_close_conn(struct beiscsi_endpoint *beiscsi_ep, int flag) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 974 | { |
| 975 | int ret = 0; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 976 | unsigned int tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 977 | struct beiscsi_hba *phba = beiscsi_ep->phba; |
| 978 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 979 | tag = mgmt_upload_connection(phba, beiscsi_ep->ep_cid, flag); |
| 980 | if (!tag) { |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 981 | SE_DEBUG(DBG_LVL_8, "upload failed for cid 0x%x\n", |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 982 | beiscsi_ep->ep_cid); |
Jayamohan Kallickal | d3ad2bb | 2010-07-22 04:16:38 +0530 | [diff] [blame] | 983 | ret = -EAGAIN; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 984 | } else { |
| 985 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], |
| 986 | phba->ctrl.mcc_numtag[tag]); |
| 987 | free_mcc_tag(&phba->ctrl, tag); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 988 | } |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 989 | return ret; |
| 990 | } |
| 991 | |
| 992 | /** |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 993 | * beiscsi_unbind_conn_to_cid - Unbind the beiscsi_conn from phba conn table |
| 994 | * @phba: The phba instance |
| 995 | * @cid: The cid to free |
| 996 | */ |
| 997 | static int beiscsi_unbind_conn_to_cid(struct beiscsi_hba *phba, |
| 998 | unsigned int cid) |
| 999 | { |
| 1000 | if (phba->conn_table[cid]) |
| 1001 | phba->conn_table[cid] = NULL; |
| 1002 | else { |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 1003 | SE_DEBUG(DBG_LVL_8, "Connection table Not occupied.\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1004 | return -EINVAL; |
| 1005 | } |
| 1006 | return 0; |
| 1007 | } |
| 1008 | |
| 1009 | /** |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1010 | * beiscsi_ep_disconnect - Tears down the TCP connection |
| 1011 | * @ep: endpoint to be used |
| 1012 | * |
| 1013 | * Tears down the TCP connection |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1014 | */ |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1015 | void beiscsi_ep_disconnect(struct iscsi_endpoint *ep) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1016 | { |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1017 | struct beiscsi_conn *beiscsi_conn; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1018 | struct beiscsi_endpoint *beiscsi_ep; |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1019 | struct beiscsi_hba *phba; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1020 | unsigned int tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1021 | unsigned short savecfg_flag = CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH; |
| 1022 | |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1023 | beiscsi_ep = ep->dd_data; |
| 1024 | phba = beiscsi_ep->phba; |
| 1025 | SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_disconnect for ep_cid = %d\n", |
| 1026 | beiscsi_ep->ep_cid); |
| 1027 | |
| 1028 | if (!beiscsi_ep->conn) { |
| 1029 | SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_disconnect, no " |
| 1030 | "beiscsi_ep\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1031 | return; |
| 1032 | } |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1033 | beiscsi_conn = beiscsi_ep->conn; |
| 1034 | iscsi_suspend_queue(beiscsi_conn->conn); |
| 1035 | |
| 1036 | SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_disconnect ep_cid = %d\n", |
| 1037 | beiscsi_ep->ep_cid); |
| 1038 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1039 | tag = mgmt_invalidate_connection(phba, beiscsi_ep, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1040 | beiscsi_ep->ep_cid, 1, |
| 1041 | savecfg_flag); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1042 | if (!tag) { |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1043 | SE_DEBUG(DBG_LVL_1, |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 1044 | "mgmt_invalidate_connection Failed for cid=%d\n", |
Jayamohan Kallickal | 90a289e | 2010-02-20 08:04:28 +0530 | [diff] [blame] | 1045 | beiscsi_ep->ep_cid); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1046 | } else { |
| 1047 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], |
| 1048 | phba->ctrl.mcc_numtag[tag]); |
| 1049 | free_mcc_tag(&phba->ctrl, tag); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1050 | } |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1051 | |
Jayamohan Kallickal | c246228 | 2010-01-05 05:05:34 +0530 | [diff] [blame] | 1052 | beiscsi_close_conn(beiscsi_ep, CONNECTION_UPLOAD_GRACEFUL); |
| 1053 | beiscsi_free_ep(beiscsi_ep); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1054 | beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid); |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1055 | iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1056 | } |
Mike Christie | 3128c6c | 2011-07-25 13:48:42 -0500 | [diff] [blame] | 1057 | |
Al Viro | 587a1f1 | 2011-07-23 23:11:19 -0400 | [diff] [blame] | 1058 | umode_t be2iscsi_attr_is_visible(int param_type, int param) |
Mike Christie | 3128c6c | 2011-07-25 13:48:42 -0500 | [diff] [blame] | 1059 | { |
| 1060 | switch (param_type) { |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame^] | 1061 | case ISCSI_NET_PARAM: |
| 1062 | switch (param) { |
| 1063 | case ISCSI_NET_PARAM_IFACE_ENABLE: |
| 1064 | case ISCSI_NET_PARAM_IPV4_ADDR: |
| 1065 | case ISCSI_NET_PARAM_IPV4_SUBNET: |
| 1066 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: |
| 1067 | case ISCSI_NET_PARAM_IPV4_GW: |
| 1068 | case ISCSI_NET_PARAM_IPV6_ADDR: |
| 1069 | return S_IRUGO; |
| 1070 | default: |
| 1071 | return 0; |
| 1072 | } |
Mike Christie | f27fb2e | 2011-07-25 13:48:45 -0500 | [diff] [blame] | 1073 | case ISCSI_HOST_PARAM: |
| 1074 | switch (param) { |
| 1075 | case ISCSI_HOST_PARAM_HWADDRESS: |
Mike Christie | f27fb2e | 2011-07-25 13:48:45 -0500 | [diff] [blame] | 1076 | return S_IRUGO; |
| 1077 | default: |
| 1078 | return 0; |
| 1079 | } |
Mike Christie | 3128c6c | 2011-07-25 13:48:42 -0500 | [diff] [blame] | 1080 | case ISCSI_PARAM: |
| 1081 | switch (param) { |
| 1082 | case ISCSI_PARAM_MAX_RECV_DLENGTH: |
| 1083 | case ISCSI_PARAM_MAX_XMIT_DLENGTH: |
| 1084 | case ISCSI_PARAM_HDRDGST_EN: |
| 1085 | case ISCSI_PARAM_DATADGST_EN: |
| 1086 | case ISCSI_PARAM_CONN_ADDRESS: |
| 1087 | case ISCSI_PARAM_CONN_PORT: |
| 1088 | case ISCSI_PARAM_EXP_STATSN: |
| 1089 | case ISCSI_PARAM_PERSISTENT_ADDRESS: |
| 1090 | case ISCSI_PARAM_PERSISTENT_PORT: |
| 1091 | case ISCSI_PARAM_PING_TMO: |
| 1092 | case ISCSI_PARAM_RECV_TMO: |
Mike Christie | 1d063c1 | 2011-07-25 13:48:43 -0500 | [diff] [blame] | 1093 | case ISCSI_PARAM_INITIAL_R2T_EN: |
| 1094 | case ISCSI_PARAM_MAX_R2T: |
| 1095 | case ISCSI_PARAM_IMM_DATA_EN: |
| 1096 | case ISCSI_PARAM_FIRST_BURST: |
| 1097 | case ISCSI_PARAM_MAX_BURST: |
| 1098 | case ISCSI_PARAM_PDU_INORDER_EN: |
| 1099 | case ISCSI_PARAM_DATASEQ_INORDER_EN: |
| 1100 | case ISCSI_PARAM_ERL: |
| 1101 | case ISCSI_PARAM_TARGET_NAME: |
| 1102 | case ISCSI_PARAM_TPGT: |
| 1103 | case ISCSI_PARAM_USERNAME: |
| 1104 | case ISCSI_PARAM_PASSWORD: |
| 1105 | case ISCSI_PARAM_USERNAME_IN: |
| 1106 | case ISCSI_PARAM_PASSWORD_IN: |
| 1107 | case ISCSI_PARAM_FAST_ABORT: |
| 1108 | case ISCSI_PARAM_ABORT_TMO: |
| 1109 | case ISCSI_PARAM_LU_RESET_TMO: |
| 1110 | case ISCSI_PARAM_IFACE_NAME: |
| 1111 | case ISCSI_PARAM_INITIATOR_NAME: |
Mike Christie | 3128c6c | 2011-07-25 13:48:42 -0500 | [diff] [blame] | 1112 | return S_IRUGO; |
| 1113 | default: |
| 1114 | return 0; |
| 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | return 0; |
| 1119 | } |