Lines Matching +full:mailbox +full:-

16  *      - Redistributions of source code must retain the above
20 * - Redistributions in binary form must reproduce the above
151 * commands. So we can't use strict timeouts described in PRM -- we
194 return readl(dev->hcr + HCR_STATUS_OFFSET) & in go_bit()
206 void __iomem *ptr = dev->cmd.dbell_map; in mthca_cmd_post_dbell()
207 u16 *offs = dev->cmd.dbell_offsets; in mthca_cmd_post_dbell()
249 return -EAGAIN; in mthca_cmd_post_hcr()
257 __raw_writel((__force u32) cpu_to_be32(in_param >> 32), dev->hcr + 0 * 4); in mthca_cmd_post_hcr()
258 __raw_writel((__force u32) cpu_to_be32(in_param & 0xfffffffful), dev->hcr + 1 * 4); in mthca_cmd_post_hcr()
259 __raw_writel((__force u32) cpu_to_be32(in_modifier), dev->hcr + 2 * 4); in mthca_cmd_post_hcr()
260 __raw_writel((__force u32) cpu_to_be32(out_param >> 32), dev->hcr + 3 * 4); in mthca_cmd_post_hcr()
261 __raw_writel((__force u32) cpu_to_be32(out_param & 0xfffffffful), dev->hcr + 4 * 4); in mthca_cmd_post_hcr()
262 __raw_writel((__force u32) cpu_to_be32(token << 16), dev->hcr + 5 * 4); in mthca_cmd_post_hcr()
270 op), dev->hcr + 6 * 4); in mthca_cmd_post_hcr()
286 mutex_lock(&dev->cmd.hcr_mutex); in mthca_cmd_post()
288 if (event && dev->cmd.flags & MTHCA_CMD_POST_DOORBELLS && fw_cmd_doorbell) in mthca_cmd_post()
295 mutex_unlock(&dev->cmd.hcr_mutex); in mthca_cmd_post()
303 [MTHCA_CMD_STAT_INTERNAL_ERR] = -EIO, in mthca_status_to_errno()
304 [MTHCA_CMD_STAT_BAD_OP] = -EPERM, in mthca_status_to_errno()
305 [MTHCA_CMD_STAT_BAD_PARAM] = -EINVAL, in mthca_status_to_errno()
306 [MTHCA_CMD_STAT_BAD_SYS_STATE] = -ENXIO, in mthca_status_to_errno()
307 [MTHCA_CMD_STAT_BAD_RESOURCE] = -EBADF, in mthca_status_to_errno()
308 [MTHCA_CMD_STAT_RESOURCE_BUSY] = -EBUSY, in mthca_status_to_errno()
309 [MTHCA_CMD_STAT_DDR_MEM_ERR] = -ENOMEM, in mthca_status_to_errno()
310 [MTHCA_CMD_STAT_EXCEED_LIM] = -ENOMEM, in mthca_status_to_errno()
311 [MTHCA_CMD_STAT_BAD_RES_STATE] = -EBADF, in mthca_status_to_errno()
312 [MTHCA_CMD_STAT_BAD_INDEX] = -EBADF, in mthca_status_to_errno()
313 [MTHCA_CMD_STAT_BAD_NVMEM] = -EFAULT, in mthca_status_to_errno()
314 [MTHCA_CMD_STAT_BAD_QPEE_STATE] = -EINVAL, in mthca_status_to_errno()
315 [MTHCA_CMD_STAT_BAD_SEG_PARAM] = -EFAULT, in mthca_status_to_errno()
316 [MTHCA_CMD_STAT_REG_BOUND] = -EBUSY, in mthca_status_to_errno()
317 [MTHCA_CMD_STAT_LAM_NOT_PRE] = -EAGAIN, in mthca_status_to_errno()
318 [MTHCA_CMD_STAT_BAD_PKT] = -EBADMSG, in mthca_status_to_errno()
319 [MTHCA_CMD_STAT_BAD_SIZE] = -ENOMEM, in mthca_status_to_errno()
325 return -EINVAL; in mthca_status_to_errno()
344 down(&dev->cmd.poll_sem); in mthca_cmd_poll()
360 err = -EBUSY; in mthca_cmd_poll()
367 __raw_readl(dev->hcr + HCR_OUT_PARAM_OFFSET)) << 32 | in mthca_cmd_poll()
369 __raw_readl(dev->hcr + HCR_OUT_PARAM_OFFSET + 4)); in mthca_cmd_poll()
371 err = -EINVAL; in mthca_cmd_poll()
375 status = be32_to_cpu((__force __be32) __raw_readl(dev->hcr + HCR_STATUS_OFFSET)) >> 24; in mthca_cmd_poll()
383 up(&dev->cmd.poll_sem); in mthca_cmd_poll()
393 &dev->cmd.context[token & dev->cmd.token_mask]; in mthca_cmd_event()
396 if (token != context->token) in mthca_cmd_event()
399 context->result = 0; in mthca_cmd_event()
400 context->status = status; in mthca_cmd_event()
401 context->out_param = out_param; in mthca_cmd_event()
403 complete(&context->done); in mthca_cmd_event()
418 down(&dev->cmd.event_sem); in mthca_cmd_wait()
420 spin_lock(&dev->cmd.context_lock); in mthca_cmd_wait()
421 BUG_ON(dev->cmd.free_head < 0); in mthca_cmd_wait()
422 context = &dev->cmd.context[dev->cmd.free_head]; in mthca_cmd_wait()
423 context->token += dev->cmd.token_mask + 1; in mthca_cmd_wait()
424 dev->cmd.free_head = context->next; in mthca_cmd_wait()
425 spin_unlock(&dev->cmd.context_lock); in mthca_cmd_wait()
427 init_completion(&context->done); in mthca_cmd_wait()
432 op, context->token, 1); in mthca_cmd_wait()
436 if (!wait_for_completion_timeout(&context->done, timeout)) { in mthca_cmd_wait()
437 err = -EBUSY; in mthca_cmd_wait()
441 err = context->result; in mthca_cmd_wait()
445 if (context->status) { in mthca_cmd_wait()
447 op, context->status); in mthca_cmd_wait()
448 err = mthca_status_to_errno(context->status); in mthca_cmd_wait()
452 *out_param = context->out_param; in mthca_cmd_wait()
454 err = -EINVAL; in mthca_cmd_wait()
459 spin_lock(&dev->cmd.context_lock); in mthca_cmd_wait()
460 context->next = dev->cmd.free_head; in mthca_cmd_wait()
461 dev->cmd.free_head = context - dev->cmd.context; in mthca_cmd_wait()
462 spin_unlock(&dev->cmd.context_lock); in mthca_cmd_wait()
464 up(&dev->cmd.event_sem); in mthca_cmd_wait()
468 /* Invoke a command with an output mailbox */
477 if (dev->cmd.flags & MTHCA_CMD_USE_EVENTS) in mthca_cmd_box()
512 if (dev->cmd.flags & MTHCA_CMD_USE_EVENTS) in mthca_cmd_imm()
524 mutex_init(&dev->cmd.hcr_mutex); in mthca_cmd_init()
525 sema_init(&dev->cmd.poll_sem, 1); in mthca_cmd_init()
526 dev->cmd.flags = 0; in mthca_cmd_init()
528 dev->hcr = ioremap(pci_resource_start(dev->pdev, 0) + MTHCA_HCR_BASE, in mthca_cmd_init()
530 if (!dev->hcr) { in mthca_cmd_init()
532 return -ENOMEM; in mthca_cmd_init()
535 dev->cmd.pool = dma_pool_create("mthca_cmd", &dev->pdev->dev, in mthca_cmd_init()
538 if (!dev->cmd.pool) { in mthca_cmd_init()
539 iounmap(dev->hcr); in mthca_cmd_init()
540 return -ENOMEM; in mthca_cmd_init()
548 dma_pool_destroy(dev->cmd.pool); in mthca_cmd_cleanup()
549 iounmap(dev->hcr); in mthca_cmd_cleanup()
550 if (dev->cmd.flags & MTHCA_CMD_POST_DOORBELLS) in mthca_cmd_cleanup()
551 iounmap(dev->cmd.dbell_map); in mthca_cmd_cleanup()
562 dev->cmd.context = kmalloc_array(dev->cmd.max_cmds, in mthca_cmd_use_events()
565 if (!dev->cmd.context) in mthca_cmd_use_events()
566 return -ENOMEM; in mthca_cmd_use_events()
568 for (i = 0; i < dev->cmd.max_cmds; ++i) { in mthca_cmd_use_events()
569 dev->cmd.context[i].token = i; in mthca_cmd_use_events()
570 dev->cmd.context[i].next = i + 1; in mthca_cmd_use_events()
573 dev->cmd.context[dev->cmd.max_cmds - 1].next = -1; in mthca_cmd_use_events()
574 dev->cmd.free_head = 0; in mthca_cmd_use_events()
576 sema_init(&dev->cmd.event_sem, dev->cmd.max_cmds); in mthca_cmd_use_events()
577 spin_lock_init(&dev->cmd.context_lock); in mthca_cmd_use_events()
579 for (dev->cmd.token_mask = 1; in mthca_cmd_use_events()
580 dev->cmd.token_mask < dev->cmd.max_cmds; in mthca_cmd_use_events()
581 dev->cmd.token_mask <<= 1) in mthca_cmd_use_events()
583 --dev->cmd.token_mask; in mthca_cmd_use_events()
585 dev->cmd.flags |= MTHCA_CMD_USE_EVENTS; in mthca_cmd_use_events()
587 down(&dev->cmd.poll_sem); in mthca_cmd_use_events()
599 dev->cmd.flags &= ~MTHCA_CMD_USE_EVENTS; in mthca_cmd_use_polling()
601 for (i = 0; i < dev->cmd.max_cmds; ++i) in mthca_cmd_use_polling()
602 down(&dev->cmd.event_sem); in mthca_cmd_use_polling()
604 kfree(dev->cmd.context); in mthca_cmd_use_polling()
606 up(&dev->cmd.poll_sem); in mthca_cmd_use_polling()
612 struct mthca_mailbox *mailbox; in mthca_alloc_mailbox() local
614 mailbox = kmalloc(sizeof *mailbox, gfp_mask); in mthca_alloc_mailbox()
615 if (!mailbox) in mthca_alloc_mailbox()
616 return ERR_PTR(-ENOMEM); in mthca_alloc_mailbox()
618 mailbox->buf = dma_pool_alloc(dev->cmd.pool, gfp_mask, &mailbox->dma); in mthca_alloc_mailbox()
619 if (!mailbox->buf) { in mthca_alloc_mailbox()
620 kfree(mailbox); in mthca_alloc_mailbox()
621 return ERR_PTR(-ENOMEM); in mthca_alloc_mailbox()
624 return mailbox; in mthca_alloc_mailbox()
627 void mthca_free_mailbox(struct mthca_dev *dev, struct mthca_mailbox *mailbox) in mthca_free_mailbox() argument
629 if (!mailbox) in mthca_free_mailbox()
632 dma_pool_free(dev->cmd.pool, mailbox->buf, mailbox->dma); in mthca_free_mailbox()
633 kfree(mailbox); in mthca_free_mailbox()
643 if (ret == -ENOMEM) in mthca_SYS_EN()
660 struct mthca_mailbox *mailbox; in mthca_map_cmd() local
669 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_map_cmd()
670 if (IS_ERR(mailbox)) in mthca_map_cmd()
671 return PTR_ERR(mailbox); in mthca_map_cmd()
672 memset(mailbox->buf, 0, MTHCA_MAILBOX_SIZE); in mthca_map_cmd()
673 pages = mailbox->buf; in mthca_map_cmd()
683 lg = ffs(mthca_icm_addr(&iter) | mthca_icm_size(&iter)) - 1; in mthca_map_cmd()
689 err = -EINVAL; in mthca_map_cmd()
693 if (virt != -1) { in mthca_map_cmd()
700 (lg - MTHCA_ICM_PAGE_SHIFT)); in mthca_map_cmd()
701 ts += 1 << (lg - 10); in mthca_map_cmd()
705 err = mthca_cmd(dev, mailbox->dma, nent, 0, op, in mthca_map_cmd()
715 err = mthca_cmd(dev, mailbox->dma, nent, 0, op, in mthca_map_cmd()
727 tc, ts, (unsigned long long) virt - (ts << 10)); in mthca_map_cmd()
732 mthca_free_mailbox(dev, mailbox); in mthca_map_cmd()
738 return mthca_map_cmd(dev, CMD_MAP_FA, icm, -1); in mthca_MAP_FA()
758 max_off = max(max_off, dev->cmd.dbell_offsets[i]); in mthca_setup_cmd_doorbells()
767 addr = pci_resource_start(dev->pdev, 2) + in mthca_setup_cmd_doorbells()
768 ((pci_resource_len(dev->pdev, 2) - 1) & base); in mthca_setup_cmd_doorbells()
769 dev->cmd.dbell_map = ioremap(addr, max_off + sizeof(u32)); in mthca_setup_cmd_doorbells()
770 if (!dev->cmd.dbell_map) in mthca_setup_cmd_doorbells()
773 dev->cmd.flags |= MTHCA_CMD_POST_DOORBELLS; in mthca_setup_cmd_doorbells()
779 struct mthca_mailbox *mailbox; in mthca_QUERY_FW() local
805 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_QUERY_FW()
806 if (IS_ERR(mailbox)) in mthca_QUERY_FW()
807 return PTR_ERR(mailbox); in mthca_QUERY_FW()
808 outbox = mailbox->buf; in mthca_QUERY_FW()
810 err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_QUERY_FW, in mthca_QUERY_FW()
816 MTHCA_GET(dev->fw_ver, outbox, QUERY_FW_VER_OFFSET); in mthca_QUERY_FW()
821 dev->fw_ver = (dev->fw_ver & 0xffff00000000ull) | in mthca_QUERY_FW()
822 ((dev->fw_ver & 0xffff0000ull) >> 16) | in mthca_QUERY_FW()
823 ((dev->fw_ver & 0x0000ffffull) << 16); in mthca_QUERY_FW()
826 dev->cmd.max_cmds = 1 << lg; in mthca_QUERY_FW()
829 (unsigned long long) dev->fw_ver, dev->cmd.max_cmds); in mthca_QUERY_FW()
831 MTHCA_GET(dev->catas_err.addr, outbox, QUERY_FW_ERR_START_OFFSET); in mthca_QUERY_FW()
832 MTHCA_GET(dev->catas_err.size, outbox, QUERY_FW_ERR_SIZE_OFFSET); in mthca_QUERY_FW()
835 (unsigned long long) dev->catas_err.addr, dev->catas_err.size); in mthca_QUERY_FW()
843 MTHCA_GET(dev->cmd.dbell_offsets[i], outbox, in mthca_QUERY_FW()
850 MTHCA_GET(dev->fw.arbel.fw_pages, outbox, QUERY_FW_SIZE_OFFSET); in mthca_QUERY_FW()
851 MTHCA_GET(dev->fw.arbel.clr_int_base, outbox, QUERY_FW_CLR_INT_BASE_OFFSET); in mthca_QUERY_FW()
852 MTHCA_GET(dev->fw.arbel.eq_arm_base, outbox, QUERY_FW_EQ_ARM_BASE_OFFSET); in mthca_QUERY_FW()
853 MTHCA_GET(dev->fw.arbel.eq_set_ci_base, outbox, QUERY_FW_EQ_SET_CI_BASE_OFFSET); in mthca_QUERY_FW()
854 mthca_dbg(dev, "FW size %d KB\n", dev->fw.arbel.fw_pages << 2); in mthca_QUERY_FW()
860 dev->fw.arbel.fw_pages = in mthca_QUERY_FW()
861 ALIGN(dev->fw.arbel.fw_pages, PAGE_SIZE / MTHCA_ICM_PAGE_SIZE) >> in mthca_QUERY_FW()
862 (PAGE_SHIFT - MTHCA_ICM_PAGE_SHIFT); in mthca_QUERY_FW()
865 (unsigned long long) dev->fw.arbel.clr_int_base, in mthca_QUERY_FW()
866 (unsigned long long) dev->fw.arbel.eq_arm_base, in mthca_QUERY_FW()
867 (unsigned long long) dev->fw.arbel.eq_set_ci_base); in mthca_QUERY_FW()
869 MTHCA_GET(dev->fw.tavor.fw_start, outbox, QUERY_FW_START_OFFSET); in mthca_QUERY_FW()
870 MTHCA_GET(dev->fw.tavor.fw_end, outbox, QUERY_FW_END_OFFSET); in mthca_QUERY_FW()
873 (int) ((dev->fw.tavor.fw_end - dev->fw.tavor.fw_start) >> 10), in mthca_QUERY_FW()
874 (unsigned long long) dev->fw.tavor.fw_start, in mthca_QUERY_FW()
875 (unsigned long long) dev->fw.tavor.fw_end); in mthca_QUERY_FW()
879 mthca_free_mailbox(dev, mailbox); in mthca_QUERY_FW()
885 struct mthca_mailbox *mailbox; in mthca_ENABLE_LAM() local
898 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_ENABLE_LAM()
899 if (IS_ERR(mailbox)) in mthca_ENABLE_LAM()
900 return PTR_ERR(mailbox); in mthca_ENABLE_LAM()
901 outbox = mailbox->buf; in mthca_ENABLE_LAM()
903 err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_ENABLE_LAM, in mthca_ENABLE_LAM()
909 MTHCA_GET(dev->ddr_start, outbox, ENABLE_LAM_START_OFFSET); in mthca_ENABLE_LAM()
910 MTHCA_GET(dev->ddr_end, outbox, ENABLE_LAM_END_OFFSET); in mthca_ENABLE_LAM()
914 !!(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) { in mthca_ENABLE_LAM()
915 mthca_info(dev, "FW reports that HCA-attached memory " in mthca_ENABLE_LAM()
921 mthca_dbg(dev, "HCA-attached memory is hidden.\n"); in mthca_ENABLE_LAM()
924 (int) ((dev->ddr_end - dev->ddr_start) >> 10), in mthca_ENABLE_LAM()
925 (unsigned long long) dev->ddr_start, in mthca_ENABLE_LAM()
926 (unsigned long long) dev->ddr_end); in mthca_ENABLE_LAM()
929 mthca_free_mailbox(dev, mailbox); in mthca_ENABLE_LAM()
940 struct mthca_mailbox *mailbox; in mthca_QUERY_DDR() local
953 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_QUERY_DDR()
954 if (IS_ERR(mailbox)) in mthca_QUERY_DDR()
955 return PTR_ERR(mailbox); in mthca_QUERY_DDR()
956 outbox = mailbox->buf; in mthca_QUERY_DDR()
958 err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_QUERY_DDR, in mthca_QUERY_DDR()
964 MTHCA_GET(dev->ddr_start, outbox, QUERY_DDR_START_OFFSET); in mthca_QUERY_DDR()
965 MTHCA_GET(dev->ddr_end, outbox, QUERY_DDR_END_OFFSET); in mthca_QUERY_DDR()
969 !!(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) { in mthca_QUERY_DDR()
970 mthca_info(dev, "FW reports that HCA-attached memory " in mthca_QUERY_DDR()
976 mthca_dbg(dev, "HCA-attached memory is hidden.\n"); in mthca_QUERY_DDR()
979 (int) ((dev->ddr_end - dev->ddr_start) >> 10), in mthca_QUERY_DDR()
980 (unsigned long long) dev->ddr_start, in mthca_QUERY_DDR()
981 (unsigned long long) dev->ddr_end); in mthca_QUERY_DDR()
984 mthca_free_mailbox(dev, mailbox); in mthca_QUERY_DDR()
991 struct mthca_mailbox *mailbox; in mthca_QUERY_DEV_LIM() local
1059 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_QUERY_DEV_LIM()
1060 if (IS_ERR(mailbox)) in mthca_QUERY_DEV_LIM()
1061 return PTR_ERR(mailbox); in mthca_QUERY_DEV_LIM()
1062 outbox = mailbox->buf; in mthca_QUERY_DEV_LIM()
1064 err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_QUERY_DEV_LIM, in mthca_QUERY_DEV_LIM()
1071 dev_lim->reserved_qps = 1 << (field & 0xf); in mthca_QUERY_DEV_LIM()
1073 dev_lim->max_qps = 1 << (field & 0x1f); in mthca_QUERY_DEV_LIM()
1075 dev_lim->reserved_srqs = 1 << (field >> 4); in mthca_QUERY_DEV_LIM()
1077 dev_lim->max_srqs = 1 << (field & 0x1f); in mthca_QUERY_DEV_LIM()
1079 dev_lim->reserved_eecs = 1 << (field & 0xf); in mthca_QUERY_DEV_LIM()
1081 dev_lim->max_eecs = 1 << (field & 0x1f); in mthca_QUERY_DEV_LIM()
1083 dev_lim->max_cq_sz = 1 << field; in mthca_QUERY_DEV_LIM()
1085 dev_lim->reserved_cqs = 1 << (field & 0xf); in mthca_QUERY_DEV_LIM()
1087 dev_lim->max_cqs = 1 << (field & 0x1f); in mthca_QUERY_DEV_LIM()
1089 dev_lim->max_mpts = 1 << (field & 0x3f); in mthca_QUERY_DEV_LIM()
1091 dev_lim->reserved_eqs = 1 << (field & 0xf); in mthca_QUERY_DEV_LIM()
1093 dev_lim->max_eqs = 1 << (field & 0x7); in mthca_QUERY_DEV_LIM()
1096 dev_lim->reserved_mtts = ALIGN((1 << (field >> 4)) * sizeof(u64), in mthca_QUERY_DEV_LIM()
1097 dev->limits.mtt_seg_size) / dev->limits.mtt_seg_size; in mthca_QUERY_DEV_LIM()
1099 dev_lim->reserved_mtts = 1 << (field >> 4); in mthca_QUERY_DEV_LIM()
1101 dev_lim->max_mrw_sz = 1 << field; in mthca_QUERY_DEV_LIM()
1103 dev_lim->reserved_mrws = 1 << (field & 0xf); in mthca_QUERY_DEV_LIM()
1105 dev_lim->max_mtt_seg = 1 << (field & 0x3f); in mthca_QUERY_DEV_LIM()
1107 dev_lim->max_requester_per_qp = 1 << (field & 0x3f); in mthca_QUERY_DEV_LIM()
1109 dev_lim->max_responder_per_qp = 1 << (field & 0x3f); in mthca_QUERY_DEV_LIM()
1111 dev_lim->max_rdma_global = 1 << (field & 0x3f); in mthca_QUERY_DEV_LIM()
1113 dev_lim->local_ca_ack_delay = field & 0x1f; in mthca_QUERY_DEV_LIM()
1115 dev_lim->max_mtu = field >> 4; in mthca_QUERY_DEV_LIM()
1116 dev_lim->max_port_width = field & 0xf; in mthca_QUERY_DEV_LIM()
1118 dev_lim->max_vl = field >> 4; in mthca_QUERY_DEV_LIM()
1119 dev_lim->num_ports = field & 0xf; in mthca_QUERY_DEV_LIM()
1121 dev_lim->max_gids = 1 << (field & 0xf); in mthca_QUERY_DEV_LIM()
1123 dev_lim->stat_rate_support = stat_rate; in mthca_QUERY_DEV_LIM()
1125 dev_lim->max_pkeys = 1 << (field & 0xf); in mthca_QUERY_DEV_LIM()
1126 MTHCA_GET(dev_lim->flags, outbox, QUERY_DEV_LIM_FLAGS_OFFSET); in mthca_QUERY_DEV_LIM()
1128 dev_lim->reserved_uars = field >> 4; in mthca_QUERY_DEV_LIM()
1130 dev_lim->uar_size = 1 << ((field & 0x3f) + 20); in mthca_QUERY_DEV_LIM()
1132 dev_lim->min_page_sz = 1 << field; in mthca_QUERY_DEV_LIM()
1134 dev_lim->max_sg = field; in mthca_QUERY_DEV_LIM()
1137 dev_lim->max_desc_sz = size; in mthca_QUERY_DEV_LIM()
1140 dev_lim->max_qp_per_mcg = 1 << field; in mthca_QUERY_DEV_LIM()
1142 dev_lim->reserved_mgms = field & 0xf; in mthca_QUERY_DEV_LIM()
1144 dev_lim->max_mcgs = 1 << field; in mthca_QUERY_DEV_LIM()
1146 dev_lim->reserved_pds = field >> 4; in mthca_QUERY_DEV_LIM()
1148 dev_lim->max_pds = 1 << (field & 0x3f); in mthca_QUERY_DEV_LIM()
1150 dev_lim->reserved_rdds = field >> 4; in mthca_QUERY_DEV_LIM()
1152 dev_lim->max_rdds = 1 << (field & 0x3f); in mthca_QUERY_DEV_LIM()
1155 dev_lim->eec_entry_sz = size; in mthca_QUERY_DEV_LIM()
1157 dev_lim->qpc_entry_sz = size; in mthca_QUERY_DEV_LIM()
1159 dev_lim->eeec_entry_sz = size; in mthca_QUERY_DEV_LIM()
1161 dev_lim->eqpc_entry_sz = size; in mthca_QUERY_DEV_LIM()
1163 dev_lim->eqc_entry_sz = size; in mthca_QUERY_DEV_LIM()
1165 dev_lim->cqc_entry_sz = size; in mthca_QUERY_DEV_LIM()
1167 dev_lim->srq_entry_sz = size; in mthca_QUERY_DEV_LIM()
1169 dev_lim->uar_scratch_entry_sz = size; in mthca_QUERY_DEV_LIM()
1173 dev_lim->max_srq_sz = 1 << field; in mthca_QUERY_DEV_LIM()
1175 dev_lim->max_qp_sz = 1 << field; in mthca_QUERY_DEV_LIM()
1177 dev_lim->hca.arbel.resize_srq = field & 1; in mthca_QUERY_DEV_LIM()
1179 dev_lim->max_sg = min_t(int, field, dev_lim->max_sg); in mthca_QUERY_DEV_LIM()
1181 dev_lim->max_desc_sz = min_t(int, size, dev_lim->max_desc_sz); in mthca_QUERY_DEV_LIM()
1183 dev_lim->mpt_entry_sz = size; in mthca_QUERY_DEV_LIM()
1185 dev_lim->hca.arbel.max_pbl_sz = 1 << (field & 0x3f); in mthca_QUERY_DEV_LIM()
1186 MTHCA_GET(dev_lim->hca.arbel.bmme_flags, outbox, in mthca_QUERY_DEV_LIM()
1188 MTHCA_GET(dev_lim->hca.arbel.reserved_lkey, outbox, in mthca_QUERY_DEV_LIM()
1191 dev_lim->hca.arbel.lam_required = field & 1; in mthca_QUERY_DEV_LIM()
1192 MTHCA_GET(dev_lim->hca.arbel.max_icm_sz, outbox, in mthca_QUERY_DEV_LIM()
1195 if (dev_lim->hca.arbel.bmme_flags & 1) in mthca_QUERY_DEV_LIM()
1198 dev_lim->hca.arbel.bmme_flags, in mthca_QUERY_DEV_LIM()
1199 dev_lim->hca.arbel.max_pbl_sz, in mthca_QUERY_DEV_LIM()
1200 dev_lim->hca.arbel.reserved_lkey); in mthca_QUERY_DEV_LIM()
1205 (unsigned long long) dev_lim->hca.arbel.max_icm_sz >> 20); in mthca_QUERY_DEV_LIM()
1208 dev_lim->max_srq_sz = (1 << field) - 1; in mthca_QUERY_DEV_LIM()
1210 dev_lim->max_qp_sz = (1 << field) - 1; in mthca_QUERY_DEV_LIM()
1212 dev_lim->hca.tavor.max_avs = 1 << (field & 0x3f); in mthca_QUERY_DEV_LIM()
1213 dev_lim->mpt_entry_sz = MTHCA_MPT_ENTRY_SIZE; in mthca_QUERY_DEV_LIM()
1217 dev_lim->max_qps, dev_lim->reserved_qps, dev_lim->qpc_entry_sz); in mthca_QUERY_DEV_LIM()
1219 dev_lim->max_srqs, dev_lim->reserved_srqs, dev_lim->srq_entry_sz); in mthca_QUERY_DEV_LIM()
1221 dev_lim->max_cqs, dev_lim->reserved_cqs, dev_lim->cqc_entry_sz); in mthca_QUERY_DEV_LIM()
1223 dev_lim->max_eqs, dev_lim->reserved_eqs, dev_lim->eqc_entry_sz); in mthca_QUERY_DEV_LIM()
1225 dev_lim->reserved_mrws, dev_lim->reserved_mtts); in mthca_QUERY_DEV_LIM()
1227 dev_lim->max_pds, dev_lim->reserved_pds, dev_lim->reserved_uars); in mthca_QUERY_DEV_LIM()
1229 dev_lim->max_pds, dev_lim->reserved_mgms); in mthca_QUERY_DEV_LIM()
1231 dev_lim->max_cq_sz, dev_lim->max_qp_sz, dev_lim->max_srq_sz); in mthca_QUERY_DEV_LIM()
1233 mthca_dbg(dev, "Flags: %08x\n", dev_lim->flags); in mthca_QUERY_DEV_LIM()
1236 mthca_free_mailbox(dev, mailbox); in mthca_QUERY_DEV_LIM()
1259 * swaps each 4-byte word before passing it back to in get_board_id()
1271 struct mthca_mailbox *mailbox; in mthca_QUERY_ADAPTER() local
1282 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_QUERY_ADAPTER()
1283 if (IS_ERR(mailbox)) in mthca_QUERY_ADAPTER()
1284 return PTR_ERR(mailbox); in mthca_QUERY_ADAPTER()
1285 outbox = mailbox->buf; in mthca_QUERY_ADAPTER()
1287 err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_QUERY_ADAPTER, in mthca_QUERY_ADAPTER()
1294 MTHCA_GET(adapter->vendor_id, outbox, in mthca_QUERY_ADAPTER()
1296 MTHCA_GET(adapter->device_id, outbox, in mthca_QUERY_ADAPTER()
1298 MTHCA_GET(adapter->revision_id, outbox, in mthca_QUERY_ADAPTER()
1301 MTHCA_GET(adapter->inta_pin, outbox, QUERY_ADAPTER_INTA_PIN_OFFSET); in mthca_QUERY_ADAPTER()
1304 adapter->board_id); in mthca_QUERY_ADAPTER()
1307 mthca_free_mailbox(dev, mailbox); in mthca_QUERY_ADAPTER()
1314 struct mthca_mailbox *mailbox; in mthca_INIT_HCA() local
1356 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_INIT_HCA()
1357 if (IS_ERR(mailbox)) in mthca_INIT_HCA()
1358 return PTR_ERR(mailbox); in mthca_INIT_HCA()
1359 inbox = mailbox->buf; in mthca_INIT_HCA()
1363 if (dev->mthca_flags & MTHCA_FLAG_SINAI_OPT) in mthca_INIT_HCA()
1377 if (dev->device_cap_flags & IB_DEVICE_UD_IP_CSUM) in mthca_INIT_HCA()
1384 MTHCA_PUT(inbox, param->qpc_base, INIT_HCA_QPC_BASE_OFFSET); in mthca_INIT_HCA()
1385 MTHCA_PUT(inbox, param->log_num_qps, INIT_HCA_LOG_QP_OFFSET); in mthca_INIT_HCA()
1386 MTHCA_PUT(inbox, param->eec_base, INIT_HCA_EEC_BASE_OFFSET); in mthca_INIT_HCA()
1387 MTHCA_PUT(inbox, param->log_num_eecs, INIT_HCA_LOG_EEC_OFFSET); in mthca_INIT_HCA()
1388 MTHCA_PUT(inbox, param->srqc_base, INIT_HCA_SRQC_BASE_OFFSET); in mthca_INIT_HCA()
1389 MTHCA_PUT(inbox, param->log_num_srqs, INIT_HCA_LOG_SRQ_OFFSET); in mthca_INIT_HCA()
1390 MTHCA_PUT(inbox, param->cqc_base, INIT_HCA_CQC_BASE_OFFSET); in mthca_INIT_HCA()
1391 MTHCA_PUT(inbox, param->log_num_cqs, INIT_HCA_LOG_CQ_OFFSET); in mthca_INIT_HCA()
1392 MTHCA_PUT(inbox, param->eqpc_base, INIT_HCA_EQPC_BASE_OFFSET); in mthca_INIT_HCA()
1393 MTHCA_PUT(inbox, param->eeec_base, INIT_HCA_EEEC_BASE_OFFSET); in mthca_INIT_HCA()
1394 MTHCA_PUT(inbox, param->eqc_base, INIT_HCA_EQC_BASE_OFFSET); in mthca_INIT_HCA()
1395 MTHCA_PUT(inbox, param->log_num_eqs, INIT_HCA_LOG_EQ_OFFSET); in mthca_INIT_HCA()
1396 MTHCA_PUT(inbox, param->rdb_base, INIT_HCA_RDB_BASE_OFFSET); in mthca_INIT_HCA()
1402 MTHCA_PUT(inbox, param->mc_base, INIT_HCA_MC_BASE_OFFSET); in mthca_INIT_HCA()
1403 MTHCA_PUT(inbox, param->log_mc_entry_sz, INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET); in mthca_INIT_HCA()
1404 MTHCA_PUT(inbox, param->mc_hash_sz, INIT_HCA_MC_HASH_SZ_OFFSET); in mthca_INIT_HCA()
1405 MTHCA_PUT(inbox, param->log_mc_table_sz, INIT_HCA_LOG_MC_TABLE_SZ_OFFSET); in mthca_INIT_HCA()
1409 MTHCA_PUT(inbox, param->mpt_base, INIT_HCA_MPT_BASE_OFFSET); in mthca_INIT_HCA()
1411 MTHCA_PUT(inbox, param->mtt_seg_sz, INIT_HCA_MTT_SEG_SZ_OFFSET); in mthca_INIT_HCA()
1412 MTHCA_PUT(inbox, param->log_mpt_sz, INIT_HCA_LOG_MPT_SZ_OFFSET); in mthca_INIT_HCA()
1413 MTHCA_PUT(inbox, param->mtt_base, INIT_HCA_MTT_BASE_OFFSET); in mthca_INIT_HCA()
1417 u8 uar_page_sz = PAGE_SHIFT - 12; in mthca_INIT_HCA()
1421 MTHCA_PUT(inbox, param->uar_scratch_base, INIT_HCA_UAR_SCATCH_BASE_OFFSET); in mthca_INIT_HCA()
1424 MTHCA_PUT(inbox, param->log_uarc_sz, INIT_HCA_UARC_SZ_OFFSET); in mthca_INIT_HCA()
1425 MTHCA_PUT(inbox, param->log_uar_sz, INIT_HCA_LOG_UAR_SZ_OFFSET); in mthca_INIT_HCA()
1426 MTHCA_PUT(inbox, param->uarc_base, INIT_HCA_UAR_CTX_BASE_OFFSET); in mthca_INIT_HCA()
1429 err = mthca_cmd(dev, mailbox->dma, 0, 0, in mthca_INIT_HCA()
1432 mthca_free_mailbox(dev, mailbox); in mthca_INIT_HCA()
1440 struct mthca_mailbox *mailbox; in mthca_INIT_IB() local
1459 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_INIT_IB()
1460 if (IS_ERR(mailbox)) in mthca_INIT_IB()
1461 return PTR_ERR(mailbox); in mthca_INIT_IB()
1462 inbox = mailbox->buf; in mthca_INIT_IB()
1467 flags |= param->set_guid0 ? INIT_IB_FLAG_G0 : 0; in mthca_INIT_IB()
1468 flags |= param->set_node_guid ? INIT_IB_FLAG_NG : 0; in mthca_INIT_IB()
1469 flags |= param->set_si_guid ? INIT_IB_FLAG_SIG : 0; in mthca_INIT_IB()
1470 flags |= param->vl_cap << INIT_IB_VL_SHIFT; in mthca_INIT_IB()
1471 flags |= param->port_width << INIT_IB_PORT_WIDTH_SHIFT; in mthca_INIT_IB()
1472 flags |= param->mtu_cap << INIT_IB_MTU_SHIFT; in mthca_INIT_IB()
1475 MTHCA_PUT(inbox, param->gid_cap, INIT_IB_MAX_GID_OFFSET); in mthca_INIT_IB()
1476 MTHCA_PUT(inbox, param->pkey_cap, INIT_IB_MAX_PKEY_OFFSET); in mthca_INIT_IB()
1477 MTHCA_PUT(inbox, param->guid0, INIT_IB_GUID0_OFFSET); in mthca_INIT_IB()
1478 MTHCA_PUT(inbox, param->node_guid, INIT_IB_NODE_GUID_OFFSET); in mthca_INIT_IB()
1479 MTHCA_PUT(inbox, param->si_guid, INIT_IB_SI_GUID_OFFSET); in mthca_INIT_IB()
1481 err = mthca_cmd(dev, mailbox->dma, port, 0, CMD_INIT_IB, in mthca_INIT_IB()
1484 mthca_free_mailbox(dev, mailbox); in mthca_INIT_IB()
1501 struct mthca_mailbox *mailbox; in mthca_SET_IB() local
1513 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_SET_IB()
1514 if (IS_ERR(mailbox)) in mthca_SET_IB()
1515 return PTR_ERR(mailbox); in mthca_SET_IB()
1516 inbox = mailbox->buf; in mthca_SET_IB()
1520 flags |= param->set_si_guid ? SET_IB_FLAG_SIG : 0; in mthca_SET_IB()
1521 flags |= param->reset_qkey_viol ? SET_IB_FLAG_RQK : 0; in mthca_SET_IB()
1524 MTHCA_PUT(inbox, param->cap_mask, SET_IB_CAP_MASK_OFFSET); in mthca_SET_IB()
1525 MTHCA_PUT(inbox, param->si_guid, SET_IB_SI_GUID_OFFSET); in mthca_SET_IB()
1527 err = mthca_cmd(dev, mailbox->dma, port, 0, CMD_SET_IB, in mthca_SET_IB()
1530 mthca_free_mailbox(dev, mailbox); in mthca_SET_IB()
1541 struct mthca_mailbox *mailbox; in mthca_MAP_ICM_page() local
1545 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_MAP_ICM_page()
1546 if (IS_ERR(mailbox)) in mthca_MAP_ICM_page()
1547 return PTR_ERR(mailbox); in mthca_MAP_ICM_page()
1548 inbox = mailbox->buf; in mthca_MAP_ICM_page()
1553 err = mthca_cmd(dev, mailbox->dma, 1, 0, CMD_MAP_ICM, in mthca_MAP_ICM_page()
1556 mthca_free_mailbox(dev, mailbox); in mthca_MAP_ICM_page()
1576 return mthca_map_cmd(dev, CMD_MAP_ICM_AUX, icm, -1); in mthca_MAP_ICM_AUX()
1597 (PAGE_SHIFT - MTHCA_ICM_PAGE_SHIFT); in mthca_SET_ICM_SIZE()
1602 int mthca_SW2HW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox, in mthca_SW2HW_MPT() argument
1605 return mthca_cmd(dev, mailbox->dma, mpt_index, 0, CMD_SW2HW_MPT, in mthca_SW2HW_MPT()
1609 int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox, in mthca_HW2SW_MPT() argument
1612 return mthca_cmd_box(dev, 0, mailbox ? mailbox->dma : 0, mpt_index, in mthca_HW2SW_MPT()
1613 !mailbox, CMD_HW2SW_MPT, in mthca_HW2SW_MPT()
1617 int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox, in mthca_WRITE_MTT() argument
1620 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT, in mthca_WRITE_MTT()
1639 int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox, in mthca_SW2HW_EQ() argument
1642 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ, in mthca_SW2HW_EQ()
1646 int mthca_HW2SW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox, in mthca_HW2SW_EQ() argument
1649 return mthca_cmd_box(dev, 0, mailbox->dma, eq_num, 0, in mthca_HW2SW_EQ()
1654 int mthca_SW2HW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox, in mthca_SW2HW_CQ() argument
1657 return mthca_cmd(dev, mailbox->dma, cq_num, 0, CMD_SW2HW_CQ, in mthca_SW2HW_CQ()
1661 int mthca_HW2SW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox, in mthca_HW2SW_CQ() argument
1664 return mthca_cmd_box(dev, 0, mailbox->dma, cq_num, 0, in mthca_HW2SW_CQ()
1671 struct mthca_mailbox *mailbox; in mthca_RESIZE_CQ() local
1679 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_RESIZE_CQ()
1680 if (IS_ERR(mailbox)) in mthca_RESIZE_CQ()
1681 return PTR_ERR(mailbox); in mthca_RESIZE_CQ()
1682 inbox = mailbox->buf; in mthca_RESIZE_CQ()
1686 * Leave start address fields zeroed out -- mthca assumes that in mthca_RESIZE_CQ()
1692 err = mthca_cmd(dev, mailbox->dma, cq_num, 1, CMD_RESIZE_CQ, in mthca_RESIZE_CQ()
1695 mthca_free_mailbox(dev, mailbox); in mthca_RESIZE_CQ()
1699 int mthca_SW2HW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox, in mthca_SW2HW_SRQ() argument
1702 return mthca_cmd(dev, mailbox->dma, srq_num, 0, CMD_SW2HW_SRQ, in mthca_SW2HW_SRQ()
1706 int mthca_HW2SW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox, in mthca_HW2SW_SRQ() argument
1709 return mthca_cmd_box(dev, 0, mailbox->dma, srq_num, 0, in mthca_HW2SW_SRQ()
1715 struct mthca_mailbox *mailbox) in mthca_QUERY_SRQ() argument
1717 return mthca_cmd_box(dev, 0, mailbox->dma, num, 0, in mthca_QUERY_SRQ()
1729 struct mthca_mailbox *mailbox, u32 optmask) in mthca_MODIFY_QP() argument
1776 op_mod = 3; /* don't write outbox, any->reset */ in mthca_MODIFY_QP()
1779 if (!mailbox) { in mthca_MODIFY_QP()
1780 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_MODIFY_QP()
1781 if (!IS_ERR(mailbox)) { in mthca_MODIFY_QP()
1783 op_mod = 2; /* write outbox, any->reset */ in mthca_MODIFY_QP()
1785 mailbox = NULL; in mthca_MODIFY_QP()
1788 err = mthca_cmd_box(dev, 0, mailbox ? mailbox->dma : 0, in mthca_MODIFY_QP()
1792 if (0 && mailbox) { in mthca_MODIFY_QP()
1795 printk(" %08x\n", be32_to_cpup(mailbox->buf)); in mthca_MODIFY_QP()
1800 be32_to_cpu(((__be32 *) mailbox->buf)[i + 2])); in mthca_MODIFY_QP()
1807 mthca_free_mailbox(dev, mailbox); in mthca_MODIFY_QP()
1812 printk(" opt param mask: %08x\n", be32_to_cpup(mailbox->buf)); in mthca_MODIFY_QP()
1817 be32_to_cpu(((__be32 *) mailbox->buf)[i + 2])); in mthca_MODIFY_QP()
1823 err = mthca_cmd(dev, mailbox->dma, optmask | (!!is_ee << 24) | num, in mthca_MODIFY_QP()
1831 struct mthca_mailbox *mailbox) in mthca_QUERY_QP() argument
1833 return mthca_cmd_box(dev, 0, mailbox->dma, (!!is_ee << 24) | num, 0, in mthca_QUERY_QP()
1855 return -EINVAL; in mthca_CONF_SPECIAL_QP()
1884 inbox = inmailbox->buf; in mthca_MAD_IFC()
1908 MTHCA_PUT(inbox, in_wc->qp->qp_num, MAD_IFC_MY_QPN_OFFSET); in mthca_MAD_IFC()
1909 MTHCA_PUT(inbox, in_wc->src_qp, MAD_IFC_RQPN_OFFSET); in mthca_MAD_IFC()
1911 val = in_wc->sl << 4; in mthca_MAD_IFC()
1914 val = in_wc->dlid_path_bits | in mthca_MAD_IFC()
1915 (in_wc->wc_flags & IB_WC_GRH ? 0x80 : 0); in mthca_MAD_IFC()
1918 MTHCA_PUT(inbox, ib_lid_cpu16(in_wc->slid), MAD_IFC_RLID_OFFSET); in mthca_MAD_IFC()
1919 MTHCA_PUT(inbox, in_wc->pkey_index, MAD_IFC_PKEY_OFFSET); in mthca_MAD_IFC()
1926 in_modifier |= ib_lid_cpu16(in_wc->slid) << 16; in mthca_MAD_IFC()
1929 err = mthca_cmd_box(dev, inmailbox->dma, outmailbox->dma, in mthca_MAD_IFC()
1934 memcpy(response_mad, outmailbox->buf, 256); in mthca_MAD_IFC()
1942 struct mthca_mailbox *mailbox) in mthca_READ_MGM() argument
1944 return mthca_cmd_box(dev, 0, mailbox->dma, index, 0, in mthca_READ_MGM()
1949 struct mthca_mailbox *mailbox) in mthca_WRITE_MGM() argument
1951 return mthca_cmd(dev, mailbox->dma, index, 0, CMD_WRITE_MGM, in mthca_WRITE_MGM()
1955 int mthca_MGID_HASH(struct mthca_dev *dev, struct mthca_mailbox *mailbox, in mthca_MGID_HASH() argument
1961 err = mthca_cmd_imm(dev, mailbox->dma, &imm, 0, 0, CMD_MGID_HASH, in mthca_MGID_HASH()