Lines Matching +full:master +full:- +full:stats
4 * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved.
16 * - Redistributions of source code must retain the above
20 * - Redistributions in binary form must reproduce the above
51 * csio_mb_fw_retval - FW return value from a mailbox response.
60 hdr = (struct fw_cmd_hdr *)(mbp->mb); in csio_mb_fw_retval()
62 return FW_CMD_RETVAL_G(ntohl(hdr->lo)); in csio_mb_fw_retval()
66 * csio_mb_hello - FW HELLO command helper
69 * @m_mbox: Master mailbox number, if any.
71 * @master: Device mastership.
77 uint32_t m_mbox, uint32_t a_mbox, enum csio_dev_master master, in csio_mb_hello() argument
80 struct fw_hello_cmd *cmdp = (struct fw_hello_cmd *)(mbp->mb); in csio_mb_hello()
84 cmdp->op_to_write = htonl(FW_CMD_OP_V(FW_HELLO_CMD) | in csio_mb_hello()
86 cmdp->retval_len16 = htonl(FW_CMD_LEN16_V(sizeof(*cmdp) / 16)); in csio_mb_hello()
87 cmdp->err_to_clearinit = htonl( in csio_mb_hello()
88 FW_HELLO_CMD_MASTERDIS_V(master == CSIO_MASTER_CANT) | in csio_mb_hello()
89 FW_HELLO_CMD_MASTERFORCE_V(master == CSIO_MASTER_MUST) | in csio_mb_hello()
90 FW_HELLO_CMD_MBMASTER_V(master == CSIO_MASTER_MUST ? in csio_mb_hello()
99 * csio_mb_process_hello_rsp - FW HELLO response processing helper
104 * @mpfn: Master pfn
112 struct fw_hello_cmd *rsp = (struct fw_hello_cmd *)(mbp->mb); in csio_mb_process_hello_rsp()
115 *retval = FW_CMD_RETVAL_G(ntohl(rsp->retval_len16)); in csio_mb_process_hello_rsp()
118 hw->fwrev = ntohl(rsp->fwrev); in csio_mb_process_hello_rsp()
120 value = ntohl(rsp->err_to_clearinit); in csio_mb_process_hello_rsp()
133 * csio_mb_bye - FW BYE command helper
143 struct fw_bye_cmd *cmdp = (struct fw_bye_cmd *)(mbp->mb); in csio_mb_bye()
147 cmdp->op_to_write = htonl(FW_CMD_OP_V(FW_BYE_CMD) | in csio_mb_bye()
149 cmdp->retval_len16 = htonl(FW_CMD_LEN16_V(sizeof(*cmdp) / 16)); in csio_mb_bye()
154 * csio_mb_reset - FW RESET command helper
166 struct fw_reset_cmd *cmdp = (struct fw_reset_cmd *)(mbp->mb); in csio_mb_reset()
170 cmdp->op_to_write = htonl(FW_CMD_OP_V(FW_RESET_CMD) | in csio_mb_reset()
172 cmdp->retval_len16 = htonl(FW_CMD_LEN16_V(sizeof(*cmdp) / 16)); in csio_mb_reset()
173 cmdp->val = htonl(reset); in csio_mb_reset()
174 cmdp->halt_pkd = htonl(halt); in csio_mb_reset()
179 * csio_mb_params - FW PARAMS command helper
200 struct fw_params_cmd *cmdp = (struct fw_params_cmd *)(mbp->mb); in csio_mb_params()
201 __be32 *p = &cmdp->param[0].mnem; in csio_mb_params()
205 cmdp->op_to_vfn = htonl(FW_CMD_OP_V(FW_PARAMS_CMD) | in csio_mb_params()
210 cmdp->retval_len16 = htonl(FW_CMD_LEN16_V(sizeof(*cmdp) / 16)); in csio_mb_params()
214 while (nparams--) { in csio_mb_params()
231 * csio_mb_process_read_params_rsp - FW PARAMS response processing helper
244 struct fw_params_cmd *rsp = (struct fw_params_cmd *)(mbp->mb); in csio_mb_process_read_params_rsp()
246 __be32 *p = &rsp->param[0].val; in csio_mb_process_read_params_rsp()
248 *retval = FW_CMD_RETVAL_G(ntohl(rsp->retval_len16)); in csio_mb_process_read_params_rsp()
256 * csio_mb_ldst - FW LDST command
266 struct fw_ldst_cmd *ldst_cmd = (struct fw_ldst_cmd *)(mbp->mb); in csio_mb_ldst()
271 * specified PCI-E Configuration Space register. in csio_mb_ldst()
273 ldst_cmd->op_to_addrspace = in csio_mb_ldst()
278 ldst_cmd->cycles_to_len16 = htonl(FW_LEN16(struct fw_ldst_cmd)); in csio_mb_ldst()
279 ldst_cmd->u.pcie.select_naccess = FW_LDST_CMD_NACCESS_V(1); in csio_mb_ldst()
280 ldst_cmd->u.pcie.ctrl_to_fn = in csio_mb_ldst()
281 (FW_LDST_CMD_LC_F | FW_LDST_CMD_FN_V(hw->pfn)); in csio_mb_ldst()
282 ldst_cmd->u.pcie.r = (uint8_t)reg; in csio_mb_ldst()
287 * csio_mb_caps_config - FW Read/Write Capabilities command helper
305 (struct fw_caps_config_cmd *)(mbp->mb); in csio_mb_caps_config()
309 cmdp->op_to_write = htonl(FW_CMD_OP_V(FW_CAPS_CONFIG_CMD) | in csio_mb_caps_config()
312 cmdp->cfvalid_to_len16 = htonl(FW_CMD_LEN16_V(sizeof(*cmdp) / 16)); in csio_mb_caps_config()
319 cmdp->fcoecaps = 0; in csio_mb_caps_config()
322 cmdp->fcoecaps |= htons(FW_CAPS_CONFIG_FCOE_CTRL_OFLD); in csio_mb_caps_config()
324 cmdp->fcoecaps |= htons(FW_CAPS_CONFIG_FCOE_INITIATOR); in csio_mb_caps_config()
326 cmdp->fcoecaps |= htons(FW_CAPS_CONFIG_FCOE_TARGET); in csio_mb_caps_config()
330 * csio_mb_port- FW PORT command helper
346 struct fw_port_cmd *cmdp = (struct fw_port_cmd *)(mbp->mb); in csio_mb_port()
350 cmdp->op_to_portid = htonl(FW_CMD_OP_V(FW_PORT_CMD) | in csio_mb_port()
355 cmdp->action_to_len16 = htonl( in csio_mb_port()
364 cmdp->action_to_len16 = htonl( in csio_mb_port()
371 cmdp->u.l1cfg.rcap = cpu_to_be32(fwcaps32_to_caps16(fc)); in csio_mb_port()
373 cmdp->u.l1cfg32.rcap32 = cpu_to_be32(fc); in csio_mb_port()
377 * csio_mb_process_read_port_rsp - FW PORT command response processing helper
389 struct fw_port_cmd *rsp = (struct fw_port_cmd *)(mbp->mb); in csio_mb_process_read_port_rsp()
391 *retval = FW_CMD_RETVAL_G(ntohl(rsp->action_to_len16)); in csio_mb_process_read_port_rsp()
395 *pcaps = fwcaps16_to_caps32(ntohs(rsp->u.info.pcap)); in csio_mb_process_read_port_rsp()
396 *acaps = fwcaps16_to_caps32(ntohs(rsp->u.info.acap)); in csio_mb_process_read_port_rsp()
398 *pcaps = be32_to_cpu(rsp->u.info32.pcaps32); in csio_mb_process_read_port_rsp()
399 *acaps = be32_to_cpu(rsp->u.info32.acaps32); in csio_mb_process_read_port_rsp()
405 * csio_mb_initialize - FW INITIALIZE command helper
416 struct fw_initialize_cmd *cmdp = (struct fw_initialize_cmd *)(mbp->mb); in csio_mb_initialize()
420 cmdp->op_to_write = htonl(FW_CMD_OP_V(FW_INITIALIZE_CMD) | in csio_mb_initialize()
422 cmdp->retval_len16 = htonl(FW_CMD_LEN16_V(sizeof(*cmdp) / 16)); in csio_mb_initialize()
427 * csio_mb_iq_alloc - Initializes the mailbox to allocate an
433 * @mb_tmo: Mailbox time-out period (in ms).
435 * @cbfn: The call-back function
444 struct fw_iq_cmd *cmdp = (struct fw_iq_cmd *)(mbp->mb); in csio_mb_iq_alloc()
448 cmdp->op_to_vfn = htonl(FW_CMD_OP_V(FW_IQ_CMD) | in csio_mb_iq_alloc()
450 FW_IQ_CMD_PFN_V(iq_params->pfn) | in csio_mb_iq_alloc()
451 FW_IQ_CMD_VFN_V(iq_params->vfn)); in csio_mb_iq_alloc()
453 cmdp->alloc_to_len16 = htonl(FW_IQ_CMD_ALLOC_F | in csio_mb_iq_alloc()
456 cmdp->type_to_iqandstindex = htonl( in csio_mb_iq_alloc()
457 FW_IQ_CMD_VIID_V(iq_params->viid) | in csio_mb_iq_alloc()
458 FW_IQ_CMD_TYPE_V(iq_params->type) | in csio_mb_iq_alloc()
459 FW_IQ_CMD_IQASYNCH_V(iq_params->iqasynch)); in csio_mb_iq_alloc()
461 cmdp->fl0size = htons(iq_params->fl0size); in csio_mb_iq_alloc()
462 cmdp->fl0size = htons(iq_params->fl1size); in csio_mb_iq_alloc()
467 * csio_mb_iq_write - Initializes the mailbox for writing into an
473 * @mb_tmo: Mailbox time-out period (in ms).
474 * @cascaded_req: TRUE - if this request is cascased with iq-alloc request.
476 * @cbfn: The call-back function
478 * NOTE: We OR relevant bits with cmdp->XXX, instead of just equating,
480 * IQ alloc request, and we dont want to over-write the bits set by
481 * that request. This logic will work even in a non-cascaded case, since the
490 struct fw_iq_cmd *cmdp = (struct fw_iq_cmd *)(mbp->mb); in csio_mb_iq_write()
492 uint32_t iq_start_stop = (iq_params->iq_start) ? in csio_mb_iq_write()
495 int relaxed = !(hw->flags & CSIO_HWF_ROOT_NO_RELAXED_ORDERING); in csio_mb_iq_write()
499 * re-initialize with 0's. in csio_mb_iq_write()
505 cmdp->op_to_vfn |= htonl(FW_CMD_OP_V(FW_IQ_CMD) | in csio_mb_iq_write()
507 FW_IQ_CMD_PFN_V(iq_params->pfn) | in csio_mb_iq_write()
508 FW_IQ_CMD_VFN_V(iq_params->vfn)); in csio_mb_iq_write()
509 cmdp->alloc_to_len16 |= htonl(iq_start_stop | in csio_mb_iq_write()
511 cmdp->iqid |= htons(iq_params->iqid); in csio_mb_iq_write()
512 cmdp->fl0id |= htons(iq_params->fl0id); in csio_mb_iq_write()
513 cmdp->fl1id |= htons(iq_params->fl1id); in csio_mb_iq_write()
514 cmdp->type_to_iqandstindex |= htonl( in csio_mb_iq_write()
515 FW_IQ_CMD_IQANDST_V(iq_params->iqandst) | in csio_mb_iq_write()
516 FW_IQ_CMD_IQANUS_V(iq_params->iqanus) | in csio_mb_iq_write()
517 FW_IQ_CMD_IQANUD_V(iq_params->iqanud) | in csio_mb_iq_write()
518 FW_IQ_CMD_IQANDSTINDEX_V(iq_params->iqandstindex)); in csio_mb_iq_write()
519 cmdp->iqdroprss_to_iqesize |= htons( in csio_mb_iq_write()
520 FW_IQ_CMD_IQPCIECH_V(iq_params->iqpciech) | in csio_mb_iq_write()
521 FW_IQ_CMD_IQDCAEN_V(iq_params->iqdcaen) | in csio_mb_iq_write()
522 FW_IQ_CMD_IQDCACPU_V(iq_params->iqdcacpu) | in csio_mb_iq_write()
523 FW_IQ_CMD_IQINTCNTTHRESH_V(iq_params->iqintcntthresh) | in csio_mb_iq_write()
524 FW_IQ_CMD_IQCPRIO_V(iq_params->iqcprio) | in csio_mb_iq_write()
525 FW_IQ_CMD_IQESIZE_V(iq_params->iqesize)); in csio_mb_iq_write()
527 cmdp->iqsize |= htons(iq_params->iqsize); in csio_mb_iq_write()
528 cmdp->iqaddr |= cpu_to_be64(iq_params->iqaddr); in csio_mb_iq_write()
530 if (iq_params->type == 0) { in csio_mb_iq_write()
531 cmdp->iqns_to_fl0congen |= htonl( in csio_mb_iq_write()
532 FW_IQ_CMD_IQFLINTIQHSEN_V(iq_params->iqflintiqhsen)| in csio_mb_iq_write()
533 FW_IQ_CMD_IQFLINTCONGEN_V(iq_params->iqflintcongen)); in csio_mb_iq_write()
536 if (iq_params->fl0size && iq_params->fl0addr && in csio_mb_iq_write()
537 (iq_params->fl0id != 0xFFFF)) { in csio_mb_iq_write()
539 cmdp->iqns_to_fl0congen |= htonl( in csio_mb_iq_write()
540 FW_IQ_CMD_FL0HOSTFCMODE_V(iq_params->fl0hostfcmode)| in csio_mb_iq_write()
541 FW_IQ_CMD_FL0CPRIO_V(iq_params->fl0cprio) | in csio_mb_iq_write()
544 FW_IQ_CMD_FL0PADEN_V(iq_params->fl0paden) | in csio_mb_iq_write()
545 FW_IQ_CMD_FL0PACKEN_V(iq_params->fl0packen)); in csio_mb_iq_write()
546 cmdp->fl0dcaen_to_fl0cidxfthresh |= htons( in csio_mb_iq_write()
547 FW_IQ_CMD_FL0DCAEN_V(iq_params->fl0dcaen) | in csio_mb_iq_write()
548 FW_IQ_CMD_FL0DCACPU_V(iq_params->fl0dcacpu) | in csio_mb_iq_write()
549 FW_IQ_CMD_FL0FBMIN_V(iq_params->fl0fbmin) | in csio_mb_iq_write()
550 FW_IQ_CMD_FL0FBMAX_V(iq_params->fl0fbmax) | in csio_mb_iq_write()
551 FW_IQ_CMD_FL0CIDXFTHRESH_V(iq_params->fl0cidxfthresh)); in csio_mb_iq_write()
552 cmdp->fl0size |= htons(iq_params->fl0size); in csio_mb_iq_write()
553 cmdp->fl0addr |= cpu_to_be64(iq_params->fl0addr); in csio_mb_iq_write()
558 * csio_mb_iq_alloc_write - Initializes the mailbox for allocating an
564 * @mb_tmo: Mailbox time-out period (in ms).
566 * @cbfn: The call-back function
580 * csio_mb_iq_alloc_write_rsp - Process the allocation & writing
594 struct fw_iq_cmd *rsp = (struct fw_iq_cmd *)(mbp->mb); in csio_mb_iq_alloc_write_rsp()
596 *ret_val = FW_CMD_RETVAL_G(ntohl(rsp->alloc_to_len16)); in csio_mb_iq_alloc_write_rsp()
598 iq_params->physiqid = ntohs(rsp->physiqid); in csio_mb_iq_alloc_write_rsp()
599 iq_params->iqid = ntohs(rsp->iqid); in csio_mb_iq_alloc_write_rsp()
600 iq_params->fl0id = ntohs(rsp->fl0id); in csio_mb_iq_alloc_write_rsp()
601 iq_params->fl1id = ntohs(rsp->fl1id); in csio_mb_iq_alloc_write_rsp()
603 iq_params->physiqid = iq_params->iqid = in csio_mb_iq_alloc_write_rsp()
604 iq_params->fl0id = iq_params->fl1id = 0; in csio_mb_iq_alloc_write_rsp()
609 * csio_mb_iq_free - Initializes the mailbox for freeing a
615 * @mb_tmo: Mailbox time-out period (in ms).
617 * @cbfn: The call-back function
626 struct fw_iq_cmd *cmdp = (struct fw_iq_cmd *)(mbp->mb); in csio_mb_iq_free()
630 cmdp->op_to_vfn = htonl(FW_CMD_OP_V(FW_IQ_CMD) | in csio_mb_iq_free()
632 FW_IQ_CMD_PFN_V(iq_params->pfn) | in csio_mb_iq_free()
633 FW_IQ_CMD_VFN_V(iq_params->vfn)); in csio_mb_iq_free()
634 cmdp->alloc_to_len16 = htonl(FW_IQ_CMD_FREE_F | in csio_mb_iq_free()
636 cmdp->type_to_iqandstindex = htonl(FW_IQ_CMD_TYPE_V(iq_params->type)); in csio_mb_iq_free()
638 cmdp->iqid = htons(iq_params->iqid); in csio_mb_iq_free()
639 cmdp->fl0id = htons(iq_params->fl0id); in csio_mb_iq_free()
640 cmdp->fl1id = htons(iq_params->fl1id); in csio_mb_iq_free()
645 * csio_mb_eq_ofld_alloc - Initializes the mailbox for allocating
646 * an offload-egress queue.
651 * @mb_tmo: Mailbox time-out period (in ms).
653 * @cbfn: The call-back function
662 struct fw_eq_ofld_cmd *cmdp = (struct fw_eq_ofld_cmd *)(mbp->mb); in csio_mb_eq_ofld_alloc()
665 cmdp->op_to_vfn = htonl(FW_CMD_OP_V(FW_EQ_OFLD_CMD) | in csio_mb_eq_ofld_alloc()
667 FW_EQ_OFLD_CMD_PFN_V(eq_ofld_params->pfn) | in csio_mb_eq_ofld_alloc()
668 FW_EQ_OFLD_CMD_VFN_V(eq_ofld_params->vfn)); in csio_mb_eq_ofld_alloc()
669 cmdp->alloc_to_len16 = htonl(FW_EQ_OFLD_CMD_ALLOC_F | in csio_mb_eq_ofld_alloc()
675 * csio_mb_eq_ofld_write - Initializes the mailbox for writing
676 * an alloacted offload-egress queue.
681 * @mb_tmo: Mailbox time-out period (in ms).
682 * @cascaded_req: TRUE - if this request is cascased with Eq-alloc request.
684 * @cbfn: The call-back function
687 * NOTE: We OR relevant bits with cmdp->XXX, instead of just equating,
689 * EQ alloc request, and we dont want to over-write the bits set by
690 * that request. This logic will work even in a non-cascaded case, since the
699 struct fw_eq_ofld_cmd *cmdp = (struct fw_eq_ofld_cmd *)(mbp->mb); in csio_mb_eq_ofld_write()
701 uint32_t eq_start_stop = (eq_ofld_params->eqstart) ? in csio_mb_eq_ofld_write()
707 * re-initialize with 0's. in csio_mb_eq_ofld_write()
713 cmdp->op_to_vfn |= htonl(FW_CMD_OP_V(FW_EQ_OFLD_CMD) | in csio_mb_eq_ofld_write()
715 FW_EQ_OFLD_CMD_PFN_V(eq_ofld_params->pfn) | in csio_mb_eq_ofld_write()
716 FW_EQ_OFLD_CMD_VFN_V(eq_ofld_params->vfn)); in csio_mb_eq_ofld_write()
717 cmdp->alloc_to_len16 |= htonl(eq_start_stop | in csio_mb_eq_ofld_write()
720 cmdp->eqid_pkd |= htonl(FW_EQ_OFLD_CMD_EQID_V(eq_ofld_params->eqid)); in csio_mb_eq_ofld_write()
722 cmdp->fetchszm_to_iqid |= htonl( in csio_mb_eq_ofld_write()
723 FW_EQ_OFLD_CMD_HOSTFCMODE_V(eq_ofld_params->hostfcmode) | in csio_mb_eq_ofld_write()
724 FW_EQ_OFLD_CMD_CPRIO_V(eq_ofld_params->cprio) | in csio_mb_eq_ofld_write()
725 FW_EQ_OFLD_CMD_PCIECHN_V(eq_ofld_params->pciechn) | in csio_mb_eq_ofld_write()
726 FW_EQ_OFLD_CMD_IQID_V(eq_ofld_params->iqid)); in csio_mb_eq_ofld_write()
728 cmdp->dcaen_to_eqsize |= htonl( in csio_mb_eq_ofld_write()
729 FW_EQ_OFLD_CMD_DCAEN_V(eq_ofld_params->dcaen) | in csio_mb_eq_ofld_write()
730 FW_EQ_OFLD_CMD_DCACPU_V(eq_ofld_params->dcacpu) | in csio_mb_eq_ofld_write()
731 FW_EQ_OFLD_CMD_FBMIN_V(eq_ofld_params->fbmin) | in csio_mb_eq_ofld_write()
732 FW_EQ_OFLD_CMD_FBMAX_V(eq_ofld_params->fbmax) | in csio_mb_eq_ofld_write()
733 FW_EQ_OFLD_CMD_CIDXFTHRESHO_V(eq_ofld_params->cidxfthresho) | in csio_mb_eq_ofld_write()
734 FW_EQ_OFLD_CMD_CIDXFTHRESH_V(eq_ofld_params->cidxfthresh) | in csio_mb_eq_ofld_write()
735 FW_EQ_OFLD_CMD_EQSIZE_V(eq_ofld_params->eqsize)); in csio_mb_eq_ofld_write()
737 cmdp->eqaddr |= cpu_to_be64(eq_ofld_params->eqaddr); in csio_mb_eq_ofld_write()
742 * csio_mb_eq_ofld_alloc_write - Initializes the mailbox for allocation
748 * @mb_tmo: Mailbox time-out period (in ms).
750 * @cbfn: The call-back function
766 * csio_mb_eq_ofld_alloc_write_rsp - Process the allocation
780 struct fw_eq_ofld_cmd *rsp = (struct fw_eq_ofld_cmd *)(mbp->mb); in csio_mb_eq_ofld_alloc_write_rsp()
782 *ret_val = FW_CMD_RETVAL_G(ntohl(rsp->alloc_to_len16)); in csio_mb_eq_ofld_alloc_write_rsp()
785 eq_ofld_params->eqid = FW_EQ_OFLD_CMD_EQID_G( in csio_mb_eq_ofld_alloc_write_rsp()
786 ntohl(rsp->eqid_pkd)); in csio_mb_eq_ofld_alloc_write_rsp()
787 eq_ofld_params->physeqid = FW_EQ_OFLD_CMD_PHYSEQID_G( in csio_mb_eq_ofld_alloc_write_rsp()
788 ntohl(rsp->physeqid_pkd)); in csio_mb_eq_ofld_alloc_write_rsp()
790 eq_ofld_params->eqid = 0; in csio_mb_eq_ofld_alloc_write_rsp()
795 * csio_mb_eq_ofld_free - Initializes the mailbox for freeing a
801 * @mb_tmo: Mailbox time-out period (in ms).
803 * @cbfn: The call-back function
812 struct fw_eq_ofld_cmd *cmdp = (struct fw_eq_ofld_cmd *)(mbp->mb); in csio_mb_eq_ofld_free()
816 cmdp->op_to_vfn = htonl(FW_CMD_OP_V(FW_EQ_OFLD_CMD) | in csio_mb_eq_ofld_free()
818 FW_EQ_OFLD_CMD_PFN_V(eq_ofld_params->pfn) | in csio_mb_eq_ofld_free()
819 FW_EQ_OFLD_CMD_VFN_V(eq_ofld_params->vfn)); in csio_mb_eq_ofld_free()
820 cmdp->alloc_to_len16 = htonl(FW_EQ_OFLD_CMD_FREE_F | in csio_mb_eq_ofld_free()
822 cmdp->eqid_pkd = htonl(FW_EQ_OFLD_CMD_EQID_V(eq_ofld_params->eqid)); in csio_mb_eq_ofld_free()
827 * csio_write_fcoe_link_cond_init_mb - Initialize Mailbox to write FCoE link
832 * @mb_tmo: Mailbox time-out period (in ms).
844 (struct fw_fcoe_link_cmd *)(mbp->mb); in csio_write_fcoe_link_cond_init_mb()
848 cmdp->op_to_portid = htonl(( in csio_write_fcoe_link_cond_init_mb()
853 cmdp->sub_opcode_fcfi = htonl( in csio_write_fcoe_link_cond_init_mb()
856 cmdp->lstatus = link_status; in csio_write_fcoe_link_cond_init_mb()
857 cmdp->retval_len16 = htonl(FW_CMD_LEN16_V(sizeof(*cmdp) / 16)); in csio_write_fcoe_link_cond_init_mb()
862 * csio_fcoe_read_res_info_init_mb - Initializes the mailbox for reading FCoE
867 * @mb_tmo: Mailbox time-out period (in ms).
868 * @cbfn: The call-back function
878 (struct fw_fcoe_res_info_cmd *)(mbp->mb); in csio_fcoe_read_res_info_init_mb()
882 cmdp->op_to_read = htonl((FW_CMD_OP_V(FW_FCOE_RES_INFO_CMD) | in csio_fcoe_read_res_info_init_mb()
886 cmdp->retval_len16 = htonl(FW_CMD_LEN16_V(sizeof(*cmdp) / 16)); in csio_fcoe_read_res_info_init_mb()
891 * csio_fcoe_vnp_alloc_init_mb - Initializes the mailbox for allocating VNP
896 * @mb_tmo: Mailbox time-out period (in ms).
902 * @cbfn: The call-back function.
913 (struct fw_fcoe_vnp_cmd *)(mbp->mb); in csio_fcoe_vnp_alloc_init_mb()
917 cmdp->op_to_fcfi = htonl((FW_CMD_OP_V(FW_FCOE_VNP_CMD) | in csio_fcoe_vnp_alloc_init_mb()
922 cmdp->alloc_to_len16 = htonl(FW_FCOE_VNP_CMD_ALLOC | in csio_fcoe_vnp_alloc_init_mb()
925 cmdp->gen_wwn_to_vnpi = htonl(FW_FCOE_VNP_CMD_VNPI(vnpi)); in csio_fcoe_vnp_alloc_init_mb()
927 cmdp->iqid = htons(iqid); in csio_fcoe_vnp_alloc_init_mb()
930 cmdp->gen_wwn_to_vnpi |= htonl(FW_FCOE_VNP_CMD_GEN_WWN); in csio_fcoe_vnp_alloc_init_mb()
933 memcpy(cmdp->vnport_wwnn, vnport_wwnn, 8); in csio_fcoe_vnp_alloc_init_mb()
935 memcpy(cmdp->vnport_wwpn, vnport_wwpn, 8); in csio_fcoe_vnp_alloc_init_mb()
940 * csio_fcoe_vnp_read_init_mb - Prepares VNP read cmd.
943 * @mb_tmo: Mailbox time-out period (in ms).
946 * @cbfn: The call-back handler.
954 (struct fw_fcoe_vnp_cmd *)(mbp->mb); in csio_fcoe_vnp_read_init_mb()
957 cmdp->op_to_fcfi = htonl(FW_CMD_OP_V(FW_FCOE_VNP_CMD) | in csio_fcoe_vnp_read_init_mb()
961 cmdp->alloc_to_len16 = htonl(FW_CMD_LEN16_V(sizeof(*cmdp) / 16)); in csio_fcoe_vnp_read_init_mb()
962 cmdp->gen_wwn_to_vnpi = htonl(FW_FCOE_VNP_CMD_VNPI(vnpi)); in csio_fcoe_vnp_read_init_mb()
966 * csio_fcoe_vnp_free_init_mb - Initializes the mailbox for freeing an
971 * @mb_tmo: Mailbox time-out period (in ms).
974 * @cbfn: The call-back function.
983 (struct fw_fcoe_vnp_cmd *)(mbp->mb); in csio_fcoe_vnp_free_init_mb()
987 cmdp->op_to_fcfi = htonl(FW_CMD_OP_V(FW_FCOE_VNP_CMD) | in csio_fcoe_vnp_free_init_mb()
991 cmdp->alloc_to_len16 = htonl(FW_FCOE_VNP_CMD_FREE | in csio_fcoe_vnp_free_init_mb()
993 cmdp->gen_wwn_to_vnpi = htonl(FW_FCOE_VNP_CMD_VNPI(vnpi)); in csio_fcoe_vnp_free_init_mb()
997 * csio_fcoe_read_fcf_init_mb - Initializes the mailbox to read the
1002 * @mb_tmo: Mailbox time-out period (in ms).
1003 * @fcf_params: FC-Forwarder parameters.
1004 * @cbfn: The call-back function
1014 (struct fw_fcoe_fcf_cmd *)(mbp->mb); in csio_fcoe_read_fcf_init_mb()
1018 cmdp->op_to_fcfi = htonl(FW_CMD_OP_V(FW_FCOE_FCF_CMD) | in csio_fcoe_read_fcf_init_mb()
1022 cmdp->retval_len16 = htonl(FW_CMD_LEN16_V(sizeof(*cmdp) / 16)); in csio_fcoe_read_fcf_init_mb()
1033 struct fw_fcoe_stats_cmd *cmdp = (struct fw_fcoe_stats_cmd *)(mbp->mb); in csio_fcoe_read_portparams_init_mb()
1036 mbp->mb_size = 64; in csio_fcoe_read_portparams_init_mb()
1038 cmdp->op_to_flowid = htonl(FW_CMD_OP_V(FW_FCOE_STATS_CMD) | in csio_fcoe_read_portparams_init_mb()
1040 cmdp->free_to_len16 = htonl(FW_CMD_LEN16_V(CSIO_MAX_MB_SIZE/16)); in csio_fcoe_read_portparams_init_mb()
1042 cmdp->u.ctl.nstats_port = FW_FCOE_STATS_CMD_NSTATS(portparams->nstats) | in csio_fcoe_read_portparams_init_mb()
1043 FW_FCOE_STATS_CMD_PORT(portparams->portid); in csio_fcoe_read_portparams_init_mb()
1045 cmdp->u.ctl.port_valid_ix = FW_FCOE_STATS_CMD_IX(portparams->idx) | in csio_fcoe_read_portparams_init_mb()
1057 struct fw_fcoe_stats_cmd *rsp = (struct fw_fcoe_stats_cmd *)(mbp->mb); in csio_mb_process_portparams_rsp()
1058 struct fw_fcoe_port_stats stats; in csio_mb_process_portparams_rsp() local
1062 *retval = FW_CMD_RETVAL_G(ntohl(rsp->free_to_len16)); in csio_mb_process_portparams_rsp()
1064 memset(&stats, 0, sizeof(struct fw_fcoe_port_stats)); in csio_mb_process_portparams_rsp()
1067 dst = (uint8_t *)(&stats) + ((portparams->idx - 1) * 8); in csio_mb_process_portparams_rsp()
1069 memcpy(dst, src, (portparams->nstats * 8)); in csio_mb_process_portparams_rsp()
1070 if (portparams->idx == 1) { in csio_mb_process_portparams_rsp()
1072 portstats->tx_bcast_bytes = stats.tx_bcast_bytes; in csio_mb_process_portparams_rsp()
1073 portstats->tx_bcast_frames = stats.tx_bcast_frames; in csio_mb_process_portparams_rsp()
1074 portstats->tx_mcast_bytes = stats.tx_mcast_bytes; in csio_mb_process_portparams_rsp()
1075 portstats->tx_mcast_frames = stats.tx_mcast_frames; in csio_mb_process_portparams_rsp()
1076 portstats->tx_ucast_bytes = stats.tx_ucast_bytes; in csio_mb_process_portparams_rsp()
1077 portstats->tx_ucast_frames = stats.tx_ucast_frames; in csio_mb_process_portparams_rsp()
1079 if (portparams->idx == 7) { in csio_mb_process_portparams_rsp()
1081 portstats->tx_drop_frames = stats.tx_drop_frames; in csio_mb_process_portparams_rsp()
1082 portstats->tx_offload_bytes = stats.tx_offload_bytes; in csio_mb_process_portparams_rsp()
1083 portstats->tx_offload_frames = stats.tx_offload_frames; in csio_mb_process_portparams_rsp()
1085 portstats->rx_pf_bytes = stats.rx_pf_bytes; in csio_mb_process_portparams_rsp()
1086 portstats->rx_pf_frames = stats.rx_pf_frames; in csio_mb_process_portparams_rsp()
1088 portstats->rx_bcast_bytes = stats.rx_bcast_bytes; in csio_mb_process_portparams_rsp()
1089 portstats->rx_bcast_frames = stats.rx_bcast_frames; in csio_mb_process_portparams_rsp()
1090 portstats->rx_mcast_bytes = stats.rx_mcast_bytes; in csio_mb_process_portparams_rsp()
1092 if (portparams->idx == 13) { in csio_mb_process_portparams_rsp()
1094 portstats->rx_mcast_frames = stats.rx_mcast_frames; in csio_mb_process_portparams_rsp()
1095 portstats->rx_ucast_bytes = stats.rx_ucast_bytes; in csio_mb_process_portparams_rsp()
1096 portstats->rx_ucast_frames = stats.rx_ucast_frames; in csio_mb_process_portparams_rsp()
1097 portstats->rx_err_frames = stats.rx_err_frames; in csio_mb_process_portparams_rsp()
1104 * csio_mb_intr_enable - Enable Interrupts from mailboxes.
1117 * csio_mb_intr_disable - Disable Interrupts from mailboxes.
1135 if ((FW_DEBUG_CMD_TYPE_G(ntohl(dbg->op_type))) == 1) { in csio_mb_dump_fw_dbg()
1137 csio_info(hw, "\tdebug->dprtstridx = %d\n", in csio_mb_dump_fw_dbg()
1138 ntohs(dbg->u.prt.dprtstridx)); in csio_mb_dump_fw_dbg()
1139 csio_info(hw, "\tdebug->dprtstrparam0 = 0x%x\n", in csio_mb_dump_fw_dbg()
1140 ntohl(dbg->u.prt.dprtstrparam0)); in csio_mb_dump_fw_dbg()
1141 csio_info(hw, "\tdebug->dprtstrparam1 = 0x%x\n", in csio_mb_dump_fw_dbg()
1142 ntohl(dbg->u.prt.dprtstrparam1)); in csio_mb_dump_fw_dbg()
1143 csio_info(hw, "\tdebug->dprtstrparam2 = 0x%x\n", in csio_mb_dump_fw_dbg()
1144 ntohl(dbg->u.prt.dprtstrparam2)); in csio_mb_dump_fw_dbg()
1145 csio_info(hw, "\tdebug->dprtstrparam3 = 0x%x\n", in csio_mb_dump_fw_dbg()
1146 ntohl(dbg->u.prt.dprtstrparam3)); in csio_mb_dump_fw_dbg()
1150 dbg->u.assert.filename_0_7, in csio_mb_dump_fw_dbg()
1151 ntohl(dbg->u.assert.line), in csio_mb_dump_fw_dbg()
1152 ntohl(dbg->u.assert.x), in csio_mb_dump_fw_dbg()
1153 ntohl(dbg->u.assert.y)); in csio_mb_dump_fw_dbg()
1162 uint32_t ctl_reg = PF_REG(hw->pfn, CIM_PF_MAILBOX_CTRL_A); in csio_mb_debug_cmd_handler()
1163 uint32_t data_reg = PF_REG(hw->pfn, CIM_PF_MAILBOX_DATA_A); in csio_mb_debug_cmd_handler()
1181 * csio_mb_issue - generic routine for issuing Mailbox commands.
1193 __be64 *cmd = mbp->mb; in csio_mb_issue()
1195 struct csio_mbm *mbm = &hw->mbm; in csio_mb_issue()
1196 uint32_t ctl_reg = PF_REG(hw->pfn, CIM_PF_MAILBOX_CTRL_A); in csio_mb_issue()
1197 uint32_t data_reg = PF_REG(hw->pfn, CIM_PF_MAILBOX_DATA_A); in csio_mb_issue()
1198 int size = mbp->mb_size; in csio_mb_issue()
1199 int rv = -EINVAL; in csio_mb_issue()
1203 if (mbp->mb_cbfn == NULL) { in csio_mb_issue()
1205 if (mbp->tmo < CSIO_MB_POLL_FREQ) { in csio_mb_issue()
1206 csio_err(hw, "Invalid tmo: 0x%x\n", mbp->tmo); in csio_mb_issue()
1212 *((uint8_t *)mbp->mb)); in csio_mb_issue()
1216 if (mbm->mcurrent != NULL) { in csio_mb_issue()
1218 if (mbp->mb_cbfn == NULL) { in csio_mb_issue()
1219 rv = -EBUSY; in csio_mb_issue()
1221 hw->pfn, *((uint8_t *)mbp->mb)); in csio_mb_issue()
1225 list_add_tail(&mbp->list, &mbm->req_q); in csio_mb_issue()
1244 if (mbp->mb_cbfn == NULL) { in csio_mb_issue()
1245 rv = owner ? -EBUSY : -ETIMEDOUT; in csio_mb_issue()
1250 hw->pfn, *((uint8_t *)mbp->mb), owner); in csio_mb_issue()
1253 if (mbm->mcurrent == NULL) { in csio_mb_issue()
1257 hw->pfn, *((uint8_t *)mbp->mb), in csio_mb_issue()
1274 CSIO_DUMP_MB(hw, hw->pfn, data_reg); in csio_mb_issue()
1276 /* Start completion timers in non-immediate modes and notify FW */ in csio_mb_issue()
1277 if (mbp->mb_cbfn != NULL) { in csio_mb_issue()
1278 mbm->mcurrent = mbp; in csio_mb_issue()
1279 mod_timer(&mbm->timer, jiffies + msecs_to_jiffies(mbp->tmo)); in csio_mb_issue()
1292 if (mbp->mb_cbfn) in csio_mb_issue()
1296 cmd = mbp->mb; in csio_mb_issue()
1298 for (ii = 0; ii < mbp->tmo; ii += CSIO_MB_POLL_FREQ) { in csio_mb_issue()
1310 CSIO_DUMP_MB(hw, hw->pfn, data_reg); in csio_mb_issue()
1315 switch (FW_CMD_OP_G(ntohl(fw_hdr->hi))) { in csio_mb_issue()
1338 hw->pfn, *((uint8_t *)cmd)); in csio_mb_issue()
1340 return -ETIMEDOUT; in csio_mb_issue()
1348 * csio_mb_completions - Completion handler for Mailbox commands
1357 struct csio_mbm *mbm = &hw->mbm; in csio_mb_completions()
1362 list_del_init(&mbp->list); in csio_mb_completions()
1370 if (mbp->mb_cbfn) in csio_mb_completions()
1371 mbp->mb_cbfn(hw, mbp); in csio_mb_completions()
1382 struct csio_pport *port = &hw->pport[port_id]; in csio_mb_portmod_changed()
1384 if (port->mod_type == FW_PORT_MOD_TYPE_NONE) in csio_mb_portmod_changed()
1385 csio_info(hw, "Port:%d - port module unplugged\n", port_id); in csio_mb_portmod_changed()
1386 else if (port->mod_type < ARRAY_SIZE(mod_str)) in csio_mb_portmod_changed()
1387 csio_info(hw, "Port:%d - %s port module inserted\n", port_id, in csio_mb_portmod_changed()
1388 mod_str[port->mod_type]); in csio_mb_portmod_changed()
1389 else if (port->mod_type == FW_PORT_MOD_TYPE_NOTSUPPORTED) in csio_mb_portmod_changed()
1391 "Port:%d - unsupported optical port module " in csio_mb_portmod_changed()
1393 else if (port->mod_type == FW_PORT_MOD_TYPE_UNKNOWN) in csio_mb_portmod_changed()
1395 "Port:%d - unknown port module inserted, forcing " in csio_mb_portmod_changed()
1397 else if (port->mod_type == FW_PORT_MOD_TYPE_ERROR) in csio_mb_portmod_changed()
1398 csio_info(hw, "Port:%d - transceiver module error\n", port_id); in csio_mb_portmod_changed()
1400 csio_info(hw, "Port:%d - unknown module type %d inserted\n", in csio_mb_portmod_changed()
1401 port_id, port->mod_type); in csio_mb_portmod_changed()
1418 ntohl(pcmd->op_to_portid)); in csio_mb_fwevt_handler()
1420 ntohl(pcmd->action_to_len16)); in csio_mb_fwevt_handler()
1425 return -EINVAL; in csio_mb_fwevt_handler()
1429 link_status = ntohl(pcmd->u.info.lstatus_to_modtype); in csio_mb_fwevt_handler()
1433 hw->pport[port_id].link_status = in csio_mb_fwevt_handler()
1437 ntohl(pcmd->u.info32.lstatus32_to_cbllen32); in csio_mb_fwevt_handler()
1439 linkattr = ntohl(pcmd->u.info32.linkattr32); in csio_mb_fwevt_handler()
1441 hw->pport[port_id].link_status = in csio_mb_fwevt_handler()
1445 hw->pport[port_id].link_speed = fwcap_to_fwspeed(linkattr); in csio_mb_fwevt_handler()
1447 csio_info(hw, "Port:%x - LINK %s\n", port_id, in csio_mb_fwevt_handler()
1448 hw->pport[port_id].link_status ? "UP" : "DOWN"); in csio_mb_fwevt_handler()
1450 if (mod_type != hw->pport[port_id].mod_type) { in csio_mb_fwevt_handler()
1451 hw->pport[port_id].mod_type = mod_type; in csio_mb_fwevt_handler()
1458 return -EINVAL; in csio_mb_fwevt_handler()
1465 * csio_mb_isr_handler - Handle mailboxes related interrupts.
1474 struct csio_mbm *mbm = &hw->mbm; in csio_mb_isr_handler()
1475 struct csio_mb *mbp = mbm->mcurrent; in csio_mb_isr_handler()
1479 uint32_t ctl_reg = PF_REG(hw->pfn, CIM_PF_MAILBOX_CTRL_A); in csio_mb_isr_handler()
1480 uint32_t data_reg = PF_REG(hw->pfn, CIM_PF_MAILBOX_DATA_A); in csio_mb_isr_handler()
1490 return -EINVAL; in csio_mb_isr_handler()
1496 * the upper level cause register. In other words, CIM-cause in csio_mb_isr_handler()
1497 * first followed by PL-Cause next. in csio_mb_isr_handler()
1506 CSIO_DUMP_MB(hw, hw->pfn, data_reg); in csio_mb_isr_handler()
1515 return -EINVAL; in csio_mb_isr_handler()
1521 switch (FW_CMD_OP_G(ntohl(fw_hdr->hi))) { in csio_mb_isr_handler()
1524 return -EINVAL; in csio_mb_isr_handler()
1527 case FW_INITIALIZE_CMD: /* When we are not master */ in csio_mb_isr_handler()
1533 cmd = mbp->mb; in csio_mb_isr_handler()
1534 size = mbp->mb_size; in csio_mb_isr_handler()
1544 mbm->mcurrent = NULL; in csio_mb_isr_handler()
1547 list_add_tail(&mbp->list, &mbm->cbfn_q); in csio_mb_isr_handler()
1566 return -EINVAL; in csio_mb_isr_handler()
1571 * csio_mb_tmo_handler - Timeout handler
1578 struct csio_mbm *mbm = &hw->mbm; in csio_mb_tmo_handler()
1579 struct csio_mb *mbp = mbm->mcurrent; in csio_mb_tmo_handler()
1591 fw_hdr = (struct fw_cmd_hdr *)(mbp->mb); in csio_mb_tmo_handler()
1593 csio_dbg(hw, "Mailbox num:%x op:0x%x timed out\n", hw->pfn, in csio_mb_tmo_handler()
1594 FW_CMD_OP_G(ntohl(fw_hdr->hi))); in csio_mb_tmo_handler()
1596 mbm->mcurrent = NULL; in csio_mb_tmo_handler()
1598 fw_hdr->lo = htonl(FW_CMD_RETVAL_V(FW_ETIMEDOUT)); in csio_mb_tmo_handler()
1604 * csio_mb_cancel_all - Cancel all waiting commands.
1614 struct csio_mbm *mbm = &hw->mbm; in csio_mb_cancel_all()
1618 if (mbm->mcurrent) { in csio_mb_cancel_all()
1619 mbp = mbm->mcurrent; in csio_mb_cancel_all()
1622 del_timer_sync(&mbm->timer); in csio_mb_cancel_all()
1625 list_add_tail(&mbp->list, cbfn_q); in csio_mb_cancel_all()
1626 mbm->mcurrent = NULL; in csio_mb_cancel_all()
1629 if (!list_empty(&mbm->req_q)) { in csio_mb_cancel_all()
1630 list_splice_tail_init(&mbm->req_q, cbfn_q); in csio_mb_cancel_all()
1631 mbm->stats.n_activeq = 0; in csio_mb_cancel_all()
1634 if (!list_empty(&mbm->cbfn_q)) { in csio_mb_cancel_all()
1635 list_splice_tail_init(&mbm->cbfn_q, cbfn_q); in csio_mb_cancel_all()
1636 mbm->stats.n_cbfnq = 0; in csio_mb_cancel_all()
1644 hdr = (struct fw_cmd_hdr *)(mbp->mb); in csio_mb_cancel_all()
1647 hw->pfn, FW_CMD_OP_G(ntohl(hdr->hi))); in csio_mb_cancel_all()
1650 hdr->lo = htonl(FW_CMD_RETVAL_V(FW_HOSTERROR)); in csio_mb_cancel_all()
1655 * csio_mbm_init - Initialize Mailbox module
1666 mbm->hw = hw; in csio_mbm_init()
1667 timer_setup(&mbm->timer, timer_fn, 0); in csio_mbm_init()
1669 INIT_LIST_HEAD(&mbm->req_q); in csio_mbm_init()
1670 INIT_LIST_HEAD(&mbm->cbfn_q); in csio_mbm_init()
1671 csio_set_mb_intr_idx(mbm, -1); in csio_mbm_init()
1677 * csio_mbm_exit - Uninitialize mailbox module
1685 del_timer_sync(&mbm->timer); in csio_mbm_exit()
1687 CSIO_DB_ASSERT(mbm->mcurrent == NULL); in csio_mbm_exit()
1688 CSIO_DB_ASSERT(list_empty(&mbm->req_q)); in csio_mbm_exit()
1689 CSIO_DB_ASSERT(list_empty(&mbm->cbfn_q)); in csio_mbm_exit()