Lines Matching full:ocs
38 #include "ocs.h"
59 * @param ocs Pointer to device instance.
64 ocs_xport_alloc(ocs_t *ocs) in ocs_xport_alloc() argument
68 ocs_assert(ocs, NULL); in ocs_xport_alloc()
69 xport = ocs_malloc(ocs, sizeof(*xport), OCS_M_ZERO); in ocs_xport_alloc()
71 xport->ocs = ocs; in ocs_xport_alloc()
89 ocs_t *ocs = xport->ocs; in ocs_xport_rq_threads_teardown() local
102 ocs_log_debug(ocs, "wait for thread %d to exit\n", i); in ocs_xport_rq_threads_teardown()
106 ocs_log_debug(ocs, "thread %d to exited\n", i); in ocs_xport_rq_threads_teardown()
130 ocs_t *ocs = xport->ocs; in ocs_xport_rq_threads_create() local
135 ocs_log_debug(ocs, "number of RQ threads %d\n", num_rq_threads); in ocs_xport_rq_threads_create()
141 …xport->rq_thread_info = ocs_malloc(ocs, sizeof(ocs_xport_rq_thread_info_t) * num_rq_threads, OCS_M… in ocs_xport_rq_threads_create()
143 ocs_log_err(ocs, "memory allocation failure\n"); in ocs_xport_rq_threads_create()
149 xport->rq_thread_info[i].ocs = ocs; in ocs_xport_rq_threads_create()
150 xport->rq_thread_info[i].seq_cbuf = ocs_cbuf_alloc(ocs, OCS_HW_RQ_NUM_HDR); in ocs_xport_rq_threads_create()
157 "ocs_unsol_rq:%d:%d", ocs->instance_index, i); in ocs_xport_rq_threads_create()
158 rc = ocs_thread_create(ocs, &xport->rq_thread_info[i].thread, ocs_unsol_rq_thread, in ocs_xport_rq_threads_create()
162 ocs_log_err(ocs, "ocs_thread_create failed: %d\n", rc); in ocs_xport_rq_threads_create()
187 ocs_t *ocs = xport->ocs; in ocs_xport_attach() local
199 ocs_list_init(&ocs->domain_list, ocs_domain_t, link); in ocs_xport_attach()
203 ocs_lock_init(ocs, &xport->fcfi[i].pend_frames_lock, "xport pend_frames[%d]", i); in ocs_xport_attach()
207 rc = ocs_hw_set_ptr(&ocs->hw, OCS_HW_WAR_VERSION, ocs->hw_war_version); in ocs_xport_attach()
209 ocs_log_test(ocs, "can't set OCS_HW_WAR_VERSION\n"); in ocs_xport_attach()
213 rc = ocs_hw_setup(&ocs->hw, ocs, SLI4_PORT_TYPE_FC); in ocs_xport_attach()
215 ocs_log_err(ocs, "%s: Can't setup hardware\n", ocs->desc); in ocs_xport_attach()
217 } else if (ocs->ctrlmask & OCS_CTRLMASK_CRASH_RESET) { in ocs_xport_attach()
218 ocs_log_debug(ocs, "stopping after ocs_hw_setup\n"); in ocs_xport_attach()
222 ocs_hw_set(&ocs->hw, OCS_HW_BOUNCE, ocs->hw_bounce); in ocs_xport_attach()
223 ocs_log_debug(ocs, "HW bounce: %d\n", ocs->hw_bounce); in ocs_xport_attach()
225 ocs_hw_set(&ocs->hw, OCS_HW_RQ_SELECTION_POLICY, ocs->rq_selection_policy); in ocs_xport_attach()
226 ocs_hw_set(&ocs->hw, OCS_HW_RR_QUANTA, ocs->rr_quanta); in ocs_xport_attach()
227 ocs_hw_get(&ocs->hw, OCS_HW_RQ_SELECTION_POLICY, &value); in ocs_xport_attach()
228 ocs_log_debug(ocs, "RQ Selection Policy: %d\n", value); in ocs_xport_attach()
230 ocs_hw_set_ptr(&ocs->hw, OCS_HW_FILTER_DEF, (void*) ocs->filter_def); in ocs_xport_attach()
232 ocs_hw_get(&ocs->hw, OCS_HW_MAX_SGL, &max_sgl); in ocs_xport_attach()
237 if (ocs->ctrlmask & OCS_CTRLMASK_TEST_CHAINED_SGLS) { in ocs_xport_attach()
242 if (ocs_hw_set(&ocs->hw, OCS_HW_N_SGL, n_sgl) != OCS_HW_RTN_SUCCESS) { in ocs_xport_attach()
243 ocs_log_err(ocs, "%s: Can't set number of SGLs\n", ocs->desc); in ocs_xport_attach()
246 ocs_log_debug(ocs, "%s: Configured for %d SGLs\n", ocs->desc, n_sgl); in ocs_xport_attach()
249 ocs_hw_get(&ocs->hw, OCS_HW_MAX_NODES, &max_remote_nodes); in ocs_xport_attach()
251 if (!ocs->max_remote_nodes) in ocs_xport_attach()
252 ocs->max_remote_nodes = max_remote_nodes; in ocs_xport_attach()
254 rc = ocs_node_create_pool(ocs, ocs->max_remote_nodes); in ocs_xport_attach()
256 ocs_log_err(ocs, "Can't allocate node pool\n"); in ocs_xport_attach()
263 xport->io_pool = ocs_io_pool_create(ocs, ocs->num_scsi_ios, in ocs_xport_attach()
264 (ocs->ctrlmask & OCS_CTRLMASK_TEST_CHAINED_SGLS) ? OCS_FC_MAX_SGL : n_sgl); in ocs_xport_attach()
266 ocs_log_err(ocs, "Can't allocate IO pool\n"); in ocs_xport_attach()
275 if (ocs_xport_rq_threads_create(xport, ocs->rq_threads) != 0) { in ocs_xport_attach()
276 ocs_log_err(ocs, "failure creating RQ threads\n"); in ocs_xport_attach()
288 ocs_node_free_pool(ocs); in ocs_xport_attach()
305 ocs_t *ocs = xport->ocs; in ocs_xport_initialize_auto_xfer_ready() local
311 ocs_hw_get(&ocs->hw, OCS_HW_AUTO_XFER_RDY_CAPABLE, &auto_xfer_rdy); in ocs_xport_initialize_auto_xfer_ready()
313 ocs->auto_xfer_rdy_size = 0; in ocs_xport_initialize_auto_xfer_ready()
314 ocs_log_test(ocs, "Cannot enable auto xfer rdy for this port\n"); in ocs_xport_initialize_auto_xfer_ready()
318 if (ocs_hw_set(&ocs->hw, OCS_HW_AUTO_XFER_RDY_SIZE, ocs->auto_xfer_rdy_size)) { in ocs_xport_initialize_auto_xfer_ready()
319 ocs_log_test(ocs, "%s: Can't set auto xfer rdy mode\n", ocs->desc); in ocs_xport_initialize_auto_xfer_ready()
344 if (ocs_hw_set(&ocs->hw, OCS_HW_AUTO_XFER_RDY_T10_ENABLE, TRUE)) { in ocs_xport_initialize_auto_xfer_ready()
345 ocs_log_test(ocs, "%s: Can't set auto xfer rdy mode\n", ocs->desc); in ocs_xport_initialize_auto_xfer_ready()
348 if (ocs_hw_set(&ocs->hw, OCS_HW_AUTO_XFER_RDY_BLK_SIZE, ramdisc_blocksize)) { in ocs_xport_initialize_auto_xfer_ready()
349 ocs_log_test(ocs, "%s: Can't set auto xfer rdy blk size\n", ocs->desc); in ocs_xport_initialize_auto_xfer_ready()
352 if (ocs_hw_set(&ocs->hw, OCS_HW_AUTO_XFER_RDY_P_TYPE, p_type)) { in ocs_xport_initialize_auto_xfer_ready()
353 ocs_log_test(ocs, "%s: Can't set auto xfer rdy mode\n", ocs->desc); in ocs_xport_initialize_auto_xfer_ready()
356 if (ocs_hw_set(&ocs->hw, OCS_HW_AUTO_XFER_RDY_REF_TAG_IS_LBA, TRUE)) { in ocs_xport_initialize_auto_xfer_ready()
357 ocs_log_test(ocs, "%s: Can't set auto xfer rdy ref tag\n", ocs->desc); in ocs_xport_initialize_auto_xfer_ready()
360 if (ocs_hw_set(&ocs->hw, OCS_HW_AUTO_XFER_RDY_APP_TAG_VALID, FALSE)) { in ocs_xport_initialize_auto_xfer_ready()
361 ocs_log_test(ocs, "%s: Can't set auto xfer rdy app tag valid\n", ocs->desc); in ocs_xport_initialize_auto_xfer_ready()
365 ocs_log_debug(ocs, "Auto xfer rdy is enabled, p_type=%d, blksize=%d\n", in ocs_xport_initialize_auto_xfer_ready()
379 * @param ocs Pointer to ocs
384 ocs_topology_setup(ocs_t *ocs) in ocs_topology_setup() argument
388 if (ocs->topology == OCS_HW_TOPOLOGY_AUTO) { in ocs_topology_setup()
389 topology = ocs_hw_get_config_persistent_topology(&ocs->hw); in ocs_topology_setup()
391 topology = ocs->topology; in ocs_topology_setup()
394 ocs_hw_set_persistent_topology(&ocs->hw, topology, OCS_CMD_POLL); in ocs_topology_setup()
397 return ocs_hw_set(&ocs->hw, OCS_HW_TOPOLOGY, topology); in ocs_topology_setup()
413 ocs_t *ocs = xport->ocs; in ocs_xport_initialize() local
429 ocs_hw_get(&ocs->hw, OCS_HW_MAX_IO, &max_hw_io); in ocs_xport_initialize()
430 if (ocs_hw_set(&ocs->hw, OCS_HW_N_IO, max_hw_io) != OCS_HW_RTN_SUCCESS) { in ocs_xport_initialize()
431 ocs_log_err(ocs, "%s: Can't set number of IOs\n", ocs->desc); in ocs_xport_initialize()
435 ocs_hw_get(&ocs->hw, OCS_HW_MAX_SGL, &max_sgl); in ocs_xport_initialize()
438 if (ocs->enable_hlm) { in ocs_xport_initialize()
439 ocs_hw_get(&ocs->hw, OCS_HW_HIGH_LOGIN_MODE, &hlm); in ocs_xport_initialize()
441 ocs->enable_hlm = FALSE; in ocs_xport_initialize()
442 ocs_log_err(ocs, "Cannot enable high login mode for this port\n"); in ocs_xport_initialize()
444 ocs_log_debug(ocs, "High login mode is enabled\n"); in ocs_xport_initialize()
445 if (ocs_hw_set(&ocs->hw, OCS_HW_HIGH_LOGIN_MODE, TRUE)) { in ocs_xport_initialize()
446 ocs_log_err(ocs, "%s: Can't set high login mode\n", ocs->desc); in ocs_xport_initialize()
453 if (ocs->auto_xfer_rdy_size > 0 && in ocs_xport_initialize()
454 (ocs->auto_xfer_rdy_size < 2048 || in ocs_xport_initialize()
455 ocs->auto_xfer_rdy_size > 65536)) { in ocs_xport_initialize()
456 ocs_log_err(ocs, "Auto XFER_RDY size is out of range (2K-64K)\n"); in ocs_xport_initialize()
460 ocs_hw_get(&ocs->hw, OCS_HW_MAX_IO, &max_hw_io); in ocs_xport_initialize()
462 if (ocs->auto_xfer_rdy_size > 0) { in ocs_xport_initialize()
464 ocs_log_err(ocs, "%s: Failed auto xfer ready setup\n", ocs->desc); in ocs_xport_initialize()
467 if (ocs->esoc){ in ocs_xport_initialize()
468 ocs_hw_set(&ocs->hw, OCS_ESOC, TRUE); in ocs_xport_initialize()
472 if (ocs->explicit_buffer_list) { in ocs_xport_initialize()
474 ocs_hw_get(&ocs->hw, OCS_HW_PREREGISTER_SGL, &i); in ocs_xport_initialize()
476 ocs_log_err(ocs, "Explicit Buffer List not supported on this device, not enabled\n"); in ocs_xport_initialize()
478 ocs_hw_set(&ocs->hw, OCS_HW_PREREGISTER_SGL, FALSE); in ocs_xport_initialize()
483 rc = ocs_topology_setup(ocs); in ocs_xport_initialize()
485 ocs_log_err(ocs, "%s: Can't set the toplogy\n", ocs->desc); in ocs_xport_initialize()
489 if (ocs_hw_set(&ocs->hw, OCS_HW_TOPOLOGY, ocs->topology) != OCS_HW_RTN_SUCCESS) { in ocs_xport_initialize()
490 ocs_log_err(ocs, "%s: Can't set the toplogy\n", ocs->desc); in ocs_xport_initialize()
493 ocs_hw_set(&ocs->hw, OCS_HW_RQ_DEFAULT_BUFFER_SIZE, OCS_FC_RQ_SIZE_DEFAULT); in ocs_xport_initialize()
495 if (ocs_hw_set(&ocs->hw, OCS_HW_LINK_SPEED, ocs->speed) != OCS_HW_RTN_SUCCESS) { in ocs_xport_initialize()
496 ocs_log_err(ocs, "%s: Can't set the link speed\n", ocs->desc); in ocs_xport_initialize()
500 if (ocs_hw_set(&ocs->hw, OCS_HW_ETH_LICENSE, ocs->ethernet_license) != OCS_HW_RTN_SUCCESS) { in ocs_xport_initialize()
501 ocs_log_err(ocs, "%s: Can't set the ethernet license\n", ocs->desc); in ocs_xport_initialize()
506 if (ocs->hw.sli.asic_type == SLI4_ASIC_TYPE_LANCER) { in ocs_xport_initialize()
507 if (ocs_hw_set(&ocs->hw, OCS_HW_DIF_SEED, OCS_FC_DIF_SEED) != OCS_HW_RTN_SUCCESS) { in ocs_xport_initialize()
508 ocs_log_err(ocs, "%s: Can't set the DIF seed\n", ocs->desc); in ocs_xport_initialize()
514 if (0 == ocs_hw_get(&ocs->hw, OCS_HW_DIF_CAPABLE, &dif_capable)) { in ocs_xport_initialize()
520 if ((rc = ocs_hw_set(&ocs->hw, OCS_HW_DIF_MODE, in ocs_xport_initialize()
522 ocs_log_err(ocs, "Requested DIF MODE not supported\n"); in ocs_xport_initialize()
527 if (ocs->target_io_timer_sec || ocs->enable_ini) { in ocs_xport_initialize()
528 if (ocs->target_io_timer_sec) in ocs_xport_initialize()
529 ocs_log_debug(ocs, "setting target io timer=%d\n", ocs->target_io_timer_sec); in ocs_xport_initialize()
531 ocs_hw_set(&ocs->hw, OCS_HW_EMULATE_WQE_TIMEOUT, TRUE); in ocs_xport_initialize()
534 ocs_hw_callback(&ocs->hw, OCS_HW_CB_DOMAIN, ocs_domain_cb, ocs); in ocs_xport_initialize()
535 ocs_hw_callback(&ocs->hw, OCS_HW_CB_REMOTE_NODE, ocs_remote_node_cb, ocs); in ocs_xport_initialize()
536 ocs_hw_callback(&ocs->hw, OCS_HW_CB_UNSOLICITED, ocs_unsolicited_cb, ocs); in ocs_xport_initialize()
537 ocs_hw_callback(&ocs->hw, OCS_HW_CB_PORT, ocs_port_cb, ocs); in ocs_xport_initialize()
539 ocs->fw_version = (const char*) ocs_hw_get_ptr(&ocs->hw, OCS_HW_FW_REV); in ocs_xport_initialize()
543 ocs_lock_init(ocs, &xport->io_pending_lock, "io_pending_lock[%d]", ocs->instance_index); in ocs_xport_initialize()
551 ocs_lock_init(ocs, &ocs->hw.watchdog_lock, " Watchdog Lock[%d]", ocs_instance(ocs)); in ocs_xport_initialize()
552 rc = ocs_hw_init(&ocs->hw); in ocs_xport_initialize()
554 ocs_log_err(ocs, "ocs_hw_init failure\n"); in ocs_xport_initialize()
561 if (ocs_hw_set(&ocs->hw, OCS_HW_RQ_PROCESS_LIMIT, rq_limit) != OCS_HW_RTN_SUCCESS) { in ocs_xport_initialize()
562 ocs_log_err(ocs, "%s: Can't set the RQ process limit\n", ocs->desc); in ocs_xport_initialize()
565 if (ocs->config_tgt) { in ocs_xport_initialize()
566 rc = ocs_scsi_tgt_new_device(ocs); in ocs_xport_initialize()
568 ocs_log_err(ocs, "failed to initialize target\n"); in ocs_xport_initialize()
575 if (ocs->enable_ini) { in ocs_xport_initialize()
576 rc = ocs_scsi_ini_new_device(ocs); in ocs_xport_initialize()
578 ocs_log_err(ocs, "failed to initialize initiator\n"); in ocs_xport_initialize()
586 if (ocs->num_vports != 0) { in ocs_xport_initialize()
588 ocs_hw_get(&ocs->hw, OCS_HW_MAX_VPORTS, &max_vports); in ocs_xport_initialize()
590 if (ocs->num_vports < max_vports) { in ocs_xport_initialize()
591 ocs_log_debug(ocs, "Provisioning %d vports\n", ocs->num_vports); in ocs_xport_initialize()
592 for (i = 0; i < ocs->num_vports; i++) { in ocs_xport_initialize()
593 ocs_vport_create_spec(ocs, 0, 0, UINT32_MAX, ocs->enable_ini, ocs->enable_tgt, NULL, NULL); in ocs_xport_initialize()
596 ocs_log_err(ocs, "failed to create vports. num_vports range should be (1-%d) \n", max_vports-1); in ocs_xport_initialize()
605 ocs_scsi_ini_del_device(ocs); in ocs_xport_initialize()
609 ocs_scsi_tgt_del_device(ocs); in ocs_xport_initialize()
614 ocs_hw_teardown(&ocs->hw); in ocs_xport_initialize()
633 ocs_t *ocs = xport->ocs; in ocs_xport_detach() local
636 if (ocs->config_tgt) in ocs_xport_detach()
637 ocs_scsi_tgt_del_device(ocs); in ocs_xport_detach()
639 if (ocs->enable_ini) { in ocs_xport_detach()
640 ocs_scsi_ini_del_device(ocs); in ocs_xport_detach()
643 if (ocs_timer_pending(&ocs->xport->stats_timer)) in ocs_xport_detach()
644 ocs_del_timer(&ocs->xport->stats_timer); in ocs_xport_detach()
647 ocs_hw_teardown(&ocs->hw); in ocs_xport_detach()
659 * @param ocs Pointer to device object.
666 ocs_xport_domain_list_empty_cb(ocs_t *ocs, void *arg) in ocs_xport_domain_list_empty_cb() argument
670 ocs_assert(ocs); in ocs_xport_domain_list_empty_cb()
710 * Perform force free of OCS.
720 ocs_t *ocs = xport->ocs; in ocs_xport_force_free() local
724 ocs_log_debug(ocs, "reset required, do force shutdown\n"); in ocs_xport_force_free()
725 ocs_device_lock(ocs); in ocs_xport_force_free()
726 ocs_list_foreach_safe(&ocs->domain_list, domain, next) { in ocs_xport_force_free()
729 ocs_device_unlock(ocs); in ocs_xport_force_free()
754 ocs_t *ocs = NULL; in ocs_xport_control() local
758 ocs_assert(xport->ocs, -1); in ocs_xport_control()
759 ocs = xport->ocs; in ocs_xport_control()
764 rc = ocs_hw_port_control(&ocs->hw, OCS_HW_PORT_INIT, 0, NULL, NULL); in ocs_xport_control()
766 ocs_log_err(ocs, "%s: Can't init port\n", ocs->desc); in ocs_xport_control()
773 if (ocs_hw_port_control(&ocs->hw, OCS_HW_PORT_SHUTDOWN, 0, NULL, NULL)) { in ocs_xport_control()
774 ocs_log_err(ocs, "port shutdown failed\n"); in ocs_xport_control()
789 if (ocs_hw_get(&ocs->hw, OCS_HW_RESET_REQUIRED, &reset_required) != OCS_HW_RTN_SUCCESS) { in ocs_xport_control()
794 ocs_log_debug(ocs, "reset required, do force shutdown\n"); in ocs_xport_control()
799 ocs_register_domain_list_empty_cb(ocs, ocs_xport_domain_list_empty_cb, &sem); in ocs_xport_control()
801 if (ocs_hw_port_control(&ocs->hw, OCS_HW_PORT_SHUTDOWN, 0, NULL, NULL)) { in ocs_xport_control()
802 ocs_log_debug(ocs, "port shutdown failed, do force shutdown\n"); in ocs_xport_control()
805 …ocs_log_debug(ocs, "Waiting %d seconds for domain shutdown.\n", (OCS_FC_DOMAIN_SHUTDOWN_TIMEOUT_US… in ocs_xport_control()
809 ocs_log_debug(ocs, "Note: Domain shutdown timed out\n"); in ocs_xport_control()
814 ocs_register_domain_list_empty_cb(ocs, NULL, NULL); in ocs_xport_control()
817 ocs_vport_del_all(ocs); in ocs_xport_control()
837 ocs_t *ocs; in ocs_xport_control() local
848 ocs_assert(node->ocs, -1); in ocs_xport_control()
850 ocs = node->ocs; in ocs_xport_control()
851 hw = &ocs->hw; in ocs_xport_control()
855 ocs_log_test(ocs, "node %p state machine disabled\n", node); in ocs_xport_control()
867 ocs_log_test(ocs, "ocs_hw_async_call failed\n"); in ocs_xport_control()
874 ocs_log_test(ocs, "POST_NODE_EVENT: sem wait failed\n"); in ocs_xport_control()
891 ocs_log_debug(ocs, " WWNN %016" PRIx64 "\n", wwnn); in ocs_xport_control()
907 ocs_log_debug(ocs, " WWPN %016" PRIx64 "\n", wwpn); in ocs_xport_control()
948 ocs_t *ocs = NULL; in ocs_xport_status() local
953 ocs_assert(xport->ocs, -1); in ocs_xport_status()
955 ocs = xport->ocs; in ocs_xport_status()
971 hw_rc = ocs_hw_get(&(ocs->hw), OCS_HW_LINK_SPEED, &value.value); in ocs_xport_status()
990 rc = ocs_hw_get(&ocs->hw, OCS_HW_LINK_SPEED, &speed); in ocs_xport_status()
1004 rc = ocs_hw_get(&ocs->hw, OCS_HW_LINK_MODULE_TYPE, &link_module_type); in ocs_xport_status()
1022 ocs_device_lock(ocs); in ocs_xport_status()
1023 ocs_memcpy((void *)result, &ocs->xport->fc_xport_stats, sizeof(ocs_xport_stats_t)); in ocs_xport_status()
1024 ocs_device_unlock(ocs); in ocs_xport_status()
1031 if ((rc = ocs_hw_get_link_stats(&ocs->hw, 0, 1, 1, ocs_xport_link_stats_cb, result)) != 0) { in ocs_xport_status()
1032 ocs_log_err(ocs, "%s: Failed to reset link statistics\n", __func__); in ocs_xport_status()
1040 ocs_log_test(ocs, "ocs_sem_p failed\n"); in ocs_xport_status()
1046 if ((rc = ocs_hw_get_host_stats(&ocs->hw, 1, ocs_xport_host_stats_cb, result)) != 0) { in ocs_xport_status()
1047 ocs_log_err(ocs, "%s: Failed to reset host statistics\n", __func__); in ocs_xport_status()
1054 ocs_log_test(ocs, "ocs_sem_p failed\n"); in ocs_xport_status()
1061 ocs_device_lock(ocs); in ocs_xport_status()
1062 result->value = ocs_list_empty(&ocs->domain_list); in ocs_xport_status()
1063 ocs_device_unlock(ocs); in ocs_xport_status()
1115 ocs_t *ocs; in ocs_xport_free() local
1119 ocs = xport->ocs; in ocs_xport_free()
1121 ocs_node_free_pool(ocs); in ocs_xport_free()
1131 ocs_free(ocs, xport, sizeof(*xport)); in ocs_xport_free()