/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */1/*2* Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.3*4* This software is available to you under a choice of one of two5* licenses. You may choose to be licensed under the terms of the GNU6* General Public License (GPL) Version 2, available from the file7* COPYING in the main directory of this source tree, or the8* OpenIB.org BSD license below:9*10* Redistribution and use in source and binary forms, with or11* without modification, are permitted provided that the following12* conditions are met:13*14* - Redistributions of source code must retain the above15* copyright notice, this list of conditions and the following16* disclaimer.17*18* - Redistributions in binary form must reproduce the above19* copyright notice, this list of conditions and the following20* disclaimer in the documentation and/or other materials21* provided with the distribution.22*23* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,24* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF25* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND26* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS27* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN28* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN29* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE30* SOFTWARE.31*/3233#ifndef RDMA_USER_RXE_H34#define RDMA_USER_RXE_H3536#include <linux/types.h>37#include <linux/socket.h>38#include <linux/in.h>39#include <linux/in6.h>4041enum {42RXE_NETWORK_TYPE_IPV4 = 1,43RXE_NETWORK_TYPE_IPV6 = 2,44};4546union rxe_gid {47__u8 raw[16];48struct {49__be64 subnet_prefix;50__be64 interface_id;51} global;52};5354struct rxe_global_route {55union rxe_gid dgid;56__u32 flow_label;57__u8 sgid_index;58__u8 hop_limit;59__u8 traffic_class;60};6162struct rxe_av {63__u8 port_num;64/* From RXE_NETWORK_TYPE_* */65__u8 network_type;66__u8 dmac[6];67struct rxe_global_route grh;68union {69struct sockaddr_in _sockaddr_in;70struct sockaddr_in6 _sockaddr_in6;71} sgid_addr, dgid_addr;72};7374struct rxe_send_wr {75__aligned_u64 wr_id;76__u32 reserved;77__u32 opcode;78__u32 send_flags;79union {80__be32 imm_data;81__u32 invalidate_rkey;82} ex;83union {84struct {85__aligned_u64 remote_addr;86__u32 length;87__u32 rkey;88__u8 type;89__u8 level;90} flush;91struct {92__aligned_u64 remote_addr;93__u32 rkey;94__u32 reserved;95} rdma;96struct {97__aligned_u64 remote_addr;98__aligned_u64 compare_add;99__aligned_u64 swap;100__u32 rkey;101__u32 reserved;102} atomic;103struct {104__u32 remote_qpn;105__u32 remote_qkey;106__u16 pkey_index;107__u16 reserved;108__u32 ah_num;109__u32 pad[4];110struct rxe_av av;111} ud;112struct {113__aligned_u64 addr;114__aligned_u64 length;115__u32 mr_lkey;116__u32 mw_rkey;117__u32 rkey;118__u32 access;119} mw;120/* reg is only used by the kernel and is not part of the uapi */121#ifdef __KERNEL__122struct {123union {124struct ib_mr *mr;125__aligned_u64 reserved;126};127__u32 key;128__u32 access;129} reg;130#endif131} wr;132};133134struct rxe_sge {135__aligned_u64 addr;136__u32 length;137__u32 lkey;138};139140struct mminfo {141__aligned_u64 offset;142__u32 size;143__u32 pad;144};145146struct rxe_dma_info {147__u32 length;148__u32 resid;149__u32 cur_sge;150__u32 num_sge;151__u32 sge_offset;152__u32 reserved;153union {154__DECLARE_FLEX_ARRAY(__u8, inline_data);155__DECLARE_FLEX_ARRAY(__u8, atomic_wr);156__DECLARE_FLEX_ARRAY(struct rxe_sge, sge);157};158};159160struct rxe_send_wqe {161struct rxe_send_wr wr;162__u32 status;163__u32 state;164__aligned_u64 iova;165__u32 mask;166__u32 first_psn;167__u32 last_psn;168__u32 ack_length;169__u32 ssn;170__u32 has_rd_atomic;171struct rxe_dma_info dma;172};173174struct rxe_recv_wqe {175__aligned_u64 wr_id;176__u32 reserved;177__u32 padding;178struct rxe_dma_info dma;179};180181struct rxe_create_ah_resp {182__u32 ah_num;183__u32 reserved;184};185186struct rxe_create_cq_resp {187struct mminfo mi;188};189190struct rxe_resize_cq_resp {191struct mminfo mi;192};193194struct rxe_create_qp_resp {195struct mminfo rq_mi;196struct mminfo sq_mi;197};198199struct rxe_create_srq_resp {200struct mminfo mi;201__u32 srq_num;202__u32 reserved;203};204205struct rxe_modify_srq_cmd {206__aligned_u64 mmap_info_addr;207};208209/* This data structure is stored at the base of work and210* completion queues shared between user space and kernel space.211* It contains the producer and consumer indices. Is also212* contains a copy of the queue size parameters for user space213* to use but the kernel must use the parameters in the214* rxe_queue struct. For performance reasons arrange to have215* producer and consumer indices in separate cache lines216* the kernel should always mask the indices to avoid accessing217* memory outside of the data area218*/219struct rxe_queue_buf {220__u32 log2_elem_size;221__u32 index_mask;222__u32 pad_1[30];223__u32 producer_index;224__u32 pad_2[31];225__u32 consumer_index;226__u32 pad_3[31];227__u8 data[];228};229230#endif /* RDMA_USER_RXE_H */231232233