36 #include <linux/pci.h>
37 #include <linux/errno.h>
38 #include <linux/sched.h>
39 #include <linux/module.h>
40 #include <linux/slab.h>
49 #define CMD_POLL_TOKEN 0xffff
187 static int fw_cmd_doorbell = 0;
189 MODULE_PARM_DESC(fw_cmd_doorbell,
"post FW commands through doorbell page if nonzero "
190 "(and supported by FW)");
230 static int mthca_cmd_post_hcr(
struct mthca_dev *dev,
270 op), dev->
hcr + 6 * 4);
275 static int mthca_cmd_post(
struct mthca_dev *dev,
289 mthca_cmd_post_dbell(dev, in_param, out_param, in_modifier,
290 op_modifier, op, token);
292 err = mthca_cmd_post_hcr(dev, in_param, out_param, in_modifier,
293 op_modifier, op, token, event);
306 static int mthca_status_to_errno(
u8 status)
308 static const int trans_table[] = {
330 && trans_table[status] == 0))
333 return trans_table[
status];
337 static int mthca_cmd_poll(
struct mthca_dev *dev,
344 unsigned long timeout)
352 err = mthca_cmd_post(dev, in_param,
353 out_param ? *out_param : 0,
354 in_modifier, op_modifier,
379 mthca_dbg(dev,
"Command %02x completed with status %02x\n",
381 err = mthca_status_to_errno(status);
385 up(&dev->
cmd.poll_sem);
395 &dev->
cmd.context[token & dev->
cmd.token_mask];
398 if (token != context->
token)
408 static int mthca_cmd_wait(
struct mthca_dev *dev,
415 unsigned long timeout)
422 spin_lock(&dev->
cmd.context_lock);
424 context = &dev->
cmd.context[dev->
cmd.free_head];
425 context->
token += dev->
cmd.token_mask + 1;
426 dev->
cmd.free_head = context->
next;
427 spin_unlock(&dev->
cmd.context_lock);
429 init_completion(&context->
done);
431 err = mthca_cmd_post(dev, in_param,
432 out_param ? *out_param : 0,
433 in_modifier, op_modifier,
434 op, context->
token, 1);
448 mthca_dbg(dev,
"Command %02x completed with status %02x\n",
450 err = mthca_status_to_errno(context->
status);
457 spin_lock(&dev->
cmd.context_lock);
458 context->
next = dev->
cmd.free_head;
459 dev->
cmd.free_head = context - dev->
cmd.context;
460 spin_unlock(&dev->
cmd.context_lock);
462 up(&dev->
cmd.event_sem);
467 static int mthca_cmd_box(
struct mthca_dev *dev,
473 unsigned long timeout)
476 return mthca_cmd_wait(dev, in_param, &out_param, 0,
477 in_modifier, op_modifier, op,
480 return mthca_cmd_poll(dev, in_param, &out_param, 0,
481 in_modifier, op_modifier, op,
491 unsigned long timeout)
493 return mthca_cmd_box(dev, in_param, 0, in_modifier,
494 op_modifier, op, timeout);
502 static int mthca_cmd_imm(
struct mthca_dev *dev,
508 unsigned long timeout)
511 return mthca_cmd_wait(dev, in_param, out_param, 1,
512 in_modifier, op_modifier, op,
515 return mthca_cmd_poll(dev, in_param, out_param, 1,
516 in_modifier, op_modifier, op,
523 sema_init(&dev->
cmd.poll_sem, 1);
529 mthca_err(dev,
"Couldn't map command register.");
533 dev->
cmd.pool = pci_pool_create(
"mthca_cmd", dev->
pdev,
536 if (!dev->
cmd.pool) {
546 pci_pool_destroy(dev->
cmd.pool);
563 if (!dev->
cmd.context)
566 for (i = 0; i < dev->
cmd.max_cmds; ++
i) {
567 dev->
cmd.context[
i].token =
i;
568 dev->
cmd.context[
i].next = i + 1;
571 dev->
cmd.context[dev->
cmd.max_cmds - 1].next = -1;
572 dev->
cmd.free_head = 0;
574 sema_init(&dev->
cmd.event_sem, dev->
cmd.max_cmds);
577 for (dev->
cmd.token_mask = 1;
578 dev->
cmd.token_mask < dev->
cmd.max_cmds;
579 dev->
cmd.token_mask <<= 1)
581 --dev->
cmd.token_mask;
599 for (i = 0; i < dev->
cmd.max_cmds; ++
i)
604 up(&dev->
cmd.poll_sem);
612 mailbox =
kmalloc(
sizeof *mailbox, gfp_mask);
616 mailbox->
buf = pci_pool_alloc(dev->
cmd.pool, gfp_mask, &mailbox->
dma);
630 pci_pool_free(dev->
cmd.pool, mailbox->
buf, mailbox->
dma);
642 mthca_warn(dev,
"SYS_EN DDR error: syn=%x, sock=%d, "
643 "sladdr=%d, SPD source=%s\n",
644 (
int) (out >> 6) & 0xf, (
int) (out >> 4) & 3,
645 (
int) (out >> 1) & 7, (
int) out & 1 ?
"NVMEM" :
"DIMM");
669 return PTR_ERR(mailbox);
671 pages = mailbox->
buf;
673 for (mthca_icm_first(icm, &iter);
674 !mthca_icm_last(&iter);
675 mthca_icm_next(&iter)) {
681 lg =
ffs(mthca_icm_addr(&iter) | mthca_icm_size(&iter)) - 1;
683 mthca_warn(dev,
"Got FW area not aligned to %d (%llx/%lx).\n",
685 (
unsigned long long) mthca_icm_addr(&iter),
686 mthca_icm_size(&iter));
690 for (i = 0; i < mthca_icm_size(&iter) >> lg; ++
i) {
696 pages[nent * 2 + 1] =
699 ts += 1 << (lg - 10);
718 mthca_dbg(dev,
"Mapped %d chunks/%d KB for FW.\n",
tc, ts);
721 mthca_dbg(dev,
"Mapped %d chunks/%d KB for ICM aux.\n",
tc, ts);
724 mthca_dbg(dev,
"Mapped %d chunks/%d KB at %llx for ICM.\n",
725 tc, ts, (
unsigned long long) virt - (ts << 10));
736 return mthca_map_cmd(dev,
CMD_MAP_FA, icm, -1);
749 static void mthca_setup_cmd_doorbells(
struct mthca_dev *dev,
u64 base)
755 for (i = 0; i < 8; ++
i)
756 max_off =
max(max_off, dev->
cmd.dbell_offsets[i]);
758 if ((base &
PAGE_MASK) != ((base + max_off) & PAGE_MASK)) {
759 mthca_warn(dev,
"Firmware doorbell region at 0x%016llx, "
760 "length 0x%x crosses a page boundary\n",
761 (
unsigned long long) base, max_off);
767 dev->
cmd.dbell_map =
ioremap(addr, max_off +
sizeof(u32));
768 if (!dev->
cmd.dbell_map)
772 mthca_dbg(dev,
"Mapped doorbell page for posting FW commands\n");
785 #define QUERY_FW_OUT_SIZE 0x100
786 #define QUERY_FW_VER_OFFSET 0x00
787 #define QUERY_FW_MAX_CMD_OFFSET 0x0f
788 #define QUERY_FW_ERR_START_OFFSET 0x30
789 #define QUERY_FW_ERR_SIZE_OFFSET 0x38
791 #define QUERY_FW_CMD_DB_EN_OFFSET 0x10
792 #define QUERY_FW_CMD_DB_OFFSET 0x50
793 #define QUERY_FW_CMD_DB_BASE 0x60
795 #define QUERY_FW_START_OFFSET 0x20
796 #define QUERY_FW_END_OFFSET 0x28
798 #define QUERY_FW_SIZE_OFFSET 0x00
799 #define QUERY_FW_CLR_INT_BASE_OFFSET 0x20
800 #define QUERY_FW_EQ_ARM_BASE_OFFSET 0x40
801 #define QUERY_FW_EQ_SET_CI_BASE_OFFSET 0x48
805 return PTR_ERR(mailbox);
806 outbox = mailbox->
buf;
820 ((dev->
fw_ver & 0xffff0000ull) >> 16) |
821 ((dev->
fw_ver & 0x0000ffffull) << 16);
824 dev->
cmd.max_cmds = 1 << lg;
826 mthca_dbg(dev,
"FW version %012llx, max commands %d\n",
827 (
unsigned long long) dev->
fw_ver, dev->
cmd.max_cmds);
832 mthca_dbg(dev,
"Catastrophic error buffer at 0x%llx, size 0x%x\n",
837 mthca_dbg(dev,
"FW supports commands through doorbells\n");
844 mthca_setup_cmd_doorbells(dev, base);
847 if (mthca_is_memfree(dev)) {
862 mthca_dbg(dev,
"Clear int @ %llx, EQ arm @ %llx, EQ set CI @ %llx\n",
863 (
unsigned long long) dev->
fw.
arbel.clr_int_base,
864 (
unsigned long long) dev->
fw.
arbel.eq_arm_base,
865 (
unsigned long long) dev->
fw.
arbel.eq_set_ci_base);
870 mthca_dbg(dev,
"FW size %d KB (start %llx, end %llx)\n",
872 (
unsigned long long) dev->
fw.
tavor.fw_start,
873 (
unsigned long long) dev->
fw.
tavor.fw_end);
888 #define ENABLE_LAM_OUT_SIZE 0x100
889 #define ENABLE_LAM_START_OFFSET 0x00
890 #define ENABLE_LAM_END_OFFSET 0x08
891 #define ENABLE_LAM_INFO_OFFSET 0x13
893 #define ENABLE_LAM_INFO_HIDDEN_FLAG (1 << 4)
894 #define ENABLE_LAM_INFO_ECC_MASK 0x3
898 return PTR_ERR(mailbox);
899 outbox = mailbox->
buf;
913 mthca_info(dev,
"FW reports that HCA-attached memory "
914 "is %s hidden; does not match PCI config\n",
915 (info & ENABLE_LAM_INFO_HIDDEN_FLAG) ?
918 if (info & ENABLE_LAM_INFO_HIDDEN_FLAG)
919 mthca_dbg(dev,
"HCA-attached memory is hidden.\n");
921 mthca_dbg(dev,
"HCA memory size %d KB (start %llx, end %llx)\n",
924 (
unsigned long long) dev->
ddr_end);
943 #define QUERY_DDR_OUT_SIZE 0x100
944 #define QUERY_DDR_START_OFFSET 0x00
945 #define QUERY_DDR_END_OFFSET 0x08
946 #define QUERY_DDR_INFO_OFFSET 0x13
948 #define QUERY_DDR_INFO_HIDDEN_FLAG (1 << 4)
949 #define QUERY_DDR_INFO_ECC_MASK 0x3
953 return PTR_ERR(mailbox);
954 outbox = mailbox->
buf;
968 mthca_info(dev,
"FW reports that HCA-attached memory "
969 "is %s hidden; does not match PCI config\n",
970 (info & QUERY_DDR_INFO_HIDDEN_FLAG) ?
973 if (info & QUERY_DDR_INFO_HIDDEN_FLAG)
974 mthca_dbg(dev,
"HCA-attached memory is hidden.\n");
976 mthca_dbg(dev,
"HCA memory size %d KB (start %llx, end %llx)\n",
979 (
unsigned long long) dev->
ddr_end);
996 #define QUERY_DEV_LIM_OUT_SIZE 0x100
997 #define QUERY_DEV_LIM_MAX_SRQ_SZ_OFFSET 0x10
998 #define QUERY_DEV_LIM_MAX_QP_SZ_OFFSET 0x11
999 #define QUERY_DEV_LIM_RSVD_QP_OFFSET 0x12
1000 #define QUERY_DEV_LIM_MAX_QP_OFFSET 0x13
1001 #define QUERY_DEV_LIM_RSVD_SRQ_OFFSET 0x14
1002 #define QUERY_DEV_LIM_MAX_SRQ_OFFSET 0x15
1003 #define QUERY_DEV_LIM_RSVD_EEC_OFFSET 0x16
1004 #define QUERY_DEV_LIM_MAX_EEC_OFFSET 0x17
1005 #define QUERY_DEV_LIM_MAX_CQ_SZ_OFFSET 0x19
1006 #define QUERY_DEV_LIM_RSVD_CQ_OFFSET 0x1a
1007 #define QUERY_DEV_LIM_MAX_CQ_OFFSET 0x1b
1008 #define QUERY_DEV_LIM_MAX_MPT_OFFSET 0x1d
1009 #define QUERY_DEV_LIM_RSVD_EQ_OFFSET 0x1e
1010 #define QUERY_DEV_LIM_MAX_EQ_OFFSET 0x1f
1011 #define QUERY_DEV_LIM_RSVD_MTT_OFFSET 0x20
1012 #define QUERY_DEV_LIM_MAX_MRW_SZ_OFFSET 0x21
1013 #define QUERY_DEV_LIM_RSVD_MRW_OFFSET 0x22
1014 #define QUERY_DEV_LIM_MAX_MTT_SEG_OFFSET 0x23
1015 #define QUERY_DEV_LIM_MAX_AV_OFFSET 0x27
1016 #define QUERY_DEV_LIM_MAX_REQ_QP_OFFSET 0x29
1017 #define QUERY_DEV_LIM_MAX_RES_QP_OFFSET 0x2b
1018 #define QUERY_DEV_LIM_MAX_RDMA_OFFSET 0x2f
1019 #define QUERY_DEV_LIM_RSZ_SRQ_OFFSET 0x33
1020 #define QUERY_DEV_LIM_ACK_DELAY_OFFSET 0x35
1021 #define QUERY_DEV_LIM_MTU_WIDTH_OFFSET 0x36
1022 #define QUERY_DEV_LIM_VL_PORT_OFFSET 0x37
1023 #define QUERY_DEV_LIM_MAX_GID_OFFSET 0x3b
1024 #define QUERY_DEV_LIM_RATE_SUPPORT_OFFSET 0x3c
1025 #define QUERY_DEV_LIM_MAX_PKEY_OFFSET 0x3f
1026 #define QUERY_DEV_LIM_FLAGS_OFFSET 0x44
1027 #define QUERY_DEV_LIM_RSVD_UAR_OFFSET 0x48
1028 #define QUERY_DEV_LIM_UAR_SZ_OFFSET 0x49
1029 #define QUERY_DEV_LIM_PAGE_SZ_OFFSET 0x4b
1030 #define QUERY_DEV_LIM_MAX_SG_OFFSET 0x51
1031 #define QUERY_DEV_LIM_MAX_DESC_SZ_OFFSET 0x52
1032 #define QUERY_DEV_LIM_MAX_SG_RQ_OFFSET 0x55
1033 #define QUERY_DEV_LIM_MAX_DESC_SZ_RQ_OFFSET 0x56
1034 #define QUERY_DEV_LIM_MAX_QP_MCG_OFFSET 0x61
1035 #define QUERY_DEV_LIM_RSVD_MCG_OFFSET 0x62
1036 #define QUERY_DEV_LIM_MAX_MCG_OFFSET 0x63
1037 #define QUERY_DEV_LIM_RSVD_PD_OFFSET 0x64
1038 #define QUERY_DEV_LIM_MAX_PD_OFFSET 0x65
1039 #define QUERY_DEV_LIM_RSVD_RDD_OFFSET 0x66
1040 #define QUERY_DEV_LIM_MAX_RDD_OFFSET 0x67
1041 #define QUERY_DEV_LIM_EEC_ENTRY_SZ_OFFSET 0x80
1042 #define QUERY_DEV_LIM_QPC_ENTRY_SZ_OFFSET 0x82
1043 #define QUERY_DEV_LIM_EEEC_ENTRY_SZ_OFFSET 0x84
1044 #define QUERY_DEV_LIM_EQPC_ENTRY_SZ_OFFSET 0x86
1045 #define QUERY_DEV_LIM_EQC_ENTRY_SZ_OFFSET 0x88
1046 #define QUERY_DEV_LIM_CQC_ENTRY_SZ_OFFSET 0x8a
1047 #define QUERY_DEV_LIM_SRQ_ENTRY_SZ_OFFSET 0x8c
1048 #define QUERY_DEV_LIM_UAR_ENTRY_SZ_OFFSET 0x8e
1049 #define QUERY_DEV_LIM_MTT_ENTRY_SZ_OFFSET 0x90
1050 #define QUERY_DEV_LIM_MPT_ENTRY_SZ_OFFSET 0x92
1051 #define QUERY_DEV_LIM_PBL_SZ_OFFSET 0x96
1052 #define QUERY_DEV_LIM_BMME_FLAGS_OFFSET 0x97
1053 #define QUERY_DEV_LIM_RSVD_LKEY_OFFSET 0x98
1054 #define QUERY_DEV_LIM_LAMR_OFFSET 0x9f
1055 #define QUERY_DEV_LIM_MAX_ICM_SZ_OFFSET 0xa0
1058 if (IS_ERR(mailbox))
1059 return PTR_ERR(mailbox);
1060 outbox = mailbox->
buf;
1071 dev_lim->
max_qps = 1 << (field & 0x1f);
1075 dev_lim->
max_srqs = 1 << (field & 0x1f);
1079 dev_lim->
max_eecs = 1 << (field & 0x1f);
1085 dev_lim->
max_cqs = 1 << (field & 0x1f);
1087 dev_lim->
max_mpts = 1 << (field & 0x3f);
1091 dev_lim->
max_eqs = 1 << (field & 0x7);
1093 if (mthca_is_memfree(dev))
1113 dev_lim->
max_mtu = field >> 4;
1116 dev_lim->
max_vl = field >> 4;
1119 dev_lim->
max_gids = 1 << (field & 0xf);
1123 dev_lim->
max_pkeys = 1 << (field & 0xf);
1128 dev_lim->
uar_size = 1 << ((field & 0x3f) + 20);
1146 dev_lim->
max_pds = 1 << (field & 0x3f);
1150 dev_lim->
max_rdds = 1 << (field & 0x3f);
1169 if (mthca_is_memfree(dev)) {
1175 dev_lim->
hca.
arbel.resize_srq = field & 1;
1183 dev_lim->
hca.
arbel.max_pbl_sz = 1 << (field & 0x3f);
1189 dev_lim->
hca.
arbel.lam_required = field & 1;
1193 if (dev_lim->
hca.
arbel.bmme_flags & 1)
1194 mthca_dbg(dev,
"Base MM extensions: yes "
1195 "(flags %d, max PBL %d, rsvd L_Key %08x)\n",
1200 mthca_dbg(dev,
"Base MM extensions: no\n");
1202 mthca_dbg(dev,
"Max ICM size %lld MB\n",
1203 (
unsigned long long) dev_lim->
hca.
arbel.max_icm_sz >> 20);
1210 dev_lim->
hca.
tavor.max_avs = 1 << (field & 0x3f);
1214 mthca_dbg(dev,
"Max QPs: %d, reserved QPs: %d, entry size: %d\n",
1216 mthca_dbg(dev,
"Max SRQs: %d, reserved SRQs: %d, entry size: %d\n",
1218 mthca_dbg(dev,
"Max CQs: %d, reserved CQs: %d, entry size: %d\n",
1220 mthca_dbg(dev,
"Max EQs: %d, reserved EQs: %d, entry size: %d\n",
1222 mthca_dbg(dev,
"reserved MPTs: %d, reserved MTTs: %d\n",
1224 mthca_dbg(dev,
"Max PDs: %d, reserved PDs: %d, reserved UARs: %d\n",
1226 mthca_dbg(dev,
"Max QP/MCG: %d, reserved MGMs: %d\n",
1228 mthca_dbg(dev,
"Max CQEs: %d, max WQEs: %d, max SRQ WQEs: %d\n",
1238 static void get_board_id(
void *vsd,
char *
board_id)
1242 #define VSD_OFFSET_SIG1 0x00
1243 #define VSD_OFFSET_SIG2 0xde
1244 #define VSD_OFFSET_MLX_BOARD_ID 0xd0
1245 #define VSD_OFFSET_TS_BOARD_ID 0x20
1247 #define VSD_SIGNATURE_TOPSPIN 0x5ad
1251 if (
be16_to_cpup(vsd + VSD_OFFSET_SIG1) == VSD_SIGNATURE_TOPSPIN &&
1252 be16_to_cpup(vsd + VSD_OFFSET_SIG2) == VSD_SIGNATURE_TOPSPIN) {
1260 for (i = 0; i < 4; ++
i)
1261 ((u32 *) board_id)[
i] =
1262 swab32(*(u32 *) (vsd + VSD_OFFSET_MLX_BOARD_ID + i * 4));
1273 #define QUERY_ADAPTER_OUT_SIZE 0x100
1274 #define QUERY_ADAPTER_VENDOR_ID_OFFSET 0x00
1275 #define QUERY_ADAPTER_DEVICE_ID_OFFSET 0x04
1276 #define QUERY_ADAPTER_REVISION_ID_OFFSET 0x08
1277 #define QUERY_ADAPTER_INTA_PIN_OFFSET 0x10
1278 #define QUERY_ADAPTER_VSD_OFFSET 0x20
1281 if (IS_ERR(mailbox))
1282 return PTR_ERR(mailbox);
1283 outbox = mailbox->
buf;
1291 if (!mthca_is_memfree(dev)) {
1316 #define INIT_HCA_IN_SIZE 0x200
1317 #define INIT_HCA_FLAGS1_OFFSET 0x00c
1318 #define INIT_HCA_FLAGS2_OFFSET 0x014
1319 #define INIT_HCA_QPC_OFFSET 0x020
1320 #define INIT_HCA_QPC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x10)
1321 #define INIT_HCA_LOG_QP_OFFSET (INIT_HCA_QPC_OFFSET + 0x17)
1322 #define INIT_HCA_EEC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x20)
1323 #define INIT_HCA_LOG_EEC_OFFSET (INIT_HCA_QPC_OFFSET + 0x27)
1324 #define INIT_HCA_SRQC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x28)
1325 #define INIT_HCA_LOG_SRQ_OFFSET (INIT_HCA_QPC_OFFSET + 0x2f)
1326 #define INIT_HCA_CQC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x30)
1327 #define INIT_HCA_LOG_CQ_OFFSET (INIT_HCA_QPC_OFFSET + 0x37)
1328 #define INIT_HCA_EQPC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x40)
1329 #define INIT_HCA_EEEC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x50)
1330 #define INIT_HCA_EQC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x60)
1331 #define INIT_HCA_LOG_EQ_OFFSET (INIT_HCA_QPC_OFFSET + 0x67)
1332 #define INIT_HCA_RDB_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x70)
1333 #define INIT_HCA_UDAV_OFFSET 0x0b0
1334 #define INIT_HCA_UDAV_LKEY_OFFSET (INIT_HCA_UDAV_OFFSET + 0x0)
1335 #define INIT_HCA_UDAV_PD_OFFSET (INIT_HCA_UDAV_OFFSET + 0x4)
1336 #define INIT_HCA_MCAST_OFFSET 0x0c0
1337 #define INIT_HCA_MC_BASE_OFFSET (INIT_HCA_MCAST_OFFSET + 0x00)
1338 #define INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x12)
1339 #define INIT_HCA_MC_HASH_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x16)
1340 #define INIT_HCA_LOG_MC_TABLE_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x1b)
1341 #define INIT_HCA_TPT_OFFSET 0x0f0
1342 #define INIT_HCA_MPT_BASE_OFFSET (INIT_HCA_TPT_OFFSET + 0x00)
1343 #define INIT_HCA_MTT_SEG_SZ_OFFSET (INIT_HCA_TPT_OFFSET + 0x09)
1344 #define INIT_HCA_LOG_MPT_SZ_OFFSET (INIT_HCA_TPT_OFFSET + 0x0b)
1345 #define INIT_HCA_MTT_BASE_OFFSET (INIT_HCA_TPT_OFFSET + 0x10)
1346 #define INIT_HCA_UAR_OFFSET 0x120
1347 #define INIT_HCA_UAR_BASE_OFFSET (INIT_HCA_UAR_OFFSET + 0x00)
1348 #define INIT_HCA_UARC_SZ_OFFSET (INIT_HCA_UAR_OFFSET + 0x09)
1349 #define INIT_HCA_LOG_UAR_SZ_OFFSET (INIT_HCA_UAR_OFFSET + 0x0a)
1350 #define INIT_HCA_UAR_PAGE_SZ_OFFSET (INIT_HCA_UAR_OFFSET + 0x0b)
1351 #define INIT_HCA_UAR_SCATCH_BASE_OFFSET (INIT_HCA_UAR_OFFSET + 0x10)
1352 #define INIT_HCA_UAR_CTX_BASE_OFFSET (INIT_HCA_UAR_OFFSET + 0x18)
1355 if (IS_ERR(mailbox))
1356 return PTR_ERR(mailbox);
1357 inbox = mailbox->
buf;
1364 #if defined(__LITTLE_ENDIAN)
1366 #elif defined(__BIG_ENDIAN)
1369 #error Host endianness not defined
1408 if (!mthca_is_memfree(dev))
1421 if (mthca_is_memfree(dev)) {
1443 #define INIT_IB_IN_SIZE 56
1444 #define INIT_IB_FLAGS_OFFSET 0x00
1445 #define INIT_IB_FLAG_SIG (1 << 18)
1446 #define INIT_IB_FLAG_NG (1 << 17)
1447 #define INIT_IB_FLAG_G0 (1 << 16)
1448 #define INIT_IB_VL_SHIFT 4
1449 #define INIT_IB_PORT_WIDTH_SHIFT 8
1450 #define INIT_IB_MTU_SHIFT 12
1451 #define INIT_IB_MAX_GID_OFFSET 0x06
1452 #define INIT_IB_MAX_PKEY_OFFSET 0x0a
1453 #define INIT_IB_GUID0_OFFSET 0x10
1454 #define INIT_IB_NODE_GUID_OFFSET 0x18
1455 #define INIT_IB_SI_GUID_OFFSET 0x20
1458 if (IS_ERR(mailbox))
1459 return PTR_ERR(mailbox);
1460 inbox = mailbox->
buf;
1504 #define SET_IB_IN_SIZE 0x40
1505 #define SET_IB_FLAGS_OFFSET 0x00
1506 #define SET_IB_FLAG_SIG (1 << 18)
1507 #define SET_IB_FLAG_RQK (1 << 0)
1508 #define SET_IB_CAP_MASK_OFFSET 0x04
1509 #define SET_IB_SI_GUID_OFFSET 0x08
1512 if (IS_ERR(mailbox))
1513 return PTR_ERR(mailbox);
1514 inbox = mailbox->
buf;
1534 return mthca_map_cmd(dev,
CMD_MAP_ICM, icm, virt);
1544 if (IS_ERR(mailbox))
1545 return PTR_ERR(mailbox);
1546 inbox = mailbox->
buf;
1557 mthca_dbg(dev,
"Mapped page at %llx to %llx for ICM.\n",
1558 (
unsigned long long) dma_addr, (
unsigned long long) virt);
1565 mthca_dbg(dev,
"Unmapping %d pages at %llx from ICM.\n",
1566 page_count, (
unsigned long long) virt);
1568 return mthca_cmd(dev, virt, page_count, 0,
1584 int ret = mthca_cmd_imm(dev, icm_size, aux_pages, 0,
1610 return mthca_cmd_box(dev, 0, mailbox ? mailbox->
dma : 0, mpt_index,
1630 mthca_dbg(dev,
"%s mask %016llx for eqn %d\n",
1631 unmap ?
"Clearing" :
"Setting",
1632 (
unsigned long long) event_mask, eq_num);
1633 return mthca_cmd(dev, event_mask, (unmap << 31) | eq_num,
1647 return mthca_cmd_box(dev, 0, mailbox->
dma, eq_num, 0,
1662 return mthca_cmd_box(dev, 0, mailbox->
dma, cq_num, 0,
1673 #define RESIZE_CQ_IN_SIZE 0x40
1674 #define RESIZE_CQ_LOG_SIZE_OFFSET 0x0c
1675 #define RESIZE_CQ_LKEY_OFFSET 0x1c
1678 if (IS_ERR(mailbox))
1679 return PTR_ERR(mailbox);
1680 inbox = mailbox->
buf;
1707 return mthca_cmd_box(dev, 0, mailbox->
dma, srq_num, 0,
1715 return mthca_cmd_box(dev, 0, mailbox->
dma, num, 0,
1779 if (!IS_ERR(mailbox)) {
1786 err = mthca_cmd_box(dev, 0, mailbox ? mailbox->
dma : 0,
1787 (!!is_ee << 24) | num, op_mod,
1792 mthca_dbg(dev,
"Dumping QP context:\n");
1794 for (i = 0; i < 0x100 / 4; ++
i) {
1796 printk(
"[%02x] ", i * 4);
1799 if ((i + 1) % 8 == 0)
1809 mthca_dbg(dev,
"Dumping QP context:\n");
1811 for (i = 0; i < 0x100 / 4; ++
i) {
1813 printk(
" [%02x] ", i * 4);
1816 if ((i + 1) % 8 == 0)
1821 err =
mthca_cmd(dev, mailbox->
dma, optmask | (!!is_ee << 24) | num,
1831 return mthca_cmd_box(dev, 0, mailbox->
dma, (!!is_ee << 24) | num, 0,
1862 void *in_mad,
void *response_mad)
1867 u32 in_modifier =
port;
1870 #define MAD_IFC_BOX_SIZE 0x400
1871 #define MAD_IFC_MY_QPN_OFFSET 0x100
1872 #define MAD_IFC_RQPN_OFFSET 0x108
1873 #define MAD_IFC_SL_OFFSET 0x10c
1874 #define MAD_IFC_G_PATH_OFFSET 0x10d
1875 #define MAD_IFC_RLID_OFFSET 0x10e
1876 #define MAD_IFC_PKEY_OFFSET 0x112
1877 #define MAD_IFC_GRH_OFFSET 0x140
1880 if (IS_ERR(inmailbox))
1881 return PTR_ERR(inmailbox);
1882 inbox = inmailbox->
buf;
1885 if (IS_ERR(outmailbox)) {
1887 return PTR_ERR(outmailbox);
1890 memcpy(inbox, in_mad, 256);
1896 if (ignore_mkey || !in_wc)
1898 if (ignore_bkey || !in_wc)
1904 memset(inbox + 256, 0, 256);
1909 val = in_wc->
sl << 4;
1924 in_modifier |= in_wc->
slid << 16;
1927 err = mthca_cmd_box(dev, inmailbox->
dma, outmailbox->
dma,
1928 in_modifier, op_modifier,
1932 memcpy(response_mad, outmailbox->
buf, 256);
1942 return mthca_cmd_box(dev, 0, mailbox->
dma, index, 0,