1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 #ifndef _ISNS_CLIENT_H_ 26 #define _ISNS_CLIENT_H_ 27 28 #include <iscsit.h> 29 30 /* 31 * List of iSNS servers with which we register. 32 */ 33 34 typedef struct { 35 int svr_retry_count; 36 struct sockaddr_storage svr_sa; 37 clock_t svr_last_msg; 38 list_node_t svr_ln; 39 uint32_t svr_registered:1, 40 svr_reset_needed:1, 41 svr_delete_needed:1, 42 svr_targets_changed:1, 43 svr_monitor_hold:1; 44 uint32_t svr_last_target_index; 45 uint32_t svr_esi_interval; 46 avl_tree_t svr_target_list; 47 } iscsit_isns_svr_t; 48 49 /* 50 * Type of registration to perform (deregister, register, update) 51 */ 52 typedef enum { 53 ISNS_DEREGISTER_TARGET = 0, 54 ISNS_DEREGISTER_ALL, 55 ISNS_REGISTER_TARGET, 56 ISNS_REGISTER_ALL, 57 ISNS_MODIFY_TARGET 58 } isns_reg_type_t; 59 60 /* 61 * This structure is used to keep state with regard to the RX threads used 62 * for ESI. 63 */ 64 65 66 typedef struct { 67 kthread_t *esi_thread; 68 kt_did_t esi_thread_did; 69 ksocket_t esi_so; 70 kmutex_t esi_mutex; 71 kcondvar_t esi_cv; 72 uint16_t esi_port; 73 boolean_t esi_enabled; 74 boolean_t esi_valid; 75 boolean_t esi_thread_running; 76 } isns_esi_tinfo_t; 77 78 79 /* 80 * Portal list - both default portals from idm_get_ipaddr and portals 81 * defined in target port groups. 82 */ 83 84 typedef struct isns_portal_s { 85 struct sockaddr_storage portal_addr; 86 avl_node_t portal_node; 87 timespec_t portal_esi_timestamp; 88 iscsit_portal_t *portal_iscsit; /* if in TPG */ 89 boolean_t portal_default; /* if in default */ 90 } isns_portal_t; 91 92 93 typedef struct isns_tpgt_addr_s { 94 list_node_t portal_ln; 95 struct sockaddr_storage portal_addr; 96 } isns_tpgt_addr_t; 97 98 typedef struct isns_tpgt_s { 99 list_node_t ti_tpgt_ln; 100 uint16_t ti_tpgt_tag; 101 list_t ti_portal_list; 102 } isns_tpgt_t; 103 104 typedef struct isns_target_info_s { 105 idm_refcnt_t ti_refcnt; 106 char ti_tgt_name[MAX_ISCSI_NODENAMELEN]; 107 char ti_tgt_alias[MAX_ISCSI_NODENAMELEN]; 108 list_t ti_tpgt_list; 109 } isns_target_info_t; 110 111 /* Contents of isns_target_list and svr->svr_target_list */ 112 typedef struct isns_target_s { 113 iscsit_tgt_t *target; 114 avl_node_t target_node; 115 boolean_t target_registered; 116 boolean_t target_update_needed; 117 boolean_t target_delete_needed; 118 isns_target_info_t *target_info; 119 } isns_target_t; 120 121 /* 122 * If no ESI request is received within this number of intervals, we'll 123 * try to re-register with the server. 124 */ 125 #define MAX_ESI_INTERVALS 3 126 127 /* 128 * Interval to ask the server to send us ESI probes, in seconds. 129 */ 130 #define ISNS_DEFAULT_ESI_INTERVAL 20 131 132 /* 133 * Registration Period (when not using ESI), in seconds. (15 min) 134 */ 135 #define ISNS_DEFAULT_REGISTRATION_PERIOD 900 136 137 /* 138 * Initial delay before sending first DevAttrReg message. 139 */ 140 #define ISNS_INITIAL_DELAY 5 141 142 it_cfg_status_t 143 isnst_config_merge(it_config_t *cfg); 144 145 int iscsit_isns_init(iscsit_hostinfo_t *hostinfo); 146 void iscsit_isns_fini(); 147 int iscsit_isns_register(iscsit_tgt_t *target); 148 int iscsit_isns_deregister(iscsit_tgt_t *target); 149 void iscsit_isns_target_update(iscsit_tgt_t *target); 150 void iscsit_isns_portal_online(iscsit_portal_t *portal); 151 void iscsit_isns_portal_offline(iscsit_portal_t *portal); 152 153 #endif /* _ISNS_CLIENT_H_ */ 154