18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
48c2ecf20Sopenharmony_ci * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef RXE_PARAM_H
88c2ecf20Sopenharmony_ci#define RXE_PARAM_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <uapi/rdma/rdma_user_rxe.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cistatic inline enum ib_mtu rxe_mtu_int_to_enum(int mtu)
138c2ecf20Sopenharmony_ci{
148c2ecf20Sopenharmony_ci	if (mtu < 256)
158c2ecf20Sopenharmony_ci		return 0;
168c2ecf20Sopenharmony_ci	else if (mtu < 512)
178c2ecf20Sopenharmony_ci		return IB_MTU_256;
188c2ecf20Sopenharmony_ci	else if (mtu < 1024)
198c2ecf20Sopenharmony_ci		return IB_MTU_512;
208c2ecf20Sopenharmony_ci	else if (mtu < 2048)
218c2ecf20Sopenharmony_ci		return IB_MTU_1024;
228c2ecf20Sopenharmony_ci	else if (mtu < 4096)
238c2ecf20Sopenharmony_ci		return IB_MTU_2048;
248c2ecf20Sopenharmony_ci	else
258c2ecf20Sopenharmony_ci		return IB_MTU_4096;
268c2ecf20Sopenharmony_ci}
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* Find the IB mtu for a given network MTU. */
298c2ecf20Sopenharmony_cistatic inline enum ib_mtu eth_mtu_int_to_enum(int mtu)
308c2ecf20Sopenharmony_ci{
318c2ecf20Sopenharmony_ci	mtu -= RXE_MAX_HDR_LENGTH;
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci	return rxe_mtu_int_to_enum(mtu);
348c2ecf20Sopenharmony_ci}
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/* default/initial rxe device parameter settings */
378c2ecf20Sopenharmony_cienum rxe_device_param {
388c2ecf20Sopenharmony_ci	RXE_MAX_MR_SIZE			= -1ull,
398c2ecf20Sopenharmony_ci	RXE_PAGE_SIZE_CAP		= 0xfffff000,
408c2ecf20Sopenharmony_ci	RXE_MAX_QP			= 0x10000,
418c2ecf20Sopenharmony_ci	RXE_MAX_QP_WR			= 0x4000,
428c2ecf20Sopenharmony_ci	RXE_DEVICE_CAP_FLAGS		= IB_DEVICE_BAD_PKEY_CNTR
438c2ecf20Sopenharmony_ci					| IB_DEVICE_BAD_QKEY_CNTR
448c2ecf20Sopenharmony_ci					| IB_DEVICE_AUTO_PATH_MIG
458c2ecf20Sopenharmony_ci					| IB_DEVICE_CHANGE_PHY_PORT
468c2ecf20Sopenharmony_ci					| IB_DEVICE_UD_AV_PORT_ENFORCE
478c2ecf20Sopenharmony_ci					| IB_DEVICE_PORT_ACTIVE_EVENT
488c2ecf20Sopenharmony_ci					| IB_DEVICE_SYS_IMAGE_GUID
498c2ecf20Sopenharmony_ci					| IB_DEVICE_RC_RNR_NAK_GEN
508c2ecf20Sopenharmony_ci					| IB_DEVICE_SRQ_RESIZE
518c2ecf20Sopenharmony_ci					| IB_DEVICE_MEM_MGT_EXTENSIONS
528c2ecf20Sopenharmony_ci					| IB_DEVICE_ALLOW_USER_UNREG,
538c2ecf20Sopenharmony_ci	RXE_MAX_SGE			= 32,
548c2ecf20Sopenharmony_ci	RXE_MAX_WQE_SIZE		= sizeof(struct rxe_send_wqe) +
558c2ecf20Sopenharmony_ci					  sizeof(struct ib_sge) * RXE_MAX_SGE,
568c2ecf20Sopenharmony_ci	RXE_MAX_INLINE_DATA		= RXE_MAX_WQE_SIZE -
578c2ecf20Sopenharmony_ci					  sizeof(struct rxe_send_wqe),
588c2ecf20Sopenharmony_ci	RXE_MAX_SGE_RD			= 32,
598c2ecf20Sopenharmony_ci	RXE_MAX_CQ			= 16384,
608c2ecf20Sopenharmony_ci	RXE_MAX_LOG_CQE			= 15,
618c2ecf20Sopenharmony_ci	RXE_MAX_MR			= 256 * 1024,
628c2ecf20Sopenharmony_ci	RXE_MAX_PD			= 0x7ffc,
638c2ecf20Sopenharmony_ci	RXE_MAX_QP_RD_ATOM		= 128,
648c2ecf20Sopenharmony_ci	RXE_MAX_RES_RD_ATOM		= 0x3f000,
658c2ecf20Sopenharmony_ci	RXE_MAX_QP_INIT_RD_ATOM		= 128,
668c2ecf20Sopenharmony_ci	RXE_MAX_MCAST_GRP		= 8192,
678c2ecf20Sopenharmony_ci	RXE_MAX_MCAST_QP_ATTACH		= 56,
688c2ecf20Sopenharmony_ci	RXE_MAX_TOT_MCAST_QP_ATTACH	= 0x70000,
698c2ecf20Sopenharmony_ci	RXE_MAX_AH			= 100,
708c2ecf20Sopenharmony_ci	RXE_MAX_SRQ			= 960,
718c2ecf20Sopenharmony_ci	RXE_MAX_SRQ_WR			= 0x4000,
728c2ecf20Sopenharmony_ci	RXE_MIN_SRQ_WR			= 1,
738c2ecf20Sopenharmony_ci	RXE_MAX_SRQ_SGE			= 27,
748c2ecf20Sopenharmony_ci	RXE_MIN_SRQ_SGE			= 1,
758c2ecf20Sopenharmony_ci	RXE_MAX_FMR_PAGE_LIST_LEN	= 512,
768c2ecf20Sopenharmony_ci	RXE_MAX_PKEYS			= 1,
778c2ecf20Sopenharmony_ci	RXE_LOCAL_CA_ACK_DELAY		= 15,
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci	RXE_MAX_UCONTEXT		= 512,
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci	RXE_NUM_PORT			= 1,
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	RXE_MIN_QP_INDEX		= 16,
848c2ecf20Sopenharmony_ci	RXE_MAX_QP_INDEX		= 0x00020000,
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	RXE_MIN_SRQ_INDEX		= 0x00020001,
878c2ecf20Sopenharmony_ci	RXE_MAX_SRQ_INDEX		= 0x00040000,
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	RXE_MIN_MR_INDEX		= 0x00000001,
908c2ecf20Sopenharmony_ci	RXE_MAX_MR_INDEX		= 0x00040000,
918c2ecf20Sopenharmony_ci	RXE_MIN_MW_INDEX		= 0x00040001,
928c2ecf20Sopenharmony_ci	RXE_MAX_MW_INDEX		= 0x00060000,
938c2ecf20Sopenharmony_ci	RXE_MAX_PKT_PER_ACK		= 64,
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	RXE_MAX_UNACKED_PSNS		= 128,
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	/* Max inflight SKBs per queue pair */
988c2ecf20Sopenharmony_ci	RXE_INFLIGHT_SKBS_PER_QP_HIGH	= 64,
998c2ecf20Sopenharmony_ci	RXE_INFLIGHT_SKBS_PER_QP_LOW	= 16,
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci	/* Max number of interations of each tasklet
1028c2ecf20Sopenharmony_ci	 * before yielding the cpu to let other
1038c2ecf20Sopenharmony_ci	 * work make progress
1048c2ecf20Sopenharmony_ci	 */
1058c2ecf20Sopenharmony_ci	RXE_MAX_ITERATIONS		= 1024,
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci	/* Delay before calling arbiter timer */
1088c2ecf20Sopenharmony_ci	RXE_NSEC_ARB_TIMER_DELAY	= 200,
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci	/* IBTA v1.4 A3.3.1 VENDOR INFORMATION section */
1118c2ecf20Sopenharmony_ci	RXE_VENDOR_ID			= 0XFFFFFF,
1128c2ecf20Sopenharmony_ci};
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci/* default/initial rxe port parameters */
1158c2ecf20Sopenharmony_cienum rxe_port_param {
1168c2ecf20Sopenharmony_ci	RXE_PORT_GID_TBL_LEN		= 1024,
1178c2ecf20Sopenharmony_ci	RXE_PORT_PORT_CAP_FLAGS		= IB_PORT_CM_SUP,
1188c2ecf20Sopenharmony_ci	RXE_PORT_MAX_MSG_SZ		= 0x800000,
1198c2ecf20Sopenharmony_ci	RXE_PORT_BAD_PKEY_CNTR		= 0,
1208c2ecf20Sopenharmony_ci	RXE_PORT_QKEY_VIOL_CNTR		= 0,
1218c2ecf20Sopenharmony_ci	RXE_PORT_LID			= 0,
1228c2ecf20Sopenharmony_ci	RXE_PORT_SM_LID			= 0,
1238c2ecf20Sopenharmony_ci	RXE_PORT_SM_SL			= 0,
1248c2ecf20Sopenharmony_ci	RXE_PORT_LMC			= 0,
1258c2ecf20Sopenharmony_ci	RXE_PORT_MAX_VL_NUM		= 1,
1268c2ecf20Sopenharmony_ci	RXE_PORT_SUBNET_TIMEOUT		= 0,
1278c2ecf20Sopenharmony_ci	RXE_PORT_INIT_TYPE_REPLY	= 0,
1288c2ecf20Sopenharmony_ci	RXE_PORT_ACTIVE_WIDTH		= IB_WIDTH_1X,
1298c2ecf20Sopenharmony_ci	RXE_PORT_ACTIVE_SPEED		= 1,
1308c2ecf20Sopenharmony_ci	RXE_PORT_PKEY_TBL_LEN		= 1,
1318c2ecf20Sopenharmony_ci	RXE_PORT_PHYS_STATE		= IB_PORT_PHYS_STATE_POLLING,
1328c2ecf20Sopenharmony_ci	RXE_PORT_SUBNET_PREFIX		= 0xfe80000000000000ULL,
1338c2ecf20Sopenharmony_ci};
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci/* default/initial port info parameters */
1368c2ecf20Sopenharmony_cienum rxe_port_info_param {
1378c2ecf20Sopenharmony_ci	RXE_PORT_INFO_VL_CAP		= 4,	/* 1-8 */
1388c2ecf20Sopenharmony_ci	RXE_PORT_INFO_MTU_CAP		= 5,	/* 4096 */
1398c2ecf20Sopenharmony_ci	RXE_PORT_INFO_OPER_VL		= 1,	/* 1 */
1408c2ecf20Sopenharmony_ci};
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci#endif /* RXE_PARAM_H */
143