338 }
339
340 err = nvlist_size(nvl, &size, NV_ENCODE_XDR);
341 if (err) {
342 status = STMF_IC_MSG_INTERNAL_ERROR;
343 goto done;
344 }
345
346 buf = kmem_alloc(size, KM_SLEEP);
347 err = nvlist_pack(nvl, &buf, &size, NV_ENCODE_XDR, 0);
348 if (err) {
349 status = STMF_IC_MSG_INTERNAL_ERROR;
350 goto done;
351 }
352
353 /* push the bits out on the wire */
354
355 status = stmf_ic_transmit(buf, size);
356
357 done:
358 if (nvl)
359 nvlist_free(nvl);
360
361 if (buf)
362 kmem_free(buf, size);
363
364 stmf_ic_msg_free(msg);
365
366
367 return (status);
368 }
369
370 /*
371 * Pass the command to the daemon for transmission to the other node.
372 */
373 stmf_ic_msg_status_t
374 stmf_ic_transmit(char *buf, size_t size)
375 {
376 int i;
377 int rc;
378 door_arg_t arg;
954 case STMF_ICM_SESSION_DESTROY:
955 stmf_ic_session_create_destroy_msg_free(
956 (stmf_ic_session_create_destroy_msg_t *)msg->icm_msg,
957 cmethod);
958 break;
959
960 case STMF_ICM_ECHO_REQUEST:
961 case STMF_ICM_ECHO_REPLY:
962 stmf_ic_echo_request_reply_msg_free(
963 (stmf_ic_echo_request_reply_msg_t *)msg->icm_msg, cmethod);
964 break;
965
966 case STMF_ICM_MAX_MSG_TYPE:
967 ASSERT(0);
968 break;
969
970 default:
971 ASSERT(0);
972 }
973
974 if (msg->icm_nvlist)
975 nvlist_free(msg->icm_nvlist);
976
977 kmem_free(msg, sizeof (*msg));
978 }
979
980 /*ARGSUSED*/
981 static void
982 stmf_ic_reg_port_msg_free(stmf_ic_reg_port_msg_t *m,
983 stmf_ic_msg_construction_method_t cmethod)
984 {
985 scsi_devid_desc_free(m->icrp_port_id);
986
987 kmem_free(m, sizeof (*m));
988 }
989
990
991 /*ARGSUSED*/
992 static void
993 stmf_ic_dereg_port_msg_free(stmf_ic_dereg_port_msg_t *m,
994 stmf_ic_msg_construction_method_t cmethod)
1159 break;
1160
1161 case STMF_ICM_ECHO_REQUEST:
1162 case STMF_ICM_ECHO_REPLY:
1163 rc = stmf_ic_echo_request_reply_msg_marshal(nvl,
1164 msg->icm_msg);
1165 break;
1166
1167 case STMF_ICM_MAX_MSG_TYPE:
1168 ASSERT(0);
1169 break;
1170
1171 default:
1172 ASSERT(0);
1173 }
1174
1175 done:
1176 if (!rc)
1177 return (nvl);
1178
1179 if (nvl)
1180 nvlist_free(nvl);
1181
1182 return (NULL);
1183 }
1184
1185
1186 static int
1187 stmf_ic_reg_port_msg_marshal(nvlist_t *nvl, void *msg)
1188 {
1189 stmf_ic_reg_port_msg_t *m = (stmf_ic_reg_port_msg_t *)msg;
1190 int rc = 0;
1191
1192 NVLIST_ADD_DEVID(m, icrp_port_id);
1193 NVLIST_ADD_FIELD(uint16, m, icrp_relative_port_id);
1194
1195 NVLIST_ADD_FIELD(uint16, m, icrp_cb_arg_len);
1196 /* only add the callback arg if necessary */
1197 if (m->icrp_cb_arg_len) {
1198 NVLIST_ADD_ARRAY_LEN(uint8, m, icrp_cb_arg, m->icrp_cb_arg_len);
1199 }
|
338 }
339
340 err = nvlist_size(nvl, &size, NV_ENCODE_XDR);
341 if (err) {
342 status = STMF_IC_MSG_INTERNAL_ERROR;
343 goto done;
344 }
345
346 buf = kmem_alloc(size, KM_SLEEP);
347 err = nvlist_pack(nvl, &buf, &size, NV_ENCODE_XDR, 0);
348 if (err) {
349 status = STMF_IC_MSG_INTERNAL_ERROR;
350 goto done;
351 }
352
353 /* push the bits out on the wire */
354
355 status = stmf_ic_transmit(buf, size);
356
357 done:
358 nvlist_free(nvl);
359
360 if (buf)
361 kmem_free(buf, size);
362
363 stmf_ic_msg_free(msg);
364
365
366 return (status);
367 }
368
369 /*
370 * Pass the command to the daemon for transmission to the other node.
371 */
372 stmf_ic_msg_status_t
373 stmf_ic_transmit(char *buf, size_t size)
374 {
375 int i;
376 int rc;
377 door_arg_t arg;
953 case STMF_ICM_SESSION_DESTROY:
954 stmf_ic_session_create_destroy_msg_free(
955 (stmf_ic_session_create_destroy_msg_t *)msg->icm_msg,
956 cmethod);
957 break;
958
959 case STMF_ICM_ECHO_REQUEST:
960 case STMF_ICM_ECHO_REPLY:
961 stmf_ic_echo_request_reply_msg_free(
962 (stmf_ic_echo_request_reply_msg_t *)msg->icm_msg, cmethod);
963 break;
964
965 case STMF_ICM_MAX_MSG_TYPE:
966 ASSERT(0);
967 break;
968
969 default:
970 ASSERT(0);
971 }
972
973 nvlist_free(msg->icm_nvlist);
974
975 kmem_free(msg, sizeof (*msg));
976 }
977
978 /*ARGSUSED*/
979 static void
980 stmf_ic_reg_port_msg_free(stmf_ic_reg_port_msg_t *m,
981 stmf_ic_msg_construction_method_t cmethod)
982 {
983 scsi_devid_desc_free(m->icrp_port_id);
984
985 kmem_free(m, sizeof (*m));
986 }
987
988
989 /*ARGSUSED*/
990 static void
991 stmf_ic_dereg_port_msg_free(stmf_ic_dereg_port_msg_t *m,
992 stmf_ic_msg_construction_method_t cmethod)
1157 break;
1158
1159 case STMF_ICM_ECHO_REQUEST:
1160 case STMF_ICM_ECHO_REPLY:
1161 rc = stmf_ic_echo_request_reply_msg_marshal(nvl,
1162 msg->icm_msg);
1163 break;
1164
1165 case STMF_ICM_MAX_MSG_TYPE:
1166 ASSERT(0);
1167 break;
1168
1169 default:
1170 ASSERT(0);
1171 }
1172
1173 done:
1174 if (!rc)
1175 return (nvl);
1176
1177 nvlist_free(nvl);
1178
1179 return (NULL);
1180 }
1181
1182
1183 static int
1184 stmf_ic_reg_port_msg_marshal(nvlist_t *nvl, void *msg)
1185 {
1186 stmf_ic_reg_port_msg_t *m = (stmf_ic_reg_port_msg_t *)msg;
1187 int rc = 0;
1188
1189 NVLIST_ADD_DEVID(m, icrp_port_id);
1190 NVLIST_ADD_FIELD(uint16, m, icrp_relative_port_id);
1191
1192 NVLIST_ADD_FIELD(uint16, m, icrp_cb_arg_len);
1193 /* only add the callback arg if necessary */
1194 if (m->icrp_cb_arg_len) {
1195 NVLIST_ADD_ARRAY_LEN(uint8, m, icrp_cb_arg, m->icrp_cb_arg_len);
1196 }
|