fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * You can obtain a copy of the license at
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * http://www.opensource.org/licenses/cddl1.txt.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Copyright (c) 2004-2012 Emulex. All rights reserved.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#define DEF_MSG_STRUCT /* Needed for emlxs_messages.h in emlxs_msg.h */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#include <emlxs.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanuint32_t emlxs_log_size = 2048;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanuint32_t emlxs_log_debugs = 0x7FFFFFFF;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanuint32_t emlxs_log_notices = 0xFFFFFFFF;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanuint32_t emlxs_log_warnings = 0xFFFFFFFF;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanuint32_t emlxs_log_errors = 0xFFFFFFFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic uint32_t emlxs_msg_log_check(emlxs_port_t *port, emlxs_msg_t *msg);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic uint32_t emlxs_msg_print_check(emlxs_port_t *port, emlxs_msg_t *msg);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_msg_sprintf(char *buffer, emlxs_msg_entry_t *entry);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_msg_log_create(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_msg_log_t *log = &LOG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t size = sizeof (emlxs_msg_entry_t) * emlxs_log_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_iblock_cookie_t iblock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if log is already created */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (log->entry) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN, "?%s%d: message log already created. log=%p",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan DRIVER_NAME, hba->ddiinst, (void *)log);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear the log */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(log, sizeof (emlxs_msg_log_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate the memory needed for the log file */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan log->entry = (emlxs_msg_entry_t *)kmem_zalloc(size, KM_SLEEP);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log->size = emlxs_log_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log->instance = hba->ddiinst;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log->start_time = emlxs_device.log_timestamp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(hba->intr_flags & EMLXS_MSI_ENABLED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the current interrupt block cookie */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_get_iblock_cookie(hba->dip, (uint_t)EMLXS_INUMBER,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &iblock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create the log mutex lock */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld mutex_init(&log->lock, NULL, MUTEX_DRIVER, (void *)iblock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef MSI_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore /* Create the temporary log mutex lock */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld mutex_init(&log->lock, NULL, MUTEX_DRIVER, NULL);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore#endif
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore} /* emlxs_msg_log_create() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amorevoid
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amoreemlxs_msg_lock_reinit(emlxs_hba_t *hba)
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore{
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_msg_log_t *log = &LOG;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore /* Check if log is already destroyed */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (!log->entry) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore cmn_err(CE_WARN,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore "?%s%d: message log already destroyed. log=%p",
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore DRIVER_NAME, hba->ddiinst, (void *)log);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore /* Destroy the temporary lock */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore mutex_destroy(&log->lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore /* Re-create the log mutex lock */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld mutex_init(&log->lock, NULL, MUTEX_DRIVER, DDI_INTR_PRI(hba->intr_arg));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore} /* emlxs_msg_lock_reinit() */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amorevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_msg_log_destroy(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_msg_log_t *log = &LOG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if log is already destroyed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!log->entry) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan cmn_err(CE_WARN,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "?%s%d: message log already destroyed. log=%p",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan DRIVER_NAME, hba->ddiinst, (void *)log);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Destroy the lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_destroy(&log->lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the log buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = sizeof (emlxs_msg_entry_t) * log->size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(log->entry, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear the log */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(log, sizeof (emlxs_msg_log_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_msg_log_destroy() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_msg_log(emlxs_port_t *port, const uint32_t fileno, const uint32_t line,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_msg_t *msg, char *buffer)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_msg_entry_t *entry;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_msg_entry_t *entry2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t time;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_msg_log_t *log;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t last;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_msg_t *msg2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the log file for this instance */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log = &LOG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if log is initialized */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (log->entry == NULL) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&log->lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the pointer to the last log entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (log->next == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte last = log->size - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte last = log->next - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry = &log->entry[last];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if this matches the last message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((entry->instance == log->instance) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (entry->vpi == port->vpi) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (entry->fileno == fileno) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (entry->line == line) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (entry->msg == msg) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strcmp(entry->buffer, buffer) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If the same message is being logged then increment */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log->repeat++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&log->lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (log->repeat) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the pointer to the next log entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry2 = &log->entry[log->next];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Increment and check the next entry index */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (++(log->next) >= log->size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log->next = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (entry->msg->level) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_NOTICE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte msg2 = &emlxs_notice_msg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_WARNING:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte msg2 = &emlxs_warning_msg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte msg2 = &emlxs_error_msg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_PANIC:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte msg2 = &emlxs_panic_msg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld case EMLXS_DEBUG:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld default:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld msg2 = &emlxs_debug_msg;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry2->id = log->count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry2->fileno = entry->fileno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry2->line = entry->line;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry2->msg = msg2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry2->instance = log->instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry2->vpi = port->vpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Save the additional info buffer */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(entry2->buffer, MAX_LOG_INFO_LENGTH,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Last message repeated %d time(s).",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log->repeat);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the entry time stamp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) drv_getparm(LBOLT, &time);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry2->time = time - log->start_time;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan gethrestime(&entry2->id_time);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log->repeat = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the pointer to the next log entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry = &log->entry[log->next];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Increment and check the next entry index */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (++(log->next) >= log->size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log->next = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry->id = log->count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry->fileno = fileno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry->line = line;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry->msg = msg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry->instance = log->instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry->vpi = port->vpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Save the additional info buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(entry->buffer, buffer, (MAX_LOG_INFO_LENGTH - 1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry->buffer[MAX_LOG_INFO_LENGTH - 1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the entry time stamp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) drv_getparm(LBOLT, &time);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry->time = time - log->start_time;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan gethrestime(&entry->id_time);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&log->lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_msg_log() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_msg_log_check(emlxs_port_t *port, emlxs_msg_t *msg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (msg->level) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_DEBUG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->mask & emlxs_log_debugs) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_NOTICE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->mask & emlxs_log_notices) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_WARNING:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->mask & emlxs_log_warnings) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->mask & emlxs_log_errors) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_PANIC:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_msg_log_check() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_msg_print_check(emlxs_port_t *port, emlxs_msg_t *msg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (msg->level) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_DEBUG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->mask & cfg[CFG_CONSOLE_DEBUGS].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval |= 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->mask & cfg[CFG_LOG_DEBUGS].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval |= 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_NOTICE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->mask & cfg[CFG_CONSOLE_NOTICES].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval |= 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->mask & cfg[CFG_LOG_NOTICES].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval |= 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_WARNING:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->mask & cfg[CFG_CONSOLE_WARNINGS].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval |= 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->mask & cfg[CFG_LOG_WARNINGS].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval |= 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->mask & cfg[CFG_CONSOLE_ERRORS].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval |= 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->mask & cfg[CFG_LOG_ERRORS].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval |= 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_PANIC:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval |= 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_msg_print_check() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_msg_printf(emlxs_port_t *port, const uint32_t fileno,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan const uint32_t line, emlxs_msg_t *msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan const char *fmt, ...)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte va_list valist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char va_str[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char msg_str[512];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *level;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t cmn_level;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char driver[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte va_str[0] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fmt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte va_start(valist, fmt);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) vsnprintf(va_str, sizeof (va_str), fmt, valist);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte va_end(valist);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#ifdef FMA_SUPPORT
bb63f56ebeb244bd34f5e8d50900e3420f01b394Sukumar Swaminathan if (msg->fm_ereport_code) {
bb63f56ebeb244bd34f5e8d50900e3420f01b394Sukumar Swaminathan emlxs_fm_ereport(hba, msg->fm_ereport_code);
bb63f56ebeb244bd34f5e8d50900e3420f01b394Sukumar Swaminathan }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
bb63f56ebeb244bd34f5e8d50900e3420f01b394Sukumar Swaminathan if (msg->fm_impact_code) {
bb63f56ebeb244bd34f5e8d50900e3420f01b394Sukumar Swaminathan emlxs_fm_service_impact(hba, msg->fm_impact_code);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* FMA_SUPPORT */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if msg should be logged */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (emlxs_msg_log_check(port, msg)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Log the message */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (emlxs_msg_log(port, fileno, line, msg, va_str)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if msg should be printed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval = emlxs_msg_print_check(port, msg)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_level = CE_CONT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (msg->level) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_DEBUG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte level = " DEBUG";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_NOTICE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte level = " NOTICE";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_WARNING:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte level = "WARNING";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte level = " ERROR";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_PANIC:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_level = CE_PANIC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte level = " PANIC";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte level = "UNKNOWN";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->vpi == 0) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(driver, sizeof (driver), "%s%d",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld DRIVER_NAME, hba->ddiinst);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(driver, sizeof (driver), "%s%d.%d",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld DRIVER_NAME, hba->ddiinst, port->vpi);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Generate the message string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->buffer[0] != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (va_str[0] != 0) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(msg_str, sizeof (msg_str),
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "[%2X.%04X]%s:%7s:%4d: %s (%s)\n", fileno,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan line, driver, level, msg->id, msg->buffer,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan va_str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(msg_str, sizeof (msg_str),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "[%2X.%04X]%s:%7s:%4d: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fileno, line, driver, level, msg->id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte msg->buffer);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (va_str[0] != 0) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(msg_str, sizeof (msg_str),
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "[%2X.%04X]%s:%7s:%4d: (%s)\n", fileno,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan line, driver, level, msg->id, va_str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(msg_str, sizeof (msg_str),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "[%2X.%04X]%s:%7s:%4d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fileno, line, driver, level, msg->id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (rval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 1: /* MESSAGE LOG ONLY */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* Message log & console, if system booted in */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* verbose mode (CE_CONT only) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(cmn_level, "?%s", msg_str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 2: /* CONSOLE ONLY */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(cmn_level, "^%s", msg_str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 3: /* CONSOLE AND MESSAGE LOG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(cmn_level, "%s", msg_str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_msg_printf() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_msg_log_get(emlxs_hba_t *hba, emlxs_log_req_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_log_resp_t *resp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_msg_log_t *log;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t last;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *resp_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log = &LOG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&log->lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if buffer is empty */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (log->count == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If so, exit now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte resp->first = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte resp->last = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte resp->count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&log->lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get current log entry ranges */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get last entry id saved */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte last = log->count - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if request is out of current range */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (req->first > last) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if so, exit now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte resp->first = last;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte resp->last = last;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte resp->count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&log->lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get oldest entry id and its index */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if buffer has already been filled once */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (log->count >= log->size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first = log->count - log->size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = log->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* Buffer not yet filled */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* Check if requested first message is greater than actual. */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* If so, adjust for it. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (req->first > first) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Adjust entry index to first requested message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index += (req->first - first);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index >= log->size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index -= log->size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first = req->first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the total number of messages available for return */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = last - first + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if requested count is less than actual. If so, adjust it. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (req->count < count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = req->count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Fill in the response header */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte resp->count = count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte resp->first = first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte resp->last = last;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Fill the response buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte resp_buf = (char *)resp + sizeof (emlxs_log_resp_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < count; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_msg_sprintf(resp_buf, &log->entry[index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Increment the response buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte resp_buf += MAX_LOG_MSG_LENGTH;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Increment index */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (++index >= log->size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&log->lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_msg_log_get() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_msg_sprintf(char *buffer, emlxs_msg_entry_t *entry)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *level;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_msg_t *msg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t secs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t hsecs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t buflen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char driver[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte msg = entry->msg;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hsecs = (entry->time % 100);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte secs = entry->time / 100;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (msg->level) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_DEBUG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte level = " DEBUG";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_NOTICE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte level = " NOTICE";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_WARNING:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte level = "WARNING";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte level = " ERROR";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EMLXS_PANIC:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte level = " PANIC";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte level = "UNKNOWN";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (entry->vpi == 0) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(driver, sizeof (driver), "%s%d", DRIVER_NAME,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld entry->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(driver, sizeof (driver), "%s%d.%d", DRIVER_NAME,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld entry->instance, entry->vpi);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Generate the message string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (msg->buffer[0] != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (entry->buffer[0] != 0) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(buf, sizeof (buf),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%8d.%02d: %6d:[%2X.%04X]%s:%7s:%4d: %s (%s)\n",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan secs, hsecs, entry->id, entry->fileno,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan entry->line, driver, level, msg->id, msg->buffer,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan entry->buffer);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(buf, sizeof (buf),
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "%8d.%02d: %6d:[%2X.%04X]%s:%7s:%4d: %s\n", secs,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hsecs, entry->id, entry->fileno, entry->line,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte driver, level, msg->id, msg->buffer);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (entry->buffer[0] != 0) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(buf, sizeof (buf),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%8d.%02d: %6d:[%2X.%04X]%s:%7s:%4d: (%s)\n",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan secs, hsecs, entry->id, entry->fileno,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan entry->line, driver, level, msg->id,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan entry->buffer);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(buf, sizeof (buf),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%8d.%02d: %6d:[%2X.%04X]%s:%7s:%4d\n",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan secs, hsecs, entry->id, entry->fileno,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan entry->line, driver, level, msg->id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(buffer, MAX_LOG_MSG_LENGTH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buflen = strlen(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (buflen > (MAX_LOG_MSG_LENGTH - 1)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(buffer, buf, (MAX_LOG_MSG_LENGTH - 2));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buffer[MAX_LOG_MSG_LENGTH - 2] = '\n';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(buffer, buf, buflen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_msg_sprintf() */