39 #include <sys/types.h>
40 #include <sys/ioctl.h>
54 #include <elx_pt_ioctl.h>
57 #define IOCTL_BUFSIZE 64*1024
59 #define DPORT_DYNAMIC_MODE 0x1
60 #define DPORT_STATIC_MODE 0x2
61 #define DPORT_QUERY_DYNAMIC_MODE 0x3
65 uint32_t inbufLength,
void *outbuf, uint32_t outbufLength);
67 uint32_t inbufLength,
void *outbuf, uint32_t outbufLength);
68 #define VPD_LARGE_RESOURCE_TYPE_ID_STRING_TAG 0x82
69 #define VPD_LARGE_RESOURCE_TYPE_R_TAG 0x90
70 #define VPD_LARGE_RESOURCE_TYPE_W_TAG 0x91
71 #define VPD_SMALL_RESOURCE_TYPE_END_TAG 0x78
97 static inline uint8_t *
103 static inline uint8_t *
104 elx_find_vpd(uint8_t *vpddata, uint32_t vpddata_length,
const char *key)
107 uint8_t *pret = NULL;
111 vpdbuf.
buffer = (uint8_t*) vpddata;
112 vpdbuf.
length = vpddata_length;
129 len = len_lo + (len_hi << 8);
150 if ((c0 == rc0) && (c1 == rc1)) {
152 for (i = 0; i < sublen; i++) {
156 }
else if (
'R' == rc0 &&
'V' == rc1) {
159 for (i = 0; i < sublen; i++) {
165 printf(
"checksum error\n");
170 for (i = 0; i < sublen; i++) {
176 for (i = 0; i < len; i++) {
200 printf(
"FW Rev: %s\n", value);
205 printf(
"FW Rev2: %s\n", value);
209 if (value && (strlen(value) > 0)) {
210 printf(
"HW Rev1: %s\n", value);
214 if (value && (strlen(value) > 0)) {
215 printf(
"HW Rev2: %s\n", value);
219 if (value && (strlen(value) > 0)) {
220 printf(
"HW Rev3: %s\n", value);
231 printf(
"-------------------------------------------------------------- \n");
233 printf(
"Num Phases = %d \n", rsp->
num_phases);
234 printf(
"Local Test Results = %d \n", rsp->
local);
235 printf(
"Remote Test Results = %d \n", rsp->
remote);
238 printf(
"Frame Size = %d \n", rsp->
frame_size);
240 printf(
"Individual test results \n");
241 printf(
"=============================================================== \n");
243 for(i=0; i < no_of_desc; i++) {
247 printf(
"Electrical Loopback Test: ");
250 printf(
"Optical Loopback Test: ");
253 printf(
"Reverse Optical Loopback Test: ");
256 printf(
"Link Traffic Test: ");
259 printf(
"Reverse Link Traffic Test: ");
281 printf(
"Phase Latency = 0x%X \n", ptr->
w1);
283 printf(
"error = 0x%X \n", ptr->
w1);
286 printf(
"=============================================================== \n");
306 link_diag_req->
diag = enable;
307 link_diag_req->
div = 1;
312 printf(
"mbox_set_link_diag_state command submission failed \n");
314 if(link_diag_rsp->hdr.status) {
315 printf(
"mbox_set_link_diag_state failed with status = %x, additional_status = %x \n",
316 link_diag_rsp->hdr.status, link_diag_rsp->hdr.additional_status);
343 dport_mode_req->
enable = enable;
345 dport_mode_req->
stop = enable ? 0 : 1;
353 printf(
"mbox_set_dport_mode command submission failed \n");
355 if(dport_mode_rsp->hdr.status) {
356 printf(
"mbox_set_dport_mode failed with status = %x, additional_status = %x \n",
357 dport_mode_rsp->hdr.status, dport_mode_rsp->hdr.additional_status);
362 rval = dport_mode_rsp->enabled;
376 printf(
"Dport mode query failed \n");
378 printf(
"Dynamic dport mode %s for device%d.\n",
379 (rval == 0) ?
"disabled" :
"enabled", device->
phy_port_num);
391 if (strcasecmp(state_str,
"enable") == 0){
397 printf(
"Set dynamic dport %s %s for device%d.\n", (state == 1) ?
"enable" :
"disable",
398 (rval == 0) ?
"successfull" :
"failed", device->
phy_port_num);
412 uint32_t link_status = 0;
413 int rval = -1, dynamic_dport_enabled = 0;
418 printf(
"Failed to alloc memory for mqe\n");
422 printf(
"Running D_Port Tests. Please wait for 2 minutes. Polling for results \n");
426 printf(
"Failed to get link status\n");
432 if (dynamic_dport_enabled < 0) {
433 printf(
"Failed to get dynamic dport status\n");
437 if (dynamic_dport_enabled) {
440 printf(
"Failed to reset dynamic dport state\n");
447 printf(
" Set link to DIAG state failed \n");
448 goto exit_mbox_get_dport_stats;
454 printf(
" Set link to dport mode failed \n");
455 goto exit_mbox_get_dport_stats;
478 sizeof (*dport_results_req), dport_results_rsp,
sizeof(*dport_results_rsp));
480 if(dport_results_rsp->hdr.status == 0) {
492 printf(
" Disabling dport mode failed \n");
493 goto exit_mbox_get_dport_stats;
499 printf(
" Set link to Normal state failed \n");
500 goto exit_mbox_get_dport_stats;
503 exit_mbox_get_dport_stats:
507 printf(
" Function reset failed. \n");
513 printf(
"Failed to set link status\n");
517 if (dynamic_dport_enabled) {
519 dynamic_dport_enabled);
521 printf(
"Failed to reset dynamic dport state\n");
548 uint32_t link_status = 0;
551 printf(
"\n============================================================\n\n");
554 printf(
"\nInternal Loopback test started......\n");
556 printf(
"\nExternal Loopback test started......\n");
558 printf(
"\nPCI Loopback test started......\n");
560 printf(
"Error: Unsupported Loopback type(%d) provided.\n", loopback_type);
561 printf(
"Usage(Loopback type)\n1 - Internal Loopback test\n");
562 printf(
" 2 - External Loopback test\n");
563 printf(
" 3 - PCI Loopback test\n");
564 goto exit_mbox_diag_loopback_tests;
569 printf(
"Unable to allocate memory for mbox command\n");
570 goto exit_mbox_diag_loopback_tests;
576 printf(
"Failed to get link status\n");
577 goto exit_mbox_diag_loopback_tests;
583 printf(
" Set link to DIAG state failed \n");
584 goto exit_mbox_diag_loopback_tests;
590 printf(
"Please install proper SFP and loopback cable before running tests\n");
592 goto exit_mbox_diag_loopback_tests;
595 printf(
"Loopback test is in progress. Polling for results.....\n\n");
596 for (i = 0; i <= retry_count; i++) {
603 printf(
"Loopback test passed after %d attempt\n", i+1);
605 printf(
" Results: PASSED\n");
611 printf(
"No loopback cable connected. Please install loopback cable before running the test\n");
612 printf(
" Results: FAILED\n");
616 printf(
" Set link to Normal state failed \n");
617 goto exit_mbox_diag_loopback_tests;
622 printf(
"Failed to set link status\n");
623 goto exit_mbox_diag_loopback_tests;
627 printf(
"PCI Loopback test is in progress. Polling for results.....\n\n");
628 for (i = 0; i <= retry_count; i++) {
634 printf(
"Loopback test passed after %d attempt\n", i+1);
636 printf(
" Results: PASSED\n");
643 printf(
" Results: FAILED\n");
646 exit_mbox_diag_loopback_tests:
648 printf(
"============================================================\n\n");
679 read_link_status->
clof = clof;
680 read_link_status->
clrc = clrc;
681 read_link_status->
rec = 1;
741 printf(
" Received LRR count: %d\n", read_link_status->
lrr_count_local);
776 read_status->
cc = clear_counter;
854 mbox, request_Len, mbox, request_Len);
856 if (rval != 0) { printf (
"Error: rval %d\n", rval);
857 }
else if (sli_config->
status) {
921 set_mbox, request_Len, set_mbox, request_Len);
924 printf (
"Error: rval %d\n", rval);
925 }
else if (sli_config->
status) {
926 printf (
"status 0x%02X addl 0x%02X, MAC address may already be used\n",
952 uint32_t mbox_words[256];
955 elx_pt_ioctl_mbox_t mbox;
960 if (device == NULL) {
964 if (mac_addr == NULL) {
972 bzero(&mbox_words,
sizeof(mbox_words));
985 mbox.words = (uint32_t *)config_req;
986 mbox.num_words = (
sizeof(mbox_words) + 3) / 4;
988 rc = ioctl(fd, IOCTL_CMD_ELX_PT_MBOX, &mbox);
991 switch(config_res->
desc[0] & 0xff) {
997 for (i=0; i<6; i++) {
1007 for (i=0; i<6; i++) {
1017 for (i=0; i<6; i++) {
1032 elx_pt_ioctl_mbox_t mbox;
1038 bzero(&req,
sizeof(req));
1042 mbox.words = (uint32_t *) &req;
1043 mbox.num_words = (
sizeof(req) + 3) / 4;
1045 rc = ioctl(fd, IOCTL_CMD_ELX_PT_MBOX_FC, &mbox);
1048 memcpy(wwnn, req.
wwnn,
sizeof(req.
wwnn));
1049 memcpy(wwpn, req.
wwpn,
sizeof(req.
wwpn));
1056 elx_pt_ioctl_mbox_t mbox;
1060 bzero(&read_rev,
sizeof(read_rev));
1064 if (dma_mem == NULL) {
1065 printf(
"%s: Failed to allocate DMA memory\n", __func__);
1074 mbox.words = (uint32_t *) &read_rev;
1075 mbox.num_words = (
sizeof(read_rev) + 3) / 4;
1077 rc = ioctl(device->
fd, IOCTL_CMD_ELX_PT_MBOX_FC, &mbox);
1078 if (!rc && !read_rev.
status) {
1079 int serial_num_len = 0;
1080 uint8_t *pserial = NULL;
1084 serial_num_len = *pserial++;
1085 if (serial_num_len > serial_num_size)
1086 serial_num_len =
sizeof(serial_num);
1088 memcpy((uint8_t *)serial_num, pserial, serial_num_len);
1100 uint32_t mbox_words[1024];
1101 elx_pt_ioctl_mbox_t mbox;
1109 uint32_t *desc_pointer;
1113 uint8_t *mac_pointer;
1114 uint8_t *temp_descriptor = NULL;
1128 p = strrchr(device->
bus_addr,
'.');
1134 pf = strtol(p, NULL, 10);
1137 bzero(&mbox_words,
sizeof(mbox_words));
1152 get_req->
typ = 0x01;
1153 mbox.words = mbox_words;
1156 rc = ioctl(device->
fd, IOCTL_CMD_ELX_PT_MBOX, &mbox);
1167 desc_pointer = (uint32_t *)get_res->
desc;
1178 type = *desc_pointer & 0x000000ff;
1185 len = (*desc_pointer & 0x0000ff00) >> 8;
1192 if (descriptor->
vft == 0) {
1196 }
else if (type == 0x52) {
1201 }
else if (type == 0x41) {
1208 desc_pointer += (len /
sizeof(uint32_t));
1211 if (mac_pointer == NULL) {
1218 mac_pointer[i] = macaddr[i];
1226 temp_descriptor = malloc(len);
1227 if (temp_descriptor == NULL) {
1230 memcpy(temp_descriptor, (uint8_t *)desc_pointer, len);
1234 bzero(&mbox_words,
sizeof(mbox_words));
1244 memcpy((uint8_t *)set_req->
desc, temp_descriptor, len);
1246 rc = ioctl(device->
fd, IOCTL_CMD_ELX_PT_MBOX, &mbox);
1256 free(temp_descriptor);
1260 if (temp_descriptor)
1261 free(temp_descriptor);
1278 elx_pt_ioctl_mbox_fc_t mbox;
1282 bzero(&req,
sizeof(req));
1285 mbox.words = (uint32_t *) &req;
1286 mbox.num_words = ((
sizeof(req) + 3) / 4);
1288 rc = ioctl(device->
fd, IOCTL_CMD_ELX_PT_MBOX_FC, &mbox);
1289 if (rc != 0 || req.
status != 0) {
1293 if (wwpn_p != NULL) {
1294 rc = sscanf(wwpn_p,
"%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx",
1299 printf(
" Invalid WWPN: %s\n", wwpn_p);
1304 if (wwnn_p != NULL) {
1305 rc = sscanf(wwnn_p,
"%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx",
1310 printf(
" Invalid WWNN: %s\n", wwnn_p);
1317 rc = ioctl(device->
fd, IOCTL_CMD_ELX_PT_MBOX_FC, &mbox);
1318 if (rc != 0 || req.
status != 0) {
1340 uint32_t outbufLength)
1347 uint32_t localOutbufLength;
1348 void *localOutbuf = NULL;
1358 localOutbufLength = outbufLength +
sizeof(*mbox);
1359 localOutbuf =
zmalloc(localOutbufLength);
1366 sli_config->
emb = 0;
1372 sli_config->
sge[0].
length = localOutbufLength;
1376 mbox->common.word1.out.timeout = 0;
1377 mbox->common.request_length = outbufLength + 0x14;
1379 mbox->flashrom_access_op_code = opcode;
1380 mbox->flashrom_access_op_type = optype;
1381 mbox->data_buffer_size = outbufLength;
1382 mbox->offset = offset;
1399 memcpy(outbuf, ((uint8_t*)localOutbuf) +
sizeof (*mbox), outbufLength);
1422 uint32_t inbufLength)
1429 uint32_t localInbufLength =
sizeof(*mbox) + inbufLength;
1433 mbox =
zmalloc(localInbufLength);
1443 sli_config->
emb = 0;
1449 sli_config->
sge[0].
length = localInbufLength;
1463 memcpy(&mbox[1], inbuf, inbufLength);
1480 memcpy(inbuf, &rsp[1], inbufLength);
1511 uint32_t bufferLength)
1518 uint32_t localBufferLength;
1519 void *localBuffer = NULL;
1529 localBufferLength = bufferLength +
sizeof(*mbox);
1530 localBuffer =
zmalloc(localBufferLength);
1537 sli_config->
emb = 0;
1543 sli_config->
sge[0].
length = localBufferLength;
1547 mbox->common.word1.out.timeout = 0;
1548 mbox->common.request_length = bufferLength + 0x14;
1550 mbox->params.request.fat_operation = fat_operation;
1551 mbox->params.request.read_log_offset = read_log_offset;
1552 mbox->params.request.read_log_length = bufferLength;
1553 mbox->params.request.data_buffer_size = bufferLength;
1569 switch (fat_operation)
1573 memcpy(buffer, ((uint8_t*)localBuffer) +
sizeof (*mbox), bufferLength);
1621 sli_config->
emb = 0;
1645 printf (
"Error: status 0x%02X addl 0x%02X\n", rsp->
word1.
in.status, rsp->
word1.
in.additional_status);
1664 uint32_t delayedAckTimerValue)
1683 sli_config->
emb = 1;
1693 mbox->
params.
request.delayed_ack_timer = delayedAckTimerValue;
1698 if (sli_config->
status) {
1699 printf(
"sli status 0x%02x, mbox status 0x%02X, mbox addl 0x%02X\n",
1720 uint16_t connectionId, uint32_t constrainWindowValue)
1739 sli_config->
emb = 1;
1750 mbox->
params.
request.window_reduction = constrainWindowValue;
1754 if (sli_config->
status) {
1755 printf(
"sli status 0x%02x, mbox status 0x%02X, mbox addl 0x%02X\n",
1795 sli_config->
emb = 1;
1808 switch (sli_config->
status) {
1811 printf(
" Connection Handle: 0x%x\n", connectionHandle);
1812 printf(
" Source Address: %s\n",
1815 printf(
" Dest Address: %s\n",
1819 printf(
" Interface Handle: 0x%08x\n", mbox->
params.
response.interface_handle);
1820 printf(
" Window Scale Shift Count: %d\n", mbox->
params.
response.window_scale_shift_count);
1825 printf(
"%x is not a valid connection handle\n", connectionHandle);
1830 printf(
"sli status 0x%02x, mbox status 0x%02X, mbox addl 0x%02X\n",
1864 for (i = 0; i <
ARRAY_SIZE(mbox_linkcfg_str); i++) {
1865 if (strncmp(mbox_linkcfg_str[i].mgmt_str, mgmt_str,
1866 strlen(mgmt_str)) == 0) {
1867 return mbox_linkcfg_str[i].
clp_str;
1885 for (i = 0; i <
ARRAY_SIZE(mbox_linkcfg_str); i++) {
1886 if (strncmp(mbox_linkcfg_str[i].clp_str, clp_str,
1887 strlen(clp_str) - 2) == 0) {
1888 return mbox_linkcfg_str[i].
mgmt_str;
1901 static char result[80];
1916 if (clp_command == NULL) {
1921 if (clp_response == NULL) {
1926 if (response == NULL) {
1930 snprintf(clp_command->
vaddr, 80,
"show / OEMELX_LinkConfig");
1949 response,
sizeof(*response));
1952 if (rval != 0 || rc != 0) {
1955 printf(
"clp_status = %02X, clp_addl_status = %02X\n",
1957 printf(
"Mbox write failed\n");
1962 resp_str = strstr(clp_response->
vaddr,
"endoutput");
1963 if (resp_str == NULL) {
1964 printf(
"Parse failure\n");
1969 resp_str = strstr(clp_response->
vaddr,
"retdata");
1970 if (resp_str == NULL) {
1971 printf(
"Parse failure\n");
1977 if (mgmt_str != NULL && strlen(mgmt_str) <
sizeof(result)) {
1978 strncpy(result, mgmt_str,
sizeof(result));
1980 strncpy(result,
"UNKNOWN",
sizeof(result));
1990 if (response != NULL) {
1993 if (clp_response != NULL) {
1996 if (clp_command != NULL) {
2011 static char linkcfg_str[32];
2012 size_t response_len;
2030 response =
zmalloc(response_len);
2031 if (response == NULL) {
2045 response, response_len);
2048 if (rval != 0 || rc != 0) {
2051 printf(
"Mbox write failed\n");
2055 strncpy(linkcfg_str,
"UNKNOWN",
sizeof(linkcfg_str));
2066 if (response != NULL) {
2088 char *linkcfg_str = NULL;
2106 const char *linkcfg_str;
2121 if (clp_command == NULL) {
2126 if (clp_response == NULL) {
2131 if (response == NULL) {
2138 snprintf(clp_command->
vaddr, 80,
"set / OEMELX_LinkConfig=%s", linkcfg_str);
2157 response,
sizeof(*response));
2160 if (rval != 0 || rc != 0) {
2163 printf(
"clp_status = %#X, clp_addl_status = %0#X\n",
2165 printf(
"Mbox write failed\n");
2170 resp_str = strstr(clp_response->
vaddr,
"status=");
2171 if (resp_str == NULL) {
2172 printf(
"Parse failure\n");
2177 clp_status = atoi(resp_str);
2178 if (clp_status != 0) {
2179 printf(
"Device returned status %d when setting link config.\n",
2186 if (response != NULL) {
2189 if (clp_response != NULL) {
2192 if (clp_command != NULL) {
2208 typedef struct mbox_skyhawk_linkcfg_map_s {
2233 for (i = 0; i <
ARRAY_SIZE(mbox_skyhawk_linkcfg_map); i++) {
2234 if (strncmp(mbox_skyhawk_linkcfg_map[i].mgmt_str, mgmt_str,
2235 strlen(mgmt_str)) == 0) {
2236 return mbox_skyhawk_linkcfg_map[i].
config_id;
2259 if (response == NULL) {
2276 response,
sizeof(*response));
2279 if (rval != 0 || rc != 0) {
2282 printf(
"Mbox write failed\n");
2286 if (response != NULL) {
2324 memset(&vport, 0,
sizeof(vport));
2333 fprintf(stderr,
"vport creation failed\n");
2344 memset(&vport, 0,
sizeof(vport));
2368 static char ret[40];
2370 uint8_t *address_bytes = (uint8_t *)address;
2372 address_type = address_bytes[3];
2375 if (address_type < 3) {
2377 sprintf(ret,
"%d.%d.%d.%d",
2384 sprintf(ret,
"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
2385 address_bytes[4], address_bytes[5],
2386 address_bytes[6], address_bytes[7],
2387 address_bytes[8], address_bytes[9],
2388 address_bytes[10], address_bytes[11],
2389 address_bytes[12], address_bytes[13],
2390 address_bytes[14], address_bytes[15],
2391 address_bytes[16], address_bytes[17],
2392 address_bytes[18], address_bytes[19]);
2419 void *inbuf, uint32_t inbufLength,
void *outbuf, uint32_t outbufLength)
2421 if (device == NULL) {
2426 return ocs_mbox(device, mboxcmd, mboxcmdLength, inbuf, inbufLength, outbuf, outbufLength);
2428 return pt_mbox(device, mboxcmd, mboxcmdLength, inbuf, inbufLength, outbuf, outbufLength);
2435 void *inbuf, uint32_t inbufLength,
void *outbuf, uint32_t outbufLength)
2441 elx_pt_ioctl_mbox_t mbox;
2449 request = malloc(inbufLength);
2450 if (request == NULL) {
2454 memcpy(request, inbuf, inbufLength);
2456 mbox.num_words = (inbufLength + (
sizeof(uint32_t)-1)) /
sizeof(uint32_t);
2457 mbox.words = (uint32_t *)request;
2459 rc = ioctl(device->
fd, IOCTL_CMD_ELX_PT_MBOX, &mbox);
2461 memcpy(outbuf, request, outbufLength);
2465 elx_pt_ioctl_mbox_fc_t mbox;
2470 request = malloc(mboxcmdLength);
2471 if (request == NULL) {
2475 memcpy(request, &(mboxcmd->
request), mboxcmdLength);
2477 mbox.num_words = (mboxcmdLength + 3) / 4;
2478 mbox.words = (uint32_t *)request;
2480 rc = ioctl(device->
fd, IOCTL_CMD_ELX_PT_MBOX_FC, &mbox);
2482 memcpy(&(mboxcmd->
response), request, mboxcmdLength);
2490 uint32_t inbufLength,
void *outbuf, uint32_t outbufLength)
2500 if (mboxcmdLength >
sizeof(cmd.
payload)) {
2501 printf(
"%s: mboxcmd too big (actual=%d allowed=%zu)\n", __func__,
2502 mboxcmdLength,
sizeof(cmd.
payload));
2506 memcpy(cmd.
payload, mboxcmd, mboxcmdLength);
2510 cmd.
in_addr = (uint64_t)inbuf;
2524 printf(
"%s, command %x not supported.\n", __func__, mboxcmd->
request.
command);
2533 memcpy(mboxcmd, cmd.
payload, mboxcmdLength);
2552 elx_pt_ioctl_dma_alloc_t dma_alloc;
2556 pagesize = sysconf(_SC_PAGESIZE);
2559 if (memref == NULL) {
2563 dma_alloc.req_size = size;
2564 rc = ioctl(device->
fd, IOCTL_CMD_ELX_PT_DMA_ALLOC, &dma_alloc);
2570 memref->
vaddr = mmap(NULL,
ROUNDUP(size, pagesize), PROT_READ | PROT_WRITE, MAP_SHARED,
2571 device->
fd, dma_alloc.tag * pagesize);
2572 if (memref->
vaddr == MAP_FAILED) {
2574 elx_pt_ioctl_dma_free_t dma_free;
2576 memset(&dma_free, 0,
sizeof(dma_free));
2577 dma_free.tag = dma_alloc.tag;
2578 (void)ioctl(device->
fd, IOCTL_CMD_ELX_PT_DMA_FREE, &dma_free);
2583 memref->
paddr = dma_alloc.paddr;
2584 memref->
tag = dma_alloc.tag;
2586 memref->
size = size;
2604 elx_pt_ioctl_dma_free_t dma_free;
2607 pagesize = sysconf(_SC_PAGESIZE);
2609 if (memref == NULL) {
2613 if (memref->
vaddr != NULL) {
2616 memset(&dma_free, 0,
sizeof(dma_free));
2617 dma_free.tag = memref->
tag;
2619 ioctl(memref->
device->
fd, IOCTL_CMD_ELX_PT_DMA_FREE, &dma_free);
2657 printf(
"Timed out waiting for SLIPORT_STATUS RDY\n");
2672 printf(
"Timed out waiting for SLIPORT_SEMAPHORE\n");
2687 printf(
"Timed out waiting for BMBX RDY\n");
2759 printf(
"Timeout waiting for RDY\n");
2763 words[0] = 0xff1234ff;
2764 words[1] = 0xff5678ff;
2796 response =
zmalloc(mbox_size);
2797 if (response == NULL) {
2811 response, mbox_size);
2816 int remaining_len = result_len;
2821 snprintf(description,
sizeof(description),
"0x%02x: %s\n",
2825 if (remaining_len <= strlen(description)) {
2829 strncat(result, description, remaining_len);
2830 remaining_len -= strlen(description);
2835 if (response != NULL) {
2864 if (response == NULL) {
2877 response,
sizeof(*response));
2881 char profile_list[5 * 1024];
2883 char active_profile_str[8];
2907 result_p = strstr(profile_list, active_profile_str);
2908 if (result_p != NULL) {
2915 char *c = strchr(result_p,
'\n');
2918 strncpy(result, result_p, result_len);
2931 if (response != NULL) {
2946 int32_t new_profile;
2961 if (response == NULL) {
2965 new_profile = strtoul(new_profile_id, NULL, 0);
2977 response,
sizeof(*response));
2982 if (response != NULL) {
uint32_t total_exchanges_responder
struct mbox_common_manage_fat_t::@9::@11 response
static void parse_dport_result(mbox_res_fcoe_get_dport_results_t *rsp)
static mbox_skyhawk_linkcfg_map_t mbox_skyhawk_linkcfg_map[]
Mapping from mgmt string to Skyhawk config IDs.
sli4_link_config_descriptor_t desc[MAX_LINK_CONFIG_DESCRIPTORS]
#define OCS_IOCTL_CMD_ELXU_MBOX
struct mbox_common_iscsi_get_connection_info_t::@29::@30 request
#define OCS_CONFIG_LINKCFG_4X10G
linkcfg strings
#define DPORT_STATIC_MODE
memref_t * elx_pt_dma_alloc(elxu_device_t *device, int size)
Request a DMA allocation through elx_pt.
#define OPCODE_COMMON_SET_ACTIVE_PROFILE
static int mbox_set_link_diag_state(elxu_device_t *device, void *mqe, int enable)
#define OPCODE_COMMON_ISCSI_GET_CONNECTION_INFO
static int vpdnext(vpdbuf_t *vpd)
struct mbox_common_iscsi_connection_update_t::@27::@28 request
#define FAT_OPERATION_TRIGGER
int mbox_connection_update(elxu_device_t *device, uint32_t request_flags, uint16_t connectionId, uint32_t constrainWindowValue)
#define OPCODE_COMMON_SET_RECONFIG_LINK_INFO
#define OPCODE_COMMON_ISCSI_SET_TCP_PARAMETERS
union mbox_common_iscsi_get_connection_info_t::@29 params
#define MBOX_SUBSYSTEM_FCOE
#define SLI4_SLIPORT_STATUS_RDY
static char * mbox_get_mgmt_from_clp_linkcfg_str(char *clp_str)
Get the mgmt config string from the CLP string.
uint32_t advertised_transmit_buffer_to_buffer_credit
uint32_t uint32_t timeout
int mbox_ioctl_common_enable_disable_port(elxu_device_t *device, uint32_t port_status)
Issue IOCTL_COMMON_ENABLE_DISABLE_PORT command.
#define MAX_LINK_CONFIG_DESCRIPTORS
uint32_t total_exchanges_originator
int mbox_set_nv_wwn_pt(elxu_device_t *device, char *wwpn_p, char *wwnn_p)
Issue a set non-volatile WWNN/WWPN.
Mapping from mgmt string to Skyhawk config IDs.
mgmt link config string to CLP string mapping.
#define VPD_SMALL_RESOURCE_TYPE_END_TAG
int mbox_tcp_parameters(elxu_device_t *device, uint32_t request_flags, uint32_t ackFrequency, uint32_t delayedAckTimerValue)
Issue the Set TCP Parameters mbox command.
uint32_t clp_detailed_status
int elxu_device_exec(elxu_device_t *device, char *name, void *arg_in, int arg_in_len, void *arg_out, int arg_out_len)
Execute a management function on a device.
static uint32_t addr32_lo(uintptr_t addr)
uint32_t round_trip_latency
union mbox_common_manage_fat_t::@9 params
uint32_t uint32_t link_number
#define MBOX_READ_NVPARMS
int mbox_set_linkcfg_skyhawk_pt(elxu_device_t *device, char *config)
#define MBOX_WRITE_NVPARMS
#define SLI4_SLIPORT_STATUS
#define FAT_OPERATION_CLEAR
struct mbox_common_t::@3::@4 out
uint32_t arbitration_timeout_count
#define OCS_CONFIG_LINKCFG_1X40G
uint8_t iscsi_mac_address[6]
#define OPCODE_COMMON_ISCSI_CONNECTION_UPDATE
uint16_t buffers_required
int mbox_set_dynamic_dport(elxu_device_t *device, char *state_str)
static const char * mbox_get_clp_from_mgmt_linkcfg_str(char *mgmt_str)
Get the CLP string from the mgmt config string.
struct mbox_common_t::@3::@5 in
uint32_t uint32_t config_description[8]
uint32_t invalid_transmission_word_error_count
uint32_t uint32_t link_config_desc_count
#define DPORT_QUERY_DYNAMIC_MODE
#define MBOX_SET_LINK_DIAG_STATE
#define OPCODE_DMTF_EXEC_CLP_CMD
int mbox_read_rev(elxu_device_t *device)
Issue read rev mailbox command.
#define OCS_IOCTL_CMD_VPORT
int mbox_soft_assign_mac(elxu_device_t *device, int *macaddr)
Soft assign MAC.
int elxu_lancer_set_link_state(elxu_device_t *device_p, uint32_t *status)
int mbox_query_dynamic_dport_status(elxu_device_t *device)
#define MBOX_SET_DPORT_MODE
int mbox_common(elxu_device_t *device, mbox_command_t *mboxcmd, uint32_t mboxcmdLength, void *inbuf, uint32_t inbufLength, void *outbuf, uint32_t outbufLength)
Send a mailbox command.
#define OPCODE_COMMON_GET_PROFILE_LIST
uint32_t link_failure_error_count
uint32_t loss_of_signal_error_count
uint32_t cmd_buf_addr_low
#define SLI4_SLIPORT_PORT_STATUS_MASK
#define OCS_CONFIG_LINKCFG_4X8G
#define DPORT_DYNAMIC_MODE
uint32_t received_soff_count
void * zmalloc(uint32_t len)
Allocates and zeroes memory to be used.
#define VPD_LARGE_RESOURCE_TYPE_R_TAG
#define SLI4_SLIPORT_CONTROL_IP
static int pt_mbox(elxu_device_t *device, mbox_command_t *mboxcmd, uint32_t mboxcmdLength, void *inbuf, uint32_t inbufLength, void *outbuf, uint32_t outbufLength)
void os_bar_read32(void *ctx, uint32_t bar, uint32_t offset, uint32_t *pdata)
int elxu_lancer_set_loopback(elxu_device_t *device_p, const char *fname, int *type)
char * mbox_get_linkcfg_lancer_pt(elxu_device_t *device)
be_resources_v1 be_resources[1]
union mbox_common_iscsi_connection_update_t::@27 params
#define OPCODE_COMMON_GET_ACTIVE_PROFILE
uint32_t receive_frame_count
#define OPCODE_COMMON_MANAGE_FAT
char * mbox_get_linkcfg_skyhawk_pt(elxu_device_t *device)
uint32_t advertised_receive_buffer_to_buffer_credit
IOCTL_CMD_IOCTL_ELXU_MBOX ioctl structure.
#define MBOX_SUBSYSTEM_COMMON_ISCSI
uint32_t test_phase_result
uint32_t received_eofdti_count
int mbox_set_linkcfg_pt(elxu_device_t *device, char *config)
Set Link configuration.
uint32_t uint32_t physical_address_low
int elxu_ioctl_device(elxu_device_t *device, int req, void *arg)
Send an ioctl to a device.
void zfree(void *p)
Frees memory that has been allocated.
int is_lancer(elxu_device_t *device_p)
Return true IFF the HBA is a Lancer.
#define SLI4_PHYSDEV_CONTROL_DD
static uint8_t * elx_find_vpd(uint8_t *vpddata, uint32_t vpddata_length, const char *key)
uint32_t active_link_config_id
#define MBOX_RUN_BIU_DIAG
void os_cfg_read32(void *ctx, uint32_t offset, uint32_t *pdata)
#define OPCODE_COMMON_READ_FLASHROM
static int mbox_set_dport_mode(elxu_device_t *device, void *mqe, int mode, int enable)
uint32_t uint32_t link_type
#define FAT_OPERATION_RETRIEVE
int remove_vport(elxu_device_t *device_p, uint64_t wwnn, uint64_t wwpn, int targetFlag, int initiatorFlag)
#define CLP_LINKCFG_4X10G
CLP string used in the DMTF_CLP_CMD mailbox command.
#define INTERNAL_LOOPBACK
uint32_t receive_p_bsy_count
int mbox_get_dport_stats(elxu_device_t *device)
Issue Get dport stats mailbox command Create a GET_DPORT_STAT mailbox command.
int mbox_set_nv_mac_pt(elxu_device_t *device, int *macaddr)
int mbox_read_status(elxu_device_t *device, uint32_t clear_counter)
Issue read status mailbox command.
uint32_t uint8_t profile_description_string[MAX_DESCRIPTION]
int mbox_ext_fat(elxu_device_t *device, uint32_t opcode, void *mbox, uint32_t mboxLength)
Issue EFD mailbox command.
uint32_t uint32_t uint32_t response_length
uint32_t receive_sequence_count
#define CLP_LINKCFG_1X40G
uint32_t receive_kbyte_count
#define CLP_LINKCFG_2X10G_2X8G
uint32_t active_profile_id
uint32_t transmit_frame_count
sli4_profile_descriptor_t desc[0]
#define MBOX_ENTRY_LENGTH
int mbox_set_linkcfg_lancer_pt(elxu_device_t *device, char *config)
#define OPCODE_COMMON_GET_RECONFIG_LINK_INFO
union mbox_common_iscsi_set_tcp_parameters_t::@25 params
uint32_t cmd_buf_addr_high
#define OPCODE_COMMON_GET_PROFILE_CONFIG
int mbox_set_active_profile_pt(elxu_device_t *device, char *new_profile_id)
static int ocs_mbox(elxu_device_t *device, mbox_command_t *mboxcmd, uint32_t mboxcmdLength, void *inbuf, uint32_t inbufLength, void *outbuf, uint32_t outbufLength)
uint32_t received_dropped_no_available_xri_resources_count
void os_cfg_write32(void *ctx, uint32_t offset, uint32_t data)
void mbox_get_wwn_pt(int fd, uint8_t *wwnn, uint8_t *wwpn)
#define OPCODE_COMMON_ENABLE_DISABLE_PORT
#define FAT_OPERATION_QUERY
#define OCS_CONFIG_LINKCFG_4X1G
#define SLI4_SLIPORT_SEMAPHORE_SH
struct mbox_command_t::@1 request
#define MBOX_SUBSYSTEM_COMMON
#define OPCODE_COMMON_GET_FUNCTION_CONFIG
int mbox_manage_fat(elxu_device_t *device, uint32_t fat_operation, uint32_t read_log_offset, void *buffer, uint32_t bufferLength)
Issue COMMON_MANAGE_FAT mailbox commands.
int mbox_read_flashrom(elxu_device_t *device, uint32_t opcode, uint32_t optype, uint32_t offset, void *outbuf, uint32_t outbufLength)
Issue read flashrom mailbox command.
uint32_t resp_buf_addr_low
#define SLI4_SLIPORT_CONTROL
uint32_t resp_buf_addr_high
uint32_t primitive_sequence_error_count
uint32_t uint32_t valid_fields
uint32_t primitive_sequence_event_timeout_count
#define OCS_CONFIG_LINKCFG_2X16G
int is_skyhawk(elxu_device_t *device_p)
Return true IFF the HBA is a Skyhawk.
uint32_t resource_descriptor_count
struct mbox_command_t::@2 response
#define CLP_LINKCFG_2X16G
int mbox_sli4_init_pt(elxu_device_t *device)
#define SLI4_SLIPORT_SEMAPHORE_LAN
#define OPCODE_COMMON_WRITE_FLASHROM
uint32_t received_eofa_count
uint32_t flashrom_access_op_type
uint32_t elastic_buffer_overrun_error_count
char * elxu_device_get_value(elxu_device_t *device, char *key)
Return a property value for a device.
int mbox_read_link_status(elxu_device_t *device, int clof, int clrc)
Issue read link status mailbox command.
void os_bar_write32(void *ctx, uint32_t bar, uint32_t offset, uint32_t data)
uint32_t overall_test_result
char * mbox_get_linkcfg_pt(elxu_device_t *device)
Get Link configuration.
#define SLI4_PHYSDEV_CONTROL_FRST
#define OCS_CONFIG_LINKCFG_2X10G
static char * format_sli4_ip_address(uint32_t *address)
Given a 6-word IP address in the format specified in the SLI4 spec, return a printable IP address...
#define OPCODE_COMMON_SET_PROFILE_CONFIG
int mbox_get_active_profile_pt(elxu_device_t *device, char *result, int result_len)
OCS_IOCTL_CMD_VPORT ioctl structure.
int create_vport(elxu_device_t *device_p, uint64_t wwnn, uint64_t wwpn, int targetFlag, int initiatorFlag)
uint32_t next_link_config_id
static uint8_t * vpdref(vpdbuf_t *vpd)
uint32_t flashrom_access_op_code
union mbox_common_t::@3 word1
static mbox_linkcfg_map_t mbox_linkcfg_str[]
#define OPCODE_COMMON_SET_BE_CONFIGURATION_AND_RESOURCES
uint32_t transmit_sequence_count
int mbox_fw_reset_pt(elxu_device_t *device, int dd)
int mbox_diag_loopback_tests(elxu_device_t *device, int loopback_type, int retry_count)
Issue set link diag loopback mailbox command.
uint32_t transmit_kbyte_count
static uint32_t addr32_hi(uintptr_t addr)
void mbox_get_mac_pt(elxu_device_t *device, uint8_t *mac_addr)
uint32_t be_resources_iscsi_v1 resource_descriptor
uint32_t available_length
uint32_t start_profile_index
int mbox_write_flashrom(elxu_device_t *device, uint32_t opcode, uint32_t optype, uint32_t offset, void *inbuf, uint32_t inbufLength)
Issue write flashrom mailbox command.
struct mbox_common_iscsi_set_tcp_parameters_t::@25::@26 request
#define SLI4_PCI_SOFT_RESET_MASK
uint32_t current_transmit_buffer_to_buffer_credit
uint32_t returned_vpd_length
uint32_t received_eofni_count
uint32_t loss_of_sync_error_count
uint32_t physical_address_high
void elx_pt_dma_free(memref_t *memref)
Free a DMA allocation through elx_pt.
int elxu_lancer_run_loopback(elxu_device_t *device_p, const char *fname, int type)
int elxu_lancer_get_link_state(elxu_device_t *device_p, uint32_t *status)
elxu_device_driver_e driver
uint32_t current_receive_buffer_to_buffer_credit
#define EXTERNAL_LOOPBACK
uint32_t data_buffer_size
#define VPD_LARGE_RESOURCE_TYPE_W_TAG
#define CLP_LINKCFG_2X10G
uint32_t active_profile_id
int mbox_get_profile_list_pt(elxu_device_t *device, char *result, int result_len)
#define MBOX_GET_DPORT_RESULTS
uint32_t received_dropped_no_aer_count
#define OCS_CONFIG_LINKCFG_2X10G_2X8G
static uint32_t mbox_get_config_id_from_mgmt_str(char *mgmt_str)
Get the config ID from the mgmt config string.
struct mbox_common_iscsi_get_connection_info_t::@29::@31 response
uint32_t received_dropped_no_available_rpi_resources_count
#define MBOX_SUBSYSTEM_DMTF
fcoe_test_result_descriptor_t trd[6]
static int vpddone(vpdbuf_t *vpd)
#define SLI4_PHYSDEV_CONTROL
uint32_t receive_f_bsy_count
int mbox_get_connection_info(elxu_device_t *device, uint32_t connectionHandle)
Get connection info.
int mbox_get_serialnum_pt(elxu_device_t *device, char *serial_num, int serial_num_size)
int mbox_ioctl_common_set_be_configuration_and_resources(elxu_device_t *device, int *mac_addr)
Issue IOCTL_COMMON_SET_BE_CONFIGRATION_AND_RESOURCES command.
#define SLI4_PCI_SOFT_RESET_CSR
#define MBOX_READ_LNK_STAT