Lines Matching full:ocs

32 #include "ocs.h"
56 ocs_firmware_write(ocs_t *ocs, const uint8_t *buf, size_t buf_len, uint8_t *change_status);
73 struct ocs_softc *ocs = arg; in __ocs_ioctl_mbox_cb() local
76 mtx_lock(&ocs->dbg_lock); in __ocs_ioctl_mbox_cb()
78 mtx_unlock(&ocs->dbg_lock); in __ocs_ioctl_mbox_cb()
86 ocs_process_sli_config (ocs_t *ocs, ocs_ioctl_elxu_mbox_t *mcmd, ocs_dma_t *dma) in ocs_process_sli_config() argument
100 if (ocs_dma_alloc(ocs, dma, mcmd->out_bytes, 4096)) { in ocs_process_sli_config()
101 device_printf(ocs->dev, "%s: COMMON_READ_OBJECT - %lld allocation failed\n", in ocs_process_sli_config()
119 if (ocs_dma_alloc(ocs, dma, wrobj->desired_write_length, 4096)) { in ocs_process_sli_config()
120 device_printf(ocs->dev, "%s: COMMON_WRITE_OBJECT - %d allocation failed\n", in ocs_process_sli_config()
133 device_printf(ocs->dev, "%s: COMMON_WRITE_OBJECT - copyin failed: %d\n", in ocs_process_sli_config()
135 ocs_dma_free(ocs, dma); in ocs_process_sli_config()
147 if (ocs_dma_alloc(ocs, dma, mcmd->out_bytes, 4096)) { in ocs_process_sli_config()
148 device_printf(ocs->dev, "%s: COMMON_READ_OBJECT_LIST - %lld allocation failed\n", in ocs_process_sli_config()
164 device_printf(ocs->dev, "%s: in=%p (%lld) out=%p (%lld)\n", __func__, in ocs_process_sli_config()
167 device_printf(ocs->dev, "%s: unknown (opc=%#x)\n", __func__, in ocs_process_sli_config()
174 if (ocs_dma_alloc(ocs, dma, max_bytes, 4096)) { in ocs_process_sli_config()
175 device_printf(ocs->dev, "%s: non-embedded - %u allocation failed\n", in ocs_process_sli_config()
182 device_printf(ocs->dev, "%s: non-embedded - copyin failed: %d\n", in ocs_process_sli_config()
184 ocs_dma_free(ocs, dma); in ocs_process_sli_config()
197 ocs_process_mbx_ioctl(ocs_t *ocs, ocs_ioctl_elxu_mbox_t *mcmd) in ocs_process_mbx_ioctl() argument
206 device_printf(ocs->dev, "%s: malformed command m=%08x s=%08x\n", in ocs_process_mbx_ioctl()
213 if (ENXIO == ocs_process_sli_config(ocs, mcmd, &dma)) in ocs_process_mbx_ioctl()
223 device_printf(ocs->dev, "command %d\n",((sli4_mbox_command_header_t *)mcmd->payload)->command); in ocs_process_mbx_ioctl()
224 device_printf(ocs->dev, "%s, command not support\n", __func__); in ocs_process_mbx_ioctl()
246 mtx_lock(&ocs->dbg_lock); in ocs_process_mbx_ioctl()
247 if (ocs_hw_command(&ocs->hw, mcmd->payload, OCS_CMD_NOWAIT, in ocs_process_mbx_ioctl()
248 __ocs_ioctl_mbox_cb, ocs)) { in ocs_process_mbx_ioctl()
249 device_printf(ocs->dev, "%s: command- %x failed\n", __func__, in ocs_process_mbx_ioctl()
252 msleep(ocs, &ocs->dbg_lock, 0, "ocsmbx", 0); in ocs_process_mbx_ioctl()
253 mtx_unlock(&ocs->dbg_lock); in ocs_process_mbx_ioctl()
261 ocs_dma_free(ocs, &dma); in ocs_process_mbx_ioctl()
272 * @param ocs pointer to ocs structure
279 ocs_process_ecd_helper (ocs_t *ocs, ocs_ioctl_ecd_helper_t *req) in ocs_process_ecd_helper() argument
295 device_printf(ocs->dev, "Error: bar %d out of range\n", req->bar); in ocs_process_ecd_helper()
298 if (ocs->reg[req->bar].res == NULL) { in ocs_process_ecd_helper()
299 device_printf(ocs->dev, "Error: bar %d not defined\n", req->bar); in ocs_process_ecd_helper()
309 v8 = ocs_config_read8(ocs, req->offset); in ocs_process_ecd_helper()
313 v16 = ocs_config_read16(ocs, req->offset); in ocs_process_ecd_helper()
317 v32 = ocs_config_read32(ocs, req->offset); in ocs_process_ecd_helper()
321 ocs_config_write8(ocs, req->offset, req->data); in ocs_process_ecd_helper()
324 ocs_config_write16(ocs, req->offset, req->data); in ocs_process_ecd_helper()
327 ocs_config_write32(ocs, req->offset, req->data); in ocs_process_ecd_helper()
330 req->data = ocs_reg_read8(ocs, req->bar, req->offset); in ocs_process_ecd_helper()
333 req->data = ocs_reg_read16(ocs, req->bar, req->offset); in ocs_process_ecd_helper()
336 req->data = ocs_reg_read32(ocs, req->bar, req->offset); in ocs_process_ecd_helper()
339 ocs_reg_write8(ocs, req->bar, req->offset, req->data); in ocs_process_ecd_helper()
342 ocs_reg_write16(ocs, req->bar, req->offset, req->data); in ocs_process_ecd_helper()
345 ocs_reg_write32(ocs, req->bar, req->offset, req->data); in ocs_process_ecd_helper()
348 device_printf(ocs->dev, "Invalid helper command=%d\n", req->cmd); in ocs_process_ecd_helper()
359 struct ocs_softc *ocs = cdev->si_drv1; in ocs_ioctl() local
360 device_t dev = ocs->dev; in ocs_ioctl()
366 status = ocs_process_mbx_ioctl(ocs, mcmd); in ocs_ioctl()
372 status = ocs_process_ecd_helper(ocs, req); in ocs_ioctl()
381 domain = ocs_domain_get_instance(ocs, req->domain_index); in ocs_ioctl()
383 device_printf(ocs->dev, "domain [%d] nod found\n", in ocs_ioctl()
393 rc = ocs_sport_vport_del(ocs, domain, req->wwpn, req->wwnn); in ocs_ioctl()
405 if (ocs_textbuf_alloc(ocs, &textbuf, req->user_buffer_len)) { in ocs_ioctl()
406 device_printf(ocs->dev, "Error: ocs_textbuf_alloc failed\n"); in ocs_ioctl()
421 if (ocs_textbuf_initialized(&ocs->ddump_saved)) { in ocs_ioctl()
422 ptbuf = &ocs->ddump_saved; in ocs_ioctl()
425 if (ocs_textbuf_alloc(ocs, &textbuf, req->user_buffer_len)) { in ocs_ioctl()
426 ocs_log_err(ocs, "Error: ocs_textbuf_alloc failed\n"); in ocs_ioctl()
449 if (ocs_ddump(ocs, &textbuf, flags, req->args.q_entries) != 0) { in ocs_ioctl()
459 ocs_log_test(ocs, "ocs_ddump failed\n"); in ocs_ioctl()
478 ocs_log_test(ocs, "Error: (%d) ocs_copy_to_user failed\n", __LINE__); in ocs_ioctl()
486 ocs_textbuf_free(ocs, &textbuf); in ocs_ioctl()
492 ocs_clear_saved_ddump(ocs); in ocs_ioctl()
495 ocs_log_err(ocs, "Error: ocs_textbuf_alloc failed\n"); in ocs_ioctl()
505 req->pci_vendor = ocs->pci_vendor; in ocs_ioctl()
506 req->pci_device = ocs->pci_device; in ocs_ioctl()
507 ocs_strncpy(req->businfo, ocs->businfo, sizeof(req->businfo)); in ocs_ioctl()
509 req->sli_intf = ocs_config_read32(ocs, SLI4_INTF_REG); in ocs_ioctl()
511 ocs_strncpy(req->fw_rev, ocs->fwrev, sizeof(req->fw_rev)); in ocs_ioctl()
512 if (ocs->domain && ocs->domain->sport) { in ocs_ioctl()
513 *((uint64_t*)req->hw_addr.fc.wwnn) = ocs_htobe64(ocs->domain->sport->wwnn); in ocs_ioctl()
514 *((uint64_t*)req->hw_addr.fc.wwpn) = ocs_htobe64(ocs->domain->sport->wwpn); in ocs_ioctl()
516 ocs_strncpy(req->serialnum, ocs->serialnum, sizeof(req->serialnum)); in ocs_ioctl()
525 if (ocs_textbuf_alloc(ocs, &textbuf, req->user_buffer_len)) { in ocs_ioctl()
526 ocs_log_err(ocs, "Error: ocs_textbuf_alloc failed\n"); in ocs_ioctl()
530 ocs_mgmt_get_list(ocs, &textbuf); in ocs_ioctl()
536 ocs_log_test(ocs, "Error: (%d) ocs_copy_to_user failed\n", __LINE__); in ocs_ioctl()
541 ocs_textbuf_free(ocs, &textbuf); in ocs_ioctl()
554 if (ocs_textbuf_alloc(ocs, &textbuf, req->user_buffer_len)) { in ocs_ioctl()
555 ocs_log_err(ocs, "Error: ocs_textbuf_alloc failed\n"); in ocs_ioctl()
559 ocs_mgmt_get_all(ocs, &textbuf); in ocs_ioctl()
565 ocs_log_err(ocs, "Error: ocs_textbuf_alloc failed\n"); in ocs_ioctl()
571 ocs_textbuf_free(ocs, &textbuf); in ocs_ioctl()
583 ocs_log_test(ocs, "ocs_copy_from_user failed\n"); in ocs_ioctl()
584 ocs_ioctl_free(ocs, req, sizeof(ocs_ioctl_cmd_get_t)); in ocs_ioctl()
589 if (ocs_textbuf_alloc(ocs, &textbuf, req->value_length)) { in ocs_ioctl()
590 ocs_log_err(ocs, "Error: ocs_textbuf_alloc failed\n"); in ocs_ioctl()
594 ocs_mgmt_get(ocs, name, &textbuf); in ocs_ioctl()
600 ocs_log_test(ocs, "Error: (%d) ocs_copy_to_user failed\n", __LINE__); in ocs_ioctl()
605 ocs_textbuf_free(ocs, &textbuf); in ocs_ioctl()
617 ocs_log_test(ocs, "Error: copy from user failed\n"); in ocs_ioctl()
618 ocs_ioctl_free(ocs, req, sizeof(*req)); in ocs_ioctl()
624 ocs_log_test(ocs, "Error: copy from user failed\n"); in ocs_ioctl()
625 ocs_ioctl_free(ocs, req, sizeof(*req)); in ocs_ioctl()
629 req->result = ocs_mgmt_set(ocs, name, value); in ocs_ioctl()
639 ocs_log_test(ocs, "Error: copy req.name from user failed\n"); in ocs_ioctl()
640 ocs_ioctl_free(ocs, req, sizeof(*req)); in ocs_ioctl()
644 req->result = ocs_mgmt_exec(ocs, action_name, req->arg_in, req->arg_in_length, in ocs_ioctl()
651 ocs_log_test(ocs, "Error: unknown cmd %#lx\n", cmd); in ocs_ioctl()
672 ocs_firmware_write(ocs_t *ocs, const uint8_t *buf, size_t buf_len, in ocs_firmware_write() argument
688 if (ocs_dma_alloc(ocs, &dma, FW_WRITE_BUFSIZE, 4096)) { in ocs_firmware_write()
689 ocs_log_err(ocs, "ocs_firmware_write: malloc failed\n"); in ocs_firmware_write()
706 ocs_hw_firmware_write(&ocs->hw, &dma, xfer_size, offset, in ocs_firmware_write()
727 ocs_dma_free(ocs, &dma); in ocs_firmware_write()
737 ocs_t *ocs = (ocs_t *)arg1; in ocs_sys_fwupgrade() local
747 device_printf(ocs->dev, "Unable to get Firmware. " in ocs_sys_fwupgrade()
758 device_printf(ocs->dev, in ocs_sys_fwupgrade()
765 if (!strncmp(ocs->fw_version, fw_image->revision, in ocs_sys_fwupgrade()
767 device_printf(ocs->dev, "No update req. " in ocs_sys_fwupgrade()
773 device_printf(ocs->dev, "Upgrading Firmware from %s to %s \n", in ocs_sys_fwupgrade()
774 ocs->fw_version, fw_image->revision); in ocs_sys_fwupgrade()
776 rc = ocs_firmware_write(ocs, fw->data, fw->datasize, &fw_change_status); in ocs_sys_fwupgrade()
778 ocs_log_err(ocs, "Firmware update failed with status = %d\n", rc); in ocs_sys_fwupgrade()
780 ocs_log_info(ocs, "Firmware updated successfully\n"); in ocs_sys_fwupgrade()
783 device_printf(ocs->dev, in ocs_sys_fwupgrade()
787 device_printf(ocs->dev, in ocs_sys_fwupgrade()
793 device_printf(ocs->dev, in ocs_sys_fwupgrade()
798 ocs_log_warn(ocs, in ocs_sys_fwupgrade()
817 ocs_t *ocs = oidp->oid_arg1; in ocs_sysctl_wwnn() local
821 ocs_xport_t *xport = ocs->xport; in ocs_sysctl_wwnn()
829 wwnn = ocs_hw_get_ptr(&ocs->hw, OCS_HW_WWN_NODE); in ocs_sysctl_wwnn()
849 return (set_req_wwnn(ocs, NULL, new)); in ocs_sysctl_wwnn()
856 ocs_t *ocs = oidp->oid_arg1; in ocs_sysctl_wwpn() local
860 ocs_xport_t *xport = ocs->xport; in ocs_sysctl_wwpn()
867 wwpn = ocs_hw_get_ptr(&ocs->hw, OCS_HW_WWN_PORT); in ocs_sysctl_wwpn()
886 return (set_req_wwpn(ocs, NULL, new)); in ocs_sysctl_wwpn()
892 ocs_t *ocs = oidp->oid_arg1; in ocs_sysctl_current_topology() local
895 ocs_hw_get(&ocs->hw, OCS_HW_TOPOLOGY, &value); in ocs_sysctl_current_topology()
903 ocs_t *ocs = oidp->oid_arg1; in ocs_sysctl_current_speed() local
906 ocs_hw_get(&ocs->hw, OCS_HW_LINK_SPEED, &value); in ocs_sysctl_current_speed()
915 ocs_t *ocs = oidp->oid_arg1; in ocs_sysctl_config_topology() local
920 ocs_hw_get(&ocs->hw, OCS_HW_CONFIG_TOPOLOGY, &old_value); in ocs_sysctl_config_topology()
937 rc = set_configured_topology(ocs, NULL, buf); in ocs_sysctl_config_topology()
945 ocs_t *ocs = oidp->oid_arg1; in ocs_sysctl_config_speed() local
950 ocs_hw_get(&ocs->hw, OCS_HW_LINK_CONFIG_SPEED, &old_value); in ocs_sysctl_config_speed()
967 rc = set_configured_speed(ocs, NULL,buf); in ocs_sysctl_config_speed()
974 ocs_t *ocs = oidp->oid_arg1; in ocs_sysctl_fcid() local
978 if (ocs->domain && ocs->domain->attached) { in ocs_sysctl_fcid()
980 ocs->domain->sport->fc_id); in ocs_sysctl_fcid()
993 ocs_t *ocs = (ocs_t *)arg1; in ocs_sysctl_port_state() local
995 ocs_xport_status(ocs->xport, OCS_XPORT_CONFIG_PORT_STATUS, &old); in ocs_sysctl_port_state()
1014 ocs_log_debug(ocs, "Setting port to %s\n", new); in ocs_sysctl_port_state()
1015 rc = ocs_xport_control(ocs->xport, OCS_XPORT_PORT_OFFLINE); in ocs_sysctl_port_state()
1017 ocs_log_err(ocs, "Setting port to offline failed\n"); in ocs_sysctl_port_state()
1023 ocs_log_debug(ocs, "Setting port to %s\n", new); in ocs_sysctl_port_state()
1024 rc = ocs_xport_control(ocs->xport, OCS_XPORT_PORT_ONLINE); in ocs_sysctl_port_state()
1026 ocs_log_err(ocs, "Setting port to online failed\n"); in ocs_sysctl_port_state()
1029 ocs_log_err(ocs, "Unsupported link state %s\n", new); in ocs_sysctl_port_state()
1066 * @param ocs pointer to ocs
1070 ocs_sysctl_init(ocs_t *ocs) in ocs_sysctl_init() argument
1072 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(ocs->dev); in ocs_sysctl_init()
1073 struct sysctl_oid *tree = device_get_sysctl_tree(ocs->dev); in ocs_sysctl_init()
1082 pci_get_devid(ocs->dev), "Device ID"); in ocs_sysctl_init()
1084 memset(ocs->modeldesc, 0, sizeof(ocs->modeldesc)); in ocs_sysctl_init()
1085 if (0 == pci_get_vpd_ident(ocs->dev, &str)) { in ocs_sysctl_init()
1086 snprintf(ocs->modeldesc, sizeof(ocs->modeldesc), "%s", str); in ocs_sysctl_init()
1090 ocs->modeldesc, in ocs_sysctl_init()
1093 memset(ocs->serialnum, 0, sizeof(ocs->serialnum)); in ocs_sysctl_init()
1094 if (0 == pci_get_vpd_readonly(ocs->dev, "SN", &str)) { in ocs_sysctl_init()
1095 snprintf(ocs->serialnum, sizeof(ocs->serialnum), "%s", str); in ocs_sysctl_init()
1099 ocs->serialnum, in ocs_sysctl_init()
1102 ocs_hw_get(&ocs->hw, OCS_HW_SLI_REV, &rev); in ocs_sysctl_init()
1103 ocs_hw_get(&ocs->hw, OCS_HW_IF_TYPE, &if_type); in ocs_sysctl_init()
1104 ocs_hw_get(&ocs->hw, OCS_HW_SLI_FAMILY, &family); in ocs_sysctl_init()
1106 memset(ocs->fwrev, 0, sizeof(ocs->fwrev)); in ocs_sysctl_init()
1107 snprintf(ocs->fwrev, sizeof(ocs->fwrev), "%s, sli-%d:%d:%x", in ocs_sysctl_init()
1108 (char *)ocs_hw_get_ptr(&ocs->hw, OCS_HW_FW_REV), in ocs_sysctl_init()
1112 ocs->fwrev, in ocs_sysctl_init()
1115 memset(ocs->sli_intf, 0, sizeof(ocs->sli_intf)); in ocs_sysctl_init()
1116 snprintf(ocs->sli_intf, sizeof(ocs->sli_intf), "%08x", in ocs_sysctl_init()
1117 ocs_config_read32(ocs, SLI4_INTF_REG)); in ocs_sysctl_init()
1120 ocs->sli_intf, in ocs_sysctl_init()
1124 CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, (void *)ocs, 0, in ocs_sysctl_init()
1129 ocs, 0, ocs_sysctl_wwnn, "A", in ocs_sysctl_init()
1134 ocs, 0, ocs_sysctl_wwpn, "A", in ocs_sysctl_init()
1139 ocs, 0, ocs_sysctl_current_topology, "IU", in ocs_sysctl_init()
1144 ocs, 0, ocs_sysctl_current_speed, "IU", in ocs_sysctl_init()
1149 ocs, 0, ocs_sysctl_config_topology, "IU", in ocs_sysctl_init()
1154 ocs, 0, ocs_sysctl_config_speed, "IU", in ocs_sysctl_init()
1158 "businfo", CTLFLAG_RD, ocs->businfo, 0, "Bus Info"); in ocs_sysctl_init()
1162 ocs, 0, ocs_sysctl_fcid, "A", "Port FC ID"); in ocs_sysctl_init()
1166 ocs, 0, ocs_sysctl_port_state, "A", "configured port state"); in ocs_sysctl_init()
1168 for (i = 0; i < ocs->num_vports; i++) { in ocs_sysctl_init()
1169 fcp = FCPORT(ocs, i+1); in ocs_sysctl_init()
1194 * kenv hint.ocs.U.P=V
1201 struct ocs_softc *ocs = os; in ocs_debug_attach() local
1208 if (0 == (error = resource_int_value(device_get_name(ocs->dev), device_get_unit(ocs->dev), in ocs_debug_attach()
1210 device_printf(ocs->dev, "setting %s to %010x\n", resname, ocs_debug_mask); in ocs_debug_attach()
1214 unit = device_get_unit(ocs->dev); in ocs_debug_attach()
1215 ocs->cdev = make_dev(&ocs_cdevsw, unit, UID_ROOT, GID_OPERATOR, 0640, in ocs_debug_attach()
1216 "ocs%d", unit); in ocs_debug_attach()
1217 if (ocs->cdev) { in ocs_debug_attach()
1218 ocs->cdev->si_drv1 = ocs; in ocs_debug_attach()
1222 ocs_sysctl_init(ocs); in ocs_debug_attach()
1223 mtx_init(&ocs->dbg_lock, "ocs_dbg_lock", NULL, MTX_DEF); in ocs_debug_attach()
1232 struct ocs_softc *ocs = os; in ocs_debug_detach() local
1234 mtx_destroy(&ocs->dbg_lock); in ocs_debug_detach()
1236 if (ocs->cdev) { in ocs_debug_detach()
1237 ocs->cdev->si_drv1 = NULL; in ocs_debug_detach()
1238 destroy_dev(ocs->cdev); in ocs_debug_detach()