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 /* 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma D depends_on library net.d 28 #pragma D depends_on library scsi.d 29 #pragma D depends_on module genunix 30 31 /* 32 * FC port information. 33 */ 34 typedef struct fc_port_info { 35 string fcp_node_wwn; /* node WWN */ 36 string fcp_sym_node_name; /* node symbolic name */ 37 string fcp_sym_port_name; /* port symbolic name */ 38 uint32_t fcp_port_hard_address; /* port hard address */ 39 } fc_port_info_t; 40 41 /* 42 * FC transfer info (somewhat analogous to iscsiinfo_t) 43 * Represents data transfer details. 44 */ 45 typedef struct fc_xferinfo { 46 uint32_t fcx_len; 47 uint32_t fcx_offset; 48 uint16_t fcx_flags; /* db_flags as defined in sys/stmf.h */ 49 } fc_xferinfo_t; 50 51 /* 52 * conninfo translators 53 */ 54 55 /* 56 * Translator for conninfo, translating from the local port. 57 */ 58 #pragma D binding "1.5" translator 59 translator conninfo_t < fct_local_port_t *P > { 60 ci_local = P->port_pwwn_str[0] ? 61 P->port_pwwn_str : "<unknown>"; 62 ci_remote = "<unknown>"; 63 ci_protocol = "fc"; 64 }; 65 66 /* 67 * Translator for conninfo, translating from the local port implementation. 68 */ 69 #pragma D binding "1.5" translator 70 translator conninfo_t < fct_i_local_port_t *P > { 71 ci_local = P->iport_port->port_pwwn_str[0] ? 72 P->iport_port->port_pwwn_str : "<unknown>"; 73 ci_remote = "<unknown>"; 74 ci_protocol = "fc"; 75 }; 76 77 /* 78 * Translator for conninfo, translating from fct cmd struct. 79 */ 80 #pragma D binding "1.5" translator 81 translator conninfo_t < fct_cmd_t *C > { 82 ci_local = (C->cmd_port ? 83 (C->cmd_port->port_pwwn_str[0] ? 84 C->cmd_port->port_pwwn_str : "<unknown>") : 85 "<unknown>"); 86 87 ci_remote = (C->cmd_rp ? 88 (C->cmd_rp->rp_pwwn_str[0] ? 89 C->cmd_rp->rp_pwwn_str : "<unknown>") : 90 "<unknown>"); 91 92 ci_protocol = "fc"; 93 }; 94 95 96 /* 97 * fc_port_info_t translators. 98 */ 99 100 /* 101 * Translator for fc_port_info_t, translating from the local port. 102 */ 103 #pragma D binding "1.5" translator 104 translator fc_port_info_t < fct_local_port_t *P > { 105 /* node WWN */ 106 fcp_node_wwn = P->port_nwwn_str[0] ? 107 P->port_nwwn_str : "<unknown>"; 108 109 /* node symbolic name */ 110 fcp_sym_node_name = P->port_sym_node_name ? 111 P->port_sym_node_name : `utsname.nodename; 112 113 /* port symbolic name */ 114 fcp_sym_port_name = P->port_sym_port_name ? 115 P->port_sym_port_name : "<unknown>"; 116 117 /* port hard address */ 118 fcp_port_hard_address = P->port_hard_address; 119 }; 120 121 122 /* 123 * Translator for fc_port_info_t, translating from the local port impl. 124 */ 125 #pragma D binding "1.5" translator 126 translator fc_port_info_t < fct_i_local_port_t *P > { 127 /* node WWN */ 128 129 fcp_node_wwn = (P->iport_port ? 130 (P->iport_port->port_nwwn_str[0] ? 131 P->iport_port->port_nwwn_str : 132 "<unknown>") : 133 "<bad iport_port ptr>"); 134 135 fcp_sym_node_name = 136 (P->iport_port ? 137 (P->iport_port->port_sym_node_name ? 138 P->iport_port->port_sym_node_name : "<unknown>") : 139 "<bad iport_port ptr>"); 140 141 fcp_sym_port_name = 142 (P->iport_port ? 143 (P->iport_port->port_sym_port_name ? 144 P->iport_port->port_sym_port_name : "<unknown>") : 145 "<bad iport_port ptr>"); 146 147 fcp_port_hard_address = 148 (P->iport_port ? 149 P->iport_port->port_hard_address : 0); 150 }; 151 152 /* 153 * Translator for fc_port_info, translating from the remote port impl 154 */ 155 #pragma D binding "1.5" translator 156 translator fc_port_info_t < fct_i_remote_port_t *P > { 157 158 /* node WWN */ 159 fcp_node_wwn = P->irp_rp ? 160 (P->irp_rp->rp_nwwn_str[0] ? 161 P->irp_rp->rp_nwwn_str : "<unknown>") : 162 "<unknown>"; 163 164 /* node symbolic name */ 165 fcp_sym_node_name = P->irp_snn ? P->irp_snn : "<unknown>"; 166 167 /* port symbolic name */ 168 fcp_sym_port_name = P->irp_spn ? P->irp_spn : "<unknown>"; 169 170 /* port hard address */ 171 fcp_port_hard_address = P->irp_rp ? P->irp_rp->rp_id : 0; 172 }; 173 174 /* 175 * Translator for fc_xferinfo, translating from stmf_data_buf_t. 176 */ 177 #pragma D binding "1.5" translator 178 translator fc_xferinfo_t < stmf_data_buf_t *B > { 179 fcx_len = B->db_data_size; 180 fcx_offset = B->db_relative_offset; 181 fcx_flags = B->db_flags; 182 }; 183