Lines Matching +full:pcie +full:- +full:mirror

1 /*-
36 * the details of the underlying SLI-4 implementation.
65 /* max command and response buffer lengths -- arbitrary at the moment */
156 io->wqe_timeout = timeout; in ocs_hw_set_io_wqe_timeout()
166 if (hw->config.emulate_wqe_timeout && io->wqe_timeout) { in ocs_hw_add_io_timed_wqe()
171 ocs_lock(&hw->io_lock); in ocs_hw_add_io_timed_wqe()
172 ocs_list_add_tail(&hw->io_timed_wqe, io); in ocs_hw_add_io_timed_wqe()
173 getmicrouptime(&io->submit_time); in ocs_hw_add_io_timed_wqe()
174 ocs_unlock(&hw->io_lock); in ocs_hw_add_io_timed_wqe()
181 if (hw->config.emulate_wqe_timeout) { in ocs_hw_remove_io_timed_wqe()
186 ocs_lock(&hw->io_lock); in ocs_hw_remove_io_timed_wqe()
187 if (ocs_list_on_list(&io->wqe_link)) { in ocs_hw_remove_io_timed_wqe()
188 ocs_list_remove(&hw->io_timed_wqe, io); in ocs_hw_remove_io_timed_wqe()
190 ocs_unlock(&hw->io_lock); in ocs_hw_remove_io_timed_wqe()
243 if (sli_get_is_dual_ulp_capable(&hw->sli) && in ocs_hw_get_num_chutes()
244 sli_get_is_ulp_enabled(&hw->sli, 0) && in ocs_hw_get_num_chutes()
245 sli_get_is_ulp_enabled(&hw->sli, 1)) { in ocs_hw_get_num_chutes()
256 hw->link.status = SLI_LINK_STATUS_MAX; in ocs_hw_link_event_init()
257 hw->link.topology = SLI_LINK_TOPO_NONE; in ocs_hw_link_event_init()
258 hw->link.medium = SLI_LINK_MEDIUM_MAX; in ocs_hw_link_event_init()
259 hw->link.speed = 0; in ocs_hw_link_event_init()
260 hw->link.loop_map = NULL; in ocs_hw_link_event_init()
261 hw->link.fc_id = UINT32_MAX; in ocs_hw_link_event_init()
275 * @return Returns 0 on success, or a non-zero value on failure.
285 if ((SLI4_IF_TYPE_LANCER_FC_ETH != sli_get_if_type(&hw->sli)) && in ocs_hw_read_max_dump_size()
286 (SLI4_IF_TYPE_LANCER_G7 != sli_get_if_type(&hw->sli))) { in ocs_hw_read_max_dump_size()
287 ocs_log_debug(hw->os, "Function only supported for I/F type 2\n"); in ocs_hw_read_max_dump_size()
295 if (hw->workaround.disable_dump_loc) { in ocs_hw_read_max_dump_size()
296 ocs_log_test(hw->os, "FW version is too old for this feature\n"); in ocs_hw_read_max_dump_size()
301 ocs_get_bus_dev_func(hw->os, &bus, &dev, &func); in ocs_hw_read_max_dump_size()
303 if (sli_cmd_common_set_dump_location(&hw->sli, buf, in ocs_hw_read_max_dump_size()
312 ocs_log_test(hw->os, "set dump location command failed\n"); in ocs_hw_read_max_dump_size()
315 hw->dump_size = rsp->buffer_length; in ocs_hw_read_max_dump_size()
316 ocs_log_debug(hw->os, "Dump size %x\n", rsp->buffer_length); in ocs_hw_read_max_dump_size()
336 * @return Returns 0 on success, or a non-zero value on failure.
349 if (hw->hw_setup_called) { in ocs_hw_setup()
350 /* Setup run-time workarounds. in ocs_hw_setup()
359 * needs allocation. If a structure is non-NULL, ocs_hw_init() won't in ocs_hw_setup()
364 hw->hw_setup_called = TRUE; in ocs_hw_setup()
366 hw->os = os; in ocs_hw_setup()
368 ocs_lock_init(hw->os, &hw->cmd_lock, "HW_cmd_lock[%d]", ocs_instance(hw->os)); in ocs_hw_setup()
369 ocs_list_init(&hw->cmd_head, ocs_command_ctx_t, link); in ocs_hw_setup()
370 ocs_list_init(&hw->cmd_pending, ocs_command_ctx_t, link); in ocs_hw_setup()
371 hw->cmd_head_count = 0; in ocs_hw_setup()
373 ocs_lock_init(hw->os, &hw->io_lock, "HW_io_lock[%d]", ocs_instance(hw->os)); in ocs_hw_setup()
374 ocs_lock_init(hw->os, &hw->io_abort_lock, "HW_io_abort_lock[%d]", ocs_instance(hw->os)); in ocs_hw_setup()
376 ocs_atomic_init(&hw->io_alloc_failed_count, 0); in ocs_hw_setup()
378 hw->config.speed = FC_LINK_SPEED_AUTO_16_8_4; in ocs_hw_setup()
379 hw->config.dif_seed = 0; in ocs_hw_setup()
380 hw->config.auto_xfer_rdy_blk_size_chip = OCS_HW_AUTO_XFER_RDY_BLK_SIZE_DEFAULT; in ocs_hw_setup()
381 hw->config.auto_xfer_rdy_ref_tag_is_lba = OCS_HW_AUTO_XFER_RDY_REF_TAG_IS_LBA_DEFAULT; in ocs_hw_setup()
382 hw->config.auto_xfer_rdy_app_tag_valid = OCS_HW_AUTO_XFER_RDY_APP_TAG_VALID_DEFAULT; in ocs_hw_setup()
383 hw->config.auto_xfer_rdy_app_tag_value = OCS_HW_AUTO_XFER_RDY_APP_TAG_VALUE_DEFAULT; in ocs_hw_setup()
385 if (sli_setup(&hw->sli, hw->os, port_type)) { in ocs_hw_setup()
386 ocs_log_err(hw->os, "SLI setup failed\n"); in ocs_hw_setup()
390 ocs_memset(hw->domains, 0, sizeof(hw->domains)); in ocs_hw_setup()
392 ocs_memset(hw->fcf_index_fcfi, 0, sizeof(hw->fcf_index_fcfi)); in ocs_hw_setup()
396 sli_callback(&hw->sli, SLI4_CB_LINK, ocs_hw_cb_link, hw); in ocs_hw_setup()
397 sli_callback(&hw->sli, SLI4_CB_FIP, ocs_hw_cb_fip, hw); in ocs_hw_setup()
403 for (i = 0; i < ARRAY_SIZE(hw->num_qentries); i++) { in ocs_hw_setup()
404 hw->num_qentries[i] = sli_get_max_qentries(&hw->sli, i); in ocs_hw_setup()
410 hw->config.rq_default_buffer_size = OCS_HW_RQ_SIZE_PAYLOAD; in ocs_hw_setup()
411 hw->config.n_io = sli_get_max_rsrc(&hw->sli, SLI_RSRC_FCOE_XRI); in ocs_hw_setup()
413 hw->config.auto_xfer_rdy_xri_cnt = ocs_strtoul(prop_buf, 0, 0); in ocs_hw_setup()
416 /* by default, enable initiator-only auto-ABTS emulation */ in ocs_hw_setup()
417 hw->config.i_only_aab = TRUE; in ocs_hw_setup()
419 /* Setup run-time workarounds */ in ocs_hw_setup()
423 if (hw->workaround.override_fcfi) { in ocs_hw_setup()
424 hw->first_domain_idx = -1; in ocs_hw_setup()
428 if ((SLI4_IF_TYPE_LANCER_FC_ETH == sli_get_if_type(&hw->sli)) || in ocs_hw_setup()
429 (SLI4_IF_TYPE_LANCER_G7 == sli_get_if_type(&hw->sli))) { in ocs_hw_setup()
438 if (! sli_is_dif_inline_capable(&hw->sli)) { in ocs_hw_setup()
439 ocs_log_test(hw->os, "not inline capable, setting mode to separate\n"); in ocs_hw_setup()
440 hw->config.dif_mode = OCS_HW_DIF_MODE_SEPARATE; in ocs_hw_setup()
443 if (hw->workaround.use_dif_sec_xri) { in ocs_hw_setup()
444 ocs_list_init(&hw->sec_hio_wait_list, ocs_hw_io_t, link); in ocs_hw_setup()
451 if (sli_get_is_dual_ulp_capable(&hw->sli)) { in ocs_hw_setup()
452 if (sli_get_is_ulp_enabled(&hw->sli, 0) && in ocs_hw_setup()
453 sli_get_is_ulp_enabled(&hw->sli, 1)) { in ocs_hw_setup()
454 hw->ulp_start = 0; in ocs_hw_setup()
455 hw->ulp_max = 1; in ocs_hw_setup()
456 } else if (sli_get_is_ulp_enabled(&hw->sli, 0)) { in ocs_hw_setup()
457 hw->ulp_start = 0; in ocs_hw_setup()
458 hw->ulp_max = 0; in ocs_hw_setup()
460 hw->ulp_start = 1; in ocs_hw_setup()
461 hw->ulp_max = 1; in ocs_hw_setup()
464 if (sli_get_is_ulp_enabled(&hw->sli, 0)) { in ocs_hw_setup()
465 hw->ulp_start = 0; in ocs_hw_setup()
466 hw->ulp_max = 0; in ocs_hw_setup()
468 hw->ulp_start = 1; in ocs_hw_setup()
469 hw->ulp_max = 1; in ocs_hw_setup()
472 ocs_log_debug(hw->os, "ulp_start %d, ulp_max %d\n", in ocs_hw_setup()
473 hw->ulp_start, hw->ulp_max); in ocs_hw_setup()
474 hw->config.queue_topology = hw_global.queue_topology_string; in ocs_hw_setup()
476 hw->qtop = ocs_hw_qtop_parse(hw, hw->config.queue_topology); in ocs_hw_setup()
478 hw->config.n_eq = hw->qtop->entry_counts[QTOP_EQ]; in ocs_hw_setup()
479 hw->config.n_cq = hw->qtop->entry_counts[QTOP_CQ]; in ocs_hw_setup()
480 hw->config.n_rq = hw->qtop->entry_counts[QTOP_RQ]; in ocs_hw_setup()
481 hw->config.n_wq = hw->qtop->entry_counts[QTOP_WQ]; in ocs_hw_setup()
482 hw->config.n_mq = hw->qtop->entry_counts[QTOP_MQ]; in ocs_hw_setup()
485 if (hw->config.n_rq > OCE_HW_MAX_NUM_MRQ_PAIRS) { in ocs_hw_setup()
486 ocs_log_crit(hw->os, "Max supported MRQ pairs = %d\n", in ocs_hw_setup()
491 if (hw->config.n_eq > OCS_HW_MAX_NUM_EQ) { in ocs_hw_setup()
492 ocs_log_crit(hw->os, "Max supported EQs = %d\n", in ocs_hw_setup()
497 if (hw->config.n_cq > OCS_HW_MAX_NUM_CQ) { in ocs_hw_setup()
498 ocs_log_crit(hw->os, "Max supported CQs = %d\n", in ocs_hw_setup()
503 if (hw->config.n_wq > OCS_HW_MAX_NUM_WQ) { in ocs_hw_setup()
504 ocs_log_crit(hw->os, "Max supported WQs = %d\n", in ocs_hw_setup()
509 if (hw->config.n_mq > OCS_HW_MAX_NUM_MQ) { in ocs_hw_setup()
510 ocs_log_crit(hw->os, "Max supported MQs = %d\n", in ocs_hw_setup()
531 * @return Returns 0 on success, or a non-zero value on failure.
547 * Make sure the command lists are empty. If this is start-of-day, in ocs_hw_init()
552 ocs_lock(&hw->cmd_lock); in ocs_hw_init()
553 if (!ocs_list_empty(&hw->cmd_head)) { in ocs_hw_init()
554 ocs_log_test(hw->os, "command found on cmd list\n"); in ocs_hw_init()
555 ocs_unlock(&hw->cmd_lock); in ocs_hw_init()
558 if (!ocs_list_empty(&hw->cmd_pending)) { in ocs_hw_init()
559 ocs_log_test(hw->os, "command found on pending list\n"); in ocs_hw_init()
560 ocs_unlock(&hw->cmd_lock); in ocs_hw_init()
563 ocs_unlock(&hw->cmd_lock); in ocs_hw_init()
570 * ocs_hw_init_io() function will re-add the IOs to the free list. in ocs_hw_init()
579 if (ocs_list_valid(&hw->io_wait_free)) { in ocs_hw_init()
580 while ((!ocs_list_empty(&hw->io_wait_free))) { in ocs_hw_init()
582 ocs_list_remove_head(&hw->io_wait_free); in ocs_hw_init()
585 ocs_log_debug(hw->os, "removed %d items from io_wait_free list\n", rem_count); in ocs_hw_init()
589 if (ocs_list_valid(&hw->io_inuse)) { in ocs_hw_init()
590 while ((!ocs_list_empty(&hw->io_inuse))) { in ocs_hw_init()
592 ocs_list_remove_head(&hw->io_inuse); in ocs_hw_init()
595 ocs_log_debug(hw->os, "removed %d items from io_inuse list\n", rem_count); in ocs_hw_init()
599 if (ocs_list_valid(&hw->io_free)) { in ocs_hw_init()
600 while ((!ocs_list_empty(&hw->io_free))) { in ocs_hw_init()
602 ocs_list_remove_head(&hw->io_free); in ocs_hw_init()
605 ocs_log_debug(hw->os, "removed %d items from io_free list\n", rem_count); in ocs_hw_init()
608 if (ocs_list_valid(&hw->io_port_owned)) { in ocs_hw_init()
609 while ((!ocs_list_empty(&hw->io_port_owned))) { in ocs_hw_init()
610 ocs_list_remove_head(&hw->io_port_owned); in ocs_hw_init()
613 ocs_list_init(&hw->io_inuse, ocs_hw_io_t, link); in ocs_hw_init()
614 ocs_list_init(&hw->io_free, ocs_hw_io_t, link); in ocs_hw_init()
615 ocs_list_init(&hw->io_port_owned, ocs_hw_io_t, link); in ocs_hw_init()
616 ocs_list_init(&hw->io_wait_free, ocs_hw_io_t, link); in ocs_hw_init()
617 ocs_list_init(&hw->io_timed_wqe, ocs_hw_io_t, wqe_link); in ocs_hw_init()
618 ocs_list_init(&hw->io_port_dnrx, ocs_hw_io_t, dnrx_link); in ocs_hw_init()
621 if (hw->config.n_rq == 1) { in ocs_hw_init()
622 hw->sli.config.features.flag.mrqp = FALSE; in ocs_hw_init()
625 if (sli_init(&hw->sli)) { in ocs_hw_init()
626 ocs_log_err(hw->os, "SLI failed to initialize\n"); in ocs_hw_init()
633 hw->auto_xfer_rdy_enabled = FALSE; in ocs_hw_init()
634 if (sli_get_auto_xfer_rdy_capable(&hw->sli) && in ocs_hw_init()
635 hw->config.auto_xfer_rdy_size > 0) { in ocs_hw_init()
636 if (hw->config.esoc){ in ocs_hw_init()
640 …written_size = sli_cmd_config_auto_xfer_rdy_hp(&hw->sli, buf, SLI4_BMBX_SIZE, hw->config.auto_xfer… in ocs_hw_init()
642 …written_size = sli_cmd_config_auto_xfer_rdy(&hw->sli, buf, SLI4_BMBX_SIZE, hw->config.auto_xfer_rd… in ocs_hw_init()
647 ocs_log_err(hw->os, "config auto xfer rdy failed\n"); in ocs_hw_init()
651 hw->auto_xfer_rdy_enabled = TRUE; in ocs_hw_init()
653 if (hw->config.auto_xfer_rdy_t10_enable) { in ocs_hw_init()
656 ocs_log_err(hw->os, "set parameters auto xfer rdy T10 PI failed\n"); in ocs_hw_init()
662 if(hw->sliport_healthcheck) { in ocs_hw_init()
665 ocs_log_err(hw->os, "Enabling Sliport Health check failed \n"); in ocs_hw_init()
673 if ((hw->sli.if_type == SLI4_IF_TYPE_LANCER_FC_ETH) && (OCS_HW_FDT_XFER_HINT != 0)) { in ocs_hw_init()
675 * Non-fatal error. In particular, we can disregard failure to set OCS_HW_FDT_XFER_HINT on in ocs_hw_init()
684 q_count = MIN(sli_get_max_queue(&hw->sli, SLI_QTYPE_EQ), in ocs_hw_init()
686 if (hw->config.n_eq > q_count) { in ocs_hw_init()
687 ocs_log_err(hw->os, "requested %d EQ but %d allowed\n", in ocs_hw_init()
688 hw->config.n_eq, q_count); in ocs_hw_init()
692 q_count = MIN(sli_get_max_queue(&hw->sli, SLI_QTYPE_CQ), in ocs_hw_init()
694 if (hw->config.n_cq > q_count) { in ocs_hw_init()
695 ocs_log_err(hw->os, "requested %d CQ but %d allowed\n", in ocs_hw_init()
696 hw->config.n_cq, q_count); in ocs_hw_init()
700 q_count = MIN(sli_get_max_queue(&hw->sli, SLI_QTYPE_MQ), in ocs_hw_init()
702 if (hw->config.n_mq > q_count) { in ocs_hw_init()
703 ocs_log_err(hw->os, "requested %d MQ but %d allowed\n", in ocs_hw_init()
704 hw->config.n_mq, q_count); in ocs_hw_init()
708 q_count = MIN(sli_get_max_queue(&hw->sli, SLI_QTYPE_RQ), in ocs_hw_init()
710 if (hw->config.n_rq > q_count) { in ocs_hw_init()
711 ocs_log_err(hw->os, "requested %d RQ but %d allowed\n", in ocs_hw_init()
712 hw->config.n_rq, q_count); in ocs_hw_init()
716 q_count = MIN(sli_get_max_queue(&hw->sli, SLI_QTYPE_WQ), in ocs_hw_init()
718 if (hw->config.n_wq > q_count) { in ocs_hw_init()
719 ocs_log_err(hw->os, "requested %d WQ but %d allowed\n", in ocs_hw_init()
720 hw->config.n_wq, q_count); in ocs_hw_init()
725 ocs_memset(hw->cq_hash, 0, sizeof(hw->cq_hash)); in ocs_hw_init()
726 ocs_log_debug(hw->os, "Max CQs %d, hash size = %d\n", in ocs_hw_init()
729 ocs_memset(hw->rq_hash, 0, sizeof(hw->rq_hash)); in ocs_hw_init()
730 ocs_log_debug(hw->os, "Max RQs %d, hash size = %d\n", in ocs_hw_init()
733 ocs_memset(hw->wq_hash, 0, sizeof(hw->wq_hash)); in ocs_hw_init()
734 ocs_log_debug(hw->os, "Max WQs %d, hash size = %d\n", in ocs_hw_init()
737 rc = ocs_hw_init_queues(hw, hw->qtop); in ocs_hw_init()
742 max_rpi = sli_get_max_rsrc(&hw->sli, SLI_RSRC_FCOE_RPI); in ocs_hw_init()
743 i = sli_fc_get_rpi_requirements(&hw->sli, max_rpi); in ocs_hw_init()
749 if (hw->rnode_mem.size) { in ocs_hw_init()
750 ocs_dma_free(hw->os, &hw->rnode_mem); in ocs_hw_init()
753 if (ocs_dma_alloc(hw->os, &hw->rnode_mem, i, 4096)) { in ocs_hw_init()
754 ocs_log_err(hw->os, "remote node memory allocation fail\n"); in ocs_hw_init()
759 if (sli_cmd_fcoe_post_hdr_templates(&hw->sli, buf, SLI4_BMBX_SIZE, in ocs_hw_init()
760 &hw->rnode_mem, UINT16_MAX, &payload_memory)) { in ocs_hw_init()
764 /* The command was non-embedded - need to free the dma buffer */ in ocs_hw_init()
765 ocs_dma_free(hw->os, &payload_memory); in ocs_hw_init()
770 ocs_log_err(hw->os, "header template registration failed\n"); in ocs_hw_init()
778 ocs_log_err(hw->os, "rx_allocate failed\n"); in ocs_hw_init()
782 /* Populate hw->seq_free_list */ in ocs_hw_init()
783 if (hw->seq_pool == NULL) { in ocs_hw_init()
788 for (i = 0; i < hw->hw_rq_count; i++) { in ocs_hw_init()
789 count += hw->hw_rq[i]->entry_count; in ocs_hw_init()
792 hw->seq_pool = ocs_array_alloc(hw->os, sizeof(ocs_hw_sequence_t), count); in ocs_hw_init()
793 if (hw->seq_pool == NULL) { in ocs_hw_init()
794 ocs_log_err(hw->os, "malloc seq_pool failed\n"); in ocs_hw_init()
800 ocs_log_err(hw->os, "WARNING - error posting RQ buffers\n"); in ocs_hw_init()
804 if (hw->rpi_ref == NULL) { in ocs_hw_init()
805 hw->rpi_ref = ocs_malloc(hw->os, max_rpi * sizeof(*hw->rpi_ref), in ocs_hw_init()
807 if (hw->rpi_ref == NULL) { in ocs_hw_init()
808 ocs_log_err(hw->os, "rpi_ref allocation failure (%d)\n", i); in ocs_hw_init()
814 ocs_atomic_init(&hw->rpi_ref[i].rpi_count, 0); in ocs_hw_init()
815 ocs_atomic_init(&hw->rpi_ref[i].rpi_attached, 0); in ocs_hw_init()
818 ocs_memset(hw->domains, 0, sizeof(hw->domains)); in ocs_hw_init()
821 if (hw->workaround.override_fcfi) { in ocs_hw_init()
822 hw->first_domain_idx = -1; in ocs_hw_init()
825 ocs_memset(hw->fcf_index_fcfi, 0, sizeof(hw->fcf_index_fcfi)); in ocs_hw_init()
828 if (sli_get_medium(&hw->sli) == SLI_LINK_MEDIUM_FC) { in ocs_hw_init()
829 if (hw->hw_mrq_count) { in ocs_hw_init()
830 ocs_log_debug(hw->os, "using REG_FCFI MRQ\n"); in ocs_hw_init()
834 ocs_log_err(hw->os, "REG_FCFI_MRQ FCFI registration failed\n"); in ocs_hw_init()
840 ocs_log_err(hw->os, "REG_FCFI_MRQ MRQ registration failed\n"); in ocs_hw_init()
846 ocs_log_debug(hw->os, "using REG_FCFI standard\n"); in ocs_hw_init()
851 rq_cfg[i].r_ctl_mask = (uint8_t) hw->config.filter_def[i]; in ocs_hw_init()
852 rq_cfg[i].r_ctl_match = (uint8_t) (hw->config.filter_def[i] >> 8); in ocs_hw_init()
853 rq_cfg[i].type_mask = (uint8_t) (hw->config.filter_def[i] >> 16); in ocs_hw_init()
854 rq_cfg[i].type_match = (uint8_t) (hw->config.filter_def[i] >> 24); in ocs_hw_init()
861 for (i = 0; i < OCS_MIN(hw->hw_rq_count, SLI4_CMD_REG_FCFI_NUM_RQ_CFG); i++) { in ocs_hw_init()
862 hw_rq_t *rq = hw->hw_rq[i]; in ocs_hw_init()
865 uint32_t mask = (rq->filter_mask != 0) ? rq->filter_mask : 1; in ocs_hw_init()
867 rq_cfg[j].rq_id = rq->hdr->id; in ocs_hw_init()
868 ocs_log_debug(hw->os, "REG_FCFI: filter[%d] %08X -> RQ[%d] id=%d\n", in ocs_hw_init()
869 j, hw->config.filter_def[j], i, rq->hdr->id); in ocs_hw_init()
876 if (sli_cmd_reg_fcfi(&hw->sli, buf, SLI4_BMBX_SIZE, 0, rq_cfg, 0)) { in ocs_hw_init()
881 ocs_log_err(hw->os, "FCFI registration failed\n"); in ocs_hw_init()
884 hw->fcf_indicator = ((sli4_cmd_reg_fcfi_t *)buf)->fcfi; in ocs_hw_init()
894 ocs_log_err(hw->os, "ocs_pool_alloc hw_wq_callback_t failed: %d\n", rc); in ocs_hw_init()
900 ocs_log_err(hw->os, "IO allocation failure\n"); in ocs_hw_init()
906 ocs_log_err(hw->os, "IO initialization failure\n"); in ocs_hw_init()
910 ocs_queue_history_init(hw->os, &hw->q_hist); in ocs_hw_init()
913 hw->linkcfg = OCS_HW_LINKCFG_NA; in ocs_hw_init()
917 if ((hw->sli.if_type == SLI4_IF_TYPE_LANCER_FC_ETH) && in ocs_hw_init()
918 (sli_get_medium(&hw->sli) == SLI_LINK_MEDIUM_ETHERNET)) { in ocs_hw_init()
919 if (ocs_hw_set_eth_license(hw, hw->eth_license)) { in ocs_hw_init()
921 ocs_log_err(hw->os, "Failed to set ethernet license\n"); in ocs_hw_init()
925 /* Set the DIF seed - only for lancer right now */ in ocs_hw_init()
926 if (SLI4_IF_TYPE_LANCER_FC_ETH == sli_get_if_type(&hw->sli) && in ocs_hw_init()
928 ocs_log_err(hw->os, "Failed to set DIF seed value\n"); in ocs_hw_init()
932 /* Set the DIF mode - skyhawk only */ in ocs_hw_init()
933 if (SLI4_IF_TYPE_BE3_SKH_PF == sli_get_if_type(&hw->sli) && in ocs_hw_init()
934 sli_get_dif_capable(&hw->sli)) { in ocs_hw_init()
937 ocs_log_err(hw->os, "Failed to set DIF mode value\n"); in ocs_hw_init()
945 for (i = 0; i < hw->eq_count; i++) { in ocs_hw_init()
946 sli_queue_arm(&hw->sli, &hw->eq[i], TRUE); in ocs_hw_init()
952 for (i = 0; i < hw->rq_count; i++) { in ocs_hw_init()
953 ocs_hw_queue_hash_add(hw->rq_hash, hw->rq[i].id, i); in ocs_hw_init()
959 for (i = 0; i < hw->wq_count; i++) { in ocs_hw_init()
960 ocs_hw_queue_hash_add(hw->wq_hash, hw->wq[i].id, i); in ocs_hw_init()
966 for (i = 0; i < hw->cq_count; i++) { in ocs_hw_init()
967 ocs_hw_queue_hash_add(hw->cq_hash, hw->cq[i].id, i); in ocs_hw_init()
968 sli_queue_arm(&hw->sli, &hw->cq[i], TRUE); in ocs_hw_init()
972 hw->state = OCS_HW_STATE_ACTIVE; in ocs_hw_init()
976 ocs_log_err(hw->os, "WARNING - error initializing RQ pair\n"); in ocs_hw_init()
980 if (hw->config.emulate_wqe_timeout) { in ocs_hw_init()
981 ocs_setup_timer(hw->os, &hw->wqe_timer, target_wqe_timer_cb, hw, in ocs_hw_init()
989 if ((count = ocs_varray_get_count(hw->wq_class_array[1])) > 0) { in ocs_hw_init()
991 hw_wq_t *wq = ocs_varray_iter_next(hw->wq_class_array[1]); in ocs_hw_init()
992 wq->send_frame_io = ocs_hw_io_alloc(hw); in ocs_hw_init()
993 if (wq->send_frame_io == NULL) { in ocs_hw_init()
994 ocs_log_err(hw->os, "ocs_hw_io_alloc for send_frame_io failed\n"); in ocs_hw_init()
998 hw->hw_wq[0]->send_frame_io = ocs_hw_io_alloc(hw); in ocs_hw_init()
999 if (hw->hw_wq[0]->send_frame_io == NULL) { in ocs_hw_init()
1000 ocs_log_err(hw->os, "ocs_hw_io_alloc for send_frame_io failed\n"); in ocs_hw_init()
1005 ocs_atomic_init(&hw->send_frame_seq_id, 0); in ocs_hw_init()
1008 hw->expiration_logged = 0; in ocs_hw_init()
1009 if(hw->watchdog_timeout) { in ocs_hw_init()
1010 if((hw->watchdog_timeout < 1) || (hw->watchdog_timeout > 65534)) { in ocs_hw_init()
1011 ocs_log_err(hw->os, "watchdog_timeout out of range: Valid range is 1 - 65534\n"); in ocs_hw_init()
1013 …ocs_log_info(hw->os, "watchdog timer configured with timeout = %d seconds \n", hw->watchdog_timeou… in ocs_hw_init()
1017 if (ocs_dma_alloc(hw->os, &hw->domain_dmem, 112, 4)) { in ocs_hw_init()
1018 ocs_log_err(hw->os, "domain node memory allocation fail\n"); in ocs_hw_init()
1022 if (ocs_dma_alloc(hw->os, &hw->fcf_dmem, OCS_HW_READ_FCF_SIZE, OCS_HW_READ_FCF_SIZE)) { in ocs_hw_init()
1023 ocs_log_err(hw->os, "domain fcf memory allocation fail\n"); in ocs_hw_init()
1027 if ((0 == hw->loop_map.size) && ocs_dma_alloc(hw->os, &hw->loop_map, in ocs_hw_init()
1029 ocs_log_err(hw->os, "Loop dma alloc failed size:%d \n", hw->loop_map.size); in ocs_hw_init()
1036 * @brief Configure Multi-RQ
1043 * @return Returns 0 on success, or a non-zero value on failure.
1062 rq_filter[i].r_ctl_mask = (uint8_t) hw->config.filter_def[i]; in ocs_hw_config_mrq()
1063 rq_filter[i].r_ctl_match = (uint8_t) (hw->config.filter_def[i] >> 8); in ocs_hw_config_mrq()
1064 rq_filter[i].type_mask = (uint8_t) (hw->config.filter_def[i] >> 16); in ocs_hw_config_mrq()
1065 rq_filter[i].type_match = (uint8_t) (hw->config.filter_def[i] >> 24); in ocs_hw_config_mrq()
1069 for (i = 0; i < hw->hw_rq_count; i++) { in ocs_hw_config_mrq()
1070 rq = hw->hw_rq[i]; in ocs_hw_config_mrq()
1072 if (rq->filter_mask & (1U << j)) { in ocs_hw_config_mrq()
1075 if (!rq->is_mrq || (rq_filter[j].rq_id != rq->base_mrq_id)) { in ocs_hw_config_mrq()
1076 ocs_log_err(hw->os, "Wrong queue topology.\n"); in ocs_hw_config_mrq()
1082 if (rq->is_mrq) { in ocs_hw_config_mrq()
1083 rq_filter[j].rq_id = rq->base_mrq_id; in ocs_hw_config_mrq()
1086 rq_filter[j].rq_id = rq->hdr->id; in ocs_hw_config_mrq()
1094 rc = sli_cmd_reg_fcfi_mrq(&hw->sli, in ocs_hw_config_mrq()
1100 hw->config.rq_selection_policy, /* RQ selection policy*/ in ocs_hw_config_mrq()
1102 hw->hw_mrq_count, /* num_mrqs */ in ocs_hw_config_mrq()
1105 ocs_log_err(hw->os, "sli_cmd_reg_fcfi_mrq() failed: %d\n", rc); in ocs_hw_config_mrq()
1113 if ((rc != OCS_HW_RTN_SUCCESS) || (rsp->hdr.status)) { in ocs_hw_config_mrq()
1114 ocs_log_err(hw->os, "FCFI MRQ registration failed. cmd = %x status = %x\n", in ocs_hw_config_mrq()
1115 rsp->hdr.command, rsp->hdr.status); in ocs_hw_config_mrq()
1120 hw->fcf_indicator = rsp->fcfi; in ocs_hw_config_mrq()
1139 hw->linkcfg = (ocs_hw_linkcfg_e)value; in ocs_hw_init_linkcfg_cb()
1141 hw->linkcfg = OCS_HW_LINKCFG_NA; in ocs_hw_init_linkcfg_cb()
1143 ocs_log_debug(hw->os, "linkcfg=%d\n", hw->linkcfg); in ocs_hw_init_linkcfg_cb()
1156 * @return Returns 0 on success, or a non-zero value on failure.
1172 destroy_queues = (hw->state == OCS_HW_STATE_ACTIVE); in ocs_hw_teardown()
1173 free_memory = (hw->state != OCS_HW_STATE_UNINITIALIZED); in ocs_hw_teardown()
1179 if(hw->watchdog_timeout) { in ocs_hw_teardown()
1180 hw->watchdog_timeout = 0; in ocs_hw_teardown()
1185 if(hw->sliport_healthcheck) { in ocs_hw_teardown()
1186 hw->sliport_healthcheck = 0; in ocs_hw_teardown()
1190 if (hw->state != OCS_HW_STATE_QUEUES_ALLOCATED) { in ocs_hw_teardown()
1191 hw->state = OCS_HW_STATE_TEARDOWN_IN_PROGRESS; in ocs_hw_teardown()
1196 while (!ocs_list_empty(&hw->cmd_head) && iters) { in ocs_hw_teardown()
1199 iters--; in ocs_hw_teardown()
1202 if (ocs_list_empty(&hw->cmd_head)) { in ocs_hw_teardown()
1203 ocs_log_debug(hw->os, "All commands completed on MQ queue\n"); in ocs_hw_teardown()
1205 ocs_log_debug(hw->os, "Some commands still pending on MQ queue\n"); in ocs_hw_teardown()
1211 hw->state = OCS_HW_STATE_TEARDOWN_IN_PROGRESS; in ocs_hw_teardown()
1214 ocs_lock_free(&hw->cmd_lock); in ocs_hw_teardown()
1217 if (hw->workaround.use_unregistered_rpi) { in ocs_hw_teardown()
1218 sli_resource_free(&hw->sli, SLI_RSRC_FCOE_RPI, hw->workaround.unregistered_rid); in ocs_hw_teardown()
1221 max_rpi = sli_get_max_rsrc(&hw->sli, SLI_RSRC_FCOE_RPI); in ocs_hw_teardown()
1222 if (hw->rpi_ref) { in ocs_hw_teardown()
1224 if (ocs_atomic_read(&hw->rpi_ref[i].rpi_count)) { in ocs_hw_teardown()
1225 ocs_log_debug(hw->os, "non-zero ref [%d]=%d\n", in ocs_hw_teardown()
1226 i, ocs_atomic_read(&hw->rpi_ref[i].rpi_count)); in ocs_hw_teardown()
1229 ocs_free(hw->os, hw->rpi_ref, max_rpi * sizeof(*hw->rpi_ref)); in ocs_hw_teardown()
1230 hw->rpi_ref = NULL; in ocs_hw_teardown()
1233 ocs_dma_free(hw->os, &hw->rnode_mem); in ocs_hw_teardown()
1235 if (hw->io) { in ocs_hw_teardown()
1236 for (i = 0; i < hw->config.n_io; i++) { in ocs_hw_teardown()
1237 if (hw->io[i] && (hw->io[i]->sgl != NULL) && in ocs_hw_teardown()
1238 (hw->io[i]->sgl->virt != NULL)) { in ocs_hw_teardown()
1239 if(hw->io[i]->is_port_owned) { in ocs_hw_teardown()
1240 ocs_lock_free(&hw->io[i]->axr_lock); in ocs_hw_teardown()
1242 ocs_dma_free(hw->os, hw->io[i]->sgl); in ocs_hw_teardown()
1244 ocs_free(hw->os, hw->io[i], sizeof(ocs_hw_io_t)); in ocs_hw_teardown()
1245 hw->io[i] = NULL; in ocs_hw_teardown()
1247 ocs_free(hw->os, hw->wqe_buffs, hw->config.n_io * hw->sli.config.wqe_size); in ocs_hw_teardown()
1248 hw->wqe_buffs = NULL; in ocs_hw_teardown()
1249 ocs_free(hw->os, hw->io, hw->config.n_io * sizeof(ocs_hw_io_t *)); in ocs_hw_teardown()
1250 hw->io = NULL; in ocs_hw_teardown()
1253 ocs_dma_free(hw->os, &hw->xfer_rdy); in ocs_hw_teardown()
1254 ocs_dma_free(hw->os, &hw->dump_sges); in ocs_hw_teardown()
1255 ocs_dma_free(hw->os, &hw->loop_map); in ocs_hw_teardown()
1257 ocs_lock_free(&hw->io_lock); in ocs_hw_teardown()
1258 ocs_lock_free(&hw->io_abort_lock); in ocs_hw_teardown()
1260 for (i = 0; i < hw->wq_count; i++) { in ocs_hw_teardown()
1261 sli_queue_free(&hw->sli, &hw->wq[i], destroy_queues, free_memory); in ocs_hw_teardown()
1264 for (i = 0; i < hw->rq_count; i++) { in ocs_hw_teardown()
1265 sli_queue_free(&hw->sli, &hw->rq[i], destroy_queues, free_memory); in ocs_hw_teardown()
1268 for (i = 0; i < hw->mq_count; i++) { in ocs_hw_teardown()
1269 sli_queue_free(&hw->sli, &hw->mq[i], destroy_queues, free_memory); in ocs_hw_teardown()
1272 for (i = 0; i < hw->cq_count; i++) { in ocs_hw_teardown()
1273 sli_queue_free(&hw->sli, &hw->cq[i], destroy_queues, free_memory); in ocs_hw_teardown()
1276 for (i = 0; i < hw->eq_count; i++) { in ocs_hw_teardown()
1277 sli_queue_free(&hw->sli, &hw->eq[i], destroy_queues, free_memory); in ocs_hw_teardown()
1280 ocs_hw_qtop_free(hw->qtop); in ocs_hw_teardown()
1289 if (sli_teardown(&hw->sli)) { in ocs_hw_teardown()
1290 ocs_log_err(hw->os, "SLI teardown failed\n"); in ocs_hw_teardown()
1293 ocs_queue_history_free(&hw->q_hist); in ocs_hw_teardown()
1295 /* record the fact that the queues are non-functional */ in ocs_hw_teardown()
1296 hw->state = OCS_HW_STATE_UNINITIALIZED; in ocs_hw_teardown()
1299 ocs_array_free(hw->seq_pool); in ocs_hw_teardown()
1300 hw->seq_pool = NULL; in ocs_hw_teardown()
1303 ocs_pool_free(hw->wq_reqtag_pool); in ocs_hw_teardown()
1305 ocs_dma_free(hw->os, &hw->domain_dmem); in ocs_hw_teardown()
1306 ocs_dma_free(hw->os, &hw->fcf_dmem); in ocs_hw_teardown()
1308 hw->hw_setup_called = FALSE; in ocs_hw_teardown()
1319 ocs_hw_state_e prev_state = hw->state; in ocs_hw_reset()
1321 if (hw->state != OCS_HW_STATE_ACTIVE) { in ocs_hw_reset()
1322 ocs_log_test(hw->os, "HW state %d is not active\n", hw->state); in ocs_hw_reset()
1325 hw->state = OCS_HW_STATE_RESET_IN_PROGRESS; in ocs_hw_reset()
1338 while (!ocs_list_empty(&hw->cmd_head) && iters) { in ocs_hw_reset()
1341 iters--; in ocs_hw_reset()
1344 if (ocs_list_empty(&hw->cmd_head)) { in ocs_hw_reset()
1345 ocs_log_debug(hw->os, "All commands completed on MQ queue\n"); in ocs_hw_reset()
1347 ocs_log_debug(hw->os, "Some commands still pending on MQ queue\n"); in ocs_hw_reset()
1353 ocs_log_debug(hw->os, "issuing function level reset\n"); in ocs_hw_reset()
1354 if (sli_reset(&hw->sli)) { in ocs_hw_reset()
1355 ocs_log_err(hw->os, "sli_reset failed\n"); in ocs_hw_reset()
1360 ocs_log_debug(hw->os, "issuing firmware reset\n"); in ocs_hw_reset()
1361 if (sli_fw_reset(&hw->sli)) { in ocs_hw_reset()
1362 ocs_log_err(hw->os, "sli_soft_reset failed\n"); in ocs_hw_reset()
1366 * Because the FW reset leaves the FW in a non-running state, in ocs_hw_reset()
1369 ocs_log_debug(hw->os, "issuing function level reset\n"); in ocs_hw_reset()
1370 if (sli_reset(&hw->sli)) { in ocs_hw_reset()
1371 ocs_log_err(hw->os, "sli_reset failed\n"); in ocs_hw_reset()
1376 ocs_log_test(hw->os, "unknown reset type - no reset performed\n"); in ocs_hw_reset()
1377 hw->state = prev_state; in ocs_hw_reset()
1388 ocs_memset(hw->domains, 0, sizeof(hw->domains)); in ocs_hw_reset()
1389 ocs_memset(hw->fcf_index_fcfi, 0, sizeof(hw->fcf_index_fcfi)); in ocs_hw_reset()
1393 ocs_lock(&hw->io_lock); in ocs_hw_reset()
1395 while (!ocs_list_empty(&hw->io_timed_wqe)) { in ocs_hw_reset()
1396 ocs_list_remove_head(&hw->io_timed_wqe); in ocs_hw_reset()
1400 while (!ocs_list_empty(&hw->io_free)) { in ocs_hw_reset()
1401 ocs_list_remove_head(&hw->io_free); in ocs_hw_reset()
1403 while (!ocs_list_empty(&hw->io_wait_free)) { in ocs_hw_reset()
1404 ocs_list_remove_head(&hw->io_wait_free); in ocs_hw_reset()
1410 ocs_unlock(&hw->io_lock); in ocs_hw_reset()
1414 for (i = 0; i < hw->wq_count; i++) { in ocs_hw_reset()
1415 sli_queue_reset(&hw->sli, &hw->wq[i]); in ocs_hw_reset()
1418 for (i = 0; i < hw->rq_count; i++) { in ocs_hw_reset()
1419 sli_queue_reset(&hw->sli, &hw->rq[i]); in ocs_hw_reset()
1422 for (i = 0; i < hw->hw_rq_count; i++) { in ocs_hw_reset()
1423 hw_rq_t *rq = hw->hw_rq[i]; in ocs_hw_reset()
1424 if (rq->rq_tracker != NULL) { in ocs_hw_reset()
1427 for (j = 0; j < rq->entry_count; j++) { in ocs_hw_reset()
1428 rq->rq_tracker[j] = NULL; in ocs_hw_reset()
1433 for (i = 0; i < hw->mq_count; i++) { in ocs_hw_reset()
1434 sli_queue_reset(&hw->sli, &hw->mq[i]); in ocs_hw_reset()
1437 for (i = 0; i < hw->cq_count; i++) { in ocs_hw_reset()
1438 sli_queue_reset(&hw->sli, &hw->cq[i]); in ocs_hw_reset()
1441 for (i = 0; i < hw->eq_count; i++) { in ocs_hw_reset()
1442 sli_queue_reset(&hw->sli, &hw->eq[i]); in ocs_hw_reset()
1456 * Re-apply the run-time workarounds after clearing the SLI config in ocs_hw_reset()
1460 hw->state = OCS_HW_STATE_QUEUES_ALLOCATED; in ocs_hw_reset()
1468 return hw->eq_count; in ocs_hw_get_num_eq()
1477 return (sli_reg_read(&hw->sli, SLI4_REG_SLIPORT_ERROR1) == 0x2 && in ocs_hw_get_fw_timed_out()
1478 sli_reg_read(&hw->sli, SLI4_REG_SLIPORT_ERROR2) == 0x10); in ocs_hw_get_fw_timed_out()
1495 *value = hw->config.n_io; in ocs_hw_get()
1498 *value = (hw->config.n_sgl - SLI4_SGE_MAX_RESERVED); in ocs_hw_get()
1501 *value = sli_get_max_rsrc(&hw->sli, SLI_RSRC_FCOE_XRI); in ocs_hw_get()
1504 *value = sli_get_max_rsrc(&hw->sli, SLI_RSRC_FCOE_RPI); in ocs_hw_get()
1507 *value = hw->num_qentries[SLI_QTYPE_RQ]; in ocs_hw_get()
1510 *value = hw->config.rq_default_buffer_size; in ocs_hw_get()
1513 *value = sli_get_auto_xfer_rdy_capable(&hw->sli); in ocs_hw_get()
1516 *value = hw->config.auto_xfer_rdy_xri_cnt; in ocs_hw_get()
1519 *value = hw->config.auto_xfer_rdy_size; in ocs_hw_get()
1522 switch (hw->config.auto_xfer_rdy_blk_size_chip) { in ocs_hw_get()
1545 *value = hw->config.auto_xfer_rdy_t10_enable; in ocs_hw_get()
1548 *value = hw->config.auto_xfer_rdy_p_type; in ocs_hw_get()
1551 *value = hw->config.auto_xfer_rdy_ref_tag_is_lba; in ocs_hw_get()
1554 *value = hw->config.auto_xfer_rdy_app_tag_valid; in ocs_hw_get()
1557 *value = hw->config.auto_xfer_rdy_app_tag_value; in ocs_hw_get()
1560 *value = sli_get_max_sge(&hw->sli); in ocs_hw_get()
1563 *value = sli_get_max_sgl(&hw->sli); in ocs_hw_get()
1570 if (hw->link.speed == 0) { in ocs_hw_get()
1574 switch (hw->link.topology) { in ocs_hw_get()
1585 ocs_log_test(hw->os, "unsupported topology %#x\n", hw->link.topology); in ocs_hw_get()
1591 *value = hw->config.topology; in ocs_hw_get()
1594 *value = hw->link.speed; in ocs_hw_get()
1597 switch (hw->config.speed) { in ocs_hw_get()
1620 ocs_log_test(hw->os, "unsupported speed %#x\n", hw->config.speed); in ocs_hw_get()
1626 *value = sli_get_if_type(&hw->sli); in ocs_hw_get()
1629 *value = sli_get_sli_rev(&hw->sli); in ocs_hw_get()
1632 *value = sli_get_sli_family(&hw->sli); in ocs_hw_get()
1635 *value = sli_get_dif_capable(&hw->sli); in ocs_hw_get()
1638 *value = hw->config.dif_seed; in ocs_hw_get()
1641 *value = hw->config.dif_mode; in ocs_hw_get()
1645 if (hw->sli.if_type == SLI4_IF_TYPE_LANCER_FC_ETH) { in ocs_hw_get()
1652 *value = hw->dump_size; in ocs_hw_get()
1655 *value = sli_dump_is_ready(&hw->sli); in ocs_hw_get()
1658 *value = sli_dump_is_present(&hw->sli); in ocs_hw_get()
1661 tmp = sli_reset_required(&hw->sli); in ocs_hw_get()
1669 *value = sli_fw_error_status(&hw->sli); in ocs_hw_get()
1672 *value = sli_fw_ready(&hw->sli); in ocs_hw_get()
1678 *value = sli_get_hlm_capable(&hw->sli); in ocs_hw_get()
1681 *value = sli_get_sgl_preregister_required(&hw->sli); in ocs_hw_get()
1684 *value = sli_get_hw_revision(&hw->sli, 0); in ocs_hw_get()
1687 *value = sli_get_hw_revision(&hw->sli, 1); in ocs_hw_get()
1690 *value = sli_get_hw_revision(&hw->sli, 2); in ocs_hw_get()
1693 *value = hw->linkcfg; in ocs_hw_get()
1696 *value = hw->eth_license; in ocs_hw_get()
1699 *value = sli_get_link_module_type(&hw->sli); in ocs_hw_get()
1705 *value = hw->workaround.disable_ar_tgt_dif; in ocs_hw_get()
1708 *value = hw->config.i_only_aab; in ocs_hw_get()
1711 *value = hw->config.emulate_wqe_timeout; in ocs_hw_get()
1714 *value = sli_get_vpd_len(&hw->sli); in ocs_hw_get()
1717 *value = sli_get_is_sgl_chaining_capable(&hw->sli) || hw->workaround.sglc_misreported; in ocs_hw_get()
1723 * 2. Skyhawk with pre-registered SGL Lists in ocs_hw_get()
1726 if ((sli_get_is_sgl_chaining_capable(&hw->sli) || hw->workaround.sglc_misreported) && in ocs_hw_get()
1727 !sli_get_sgl_preregister(&hw->sli) && in ocs_hw_get()
1728 SLI4_IF_TYPE_LANCER_FC_ETH == sli_get_if_type(&hw->sli)) { in ocs_hw_get()
1732 if ((sli_get_is_sgl_chaining_capable(&hw->sli) || hw->workaround.sglc_misreported) && in ocs_hw_get()
1733 sli_get_sgl_preregister(&hw->sli) && in ocs_hw_get()
1734 ((SLI4_IF_TYPE_BE3_SKH_PF == sli_get_if_type(&hw->sli)) || in ocs_hw_get()
1735 (SLI4_IF_TYPE_BE3_SKH_VF == sli_get_if_type(&hw->sli)))) { in ocs_hw_get()
1741 *value = ((sli_get_is_sgl_chaining_capable(&hw->sli) || hw->workaround.sglc_misreported) && in ocs_hw_get()
1742 (SLI4_IF_TYPE_LANCER_FC_ETH == sli_get_if_type(&hw->sli))); in ocs_hw_get()
1745 if (hw->workaround.ignore_send_frame) { in ocs_hw_get()
1749 *value = sli_get_if_type(&hw->sli) == SLI4_IF_TYPE_LANCER_FC_ETH; in ocs_hw_get()
1753 *value = hw->config.rq_selection_policy; in ocs_hw_get()
1756 *value = hw->config.rr_quanta; in ocs_hw_get()
1759 *value = sli_get_max_rsrc(&hw->sli, SLI_RSRC_FCOE_VPI); in ocs_hw_get()
1762 ocs_log_test(hw->os, "unsupported property %#x\n", prop); in ocs_hw_get()
1776 rc = sli_get_wwn_node(&hw->sli); in ocs_hw_get_ptr()
1779 rc = sli_get_wwn_port(&hw->sli); in ocs_hw_get_ptr()
1782 /* make sure VPD length is non-zero */ in ocs_hw_get_ptr()
1783 if (sli_get_vpd_len(&hw->sli)) { in ocs_hw_get_ptr()
1784 rc = sli_get_vpd(&hw->sli); in ocs_hw_get_ptr()
1788 rc = sli_get_fw_name(&hw->sli, 0); in ocs_hw_get_ptr()
1791 rc = sli_get_fw_name(&hw->sli, 1); in ocs_hw_get_ptr()
1794 rc = sli_get_ipl_name(&hw->sli); in ocs_hw_get_ptr()
1797 rc = sli_get_portnum(&hw->sli); in ocs_hw_get_ptr()
1800 rc = sli_get_bios_version_string(&hw->sli); in ocs_hw_get_ptr()
1803 ocs_log_test(hw->os, "unsupported property %#x\n", prop); in ocs_hw_get_ptr()
1816 if (value > sli_get_max_rsrc(&hw->sli, SLI_RSRC_FCOE_XRI) || in ocs_hw_set()
1818 ocs_log_test(hw->os, "IO value out of range %d vs %d\n", in ocs_hw_set()
1819 value, sli_get_max_rsrc(&hw->sli, SLI_RSRC_FCOE_XRI)); in ocs_hw_set()
1822 hw->config.n_io = value; in ocs_hw_set()
1827 if (value > sli_get_max_sgl(&hw->sli)) { in ocs_hw_set()
1828 ocs_log_test(hw->os, "SGL value out of range %d vs %d\n", in ocs_hw_set()
1829 value, sli_get_max_sgl(&hw->sli)); in ocs_hw_set()
1832 hw->config.n_sgl = value; in ocs_hw_set()
1836 if ((sli_get_medium(&hw->sli) != SLI_LINK_MEDIUM_FC) && in ocs_hw_set()
1838 ocs_log_test(hw->os, "unsupported topology=%#x medium=%#x\n", in ocs_hw_set()
1839 value, sli_get_medium(&hw->sli)); in ocs_hw_set()
1846 if (sli_get_medium(&hw->sli) == SLI_LINK_MEDIUM_FC) { in ocs_hw_set()
1847 sli_set_topology(&hw->sli, SLI4_READ_CFG_TOPO_FC); in ocs_hw_set()
1849 sli_set_topology(&hw->sli, SLI4_READ_CFG_TOPO_FCOE); in ocs_hw_set()
1853 sli_set_topology(&hw->sli, SLI4_READ_CFG_TOPO_FC_DA); in ocs_hw_set()
1856 sli_set_topology(&hw->sli, SLI4_READ_CFG_TOPO_FC_AL); in ocs_hw_set()
1859 ocs_log_test(hw->os, "unsupported topology %#x\n", value); in ocs_hw_set()
1862 hw->config.topology = value; in ocs_hw_set()
1865 if (sli_get_medium(&hw->sli) != SLI_LINK_MEDIUM_FC) { in ocs_hw_set()
1867 case 0: /* Auto-speed negotiation */ in ocs_hw_set()
1869 hw->config.speed = FC_LINK_SPEED_10G; in ocs_hw_set()
1872 ocs_log_test(hw->os, "unsupported speed=%#x medium=%#x\n", in ocs_hw_set()
1873 value, sli_get_medium(&hw->sli)); in ocs_hw_set()
1880 case 0: /* Auto-speed negotiation */ in ocs_hw_set()
1881 hw->config.speed = FC_LINK_SPEED_AUTO_16_8_4; in ocs_hw_set()
1884 hw->config.speed = FC_LINK_SPEED_2G; in ocs_hw_set()
1887 hw->config.speed = FC_LINK_SPEED_4G; in ocs_hw_set()
1890 hw->config.speed = FC_LINK_SPEED_8G; in ocs_hw_set()
1893 hw->config.speed = FC_LINK_SPEED_16G; in ocs_hw_set()
1896 hw->config.speed = FC_LINK_SPEED_32G; in ocs_hw_set()
1899 ocs_log_test(hw->os, "unsupported speed %d\n", value); in ocs_hw_set()
1904 /* Set the DIF seed - only for lancer right now */ in ocs_hw_set()
1905 if (SLI4_IF_TYPE_LANCER_FC_ETH != sli_get_if_type(&hw->sli)) { in ocs_hw_set()
1906 ocs_log_test(hw->os, "DIF seed not supported for this device\n"); in ocs_hw_set()
1909 hw->config.dif_seed = value; in ocs_hw_set()
1921 if (sli_is_dif_inline_capable(&hw->sli)) { in ocs_hw_set()
1922 hw->config.dif_mode = value; in ocs_hw_set()
1924 ocs_log_test(hw->os, "chip does not support DIF inline\n"); in ocs_hw_set()
1930 if (sli_is_dif_separate_capable(&hw->sli)) { in ocs_hw_set()
1931 hw->config.dif_mode = value; in ocs_hw_set()
1933 ocs_log_test(hw->os, "chip does not support DIF separate\n"); in ocs_hw_set()
1943 for (i = 0; i < hw->hw_rq_count; i++) { in ocs_hw_set()
1944 rq = hw->hw_rq[i]; in ocs_hw_set()
1945 hw->cq[rq->cq->instance].proc_limit = value; in ocs_hw_set()
1950 hw->config.rq_default_buffer_size = value; in ocs_hw_set()
1953 hw->config.auto_xfer_rdy_xri_cnt = value; in ocs_hw_set()
1956 hw->config.auto_xfer_rdy_size = value; in ocs_hw_set()
1961 hw->config.auto_xfer_rdy_blk_size_chip = 0; in ocs_hw_set()
1964 hw->config.auto_xfer_rdy_blk_size_chip = 1; in ocs_hw_set()
1967 hw->config.auto_xfer_rdy_blk_size_chip = 2; in ocs_hw_set()
1970 hw->config.auto_xfer_rdy_blk_size_chip = 3; in ocs_hw_set()
1973 hw->config.auto_xfer_rdy_blk_size_chip = 4; in ocs_hw_set()
1976 ocs_log_err(hw->os, "Invalid block size %d\n", in ocs_hw_set()
1982 hw->config.auto_xfer_rdy_t10_enable = value; in ocs_hw_set()
1985 hw->config.auto_xfer_rdy_p_type = value; in ocs_hw_set()
1988 hw->config.auto_xfer_rdy_ref_tag_is_lba = value; in ocs_hw_set()
1991 hw->config.auto_xfer_rdy_app_tag_valid = value; in ocs_hw_set()
1994 hw->config.auto_xfer_rdy_app_tag_value = value; in ocs_hw_set()
1997 hw->config.esoc = value; in ocs_hw_set()
2000 rc = sli_set_hlm(&hw->sli, value); in ocs_hw_set()
2003 rc = sli_set_sgl_preregister(&hw->sli, value); in ocs_hw_set()
2006 hw->eth_license = value; in ocs_hw_set()
2009 hw->config.i_only_aab = value; in ocs_hw_set()
2012 hw->config.emulate_wqe_timeout = value; in ocs_hw_set()
2015 hw->config.bounce = value; in ocs_hw_set()
2018 hw->config.rq_selection_policy = value; in ocs_hw_set()
2021 hw->config.rr_quanta = value; in ocs_hw_set()
2024 ocs_log_test(hw->os, "unsupported property %#x\n", prop); in ocs_hw_set()
2038 hw->hw_war_version = value; in ocs_hw_set_ptr()
2044 for (idx = 0; idx < ARRAY_SIZE(hw->config.filter_def); idx++) { in ocs_hw_set_ptr()
2045 hw->config.filter_def[idx] = 0; in ocs_hw_set_ptr()
2048 for (idx = 0; (idx < ARRAY_SIZE(hw->config.filter_def)) && (p != NULL) && *p; ) { in ocs_hw_set_ptr()
2049 hw->config.filter_def[idx++] = ocs_strtoul(p, 0, 0); in ocs_hw_set_ptr()
2059 ocs_log_test(hw->os, "unsupported property %#x\n", prop); in ocs_hw_set_ptr()
2070 * @param vector Zero-based interrupt vector number.
2072 * @return Returns 0 on success, or a non-zero value on failure.
2081 return -1; in ocs_hw_event_check()
2084 if (vector > hw->eq_count) { in ocs_hw_event_check()
2085 ocs_log_err(hw->os, "vector %d. max %d\n", in ocs_hw_event_check()
2086 vector, hw->eq_count); in ocs_hw_event_check()
2087 return -1; in ocs_hw_event_check()
2093 * OCS_HW_STATE_UNINITIALIZED - No queues allocated in ocs_hw_event_check()
2094 * OCS_HW_STATE_QUEUES_ALLOCATED - The state after a chip reset, in ocs_hw_event_check()
2096 * OCS_HW_STATE_ACTIVE - Chip and queues are operational in ocs_hw_event_check()
2097 * OCS_HW_STATE_RESET_IN_PROGRESS - reset, we still want completions in ocs_hw_event_check()
2098 * OCS_HW_STATE_TEARDOWN_IN_PROGRESS - We still want mailbox in ocs_hw_event_check()
2101 if (hw->state != OCS_HW_STATE_UNINITIALIZED) { in ocs_hw_event_check()
2102 rc = sli_queue_is_empty(&hw->sli, &hw->eq[vector]); in ocs_hw_event_check()
2104 /* Re-arm queue if there are no entries */ in ocs_hw_event_check()
2106 sli_queue_arm(&hw->sli, &hw->eq[vector], TRUE); in ocs_hw_event_check()
2116 ocs_hw_t *hw = seq->hw; in ocs_hw_unsol_process_bounce()
2119 ocs_hw_assert(hw->callback.unsolicited != NULL); in ocs_hw_unsol_process_bounce()
2121 hw->callback.unsolicited(hw->args.unsolicited, seq); in ocs_hw_unsol_process_bounce()
2135 * OCS_HW_STATE_UNINITIALIZED - No queues allocated in ocs_hw_process()
2136 * OCS_HW_STATE_QUEUES_ALLOCATED - The state after a chip reset, in ocs_hw_process()
2138 * OCS_HW_STATE_ACTIVE - Chip and queues are operational in ocs_hw_process()
2139 * OCS_HW_STATE_RESET_IN_PROGRESS - reset, we still want completions in ocs_hw_process()
2140 * OCS_HW_STATE_TEARDOWN_IN_PROGRESS - We still want mailbox in ocs_hw_process()
2143 if (hw->state == OCS_HW_STATE_UNINITIALIZED) { in ocs_hw_process()
2148 eq = hw->hw_eq[vector]; in ocs_hw_process()
2150 OCS_STAT(eq->use_count++); in ocs_hw_process()
2176 * @return Returns 0 on success, or a non-zero value on failure.
2192 while (!done && !sli_queue_read(&hw->sli, eq->queue, eqe)) { in ocs_hw_eq_process()
2196 rc = sli_eq_parse(&hw->sli, eqe, &cq_id); in ocs_hw_eq_process()
2205 for (i = 0; i < hw->cq_count; i++) { in ocs_hw_eq_process()
2206 ocs_hw_cq_process(hw, hw->hw_cq[i]); in ocs_hw_eq_process()
2213 int32_t index = ocs_hw_queue_hash_find(hw->cq_hash, cq_id); in ocs_hw_eq_process()
2215 ocs_hw_cq_process(hw, hw->hw_cq[index]); in ocs_hw_eq_process()
2217 ocs_log_err(hw->os, "bad CQ_ID %#06x\n", cq_id); in ocs_hw_eq_process()
2221 if (eq->queue->n_posted > (eq->queue->posted_limit)) { in ocs_hw_eq_process()
2222 sli_queue_arm(&hw->sli, eq->queue, FALSE); in ocs_hw_eq_process()
2225 if (tcheck_count && (--tcheck_count == 0)) { in ocs_hw_eq_process()
2227 telapsed = ocs_msectime() - tstart; in ocs_hw_eq_process()
2233 sli_queue_eq_arm(&hw->sli, eq->queue, TRUE); in ocs_hw_eq_process()
2243 * --- Assumes that hw->cmd_lock is held ---
2258 while (hw->cmd_head_count < (OCS_HW_MQ_DEPTH - 1)) { in ocs_hw_cmd_submit_pending()
2259 ctx = ocs_list_remove_head(&hw->cmd_pending); in ocs_hw_cmd_submit_pending()
2263 ocs_list_add_tail(&hw->cmd_head, ctx); in ocs_hw_cmd_submit_pending()
2264 hw->cmd_head_count++; in ocs_hw_cmd_submit_pending()
2265 if (sli_queue_write(&hw->sli, hw->mq, ctx->buf) < 0) { in ocs_hw_cmd_submit_pending()
2266 ocs_log_test(hw->os, "sli_queue_write failed: %d\n", rc); in ocs_hw_cmd_submit_pending()
2267 rc = -1; in ocs_hw_cmd_submit_pending()
2285 * - OCS_CMD_POLL - Command executes synchronously and busy-waits for the completion.
2286 * - OCS_CMD_NOWAIT - Command executes asynchronously. Uses callback.
2294 * @return Returns 0 on success, or a non-zero value on failure.
2305 if (sli_fw_error_status(&hw->sli) > 0) { in ocs_hw_command()
2306 uint32_t err1 = sli_reg_read(&hw->sli, SLI4_REG_SLIPORT_ERROR1); in ocs_hw_command()
2307 uint32_t err2 = sli_reg_read(&hw->sli, SLI4_REG_SLIPORT_ERROR2); in ocs_hw_command()
2308 if (hw->expiration_logged == 0 && err1 == 0x2 && err2 == 0x10) { in ocs_hw_command()
2309 hw->expiration_logged = 1; in ocs_hw_command()
2310 ocs_log_crit(hw->os,"Emulex: Heartbeat expired after %d seconds\n", in ocs_hw_command()
2311 hw->watchdog_timeout); in ocs_hw_command()
2313 ocs_log_crit(hw->os, "Chip is in an error state - reset needed\n"); in ocs_hw_command()
2314 ocs_log_crit(hw->os, "status=%#x error1=%#x error2=%#x\n", in ocs_hw_command()
2315 sli_reg_read(&hw->sli, SLI4_REG_SLIPORT_STATUS), in ocs_hw_command()
2322 ocs_lock(&hw->cmd_lock); in ocs_hw_command()
2323 if (hw->mq->length && !sli_queue_is_empty(&hw->sli, hw->mq)) { in ocs_hw_command()
2325 * Can't issue Boot-strap mailbox command with other in ocs_hw_command()
2326 * mail-queue commands pending as this interaction is in ocs_hw_command()
2331 void *bmbx = hw->sli.bmbx.virt; in ocs_hw_command()
2336 if (sli_bmbx_command(&hw->sli) == 0) { in ocs_hw_command()
2341 ocs_unlock(&hw->cmd_lock); in ocs_hw_command()
2345 ctx = ocs_malloc(hw->os, sizeof(ocs_command_ctx_t), OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_command()
2347 ocs_log_err(hw->os, "can't allocate command context\n"); in ocs_hw_command()
2351 if (hw->state != OCS_HW_STATE_ACTIVE) { in ocs_hw_command()
2352 ocs_log_err(hw->os, "Can't send command, HW state=%d\n", hw->state); in ocs_hw_command()
2353 ocs_free(hw->os, ctx, sizeof(*ctx)); in ocs_hw_command()
2358 ctx->cb = cb; in ocs_hw_command()
2359 ctx->arg = arg; in ocs_hw_command()
2361 ctx->buf = cmd; in ocs_hw_command()
2362 ctx->ctx = hw; in ocs_hw_command()
2364 ocs_lock(&hw->cmd_lock); in ocs_hw_command()
2367 ocs_list_add_tail(&hw->cmd_pending, ctx); in ocs_hw_command()
2374 ocs_unlock(&hw->cmd_lock); in ocs_hw_command()
2389 * @return Returns 0 on success, or a non-zero value on failure.
2403 hw->callback.domain = func; in ocs_hw_callback()
2404 hw->args.domain = arg; in ocs_hw_callback()
2407 hw->callback.port = func; in ocs_hw_callback()
2408 hw->args.port = arg; in ocs_hw_callback()
2411 hw->callback.unsolicited = func; in ocs_hw_callback()
2412 hw->args.unsolicited = arg; in ocs_hw_callback()
2415 hw->callback.rnode = func; in ocs_hw_callback()
2416 hw->args.rnode = arg; in ocs_hw_callback()
2419 hw->callback.bounce = func; in ocs_hw_callback()
2420 hw->args.bounce = arg; in ocs_hw_callback()
2423 ocs_log_test(hw->os, "unknown callback %#x\n", which); in ocs_hw_callback()
2441 * @param wwpn Port's WWPN in big-endian order, or NULL to use default.
2443 * @return Returns 0 on success, or a non-zero value on failure.
2453 sport->indicator = UINT32_MAX; in ocs_hw_port_alloc()
2454 sport->hw = hw; in ocs_hw_port_alloc()
2455 sport->ctx.app = sport; in ocs_hw_port_alloc()
2456 sport->sm_free_req_pending = 0; in ocs_hw_port_alloc()
2461 if (sli_fw_error_status(&hw->sli) > 0) { in ocs_hw_port_alloc()
2462 ocs_log_crit(hw->os, "Chip is in an error state - reset needed\n"); in ocs_hw_port_alloc()
2467 ocs_memcpy(&sport->sli_wwpn, wwpn, sizeof(sport->sli_wwpn)); in ocs_hw_port_alloc()
2470 if (sli_resource_alloc(&hw->sli, SLI_RSRC_FCOE_VPI, &sport->indicator, &index)) { in ocs_hw_port_alloc()
2471 ocs_log_err(hw->os, "FCOE_VPI allocation failure\n"); in ocs_hw_port_alloc()
2478 cmd = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_port_alloc()
2480 ocs_log_err(hw->os, "command memory allocation failed\n"); in ocs_hw_port_alloc()
2494 ocs_sm_transition(&sport->ctx, next, cmd); in ocs_hw_port_alloc()
2497 ocs_log_test(hw->os, "need WWN for physical port\n"); in ocs_hw_port_alloc()
2500 /* domain NULL and wwpn non-NULL */ in ocs_hw_port_alloc()
2501 ocs_sm_transition(&sport->ctx, __ocs_hw_port_alloc_init, NULL); in ocs_hw_port_alloc()
2506 ocs_free(hw->os, cmd, SLI4_BMBX_SIZE); in ocs_hw_port_alloc()
2508 sli_resource_free(&hw->sli, SLI_RSRC_FCOE_VPI, sport->indicator); in ocs_hw_port_alloc()
2519 * This function registers a previously-allocated VPI with the
2535 ocs_log_err(hw ? hw->os : NULL, in ocs_hw_port_attach()
2544 if (sli_fw_error_status(&hw->sli) > 0) { in ocs_hw_port_attach()
2545 ocs_log_crit(hw->os, "Chip is in an error state - reset needed\n"); in ocs_hw_port_attach()
2549 buf = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_port_attach()
2551 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_port_attach()
2555 sport->fc_id = fc_id; in ocs_hw_port_attach()
2556 ocs_sm_post_event(&sport->ctx, OCS_EVT_HW_PORT_REQ_ATTACH, buf); in ocs_hw_port_attach()
2576 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_port_control()
2586 * - @b OCS_HW_PORT_INIT -
2590 * - @b OCS_HW_PORT_SHUTDOWN -
2594 * - @b OCS_HW_PORT_SET_LINK_CONFIG -
2599 * - OCS_HW_PORT_INIT
2600 * - OCS_HW_PORT_SHUTDOWN
2601 * - OCS_HW_PORT_SET_LINK_CONFIG
2603 * @param value Operation-specific value.
2604 * - OCS_HW_PORT_INIT - Selective reset AL_PA
2605 * - OCS_HW_PORT_SHUTDOWN - N/A
2606 * - OCS_HW_PORT_SET_LINK_CONFIG - An enum #ocs_hw_linkcfg_e value.
2609 * - OCS_HW_PORT_INIT/OCS_HW_PORT_SHUTDOWN - NULL (link events
2611 * - OCS_HW_PORT_SET_LINK_CONFIG - Invoked after linkcfg mailbox command
2615 * - OCS_HW_PORT_INIT/OCS_HW_PORT_SHUTDOWN - NULL (link events
2617 * - OCS_HW_PORT_SET_LINK_CONFIG - Invoked after linkcfg mailbox command
2620 * @return Returns 0 on success, or a non-zero value on failure.
2634 if (SLI_LINK_MEDIUM_FC == sli_get_medium(&hw->sli)) { in ocs_hw_port_control()
2637 cfg_link = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_port_control()
2639 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_port_control()
2643 if (sli_cmd_config_link(&hw->sli, cfg_link, SLI4_BMBX_SIZE)) { in ocs_hw_port_control()
2649 ocs_free(hw->os, cfg_link, SLI4_BMBX_SIZE); in ocs_hw_port_control()
2650 ocs_log_err(hw->os, "CONFIG_LINK failed\n"); in ocs_hw_port_control()
2653 speed = hw->config.speed; in ocs_hw_port_control()
2662 if (hw->workaround.fw_version_too_low) { in ocs_hw_port_control()
2663 if (SLI4_IF_TYPE_LANCER_FC_ETH == hw->sli.if_type) { in ocs_hw_port_control()
2664 …ocs_log_err(hw->os, "Cannot bring up link. Please update firmware to %s or later (current version… in ocs_hw_port_control()
2665 OCS_FW_VER_STR(OCS_MIN_FW_VER_LANCER), (char *) sli_get_fw_name(&hw->sli,0)); in ocs_hw_port_control()
2667 …ocs_log_err(hw->os, "Cannot bring up link. Please update firmware to %s or later (current version… in ocs_hw_port_control()
2668 OCS_FW_VER_STR(OCS_MIN_FW_VER_SKYHAWK), (char *) sli_get_fw_name(&hw->sli, 0)); in ocs_hw_port_control()
2677 init_link = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_port_control()
2679 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_port_control()
2683 if (sli_cmd_init_link(&hw->sli, init_link, SLI4_BMBX_SIZE, speed, reset_alpa)) { in ocs_hw_port_control()
2689 ocs_free(hw->os, init_link, SLI4_BMBX_SIZE); in ocs_hw_port_control()
2690 ocs_log_err(hw->os, "INIT_LINK failed\n"); in ocs_hw_port_control()
2698 down_link = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_port_control()
2700 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_port_control()
2703 if (sli_cmd_down_link(&hw->sli, down_link, SLI4_BMBX_SIZE)) { in ocs_hw_port_control()
2709 ocs_free(hw->os, down_link, SLI4_BMBX_SIZE); in ocs_hw_port_control()
2710 ocs_log_err(hw->os, "DOWN_LINK failed\n"); in ocs_hw_port_control()
2718 ocs_log_test(hw->os, "unhandled control %#x\n", ctrl); in ocs_hw_port_control()
2735 * @return Returns 0 on success, or a non-zero value on failure.
2743 ocs_log_err(hw ? hw->os : NULL, in ocs_hw_port_free()
2752 if (sli_fw_error_status(&hw->sli) > 0) { in ocs_hw_port_free()
2753 ocs_log_crit(hw->os, "Chip is in an error state - reset needed\n"); in ocs_hw_port_free()
2757 ocs_sm_post_event(&sport->ctx, OCS_EVT_HW_PORT_REQ_FREE, NULL); in ocs_hw_port_free()
2767 * - REG_FCFI
2768 * - INIT_VFI
2769 * - READ_SPARMS
2780 * @return Returns 0 on success, or a non-zero value on failure.
2788 if (!hw || !domain || !domain->sport) { in ocs_hw_domain_alloc()
2790 hw, domain, domain ? domain->sport : NULL); in ocs_hw_domain_alloc()
2797 if (sli_fw_error_status(&hw->sli) > 0) { in ocs_hw_domain_alloc()
2798 ocs_log_crit(hw->os, "Chip is in an error state - reset needed\n"); in ocs_hw_domain_alloc()
2802 cmd = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_domain_alloc()
2804 ocs_log_err(hw->os, "command memory allocation failed\n"); in ocs_hw_domain_alloc()
2808 domain->dma = hw->domain_dmem; in ocs_hw_domain_alloc()
2810 domain->hw = hw; in ocs_hw_domain_alloc()
2811 domain->sm.app = domain; in ocs_hw_domain_alloc()
2812 domain->fcf = fcf; in ocs_hw_domain_alloc()
2813 domain->fcf_indicator = UINT32_MAX; in ocs_hw_domain_alloc()
2814 domain->vlan_id = vlan; in ocs_hw_domain_alloc()
2815 domain->indicator = UINT32_MAX; in ocs_hw_domain_alloc()
2817 if (sli_resource_alloc(&hw->sli, SLI_RSRC_FCOE_VFI, &domain->indicator, &index)) { in ocs_hw_domain_alloc()
2818 ocs_log_err(hw->os, "FCOE_VFI allocation failure\n"); in ocs_hw_domain_alloc()
2820 ocs_free(hw->os, cmd, SLI4_BMBX_SIZE); in ocs_hw_domain_alloc()
2825 ocs_sm_transition(&domain->sm, __ocs_hw_domain_init, cmd); in ocs_hw_domain_alloc()
2837 * @return Returns 0 on success, or a non-zero value on failure.
2846 ocs_log_err(hw ? hw->os : NULL, in ocs_hw_domain_attach()
2855 if (sli_fw_error_status(&hw->sli) > 0) { in ocs_hw_domain_attach()
2856 ocs_log_crit(hw->os, "Chip is in an error state - reset needed\n"); in ocs_hw_domain_attach()
2860 buf = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_domain_attach()
2862 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_domain_attach()
2866 domain->sport->fc_id = fc_id; in ocs_hw_domain_attach()
2867 ocs_sm_post_event(&domain->sm, OCS_EVT_HW_DOMAIN_REQ_ATTACH, buf); in ocs_hw_domain_attach()
2881 * @return Returns 0 on success, or a non-zero value on failure.
2889 ocs_log_err(hw ? hw->os : NULL, in ocs_hw_domain_free()
2898 if (sli_fw_error_status(&hw->sli) > 0) { in ocs_hw_domain_free()
2899 ocs_log_crit(hw->os, "Chip is in an error state - reset needed\n"); in ocs_hw_domain_free()
2903 ocs_sm_post_event(&domain->sm, OCS_EVT_HW_DOMAIN_REQ_FREE, NULL); in ocs_hw_domain_free()
2919 * @return Returns 0 on success, or a non-zero value on failure.
2929 sli_resource_free(&hw->sli, SLI_RSRC_FCOE_VFI, domain->indicator); in ocs_hw_domain_force_free()
2943 * @return Returns 0 on success, or a non-zero value on failure.
2950 if (UINT32_MAX != rnode->indicator) { in ocs_hw_node_alloc()
2951 ocs_log_err(hw->os, "FCOE_RPI allocation failure addr=%#x rpi=%#x\n", in ocs_hw_node_alloc()
2952 fc_addr, rnode->indicator); in ocs_hw_node_alloc()
2959 if (sli_fw_error_status(&hw->sli) > 0) { in ocs_hw_node_alloc()
2960 ocs_log_crit(hw->os, "Chip is in an error state - reset needed\n"); in ocs_hw_node_alloc()
2965 rnode->sport = NULL; in ocs_hw_node_alloc()
2967 if (sli_resource_alloc(&hw->sli, SLI_RSRC_FCOE_RPI, &rnode->indicator, &rnode->index)) { in ocs_hw_node_alloc()
2968 ocs_log_err(hw->os, "FCOE_RPI allocation failure addr=%#x\n", in ocs_hw_node_alloc()
2973 rnode->fc_id = fc_addr; in ocs_hw_node_alloc()
2974 rnode->sport = sport; in ocs_hw_node_alloc()
2987 * @return Returns 0 on success, or a non-zero value on failure.
3005 if (sli_fw_error_status(&hw->sli) > 0) { in ocs_hw_node_attach()
3006 ocs_log_crit(hw->os, "Chip is in an error state - reset needed\n"); in ocs_hw_node_attach()
3010 buf = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_node_attach()
3012 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_node_attach()
3017 * If the attach count is non-zero, this RPI has already been registered. in ocs_hw_node_attach()
3020 if (rnode->index == UINT32_MAX) { in ocs_hw_node_attach()
3021 ocs_log_err(NULL, "bad parameter rnode->index invalid\n"); in ocs_hw_node_attach()
3022 ocs_free(hw->os, buf, SLI4_BMBX_SIZE); in ocs_hw_node_attach()
3025 count = ocs_atomic_add_return(&hw->rpi_ref[rnode->index].rpi_count, 1); in ocs_hw_node_attach()
3031 if (sli_get_hlm(&hw->sli) == FALSE) { in ocs_hw_node_attach()
3032 ocs_log_test(hw->os, "attach to already attached node HLM=%d count=%d\n", in ocs_hw_node_attach()
3033 sli_get_hlm(&hw->sli), count); in ocs_hw_node_attach()
3036 rnode->node_group = TRUE; in ocs_hw_node_attach()
3037 rnode->attached = ocs_atomic_read(&hw->rpi_ref[rnode->index].rpi_attached); in ocs_hw_node_attach()
3038 rc = rnode->attached ? OCS_HW_RTN_SUCCESS_SYNC : OCS_HW_RTN_SUCCESS; in ocs_hw_node_attach()
3041 rnode->node_group = FALSE; in ocs_hw_node_attach()
3043 ocs_display_sparams("", "reg rpi", 0, NULL, sparms->virt); in ocs_hw_node_attach()
3044 if (sli_cmd_reg_rpi(&hw->sli, buf, SLI4_BMBX_SIZE, rnode->fc_id, in ocs_hw_node_attach()
3045 rnode->indicator, rnode->sport->indicator, in ocs_hw_node_attach()
3046 sparms, 0, (hw->auto_xfer_rdy_enabled && hw->config.auto_xfer_rdy_t10_enable))) { in ocs_hw_node_attach()
3054 ocs_atomic_sub_return(&hw->rpi_ref[rnode->index].rpi_count, 1); in ocs_hw_node_attach()
3055 ocs_log_err(hw->os, "%s error\n", count ? "HLM" : "REG_RPI"); in ocs_hw_node_attach()
3057 ocs_free(hw->os, buf, SLI4_BMBX_SIZE); in ocs_hw_node_attach()
3070 * @return Returns 0 on success, or a non-zero value on failure.
3083 if (rnode->sport) { in ocs_hw_node_free_resources()
3084 if (!rnode->attached) { in ocs_hw_node_free_resources()
3085 if (rnode->indicator != UINT32_MAX) { in ocs_hw_node_free_resources()
3086 if (sli_resource_free(&hw->sli, SLI_RSRC_FCOE_RPI, rnode->indicator)) { in ocs_hw_node_free_resources()
3087 ocs_log_err(hw->os, "FCOE_RPI free failure RPI %d addr=%#x\n", in ocs_hw_node_free_resources()
3088 rnode->indicator, rnode->fc_id); in ocs_hw_node_free_resources()
3091 rnode->node_group = FALSE; in ocs_hw_node_free_resources()
3092 rnode->indicator = UINT32_MAX; in ocs_hw_node_free_resources()
3093 rnode->index = UINT32_MAX; in ocs_hw_node_free_resources()
3094 rnode->free_group = FALSE; in ocs_hw_node_free_resources()
3098 ocs_log_err(hw->os, "Error: rnode is still attached\n"); in ocs_hw_node_free_resources()
3113 * @return Returns 0 on success, or a non-zero value on failure.
3131 if (sli_fw_error_status(&hw->sli) > 0) { in ocs_hw_node_detach()
3132 ocs_log_crit(hw->os, "Chip is in an error state - reset needed\n"); in ocs_hw_node_detach()
3136 index = rnode->index; in ocs_hw_node_detach()
3138 if (rnode->sport) { in ocs_hw_node_detach()
3142 if (!rnode->attached) { in ocs_hw_node_detach()
3146 buf = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_node_detach()
3148 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_node_detach()
3152 count = ocs_atomic_sub_return(&hw->rpi_ref[index].rpi_count, 1); in ocs_hw_node_detach()
3158 rnode->node_group = FALSE; in ocs_hw_node_detach()
3159 rnode->free_group = TRUE; in ocs_hw_node_detach()
3161 if (sli_get_hlm(&hw->sli) == FALSE) { in ocs_hw_node_detach()
3162 ocs_log_test(hw->os, "Invalid count with HLM disabled, count=%d\n", in ocs_hw_node_detach()
3165 fc_id = rnode->fc_id & 0x00ffffff; in ocs_hw_node_detach()
3170 if (sli_cmd_unreg_rpi(&hw->sli, buf, SLI4_BMBX_SIZE, rnode->indicator, in ocs_hw_node_detach()
3176 ocs_log_err(hw->os, "UNREG_RPI failed\n"); in ocs_hw_node_detach()
3177 ocs_free(hw->os, buf, SLI4_BMBX_SIZE); in ocs_hw_node_detach()
3191 * @return Returns 0 on success, or a non-zero value on failure.
3207 if (sli_fw_error_status(&hw->sli) > 0) { in ocs_hw_node_free_all()
3208 ocs_log_crit(hw->os, "Chip is in an error state - reset needed\n"); in ocs_hw_node_free_all()
3212 buf = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_node_free_all()
3214 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_node_free_all()
3218 if (sli_cmd_unreg_rpi(&hw->sli, buf, SLI4_BMBX_SIZE, 0xffff, in ocs_hw_node_free_all()
3225 ocs_log_err(hw->os, "UNREG_RPI failed\n"); in ocs_hw_node_free_all()
3226 ocs_free(hw->os, buf, SLI4_BMBX_SIZE); in ocs_hw_node_free_all()
3243 if (sli_resource_alloc(&hw->sli, SLI_RSRC_FCOE_RPI, &ngroup->indicator, in ocs_hw_node_group_alloc()
3244 &ngroup->index)) { in ocs_hw_node_group_alloc()
3245 ocs_log_err(hw->os, "FCOE_RPI allocation failure addr=%#x\n", in ocs_hw_node_group_alloc()
3246 ngroup->indicator); in ocs_hw_node_group_alloc()
3263 if (rnode->attached) { in ocs_hw_node_group_attach()
3264 ocs_log_err(hw->os, "node already attached RPI=%#x addr=%#x\n", in ocs_hw_node_group_attach()
3265 rnode->indicator, rnode->fc_id); in ocs_hw_node_group_attach()
3269 if (sli_resource_free(&hw->sli, SLI_RSRC_FCOE_RPI, rnode->indicator)) { in ocs_hw_node_group_attach()
3270 ocs_log_err(hw->os, "FCOE_RPI free failure RPI=%#x\n", in ocs_hw_node_group_attach()
3271 rnode->indicator); in ocs_hw_node_group_attach()
3275 rnode->indicator = ngroup->indicator; in ocs_hw_node_group_attach()
3276 rnode->index = ngroup->index; in ocs_hw_node_group_attach()
3292 ref = ocs_atomic_read(&hw->rpi_ref[ngroup->index].rpi_count); in ocs_hw_node_group_free()
3294 /* Hmmm, the reference count is non-zero */ in ocs_hw_node_group_free()
3295 ocs_log_debug(hw->os, "node group reference=%d (RPI=%#x)\n", in ocs_hw_node_group_free()
3296 ref, ngroup->indicator); in ocs_hw_node_group_free()
3298 if (sli_resource_free(&hw->sli, SLI_RSRC_FCOE_RPI, ngroup->indicator)) { in ocs_hw_node_group_free()
3299 ocs_log_err(hw->os, "FCOE_RPI free failure RPI=%#x\n", in ocs_hw_node_group_free()
3300 ngroup->indicator); in ocs_hw_node_group_free()
3304 ocs_atomic_set(&hw->rpi_ref[ngroup->index].rpi_count, 0); in ocs_hw_node_group_free()
3307 ngroup->indicator = UINT32_MAX; in ocs_hw_node_group_free()
3308 ngroup->index = UINT32_MAX; in ocs_hw_node_group_free()
3317 * alloc call) because port-owned XRIs are not
3327 * Set io->done to NULL, to avoid any callbacks, should in ocs_hw_init_free_io()
3330 io->done = NULL; in ocs_hw_init_free_io()
3331 io->abort_done = NULL; in ocs_hw_init_free_io()
3332 io->status_saved = 0; in ocs_hw_init_free_io()
3333 io->abort_in_progress = FALSE; in ocs_hw_init_free_io()
3334 io->port_owned_abort_count = 0; in ocs_hw_init_free_io()
3335 io->rnode = NULL; in ocs_hw_init_free_io()
3336 io->type = 0xFFFF; in ocs_hw_init_free_io()
3337 io->wq = NULL; in ocs_hw_init_free_io()
3338 io->ul_io = NULL; in ocs_hw_init_free_io()
3339 io->wqe_timeout = 0; in ocs_hw_init_free_io()
3347 * Assume that hw->ocs_lock is held. This function is only used if
3359 if (NULL != (io = ocs_list_remove_head(&hw->io_free))) { in _ocs_hw_io_alloc()
3360 ocs_list_add_tail(&hw->io_inuse, io); in _ocs_hw_io_alloc()
3361 io->state = OCS_HW_IO_STATE_INUSE; in _ocs_hw_io_alloc()
3362 io->quarantine = FALSE; in _ocs_hw_io_alloc()
3363 io->quarantine_first_phase = TRUE; in _ocs_hw_io_alloc()
3364 io->abort_reqtag = UINT32_MAX; in _ocs_hw_io_alloc()
3365 ocs_ref_init(&io->ref, ocs_hw_io_free_internal, io); in _ocs_hw_io_alloc()
3367 ocs_atomic_add_return(&hw->io_alloc_failed_count, 1); in _ocs_hw_io_alloc()
3377 * @n @b Note: This function applies to non-port owned XRIs
3389 ocs_lock(&hw->io_lock); in ocs_hw_io_alloc()
3391 ocs_unlock(&hw->io_lock); in ocs_hw_io_alloc()
3402 * allocated by the SLI-Port. This will "activate" the HW IO
3403 * associated with the XRI received from the SLI-Port to mirror
3415 if (ocs_ref_read_count(&io->ref) > 0) { in ocs_hw_io_activate_port_owned()
3416 ocs_log_err(hw->os, "Bad parameter: refcount > 0\n"); in ocs_hw_io_activate_port_owned()
3420 if (io->wq != NULL) { in ocs_hw_io_activate_port_owned()
3421 ocs_log_err(hw->os, "XRI %x already in use\n", io->indicator); in ocs_hw_io_activate_port_owned()
3425 ocs_ref_init(&io->ref, ocs_hw_io_free_port_owned, io); in ocs_hw_io_activate_port_owned()
3426 io->xbusy = TRUE; in ocs_hw_io_activate_port_owned()
3437 * @n @b Note: Assumes that the hw->io_lock is held and the item has been removed
3446 if (io->xbusy) { in ocs_hw_io_free_move_correct_list()
3448 ocs_list_add_tail(&hw->io_wait_free, io); in ocs_hw_io_free_move_correct_list()
3449 io->state = OCS_HW_IO_STATE_WAIT_FREE; in ocs_hw_io_free_move_correct_list()
3452 ocs_list_add_tail(&hw->io_free, io); in ocs_hw_io_free_move_correct_list()
3453 io->state = OCS_HW_IO_STATE_FREE; in ocs_hw_io_free_move_correct_list()
3457 if (hw->workaround.use_dif_sec_xri) { in ocs_hw_io_free_move_correct_list()
3465 * port and host-owned IOs.
3482 * @brief Free a HW IO object associated with a port-owned XRI.
3490 ocs_hw_t *hw = io->hw; in ocs_hw_io_free_port_owned()
3496 if (io->auto_xfer_rdy_dnrx) { in ocs_hw_io_free_port_owned()
3497 ocs_lock(&hw->io_lock); in ocs_hw_io_free_port_owned()
3499 ocs_ref_init(&io->ref, ocs_hw_io_free_port_owned, io); in ocs_hw_io_free_port_owned()
3500 ocs_list_add_tail(&hw->io_port_dnrx, io); in ocs_hw_io_free_port_owned()
3501 ocs_unlock(&hw->io_lock); in ocs_hw_io_free_port_owned()
3510 * @brief Free a previously-allocated HW IO object. Called when
3511 * IO refcount goes to zero (host-owned IOs only).
3519 ocs_hw_t *hw = io->hw; in ocs_hw_io_free_internal()
3524 ocs_lock(&hw->io_lock); in ocs_hw_io_free_internal()
3525 /* remove from in-use list */ in ocs_hw_io_free_internal()
3526 ocs_list_remove(&hw->io_inuse, io); in ocs_hw_io_free_internal()
3528 ocs_unlock(&hw->io_lock); in ocs_hw_io_free_internal()
3533 * @brief Free a previously-allocated HW IO object.
3541 * @return Returns a non-zero value if HW IO was freed, 0 if references
3548 if (ocs_ref_read_count(&io->ref) <= 0) { in ocs_hw_io_free()
3549 ocs_log_err(hw->os, "Bad parameter: refcount <= 0 xri=%x tag=%x\n", in ocs_hw_io_free()
3550 io->indicator, io->reqtag); in ocs_hw_io_free()
3551 return -1; in ocs_hw_io_free()
3554 return ocs_ref_put(&io->ref); /* ocs_ref_get(): ocs_hw_io_alloc() */ in ocs_hw_io_free()
3559 * @brief Check if given HW IO is in-use
3563 * allocated and is in-use, and FALSE otherwise. It applies to
3574 return (ocs_ref_read_count(&io->ref) > 0); in ocs_hw_io_inuse()
3586 * @n @b Note: Assumes the SLI-4 queue lock is held.
3597 if (wq->wqec_count) { in _hw_wq_write()
3598 wq->wqec_count--; in _hw_wq_write()
3600 if (wq->wqec_count == 0) { in _hw_wq_write()
3601 sli4_generic_wqe_t *genwqe = (void*)wqe->wqebuf; in _hw_wq_write()
3602 genwqe->wqec = 1; in _hw_wq_write()
3603 wq->wqec_count = wq->wqec_set_count; in _hw_wq_write()
3607 wq->free_count--; in _hw_wq_write()
3609 queue_rc = _sli_queue_write(&wq->hw->sli, wq->queue, wqe->wqebuf); in _hw_wq_write()
3612 rc = -1; in _hw_wq_write()
3615 ocs_queue_history_wq(&wq->hw->q_hist, (void *) wqe->wqebuf, wq->queue->id, queue_rc); in _hw_wq_write()
3630 * @n @b Note: Takes the SLI-4 queue lock.
3639 sli_queue_lock(wq->queue); in hw_wq_write()
3640 if ( ! ocs_list_empty(&wq->pending_list)) { in hw_wq_write()
3641 ocs_list_add_tail(&wq->pending_list, wqe); in hw_wq_write()
3642 OCS_STAT(wq->wq_pending_count++;) in hw_wq_write()
3643 while ((wq->free_count > 0) && ((wqe = ocs_list_remove_head(&wq->pending_list)) != NULL)) { in hw_wq_write()
3648 if (wqe->abort_wqe_submit_needed) { in hw_wq_write()
3649 wqe->abort_wqe_submit_needed = 0; in hw_wq_write()
3650 sli_abort_wqe(&wq->hw->sli, wqe->wqebuf, wq->hw->sli.config.wqe_size, SLI_ABORT_XRI, in hw_wq_write()
3651 wqe->send_abts, wqe->id, 0, wqe->abort_reqtag, SLI4_CQ_DEFAULT ); in hw_wq_write()
3652 ocs_list_add_tail(&wq->pending_list, wqe); in hw_wq_write()
3653 OCS_STAT(wq->wq_pending_count++;) in hw_wq_write()
3657 if (wq->free_count > 0) { in hw_wq_write()
3660 ocs_list_add_tail(&wq->pending_list, wqe); in hw_wq_write()
3661 OCS_STAT(wq->wq_pending_count++;) in hw_wq_write()
3665 sli_queue_unlock(wq->queue); in hw_wq_write()
3688 sli_queue_lock(wq->queue); in hw_wq_submit_pending()
3691 wq->free_count += update_free_count; in hw_wq_submit_pending()
3693 while ((wq->free_count > 0) && ((wqe = ocs_list_remove_head(&wq->pending_list)) != NULL)) { in hw_wq_submit_pending()
3696 if (wqe->abort_wqe_submit_needed) { in hw_wq_submit_pending()
3697 wqe->abort_wqe_submit_needed = 0; in hw_wq_submit_pending()
3698 sli_abort_wqe(&wq->hw->sli, wqe->wqebuf, wq->hw->sli.config.wqe_size, SLI_ABORT_XRI, in hw_wq_submit_pending()
3699 wqe->send_abts, wqe->id, 0, wqe->abort_reqtag, SLI4_CQ_DEFAULT); in hw_wq_submit_pending()
3700 ocs_list_add_tail(&wq->pending_list, wqe); in hw_wq_submit_pending()
3701 OCS_STAT(wq->wq_pending_count++;) in hw_wq_submit_pending()
3705 sli_queue_unlock(wq->queue); in hw_wq_submit_pending()
3712 * Checks hw->sec_hio_wait_list, if an IO is waiting for a HW IO, then try
3715 * @n @b Note: hw->io_lock MUST be taken when called.
3728 while (!ocs_list_empty(&hw->sec_hio_wait_list)) { in ocs_hw_check_sec_hio_list()
3736 io = ocs_list_remove_head(&hw->sec_hio_wait_list); in ocs_hw_check_sec_hio_list()
3737 ocs_list_add_tail(&hw->io_inuse, io); in ocs_hw_check_sec_hio_list()
3738 io->state = OCS_HW_IO_STATE_INUSE; in ocs_hw_check_sec_hio_list()
3739 io->sec_hio = sec_io; in ocs_hw_check_sec_hio_list()
3742 if (io->xbusy) { in ocs_hw_check_sec_hio_list()
3743 sec_io->quarantine = TRUE; in ocs_hw_check_sec_hio_list()
3746 flags = io->sec_iparam.fcp_tgt.flags; in ocs_hw_check_sec_hio_list()
3747 if (io->xbusy) { in ocs_hw_check_sec_hio_list()
3753 io->wqe_timeout = io->sec_iparam.fcp_tgt.timeout; in ocs_hw_check_sec_hio_list()
3756 if (io->xbusy) { in ocs_hw_check_sec_hio_list()
3757 if (sli_fcp_cont_treceive64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, &io->def_sgl, in ocs_hw_check_sec_hio_list()
3758 io->first_data_sge, in ocs_hw_check_sec_hio_list()
3759 io->sec_iparam.fcp_tgt.offset, io->sec_len, io->indicator, io->sec_hio->indicator, in ocs_hw_check_sec_hio_list()
3760 io->reqtag, SLI4_CQ_DEFAULT, in ocs_hw_check_sec_hio_list()
3761 io->sec_iparam.fcp_tgt.ox_id, io->rnode->indicator, io->rnode, in ocs_hw_check_sec_hio_list()
3763 …io->sec_iparam.fcp_tgt.dif_oper, io->sec_iparam.fcp_tgt.blk_size, io->sec_iparam.fcp_tgt.cs_ctl, i… in ocs_hw_check_sec_hio_list()
3764 ocs_log_test(hw->os, "TRECEIVE WQE error\n"); in ocs_hw_check_sec_hio_list()
3768 if (sli_fcp_treceive64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, &io->def_sgl, in ocs_hw_check_sec_hio_list()
3769 io->first_data_sge, in ocs_hw_check_sec_hio_list()
3770 io->sec_iparam.fcp_tgt.offset, io->sec_len, io->indicator, in ocs_hw_check_sec_hio_list()
3771 io->reqtag, SLI4_CQ_DEFAULT, in ocs_hw_check_sec_hio_list()
3772 io->sec_iparam.fcp_tgt.ox_id, io->rnode->indicator, io->rnode, in ocs_hw_check_sec_hio_list()
3774 io->sec_iparam.fcp_tgt.dif_oper, io->sec_iparam.fcp_tgt.blk_size, in ocs_hw_check_sec_hio_list()
3775 io->sec_iparam.fcp_tgt.cs_ctl, io->sec_iparam.fcp_tgt.app_id)) { in ocs_hw_check_sec_hio_list()
3776 ocs_log_test(hw->os, "TRECEIVE WQE error\n"); in ocs_hw_check_sec_hio_list()
3781 if (io->wq == NULL) { in ocs_hw_check_sec_hio_list()
3782 io->wq = ocs_hw_queue_next_wq(hw, io); in ocs_hw_check_sec_hio_list()
3783 ocs_hw_assert(io->wq != NULL); in ocs_hw_check_sec_hio_list()
3785 io->xbusy = TRUE; in ocs_hw_check_sec_hio_list()
3792 rc = hw_wq_write(io->wq, &io->wqe); in ocs_hw_check_sec_hio_list()
3794 /* non-negative return is success */ in ocs_hw_check_sec_hio_list()
3798 ocs_log_err(hw->os, "sli_queue_write failed: %d\n", rc); in ocs_hw_check_sec_hio_list()
3799 io->xbusy = FALSE; in ocs_hw_check_sec_hio_list()
3812 * - Sending an ELS request.
3813 * - Sending an ELS response - To send an ELS reponse, the caller must provide
3815 * - Sending a FC Common Transport (FC-CT) request - To send a FC-CT request,
3824 * @param type Type of sequence (ELS request/response, FC-CT).
3825 * @param io Previously-allocated HW IO object.
3830 * @param iparam IO parameters (ELS response and FC-CT).
3834 * @return Returns 0 on success, or a non-zero on failure.
3852 if (hw->state != OCS_HW_STATE_ACTIVE) { in ocs_hw_srrs_send()
3853 ocs_log_test(hw->os, "cannot send SRRS, HW state=%d\n", hw->state); in ocs_hw_srrs_send()
3857 if (ocs_hw_is_xri_port_owned(hw, io->indicator)) { in ocs_hw_srrs_send()
3861 io->rnode = rnode; in ocs_hw_srrs_send()
3862 io->type = type; in ocs_hw_srrs_send()
3863 io->done = cb; in ocs_hw_srrs_send()
3864 io->arg = arg; in ocs_hw_srrs_send()
3866 sge = io->sgl->virt; in ocs_hw_srrs_send()
3869 ocs_memset(io->sgl->virt, 0, 2 * sizeof(sli4_sge_t)); in ocs_hw_srrs_send()
3872 sge[0].buffer_address_high = ocs_addr32_hi(send->phys); in ocs_hw_srrs_send()
3873 sge[0].buffer_address_low = ocs_addr32_lo(send->phys); in ocs_hw_srrs_send()
3879 sge[1].buffer_address_high = ocs_addr32_hi(receive->phys); in ocs_hw_srrs_send()
3880 sge[1].buffer_address_low = ocs_addr32_lo(receive->phys); in ocs_hw_srrs_send()
3882 sge[1].buffer_length = receive->size; in ocs_hw_srrs_send()
3890 if ( (!send) || sli_els_request64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, io->sgl, in ocs_hw_srrs_send()
3891 *((uint8_t *)(send->virt)), /* req_type */ in ocs_hw_srrs_send()
3892 len, receive->size, in ocs_hw_srrs_send()
3893 iparam->els.timeout, io->indicator, io->reqtag, SLI4_CQ_DEFAULT, rnode)) { in ocs_hw_srrs_send()
3894 ocs_log_err(hw->os, "REQ WQE error\n"); in ocs_hw_srrs_send()
3899 …if ( (!send) || sli_xmit_els_rsp64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, send, le… in ocs_hw_srrs_send()
3900 io->indicator, io->reqtag, SLI4_CQ_DEFAULT, in ocs_hw_srrs_send()
3901 iparam->els.ox_id, in ocs_hw_srrs_send()
3903 ocs_log_err(hw->os, "RSP WQE error\n"); in ocs_hw_srrs_send()
3908 …if ( (!send) || sli_xmit_els_rsp64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, send, le… in ocs_hw_srrs_send()
3909 io->indicator, io->reqtag, SLI4_CQ_DEFAULT, in ocs_hw_srrs_send()
3910 iparam->els_sid.ox_id, in ocs_hw_srrs_send()
3911 rnode, local_flags, iparam->els_sid.s_id)) { in ocs_hw_srrs_send()
3912 ocs_log_err(hw->os, "RSP (SID) WQE error\n"); in ocs_hw_srrs_send()
3917 …if ( (!send) || sli_gen_request64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, io->sgl, … in ocs_hw_srrs_send()
3918 receive->size, iparam->fc_ct.timeout, io->indicator, in ocs_hw_srrs_send()
3919 io->reqtag, SLI4_CQ_DEFAULT, rnode, iparam->fc_ct.r_ctl, in ocs_hw_srrs_send()
3920 iparam->fc_ct.type, iparam->fc_ct.df_ctl)) { in ocs_hw_srrs_send()
3921 ocs_log_err(hw->os, "GEN WQE error\n"); in ocs_hw_srrs_send()
3926 …if ( (!send) || sli_xmit_sequence64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, io->sgl… in ocs_hw_srrs_send()
3927 iparam->fc_ct_rsp.timeout, iparam->fc_ct_rsp.ox_id, io->indicator, in ocs_hw_srrs_send()
3928 io->reqtag, rnode, iparam->fc_ct_rsp.r_ctl, in ocs_hw_srrs_send()
3929 iparam->fc_ct_rsp.type, iparam->fc_ct_rsp.df_ctl)) { in ocs_hw_srrs_send()
3930 ocs_log_err(hw->os, "XMIT SEQ WQE error\n"); in ocs_hw_srrs_send()
3941 ocs_memcpy(&bls.u.acc, iparam->bls.payload, sizeof(bls.u.acc)); in ocs_hw_srrs_send()
3944 ocs_memcpy(&bls.u.rjt, iparam->bls.payload, sizeof(bls.u.rjt)); in ocs_hw_srrs_send()
3947 bls.ox_id = iparam->bls.ox_id; in ocs_hw_srrs_send()
3948 bls.rx_id = iparam->bls.rx_id; in ocs_hw_srrs_send()
3950 if (sli_xmit_bls_rsp64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, &bls, in ocs_hw_srrs_send()
3951 io->indicator, io->reqtag, in ocs_hw_srrs_send()
3954 ocs_log_err(hw->os, "XMIT_BLS_RSP64 WQE error\n"); in ocs_hw_srrs_send()
3964 ocs_memcpy(&bls.u.acc, iparam->bls_sid.payload, sizeof(bls.u.acc)); in ocs_hw_srrs_send()
3966 bls.ox_id = iparam->bls_sid.ox_id; in ocs_hw_srrs_send()
3967 bls.rx_id = iparam->bls_sid.rx_id; in ocs_hw_srrs_send()
3969 if (sli_xmit_bls_rsp64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, &bls, in ocs_hw_srrs_send()
3970 io->indicator, io->reqtag, in ocs_hw_srrs_send()
3972 rnode, iparam->bls_sid.s_id)) { in ocs_hw_srrs_send()
3973 ocs_log_err(hw->os, "XMIT_BLS_RSP64 WQE SID error\n"); in ocs_hw_srrs_send()
3979 if ( (!send) || sli_xmit_bcast64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, send, len, in ocs_hw_srrs_send()
3980 iparam->bcast.timeout, io->indicator, io->reqtag, in ocs_hw_srrs_send()
3982 iparam->bcast.r_ctl, iparam->bcast.type, iparam->bcast.df_ctl)) { in ocs_hw_srrs_send()
3983 ocs_log_err(hw->os, "XMIT_BCAST64 WQE error\n"); in ocs_hw_srrs_send()
3988 ocs_log_err(hw->os, "bad SRRS type %#x\n", type); in ocs_hw_srrs_send()
3993 if (io->wq == NULL) { in ocs_hw_srrs_send()
3994 io->wq = ocs_hw_queue_next_wq(hw, io); in ocs_hw_srrs_send()
3995 ocs_hw_assert(io->wq != NULL); in ocs_hw_srrs_send()
3997 io->xbusy = TRUE; in ocs_hw_srrs_send()
4003 OCS_STAT(io->wq->use_count++); in ocs_hw_srrs_send()
4005 rc = hw_wq_write(io->wq, &io->wqe); in ocs_hw_srrs_send()
4007 /* non-negative return is success */ in ocs_hw_srrs_send()
4011 ocs_log_err(hw->os, "sli_queue_write failed: %d\n", rc); in ocs_hw_srrs_send()
4012 io->xbusy = FALSE; in ocs_hw_srrs_send()
4025 * This routine supports sending a higher-level IO (for example, FCP) between two endpoints
4027 * - Sending read data and good response (target).
4028 * - Sending a response (target with no data or after receiving write data).
4035 * @param io Previously-allocated HW IO object.
4042 * @return Returns 0 on success, or a non-zero value on failure.
4045 * - Support specifiying relative offset.
4046 * - Use a WQ other than 0.
4066 if (hw->state != OCS_HW_STATE_ACTIVE) { in ocs_hw_io_send()
4067 ocs_log_err(hw->os, "cannot send IO, HW state=%d\n", hw->state); in ocs_hw_io_send()
4071 rpi = rnode->indicator; in ocs_hw_io_send()
4073 if (hw->workaround.use_unregistered_rpi && (rpi == UINT32_MAX)) { in ocs_hw_io_send()
4074 rpi = hw->workaround.unregistered_rid; in ocs_hw_io_send()
4075 ocs_log_test(hw->os, "using unregistered RPI: %d\n", rpi); in ocs_hw_io_send()
4081 io->rnode = rnode; in ocs_hw_io_send()
4082 io->type = type; in ocs_hw_io_send()
4083 io->done = cb; in ocs_hw_io_send()
4084 io->arg = arg; in ocs_hw_io_send()
4091 timeout = ocs_hw_set_io_wqe_timeout(io, iparam->fcp_ini.timeout); in ocs_hw_io_send()
4097 if (hw->workaround.use_dif_quarantine && (hw->config.dif_mode == OCS_HW_DIF_MODE_SEPARATE) && in ocs_hw_io_send()
4098 (iparam->fcp_tgt.dif_oper != OCS_HW_DIF_OPER_DISABLED)) { in ocs_hw_io_send()
4099 io->quarantine = TRUE; in ocs_hw_io_send()
4102 ocs_hw_io_ini_sge(hw, io, iparam->fcp_ini.cmnd, iparam->fcp_ini.cmnd_size, in ocs_hw_io_send()
4103 iparam->fcp_ini.rsp); in ocs_hw_io_send()
4105 …if (sli_fcp_iread64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, &io->def_sgl, io->first… in ocs_hw_io_send()
4106 io->indicator, io->reqtag, SLI4_CQ_DEFAULT, rpi, rnode, in ocs_hw_io_send()
4107 iparam->fcp_ini.dif_oper, iparam->fcp_ini.blk_size, in ocs_hw_io_send()
4109 ocs_log_err(hw->os, "IREAD WQE error\n"); in ocs_hw_io_send()
4114 timeout = ocs_hw_set_io_wqe_timeout(io, iparam->fcp_ini.timeout); in ocs_hw_io_send()
4116 ocs_hw_io_ini_sge(hw, io, iparam->fcp_ini.cmnd, iparam->fcp_ini.cmnd_size, in ocs_hw_io_send()
4117 iparam->fcp_ini.rsp); in ocs_hw_io_send()
4119 …if (sli_fcp_iwrite64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, &io->def_sgl, io->firs… in ocs_hw_io_send()
4120 len, iparam->fcp_ini.first_burst, in ocs_hw_io_send()
4121 io->indicator, io->reqtag, in ocs_hw_io_send()
4123 iparam->fcp_ini.dif_oper, iparam->fcp_ini.blk_size, in ocs_hw_io_send()
4125 ocs_log_err(hw->os, "IWRITE WQE error\n"); in ocs_hw_io_send()
4130 timeout = ocs_hw_set_io_wqe_timeout(io, iparam->fcp_ini.timeout); in ocs_hw_io_send()
4132 ocs_hw_io_ini_sge(hw, io, iparam->fcp_ini.cmnd, iparam->fcp_ini.cmnd_size, in ocs_hw_io_send()
4133 iparam->fcp_ini.rsp); in ocs_hw_io_send()
4135 if (sli_fcp_icmnd64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, &io->def_sgl, in ocs_hw_io_send()
4136 io->indicator, io->reqtag, SLI4_CQ_DEFAULT, in ocs_hw_io_send()
4138 ocs_log_err(hw->os, "ICMND WQE error\n"); in ocs_hw_io_send()
4143 uint16_t flags = iparam->fcp_tgt.flags; in ocs_hw_io_send()
4144 fcp_xfer_rdy_iu_t *xfer = io->xfer_rdy.virt; in ocs_hw_io_send()
4149 *((uint32_t *)xfer->fcp_data_ro) = ocs_htobe32(iparam->fcp_tgt.offset); in ocs_hw_io_send()
4150 *((uint32_t *)xfer->fcp_burst_len) = ocs_htobe32(len); in ocs_hw_io_send()
4151 *((uint32_t *)xfer->rsvd) = 0; in ocs_hw_io_send()
4153 if (io->xbusy) { in ocs_hw_io_send()
4159 io->wqe_timeout = iparam->fcp_tgt.timeout; in ocs_hw_io_send()
4165 if (hw->workaround.use_dif_quarantine && (hw->config.dif_mode == OCS_HW_DIF_MODE_SEPARATE) && in ocs_hw_io_send()
4166 (iparam->fcp_tgt.dif_oper != OCS_HW_DIF_OPER_DISABLED)) { in ocs_hw_io_send()
4167 io->quarantine = TRUE; in ocs_hw_io_send()
4175 * are on hw->sec_hio_wait_list. If this secondary XRI is not for the first in ocs_hw_io_send()
4178 if (hw->workaround.use_dif_sec_xri && (iparam->fcp_tgt.dif_oper != OCS_HW_DIF_OPER_DISABLED)) { in ocs_hw_io_send()
4181 * we can re-use this for the sec_hio. in ocs_hw_io_send()
4183 if (io->ovfl_io != NULL) { in ocs_hw_io_send()
4184 io->sec_hio = io->ovfl_io; in ocs_hw_io_send()
4185 io->sec_hio->quarantine = TRUE; in ocs_hw_io_send()
4187 io->sec_hio = ocs_hw_io_alloc(hw); in ocs_hw_io_send()
4189 if (io->sec_hio == NULL) { in ocs_hw_io_send()
4193 io->sec_iparam = *iparam; in ocs_hw_io_send()
4194 io->sec_len = len; in ocs_hw_io_send()
4195 ocs_lock(&hw->io_lock); in ocs_hw_io_send()
4196 ocs_list_remove(&hw->io_inuse, io); in ocs_hw_io_send()
4197 ocs_list_add_tail(&hw->sec_hio_wait_list, io); in ocs_hw_io_send()
4198 io->state = OCS_HW_IO_STATE_WAIT_SEC_HIO; in ocs_hw_io_send()
4199 hw->sec_hio_wait_count++; in ocs_hw_io_send()
4200 ocs_unlock(&hw->io_lock); in ocs_hw_io_send()
4206 if (io->xbusy) { in ocs_hw_io_send()
4207 io->sec_hio->quarantine = TRUE; in ocs_hw_io_send()
4212 * If not the first data phase, and io->sec_hio has been allocated, then issue in ocs_hw_io_send()
4215 if (io->xbusy && (io->sec_hio != NULL)) { in ocs_hw_io_send()
4216 …if (sli_fcp_cont_treceive64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, &io->def_sgl, i… in ocs_hw_io_send()
4217 iparam->fcp_tgt.offset, len, io->indicator, io->sec_hio->indicator, in ocs_hw_io_send()
4218 io->reqtag, SLI4_CQ_DEFAULT, in ocs_hw_io_send()
4219 iparam->fcp_tgt.ox_id, rpi, rnode, in ocs_hw_io_send()
4221 iparam->fcp_tgt.dif_oper, iparam->fcp_tgt.blk_size, in ocs_hw_io_send()
4222 iparam->fcp_tgt.cs_ctl, iparam->fcp_tgt.app_id)) { in ocs_hw_io_send()
4223 ocs_log_err(hw->os, "TRECEIVE WQE error\n"); in ocs_hw_io_send()
4227 …if (sli_fcp_treceive64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, &io->def_sgl, io->fi… in ocs_hw_io_send()
4228 iparam->fcp_tgt.offset, len, io->indicator, io->reqtag, in ocs_hw_io_send()
4230 iparam->fcp_tgt.ox_id, rpi, rnode, in ocs_hw_io_send()
4232 iparam->fcp_tgt.dif_oper, iparam->fcp_tgt.blk_size, in ocs_hw_io_send()
4233 iparam->fcp_tgt.cs_ctl, iparam->fcp_tgt.app_id)) { in ocs_hw_io_send()
4234 ocs_log_err(hw->os, "TRECEIVE WQE error\n"); in ocs_hw_io_send()
4241 uint16_t flags = iparam->fcp_tgt.flags; in ocs_hw_io_send()
4243 if (io->xbusy) { in ocs_hw_io_send()
4249 io->wqe_timeout = iparam->fcp_tgt.timeout; in ocs_hw_io_send()
4250 …if (sli_fcp_tsend64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, &io->def_sgl, io->first… in ocs_hw_io_send()
4251 iparam->fcp_tgt.offset, len, io->indicator, io->reqtag, in ocs_hw_io_send()
4253 iparam->fcp_tgt.ox_id, rpi, rnode, in ocs_hw_io_send()
4255 iparam->fcp_tgt.dif_oper, in ocs_hw_io_send()
4256 iparam->fcp_tgt.blk_size, in ocs_hw_io_send()
4257 iparam->fcp_tgt.cs_ctl, in ocs_hw_io_send()
4258 iparam->fcp_tgt.app_id)) { in ocs_hw_io_send()
4259 ocs_log_err(hw->os, "TSEND WQE error\n"); in ocs_hw_io_send()
4261 } else if (hw->workaround.retain_tsend_io_length) { in ocs_hw_io_send()
4262 io->length = len; in ocs_hw_io_send()
4267 uint16_t flags = iparam->fcp_tgt.flags; in ocs_hw_io_send()
4269 if (io->xbusy) { in ocs_hw_io_send()
4276 if (hw->auto_xfer_rdy_enabled && io->is_port_owned) { in ocs_hw_io_send()
4277 if ((io->auto_xfer_rdy_dnrx = ocs_hw_rqpair_auto_xfer_rdy_buffer_post(hw, io, 1))) { in ocs_hw_io_send()
4282 io->wqe_timeout = iparam->fcp_tgt.timeout; in ocs_hw_io_send()
4283 if (sli_fcp_trsp64_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, in ocs_hw_io_send()
4284 &io->def_sgl, in ocs_hw_io_send()
4286 io->indicator, io->reqtag, in ocs_hw_io_send()
4288 iparam->fcp_tgt.ox_id, in ocs_hw_io_send()
4290 flags, iparam->fcp_tgt.cs_ctl, in ocs_hw_io_send()
4291 io->is_port_owned, in ocs_hw_io_send()
4292 iparam->fcp_tgt.app_id)) { in ocs_hw_io_send()
4293 ocs_log_err(hw->os, "TRSP WQE error\n"); in ocs_hw_io_send()
4300 ocs_log_err(hw->os, "unsupported IO type %#x\n", type); in ocs_hw_io_send()
4305 if (io->wq == NULL) { in ocs_hw_io_send()
4306 io->wq = ocs_hw_queue_next_wq(hw, io); in ocs_hw_io_send()
4307 ocs_hw_assert(io->wq != NULL); in ocs_hw_io_send()
4310 io->xbusy = TRUE; in ocs_hw_io_send()
4316 OCS_STAT(hw->tcmd_wq_submit[io->wq->instance]++); in ocs_hw_io_send()
4317 OCS_STAT(io->wq->use_count++); in ocs_hw_io_send()
4319 rc = hw_wq_write(io->wq, &io->wqe); in ocs_hw_io_send()
4321 /* non-negative return is success */ in ocs_hw_io_send()
4325 ocs_log_err(hw->os, "sli_queue_write failed: %d\n", rc); in ocs_hw_io_send()
4326 io->xbusy = FALSE; in ocs_hw_io_send()
4360 wqe = &ctx->wqe; in ocs_hw_send_frame()
4363 ctx->hw = hw; in ocs_hw_send_frame()
4366 ctx->wqcb = ocs_hw_reqtag_alloc(hw, callback, arg); in ocs_hw_send_frame()
4367 if (ctx->wqcb == NULL) { in ocs_hw_send_frame()
4368 ocs_log_err(hw->os, "can't allocate request tag\n"); in ocs_hw_send_frame()
4373 wq = ocs_varray_iter_next(hw->wq_class_array[1]); in ocs_hw_send_frame()
4375 wq = hw->hw_wq[0]; in ocs_hw_send_frame()
4379 xri = wq->send_frame_io->indicator; in ocs_hw_send_frame()
4382 …rc = sli_send_frame_wqe(&hw->sli, wqe->wqebuf, hw->sli.config.wqe_size, sof, eof, (uint32_t*) hdr,… in ocs_hw_send_frame()
4383 payload->len, OCS_HW_SEND_FRAME_TIMEOUT, xri, ctx->wqcb->instance_index); in ocs_hw_send_frame()
4385 ocs_log_err(hw->os, "sli_send_frame_wqe failed: %d\n", rc); in ocs_hw_send_frame()
4392 ocs_log_err(hw->os, "hw_wq_write failed: %d\n", rc); in ocs_hw_send_frame()
4396 OCS_STAT(wq->use_count++); in ocs_hw_send_frame()
4404 if (sli_get_sgl_preregister(&hw->sli)) { in ocs_hw_io_register_sgl()
4405 ocs_log_err(hw->os, "can't use temporary SGL with pre-registered SGLs\n"); in ocs_hw_io_register_sgl()
4408 io->ovfl_sgl = sgl; in ocs_hw_io_register_sgl()
4409 io->ovfl_sgl_count = sgl_count; in ocs_hw_io_register_sgl()
4410 io->ovfl_io = NULL; in ocs_hw_io_register_sgl()
4419 io->sgl = &io->def_sgl; in ocs_hw_io_restore_sgl()
4420 io->sgl_count = io->def_sgl_count; in ocs_hw_io_restore_sgl()
4430 if (io->ovfl_io != NULL) { in ocs_hw_io_restore_sgl()
4431 ocs_hw_io_free(hw, io->ovfl_io); in ocs_hw_io_restore_sgl()
4432 io->ovfl_io = NULL; in ocs_hw_io_restore_sgl()
4436 io->ovfl_sgl = NULL; in ocs_hw_io_restore_sgl()
4437 io->ovfl_sgl_count = 0; in ocs_hw_io_restore_sgl()
4438 io->ovfl_lsp = NULL; in ocs_hw_io_restore_sgl()
4446 * @param io Previously-allocated HW IO object.
4449 * @return Returns 0 on success, or a non-zero value on failure.
4459 ocs_log_err(hw ? hw->os : NULL, "bad parameter hw=%p io=%p\n", in ocs_hw_io_init_sges()
4464 /* Clear / reset the scatter-gather list */ in ocs_hw_io_init_sges()
4465 io->sgl = &io->def_sgl; in ocs_hw_io_init_sges()
4466 io->sgl_count = io->def_sgl_count; in ocs_hw_io_init_sges()
4467 io->first_data_sge = 0; in ocs_hw_io_init_sges()
4469 ocs_memset(io->sgl->virt, 0, 2 * sizeof(sli4_sge_t)); in ocs_hw_io_init_sges()
4470 io->n_sge = 0; in ocs_hw_io_init_sges()
4471 io->sge_offset = 0; in ocs_hw_io_init_sges()
4473 io->type = type; in ocs_hw_io_init_sges()
4475 data = io->sgl->virt; in ocs_hw_io_init_sges()
4490 data->sge_type = SLI4_SGE_TYPE_DATA; in ocs_hw_io_init_sges()
4494 data->sge_type = SLI4_SGE_TYPE_DATA; in ocs_hw_io_init_sges()
4497 data->last = TRUE; in ocs_hw_io_init_sges()
4501 io->n_sge = 2; in ocs_hw_io_init_sges()
4508 data->sge_type = SLI4_SGE_TYPE_DATA; in ocs_hw_io_init_sges()
4509 data->buffer_address_high = ocs_addr32_hi(io->xfer_rdy.phys); in ocs_hw_io_init_sges()
4510 data->buffer_address_low = ocs_addr32_lo(io->xfer_rdy.phys); in ocs_hw_io_init_sges()
4511 data->buffer_length = io->xfer_rdy.size; in ocs_hw_io_init_sges()
4514 skips--; in ocs_hw_io_init_sges()
4516 io->n_sge = 1; in ocs_hw_io_init_sges()
4531 ocs_log_err(hw->os, "unsupported IO type %#x\n", type); in ocs_hw_io_init_sges()
4539 data->sge_type = SLI4_SGE_TYPE_SKIP; in ocs_hw_io_init_sges()
4543 io->n_sge += skips; in ocs_hw_io_init_sges()
4548 data->last = TRUE; in ocs_hw_io_init_sges()
4558 * @param io Previously-allocated HW IO object.
4561 * @return Returns 0 on success, or a non-zero value on failure.
4570 if ((dif_info == NULL) || (dif_info->dif_oper == OCS_HW_DIF_OPER_DISABLED)) { in ocs_hw_io_add_seed_sge()
4575 ocs_log_err(hw ? hw->os : NULL, "bad parameter hw=%p io=%p dif_info=%p\n", in ocs_hw_io_add_seed_sge()
4580 data = io->sgl->virt; in ocs_hw_io_add_seed_sge()
4581 data += io->n_sge; in ocs_hw_io_add_seed_sge()
4586 dif_seed->ref_tag_cmp = dif_info->ref_tag_cmp; in ocs_hw_io_add_seed_sge()
4587 dif_seed->ref_tag_repl = dif_info->ref_tag_repl; in ocs_hw_io_add_seed_sge()
4588 dif_seed->app_tag_repl = dif_info->app_tag_repl; in ocs_hw_io_add_seed_sge()
4589 dif_seed->repl_app_tag = dif_info->repl_app_tag; in ocs_hw_io_add_seed_sge()
4590 if (SLI4_IF_TYPE_LANCER_FC_ETH != hw->sli.if_type) { in ocs_hw_io_add_seed_sge()
4591 dif_seed->atrt = dif_info->disable_app_ref_ffff; in ocs_hw_io_add_seed_sge()
4592 dif_seed->at = dif_info->disable_app_ffff; in ocs_hw_io_add_seed_sge()
4594 dif_seed->sge_type = SLI4_SGE_TYPE_DISEED; in ocs_hw_io_add_seed_sge()
4596 if (((io->type == OCS_HW_IO_TARGET_WRITE) || (io->type == OCS_HW_IO_INITIATOR_READ)) && in ocs_hw_io_add_seed_sge()
4597 (SLI4_IF_TYPE_LANCER_FC_ETH != hw->sli.if_type) && dif_info->dif_separate) { in ocs_hw_io_add_seed_sge()
4598 dif_seed->sge_type = SLI4_SGE_TYPE_SKIP; in ocs_hw_io_add_seed_sge()
4601 dif_seed->app_tag_cmp = dif_info->app_tag_cmp; in ocs_hw_io_add_seed_sge()
4602 dif_seed->dif_blk_size = dif_info->blk_size; in ocs_hw_io_add_seed_sge()
4603 dif_seed->auto_incr_ref_tag = dif_info->auto_incr_ref_tag; in ocs_hw_io_add_seed_sge()
4604 dif_seed->check_app_tag = dif_info->check_app_tag; in ocs_hw_io_add_seed_sge()
4605 dif_seed->check_ref_tag = dif_info->check_ref_tag; in ocs_hw_io_add_seed_sge()
4606 dif_seed->check_crc = dif_info->check_guard; in ocs_hw_io_add_seed_sge()
4607 dif_seed->new_ref_tag = dif_info->repl_ref_tag; in ocs_hw_io_add_seed_sge()
4609 switch(dif_info->dif_oper) { in ocs_hw_io_add_seed_sge()
4611 dif_seed->dif_op_rx = SLI4_SGE_DIF_OP_IN_NODIF_OUT_CRC; in ocs_hw_io_add_seed_sge()
4612 dif_seed->dif_op_tx = SLI4_SGE_DIF_OP_IN_NODIF_OUT_CRC; in ocs_hw_io_add_seed_sge()
4615 dif_seed->dif_op_rx = SLI4_SGE_DIF_OP_IN_CRC_OUT_NODIF; in ocs_hw_io_add_seed_sge()
4616 dif_seed->dif_op_tx = SLI4_SGE_DIF_OP_IN_CRC_OUT_NODIF; in ocs_hw_io_add_seed_sge()
4619 dif_seed->dif_op_rx = SLI4_SGE_DIF_OP_IN_NODIF_OUT_CHKSUM; in ocs_hw_io_add_seed_sge()
4620 dif_seed->dif_op_tx = SLI4_SGE_DIF_OP_IN_NODIF_OUT_CHKSUM; in ocs_hw_io_add_seed_sge()
4623 dif_seed->dif_op_rx = SLI4_SGE_DIF_OP_IN_CHKSUM_OUT_NODIF; in ocs_hw_io_add_seed_sge()
4624 dif_seed->dif_op_tx = SLI4_SGE_DIF_OP_IN_CHKSUM_OUT_NODIF; in ocs_hw_io_add_seed_sge()
4627 dif_seed->dif_op_rx = SLI4_SGE_DIF_OP_IN_CRC_OUT_CRC; in ocs_hw_io_add_seed_sge()
4628 dif_seed->dif_op_tx = SLI4_SGE_DIF_OP_IN_CRC_OUT_CRC; in ocs_hw_io_add_seed_sge()
4631 dif_seed->dif_op_rx = SLI4_SGE_DIF_OP_IN_CHKSUM_OUT_CHKSUM; in ocs_hw_io_add_seed_sge()
4632 dif_seed->dif_op_tx = SLI4_SGE_DIF_OP_IN_CHKSUM_OUT_CHKSUM; in ocs_hw_io_add_seed_sge()
4635 dif_seed->dif_op_rx = SLI4_SGE_DIF_OP_IN_CRC_OUT_CHKSUM; in ocs_hw_io_add_seed_sge()
4636 dif_seed->dif_op_tx = SLI4_SGE_DIF_OP_IN_CRC_OUT_CHKSUM; in ocs_hw_io_add_seed_sge()
4639 dif_seed->dif_op_rx = SLI4_SGE_DIF_OP_IN_CHKSUM_OUT_CRC; in ocs_hw_io_add_seed_sge()
4640 dif_seed->dif_op_tx = SLI4_SGE_DIF_OP_IN_CHKSUM_OUT_CRC; in ocs_hw_io_add_seed_sge()
4643 dif_seed->dif_op_rx = SLI4_SGE_DIF_OP_IN_RAW_OUT_RAW; in ocs_hw_io_add_seed_sge()
4644 dif_seed->dif_op_tx = SLI4_SGE_DIF_OP_IN_RAW_OUT_RAW; in ocs_hw_io_add_seed_sge()
4647 ocs_log_err(hw->os, "unsupported DIF operation %#x\n", in ocs_hw_io_add_seed_sge()
4648 dif_info->dif_oper); in ocs_hw_io_add_seed_sge()
4655 data->last = TRUE; in ocs_hw_io_add_seed_sge()
4656 if (io->n_sge) { in ocs_hw_io_add_seed_sge()
4657 data[-1].last = FALSE; in ocs_hw_io_add_seed_sge()
4660 io->n_sge++; in ocs_hw_io_add_seed_sge()
4671 if (io->sgl == io->ovfl_sgl) { in ocs_hw_io_overflow_sgl()
4681 if (sli_get_sgl_preregister(&hw->sli) && in ocs_hw_io_overflow_sgl()
4682 io->def_sgl_count > 4 && in ocs_hw_io_overflow_sgl()
4683 io->ovfl_io == NULL && in ocs_hw_io_overflow_sgl()
4684 ((SLI4_IF_TYPE_BE3_SKH_PF == sli_get_if_type(&hw->sli)) || in ocs_hw_io_overflow_sgl()
4685 (SLI4_IF_TYPE_BE3_SKH_VF == sli_get_if_type(&hw->sli)))) { in ocs_hw_io_overflow_sgl()
4686 io->ovfl_io = ocs_hw_io_alloc(hw); in ocs_hw_io_overflow_sgl()
4687 if (io->ovfl_io != NULL) { in ocs_hw_io_overflow_sgl()
4690 * because it checks that SGLs are not pre-registered in ocs_hw_io_overflow_sgl()
4693 io->ovfl_sgl = &io->ovfl_io->def_sgl; in ocs_hw_io_overflow_sgl()
4694 io->ovfl_sgl_count = io->ovfl_io->def_sgl_count; in ocs_hw_io_overflow_sgl()
4699 if (io->ovfl_io == NULL || io->ovfl_sgl == NULL) { in ocs_hw_io_overflow_sgl()
4708 ((sli4_sge_t*)io->ovfl_sgl->virt)[0] = ((sli4_sge_t*)io->sgl->virt)[io->n_sge - 1]; in ocs_hw_io_overflow_sgl()
4710 lsp = &((sli4_lsp_sge_t*)io->sgl->virt)[io->n_sge - 1]; in ocs_hw_io_overflow_sgl()
4713 if ((SLI4_IF_TYPE_BE3_SKH_PF == sli_get_if_type(&hw->sli)) || in ocs_hw_io_overflow_sgl()
4714 (SLI4_IF_TYPE_BE3_SKH_VF == sli_get_if_type(&hw->sli))) { in ocs_hw_io_overflow_sgl()
4715 sli_skh_chain_sge_build(&hw->sli, in ocs_hw_io_overflow_sgl()
4717 io->ovfl_io->indicator, in ocs_hw_io_overflow_sgl()
4721 lsp->buffer_address_high = ocs_addr32_hi(io->ovfl_sgl->phys); in ocs_hw_io_overflow_sgl()
4722 lsp->buffer_address_low = ocs_addr32_lo(io->ovfl_sgl->phys); in ocs_hw_io_overflow_sgl()
4723 lsp->sge_type = SLI4_SGE_TYPE_LSP; in ocs_hw_io_overflow_sgl()
4724 lsp->last = 0; in ocs_hw_io_overflow_sgl()
4725 io->ovfl_lsp = lsp; in ocs_hw_io_overflow_sgl()
4726 io->ovfl_lsp->segment_length = sizeof(sli4_sge_t); in ocs_hw_io_overflow_sgl()
4730 io->sgl = io->ovfl_sgl; in ocs_hw_io_overflow_sgl()
4731 io->sgl_count = io->ovfl_sgl_count; in ocs_hw_io_overflow_sgl()
4732 io->n_sge = 1; in ocs_hw_io_overflow_sgl()
4742 * @param io Previously-allocated HW IO object.
4746 * @return Returns 0 on success, or a non-zero value on failure.
4754 ocs_log_err(hw ? hw->os : NULL, in ocs_hw_io_add_sge()
4760 if ((length != 0) && (io->n_sge + 1) > io->sgl_count) { in ocs_hw_io_add_sge()
4762 ocs_log_err(hw->os, "SGL full (%d)\n", io->n_sge); in ocs_hw_io_add_sge()
4767 if (length > sli_get_max_sge(&hw->sli)) { in ocs_hw_io_add_sge()
4768 ocs_log_err(hw->os, "length of SGE %d bigger than allowed %d\n", in ocs_hw_io_add_sge()
4769 length, sli_get_max_sge(&hw->sli)); in ocs_hw_io_add_sge()
4773 data = io->sgl->virt; in ocs_hw_io_add_sge()
4774 data += io->n_sge; in ocs_hw_io_add_sge()
4776 data->sge_type = SLI4_SGE_TYPE_DATA; in ocs_hw_io_add_sge()
4777 data->buffer_address_high = ocs_addr32_hi(addr); in ocs_hw_io_add_sge()
4778 data->buffer_address_low = ocs_addr32_lo(addr); in ocs_hw_io_add_sge()
4779 data->buffer_length = length; in ocs_hw_io_add_sge()
4780 data->data_offset = io->sge_offset; in ocs_hw_io_add_sge()
4786 data->last = TRUE; in ocs_hw_io_add_sge()
4787 if (io->n_sge) { in ocs_hw_io_add_sge()
4788 data[-1].last = FALSE; in ocs_hw_io_add_sge()
4792 if (io->first_data_sge == 0) { in ocs_hw_io_add_sge()
4793 io->first_data_sge = io->n_sge; in ocs_hw_io_add_sge()
4796 io->sge_offset += length; in ocs_hw_io_add_sge()
4797 io->n_sge++; in ocs_hw_io_add_sge()
4800 if (io->ovfl_lsp != NULL) { in ocs_hw_io_add_sge()
4801 io->ovfl_lsp->segment_length = io->n_sge * sizeof(sli4_sge_t); in ocs_hw_io_add_sge()
4812 * @param io Previously-allocated HW IO object.
4815 * @return Returns 0 on success, or a non-zero value on failure.
4823 ocs_log_err(hw ? hw->os : NULL, in ocs_hw_io_add_dif_sge()
4829 if ((io->n_sge + 1) > hw->config.n_sgl) { in ocs_hw_io_add_dif_sge()
4831 ocs_log_err(hw->os, "SGL full (%d)\n", io->n_sge); in ocs_hw_io_add_dif_sge()
4836 data = io->sgl->virt; in ocs_hw_io_add_dif_sge()
4837 data += io->n_sge; in ocs_hw_io_add_dif_sge()
4839 data->sge_type = SLI4_SGE_TYPE_DIF; in ocs_hw_io_add_dif_sge()
4841 if (((io->type == OCS_HW_IO_TARGET_WRITE) || (io->type == OCS_HW_IO_INITIATOR_READ)) && in ocs_hw_io_add_dif_sge()
4842 (SLI4_IF_TYPE_LANCER_FC_ETH != hw->sli.if_type)) { in ocs_hw_io_add_dif_sge()
4843 data->sge_type = SLI4_SGE_TYPE_SKIP; in ocs_hw_io_add_dif_sge()
4846 data->buffer_address_high = ocs_addr32_hi(addr); in ocs_hw_io_add_dif_sge()
4847 data->buffer_address_low = ocs_addr32_lo(addr); in ocs_hw_io_add_dif_sge()
4854 data->last = TRUE; in ocs_hw_io_add_dif_sge()
4855 if (io->n_sge) { in ocs_hw_io_add_dif_sge()
4856 data[-1].last = FALSE; in ocs_hw_io_add_dif_sge()
4859 io->n_sge++; in ocs_hw_io_add_dif_sge()
4866 * @brief Abort a previously-started IO.
4875 * @return Returns 0 on success, or a non-zero value on failure.
4886 ocs_log_err(hw ? hw->os : NULL, in ocs_hw_io_abort()
4892 if (hw->state != OCS_HW_STATE_ACTIVE) { in ocs_hw_io_abort()
4893 ocs_log_err(hw->os, "cannot send IO abort, HW state=%d\n", in ocs_hw_io_abort()
4894 hw->state); in ocs_hw_io_abort()
4899 if (ocs_ref_get_unless_zero(&io_to_abort->ref) == 0) { in ocs_hw_io_abort()
4901 ocs_log_test(hw ? hw->os : NULL, in ocs_hw_io_abort()
4903 io_to_abort->indicator, io_to_abort->reqtag); in ocs_hw_io_abort()
4907 /* non-port owned XRI checks */ in ocs_hw_io_abort()
4909 if (io_to_abort->wq == NULL) { in ocs_hw_io_abort()
4910 ocs_log_test(hw->os, "io_to_abort xri=0x%x not active on WQ\n", in ocs_hw_io_abort()
4911 io_to_abort->indicator); in ocs_hw_io_abort()
4912 ocs_ref_put(&io_to_abort->ref); /* ocs_ref_get(): same function */ in ocs_hw_io_abort()
4917 ocs_lock(&hw->io_abort_lock); in ocs_hw_io_abort()
4918 if (io_to_abort->abort_in_progress) { in ocs_hw_io_abort()
4919 ocs_unlock(&hw->io_abort_lock); in ocs_hw_io_abort()
4920 ocs_ref_put(&io_to_abort->ref); /* ocs_ref_get(): same function */ in ocs_hw_io_abort()
4921 ocs_log_debug(hw ? hw->os : NULL, in ocs_hw_io_abort()
4923 io_to_abort->indicator, io_to_abort->reqtag); in ocs_hw_io_abort()
4931 io_to_abort->abort_in_progress = 1; in ocs_hw_io_abort()
4932 ocs_unlock(&hw->io_abort_lock); in ocs_hw_io_abort()
4936 * - host owned xri in ocs_hw_io_abort()
4937 * - io_to_abort->wq_index != UINT32_MAX in ocs_hw_io_abort()
4938 * - submit ABORT_WQE to same WQ in ocs_hw_io_abort()
4939 * - port owned xri: in ocs_hw_io_abort()
4940 * - rxri: io_to_abort->wq_index == UINT32_MAX in ocs_hw_io_abort()
4941 * - submit ABORT_WQE to any WQ in ocs_hw_io_abort()
4942 * - non-rxri in ocs_hw_io_abort()
4943 * - io_to_abort->index != UINT32_MAX in ocs_hw_io_abort()
4944 * - submit ABORT_WQE to same WQ in ocs_hw_io_abort()
4945 * - io_to_abort->index == UINT32_MAX in ocs_hw_io_abort()
4946 * - submit ABORT_WQE to any WQ in ocs_hw_io_abort()
4948 io_to_abort->abort_done = cb; in ocs_hw_io_abort()
4949 io_to_abort->abort_arg = arg; in ocs_hw_io_abort()
4952 id = io_to_abort->indicator; in ocs_hw_io_abort()
4957 ocs_log_err(hw->os, "can't allocate request tag\n"); in ocs_hw_io_abort()
4960 io_to_abort->abort_reqtag = wqcb->instance_index; in ocs_hw_io_abort()
4966 if (io_to_abort->wq != NULL) { in ocs_hw_io_abort()
4967 sli_queue_lock(io_to_abort->wq->queue); in ocs_hw_io_abort()
4968 if (ocs_list_on_list(&io_to_abort->wqe.link)) { in ocs_hw_io_abort()
4969 io_to_abort->wqe.abort_wqe_submit_needed = 1; in ocs_hw_io_abort()
4970 io_to_abort->wqe.send_abts = send_abts; in ocs_hw_io_abort()
4971 io_to_abort->wqe.id = id; in ocs_hw_io_abort()
4972 io_to_abort->wqe.abort_reqtag = io_to_abort->abort_reqtag; in ocs_hw_io_abort()
4973 sli_queue_unlock(io_to_abort->wq->queue); in ocs_hw_io_abort()
4976 sli_queue_unlock(io_to_abort->wq->queue); in ocs_hw_io_abort()
4979 …if (sli_abort_wqe(&hw->sli, io_to_abort->wqe.wqebuf, hw->sli.config.wqe_size, atype, send_abts, id… in ocs_hw_io_abort()
4980 io_to_abort->abort_reqtag, SLI4_CQ_DEFAULT)) { in ocs_hw_io_abort()
4981 ocs_log_err(hw->os, "ABORT WQE error\n"); in ocs_hw_io_abort()
4982 io_to_abort->abort_reqtag = UINT32_MAX; in ocs_hw_io_abort()
4988 if (io_to_abort->wq == NULL) { in ocs_hw_io_abort()
4989 io_to_abort->wq = ocs_hw_queue_next_wq(hw, io_to_abort); in ocs_hw_io_abort()
4990 ocs_hw_assert(io_to_abort->wq != NULL); in ocs_hw_io_abort()
4993 * therefore, keep xbusy as-is to track the exchange's state, in ocs_hw_io_abort()
4996 rc = hw_wq_write(io_to_abort->wq, &io_to_abort->wqe); in ocs_hw_io_abort()
4998 /* non-negative return is success */ in ocs_hw_io_abort()
5005 ocs_lock(&hw->io_abort_lock); in ocs_hw_io_abort()
5006 io_to_abort->abort_in_progress = 0; in ocs_hw_io_abort()
5007 ocs_unlock(&hw->io_abort_lock); in ocs_hw_io_abort()
5008 ocs_ref_put(&io_to_abort->ref); /* ocs_ref_get(): same function */ in ocs_hw_io_abort()
5020 * @return Returns X_ID on success, or -1 on failure.
5026 ocs_log_err(hw ? hw->os : NULL, in ocs_hw_io_get_xid()
5028 return -1; in ocs_hw_io_get_xid()
5031 return io->indicator; in ocs_hw_io_get_xid()
5089 * @return Returns 0 on success, or a non-zero value on failure.
5094 if (hw->sli.if_type == SLI4_IF_TYPE_LANCER_FC_ETH) { in ocs_hw_firmware_write()
5098 return -1; in ocs_hw_firmware_write()
5121 * @return Returns 0 on success, or a non-zero value on failure.
5129 int noc=0; /* No Commit bit - set to 1 for testing */ in ocs_hw_firmware_write_lancer()
5131 if (SLI4_IF_TYPE_LANCER_FC_ETH != sli_get_if_type(&hw->sli)) { in ocs_hw_firmware_write_lancer()
5132 ocs_log_test(hw->os, "Function only supported for I/F type 2\n"); in ocs_hw_firmware_write_lancer()
5136 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_firmware_write_lancer()
5138 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_firmware_write_lancer()
5142 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_fw_write_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_firmware_write_lancer()
5144 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_firmware_write_lancer()
5145 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_firmware_write_lancer()
5149 cb_arg->cb = cb; in ocs_hw_firmware_write_lancer()
5150 cb_arg->arg = arg; in ocs_hw_firmware_write_lancer()
5152 if (sli_cmd_common_write_object(&hw->sli, mbxdata, SLI4_BMBX_SIZE, noc, last, in ocs_hw_firmware_write_lancer()
5158 ocs_log_test(hw->os, "COMMON_WRITE_OBJECT failed\n"); in ocs_hw_firmware_write_lancer()
5159 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_firmware_write_lancer()
5160 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_fw_write_cb_arg_t)); in ocs_hw_firmware_write_lancer()
5188 …sli4_res_common_write_object_t* wr_obj_rsp = (sli4_res_common_write_object_t*) &(mbox_rsp->payload… in ocs_hw_cb_fw_write()
5194 bytes_written = wr_obj_rsp->actual_write_length; in ocs_hw_cb_fw_write()
5195 mbox_status = mbox_rsp->hdr.status; in ocs_hw_cb_fw_write()
5196 change_status = wr_obj_rsp->change_status; in ocs_hw_cb_fw_write()
5198 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_fw_write()
5201 if (cb_arg->cb) { in ocs_hw_cb_fw_write()
5205 cb_arg->cb(status, bytes_written, change_status, cb_arg->arg); in ocs_hw_cb_fw_write()
5208 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_fw_write_cb_arg_t)); in ocs_hw_cb_fw_write()
5241 payload = &(cb_arg->payload); in ocs_hw_cb_sfp()
5242 if (cb_arg->cb) { in ocs_hw_cb_sfp()
5243 mbox_rsp = (sli4_res_common_read_transceiver_data_t*) payload->virt; in ocs_hw_cb_sfp()
5244 bytes_written = mbox_rsp->hdr.response_length; in ocs_hw_cb_sfp()
5245 if ((status == 0) && mbox_rsp->hdr.status) { in ocs_hw_cb_sfp()
5246 status = mbox_rsp->hdr.status; in ocs_hw_cb_sfp()
5248 cb_arg->cb(hw->os, status, bytes_written, mbox_rsp->page_data, cb_arg->arg); in ocs_hw_cb_sfp()
5251 ocs_dma_free(hw->os, &cb_arg->payload); in ocs_hw_cb_sfp()
5252 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_sfp_cb_arg_t)); in ocs_hw_cb_sfp()
5255 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_sfp()
5278 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_get_sfp()
5280 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_get_sfp()
5285 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_sfp_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_get_sfp()
5287 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_get_sfp()
5288 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_sfp()
5292 cb_arg->cb = cb; in ocs_hw_get_sfp()
5293 cb_arg->arg = arg; in ocs_hw_get_sfp()
5295 /* payload holds the non-embedded portion */ in ocs_hw_get_sfp()
5296 if (ocs_dma_alloc(hw->os, &cb_arg->payload, sizeof(sli4_res_common_read_transceiver_data_t), in ocs_hw_get_sfp()
5298 ocs_log_err(hw->os, "Failed to allocate DMA buffer\n"); in ocs_hw_get_sfp()
5299 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_sfp_cb_arg_t)); in ocs_hw_get_sfp()
5300 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_sfp()
5305 if (sli_cmd_common_read_transceiver_data(&hw->sli, mbxdata, SLI4_BMBX_SIZE, page, in ocs_hw_get_sfp()
5306 &cb_arg->payload)) { in ocs_hw_get_sfp()
5311 ocs_log_test(hw->os, "READ_TRANSCEIVER_DATA failed with status %d\n", in ocs_hw_get_sfp()
5313 ocs_dma_free(hw->os, &cb_arg->payload); in ocs_hw_get_sfp()
5314 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_sfp_cb_arg_t)); in ocs_hw_get_sfp()
5315 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_sfp()
5337 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_get_temperature()
5339 ocs_log_err(hw->os, "failed to malloc mbox"); in ocs_hw_get_temperature()
5343 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_temp_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_get_temperature()
5345 ocs_log_err(hw->os, "failed to malloc cb_arg"); in ocs_hw_get_temperature()
5346 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_temperature()
5350 cb_arg->cb = cb; in ocs_hw_get_temperature()
5351 cb_arg->arg = arg; in ocs_hw_get_temperature()
5353 if (sli_cmd_dump_type4(&hw->sli, mbxdata, SLI4_BMBX_SIZE, in ocs_hw_get_temperature()
5359 ocs_log_test(hw->os, "DUMP_TYPE4 failed\n"); in ocs_hw_get_temperature()
5360 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_temperature()
5361 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_temp_cb_arg_t)); in ocs_hw_get_temperature()
5388 uint32_t curr_temp = mbox_rsp->resp_data[0]; /* word 5 */ in ocs_hw_cb_temp()
5389 uint32_t crit_temp_thrshld = mbox_rsp->resp_data[1]; /* word 6*/ in ocs_hw_cb_temp()
5390 uint32_t warn_temp_thrshld = mbox_rsp->resp_data[2]; /* word 7 */ in ocs_hw_cb_temp()
5391 uint32_t norm_temp_thrshld = mbox_rsp->resp_data[3]; /* word 8 */ in ocs_hw_cb_temp()
5392 uint32_t fan_off_thrshld = mbox_rsp->resp_data[4]; /* word 9 */ in ocs_hw_cb_temp()
5393 uint32_t fan_on_thrshld = mbox_rsp->resp_data[5]; /* word 10 */ in ocs_hw_cb_temp()
5396 if (cb_arg->cb) { in ocs_hw_cb_temp()
5397 if ((status == 0) && mbox_rsp->hdr.status) { in ocs_hw_cb_temp()
5398 status = mbox_rsp->hdr.status; in ocs_hw_cb_temp()
5400 cb_arg->cb(status, in ocs_hw_cb_temp()
5407 cb_arg->arg); in ocs_hw_cb_temp()
5410 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_temp_cb_arg_t)); in ocs_hw_cb_temp()
5412 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_temp()
5441 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_get_link_stats()
5443 ocs_log_err(hw->os, "failed to malloc mbox"); in ocs_hw_get_link_stats()
5447 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_link_stat_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_get_link_stats()
5449 ocs_log_err(hw->os, "failed to malloc cb_arg"); in ocs_hw_get_link_stats()
5450 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_link_stats()
5454 cb_arg->cb = cb; in ocs_hw_get_link_stats()
5455 cb_arg->arg = arg; in ocs_hw_get_link_stats()
5457 if (sli_cmd_read_link_stats(&hw->sli, mbxdata, SLI4_BMBX_SIZE, in ocs_hw_get_link_stats()
5465 ocs_log_test(hw->os, "READ_LINK_STATS failed\n"); in ocs_hw_get_link_stats()
5466 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_link_stats()
5467 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_link_stat_cb_arg_t)); in ocs_hw_get_link_stats()
5495 uint32_t num_counters = (mbox_rsp->gec ? 20 : 13); in ocs_hw_cb_link_stat()
5500 counts[OCS_HW_LINK_STAT_LINK_FAILURE_COUNT].overflow = mbox_rsp->w02of; in ocs_hw_cb_link_stat()
5501 counts[OCS_HW_LINK_STAT_LOSS_OF_SYNC_COUNT].overflow = mbox_rsp->w03of; in ocs_hw_cb_link_stat()
5502 counts[OCS_HW_LINK_STAT_LOSS_OF_SIGNAL_COUNT].overflow = mbox_rsp->w04of; in ocs_hw_cb_link_stat()
5503 counts[OCS_HW_LINK_STAT_PRIMITIVE_SEQ_COUNT].overflow = mbox_rsp->w05of; in ocs_hw_cb_link_stat()
5504 counts[OCS_HW_LINK_STAT_INVALID_XMIT_WORD_COUNT].overflow = mbox_rsp->w06of; in ocs_hw_cb_link_stat()
5505 counts[OCS_HW_LINK_STAT_CRC_COUNT].overflow = mbox_rsp->w07of; in ocs_hw_cb_link_stat()
5506 counts[OCS_HW_LINK_STAT_PRIMITIVE_SEQ_TIMEOUT_COUNT].overflow = mbox_rsp->w08of; in ocs_hw_cb_link_stat()
5507 counts[OCS_HW_LINK_STAT_ELASTIC_BUFFER_OVERRUN_COUNT].overflow = mbox_rsp->w09of; in ocs_hw_cb_link_stat()
5508 counts[OCS_HW_LINK_STAT_ARB_TIMEOUT_COUNT].overflow = mbox_rsp->w10of; in ocs_hw_cb_link_stat()
5509 counts[OCS_HW_LINK_STAT_ADVERTISED_RCV_B2B_CREDIT].overflow = mbox_rsp->w11of; in ocs_hw_cb_link_stat()
5510 counts[OCS_HW_LINK_STAT_CURR_RCV_B2B_CREDIT].overflow = mbox_rsp->w12of; in ocs_hw_cb_link_stat()
5511 counts[OCS_HW_LINK_STAT_ADVERTISED_XMIT_B2B_CREDIT].overflow = mbox_rsp->w13of; in ocs_hw_cb_link_stat()
5512 counts[OCS_HW_LINK_STAT_CURR_XMIT_B2B_CREDIT].overflow = mbox_rsp->w14of; in ocs_hw_cb_link_stat()
5513 counts[OCS_HW_LINK_STAT_RCV_EOFA_COUNT].overflow = mbox_rsp->w15of; in ocs_hw_cb_link_stat()
5514 counts[OCS_HW_LINK_STAT_RCV_EOFDTI_COUNT].overflow = mbox_rsp->w16of; in ocs_hw_cb_link_stat()
5515 counts[OCS_HW_LINK_STAT_RCV_EOFNI_COUNT].overflow = mbox_rsp->w17of; in ocs_hw_cb_link_stat()
5516 counts[OCS_HW_LINK_STAT_RCV_SOFF_COUNT].overflow = mbox_rsp->w18of; in ocs_hw_cb_link_stat()
5517 counts[OCS_HW_LINK_STAT_RCV_DROPPED_NO_AER_COUNT].overflow = mbox_rsp->w19of; in ocs_hw_cb_link_stat()
5518 counts[OCS_HW_LINK_STAT_RCV_DROPPED_NO_RPI_COUNT].overflow = mbox_rsp->w20of; in ocs_hw_cb_link_stat()
5519 counts[OCS_HW_LINK_STAT_RCV_DROPPED_NO_XRI_COUNT].overflow = mbox_rsp->w21of; in ocs_hw_cb_link_stat()
5521 counts[OCS_HW_LINK_STAT_LINK_FAILURE_COUNT].counter = mbox_rsp->link_failure_error_count; in ocs_hw_cb_link_stat()
5522 counts[OCS_HW_LINK_STAT_LOSS_OF_SYNC_COUNT].counter = mbox_rsp->loss_of_sync_error_count; in ocs_hw_cb_link_stat()
5523 counts[OCS_HW_LINK_STAT_LOSS_OF_SIGNAL_COUNT].counter = mbox_rsp->loss_of_signal_error_count; in ocs_hw_cb_link_stat()
5524 counts[OCS_HW_LINK_STAT_PRIMITIVE_SEQ_COUNT].counter = mbox_rsp->primitive_sequence_error_count; in ocs_hw_cb_link_stat()
5525 …counts[OCS_HW_LINK_STAT_INVALID_XMIT_WORD_COUNT].counter = mbox_rsp->invalid_transmission_word_err… in ocs_hw_cb_link_stat()
5526 counts[OCS_HW_LINK_STAT_CRC_COUNT].counter = mbox_rsp->crc_error_count; in ocs_hw_cb_link_stat()
5527 …counts[OCS_HW_LINK_STAT_PRIMITIVE_SEQ_TIMEOUT_COUNT].counter = mbox_rsp->primitive_sequence_event_… in ocs_hw_cb_link_stat()
5528 …counts[OCS_HW_LINK_STAT_ELASTIC_BUFFER_OVERRUN_COUNT].counter = mbox_rsp->elastic_buffer_overrun_e… in ocs_hw_cb_link_stat()
5529 counts[OCS_HW_LINK_STAT_ARB_TIMEOUT_COUNT].counter = mbox_rsp->arbitration_fc_al_timout_count; in ocs_hw_cb_link_stat()
5530 …counts[OCS_HW_LINK_STAT_ADVERTISED_RCV_B2B_CREDIT].counter = mbox_rsp->advertised_receive_bufftor_… in ocs_hw_cb_link_stat()
5531 …counts[OCS_HW_LINK_STAT_CURR_RCV_B2B_CREDIT].counter = mbox_rsp->current_receive_buffer_to_buffer_… in ocs_hw_cb_link_stat()
5532 …counts[OCS_HW_LINK_STAT_ADVERTISED_XMIT_B2B_CREDIT].counter = mbox_rsp->advertised_transmit_buffer… in ocs_hw_cb_link_stat()
5533 …counts[OCS_HW_LINK_STAT_CURR_XMIT_B2B_CREDIT].counter = mbox_rsp->current_transmit_buffer_to_buffe… in ocs_hw_cb_link_stat()
5534 counts[OCS_HW_LINK_STAT_RCV_EOFA_COUNT].counter = mbox_rsp->received_eofa_count; in ocs_hw_cb_link_stat()
5535 counts[OCS_HW_LINK_STAT_RCV_EOFDTI_COUNT].counter = mbox_rsp->received_eofdti_count; in ocs_hw_cb_link_stat()
5536 counts[OCS_HW_LINK_STAT_RCV_EOFNI_COUNT].counter = mbox_rsp->received_eofni_count; in ocs_hw_cb_link_stat()
5537 counts[OCS_HW_LINK_STAT_RCV_SOFF_COUNT].counter = mbox_rsp->received_soff_count; in ocs_hw_cb_link_stat()
5538 …counts[OCS_HW_LINK_STAT_RCV_DROPPED_NO_AER_COUNT].counter = mbox_rsp->received_dropped_no_aer_coun… in ocs_hw_cb_link_stat()
5539 …counts[OCS_HW_LINK_STAT_RCV_DROPPED_NO_RPI_COUNT].counter = mbox_rsp->received_dropped_no_availabl… in ocs_hw_cb_link_stat()
5540 …counts[OCS_HW_LINK_STAT_RCV_DROPPED_NO_XRI_COUNT].counter = mbox_rsp->received_dropped_no_availabl… in ocs_hw_cb_link_stat()
5543 if (cb_arg->cb) { in ocs_hw_cb_link_stat()
5544 if ((status == 0) && mbox_rsp->hdr.status) { in ocs_hw_cb_link_stat()
5545 status = mbox_rsp->hdr.status; in ocs_hw_cb_link_stat()
5547 cb_arg->cb(status, in ocs_hw_cb_link_stat()
5550 cb_arg->arg); in ocs_hw_cb_link_stat()
5553 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_link_stat_cb_arg_t)); in ocs_hw_cb_link_stat()
5555 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_link_stat()
5577 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO); in ocs_hw_get_host_stats()
5579 ocs_log_err(hw->os, "failed to malloc mbox"); in ocs_hw_get_host_stats()
5583 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_host_stat_cb_arg_t), 0); in ocs_hw_get_host_stats()
5585 ocs_log_err(hw->os, "failed to malloc cb_arg"); in ocs_hw_get_host_stats()
5586 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_host_stats()
5590 cb_arg->cb = cb; in ocs_hw_get_host_stats()
5591 cb_arg->arg = arg; in ocs_hw_get_host_stats()
5594 if (sli_cmd_read_status(&hw->sli, mbxdata, SLI4_BMBX_SIZE, cc)) { in ocs_hw_get_host_stats()
5599 ocs_log_test(hw->os, "READ_HOST_STATS failed\n"); in ocs_hw_get_host_stats()
5600 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_host_stats()
5601 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_host_stat_cb_arg_t)); in ocs_hw_get_host_stats()
5636 counts[OCS_HW_HOST_STAT_TX_KBYTE_COUNT].counter = mbox_rsp->transmit_kbyte_count; in ocs_hw_cb_host_stat()
5637 counts[OCS_HW_HOST_STAT_RX_KBYTE_COUNT].counter = mbox_rsp->receive_kbyte_count; in ocs_hw_cb_host_stat()
5638 counts[OCS_HW_HOST_STAT_TX_FRAME_COUNT].counter = mbox_rsp->transmit_frame_count; in ocs_hw_cb_host_stat()
5639 counts[OCS_HW_HOST_STAT_RX_FRAME_COUNT].counter = mbox_rsp->receive_frame_count; in ocs_hw_cb_host_stat()
5640 counts[OCS_HW_HOST_STAT_TX_SEQ_COUNT].counter = mbox_rsp->transmit_sequence_count; in ocs_hw_cb_host_stat()
5641 counts[OCS_HW_HOST_STAT_RX_SEQ_COUNT].counter = mbox_rsp->receive_sequence_count; in ocs_hw_cb_host_stat()
5642 counts[OCS_HW_HOST_STAT_TOTAL_EXCH_ORIG].counter = mbox_rsp->total_exchanges_originator; in ocs_hw_cb_host_stat()
5643 counts[OCS_HW_HOST_STAT_TOTAL_EXCH_RESP].counter = mbox_rsp->total_exchanges_responder; in ocs_hw_cb_host_stat()
5644 counts[OCS_HW_HOSY_STAT_RX_P_BSY_COUNT].counter = mbox_rsp->receive_p_bsy_count; in ocs_hw_cb_host_stat()
5645 counts[OCS_HW_HOST_STAT_RX_F_BSY_COUNT].counter = mbox_rsp->receive_f_bsy_count; in ocs_hw_cb_host_stat()
5646 …counts[OCS_HW_HOST_STAT_DROP_FRM_DUE_TO_NO_RQ_BUF_COUNT].counter = mbox_rsp->dropped_frames_due_to… in ocs_hw_cb_host_stat()
5647 counts[OCS_HW_HOST_STAT_EMPTY_RQ_TIMEOUT_COUNT].counter = mbox_rsp->empty_rq_timeout_count; in ocs_hw_cb_host_stat()
5648 …counts[OCS_HW_HOST_STAT_DROP_FRM_DUE_TO_NO_XRI_COUNT].counter = mbox_rsp->dropped_frames_due_to_no… in ocs_hw_cb_host_stat()
5649 counts[OCS_HW_HOST_STAT_EMPTY_XRI_POOL_COUNT].counter = mbox_rsp->empty_xri_pool_count; in ocs_hw_cb_host_stat()
5652 if (cb_arg->cb) { in ocs_hw_cb_host_stat()
5653 if ((status == 0) && mbox_rsp->hdr.status) { in ocs_hw_cb_host_stat()
5654 status = mbox_rsp->hdr.status; in ocs_hw_cb_host_stat()
5656 cb_arg->cb(status, in ocs_hw_cb_host_stat()
5659 cb_arg->arg); in ocs_hw_cb_host_stat()
5662 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_host_stat_cb_arg_t)); in ocs_hw_cb_host_stat()
5664 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_host_stat()
5825 if (!sli_link_is_configurable(&hw->sli)) { in ocs_hw_set_linkcfg()
5826 ocs_log_debug(hw->os, "Function not supported\n"); in ocs_hw_set_linkcfg()
5830 if (SLI4_IF_TYPE_LANCER_FC_ETH == sli_get_if_type(&hw->sli)) { in ocs_hw_set_linkcfg()
5832 } else if ((SLI4_IF_TYPE_BE3_SKH_PF == sli_get_if_type(&hw->sli)) || in ocs_hw_set_linkcfg()
5833 (SLI4_IF_TYPE_BE3_SKH_VF == sli_get_if_type(&hw->sli))) { in ocs_hw_set_linkcfg()
5836 ocs_log_test(hw->os, "Function not supported for this IF_TYPE\n"); in ocs_hw_set_linkcfg()
5865 cb_arg = ocs_malloc(hw->os, sizeof(*cb_arg), OCS_M_NOWAIT); in ocs_hw_set_linkcfg_lancer()
5867 ocs_log_err(hw->os, "failed to malloc cb_arg"); in ocs_hw_set_linkcfg_lancer()
5873 if (ocs_dma_alloc(hw->os, &cb_arg->dma_cmd, ocs_strlen(cmd)+1, 4096)) { in ocs_hw_set_linkcfg_lancer()
5874 ocs_log_err(hw->os, "malloc failed\n"); in ocs_hw_set_linkcfg_lancer()
5875 ocs_free(hw->os, cb_arg, sizeof(*cb_arg)); in ocs_hw_set_linkcfg_lancer()
5878 ocs_memset(cb_arg->dma_cmd.virt, 0, ocs_strlen(cmd)+1); in ocs_hw_set_linkcfg_lancer()
5879 ocs_memcpy(cb_arg->dma_cmd.virt, cmd, ocs_strlen(cmd)); in ocs_hw_set_linkcfg_lancer()
5882 if (ocs_dma_alloc(hw->os, &cb_arg->dma_resp, OCS_HW_DMTF_CLP_RSP_MAX, 4096)) { in ocs_hw_set_linkcfg_lancer()
5883 ocs_log_err(hw->os, "malloc failed\n"); in ocs_hw_set_linkcfg_lancer()
5884 ocs_dma_free(hw->os, &cb_arg->dma_cmd); in ocs_hw_set_linkcfg_lancer()
5885 ocs_free(hw->os, cb_arg, sizeof(*cb_arg)); in ocs_hw_set_linkcfg_lancer()
5888 cb_arg->cb = cb; in ocs_hw_set_linkcfg_lancer()
5889 cb_arg->arg = arg; in ocs_hw_set_linkcfg_lancer()
5890 cb_arg->opts = opts; in ocs_hw_set_linkcfg_lancer()
5892 rc = ocs_hw_exec_dmtf_clp_cmd(hw, &cb_arg->dma_cmd, &cb_arg->dma_resp, in ocs_hw_set_linkcfg_lancer()
5900 ocs_log_test(hw->os, "CLP cmd=\"%s\" failed\n", in ocs_hw_set_linkcfg_lancer()
5901 (char *)cb_arg->dma_cmd.virt); in ocs_hw_set_linkcfg_lancer()
5903 ocs_dma_free(hw->os, &cb_arg->dma_cmd); in ocs_hw_set_linkcfg_lancer()
5904 ocs_dma_free(hw->os, &cb_arg->dma_resp); in ocs_hw_set_linkcfg_lancer()
5905 ocs_free(hw->os, cb_arg, sizeof(*cb_arg)); in ocs_hw_set_linkcfg_lancer()
5926 ocs_log_test(hw->os, "SET_RECONFIG_LINK_ID failed, status=%d\n", status); in ocs_hw_set_active_link_config_cb()
5930 if (cb_arg->cb) { in ocs_hw_set_active_link_config_cb()
5931 cb_arg->cb(status, 0, cb_arg->arg); in ocs_hw_set_active_link_config_cb()
5935 if (cb_arg->opts != OCS_CMD_POLL) { in ocs_hw_set_active_link_config_cb()
5936 ocs_free(hw->os, cb_arg, sizeof(*cb_arg)); in ocs_hw_set_active_link_config_cb()
5963 ocs_log_test(hw->os, "Link config %d not supported by Skyhawk\n", value); in ocs_hw_set_linkcfg_skyhawk()
5968 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_set_linkcfg_skyhawk()
5970 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_set_linkcfg_skyhawk()
5975 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_linkcfg_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_set_linkcfg_skyhawk()
5977 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_set_linkcfg_skyhawk()
5978 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_linkcfg_skyhawk()
5982 cb_arg->cb = cb; in ocs_hw_set_linkcfg_skyhawk()
5983 cb_arg->arg = arg; in ocs_hw_set_linkcfg_skyhawk()
5985 if (sli_cmd_common_set_reconfig_link_id(&hw->sli, mbxdata, SLI4_BMBX_SIZE, NULL, 0, config_id)) { in ocs_hw_set_linkcfg_skyhawk()
5990 ocs_log_err(hw->os, "SET_RECONFIG_LINK_ID failed\n"); in ocs_hw_set_linkcfg_skyhawk()
5991 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_linkcfg_skyhawk()
5992 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_linkcfg_cb_arg_t)); in ocs_hw_set_linkcfg_skyhawk()
5996 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_linkcfg_skyhawk()
5997 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_linkcfg_cb_arg_t)); in ocs_hw_set_linkcfg_skyhawk()
6000 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_linkcfg_skyhawk()
6019 if (!sli_link_is_configurable(&hw->sli)) { in ocs_hw_get_linkcfg()
6020 ocs_log_debug(hw->os, "Function not supported\n"); in ocs_hw_get_linkcfg()
6024 if ((SLI4_IF_TYPE_LANCER_FC_ETH == sli_get_if_type(&hw->sli)) || in ocs_hw_get_linkcfg()
6025 (SLI4_IF_TYPE_LANCER_G7 == sli_get_if_type(&hw->sli))){ in ocs_hw_get_linkcfg()
6027 } else if ((SLI4_IF_TYPE_BE3_SKH_PF == sli_get_if_type(&hw->sli)) || in ocs_hw_get_linkcfg()
6028 (SLI4_IF_TYPE_BE3_SKH_VF == sli_get_if_type(&hw->sli))) { in ocs_hw_get_linkcfg()
6031 ocs_log_test(hw->os, "Function not supported for this IF_TYPE\n"); in ocs_hw_get_linkcfg()
6054 cb_arg = ocs_malloc(hw->os, sizeof(*cb_arg), OCS_M_NOWAIT); in ocs_hw_get_linkcfg_lancer()
6056 ocs_log_err(hw->os, "failed to malloc cb_arg"); in ocs_hw_get_linkcfg_lancer()
6063 if (ocs_dma_alloc(hw->os, &cb_arg->dma_cmd, ocs_strlen(cmd)+1, 4096)) { in ocs_hw_get_linkcfg_lancer()
6064 ocs_log_err(hw->os, "malloc failed\n"); in ocs_hw_get_linkcfg_lancer()
6065 ocs_free(hw->os, cb_arg, sizeof(*cb_arg)); in ocs_hw_get_linkcfg_lancer()
6070 ocs_memset(cb_arg->dma_cmd.virt, 0, ocs_strlen(cmd)+1); in ocs_hw_get_linkcfg_lancer()
6071 ocs_memcpy(cb_arg->dma_cmd.virt, cmd, ocs_strlen(cmd)); in ocs_hw_get_linkcfg_lancer()
6074 if (ocs_dma_alloc(hw->os, &cb_arg->dma_resp, OCS_HW_DMTF_CLP_RSP_MAX, 4096)) { in ocs_hw_get_linkcfg_lancer()
6075 ocs_log_err(hw->os, "malloc failed\n"); in ocs_hw_get_linkcfg_lancer()
6076 ocs_dma_free(hw->os, &cb_arg->dma_cmd); in ocs_hw_get_linkcfg_lancer()
6077 ocs_free(hw->os, cb_arg, sizeof(*cb_arg)); in ocs_hw_get_linkcfg_lancer()
6080 cb_arg->cb = cb; in ocs_hw_get_linkcfg_lancer()
6081 cb_arg->arg = arg; in ocs_hw_get_linkcfg_lancer()
6082 cb_arg->opts = opts; in ocs_hw_get_linkcfg_lancer()
6084 rc = ocs_hw_exec_dmtf_clp_cmd(hw, &cb_arg->dma_cmd, &cb_arg->dma_resp, in ocs_hw_get_linkcfg_lancer()
6092 ocs_log_test(hw->os, "CLP cmd=\"%s\" failed\n", in ocs_hw_get_linkcfg_lancer()
6093 (char *)cb_arg->dma_cmd.virt); in ocs_hw_get_linkcfg_lancer()
6095 ocs_dma_free(hw->os, &cb_arg->dma_cmd); in ocs_hw_get_linkcfg_lancer()
6096 ocs_dma_free(hw->os, &cb_arg->dma_resp); in ocs_hw_get_linkcfg_lancer()
6097 ocs_free(hw->os, cb_arg, sizeof(*cb_arg)); in ocs_hw_get_linkcfg_lancer()
6116 sli4_res_common_get_reconfig_link_info_t *rsp = cb_arg->dma_cmd.virt; in ocs_hw_get_active_link_config_cb()
6120 ocs_log_test(hw->os, "GET_RECONFIG_LINK_INFO failed, status=%d\n", status); in ocs_hw_get_active_link_config_cb()
6123 value = ocs_hw_linkcfg_from_config_id(rsp->active_link_config_id); in ocs_hw_get_active_link_config_cb()
6127 if (cb_arg->cb) { in ocs_hw_get_active_link_config_cb()
6128 cb_arg->cb(status, value, cb_arg->arg); in ocs_hw_get_active_link_config_cb()
6132 if (cb_arg->opts != OCS_CMD_POLL) { in ocs_hw_get_active_link_config_cb()
6133 ocs_dma_free(hw->os, &cb_arg->dma_cmd); in ocs_hw_get_active_link_config_cb()
6134 ocs_free(hw->os, cb_arg, sizeof(*cb_arg)); in ocs_hw_get_active_link_config_cb()
6156 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_get_linkcfg_skyhawk()
6158 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_get_linkcfg_skyhawk()
6163 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_linkcfg_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_get_linkcfg_skyhawk()
6165 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_get_linkcfg_skyhawk()
6166 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_linkcfg_skyhawk()
6170 cb_arg->cb = cb; in ocs_hw_get_linkcfg_skyhawk()
6171 cb_arg->arg = arg; in ocs_hw_get_linkcfg_skyhawk()
6172 cb_arg->opts = opts; in ocs_hw_get_linkcfg_skyhawk()
6174 /* dma_mem holds the non-embedded portion */ in ocs_hw_get_linkcfg_skyhawk()
6175 if (ocs_dma_alloc(hw->os, &cb_arg->dma_cmd, sizeof(sli4_res_common_get_reconfig_link_info_t), 4)) { in ocs_hw_get_linkcfg_skyhawk()
6176 ocs_log_err(hw->os, "Failed to allocate DMA buffer\n"); in ocs_hw_get_linkcfg_skyhawk()
6177 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_linkcfg_skyhawk()
6178 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_linkcfg_cb_arg_t)); in ocs_hw_get_linkcfg_skyhawk()
6182 if (sli_cmd_common_get_reconfig_link_info(&hw->sli, mbxdata, SLI4_BMBX_SIZE, &cb_arg->dma_cmd)) { in ocs_hw_get_linkcfg_skyhawk()
6187 ocs_log_err(hw->os, "GET_RECONFIG_LINK_INFO failed\n"); in ocs_hw_get_linkcfg_skyhawk()
6188 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_linkcfg_skyhawk()
6189 ocs_dma_free(hw->os, &cb_arg->dma_cmd); in ocs_hw_get_linkcfg_skyhawk()
6190 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_linkcfg_cb_arg_t)); in ocs_hw_get_linkcfg_skyhawk()
6194 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_linkcfg_skyhawk()
6195 ocs_dma_free(hw->os, &cb_arg->dma_cmd); in ocs_hw_get_linkcfg_skyhawk()
6196 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_linkcfg_cb_arg_t)); in ocs_hw_get_linkcfg_skyhawk()
6199 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_linkcfg_skyhawk()
6220 seed_param.seed = hw->config.dif_seed; in ocs_hw_set_dif_seed()
6223 if (sli_cmd_common_set_features(&hw->sli, buf, SLI4_BMBX_SIZE, in ocs_hw_set_dif_seed()
6229 ocs_log_err(hw->os, "ocs_hw_command returns %d\n", rc); in ocs_hw_set_dif_seed()
6231 ocs_log_debug(hw->os, "DIF seed set to 0x%x\n", in ocs_hw_set_dif_seed()
6232 hw->config.dif_seed); in ocs_hw_set_dif_seed()
6235 ocs_log_err(hw->os, "sli_cmd_common_set_features failed\n"); in ocs_hw_set_dif_seed()
6256 mode_param.tmm = (hw->config.dif_mode == OCS_HW_DIF_MODE_INLINE ? 0 : 1); in ocs_hw_set_dif_mode()
6259 if (sli_cmd_common_set_features(&hw->sli, buf, SLI4_BMBX_SIZE, in ocs_hw_set_dif_mode()
6265 ocs_log_err(hw->os, "ocs_hw_command returns %d\n", rc); in ocs_hw_set_dif_mode()
6267 ocs_log_test(hw->os, "DIF mode set to %s\n", in ocs_hw_set_dif_mode()
6268 (hw->config.dif_mode == OCS_HW_DIF_MODE_INLINE ? "inline" : "separate")); in ocs_hw_set_dif_mode()
6271 ocs_log_err(hw->os, "sli_cmd_common_set_features failed\n"); in ocs_hw_set_dif_mode()
6289 uint16_t timeout = hw->watchdog_timeout; in ocs_hw_cb_cfg_watchdog()
6292 ocs_log_err(hw->os, "config watchdog timer failed, rc = %d\n", status); in ocs_hw_cb_cfg_watchdog()
6296 … ocs_setup_timer(hw->os, &hw->watchdog_timer, ocs_hw_watchdog_timer_cb, hw, (timeout*1000 - 500) ); in ocs_hw_cb_cfg_watchdog()
6298 ocs_del_timer(&hw->watchdog_timer); in ocs_hw_cb_cfg_watchdog()
6302 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_cfg_watchdog()
6318 uint8_t *buf = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_config_watchdog_timer()
6321 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_config_watchdog_timer()
6325 sli4_cmd_lowlevel_set_watchdog(&hw->sli, buf, SLI4_BMBX_SIZE, hw->watchdog_timeout); in ocs_hw_config_watchdog_timer()
6328 ocs_free(hw->os, buf, SLI4_BMBX_SIZE); in ocs_hw_config_watchdog_timer()
6329 ocs_log_err(hw->os, "config watchdog timer failed, rc = %d\n", rc); in ocs_hw_config_watchdog_timer()
6335 * @brief Set configuration parameters for auto-generate xfer_rdy T10 PI feature.
6349 param.rtc = (hw->config.auto_xfer_rdy_ref_tag_is_lba ? 0 : 1); in ocs_hw_config_auto_xfer_rdy_t10pi()
6350 param.atv = (hw->config.auto_xfer_rdy_app_tag_valid ? 1 : 0); in ocs_hw_config_auto_xfer_rdy_t10pi()
6351 param.tmm = ((hw->config.dif_mode == OCS_HW_DIF_MODE_INLINE) ? 0 : 1); in ocs_hw_config_auto_xfer_rdy_t10pi()
6352 param.app_tag = hw->config.auto_xfer_rdy_app_tag_value; in ocs_hw_config_auto_xfer_rdy_t10pi()
6353 param.blk_size = hw->config.auto_xfer_rdy_blk_size_chip; in ocs_hw_config_auto_xfer_rdy_t10pi()
6355 switch (hw->config.auto_xfer_rdy_p_type) { in ocs_hw_config_auto_xfer_rdy_t10pi()
6363 ocs_log_err(hw->os, "unsupported p_type %d\n", in ocs_hw_config_auto_xfer_rdy_t10pi()
6364 hw->config.auto_xfer_rdy_p_type); in ocs_hw_config_auto_xfer_rdy_t10pi()
6369 sli_cmd_common_set_features(&hw->sli, buf, SLI4_BMBX_SIZE, in ocs_hw_config_auto_xfer_rdy_t10pi()
6376 ocs_log_err(hw->os, "ocs_hw_command returns %d\n", rc); in ocs_hw_config_auto_xfer_rdy_t10pi()
6378 …ocs_log_test(hw->os, "Auto XFER RDY T10 PI configured rtc:%d atv:%d p_type:%d app_tag:%x blk_size:… in ocs_hw_config_auto_xfer_rdy_t10pi()
6409 sli_cmd_common_set_features(&hw->sli, buf, SLI4_BMBX_SIZE, in ocs_hw_config_sli_port_health_check()
6416 ocs_log_err(hw->os, "ocs_hw_command returns %d\n", rc); in ocs_hw_config_sli_port_health_check()
6418 ocs_log_test(hw->os, "SLI Port Health Check is enabled \n"); in ocs_hw_config_sli_port_health_check()
6442 sli_cmd_common_set_features(&hw->sli, buf, SLI4_BMBX_SIZE, in ocs_hw_config_set_fdt_xfer_hint()
6449 ocs_log_warn(hw->os, "set FDT hint %d failed: %d\n", fdt_xfer_hint, rc); in ocs_hw_config_set_fdt_xfer_hint()
6451 ocs_log_debug(hw->os, "Set FTD transfer hint to %d\n", param.fdt_xfer_hint); in ocs_hw_config_set_fdt_xfer_hint()
6476 ocs_log_test(hw->os, "CLP cmd failed, status=%d\n", status); in ocs_hw_linkcfg_dmtf_clp_cb()
6481 cb_arg->dma_resp.virt, in ocs_hw_linkcfg_dmtf_clp_cb()
6485 ocs_log_err(hw->os, "failed to get retdata %d\n", result_len); in ocs_hw_linkcfg_dmtf_clp_cb()
6493 if (cb_arg->cb) { in ocs_hw_linkcfg_dmtf_clp_cb()
6494 cb_arg->cb(status, linkcfg, cb_arg->arg); in ocs_hw_linkcfg_dmtf_clp_cb()
6498 if (cb_arg->opts != OCS_CMD_POLL) { in ocs_hw_linkcfg_dmtf_clp_cb()
6499 ocs_dma_free(hw->os, &cb_arg->dma_cmd); in ocs_hw_linkcfg_dmtf_clp_cb()
6500 ocs_dma_free(hw->os, &cb_arg->dma_resp); in ocs_hw_linkcfg_dmtf_clp_cb()
6501 ocs_free(hw->os, cb_arg, sizeof(*cb_arg)); in ocs_hw_linkcfg_dmtf_clp_cb()
6528 if (hw->workaround.disable_dump_loc) { in ocs_hw_set_dump_location()
6529 ocs_log_test(hw->os, "FW version is too old for this feature\n"); in ocs_hw_set_dump_location()
6534 ocs_get_bus_dev_func(hw->os, &bus, &dev, &func); in ocs_hw_set_dump_location()
6536 ocs_log_test(hw->os, "function only valid for pci function 0, %d passed\n", in ocs_hw_set_dump_location()
6550 if (hw->dump_sges.size < sge_size) { in ocs_hw_set_dump_location()
6551 ocs_dma_free(hw->os, &hw->dump_sges); in ocs_hw_set_dump_location()
6552 if (ocs_dma_alloc(hw->os, &hw->dump_sges, sge_size, OCS_MIN_DMA_ALIGNMENT)) { in ocs_hw_set_dump_location()
6553 ocs_log_err(hw->os, "SGE DMA allocation failed\n"); in ocs_hw_set_dump_location()
6558 ocs_memset(hw->dump_sges.virt, 0, hw->dump_sges.size); in ocs_hw_set_dump_location()
6559 hw->dump_sges.len = sge_size; in ocs_hw_set_dump_location()
6560 sge = hw->dump_sges.virt; in ocs_hw_set_dump_location()
6564 sge[i].last = (i == num_buffers - 1 ? 1 : 0); in ocs_hw_set_dump_location()
6567 rc = sli_cmd_common_set_dump_location(&hw->sli, (void *)buf, in ocs_hw_set_dump_location()
6569 &hw->dump_sges, fdb); in ocs_hw_set_dump_location()
6571 dump_buffers->len = dump_buffers->size; in ocs_hw_set_dump_location()
6572 rc = sli_cmd_common_set_dump_location(&hw->sli, (void *)buf, in ocs_hw_set_dump_location()
6581 ocs_log_err(hw->os, "ocs_hw_command returns %d\n", in ocs_hw_set_dump_location()
6585 ocs_log_err(hw->os, in ocs_hw_set_dump_location()
6603 * @param license 32-bit license value.
6616 if (SLI4_IF_TYPE_LANCER_FC_ETH != sli_get_if_type(&hw->sli)) { in ocs_hw_set_eth_license()
6617 ocs_log_test(hw->os, "Function only supported for I/F type 2\n"); in ocs_hw_set_eth_license()
6623 if (ocs_dma_alloc(hw->os, &dma_cmd, ocs_strlen(cmd)+1, 4096)) { in ocs_hw_set_eth_license()
6624 ocs_log_err(hw->os, "malloc failed\n"); in ocs_hw_set_eth_license()
6631 if (ocs_dma_alloc(hw->os, &dma_resp, OCS_HW_DMTF_CLP_RSP_MAX, 4096)) { in ocs_hw_set_eth_license()
6632 ocs_log_err(hw->os, "malloc failed\n"); in ocs_hw_set_eth_license()
6633 ocs_dma_free(hw->os, &dma_cmd); in ocs_hw_set_eth_license()
6639 ocs_log_err(hw->os, "CLP cmd=\"%s\" failed\n", (char *)dma_cmd.virt); in ocs_hw_set_eth_license()
6643 ocs_dma_free(hw->os, &dma_cmd); in ocs_hw_set_eth_license()
6644 ocs_dma_free(hw->os, &dma_resp); in ocs_hw_set_eth_license()
6680 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_exec_dmtf_clp_cmd()
6682 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_exec_dmtf_clp_cmd()
6687 cb_arg = ocs_malloc(hw->os, sizeof(*cb_arg), OCS_M_NOWAIT); in ocs_hw_exec_dmtf_clp_cmd()
6689 ocs_log_err(hw->os, "failed to malloc cb_arg"); in ocs_hw_exec_dmtf_clp_cmd()
6690 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_exec_dmtf_clp_cmd()
6694 cb_arg->cb = cb; in ocs_hw_exec_dmtf_clp_cmd()
6695 cb_arg->arg = arg; in ocs_hw_exec_dmtf_clp_cmd()
6696 cb_arg->dma_resp = dma_resp; in ocs_hw_exec_dmtf_clp_cmd()
6697 cb_arg->opts = opts; in ocs_hw_exec_dmtf_clp_cmd()
6700 if (sli_cmd_dmtf_exec_clp_cmd(&hw->sli, mbxdata, SLI4_BMBX_SIZE, in ocs_hw_exec_dmtf_clp_cmd()
6707 ocs_memcpy(mbxdata, hw->sli.bmbx.virt, SLI4_BMBX_SIZE); in ocs_hw_exec_dmtf_clp_cmd()
6711 rc = cb_arg->status; in ocs_hw_exec_dmtf_clp_cmd()
6717 ocs_log_test(hw->os, "ocs_hw_command failed\n"); in ocs_hw_exec_dmtf_clp_cmd()
6719 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_exec_dmtf_clp_cmd()
6720 ocs_free(hw->os, cb_arg, sizeof(*cb_arg)); in ocs_hw_exec_dmtf_clp_cmd()
6723 ocs_log_test(hw->os, "sli_cmd_dmtf_exec_clp_cmd failed\n"); in ocs_hw_exec_dmtf_clp_cmd()
6725 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_exec_dmtf_clp_cmd()
6726 ocs_free(hw->os, cb_arg, sizeof(*cb_arg)); in ocs_hw_exec_dmtf_clp_cmd()
6748 sli4_res_dmtf_exec_clp_cmd_t *clp_rsp = (sli4_res_dmtf_exec_clp_cmd_t *) mbox_rsp->payload.embed; in ocs_hw_dmtf_clp_cb()
6757 if (status || mbox_rsp->hdr.status || clp_rsp->clp_status) { in ocs_hw_dmtf_clp_cb()
6758 ocs_log_debug(hw->os, "status=x%x/x%x/x%x addl=x%x clp=x%x detail=x%x\n", in ocs_hw_dmtf_clp_cb()
6760 mbox_rsp->hdr.status, in ocs_hw_dmtf_clp_cb()
6761 clp_rsp->hdr.status, in ocs_hw_dmtf_clp_cb()
6762 clp_rsp->hdr.additional_status, in ocs_hw_dmtf_clp_cb()
6763 clp_rsp->clp_status, in ocs_hw_dmtf_clp_cb()
6764 clp_rsp->clp_detailed_status); in ocs_hw_dmtf_clp_cb()
6767 } else if (mbox_rsp->hdr.status) { in ocs_hw_dmtf_clp_cb()
6768 cb_status = mbox_rsp->hdr.status; in ocs_hw_dmtf_clp_cb()
6770 cb_status = clp_rsp->clp_status; in ocs_hw_dmtf_clp_cb()
6773 result_len = clp_rsp->resp_length; in ocs_hw_dmtf_clp_cb()
6780 if ((result_len == 0) || (cb_arg->dma_resp->size < result_len)) { in ocs_hw_dmtf_clp_cb()
6781 ocs_log_test(hw->os, "Invalid response length: resp_len=%zu result len=%d\n", in ocs_hw_dmtf_clp_cb()
6782 cb_arg->dma_resp->size, result_len); in ocs_hw_dmtf_clp_cb()
6783 cb_status = -1; in ocs_hw_dmtf_clp_cb()
6790 cb_arg->dma_resp->virt, in ocs_hw_dmtf_clp_cb()
6794 ocs_log_test(hw->os, "failed to get status %d\n", stat_len); in ocs_hw_dmtf_clp_cb()
6795 cb_status = -1; in ocs_hw_dmtf_clp_cb()
6800 ocs_log_test(hw->os, "CLP status indicates failure=%s\n", stat_str); in ocs_hw_dmtf_clp_cb()
6801 cb_status = -1; in ocs_hw_dmtf_clp_cb()
6808 cb_arg->status = cb_status; in ocs_hw_dmtf_clp_cb()
6809 if (cb_arg->cb) { in ocs_hw_dmtf_clp_cb()
6810 cb_arg->cb(hw, cb_status, result_len, cb_arg->arg); in ocs_hw_dmtf_clp_cb()
6813 if (cb_arg->opts != OCS_CMD_POLL) { in ocs_hw_dmtf_clp_cb()
6814 ocs_free(hw->os, cb_arg, sizeof(*cb_arg)); in ocs_hw_dmtf_clp_cb()
6815 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_dmtf_clp_cb()
6843 ocs_log_test(hw->os, "could not find keyword=%s in CLP response\n", in ocs_hw_clp_resp_get_value()
6845 return -1; in ocs_hw_clp_resp_get_value()
6851 ocs_log_test(hw->os, "could not find \'=\' in CLP response for keyword=%s\n", in ocs_hw_clp_resp_get_value()
6853 return -1; in ocs_hw_clp_resp_get_value()
6860 ocs_log_test(hw->os, "could not find \\r\\n for keyword=%s in CLP response\n", in ocs_hw_clp_resp_get_value()
6862 return -1; in ocs_hw_clp_resp_get_value()
6866 if ((end - start + 1) > value_len) { in ocs_hw_clp_resp_get_value()
6867 ocs_log_test(hw->os, "value len=%d not large enough for actual=%ld\n", in ocs_hw_clp_resp_get_value()
6868 value_len, (end-start)); in ocs_hw_clp_resp_get_value()
6869 return -1; in ocs_hw_clp_resp_get_value()
6872 ocs_strncpy(value, start, (end - start)); in ocs_hw_clp_resp_get_value()
6873 value[end-start] = '\0'; in ocs_hw_clp_resp_get_value()
6874 return (end-start+1); in ocs_hw_clp_resp_get_value()
6888 * @return Returns 0 on success, or a non-zero value on failure.
6896 if (sli_raise_ue(&hw->sli, dump) != 0) { in ocs_hw_raise_ue()
6899 if (hw->state != OCS_HW_STATE_UNINITIALIZED) { in ocs_hw_raise_ue()
6900 hw->state = OCS_HW_STATE_QUEUES_ALLOCATED; in ocs_hw_raise_ue()
6927 …sli4_res_common_read_object_t* rd_obj_rsp = (sli4_res_common_read_object_t*) mbox_rsp->payload.emb… in ocs_hw_cb_dump_get()
6932 bytes_read = rd_obj_rsp->actual_read_length; in ocs_hw_cb_dump_get()
6933 eof = rd_obj_rsp->eof; in ocs_hw_cb_dump_get()
6936 if (cb_arg->cb) { in ocs_hw_cb_dump_get()
6937 if ((status == 0) && mbox_rsp->hdr.status) { in ocs_hw_cb_dump_get()
6938 status = mbox_rsp->hdr.status; in ocs_hw_cb_dump_get()
6940 cb_arg->cb(status, bytes_read, eof, cb_arg->arg); in ocs_hw_cb_dump_get()
6943 ocs_free(hw->os, cb_arg->mbox_cmd, SLI4_BMBX_SIZE); in ocs_hw_cb_dump_get()
6944 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_dump_get_cb_arg_t)); in ocs_hw_cb_dump_get()
6968 * @return Returns 0 on success, or a non-zero value on failure.
6976 uint32_t opts = (hw->state == OCS_HW_STATE_ACTIVE ? OCS_CMD_NOWAIT : OCS_CMD_POLL); in ocs_hw_dump_get()
6978 if (SLI4_IF_TYPE_LANCER_FC_ETH != sli_get_if_type(&hw->sli)) { in ocs_hw_dump_get()
6979 ocs_log_test(hw->os, "Function only supported for I/F type 2\n"); in ocs_hw_dump_get()
6983 if (1 != sli_dump_is_present(&hw->sli)) { in ocs_hw_dump_get()
6984 ocs_log_test(hw->os, "No dump is present\n"); in ocs_hw_dump_get()
6988 if (1 == sli_reset_required(&hw->sli)) { in ocs_hw_dump_get()
6989 ocs_log_test(hw->os, "device reset required\n"); in ocs_hw_dump_get()
6993 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_dump_get()
6995 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_dump_get()
6999 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_dump_get_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_dump_get()
7001 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_dump_get()
7002 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_dump_get()
7006 cb_arg->cb = cb; in ocs_hw_dump_get()
7007 cb_arg->arg = arg; in ocs_hw_dump_get()
7008 cb_arg->mbox_cmd = mbxdata; in ocs_hw_dump_get()
7010 if (sli_cmd_common_read_object(&hw->sli, mbxdata, SLI4_BMBX_SIZE, in ocs_hw_dump_get()
7014 ocs_memcpy(mbxdata, hw->sli.bmbx.virt, SLI4_BMBX_SIZE); in ocs_hw_dump_get()
7020 ocs_log_test(hw->os, "COMMON_READ_OBJECT failed\n"); in ocs_hw_dump_get()
7021 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_dump_get()
7022 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_dump_get_cb_arg_t)); in ocs_hw_dump_get()
7050 if (cb_arg->cb) { in ocs_hw_cb_dump_clear()
7051 if ((status == 0) && mbox_rsp->hdr.status) { in ocs_hw_cb_dump_clear()
7052 status = mbox_rsp->hdr.status; in ocs_hw_cb_dump_clear()
7054 cb_arg->cb(status, cb_arg->arg); in ocs_hw_cb_dump_clear()
7057 ocs_free(hw->os, cb_arg->mbox_cmd, SLI4_BMBX_SIZE); in ocs_hw_cb_dump_clear()
7058 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_dump_clear_cb_arg_t)); in ocs_hw_cb_dump_clear()
7079 * @return Returns 0 on success, or a non-zero value on failure.
7087 uint32_t opts = (hw->state == OCS_HW_STATE_ACTIVE ? OCS_CMD_NOWAIT : OCS_CMD_POLL); in ocs_hw_dump_clear()
7089 if (SLI4_IF_TYPE_LANCER_FC_ETH != sli_get_if_type(&hw->sli)) { in ocs_hw_dump_clear()
7090 ocs_log_test(hw->os, "Function only supported for I/F type 2\n"); in ocs_hw_dump_clear()
7094 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_dump_clear()
7096 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_dump_clear()
7100 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_dump_clear_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_dump_clear()
7102 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_dump_clear()
7103 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_dump_clear()
7107 cb_arg->cb = cb; in ocs_hw_dump_clear()
7108 cb_arg->arg = arg; in ocs_hw_dump_clear()
7109 cb_arg->mbox_cmd = mbxdata; in ocs_hw_dump_clear()
7111 if (sli_cmd_common_delete_object(&hw->sli, mbxdata, SLI4_BMBX_SIZE, in ocs_hw_dump_clear()
7115 ocs_memcpy(mbxdata, hw->sli.bmbx.virt, SLI4_BMBX_SIZE); in ocs_hw_dump_clear()
7121 ocs_log_test(hw->os, "COMMON_DELETE_OBJECT failed\n"); in ocs_hw_dump_clear()
7122 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_dump_clear()
7123 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_dump_clear_cb_arg_t)); in ocs_hw_dump_clear()
7145 * @return Returns 0 on success, or a non-zero value on failure.
7152 ocs_dma_t *payload = &(cb_arg->payload); in ocs_hw_get_port_protocol_cb()
7153 …sli4_res_common_get_profile_config_t* response = (sli4_res_common_get_profile_config_t*) payload->… in ocs_hw_get_port_protocol_cb()
7162 num_descriptors = response->desc_count; in ocs_hw_get_port_protocol_cb()
7163 desc_p = (sli4_resource_descriptor_v1_t *)response->desc; in ocs_hw_get_port_protocol_cb()
7165 if (desc_p->descriptor_type == SLI4_RESOURCE_DESCRIPTOR_TYPE_PCIE) { in ocs_hw_get_port_protocol_cb()
7167 if (pcie_desc_p->pf_number == cb_arg->pci_func) { in ocs_hw_get_port_protocol_cb()
7168 switch(pcie_desc_p->pf_type) { in ocs_hw_get_port_protocol_cb()
7185 desc_p = (sli4_resource_descriptor_v1_t *) ((uint8_t *)desc_p + desc_p->descriptor_length); in ocs_hw_get_port_protocol_cb()
7188 if (cb_arg->cb) { in ocs_hw_get_port_protocol_cb()
7189 cb_arg->cb(status, port_protocol, cb_arg->arg); in ocs_hw_get_port_protocol_cb()
7192 ocs_dma_free(hw->os, &cb_arg->payload); in ocs_hw_get_port_protocol_cb()
7193 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_get_port_protocol_cb_arg_t)); in ocs_hw_get_port_protocol_cb()
7194 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_get_port_protocol_cb()
7213 * - OCS_HW_RTN_SUCCESS on success.
7214 * - OCS_HW_RTN_NO_MEMORY if a malloc fails.
7215 * - OCS_HW_RTN_NO_RESOURCES if unable to get a command
7217 * - OCS_HW_RTN_ERROR on any other error.
7228 if (sli_get_if_type(&hw->sli) != SLI4_IF_TYPE_BE3_SKH_PF) { in ocs_hw_get_port_protocol()
7233 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_get_port_protocol()
7235 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_get_port_protocol()
7240 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_get_port_protocol_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_get_port_protocol()
7242 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_get_port_protocol()
7243 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_port_protocol()
7247 cb_arg->cb = cb; in ocs_hw_get_port_protocol()
7248 cb_arg->arg = ul_arg; in ocs_hw_get_port_protocol()
7249 cb_arg->pci_func = pci_func; in ocs_hw_get_port_protocol()
7251 /* dma_mem holds the non-embedded portion */ in ocs_hw_get_port_protocol()
7252 if (ocs_dma_alloc(hw->os, &cb_arg->payload, 4096, 4)) { in ocs_hw_get_port_protocol()
7253 ocs_log_err(hw->os, "Failed to allocate DMA buffer\n"); in ocs_hw_get_port_protocol()
7254 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_port_protocol()
7255 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_get_port_protocol_cb_arg_t)); in ocs_hw_get_port_protocol()
7259 if (sli_cmd_common_get_profile_config(&hw->sli, mbxdata, SLI4_BMBX_SIZE, &cb_arg->payload)) { in ocs_hw_get_port_protocol()
7264 ocs_log_test(hw->os, "GET_PROFILE_CONFIG failed\n"); in ocs_hw_get_port_protocol()
7265 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_port_protocol()
7266 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_fw_write_cb_arg_t)); in ocs_hw_get_port_protocol()
7267 ocs_dma_free(hw->os, &cb_arg->payload); in ocs_hw_get_port_protocol()
7288 * function. The set operation is a read-modify-write. This
7297 * @return 0 on success, non-zero otherwise
7304 if (cb_arg->cb) { in ocs_hw_set_port_protocol_cb2()
7305 cb_arg->cb( status, cb_arg->arg); in ocs_hw_set_port_protocol_cb2()
7308 ocs_dma_free(hw->os, &(cb_arg->payload)); in ocs_hw_set_port_protocol_cb2()
7309 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_set_port_protocol_cb2()
7310 ocs_free(hw->os, arg, sizeof(ocs_hw_set_port_protocol_cb_arg_t)); in ocs_hw_set_port_protocol_cb2()
7321 * function. The set operation is a read-modify-write. This
7336 * @return Returns 0 on success, or a non-zero value otherwise.
7342 ocs_dma_t *payload = &(cb_arg->payload); in ocs_hw_set_port_protocol_cb1()
7343 …sli4_res_common_get_profile_config_t* response = (sli4_res_common_get_profile_config_t*) payload->… in ocs_hw_set_port_protocol_cb1()
7358 new_protocol = (ocs_hw_port_protocol_e)cb_arg->new_protocol; in ocs_hw_set_port_protocol_cb1()
7360 num_descriptors = response->desc_count; in ocs_hw_set_port_protocol_cb1()
7364 desc_p = (sli4_resource_descriptor_v1_t *)response->desc; in ocs_hw_set_port_protocol_cb1()
7366 if (desc_p->descriptor_type == SLI4_RESOURCE_DESCRIPTOR_TYPE_PCIE) { in ocs_hw_set_port_protocol_cb1()
7369 desc_p = (sli4_resource_descriptor_v1_t *) ((uint8_t *)desc_p + desc_p->descriptor_length); in ocs_hw_set_port_protocol_cb1()
7373 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_set_port_protocol_cb1()
7375 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_set_port_protocol_cb1()
7380 new_cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_set_port_protocol_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_set_port_protocol_cb1()
7382 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_set_port_protocol_cb1()
7383 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_port_protocol_cb1()
7387 new_cb_arg->cb = cb_arg->cb; in ocs_hw_set_port_protocol_cb1()
7388 new_cb_arg->arg = cb_arg->arg; in ocs_hw_set_port_protocol_cb1()
7392 if (ocs_dma_alloc(hw->os, &new_cb_arg->payload, sizeof(sli4_req_common_set_profile_config_t) + in ocs_hw_set_port_protocol_cb1()
7395 ocs_log_err(hw->os, "Failed to allocate DMA buffer\n"); in ocs_hw_set_port_protocol_cb1()
7396 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_port_protocol_cb1()
7397 ocs_free(hw->os, new_cb_arg, sizeof(ocs_hw_set_port_protocol_cb_arg_t)); in ocs_hw_set_port_protocol_cb1()
7401 sli_cmd_common_set_profile_config(&hw->sli, mbxdata, SLI4_BMBX_SIZE, in ocs_hw_set_port_protocol_cb1()
7402 &new_cb_arg->payload, in ocs_hw_set_port_protocol_cb1()
7406 dst = (uint8_t *)&(((sli4_req_common_set_profile_config_t *) new_cb_arg->payload.virt)->desc); in ocs_hw_set_port_protocol_cb1()
7408 /* Loop over all descriptors. If the descriptor is a PCIe descriptor, copy it in ocs_hw_set_port_protocol_cb1()
7412 desc_p = (sli4_resource_descriptor_v1_t *)response->desc; in ocs_hw_set_port_protocol_cb1()
7414 if (desc_p->descriptor_type == SLI4_RESOURCE_DESCRIPTOR_TYPE_PCIE) { in ocs_hw_set_port_protocol_cb1()
7416 if (pcie_desc_p->pf_number == cb_arg->pci_func) { in ocs_hw_set_port_protocol_cb1()
7417 /* This is the PCIe descriptor for this OCS instance. in ocs_hw_set_port_protocol_cb1()
7421 pcie_desc_p->pf_type = SLI4_PROTOCOL_FC; in ocs_hw_set_port_protocol_cb1()
7424 pcie_desc_p->pf_type = SLI4_PROTOCOL_FCOE; in ocs_hw_set_port_protocol_cb1()
7427 pcie_desc_p->pf_type = SLI4_PROTOCOL_ISCSI; in ocs_hw_set_port_protocol_cb1()
7430 pcie_desc_p->pf_type = SLI4_PROTOCOL_DEFAULT; in ocs_hw_set_port_protocol_cb1()
7435 if (pcie_desc_p->pf_type == SLI4_PROTOCOL_FCOE) { in ocs_hw_set_port_protocol_cb1()
7438 if (pcie_desc_p->pf_type == SLI4_PROTOCOL_ISCSI) { in ocs_hw_set_port_protocol_cb1()
7445 desc_p = (sli4_resource_descriptor_v1_t *) ((uint8_t *)desc_p + desc_p->descriptor_length); in ocs_hw_set_port_protocol_cb1()
7450 isap_desc_p->descriptor_type = SLI4_RESOURCE_DESCRIPTOR_TYPE_ISAP; in ocs_hw_set_port_protocol_cb1()
7451 isap_desc_p->descriptor_length = sizeof(sli4_isap_resouce_descriptor_v1_t); in ocs_hw_set_port_protocol_cb1()
7453 isap_desc_p->iscsi_tgt = 1; in ocs_hw_set_port_protocol_cb1()
7454 isap_desc_p->iscsi_ini = 1; in ocs_hw_set_port_protocol_cb1()
7455 isap_desc_p->iscsi_dif = 1; in ocs_hw_set_port_protocol_cb1()
7458 isap_desc_p->fcoe_tgt = 1; in ocs_hw_set_port_protocol_cb1()
7459 isap_desc_p->fcoe_ini = 1; in ocs_hw_set_port_protocol_cb1()
7460 isap_desc_p->fcoe_dif = 1; in ocs_hw_set_port_protocol_cb1()
7464 ocs_dma_free(hw->os, &cb_arg->payload); in ocs_hw_set_port_protocol_cb1()
7465 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_set_port_protocol_cb1()
7466 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_set_port_protocol_cb_arg_t)); in ocs_hw_set_port_protocol_cb1()
7471 ocs_log_err(hw->os, "Error posting COMMON_SET_PROFILE_CONFIG\n"); in ocs_hw_set_port_protocol_cb1()
7473 if (new_cb_arg->cb) { in ocs_hw_set_port_protocol_cb1()
7474 new_cb_arg->cb( rc, new_cb_arg->arg); in ocs_hw_set_port_protocol_cb1()
7478 ocs_dma_free(hw->os, &new_cb_arg->payload); in ocs_hw_set_port_protocol_cb1()
7479 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_port_protocol_cb1()
7480 ocs_free(hw->os, new_cb_arg, sizeof(ocs_hw_set_port_protocol_cb_arg_t)); in ocs_hw_set_port_protocol_cb1()
7490 * Setting the port protocol is a read-modify-write operation.
7506 * - OCS_HW_RTN_SUCCESS on success.
7507 * - OCS_HW_RTN_NO_MEMORY if a malloc fails.
7508 * - OCS_HW_RTN_NO_RESOURCES if unable to get a command
7510 * - OCS_HW_RTN_ERROR on any other error.
7521 if (sli_get_if_type(&hw->sli) != SLI4_IF_TYPE_BE3_SKH_PF) { in ocs_hw_set_port_protocol()
7526 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_set_port_protocol()
7528 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_set_port_protocol()
7533 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_set_port_protocol_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_set_port_protocol()
7535 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_set_port_protocol()
7536 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_port_protocol()
7540 cb_arg->cb = cb; in ocs_hw_set_port_protocol()
7541 cb_arg->arg = ul_arg; in ocs_hw_set_port_protocol()
7542 cb_arg->new_protocol = new_protocol; in ocs_hw_set_port_protocol()
7543 cb_arg->pci_func = pci_func; in ocs_hw_set_port_protocol()
7545 /* dma_mem holds the non-embedded portion */ in ocs_hw_set_port_protocol()
7546 if (ocs_dma_alloc(hw->os, &cb_arg->payload, 4096, 4)) { in ocs_hw_set_port_protocol()
7547 ocs_log_err(hw->os, "Failed to allocate DMA buffer\n"); in ocs_hw_set_port_protocol()
7548 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_port_protocol()
7549 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_get_port_protocol_cb_arg_t)); in ocs_hw_set_port_protocol()
7553 if (sli_cmd_common_get_profile_config(&hw->sli, mbxdata, SLI4_BMBX_SIZE, &cb_arg->payload)) { in ocs_hw_set_port_protocol()
7558 ocs_log_test(hw->os, "GET_PROFILE_CONFIG failed\n"); in ocs_hw_set_port_protocol()
7559 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_port_protocol()
7560 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_fw_write_cb_arg_t)); in ocs_hw_set_port_protocol()
7561 ocs_dma_free(hw->os, &cb_arg->payload); in ocs_hw_set_port_protocol()
7579 * ctx->non_embedded_mem.virt. This function parses the
7588 * @return Returns 0 on success, or a non-zero value on failure.
7595 ocs_dma_t *payload = &(cb_arg->payload); in ocs_hw_get_profile_list_cb()
7596 sli4_res_common_get_profile_list_t *response = (sli4_res_common_get_profile_list_t *)payload->virt; in ocs_hw_get_profile_list_cb()
7600 list = ocs_malloc(hw->os, sizeof(ocs_hw_profile_list_t), OCS_M_ZERO); in ocs_hw_get_profile_list_cb()
7602 ocs_log_err(hw->os, "failed to malloc list\n"); in ocs_hw_get_profile_list_cb()
7606 list->num_descriptors = response->profile_descriptor_count; in ocs_hw_get_profile_list_cb()
7608 num_descriptors = list->num_descriptors; in ocs_hw_get_profile_list_cb()
7614 list->descriptors[i].profile_id = response->profile_descriptor[i].profile_id; in ocs_hw_get_profile_list_cb()
7615 list->descriptors[i].profile_index = response->profile_descriptor[i].profile_index; in ocs_hw_get_profile_list_cb()
7616 …ocs_strcpy(list->descriptors[i].profile_description, (char *)response->profile_descriptor[i].profi… in ocs_hw_get_profile_list_cb()
7619 if (cb_arg->cb) { in ocs_hw_get_profile_list_cb()
7620 cb_arg->cb(status, list, cb_arg->arg); in ocs_hw_get_profile_list_cb()
7622 ocs_free(hw->os, list, sizeof(*list)); in ocs_hw_get_profile_list_cb()
7625 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_get_profile_list_cb()
7626 ocs_dma_free(hw->os, &cb_arg->payload); in ocs_hw_get_profile_list_cb()
7627 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_get_profile_list_cb_arg_t)); in ocs_hw_get_profile_list_cb()
7636 * Issues a SLI-4 COMMON_GET_PROFILE_LIST mailbox. When the
7647 * - OCS_HW_RTN_SUCCESS on success.
7648 * - OCS_HW_RTN_NO_MEMORY if a malloc fails.
7649 * - OCS_HW_RTN_NO_RESOURCES if unable to get a command
7651 * - OCS_HW_RTN_ERROR on any other error.
7661 if (sli_get_if_type(&hw->sli) != SLI4_IF_TYPE_BE3_SKH_PF) { in ocs_hw_get_profile_list()
7666 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_get_profile_list()
7668 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_get_profile_list()
7673 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_get_profile_list_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_get_profile_list()
7675 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_get_profile_list()
7676 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_profile_list()
7680 cb_arg->cb = cb; in ocs_hw_get_profile_list()
7681 cb_arg->arg = ul_arg; in ocs_hw_get_profile_list()
7683 /* dma_mem holds the non-embedded portion */ in ocs_hw_get_profile_list()
7684 if (ocs_dma_alloc(hw->os, &cb_arg->payload, sizeof(sli4_res_common_get_profile_list_t), 4)) { in ocs_hw_get_profile_list()
7685 ocs_log_err(hw->os, "Failed to allocate DMA buffer\n"); in ocs_hw_get_profile_list()
7686 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_profile_list()
7687 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_get_profile_list_cb_arg_t)); in ocs_hw_get_profile_list()
7691 if (sli_cmd_common_get_profile_list(&hw->sli, mbxdata, SLI4_BMBX_SIZE, 0, &cb_arg->payload)) { in ocs_hw_get_profile_list()
7696 ocs_log_test(hw->os, "GET_PROFILE_LIST failed\n"); in ocs_hw_get_profile_list()
7697 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_profile_list()
7698 ocs_dma_free(hw->os, &cb_arg->payload); in ocs_hw_get_profile_list()
7699 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_get_profile_list_cb_arg_t)); in ocs_hw_get_profile_list()
7719 * @return Returns 0 on success, or a non-zero value on failure.
7726 …sli4_res_common_get_active_profile_t* response = (sli4_res_common_get_active_profile_t*) mbox_rsp- in ocs_hw_get_active_profile_cb()
7729 active_profile = response->active_profile_id; in ocs_hw_get_active_profile_cb()
7731 if (cb_arg->cb) { in ocs_hw_get_active_profile_cb()
7732 cb_arg->cb(status, active_profile, cb_arg->arg); in ocs_hw_get_active_profile_cb()
7735 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_get_active_profile_cb()
7736 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_get_active_profile_cb_arg_t)); in ocs_hw_get_active_profile_cb()
7745 * Issues a SLI-4 COMMON_GET_ACTIVE_PROFILE mailbox. When the
7756 * - OCS_HW_RTN_SUCCESS on success.
7757 * - OCS_HW_RTN_NO_MEMORY if a malloc fails.
7758 * - OCS_HW_RTN_NO_RESOURCES if unable to get a command
7760 * - OCS_HW_RTN_ERROR on any other error.
7770 if (sli_get_if_type(&hw->sli) != SLI4_IF_TYPE_BE3_SKH_PF) { in ocs_hw_get_active_profile()
7775 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_get_active_profile()
7777 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_get_active_profile()
7782 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_get_active_profile_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_get_active_profile()
7784 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_get_active_profile()
7785 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_active_profile()
7789 cb_arg->cb = cb; in ocs_hw_get_active_profile()
7790 cb_arg->arg = ul_arg; in ocs_hw_get_active_profile()
7792 if (sli_cmd_common_get_active_profile(&hw->sli, mbxdata, SLI4_BMBX_SIZE)) { in ocs_hw_get_active_profile()
7797 ocs_log_test(hw->os, "GET_ACTIVE_PROFILE failed\n"); in ocs_hw_get_active_profile()
7798 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_active_profile()
7799 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_get_active_profile_cb_arg_t)); in ocs_hw_get_active_profile()
7819 * @return 0 on success, non-zero otherwise
7827 if (cb_arg->cb) { in ocs_hw_get_nvparms_cb()
7828 cb_arg->cb(status, mbox_rsp->wwpn, mbox_rsp->wwnn, mbox_rsp->hard_alpa, in ocs_hw_get_nvparms_cb()
7829 mbox_rsp->preferred_d_id, cb_arg->arg); in ocs_hw_get_nvparms_cb()
7832 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_get_nvparms_cb()
7833 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_get_nvparms_cb_arg_t)); in ocs_hw_get_nvparms_cb()
7840 * @brief Read non-volatile parms.
7842 * Issues a SLI-4 READ_NVPARMS mailbox. When the
7853 * - OCS_HW_RTN_SUCCESS on success.
7854 * - OCS_HW_RTN_NO_MEMORY if a malloc fails.
7855 * - OCS_HW_RTN_NO_RESOURCES if unable to get a command
7857 * - OCS_HW_RTN_ERROR on any other error.
7867 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_get_nvparms()
7869 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_get_nvparms()
7874 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_get_nvparms_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_get_nvparms()
7876 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_get_nvparms()
7877 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_nvparms()
7881 cb_arg->cb = cb; in ocs_hw_get_nvparms()
7882 cb_arg->arg = ul_arg; in ocs_hw_get_nvparms()
7884 if (sli_cmd_read_nvparms(&hw->sli, mbxdata, SLI4_BMBX_SIZE)) { in ocs_hw_get_nvparms()
7889 ocs_log_test(hw->os, "READ_NVPARMS failed\n"); in ocs_hw_get_nvparms()
7890 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_get_nvparms()
7891 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_get_nvparms_cb_arg_t)); in ocs_hw_get_nvparms()
7911 * @return Returns 0 on success, or a non-zero value on failure.
7918 if (cb_arg->cb) { in ocs_hw_set_nvparms_cb()
7919 cb_arg->cb(status, cb_arg->arg); in ocs_hw_set_nvparms_cb()
7922 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_set_nvparms_cb()
7923 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_set_nvparms_cb_arg_t)); in ocs_hw_set_nvparms_cb()
7930 * @brief Write non-volatile parms.
7932 * Issues a SLI-4 WRITE_NVPARMS mailbox. When the
7939 * @param wwpn Port's WWPN in big-endian order, or NULL to use default.
7940 * @param wwnn Port's WWNN in big-endian order, or NULL to use default.
7950 * - OCS_HW_RTN_SUCCESS on success.
7951 * - OCS_HW_RTN_NO_MEMORY if a malloc fails.
7952 * - OCS_HW_RTN_NO_RESOURCES if unable to get a command
7954 * - OCS_HW_RTN_ERROR on any other error.
7965 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_set_nvparms()
7967 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_set_nvparms()
7972 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_set_nvparms_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_set_nvparms()
7974 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_set_nvparms()
7975 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_nvparms()
7979 cb_arg->cb = cb; in ocs_hw_set_nvparms()
7980 cb_arg->arg = ul_arg; in ocs_hw_set_nvparms()
7982 …if (sli_cmd_write_nvparms(&hw->sli, mbxdata, SLI4_BMBX_SIZE, wwpn, wwnn, hard_alpa, preferred_d_id… in ocs_hw_set_nvparms()
7987 ocs_log_test(hw->os, "SET_NVPARMS failed\n"); in ocs_hw_set_nvparms()
7988 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_nvparms()
7989 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_set_nvparms_cb_arg_t)); in ocs_hw_set_nvparms()
8009 ocs_lock(&hw->io_lock); in ocs_hw_io_get_count()
8013 ocs_list_foreach(&hw->io_inuse, io) { in ocs_hw_io_get_count()
8018 ocs_list_foreach(&hw->io_free, io) { in ocs_hw_io_get_count()
8023 ocs_list_foreach(&hw->io_wait_free, io) { in ocs_hw_io_get_count()
8028 ocs_list_foreach(&hw->io_port_owned, io) { in ocs_hw_io_get_count()
8033 count = hw->config.n_io; in ocs_hw_io_get_count()
8037 ocs_unlock(&hw->io_lock); in ocs_hw_io_get_count()
8056 for (i = 0; i < hw->hw_rq_count; i++) { in ocs_hw_get_rqes_produced_count()
8057 hw_rq_t *rq = hw->hw_rq[i]; in ocs_hw_get_rqes_produced_count()
8058 if (rq->rq_tracker != NULL) { in ocs_hw_get_rqes_produced_count()
8059 for (j = 0; j < rq->entry_count; j++) { in ocs_hw_get_rqes_produced_count()
8060 if (rq->rq_tracker[j] != NULL) { in ocs_hw_get_rqes_produced_count()
8084 * @return Returns 0 on success, or a non-zero value on failure.
8091 if (cb_arg->cb) { in ocs_hw_set_active_profile_cb()
8092 cb_arg->cb(status, cb_arg->arg); in ocs_hw_set_active_profile_cb()
8095 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_set_active_profile_cb()
8096 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_get_active_profile_cb_arg_t)); in ocs_hw_set_active_profile_cb()
8115 * - OCS_HW_RTN_SUCCESS on success.
8116 * - OCS_HW_RTN_NO_MEMORY if a malloc fails.
8117 * - OCS_HW_RTN_NO_RESOURCES if unable to get a command
8119 * - OCS_HW_RTN_ERROR on any other error.
8129 if (sli_get_if_type(&hw->sli) != SLI4_IF_TYPE_BE3_SKH_PF) { in ocs_hw_set_active_profile()
8134 mbxdata = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_set_active_profile()
8136 ocs_log_err(hw->os, "failed to malloc mbox\n"); in ocs_hw_set_active_profile()
8141 cb_arg = ocs_malloc(hw->os, sizeof(ocs_hw_set_active_profile_cb_arg_t), OCS_M_NOWAIT); in ocs_hw_set_active_profile()
8143 ocs_log_err(hw->os, "failed to malloc cb_arg\n"); in ocs_hw_set_active_profile()
8144 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_active_profile()
8148 cb_arg->cb = cb; in ocs_hw_set_active_profile()
8149 cb_arg->arg = ul_arg; in ocs_hw_set_active_profile()
8151 if (sli_cmd_common_set_active_profile(&hw->sli, mbxdata, SLI4_BMBX_SIZE, 0, profile_id)) { in ocs_hw_set_active_profile()
8156 ocs_log_test(hw->os, "SET_ACTIVE_PROFILE failed\n"); in ocs_hw_set_active_profile()
8157 ocs_free(hw->os, mbxdata, SLI4_BMBX_SIZE); in ocs_hw_set_active_profile()
8158 ocs_free(hw->os, cb_arg, sizeof(ocs_hw_set_active_profile_cb_arg_t)); in ocs_hw_set_active_profile()
8178 uint32_t hash_index = id & (OCS_HW_Q_HASH_SIZE - 1); in ocs_hw_queue_hash_add()
8185 hash_index = (hash_index + 1) & (OCS_HW_Q_HASH_SIZE - 1); in ocs_hw_queue_hash_add()
8200 * @return Returns the index into the HW cq array or -1 if not found.
8205 int32_t rc = -1; in ocs_hw_queue_hash_find()
8206 int32_t index = id & (OCS_HW_Q_HASH_SIZE - 1); in ocs_hw_queue_hash_find()
8218 index = (index + 1) & (OCS_HW_Q_HASH_SIZE - 1); in ocs_hw_queue_hash_find()
8220 } while(rc == -1 && hash[index].in_use); in ocs_hw_queue_hash_find()
8237 fcfi = domain->fcf_indicator; in ocs_hw_domain_add()
8242 ocs_log_debug(hw->os, "adding domain %p @ %#x\n", in ocs_hw_domain_add()
8244 hw->domains[fcfi] = domain; in ocs_hw_domain_add()
8247 if (hw->workaround.override_fcfi) { in ocs_hw_domain_add()
8248 if (hw->first_domain_idx < 0) { in ocs_hw_domain_add()
8249 hw->first_domain_idx = fcfi; in ocs_hw_domain_add()
8253 fcf_index = domain->fcf; in ocs_hw_domain_add()
8256 ocs_log_debug(hw->os, "adding map of FCF index %d to FCFI %d\n", in ocs_hw_domain_add()
8258 hw->fcf_index_fcfi[fcf_index] = fcfi; in ocs_hw_domain_add()
8261 ocs_log_test(hw->os, "FCF index %d out of range (max %d)\n", in ocs_hw_domain_add()
8263 hw->domains[fcfi] = NULL; in ocs_hw_domain_add()
8266 ocs_log_test(hw->os, "FCFI %#x out of range (max %#x)\n", in ocs_hw_domain_add()
8285 fcfi = domain->fcf_indicator; in ocs_hw_domain_del()
8290 ocs_log_debug(hw->os, "deleting domain %p @ %#x\n", in ocs_hw_domain_del()
8293 if (domain != hw->domains[fcfi]) { in ocs_hw_domain_del()
8294 ocs_log_test(hw->os, "provided domain %p does not match stored domain %p\n", in ocs_hw_domain_del()
8295 domain, hw->domains[fcfi]); in ocs_hw_domain_del()
8299 hw->domains[fcfi] = NULL; in ocs_hw_domain_del()
8302 if (hw->workaround.override_fcfi) { in ocs_hw_domain_del()
8303 if (hw->first_domain_idx == fcfi) { in ocs_hw_domain_del()
8304 hw->first_domain_idx = -1; in ocs_hw_domain_del()
8308 fcf_index = domain->fcf; in ocs_hw_domain_del()
8311 if (hw->fcf_index_fcfi[fcf_index] == fcfi) { in ocs_hw_domain_del()
8312 hw->fcf_index_fcfi[fcf_index] = 0; in ocs_hw_domain_del()
8315 ocs_log_test(hw->os, "indexed FCFI %#x doesn't match provided %#x @ %d\n", in ocs_hw_domain_del()
8316 hw->fcf_index_fcfi[fcf_index], fcfi, fcf_index); in ocs_hw_domain_del()
8319 ocs_log_test(hw->os, "FCF index %d out of range (max %d)\n", in ocs_hw_domain_del()
8323 ocs_log_test(hw->os, "FCFI %#x out of range (max %#x)\n", in ocs_hw_domain_del()
8340 return hw->domains[fcfi]; in ocs_hw_domain_get()
8342 ocs_log_test(hw->os, "FCFI %#x out of range (max %#x)\n", in ocs_hw_domain_get()
8358 return ocs_hw_domain_get(hw, hw->fcf_index_fcfi[fcf_index]); in ocs_hw_domain_get_indexed()
8360 ocs_log_test(hw->os, "FCF index %d out of range (max %d)\n", in ocs_hw_domain_get_indexed()
8372 * @n @b Note: BZ 160124 - If this is a target write or an initiator read using
8383 ocs_quarantine_info_t *q_info = &wq->quarantine_info; in ocs_hw_io_quarantine()
8388 if (!io->quarantine) { in ocs_hw_io_quarantine()
8393 if (ocs_ref_get_unless_zero(&io->ref) == 0) { in ocs_hw_io_quarantine()
8395 ocs_log_debug(hw ? hw->os : NULL, in ocs_hw_io_quarantine()
8397 io->indicator, io->reqtag); in ocs_hw_io_quarantine()
8401 sli_queue_lock(wq->queue); in ocs_hw_io_quarantine()
8402 index = q_info->quarantine_index; in ocs_hw_io_quarantine()
8403 free_io = q_info->quarantine_ios[index]; in ocs_hw_io_quarantine()
8404 q_info->quarantine_ios[index] = io; in ocs_hw_io_quarantine()
8405 q_info->quarantine_index = (index + 1) % OCS_HW_QUARANTINE_QUEUE_DEPTH; in ocs_hw_io_quarantine()
8406 sli_queue_unlock(wq->queue); in ocs_hw_io_quarantine()
8409 ocs_ref_put(&free_io->ref); /* ocs_ref_get(): same function */ in ocs_hw_io_quarantine()
8434 while (!sli_queue_read(&hw->sli, cq->queue, cqe)) { in ocs_hw_cq_process()
8435 status = sli_cq_parse(&hw->sli, cq->queue, cqe, &ctype, &rid); in ocs_hw_cq_process()
8443 if (status == -2) { in ocs_hw_cq_process()
8454 sli_cqe_async(&hw->sli, cqe); in ocs_hw_cq_process()
8462 ocs_hw_mq_process(hw, status, hw->mq); in ocs_hw_cq_process()
8476 int32_t index = ocs_hw_queue_hash_find(hw->wq_hash, wq_id); in ocs_hw_cq_process()
8479 ocs_log_err(hw->os, "unknown idx=%#x rid=%#x\n", in ocs_hw_cq_process()
8484 hw_wq_t *wq = hw->hw_wq[index]; in ocs_hw_cq_process()
8487 hw_wq_submit_pending(wq, wq->wqec_set_count); in ocs_hw_cq_process()
8502 ocs_log_test(hw->os, "unhandled ctype=%#x rid=%#x\n", ctype, rid); in ocs_hw_cq_process()
8507 if (n_processed == cq->queue->proc_limit) { in ocs_hw_cq_process()
8511 if (cq->queue->n_posted >= (cq->queue->posted_limit)) { in ocs_hw_cq_process()
8512 sli_queue_arm(&hw->sli, cq->queue, FALSE); in ocs_hw_cq_process()
8516 sli_queue_arm(&hw->sli, cq->queue, TRUE); in ocs_hw_cq_process()
8518 if (n_processed > cq->queue->max_num_processed) { in ocs_hw_cq_process()
8519 cq->queue->max_num_processed = n_processed; in ocs_hw_cq_process()
8521 telapsed = ocs_msectime() - tstart; in ocs_hw_cq_process()
8522 if (telapsed > cq->queue->max_process_time) { in ocs_hw_cq_process()
8523 cq->queue->max_process_time = telapsed; in ocs_hw_cq_process()
8543 …ocs_queue_history_cqe(&hw->q_hist, SLI_QENTRY_WQ, (void *)cqe, ((sli4_fc_wcqe_t *)cqe)->status, cq in ocs_hw_wq_process()
8544 ((cq->queue->index - 1) & (cq->queue->length - 1))); in ocs_hw_wq_process()
8548 ocs_log_err(hw->os, "reque xri failed, status = %d \n", status); in ocs_hw_wq_process()
8555 ocs_log_err(hw->os, "invalid request tag: x%x\n", rid); in ocs_hw_wq_process()
8559 if (wqcb->callback == NULL) { in ocs_hw_wq_process()
8560 ocs_log_err(hw->os, "wqcb callback is NULL\n"); in ocs_hw_wq_process()
8564 (*wqcb->callback)(wqcb->arg, cqe, status); in ocs_hw_wq_process()
8575 * @n @b Note: Regarding io->reqtag, the reqtag is assigned once when HW IOs are initialized
8576 * in ocs_hw_setup_io(), and don't need to be returned to the hw->wq_reqtag_pool.
8584 ocs_hw_t *hw = io->hw; in ocs_hw_wq_process_io()
8602 if (io->quarantine && io->quarantine_first_phase) { in ocs_hw_wq_process_io()
8603 io->quarantine = (wcqe->qx == 1); in ocs_hw_wq_process_io()
8604 ocs_hw_io_quarantine(hw, io->wq, io); in ocs_hw_wq_process_io()
8606 io->quarantine_first_phase = FALSE; in ocs_hw_wq_process_io()
8608 /* BZ 161832 - free secondary HW IO */ in ocs_hw_wq_process_io()
8609 if (io->sec_hio != NULL && in ocs_hw_wq_process_io()
8610 io->sec_hio->quarantine) { in ocs_hw_wq_process_io()
8617 io->sec_hio->quarantine = (wcqe->qx == 1); in ocs_hw_wq_process_io()
8618 /* use the primary io->wq because it is not set on the secondary IO. */ in ocs_hw_wq_process_io()
8619 ocs_hw_io_quarantine(hw, io->wq, io->sec_hio); in ocs_hw_wq_process_io()
8625 if (io->xbusy && wcqe->xb == 0) { in ocs_hw_wq_process_io()
8626 io->xbusy = FALSE; in ocs_hw_wq_process_io()
8630 switch (io->type) { in ocs_hw_wq_process_io()
8635 sli_fc_els_did(&hw->sli, cqe, &ext); in ocs_hw_wq_process_io()
8636 len = sli_fc_response_length(&hw->sli, cqe); in ocs_hw_wq_process_io()
8643 len = sli_fc_response_length(&hw->sli, cqe); in ocs_hw_wq_process_io()
8646 len = sli_fc_io_length(&hw->sli, cqe); in ocs_hw_wq_process_io()
8655 len = sli_fc_io_length(&hw->sli, cqe); in ocs_hw_wq_process_io()
8661 if (hw->workaround.retain_tsend_io_length && !len && !status) { in ocs_hw_wq_process_io()
8662 len = io->length; in ocs_hw_wq_process_io()
8667 if(io->is_port_owned) { in ocs_hw_wq_process_io()
8668 ocs_lock(&io->axr_lock); in ocs_hw_wq_process_io()
8670 if(io->axr_buf->call_axr_cmd) { in ocs_hw_wq_process_io()
8673 if(io->axr_buf->call_axr_data) { in ocs_hw_wq_process_io()
8679 len = sli_fc_io_length(&hw->sli, cqe); in ocs_hw_wq_process_io()
8682 len = sli_fc_io_length(&hw->sli, cqe); in ocs_hw_wq_process_io()
8687 /* release the count for re-posting the buffer */ in ocs_hw_wq_process_io()
8691 ocs_log_test(hw->os, "XXX unhandled io type %#x for XRI 0x%x\n", in ocs_hw_wq_process_io()
8692 io->type, io->indicator); in ocs_hw_wq_process_io()
8696 ext = sli_fc_ext_status(&hw->sli, cqe); in ocs_hw_wq_process_io()
8700 if (hw->config.i_only_aab && in ocs_hw_wq_process_io()
8701 (ocs_hw_iotype_is_originator(io->type)) && in ocs_hw_wq_process_io()
8702 (ocs_hw_wcqe_abort_needed(status, ext, wcqe->xb))) { in ocs_hw_wq_process_io()
8705 ocs_log_debug(hw->os, "aborting xri=%#x tag=%#x\n", in ocs_hw_wq_process_io()
8706 io->indicator, io->reqtag); in ocs_hw_wq_process_io()
8716 io->status_saved = 1; in ocs_hw_wq_process_io()
8717 io->saved_status = status; in ocs_hw_wq_process_io()
8718 io->saved_ext = ext; in ocs_hw_wq_process_io()
8719 io->saved_len = len; in ocs_hw_wq_process_io()
8727 ocs_log_debug(hw->os, "abort in progress xri=%#x tag=%#x\n", in ocs_hw_wq_process_io()
8728 io->indicator, io->reqtag); in ocs_hw_wq_process_io()
8732 ocs_log_test(hw->os, "Failed to abort xri=%#x tag=%#x rc=%d\n", in ocs_hw_wq_process_io()
8733 io->indicator, io->reqtag, rc); in ocs_hw_wq_process_io()
8740 if ( (! ocs_hw_iotype_is_originator(io->type)) && wcqe->xb) { in ocs_hw_wq_process_io()
8743 ocs_log_debug(hw->os, "aborting xri=%#x tag=%#x\n", io->indicator, io->reqtag); in ocs_hw_wq_process_io()
8752 io->status_saved = 1; in ocs_hw_wq_process_io()
8753 io->saved_status = status; in ocs_hw_wq_process_io()
8754 io->saved_ext = ext; in ocs_hw_wq_process_io()
8755 io->saved_len = len; in ocs_hw_wq_process_io()
8763 ocs_log_debug(hw->os, "abort in progress xri=%#x tag=%#x\n", in ocs_hw_wq_process_io()
8764 io->indicator, io->reqtag); in ocs_hw_wq_process_io()
8768 ocs_log_test(hw->os, "Failed to abort xri=%#x tag=%#x rc=%d\n", in ocs_hw_wq_process_io()
8769 io->indicator, io->reqtag, rc); in ocs_hw_wq_process_io()
8773 /* BZ 161832 - free secondary HW IO */ in ocs_hw_wq_process_io()
8774 if (io->sec_hio != NULL) { in ocs_hw_wq_process_io()
8775 ocs_hw_io_free(hw, io->sec_hio); in ocs_hw_wq_process_io()
8776 io->sec_hio = NULL; in ocs_hw_wq_process_io()
8779 if (io->done != NULL) { in ocs_hw_wq_process_io()
8780 ocs_hw_done_t done = io->done; in ocs_hw_wq_process_io()
8781 void *arg = io->arg; in ocs_hw_wq_process_io()
8783 io->done = NULL; in ocs_hw_wq_process_io()
8785 if (io->status_saved) { in ocs_hw_wq_process_io()
8787 status = io->saved_status; in ocs_hw_wq_process_io()
8788 len = io->saved_len; in ocs_hw_wq_process_io()
8789 ext = io->saved_ext; in ocs_hw_wq_process_io()
8790 io->status_saved = 0; in ocs_hw_wq_process_io()
8795 done(io, io->rnode, len, status, ext, arg); in ocs_hw_wq_process_io()
8800 if (hw->config.bounce) { in ocs_hw_wq_process_io()
8801 fc_header_t *hdr = io->axr_buf->cmd_seq->header->dma.virt; in ocs_hw_wq_process_io()
8802 uint32_t s_id = fc_be24toh(hdr->s_id); in ocs_hw_wq_process_io()
8803 uint32_t d_id = fc_be24toh(hdr->d_id); in ocs_hw_wq_process_io()
8804 uint32_t ox_id = ocs_be16toh(hdr->ox_id); in ocs_hw_wq_process_io()
8805 if (hw->callback.bounce != NULL) { in ocs_hw_wq_process_io()
8806 (*hw->callback.bounce)(ocs_hw_unsol_process_bounce, io->axr_buf->cmd_seq, s_id, d_id, ox_id); in ocs_hw_wq_process_io()
8809 hw->callback.unsolicited(hw->args.unsolicited, io->axr_buf->cmd_seq); in ocs_hw_wq_process_io()
8814 if (hw->config.bounce) { in ocs_hw_wq_process_io()
8815 fc_header_t *hdr = io->axr_buf->seq.header->dma.virt; in ocs_hw_wq_process_io()
8816 uint32_t s_id = fc_be24toh(hdr->s_id); in ocs_hw_wq_process_io()
8817 uint32_t d_id = fc_be24toh(hdr->d_id); in ocs_hw_wq_process_io()
8818 uint32_t ox_id = ocs_be16toh(hdr->ox_id); in ocs_hw_wq_process_io()
8819 if (hw->callback.bounce != NULL) { in ocs_hw_wq_process_io()
8820 (*hw->callback.bounce)(ocs_hw_unsol_process_bounce, &io->axr_buf->seq, s_id, d_id, ox_id); in ocs_hw_wq_process_io()
8823 hw->callback.unsolicited(hw->args.unsolicited, &io->axr_buf->seq); in ocs_hw_wq_process_io()
8830 ocs_unlock(&io->axr_lock); in ocs_hw_wq_process_io()
8847 ocs_hw_t *hw = io->hw; in ocs_hw_wq_process_abort()
8857 ext = sli_fc_ext_status(&hw->sli, cqe); in ocs_hw_wq_process_abort()
8860 io->done != NULL) { in ocs_hw_wq_process_abort()
8861 ocs_hw_done_t done = io->done; in ocs_hw_wq_process_abort()
8862 void *arg = io->arg; in ocs_hw_wq_process_abort()
8864 io->done = NULL; in ocs_hw_wq_process_abort()
8872 status = io->saved_status; in ocs_hw_wq_process_abort()
8873 len = io->saved_len; in ocs_hw_wq_process_abort()
8874 ext = io->saved_ext; in ocs_hw_wq_process_abort()
8875 io->status_saved = 0; in ocs_hw_wq_process_abort()
8876 done(io, io->rnode, len, status, ext, arg); in ocs_hw_wq_process_abort()
8879 if (io->abort_done != NULL) { in ocs_hw_wq_process_abort()
8880 ocs_hw_done_t done = io->abort_done; in ocs_hw_wq_process_abort()
8881 void *arg = io->abort_arg; in ocs_hw_wq_process_abort()
8883 io->abort_done = NULL; in ocs_hw_wq_process_abort()
8885 done(io, io->rnode, len, status, ext, arg); in ocs_hw_wq_process_abort()
8887 ocs_lock(&hw->io_abort_lock); in ocs_hw_wq_process_abort()
8889 io->abort_in_progress = 0; in ocs_hw_wq_process_abort()
8890 ocs_unlock(&hw->io_abort_lock); in ocs_hw_wq_process_abort()
8893 ocs_hw_assert(io->abort_reqtag != UINT32_MAX); in ocs_hw_wq_process_abort()
8894 wqcb = ocs_hw_reqtag_get_instance(hw, io->abort_reqtag); in ocs_hw_wq_process_abort()
8923 ocs_queue_history_cqe(&hw->q_hist, SLI_QENTRY_XABT, (void *)cqe, 0, cq->queue->id, in ocs_hw_xabt_process()
8924 ((cq->queue->index - 1) & (cq->queue->length - 1))); in ocs_hw_xabt_process()
8927 ocs_log_err(hw->os, "Error: xabt io lookup failed rid=%#x\n", rid); in ocs_hw_xabt_process()
8931 if (!io->xbusy) { in ocs_hw_xabt_process()
8932 ocs_log_debug(hw->os, "xabt io not busy rid=%#x\n", rid); in ocs_hw_xabt_process()
8935 io->xbusy = FALSE; in ocs_hw_xabt_process()
8938 if (io->is_port_owned) { in ocs_hw_xabt_process()
8939 ocs_lock(&hw->io_lock); in ocs_hw_xabt_process()
8941 ocs_ref_get(&io->ref); in ocs_hw_xabt_process()
8942 ocs_unlock(&hw->io_lock); in ocs_hw_xabt_process()
8946 if (io->done != NULL) { in ocs_hw_xabt_process()
8947 ocs_hw_done_t done = io->done; in ocs_hw_xabt_process()
8948 void *arg = io->arg; in ocs_hw_xabt_process()
8951 int32_t status = io->saved_status; in ocs_hw_xabt_process()
8952 uint32_t len = io->saved_len; in ocs_hw_xabt_process()
8953 uint32_t ext = io->saved_ext; in ocs_hw_xabt_process()
8955 io->done = NULL; in ocs_hw_xabt_process()
8956 io->status_saved = 0; in ocs_hw_xabt_process()
8958 done(io, io->rnode, len, status, ext, arg); in ocs_hw_xabt_process()
8962 if (io->is_port_owned) { in ocs_hw_xabt_process()
8963 ocs_lock(&hw->io_lock); in ocs_hw_xabt_process()
8965 ocs_unlock(&hw->io_lock); in ocs_hw_xabt_process()
8971 ocs_lock(&hw->io_lock); in ocs_hw_xabt_process()
8972 if ((io->state == OCS_HW_IO_STATE_INUSE) || (io->state == OCS_HW_IO_STATE_WAIT_FREE)) { in ocs_hw_xabt_process()
8975 * if on in-use list, already marked as no longer busy; in ocs_hw_xabt_process()
8978 if (io->state == OCS_HW_IO_STATE_WAIT_FREE) { in ocs_hw_xabt_process()
8979 io->state = OCS_HW_IO_STATE_FREE; in ocs_hw_xabt_process()
8980 ocs_list_remove(&hw->io_wait_free, io); in ocs_hw_xabt_process()
8984 ocs_unlock(&hw->io_lock); in ocs_hw_xabt_process()
9000 uint32_t max_wq_num = sli_get_max_queue(&hw->sli, SLI_QTYPE_WQ); in ocs_hw_adjust_wqs()
9001 uint32_t max_wq_entries = hw->num_qentries[SLI_QTYPE_WQ]; in ocs_hw_adjust_wqs()
9002 uint32_t max_cq_entries = hw->num_qentries[SLI_QTYPE_CQ]; in ocs_hw_adjust_wqs()
9007 * handle multi-phase as well as aborts. in ocs_hw_adjust_wqs()
9010 max_wq_entries = hw->num_qentries[SLI_QTYPE_WQ] = max_cq_entries / 2; in ocs_hw_adjust_wqs()
9021 hw->config.n_wq = ((hw->config.n_io * 2) + (max_wq_entries - 1)) / max_wq_entries; in ocs_hw_adjust_wqs()
9027 if (hw->config.n_wq < 4 && in ocs_hw_adjust_wqs()
9028 SLI4_IF_TYPE_BE3_SKH_PF == sli_get_if_type(&hw->sli)) { in ocs_hw_adjust_wqs()
9029 hw->config.n_wq = 4; in ocs_hw_adjust_wqs()
9033 * For dual-chute support, we need to have at least one WQ per chute. in ocs_hw_adjust_wqs()
9035 if (hw->config.n_wq < 2 && in ocs_hw_adjust_wqs()
9037 hw->config.n_wq = 2; in ocs_hw_adjust_wqs()
9041 if (hw->config.n_wq > OCS_HW_MAX_NUM_WQ) { in ocs_hw_adjust_wqs()
9042 hw->config.n_wq = OCS_HW_MAX_NUM_WQ; in ocs_hw_adjust_wqs()
9046 if (hw->config.n_wq > max_wq_num) { in ocs_hw_adjust_wqs()
9047 hw->config.n_wq = max_wq_num; in ocs_hw_adjust_wqs()
9053 hw->config.n_wq /= ocs_hw_get_num_chutes(hw); in ocs_hw_adjust_wqs()
9061 ocs_lock(&hw->cmd_lock); in ocs_hw_command_process()
9062 if (NULL == (ctx = ocs_list_remove_head(&hw->cmd_head))) { in ocs_hw_command_process()
9063 ocs_log_err(hw->os, "XXX no command context?!?\n"); in ocs_hw_command_process()
9064 ocs_unlock(&hw->cmd_lock); in ocs_hw_command_process()
9065 return -1; in ocs_hw_command_process()
9068 hw->cmd_head_count--; in ocs_hw_command_process()
9073 ocs_unlock(&hw->cmd_lock); in ocs_hw_command_process()
9075 if (ctx->cb) { in ocs_hw_command_process()
9076 if (ctx->buf) { in ocs_hw_command_process()
9077 ocs_memcpy(ctx->buf, mqe, size); in ocs_hw_command_process()
9079 ctx->cb(hw, status, ctx->buf, ctx->arg); in ocs_hw_command_process()
9083 ocs_free(hw->os, ctx, sizeof(ocs_command_ctx_t)); in ocs_hw_command_process()
9095 * @return Returns 0 on success, or a non-zero value on failure.
9102 if (!sli_queue_read(&hw->sli, mq, mqe)) { in ocs_hw_mq_process()
9103 ocs_hw_command_process(hw, status, mqe, mq->size); in ocs_hw_mq_process()
9117 * @return Returns 0 on success, or a non-zero value on failure.
9125 buf = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_read_fcf()
9127 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_read_fcf()
9131 if (sli_cmd_fcoe_read_fcf_table(&hw->sli, buf, SLI4_BMBX_SIZE, &hw->fcf_dmem, in ocs_hw_read_fcf()
9133 rc = ocs_hw_command(hw, buf, OCS_CMD_NOWAIT, ocs_hw_cb_read_fcf, &hw->fcf_dmem); in ocs_hw_read_fcf()
9137 ocs_log_test(hw->os, "FCOE_READ_FCF_TABLE failed\n"); in ocs_hw_read_fcf()
9138 ocs_free(hw->os, buf, SLI4_BMBX_SIZE); in ocs_hw_read_fcf()
9149 * - DMA memory to hold the table contents
9150 * - DMA memory structure
9151 * - Command/results buffer
9160 * @return Returns 0 on success, or a non-zero value on failure.
9168 if (status || hdr->status) { in ocs_hw_cb_read_fcf()
9169 ocs_log_test(hw->os, "bad status cqe=%#x mqe=%#x\n", in ocs_hw_cb_read_fcf()
9170 status, hdr->status); in ocs_hw_cb_read_fcf()
9171 } else if (dma->virt) { in ocs_hw_cb_read_fcf()
9172 sli4_res_fcoe_read_fcf_table_t *read_fcf = dma->virt; in ocs_hw_cb_read_fcf()
9175 if (read_fcf->fcf_entry.fc || in ocs_hw_cb_read_fcf()
9176 (read_fcf->fcf_entry.val && !read_fcf->fcf_entry.sol)) { in ocs_hw_cb_read_fcf()
9177 if (hw->callback.domain != NULL) { in ocs_hw_cb_read_fcf()
9180 if (read_fcf->fcf_entry.fc) { in ocs_hw_cb_read_fcf()
9185 drec.speed = hw->link.speed; in ocs_hw_cb_read_fcf()
9186 drec.fc_id = hw->link.fc_id; in ocs_hw_cb_read_fcf()
9188 if (SLI_LINK_TOPO_LOOP == hw->link.topology) { in ocs_hw_cb_read_fcf()
9190 ocs_memcpy(drec.map.loop, hw->link.loop_map, in ocs_hw_cb_read_fcf()
9192 } else if (SLI_LINK_TOPO_NPORT == hw->link.topology) { in ocs_hw_cb_read_fcf()
9196 drec.index = read_fcf->fcf_entry.fcf_index; in ocs_hw_cb_read_fcf()
9197 drec.priority = read_fcf->fcf_entry.fip_priority; in ocs_hw_cb_read_fcf()
9200 ocs_memcpy(drec.address, read_fcf->fcf_entry.fcf_mac_address, in ocs_hw_cb_read_fcf()
9202 ocs_memcpy(drec.wwn, read_fcf->fcf_entry.fabric_name_id, in ocs_hw_cb_read_fcf()
9204 ocs_memcpy(drec.map.vlan, read_fcf->fcf_entry.vlan_bitmap, in ocs_hw_cb_read_fcf()
9211 hw->callback.domain(hw->args.domain, in ocs_hw_cb_read_fcf()
9217 ocs_log_test(hw->os, "ignore invalid FCF entry\n"); in ocs_hw_cb_read_fcf()
9220 if (SLI4_FCOE_FCF_TABLE_LAST != read_fcf->next_index) { in ocs_hw_cb_read_fcf()
9221 ocs_hw_read_fcf(hw, read_fcf->next_index); in ocs_hw_cb_read_fcf()
9225 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_read_fcf()
9226 //ocs_dma_free(hw->os, dma); in ocs_hw_cb_read_fcf()
9227 //ocs_free(hw->os, dma, sizeof(ocs_dma_t)); in ocs_hw_cb_read_fcf()
9241 * @return Returns 0 on success, or a non-zero value on failure.
9251 ocs_t *ocs = hw->os; in ocs_hw_cb_link()
9255 switch (event->status) { in ocs_hw_cb_link()
9258 hw->link = *event; in ocs_hw_cb_link()
9260 if (SLI_LINK_TOPO_NPORT == event->topology) { in ocs_hw_cb_link()
9261 device_printf(ocs->dev, "Link Up, NPORT, speed is %d\n", event->speed); in ocs_hw_cb_link()
9263 } else if (SLI_LINK_TOPO_LOOP == event->topology) { in ocs_hw_cb_link()
9265 device_printf(ocs->dev, "Link Up, LOOP, speed is %d\n", event->speed); in ocs_hw_cb_link()
9267 buf = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_cb_link()
9269 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_cb_link()
9273 if (sli_cmd_read_topology(&hw->sli, buf, SLI4_BMBX_SIZE, &hw->loop_map)) { in ocs_hw_cb_link()
9278 ocs_log_test(hw->os, "READ_TOPOLOGY failed\n"); in ocs_hw_cb_link()
9279 ocs_free(hw->os, buf, SLI4_BMBX_SIZE); in ocs_hw_cb_link()
9282 device_printf(ocs->dev, "Link Up, unsupported topology (%#x), speed is %d\n", in ocs_hw_cb_link()
9283 event->topology, event->speed); in ocs_hw_cb_link()
9287 device_printf(ocs->dev, "Link Down\n"); in ocs_hw_cb_link()
9289 hw->link.status = event->status; in ocs_hw_cb_link()
9292 d = hw->domains[i]; in ocs_hw_cb_link()
9294 hw->callback.domain != NULL) { in ocs_hw_cb_link()
9295 hw->callback.domain(hw->args.domain, OCS_HW_DOMAIN_LOST, d); in ocs_hw_cb_link()
9300 ocs_log_test(hw->os, "unhandled link status %#x\n", event->status); in ocs_hw_cb_link()
9318 if (event->type == SLI4_FCOE_FIP_FCF_CLEAR_VLINK) { in ocs_hw_cb_fip()
9326 d = hw->domains[i]; in ocs_hw_cb_fip()
9330 ocs_list_foreach(&d->sport_list, sport) { in ocs_hw_cb_fip()
9331 if (sport->indicator == event->index) { in ocs_hw_cb_fip()
9343 domain = ocs_hw_domain_get_indexed(hw, event->index); in ocs_hw_cb_fip()
9346 switch (event->type) { in ocs_hw_cb_fip()
9348 ocs_hw_read_fcf(hw, event->index); in ocs_hw_cb_fip()
9352 hw->callback.domain != NULL) { in ocs_hw_cb_fip()
9353 hw->callback.domain(hw->args.domain, OCS_HW_DOMAIN_LOST, domain); in ocs_hw_cb_fip()
9358 hw->callback.domain != NULL) { in ocs_hw_cb_fip()
9363 domain->req_rediscover_fcf = TRUE; in ocs_hw_cb_fip()
9364 hw->callback.domain(hw->args.domain, OCS_HW_DOMAIN_LOST, domain); in ocs_hw_cb_fip()
9369 hw->callback.domain != NULL) { in ocs_hw_cb_fip()
9370 hw->callback.domain(hw->args.domain, OCS_HW_DOMAIN_LOST, domain); in ocs_hw_cb_fip()
9373 ocs_hw_read_fcf(hw, event->index); in ocs_hw_cb_fip()
9376 ocs_log_test(hw->os, "unsupported event %#x\n", event->type); in ocs_hw_cb_fip()
9389 if (status || hdr->status) { in ocs_hw_cb_node_attach()
9390 ocs_log_debug(hw->os, "bad status cqe=%#x mqe=%#x\n", status, in ocs_hw_cb_node_attach()
9391 hdr->status); in ocs_hw_cb_node_attach()
9392 ocs_atomic_sub_return(&hw->rpi_ref[rnode->index].rpi_count, 1); in ocs_hw_cb_node_attach()
9393 rnode->attached = FALSE; in ocs_hw_cb_node_attach()
9394 ocs_atomic_set(&hw->rpi_ref[rnode->index].rpi_attached, 0); in ocs_hw_cb_node_attach()
9397 rnode->attached = TRUE; in ocs_hw_cb_node_attach()
9398 ocs_atomic_set(&hw->rpi_ref[rnode->index].rpi_attached, 1); in ocs_hw_cb_node_attach()
9402 if (hw->callback.rnode != NULL) { in ocs_hw_cb_node_attach()
9403 hw->callback.rnode(hw->args.rnode, evt, rnode); in ocs_hw_cb_node_attach()
9405 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_node_attach()
9418 if (status || hdr->status) { in ocs_hw_cb_node_free()
9419 ocs_log_debug(hw->os, "bad status cqe=%#x mqe=%#x\n", status, in ocs_hw_cb_node_free()
9420 hdr->status); in ocs_hw_cb_node_free()
9423 * In certain cases, a non-zero MQE status is OK (all must be true): in ocs_hw_cb_node_free()
9424 * - node is attached in ocs_hw_cb_node_free()
9425 * - if High Login Mode is enabled, node is part of a node group in ocs_hw_cb_node_free()
9426 * - status is 0x1400 in ocs_hw_cb_node_free()
9428 if (!rnode->attached || ((sli_get_hlm(&hw->sli) == TRUE) && !rnode->node_group) || in ocs_hw_cb_node_free()
9429 (hdr->status != SLI4_MBOX_STATUS_RPI_NOT_REG)) { in ocs_hw_cb_node_free()
9430 rc = -1; in ocs_hw_cb_node_free()
9435 rnode->node_group = FALSE; in ocs_hw_cb_node_free()
9436 rnode->attached = FALSE; in ocs_hw_cb_node_free()
9438 if (ocs_atomic_read(&hw->rpi_ref[rnode->index].rpi_count) == 0) { in ocs_hw_cb_node_free()
9439 ocs_atomic_set(&hw->rpi_ref[rnode->index].rpi_attached, 0); in ocs_hw_cb_node_free()
9445 if (hw->callback.rnode != NULL) { in ocs_hw_cb_node_free()
9446 hw->callback.rnode(hw->args.rnode, evt, rnode); in ocs_hw_cb_node_free()
9449 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_node_free()
9462 if (status || hdr->status) { in ocs_hw_cb_node_free_all()
9463 ocs_log_debug(hw->os, "bad status cqe=%#x mqe=%#x\n", status, in ocs_hw_cb_node_free_all()
9464 hdr->status); in ocs_hw_cb_node_free_all()
9470 for (i = 0; i < sli_get_max_rsrc(&hw->sli, SLI_RSRC_FCOE_RPI); i++) { in ocs_hw_cb_node_free_all()
9471 ocs_atomic_set(&hw->rpi_ref[i].rpi_count, 0); in ocs_hw_cb_node_free_all()
9474 if (sli_resource_reset(&hw->sli, SLI_RSRC_FCOE_RPI)) { in ocs_hw_cb_node_free_all()
9475 ocs_log_test(hw->os, "FCOE_RPI free all failure\n"); in ocs_hw_cb_node_free_all()
9476 rc = -1; in ocs_hw_cb_node_free_all()
9480 if (hw->callback.rnode != NULL) { in ocs_hw_cb_node_free_all()
9481 hw->callback.rnode(hw->args.rnode, evt, NULL); in ocs_hw_cb_node_free_all()
9484 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_node_free_all()
9494 * @return Returns 0 on success, or a non-zero value on failure.
9506 if (NULL == hw->io) { in ocs_hw_setup_io()
9507 hw->io = ocs_malloc(hw->os, hw->config.n_io * sizeof(ocs_hw_io_t *), OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_setup_io()
9509 if (NULL == hw->io) { in ocs_hw_setup_io()
9510 ocs_log_err(hw->os, "IO pointer memory allocation failed, %d Ios at size %zu\n", in ocs_hw_setup_io()
9511 hw->config.n_io, in ocs_hw_setup_io()
9515 for (i = 0; i < hw->config.n_io; i++) { in ocs_hw_setup_io()
9516 hw->io[i] = ocs_malloc(hw->os, sizeof(ocs_hw_io_t), in ocs_hw_setup_io()
9518 if (hw->io[i] == NULL) { in ocs_hw_setup_io()
9519 ocs_log_err(hw->os, "IO(%d) memory allocation failed\n", i); in ocs_hw_setup_io()
9525 hw->wqe_buffs = ocs_malloc(hw->os, hw->config.n_io * hw->sli.config.wqe_size, in ocs_hw_setup_io()
9527 if (NULL == hw->wqe_buffs) { in ocs_hw_setup_io()
9528 ocs_free(hw->os, hw->io, hw->config.n_io * sizeof(ocs_hw_io_t)); in ocs_hw_setup_io()
9529 ocs_log_err(hw->os, "%s: IO WQE buff allocation failed, %d Ios at size %zu\n", in ocs_hw_setup_io()
9530 __func__, hw->config.n_io, hw->sli.config.wqe_size); in ocs_hw_setup_io()
9535 /* re-use existing IOs, including SGLs */ in ocs_hw_setup_io()
9540 if (ocs_dma_alloc(hw->os, &hw->xfer_rdy, in ocs_hw_setup_io()
9541 sizeof(fcp_xfer_rdy_iu_t) * hw->config.n_io, in ocs_hw_setup_io()
9543 ocs_log_err(hw->os, "XFER_RDY buffer allocation failed\n"); in ocs_hw_setup_io()
9547 xfer_virt = (uintptr_t)hw->xfer_rdy.virt; in ocs_hw_setup_io()
9548 xfer_phys = hw->xfer_rdy.phys; in ocs_hw_setup_io()
9550 for (i = 0; i < hw->config.n_io; i++) { in ocs_hw_setup_io()
9553 io = hw->io[i]; in ocs_hw_setup_io()
9556 io->hw = hw; in ocs_hw_setup_io()
9559 io->wqe.wqebuf = &hw->wqe_buffs[i * hw->sli.config.wqe_size]; in ocs_hw_setup_io()
9564 ocs_log_err(hw->os, "can't allocate request tag\n"); in ocs_hw_setup_io()
9567 io->reqtag = wqcb->instance_index; in ocs_hw_setup_io()
9573 io->xbusy = 0; in ocs_hw_setup_io()
9575 if (sli_resource_alloc(&hw->sli, SLI_RSRC_FCOE_XRI, &io->indicator, &index)) { in ocs_hw_setup_io()
9576 ocs_log_err(hw->os, "sli_resource_alloc failed @ %d\n", i); in ocs_hw_setup_io()
9580 if (new_alloc && ocs_dma_alloc(hw->os, &io->def_sgl, hw->config.n_sgl * sizeof(sli4_sge_t), 64)) { in ocs_hw_setup_io()
9581 ocs_log_err(hw->os, "ocs_dma_alloc failed @ %d\n", i); in ocs_hw_setup_io()
9582 ocs_memset(&io->def_sgl, 0, sizeof(ocs_dma_t)); in ocs_hw_setup_io()
9585 io->def_sgl_count = hw->config.n_sgl; in ocs_hw_setup_io()
9586 io->sgl = &io->def_sgl; in ocs_hw_setup_io()
9587 io->sgl_count = io->def_sgl_count; in ocs_hw_setup_io()
9589 if (hw->xfer_rdy.size) { in ocs_hw_setup_io()
9590 io->xfer_rdy.virt = (void *)xfer_virt; in ocs_hw_setup_io()
9591 io->xfer_rdy.phys = xfer_phys; in ocs_hw_setup_io()
9592 io->xfer_rdy.size = sizeof(fcp_xfer_rdy_iu_t); in ocs_hw_setup_io()
9601 for (i = 0; i < hw->config.n_io && hw->io[i]; i++) { in ocs_hw_setup_io()
9602 ocs_free(hw->os, hw->io[i], sizeof(ocs_hw_io_t)); in ocs_hw_setup_io()
9603 hw->io[i] = NULL; in ocs_hw_setup_io()
9623 prereg = sli_get_sgl_preregister(&hw->sli); in ocs_hw_init_io()
9626 sgls = ocs_malloc(hw->os, sizeof(*sgls) * sgls_per_request, OCS_M_NOWAIT); in ocs_hw_init_io()
9628 ocs_log_err(hw->os, "ocs_malloc sgls failed\n"); in ocs_hw_init_io()
9632 rc = ocs_dma_alloc(hw->os, &reqbuf, 32 + sgls_per_request*16, OCS_MIN_DMA_ALIGNMENT); in ocs_hw_init_io()
9634 ocs_log_err(hw->os, "ocs_dma_alloc reqbuf failed\n"); in ocs_hw_init_io()
9635 ocs_free(hw->os, sgls, sizeof(*sgls) * sgls_per_request); in ocs_hw_init_io()
9640 io = hw->io[io_index]; in ocs_hw_init_io()
9641 for (nremaining = hw->config.n_io; nremaining; nremaining -= n) { in ocs_hw_init_io()
9649 if (hw->io[io_index + n]->indicator != (hw->io[io_index + n-1]->indicator+1)) { in ocs_hw_init_io()
9653 sgls[n] = hw->io[io_index + n]->sgl; in ocs_hw_init_io()
9656 if (sli_cmd_fcoe_post_sgl_pages(&hw->sli, cmd, sizeof(cmd), in ocs_hw_init_io()
9657 io->indicator, n, sgls, NULL, &reqbuf)) { in ocs_hw_init_io()
9660 ocs_log_err(hw->os, "SGL post failed\n"); in ocs_hw_init_io()
9670 io->is_port_owned = 0; in ocs_hw_init_io()
9671 io->state = OCS_HW_IO_STATE_FREE; in ocs_hw_init_io()
9672 ocs_list_add_tail(&hw->io_free, io); in ocs_hw_init_io()
9673 io = hw->io[io_index+1]; in ocs_hw_init_io()
9679 ocs_dma_free(hw->os, &reqbuf); in ocs_hw_init_io()
9680 ocs_free(hw->os, sgls, sizeof(*sgls) * sgls_per_request); in ocs_hw_init_io()
9692 for (i = 0; i < hw->eq_count; i++) { in ocs_hw_flush()
9703 ocs_lock(&hw->cmd_lock); in ocs_hw_command_cancel()
9710 while (!ocs_list_empty(&hw->cmd_head)) { in ocs_hw_command_cancel()
9712 ocs_command_ctx_t *ctx = ocs_list_get_head(&hw->cmd_head); in ocs_hw_command_cancel()
9714 ocs_log_test(hw->os, "hung command %08x\n", in ocs_hw_command_cancel()
9716 (NULL == ctx->buf ? UINT32_MAX : *((uint32_t *)ctx->buf))); in ocs_hw_command_cancel()
9717 ocs_unlock(&hw->cmd_lock); in ocs_hw_command_cancel()
9718 ocs_hw_command_process(hw, -1/*Bad status*/, mqe, SLI4_BMBX_SIZE); in ocs_hw_command_cancel()
9719 ocs_lock(&hw->cmd_lock); in ocs_hw_command_cancel()
9722 ocs_unlock(&hw->cmd_lock); in ocs_hw_command_cancel()
9739 ioindex = xri - hw->sli.config.extent[SLI_RSRC_FCOE_XRI].base[0]; in ocs_hw_io_lookup()
9740 return hw->io[ioindex]; in ocs_hw_io_lookup()
9752 ocs_hw_done_t done = io->done; in ocs_hw_io_cancel_cleanup()
9753 ocs_hw_done_t abort_done = io->abort_done; in ocs_hw_io_cancel_cleanup()
9756 if (ocs_list_on_list(&io->wqe_link)) { in ocs_hw_io_cancel_cleanup()
9757 ocs_list_remove(&hw->io_timed_wqe, io); in ocs_hw_io_cancel_cleanup()
9761 if ((io->wq != NULL) && ocs_list_on_list(&io->wq->pending_list)) { in ocs_hw_io_cancel_cleanup()
9762 ocs_list_remove(&io->wq->pending_list, io); in ocs_hw_io_cancel_cleanup()
9765 if (io->done) { in ocs_hw_io_cancel_cleanup()
9766 void *arg = io->arg; in ocs_hw_io_cancel_cleanup()
9768 io->done = NULL; in ocs_hw_io_cancel_cleanup()
9769 ocs_unlock(&hw->io_lock); in ocs_hw_io_cancel_cleanup()
9770 done(io, io->rnode, 0, SLI4_FC_WCQE_STATUS_SHUTDOWN, 0, arg); in ocs_hw_io_cancel_cleanup()
9771 ocs_lock(&hw->io_lock); in ocs_hw_io_cancel_cleanup()
9774 if (io->abort_done != NULL) { in ocs_hw_io_cancel_cleanup()
9775 void *abort_arg = io->abort_arg; in ocs_hw_io_cancel_cleanup()
9777 io->abort_done = NULL; in ocs_hw_io_cancel_cleanup()
9778 ocs_unlock(&hw->io_lock); in ocs_hw_io_cancel_cleanup()
9779 abort_done(io, io->rnode, 0, SLI4_FC_WCQE_STATUS_SHUTDOWN, 0, abort_arg); in ocs_hw_io_cancel_cleanup()
9780 ocs_lock(&hw->io_lock); in ocs_hw_io_cancel_cleanup()
9795 ocs_lock(&hw->io_lock); in ocs_hw_io_cancel()
9796 ocs_list_foreach_safe(&hw->io_inuse, io, tmp_io) { in ocs_hw_io_cancel()
9797 ocs_hw_done_t done = io->done; in ocs_hw_io_cancel()
9798 ocs_hw_done_t abort_done = io->abort_done; in ocs_hw_io_cancel()
9820 ocs_list_remove(&hw->io_inuse, io); in ocs_hw_io_cancel()
9829 ocs_list_foreach_safe(&hw->io_port_owned, io, tmp_io) { in ocs_hw_io_cancel()
9831 if (ocs_list_on_list(&io->dnrx_link)) { in ocs_hw_io_cancel()
9832 ocs_list_remove(&hw->io_port_dnrx, io); in ocs_hw_io_cancel()
9833 ocs_ref_put(&io->ref); /* ocs_ref_get(): same function */ in ocs_hw_io_cancel()
9836 ocs_list_remove(&hw->io_port_owned, io); in ocs_hw_io_cancel()
9839 ocs_unlock(&hw->io_lock); in ocs_hw_io_cancel()
9844 iters--; in ocs_hw_io_cancel()
9845 } while (!ocs_list_empty(&hw->io_inuse) && iters); in ocs_hw_io_cancel()
9848 if (!ocs_list_empty(&hw->io_inuse)) { in ocs_hw_io_cancel()
9849 ocs_log_test(hw->os, "io_inuse list is not empty\n"); in ocs_hw_io_cancel()
9866 data = io->def_sgl.virt; in ocs_hw_io_ini_sge()
9869 data->buffer_address_high = ocs_addr32_hi(cmnd->phys); in ocs_hw_io_ini_sge()
9870 data->buffer_address_low = ocs_addr32_lo(cmnd->phys); in ocs_hw_io_ini_sge()
9871 data->buffer_length = cmnd_size; in ocs_hw_io_ini_sge()
9875 data->buffer_address_high = ocs_addr32_hi(rsp->phys); in ocs_hw_io_ini_sge()
9876 data->buffer_address_low = ocs_addr32_lo(rsp->phys); in ocs_hw_io_ini_sge()
9877 data->buffer_length = rsp->size; in ocs_hw_io_ini_sge()
9887 if (status || read_topo->hdr.status) { in __ocs_read_topology_cb()
9888 ocs_log_debug(hw->os, "bad status cqe=%#x mqe=%#x\n", in __ocs_read_topology_cb()
9889 status, read_topo->hdr.status); in __ocs_read_topology_cb()
9890 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in __ocs_read_topology_cb()
9891 return -1; in __ocs_read_topology_cb()
9894 switch (read_topo->attention_type) { in __ocs_read_topology_cb()
9896 hw->link.status = SLI_LINK_STATUS_UP; in __ocs_read_topology_cb()
9899 hw->link.status = SLI_LINK_STATUS_DOWN; in __ocs_read_topology_cb()
9902 hw->link.status = SLI_LINK_STATUS_NO_ALPA; in __ocs_read_topology_cb()
9905 hw->link.status = SLI_LINK_STATUS_MAX; in __ocs_read_topology_cb()
9909 switch (read_topo->topology) { in __ocs_read_topology_cb()
9911 hw->link.topology = SLI_LINK_TOPO_NPORT; in __ocs_read_topology_cb()
9914 hw->link.topology = SLI_LINK_TOPO_LOOP; in __ocs_read_topology_cb()
9915 if (SLI_LINK_STATUS_UP == hw->link.status) { in __ocs_read_topology_cb()
9916 hw->link.loop_map = hw->loop_map.virt; in __ocs_read_topology_cb()
9918 hw->link.fc_id = read_topo->acquired_al_pa; in __ocs_read_topology_cb()
9921 hw->link.topology = SLI_LINK_TOPO_MAX; in __ocs_read_topology_cb()
9925 hw->link.medium = SLI_LINK_MEDIUM_FC; in __ocs_read_topology_cb()
9927 switch (read_topo->link_current.link_speed) { in __ocs_read_topology_cb()
9929 hw->link.speed = 1 * 1000; in __ocs_read_topology_cb()
9932 hw->link.speed = 2 * 1000; in __ocs_read_topology_cb()
9935 hw->link.speed = 4 * 1000; in __ocs_read_topology_cb()
9938 hw->link.speed = 8 * 1000; in __ocs_read_topology_cb()
9941 hw->link.speed = 16 * 1000; in __ocs_read_topology_cb()
9942 hw->link.loop_map = NULL; in __ocs_read_topology_cb()
9945 hw->link.speed = 32 * 1000; in __ocs_read_topology_cb()
9946 hw->link.loop_map = NULL; in __ocs_read_topology_cb()
9950 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in __ocs_read_topology_cb()
9960 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_common()
9961 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_common()
9973 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_port_common()
9977 ocs_log_test(hw->os, "%s %-20s not handled\n", funcname, ocs_sm_event_name(evt)); in __ocs_hw_port_common()
9987 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_free_report_fail()
9988 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_free_report_fail()
9995 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_port_free_report_fail()
9997 if (hw->callback.port != NULL) { in __ocs_hw_port_free_report_fail()
9998 hw->callback.port(hw->args.port, in __ocs_hw_port_free_report_fail()
10012 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_freed()
10013 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_freed()
10020 if (sli_resource_free(&hw->sli, SLI_RSRC_FCOE_VPI, sport->indicator)) { in __ocs_hw_port_freed()
10021 ocs_log_err(hw->os, "FCOE_VPI free failure addr=%#x\n", sport->fc_id); in __ocs_hw_port_freed()
10026 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_port_freed()
10028 if (hw->callback.port != NULL) { in __ocs_hw_port_freed()
10029 hw->callback.port(hw->args.port, in __ocs_hw_port_freed()
10043 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_attach_report_fail()
10044 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_attach_report_fail()
10051 sli_resource_free(&hw->sli, SLI_RSRC_FCOE_VPI, sport->indicator); in __ocs_hw_port_attach_report_fail()
10055 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_port_attach_report_fail()
10058 if (hw->callback.port != NULL) { in __ocs_hw_port_attach_report_fail()
10059 hw->callback.port(hw->args.port, in __ocs_hw_port_attach_report_fail()
10062 if (sport->sm_free_req_pending) { in __ocs_hw_port_attach_report_fail()
10077 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_free_unreg_vpi()
10078 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_free_unreg_vpi()
10086 cmd = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in __ocs_hw_port_free_unreg_vpi()
10092 if (0 == sli_cmd_unreg_vpi(&hw->sli, cmd, SLI4_BMBX_SIZE, sport->indicator, in __ocs_hw_port_free_unreg_vpi()
10094 ocs_log_err(hw->os, "UNREG_VPI format failure\n"); in __ocs_hw_port_free_unreg_vpi()
10095 ocs_free(hw->os, cmd, SLI4_BMBX_SIZE); in __ocs_hw_port_free_unreg_vpi()
10101 ocs_log_err(hw->os, "UNREG_VPI command failure\n"); in __ocs_hw_port_free_unreg_vpi()
10102 ocs_free(hw->os, cmd, SLI4_BMBX_SIZE); in __ocs_hw_port_free_unreg_vpi()
10124 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_free_nop()
10125 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_free_nop()
10133 ocs_log_err(hw->os, "ocs_hw_async_call failed\n"); in __ocs_hw_port_free_nop()
10152 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_attached()
10153 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_attached()
10160 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_port_attached()
10162 if (hw->callback.port != NULL) { in __ocs_hw_port_attached()
10163 hw->callback.port(hw->args.port, in __ocs_hw_port_attached()
10166 if (sport->sm_free_req_pending) { in __ocs_hw_port_attached()
10185 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_attach_reg_vpi()
10186 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_attach_reg_vpi()
10192 if (0 == sli_cmd_reg_vpi(&hw->sli, data, SLI4_BMBX_SIZE, sport, FALSE)) { in __ocs_hw_port_attach_reg_vpi()
10193 ocs_log_err(hw->os, "REG_VPI format failure\n"); in __ocs_hw_port_attach_reg_vpi()
10199 ocs_log_err(hw->os, "REG_VPI command failure\n"); in __ocs_hw_port_attach_reg_vpi()
10212 sport->sm_free_req_pending = 1; in __ocs_hw_port_attach_reg_vpi()
10225 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_done()
10226 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_done()
10233 sli_resource_free(&hw->sli, SLI_RSRC_FCOE_VPI, sport->indicator); in __ocs_hw_port_done()
10237 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_port_done()
10251 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_allocated()
10252 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_allocated()
10259 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_port_allocated()
10261 if (hw->callback.port != NULL) { in __ocs_hw_port_allocated()
10262 hw->callback.port(hw->args.port, in __ocs_hw_port_allocated()
10266 if (sport->sm_free_req_pending) { in __ocs_hw_port_allocated()
10280 if (SLI4_IF_TYPE_LANCER_FC_ETH == sli_get_if_type(&hw->sli)) { in __ocs_hw_port_allocated()
10305 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_alloc_report_fail()
10306 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_alloc_report_fail()
10313 sli_resource_free(&hw->sli, SLI_RSRC_FCOE_VPI, sport->indicator); in __ocs_hw_port_alloc_report_fail()
10317 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_port_alloc_report_fail()
10320 if (hw->callback.port != NULL) { in __ocs_hw_port_alloc_report_fail()
10321 hw->callback.port(hw->args.port, in __ocs_hw_port_alloc_report_fail()
10326 if (sport->sm_free_req_pending) { in __ocs_hw_port_alloc_report_fail()
10341 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_alloc_read_sparm64()
10342 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_alloc_read_sparm64()
10350 if (ocs_dma_alloc(hw->os, &sport->dma, 112, 4)) { in __ocs_hw_port_alloc_read_sparm64()
10351 ocs_log_err(hw->os, "Failed to allocate DMA memory\n"); in __ocs_hw_port_alloc_read_sparm64()
10356 if (0 == sli_cmd_read_sparm64(&hw->sli, data, SLI4_BMBX_SIZE, in __ocs_hw_port_alloc_read_sparm64()
10357 &sport->dma, sport->indicator)) { in __ocs_hw_port_alloc_read_sparm64()
10358 ocs_log_err(hw->os, "READ_SPARM64 allocation failure\n"); in __ocs_hw_port_alloc_read_sparm64()
10359 ocs_dma_free(hw->os, &sport->dma); in __ocs_hw_port_alloc_read_sparm64()
10365 ocs_log_err(hw->os, "READ_SPARM64 command failure\n"); in __ocs_hw_port_alloc_read_sparm64()
10366 ocs_dma_free(hw->os, &sport->dma); in __ocs_hw_port_alloc_read_sparm64()
10372 payload = sport->dma.virt; in __ocs_hw_port_alloc_read_sparm64()
10374 ocs_display_sparams(sport->display_name, "sport sparm64", 0, NULL, payload); in __ocs_hw_port_alloc_read_sparm64()
10376 ocs_memcpy(&sport->sli_wwpn, payload + SLI4_READ_SPARM64_WWPN_OFFSET, in __ocs_hw_port_alloc_read_sparm64()
10377 sizeof(sport->sli_wwpn)); in __ocs_hw_port_alloc_read_sparm64()
10378 ocs_memcpy(&sport->sli_wwnn, payload + SLI4_READ_SPARM64_WWNN_OFFSET, in __ocs_hw_port_alloc_read_sparm64()
10379 sizeof(sport->sli_wwnn)); in __ocs_hw_port_alloc_read_sparm64()
10381 ocs_dma_free(hw->os, &sport->dma); in __ocs_hw_port_alloc_read_sparm64()
10385 ocs_dma_free(hw->os, &sport->dma); in __ocs_hw_port_alloc_read_sparm64()
10390 sport->sm_free_req_pending = 1; in __ocs_hw_port_alloc_read_sparm64()
10405 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_alloc_init()
10411 /* no-op */ in __ocs_hw_port_alloc_init()
10421 sport->sm_free_req_pending = 1; in __ocs_hw_port_alloc_init()
10434 ocs_sli_port_t *sport = ctx->app; in __ocs_hw_port_alloc_init_vpi()
10435 ocs_hw_t *hw = sport->hw; in __ocs_hw_port_alloc_init_vpi()
10442 if (sport->sm_free_req_pending) { in __ocs_hw_port_alloc_init_vpi()
10452 if (0 == sli_cmd_init_vpi(&hw->sli, data, SLI4_BMBX_SIZE, in __ocs_hw_port_alloc_init_vpi()
10453 sport->indicator, sport->domain->indicator)) { in __ocs_hw_port_alloc_init_vpi()
10454 ocs_log_err(hw->os, "INIT_VPI allocation failure\n"); in __ocs_hw_port_alloc_init_vpi()
10460 ocs_log_err(hw->os, "INIT_VPI command failure\n"); in __ocs_hw_port_alloc_init_vpi()
10473 sport->sm_free_req_pending = 1; in __ocs_hw_port_alloc_init_vpi()
10492 if (status || hdr->status) { in __ocs_hw_port_cb()
10493 ocs_log_debug(hw->os, "bad status vpi=%#x st=%x hdr=%x\n", in __ocs_hw_port_cb()
10494 sport->indicator, status, hdr->status); in __ocs_hw_port_cb()
10500 ocs_sm_post_event(&sport->ctx, evt, mqe); in __ocs_hw_port_cb()
10513 if (status || hdr->status) { in __ocs_hw_port_realloc_cb()
10514 ocs_log_debug(hw->os, "bad status vpi=%#x st=%x hdr=%x\n", in __ocs_hw_port_realloc_cb()
10515 sport->indicator, status, hdr->status); in __ocs_hw_port_realloc_cb()
10525 mqecpy = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in __ocs_hw_port_realloc_cb()
10527 ocs_log_err(hw->os, "malloc mqecpy failed\n"); in __ocs_hw_port_realloc_cb()
10528 return -1; in __ocs_hw_port_realloc_cb()
10532 ocs_sm_post_event(&sport->ctx, evt, mqecpy); in __ocs_hw_port_realloc_cb()
10544 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_common()
10545 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_common()
10555 ocs_log_test(hw->os, "%s %-20s not handled\n", funcname, ocs_sm_event_name(evt)); in __ocs_hw_domain_common()
10565 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_alloc_report_fail()
10566 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_alloc_report_fail()
10574 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_domain_alloc_report_fail()
10577 sli_resource_free(&hw->sli, SLI_RSRC_FCOE_VFI, domain->indicator); in __ocs_hw_domain_alloc_report_fail()
10580 if (hw->callback.domain != NULL) { in __ocs_hw_domain_alloc_report_fail()
10581 hw->callback.domain(hw->args.domain, in __ocs_hw_domain_alloc_report_fail()
10597 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_attached()
10598 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_attached()
10605 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_domain_attached()
10606 ocs_sm_post_event(&domain->sport->ctx, OCS_EVT_HW_PORT_ATTACH_OK, NULL); in __ocs_hw_domain_attached()
10609 if (hw->callback.domain != NULL) { in __ocs_hw_domain_attached()
10610 hw->callback.domain(hw->args.domain, in __ocs_hw_domain_attached()
10629 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_attach_report_fail()
10630 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_attach_report_fail()
10637 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_domain_attach_report_fail()
10640 sli_resource_free(&hw->sli, SLI_RSRC_FCOE_VFI, domain->indicator); in __ocs_hw_domain_attach_report_fail()
10643 if (hw->callback.domain != NULL) { in __ocs_hw_domain_attach_report_fail()
10644 hw->callback.domain(hw->args.domain, in __ocs_hw_domain_attach_report_fail()
10662 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_attach_reg_vfi()
10663 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_attach_reg_vfi()
10670 ocs_display_sparams("", "reg vpi", 0, NULL, domain->dma.virt); in __ocs_hw_domain_attach_reg_vfi()
10672 if (0 == sli_cmd_reg_vfi(&hw->sli, data, SLI4_BMBX_SIZE, domain)) { in __ocs_hw_domain_attach_reg_vfi()
10673 ocs_log_err(hw->os, "REG_VFI format failure\n"); in __ocs_hw_domain_attach_reg_vfi()
10679 ocs_log_err(hw->os, "REG_VFI command failure\n"); in __ocs_hw_domain_attach_reg_vfi()
10701 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_allocated()
10702 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_allocated()
10709 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_domain_allocated()
10710 ocs_sm_post_event(&domain->sport->ctx, OCS_EVT_HW_PORT_ALLOC_OK, NULL); in __ocs_hw_domain_allocated()
10715 if (hw->callback.domain != NULL) { in __ocs_hw_domain_allocated()
10716 hw->callback.domain(hw->args.domain, in __ocs_hw_domain_allocated()
10726 if (SLI4_IF_TYPE_BE3_SKH_PF == sli_get_if_type(&hw->sli)) { in __ocs_hw_domain_allocated()
10743 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_alloc_read_sparm64()
10744 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_alloc_read_sparm64()
10750 if (0 == sli_cmd_read_sparm64(&hw->sli, data, SLI4_BMBX_SIZE, in __ocs_hw_domain_alloc_read_sparm64()
10751 &domain->dma, SLI4_READ_SPARM64_VPI_DEFAULT)) { in __ocs_hw_domain_alloc_read_sparm64()
10752 ocs_log_err(hw->os, "READ_SPARM64 format failure\n"); in __ocs_hw_domain_alloc_read_sparm64()
10758 ocs_log_err(hw->os, "READ_SPARM64 command failure\n"); in __ocs_hw_domain_alloc_read_sparm64()
10766 ocs_display_sparams(domain->display_name, "domain sparm64", 0, NULL, domain->dma.virt); in __ocs_hw_domain_alloc_read_sparm64()
10784 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_alloc_init_vfi()
10785 ocs_sli_port_t *sport = domain->sport; in __ocs_hw_domain_alloc_init_vfi()
10786 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_alloc_init_vfi()
10792 if (0 == sli_cmd_init_vfi(&hw->sli, data, SLI4_BMBX_SIZE, domain->indicator, in __ocs_hw_domain_alloc_init_vfi()
10793 domain->fcf_indicator, sport->indicator)) { in __ocs_hw_domain_alloc_init_vfi()
10794 ocs_log_err(hw->os, "INIT_VFI format failure\n"); in __ocs_hw_domain_alloc_init_vfi()
10799 ocs_log_err(hw->os, "INIT_VFI command failure\n"); in __ocs_hw_domain_alloc_init_vfi()
10823 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_alloc_reg_fcfi()
10824 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_alloc_reg_fcfi()
10836 rq_cfg[i].r_ctl_mask = (uint8_t) hw->config.filter_def[i]; in __ocs_hw_domain_alloc_reg_fcfi()
10837 rq_cfg[i].r_ctl_match = (uint8_t) (hw->config.filter_def[i] >> 8); in __ocs_hw_domain_alloc_reg_fcfi()
10838 rq_cfg[i].type_mask = (uint8_t) (hw->config.filter_def[i] >> 16); in __ocs_hw_domain_alloc_reg_fcfi()
10839 rq_cfg[i].type_match = (uint8_t) (hw->config.filter_def[i] >> 24); in __ocs_hw_domain_alloc_reg_fcfi()
10843 for (i = 0; i < hw->hw_rq_count; i++) { in __ocs_hw_domain_alloc_reg_fcfi()
10845 ocs_log_warn(hw->os, "more RQs than REG_FCFI filter entries\n"); in __ocs_hw_domain_alloc_reg_fcfi()
10848 rq_cfg[i].rq_id = hw->hw_rq[i]->hdr->id; in __ocs_hw_domain_alloc_reg_fcfi()
10856 if (hw->hw_mrq_count) { in __ocs_hw_domain_alloc_reg_fcfi()
10858 domain->vlan_id, domain->fcf)) { in __ocs_hw_domain_alloc_reg_fcfi()
10859 ocs_log_err(hw->os, "REG_FCFI_MRQ format failure\n"); in __ocs_hw_domain_alloc_reg_fcfi()
10865 if (0 == sli_cmd_reg_fcfi(&hw->sli, data, SLI4_BMBX_SIZE, domain->fcf, in __ocs_hw_domain_alloc_reg_fcfi()
10866 rq_cfg, domain->vlan_id)) { in __ocs_hw_domain_alloc_reg_fcfi()
10867 ocs_log_err(hw->os, "REG_FCFI format failure\n"); in __ocs_hw_domain_alloc_reg_fcfi()
10874 ocs_log_err(hw->os, "REG_FCFI command failure\n"); in __ocs_hw_domain_alloc_reg_fcfi()
10888 domain->fcf_indicator = ((sli4_cmd_reg_fcfi_t *)data)->fcfi; in __ocs_hw_domain_alloc_reg_fcfi()
10895 if (SLI4_IF_TYPE_BE3_SKH_PF == sli_get_if_type(&hw->sli)) { in __ocs_hw_domain_alloc_reg_fcfi()
10915 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_init()
10916 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_init()
10922 if (sli_get_medium(&hw->sli) == SLI_LINK_MEDIUM_FC) { in __ocs_hw_domain_init()
10927 domain->fcf_indicator = hw->fcf_indicator; in __ocs_hw_domain_init()
10928 ocs_sm_transition(&domain->sm, __ocs_hw_domain_alloc_init_vfi, data); in __ocs_hw_domain_init()
10930 ocs_sm_transition(&domain->sm, __ocs_hw_domain_alloc_reg_fcfi, data); in __ocs_hw_domain_init()
10944 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_free_report_fail()
10951 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_free_report_fail()
10955 if (hw->callback.domain != NULL) { in __ocs_hw_domain_free_report_fail()
10956 hw->callback.domain(hw->args.domain, in __ocs_hw_domain_free_report_fail()
10964 ocs_free(domain != NULL ? domain->hw->os : NULL, data, SLI4_BMBX_SIZE); in __ocs_hw_domain_free_report_fail()
10980 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_freed()
10988 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_freed()
10991 sli_resource_free(&hw->sli, SLI_RSRC_FCOE_VFI, in __ocs_hw_domain_freed()
10992 domain->indicator); in __ocs_hw_domain_freed()
10997 if (hw->callback.domain != NULL) { in __ocs_hw_domain_freed()
10998 hw->callback.domain(hw->args.domain, in __ocs_hw_domain_freed()
11020 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_free_redisc_fcf()
11021 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_free_redisc_fcf()
11028 if (hw->state == OCS_HW_STATE_TEARDOWN_IN_PROGRESS) { in __ocs_hw_domain_free_redisc_fcf()
11032 if (0 == sli_cmd_fcoe_rediscover_fcf(&hw->sli, data, SLI4_BMBX_SIZE, domain->fcf)) { in __ocs_hw_domain_free_redisc_fcf()
11033 ocs_log_err(hw->os, "REDISCOVER_FCF format failure\n"); in __ocs_hw_domain_free_redisc_fcf()
11039 ocs_log_err(hw->os, "REDISCOVER_FCF command failure\n"); in __ocs_hw_domain_free_redisc_fcf()
11061 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_free_unreg_fcfi()
11062 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_free_unreg_fcfi()
11069 data = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in __ocs_hw_domain_free_unreg_fcfi()
11076 if (0 == sli_cmd_unreg_fcfi(&hw->sli, data, SLI4_BMBX_SIZE, domain->fcf_indicator)) { in __ocs_hw_domain_free_unreg_fcfi()
11077 ocs_log_err(hw->os, "UNREG_FCFI format failure\n"); in __ocs_hw_domain_free_unreg_fcfi()
11078 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_domain_free_unreg_fcfi()
11084 ocs_log_err(hw->os, "UNREG_FCFI command failure\n"); in __ocs_hw_domain_free_unreg_fcfi()
11085 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_domain_free_unreg_fcfi()
11091 if (domain->req_rediscover_fcf) { in __ocs_hw_domain_free_unreg_fcfi()
11092 domain->req_rediscover_fcf = FALSE; in __ocs_hw_domain_free_unreg_fcfi()
11114 ocs_domain_t *domain = ctx->app; in __ocs_hw_domain_free_unreg_vfi()
11115 ocs_hw_t *hw = domain->hw; in __ocs_hw_domain_free_unreg_vfi()
11120 is_fc = (sli_get_medium(&hw->sli) == SLI_LINK_MEDIUM_FC); in __ocs_hw_domain_free_unreg_vfi()
11125 data = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_ZERO | OCS_M_NOWAIT); in __ocs_hw_domain_free_unreg_vfi()
11132 if (0 == sli_cmd_unreg_vfi(&hw->sli, data, SLI4_BMBX_SIZE, domain, in __ocs_hw_domain_free_unreg_vfi()
11134 ocs_log_err(hw->os, "UNREG_VFI format failure\n"); in __ocs_hw_domain_free_unreg_vfi()
11135 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_domain_free_unreg_vfi()
11141 ocs_log_err(hw->os, "UNREG_VFI command failure\n"); in __ocs_hw_domain_free_unreg_vfi()
11142 ocs_free(hw->os, data, SLI4_BMBX_SIZE); in __ocs_hw_domain_free_unreg_vfi()
11177 if (status || hdr->status) { in __ocs_hw_domain_cb()
11178 ocs_log_debug(hw->os, "bad status vfi=%#x st=%x hdr=%x\n", in __ocs_hw_domain_cb()
11179 domain->indicator, status, hdr->status); in __ocs_hw_domain_cb()
11185 ocs_sm_post_event(&domain->sm, evt, mqe); in __ocs_hw_domain_cb()
11200 if (status || hdr->status) { in target_wqe_timer_nop_cb()
11201 ocs_log_debug(hw->os, "bad status st=%x hdr=%x\n", in target_wqe_timer_nop_cb()
11202 status, hdr->status); in target_wqe_timer_nop_cb()
11207 ocs_lock(&hw->io_lock); in target_wqe_timer_nop_cb()
11208 ocs_list_foreach_safe(&hw->io_timed_wqe, io, io_next) { in target_wqe_timer_nop_cb()
11215 timevalsub(&cur_time, &io->submit_time); in target_wqe_timer_nop_cb()
11216 if (cur_time.tv_sec > io->wqe_timeout) { in target_wqe_timer_nop_cb()
11217 ocs_log_info(hw->os, "IO timeout xri=0x%x tag=0x%x type=%d elapsed time:%u\n", in target_wqe_timer_nop_cb()
11218 io->indicator, io->reqtag, io->type, cur_time.tv_sec); in target_wqe_timer_nop_cb()
11221 ocs_list_remove(&hw->io_timed_wqe, io); in target_wqe_timer_nop_cb()
11224 io->status_saved = 1; in target_wqe_timer_nop_cb()
11225 io->saved_status = SLI4_FC_WCQE_STATUS_WQE_TIMEOUT; in target_wqe_timer_nop_cb()
11226 io->saved_ext = 0; in target_wqe_timer_nop_cb()
11227 io->saved_len = 0; in target_wqe_timer_nop_cb()
11232 ocs_log_test(hw->os, in target_wqe_timer_nop_cb()
11234 io->indicator, io->reqtag, rc); in target_wqe_timer_nop_cb()
11242 ocs_unlock(&hw->io_lock); in target_wqe_timer_nop_cb()
11245 if (!hw->active_wqe_timer_shutdown) { in target_wqe_timer_nop_cb()
11246 ocs_setup_timer(hw->os, &hw->wqe_timer, target_wqe_timer_cb, hw, OCS_HW_WQ_TIMER_PERIOD_MS); in target_wqe_timer_nop_cb()
11248 hw->in_active_wqe_timer = FALSE; in target_wqe_timer_nop_cb()
11258 hw->in_active_wqe_timer = TRUE; in target_wqe_timer_cb()
11262 ocs_log_test(hw->os, "ocs_hw_async_call failed\n"); in target_wqe_timer_cb()
11271 if (hw->config.emulate_wqe_timeout) { in shutdown_target_wqe_timer()
11273 hw->active_wqe_timer_shutdown = TRUE; in shutdown_target_wqe_timer()
11276 ocs_del_timer(&hw->wqe_timer); in shutdown_target_wqe_timer()
11279 while (hw->in_active_wqe_timer && iters) { in shutdown_target_wqe_timer()
11285 iters--; in shutdown_target_wqe_timer()
11289 ocs_log_test(hw->os, "Failed to shutdown active wqe timer\n"); in shutdown_target_wqe_timer()
11303 * @return Returns TRUE if given HW IO is port-owned.
11309 return io->is_port_owned; in ocs_hw_is_io_port_owned()
11313 * @brief Return TRUE if exchange is port-owned.
11316 * Test to see if the xri is a port-owned xri.
11328 return (io == NULL ? FALSE : io->is_port_owned); in ocs_hw_is_xri_port_owned()
11354 if (hw->auto_xfer_rdy_enabled) { in ocs_hw_reclaim_xri()
11358 ocs_lock(&hw->io_lock); in ocs_hw_reclaim_xri()
11359 ocs_list_remove(&hw->io_port_owned, io); in ocs_hw_reclaim_xri()
11360 io->is_port_owned = 0; in ocs_hw_reclaim_xri()
11361 ocs_list_add_tail(&hw->io_free, io); in ocs_hw_reclaim_xri()
11362 ocs_unlock(&hw->io_lock); in ocs_hw_reclaim_xri()
11386 ocs_log_debug(hw->os, "Status 0x%x for XRI base 0x%x, cnt =x%x\n", in ocs_hw_cb_post_xri()
11387 status, post_xri->xri_base, post_xri->xri_count); in ocs_hw_cb_post_xri()
11388 ocs_hw_reclaim_xri(hw, post_xri->xri_base, post_xri->xri_count); in ocs_hw_cb_post_xri()
11391 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_post_xri()
11396 * @brief Issues a mailbox command to move XRIs from the host-controlled pool to the port.
11412 post_xri = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_post_xri()
11414 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_post_xri()
11419 if (sli_cmd_post_xri(&hw->sli, post_xri, SLI4_BMBX_SIZE, in ocs_hw_post_xri()
11423 ocs_free(hw->os, post_xri, SLI4_BMBX_SIZE); in ocs_hw_post_xri()
11424 ocs_log_err(hw->os, "post_xri failed\n"); in ocs_hw_post_xri()
11431 * @brief Move XRIs from the host-controlled pool to the port.
11454 ocs_lock(&hw->io_lock); in ocs_hw_xri_move_to_port_owned()
11457 if (NULL != (io = ocs_list_remove_head(&hw->io_free))) { in ocs_hw_xri_move_to_port_owned()
11466 if (hw->auto_xfer_rdy_enabled) { in ocs_hw_xri_move_to_port_owned()
11468 ocs_unlock(&hw->io_lock); in ocs_hw_xri_move_to_port_owned()
11470 ocs_lock(&hw->io_lock); in ocs_hw_xri_move_to_port_owned()
11472 ocs_list_add_head(&hw->io_free, io); in ocs_hw_xri_move_to_port_owned()
11476 ocs_lock_init(hw->os, &io->axr_lock, "HW_axr_lock[%d]", io->indicator); in ocs_hw_xri_move_to_port_owned()
11477 io->is_port_owned = 1; in ocs_hw_xri_move_to_port_owned()
11478 ocs_list_add_tail(&hw->io_port_owned, io); in ocs_hw_xri_move_to_port_owned()
11481 if (ocs_hw_post_xri(hw, io->indicator, 1) != OCS_HW_RTN_SUCCESS ) { in ocs_hw_xri_move_to_port_owned()
11482 ocs_hw_reclaim_xri(hw, io->indicator, i); in ocs_hw_xri_move_to_port_owned()
11491 ocs_unlock(&hw->io_lock); in ocs_hw_xri_move_to_port_owned()
11517 ocs_log_err(hw->os, "Status 0x%x\n", status); in ocs_hw_cb_release_xri()
11519 for (i = 0; i < release_xri->released_xri_count; i++) { in ocs_hw_cb_release_xri()
11520 uint16_t xri = ((i & 1) == 0 ? release_xri->xri_tbl[i/2].xri_tag0 : in ocs_hw_cb_release_xri()
11521 release_xri->xri_tbl[i/2].xri_tag1); in ocs_hw_cb_release_xri()
11526 ocs_free(hw->os, mqe, SLI4_BMBX_SIZE); in ocs_hw_cb_release_xri()
11531 * @brief Move XRIs from the port-controlled pool to the host.
11533 * Requests XRIs from the FW to return to the host-owned pool.
11547 /* non-local buffer required for mailbox queue */ in ocs_hw_xri_move_to_host_owned()
11548 release_xri = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT); in ocs_hw_xri_move_to_host_owned()
11550 ocs_log_err(hw->os, "no buffer for command\n"); in ocs_hw_xri_move_to_host_owned()
11555 if (sli_cmd_release_xri(&hw->sli, release_xri, SLI4_BMBX_SIZE, num_xri)) { in ocs_hw_xri_move_to_host_owned()
11558 ocs_log_err(hw->os, "release_xri failed\n"); in ocs_hw_xri_move_to_host_owned()
11563 ocs_free(hw->os, release_xri, SLI4_BMBX_SIZE); in ocs_hw_xri_move_to_host_owned()
11584 ocs_t *ocs = hw->os; in ocs_hw_rx_buffer_alloc()
11590 rq_buf = ocs_malloc(hw->os, sizeof(*rq_buf) * count, OCS_M_NOWAIT | OCS_M_ZERO); in ocs_hw_rx_buffer_alloc()
11592 ocs_log_err(hw->os, "Failure to allocate unsolicited DMA trackers\n"); in ocs_hw_rx_buffer_alloc()
11597 prq->rqindex = rqindex; in ocs_hw_rx_buffer_alloc()
11598 if (ocs_dma_alloc(ocs, &prq->dma, size, OCS_MIN_DMA_ALIGNMENT)) { in ocs_hw_rx_buffer_alloc()
11599 ocs_log_err(hw->os, "DMA allocation failed\n"); in ocs_hw_rx_buffer_alloc()
11600 ocs_free(hw->os, rq_buf, sizeof(*rq_buf) * count); in ocs_hw_rx_buffer_alloc()
11624 ocs_t *ocs = hw->os; in ocs_hw_rx_buffer_free()
11630 ocs_dma_free(ocs, &prq->dma); in ocs_hw_rx_buffer_free()
11632 ocs_free(hw->os, rq_buf, sizeof(*rq_buf) * count); in ocs_hw_rx_buffer_free()
11641 * @return Returns 0 on success, or a non-zero value on failure.
11646 ocs_t *ocs = hw->os; in ocs_hw_rx_allocate()
11652 uint32_t payload_size = hw->config.rq_default_buffer_size; in ocs_hw_rx_allocate()
11656 for (i = 0; i < hw->hw_rq_count; i++) { in ocs_hw_rx_allocate()
11657 rq = hw->hw_rq[i]; in ocs_hw_rx_allocate()
11660 rq->hdr_buf = ocs_hw_rx_buffer_alloc(hw, rqindex, rq->entry_count, hdr_size); in ocs_hw_rx_allocate()
11661 if (rq->hdr_buf == NULL) { in ocs_hw_rx_allocate()
11667 ocs_log_debug(hw->os, "rq[%2d] rq_id %02d header %4d by %4d bytes\n", i, rq->hdr->id, in ocs_hw_rx_allocate()
11668 rq->entry_count, hdr_size); in ocs_hw_rx_allocate()
11673 rq->payload_buf = ocs_hw_rx_buffer_alloc(hw, rqindex, rq->entry_count, payload_size); in ocs_hw_rx_allocate()
11674 if (rq->payload_buf == NULL) { in ocs_hw_rx_allocate()
11679 ocs_log_debug(hw->os, "rq[%2d] rq_id %02d default %4d by %4d bytes\n", i, rq->data->id, in ocs_hw_rx_allocate()
11680 rq->entry_count, payload_size); in ocs_hw_rx_allocate()
11692 * @return Returns 0 on success, or a non-zero value on failure.
11706 for (rq_idx = 0, idx = 0; rq_idx < hw->hw_rq_count; rq_idx++) { in ocs_hw_rx_post()
11707 hw_rq_t *rq = hw->hw_rq[rq_idx]; in ocs_hw_rx_post()
11709 for (i = 0; i < rq->entry_count-1; i++) { in ocs_hw_rx_post()
11710 ocs_hw_sequence_t *seq = ocs_array_get(hw->seq_pool, idx++); in ocs_hw_rx_post()
11713 seq->header = &rq->hdr_buf[i]; in ocs_hw_rx_post()
11715 seq->payload = &rq->payload_buf[i]; in ocs_hw_rx_post()
11743 for (i = 0; i < hw->hw_rq_count; i++) { in ocs_hw_rx_free()
11744 rq = hw->hw_rq[i]; in ocs_hw_rx_free()
11746 ocs_hw_rx_buffer_free(hw, rq->hdr_buf, rq->entry_count); in ocs_hw_rx_free()
11747 rq->hdr_buf = NULL; in ocs_hw_rx_free()
11748 ocs_hw_rx_buffer_free(hw, rq->payload_buf, rq->entry_count); in ocs_hw_rx_free()
11749 rq->payload_buf = NULL; in ocs_hw_rx_free()
11773 * @param arg Caller-provided argument.
11783 if (ctx->callback != NULL) { in ocs_hw_async_cb()
11784 (*ctx->callback)(hw, status, mqe, ctx->arg); in ocs_hw_async_cb()
11786 ocs_free(hw->os, ctx, sizeof(*ctx)); in ocs_hw_async_cb()
11799 * @param arg Caller-provided callback.
11813 ctx = ocs_malloc(hw->os, sizeof(*ctx), OCS_M_ZERO | OCS_M_NOWAIT); in ocs_hw_async_call()
11815 ocs_log_err(hw->os, "failed to malloc async call context\n"); in ocs_hw_async_call()
11818 ctx->callback = callback; in ocs_hw_async_call()
11819 ctx->arg = arg; in ocs_hw_async_call()
11822 if (sli_cmd_common_nop(&hw->sli, ctx->cmd, sizeof(ctx->cmd), 0) == 0) { in ocs_hw_async_call()
11823 ocs_log_err(hw->os, "COMMON_NOP format failure\n"); in ocs_hw_async_call()
11824 ocs_free(hw->os, ctx, sizeof(*ctx)); in ocs_hw_async_call()
11828 if (ocs_hw_command(hw, ctx->cmd, OCS_CMD_NOWAIT, ocs_hw_async_cb, ctx)) { in ocs_hw_async_call()
11829 ocs_log_err(hw->os, "COMMON_NOP command failure\n"); in ocs_hw_async_call()
11830 ocs_free(hw->os, ctx, sizeof(*ctx)); in ocs_hw_async_call()
11849 if (hw->wq_reqtag_pool == NULL) { in ocs_hw_reqtag_init()
11850 hw->wq_reqtag_pool = ocs_pool_alloc(hw->os, sizeof(hw_wq_callback_t), 65536, TRUE); in ocs_hw_reqtag_init()
11851 if (hw->wq_reqtag_pool == NULL) { in ocs_hw_reqtag_init()
11852 ocs_log_err(hw->os, "ocs_pool_alloc hw_wq_callback_t failed\n"); in ocs_hw_reqtag_init()
11878 wqcb = ocs_pool_get(hw->wq_reqtag_pool); in ocs_hw_reqtag_alloc()
11880 ocs_hw_assert(wqcb->callback == NULL); in ocs_hw_reqtag_alloc()
11881 wqcb->callback = callback; in ocs_hw_reqtag_alloc()
11882 wqcb->arg = arg; in ocs_hw_reqtag_alloc()
11900 ocs_hw_assert(wqcb->callback != NULL); in ocs_hw_reqtag_free()
11901 wqcb->callback = NULL; in ocs_hw_reqtag_free()
11902 wqcb->arg = NULL; in ocs_hw_reqtag_free()
11903 ocs_pool_put(hw->wq_reqtag_pool, wqcb); in ocs_hw_reqtag_free()
11922 wqcb = ocs_pool_get_instance(hw->wq_reqtag_pool, instance_index); in ocs_hw_reqtag_get_instance()
11924 ocs_log_err(hw->os, "wqcb for instance %d is null\n", instance_index); in ocs_hw_reqtag_get_instance()
11946 while(ocs_pool_get(hw->wq_reqtag_pool) != NULL) { in ocs_hw_reqtag_reset()
11951 for (i = 0; ((wqcb = ocs_pool_get_instance(hw->wq_reqtag_pool, i)) != NULL); i++) { in ocs_hw_reqtag_reset()
11952 wqcb->instance_index = i; in ocs_hw_reqtag_reset()
11953 wqcb->callback = NULL; in ocs_hw_reqtag_reset()
11954 wqcb->arg = NULL; in ocs_hw_reqtag_reset()
11955 ocs_pool_put(hw->wq_reqtag_pool, wqcb); in ocs_hw_reqtag_reset()
12005 * @return Return 0 if successful else returns -1
12014 ocs_list_add_tail(&hw->io_port_dnrx, io); in ocs_hw_reque_xri()
12015 rc = -1; in ocs_hw_reque_xri()
12019 io->auto_xfer_rdy_dnrx = 0; in ocs_hw_reque_xri()
12020 io->type = OCS_HW_IO_DNRX_REQUEUE; in ocs_hw_reque_xri()
12021 …if (sli_requeue_xri_wqe(&hw->sli, io->wqe.wqebuf, hw->sli.config.wqe_size, io->indicator, OCS_HW_R… in ocs_hw_reque_xri()
12023 ocs_pool_put(hw->auto_xfer_rdy_buf_pool, io->axr_buf); in ocs_hw_reque_xri()
12024 io->axr_buf = NULL; in ocs_hw_reque_xri()
12026 ocs_log_err(hw->os, "requeue_xri WQE error\n"); in ocs_hw_reque_xri()
12027 ocs_list_add_tail(&hw->io_port_dnrx, io); in ocs_hw_reque_xri()
12029 rc = -1; in ocs_hw_reque_xri()
12033 if (io->wq == NULL) { in ocs_hw_reque_xri()
12034 io->wq = ocs_hw_queue_next_wq(hw, io); in ocs_hw_reque_xri()
12035 ocs_hw_assert(io->wq != NULL); in ocs_hw_reque_xri()
12042 OCS_STAT(hw->tcmd_wq_submit[io->wq->instance]++); in ocs_hw_reque_xri()
12043 OCS_STAT(io->wq->use_count++); in ocs_hw_reque_xri()
12045 rc = hw_wq_write(io->wq, &io->wqe); in ocs_hw_reque_xri()
12047 ocs_log_err(hw->os, "sli_queue_write reque xri failed: %d\n", rc); in ocs_hw_reque_xri()
12048 rc = -1; in ocs_hw_reque_xri()
12058 sli4_t *sli4 = &ocs->hw.sli; in ocs_hw_get_def_wwn()
12062 int indicator = sli4->config.extent[SLI_RSRC_FCOE_VPI].base[0] + chan; in ocs_hw_get_def_wwn()
12070 if (0 == sli_cmd_read_sparm64(sli4, sli4->bmbx.virt, SLI4_BMBX_SIZE, in ocs_hw_get_def_wwn()
12094 sli4_t *sli = &hw->sli; in ocs_hw_get_config_persistent_topology()
12099 switch (sli->config.pt) { in ocs_hw_get_config_persistent_topology()
12134 * @return 0 on success, non-zero otherwise
12141 req->status = status; in ocs_hw_set_persistent_topolgy_cb()
12143 ocs_sem_v(&req->semaphore); in ocs_hw_set_persistent_topolgy_cb()
12159 * 1 Attempt point-to-point initialization (direct attach or Fabric topology).
12160 * 2 Attempt FC-AL loop initialization.
12164 * 0 Attempt FC-AL loop initialization; if it fails, attempt point-to-point initialization.
12165 * 1 Attempt point-to-point initialization; if it fails, attempt FC-AL loop initialization.
12174 * elxsdkutil set-topology cmd
12176 * @return Returns 0 on success, or a non-zero value on failure.
12191 if (sli_get_asic_type(&hw->sli) == SLI4_ASIC_TYPE_LANCER) { in ocs_hw_set_persistent_topology()
12211 ocs_log_err(hw->os, "unsupported topology %#x\n", topology); in ocs_hw_set_persistent_topology()
12212 return -1; in ocs_hw_set_persistent_topology()
12218 sli_cmd_common_set_features(&hw->sli, buf, SLI4_BMBX_SIZE, in ocs_hw_set_persistent_topology()
12224 ocs_log_err(hw->os, "Failed to set persistent topology, rc: %#x\n", rc); in ocs_hw_set_persistent_topology()
12232 ocs_log_err(hw->os, "Failed to set persistent topology, rc: %#x\n", rc); in ocs_hw_set_persistent_topology()
12237 ocs_log_err(hw->os, "ocs_sem_p failed\n"); in ocs_hw_set_persistent_topology()
12238 return -ENXIO; in ocs_hw_set_persistent_topology()
12242 ocs_log_err(hw->os, "set persistent topology failed; status: %d\n", request.status); in ocs_hw_set_persistent_topology()
12243 return -EFAULT; in ocs_hw_set_persistent_topology()
12247 sli_config_persistent_topology(&hw->sli, &param); in ocs_hw_set_persistent_topology()
12254 * - @ref devInitShutdown
12255 * - @ref domain
12256 * - @ref port
12257 * - @ref node
12258 * - @ref io
12259 * - @ref interrupt
12262 * The Hardware Abstraction Layer (HW) insulates the higher-level code from the SLI-4
12267 * The HW uses function callbacks to notify the higher-level code of events
12275 * the SLI-4 receive queue.</li>
12283 * The FC/FCoE HW component builds upon the SLI-4 component to establish a flexible
12286 * between a driver and the SLI-4 hardware. The broad categories of functionality include:
12288 * <ul><li>Setting-up and tearing-down of the HW.</li>
12297 * This step performs a basic configuration of the SLI-4 component and the HW to
12352 * includes using a position map, querying the fabric name server, or an out-of-band
12354 * Prior to sending login-related ELS commands (ocs_hw_srrs_send()), the driver must
12364 * The HW provides separate interfaces for sending BLS/ ELS/ FC-CT and FCP, but the
12368 * operations, but each operation must use a unique HW I/O object. In the SLI-4
12378 * To tear-down the HW:
12385 * </div><!-- overview -->
12394 * during ocs_hw_setup() (for example the MAX_QUEUE overrides for mis-reported queue
12399 * would have the driver look like: "if (hw->workaround.enable_xxx) then ...", rather than
12422 HW_WORKAROUND_DISABLE_AR_TGT_DIF, /**< Disable of auto-response target DIF */
12457 /* Bug: unknown, Lancer A0 has mis-reported max queue depth */
12461 /* Bug: 143399, BE3 has mis-reported max RQ queue depth */
12465 /* Bug: 143399, skyhawk has mis-reported max RQ queue depth */
12469 /* Bug: 103487, BE3 before f/w 4.2.314.0 has mis-reported WQE count method */
12473 /* Bug: 103487, BE3 before f/w 4.2.314.0 has mis-reported RQE count method */
12481 /* Bug: unknown, Skyhawk won't support auto-response on target T10-PI */
12572 return (((w->asic_type == SLI4_ASIC_TYPE_ANY) || (w->asic_type == hw->sli.asic_type)) && in ocs_hw_workaround_match()
12573 ((w->asic_rev == SLI4_ASIC_REV_ANY) || (w->asic_rev == hw->sli.asic_rev)) && in ocs_hw_workaround_match()
12574 (w->fwrev_low <= hw->workaround.fwrev) && in ocs_hw_workaround_match()
12575 ((w->fwrev_high == HW_FWREV_MAX) || (hw->workaround.fwrev < w->fwrev_high))); in ocs_hw_workaround_match()
12593 sli4_t *sli4 = &hw->sli; in ocs_hw_workaround_setup()
12597 ocs_memset(&hw->workaround, 0, sizeof(hw->workaround)); in ocs_hw_workaround_setup()
12599 /* If hw_war_version is non-null, then its a value that was set by a module parameter in ocs_hw_workaround_setup()
12603 if (hw->hw_war_version) { in ocs_hw_workaround_setup()
12604 hw->workaround.fwrev = parse_fw_version(hw->hw_war_version); in ocs_hw_workaround_setup()
12606 hw->workaround.fwrev = parse_fw_version((char*) sli4->config.fw_name[0]); in ocs_hw_workaround_setup()
12612 switch(w->workaround) { in ocs_hw_workaround_setup()
12614 ocs_log_debug(hw->os, "Override: test: %d\n", w->value); in ocs_hw_workaround_setup()
12619 ocs_log_debug(hw->os, "HW Workaround: retain TSEND IO length\n"); in ocs_hw_workaround_setup()
12620 hw->workaround.retain_tsend_io_length = 1; in ocs_hw_workaround_setup()
12626 ocs_log_debug(hw->os, "HW Workaround: override max_qentries: %d\n", w->value); in ocs_hw_workaround_setup()
12628 if (hw->num_qentries[q] > w->value) { in ocs_hw_workaround_setup()
12629 hw->num_qentries[q] = w->value; in ocs_hw_workaround_setup()
12635 ocs_log_debug(hw->os, "HW Workaround: override RQ max_qentries: %d\n", w->value); in ocs_hw_workaround_setup()
12636 if (hw->num_qentries[SLI_QTYPE_RQ] > w->value) { in ocs_hw_workaround_setup()
12637 hw->num_qentries[SLI_QTYPE_RQ] = w->value; in ocs_hw_workaround_setup()
12642 ocs_log_debug(hw->os, "HW Workaround: set WQE count method=%d\n", w->value); in ocs_hw_workaround_setup()
12643 sli4->config.count_method[SLI_QTYPE_WQ] = w->value; in ocs_hw_workaround_setup()
12648 ocs_log_debug(hw->os, "HW Workaround: set RQE count method=%d\n", w->value); in ocs_hw_workaround_setup()
12649 sli4->config.count_method[SLI_QTYPE_RQ] = w->value; in ocs_hw_workaround_setup()
12654 ocs_log_debug(hw->os, "HW Workaround: use unreg'd RPI if rnode->indicator == 0xFFFF\n"); in ocs_hw_workaround_setup()
12655 hw->workaround.use_unregistered_rpi = TRUE; in ocs_hw_workaround_setup()
12660 if (sli_resource_alloc(&hw->sli, SLI_RSRC_FCOE_RPI, &hw->workaround.unregistered_rid, in ocs_hw_workaround_setup()
12661 &hw->workaround.unregistered_index)) { in ocs_hw_workaround_setup()
12662 ocs_log_err(hw->os, "sli_resource_alloc unregistered RPI failed\n"); in ocs_hw_workaround_setup()
12663 hw->workaround.use_unregistered_rpi = FALSE; in ocs_hw_workaround_setup()
12667 ocs_log_debug(hw->os, "HW Workaround: disable AR on T10-PI TSEND\n"); in ocs_hw_workaround_setup()
12668 hw->workaround.disable_ar_tgt_dif = TRUE; in ocs_hw_workaround_setup()
12671 ocs_log_debug(hw->os, "HW Workaround: disable set_dump_loc\n"); in ocs_hw_workaround_setup()
12672 hw->workaround.disable_dump_loc = TRUE; in ocs_hw_workaround_setup()
12675 ocs_log_debug(hw->os, "HW Workaround: use DIF quarantine\n"); in ocs_hw_workaround_setup()
12676 hw->workaround.use_dif_quarantine = TRUE; in ocs_hw_workaround_setup()
12679 ocs_log_debug(hw->os, "HW Workaround: use DIF secondary xri\n"); in ocs_hw_workaround_setup()
12680 hw->workaround.use_dif_sec_xri = TRUE; in ocs_hw_workaround_setup()
12683 ocs_log_debug(hw->os, "HW Workaround: override FCFI in SRB\n"); in ocs_hw_workaround_setup()
12684 hw->workaround.override_fcfi = TRUE; in ocs_hw_workaround_setup()
12688 ocs_log_debug(hw->os, "HW Workaround: fw version is below the minimum for this driver\n"); in ocs_hw_workaround_setup()
12689 hw->workaround.fw_version_too_low = TRUE; in ocs_hw_workaround_setup()
12692 ocs_log_debug(hw->os, "HW Workaround: SGLC misreported - chaining is enabled\n"); in ocs_hw_workaround_setup()
12693 hw->workaround.sglc_misreported = TRUE; in ocs_hw_workaround_setup()
12696 ocs_log_debug(hw->os, "HW Workaround: not SEND_FRAME capable - disabled\n"); in ocs_hw_workaround_setup()
12697 hw->workaround.ignore_send_frame = TRUE; in ocs_hw_workaround_setup()
12699 } /* switch(w->workaround) */ in ocs_hw_workaround_setup()