Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
0002 /*
0003  * Copyright (c) 2008, 2018 Oracle and/or its affiliates. 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 
0035 #ifndef _LINUX_RDS_H
0036 #define _LINUX_RDS_H
0037 
0038 #include <linux/types.h>
0039 #include <linux/socket.h>       /* For __kernel_sockaddr_storage. */
0040 #include <linux/in6.h>          /* For struct in6_addr. */
0041 
0042 #define RDS_IB_ABI_VERSION      0x301
0043 
0044 #define SOL_RDS     276
0045 
0046 /*
0047  * setsockopt/getsockopt for SOL_RDS
0048  */
0049 #define RDS_CANCEL_SENT_TO          1
0050 #define RDS_GET_MR          2
0051 #define RDS_FREE_MR         3
0052 /* deprecated: RDS_BARRIER 4 */
0053 #define RDS_RECVERR         5
0054 #define RDS_CONG_MONITOR        6
0055 #define RDS_GET_MR_FOR_DEST     7
0056 #define SO_RDS_TRANSPORT        8
0057 
0058 /* Socket option to tap receive path latency
0059  *  SO_RDS: SO_RDS_MSG_RXPATH_LATENCY
0060  *  Format used struct rds_rx_trace_so
0061  */
0062 #define SO_RDS_MSG_RXPATH_LATENCY   10
0063 
0064 
0065 /* supported values for SO_RDS_TRANSPORT */
0066 #define RDS_TRANS_IB    0
0067 #define RDS_TRANS_GAP   1
0068 #define RDS_TRANS_TCP   2
0069 #define RDS_TRANS_COUNT 3
0070 #define RDS_TRANS_NONE  (~0)
0071 /* don't use RDS_TRANS_IWARP - it is deprecated */
0072 #define RDS_TRANS_IWARP RDS_TRANS_GAP
0073 
0074 /* IOCTLS commands for SOL_RDS */
0075 #define SIOCRDSSETTOS       (SIOCPROTOPRIVATE)
0076 #define SIOCRDSGETTOS       (SIOCPROTOPRIVATE + 1)
0077 
0078 typedef __u8    rds_tos_t;
0079 
0080 /*
0081  * Control message types for SOL_RDS.
0082  *
0083  * CMSG_RDMA_ARGS (sendmsg)
0084  *  Request a RDMA transfer to/from the specified
0085  *  memory ranges.
0086  *  The cmsg_data is a struct rds_rdma_args.
0087  * RDS_CMSG_RDMA_DEST (recvmsg, sendmsg)
0088  *  Kernel informs application about intended
0089  *  source/destination of a RDMA transfer
0090  * RDS_CMSG_RDMA_MAP (sendmsg)
0091  *  Application asks kernel to map the given
0092  *  memory range into a IB MR, and send the
0093  *  R_Key along in an RDS extension header.
0094  *  The cmsg_data is a struct rds_get_mr_args,
0095  *  the same as for the GET_MR setsockopt.
0096  * RDS_CMSG_RDMA_STATUS (recvmsg)
0097  *  Returns the status of a completed RDMA operation.
0098  * RDS_CMSG_RXPATH_LATENCY(recvmsg)
0099  *  Returns rds message latencies in various stages of receive
0100  *  path in nS. Its set per socket using SO_RDS_MSG_RXPATH_LATENCY
0101  *  socket option. Legitimate points are defined in
0102  *  enum rds_message_rxpath_latency. More points can be added in
0103  *  future. CSMG format is struct rds_cmsg_rx_trace.
0104  */
0105 #define RDS_CMSG_RDMA_ARGS      1
0106 #define RDS_CMSG_RDMA_DEST      2
0107 #define RDS_CMSG_RDMA_MAP       3
0108 #define RDS_CMSG_RDMA_STATUS        4
0109 #define RDS_CMSG_CONG_UPDATE        5
0110 #define RDS_CMSG_ATOMIC_FADD        6
0111 #define RDS_CMSG_ATOMIC_CSWP        7
0112 #define RDS_CMSG_MASKED_ATOMIC_FADD 8
0113 #define RDS_CMSG_MASKED_ATOMIC_CSWP 9
0114 #define RDS_CMSG_RXPATH_LATENCY     11
0115 #define RDS_CMSG_ZCOPY_COOKIE       12
0116 #define RDS_CMSG_ZCOPY_COMPLETION   13
0117 
0118 #define RDS_INFO_FIRST          10000
0119 #define RDS_INFO_COUNTERS       10000
0120 #define RDS_INFO_CONNECTIONS        10001
0121 /* 10002 aka RDS_INFO_FLOWS is deprecated */
0122 #define RDS_INFO_SEND_MESSAGES      10003
0123 #define RDS_INFO_RETRANS_MESSAGES       10004
0124 #define RDS_INFO_RECV_MESSAGES          10005
0125 #define RDS_INFO_SOCKETS                10006
0126 #define RDS_INFO_TCP_SOCKETS            10007
0127 #define RDS_INFO_IB_CONNECTIONS     10008
0128 #define RDS_INFO_CONNECTION_STATS   10009
0129 #define RDS_INFO_IWARP_CONNECTIONS  10010
0130 
0131 /* PF_RDS6 options */
0132 #define RDS6_INFO_CONNECTIONS       10011
0133 #define RDS6_INFO_SEND_MESSAGES     10012
0134 #define RDS6_INFO_RETRANS_MESSAGES  10013
0135 #define RDS6_INFO_RECV_MESSAGES     10014
0136 #define RDS6_INFO_SOCKETS       10015
0137 #define RDS6_INFO_TCP_SOCKETS       10016
0138 #define RDS6_INFO_IB_CONNECTIONS    10017
0139 
0140 #define RDS_INFO_LAST           10017
0141 
0142 struct rds_info_counter {
0143     __u8    name[32];
0144     __u64   value;
0145 } __attribute__((packed));
0146 
0147 #define RDS_INFO_CONNECTION_FLAG_SENDING    0x01
0148 #define RDS_INFO_CONNECTION_FLAG_CONNECTING 0x02
0149 #define RDS_INFO_CONNECTION_FLAG_CONNECTED  0x04
0150 
0151 #define TRANSNAMSIZ 16
0152 
0153 struct rds_info_connection {
0154     __u64       next_tx_seq;
0155     __u64       next_rx_seq;
0156     __be32      laddr;
0157     __be32      faddr;
0158     __u8        transport[TRANSNAMSIZ];     /* null term ascii */
0159     __u8        flags;
0160     __u8        tos;
0161 } __attribute__((packed));
0162 
0163 struct rds6_info_connection {
0164     __u64       next_tx_seq;
0165     __u64       next_rx_seq;
0166     struct in6_addr laddr;
0167     struct in6_addr faddr;
0168     __u8        transport[TRANSNAMSIZ];     /* null term ascii */
0169     __u8        flags;
0170 } __attribute__((packed));
0171 
0172 #define RDS_INFO_MESSAGE_FLAG_ACK               0x01
0173 #define RDS_INFO_MESSAGE_FLAG_FAST_ACK          0x02
0174 
0175 struct rds_info_message {
0176     __u64       seq;
0177     __u32       len;
0178     __be32      laddr;
0179     __be32      faddr;
0180     __be16      lport;
0181     __be16      fport;
0182     __u8        flags;
0183     __u8        tos;
0184 } __attribute__((packed));
0185 
0186 struct rds6_info_message {
0187     __u64   seq;
0188     __u32   len;
0189     struct in6_addr laddr;
0190     struct in6_addr faddr;
0191     __be16      lport;
0192     __be16      fport;
0193     __u8        flags;
0194     __u8        tos;
0195 } __attribute__((packed));
0196 
0197 struct rds_info_socket {
0198     __u32       sndbuf;
0199     __be32      bound_addr;
0200     __be32      connected_addr;
0201     __be16      bound_port;
0202     __be16      connected_port;
0203     __u32       rcvbuf;
0204     __u64       inum;
0205 } __attribute__((packed));
0206 
0207 struct rds6_info_socket {
0208     __u32       sndbuf;
0209     struct in6_addr bound_addr;
0210     struct in6_addr connected_addr;
0211     __be16      bound_port;
0212     __be16      connected_port;
0213     __u32       rcvbuf;
0214     __u64       inum;
0215 } __attribute__((packed));
0216 
0217 struct rds_info_tcp_socket {
0218     __be32          local_addr;
0219     __be16          local_port;
0220     __be32          peer_addr;
0221     __be16          peer_port;
0222     __u64           hdr_rem;
0223     __u64           data_rem;
0224     __u32           last_sent_nxt;
0225     __u32           last_expected_una;
0226     __u32           last_seen_una;
0227     __u8        tos;
0228 } __attribute__((packed));
0229 
0230 struct rds6_info_tcp_socket {
0231     struct in6_addr local_addr;
0232     __be16      local_port;
0233     struct in6_addr peer_addr;
0234     __be16      peer_port;
0235     __u64       hdr_rem;
0236     __u64       data_rem;
0237     __u32       last_sent_nxt;
0238     __u32       last_expected_una;
0239     __u32       last_seen_una;
0240 } __attribute__((packed));
0241 
0242 #define RDS_IB_GID_LEN  16
0243 struct rds_info_rdma_connection {
0244     __be32      src_addr;
0245     __be32      dst_addr;
0246     __u8        src_gid[RDS_IB_GID_LEN];
0247     __u8        dst_gid[RDS_IB_GID_LEN];
0248 
0249     __u32       max_send_wr;
0250     __u32       max_recv_wr;
0251     __u32       max_send_sge;
0252     __u32       rdma_mr_max;
0253     __u32       rdma_mr_size;
0254     __u8        tos;
0255     __u8        sl;
0256     __u32       cache_allocs;
0257 };
0258 
0259 struct rds6_info_rdma_connection {
0260     struct in6_addr src_addr;
0261     struct in6_addr dst_addr;
0262     __u8        src_gid[RDS_IB_GID_LEN];
0263     __u8        dst_gid[RDS_IB_GID_LEN];
0264 
0265     __u32       max_send_wr;
0266     __u32       max_recv_wr;
0267     __u32       max_send_sge;
0268     __u32       rdma_mr_max;
0269     __u32       rdma_mr_size;
0270     __u8        tos;
0271     __u8        sl;
0272     __u32       cache_allocs;
0273 };
0274 
0275 /* RDS message Receive Path Latency points */
0276 enum rds_message_rxpath_latency {
0277     RDS_MSG_RX_HDR_TO_DGRAM_START = 0,
0278     RDS_MSG_RX_DGRAM_REASSEMBLE,
0279     RDS_MSG_RX_DGRAM_DELIVERED,
0280     RDS_MSG_RX_DGRAM_TRACE_MAX
0281 };
0282 
0283 struct rds_rx_trace_so {
0284     __u8 rx_traces;
0285     __u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX];
0286 };
0287 
0288 struct rds_cmsg_rx_trace {
0289     __u8 rx_traces;
0290     __u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX];
0291     __u64 rx_trace[RDS_MSG_RX_DGRAM_TRACE_MAX];
0292 };
0293 
0294 /*
0295  * Congestion monitoring.
0296  * Congestion control in RDS happens at the host connection
0297  * level by exchanging a bitmap marking congested ports.
0298  * By default, a process sleeping in poll() is always woken
0299  * up when the congestion map is updated.
0300  * With explicit monitoring, an application can have more
0301  * fine-grained control.
0302  * The application installs a 64bit mask value in the socket,
0303  * where each bit corresponds to a group of ports.
0304  * When a congestion update arrives, RDS checks the set of
0305  * ports that are now uncongested against the list bit mask
0306  * installed in the socket, and if they overlap, we queue a
0307  * cong_notification on the socket.
0308  *
0309  * To install the congestion monitor bitmask, use RDS_CONG_MONITOR
0310  * with the 64bit mask.
0311  * Congestion updates are received via RDS_CMSG_CONG_UPDATE
0312  * control messages.
0313  *
0314  * The correspondence between bits and ports is
0315  *  1 << (portnum % 64)
0316  */
0317 #define RDS_CONG_MONITOR_SIZE   64
0318 #define RDS_CONG_MONITOR_BIT(port)  (((unsigned int) port) % RDS_CONG_MONITOR_SIZE)
0319 #define RDS_CONG_MONITOR_MASK(port) (1ULL << RDS_CONG_MONITOR_BIT(port))
0320 
0321 /*
0322  * RDMA related types
0323  */
0324 
0325 /*
0326  * This encapsulates a remote memory location.
0327  * In the current implementation, it contains the R_Key
0328  * of the remote memory region, and the offset into it
0329  * (so that the application does not have to worry about
0330  * alignment).
0331  */
0332 typedef __u64       rds_rdma_cookie_t;
0333 
0334 struct rds_iovec {
0335     __u64       addr;
0336     __u64       bytes;
0337 };
0338 
0339 struct rds_get_mr_args {
0340     struct rds_iovec vec;
0341     __u64       cookie_addr;
0342     __u64       flags;
0343 };
0344 
0345 struct rds_get_mr_for_dest_args {
0346     struct __kernel_sockaddr_storage dest_addr;
0347     struct rds_iovec    vec;
0348     __u64           cookie_addr;
0349     __u64           flags;
0350 };
0351 
0352 struct rds_free_mr_args {
0353     rds_rdma_cookie_t cookie;
0354     __u64       flags;
0355 };
0356 
0357 struct rds_rdma_args {
0358     rds_rdma_cookie_t cookie;
0359     struct rds_iovec remote_vec;
0360     __u64       local_vec_addr;
0361     __u64       nr_local;
0362     __u64       flags;
0363     __u64       user_token;
0364 };
0365 
0366 struct rds_atomic_args {
0367     rds_rdma_cookie_t cookie;
0368     __u64       local_addr;
0369     __u64       remote_addr;
0370     union {
0371         struct {
0372             __u64       compare;
0373             __u64       swap;
0374         } cswp;
0375         struct {
0376             __u64       add;
0377         } fadd;
0378         struct {
0379             __u64       compare;
0380             __u64       swap;
0381             __u64       compare_mask;
0382             __u64       swap_mask;
0383         } m_cswp;
0384         struct {
0385             __u64       add;
0386             __u64       nocarry_mask;
0387         } m_fadd;
0388     };
0389     __u64       flags;
0390     __u64       user_token;
0391 };
0392 
0393 struct rds_rdma_notify {
0394     __u64       user_token;
0395     __s32       status;
0396 };
0397 
0398 #define RDS_RDMA_SUCCESS    0
0399 #define RDS_RDMA_REMOTE_ERROR   1
0400 #define RDS_RDMA_CANCELED   2
0401 #define RDS_RDMA_DROPPED    3
0402 #define RDS_RDMA_OTHER_ERROR    4
0403 
0404 #define RDS_MAX_ZCOOKIES    8
0405 struct rds_zcopy_cookies {
0406     __u32 num;
0407     __u32 cookies[RDS_MAX_ZCOOKIES];
0408 };
0409 
0410 /*
0411  * Common set of flags for all RDMA related structs
0412  */
0413 #define RDS_RDMA_READWRITE  0x0001
0414 #define RDS_RDMA_FENCE      0x0002  /* use FENCE for immediate send */
0415 #define RDS_RDMA_INVALIDATE 0x0004  /* invalidate R_Key after freeing MR */
0416 #define RDS_RDMA_USE_ONCE   0x0008  /* free MR after use */
0417 #define RDS_RDMA_DONTWAIT   0x0010  /* Don't wait in SET_BARRIER */
0418 #define RDS_RDMA_NOTIFY_ME  0x0020  /* Notify when operation completes */
0419 #define RDS_RDMA_SILENT     0x0040  /* Do not interrupt remote */
0420 
0421 #endif /* IB_RDS_H */