45 #if defined(OCS_INCLUDE_RAMD)
118 void *buf, uint32_t buf_len,
119 void *arg_out, uint32_t arg_out_length);
122 void *buf, uint32_t buf_len,
123 void *arg_out, uint32_t arg_out_length);
126 void *buf, uint32_t buf_len,
127 void *arg_out, uint32_t arg_out_length);
130 void *buf, uint32_t buf_len,
131 void *arg_out, uint32_t arg_out_length);
137 ocs_mgmt_ip_add(ocs_t *ocs,
char *,
void *, uint32_t ,
void *, uint32_t);
139 ocs_mgmt_ip_get(ocs_t *ocs,
char *,
void *, uint32_t ,
void *, uint32_t);
140 #if defined(OCS_INCLUDE_RAMD)
142 ocs_mgmt_read_phys(ocs_t *ocs,
char *,
void *, uint32_t ,
void *, uint32_t);
153 uint32_t arg_in_length,
void *arg_out, uint32_t arg_out_length);
161 uint32_t arg_in_len,
void *arg_out,
162 uint32_t arg_out_len);
165 uint32_t arg_in_len,
void *arg_out,
166 uint32_t arg_out_len);
169 void *arg_in, uint32_t arg_in_len,
170 void *arg_out, uint32_t arg_out_len);
173 void *arg_out, uint32_t arg_out_length);
176 void *arg_out, uint32_t arg_out_length);
179 void *arg_out, uint32_t arg_out_length);
182 #if defined(OCS_INCLUDE_RAMD)
183 static void* find_address_in_target(
ocs_ramdisc_t **ramdisc_array, uint32_t ramdisc_count, uintptr_t target_addr);
192 {
"sn",
get_sn, NULL, NULL},
193 {
"pn",
get_pn, NULL, NULL},
233 #if defined(OCS_INCLUDE_RAMD)
234 {
"read_phys", NULL, NULL, ocs_mgmt_read_phys},
283 for (i=0;i<ARRAY_SIZE(mgmt_table);i++) {
285 if (mgmt_table[i].get_handler) {
288 if (mgmt_table[i].set_handler) {
291 if (mgmt_table[i].action_handler) {
297 if ((ocs->mgmt_functions) && (ocs->mgmt_functions->get_list_handler)) {
298 ocs->mgmt_functions->get_list_handler(textbuf, ocs);
301 if ((ocs->tgt_mgmt_functions) && (ocs->tgt_mgmt_functions->get_list_handler)) {
302 ocs->tgt_mgmt_functions->get_list_handler(textbuf, &(ocs->tgt_ocs));
305 if ((ocs->domain->mgmt_functions) && (ocs->domain->mgmt_functions->get_list_handler)) {
306 ocs->domain->mgmt_functions->get_list_handler(textbuf, ocs->domain);
346 snprintf(qualifier,
sizeof(qualifier),
"/ocs");
349 if (ocs_strncmp(name, qualifier, strlen(qualifier)) == 0) {
350 char *unqualified_name = name + strlen(qualifier) + 1;
354 for (i=0;i<ARRAY_SIZE(mgmt_table);i++) {
355 if (ocs_strcmp(unqualified_name, mgmt_table[i].name) == 0) {
356 if (mgmt_table[i].get_handler) {
357 mgmt_table[i].
get_handler(ocs, mgmt_table[i].name, textbuf);
366 if ((ocs->mgmt_functions) && (ocs->mgmt_functions->get_handler)) {
367 retval = ocs->mgmt_functions->get_handler(textbuf, qualifier, name, ocs);
371 if ((ocs->tgt_mgmt_functions) && (ocs->tgt_mgmt_functions->get_handler)) {
372 retval = ocs->tgt_mgmt_functions->get_handler(textbuf, qualifier,
373 name, &(ocs->tgt_ocs));
381 if ((ocs->domain->mgmt_functions) && (ocs->domain->mgmt_functions->get_handler)) {
382 retval = ocs->domain->mgmt_functions->get_handler(textbuf, qualifier, name, ocs->domain);
398 ocs_domain_t *domain;
403 for (i=0;i<ARRAY_SIZE(mgmt_table);i++) {
404 if (mgmt_table[i].get_handler) {
406 }
else if (mgmt_table[i].action_handler) {
411 if ((ocs->mgmt_functions) && (ocs->mgmt_functions->get_all_handler)) {
412 ocs->mgmt_functions->get_all_handler(textbuf, ocs);
415 if ((ocs->tgt_mgmt_functions) && (ocs->tgt_mgmt_functions->get_all_handler)) {
416 ocs->tgt_mgmt_functions->get_all_handler(textbuf, &(ocs->tgt_ocs));
421 if ((domain->mgmt_functions) && (domain->mgmt_functions->get_all_handler)) {
422 domain->mgmt_functions->get_all_handler(textbuf, domain);
462 snprintf(qualifier,
sizeof(qualifier),
"/ocs");
465 if (ocs_strncmp(name, qualifier, strlen(qualifier)) == 0) {
466 char *unqualified_name = name + strlen(qualifier) +1;
469 for (i=0;i<ARRAY_SIZE(mgmt_table);i++) {
470 if (ocs_strcmp(unqualified_name, mgmt_table[i].name) == 0) {
471 if (mgmt_table[i].set_handler) {
472 return mgmt_table[i].
set_handler(ocs, mgmt_table[i].name, value);
477 if ((ocs->mgmt_functions) && (ocs->mgmt_functions->set_handler)) {
478 result = ocs->mgmt_functions->set_handler(qualifier, name, (
char *)value, ocs);
482 if ((ocs->tgt_mgmt_functions) && (ocs->tgt_mgmt_functions->set_handler)) {
483 result = ocs->tgt_mgmt_functions->set_handler(qualifier, name,
484 (
char *)value, &(ocs->tgt_ocs));
491 if ((ocs->domain->mgmt_functions) && (ocs->domain->mgmt_functions->set_handler)) {
492 result = ocs->domain->mgmt_functions->set_handler(qualifier, name, (
char*)value, ocs->domain);
530 ocs_mgmt_exec(ocs_t *ocs,
char *action,
void *arg_in, uint32_t arg_in_length,
void *arg_out, uint32_t arg_out_length)
536 snprintf(qualifier,
sizeof(qualifier),
"/ocs");
539 if (ocs_strncmp(action, qualifier, strlen(qualifier)) == 0) {
540 char *unqualified_name = action + strlen(qualifier) +1;
543 for (i=0;i<ARRAY_SIZE(mgmt_table); i++) {
544 if (ocs_strcmp(unqualified_name, mgmt_table[i].
name) == 0) {
545 if (mgmt_table[i].action_handler) {
546 return mgmt_table[i].
action_handler(ocs, action, arg_in, arg_in_length,
547 arg_out, arg_out_length);
553 if ((ocs->mgmt_functions) && (ocs->mgmt_functions->exec_handler)) {
554 result = ocs->mgmt_functions->exec_handler(qualifier, action, arg_in, arg_in_length,
555 arg_out, arg_out_length, ocs);
559 if ((ocs->tgt_mgmt_functions) && (ocs->tgt_mgmt_functions->exec_handler)) {
560 result = ocs->tgt_mgmt_functions->exec_handler(qualifier, action,
561 arg_in, arg_in_length, arg_out, arg_out_length,
569 if ((ocs->domain->mgmt_functions) && (ocs->domain->mgmt_functions->exec_handler)) {
570 result = ocs->domain->mgmt_functions->exec_handler(qualifier, action, arg_in, arg_in_length,
571 arg_out, arg_out_length, ocs->domain);
581 #if defined(OCS_INCLUDE_RAMD)
583 ocs_mgmt_read_phys(ocs_t *ocs,
char *
name,
void *arg_in, uint32_t arg_in_length,
void *arg_out, uint32_t arg_out_length)
587 uintptr_t target_addr;
590 uint32_t ramdisc_count;
593 if ((arg_in == NULL) ||
594 (arg_in_length == 0) ||
596 (arg_out_length == 0)) {
600 if (arg_in_length > 80) {
604 if (ocs_copy_from_user(addr_str, arg_in, arg_in_length)) {
605 ocs_log_test(ocs,
"Failed to copy addr from user\n");
609 target_addr = (uintptr_t)ocs_strtoul(addr_str, NULL, 0);
615 if (ocs->tgt_ocs.use_global_ramd) {
617 ramdisc_count = ocs->tgt_ocs.rdisc_count;
618 ramdisc_array = ocs->tgt_ocs.rdisc;
619 vaddr = find_address_in_target(ramdisc_array, ramdisc_count, target_addr);
622 for (sport_idx=0; sport_idx < ocs->iscsi.num_tgts; sport_idx++) {
623 ramdisc_count = ocs->sport[sport_idx].tgt_sport.rdisc_count;
624 ramdisc_array = ocs->sport[sport_idx].tgt_sport.rdisc;
625 vaddr = find_address_in_target(ramdisc_array, ramdisc_count, target_addr);
636 length = arg_out_length;
640 if (ocs_copy_to_user(arg_out, vaddr, length)) {
641 ocs_log_test(ocs,
"Failed to copy buffer to user\n");
658 #if defined(OCS_INCLUDE_RAMD)
659 static void* find_address_in_target(
ocs_ramdisc_t **ramdisc_array, uint32_t ramdisc_count, uintptr_t target_addr)
662 uint32_t ramdisc_idx;
665 for (ramdisc_idx=0; ramdisc_idx<ramdisc_count; ramdisc_idx++) {
666 uint32_t segment_idx;
668 rdisc = ramdisc_array[ramdisc_idx];
670 for (segment_idx=0; segment_idx<rdisc->
segment_count; segment_idx++) {
672 uintptr_t segment_start;
673 uintptr_t segment_end;
678 if ((target_addr >= segment_start) && (target_addr <= segment_end)) {
680 offset = target_addr - segment_start;
687 if ((target_addr >= segment_start) && (target_addr <= segment_end)) {
689 offset = target_addr - segment_start;
716 uint8_t bus, dev, func;
720 ocs_log_debug(ocs,
"Resetting port\n");
722 ocs_log_test(ocs,
"failed to reset port\n");
725 ocs_log_debug(ocs,
"successfully reset port\n");
734 uint8_t other_bus, other_dev, other_func;
738 if ((bus == other_bus) && (dev == other_dev)) {
748 #define FW_WRITE_BUFSIZE 64*1024
750 typedef struct ocs_mgmt_fw_write_result {
769 ocs_sem_init(&(result.
semaphore), 0,
"fw_write");
771 bytes_left = buf_len;
773 userp = (uint8_t *)buf;
776 ocs_log_err(ocs,
"ocs_mgmt_firmware_write: malloc failed");
780 while (bytes_left > 0) {
784 xfer_size = bytes_left;
788 if (ocs_copy_from_user(dma.virt, userp, xfer_size)) {
794 if (bytes_left == xfer_size) {
803 if (ocs_sem_p(&(result.
semaphore), OCS_SEM_FOREVER) != 0) {
805 ocs_log_test(ocs,
"ocs_sem_p failed\n");
811 ocs_log_test(ocs,
"actual_write_length is %d\n", result.
actual_xfer);
818 ocs_log_test(ocs,
"write returned status %d\n", result.
status);
828 ocs_dma_free(ocs, &dma);
844 typedef struct ocs_mgmt_get_profile_list_result {
884 ocs_sem_init(&(result.
semaphore), 0,
"get_profile_list");
887 if (ocs_sem_p(&(result.
semaphore), OCS_SEM_FOREVER) != 0) {
889 ocs_log_test(ocs,
"ocs_sem_p failed\n");
893 #define MAX_LINE_SIZE 520
894 #define BUFFER_SIZE MAX_LINE_SIZE*40
900 result_buf = ocs_malloc(ocs,
BUFFER_SIZE, OCS_M_ZERO);
906 if (strlen(result_line) < bytes_left) {
907 strcat(result_buf, result_line);
908 bytes_left -= strlen(result_line);
917 ocs_log_test(ocs,
"getting profile list status 0x%x\n", result.
status);
922 typedef struct ocs_mgmt_get_active_profile_result {
935 uint32_t *profile_id;
937 profile_id = (uint32_t *)params;
945 #define MAX_PROFILE_LENGTH 5
967 ocs_sem_init(&(result.
semaphore), 0,
"get_active_profile");
970 if (ocs_sem_p(&(result.
semaphore), OCS_SEM_FOREVER) != 0) {
972 ocs_log_test(ocs,
"ocs_sem_p failed\n");
979 ocs_log_test(ocs,
"getting active profile status 0x%x\n", result.
status);
984 typedef struct ocs_mgmt_set_active_profile_result {
1022 int32_t new_profile;
1024 new_profile = ocs_strtoul(value, NULL, 0);
1026 ocs_sem_init(&(result.
semaphore), 0,
"set_active_profile");
1030 if (ocs_sem_p(&(result.
semaphore), OCS_SEM_FOREVER) != 0) {
1032 ocs_log_test(ocs,
"ocs_sem_p failed\n");
1035 if (result.
status == 0) {
1040 ocs_log_test(ocs,
"setting active profile status 0x%x\n", result.
status);
1048 typedef struct ocs_mgmt_get_port_protocol_result {
1057 uint32_t ext_status,
1061 uint32_t *port_protocol;
1063 port_protocol = (uint32_t *)params;
1081 ocs_sem_init(&(result.
semaphore), 0,
"get_port_protocol");
1084 if (ocs_sem_p(&(result.
semaphore), OCS_SEM_FOREVER) != 0) {
1086 ocs_log_test(ocs,
"ocs_sem_p failed\n");
1088 if (result.
status == 0) {
1107 ocs_log_test(ocs,
"getting port profile status 0x%x\n",
1113 typedef struct ocs_mgmt_set_port_protocol_result {
1122 uint32_t ext_status,
1157 ocs_sem_init(&(result.
semaphore), 0,
"set_port_protocol");
1159 if (ocs_strcasecmp(value,
"iscsi") == 0) {
1161 }
else if (ocs_strcasecmp(value,
"fc") == 0) {
1163 }
else if (ocs_strcasecmp(value,
"fcoe") == 0) {
1171 if (ocs_sem_p(&(result.
semaphore), OCS_SEM_FOREVER) != 0) {
1173 ocs_log_test(ocs,
"ocs_sem_p failed\n");
1176 if (result.
status == 0) {
1181 ocs_log_test(ocs,
"setting active profile status 0x%x\n", result.
status);
1200 if (ocs_strcasecmp(value,
"false") == 0) {
1201 ocs->enable_jumbo_frame = FALSE;
1203 }
else if (ocs_strcasecmp(value,
"true") == 0) {
1204 ocs->enable_jumbo_frame = TRUE;
1207 ocs_log_test(ocs,
"Rejecting invalid jumbo_frames value '%s'\n", value);
1225 if (ocs_strcasecmp(value,
"false") == 0) {
1226 ocs->enable_data_digest = FALSE;
1228 }
else if (ocs_strcasecmp(value,
"true") == 0) {
1229 ocs->enable_data_digest = TRUE;
1232 ocs_log_test(ocs,
"Rejecting invalid data_digest value '%s'\n", value);
1250 if (ocs_strcasecmp(value,
"false") == 0) {
1251 ocs->enable_hdr_digest = FALSE;
1253 }
else if (ocs_strcasecmp(value,
"true") == 0) {
1254 ocs->enable_hdr_digest = TRUE;
1257 ocs_log_test(ocs,
"Rejecting invalid header_digest value '%s'\n", value);
1273 int32_t window_size;
1275 window_size = ocs_strtoul(value, NULL, 0);
1276 if ((window_size < 1) || (window_size > 65536)) {
1277 ocs_log_test(ocs,
"Rejecting invalid window_size %d\n", window_size);
1281 ocs->tcp_window_size = window_size;
1295 int32_t window_scale;
1297 window_scale = ocs_strtoul(value, NULL, 0);
1298 if ((window_scale < 0) || (window_scale > 14)) {
1299 ocs_log_test(ocs,
"Rejecting invalid window_scale %d\n", window_scale);
1303 ocs->tcp_window_scale = window_scale;
1319 max_cxns = ocs_strtoul(value, NULL, 0);
1320 if (max_cxns <= 0) {
1321 ocs_log_test(ocs,
"Rejecting invalid max_cxns_per_session %d\n", max_cxns);
1325 ocs->max_cxns_per_session = max_cxns;
1355 ocs_log_test(ocs,
"Rejecting invalid gateway IP address '%s'\n", value);
1368 ip_str,
sizeof(ip_str));
1369 ocs_log_debug(ocs,
"Added Gateway address %s\n", ip_str);
1371 ocs_log_test(ocs,
"setting gateway returned status %d\n", rc);
1390 if (ocs_strcasecmp(value,
"false") == 0) {
1391 ocs->require_chap = FALSE;
1393 }
else if (ocs_strcasecmp(value,
"true") == 0) {
1394 ocs->require_chap = TRUE;
1411 typedef struct ocs_mgmt_linkcfg_map_s {
1436 for (i = 0; i < ARRAY_SIZE(mgmt_linkcfg_map); i++) {
1437 if (ocs_strncmp(mgmt_linkcfg_map[i].mgmt_str,
1438 mgmt_str, ocs_strlen(mgmt_str)) == 0) {
1439 return mgmt_linkcfg_map[i].
linkcfg;
1456 for (i = 0; i < ARRAY_SIZE(mgmt_linkcfg_map); i++) {
1457 if (mgmt_linkcfg_map[i].linkcfg == linkcfg) {
1458 return mgmt_linkcfg_map[i].
mgmt_str;
1467 typedef struct ocs_mgmt_linkcfg_arg_s {
1474 typedef struct ocs_mgmt_get_linkcfg_result {
1483 uint32_t ext_status,
1511 const char *result_string;
1515 ocs_sem_init(&(result.
semaphore), 0,
"get_linkcfg");
1518 if (ocs_sem_p(&(result.
semaphore), OCS_SEM_FOREVER) != 0) {
1520 ocs_log_test(ocs,
"ocs_sem_p failed\n");
1522 if (result.
status == 0) {
1528 ocs_log_test(ocs,
"getting linkcfg status 0x%x\n", result.
status);
1533 typedef struct ocs_mgmt_set_linkcfg_result {
1542 uint32_t ext_status,
1570 ocs_log_test(ocs,
"undefined linkcfg type %s\n", value);
1574 ocs_sem_init(&(result.
semaphore), 0,
"set_linkcfg");
1578 if (ocs_sem_p(&(result.
semaphore), OCS_SEM_FOREVER) != 0) {
1580 ocs_log_test(ocs,
"ocs_sem_p failed\n");
1583 if (result.
status == 0) {
1588 ocs_log_test(ocs,
"setting link configuration status 0x%x\n", result.
status);
1598 uint32_t arg_in_length,
void *arg_out,
1599 uint32_t arg_out_length)
1605 int ip_found = FALSE;
1609 if (!ocs->enable_tgt) {
1611 ocs_log_info(ocs,
"Request not applicable in non-target mode\n");
1615 if (arg_in == NULL || !arg_in_length ||
1617 ocs_log_err(ocs,
"Invalid arguments list\n");
1622 if (ocs_copy_from_user(cmd_params, arg_in, arg_in_length)) {
1623 ocs_log_err(ocs,
"Copy from user failed\n");
1627 ip_str = cmd_params;
1635 ocs_log_test(ocs,
"Rejecting invalid listen IP address '%s'\n", ip_str);
1639 for (i=0; i<iscsi->
num_ips; i++) {
1646 ocs_log_test(ocs,
"already listening on IP %s\n", ip_str);
1655 ocs_log_debug(ocs,
"Listen server started on %s\n",
1659 ocs_log_test(ocs,
"listen returned status %d on %s\n",
1669 ocs_log_test(ocs,
"Can't listen on IP %s, IP not found\n", ip_str);
1678 void *arg_in, uint32_t arg_in_length,
1679 void *arg_out, uint32_t arg_out_length)
1685 int ip_found = FALSE;
1689 if (!ocs->enable_tgt) {
1691 ocs_log_info(ocs,
"Request not applicable in non-target mode\n");
1695 if (arg_in == NULL || !arg_in_length ||
1697 ocs_log_err(ocs,
"Invalid arguments list\n");
1702 if (ocs_copy_from_user(cmd_params, arg_in, arg_in_length)) {
1703 ocs_log_err(ocs,
"Copy from user failed\n");
1707 ip_str = cmd_params;
1715 ocs_log_test(ocs,
"Rejecting invalid listen IP address '%s'\n", ip_str);
1719 for (i=0; i<iscsi->
num_ips; i++) {
1728 ocs_log_test(ocs,
"failed Stopping Listen on IP %s\n",
1732 ocs_log_debug(ocs,
"Stopped Listening on IP %s\n", ip_str);
1737 ocs_log_test(ocs,
"Not listening on IP %s\n", ip_str);
1745 ocs_log_test(ocs,
"IP %s not found\n", ip_str);
1757 void *arg_out, uint32_t arg_out_length)
1765 char local_subnet[64];
1768 char vlan_id_str[32];
1776 ocs_log_test(ocs,
"Internal error - Max IPs already configured\n");
1780 if (arg_in == NULL || !arg_in_length ||
1782 ocs_log_err(ocs,
"Invalid IP add input arguments\n");
1787 if (ocs_copy_from_user(cmd_params, arg_in, arg_in_length)) {
1788 ocs_log_err(ocs,
"Copy from user buffer failed\n");
1795 slash = ocs_strchr(buf,
'/');
1796 if (slash == NULL) {
1797 ocs_log_test(ocs,
"Internal error - cannot split IP address and subnet\n");
1801 num_chars = slash - (
char*)buf;
1802 ocs_strncpy(local_ip, (
char*)buf, num_chars);
1803 local_ip[num_chars] =
'\0';
1807 slash = ocs_strchr(buf,
'/');
1808 if (slash == NULL) {
1809 ocs_log_test(ocs,
"Internal error - cannot split subnet\n");
1813 num_chars = slash - (
char *)buf;
1814 ocs_strncpy(local_subnet, (
char *)buf, num_chars);
1815 local_subnet[num_chars] =
'\0';
1818 num_chars = arg_in_length - (slash - cmd_params);
1819 ocs_strncpy(vlan_id_str, (
char *)slash, num_chars);
1820 vlan_id_str[num_chars] =
'\0';
1821 vlan_id = ocs_atoi(vlan_id_str);
1826 ocs_log_err(ocs,
"iSCSI portal is not exists for vlan_id %d\n",
1840 ocs_log_test(ocs,
"IPv4 address supplied, but subnet is not an valid IPv4 subnet\n");
1847 ocs_log_test(ocs,
"IPv6 address supplied, but subnet is not an valid IPv6 subnet\n");
1851 ocs_log_test(ocs,
"ERROR: Local address supplied is not a valid IPv4, IPv6, DHCP or AutoV6\n");
1857 ocs_log_debug(ocs,
"Added IP address %s mask %s\n",
1858 local_ip, local_subnet);
1860 ocs_log_err(ocs,
"Add IP failed status %d\n", rc);
1877 for (i = 0; i < iscsi->
num_ips; i++) {
1900 int32_t rc = -EFAULT;
1902 for (i = 0; i < iscsi->
num_ips; i++) {
1922 void *arg_out, uint32_t arg_out_length)
1935 char vlan_id_str[32];
1938 if (arg_in == NULL || !arg_in_length ||
1940 ocs_log_err(ocs,
"Invalid IP remove args list\n");
1945 ocs_log_debug(ocs,
"Internal error - No IPs configured\n");
1950 if (ocs_copy_from_user(cmd_params, arg_in, arg_in_length)) {
1951 ocs_log_err(ocs,
"Copy from user buffer failed\n");
1958 slash = ocs_strchr(buf,
'/');
1959 if (slash == NULL) {
1960 ocs_log_test(ocs,
"Internal error - cannot split IP address\n");
1964 num_chars = slash - (
char*)buf;
1965 ocs_strncpy(ipaddr, (
char*)buf, num_chars);
1966 ipaddr[num_chars] =
'\0';
1968 num_chars = arg_in_length - ((slash - (
char*)buf) + 1);
1969 ocs_strncpy(vlan_id_str, slash + 1, num_chars);
1970 vlan_id_str[num_chars] =
'\0';
1971 vlan_id = ocs_atoi(vlan_id_str);
1976 ocs_log_err(ocs,
"iSCSI portal is not exists for vlan_id %d\n",
1989 ocs_log_test(ocs,
"IP address supplied is not a valid IPv4, IPv6, DHCP or AutoV6\n");
1995 ocs_log_debug(ocs,
"IP addr %s is in listening mode\n", ipaddr);
2000 ocs_memset(&subnet, 0,
sizeof(subnet));
2002 ocs_log_debug(ocs,
"Subnet is not found for IP addr %s\n",
2010 ocs_log_debug(ocs,
"Removed IP address %s\n", (
char *)ipaddr);
2012 ocs_log_test(ocs,
"Remove IP failed status %d\n", rc);
2021 uint32_t *bytes_copied,
2027 char subnet_str[40];
2028 uint32_t remain = userbuff_len;
2030 uint32_t tot_bytes = 0;
2031 uint32_t bytes_to_copy;
2033 for (index = 0; index < num_ips; index++) {
2035 ipsub[index].ip_address,
2036 ip_str,
sizeof(ip_str));
2039 ipsub[index].subnet,
2040 subnet_str,
sizeof(subnet_str));
2042 len = ocs_strlen(ip_str);
2043 bytes_to_copy = (len > remain ? remain : len);
2044 if (ocs_copy_to_user(userbuff, ip_str, bytes_to_copy)) {
2047 userbuff += bytes_to_copy;
2048 remain -= bytes_to_copy;
2049 tot_bytes += bytes_to_copy;
2053 if (ocs_copy_to_user(userbuff,
" ", 1)) {
2062 len = ocs_strlen(subnet_str);
2063 bytes_to_copy = (len > remain ? remain : len);
2064 if (ocs_copy_to_user(userbuff, subnet_str, bytes_to_copy)) {
2067 userbuff += bytes_to_copy;
2068 remain -= bytes_to_copy;
2069 tot_bytes += bytes_to_copy;
2073 if (ocs_copy_to_user(userbuff,
"\n", 1)) {
2083 *bytes_copied = tot_bytes;
2092 void *arg_out, uint32_t arg_out_length)
2095 uint32_t userbuff_remain = 0;
2096 uint32_t bytes_copied = 0;
2102 uint32_t num_ips = 0;
2106 if (arg_in == NULL || arg_out == NULL ||
2107 (arg_in_length >
sizeof(ip_type))) {
2108 ocs_log_err(ocs,
"Invalid arguments list\n");
2112 if (ocs_copy_from_user(&ip_type, arg_in, arg_in_length)) {
2113 ocs_log_err(ocs,
"Copy from user failed\n");
2119 }
else if (ip_type == 6) {
2122 ocs_log_err(ocs,
"Invalid request of IP type %d\n", ip_type);
2127 OCS_M_ZERO | OCS_M_NOWAIT);
2128 if (ipsub == NULL) {
2129 ocs_log_err(ocs,
"Failed to allocate ipsub\n");
2133 userbuff = (
char *)arg_out;
2134 userbuff_remain = arg_out_length;
2139 OCS_MAX_IP, &num_ips, ipsub);
2141 ocs_log_err(ocs,
"Query IP's on default interface failed\n");
2146 snprintf(str,
sizeof(str),
"\nDefault interface\n");
2147 if (userbuff_remain > ocs_strlen(str)) {
2148 if (ocs_copy_to_user(userbuff, str, ocs_strlen(str))) {
2152 userbuff += ocs_strlen(str);
2153 userbuff_remain -= ocs_strlen(str);
2158 &bytes_copied, num_ips, ipsub);
2160 ocs_log_err(ocs,
"Failed to copy ip addresses to user buffer\n");
2164 userbuff += bytes_copied;
2165 userbuff_remain -= bytes_copied;
2167 snprintf(str,
sizeof(str),
"Empty\n");
2168 if (userbuff_remain > ocs_strlen(str)) {
2169 if (ocs_copy_to_user(userbuff, str, ocs_strlen(str))) {
2170 ocs_log_info(ocs,
"Copy to user failed\n");
2174 userbuff += ocs_strlen(str);
2175 userbuff_remain -= ocs_strlen(str);
2181 ocs_memset(ipsub, 0,
sizeof(*ipsub));
2184 snprintf(str,
sizeof(str),
"\nVLAN interface %d\n",
2186 if (userbuff_remain > ocs_strlen(str)) {
2187 if (ocs_copy_to_user(userbuff, str, ocs_strlen(str))) {
2188 ocs_log_err(ocs,
"Copy to user failed\n");
2192 userbuff += ocs_strlen(str);
2193 userbuff_remain -= ocs_strlen(str);
2198 OCS_MAX_IP, &num_ips, ipsub);
2200 ocs_log_err(ocs,
"Query IP's on iface handle %d failed\n",
2208 &bytes_copied, num_ips, ipsub);
2210 ocs_log_err(ocs,
"Failed to copy ip addresses to user buffer\n");
2214 userbuff += bytes_copied;
2215 userbuff_remain -= bytes_copied;
2217 snprintf(str,
sizeof(str),
"Empty\n");
2218 if (userbuff_remain >
sizeof(str)) {
2219 if (ocs_copy_to_user(userbuff, str, ocs_strlen(str))) {
2220 ocs_log_err(ocs,
"Copy to user failed\n");
2224 userbuff += ocs_strlen(str);
2225 userbuff_remain -= ocs_strlen(str);
2232 if (userbuff_remain > 1) {
2233 if (!ocs_copy_to_user(userbuff,
"\0", 1)) {
2244 uint32_t params_len,
char *ip_addr,
2245 char *netmask,
char *gateway)
2251 slash = ocs_strchr(cmd_params,
'/');
2252 if (slash == NULL) {
2253 ocs_log_err(ocs,
"Unexpected data in arg_in\n");
2257 num_chars = slash - (
char *)cmd_params;
2258 ocs_strncpy(ip_addr, (
char *)cmd_params, num_chars);
2259 ip_addr[num_chars] =
'\0';
2261 params = (
char *)(cmd_params + num_chars + 1);
2262 slash = ocs_strchr(params,
'/');
2263 if (slash == NULL) {
2264 ocs_log_err(ocs,
"Unexpected data in arg_in\n");
2268 num_chars = slash - params;
2269 ocs_strncpy(netmask, params, num_chars);
2270 netmask[num_chars] =
'\0';
2272 num_chars = params_len - ((slash - (
char *)cmd_params) + 1);
2273 ocs_strncpy(gateway, slash + 1, num_chars);
2274 gateway[num_chars] =
'\0';
2281 void *arg_in, uint32_t arg_in_len,
2282 void *arg_out, uint32_t arg_out_len)
2287 char cmd_params[256];
2294 if (arg_in == NULL) {
2295 ocs_log_err(ocs,
"Route del entry arg missing\n");
2299 if (ocs_copy_from_user(cmd_params, arg_in, arg_in_len)) {
2300 ocs_log_err(ocs,
"copy from user failed\n");
2305 ip_addr, netmask, gateway);
2307 ocs_log_err(ocs,
"route command params parse error\n");
2317 ocs_log_err(ocs,
"IPv4 address supplied, but subnet is not an valid IPv4 subnet\n");
2323 ocs_log_err(ocs,
"Gateway address supplied is not a valid IPv4 format\n");
2330 ocs_log_test(ocs,
"IPv6 address supplied, but subnet is not an valid IPv6 subnet\n");
2336 ocs_log_err(ocs,
"Gateway address supplied is not a valid IPv6 formate\n");
2340 ocs_log_test(ocs,
"ERROR: IP address supplied is not a valid IPv4/IPv6\n");
2345 ocs_log_err(ocs,
"Route table delete entry %s - %s/%s/%s\n",
2346 (rc ?
"failed" :
"successful"),
2347 ip_addr, netmask, gateway);
2354 void *arg_in, uint32_t arg_in_len,
2355 void *arg_out, uint32_t arg_out_len)
2360 char cmd_params[256];
2367 if (arg_in == NULL) {
2368 ocs_log_err(ocs,
"Route del entry arg missing\n");
2372 if (ocs_copy_from_user(cmd_params, arg_in, arg_in_len)) {
2373 ocs_log_err(ocs,
"copy from user failed\n");
2378 ip_addr, netmask, gateway);
2380 ocs_log_err(ocs,
"route command params parse error\n");
2390 ocs_log_err(ocs,
"IPv4 address supplied, but subnet is not an valid IPv4 subnet\n");
2396 ocs_log_err(ocs,
"Gateway address supplied is not a valid IPv4 format\n");
2403 ocs_log_test(ocs,
"IPv6 address supplied, but subnet is not an valid IPv6 subnet\n");
2409 ocs_log_err(ocs,
"Gateway address supplied is not a valid IPv6 formate\n");
2413 ocs_log_test(ocs,
"ERROR: IP address supplied is not a valid IPv4/IPv6\n");
2418 ocs_log_err(ocs,
"Route table add entry %s - %s/%s/%s\n",
2419 (rc ?
"failed" :
"successful"),
2420 ip_addr, netmask, gateway);
2427 void *arg_in, uint32_t arg_in_len,
2428 void *arg_out, uint32_t arg_out_len)
2430 int32_t rc = -EFAULT;
2434 ocs_log_err(ocs,
"Insufficient buffer %d, argoutlen %d\n",
2439 route_table = ocs_malloc(ocs,
sizeof(*route_table),
2440 OCS_M_ZERO | OCS_M_NOWAIT);
2441 if (route_table == NULL) {
2442 ocs_log_err(ocs,
"Failed to alloc\n");
2448 ocs_log_err(ocs,
"Get route table failed\n");
2449 ocs_free(ocs, route_table,
sizeof(*route_table));
2453 rc = ocs_copy_to_user(arg_out, route_table,
sizeof(*route_table));
2455 ocs_log_err(ocs,
"Copy to user failed\n");
2456 ocs_free(ocs, route_table,
sizeof(*route_table));
2460 ocs_log_debug(ocs,
"Get route table successful.\n");
2462 ocs_free(ocs, route_table,
sizeof(*route_table));
2474 void *buf, uint32_t buflen,
2475 void *argout, uint32_t argout_len)
2484 slash = ocs_strchr(buf,
'/');
2488 ctgt = ocs_malloc(ocs,
sizeof(*ctgt), OCS_M_NOWAIT|OCS_M_ZERO);
2490 ocs_log_err(ocs,
"Failed to allocate memory\n");
2494 memset(ctgt, 0,
sizeof(*ctgt));
2495 num_chars = slash - (
char *)buf;
2496 if (ocs_copy_from_user(ctgt->
tgt_name, buf, num_chars)) {
2497 ocs_log_err(ocs,
"Cluster target copy name from user failed\n");
2499 goto clusttgt_add_err;
2503 num_chars = buflen - ((slash - (
char *)buf) + 1);
2504 if (ocs_copy_from_user(ctgt->
tgt_addr, (slash + 1), num_chars)) {
2505 ocs_log_err(ocs,
"Cluster target copy addr from user failed\n");
2507 goto clusttgt_add_err;
2518 ocs_free(ocs, ctgt,
sizeof(*ctgt));
2532 void *buf, uint32_t buflen,
2533 void *arg_out, uint32_t arg_out_len)
2541 bool found_target =
false;
2545 ocs_log_debug(ocs,
"Cluster target list is empty\n");
2549 slash = ocs_strchr(buf,
'/');
2553 num_chars = slash - (
char *)buf;
2554 if (ocs_copy_from_user(tgtname, buf, num_chars)) {
2555 ocs_log_err(ocs,
"Cluster target copy name from user failed\n");
2559 tgtname[num_chars] =
'\0';
2560 num_chars = buflen - ((slash - (
char *)buf) + 1);
2561 if (ocs_copy_from_user(tgtaddr, (slash + 1), num_chars)) {
2562 ocs_log_err(ocs,
"Cluster target copy addr from user failed\n");
2566 tgtaddr[num_chars] =
'\0';
2571 found_target =
true;
2576 if (!found_target) {
2577 ocs_log_test(ocs,
"Target %s:%s not found\n", tgtname, tgtaddr);
2582 ocs_free(ocs, ctgt,
sizeof(*ctgt));
2597 void *buf, uint32_t buflen,
2598 void *arg_out, uint32_t arg_out_len)
2605 char *userp = (
char *)arg_out;
2611 ocs_log_debug(ocs,
"Cluster target list is empty\n");
2615 memset(buf_tmp, 0,
sizeof(buf_tmp));
2616 if (ocs_copy_from_user(buf_tmp, buf, buflen)) {
2617 ocs_log_err(ocs,
"Cluster target inx copy from user failed\n");
2621 inx = ocs_strtoul(buf_tmp, NULL, 10);
2630 if (inx >= ocs_atomic_read(&iscsi->
clusttgt.
cnt)) {
2631 ocs_log_debug(ocs,
"Cluster target index %d not found\n", inx);
2645 ocs_log_debug(ocs,
"Cluster target index %d not found\n", inx);
2649 len_tmp = snprintf(buf_tmp,
sizeof(buf_tmp),
"%s/%s",
2651 if (ocs_copy_to_user(userp, buf_tmp, len_tmp)) {
2653 "Cluster target copy failed\n");
2669 void *buf, uint32_t buf_len,
2670 void *arg_out, uint32_t arg_out_length)
2720 strncpy(sn_buf, (
char*)pserial, len);
2738 strncpy(sn_buf, (
char*)pserial, len);
2757 char *phy_port = NULL;
2779 uint32_t asic_gen_num;
2780 uint32_t asic_rev_num;
2782 char result_buf[80];
2785 family = (ocs_config_read32(ocs,
SLI4_INTF_REG) & 0x00000f00) >> 8;
2787 asic_rev_num = asic_id & 0xff;
2788 asic_gen_num = (asic_id & 0xff00) >> 8;
2795 ocs_strcpy(result_buf,
"BE2 A");
2796 ocs_snprintf(tmp_buf, 2,
"%d", rev_id);
2797 strcat(result_buf, tmp_buf);
2801 ocs_strcpy(result_buf,
"BE3");
2802 if (rev_id >= 0x10) {
2803 strcat(result_buf,
"-R");
2805 ocs_snprintf(tmp_buf, 3,
" %c", ((rev_id & 0xf0) >> 4) +
'A');
2806 strcat(result_buf, tmp_buf);
2807 ocs_snprintf(tmp_buf, 2,
"%d", rev_id & 0x0f);
2808 strcat(result_buf, tmp_buf);
2812 strcpy(result_buf,
"Skyhawk A0");
2816 strcpy(result_buf,
"Lancer A");
2817 ocs_snprintf(tmp_buf, 2,
"%d", rev_id & 0x0f);
2818 strcat(result_buf, tmp_buf);
2822 ocs_strcpy(result_buf,
"Lancer");
2823 ocs_snprintf(tmp_buf, 3,
" %c", ((rev_id & 0xf0) >> 4) +
'A');
2824 strcat(result_buf, tmp_buf);
2825 ocs_snprintf(tmp_buf, 2,
"%d", rev_id & 0x0f);
2826 strcat(result_buf, tmp_buf);
2830 switch(asic_gen_num) {
2832 strcpy(result_buf,
"BE2");
2835 strcpy(result_buf,
"BE3-R");
2838 strcpy(result_buf,
"Skyhawk-R");
2841 strcpy(result_buf,
"Corsair");
2844 strcpy(result_buf,
"Lancer");
2847 strcpy(result_buf,
"Unknown");
2849 if (ocs_strcmp(result_buf,
"Unknown") != 0) {
2850 ocs_snprintf(tmp_buf, 3,
" %c", ((asic_rev_num & 0xf0) >> 4) +
'A');
2851 strcat(result_buf, tmp_buf);
2852 ocs_snprintf(tmp_buf, 2,
"%d", asic_rev_num & 0x0f);
2853 strcat(result_buf, tmp_buf);
2857 strcpy(result_buf,
"Unknown");
2935 #define SFP_BYTES 256
2948 sprintf(d,
"%02x ", *s);
2967 sprintf(d,
"%02x ", *s);
3023 char mac_address[18];
3036 uint8_t mac_address[6];
3055 if (ocs_strcasecmp(value,
"false") == 0) {
3058 }
else if (ocs_strcasecmp(value,
"true") == 0) {
3073 if (ocs_strcasecmp(value,
"false") == 0) {
3076 }
else if (ocs_strcasecmp(value,
"true") == 0) {
3091 if (ocs_strcasecmp(value,
"false") == 0) {
3094 }
else if (ocs_strcasecmp(value,
"true") == 0) {
3109 if (ocs_strcasecmp(value,
"false") == 0) {
3112 }
else if (ocs_strcasecmp(value,
"true") == 0) {
3127 if (ocs_strcasecmp(value,
"false") == 0) {
3130 }
else if (ocs_strcasecmp(value,
"true") == 0) {
3145 if (ocs_strcasecmp(value,
"false") == 0) {
3148 }
else if (ocs_strcasecmp(value,
"true") == 0) {
3160 uint32_t arg_in_length,
void *arg_out,
3161 uint32_t arg_out_length)
3167 if (arg_in_length <= 3) {
3171 if (arg_in == NULL) {
3175 memset(&chap_user_buff, 0,
sizeof(chap_user_buff));
3176 if (ocs_copy_from_user(&chap_user_buff, arg_in,
sizeof(chap_user_buff))) {
3177 ocs_log_err(ocs,
"copy_from_user failed\n");
3182 chap_user_buff.
type, chap_user_buff.
mode);
3188 uint32_t arg_in_length,
void *arg_out,
3189 uint32_t arg_out_length)
3194 if (arg_in_length <= 0 || arg_in == NULL) {
3195 ocs_log_err(ocs,
"Insufficient input buffers\n");
3199 memset(&chap_user_buff, 0,
sizeof(chap_user_buff));
3200 if (ocs_copy_from_user(&chap_user_buff, arg_in,
sizeof(chap_user_buff))) {
3201 ocs_log_err(ocs,
"copy_from_user failed\n");
3206 chap_user_buff.
type,
3207 chap_user_buff.
mode);
3219 uint32_t arg_in_length,
void *arg_out, uint32_t arg_out_length)
3221 if (arg_in == NULL && arg_out == NULL) {
3225 if (arg_out == NULL || arg_out_length == 0) {
3226 ocs_log_err(ocs,
"Invalid output buffer\n");
3241 void *arg_out, uint32_t arg_out_length)
3243 uint32_t vlan_id = 0;
3245 int32_t rc = -EFAULT;
3247 if (arg_in == NULL || (arg_in_length <
sizeof(vlan_id))) {
3248 ocs_log_err(ocs,
"vlan_id buffer is missing\n");
3252 if (ocs_copy_from_user(&vlan_id, arg_in,
sizeof(vlan_id))) {
3253 ocs_log_err(ocs,
"copy from user failed\n");
3259 ocs_log_err(ocs,
"iSCSI portal is not exists for vlan id %d\n",
3269 ocs_log_err(ocs,
"Failed to remove IP addresses of iface %d\n",
3276 ocs_log_err(ocs,
"Delete iface failed\n");
3278 ocs_log_debug(ocs,
"Deleted IFACE handle %d of vlan id %d\n",
3279 portal_iface, vlan_id);
3286 ocs_log_err(ocs,
"Failed to delete portal\n");
3301 void *arg_out, uint32_t arg_out_length)
3303 uint32_t vlan_id = 0;
3305 int32_t rc = -EFAULT;
3307 if (arg_in == NULL || (arg_in_length <
sizeof(vlan_id))) {
3308 ocs_log_err(ocs,
"vlan_id buffer is missing\n");
3312 if (ocs_copy_from_user(&vlan_id, arg_in,
sizeof(vlan_id))) {
3313 ocs_log_err(ocs,
"copy from user failed\n");
3319 ocs_log_err(ocs,
"Create iface failed\n");
3321 ocs_log_debug(ocs,
"Created IFACE handle %d for vlan id %d\n",
3322 portal_iface, vlan_id);
3330 void *arg_out, uint32_t arg_out_length)
3332 int32_t ret = -EFAULT;
3334 if (arg_out == NULL) {
3335 ocs_log_err(ocs,
"Insufficient arg_out buffer\n");
3341 ocs_log_err(ocs,
"Failed to read vlan ids\n");
3349 static void ocs_mgmt_sli4_queue_status(
ocs_textbuf_t *textbuf,
const char *name,
3361 ocs_mgmt_status_hal(textbuf, &ocs->hal);
3371 ocs_t *ocs = hal->
os;
3378 ocs_mgmt_sli4_queue_status(textbuf,
"wq", hal->
wq, 1);
3379 ocs_mgmt_sli4_queue_status(textbuf,
"rq", hal->
rq, ARRAY_SIZE(hal->
rq));
3380 ocs_mgmt_sli4_queue_status(textbuf,
"mq", hal->
mq, ARRAY_SIZE(hal->
mq));
3381 ocs_mgmt_sli4_queue_status(textbuf,
"cq", hal->
cq, ARRAY_SIZE(hal->
cq));
3382 ocs_mgmt_sli4_queue_status(textbuf,
"eq", hal->
eq, ARRAY_SIZE(hal->
eq));
3393 for (i = 0; i < q_count; i ++, q ++) {
3395 ocs_mgmt_status_int(textbuf,
"index",
"%d", q->
index);
3396 ocs_mgmt_status_int(textbuf,
"size",
"%d", q->
size);
3397 ocs_mgmt_status_int(textbuf,
"length",
"%d", q->
length);
3398 ocs_mgmt_status_int(textbuf,
"n_posted",
"%d", q->
n_posted);
3399 ocs_mgmt_status_int(textbuf,
"id",
"%d", q->
id);
3400 ocs_mgmt_status_int(textbuf,
"type",
"%d", q->
type);
3401 ocs_mgmt_status_int(textbuf,
"limit",
"%d", q->limit);
structure for storing VLAN id and interface handle together
#define OCS_CONFIG_LINKCFG_4X10G
linkcfg strings
static int set_mac_address(ocs_t *, char *, char *)
static int32_t ocs_iscsi_get_subnet_ip_address(ocs_iscsi_t *iscsi, ocs_hal_portal_t portal, ocs_ip_address_t *subnet, ocs_ip_address_t *ip)
static void get_sn(ocs_t *, char *, ocs_textbuf_t *)
static void get_header_digest(ocs_t *, char *, ocs_textbuf_t *)
ocs_hal_linkcfg_e linkcfg
static int32_t ocs_iscsi_ip_get_copy_to_user(ocs_t *ocs, char *userbuff, uint32_t userbuff_len, uint32_t *bytes_copied, uint32_t num_ips, ocs_ip_address_subnet_t *ipsub)
int32_t ocs_hal_get_active_profile(ocs_hal_t *hal, mgmt_cb_t cb, void *ul_arg)
Get the currently active profile.
ocs_t * ocs_get_instance(uint32_t index)
Returns a pointer to the ocs structure given the instance index.
static void get_max_sge_size(ocs_t *, char *, ocs_textbuf_t *)
ocs_mgmt_action_func action_handler
static void get_debug_io_trace(ocs_t *, char *, ocs_textbuf_t *)
#define OCS_DEBUG_ENABLE_MQ_DUMP
int ocs_mgmt_get(ocs_t *ocs, char *name, ocs_textbuf_t *textbuf)
return the value of a mgmt item
void ocs_iscsi_cluster_tgts_free(ocs_iscsi_t *iscsi)
iscsi cluster targets free
#define OCS_DEBUG_ENABLE_SM_TRACE
int32_t parse_mac_address(const char *src, uint8_t *dest)
Parse a string into a MAC address.
ocs_mgmt_set_func set_handler
int32_t ocs_iscsi_mtu_set(ocs_t *ocs, uint8_t is_jumbo)
Sets the TCP MTU size of the iSCSI device.
int32_t ocs_iscsi_find_portal_from_vlan(ocs_t *ocs, uint32_t vlan_id, ocs_hal_portal_t *iface_handle)
Helper function to find respective interface handle of VLAN id.
static void get_tcp_window_size(ocs_t *, char *, ocs_textbuf_t *)
void ocs_mgmt_emit_int(ocs_textbuf_t *textbuf, int mode, const char *name, const char *fmt,...)
Generate a property with an integer value in a management XML document.
int32_t ocs_hal_get_linkcfg(ocs_hal_t *hal, mgmt_cb_t cb, void *ul_arg)
Get the current link configuration.
static int set_max_cxns_per_session(ocs_t *, char *, char *)
#define OCS_CONFIG_LINKCFG_1X40G
static void get_pci_vendor(ocs_t *, char *, ocs_textbuf_t *)
static void get_driver_version(ocs_t *, char *, ocs_textbuf_t *)
ocs_hal_rtn_e ocs_hal_set_linkcfg(ocs_hal_t *hal, mgmt_cb_t cb, ocs_hal_linkcfg_e value, void *ul_arg)
Set the link configuration (Skyhawk only).
static void get_jumbo_frames(ocs_t *, char *, ocs_textbuf_t *)
char profile_description[512]
ocs_mgmt_get_func get_handler
static void get_pn(ocs_t *, char *, ocs_textbuf_t *)
int ocs_mgmt_set(ocs_t *ocs, char *name, char *value)
set the value of a mgmt item
static void get_debug_sm_trace(ocs_t *, char *, ocs_textbuf_t *)
static int set_require_chap(ocs_t *, char *, char *)
static int set_tcp_window_size(ocs_t *, char *, char *)
static int32_t ocs_mgmt_iclusttgt_entry_get(ocs_t *ocs, char *name, void *buf, uint32_t buf_len, void *arg_out, uint32_t arg_out_length)
ocs_hal_rtn_e ocs_hal_set_active_profile(ocs_hal_t *hal, mgmt_cb_t cb, uint32_t profile_id, void *ul_arg)
Set the currently active profile.
static void get_debug_wq_dump(ocs_t *, char *, ocs_textbuf_t *)
int ocs_mgmt_exec(ocs_t *ocs, char *action, void *arg_in, uint32_t arg_in_length, void *arg_out, uint32_t arg_out_length)
perform a management action
void format_mac_address(uint8_t *address, char *buffer, int size)
Format a MAC address into a string.
int32_t ocs_iscsi_listen_start(ocs_t *ocs, ocs_ip_address_t *ip, uint16_t tcp_port)
Starts a TCP listen socket.
static int32_t ocs_mgmt_ip_remove(ocs_t *ocs, char *, void *, uint32_t, void *, uint32_t)
#define OCS_CONFIG_LINKCFG_4X8G
void ocs_iscsi_ipsub_combine(ocs_ip_address_subnet_t *ipsub, ocs_ip_address_t *ip, ocs_ip_address_t *subnet)
Combines an iSCSI IP address and subnet into the combined structure.
static int32_t ocs_mgmt_vlan_del(ocs_t *ocs, char *name, void *arg_in, uint32_t arg_in_length, void *arg_out, uint32_t arg_out_length)
Delete VLAN will actually deletes the interface handle of vlan This function first removes the IP add...
int32_t ocs_iscsi_chap_user_del(ocs_t *ocs, char *username, uint32_t type, uint32_t mode)
Delete CHAP user.
static void ocs_mgmt_get_linkcfg_cb(void *ul_arg, int32_t status, uint32_t ext_status, void *params)
static void ocs_device_lock(ocs_t *ocs)
#define OCS_DEBUG_ENABLE_SCSI_TGT_TRACE
static int32_t ocs_mgmt_chap_show_list(ocs_t *ocs, char *name, void *arg_in, uint32_t arg_in_length, void *arg_out, uint32_t arg_out_length)
Copy the chap_list to user supplied buffer.
static void get_max_cxns_per_session(ocs_t *, char *, ocs_textbuf_t *)
#define OCS_ISCSI_MGMT_CMD_PARAMS_LEN
static int set_port_protocol(ocs_t *, char *, char *)
Set port profile.
static void get_enable_ini(ocs_t *, char *, ocs_textbuf_t *)
static int32_t ocs_mgmt_route_table_add_entry(ocs_t *ocs, char *name, void *arg_in, uint32_t arg_in_len, void *arg_out, uint32_t arg_out_len)
void ocs_mgmt_start_unnumbered_section(ocs_textbuf_t *textbuf, const char *name)
Generate the beginning of an unnumbered section in a management XML document.
ramdisc instance structure
static void get_sfp_a0(ocs_t *, char *, ocs_textbuf_t *)
ramdisc segment structure
void ocs_mgmt_start_section(ocs_textbuf_t *textbuf, const char *name, int index)
Generate the beginning of a numbered section in a management XML document.
int const char const char void ocs_mgmt_emit_boolean(ocs_textbuf_t *textbuf, int access, const char *name, const int value)
Generate a property with a boolean value in a management XML document.
static void get_local_subnet(ocs_t *, char *, ocs_textbuf_t *)
uint32_t ocs_hal_portal_t
static int32_t ocs_mgmt_listen_start(ocs_t *ocs, char *, void *, uint32_t, void *, uint32_t)
static int32_t ocs_mgmt_iclusttgt_clear(ocs_t *ocs, char *name, void *buf, uint32_t buf_len, void *arg_out, uint32_t arg_out_length)
#define SLI4_ASIC_ID_REG
ASIC_ID - SLI ASIC Type and Revision Register.
uint32_t active_profile_id
ocs_hal_port_protocol_e
Port protocols.
ocs_hal_profile_descriptor_t descriptors[OCS_HAL_MAX_PROFILES]
static void ocs_mgmt_set_active_profile_cb(void *ul_arg, int32_t status, uint32_t ext_status, void *params)
static void * ocs_list_remove(ocs_list_t *list, void *item)
Remove an item from the list.
static void get_enable_tgt(ocs_t *, char *, ocs_textbuf_t *)
void ocs_iscsi_uninitialize(ocs_iscsi_t *iscsi)
Indicate that HAL is not initialized.
static int set_debug_wq_dump(ocs_t *, char *, char *)
static void get_require_chap(ocs_t *, char *, ocs_textbuf_t *)
void ocs_mgmt_get_list(ocs_t *ocs, ocs_textbuf_t *textbuf)
get a list of mgmt items supported by the driver
int32_t ocs_iscsi_route_table_read(ocs_t *ocs, ocs_route_table_t *route_table)
static void get_desc(ocs_t *, char *, ocs_textbuf_t *)
uint8_t * ocs_iscsi_mac_get(ocs_t *ocs)
Gets the MAC address of the iSCSI device.
sli4_queue_t rq[OCS_HAL_MAX_NUM_RQ]
#define OCS_CONFIG_LINKCFG_UNKNOWN
ocs_hal_rtn_e ocs_hal_reset(ocs_hal_t *hal, ocs_hal_reset_e reset)
void ocs_mgmt_get_all(ocs_t *ocs, ocs_textbuf_t *textbuf)
int32_t ocs_iscsi_chap_user_add(ocs_t *ocs, char *username, char *secret, uint32_t type, uint32_t mode)
Add CHAP user. If CHAP user of same type is already exists, return error.
static int32_t ocs_mgmt_iclusttgt_entry_del(ocs_t *ocs, char *name, void *buf, uint32_t buf_len, void *arg_out, uint32_t arg_out_length)
static int set_data_digest(ocs_t *, char *, char *)
sli4_queue_t eq[OCS_HAL_MAX_NUM_EQ]
static void get_chip_type(ocs_t *, char *, ocs_textbuf_t *)
int32_t ocs_iscsi_listen_stop(ocs_t *ocs, ocs_ip_address_t *ip, uint16_t tcp_port)
Stops a TCP listen socket.
static void get_port_protocol(ocs_t *, char *, ocs_textbuf_t *)
static void get_fw_rev(ocs_t *, char *, ocs_textbuf_t *)
ocs_hal_portal_t ocs_iscsi_portal_get_default(ocs_t *ocs)
Retrieves the default portal.
int32_t ocs_iscsi_ip_address_remove(ocs_t *ocs, ocs_hal_portal_t portal, ocs_ip_address_subnet_t *ipsub)
Remove the IP address to the specified interface.
ramdisc_segment_t ** segments
#define ocs_list_foreach_safe(list, item, nxt)
Iterate a linked list safely.
void ocs_mgmt_end_unnumbered_section(ocs_textbuf_t *textbuf, const char *name)
Generate the end of a section in a management XML document.
static void get_pci_device(ocs_t *, char *, ocs_textbuf_t *)
static int32_t ocs_mgmt_vlan_add(ocs_t *ocs, char *name, void *arg_in, uint32_t arg_in_length, void *arg_out, uint32_t arg_out_length)
Add VLAN tag will actually creates an interface along with VLAN ID Rule 1: Cannot set VLAN on default...
static void ocs_device_unlock(ocs_t *ocs)
static int32_t ocs_mgmt_iclusttgt_entry_add(ocs_t *ocs, char *name, void *buf, uint32_t buf_len, void *arg_out, uint32_t arg_out_length)
static void get_phy_port_num(ocs_t *, char *, ocs_textbuf_t *)
#define MAX_PROFILE_LENGTH
static int32_t ocs_iscsi_is_ipaddr_listening(ocs_iscsi_t *iscsi, ocs_hal_portal_t portal, ocs_ip_address_t *ip)
int32_t ocs_iscsi_ip_address_query(ocs_t *ocs, ocs_hal_portal_t portal, ocs_ip_type_e ip_type, uint32_t max_entries, uint32_t *num_ips, ocs_ip_address_subnet_t *ipsub)
Queries the IP addresses on the default interface.
ocs_hal_linkcfg_e
Link configurations.
static int ocs_mgmt_firmware_write(ocs_t *ocs, char *, void *buf, uint32_t buf_len, void *, uint32_t)
#define OCS_CLUST_TARGET_KEY_RETCNT
#define OCS_CONFIG_LINKCFG_4X1G
void ocs_mgmt_end_section(ocs_textbuf_t *textbuf, const char *name, int index)
Generate the indexed end of a section in a management XML document.
ocs_hal_portal_t iface_handle
ocs_hal_profile_list_t * list
#define OCS_DEBUG_ENABLE_CQ_DUMP
static void get_local_ip(ocs_t *, char *, ocs_textbuf_t *)
static int32_t ocs_mgmt_route_table_read(ocs_t *ocs, char *name, void *arg_in, uint32_t arg_in_len, void *arg_out, uint32_t arg_out_len)
static ocs_mgmt_linkcfg_map_t mgmt_linkcfg_map[]
static void get_profile_list(ocs_t *, char *, ocs_textbuf_t *)
Get list of profiles.
static void get_sfp_a2(ocs_t *, char *, ocs_textbuf_t *)
static int32_t ocs_mgmt_vlan_show(ocs_t *ocs, char *name, void *arg_in, uint32_t arg_in_length, void *arg_out, uint32_t arg_out_length)
static void get_fw_rev2(ocs_t *, char *, ocs_textbuf_t *)
#define OCS_DEBUG_ENABLE_IO_TRACE
int32_t ocs_iscsi_chap_list_count(ocs_t *ocs)
Returns the count of chap_list.
static int set_debug_io_trace(ocs_t *, char *, char *)
static void get_enable_sgl_chaining(ocs_t *, char *, ocs_textbuf_t *)
static int set_tcp_window_scale(ocs_t *, char *, char *)
static void get_debug_cq_dump(ocs_t *, char *, ocs_textbuf_t *)
static void get_num_tgts(ocs_t *, char *, ocs_textbuf_t *)
static int set_active_profile(ocs_t *, char *, char *)
Set active profile.
static void get_active_profile(ocs_t *, char *, ocs_textbuf_t *)
Get active profile.
int32_t ocs_iscsi_portal_del_vlan(ocs_t *ocs, ocs_hal_portal_t iface)
Delete iface handle and VLAN from portal_list.
#define OCS_CONFIG_LINKCFG_2X16G
static ocs_hal_linkcfg_e ocs_hal_linkcfg_from_mgmt(const char *mgmt_str)
Get the HAL linkcfg enum from the mgmt config string.
ocs_hal_rtn_e ocs_hal_get_profile_list(ocs_hal_t *hal, mgmt_cb_t mgmt_cb, void *ul_arg)
Get a list of available profiles.
int32_t ocs_iscsi_portal_delete(ocs_t *ocs, ocs_hal_portal_t portal)
Removes a previously-created portal.
static int set_debug_cq_dump(ocs_t *, char *, char *)
int32_t ocs_iscsi_portal_read_vlan_ids(ocs_t *ocs, void *arg_out, uint32_t arg_out_length)
Read VLAN IDs to provided buffer.
static int32_t ocs_mgmt_ip_add(ocs_t *ocs, char *, void *, uint32_t, void *, uint32_t)
static void ocs_mgmt_get_active_profile_cb(void *ul_arg, int32_t status, uint32_t ext_status, void *params)
int32_t ocs_iscsi_gateway_set(ocs_t *ocs, ocs_ip_address_t *gateway)
Sets the IP gateway address.
static void get_tcp_window_scale(ocs_t *, char *, ocs_textbuf_t *)
int32_t ocs_iscsi_mac_set(ocs_t *ocs, uint8_t *mac_address)
Sets the MAC address of the iSCSI device.
static int set_debug_sm_trace(ocs_t *, char *, char *)
static void ocs_list_add_tail(ocs_list_t *list, void *item)
Add an item to the tail of the list.
static void ocs_mgmt_set_linkcfg_cb(void *ul_arg, int32_t status, uint32_t ext_status, void *params)
This structure is used to track the SLI4 queues.
structure wrapping an IP address and subnet together with their type.
#define OCS_CONFIG_LINKCFG_2X10G
void format_ip_address(ocs_ip_type_e ip_type, uint8_t *address, char *buffer, int size)
Format an IP address into a string.
ocs_iscsi_cluster_sendtargets_t clusttgt
static void get_debug_mq_dump(ocs_t *, char *, ocs_textbuf_t *)
ocs_hal_linkcfg_e config_id
static int set_debug_scsi_tgt_trace(ocs_t *, char *, char *)
#define SLI4_INTF_REG
SLI_INTF - SLI Interface Definition Register.
static void get_gateway(ocs_t *, char *, ocs_textbuf_t *)
int32_t ocs_iscsi_portal_remove_ip_addresses(ocs_t *ocs, ocs_hal_portal_t iface_handle)
Check and remove IP addresses of the corresponding interface.
#define SLI4_PCI_CLASS_REVISION
static int set_gateway(ocs_t *, char *, char *)
ocs_ip_type_e
enum identifying the types of IP addresses.
static void get_businfo(ocs_t *, char *, ocs_textbuf_t *)
static void get_mac_address(ocs_t *, char *, ocs_textbuf_t *)
static int set_linkcfg(ocs_t *, char *, char *)
Set linkcfg config value.
int32_t ocs_iscsi_chap_list_get(ocs_t *ocs, char *userbuf, int32_t buflen)
Return CHAP list items.
void ocs_debug_enable(uint32_t mask)
enable debug options
static void get_data_digest(ocs_t *, char *, ocs_textbuf_t *)
ocs_hal_port_protocol_e port_protocol
static void ocs_mgmt_set_port_protocol_cb(void *ul_arg, int32_t status, uint32_t ext_status, void *params)
static int set_debug_mq_dump(ocs_t *, char *, char *)
static void get_linkcfg(ocs_t *, char *, ocs_textbuf_t *)
Get current link configuration.
static void get_pci_subsystem_device(ocs_t *, char *, ocs_textbuf_t *)
int32_t ocs_iscsi_ip_address_add(ocs_t *ocs, ocs_hal_portal_t portal, ocs_ip_address_subnet_t *ipsub)
Adds the IP address to the specified interface.
static const char * ocs_mgmt_from_hal_linkcfg(ocs_hal_linkcfg_e linkcfg)
Get the mgmt string value from the HAL linkcfg enum.
int32_t ocs_get_bus_dev_func(ocs_t *ocs, uint8_t *bus, uint8_t *dev, uint8_t *func)
int32_t ocs_iscsi_route_table_del_entry(ocs_t *ocs, ocs_ip_address_subnet_t *ipsub, ocs_ip_address_t *gateway)
Deletes an entry from a routing table.
ocs_hal_rtn_e ocs_hal_set_port_protocol(ocs_hal_t *hal, uint32_t pci_func, ocs_hal_port_protocol_e new_protocol, mgmt_cb_t cb, void *ul_arg)
Set the port protocol.
static void get_debug_scsi_tgt_trace(ocs_t *, char *, ocs_textbuf_t *)
int ocs_debug_is_enabled(uint32_t mask)
return true if debug bits are enabled
Link configuration callback argument.
int32_t ocs_iscsi_inet_pton4(const char *src, ocs_ip_address_t *ip)
Converts an IPv4 address from a string to the IP structure.
static void get_asic_id_reg(ocs_t *, char *, ocs_textbuf_t *)
void ocs_textbuf_reset(ocs_textbuf_t *textbuf)
int32_t ocs_hal_get_port_protocol(ocs_hal_t *hal, uint32_t pci_func, mgmt_cb_t cb, void *ul_arg)
Get the current port protocol.
static int32_t ocs_mgmt_ip_get(ocs_t *ocs, char *, void *, uint32_t, void *, uint32_t)
#define ocs_assert(cond,...)
#define OCS_MAX_ISCSI_NAME
#define OCS_ISCSI_TCP_PORT
ocs_iscsi_tgt_ip_t * ip_info
int32_t ocs_iscsi_inet_pton6(const char *src, ocs_ip_address_t *ip)
Converts an IPv6 address from a string to the IP structure.
static void ocs_mgmt_fw_write_cb(int32_t status, uint32_t actual_write_length, void *arg)
static void ocs_mgmt_get_profile_list_cb(void *ul_arg, int32_t status, uint32_t ext_status, void *params)
int32_t ocs_iscsi_portal_create(ocs_t *ocs, unsigned int vlan_id, ocs_hal_portal_t *portal)
Creates a portal for a VLAN.
void * ocs_hal_get_ptr(ocs_hal_t *hal, ocs_hal_property_e prop)
HAL link config enum to mgmt string value mapping.
static void ocs_mgmt_get_port_protocol_cb(void *ul_arg, int32_t status, uint32_t ext_status, void *params)
static int32_t ocs_mgmt_chap_add_user(ocs_t *ocs, char *, void *, uint32_t, void *, uint32_t)
void ocs_mgmt_emit_string(ocs_textbuf_t *textbuf, int access, const char *name, const char *value)
Generate a property with a string value in a management XML document.
#define ocs_list_foreach(list, item)
Iterate a linked list.
static void get_pci_subsystem_vendor(ocs_t *, char *, ocs_textbuf_t *)
structure wrapping an IP address together with it's type.
static void get_sli4_intf_reg(ocs_t *, char *, ocs_textbuf_t *)
char tgt_name[OCS_MAX_ISCSI_NAME]
static int set_header_digest(ocs_t *, char *, char *)
static void get_ipl(ocs_t *, char *, ocs_textbuf_t *)
static int32_t ocs_mgmt_chap_remove_user(ocs_t *ocs, char *, void *, uint32_t, void *, uint32_t)
void * ocs_scsi_get_property_ptr(ocs_t *ocs, ocs_scsi_property_e prop)
return a property pointer.
ocs_hal_linkcfg_e linkcfg
#define OCS_CONFIG_LINKCFG_2X10G_2X8G
static int ocs_mgmt_firmware_reset(ocs_t *ocs, char *, void *buf, uint32_t buf_len, void *, uint32_t)
ocs_mgmt_table_entry_t mgmt_table[]
static int32_t ocs_mgmt_listen_stop(ocs_t *ocs, char *, void *, uint32_t, void *, uint32_t)
int32_t ocs_iscsi_route_table_add_entry(ocs_t *ocs, ocs_ip_address_subnet_t *ipsub, ocs_ip_address_t *gateway)
Adds an entry to a routing table.
void ocs_mgmt_emit_property_name(ocs_textbuf_t *textbuf, int access, const char *name)
Generate a property, with no value, in a management XML document.
void ocs_debug_disable(uint32_t mask)
disable debug options
static int set_jumbo_frames(ocs_t *, char *, char *)
ocs_hal_rtn_e ocs_hal_firmware_write(ocs_hal_t *hal, ocs_dma_t *dma, uint32_t size, uint32_t offset, int last, ocs_hal_fw_cb_t cb, void *arg)
Write a portion of a firmware image to the device.
#define OCS_DEBUG_ENABLE_WQ_DUMP
static int32_t ocs_mgmt_route_parse_params(ocs_t *ocs, char *cmd_params, uint32_t params_len, char *ip_addr, char *netmask, char *gateway)
static int32_t ocs_mgmt_route_table_del_entry(ocs_t *ocs, char *name, void *arg_in, uint32_t arg_in_len, void *arg_out, uint32_t arg_out_len)