fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Discovery of targets and access to the persistent storage starts here.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local function prototypes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic boolean_t iscsid_init_config(iscsi_hba_t *ihp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic boolean_t iscsid_init_targets(iscsi_hba_t *ihp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void iscsid_thread_static(iscsi_thread_t *thread, void *p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void iscsid_thread_sendtgts(iscsi_thread_t *thread, void *p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void iscsid_thread_isns(iscsi_thread_t *thread, void *p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void iscsid_thread_slp(iscsi_thread_t *thread, void *p);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Mengstatic void iscsid_thread_boot_wd(iscsi_thread_t *thread, void *p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void iscsid_threads_create(iscsi_hba_t *ihp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void iscsid_threads_destroy(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iscsid_copyto_param_set(uint32_t param_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_login_params_t *params, iscsi_param_set_t *ipsp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void iscsid_add_pg_list_to_cache(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void iscsid_remove_target_param(char *name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic boolean_t iscsid_add(iscsi_hba_t *ihp, iSCSIDiscoveryMethod_t method,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sockaddr *addr_dsc, char *target_name, int tpgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void iscsi_discovery_event(iscsi_hba_t *ihp,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Mengstatic boolean_t iscsid_boot_init_config(iscsi_hba_t *ihp);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Mengstatic iscsi_sess_t *iscsi_add_boot_sess(iscsi_hba_t *ihp, int isid);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Mengstatic boolean_t iscsid_make_entry(ib_boot_prop_t *boot_prop_entry,
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Mengstatic boolean_t iscsid_check_active_boot_conn(iscsi_hba_t *ihp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI target discovery thread table
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "SendTarget" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * discovery method event table
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSIDiscoveryMethodUnknown /* terminating value */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * The following private tunable, set in /etc/system, e.g.,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * set iscsi:iscsi_boot_max_delay = 360
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * , provides with customer a max wait time in
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * seconds to wait for boot lun online during iscsi boot.
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * Defaults to 180s.
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Mengint iscsi_boot_max_delay = ISCSI_BOOT_DEFAULT_MAX_DELAY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * discovery configuration semaphore
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Mengstatic iscsi_thread_t *iscsi_boot_wd_handle = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CHECK_METHOD(v) ((dm & v) ? B_TRUE : B_FALSE)
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * Check if IP is valid
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng for (; (ip[i] == 0) && (i < IB_IP_BUFLEN); i++) {}
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* invalid IP address */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * Make an entry for the boot target.
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * return B_TRUE upon success
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * B_FALSE if fail
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Mengiscsid_make_entry(ib_boot_prop_t *boot_prop_entry, entry_t *entry)
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (boot_prop_entry->boot_tgt.sin_family != AF_INET &&
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (boot_prop_entry->boot_tgt.sin_family == AF_INET) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng &boot_prop_entry->boot_tgt.tgt_ip_u.u_in6.s6_addr,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng entry->e_port = boot_prop_entry->boot_tgt.tgt_port;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * Create the boot session
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * iscsid_init -- to initialize stuffs related to iscsi daemon,
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * and to create boot session if needed
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng /* normal case, load the persistent store */
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng if ((modrootloaded == 0) && (iscsiboot_prop != NULL)) {
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng cmn_err(CE_NOTE, "Initializaton of iscsi boot session"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " partially failed");
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * iscsid_start -- start the iscsi initiator daemon, actually this code
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * is just to enable discovery methods which are set enabled in
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * persistent store, as an economic way to present the 'daemon' funtionality
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * In case of failure the events still need to be sent
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * because the door daemon will pause until all these
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * events have occurred.
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng /* ---- Send both start and end events ---- */
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * iscsid_stop -- stop the iscsi initiator daemon, by disabling
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * all the discovery methods first, and then try to stop all
08dcd69c259e91563982b9e7715366f99fee816eJack Meng * related threads. This is a try-best effort, leave any 'busy' device
08dcd69c259e91563982b9e7715366f99fee816eJack Meng * (and therefore session) there and just return.
aefdd1313598221872b3e520302b40e1874f2dc7bing zhao - Sun Microsystems - Beijing China iscsi_sess_t *isp = NULL;
08dcd69c259e91563982b9e7715366f99fee816eJack Meng (void) iscsid_disable_discovery(ihp, ISCSI_ALL_DISCOVERY_METHODS);
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng /* final check */
aefdd1313598221872b3e520302b40e1874f2dc7bing zhao - Sun Microsystems - Beijing China * If only boot session is left, that is OK.
08dcd69c259e91563982b9e7715366f99fee816eJack Meng * Otherwise, we should report that some sessions are left.
aefdd1313598221872b3e520302b40e1874f2dc7bing zhao - Sun Microsystems - Beijing China for (isp = ihp->hba_sess_list; isp != NULL;
aefdd1313598221872b3e520302b40e1874f2dc7bing zhao - Sun Microsystems - Beijing China isp = isp->sess_next) {
aefdd1313598221872b3e520302b40e1874f2dc7bing zhao - Sun Microsystems - Beijing China if (isp->sess_boot == B_FALSE) {
aefdd1313598221872b3e520302b40e1874f2dc7bing zhao - Sun Microsystems - Beijing China rval = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_fini -- do whatever is required to clean up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_props -- returns discovery thread information, used by ioctl code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ---- change once thread is implemented ---- */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte props->iSNSDiscoveryMethod = iSNSDiscoveryMethodStatic;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte props->iSNSDiscoveryEnabled = CHECK_METHOD(iSCSIDiscoveryMethodISNS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte props->SLPDiscoveryEnabled = CHECK_METHOD(iSCSIDiscoveryMethodSLP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_enable_discovery - start specified discovery methods
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_enable_discovery(iscsi_hba_t *ihp, iSCSIDiscoveryMethod_t idm,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * start the specified discovery method(s)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (dt = &iscsid_thr[0]; dt->method != iSCSIDiscoveryMethodUnknown;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * unexpected condition. The threads for each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * discovery method should have started at
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initialization
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* END for() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_disable_discovery - stop specified discovery methods
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_disable_discovery(iscsi_hba_t *ihp, iSCSIDiscoveryMethod_t idm)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stop the specified discovery method(s)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (dt = &iscsid_thr[0]; dt->method != iSCSIDiscoveryMethodUnknown;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* signal discovery event change - begin */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Attempt to logout of all associated targets */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Successfully logged out of targets */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * signal discovery
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * event change - end
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * unexpected condition. The threads
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for each discovery method should
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * have started at initialization
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* signal discovery event change - end */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* END for() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_poke_discovery - wakeup discovery methods to find any new targets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and wait for all discovery processes to complete.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_poke_discovery(iscsi_hba_t *ihp, iSCSIDiscoveryMethod_t method)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reset discovery flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ihp->hba_discovery_events = iSCSIDiscoveryMethodUnknown;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* start all enabled discovery methods */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (dt = &iscsid_thr[0]; dt->method != iSCSIDiscoveryMethodUnknown;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ihp->hba_discovery_events != ISCSI_ALL_DISCOVERY_METHODS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_do_sendtgts - issue send targets command to the given discovery
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * address and then add the discovered targets to the discovery queue
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng iSCSIDiscoveryMethod_t dm = iSCSIDiscoveryMethodSendTargets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate and initialize sendtargets list header */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stl_sz = sizeof (*stl_hdr) + ((stl_num_tgts - 1) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stl_hdr->stl_entry.e_vers = ISCSI_INTERFACE_VERSION;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* lock interface so only one SendTargets operation occurs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ihp = (iscsi_hba_t *)ddi_get_soft_state(iscsi_state, 0)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_NOTE, "!iscsi discovery failure - SendTargets. "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "failure to get soft state");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "iscsi discovery failure - SendTargets (%s)\n", ip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check if all targets received */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stl_hdr->stl_in_cnt < stl_hdr->stl_out_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct in_addr) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (ctr = 0; ctr < stl_hdr->stl_out_cnt; ctr++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &disc_addr->e_u, disc_addr->e_port, &addr_dsc.sin);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stl_hdr->stl_list[ctr].ste_ipaddr.a_addr.i_insize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(stl_hdr->stl_list[ctr].ste_ipaddr.a_addr.i_addr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &addr_dsc.sin, (char *)stl_hdr->stl_list[ctr].ste_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_do_isns_query_one_server(iscsi_hba_t *ihp, entry_t *isns_server)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ap = (iscsi_addr_t *)kmem_zalloc(sizeof (iscsi_addr_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_server->e_insize == sizeof (struct in_addr)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ap->a_addr.i_addr.in4.s_addr = (isns_server->e_u.u_in4.s_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (isns_server->e_insize == sizeof (struct in6_addr)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (query_status != isns_ok || pg_list == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE1(iscsid_do_isns_query_one_server_status,
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (pg_list == NULL) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China DTRACE_PROBE1(iscsid_do_isns_query_status,
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China int, query_status);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China query_status != isns_op_partially_failed)) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China pg_sz = sizeof (isns_portal_group_list_t);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (pg_list->pg_out_cnt > 0) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China pg_sz += (pg_list->pg_out_cnt - 1) *
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China sizeof (isns_portal_group_t);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China kmem_free(pg_list, pg_sz);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_config_one - for the given target name, attempt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to login to all targets associated with name. If target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * name is not found in discovery queue, reset the discovery
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * queue, kick the discovery processes, and then retry.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE: The caller of this function must hold the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_config_semaphore across this call.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_config_one(iscsi_hba_t *ihp, char *name, boolean_t protect)
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " iSCSI boot session...");
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap cmn_err(CE_WARN, "Failed to configure interface"
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap " for iSCSI boot session");
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * create boot session
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * no active connection for the boot
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * session, retry the login until
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * one is found or the retry count
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * is exceeded
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * The boot session has been created with active
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * connection. If the target lun has not been online,
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * we should wait here for a while
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng } while ((lun_online == 0) &&
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " boot session");
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng rc = iscsid_login_tgt(ihp, name, iSCSIDiscoveryMethodUnknown,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * If we didn't login to the device we might have
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * to update our discovery information and attempt
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * the login again.
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * Stale /dev links can cause us to get floods
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * of config requests. Prevent these repeated
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * requests from causing unneeded discovery updates
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * if ISCSI_CONFIG_STORM_PROTECT is set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_config_all - reset the discovery queue, kick the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * discovery processes, and login to all targets found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE: The caller of this function must hold the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_config_semaphore across this call.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_config_all(iscsi_hba_t *ihp, boolean_t protect)
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " iSCSI boot session...");
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * No boot session has been created.
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * We would like to create the boot
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * Session first.
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * no active connection for the boot
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * session, retry the login until
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * one is found or the retry count
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * is exceeded
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * The boot session has been created with active
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * connection. If the target lun has not been online,
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng * we should wait here for a while
f53e1f190fa4dbfc4440b8598a0d6925192bdc54Jack Meng } while ((lun_online == 0) &&
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " boot session");
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * Stale /dev links can cause us to get floods
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * of config requests. Prevent these repeated
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * requests from causing unneeded discovery updates
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * if ISCSI_CONFIG_STORM_PROTECT is set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * isns_scn_callback - iSNS client received an SCN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This code processes the iSNS client SCN events. These
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * could relate to the addition, removal, or update of a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No argument */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ihp = (iscsi_hba_t *)ddi_get_soft_state(iscsi_state, 0)) == NULL) {
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * All isns callbacks are from a standalone taskq
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * therefore the blocking here doesn't affect the enable/disable
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * of isns discovery method
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng if (iscsi_client_request_service(ihp) == B_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scn_type = ((isns_scn_callback_arg_t *)arg)->scn_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE1(isns_scn_callback_scn_type, int, scn_type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ISNS_OBJ_ADDED - An object has been added.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Query iSNS server for contact information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((isns_scn_callback_arg_t *)arg)->source_key_attr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify portal group is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Add all portals for logical unit to discovery cache */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsid_addr_to_sockaddr(pg_list->pg_list[i].insize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Force target to login */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_list[i].pg_iscsi_name, iSCSIDiscoveryMethodISNS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ISNS_OBJ_REMOVED - logical unit has been removed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte source_key_attr, iSCSIDiscoveryMethodISNS, NULL) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "isns remove scn failed for target %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ISNS_OBJ_UPDATED - logical unit has changed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "received iSNS update SCN for %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ISNS_OBJ_UNKNOWN -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "received unknown iSNS SCN type 0x%x\n", scn_type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(arg, sizeof (isns_scn_callback_arg_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_add - Creates discovered session and connection
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_add(iscsi_hba_t *ihp, iSCSIDiscoveryMethod_t method,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sockaddr *addr_dsc, char *target_name, int tpgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* setup initial buffer for configured session information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get configured sessions information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (persistent_get_config_session(tmp, ics) == B_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No target information available check for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initiator information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (persistent_get_config_session(tmp, ics) == B_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No hba information is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found. So assume default
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one session unbound behavior.
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * iscsi boot with mpxio disabled
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * no need to search configured boot session
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to see if we need to get more information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* record new size and free last buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate new buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get configured sessions information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (persistent_get_config_session(tmp, ics) != B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "unable to get configured session information\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* loop for all configured sessions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* create or find matching session */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isp = iscsi_sess_create(ihp, method, addr_dsc, target_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* create or find matching connection */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!ISCSI_SUCCESS(iscsi_conn_create(addr_tgt, isp, &icp))) {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * Teardown the session we just created. It can't
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * have any luns or connections associated with it
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * so this should always succeed (luckily since what
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * would we do if it failed?)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_del - Attempts to delete all associated sessions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSIDiscoveryMethod_t method, struct sockaddr *addr_dsc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* target name can be NULL or !NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* addr_dsc can be NULL or !NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If no target_name is listed (meaning all targets)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or this specific target was listed. And the same
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * discovery method discovered this target then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * continue evaulation. Otherwise fail.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strcmp((char *)isp->sess_name, target_name) == 0)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If iSNS, SendTargets, or Static then special
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * handling for disc_addr.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If NULL addr_dsc (meaning all disc_addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or matching discovered addr.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (method == iSCSIDiscoveryMethodStatic) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If NULL addr_dsc (meaning all disc_addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or matching active connection.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Unknown discovery specified */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The most likely destroy failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is that ndi/mdi offline failed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This means that the resource is
5295a27a4fa085a76d771898093c66c844868fc1Jack Meng "resource is in use\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "session logout failed (%d)\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_login_tgt - request target(s) to login
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_login_tgt(iscsi_hba_t *ihp, char *target_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSIDiscoveryMethod_t method, struct sockaddr *addr_dsc)
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China boolean_t rtn = B_FALSE;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China iscsi_sess_t *isp = NULL;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China iscsi_sess_list_t *isp_list = NULL;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China iscsi_sess_list_t *last_sess = NULL;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China iscsi_sess_list_t *cur_sess = NULL;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China ddi_taskq_t *login_taskq = NULL;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China char taskq_name[ISCSI_TH_MAX_NAME_LEN] = {0};
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China time_t time_stamp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop thru sessions */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* unknown method mean login to all */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng#define SESS_DISC_ADDR isp->sess_discovered_addr.sin
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * iSNS or sendtarget
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * discovery and
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * discovery address
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * is NULL or match
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* addr_dsc not a match */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* static configuration */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* method not a match */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* target_name match */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* target_name not a match */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * online the boot session.
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China if (try_online == B_TRUE &&
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China isp->sess_type == ISCSI_SESS_TYPE_NORMAL) {
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China /* Copy these sessions to the list. */
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China if (isp_list == NULL) {
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China (iscsi_sess_list_t *)kmem_zalloc(
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China sizeof (iscsi_sess_list_t), KM_SLEEP);
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China last_sess = isp_list;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China last_sess->session = isp;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China last_sess->next = NULL;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China last_sess->next =
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China (iscsi_sess_list_t *)kmem_zalloc(
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China sizeof (iscsi_sess_list_t), KM_SLEEP);
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China last_sess->next->session = isp;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China last_sess->next->next = NULL;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China last_sess = last_sess->next;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China if (total > 0) {
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China time_stamp = ddi_get_time();
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China (void) snprintf(taskq_name, (ISCSI_TH_MAX_NAME_LEN - 1),
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China "login_queue.%lx", time_stamp);
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China login_taskq = ddi_taskq_create(ihp->hba_dip,
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China taskq_name, total, TASKQ_DEFAULTPRI, 0);
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China if (login_taskq == NULL) {
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China while (isp_list != NULL) {
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China cur_sess = isp_list;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China isp_list = isp_list->next;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China kmem_free(cur_sess, sizeof (iscsi_sess_list_t));
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China rw_exit(&ihp->hba_sess_list_rwlock);
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China for (cur_sess = isp_list; cur_sess != NULL;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China cur_sess = cur_sess->next) {
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China if (ddi_taskq_dispatch(login_taskq,
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China iscsi_sess_online, (void *)cur_sess->session,
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China DDI_SLEEP) != DDI_SUCCESS) {
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China cmn_err(CE_NOTE, "Can't dispatch the task "
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China "for login to the target: %s",
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China cur_sess->session->sess_name);
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China ddi_taskq_wait(login_taskq);
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China ddi_taskq_destroy(login_taskq);
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China while (isp_list != NULL) {
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China cur_sess = isp_list;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China isp_list = isp_list->next;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China kmem_free(cur_sess, sizeof (iscsi_sess_list_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * +--------------------------------------------------------------------+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | Local Helper Functions |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * +--------------------------------------------------------------------+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_init_config -- initialize configuration parameters of iSCSI initiator
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China persistent_tunable_param_t pparam;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate memory to hold initiator names */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte initiatorName = kmem_zalloc(ISCSI_MAX_NAME_LEN, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initialize iSCSI initiator name
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiboot_prop && !iscsi_cmp_boot_ini_name(initiatorName)) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China /* use default tunable value */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ihp->hba_tunable_params.recv_login_rsp_timeout =
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_DEFAULT_RX_TIMEOUT_VALUE;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ihp->hba_tunable_params.polling_login_delay =
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_DEFAULT_LOGIN_POLLING_DELAY;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ihp->hba_tunable_params.conn_login_max =
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_DEFAULT_CONN_DEFAULT_LOGIN_MAX;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " from firmware");
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (persistent_get_tunable_param(initiatorName,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China &pparam) == B_FALSE) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China /* use default value */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China pparam.p_params.recv_login_rsp_timeout =
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_DEFAULT_RX_TIMEOUT_VALUE;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China pparam.p_params.polling_login_delay =
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_DEFAULT_LOGIN_POLLING_DELAY;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China pparam.p_params.conn_login_max =
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_DEFAULT_CONN_DEFAULT_LOGIN_MAX;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China bcopy(&pparam.p_params, &ihp->hba_tunable_params,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China sizeof (iscsi_tunable_params_t));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * if no initiator-node name available it is most
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * likely due to a fresh install, or the persistent
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * store is not working correctly. Set
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * a default initiator name so that the initiator can
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be brought up properly.
329c9e3ded64bba19a3bbac9ee1a0124f04dc044Jack Meng iscsid_set_default_initiator_node_settings(ihp, B_FALSE);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) strncpy(initiatorName, (const char *)ihp->hba_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initialize iSCSI initiator alias (if any)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (persistent_alias_name_get((char *)ips.s_value.v_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No alias defined - not a problem. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * load up the overriden iSCSI initiator parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = kmem_zalloc(ISCSI_MAX_NAME_LEN, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (persistent_param_next(&v, name, &pp) == B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(name, initiatorName, ISCSI_MAX_NAME_LEN) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (param_id = 0; param_id < ISCSI_NUM_LOGIN_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* note error but continue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Failed to set "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "param %d for OID %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* END for() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* END while() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_init_targets -- Load up the driver with known static targets and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * targets whose parameters have been modified.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is done so that the CLI can find a list of targets the driver
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * currently knows about.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The driver doesn't need to log into these targets. Log in is done based
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * upon the enabled discovery methods.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate memory to hold target names */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = kmem_zalloc(ISCSI_MAX_NAME_LEN, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * load up targets whose parameters have been overriden
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ---- only need to be set once ---- */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate memory to hold initiator name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iname = kmem_zalloc(ISCSI_MAX_NAME_LEN, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) persistent_initiator_name_get(iname, ISCSI_MAX_NAME_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (persistent_param_next(&v, name, &pp) == B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(iname, name, ISCSI_MAX_NAME_LEN) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * target name matched initiator's name so,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * continue to next target. Initiator's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parmeters have already been set.
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiboot_prop && iscsi_cmp_boot_tgt_name(name) &&
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * boot target is not mpxio enabled
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * simply ignore these overriden parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ips.s_oid = iscsi_targetparam_get_oid((unsigned char *)name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (param_id = 0; param_id < ISCSI_NUM_LOGIN_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* note error but continue ---- */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "param %d for OID %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* END for() */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiboot_prop && iscsi_cmp_boot_tgt_name(name) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* END while() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_thread_static -- If static discovery is enabled, this routine obtains
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * all statically configured targets from the peristent store and issues a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * login request to the driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_thread_static(iscsi_thread_t *thread, void *p)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_discovery_event(ihp, iSCSIDiscoveryMethodStatic, B_TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ---- ensure static target discovery is enabled ---- */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "iscsi discovery failure - "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "StaticTargets method is not enabled");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * walk list of the statically configured targets from the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * persistent store
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (persistent_static_addr_next(&v, name, &entry) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) iscsid_add(ihp, iSCSIDiscoveryMethodStatic,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_discovery_event(ihp, iSCSIDiscoveryMethodStatic, B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_thread_sendtgts -- If SendTargets discovery is enabled, this routine
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obtains all target discovery addresses configured from the peristent store
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and probe the IP/port addresses for possible targets. It will then issue
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a login request to the driver for all discoveryed targets.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_thread_sendtgts(iscsi_thread_t *thread, void *p)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_discovery_event(ihp, iSCSIDiscoveryMethodSendTargets,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ---- ensure SendTargets discovery is enabled ---- */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dm & iSCSIDiscoveryMethodSendTargets) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "iscsi discovery failure - "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "SendTargets method is not enabled");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * walk list of the SendTarget discovery addresses from the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * persistent store
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (persistent_disc_addr_next(&v, &entry) == B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_discovery_event(ihp, iSCSIDiscoveryMethodSendTargets,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_thread_slp -- If SLP discovery is enabled, this routine provides
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the SLP discovery service.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_thread_slp(iscsi_thread_t *thread, void *p)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Even though we don't have support for SLP at this point
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we'll send the events if someone has enabled this thread.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this is not done the daemon waiting for discovery to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * complete will pause forever holding up the boot process.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_discovery_event(ihp, iSCSIDiscoveryMethodSLP, B_TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_discovery_event(ihp, iSCSIDiscoveryMethodSLP, B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_thread_isns --
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_thread_isns(iscsi_thread_t *thread, void *ptr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_discovery_event(ihp, iSCSIDiscoveryMethodISNS, B_TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ---- ensure iSNS discovery is enabled ---- */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "iscsi discovery failure - "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "iSNS method is not enabled");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_discovery_event(ihp, iSCSIDiscoveryMethodISNS, B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Thread stopped. Deregister from iSNS servers(s). */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_threads_create -- Creates all the discovery threads.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * start a thread for each discovery method
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (t = &iscsid_thr[0]; t->method != iSCSIDiscoveryMethodUnknown;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t->thr_id = iscsi_thread_create(ihp->hba_dip, t->name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_threads_destroy -- Destroys all the discovery threads.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (t = &iscsid_thr[0]; t->method != iSCSIDiscoveryMethodUnknown;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_copyto_param_set - helper function for iscsid_init_params.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_copyto_param_set(uint32_t param_id, iscsi_login_params_t *params,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Boolean parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipsp->s_value.v_bool = params->data_pdu_in_order;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipsp->s_value.v_bool = params->data_pdu_in_order;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Integer parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipsp->s_value.v_integer = params->default_time_to_retain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipsp->s_value.v_integer = params->default_time_to_wait;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISCSI_LOGIN_PARAM_MAX_RECV_DATA_SEGMENT_LENGTH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipsp->s_value.v_integer = params->max_recv_data_seg_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipsp->s_value.v_integer = params->first_burst_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipsp->s_value.v_integer = params->max_burst_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Integer parameters which currently are unsettable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ---- drop through to default case ---- */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if all is well, set the parameter identifier */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_add_pg_list_to_cache - Add portal groups in the list to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * discovery cache.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) iscsid_add(ihp, iSCSIDiscoveryMethodISNS, &addr_dsc.sin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set_initiator_name - set default initiator name and alias.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This sets the default initiator name and alias. The
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initiator name is composed of sun's reverse domain name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and registration followed and a unique classifier. This
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * classifier is the mac address of the first NIC in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * host and a timestamp to make sure the classifier is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * unique if the NIC is moved between hosts. The alias
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is just the hostname.
329c9e3ded64bba19a3bbac9ee1a0124f04dc044Jack Mengiscsid_set_default_initiator_node_settings(iscsi_hba_t *ihp, boolean_t minimal)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set default initiator-node name */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiboot_prop && iscsiboot_prop->boot_init.ini_name != NULL) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng for (i = 0; i < ETHERADDRL; i++) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* Set default initiator-node alias */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncat((char *)ihp->hba_name, val, ISCSI_MAX_NAME_LEN);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng ihp->hba_alias_length = strlen((char *)ihp->hba_alias);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) persistent_initiator_name_set((char *)ihp->hba_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set default initiator-node CHAP settings */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (persistent_initiator_name_get((char *)ihp->hba_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chap = (iscsi_chap_props_t *)kmem_zalloc(sizeof (*chap),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (persistent_chap_get((char *)ihp->hba_name, chap) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chap->c_user_len = strlen((char *)ihp->hba_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) persistent_chap_set((char *)ihp->hba_name, chap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove target-param <-> target mapping.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Only remove if there is not any overridden
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parameters in the persistent store
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pparam = (persistent_param_t *)kmem_zalloc(sizeof (*pparam), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * setup initial buffer for configured session
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ics = (iscsi_config_sess_t *)kmem_zalloc(sizeof (*ics), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((persistent_param_get(name, pparam) == B_FALSE) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (persistent_get_config_session(name, ics) == B_FALSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t_oid = iscsi_targetparam_get_oid((uchar_t *)name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsid_addr_to_sockaddr - convert other types to struct sockaddr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsid_addr_to_sockaddr(int src_insize, void *src_addr, int src_port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT((src_insize == sizeof (struct in_addr)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* translate discovery information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct in_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct in6_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_discovery_event -- send event associated with discovery operations
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Each discovery event has a start and end event. Which is sent is based
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on the boolean argument start with the obvious results.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_discovery_event(iscsi_hba_t *ihp, iSCSIDiscoveryMethod_t m,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (m) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ihp->hba_discovery_events |= iSCSIDiscoveryMethodStatic;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ihp->hba_discovery_events |= iSCSIDiscoveryMethodSLP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ihp->hba_discovery_events |= iSCSIDiscoveryMethodISNS;
c60a6da3c3825f88388f3fba451c3dd975088f07bing zhao - Sun Microsystems - Beijing China iscsi_send_sysevent(ihp, EC_ISCSI, subclass, NULL);
c60a6da3c3825f88388f3fba451c3dd975088f07bing zhao - Sun Microsystems - Beijing China * iscsi_send_sysevent -- send sysevent using specified class
c60a6da3c3825f88388f3fba451c3dd975088f07bing zhao - Sun Microsystems - Beijing Chinaiscsi_send_sysevent(
c60a6da3c3825f88388f3fba451c3dd975088f07bing zhao - Sun Microsystems - Beijing China iscsi_hba_t *ihp,
c60a6da3c3825f88388f3fba451c3dd975088f07bing zhao - Sun Microsystems - Beijing China char *eventclass,
c60a6da3c3825f88388f3fba451c3dd975088f07bing zhao - Sun Microsystems - Beijing China char *subclass,
c60a6da3c3825f88388f3fba451c3dd975088f07bing zhao - Sun Microsystems - Beijing China (void) ddi_log_sysevent(ihp->hba_dip, DDI_VENDOR_SUNW, eventclass,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (strlen((const char *)iscsiboot_prop->boot_init.ini_name) != 0) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng strlen((const char *)iscsiboot_prop->boot_init.ini_name));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* or using default login param for boot session */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* get information of number of sessions to be configured */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (persistent_get_config_session(name, ics) == B_FALSE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * No target information available to check
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * initiator information. Assume one session
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * by default.
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng name = (char *)iscsiboot_prop->boot_init.ini_name;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (persistent_get_config_session(name, ics) == B_FALSE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* get necessary information */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* get configured sessions information */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng "failed to setup multiple sessions",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* create a temporary session to keep boot session connective */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng t_isp = iscsi_add_boot_sess(ihp, ISCSI_MAX_CONFIG_SESSIONS);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* destroy all old boot sessions */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsi_chk_bootlun_mpxio(ihp) && isp->sess_boot) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (isp->sess_isid[5] != ISCSI_MAX_CONFIG_SESSIONS) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * destroy all stale sessions
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * except temporary boot session
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * couldn't destroy stale sessions
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * at least poke it to disconnect
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng "failed to setup multiple"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * fail to create any new boot session
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * so only the temporary session is alive
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * quit without destroying it
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* couldn't destroy temp boot session */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng addr_dst.sin.sa_family = iscsiboot_prop->boot_tgt.sin_family;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng bcopy(&iscsiboot_prop->boot_tgt.tgt_ip_u.u_in4.s_addr,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng &addr_dst.sin4.sin_addr.s_addr, sizeof (struct in_addr));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng bcopy(&iscsiboot_prop->boot_tgt.tgt_ip_u.u_in6.s6_addr,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng sizeof (struct in6_addr));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng iSCSIDiscoveryMethodBoot|iSCSIDiscoveryMethodStatic,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng ISCSI_DEFAULT_TPGT, isid, ISCSI_SESS_TYPE_NORMAL, &oid);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* create temp booting session failed */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (!ISCSI_SUCCESS(iscsi_conn_create((struct sockaddr *)&addr_dst,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* now online created session */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsid_login_tgt(ihp, (char *)iscsiboot_prop->boot_tgt.tgt_name,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng iSCSIDiscoveryMethodBoot|iSCSIDiscoveryMethodStatic,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Mengiscsid_thread_boot_wd(iscsi_thread_t *thread, void *p)
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng while (rc != 0) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiboot_prop && (strncmp((const char *)name,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiboot_prop && (strncmp((const char *)name,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng lun_num = *((uint64_t *)(iscsiboot_prop->boot_tgt.tgt_boot_lun));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * found boot session.
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * check its mdi path info is null or not
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * iscsiboot_prop not NULL while no boot lun found
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * in most cases this is none iscsi boot while iscsiboot_prop
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * is not NULL, in this scenario return iscsi HBA's mpxio config