162306a36Sopenharmony_ci/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2017-2018, Mellanox Technologies inc.  All rights reserved.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * This software is available to you under a choice of one of two
662306a36Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
762306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
862306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the
962306a36Sopenharmony_ci * OpenIB.org BSD license below:
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
1262306a36Sopenharmony_ci *     without modification, are permitted provided that the following
1362306a36Sopenharmony_ci *     conditions are met:
1462306a36Sopenharmony_ci *
1562306a36Sopenharmony_ci *      - Redistributions of source code must retain the above
1662306a36Sopenharmony_ci *        copyright notice, this list of conditions and the following
1762306a36Sopenharmony_ci *        disclaimer.
1862306a36Sopenharmony_ci *
1962306a36Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
2062306a36Sopenharmony_ci *        copyright notice, this list of conditions and the following
2162306a36Sopenharmony_ci *        disclaimer in the documentation and/or other materials
2262306a36Sopenharmony_ci *        provided with the distribution.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2562306a36Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2662306a36Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2762306a36Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2862306a36Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2962306a36Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3062306a36Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3162306a36Sopenharmony_ci * SOFTWARE.
3262306a36Sopenharmony_ci */
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci#ifndef IB_USER_IOCTL_VERBS_H
3562306a36Sopenharmony_ci#define IB_USER_IOCTL_VERBS_H
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#include <linux/types.h>
3862306a36Sopenharmony_ci#include <rdma/ib_user_verbs.h>
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#ifndef RDMA_UAPI_PTR
4162306a36Sopenharmony_ci#define RDMA_UAPI_PTR(_type, _name)	__aligned_u64 _name
4262306a36Sopenharmony_ci#endif
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci#define IB_UVERBS_ACCESS_OPTIONAL_FIRST (1 << 20)
4562306a36Sopenharmony_ci#define IB_UVERBS_ACCESS_OPTIONAL_LAST (1 << 29)
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_cienum ib_uverbs_core_support {
4862306a36Sopenharmony_ci	IB_UVERBS_CORE_SUPPORT_OPTIONAL_MR_ACCESS = 1 << 0,
4962306a36Sopenharmony_ci};
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_cienum ib_uverbs_access_flags {
5262306a36Sopenharmony_ci	IB_UVERBS_ACCESS_LOCAL_WRITE = 1 << 0,
5362306a36Sopenharmony_ci	IB_UVERBS_ACCESS_REMOTE_WRITE = 1 << 1,
5462306a36Sopenharmony_ci	IB_UVERBS_ACCESS_REMOTE_READ = 1 << 2,
5562306a36Sopenharmony_ci	IB_UVERBS_ACCESS_REMOTE_ATOMIC = 1 << 3,
5662306a36Sopenharmony_ci	IB_UVERBS_ACCESS_MW_BIND = 1 << 4,
5762306a36Sopenharmony_ci	IB_UVERBS_ACCESS_ZERO_BASED = 1 << 5,
5862306a36Sopenharmony_ci	IB_UVERBS_ACCESS_ON_DEMAND = 1 << 6,
5962306a36Sopenharmony_ci	IB_UVERBS_ACCESS_HUGETLB = 1 << 7,
6062306a36Sopenharmony_ci	IB_UVERBS_ACCESS_FLUSH_GLOBAL = 1 << 8,
6162306a36Sopenharmony_ci	IB_UVERBS_ACCESS_FLUSH_PERSISTENT = 1 << 9,
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci	IB_UVERBS_ACCESS_RELAXED_ORDERING = IB_UVERBS_ACCESS_OPTIONAL_FIRST,
6462306a36Sopenharmony_ci	IB_UVERBS_ACCESS_OPTIONAL_RANGE =
6562306a36Sopenharmony_ci		((IB_UVERBS_ACCESS_OPTIONAL_LAST << 1) - 1) &
6662306a36Sopenharmony_ci		~(IB_UVERBS_ACCESS_OPTIONAL_FIRST - 1)
6762306a36Sopenharmony_ci};
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_cienum ib_uverbs_srq_type {
7062306a36Sopenharmony_ci	IB_UVERBS_SRQT_BASIC,
7162306a36Sopenharmony_ci	IB_UVERBS_SRQT_XRC,
7262306a36Sopenharmony_ci	IB_UVERBS_SRQT_TM,
7362306a36Sopenharmony_ci};
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_cienum ib_uverbs_wq_type {
7662306a36Sopenharmony_ci	IB_UVERBS_WQT_RQ,
7762306a36Sopenharmony_ci};
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_cienum ib_uverbs_wq_flags {
8062306a36Sopenharmony_ci	IB_UVERBS_WQ_FLAGS_CVLAN_STRIPPING = 1 << 0,
8162306a36Sopenharmony_ci	IB_UVERBS_WQ_FLAGS_SCATTER_FCS = 1 << 1,
8262306a36Sopenharmony_ci	IB_UVERBS_WQ_FLAGS_DELAY_DROP = 1 << 2,
8362306a36Sopenharmony_ci	IB_UVERBS_WQ_FLAGS_PCI_WRITE_END_PADDING = 1 << 3,
8462306a36Sopenharmony_ci};
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_cienum ib_uverbs_qp_type {
8762306a36Sopenharmony_ci	IB_UVERBS_QPT_RC = 2,
8862306a36Sopenharmony_ci	IB_UVERBS_QPT_UC,
8962306a36Sopenharmony_ci	IB_UVERBS_QPT_UD,
9062306a36Sopenharmony_ci	IB_UVERBS_QPT_RAW_PACKET = 8,
9162306a36Sopenharmony_ci	IB_UVERBS_QPT_XRC_INI,
9262306a36Sopenharmony_ci	IB_UVERBS_QPT_XRC_TGT,
9362306a36Sopenharmony_ci	IB_UVERBS_QPT_DRIVER = 0xFF,
9462306a36Sopenharmony_ci};
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_cienum ib_uverbs_qp_create_flags {
9762306a36Sopenharmony_ci	IB_UVERBS_QP_CREATE_BLOCK_MULTICAST_LOOPBACK = 1 << 1,
9862306a36Sopenharmony_ci	IB_UVERBS_QP_CREATE_SCATTER_FCS = 1 << 8,
9962306a36Sopenharmony_ci	IB_UVERBS_QP_CREATE_CVLAN_STRIPPING = 1 << 9,
10062306a36Sopenharmony_ci	IB_UVERBS_QP_CREATE_PCI_WRITE_END_PADDING = 1 << 11,
10162306a36Sopenharmony_ci	IB_UVERBS_QP_CREATE_SQ_SIG_ALL = 1 << 12,
10262306a36Sopenharmony_ci};
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_cienum ib_uverbs_query_port_cap_flags {
10562306a36Sopenharmony_ci	IB_UVERBS_PCF_SM = 1 << 1,
10662306a36Sopenharmony_ci	IB_UVERBS_PCF_NOTICE_SUP = 1 << 2,
10762306a36Sopenharmony_ci	IB_UVERBS_PCF_TRAP_SUP = 1 << 3,
10862306a36Sopenharmony_ci	IB_UVERBS_PCF_OPT_IPD_SUP = 1 << 4,
10962306a36Sopenharmony_ci	IB_UVERBS_PCF_AUTO_MIGR_SUP = 1 << 5,
11062306a36Sopenharmony_ci	IB_UVERBS_PCF_SL_MAP_SUP = 1 << 6,
11162306a36Sopenharmony_ci	IB_UVERBS_PCF_MKEY_NVRAM = 1 << 7,
11262306a36Sopenharmony_ci	IB_UVERBS_PCF_PKEY_NVRAM = 1 << 8,
11362306a36Sopenharmony_ci	IB_UVERBS_PCF_LED_INFO_SUP = 1 << 9,
11462306a36Sopenharmony_ci	IB_UVERBS_PCF_SM_DISABLED = 1 << 10,
11562306a36Sopenharmony_ci	IB_UVERBS_PCF_SYS_IMAGE_GUID_SUP = 1 << 11,
11662306a36Sopenharmony_ci	IB_UVERBS_PCF_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12,
11762306a36Sopenharmony_ci	IB_UVERBS_PCF_EXTENDED_SPEEDS_SUP = 1 << 14,
11862306a36Sopenharmony_ci	IB_UVERBS_PCF_CM_SUP = 1 << 16,
11962306a36Sopenharmony_ci	IB_UVERBS_PCF_SNMP_TUNNEL_SUP = 1 << 17,
12062306a36Sopenharmony_ci	IB_UVERBS_PCF_REINIT_SUP = 1 << 18,
12162306a36Sopenharmony_ci	IB_UVERBS_PCF_DEVICE_MGMT_SUP = 1 << 19,
12262306a36Sopenharmony_ci	IB_UVERBS_PCF_VENDOR_CLASS_SUP = 1 << 20,
12362306a36Sopenharmony_ci	IB_UVERBS_PCF_DR_NOTICE_SUP = 1 << 21,
12462306a36Sopenharmony_ci	IB_UVERBS_PCF_CAP_MASK_NOTICE_SUP = 1 << 22,
12562306a36Sopenharmony_ci	IB_UVERBS_PCF_BOOT_MGMT_SUP = 1 << 23,
12662306a36Sopenharmony_ci	IB_UVERBS_PCF_LINK_LATENCY_SUP = 1 << 24,
12762306a36Sopenharmony_ci	IB_UVERBS_PCF_CLIENT_REG_SUP = 1 << 25,
12862306a36Sopenharmony_ci	/*
12962306a36Sopenharmony_ci	 * IsOtherLocalChangesNoticeSupported is aliased by IP_BASED_GIDS and
13062306a36Sopenharmony_ci	 * is inaccessible
13162306a36Sopenharmony_ci	 */
13262306a36Sopenharmony_ci	IB_UVERBS_PCF_LINK_SPEED_WIDTH_TABLE_SUP = 1 << 27,
13362306a36Sopenharmony_ci	IB_UVERBS_PCF_VENDOR_SPECIFIC_MADS_TABLE_SUP = 1 << 28,
13462306a36Sopenharmony_ci	IB_UVERBS_PCF_MCAST_PKEY_TRAP_SUPPRESSION_SUP = 1 << 29,
13562306a36Sopenharmony_ci	IB_UVERBS_PCF_MCAST_FDB_TOP_SUP = 1 << 30,
13662306a36Sopenharmony_ci	IB_UVERBS_PCF_HIERARCHY_INFO_SUP = 1ULL << 31,
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci	/* NOTE this is an internal flag, not an IBA flag */
13962306a36Sopenharmony_ci	IB_UVERBS_PCF_IP_BASED_GIDS = 1 << 26,
14062306a36Sopenharmony_ci};
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_cienum ib_uverbs_query_port_flags {
14362306a36Sopenharmony_ci	IB_UVERBS_QPF_GRH_REQUIRED = 1 << 0,
14462306a36Sopenharmony_ci};
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_cienum ib_uverbs_flow_action_esp_keymat {
14762306a36Sopenharmony_ci	IB_UVERBS_FLOW_ACTION_ESP_KEYMAT_AES_GCM,
14862306a36Sopenharmony_ci};
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_cienum ib_uverbs_flow_action_esp_keymat_aes_gcm_iv_algo {
15162306a36Sopenharmony_ci	IB_UVERBS_FLOW_ACTION_IV_ALGO_SEQ,
15262306a36Sopenharmony_ci};
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_cistruct ib_uverbs_flow_action_esp_keymat_aes_gcm {
15562306a36Sopenharmony_ci	__aligned_u64	iv;
15662306a36Sopenharmony_ci	__u32		iv_algo; /* Use enum ib_uverbs_flow_action_esp_keymat_aes_gcm_iv_algo */
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci	__u32		salt;
15962306a36Sopenharmony_ci	__u32		icv_len;
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci	__u32		key_len;
16262306a36Sopenharmony_ci	__u32		aes_key[256 / 32];
16362306a36Sopenharmony_ci};
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_cienum ib_uverbs_flow_action_esp_replay {
16662306a36Sopenharmony_ci	IB_UVERBS_FLOW_ACTION_ESP_REPLAY_NONE,
16762306a36Sopenharmony_ci	IB_UVERBS_FLOW_ACTION_ESP_REPLAY_BMP,
16862306a36Sopenharmony_ci};
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_cistruct ib_uverbs_flow_action_esp_replay_bmp {
17162306a36Sopenharmony_ci	__u32	size;
17262306a36Sopenharmony_ci};
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_cienum ib_uverbs_flow_action_esp_flags {
17562306a36Sopenharmony_ci	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_INLINE_CRYPTO	= 0UL << 0,	/* Default */
17662306a36Sopenharmony_ci	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_FULL_OFFLOAD	= 1UL << 0,
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_ci	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_TUNNEL		= 0UL << 1,	/* Default */
17962306a36Sopenharmony_ci	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_TRANSPORT	= 1UL << 1,
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ci	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_DECRYPT		= 0UL << 2,	/* Default */
18262306a36Sopenharmony_ci	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_ENCRYPT		= 1UL << 2,
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_ESN_NEW_WINDOW	= 1UL << 3,
18562306a36Sopenharmony_ci};
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_cistruct ib_uverbs_flow_action_esp_encap {
18862306a36Sopenharmony_ci	/* This struct represents a list of pointers to flow_xxxx_filter that
18962306a36Sopenharmony_ci	 * encapsulates the payload in ESP tunnel mode.
19062306a36Sopenharmony_ci	 */
19162306a36Sopenharmony_ci	RDMA_UAPI_PTR(void *, val_ptr); /* pointer to a flow_xxxx_filter */
19262306a36Sopenharmony_ci	RDMA_UAPI_PTR(struct ib_uverbs_flow_action_esp_encap *, next_ptr);
19362306a36Sopenharmony_ci	__u16	len;		/* Len of the filter struct val_ptr points to */
19462306a36Sopenharmony_ci	__u16	type;		/* Use flow_spec_type enum */
19562306a36Sopenharmony_ci};
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_cistruct ib_uverbs_flow_action_esp {
19862306a36Sopenharmony_ci	__u32		spi;
19962306a36Sopenharmony_ci	__u32		seq;
20062306a36Sopenharmony_ci	__u32		tfc_pad;
20162306a36Sopenharmony_ci	__u32		flags;
20262306a36Sopenharmony_ci	__aligned_u64	hard_limit_pkts;
20362306a36Sopenharmony_ci};
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_cienum ib_uverbs_read_counters_flags {
20662306a36Sopenharmony_ci	/* prefer read values from driver cache */
20762306a36Sopenharmony_ci	IB_UVERBS_READ_COUNTERS_PREFER_CACHED = 1 << 0,
20862306a36Sopenharmony_ci};
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_cienum ib_uverbs_advise_mr_advice {
21162306a36Sopenharmony_ci	IB_UVERBS_ADVISE_MR_ADVICE_PREFETCH,
21262306a36Sopenharmony_ci	IB_UVERBS_ADVISE_MR_ADVICE_PREFETCH_WRITE,
21362306a36Sopenharmony_ci	IB_UVERBS_ADVISE_MR_ADVICE_PREFETCH_NO_FAULT,
21462306a36Sopenharmony_ci};
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_cienum ib_uverbs_advise_mr_flag {
21762306a36Sopenharmony_ci	IB_UVERBS_ADVISE_MR_FLAG_FLUSH = 1 << 0,
21862306a36Sopenharmony_ci};
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_cistruct ib_uverbs_query_port_resp_ex {
22162306a36Sopenharmony_ci	struct ib_uverbs_query_port_resp legacy_resp;
22262306a36Sopenharmony_ci	__u16 port_cap_flags2;
22362306a36Sopenharmony_ci	__u8  reserved[6];
22462306a36Sopenharmony_ci};
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_cistruct ib_uverbs_qp_cap {
22762306a36Sopenharmony_ci	__u32 max_send_wr;
22862306a36Sopenharmony_ci	__u32 max_recv_wr;
22962306a36Sopenharmony_ci	__u32 max_send_sge;
23062306a36Sopenharmony_ci	__u32 max_recv_sge;
23162306a36Sopenharmony_ci	__u32 max_inline_data;
23262306a36Sopenharmony_ci};
23362306a36Sopenharmony_ci
23462306a36Sopenharmony_cienum rdma_driver_id {
23562306a36Sopenharmony_ci	RDMA_DRIVER_UNKNOWN,
23662306a36Sopenharmony_ci	RDMA_DRIVER_MLX5,
23762306a36Sopenharmony_ci	RDMA_DRIVER_MLX4,
23862306a36Sopenharmony_ci	RDMA_DRIVER_CXGB3,
23962306a36Sopenharmony_ci	RDMA_DRIVER_CXGB4,
24062306a36Sopenharmony_ci	RDMA_DRIVER_MTHCA,
24162306a36Sopenharmony_ci	RDMA_DRIVER_BNXT_RE,
24262306a36Sopenharmony_ci	RDMA_DRIVER_OCRDMA,
24362306a36Sopenharmony_ci	RDMA_DRIVER_NES,
24462306a36Sopenharmony_ci	RDMA_DRIVER_I40IW,
24562306a36Sopenharmony_ci	RDMA_DRIVER_IRDMA = RDMA_DRIVER_I40IW,
24662306a36Sopenharmony_ci	RDMA_DRIVER_VMW_PVRDMA,
24762306a36Sopenharmony_ci	RDMA_DRIVER_QEDR,
24862306a36Sopenharmony_ci	RDMA_DRIVER_HNS,
24962306a36Sopenharmony_ci	RDMA_DRIVER_USNIC,
25062306a36Sopenharmony_ci	RDMA_DRIVER_RXE,
25162306a36Sopenharmony_ci	RDMA_DRIVER_HFI1,
25262306a36Sopenharmony_ci	RDMA_DRIVER_QIB,
25362306a36Sopenharmony_ci	RDMA_DRIVER_EFA,
25462306a36Sopenharmony_ci	RDMA_DRIVER_SIW,
25562306a36Sopenharmony_ci	RDMA_DRIVER_ERDMA,
25662306a36Sopenharmony_ci	RDMA_DRIVER_MANA,
25762306a36Sopenharmony_ci};
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_cienum ib_uverbs_gid_type {
26062306a36Sopenharmony_ci	IB_UVERBS_GID_TYPE_IB,
26162306a36Sopenharmony_ci	IB_UVERBS_GID_TYPE_ROCE_V1,
26262306a36Sopenharmony_ci	IB_UVERBS_GID_TYPE_ROCE_V2,
26362306a36Sopenharmony_ci};
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_cistruct ib_uverbs_gid_entry {
26662306a36Sopenharmony_ci	__aligned_u64 gid[2];
26762306a36Sopenharmony_ci	__u32 gid_index;
26862306a36Sopenharmony_ci	__u32 port_num;
26962306a36Sopenharmony_ci	__u32 gid_type;
27062306a36Sopenharmony_ci	__u32 netdev_ifindex; /* It is 0 if there is no netdev associated with it */
27162306a36Sopenharmony_ci};
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci#endif
274