37 #include <sys/types.h>
41 #include <sys/types.h>
42 #include <sys/ioctl.h>
65 void *ret = malloc (len);
100 void dump8 (
const char *label,
void *buffer, uint32_t bufferLength)
103 uint8_t *pbuf = (uint8_t*) buffer;
104 const uint32_t columns = 16;
109 printf (
"%s\n", label);
112 nremaining = bufferLength;
113 while (nremaining > 0) {
114 n =
min(columns, nremaining);
117 for (i = 0; i < n; i ++) {
118 printf (
"%02X ", pbuf[i]);
121 for (; i < columns; i ++) {
125 for (i = 0; i < n; i ++) {
126 printf (
"%c", isprint (pbuf[i]) ? pbuf[i] :
'.');
129 for (; i < columns; i ++) {
166 printf(
"[%d] ", devname.
devidx);
211 uint32_t fabemu_enable, phy_port;
216 printf(
" modeldesc: %s\n", modeldesc);
228 printf(
" Physical Port number: %d\n", phy_port);
231 printf(
" fwrev: %s\n", fwrev);
234 printf(
" IPL: %s\n ", ipl);
237 printf(
" s/n: %s\n", serialnum);
240 printf(
" Physical NUMA Node: %s\n", physnuma);
243 printf(
" NUMA Map: %s", numamap);
246 printf(
" Fabric Emul:%s Enabled\n", (fabemu_enable & 0x100) ?
"" :
" Not");
256 if (num_sports > 1) {
257 printf(
" Additional vports:\n");
258 for (i = 1; i <= num_sports; i++) {
262 sprintf(buf,
"/ocs/domain[0]/sport[%d]/wwnn", i);
264 if (strlen(nn) > 0) {
265 wwn = strtoull(nn, NULL, 0);
267 printf(
" wwnn: %s\n", fmtwwn);
270 sprintf(buf,
"/ocs/domain[0]/sport[%d]/wwpn", i);
272 if (strlen(nn) > 0) {
273 wwn = strtoull(nn, NULL, 0);
275 printf(
" wwpn: %s\n", fmtwwn);
289 static char* family_names[] = {
290 "BE2",
"Unknown",
"Unknown",
"BE3-R",
291 "Skyhawk-R",
"Corsair",
"Talon",
"Unknown",
292 "Unknown",
"Unknown",
"Unknown",
"Lancer",
293 "Lancer G6",
"Unknown",
"Unknown",
"See ASIC_ID",
298 printf(
" PCI bus address: %s\n", device_p->
bus_addr);
299 printf(
" ASIC ID: 0x%04x\n", device_p->
asic_id);
300 printf(
" SLI_INTF: 0x%08x\n", device_p->
sli_intf);
301 sli_family = ((device_p->
sli_intf & 0xf00) >> 8);
302 printf(
" SLI_FAMILY: 0x%02x (%s)\n", sli_family, family_names[sli_family]);
303 printf(
" fwrev: %s\n", device_p->
fwrev);
304 printf(
" s/n: %s\n", device_p->
serialnum);
308 if (
is_fc(device_p)) {
339 rc = sscanf(wwn_in,
"%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx",
340 &byte0, &byte1, &byte2, &byte3,
341 &byte4, &byte5, &byte6, &byte7);
344 *wwn_out = ((uint64_t)byte0 << 56) |
345 ((uint64_t)byte1 << 48) |
346 ((uint64_t)byte2 << 40) |
347 ((uint64_t)byte3 << 32) |
348 ((uint64_t)byte4 << 24) |
349 ((uint64_t)byte5 << 16) |
350 ((uint64_t)byte6 << 8) |
372 sprintf(result,
"%02llx:%02llx:%02llx:%02llx:%02llx:%02llx:%02llx:%02llx",
373 ((wwn_in & 0xff00000000000000ll) >> 56),
374 ((wwn_in & 0x00ff000000000000ll) >> 48),
375 ((wwn_in & 0x0000ff0000000000ll) >> 40),
376 ((wwn_in & 0x000000ff00000000ll) >> 32),
377 ((wwn_in & 0x00000000ff000000ll) >> 24),
378 ((wwn_in & 0x0000000000ff0000ll) >> 16),
379 ((wwn_in & 0x000000000000ff00ll) >> 8),
380 ((wwn_in & 0x00000000000000ffll)));
382 return strdup(result);
403 static char result[80];
412 for (i = 0; i < size; i++) {
413 sprintf(buf,
"%02x ", value[i]);
439 static char result[2048];
446 while (isprint(*s)) {
450 if ((d-result) >= 2048) {
484 return "iSCSI/NIC ARM Firmware";
486 return "FCoE/NIC ARM Firmware";
488 return "Compressed iSCSI/NIC Firmware";
490 return "Compressed FCoE/NIC Firmware";
492 return "Backup iSCSI/NIC Firmware";
494 return "Backup FCoE/NIC Firmware";
496 return "Backup Compressed iSCSI/NIC Firmware";
498 return "Backup Compressed FCoE/NIC Firmware";
502 return "Binary NCSI Firmware";
504 return "ISM and Jump Vectors";
508 return "Jump Vectors";
510 return "PHY Firmware";
512 return "Redboot Directory";
514 return "Redboot Configuration";
516 return "UFI Directory";
540 #define NODERESULT 40
546 static const char *cmd =
"cat /sys/devices/system/node";
547 static const char *port_cmd =
"for i in $(pgrep ocs:); do ps -mo psr -p $i --no-heading | grep -v '-'; done ";
548 static const char *nnode_cmd =
"ls /sys/devices/system/node/ 2> /dev/null | grep node";
562 int port_cpu_cnt = 0;
565 if ((ptr = popen(nnode_cmd,
"r")) != NULL) {
566 while (fgets(buf, BUFSIZ, ptr) != NULL) {
567 strncpy(numa_node_list[nnode_cnt], buf,
NODELEN);
574 if (nnode_cnt == 0 ) {
575 snprintf(result, 6,
"n/a");
576 return strdup(result);
579 for (loop_node = 0; loop_node < nnode_cnt; loop_node++) {
580 ret_val = snprintf(nnode_list,
sizeof nnode_list,
"%s/%s%d/%s",cmd,
"node", loop_node,
"cpulist");
585 if ((ptr = popen(nnode_list,
"r")) != NULL) {
586 while (fgets(buf, BUFSIZ, ptr) != NULL){
594 for (i = 0; buf[i] !=
'\0'; i++) {
597 while (cpu_val < atoi(&buf[i+1])) {
598 cpu_list[cpu_cnt] = ++cpu_val;
603 }
else if (buf[i] ==
',') {
606 if (isalnum(buf[i])) {
607 cpu_list[cpu_cnt] = atoi(&buf[i]);
608 cpu_val = cpu_list[cpu_cnt];
616 if ((ptr = popen(port_cmd,
"r")) != NULL) {
618 while (fgets(buf, BUFSIZ, ptr) != NULL) {
619 port_cpu_list[port_cpu_cnt] = atoi(buf);
627 port_cpu_cnt = device_port;
629 for (k = 0; k < cpu_cnt; k++) {
630 if (cpu_list[k] == port_cpu_list[port_cpu_cnt]) {
631 snprintf(result, 20,
"cpu%d:%s", port_cpu_list[port_cpu_cnt],
632 numa_node_list[loop_node]);
640 return strdup(result);
666 static char device_buff[
DEVBUFF];
671 for (device_inst = 0; bus_addr[device_inst] !=
'\0'; device_inst++) {
672 if (path_id != 1 || (bus_addr[device_inst] !=
':')) {
673 device_id[device_inst] = bus_addr[device_inst];
674 if(bus_addr[device_inst] ==
':') {
680 snprintf(node_path,
sizeof(node_path)-1,
"/sys/class/pci_bus/%s/device/%s/numa_node", device_id, bus_addr);
682 fp = fopen(node_path,
"r");
684 res = fscanf(fp,
"%7s", device_buff);
686 snprintf(device_buff,
DEVBUFF,
"n/a");
690 snprintf(device_buff,
DEVBUFF,
"n/a");
693 return strdup(device_buff);
const char * elxu_get_vendor_name(elxu_device_t *device)
Return the vendor name for a device.
char * elxu_get_modeldesc(elxu_device_t *device)
Return the model description for a device.
char * trimmed_string(uint8_t *string)
Trim trailing non-printable characters from a string.
int is_fc(elxu_device_t *device_p)
Return true IFF the HBA is a FC HBA.
int parse_wwn(char *wwn_in, uint64_t *wwn_out)
Parse a WWN from a string into a 64-bit value.
void elxu_display_device_list(char *hostname)
Display the list of available devices.
char * get_physical_numa_node(char *bus_addr)
Return the physical Numa Node location for an OCS port .
char * elxu_get_ipl(elxu_device_t *device)
Return the IPL version for a device.
device name specifier This structure is used to describe the type and name of the device ioctl connec...
void * zmalloc(uint32_t len)
Allocates and zeroes memory to be used.
char * format_wwn(uint64_t wwn_in)
Format a 64-bit WWN for printing.
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.
const char * elxu_get_subsystem_vendor(elxu_device_t *device)
Return the PCI subsystem vendor value for a device.
char * elxu_get_serialnumber(elxu_device_t *device)
Return the serial number for a device.
const char * elxu_get_device_name(elxu_device_t *device)
Return the device name for a device.
char * decode_entry_type(uint32_t entry_type)
Return the name of a UFI entry type.
uint32_t elxu_get_phy_port_num(elxu_device_t *device)
Return the physical port number for a device.
elxu_device_t * elxu_device_by_index(int index)
Return a pointer to a device given an index.
int is_nic(elxu_device_t *device_p)
Return true IFF the HBA is a NIC HBA.
char * elxu_device_get_value(elxu_device_t *device, char *key)
Return a property value for a device.
static void hba_list_info_pt(elxu_device_t *device_p)
elxu_device_t * elxu_open_device(elxu_device_name_t *devname)
Open a device file.
int is_iscsi(elxu_device_t *device_p)
Return true IFF the HBA is an iSCSI HBA.
void elxu_close_device(elxu_device_t *device)
Close a device.
static void hba_list_info_ocs(elxu_device_t *device_p)
char * elxu_get_fwrev(elxu_device_t *device)
Return the firmware revision for a device.
void dump8(const char *label, void *buffer, uint32_t bufferLength)
Print a buffer in hexadecimal and ASCII.
elxu_device_driver_e driver
char * hex_dump(uint8_t *value, int size)
Display a buffer in hexadecimal.
const char * elxu_get_subsystem_device(elxu_device_t *device)
Return the PCI subsystem device value for a device.
char * get_numa_node_map(uint32_t device_port)
Return a string of cpu to numa node mapping .
void elxu_hba_list_info(elxu_device_t *device_p)
Displays HBA List information.