Lines Matching defs:lsp
128 static int channel_openreset(struct ldmsvcs_info *lsp);
129 static int read_msg(struct ldmsvcs_info *lsp);
154 channel_close(struct ldmsvcs_info *lsp)
156 (void) pthread_mutex_lock(&lsp->mt);
158 if (lsp->fds_chan.state == CHANNEL_OPEN ||
159 lsp->fds_chan.state == CHANNEL_READY) {
160 (void) close(lsp->fds_chan.fd);
161 lsp->cv_twait = get_smf_int_val(LDM_INIT_TO_PROP_NM,
163 lsp->fds_chan.state = CHANNEL_CLOSED;
166 (void) pthread_mutex_unlock(&lsp->mt);
447 struct ldmsvcs_info *lsp;
453 lsp = (struct ldmsvcs_info *)arg;
479 if ((ier = channel_openreset(lsp)) == 1) {
492 recv_fd->fd = lsp->fds_chan.fd; /* FMA LDC */
501 channel_close(lsp);
504 channel_close(lsp);
506 } else if (read_msg(lsp) != 0) {
511 channel_close(lsp);
523 poller_init(struct ldmsvcs_info *lsp)
538 poller_loop, lsp) != 0)
581 fds_send(struct ldmsvcs_info *lsp, void *msg, size_t msglen)
587 if (write(lsp->fds_chan.fd, msg, msglen) != msglen) {
588 channel_close(lsp);
687 fds_svc_add(struct ldmsvcs_info *lsp, ds_reg_req_t *req, int minor)
693 for (i = 0; i < lsp->fmas_svcs.nsvcs; i++) {
694 if (strcmp(lsp->fmas_svcs.tbl[i]->name, req->svc_id) == 0) {
695 svc = lsp->fmas_svcs.tbl[i];
703 (void) pthread_mutex_lock(&lsp->fmas_svcs.mt);
718 (void) pthread_cond_broadcast(&lsp->fmas_svcs.cv);
721 (void) pthread_mutex_unlock(&lsp->fmas_svcs.mt);
728 fds_svc_reset(struct ldmsvcs_info *lsp, int index)
737 end = lsp->fmas_svcs.nsvcs;
740 (void) pthread_mutex_lock(&lsp->fmas_svcs.mt);
743 lsp->fmas_svcs.tbl[i]->hdl = 0;
744 lsp->fmas_svcs.tbl[i]->state = DS_SVC_INVAL;
745 lsp->fmas_svcs.tbl[i]->ver.major =
747 lsp->fmas_svcs.tbl[i]->ver.minor =
751 (void) pthread_mutex_unlock(&lsp->fmas_svcs.mt);
756 fds_svc_remove(struct ldmsvcs_info *lsp, ds_svc_hdl_t svc_handle)
760 for (i = 0; i < lsp->fmas_svcs.nsvcs; i++) {
761 if (lsp->fmas_svcs.tbl[i]->hdl == svc_handle) {
762 fds_svc_reset(lsp, i);
776 ds_handle_msg_noop(struct ldmsvcs_info *lsp, void *buf, size_t len)
781 ds_handle_init_req(struct ldmsvcs_info *lsp, void *buf, size_t len)
791 channel_close(lsp);
812 if (fds_send(lsp, H, msglen) != 0)
815 (void) pthread_mutex_lock(&lsp->mt);
816 ASSERT(lsp->fds_chan.state == CHANNEL_OPEN);
817 lsp->fds_chan.state = CHANNEL_READY;
824 lsp->cv_twait = get_smf_int_val(LDM_RUNNING_TO_PROP_NM,
827 (void) pthread_mutex_unlock(&lsp->mt);
840 (void) fds_send(lsp, H, msglen);
851 ds_handle_reg_req(struct ldmsvcs_info *lsp, void *buf, size_t len)
867 channel_close(lsp);
872 (dup_svcreg = fds_svc_add(lsp, req,
893 (void) fds_send(lsp, H, msglen);
913 (void) fds_send(lsp, H, msglen);
920 ds_handle_unreg(struct ldmsvcs_info *lsp, void *buf, size_t len)
927 if (fds_svc_remove(lsp, req->svc_handle) == 0) {
939 (void) fds_send(lsp, H, msglen);
952 (void) fds_send(lsp, H, msglen);
961 typedef void (*ds_msg_handler_t)(struct ldmsvcs_info *lsp,
983 fds_svc_alloc(struct ldmsvcs_info *lsp)
989 (void) pthread_mutex_init(&lsp->fmas_svcs.mt, NULL);
990 (void) pthread_cond_init(&lsp->fmas_svcs.cv, NULL);
992 for (lsp->fmas_svcs.nsvcs = 0; name[lsp->fmas_svcs.nsvcs] != NULL;
993 lsp->fmas_svcs.nsvcs++)
996 lsp->fmas_svcs.tbl = (fds_svc_t **)ldom_alloc(sizeof (fds_svc_t *) *
997 lsp->fmas_svcs.nsvcs);
999 for (i = 0; i < lsp->fmas_svcs.nsvcs; i++) {
1000 lsp->fmas_svcs.tbl[i] =
1002 bzero(lsp->fmas_svcs.tbl[i], sizeof (fds_svc_t));
1003 lsp->fmas_svcs.tbl[i]->name = name[i];
1009 fds_svc_lookup(struct ldmsvcs_info *lsp, char *name)
1015 if (pthread_mutex_lock(&lsp->fmas_svcs.mt) == EINVAL)
1019 for (i = 0; i < lsp->fmas_svcs.nsvcs; i++) {
1020 if (strcmp(lsp->fmas_svcs.tbl[i]->name, name) == 0) {
1021 svc = lsp->fmas_svcs.tbl[i];
1033 twait.tv_sec = time(NULL) + lsp->cv_twait;
1037 lsp->fds_chan.state != CHANNEL_UNUSABLE)
1038 ier = pthread_cond_timedwait(&lsp->fmas_svcs.cv,
1039 &lsp->fmas_svcs.mt, &twait);
1051 (void) pthread_mutex_unlock(&lsp->fmas_svcs.mt);
1073 read_msg(struct ldmsvcs_info *lsp)
1081 if (read_stream(lsp->fds_chan.fd, &header, sizeof (ds_hdr_t)) != 0)
1092 return (poller_handle_data(lsp->fds_chan.fd,
1104 if (read_stream(lsp->fds_chan.fd, msg_buf, header.payload_len) != 0)
1107 (*ds_msg_handlers[header.msg_type])(lsp, msg_buf, header.payload_len);
1120 channel_openreset(struct ldmsvcs_info *lsp)
1124 ier = pthread_mutex_lock(&lsp->mt);
1126 if (ier == EINVAL || lsp->fds_chan.state == CHANNEL_EXIT ||
1127 lsp->fds_chan.state == CHANNEL_UNUSABLE) {
1128 (void) pthread_mutex_unlock(&lsp->mt);
1132 if (lsp->fds_chan.state == CHANNEL_UNINITIALIZED ||
1133 lsp->fds_chan.state == CHANNEL_CLOSED) {
1134 (void) pthread_cond_broadcast(&lsp->cv);
1136 if ((lsp->fds_chan.fd = open(FDS_VLDC, O_RDWR)) < 0) {
1137 lsp->fds_chan.state = CHANNEL_UNUSABLE;
1138 lsp->cv_twait = get_smf_int_val(LDM_RUNNING_TO_PROP_NM,
1140 (void) pthread_mutex_unlock(&lsp->mt);
1141 (void) pthread_cond_broadcast(&lsp->fmas_svcs.cv);
1151 if (ioctl(lsp->fds_chan.fd, VLDC_IOCTL_OPT_OP,
1153 (void) close(lsp->fds_chan.fd);
1154 (void) pthread_mutex_unlock(&lsp->mt);
1158 lsp->fds_chan.state = CHANNEL_OPEN;
1161 if (lsp->fds_chan.state == CHANNEL_OPEN) {
1165 lsp->fds_chan.ver.major = 0;
1166 lsp->fds_chan.ver.minor = 0;
1167 fds_svc_reset(lsp, -1);
1169 (void) pthread_mutex_unlock(&lsp->mt);
1179 struct ldmsvcs_info *lsp;
1186 if ((lsp = channel_init(NULL)) == NULL)
1189 (void) pthread_mutex_lock(&lsp->mt);
1191 lsp->fds_chan.state = CHANNEL_EXIT;
1192 (void) close(lsp->fds_chan.fd);
1194 (void) pthread_mutex_unlock(&lsp->mt);
1197 for (i = 0; i < lsp->fmas_svcs.nsvcs; i++) {
1198 ldom_free(lsp->fmas_svcs.tbl[i], sizeof (fds_svc_t));
1200 ldom_free(lsp->fmas_svcs.tbl,
1201 lsp->fmas_svcs.nsvcs * sizeof (fds_svc_t *));
1202 ldom_free(lsp, sizeof (struct ldmsvcs_info));
1288 struct ldmsvcs_info *lsp;
1292 lsp = lhp->lsinfo;
1301 if ((svc = fds_svc_lookup(lsp, svcname)) == NULL) {
1302 (void) pthread_mutex_lock(&lsp->mt);
1304 if (lsp->fds_chan.state != CHANNEL_READY)
1309 (void) pthread_mutex_unlock(&lsp->mt);
1319 if ((ier = fds_send(lsp, msg, msglen)) != 0 ||