18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  linux/drivers/net/ethernet/ibm/ehea/ehea_phyp.c
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  eHEA ethernet device driver for IBM eServer System p
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci *  (C) Copyright IBM Corp. 2006
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci *  Authors:
108c2ecf20Sopenharmony_ci *	 Christoph Raisch <raisch@de.ibm.com>
118c2ecf20Sopenharmony_ci *	 Jan-Bernd Themann <themann@de.ibm.com>
128c2ecf20Sopenharmony_ci *	 Thomas Klein <tklein@de.ibm.com>
138c2ecf20Sopenharmony_ci */
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include "ehea_phyp.h"
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_cistatic inline u16 get_order_of_qentries(u16 queue_entries)
218c2ecf20Sopenharmony_ci{
228c2ecf20Sopenharmony_ci	u8 ld = 1;		/*  logarithmus dualis */
238c2ecf20Sopenharmony_ci	while (((1U << ld) - 1) < queue_entries)
248c2ecf20Sopenharmony_ci		ld++;
258c2ecf20Sopenharmony_ci	return ld - 1;
268c2ecf20Sopenharmony_ci}
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* Defines for H_CALL H_ALLOC_RESOURCE */
298c2ecf20Sopenharmony_ci#define H_ALL_RES_TYPE_QP	 1
308c2ecf20Sopenharmony_ci#define H_ALL_RES_TYPE_CQ	 2
318c2ecf20Sopenharmony_ci#define H_ALL_RES_TYPE_EQ	 3
328c2ecf20Sopenharmony_ci#define H_ALL_RES_TYPE_MR	 5
338c2ecf20Sopenharmony_ci#define H_ALL_RES_TYPE_MW	 6
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic long ehea_plpar_hcall_norets(unsigned long opcode,
368c2ecf20Sopenharmony_ci				    unsigned long arg1,
378c2ecf20Sopenharmony_ci				    unsigned long arg2,
388c2ecf20Sopenharmony_ci				    unsigned long arg3,
398c2ecf20Sopenharmony_ci				    unsigned long arg4,
408c2ecf20Sopenharmony_ci				    unsigned long arg5,
418c2ecf20Sopenharmony_ci				    unsigned long arg6,
428c2ecf20Sopenharmony_ci				    unsigned long arg7)
438c2ecf20Sopenharmony_ci{
448c2ecf20Sopenharmony_ci	long ret;
458c2ecf20Sopenharmony_ci	int i, sleep_msecs;
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
488c2ecf20Sopenharmony_ci		ret = plpar_hcall_norets(opcode, arg1, arg2, arg3, arg4,
498c2ecf20Sopenharmony_ci					 arg5, arg6, arg7);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci		if (H_IS_LONG_BUSY(ret)) {
528c2ecf20Sopenharmony_ci			sleep_msecs = get_longbusy_msecs(ret);
538c2ecf20Sopenharmony_ci			msleep_interruptible(sleep_msecs);
548c2ecf20Sopenharmony_ci			continue;
558c2ecf20Sopenharmony_ci		}
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci		if (ret < H_SUCCESS)
588c2ecf20Sopenharmony_ci			pr_err("opcode=%lx ret=%lx"
598c2ecf20Sopenharmony_ci			       " arg1=%lx arg2=%lx arg3=%lx arg4=%lx"
608c2ecf20Sopenharmony_ci			       " arg5=%lx arg6=%lx arg7=%lx\n",
618c2ecf20Sopenharmony_ci			       opcode, ret,
628c2ecf20Sopenharmony_ci			       arg1, arg2, arg3, arg4, arg5, arg6, arg7);
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci		return ret;
658c2ecf20Sopenharmony_ci	}
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci	return H_BUSY;
688c2ecf20Sopenharmony_ci}
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_cistatic long ehea_plpar_hcall9(unsigned long opcode,
718c2ecf20Sopenharmony_ci			      unsigned long *outs, /* array of 9 outputs */
728c2ecf20Sopenharmony_ci			      unsigned long arg1,
738c2ecf20Sopenharmony_ci			      unsigned long arg2,
748c2ecf20Sopenharmony_ci			      unsigned long arg3,
758c2ecf20Sopenharmony_ci			      unsigned long arg4,
768c2ecf20Sopenharmony_ci			      unsigned long arg5,
778c2ecf20Sopenharmony_ci			      unsigned long arg6,
788c2ecf20Sopenharmony_ci			      unsigned long arg7,
798c2ecf20Sopenharmony_ci			      unsigned long arg8,
808c2ecf20Sopenharmony_ci			      unsigned long arg9)
818c2ecf20Sopenharmony_ci{
828c2ecf20Sopenharmony_ci	long ret;
838c2ecf20Sopenharmony_ci	int i, sleep_msecs;
848c2ecf20Sopenharmony_ci	u8 cb_cat;
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++) {
878c2ecf20Sopenharmony_ci		ret = plpar_hcall9(opcode, outs,
888c2ecf20Sopenharmony_ci				   arg1, arg2, arg3, arg4, arg5,
898c2ecf20Sopenharmony_ci				   arg6, arg7, arg8, arg9);
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci		if (H_IS_LONG_BUSY(ret)) {
928c2ecf20Sopenharmony_ci			sleep_msecs = get_longbusy_msecs(ret);
938c2ecf20Sopenharmony_ci			msleep_interruptible(sleep_msecs);
948c2ecf20Sopenharmony_ci			continue;
958c2ecf20Sopenharmony_ci		}
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci		cb_cat = EHEA_BMASK_GET(H_MEHEAPORT_CAT, arg2);
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci		if ((ret < H_SUCCESS) && !(((ret == H_AUTHORITY)
1008c2ecf20Sopenharmony_ci		    && (opcode == H_MODIFY_HEA_PORT))
1018c2ecf20Sopenharmony_ci		    && (((cb_cat == H_PORT_CB4) && ((arg3 == H_PORT_CB4_JUMBO)
1028c2ecf20Sopenharmony_ci		    || (arg3 == H_PORT_CB4_SPEED))) || ((cb_cat == H_PORT_CB7)
1038c2ecf20Sopenharmony_ci		    && (arg3 == H_PORT_CB7_DUCQPN)))))
1048c2ecf20Sopenharmony_ci			pr_err("opcode=%lx ret=%lx"
1058c2ecf20Sopenharmony_ci			       " arg1=%lx arg2=%lx arg3=%lx arg4=%lx"
1068c2ecf20Sopenharmony_ci			       " arg5=%lx arg6=%lx arg7=%lx arg8=%lx"
1078c2ecf20Sopenharmony_ci			       " arg9=%lx"
1088c2ecf20Sopenharmony_ci			       " out1=%lx out2=%lx out3=%lx out4=%lx"
1098c2ecf20Sopenharmony_ci			       " out5=%lx out6=%lx out7=%lx out8=%lx"
1108c2ecf20Sopenharmony_ci			       " out9=%lx\n",
1118c2ecf20Sopenharmony_ci			       opcode, ret,
1128c2ecf20Sopenharmony_ci			       arg1, arg2, arg3, arg4, arg5,
1138c2ecf20Sopenharmony_ci			       arg6, arg7, arg8, arg9,
1148c2ecf20Sopenharmony_ci			       outs[0], outs[1], outs[2], outs[3], outs[4],
1158c2ecf20Sopenharmony_ci			       outs[5], outs[6], outs[7], outs[8]);
1168c2ecf20Sopenharmony_ci		return ret;
1178c2ecf20Sopenharmony_ci	}
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci	return H_BUSY;
1208c2ecf20Sopenharmony_ci}
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ciu64 ehea_h_query_ehea_qp(const u64 adapter_handle, const u8 qp_category,
1238c2ecf20Sopenharmony_ci			 const u64 qp_handle, const u64 sel_mask, void *cb_addr)
1248c2ecf20Sopenharmony_ci{
1258c2ecf20Sopenharmony_ci	return ehea_plpar_hcall_norets(H_QUERY_HEA_QP,
1268c2ecf20Sopenharmony_ci				       adapter_handle,		/* R4 */
1278c2ecf20Sopenharmony_ci				       qp_category,		/* R5 */
1288c2ecf20Sopenharmony_ci				       qp_handle,		/* R6 */
1298c2ecf20Sopenharmony_ci				       sel_mask,		/* R7 */
1308c2ecf20Sopenharmony_ci				       __pa(cb_addr),		/* R8 */
1318c2ecf20Sopenharmony_ci				       0, 0);
1328c2ecf20Sopenharmony_ci}
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci/* input param R5 */
1358c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_EQPO	  EHEA_BMASK_IBM(9, 11)
1368c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_QPP	  EHEA_BMASK_IBM(12, 12)
1378c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_RQR	  EHEA_BMASK_IBM(13, 15)
1388c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_EQEG	  EHEA_BMASK_IBM(16, 16)
1398c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_LL_QP	  EHEA_BMASK_IBM(17, 17)
1408c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_DMA128	  EHEA_BMASK_IBM(19, 19)
1418c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_HSM	  EHEA_BMASK_IBM(20, 21)
1428c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_SIGT	  EHEA_BMASK_IBM(22, 23)
1438c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_TENURE	  EHEA_BMASK_IBM(48, 55)
1448c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_RES_TYP	  EHEA_BMASK_IBM(56, 63)
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci/* input param R9  */
1478c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_TOKEN	  EHEA_BMASK_IBM(0, 31)
1488c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_PD		  EHEA_BMASK_IBM(32, 63)
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci/* input param R10 */
1518c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_MAX_SWQE	  EHEA_BMASK_IBM(4, 7)
1528c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_MAX_R1WQE	  EHEA_BMASK_IBM(12, 15)
1538c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_MAX_R2WQE	  EHEA_BMASK_IBM(20, 23)
1548c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_MAX_R3WQE	  EHEA_BMASK_IBM(28, 31)
1558c2ecf20Sopenharmony_ci/* Max Send Scatter Gather Elements */
1568c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_MAX_SSGE	  EHEA_BMASK_IBM(37, 39)
1578c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_MAX_R1SGE	  EHEA_BMASK_IBM(45, 47)
1588c2ecf20Sopenharmony_ci/* Max Receive SG Elements RQ1 */
1598c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_MAX_R2SGE	  EHEA_BMASK_IBM(53, 55)
1608c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_MAX_R3SGE	  EHEA_BMASK_IBM(61, 63)
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci/* input param R11 */
1638c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_SWQE_IDL	  EHEA_BMASK_IBM(0, 7)
1648c2ecf20Sopenharmony_ci/* max swqe immediate data length */
1658c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_PORT_NUM	  EHEA_BMASK_IBM(48, 63)
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci/* input param R12 */
1688c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_TH_RQ2	  EHEA_BMASK_IBM(0, 15)
1698c2ecf20Sopenharmony_ci/* Threshold RQ2 */
1708c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_TH_RQ3	  EHEA_BMASK_IBM(16, 31)
1718c2ecf20Sopenharmony_ci/* Threshold RQ3 */
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci/* output param R6 */
1748c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_ACT_SWQE	  EHEA_BMASK_IBM(0, 15)
1758c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_ACT_R1WQE	  EHEA_BMASK_IBM(16, 31)
1768c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_ACT_R2WQE	  EHEA_BMASK_IBM(32, 47)
1778c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_ACT_R3WQE	  EHEA_BMASK_IBM(48, 63)
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci/* output param, R7 */
1808c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_ACT_SSGE	  EHEA_BMASK_IBM(0, 7)
1818c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_ACT_R1SGE	  EHEA_BMASK_IBM(8, 15)
1828c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_ACT_R2SGE	  EHEA_BMASK_IBM(16, 23)
1838c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_ACT_R3SGE	  EHEA_BMASK_IBM(24, 31)
1848c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_ACT_SWQE_IDL EHEA_BMASK_IBM(32, 39)
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci/* output param R8,R9 */
1878c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_SIZE_SQ	  EHEA_BMASK_IBM(0, 31)
1888c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_SIZE_RQ1	  EHEA_BMASK_IBM(32, 63)
1898c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_SIZE_RQ2	  EHEA_BMASK_IBM(0, 31)
1908c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_SIZE_RQ3	  EHEA_BMASK_IBM(32, 63)
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci/* output param R11,R12 */
1938c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_LIOBN_SQ	  EHEA_BMASK_IBM(0, 31)
1948c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_LIOBN_RQ1	  EHEA_BMASK_IBM(32, 63)
1958c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_LIOBN_RQ2	  EHEA_BMASK_IBM(0, 31)
1968c2ecf20Sopenharmony_ci#define H_ALL_RES_QP_LIOBN_RQ3	  EHEA_BMASK_IBM(32, 63)
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ciu64 ehea_h_alloc_resource_qp(const u64 adapter_handle,
1998c2ecf20Sopenharmony_ci			     struct ehea_qp_init_attr *init_attr, const u32 pd,
2008c2ecf20Sopenharmony_ci			     u64 *qp_handle, struct h_epas *h_epas)
2018c2ecf20Sopenharmony_ci{
2028c2ecf20Sopenharmony_ci	u64 hret;
2038c2ecf20Sopenharmony_ci	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci	u64 allocate_controls =
2068c2ecf20Sopenharmony_ci	    EHEA_BMASK_SET(H_ALL_RES_QP_EQPO, init_attr->low_lat_rq1 ? 1 : 0)
2078c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_QPP, 0)
2088c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_RQR, 6)	/* rq1 & rq2 & rq3 */
2098c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_EQEG, 0)	/* EQE gen. disabled */
2108c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_LL_QP, init_attr->low_lat_rq1)
2118c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_DMA128, 0)
2128c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_HSM, 0)
2138c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_SIGT, init_attr->signalingtype)
2148c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_RES_TYP, H_ALL_RES_TYPE_QP);
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci	u64 r9_reg = EHEA_BMASK_SET(H_ALL_RES_QP_PD, pd)
2178c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_TOKEN, init_attr->qp_token);
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci	u64 max_r10_reg =
2208c2ecf20Sopenharmony_ci	    EHEA_BMASK_SET(H_ALL_RES_QP_MAX_SWQE,
2218c2ecf20Sopenharmony_ci			   get_order_of_qentries(init_attr->max_nr_send_wqes))
2228c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_R1WQE,
2238c2ecf20Sopenharmony_ci			     get_order_of_qentries(init_attr->max_nr_rwqes_rq1))
2248c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_R2WQE,
2258c2ecf20Sopenharmony_ci			     get_order_of_qentries(init_attr->max_nr_rwqes_rq2))
2268c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_R3WQE,
2278c2ecf20Sopenharmony_ci			     get_order_of_qentries(init_attr->max_nr_rwqes_rq3))
2288c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_SSGE, init_attr->wqe_size_enc_sq)
2298c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_R1SGE,
2308c2ecf20Sopenharmony_ci			     init_attr->wqe_size_enc_rq1)
2318c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_R2SGE,
2328c2ecf20Sopenharmony_ci			     init_attr->wqe_size_enc_rq2)
2338c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_MAX_R3SGE,
2348c2ecf20Sopenharmony_ci			     init_attr->wqe_size_enc_rq3);
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci	u64 r11_in =
2378c2ecf20Sopenharmony_ci	    EHEA_BMASK_SET(H_ALL_RES_QP_SWQE_IDL, init_attr->swqe_imm_data_len)
2388c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_PORT_NUM, init_attr->port_nr);
2398c2ecf20Sopenharmony_ci	u64 threshold =
2408c2ecf20Sopenharmony_ci	    EHEA_BMASK_SET(H_ALL_RES_QP_TH_RQ2, init_attr->rq2_threshold)
2418c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_QP_TH_RQ3, init_attr->rq3_threshold);
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci	hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
2448c2ecf20Sopenharmony_ci				 outs,
2458c2ecf20Sopenharmony_ci				 adapter_handle,		/* R4 */
2468c2ecf20Sopenharmony_ci				 allocate_controls,		/* R5 */
2478c2ecf20Sopenharmony_ci				 init_attr->send_cq_handle,	/* R6 */
2488c2ecf20Sopenharmony_ci				 init_attr->recv_cq_handle,	/* R7 */
2498c2ecf20Sopenharmony_ci				 init_attr->aff_eq_handle,	/* R8 */
2508c2ecf20Sopenharmony_ci				 r9_reg,			/* R9 */
2518c2ecf20Sopenharmony_ci				 max_r10_reg,			/* R10 */
2528c2ecf20Sopenharmony_ci				 r11_in,			/* R11 */
2538c2ecf20Sopenharmony_ci				 threshold);			/* R12 */
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci	*qp_handle = outs[0];
2568c2ecf20Sopenharmony_ci	init_attr->qp_nr = (u32)outs[1];
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci	init_attr->act_nr_send_wqes =
2598c2ecf20Sopenharmony_ci	    (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_SWQE, outs[2]);
2608c2ecf20Sopenharmony_ci	init_attr->act_nr_rwqes_rq1 =
2618c2ecf20Sopenharmony_ci	    (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R1WQE, outs[2]);
2628c2ecf20Sopenharmony_ci	init_attr->act_nr_rwqes_rq2 =
2638c2ecf20Sopenharmony_ci	    (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R2WQE, outs[2]);
2648c2ecf20Sopenharmony_ci	init_attr->act_nr_rwqes_rq3 =
2658c2ecf20Sopenharmony_ci	    (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R3WQE, outs[2]);
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci	init_attr->act_wqe_size_enc_sq = init_attr->wqe_size_enc_sq;
2688c2ecf20Sopenharmony_ci	init_attr->act_wqe_size_enc_rq1 = init_attr->wqe_size_enc_rq1;
2698c2ecf20Sopenharmony_ci	init_attr->act_wqe_size_enc_rq2 = init_attr->wqe_size_enc_rq2;
2708c2ecf20Sopenharmony_ci	init_attr->act_wqe_size_enc_rq3 = init_attr->wqe_size_enc_rq3;
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci	init_attr->nr_sq_pages =
2738c2ecf20Sopenharmony_ci	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_SQ, outs[4]);
2748c2ecf20Sopenharmony_ci	init_attr->nr_rq1_pages =
2758c2ecf20Sopenharmony_ci	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ1, outs[4]);
2768c2ecf20Sopenharmony_ci	init_attr->nr_rq2_pages =
2778c2ecf20Sopenharmony_ci	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ2, outs[5]);
2788c2ecf20Sopenharmony_ci	init_attr->nr_rq3_pages =
2798c2ecf20Sopenharmony_ci	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ3, outs[5]);
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci	init_attr->liobn_sq =
2828c2ecf20Sopenharmony_ci	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_SQ, outs[7]);
2838c2ecf20Sopenharmony_ci	init_attr->liobn_rq1 =
2848c2ecf20Sopenharmony_ci	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ1, outs[7]);
2858c2ecf20Sopenharmony_ci	init_attr->liobn_rq2 =
2868c2ecf20Sopenharmony_ci	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ2, outs[8]);
2878c2ecf20Sopenharmony_ci	init_attr->liobn_rq3 =
2888c2ecf20Sopenharmony_ci	    (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ3, outs[8]);
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci	if (!hret)
2918c2ecf20Sopenharmony_ci		hcp_epas_ctor(h_epas, outs[6], outs[6]);
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci	return hret;
2948c2ecf20Sopenharmony_ci}
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ciu64 ehea_h_alloc_resource_cq(const u64 adapter_handle,
2978c2ecf20Sopenharmony_ci			     struct ehea_cq_attr *cq_attr,
2988c2ecf20Sopenharmony_ci			     u64 *cq_handle, struct h_epas *epas)
2998c2ecf20Sopenharmony_ci{
3008c2ecf20Sopenharmony_ci	u64 hret;
3018c2ecf20Sopenharmony_ci	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
3048c2ecf20Sopenharmony_ci				 outs,
3058c2ecf20Sopenharmony_ci				 adapter_handle,		/* R4 */
3068c2ecf20Sopenharmony_ci				 H_ALL_RES_TYPE_CQ,		/* R5 */
3078c2ecf20Sopenharmony_ci				 cq_attr->eq_handle,		/* R6 */
3088c2ecf20Sopenharmony_ci				 cq_attr->cq_token,		/* R7 */
3098c2ecf20Sopenharmony_ci				 cq_attr->max_nr_of_cqes,	/* R8 */
3108c2ecf20Sopenharmony_ci				 0, 0, 0, 0);			/* R9-R12 */
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci	*cq_handle = outs[0];
3138c2ecf20Sopenharmony_ci	cq_attr->act_nr_of_cqes = outs[3];
3148c2ecf20Sopenharmony_ci	cq_attr->nr_pages = outs[4];
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci	if (!hret)
3178c2ecf20Sopenharmony_ci		hcp_epas_ctor(epas, outs[5], outs[6]);
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci	return hret;
3208c2ecf20Sopenharmony_ci}
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci/* Defines for H_CALL H_ALLOC_RESOURCE */
3238c2ecf20Sopenharmony_ci#define H_ALL_RES_TYPE_QP	 1
3248c2ecf20Sopenharmony_ci#define H_ALL_RES_TYPE_CQ	 2
3258c2ecf20Sopenharmony_ci#define H_ALL_RES_TYPE_EQ	 3
3268c2ecf20Sopenharmony_ci#define H_ALL_RES_TYPE_MR	 5
3278c2ecf20Sopenharmony_ci#define H_ALL_RES_TYPE_MW	 6
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci/*  input param R5 */
3308c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_NEQ	     EHEA_BMASK_IBM(0, 0)
3318c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_NON_NEQ_ISN     EHEA_BMASK_IBM(6, 7)
3328c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_INH_EQE_GEN     EHEA_BMASK_IBM(16, 16)
3338c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_RES_TYPE	     EHEA_BMASK_IBM(56, 63)
3348c2ecf20Sopenharmony_ci/*  input param R6 */
3358c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_MAX_EQE	     EHEA_BMASK_IBM(32, 63)
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ci/*  output param R6 */
3388c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_LIOBN	     EHEA_BMASK_IBM(32, 63)
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci/*  output param R7 */
3418c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_ACT_EQE	     EHEA_BMASK_IBM(32, 63)
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci/*  output param R8 */
3448c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_ACT_PS	     EHEA_BMASK_IBM(32, 63)
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_ci/*  output param R9 */
3478c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_ACT_EQ_IST_C    EHEA_BMASK_IBM(30, 31)
3488c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_ACT_EQ_IST_1    EHEA_BMASK_IBM(40, 63)
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci/*  output param R10 */
3518c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_ACT_EQ_IST_2    EHEA_BMASK_IBM(40, 63)
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci/*  output param R11 */
3548c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_ACT_EQ_IST_3    EHEA_BMASK_IBM(40, 63)
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci/*  output param R12 */
3578c2ecf20Sopenharmony_ci#define H_ALL_RES_EQ_ACT_EQ_IST_4    EHEA_BMASK_IBM(40, 63)
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_ciu64 ehea_h_alloc_resource_eq(const u64 adapter_handle,
3608c2ecf20Sopenharmony_ci			     struct ehea_eq_attr *eq_attr, u64 *eq_handle)
3618c2ecf20Sopenharmony_ci{
3628c2ecf20Sopenharmony_ci	u64 hret, allocate_controls;
3638c2ecf20Sopenharmony_ci	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ci	/* resource type */
3668c2ecf20Sopenharmony_ci	allocate_controls =
3678c2ecf20Sopenharmony_ci	    EHEA_BMASK_SET(H_ALL_RES_EQ_RES_TYPE, H_ALL_RES_TYPE_EQ)
3688c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_EQ_NEQ, eq_attr->type ? 1 : 0)
3698c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_EQ_INH_EQE_GEN, !eq_attr->eqe_gen)
3708c2ecf20Sopenharmony_ci	    | EHEA_BMASK_SET(H_ALL_RES_EQ_NON_NEQ_ISN, 1);
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
3738c2ecf20Sopenharmony_ci				 outs,
3748c2ecf20Sopenharmony_ci				 adapter_handle,		/* R4 */
3758c2ecf20Sopenharmony_ci				 allocate_controls,		/* R5 */
3768c2ecf20Sopenharmony_ci				 eq_attr->max_nr_of_eqes,	/* R6 */
3778c2ecf20Sopenharmony_ci				 0, 0, 0, 0, 0, 0);		/* R7-R10 */
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci	*eq_handle = outs[0];
3808c2ecf20Sopenharmony_ci	eq_attr->act_nr_of_eqes = outs[3];
3818c2ecf20Sopenharmony_ci	eq_attr->nr_pages = outs[4];
3828c2ecf20Sopenharmony_ci	eq_attr->ist1 = outs[5];
3838c2ecf20Sopenharmony_ci	eq_attr->ist2 = outs[6];
3848c2ecf20Sopenharmony_ci	eq_attr->ist3 = outs[7];
3858c2ecf20Sopenharmony_ci	eq_attr->ist4 = outs[8];
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_ci	return hret;
3888c2ecf20Sopenharmony_ci}
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ciu64 ehea_h_modify_ehea_qp(const u64 adapter_handle, const u8 cat,
3918c2ecf20Sopenharmony_ci			  const u64 qp_handle, const u64 sel_mask,
3928c2ecf20Sopenharmony_ci			  void *cb_addr, u64 *inv_attr_id, u64 *proc_mask,
3938c2ecf20Sopenharmony_ci			  u16 *out_swr, u16 *out_rwr)
3948c2ecf20Sopenharmony_ci{
3958c2ecf20Sopenharmony_ci	u64 hret;
3968c2ecf20Sopenharmony_ci	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_ci	hret = ehea_plpar_hcall9(H_MODIFY_HEA_QP,
3998c2ecf20Sopenharmony_ci				 outs,
4008c2ecf20Sopenharmony_ci				 adapter_handle,		/* R4 */
4018c2ecf20Sopenharmony_ci				 (u64) cat,			/* R5 */
4028c2ecf20Sopenharmony_ci				 qp_handle,			/* R6 */
4038c2ecf20Sopenharmony_ci				 sel_mask,			/* R7 */
4048c2ecf20Sopenharmony_ci				 __pa(cb_addr),			/* R8 */
4058c2ecf20Sopenharmony_ci				 0, 0, 0, 0);			/* R9-R12 */
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_ci	*inv_attr_id = outs[0];
4088c2ecf20Sopenharmony_ci	*out_swr = outs[3];
4098c2ecf20Sopenharmony_ci	*out_rwr = outs[4];
4108c2ecf20Sopenharmony_ci	*proc_mask = outs[5];
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ci	return hret;
4138c2ecf20Sopenharmony_ci}
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ciu64 ehea_h_register_rpage(const u64 adapter_handle, const u8 pagesize,
4168c2ecf20Sopenharmony_ci			  const u8 queue_type, const u64 resource_handle,
4178c2ecf20Sopenharmony_ci			  const u64 log_pageaddr, u64 count)
4188c2ecf20Sopenharmony_ci{
4198c2ecf20Sopenharmony_ci	u64  reg_control;
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_ci	reg_control = EHEA_BMASK_SET(H_REG_RPAGE_PAGE_SIZE, pagesize)
4228c2ecf20Sopenharmony_ci		    | EHEA_BMASK_SET(H_REG_RPAGE_QT, queue_type);
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci	return ehea_plpar_hcall_norets(H_REGISTER_HEA_RPAGES,
4258c2ecf20Sopenharmony_ci				       adapter_handle,		/* R4 */
4268c2ecf20Sopenharmony_ci				       reg_control,		/* R5 */
4278c2ecf20Sopenharmony_ci				       resource_handle,		/* R6 */
4288c2ecf20Sopenharmony_ci				       log_pageaddr,		/* R7 */
4298c2ecf20Sopenharmony_ci				       count,			/* R8 */
4308c2ecf20Sopenharmony_ci				       0, 0);			/* R9-R10 */
4318c2ecf20Sopenharmony_ci}
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ciu64 ehea_h_register_smr(const u64 adapter_handle, const u64 orig_mr_handle,
4348c2ecf20Sopenharmony_ci			const u64 vaddr_in, const u32 access_ctrl, const u32 pd,
4358c2ecf20Sopenharmony_ci			struct ehea_mr *mr)
4368c2ecf20Sopenharmony_ci{
4378c2ecf20Sopenharmony_ci	u64 hret;
4388c2ecf20Sopenharmony_ci	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci	hret = ehea_plpar_hcall9(H_REGISTER_SMR,
4418c2ecf20Sopenharmony_ci				 outs,
4428c2ecf20Sopenharmony_ci				 adapter_handle	      ,		 /* R4 */
4438c2ecf20Sopenharmony_ci				 orig_mr_handle,		 /* R5 */
4448c2ecf20Sopenharmony_ci				 vaddr_in,			 /* R6 */
4458c2ecf20Sopenharmony_ci				 (((u64)access_ctrl) << 32ULL),	 /* R7 */
4468c2ecf20Sopenharmony_ci				 pd,				 /* R8 */
4478c2ecf20Sopenharmony_ci				 0, 0, 0, 0);			 /* R9-R12 */
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci	mr->handle = outs[0];
4508c2ecf20Sopenharmony_ci	mr->lkey = (u32)outs[2];
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_ci	return hret;
4538c2ecf20Sopenharmony_ci}
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ciu64 ehea_h_disable_and_get_hea(const u64 adapter_handle, const u64 qp_handle)
4568c2ecf20Sopenharmony_ci{
4578c2ecf20Sopenharmony_ci	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
4588c2ecf20Sopenharmony_ci
4598c2ecf20Sopenharmony_ci	return ehea_plpar_hcall9(H_DISABLE_AND_GET_HEA,
4608c2ecf20Sopenharmony_ci				 outs,
4618c2ecf20Sopenharmony_ci				 adapter_handle,		/* R4 */
4628c2ecf20Sopenharmony_ci				 H_DISABLE_GET_EHEA_WQE_P,	/* R5 */
4638c2ecf20Sopenharmony_ci				 qp_handle,			/* R6 */
4648c2ecf20Sopenharmony_ci				 0, 0, 0, 0, 0, 0);		/* R7-R12 */
4658c2ecf20Sopenharmony_ci}
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_ciu64 ehea_h_free_resource(const u64 adapter_handle, const u64 res_handle,
4688c2ecf20Sopenharmony_ci			 u64 force_bit)
4698c2ecf20Sopenharmony_ci{
4708c2ecf20Sopenharmony_ci	return ehea_plpar_hcall_norets(H_FREE_RESOURCE,
4718c2ecf20Sopenharmony_ci				       adapter_handle,	   /* R4 */
4728c2ecf20Sopenharmony_ci				       res_handle,	   /* R5 */
4738c2ecf20Sopenharmony_ci				       force_bit,
4748c2ecf20Sopenharmony_ci				       0, 0, 0, 0);	   /* R7-R10 */
4758c2ecf20Sopenharmony_ci}
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_ciu64 ehea_h_alloc_resource_mr(const u64 adapter_handle, const u64 vaddr,
4788c2ecf20Sopenharmony_ci			     const u64 length, const u32 access_ctrl,
4798c2ecf20Sopenharmony_ci			     const u32 pd, u64 *mr_handle, u32 *lkey)
4808c2ecf20Sopenharmony_ci{
4818c2ecf20Sopenharmony_ci	u64 hret;
4828c2ecf20Sopenharmony_ci	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
4838c2ecf20Sopenharmony_ci
4848c2ecf20Sopenharmony_ci	hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
4858c2ecf20Sopenharmony_ci				 outs,
4868c2ecf20Sopenharmony_ci				 adapter_handle,		   /* R4 */
4878c2ecf20Sopenharmony_ci				 5,				   /* R5 */
4888c2ecf20Sopenharmony_ci				 vaddr,				   /* R6 */
4898c2ecf20Sopenharmony_ci				 length,			   /* R7 */
4908c2ecf20Sopenharmony_ci				 (((u64) access_ctrl) << 32ULL),   /* R8 */
4918c2ecf20Sopenharmony_ci				 pd,				   /* R9 */
4928c2ecf20Sopenharmony_ci				 0, 0, 0);			   /* R10-R12 */
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ci	*mr_handle = outs[0];
4958c2ecf20Sopenharmony_ci	*lkey = (u32)outs[2];
4968c2ecf20Sopenharmony_ci	return hret;
4978c2ecf20Sopenharmony_ci}
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ciu64 ehea_h_register_rpage_mr(const u64 adapter_handle, const u64 mr_handle,
5008c2ecf20Sopenharmony_ci			     const u8 pagesize, const u8 queue_type,
5018c2ecf20Sopenharmony_ci			     const u64 log_pageaddr, const u64 count)
5028c2ecf20Sopenharmony_ci{
5038c2ecf20Sopenharmony_ci	if ((count > 1) && (log_pageaddr & ~PAGE_MASK)) {
5048c2ecf20Sopenharmony_ci		pr_err("not on pageboundary\n");
5058c2ecf20Sopenharmony_ci		return H_PARAMETER;
5068c2ecf20Sopenharmony_ci	}
5078c2ecf20Sopenharmony_ci
5088c2ecf20Sopenharmony_ci	return ehea_h_register_rpage(adapter_handle, pagesize,
5098c2ecf20Sopenharmony_ci				     queue_type, mr_handle,
5108c2ecf20Sopenharmony_ci				     log_pageaddr, count);
5118c2ecf20Sopenharmony_ci}
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_ciu64 ehea_h_query_ehea(const u64 adapter_handle, void *cb_addr)
5148c2ecf20Sopenharmony_ci{
5158c2ecf20Sopenharmony_ci	u64 hret, cb_logaddr;
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_ci	cb_logaddr = __pa(cb_addr);
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci	hret = ehea_plpar_hcall_norets(H_QUERY_HEA,
5208c2ecf20Sopenharmony_ci				       adapter_handle,		/* R4 */
5218c2ecf20Sopenharmony_ci				       cb_logaddr,		/* R5 */
5228c2ecf20Sopenharmony_ci				       0, 0, 0, 0, 0);		/* R6-R10 */
5238c2ecf20Sopenharmony_ci#ifdef DEBUG
5248c2ecf20Sopenharmony_ci	ehea_dump(cb_addr, sizeof(struct hcp_query_ehea), "hcp_query_ehea");
5258c2ecf20Sopenharmony_ci#endif
5268c2ecf20Sopenharmony_ci	return hret;
5278c2ecf20Sopenharmony_ci}
5288c2ecf20Sopenharmony_ci
5298c2ecf20Sopenharmony_ciu64 ehea_h_query_ehea_port(const u64 adapter_handle, const u16 port_num,
5308c2ecf20Sopenharmony_ci			   const u8 cb_cat, const u64 select_mask,
5318c2ecf20Sopenharmony_ci			   void *cb_addr)
5328c2ecf20Sopenharmony_ci{
5338c2ecf20Sopenharmony_ci	u64 port_info;
5348c2ecf20Sopenharmony_ci	u64 cb_logaddr = __pa(cb_addr);
5358c2ecf20Sopenharmony_ci	u64 arr_index = 0;
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_ci	port_info = EHEA_BMASK_SET(H_MEHEAPORT_CAT, cb_cat)
5388c2ecf20Sopenharmony_ci		  | EHEA_BMASK_SET(H_MEHEAPORT_PN, port_num);
5398c2ecf20Sopenharmony_ci
5408c2ecf20Sopenharmony_ci	return ehea_plpar_hcall_norets(H_QUERY_HEA_PORT,
5418c2ecf20Sopenharmony_ci				       adapter_handle,		/* R4 */
5428c2ecf20Sopenharmony_ci				       port_info,		/* R5 */
5438c2ecf20Sopenharmony_ci				       select_mask,		/* R6 */
5448c2ecf20Sopenharmony_ci				       arr_index,		/* R7 */
5458c2ecf20Sopenharmony_ci				       cb_logaddr,		/* R8 */
5468c2ecf20Sopenharmony_ci				       0, 0);			/* R9-R10 */
5478c2ecf20Sopenharmony_ci}
5488c2ecf20Sopenharmony_ci
5498c2ecf20Sopenharmony_ciu64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num,
5508c2ecf20Sopenharmony_ci			    const u8 cb_cat, const u64 select_mask,
5518c2ecf20Sopenharmony_ci			    void *cb_addr)
5528c2ecf20Sopenharmony_ci{
5538c2ecf20Sopenharmony_ci	unsigned long outs[PLPAR_HCALL9_BUFSIZE];
5548c2ecf20Sopenharmony_ci	u64 port_info;
5558c2ecf20Sopenharmony_ci	u64 arr_index = 0;
5568c2ecf20Sopenharmony_ci	u64 cb_logaddr = __pa(cb_addr);
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_ci	port_info = EHEA_BMASK_SET(H_MEHEAPORT_CAT, cb_cat)
5598c2ecf20Sopenharmony_ci		  | EHEA_BMASK_SET(H_MEHEAPORT_PN, port_num);
5608c2ecf20Sopenharmony_ci#ifdef DEBUG
5618c2ecf20Sopenharmony_ci	ehea_dump(cb_addr, sizeof(struct hcp_ehea_port_cb0), "Before HCALL");
5628c2ecf20Sopenharmony_ci#endif
5638c2ecf20Sopenharmony_ci	return ehea_plpar_hcall9(H_MODIFY_HEA_PORT,
5648c2ecf20Sopenharmony_ci				 outs,
5658c2ecf20Sopenharmony_ci				 adapter_handle,		/* R4 */
5668c2ecf20Sopenharmony_ci				 port_info,			/* R5 */
5678c2ecf20Sopenharmony_ci				 select_mask,			/* R6 */
5688c2ecf20Sopenharmony_ci				 arr_index,			/* R7 */
5698c2ecf20Sopenharmony_ci				 cb_logaddr,			/* R8 */
5708c2ecf20Sopenharmony_ci				 0, 0, 0, 0);			/* R9-R12 */
5718c2ecf20Sopenharmony_ci}
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_ciu64 ehea_h_reg_dereg_bcmc(const u64 adapter_handle, const u16 port_num,
5748c2ecf20Sopenharmony_ci			  const u8 reg_type, const u64 mc_mac_addr,
5758c2ecf20Sopenharmony_ci			  const u16 vlan_id, const u32 hcall_id)
5768c2ecf20Sopenharmony_ci{
5778c2ecf20Sopenharmony_ci	u64 r5_port_num, r6_reg_type, r7_mc_mac_addr, r8_vlan_id;
5788c2ecf20Sopenharmony_ci	u64 mac_addr = mc_mac_addr >> 16;
5798c2ecf20Sopenharmony_ci
5808c2ecf20Sopenharmony_ci	r5_port_num = EHEA_BMASK_SET(H_REGBCMC_PN, port_num);
5818c2ecf20Sopenharmony_ci	r6_reg_type = EHEA_BMASK_SET(H_REGBCMC_REGTYPE, reg_type);
5828c2ecf20Sopenharmony_ci	r7_mc_mac_addr = EHEA_BMASK_SET(H_REGBCMC_MACADDR, mac_addr);
5838c2ecf20Sopenharmony_ci	r8_vlan_id = EHEA_BMASK_SET(H_REGBCMC_VLANID, vlan_id);
5848c2ecf20Sopenharmony_ci
5858c2ecf20Sopenharmony_ci	return ehea_plpar_hcall_norets(hcall_id,
5868c2ecf20Sopenharmony_ci				       adapter_handle,		/* R4 */
5878c2ecf20Sopenharmony_ci				       r5_port_num,		/* R5 */
5888c2ecf20Sopenharmony_ci				       r6_reg_type,		/* R6 */
5898c2ecf20Sopenharmony_ci				       r7_mc_mac_addr,		/* R7 */
5908c2ecf20Sopenharmony_ci				       r8_vlan_id,		/* R8 */
5918c2ecf20Sopenharmony_ci				       0, 0);			/* R9-R12 */
5928c2ecf20Sopenharmony_ci}
5938c2ecf20Sopenharmony_ci
5948c2ecf20Sopenharmony_ciu64 ehea_h_reset_events(const u64 adapter_handle, const u64 neq_handle,
5958c2ecf20Sopenharmony_ci			const u64 event_mask)
5968c2ecf20Sopenharmony_ci{
5978c2ecf20Sopenharmony_ci	return ehea_plpar_hcall_norets(H_RESET_EVENTS,
5988c2ecf20Sopenharmony_ci				       adapter_handle,		/* R4 */
5998c2ecf20Sopenharmony_ci				       neq_handle,		/* R5 */
6008c2ecf20Sopenharmony_ci				       event_mask,		/* R6 */
6018c2ecf20Sopenharmony_ci				       0, 0, 0, 0);		/* R7-R12 */
6028c2ecf20Sopenharmony_ci}
6038c2ecf20Sopenharmony_ci
6048c2ecf20Sopenharmony_ciu64 ehea_h_error_data(const u64 adapter_handle, const u64 ressource_handle,
6058c2ecf20Sopenharmony_ci		      void *rblock)
6068c2ecf20Sopenharmony_ci{
6078c2ecf20Sopenharmony_ci	return ehea_plpar_hcall_norets(H_ERROR_DATA,
6088c2ecf20Sopenharmony_ci				       adapter_handle,		/* R4 */
6098c2ecf20Sopenharmony_ci				       ressource_handle,	/* R5 */
6108c2ecf20Sopenharmony_ci				       __pa(rblock),		/* R6 */
6118c2ecf20Sopenharmony_ci				       0, 0, 0, 0);		/* R7-R12 */
6128c2ecf20Sopenharmony_ci}
613