31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * CDDL HEADER START
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * The contents of this file are subject to the terms of the
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * Common Development and Distribution License (the "License").
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * You may not use this file except in compliance with the License.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * See the License for the specific language governing permissions
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * and limitations under the License.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * When distributing Covered Code, include this CDDL HEADER in each
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * If applicable, add the following below this CDDL HEADER, with the
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * fields enclosed by brackets "[]" replaced with your own identifying
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * information: Portions Copyright [yyyy] [name of copyright owner]
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * CDDL HEADER END
f044df33d9fe9e8e3ed7344a8b548b17f20709f2Vuong Nguyen * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn "assertion failure in %s:%d: %s\n", \
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn "/devices/virtual-devices@100/channel-devices@200/" \
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn "/virtual-channel-client@1:ldmfma"
c3b50bc594edb4e967f0156a09c6e64b845dd8earb/* allow timeouts in sec that are nearly forever but small enough for an int */
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * functions in this file are for version 1.0 of FMA domain services
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * information for each channel
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * struct listdata_s and struct poller_s are used to maintain the state of
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * the poller thread. this thread is used to manage incoming messages and
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * pass those messages onto the correct requesting thread. see the "poller
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * functions" section for more details.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic struct ldmsvcs_info *channel_init(struct ldom_hdl *lhp);
c3b50bc594edb4e967f0156a09c6e64b845dd8earbget_smf_int_val(char *prop_nm, int min, int max, int default_val)
c3b50bc594edb4e967f0156a09c6e64b845dd8earb if ((prop = scf_simple_prop_get(NULL, LDM_SVC_NM, LDM_PROP_GROUP_NM,
c3b50bc594edb4e967f0156a09c6e64b845dd8earb if ((valp = scf_simple_prop_next_integer(prop)) != NULL) {
c3b50bc594edb4e967f0156a09c6e64b845dd8earb return ((int)val);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * read size bytes of data from a streaming fd into buf
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * data may come in bits and pieces
f044df33d9fe9e8e3ed7344a8b548b17f20709f2Vuong Nguyen if (errno == EAGAIN && poll(&pollfd, 1, 3000) > 0)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn continue; /* retry */
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (1);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn } while (data_left > 0);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (0);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * poller functions
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * at init time, a thread is created for the purpose of monitoring incoming
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * messages and doing one of the following:
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * 1. doing the initial handshake and version negotiation
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * 2. handing incoming data off to the requesting thread (which is an fmd
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * module or scheme thread)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (1);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (1);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn req_num = (uint64_t *)((ptrdiff_t)pr + sizeof (ds_data_handle_t));
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * now wait for receiving thread to read in the data
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (0);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * note that this function is meant to handle only DS_DATA messages
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnpoller_recv_data(struct ldom_hdl *lhp, uint64_t req_num, int index,
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn if (ier == 0) {
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * need to add req_num to beginning of resp
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * get to this point if list is not long enough.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * check for a runaway list. since requests are
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * synchronous (clients send a request and need to
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * wait for the result before returning) the size
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * of the list cannot be much more than the number
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * of clients.
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen sizeof (struct listdata_s *));
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen sizeof (struct listdata_s *));
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn if (--(pollbase.pending_count) == 0 && pollbase.doreset == 1)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
f044df33d9fe9e8e3ed7344a8b548b17f20709f2Vuong Nguyen * Write a byte to the pipe to notify the poller thread to exit.
f044df33d9fe9e8e3ed7344a8b548b17f20709f2Vuong Nguyen * Then wait for it to exit.
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen (void) pthread_join(pollbase.polling_tid, NULL);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * perform the polling of incoming messages. manage any resets (usually
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * due to one end of the connection being closed) as well as exit
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * conditions.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void *
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn for (;;) {
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * start exit preparations
f044df33d9fe9e8e3ed7344a8b548b17f20709f2Vuong Nguyen pipe_fd->fd = pollbase.notify_pipe[1]; /* notification pipe */
f044df33d9fe9e8e3ed7344a8b548b17f20709f2Vuong Nguyen /* fd got closed */
f044df33d9fe9e8e3ed7344a8b548b17f20709f2Vuong Nguyen /* Receive a notification to exit */
f044df33d9fe9e8e3ed7344a8b548b17f20709f2Vuong Nguyen /* fail to read a message from the LDOM manager */
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * create the polling thread
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen * create a joinable polling thread for receiving messages
f044df33d9fe9e8e3ed7344a8b548b17f20709f2Vuong Nguyen * The notify pipe is for stopping the thread
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen if (pthread_create(&pollbase.polling_tid, attr,
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (rc);
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen * Cleanup the polling thread
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen /* stop the poller thread */
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen /* Free up the list of outstanding requests */
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen sizeof (struct listdata_s));
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen sizeof (struct listdata_s *));
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * utilities for message handlers
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnfds_send(struct ldmsvcs_info *lsp, void *msg, size_t msglen)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (0);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * Find the max and min version supported
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnfds_min_max_versions(uint16_t *min_major, uint16_t *max_major)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * check whether the major and minor numbers requested by remote ds client
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * can be satisfied. if the requested major is supported, true is
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * returned, and the agreed minor is returned in new_minor. if the
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * requested major is not supported, the routine returns false, and the
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * closest major is returned in *new_major, upon which the ds client should
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * renegotiate. the closest major is the just lower that the requested
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * major number.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnfds_negotiate_version(uint16_t req_major, uint16_t *new_majorp,
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn int i = 0;
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * if the minimum version supported is greater than the version
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * requested, return the lowest version supported
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * if the largest version supported is lower than the version
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * requested, return the largest version supported
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * now we know that the requested version lies between the min and
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * max versions supported. check if the requested major can be
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * found in supported versions.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn for (i = 0; i < DS_NUM_VER; i++) {
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * If no match is found, return the closest available number
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * return 0 if service is added; 1 if service is a duplicate
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnfds_svc_add(struct ldmsvcs_info *lsp, ds_reg_req_t *req, int minor)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn if (strcmp(lsp->fmas_svcs.tbl[i]->name, req->svc_id) == 0) {
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (0); /* we don't need this service */
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * duplicate registration is OK --- we retain the previous entry
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * (which has not been unregistered anyway)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (rc);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn if (index >= 0) {
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnfds_svc_remove(struct ldmsvcs_info *lsp, ds_svc_hdl_t svc_handle)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (0);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (1);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * message handlers
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn/*ARGSUSED*/
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnds_handle_msg_noop(struct ldmsvcs_info *lsp, void *buf, size_t len)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnds_handle_init_req(struct ldmsvcs_info *lsp, void *buf, size_t len)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn /* sanity check the incoming message */
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * Check version info. ACK only if the major numbers exactly
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * match. The service entity can retry with a new minor
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * based on the response sent as part of the NACK.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn if (fds_negotiate_version(req->major_vers, &new_major, &new_minor)) {
a298b85fd4d5149fdcc1bae48f9baab83a0390c9vn * Now the channel is ready after the handshake completes.
a298b85fd4d5149fdcc1bae48f9baab83a0390c9vn * Reset the timeout to a smaller value for receiving messages
a298b85fd4d5149fdcc1bae48f9baab83a0390c9vn * from the domain services.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * do not update state; remote end may attempt to initiate
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * connection with a different version
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn/*ARGSUSED*/
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnds_handle_reg_req(struct ldmsvcs_info *lsp, void *buf, size_t len)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * Service must be NULL terminated
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn if (fds_negotiate_version(req->major_vers, &new_major, &new_minor) &&
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * Check version info. ACK only if the major numbers
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * exactly match. The service entity can retry with a new
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * minor based on the response sent as part of the NACK.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn/*ARGSUSED*/
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnds_handle_unreg(struct ldmsvcs_info *lsp, void *buf, size_t len)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * Message handler lookup table (v1.0 only for now) Future
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * versions can add their own lookup table.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avntypedef void (*ds_msg_handler_t)(struct ldmsvcs_info *lsp,
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * message and service internal functions
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen static char *name[] = { LDM_DS_NAME_CPU, LDM_DS_NAME_MEM,
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn for (lsp->fmas_svcs.nsvcs = 0; name[lsp->fmas_svcs.nsvcs] != NULL;
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen lsp->fmas_svcs.tbl = (fds_svc_t **)ldom_alloc(sizeof (fds_svc_t *) *
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen /* service is not registered */
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen while (svc->state != DS_SVC_ACTIVE && ier == 0 &&
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen ier = pthread_cond_timedwait(&lsp->fmas_svcs.cv,
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen * By now, the ds service should have registered already.
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen * If it does not, ldmd probably does not support this service.
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen * Then mark the service state as inactive.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (req_num++);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * return 0 if successful, 1 if otherwise
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * read the header
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn if (read_stream(lsp->fds_chan.fd, &header, sizeof (ds_hdr_t)) != 0)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (1);
c3b50bc594edb4e967f0156a09c6e64b845dd8earb return (1);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * handle data as a special case
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * all other types of messages should be small
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * read the payload
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn if (read_stream(lsp->fds_chan.fd, msg_buf, header.payload_len) != 0)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (1);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn (*ds_msg_handlers[header.msg_type])(lsp, msg_buf, header.payload_len);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (0);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * return values:
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * 0 - success
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * 1 - problem with opening the channel
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * 2 - channed not opened; request to exit has been detected
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn if (ier == EINVAL || lsp->fds_chan.state == CHANNEL_EXIT ||
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (2);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (2);
c3b50bc594edb4e967f0156a09c6e64b845dd8earb &op) != 0) {
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (1);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * reset various channel parameters
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (0);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic void
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * End the poller thread
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen /* Free the ldom service structure */
3dc13b01e6ccde35cc4e663e261cdcbed0070e48Vuong Nguyen ldom_free(lsp->fmas_svcs.tbl[i], sizeof (fds_svc_t));
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnstatic struct ldmsvcs_info *
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * get to this point if we need to open the channel
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * wait for channel to become uninitialized. this should be quick.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn while (root->fds_chan.state == CHANNEL_UNINITIALIZED && expired == 0)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn expired = pthread_cond_timedwait(&root->cv, &root->mt, &twait);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn void *msg, size_t msglen, ds_svc_hdl_t *svc_hdl, char *svcname,
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * if any of the calls in this loop fail, retry some number
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * of times before giving up.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * msg_type - requested operation: FMA_CPU_REQ_STATUS or FMA_CPU_REQ_OFFLINE
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * cpuid - physical cpu id
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * normal return values:
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * P_OFFLINE - cpu is offline
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * P_ONLINE - cpu is online
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * abnormal return values:
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * ETIMEDOUT - LDOM manager is not responding
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * ENOTSUP - LDOM service for cpu offlining/status is not available
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * ENOMSG - got an unexpected response from the LDOM cpu service
31e37bb439502e3f7c4c0a9a77d655ea5d56887avncpu_request(struct ldom_hdl *lhp, uint32_t msg_type, uint32_t cpuid)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn reqmsglen = sizeof (ds_hdr_t) + sizeof (ds_data_handle_t) +
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (rc);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (rc);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * msg_type - requested operation: FMA_MEM_REQ_STATUS or FMA_MEM_REQ_RETIRE
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * pa - starting address of memory page
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * pgsize - memory page size in bytes
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * normal return values for msg_type == FMA_MEM_REQ_STATUS:
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * 0 - page is retired
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * EAGAIN - page is scheduled for retirement
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * EIO - page not scheduled for retirement
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * EINVAL - error
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * normal return values for msg_type == FMA_MEM_REQ_RETIRE:
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * 0 - success in retiring page
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * EIO - page is already retired
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * EAGAIN - page is scheduled for retirement
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * EINVAL - error
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * abnormal return values (regardless of msg_type)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * ETIMEDOUT - LDOM manager is not responding
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * ENOTSUP - LDOM service for cpu offlining/status is not available
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * ENOMSG - got an unexpected response from the LDOM cpu service
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnmem_request(struct ldom_hdl *lhp, uint32_t msg_type, uint64_t pa,
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn reqmsglen = sizeof (ds_hdr_t) + sizeof (ds_data_handle_t) +
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (rc);
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye } else if (msg_type == FMA_MEM_REQ_RESURRECT) {
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye if (respmsg->status == FMA_MEM_STAT_NOTRETIRED)
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye } if (respmsg->result == FMA_MEM_RESP_FAILURE) {
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye else if (respmsg->status == FMA_MEM_STAT_NOTRETIRED)
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye else if (respmsg->status == FMA_MEM_STAT_ILLEGAL)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (rc);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (0); /* vldc exists */
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn/*ARGSUSED*/
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn/*ARGSUSED*/
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn/*ARGSUSED*/
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (-1);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn reqmsglen = sizeof (ds_hdr_t) + sizeof (ds_data_handle_t) +
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (-1);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * resp should contain the req_num immediately followed by the PRI
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * (the latter may or may not be present). unfortunately, the
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * current compiler flags cause a warning for the following
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * definition
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * typedef struct {
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * uint64_t req_num;
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * uint8_t pri[];
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * } fma_pri_resp_t;
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * so we do not use the struct here.
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (0);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (-1);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn bcopy((void *)((ptrdiff_t)resp + sizeof (uint64_t)), *buf, buflen);
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * see cpu_request() for a description of return values
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnldmsvcs_cpu_req_status(struct ldom_hdl *lhp, uint32_t cpuid)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avnldmsvcs_cpu_req_offline(struct ldom_hdl *lhp, uint32_t cpuid)
5f149bca52352f45598e5563debe72ce04bd7a21cyldmsvcs_cpu_req_online(struct ldom_hdl *lhp, uint32_t cpuid)
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn * see mem_request() for a description of return values
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (mem_request(lhp, FMA_MEM_REQ_STATUS, pa, getpagesize()));
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn return (mem_request(lhp, FMA_MEM_REQ_RETIRE, pa, getpagesize()));
5f149bca52352f45598e5563debe72ce04bd7a21cyldmsvcs_mem_req_unretire(struct ldom_hdl *lhp, uint64_t pa)
5f149bca52352f45598e5563debe72ce04bd7a21cy return (mem_request(lhp, FMA_MEM_REQ_RESURRECT, pa, getpagesize()));
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyenldmsvcs_io_req_id(struct ldom_hdl *lhp, uint64_t addr, uint_t type,
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen uint64_t *virt_addr, char *name, int name_len, uint64_t *did)
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen return (-1);
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen reqmsglen = sizeof (ds_hdr_t) + sizeof (ds_data_handle_t) +
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen D = (void *)((ptrdiff_t)H + sizeof (ds_hdr_t));
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen R = (void *)((ptrdiff_t)D + sizeof (ds_data_handle_t));
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen H->payload_len = sizeof (ds_data_handle_t) + sizeof (fma_io_req_t);
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen if ((rc = sendrecv(lhp, R->req_num, H, reqmsglen,
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen &D->svc_handle, svcname, &resp, &resplen)) != 0) {
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen * resp should contain the req_num, status, virtual addr, domain id
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen * and the domain name. The domain name may or may not be present.
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen return (-1);
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen /* success */
25351652d920ae27c5a56c199da581033ce763f6Vuong Nguyen (void) strncpy(name, (char *)((ptrdiff_t)resp + offset),
31e37bb439502e3f7c4c0a9a77d655ea5d56887avn/* end file */