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