| 1 |
/* |
| 2 |
* Copyright (c) 2006-2012. QLogic Corporation. All rights reserved. |
| 3 |
* Copyright (c) 2003-2006, PathScale, Inc. All rights reserved. |
| 4 |
* |
| 5 |
* This software is available to you under a choice of one of two |
| 6 |
* licenses. You may choose to be licensed under the terms of the GNU |
| 7 |
* General Public License (GPL) Version 2, available from the file |
| 8 |
* COPYING in the main directory of this source tree, or the |
| 9 |
* OpenIB.org BSD license below: |
| 10 |
* |
| 11 |
* Redistribution and use in source and binary forms, with or |
| 12 |
* without modification, are permitted provided that the following |
| 13 |
* conditions are met: |
| 14 |
* |
| 15 |
* - Redistributions of source code must retain the above |
| 16 |
* copyright notice, this list of conditions and the following |
| 17 |
* disclaimer. |
| 18 |
* |
| 19 |
* - Redistributions in binary form must reproduce the above |
| 20 |
* copyright notice, this list of conditions and the following |
| 21 |
* disclaimer in the documentation and/or other materials |
| 22 |
* provided with the distribution. |
| 23 |
* |
| 24 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 25 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 26 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 27 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 28 |
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 29 |
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 30 |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 31 |
* SOFTWARE. |
| 32 |
*/ |
| 33 |
|
| 34 |
/* IPS - Interconnect Protocol Stack */ |
| 35 |
|
| 36 |
#include <stdio.h> |
| 37 |
#include <string.h> |
| 38 |
#include <errno.h> |
| 39 |
#include <ipserror.h> |
| 40 |
|
| 41 |
char * ips_err_str(int ips_error) |
| 42 |
{ |
| 43 |
static char err_str[128]; |
| 44 |
|
| 45 |
switch (ips_error) { |
| 46 |
case IPS_RC_OK: |
| 47 |
return "OK!"; |
| 48 |
|
| 49 |
case IPS_RC_ERROR: |
| 50 |
return "general error"; |
| 51 |
|
| 52 |
case IPS_RC_PENDING: |
| 53 |
return "request pending"; |
| 54 |
|
| 55 |
case IPS_RC_EXIST: |
| 56 |
return "entry exist"; |
| 57 |
|
| 58 |
case IPS_RC_MAX_ENTRIES_EXCEEDED: |
| 59 |
return "max entries has been exceeded"; |
| 60 |
|
| 61 |
case IPS_RC_NOT_ENOUGH_BUFFERS: |
| 62 |
return "not enough buffers to complete request"; |
| 63 |
|
| 64 |
case IPS_RC_NO_FREE_MEM: |
| 65 |
return "no free memory"; |
| 66 |
|
| 67 |
case IPS_RC_NAME_LOOKUP_FAILED: |
| 68 |
return "name lookup failed"; |
| 69 |
|
| 70 |
case IPS_RC_PARAM_ERROR: |
| 71 |
return "invalid parameter"; |
| 72 |
|
| 73 |
case IPS_RC_UNKNOWN_DEVICE: |
| 74 |
return "unknown device"; |
| 75 |
|
| 76 |
case IPS_RC_DEVICE_INIT_FAILED: |
| 77 |
return "device init failed"; |
| 78 |
|
| 79 |
case IPS_RC_DATA_TRUNCATED: |
| 80 |
return "data truncated"; |
| 81 |
|
| 82 |
case IPS_RC_INVALID_RANK: |
| 83 |
return "invalid rank"; |
| 84 |
|
| 85 |
case IPS_RC_INVALID_OPCODE: |
| 86 |
return "invalid op code"; |
| 87 |
|
| 88 |
case IPS_RC_PEER_NOT_READY: |
| 89 |
return "peer is not ready"; |
| 90 |
|
| 91 |
case IPS_RC_PEER_CLOSED : |
| 92 |
return "peer is closed"; |
| 93 |
|
| 94 |
case IPS_RC_DEST_EQUAL_LOCAL_RANK: |
| 95 |
return "src and dest rank is equal"; |
| 96 |
|
| 97 |
case IPS_RC_DEVICE_ERROR: |
| 98 |
return "InfiniPath hardware not found, hardware problem, or disabled"; |
| 99 |
|
| 100 |
case IPS_RC_NETWORK_DOWN: |
| 101 |
return "The link is down"; |
| 102 |
|
| 103 |
case IPS_RC_NOT_ENOUGH_FREE_TIDS: |
| 104 |
return "Not enough free TIDS to complete request"; |
| 105 |
|
| 106 |
case IPS_RC_NO_RESOURCE_AVAILABLE: |
| 107 |
return "Internal resources exhausted"; |
| 108 |
|
| 109 |
case IPS_RC_HW_UPDATE_FAILED: |
| 110 |
return "Failed TID update for rendevous, allocation problem"; |
| 111 |
|
| 112 |
case IPS_RC_PARTITION_ERROR: |
| 113 |
return "One or more nodes is on a different partition"; |
| 114 |
|
| 115 |
case IPS_RC_RUN_ERROR: |
| 116 |
return "One or more nodes is still running the previous job"; |
| 117 |
|
| 118 |
case IPS_RC_ALREADY_OPEN: |
| 119 |
return "Open/init has already been called"; |
| 120 |
|
| 121 |
case IPS_RC_WAS_CLOSED: |
| 122 |
return "Close has already been called"; |
| 123 |
|
| 124 |
case IPS_RC_DEST_EQUAL_LOCAL_LID: |
| 125 |
return "src and dest LID is equal"; |
| 126 |
|
| 127 |
case IPS_RC_BUFFER_ALIGMENT_ERROR: |
| 128 |
return "Buffer start address is not 32 bit aligned"; |
| 129 |
|
| 130 |
case IPS_RC_LENGTH_ALIGMENT_ERROR: |
| 131 |
return "Buffer length is not a whole # of 32 bit words"; |
| 132 |
|
| 133 |
case IPS_RC_INVALID_DATA_LENGTH: |
| 134 |
return "invalid data length"; |
| 135 |
|
| 136 |
case IPS_RC_BUSY: |
| 137 |
return "Device is busy"; |
| 138 |
|
| 139 |
case IPS_RC_INIT_TIMEOUT_EXPIRED: |
| 140 |
return "Could not connect to other nodes"; |
| 141 |
|
| 142 |
case IPS_RC_NO_PORTS_AVAILABLE: |
| 143 |
return "All InfiniPath ports are in use."; |
| 144 |
|
| 145 |
/* Performance Counters codes */ |
| 146 |
case IPS_RCPERF_INIT_FAILED: |
| 147 |
return "Initialization of performance counters failed"; |
| 148 |
|
| 149 |
case IPS_RCPERF_EVENT_SETUP_FAILED: |
| 150 |
return "Setting performance counter events failed"; |
| 151 |
|
| 152 |
case IPS_RCPERF_REG_DEFAULT_SET: |
| 153 |
return "Default event set for one of the counters"; |
| 154 |
|
| 155 |
case IPS_RCPERF_UNSUPPORTED_CPU: |
| 156 |
return "This CPU type is not supported"; |
| 157 |
|
| 158 |
case IPS_RCPERF_REG_GET_FAILED: |
| 159 |
return "Failed to get register value for event"; |
| 160 |
|
| 161 |
case IPS_RCPERF_SET_EVENT_STR_FAILED: |
| 162 |
return "Failed to find event description"; |
| 163 |
|
| 164 |
case IPS_RCPERF_INVALID_REGISTER: |
| 165 |
return "Register index out of range of available counters"; |
| 166 |
|
| 167 |
case IPS_RC_SYSERR: // we hope errno hasn't changed since this was set... |
| 168 |
snprintf(err_str, sizeof err_str, "System error: %s", strerror(errno)); |
| 169 |
return err_str; |
| 170 |
|
| 171 |
default: |
| 172 |
snprintf(err_str, sizeof err_str, "Error code %i: <no interpretation>", ips_error); |
| 173 |
return err_str; |
| 174 |
} |
| 175 |
} |