52 #define H_ALL_RES_QP_ENHANCED_OPS EHCA_BMASK_IBM(9, 11)
53 #define H_ALL_RES_QP_PTE_PIN EHCA_BMASK_IBM(12, 12)
54 #define H_ALL_RES_QP_SERVICE_TYPE EHCA_BMASK_IBM(13, 15)
55 #define H_ALL_RES_QP_STORAGE EHCA_BMASK_IBM(16, 17)
56 #define H_ALL_RES_QP_LL_RQ_CQE_POSTING EHCA_BMASK_IBM(18, 18)
57 #define H_ALL_RES_QP_LL_SQ_CQE_POSTING EHCA_BMASK_IBM(19, 21)
58 #define H_ALL_RES_QP_SIGNALING_TYPE EHCA_BMASK_IBM(22, 23)
59 #define H_ALL_RES_QP_UD_AV_LKEY_CTRL EHCA_BMASK_IBM(31, 31)
60 #define H_ALL_RES_QP_SMALL_SQ_PAGE_SIZE EHCA_BMASK_IBM(32, 35)
61 #define H_ALL_RES_QP_SMALL_RQ_PAGE_SIZE EHCA_BMASK_IBM(36, 39)
62 #define H_ALL_RES_QP_RESOURCE_TYPE EHCA_BMASK_IBM(56, 63)
64 #define H_ALL_RES_QP_MAX_OUTST_SEND_WR EHCA_BMASK_IBM(0, 15)
65 #define H_ALL_RES_QP_MAX_OUTST_RECV_WR EHCA_BMASK_IBM(16, 31)
66 #define H_ALL_RES_QP_MAX_SEND_SGE EHCA_BMASK_IBM(32, 39)
67 #define H_ALL_RES_QP_MAX_RECV_SGE EHCA_BMASK_IBM(40, 47)
69 #define H_ALL_RES_QP_UD_AV_LKEY EHCA_BMASK_IBM(32, 63)
70 #define H_ALL_RES_QP_SRQ_QP_TOKEN EHCA_BMASK_IBM(0, 31)
71 #define H_ALL_RES_QP_SRQ_QP_HANDLE EHCA_BMASK_IBM(0, 64)
72 #define H_ALL_RES_QP_SRQ_LIMIT EHCA_BMASK_IBM(48, 63)
73 #define H_ALL_RES_QP_SRQ_QPN EHCA_BMASK_IBM(40, 63)
75 #define H_ALL_RES_QP_ACT_OUTST_SEND_WR EHCA_BMASK_IBM(16, 31)
76 #define H_ALL_RES_QP_ACT_OUTST_RECV_WR EHCA_BMASK_IBM(48, 63)
77 #define H_ALL_RES_QP_ACT_SEND_SGE EHCA_BMASK_IBM(8, 15)
78 #define H_ALL_RES_QP_ACT_RECV_SGE EHCA_BMASK_IBM(24, 31)
80 #define H_ALL_RES_QP_SQUEUE_SIZE_PAGES EHCA_BMASK_IBM(0, 31)
81 #define H_ALL_RES_QP_RQUEUE_SIZE_PAGES EHCA_BMASK_IBM(32, 63)
83 #define H_MP_INIT_TYPE EHCA_BMASK_IBM(44, 47)
84 #define H_MP_SHUTDOWN EHCA_BMASK_IBM(48, 48)
85 #define H_MP_RESET_QKEY_CTR EHCA_BMASK_IBM(49, 49)
87 #define HCALL4_REGS_FORMAT "r4=%lx r5=%lx r6=%lx r7=%lx"
88 #define HCALL7_REGS_FORMAT HCALL4_REGS_FORMAT " r8=%lx r9=%lx r10=%lx"
89 #define HCALL9_REGS_FORMAT HCALL7_REGS_FORMAT " r11=%lx r12=%lx"
93 static u32 get_longbusy_msecs(
int longbusy_rc)
95 switch (longbusy_rc) {
96 case H_LONG_BUSY_ORDER_1_MSEC:
98 case H_LONG_BUSY_ORDER_10_MSEC:
100 case H_LONG_BUSY_ORDER_100_MSEC:
102 case H_LONG_BUSY_ORDER_1_SEC:
104 case H_LONG_BUSY_ORDER_10_SEC:
106 case H_LONG_BUSY_ORDER_100_SEC:
113 static long ehca_plpar_hcall_norets(
unsigned long opcode,
124 unsigned long flags = 0;
128 opcode, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
130 for (i = 0; i < 5; i++) {
135 ret = plpar_hcall_norets(opcode, arg1, arg2, arg3, arg4,
139 spin_unlock_irqrestore(&hcall_lock, flags);
141 if (H_IS_LONG_BUSY(ret)) {
142 sleep_msecs = get_longbusy_msecs(ret);
149 opcode, ret, arg1, arg2, arg3,
150 arg4, arg5, arg6, arg7);
161 static long ehca_plpar_hcall9(
unsigned long opcode,
175 unsigned long flags = 0;
179 arg1, arg2, arg3, arg4, arg5,
180 arg6, arg7, arg8, arg9);
182 for (i = 0; i < 5; i++) {
187 ret = plpar_hcall9(opcode, outs,
188 arg1, arg2, arg3, arg4, arg5,
189 arg6, arg7, arg8, arg9);
192 spin_unlock_irqrestore(&hcall_lock, flags);
194 if (H_IS_LONG_BUSY(ret)) {
195 sleep_msecs = get_longbusy_msecs(ret);
200 if (ret < H_SUCCESS) {
202 opcode, arg1, arg2, arg3, arg4, arg5,
203 arg6, arg7, arg8, arg9);
205 ret, outs[0], outs[1], outs[2], outs[3],
206 outs[4], outs[5], outs[6], outs[7],
210 ret, outs[0], outs[1], outs[2], outs[3],
211 outs[4], outs[5], outs[6], outs[7],
221 const u32 neq_control,
224 u32 *act_nr_of_entries,
229 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
230 u64 allocate_controls;
233 allocate_controls = 3ULL;
236 if (neq_control != 1)
237 allocate_controls = (1ULL << (63 - 7)) | allocate_controls;
239 allocate_controls = (1ULL << 63) | allocate_controls;
241 ret = ehca_plpar_hcall9(H_ALLOC_RESOURCE, outs,
246 eq_handle->
handle = outs[0];
247 *act_nr_of_entries = (
u32)outs[3];
248 *act_pages = (
u32)outs[4];
249 *eq_ist = (
u32)outs[5];
251 if (ret == H_NOT_ENOUGH_RESOURCES)
259 const u64 event_mask)
261 return ehca_plpar_hcall_norets(H_RESET_EVENTS,
274 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
276 ret = ehca_plpar_hcall9(H_ALLOC_RESOURCE, outs,
287 if (ret == H_SUCCESS) {
290 ehca_gen_err(
"Could not establish HW access. rc=%d paddr=%#lx",
293 ehca_plpar_hcall_norets(H_FREE_RESOURCE,
301 if (ret == H_NOT_ENOUGH_RESOURCES)
312 u64 allocate_controls, max_r10_reg,
r11,
r12;
313 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
350 ret = ehca_plpar_hcall9(H_ALLOC_RESOURCE, outs,
353 parms->send_cq_handle.handle,
357 max_r10_reg, r11, r12);
361 parms->
squeue.act_nr_wqes =
363 parms->
rqueue.act_nr_wqes =
365 parms->
squeue.act_nr_sges =
367 parms->
rqueue.act_nr_sges =
369 parms->
squeue.queue_size =
371 parms->
rqueue.queue_size =
374 if (ret == H_SUCCESS) {
377 ehca_gen_err(
"Could not establish HW access. rc=%d paddr=%#lx",
380 ehca_plpar_hcall_norets(H_FREE_RESOURCE,
388 if (ret == H_NOT_ENOUGH_RESOURCES)
399 u64 r_cb =
__pa(query_port_response_block);
406 ret = ehca_plpar_hcall_norets(H_QUERY_PORT,
413 ehca_dmp(query_port_response_block, 64,
"response_block");
420 const u8 init_type,
const int modify_mask)
422 u64 port_attributes = port_cap;
431 return ehca_plpar_hcall_norets(H_MODIFY_PORT,
441 u64 r_cb =
__pa(query_hca_rblock);
449 return ehca_plpar_hcall_norets(H_QUERY_HCA,
459 const u64 logical_address_of_page,
462 return ehca_plpar_hcall_norets(H_REGISTER_RPAGES,
464 (
u64)queue_type | ((
u64)pagesize) << 8,
467 logical_address_of_page,
477 const u64 logical_address_of_page,
488 logical_address_of_page, count);
495 ret = ehca_plpar_hcall_norets(H_QUERY_INT_STATE,
500 if (ret != H_SUCCESS && ret != H_BUSY)
511 const u64 logical_address_of_page,
521 cq_handle.
handle, logical_address_of_page,
530 const u64 logical_address_of_page,
540 qp_handle.
handle, logical_address_of_page,
547 void **log_addr_next_sq_wqe2processed,
548 void **log_addr_next_rq_wqe2processed,
549 int dis_and_get_function_code)
552 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
554 ret = ehca_plpar_hcall9(H_DISABLE_AND_GETC, outs,
556 dis_and_get_function_code,
559 if (log_addr_next_sq_wqe2processed)
560 *log_addr_next_sq_wqe2processed = (
void *)outs[0];
561 if (log_addr_next_rq_wqe2processed)
562 *log_addr_next_rq_wqe2processed = (
void *)outs[1];
570 const u64 update_mask,
575 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
576 ret = ehca_plpar_hcall9(H_MODIFY_QP, outs,
583 if (ret == H_NOT_ENOUGH_RESOURCES)
595 return ehca_plpar_hcall_norets(H_QUERY_QP,
606 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
613 ret = ehca_plpar_hcall9(H_DISABLE_AND_GETC, outs,
619 if (ret == H_HARDWARE)
622 ret = ehca_plpar_hcall_norets(H_FREE_RESOURCE,
627 if (ret == H_RESOURCE)
638 return ehca_plpar_hcall_norets(H_DEFINE_AQP0,
652 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
654 ret = ehca_plpar_hcall9(H_DEFINE_AQP1, outs,
659 *pma_qp_nr = (
u32)outs[0];
660 *bma_qp_nr = (
u32)outs[1];
662 if (ret == H_ALIAS_EXIST)
672 u64 subnet_prefix,
u64 interface_id)
676 ret = ehca_plpar_hcall_norets(H_ATTACH_MCQP,
684 if (ret == H_NOT_ENOUGH_RESOURCES)
694 u64 subnet_prefix,
u64 interface_id)
696 return ehca_plpar_hcall_norets(H_DETACH_MCQP,
717 ret = ehca_plpar_hcall_norets(H_FREE_RESOURCE,
720 force_flag != 0 ? 1
L : 0
L,
723 if (ret == H_RESOURCE)
740 ret = ehca_plpar_hcall_norets(H_FREE_RESOURCE,
745 if (ret == H_RESOURCE)
755 const u32 access_ctrl,
760 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
762 ret = ehca_plpar_hcall9(H_ALLOC_RESOURCE, outs,
767 (((
u64)access_ctrl) << 32ULL),
770 outparms->
handle.handle = outs[0];
781 const u64 logical_address_of_page,
790 kpage =
__va(logical_address_of_page);
791 for (i = 0; i <
count; i++)
793 i, (
void *)kpage[i]);
796 (
void *)logical_address_of_page);
799 if ((count > 1) && (logical_address_of_page & (
EHCA_PAGESIZE-1))) {
800 ehca_gen_err(
"logical_address_of_page not on a 4k boundary "
801 "adapter_handle=%llx mr=%p mr_handle=%llx "
802 "pagesize=%x queue_type=%x "
803 "logical_address_of_page=%llx count=%llx",
804 adapter_handle.
handle, mr,
806 logical_address_of_page, count);
812 logical_address_of_page, count);
821 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
823 ret = ehca_plpar_hcall9(H_QUERY_MR, outs,
826 0, 0, 0, 0, 0, 0, 0);
827 outparms->
len = outs[0];
828 outparms->
vaddr = outs[1];
829 outparms->
acl = outs[4] >> 32;
830 outparms->
lkey = (
u32)(outs[5] >> 32);
831 outparms->
rkey = (
u32)(outs[5] & (0xffffffff));
839 return ehca_plpar_hcall_norets(H_FREE_RESOURCE,
849 const u32 access_ctrl,
851 const u64 mr_addr_cb,
855 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
857 ret = ehca_plpar_hcall9(H_REREGISTER_PMR, outs,
863 ((((
u64)access_ctrl) << 32ULL) | pd.
value),
866 outparms->
vaddr = outs[1];
877 const u32 access_ctrl,
882 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
884 ret = ehca_plpar_hcall9(H_REGISTER_SMR, outs,
888 (((
u64)access_ctrl) << 32ULL),
891 outparms->
handle.handle = outs[0];
904 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
906 ret = ehca_plpar_hcall9(H_ALLOC_RESOURCE, outs,
911 outparms->
handle.handle = outs[0];
922 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
924 ret = ehca_plpar_hcall9(H_QUERY_MW, outs,
927 0, 0, 0, 0, 0, 0, 0);
936 return ehca_plpar_hcall_norets(H_FREE_RESOURCE,
943 const u64 ressource_handle,
945 unsigned long *byte_count)
954 return ehca_plpar_hcall_norets(H_ERROR_DATA,
966 xirr = (0xffULL << 24) | irq;
968 return plpar_hcall_norets(H_EOI, xirr);