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 boolean_t svr_registered; 40 uint32_t svr_esi_interval; 41 } iscsit_isns_svr_t; 42 43 /* 44 * Type of registration to perform (deregister, register, update) 45 */ 46 typedef enum { 47 ISNS_DEREGISTER_TARGET = 0, 48 ISNS_DEREGISTER_ALL, 49 ISNS_REGISTER_TARGET, 50 ISNS_REGISTER_ALL, 51 ISNS_UPDATE_TARGET 52 } isns_reg_type_t; 53 54 /* 55 * This structure is used to keep state with regard to the RX threads used 56 * for ESI. There must always be a 1:1 correspondence between the entries 57 * in this list and the entries in the portal_list. 58 */ 59 60 struct isns_portal_list_s; 61 62 typedef struct { 63 kthread_t *esi_thread; 64 kt_did_t esi_thread_did; 65 ksocket_t esi_so; 66 kmutex_t esi_mutex; 67 kcondvar_t esi_cv; 68 uint16_t esi_port; 69 boolean_t esi_enabled; 70 boolean_t esi_valid; 71 boolean_t esi_thread_running; 72 } isns_esi_tinfo_t; 73 74 75 /* 76 * Portal list - comprised of "default" portals (i.e. idm_get_ipaddr) and 77 * portals that are part of target portal groups. 78 */ 79 80 typedef struct isns_portal_list_s { 81 struct sockaddr_storage portal_addr; 82 iscsit_portal_t *portal_iscsit; 83 list_node_t portal_ln; 84 timespec_t portal_esi_timestamp; 85 } isns_portal_list_t; 86 87 typedef struct isns_target_s { 88 iscsit_tgt_t *target; 89 avl_node_t target_node; 90 boolean_t target_registered; 91 } isns_target_t; 92 93 /* 94 * If no ESI request is received within this number of intervals, we'll 95 * try to re-register with the server. 96 */ 97 #define MAX_ESI_INTERVALS 3 98 99 it_cfg_status_t 100 isnst_config_merge(it_config_t *cfg); 101 102 int iscsit_isns_init(iscsit_hostinfo_t *hostinfo); 103 void iscsit_isns_fini(); 104 int iscsit_isns_register(iscsit_tgt_t *target); 105 int iscsit_isns_deregister(iscsit_tgt_t *target); 106 void iscsit_isns_target_update(iscsit_tgt_t *target); 107 void iscsit_isns_portal_online(iscsit_portal_t *portal); 108 void iscsit_isns_portal_offline(iscsit_portal_t *portal); 109 110 #endif /* _ISNS_CLIENT_H_ */ 111