xref: /linux/drivers/net/ethernet/ibm/ehea/ehea_phyp.c (revision de6cc651)
1*de6cc651SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
29aa32835SJeff Kirsher /*
33396c782SPaul Gortmaker  *  linux/drivers/net/ethernet/ibm/ehea/ehea_phyp.c
49aa32835SJeff Kirsher  *
59aa32835SJeff Kirsher  *  eHEA ethernet device driver for IBM eServer System p
69aa32835SJeff Kirsher  *
79aa32835SJeff Kirsher  *  (C) Copyright IBM Corp. 2006
89aa32835SJeff Kirsher  *
99aa32835SJeff Kirsher  *  Authors:
109aa32835SJeff Kirsher  *	 Christoph Raisch <raisch@de.ibm.com>
119aa32835SJeff Kirsher  *	 Jan-Bernd Themann <themann@de.ibm.com>
129aa32835SJeff Kirsher  *	 Thomas Klein <tklein@de.ibm.com>
139aa32835SJeff Kirsher  */
149aa32835SJeff Kirsher 
159aa32835SJeff Kirsher #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
169aa32835SJeff Kirsher 
179aa32835SJeff Kirsher #include "ehea_phyp.h"
189aa32835SJeff Kirsher 
199aa32835SJeff Kirsher 
get_order_of_qentries(u16 queue_entries)209aa32835SJeff Kirsher static inline u16 get_order_of_qentries(u16 queue_entries)
219aa32835SJeff Kirsher {
229aa32835SJeff Kirsher 	u8 ld = 1;		/*  logarithmus dualis */
239aa32835SJeff Kirsher 	while (((1U << ld) - 1) < queue_entries)
249aa32835SJeff Kirsher 		ld++;
259aa32835SJeff Kirsher 	return ld - 1;
269aa32835SJeff Kirsher }
279aa32835SJeff Kirsher 
289aa32835SJeff Kirsher /* Defines for H_CALL H_ALLOC_RESOURCE */
299aa32835SJeff Kirsher #define H_ALL_RES_TYPE_QP	 1
309aa32835SJeff Kirsher #define H_ALL_RES_TYPE_CQ	 2
319aa32835SJeff Kirsher #define H_ALL_RES_TYPE_EQ	 3
329aa32835SJeff Kirsher #define H_ALL_RES_TYPE_MR	 5
339aa32835SJeff Kirsher #define H_ALL_RES_TYPE_MW	 6
349aa32835SJeff Kirsher 
ehea_plpar_hcall_norets(unsigned long opcode,unsigned long arg1,unsigned long arg2,unsigned long arg3,unsigned long arg4,unsigned long arg5,unsigned long arg6,unsigned long arg7)359aa32835SJeff Kirsher static long ehea_plpar_hcall_norets(unsigned long opcode,
369aa32835SJeff Kirsher 				    unsigned long arg1,
379aa32835SJeff Kirsher 				    unsigned long arg2,
389aa32835SJeff Kirsher 				    unsigned long arg3,
399aa32835SJeff Kirsher 				    unsigned long arg4,
409aa32835SJeff Kirsher 				    unsigned long arg5,
419aa32835SJeff Kirsher 				    unsigned long arg6,
429aa32835SJeff Kirsher 				    unsigned long arg7)
439aa32835SJeff Kirsher {
449aa32835SJeff Kirsher 	long ret;
459aa32835SJeff Kirsher 	int i, sleep_msecs;
469aa32835SJeff Kirsher 
479aa32835SJeff Kirsher 	for (i = 0; i < 5; i++) {
489aa32835SJeff Kirsher 		ret = plpar_hcall_norets(opcode, arg1, arg2, arg3, arg4,
499aa32835SJeff Kirsher 					 arg5, arg6, arg7);
509aa32835SJeff Kirsher 
519aa32835SJeff Kirsher 		if (H_IS_LONG_BUSY(ret)) {
529aa32835SJeff Kirsher 			sleep_msecs = get_longbusy_msecs(ret);
539aa32835SJeff Kirsher 			msleep_interruptible(sleep_msecs);
549aa32835SJeff Kirsher 			continue;
559aa32835SJeff Kirsher 		}
569aa32835SJeff Kirsher 
579aa32835SJeff Kirsher 		if (ret < H_SUCCESS)
589aa32835SJeff Kirsher 			pr_err("opcode=%lx ret=%lx"
599aa32835SJeff Kirsher 			       " arg1=%lx arg2=%lx arg3=%lx arg4=%lx"
609aa32835SJeff Kirsher 			       " arg5=%lx arg6=%lx arg7=%lx\n",
619aa32835SJeff Kirsher 			       opcode, ret,
629aa32835SJeff Kirsher 			       arg1, arg2, arg3, arg4, arg5, arg6, arg7);
639aa32835SJeff Kirsher 
649aa32835SJeff Kirsher 		return ret;
659aa32835SJeff Kirsher 	}
669aa32835SJeff Kirsher 
679aa32835SJeff Kirsher 	return H_BUSY;
689aa32835SJeff Kirsher }
699aa32835SJeff Kirsher 
ehea_plpar_hcall9(unsigned long opcode,unsigned long * outs,unsigned long arg1,unsigned long arg2,unsigned long arg3,unsigned long arg4,unsigned long arg5,unsigned long arg6,unsigned long arg7,unsigned long arg8,unsigned long arg9)709aa32835SJeff Kirsher static long ehea_plpar_hcall9(unsigned long opcode,
719aa32835SJeff Kirsher 			      unsigned long *outs, /* array of 9 outputs */
729aa32835SJeff Kirsher 			      unsigned long arg1,
739aa32835SJeff Kirsher 			      unsigned long arg2,
749aa32835SJeff Kirsher 			      unsigned long arg3,
759aa32835SJeff Kirsher 			      unsigned long arg4,
769aa32835SJeff Kirsher 			      unsigned long arg5,
779aa32835SJeff Kirsher 			      unsigned long arg6,
789aa32835SJeff Kirsher 			      unsigned long arg7,
799aa32835SJeff Kirsher 			      unsigned long arg8,
809aa32835SJeff Kirsher 			      unsigned long arg9)
819aa32835SJeff Kirsher {
829aa32835SJeff Kirsher 	long ret;
839aa32835SJeff Kirsher 	int i, sleep_msecs;
849aa32835SJeff Kirsher 	u8 cb_cat;
859aa32835SJeff Kirsher 
869aa32835SJeff Kirsher 	for (i = 0; i < 5; i++) {
879aa32835SJeff Kirsher 		ret = plpar_hcall9(opcode, outs,
889aa32835SJeff Kirsher 				   arg1, arg2, arg3, arg4, arg5,
899aa32835SJeff Kirsher 				   arg6, arg7, arg8, arg9);
909aa32835SJeff Kirsher 
919aa32835SJeff Kirsher 		if (H_IS_LONG_BUSY(ret)) {
929aa32835SJeff Kirsher 			sleep_msecs = get_longbusy_msecs(ret);
939aa32835SJeff Kirsher 			msleep_interruptible(sleep_msecs);
949aa32835SJeff Kirsher 			continue;
959aa32835SJeff Kirsher 		}
969aa32835SJeff Kirsher 
979aa32835SJeff Kirsher 		cb_cat = EHEA_BMASK_GET(H_MEHEAPORT_CAT, arg2);
989aa32835SJeff Kirsher 
999aa32835SJeff Kirsher 		if ((ret < H_SUCCESS) && !(((ret == H_AUTHORITY)
1009aa32835SJeff Kirsher 		    && (opcode == H_MODIFY_HEA_PORT))
1019aa32835SJeff Kirsher 		    && (((cb_cat == H_PORT_CB4) && ((arg3 == H_PORT_CB4_JUMBO)
1029aa32835SJeff Kirsher 		    || (arg3 == H_PORT_CB4_SPEED))) || ((cb_cat == H_PORT_CB7)
1039aa32835SJeff Kirsher 		    && (arg3 == H_PORT_CB7_DUCQPN)))))
1049aa32835SJeff Kirsher 			pr_err("opcode=%lx ret=%lx"
1059aa32835SJeff Kirsher 			       " arg1=%lx arg2=%lx arg3=%lx arg4=%lx"
1069aa32835SJeff Kirsher 			       " arg5=%lx arg6=%lx arg7=%lx arg8=%lx"
1079aa32835SJeff Kirsher 			       " arg9=%lx"
1089aa32835SJeff Kirsher 			       " out1=%lx out2=%lx out3=%lx out4=%lx"
1099aa32835SJeff Kirsher 			       " out5=%lx out6=%lx out7=%lx out8=%lx"
1109aa32835SJeff Kirsher 			       " out9=%lx\n",
1119aa32835SJeff Kirsher 			       opcode, ret,
1129aa32835SJeff Kirsher 			       arg1, arg2, arg3, arg4, arg5,
1139aa32835SJeff Kirsher 			       arg6, arg7, arg8, arg9,
1149aa32835SJeff Kirsher 			       outs[0], outs[1], outs[2], outs[3], outs[4],
1159aa32835SJeff Kirsher 			       outs[5], outs[6], outs[7], outs[8]);
1169aa32835SJeff Kirsher 		return ret;
1179aa32835SJeff Kirsher 	}
1189aa32835SJeff Kirsher 
1199aa32835SJeff Kirsher 	return H_BUSY;
1209aa32835SJeff Kirsher }
1219aa32835SJeff Kirsher 
ehea_h_query_ehea_qp(const u64 adapter_handle,const u8 qp_category,const u64 qp_handle,const u64 sel_mask,void * cb_addr)1229aa32835SJeff Kirsher u64 ehea_h_query_ehea_qp(const u64 adapter_handle, const u8 qp_category,
1239aa32835SJeff Kirsher 			 const u64 qp_handle, const u64 sel_mask, void *cb_addr)
1249aa32835SJeff Kirsher {
1259aa32835SJeff Kirsher 	return ehea_plpar_hcall_norets(H_QUERY_HEA_QP,
1269aa32835SJeff Kirsher 				       adapter_handle,		/* R4 */
1279aa32835SJeff Kirsher 				       qp_category,		/* R5 */
1289aa32835SJeff Kirsher 				       qp_handle,		/* R6 */
1299aa32835SJeff Kirsher 				       sel_mask,		/* R7 */
13067e1dbcbSMichael Ellerman 				       __pa(cb_addr),		/* R8 */
1319aa32835SJeff Kirsher 				       0, 0);
1329aa32835SJeff Kirsher }
1339aa32835SJeff Kirsher 
1349aa32835SJeff Kirsher /* input param R5 */
1359aa32835SJeff Kirsher #define H_ALL_RES_QP_EQPO	  EHEA_BMASK_IBM(9, 11)
1369aa32835SJeff Kirsher #define H_ALL_RES_QP_QPP	  EHEA_BMASK_IBM(12, 12)
1379aa32835SJeff Kirsher #define H_ALL_RES_QP_RQR	  EHEA_BMASK_IBM(13, 15)
1389aa32835SJeff Kirsher #define H_ALL_RES_QP_EQEG	  EHEA_BMASK_IBM(16, 16)
1399aa32835SJeff Kirsher #define H_ALL_RES_QP_LL_QP	  EHEA_BMASK_IBM(17, 17)
1409aa32835SJeff Kirsher #define H_ALL_RES_QP_DMA128	  EHEA_BMASK_IBM(19, 19)
1419aa32835SJeff Kirsher #define H_ALL_RES_QP_HSM	  EHEA_BMASK_IBM(20, 21)
1429aa32835SJeff Kirsher #define H_ALL_RES_QP_SIGT	  EHEA_BMASK_IBM(22, 23)
1439aa32835SJeff Kirsher #define H_ALL_RES_QP_TENURE	  EHEA_BMASK_IBM(48, 55)
1449aa32835SJeff Kirsher #define H_ALL_RES_QP_RES_TYP	  EHEA_BMASK_IBM(56, 63)
1459aa32835SJeff Kirsher 
1469aa32835SJeff Kirsher /* input param R9  */
1479aa32835SJeff Kirsher #define H_ALL_RES_QP_TOKEN	  EHEA_BMASK_IBM(0, 31)
1489aa32835SJeff Kirsher #define H_ALL_RES_QP_PD		  EHEA_BMASK_IBM(32, 63)
1499aa32835SJeff Kirsher 
1509aa32835SJeff Kirsher /* input param R10 */
1519aa32835SJeff Kirsher #define H_ALL_RES_QP_MAX_SWQE	  EHEA_BMASK_IBM(4, 7)
1529aa32835SJeff Kirsher #define H_ALL_RES_QP_MAX_R1WQE	  EHEA_BMASK_IBM(12, 15)
1539aa32835SJeff Kirsher #define H_ALL_RES_QP_MAX_R2WQE	  EHEA_BMASK_IBM(20, 23)
1549aa32835SJeff Kirsher #define H_ALL_RES_QP_MAX_R3WQE	  EHEA_BMASK_IBM(28, 31)
1559aa32835SJeff Kirsher /* Max Send Scatter Gather Elements */
1569aa32835SJeff Kirsher #define H_ALL_RES_QP_MAX_SSGE	  EHEA_BMASK_IBM(37, 39)
1579aa32835SJeff Kirsher #define H_ALL_RES_QP_MAX_R1SGE	  EHEA_BMASK_IBM(45, 47)
1589aa32835SJeff Kirsher /* Max Receive SG Elements RQ1 */
1599aa32835SJeff Kirsher #define H_ALL_RES_QP_MAX_R2SGE	  EHEA_BMASK_IBM(53, 55)
1609aa32835SJeff Kirsher #define H_ALL_RES_QP_MAX_R3SGE	  EHEA_BMASK_IBM(61, 63)
1619aa32835SJeff Kirsher 
1629aa32835SJeff Kirsher /* input param R11 */
1639aa32835SJeff Kirsher #define H_ALL_RES_QP_SWQE_IDL	  EHEA_BMASK_IBM(0, 7)
1649aa32835SJeff Kirsher /* max swqe immediate data length */
1659aa32835SJeff Kirsher #define H_ALL_RES_QP_PORT_NUM	  EHEA_BMASK_IBM(48, 63)
1669aa32835SJeff Kirsher 
1679aa32835SJeff Kirsher /* input param R12 */
1689aa32835SJeff Kirsher #define H_ALL_RES_QP_TH_RQ2	  EHEA_BMASK_IBM(0, 15)
1699aa32835SJeff Kirsher /* Threshold RQ2 */
1709aa32835SJeff Kirsher #define H_ALL_RES_QP_TH_RQ3	  EHEA_BMASK_IBM(16, 31)
1719aa32835SJeff Kirsher /* Threshold RQ3 */
1729aa32835SJeff Kirsher 
1739aa32835SJeff Kirsher /* output param R6 */
1749aa32835SJeff Kirsher #define H_ALL_RES_QP_ACT_SWQE	  EHEA_BMASK_IBM(0, 15)
1759aa32835SJeff Kirsher #define H_ALL_RES_QP_ACT_R1WQE	  EHEA_BMASK_IBM(16, 31)
1769aa32835SJeff Kirsher #define H_ALL_RES_QP_ACT_R2WQE	  EHEA_BMASK_IBM(32, 47)
1779aa32835SJeff Kirsher #define H_ALL_RES_QP_ACT_R3WQE	  EHEA_BMASK_IBM(48, 63)
1789aa32835SJeff Kirsher 
1799aa32835SJeff Kirsher /* output param, R7 */
1809aa32835SJeff Kirsher #define H_ALL_RES_QP_ACT_SSGE	  EHEA_BMASK_IBM(0, 7)
1819aa32835SJeff Kirsher #define H_ALL_RES_QP_ACT_R1SGE	  EHEA_BMASK_IBM(8, 15)
1829aa32835SJeff Kirsher #define H_ALL_RES_QP_ACT_R2SGE	  EHEA_BMASK_IBM(16, 23)
1839aa32835SJeff Kirsher #define H_ALL_RES_QP_ACT_R3SGE	  EHEA_BMASK_IBM(24, 31)
1849aa32835SJeff Kirsher #define H_ALL_RES_QP_ACT_SWQE_IDL EHEA_BMASK_IBM(32, 39)
1859aa32835SJeff Kirsher 
1869aa32835SJeff Kirsher /* output param R8,R9 */
1879aa32835SJeff Kirsher #define H_ALL_RES_QP_SIZE_SQ	  EHEA_BMASK_IBM(0, 31)
1889aa32835SJeff Kirsher #define H_ALL_RES_QP_SIZE_RQ1	  EHEA_BMASK_IBM(32, 63)
1899aa32835SJeff Kirsher #define H_ALL_RES_QP_SIZE_RQ2	  EHEA_BMASK_IBM(0, 31)
1909aa32835SJeff Kirsher #define H_ALL_RES_QP_SIZE_RQ3	  EHEA_BMASK_IBM(32, 63)
1919aa32835SJeff Kirsher 
1929aa32835SJeff Kirsher /* output param R11,R12 */
1939aa32835SJeff Kirsher #define H_ALL_RES_QP_LIOBN_SQ	  EHEA_BMASK_IBM(0, 31)
1949aa32835SJeff Kirsher #define H_ALL_RES_QP_LIOBN_RQ1	  EHEA_BMASK_IBM(32, 63)
1959aa32835SJeff Kirsher #define H_ALL_RES_QP_LIOBN_RQ2	  EHEA_BMASK_IBM(0, 31)
1969aa32835SJeff Kirsher #define H_ALL_RES_QP_LIOBN_RQ3	  EHEA_BMASK_IBM(32, 63)
1979aa32835SJeff Kirsher 
ehea_h_alloc_resource_qp(const u64 adapter_handle,struct ehea_qp_init_attr * init_attr,const u32 pd,u64 * qp_handle,struct h_epas * h_epas)1989aa32835SJeff Kirsher u64 ehea_h_alloc_resource_qp(const u64 adapter_handle,
1999aa32835SJeff Kirsher 			     struct ehea_qp_init_attr *init_attr, const u32 pd,
2009aa32835SJeff Kirsher 			     u64 *qp_handle, struct h_epas *h_epas)
2019aa32835SJeff Kirsher {
2029aa32835SJeff Kirsher 	u64 hret;
2039aa32835SJeff Kirsher 	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
2049aa32835SJeff Kirsher 
2059aa32835SJeff Kirsher 	u64 allocate_controls =
2069aa32835SJeff Kirsher 	    EHEA_BMASK_SET(H_ALL_RES_QP_EQPO, init_attr->low_lat_rq1 ? 1 : 0)
2079aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_QPP, 0)
2089aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_RQR, 6)	/* rq1 & rq2 & rq3 */
2099aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_EQEG, 0)	/* EQE gen. disabled */
2109aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_LL_QP, init_attr->low_lat_rq1)
2119aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_DMA128, 0)
2129aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_HSM, 0)
2139aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_SIGT, init_attr->signalingtype)
2149aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_RES_TYP, H_ALL_RES_TYPE_QP);
2159aa32835SJeff Kirsher 
2169aa32835SJeff Kirsher 	u64 r9_reg = EHEA_BMASK_SET(H_ALL_RES_QP_PD, pd)
2179aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_TOKEN, init_attr->qp_token);
2189aa32835SJeff Kirsher 
2199aa32835SJeff Kirsher 	u64 max_r10_reg =
2209aa32835SJeff Kirsher 	    EHEA_BMASK_SET(H_ALL_RES_QP_MAX_SWQE,
2219aa32835SJeff Kirsher 			   get_order_of_qentries(init_attr->max_nr_send_wqes))
2229aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_R1WQE,
2239aa32835SJeff Kirsher 			     get_order_of_qentries(init_attr->max_nr_rwqes_rq1))
2249aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_R2WQE,
2259aa32835SJeff Kirsher 			     get_order_of_qentries(init_attr->max_nr_rwqes_rq2))
2269aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_R3WQE,
2279aa32835SJeff Kirsher 			     get_order_of_qentries(init_attr->max_nr_rwqes_rq3))
2289aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_SSGE, init_attr->wqe_size_enc_sq)
2299aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_R1SGE,
2309aa32835SJeff Kirsher 			     init_attr->wqe_size_enc_rq1)
2319aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_R2SGE,
2329aa32835SJeff Kirsher 			     init_attr->wqe_size_enc_rq2)
2339aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_R3SGE,
2349aa32835SJeff Kirsher 			     init_attr->wqe_size_enc_rq3);
2359aa32835SJeff Kirsher 
2369aa32835SJeff Kirsher 	u64 r11_in =
2379aa32835SJeff Kirsher 	    EHEA_BMASK_SET(H_ALL_RES_QP_SWQE_IDL, init_attr->swqe_imm_data_len)
2389aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_PORT_NUM, init_attr->port_nr);
2399aa32835SJeff Kirsher 	u64 threshold =
2409aa32835SJeff Kirsher 	    EHEA_BMASK_SET(H_ALL_RES_QP_TH_RQ2, init_attr->rq2_threshold)
2419aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_QP_TH_RQ3, init_attr->rq3_threshold);
2429aa32835SJeff Kirsher 
2439aa32835SJeff Kirsher 	hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
2449aa32835SJeff Kirsher 				 outs,
2459aa32835SJeff Kirsher 				 adapter_handle,		/* R4 */
2469aa32835SJeff Kirsher 				 allocate_controls,		/* R5 */
2479aa32835SJeff Kirsher 				 init_attr->send_cq_handle,	/* R6 */
2489aa32835SJeff Kirsher 				 init_attr->recv_cq_handle,	/* R7 */
2499aa32835SJeff Kirsher 				 init_attr->aff_eq_handle,	/* R8 */
2509aa32835SJeff Kirsher 				 r9_reg,			/* R9 */
2519aa32835SJeff Kirsher 				 max_r10_reg,			/* R10 */
2529aa32835SJeff Kirsher 				 r11_in,			/* R11 */
2539aa32835SJeff Kirsher 				 threshold);			/* R12 */
2549aa32835SJeff Kirsher 
2559aa32835SJeff Kirsher 	*qp_handle = outs[0];
2569aa32835SJeff Kirsher 	init_attr->qp_nr = (u32)outs[1];
2579aa32835SJeff Kirsher 
2589aa32835SJeff Kirsher 	init_attr->act_nr_send_wqes =
2599aa32835SJeff Kirsher 	    (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_SWQE, outs[2]);
2609aa32835SJeff Kirsher 	init_attr->act_nr_rwqes_rq1 =
2619aa32835SJeff Kirsher 	    (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R1WQE, outs[2]);
2629aa32835SJeff Kirsher 	init_attr->act_nr_rwqes_rq2 =
2639aa32835SJeff Kirsher 	    (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R2WQE, outs[2]);
2649aa32835SJeff Kirsher 	init_attr->act_nr_rwqes_rq3 =
2659aa32835SJeff Kirsher 	    (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R3WQE, outs[2]);
2669aa32835SJeff Kirsher 
2679aa32835SJeff Kirsher 	init_attr->act_wqe_size_enc_sq = init_attr->wqe_size_enc_sq;
2689aa32835SJeff Kirsher 	init_attr->act_wqe_size_enc_rq1 = init_attr->wqe_size_enc_rq1;
2699aa32835SJeff Kirsher 	init_attr->act_wqe_size_enc_rq2 = init_attr->wqe_size_enc_rq2;
2709aa32835SJeff Kirsher 	init_attr->act_wqe_size_enc_rq3 = init_attr->wqe_size_enc_rq3;
2719aa32835SJeff Kirsher 
2729aa32835SJeff Kirsher 	init_attr->nr_sq_pages =
2739aa32835SJeff Kirsher 	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_SQ, outs[4]);
2749aa32835SJeff Kirsher 	init_attr->nr_rq1_pages =
2759aa32835SJeff Kirsher 	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ1, outs[4]);
2769aa32835SJeff Kirsher 	init_attr->nr_rq2_pages =
2779aa32835SJeff Kirsher 	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ2, outs[5]);
2789aa32835SJeff Kirsher 	init_attr->nr_rq3_pages =
2799aa32835SJeff Kirsher 	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ3, outs[5]);
2809aa32835SJeff Kirsher 
2819aa32835SJeff Kirsher 	init_attr->liobn_sq =
2829aa32835SJeff Kirsher 	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_SQ, outs[7]);
2839aa32835SJeff Kirsher 	init_attr->liobn_rq1 =
2849aa32835SJeff Kirsher 	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ1, outs[7]);
2859aa32835SJeff Kirsher 	init_attr->liobn_rq2 =
2869aa32835SJeff Kirsher 	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ2, outs[8]);
2879aa32835SJeff Kirsher 	init_attr->liobn_rq3 =
2889aa32835SJeff Kirsher 	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ3, outs[8]);
2899aa32835SJeff Kirsher 
2909aa32835SJeff Kirsher 	if (!hret)
2919aa32835SJeff Kirsher 		hcp_epas_ctor(h_epas, outs[6], outs[6]);
2929aa32835SJeff Kirsher 
2939aa32835SJeff Kirsher 	return hret;
2949aa32835SJeff Kirsher }
2959aa32835SJeff Kirsher 
ehea_h_alloc_resource_cq(const u64 adapter_handle,struct ehea_cq_attr * cq_attr,u64 * cq_handle,struct h_epas * epas)2969aa32835SJeff Kirsher u64 ehea_h_alloc_resource_cq(const u64 adapter_handle,
2979aa32835SJeff Kirsher 			     struct ehea_cq_attr *cq_attr,
2989aa32835SJeff Kirsher 			     u64 *cq_handle, struct h_epas *epas)
2999aa32835SJeff Kirsher {
3009aa32835SJeff Kirsher 	u64 hret;
3019aa32835SJeff Kirsher 	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
3029aa32835SJeff Kirsher 
3039aa32835SJeff Kirsher 	hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
3049aa32835SJeff Kirsher 				 outs,
3059aa32835SJeff Kirsher 				 adapter_handle,		/* R4 */
3069aa32835SJeff Kirsher 				 H_ALL_RES_TYPE_CQ,		/* R5 */
3079aa32835SJeff Kirsher 				 cq_attr->eq_handle,		/* R6 */
3089aa32835SJeff Kirsher 				 cq_attr->cq_token,		/* R7 */
3099aa32835SJeff Kirsher 				 cq_attr->max_nr_of_cqes,	/* R8 */
3109aa32835SJeff Kirsher 				 0, 0, 0, 0);			/* R9-R12 */
3119aa32835SJeff Kirsher 
3129aa32835SJeff Kirsher 	*cq_handle = outs[0];
3139aa32835SJeff Kirsher 	cq_attr->act_nr_of_cqes = outs[3];
3149aa32835SJeff Kirsher 	cq_attr->nr_pages = outs[4];
3159aa32835SJeff Kirsher 
3169aa32835SJeff Kirsher 	if (!hret)
3179aa32835SJeff Kirsher 		hcp_epas_ctor(epas, outs[5], outs[6]);
3189aa32835SJeff Kirsher 
3199aa32835SJeff Kirsher 	return hret;
3209aa32835SJeff Kirsher }
3219aa32835SJeff Kirsher 
3229aa32835SJeff Kirsher /* Defines for H_CALL H_ALLOC_RESOURCE */
3239aa32835SJeff Kirsher #define H_ALL_RES_TYPE_QP	 1
3249aa32835SJeff Kirsher #define H_ALL_RES_TYPE_CQ	 2
3259aa32835SJeff Kirsher #define H_ALL_RES_TYPE_EQ	 3
3269aa32835SJeff Kirsher #define H_ALL_RES_TYPE_MR	 5
3279aa32835SJeff Kirsher #define H_ALL_RES_TYPE_MW	 6
3289aa32835SJeff Kirsher 
3299aa32835SJeff Kirsher /*  input param R5 */
3309aa32835SJeff Kirsher #define H_ALL_RES_EQ_NEQ	     EHEA_BMASK_IBM(0, 0)
3319aa32835SJeff Kirsher #define H_ALL_RES_EQ_NON_NEQ_ISN     EHEA_BMASK_IBM(6, 7)
3329aa32835SJeff Kirsher #define H_ALL_RES_EQ_INH_EQE_GEN     EHEA_BMASK_IBM(16, 16)
3339aa32835SJeff Kirsher #define H_ALL_RES_EQ_RES_TYPE	     EHEA_BMASK_IBM(56, 63)
3349aa32835SJeff Kirsher /*  input param R6 */
3359aa32835SJeff Kirsher #define H_ALL_RES_EQ_MAX_EQE	     EHEA_BMASK_IBM(32, 63)
3369aa32835SJeff Kirsher 
3379aa32835SJeff Kirsher /*  output param R6 */
3389aa32835SJeff Kirsher #define H_ALL_RES_EQ_LIOBN	     EHEA_BMASK_IBM(32, 63)
3399aa32835SJeff Kirsher 
3409aa32835SJeff Kirsher /*  output param R7 */
3419aa32835SJeff Kirsher #define H_ALL_RES_EQ_ACT_EQE	     EHEA_BMASK_IBM(32, 63)
3429aa32835SJeff Kirsher 
3439aa32835SJeff Kirsher /*  output param R8 */
3449aa32835SJeff Kirsher #define H_ALL_RES_EQ_ACT_PS	     EHEA_BMASK_IBM(32, 63)
3459aa32835SJeff Kirsher 
3469aa32835SJeff Kirsher /*  output param R9 */
3479aa32835SJeff Kirsher #define H_ALL_RES_EQ_ACT_EQ_IST_C    EHEA_BMASK_IBM(30, 31)
3489aa32835SJeff Kirsher #define H_ALL_RES_EQ_ACT_EQ_IST_1    EHEA_BMASK_IBM(40, 63)
3499aa32835SJeff Kirsher 
3509aa32835SJeff Kirsher /*  output param R10 */
3519aa32835SJeff Kirsher #define H_ALL_RES_EQ_ACT_EQ_IST_2    EHEA_BMASK_IBM(40, 63)
3529aa32835SJeff Kirsher 
3539aa32835SJeff Kirsher /*  output param R11 */
3549aa32835SJeff Kirsher #define H_ALL_RES_EQ_ACT_EQ_IST_3    EHEA_BMASK_IBM(40, 63)
3559aa32835SJeff Kirsher 
3569aa32835SJeff Kirsher /*  output param R12 */
3579aa32835SJeff Kirsher #define H_ALL_RES_EQ_ACT_EQ_IST_4    EHEA_BMASK_IBM(40, 63)
3589aa32835SJeff Kirsher 
ehea_h_alloc_resource_eq(const u64 adapter_handle,struct ehea_eq_attr * eq_attr,u64 * eq_handle)3599aa32835SJeff Kirsher u64 ehea_h_alloc_resource_eq(const u64 adapter_handle,
3609aa32835SJeff Kirsher 			     struct ehea_eq_attr *eq_attr, u64 *eq_handle)
3619aa32835SJeff Kirsher {
3629aa32835SJeff Kirsher 	u64 hret, allocate_controls;
3639aa32835SJeff Kirsher 	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
3649aa32835SJeff Kirsher 
3659aa32835SJeff Kirsher 	/* resource type */
3669aa32835SJeff Kirsher 	allocate_controls =
3679aa32835SJeff Kirsher 	    EHEA_BMASK_SET(H_ALL_RES_EQ_RES_TYPE, H_ALL_RES_TYPE_EQ)
3689aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_EQ_NEQ, eq_attr->type ? 1 : 0)
3699aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_EQ_INH_EQE_GEN, !eq_attr->eqe_gen)
3709aa32835SJeff Kirsher 	    | EHEA_BMASK_SET(H_ALL_RES_EQ_NON_NEQ_ISN, 1);
3719aa32835SJeff Kirsher 
3729aa32835SJeff Kirsher 	hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
3739aa32835SJeff Kirsher 				 outs,
3749aa32835SJeff Kirsher 				 adapter_handle,		/* R4 */
3759aa32835SJeff Kirsher 				 allocate_controls,		/* R5 */
3769aa32835SJeff Kirsher 				 eq_attr->max_nr_of_eqes,	/* R6 */
3779aa32835SJeff Kirsher 				 0, 0, 0, 0, 0, 0);		/* R7-R10 */
3789aa32835SJeff Kirsher 
3799aa32835SJeff Kirsher 	*eq_handle = outs[0];
3809aa32835SJeff Kirsher 	eq_attr->act_nr_of_eqes = outs[3];
3819aa32835SJeff Kirsher 	eq_attr->nr_pages = outs[4];
3829aa32835SJeff Kirsher 	eq_attr->ist1 = outs[5];
3839aa32835SJeff Kirsher 	eq_attr->ist2 = outs[6];
3849aa32835SJeff Kirsher 	eq_attr->ist3 = outs[7];
3859aa32835SJeff Kirsher 	eq_attr->ist4 = outs[8];
3869aa32835SJeff Kirsher 
3879aa32835SJeff Kirsher 	return hret;
3889aa32835SJeff Kirsher }
3899aa32835SJeff Kirsher 
ehea_h_modify_ehea_qp(const u64 adapter_handle,const u8 cat,const u64 qp_handle,const u64 sel_mask,void * cb_addr,u64 * inv_attr_id,u64 * proc_mask,u16 * out_swr,u16 * out_rwr)3909aa32835SJeff Kirsher u64 ehea_h_modify_ehea_qp(const u64 adapter_handle, const u8 cat,
3919aa32835SJeff Kirsher 			  const u64 qp_handle, const u64 sel_mask,
3929aa32835SJeff Kirsher 			  void *cb_addr, u64 *inv_attr_id, u64 *proc_mask,
3939aa32835SJeff Kirsher 			  u16 *out_swr, u16 *out_rwr)
3949aa32835SJeff Kirsher {
3959aa32835SJeff Kirsher 	u64 hret;
3969aa32835SJeff Kirsher 	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
3979aa32835SJeff Kirsher 
3989aa32835SJeff Kirsher 	hret = ehea_plpar_hcall9(H_MODIFY_HEA_QP,
3999aa32835SJeff Kirsher 				 outs,
4009aa32835SJeff Kirsher 				 adapter_handle,		/* R4 */
4019aa32835SJeff Kirsher 				 (u64) cat,			/* R5 */
4029aa32835SJeff Kirsher 				 qp_handle,			/* R6 */
4039aa32835SJeff Kirsher 				 sel_mask,			/* R7 */
40467e1dbcbSMichael Ellerman 				 __pa(cb_addr),			/* R8 */
4059aa32835SJeff Kirsher 				 0, 0, 0, 0);			/* R9-R12 */
4069aa32835SJeff Kirsher 
4079aa32835SJeff Kirsher 	*inv_attr_id = outs[0];
4089aa32835SJeff Kirsher 	*out_swr = outs[3];
4099aa32835SJeff Kirsher 	*out_rwr = outs[4];
4109aa32835SJeff Kirsher 	*proc_mask = outs[5];
4119aa32835SJeff Kirsher 
4129aa32835SJeff Kirsher 	return hret;
4139aa32835SJeff Kirsher }
4149aa32835SJeff Kirsher 
ehea_h_register_rpage(const u64 adapter_handle,const u8 pagesize,const u8 queue_type,const u64 resource_handle,const u64 log_pageaddr,u64 count)4159aa32835SJeff Kirsher u64 ehea_h_register_rpage(const u64 adapter_handle, const u8 pagesize,
4169aa32835SJeff Kirsher 			  const u8 queue_type, const u64 resource_handle,
4179aa32835SJeff Kirsher 			  const u64 log_pageaddr, u64 count)
4189aa32835SJeff Kirsher {
4199aa32835SJeff Kirsher 	u64  reg_control;
4209aa32835SJeff Kirsher 
4219aa32835SJeff Kirsher 	reg_control = EHEA_BMASK_SET(H_REG_RPAGE_PAGE_SIZE, pagesize)
4229aa32835SJeff Kirsher 		    | EHEA_BMASK_SET(H_REG_RPAGE_QT, queue_type);
4239aa32835SJeff Kirsher 
4249aa32835SJeff Kirsher 	return ehea_plpar_hcall_norets(H_REGISTER_HEA_RPAGES,
4259aa32835SJeff Kirsher 				       adapter_handle,		/* R4 */
4269aa32835SJeff Kirsher 				       reg_control,		/* R5 */
4279aa32835SJeff Kirsher 				       resource_handle,		/* R6 */
4289aa32835SJeff Kirsher 				       log_pageaddr,		/* R7 */
4299aa32835SJeff Kirsher 				       count,			/* R8 */
4309aa32835SJeff Kirsher 				       0, 0);			/* R9-R10 */
4319aa32835SJeff Kirsher }
4329aa32835SJeff Kirsher 
ehea_h_register_smr(const u64 adapter_handle,const u64 orig_mr_handle,const u64 vaddr_in,const u32 access_ctrl,const u32 pd,struct ehea_mr * mr)4339aa32835SJeff Kirsher u64 ehea_h_register_smr(const u64 adapter_handle, const u64 orig_mr_handle,
4349aa32835SJeff Kirsher 			const u64 vaddr_in, const u32 access_ctrl, const u32 pd,
4359aa32835SJeff Kirsher 			struct ehea_mr *mr)
4369aa32835SJeff Kirsher {
4379aa32835SJeff Kirsher 	u64 hret;
4389aa32835SJeff Kirsher 	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
4399aa32835SJeff Kirsher 
4409aa32835SJeff Kirsher 	hret = ehea_plpar_hcall9(H_REGISTER_SMR,
4419aa32835SJeff Kirsher 				 outs,
4429aa32835SJeff Kirsher 				 adapter_handle	      ,		 /* R4 */
4439aa32835SJeff Kirsher 				 orig_mr_handle,		 /* R5 */
4449aa32835SJeff Kirsher 				 vaddr_in,			 /* R6 */
4459aa32835SJeff Kirsher 				 (((u64)access_ctrl) << 32ULL),	 /* R7 */
4469aa32835SJeff Kirsher 				 pd,				 /* R8 */
4479aa32835SJeff Kirsher 				 0, 0, 0, 0);			 /* R9-R12 */
4489aa32835SJeff Kirsher 
4499aa32835SJeff Kirsher 	mr->handle = outs[0];
4509aa32835SJeff Kirsher 	mr->lkey = (u32)outs[2];
4519aa32835SJeff Kirsher 
4529aa32835SJeff Kirsher 	return hret;
4539aa32835SJeff Kirsher }
4549aa32835SJeff Kirsher 
ehea_h_disable_and_get_hea(const u64 adapter_handle,const u64 qp_handle)4559aa32835SJeff Kirsher u64 ehea_h_disable_and_get_hea(const u64 adapter_handle, const u64 qp_handle)
4569aa32835SJeff Kirsher {
4579aa32835SJeff Kirsher 	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
4589aa32835SJeff Kirsher 
4599aa32835SJeff Kirsher 	return ehea_plpar_hcall9(H_DISABLE_AND_GET_HEA,
4609aa32835SJeff Kirsher 				 outs,
4619aa32835SJeff Kirsher 				 adapter_handle,		/* R4 */
4629aa32835SJeff Kirsher 				 H_DISABLE_GET_EHEA_WQE_P,	/* R5 */
4639aa32835SJeff Kirsher 				 qp_handle,			/* R6 */
4649aa32835SJeff Kirsher 				 0, 0, 0, 0, 0, 0);		/* R7-R12 */
4659aa32835SJeff Kirsher }
4669aa32835SJeff Kirsher 
ehea_h_free_resource(const u64 adapter_handle,const u64 res_handle,u64 force_bit)4679aa32835SJeff Kirsher u64 ehea_h_free_resource(const u64 adapter_handle, const u64 res_handle,
4689aa32835SJeff Kirsher 			 u64 force_bit)
4699aa32835SJeff Kirsher {
4709aa32835SJeff Kirsher 	return ehea_plpar_hcall_norets(H_FREE_RESOURCE,
4719aa32835SJeff Kirsher 				       adapter_handle,	   /* R4 */
4729aa32835SJeff Kirsher 				       res_handle,	   /* R5 */
4739aa32835SJeff Kirsher 				       force_bit,
4749aa32835SJeff Kirsher 				       0, 0, 0, 0);	   /* R7-R10 */
4759aa32835SJeff Kirsher }
4769aa32835SJeff Kirsher 
ehea_h_alloc_resource_mr(const u64 adapter_handle,const u64 vaddr,const u64 length,const u32 access_ctrl,const u32 pd,u64 * mr_handle,u32 * lkey)4779aa32835SJeff Kirsher u64 ehea_h_alloc_resource_mr(const u64 adapter_handle, const u64 vaddr,
4789aa32835SJeff Kirsher 			     const u64 length, const u32 access_ctrl,
4799aa32835SJeff Kirsher 			     const u32 pd, u64 *mr_handle, u32 *lkey)
4809aa32835SJeff Kirsher {
4819aa32835SJeff Kirsher 	u64 hret;
4829aa32835SJeff Kirsher 	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
4839aa32835SJeff Kirsher 
4849aa32835SJeff Kirsher 	hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
4859aa32835SJeff Kirsher 				 outs,
4869aa32835SJeff Kirsher 				 adapter_handle,		   /* R4 */
4879aa32835SJeff Kirsher 				 5,				   /* R5 */
4889aa32835SJeff Kirsher 				 vaddr,				   /* R6 */
4899aa32835SJeff Kirsher 				 length,			   /* R7 */
4909aa32835SJeff Kirsher 				 (((u64) access_ctrl) << 32ULL),   /* R8 */
4919aa32835SJeff Kirsher 				 pd,				   /* R9 */
4929aa32835SJeff Kirsher 				 0, 0, 0);			   /* R10-R12 */
4939aa32835SJeff Kirsher 
4949aa32835SJeff Kirsher 	*mr_handle = outs[0];
4959aa32835SJeff Kirsher 	*lkey = (u32)outs[2];
4969aa32835SJeff Kirsher 	return hret;
4979aa32835SJeff Kirsher }
4989aa32835SJeff Kirsher 
ehea_h_register_rpage_mr(const u64 adapter_handle,const u64 mr_handle,const u8 pagesize,const u8 queue_type,const u64 log_pageaddr,const u64 count)4999aa32835SJeff Kirsher u64 ehea_h_register_rpage_mr(const u64 adapter_handle, const u64 mr_handle,
5009aa32835SJeff Kirsher 			     const u8 pagesize, const u8 queue_type,
5019aa32835SJeff Kirsher 			     const u64 log_pageaddr, const u64 count)
5029aa32835SJeff Kirsher {
5039aa32835SJeff Kirsher 	if ((count > 1) && (log_pageaddr & ~PAGE_MASK)) {
5049aa32835SJeff Kirsher 		pr_err("not on pageboundary\n");
5059aa32835SJeff Kirsher 		return H_PARAMETER;
5069aa32835SJeff Kirsher 	}
5079aa32835SJeff Kirsher 
5089aa32835SJeff Kirsher 	return ehea_h_register_rpage(adapter_handle, pagesize,
5099aa32835SJeff Kirsher 				     queue_type, mr_handle,
5109aa32835SJeff Kirsher 				     log_pageaddr, count);
5119aa32835SJeff Kirsher }
5129aa32835SJeff Kirsher 
ehea_h_query_ehea(const u64 adapter_handle,void * cb_addr)5139aa32835SJeff Kirsher u64 ehea_h_query_ehea(const u64 adapter_handle, void *cb_addr)
5149aa32835SJeff Kirsher {
5159aa32835SJeff Kirsher 	u64 hret, cb_logaddr;
5169aa32835SJeff Kirsher 
51767e1dbcbSMichael Ellerman 	cb_logaddr = __pa(cb_addr);
5189aa32835SJeff Kirsher 
5199aa32835SJeff Kirsher 	hret = ehea_plpar_hcall_norets(H_QUERY_HEA,
5209aa32835SJeff Kirsher 				       adapter_handle,		/* R4 */
5219aa32835SJeff Kirsher 				       cb_logaddr,		/* R5 */
5229aa32835SJeff Kirsher 				       0, 0, 0, 0, 0);		/* R6-R10 */
5239aa32835SJeff Kirsher #ifdef DEBUG
5249aa32835SJeff Kirsher 	ehea_dump(cb_addr, sizeof(struct hcp_query_ehea), "hcp_query_ehea");
5259aa32835SJeff Kirsher #endif
5269aa32835SJeff Kirsher 	return hret;
5279aa32835SJeff Kirsher }
5289aa32835SJeff Kirsher 
ehea_h_query_ehea_port(const u64 adapter_handle,const u16 port_num,const u8 cb_cat,const u64 select_mask,void * cb_addr)5299aa32835SJeff Kirsher u64 ehea_h_query_ehea_port(const u64 adapter_handle, const u16 port_num,
5309aa32835SJeff Kirsher 			   const u8 cb_cat, const u64 select_mask,
5319aa32835SJeff Kirsher 			   void *cb_addr)
5329aa32835SJeff Kirsher {
5339aa32835SJeff Kirsher 	u64 port_info;
53467e1dbcbSMichael Ellerman 	u64 cb_logaddr = __pa(cb_addr);
5359aa32835SJeff Kirsher 	u64 arr_index = 0;
5369aa32835SJeff Kirsher 
5379aa32835SJeff Kirsher 	port_info = EHEA_BMASK_SET(H_MEHEAPORT_CAT, cb_cat)
5389aa32835SJeff Kirsher 		  | EHEA_BMASK_SET(H_MEHEAPORT_PN, port_num);
5399aa32835SJeff Kirsher 
5409aa32835SJeff Kirsher 	return ehea_plpar_hcall_norets(H_QUERY_HEA_PORT,
5419aa32835SJeff Kirsher 				       adapter_handle,		/* R4 */
5429aa32835SJeff Kirsher 				       port_info,		/* R5 */
5439aa32835SJeff Kirsher 				       select_mask,		/* R6 */
5449aa32835SJeff Kirsher 				       arr_index,		/* R7 */
5459aa32835SJeff Kirsher 				       cb_logaddr,		/* R8 */
5469aa32835SJeff Kirsher 				       0, 0);			/* R9-R10 */
5479aa32835SJeff Kirsher }
5489aa32835SJeff Kirsher 
ehea_h_modify_ehea_port(const u64 adapter_handle,const u16 port_num,const u8 cb_cat,const u64 select_mask,void * cb_addr)5499aa32835SJeff Kirsher u64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num,
5509aa32835SJeff Kirsher 			    const u8 cb_cat, const u64 select_mask,
5519aa32835SJeff Kirsher 			    void *cb_addr)
5529aa32835SJeff Kirsher {
5539aa32835SJeff Kirsher 	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
5549aa32835SJeff Kirsher 	u64 port_info;
5559aa32835SJeff Kirsher 	u64 arr_index = 0;
55667e1dbcbSMichael Ellerman 	u64 cb_logaddr = __pa(cb_addr);
5579aa32835SJeff Kirsher 
5589aa32835SJeff Kirsher 	port_info = EHEA_BMASK_SET(H_MEHEAPORT_CAT, cb_cat)
5599aa32835SJeff Kirsher 		  | EHEA_BMASK_SET(H_MEHEAPORT_PN, port_num);
5609aa32835SJeff Kirsher #ifdef DEBUG
5619aa32835SJeff Kirsher 	ehea_dump(cb_addr, sizeof(struct hcp_ehea_port_cb0), "Before HCALL");
5629aa32835SJeff Kirsher #endif
5639aa32835SJeff Kirsher 	return ehea_plpar_hcall9(H_MODIFY_HEA_PORT,
5649aa32835SJeff Kirsher 				 outs,
5659aa32835SJeff Kirsher 				 adapter_handle,		/* R4 */
5669aa32835SJeff Kirsher 				 port_info,			/* R5 */
5679aa32835SJeff Kirsher 				 select_mask,			/* R6 */
5689aa32835SJeff Kirsher 				 arr_index,			/* R7 */
5699aa32835SJeff Kirsher 				 cb_logaddr,			/* R8 */
5709aa32835SJeff Kirsher 				 0, 0, 0, 0);			/* R9-R12 */
5719aa32835SJeff Kirsher }
5729aa32835SJeff Kirsher 
ehea_h_reg_dereg_bcmc(const u64 adapter_handle,const u16 port_num,const u8 reg_type,const u64 mc_mac_addr,const u16 vlan_id,const u32 hcall_id)5739aa32835SJeff Kirsher u64 ehea_h_reg_dereg_bcmc(const u64 adapter_handle, const u16 port_num,
5749aa32835SJeff Kirsher 			  const u8 reg_type, const u64 mc_mac_addr,
5759aa32835SJeff Kirsher 			  const u16 vlan_id, const u32 hcall_id)
5769aa32835SJeff Kirsher {
5779aa32835SJeff Kirsher 	u64 r5_port_num, r6_reg_type, r7_mc_mac_addr, r8_vlan_id;
5789aa32835SJeff Kirsher 	u64 mac_addr = mc_mac_addr >> 16;
5799aa32835SJeff Kirsher 
5809aa32835SJeff Kirsher 	r5_port_num = EHEA_BMASK_SET(H_REGBCMC_PN, port_num);
5819aa32835SJeff Kirsher 	r6_reg_type = EHEA_BMASK_SET(H_REGBCMC_REGTYPE, reg_type);
5829aa32835SJeff Kirsher 	r7_mc_mac_addr = EHEA_BMASK_SET(H_REGBCMC_MACADDR, mac_addr);
5839aa32835SJeff Kirsher 	r8_vlan_id = EHEA_BMASK_SET(H_REGBCMC_VLANID, vlan_id);
5849aa32835SJeff Kirsher 
5859aa32835SJeff Kirsher 	return ehea_plpar_hcall_norets(hcall_id,
5869aa32835SJeff Kirsher 				       adapter_handle,		/* R4 */
5879aa32835SJeff Kirsher 				       r5_port_num,		/* R5 */
5889aa32835SJeff Kirsher 				       r6_reg_type,		/* R6 */
5899aa32835SJeff Kirsher 				       r7_mc_mac_addr,		/* R7 */
5909aa32835SJeff Kirsher 				       r8_vlan_id,		/* R8 */
5919aa32835SJeff Kirsher 				       0, 0);			/* R9-R12 */
5929aa32835SJeff Kirsher }
5939aa32835SJeff Kirsher 
ehea_h_reset_events(const u64 adapter_handle,const u64 neq_handle,const u64 event_mask)5949aa32835SJeff Kirsher u64 ehea_h_reset_events(const u64 adapter_handle, const u64 neq_handle,
5959aa32835SJeff Kirsher 			const u64 event_mask)
5969aa32835SJeff Kirsher {
5979aa32835SJeff Kirsher 	return ehea_plpar_hcall_norets(H_RESET_EVENTS,
5989aa32835SJeff Kirsher 				       adapter_handle,		/* R4 */
5999aa32835SJeff Kirsher 				       neq_handle,		/* R5 */
6009aa32835SJeff Kirsher 				       event_mask,		/* R6 */
6019aa32835SJeff Kirsher 				       0, 0, 0, 0);		/* R7-R12 */
6029aa32835SJeff Kirsher }
6039aa32835SJeff Kirsher 
ehea_h_error_data(const u64 adapter_handle,const u64 ressource_handle,void * rblock)6049aa32835SJeff Kirsher u64 ehea_h_error_data(const u64 adapter_handle, const u64 ressource_handle,
6059aa32835SJeff Kirsher 		      void *rblock)
6069aa32835SJeff Kirsher {
6079aa32835SJeff Kirsher 	return ehea_plpar_hcall_norets(H_ERROR_DATA,
6089aa32835SJeff Kirsher 				       adapter_handle,		/* R4 */
6099aa32835SJeff Kirsher 				       ressource_handle,	/* R5 */
61067e1dbcbSMichael Ellerman 				       __pa(rblock),		/* R6 */
6119aa32835SJeff Kirsher 				       0, 0, 0, 0);		/* R7-R12 */
6129aa32835SJeff Kirsher }
613