root/include/uapi/linux/rds.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
   2 /*
   3  * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
   4  *
   5  * This software is available to you under a choice of one of two
   6  * licenses.  You may choose to be licensed under the terms of the GNU
   7  * General Public License (GPL) Version 2, available from the file
   8  * COPYING in the main directory of this source tree, or the
   9  * OpenIB.org BSD license below:
  10  *
  11  *     Redistribution and use in source and binary forms, with or
  12  *     without modification, are permitted provided that the following
  13  *     conditions are met:
  14  *
  15  *      - Redistributions of source code must retain the above
  16  *        copyright notice, this list of conditions and the following
  17  *        disclaimer.
  18  *
  19  *      - Redistributions in binary form must reproduce the above
  20  *        copyright notice, this list of conditions and the following
  21  *        disclaimer in the documentation and/or other materials
  22  *        provided with the distribution.
  23  *
  24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31  * SOFTWARE.
  32  *
  33  */
  34 
  35 #ifndef _LINUX_RDS_H
  36 #define _LINUX_RDS_H
  37 
  38 #include <linux/types.h>
  39 #include <linux/socket.h>               /* For __kernel_sockaddr_storage. */
  40 #include <linux/in6.h>                  /* For struct in6_addr. */
  41 
  42 #define RDS_IB_ABI_VERSION              0x301
  43 
  44 #define SOL_RDS         276
  45 
  46 /*
  47  * setsockopt/getsockopt for SOL_RDS
  48  */
  49 #define RDS_CANCEL_SENT_TO              1
  50 #define RDS_GET_MR                      2
  51 #define RDS_FREE_MR                     3
  52 /* deprecated: RDS_BARRIER 4 */
  53 #define RDS_RECVERR                     5
  54 #define RDS_CONG_MONITOR                6
  55 #define RDS_GET_MR_FOR_DEST             7
  56 #define SO_RDS_TRANSPORT                8
  57 
  58 /* Socket option to tap receive path latency
  59  *      SO_RDS: SO_RDS_MSG_RXPATH_LATENCY
  60  *      Format used struct rds_rx_trace_so
  61  */
  62 #define SO_RDS_MSG_RXPATH_LATENCY       10
  63 
  64 
  65 /* supported values for SO_RDS_TRANSPORT */
  66 #define RDS_TRANS_IB    0
  67 #define RDS_TRANS_IWARP 1
  68 #define RDS_TRANS_TCP   2
  69 #define RDS_TRANS_COUNT 3
  70 #define RDS_TRANS_NONE  (~0)
  71 
  72 /* IOCTLS commands for SOL_RDS */
  73 #define SIOCRDSSETTOS           (SIOCPROTOPRIVATE)
  74 #define SIOCRDSGETTOS           (SIOCPROTOPRIVATE + 1)
  75 
  76 typedef __u8    rds_tos_t;
  77 
  78 /*
  79  * Control message types for SOL_RDS.
  80  *
  81  * CMSG_RDMA_ARGS (sendmsg)
  82  *      Request a RDMA transfer to/from the specified
  83  *      memory ranges.
  84  *      The cmsg_data is a struct rds_rdma_args.
  85  * RDS_CMSG_RDMA_DEST (recvmsg, sendmsg)
  86  *      Kernel informs application about intended
  87  *      source/destination of a RDMA transfer
  88  * RDS_CMSG_RDMA_MAP (sendmsg)
  89  *      Application asks kernel to map the given
  90  *      memory range into a IB MR, and send the
  91  *      R_Key along in an RDS extension header.
  92  *      The cmsg_data is a struct rds_get_mr_args,
  93  *      the same as for the GET_MR setsockopt.
  94  * RDS_CMSG_RDMA_STATUS (recvmsg)
  95  *      Returns the status of a completed RDMA operation.
  96  * RDS_CMSG_RXPATH_LATENCY(recvmsg)
  97  *      Returns rds message latencies in various stages of receive
  98  *      path in nS. Its set per socket using SO_RDS_MSG_RXPATH_LATENCY
  99  *      socket option. Legitimate points are defined in
 100  *      enum rds_message_rxpath_latency. More points can be added in
 101  *      future. CSMG format is struct rds_cmsg_rx_trace.
 102  */
 103 #define RDS_CMSG_RDMA_ARGS              1
 104 #define RDS_CMSG_RDMA_DEST              2
 105 #define RDS_CMSG_RDMA_MAP               3
 106 #define RDS_CMSG_RDMA_STATUS            4
 107 #define RDS_CMSG_CONG_UPDATE            5
 108 #define RDS_CMSG_ATOMIC_FADD            6
 109 #define RDS_CMSG_ATOMIC_CSWP            7
 110 #define RDS_CMSG_MASKED_ATOMIC_FADD     8
 111 #define RDS_CMSG_MASKED_ATOMIC_CSWP     9
 112 #define RDS_CMSG_RXPATH_LATENCY         11
 113 #define RDS_CMSG_ZCOPY_COOKIE           12
 114 #define RDS_CMSG_ZCOPY_COMPLETION       13
 115 
 116 #define RDS_INFO_FIRST                  10000
 117 #define RDS_INFO_COUNTERS               10000
 118 #define RDS_INFO_CONNECTIONS            10001
 119 /* 10002 aka RDS_INFO_FLOWS is deprecated */
 120 #define RDS_INFO_SEND_MESSAGES          10003
 121 #define RDS_INFO_RETRANS_MESSAGES       10004
 122 #define RDS_INFO_RECV_MESSAGES          10005
 123 #define RDS_INFO_SOCKETS                10006
 124 #define RDS_INFO_TCP_SOCKETS            10007
 125 #define RDS_INFO_IB_CONNECTIONS         10008
 126 #define RDS_INFO_CONNECTION_STATS       10009
 127 #define RDS_INFO_IWARP_CONNECTIONS      10010
 128 
 129 /* PF_RDS6 options */
 130 #define RDS6_INFO_CONNECTIONS           10011
 131 #define RDS6_INFO_SEND_MESSAGES         10012
 132 #define RDS6_INFO_RETRANS_MESSAGES      10013
 133 #define RDS6_INFO_RECV_MESSAGES         10014
 134 #define RDS6_INFO_SOCKETS               10015
 135 #define RDS6_INFO_TCP_SOCKETS           10016
 136 #define RDS6_INFO_IB_CONNECTIONS        10017
 137 
 138 #define RDS_INFO_LAST                   10017
 139 
 140 struct rds_info_counter {
 141         __u8    name[32];
 142         __u64   value;
 143 } __attribute__((packed));
 144 
 145 #define RDS_INFO_CONNECTION_FLAG_SENDING        0x01
 146 #define RDS_INFO_CONNECTION_FLAG_CONNECTING     0x02
 147 #define RDS_INFO_CONNECTION_FLAG_CONNECTED      0x04
 148 
 149 #define TRANSNAMSIZ     16
 150 
 151 struct rds_info_connection {
 152         __u64           next_tx_seq;
 153         __u64           next_rx_seq;
 154         __be32          laddr;
 155         __be32          faddr;
 156         __u8            transport[TRANSNAMSIZ];         /* null term ascii */
 157         __u8            flags;
 158         __u8            tos;
 159 } __attribute__((packed));
 160 
 161 struct rds6_info_connection {
 162         __u64           next_tx_seq;
 163         __u64           next_rx_seq;
 164         struct in6_addr laddr;
 165         struct in6_addr faddr;
 166         __u8            transport[TRANSNAMSIZ];         /* null term ascii */
 167         __u8            flags;
 168 } __attribute__((packed));
 169 
 170 #define RDS_INFO_MESSAGE_FLAG_ACK               0x01
 171 #define RDS_INFO_MESSAGE_FLAG_FAST_ACK          0x02
 172 
 173 struct rds_info_message {
 174         __u64           seq;
 175         __u32           len;
 176         __be32          laddr;
 177         __be32          faddr;
 178         __be16          lport;
 179         __be16          fport;
 180         __u8            flags;
 181         __u8            tos;
 182 } __attribute__((packed));
 183 
 184 struct rds6_info_message {
 185         __u64   seq;
 186         __u32   len;
 187         struct in6_addr laddr;
 188         struct in6_addr faddr;
 189         __be16          lport;
 190         __be16          fport;
 191         __u8            flags;
 192         __u8            tos;
 193 } __attribute__((packed));
 194 
 195 struct rds_info_socket {
 196         __u32           sndbuf;
 197         __be32          bound_addr;
 198         __be32          connected_addr;
 199         __be16          bound_port;
 200         __be16          connected_port;
 201         __u32           rcvbuf;
 202         __u64           inum;
 203 } __attribute__((packed));
 204 
 205 struct rds6_info_socket {
 206         __u32           sndbuf;
 207         struct in6_addr bound_addr;
 208         struct in6_addr connected_addr;
 209         __be16          bound_port;
 210         __be16          connected_port;
 211         __u32           rcvbuf;
 212         __u64           inum;
 213 } __attribute__((packed));
 214 
 215 struct rds_info_tcp_socket {
 216         __be32          local_addr;
 217         __be16          local_port;
 218         __be32          peer_addr;
 219         __be16          peer_port;
 220         __u64           hdr_rem;
 221         __u64           data_rem;
 222         __u32           last_sent_nxt;
 223         __u32           last_expected_una;
 224         __u32           last_seen_una;
 225         __u8            tos;
 226 } __attribute__((packed));
 227 
 228 struct rds6_info_tcp_socket {
 229         struct in6_addr local_addr;
 230         __be16          local_port;
 231         struct in6_addr peer_addr;
 232         __be16          peer_port;
 233         __u64           hdr_rem;
 234         __u64           data_rem;
 235         __u32           last_sent_nxt;
 236         __u32           last_expected_una;
 237         __u32           last_seen_una;
 238 } __attribute__((packed));
 239 
 240 #define RDS_IB_GID_LEN  16
 241 struct rds_info_rdma_connection {
 242         __be32          src_addr;
 243         __be32          dst_addr;
 244         __u8            src_gid[RDS_IB_GID_LEN];
 245         __u8            dst_gid[RDS_IB_GID_LEN];
 246 
 247         __u32           max_send_wr;
 248         __u32           max_recv_wr;
 249         __u32           max_send_sge;
 250         __u32           rdma_mr_max;
 251         __u32           rdma_mr_size;
 252         __u8            tos;
 253         __u8            sl;
 254         __u32           cache_allocs;
 255 };
 256 
 257 struct rds6_info_rdma_connection {
 258         struct in6_addr src_addr;
 259         struct in6_addr dst_addr;
 260         __u8            src_gid[RDS_IB_GID_LEN];
 261         __u8            dst_gid[RDS_IB_GID_LEN];
 262 
 263         __u32           max_send_wr;
 264         __u32           max_recv_wr;
 265         __u32           max_send_sge;
 266         __u32           rdma_mr_max;
 267         __u32           rdma_mr_size;
 268         __u8            tos;
 269         __u8            sl;
 270         __u32           cache_allocs;
 271 };
 272 
 273 /* RDS message Receive Path Latency points */
 274 enum rds_message_rxpath_latency {
 275         RDS_MSG_RX_HDR_TO_DGRAM_START = 0,
 276         RDS_MSG_RX_DGRAM_REASSEMBLE,
 277         RDS_MSG_RX_DGRAM_DELIVERED,
 278         RDS_MSG_RX_DGRAM_TRACE_MAX
 279 };
 280 
 281 struct rds_rx_trace_so {
 282         __u8 rx_traces;
 283         __u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX];
 284 };
 285 
 286 struct rds_cmsg_rx_trace {
 287         __u8 rx_traces;
 288         __u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX];
 289         __u64 rx_trace[RDS_MSG_RX_DGRAM_TRACE_MAX];
 290 };
 291 
 292 /*
 293  * Congestion monitoring.
 294  * Congestion control in RDS happens at the host connection
 295  * level by exchanging a bitmap marking congested ports.
 296  * By default, a process sleeping in poll() is always woken
 297  * up when the congestion map is updated.
 298  * With explicit monitoring, an application can have more
 299  * fine-grained control.
 300  * The application installs a 64bit mask value in the socket,
 301  * where each bit corresponds to a group of ports.
 302  * When a congestion update arrives, RDS checks the set of
 303  * ports that are now uncongested against the list bit mask
 304  * installed in the socket, and if they overlap, we queue a
 305  * cong_notification on the socket.
 306  *
 307  * To install the congestion monitor bitmask, use RDS_CONG_MONITOR
 308  * with the 64bit mask.
 309  * Congestion updates are received via RDS_CMSG_CONG_UPDATE
 310  * control messages.
 311  *
 312  * The correspondence between bits and ports is
 313  *      1 << (portnum % 64)
 314  */
 315 #define RDS_CONG_MONITOR_SIZE   64
 316 #define RDS_CONG_MONITOR_BIT(port)  (((unsigned int) port) % RDS_CONG_MONITOR_SIZE)
 317 #define RDS_CONG_MONITOR_MASK(port) (1ULL << RDS_CONG_MONITOR_BIT(port))
 318 
 319 /*
 320  * RDMA related types
 321  */
 322 
 323 /*
 324  * This encapsulates a remote memory location.
 325  * In the current implementation, it contains the R_Key
 326  * of the remote memory region, and the offset into it
 327  * (so that the application does not have to worry about
 328  * alignment).
 329  */
 330 typedef __u64           rds_rdma_cookie_t;
 331 
 332 struct rds_iovec {
 333         __u64           addr;
 334         __u64           bytes;
 335 };
 336 
 337 struct rds_get_mr_args {
 338         struct rds_iovec vec;
 339         __u64           cookie_addr;
 340         __u64           flags;
 341 };
 342 
 343 struct rds_get_mr_for_dest_args {
 344         struct __kernel_sockaddr_storage dest_addr;
 345         struct rds_iovec        vec;
 346         __u64                   cookie_addr;
 347         __u64                   flags;
 348 };
 349 
 350 struct rds_free_mr_args {
 351         rds_rdma_cookie_t cookie;
 352         __u64           flags;
 353 };
 354 
 355 struct rds_rdma_args {
 356         rds_rdma_cookie_t cookie;
 357         struct rds_iovec remote_vec;
 358         __u64           local_vec_addr;
 359         __u64           nr_local;
 360         __u64           flags;
 361         __u64           user_token;
 362 };
 363 
 364 struct rds_atomic_args {
 365         rds_rdma_cookie_t cookie;
 366         __u64           local_addr;
 367         __u64           remote_addr;
 368         union {
 369                 struct {
 370                         __u64           compare;
 371                         __u64           swap;
 372                 } cswp;
 373                 struct {
 374                         __u64           add;
 375                 } fadd;
 376                 struct {
 377                         __u64           compare;
 378                         __u64           swap;
 379                         __u64           compare_mask;
 380                         __u64           swap_mask;
 381                 } m_cswp;
 382                 struct {
 383                         __u64           add;
 384                         __u64           nocarry_mask;
 385                 } m_fadd;
 386         };
 387         __u64           flags;
 388         __u64           user_token;
 389 };
 390 
 391 struct rds_rdma_notify {
 392         __u64           user_token;
 393         __s32           status;
 394 };
 395 
 396 #define RDS_RDMA_SUCCESS        0
 397 #define RDS_RDMA_REMOTE_ERROR   1
 398 #define RDS_RDMA_CANCELED       2
 399 #define RDS_RDMA_DROPPED        3
 400 #define RDS_RDMA_OTHER_ERROR    4
 401 
 402 #define RDS_MAX_ZCOOKIES        8
 403 struct rds_zcopy_cookies {
 404         __u32 num;
 405         __u32 cookies[RDS_MAX_ZCOOKIES];
 406 };
 407 
 408 /*
 409  * Common set of flags for all RDMA related structs
 410  */
 411 #define RDS_RDMA_READWRITE      0x0001
 412 #define RDS_RDMA_FENCE          0x0002  /* use FENCE for immediate send */
 413 #define RDS_RDMA_INVALIDATE     0x0004  /* invalidate R_Key after freeing MR */
 414 #define RDS_RDMA_USE_ONCE       0x0008  /* free MR after use */
 415 #define RDS_RDMA_DONTWAIT       0x0010  /* Don't wait in SET_BARRIER */
 416 #define RDS_RDMA_NOTIFY_ME      0x0020  /* Notify when operation completes */
 417 #define RDS_RDMA_SILENT         0x0040  /* Do not interrupt remote */
 418 
 419 #endif /* IB_RDS_H */

/* [<][>][^][v][top][bottom][index][help] */