Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
0002 /*
0003  * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
0004  *
0005  * This software is available to you under a choice of one of two
0006  * licenses.  You may choose to be licensed under the terms of the GNU
0007  * General Public License (GPL) Version 2, available from the file
0008  * COPYING in the main directory of this source tree, or the
0009  * OpenIB.org BSD license below:
0010  *
0011  *     Redistribution and use in source and binary forms, with or
0012  *     without modification, are permitted provided that the following
0013  *     conditions are met:
0014  *
0015  *  - Redistributions of source code must retain the above
0016  *    copyright notice, this list of conditions and the following
0017  *    disclaimer.
0018  *
0019  *  - Redistributions in binary form must reproduce the above
0020  *    copyright notice, this list of conditions and the following
0021  *    disclaimer in the documentation and/or other materials
0022  *    provided with the distribution.
0023  *
0024  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0025  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0026  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0027  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0028  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0029  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0030  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0031  * SOFTWARE.
0032  */
0033 
0034 #ifndef RDMA_USER_RXE_H
0035 #define RDMA_USER_RXE_H
0036 
0037 #include <linux/types.h>
0038 #include <linux/socket.h>
0039 #include <linux/in.h>
0040 #include <linux/in6.h>
0041 
0042 enum {
0043     RXE_NETWORK_TYPE_IPV4 = 1,
0044     RXE_NETWORK_TYPE_IPV6 = 2,
0045 };
0046 
0047 union rxe_gid {
0048     __u8    raw[16];
0049     struct {
0050         __be64  subnet_prefix;
0051         __be64  interface_id;
0052     } global;
0053 };
0054 
0055 struct rxe_global_route {
0056     union rxe_gid   dgid;
0057     __u32       flow_label;
0058     __u8        sgid_index;
0059     __u8        hop_limit;
0060     __u8        traffic_class;
0061 };
0062 
0063 struct rxe_av {
0064     __u8            port_num;
0065     /* From RXE_NETWORK_TYPE_* */
0066     __u8            network_type;
0067     __u8            dmac[6];
0068     struct rxe_global_route grh;
0069     union {
0070         struct sockaddr_in  _sockaddr_in;
0071         struct sockaddr_in6 _sockaddr_in6;
0072     } sgid_addr, dgid_addr;
0073 };
0074 
0075 struct rxe_send_wr {
0076     __aligned_u64       wr_id;
0077     __u32           num_sge;
0078     __u32           opcode;
0079     __u32           send_flags;
0080     union {
0081         __be32      imm_data;
0082         __u32       invalidate_rkey;
0083     } ex;
0084     union {
0085         struct {
0086             __aligned_u64 remote_addr;
0087             __u32   rkey;
0088             __u32   reserved;
0089         } rdma;
0090         struct {
0091             __aligned_u64 remote_addr;
0092             __aligned_u64 compare_add;
0093             __aligned_u64 swap;
0094             __u32   rkey;
0095             __u32   reserved;
0096         } atomic;
0097         struct {
0098             __u32   remote_qpn;
0099             __u32   remote_qkey;
0100             __u16   pkey_index;
0101             __u16   reserved;
0102             __u32   ah_num;
0103             __u32   pad[4];
0104             struct rxe_av av;
0105         } ud;
0106         struct {
0107             __aligned_u64   addr;
0108             __aligned_u64   length;
0109             __u32       mr_lkey;
0110             __u32       mw_rkey;
0111             __u32       rkey;
0112             __u32       access;
0113         } mw;
0114         /* reg is only used by the kernel and is not part of the uapi */
0115 #ifdef __KERNEL__
0116         struct {
0117             union {
0118                 struct ib_mr *mr;
0119                 __aligned_u64 reserved;
0120             };
0121             __u32        key;
0122             __u32        access;
0123         } reg;
0124 #endif
0125     } wr;
0126 };
0127 
0128 struct rxe_sge {
0129     __aligned_u64 addr;
0130     __u32   length;
0131     __u32   lkey;
0132 };
0133 
0134 struct mminfo {
0135     __aligned_u64       offset;
0136     __u32           size;
0137     __u32           pad;
0138 };
0139 
0140 struct rxe_dma_info {
0141     __u32           length;
0142     __u32           resid;
0143     __u32           cur_sge;
0144     __u32           num_sge;
0145     __u32           sge_offset;
0146     __u32           reserved;
0147     union {
0148         __DECLARE_FLEX_ARRAY(__u8, inline_data);
0149         __DECLARE_FLEX_ARRAY(struct rxe_sge, sge);
0150     };
0151 };
0152 
0153 struct rxe_send_wqe {
0154     struct rxe_send_wr  wr;
0155     __u32           status;
0156     __u32           state;
0157     __aligned_u64       iova;
0158     __u32           mask;
0159     __u32           first_psn;
0160     __u32           last_psn;
0161     __u32           ack_length;
0162     __u32           ssn;
0163     __u32           has_rd_atomic;
0164     struct rxe_dma_info dma;
0165 };
0166 
0167 struct rxe_recv_wqe {
0168     __aligned_u64       wr_id;
0169     __u32           num_sge;
0170     __u32           padding;
0171     struct rxe_dma_info dma;
0172 };
0173 
0174 struct rxe_create_ah_resp {
0175     __u32 ah_num;
0176     __u32 reserved;
0177 };
0178 
0179 struct rxe_create_cq_resp {
0180     struct mminfo mi;
0181 };
0182 
0183 struct rxe_resize_cq_resp {
0184     struct mminfo mi;
0185 };
0186 
0187 struct rxe_create_qp_resp {
0188     struct mminfo rq_mi;
0189     struct mminfo sq_mi;
0190 };
0191 
0192 struct rxe_create_srq_resp {
0193     struct mminfo mi;
0194     __u32 srq_num;
0195     __u32 reserved;
0196 };
0197 
0198 struct rxe_modify_srq_cmd {
0199     __aligned_u64 mmap_info_addr;
0200 };
0201 
0202 /* This data structure is stored at the base of work and
0203  * completion queues shared between user space and kernel space.
0204  * It contains the producer and consumer indices. Is also
0205  * contains a copy of the queue size parameters for user space
0206  * to use but the kernel must use the parameters in the
0207  * rxe_queue struct. For performance reasons arrange to have
0208  * producer and consumer indices in separate cache lines
0209  * the kernel should always mask the indices to avoid accessing
0210  * memory outside of the data area
0211  */
0212 struct rxe_queue_buf {
0213     __u32           log2_elem_size;
0214     __u32           index_mask;
0215     __u32           pad_1[30];
0216     __u32           producer_index;
0217     __u32           pad_2[31];
0218     __u32           consumer_index;
0219     __u32           pad_3[31];
0220     __u8            data[];
0221 };
0222 
0223 #endif /* RDMA_USER_RXE_H */