18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _RDS_RDS_H 38c2ecf20Sopenharmony_ci#define _RDS_RDS_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <net/sock.h> 68c2ecf20Sopenharmony_ci#include <linux/scatterlist.h> 78c2ecf20Sopenharmony_ci#include <linux/highmem.h> 88c2ecf20Sopenharmony_ci#include <rdma/rdma_cm.h> 98c2ecf20Sopenharmony_ci#include <linux/mutex.h> 108c2ecf20Sopenharmony_ci#include <linux/rds.h> 118c2ecf20Sopenharmony_ci#include <linux/rhashtable.h> 128c2ecf20Sopenharmony_ci#include <linux/refcount.h> 138c2ecf20Sopenharmony_ci#include <linux/in6.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "info.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/* 188c2ecf20Sopenharmony_ci * RDS Network protocol version 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci#define RDS_PROTOCOL_3_0 0x0300 218c2ecf20Sopenharmony_ci#define RDS_PROTOCOL_3_1 0x0301 228c2ecf20Sopenharmony_ci#define RDS_PROTOCOL_4_0 0x0400 238c2ecf20Sopenharmony_ci#define RDS_PROTOCOL_4_1 0x0401 248c2ecf20Sopenharmony_ci#define RDS_PROTOCOL_VERSION RDS_PROTOCOL_3_1 258c2ecf20Sopenharmony_ci#define RDS_PROTOCOL_MAJOR(v) ((v) >> 8) 268c2ecf20Sopenharmony_ci#define RDS_PROTOCOL_MINOR(v) ((v) & 255) 278c2ecf20Sopenharmony_ci#define RDS_PROTOCOL(maj, min) (((maj) << 8) | min) 288c2ecf20Sopenharmony_ci#define RDS_PROTOCOL_COMPAT_VERSION RDS_PROTOCOL_3_1 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* The following ports, 16385, 18634, 18635, are registered with IANA as 318c2ecf20Sopenharmony_ci * the ports to be used for RDS over TCP and UDP. Currently, only RDS over 328c2ecf20Sopenharmony_ci * TCP and RDS over IB/RDMA are implemented. 18634 is the historical value 338c2ecf20Sopenharmony_ci * used for the RDMA_CM listener port. RDS/TCP uses port 16385. After 348c2ecf20Sopenharmony_ci * IPv6 work, RDMA_CM also uses 16385 as the listener port. 18634 is kept 358c2ecf20Sopenharmony_ci * to ensure compatibility with older RDS modules. Those ports are defined 368c2ecf20Sopenharmony_ci * in each transport's header file. 378c2ecf20Sopenharmony_ci */ 388c2ecf20Sopenharmony_ci#define RDS_PORT 18634 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#ifdef ATOMIC64_INIT 418c2ecf20Sopenharmony_ci#define KERNEL_HAS_ATOMIC64 428c2ecf20Sopenharmony_ci#endif 438c2ecf20Sopenharmony_ci#ifdef RDS_DEBUG 448c2ecf20Sopenharmony_ci#define rdsdebug(fmt, args...) pr_debug("%s(): " fmt, __func__ , ##args) 458c2ecf20Sopenharmony_ci#else 468c2ecf20Sopenharmony_ci/* sigh, pr_debug() causes unused variable warnings */ 478c2ecf20Sopenharmony_cistatic inline __printf(1, 2) 488c2ecf20Sopenharmony_civoid rdsdebug(char *fmt, ...) 498c2ecf20Sopenharmony_ci{ 508c2ecf20Sopenharmony_ci} 518c2ecf20Sopenharmony_ci#endif 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define RDS_FRAG_SHIFT 12 548c2ecf20Sopenharmony_ci#define RDS_FRAG_SIZE ((unsigned int)(1 << RDS_FRAG_SHIFT)) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* Used to limit both RDMA and non-RDMA RDS message to 1MB */ 578c2ecf20Sopenharmony_ci#define RDS_MAX_MSG_SIZE ((unsigned int)(1 << 20)) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define RDS_CONG_MAP_BYTES (65536 / 8) 608c2ecf20Sopenharmony_ci#define RDS_CONG_MAP_PAGES (PAGE_ALIGN(RDS_CONG_MAP_BYTES) / PAGE_SIZE) 618c2ecf20Sopenharmony_ci#define RDS_CONG_MAP_PAGE_BITS (PAGE_SIZE * 8) 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistruct rds_cong_map { 648c2ecf20Sopenharmony_ci struct rb_node m_rb_node; 658c2ecf20Sopenharmony_ci struct in6_addr m_addr; 668c2ecf20Sopenharmony_ci wait_queue_head_t m_waitq; 678c2ecf20Sopenharmony_ci struct list_head m_conn_list; 688c2ecf20Sopenharmony_ci unsigned long m_page_addrs[RDS_CONG_MAP_PAGES]; 698c2ecf20Sopenharmony_ci}; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci/* 738c2ecf20Sopenharmony_ci * This is how we will track the connection state: 748c2ecf20Sopenharmony_ci * A connection is always in one of the following 758c2ecf20Sopenharmony_ci * states. Updates to the state are atomic and imply 768c2ecf20Sopenharmony_ci * a memory barrier. 778c2ecf20Sopenharmony_ci */ 788c2ecf20Sopenharmony_cienum { 798c2ecf20Sopenharmony_ci RDS_CONN_DOWN = 0, 808c2ecf20Sopenharmony_ci RDS_CONN_CONNECTING, 818c2ecf20Sopenharmony_ci RDS_CONN_DISCONNECTING, 828c2ecf20Sopenharmony_ci RDS_CONN_UP, 838c2ecf20Sopenharmony_ci RDS_CONN_RESETTING, 848c2ecf20Sopenharmony_ci RDS_CONN_ERROR, 858c2ecf20Sopenharmony_ci}; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* Bits for c_flags */ 888c2ecf20Sopenharmony_ci#define RDS_LL_SEND_FULL 0 898c2ecf20Sopenharmony_ci#define RDS_RECONNECT_PENDING 1 908c2ecf20Sopenharmony_ci#define RDS_IN_XMIT 2 918c2ecf20Sopenharmony_ci#define RDS_RECV_REFILL 3 928c2ecf20Sopenharmony_ci#define RDS_DESTROY_PENDING 4 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci/* Max number of multipaths per RDS connection. Must be a power of 2 */ 958c2ecf20Sopenharmony_ci#define RDS_MPATH_WORKERS 8 968c2ecf20Sopenharmony_ci#define RDS_MPATH_HASH(rs, n) (jhash_1word((rs)->rs_bound_port, \ 978c2ecf20Sopenharmony_ci (rs)->rs_hash_initval) & ((n) - 1)) 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#define IS_CANONICAL(laddr, faddr) (htonl(laddr) < htonl(faddr)) 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci/* Per mpath connection state */ 1028c2ecf20Sopenharmony_cistruct rds_conn_path { 1038c2ecf20Sopenharmony_ci struct rds_connection *cp_conn; 1048c2ecf20Sopenharmony_ci struct rds_message *cp_xmit_rm; 1058c2ecf20Sopenharmony_ci unsigned long cp_xmit_sg; 1068c2ecf20Sopenharmony_ci unsigned int cp_xmit_hdr_off; 1078c2ecf20Sopenharmony_ci unsigned int cp_xmit_data_off; 1088c2ecf20Sopenharmony_ci unsigned int cp_xmit_atomic_sent; 1098c2ecf20Sopenharmony_ci unsigned int cp_xmit_rdma_sent; 1108c2ecf20Sopenharmony_ci unsigned int cp_xmit_data_sent; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci spinlock_t cp_lock; /* protect msg queues */ 1138c2ecf20Sopenharmony_ci u64 cp_next_tx_seq; 1148c2ecf20Sopenharmony_ci struct list_head cp_send_queue; 1158c2ecf20Sopenharmony_ci struct list_head cp_retrans; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci u64 cp_next_rx_seq; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci void *cp_transport_data; 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci atomic_t cp_state; 1228c2ecf20Sopenharmony_ci unsigned long cp_send_gen; 1238c2ecf20Sopenharmony_ci unsigned long cp_flags; 1248c2ecf20Sopenharmony_ci unsigned long cp_reconnect_jiffies; 1258c2ecf20Sopenharmony_ci struct delayed_work cp_send_w; 1268c2ecf20Sopenharmony_ci struct delayed_work cp_recv_w; 1278c2ecf20Sopenharmony_ci struct delayed_work cp_conn_w; 1288c2ecf20Sopenharmony_ci struct work_struct cp_down_w; 1298c2ecf20Sopenharmony_ci struct mutex cp_cm_lock; /* protect cp_state & cm */ 1308c2ecf20Sopenharmony_ci wait_queue_head_t cp_waitq; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci unsigned int cp_unacked_packets; 1338c2ecf20Sopenharmony_ci unsigned int cp_unacked_bytes; 1348c2ecf20Sopenharmony_ci unsigned int cp_index; 1358c2ecf20Sopenharmony_ci}; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci/* One rds_connection per RDS address pair */ 1388c2ecf20Sopenharmony_cistruct rds_connection { 1398c2ecf20Sopenharmony_ci struct hlist_node c_hash_node; 1408c2ecf20Sopenharmony_ci struct in6_addr c_laddr; 1418c2ecf20Sopenharmony_ci struct in6_addr c_faddr; 1428c2ecf20Sopenharmony_ci int c_dev_if; /* ifindex used for this conn */ 1438c2ecf20Sopenharmony_ci int c_bound_if; /* ifindex of c_laddr */ 1448c2ecf20Sopenharmony_ci unsigned int c_loopback:1, 1458c2ecf20Sopenharmony_ci c_isv6:1, 1468c2ecf20Sopenharmony_ci c_ping_triggered:1, 1478c2ecf20Sopenharmony_ci c_pad_to_32:29; 1488c2ecf20Sopenharmony_ci int c_npaths; 1498c2ecf20Sopenharmony_ci struct rds_connection *c_passive; 1508c2ecf20Sopenharmony_ci struct rds_transport *c_trans; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci struct rds_cong_map *c_lcong; 1538c2ecf20Sopenharmony_ci struct rds_cong_map *c_fcong; 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci /* Protocol version */ 1568c2ecf20Sopenharmony_ci unsigned int c_proposed_version; 1578c2ecf20Sopenharmony_ci unsigned int c_version; 1588c2ecf20Sopenharmony_ci possible_net_t c_net; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci /* TOS */ 1618c2ecf20Sopenharmony_ci u8 c_tos; 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci struct list_head c_map_item; 1648c2ecf20Sopenharmony_ci unsigned long c_map_queued; 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci struct rds_conn_path *c_path; 1678c2ecf20Sopenharmony_ci wait_queue_head_t c_hs_waitq; /* handshake waitq */ 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci u32 c_my_gen_num; 1708c2ecf20Sopenharmony_ci u32 c_peer_gen_num; 1718c2ecf20Sopenharmony_ci}; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_cistatic inline 1748c2ecf20Sopenharmony_cistruct net *rds_conn_net(struct rds_connection *conn) 1758c2ecf20Sopenharmony_ci{ 1768c2ecf20Sopenharmony_ci return read_pnet(&conn->c_net); 1778c2ecf20Sopenharmony_ci} 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_cistatic inline 1808c2ecf20Sopenharmony_civoid rds_conn_net_set(struct rds_connection *conn, struct net *net) 1818c2ecf20Sopenharmony_ci{ 1828c2ecf20Sopenharmony_ci write_pnet(&conn->c_net, net); 1838c2ecf20Sopenharmony_ci} 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci#define RDS_FLAG_CONG_BITMAP 0x01 1868c2ecf20Sopenharmony_ci#define RDS_FLAG_ACK_REQUIRED 0x02 1878c2ecf20Sopenharmony_ci#define RDS_FLAG_RETRANSMITTED 0x04 1888c2ecf20Sopenharmony_ci#define RDS_MAX_ADV_CREDIT 255 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci/* RDS_FLAG_PROBE_PORT is the reserved sport used for sending a ping 1918c2ecf20Sopenharmony_ci * probe to exchange control information before establishing a connection. 1928c2ecf20Sopenharmony_ci * Currently the control information that is exchanged is the number of 1938c2ecf20Sopenharmony_ci * supported paths. If the peer is a legacy (older kernel revision) peer, 1948c2ecf20Sopenharmony_ci * it would return a pong message without additional control information 1958c2ecf20Sopenharmony_ci * that would then alert the sender that the peer was an older rev. 1968c2ecf20Sopenharmony_ci */ 1978c2ecf20Sopenharmony_ci#define RDS_FLAG_PROBE_PORT 1 1988c2ecf20Sopenharmony_ci#define RDS_HS_PROBE(sport, dport) \ 1998c2ecf20Sopenharmony_ci ((sport == RDS_FLAG_PROBE_PORT && dport == 0) || \ 2008c2ecf20Sopenharmony_ci (sport == 0 && dport == RDS_FLAG_PROBE_PORT)) 2018c2ecf20Sopenharmony_ci/* 2028c2ecf20Sopenharmony_ci * Maximum space available for extension headers. 2038c2ecf20Sopenharmony_ci */ 2048c2ecf20Sopenharmony_ci#define RDS_HEADER_EXT_SPACE 16 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_cistruct rds_header { 2078c2ecf20Sopenharmony_ci __be64 h_sequence; 2088c2ecf20Sopenharmony_ci __be64 h_ack; 2098c2ecf20Sopenharmony_ci __be32 h_len; 2108c2ecf20Sopenharmony_ci __be16 h_sport; 2118c2ecf20Sopenharmony_ci __be16 h_dport; 2128c2ecf20Sopenharmony_ci u8 h_flags; 2138c2ecf20Sopenharmony_ci u8 h_credit; 2148c2ecf20Sopenharmony_ci u8 h_padding[4]; 2158c2ecf20Sopenharmony_ci __sum16 h_csum; 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci u8 h_exthdr[RDS_HEADER_EXT_SPACE]; 2188c2ecf20Sopenharmony_ci}; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci/* 2218c2ecf20Sopenharmony_ci * Reserved - indicates end of extensions 2228c2ecf20Sopenharmony_ci */ 2238c2ecf20Sopenharmony_ci#define RDS_EXTHDR_NONE 0 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci/* 2268c2ecf20Sopenharmony_ci * This extension header is included in the very 2278c2ecf20Sopenharmony_ci * first message that is sent on a new connection, 2288c2ecf20Sopenharmony_ci * and identifies the protocol level. This will help 2298c2ecf20Sopenharmony_ci * rolling updates if a future change requires breaking 2308c2ecf20Sopenharmony_ci * the protocol. 2318c2ecf20Sopenharmony_ci * NB: This is no longer true for IB, where we do a version 2328c2ecf20Sopenharmony_ci * negotiation during the connection setup phase (protocol 2338c2ecf20Sopenharmony_ci * version information is included in the RDMA CM private data). 2348c2ecf20Sopenharmony_ci */ 2358c2ecf20Sopenharmony_ci#define RDS_EXTHDR_VERSION 1 2368c2ecf20Sopenharmony_cistruct rds_ext_header_version { 2378c2ecf20Sopenharmony_ci __be32 h_version; 2388c2ecf20Sopenharmony_ci}; 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci/* 2418c2ecf20Sopenharmony_ci * This extension header is included in the RDS message 2428c2ecf20Sopenharmony_ci * chasing an RDMA operation. 2438c2ecf20Sopenharmony_ci */ 2448c2ecf20Sopenharmony_ci#define RDS_EXTHDR_RDMA 2 2458c2ecf20Sopenharmony_cistruct rds_ext_header_rdma { 2468c2ecf20Sopenharmony_ci __be32 h_rdma_rkey; 2478c2ecf20Sopenharmony_ci}; 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci/* 2508c2ecf20Sopenharmony_ci * This extension header tells the peer about the 2518c2ecf20Sopenharmony_ci * destination <R_Key,offset> of the requested RDMA 2528c2ecf20Sopenharmony_ci * operation. 2538c2ecf20Sopenharmony_ci */ 2548c2ecf20Sopenharmony_ci#define RDS_EXTHDR_RDMA_DEST 3 2558c2ecf20Sopenharmony_cistruct rds_ext_header_rdma_dest { 2568c2ecf20Sopenharmony_ci __be32 h_rdma_rkey; 2578c2ecf20Sopenharmony_ci __be32 h_rdma_offset; 2588c2ecf20Sopenharmony_ci}; 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci/* Extension header announcing number of paths. 2618c2ecf20Sopenharmony_ci * Implicit length = 2 bytes. 2628c2ecf20Sopenharmony_ci */ 2638c2ecf20Sopenharmony_ci#define RDS_EXTHDR_NPATHS 5 2648c2ecf20Sopenharmony_ci#define RDS_EXTHDR_GEN_NUM 6 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci#define __RDS_EXTHDR_MAX 16 /* for now */ 2678c2ecf20Sopenharmony_ci#define RDS_RX_MAX_TRACES (RDS_MSG_RX_DGRAM_TRACE_MAX + 1) 2688c2ecf20Sopenharmony_ci#define RDS_MSG_RX_HDR 0 2698c2ecf20Sopenharmony_ci#define RDS_MSG_RX_START 1 2708c2ecf20Sopenharmony_ci#define RDS_MSG_RX_END 2 2718c2ecf20Sopenharmony_ci#define RDS_MSG_RX_CMSG 3 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci/* The following values are whitelisted for usercopy */ 2748c2ecf20Sopenharmony_cistruct rds_inc_usercopy { 2758c2ecf20Sopenharmony_ci rds_rdma_cookie_t rdma_cookie; 2768c2ecf20Sopenharmony_ci ktime_t rx_tstamp; 2778c2ecf20Sopenharmony_ci}; 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_cistruct rds_incoming { 2808c2ecf20Sopenharmony_ci refcount_t i_refcount; 2818c2ecf20Sopenharmony_ci struct list_head i_item; 2828c2ecf20Sopenharmony_ci struct rds_connection *i_conn; 2838c2ecf20Sopenharmony_ci struct rds_conn_path *i_conn_path; 2848c2ecf20Sopenharmony_ci struct rds_header i_hdr; 2858c2ecf20Sopenharmony_ci unsigned long i_rx_jiffies; 2868c2ecf20Sopenharmony_ci struct in6_addr i_saddr; 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci struct rds_inc_usercopy i_usercopy; 2898c2ecf20Sopenharmony_ci u64 i_rx_lat_trace[RDS_RX_MAX_TRACES]; 2908c2ecf20Sopenharmony_ci}; 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_cistruct rds_mr { 2938c2ecf20Sopenharmony_ci struct rb_node r_rb_node; 2948c2ecf20Sopenharmony_ci struct kref r_kref; 2958c2ecf20Sopenharmony_ci u32 r_key; 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci /* A copy of the creation flags */ 2988c2ecf20Sopenharmony_ci unsigned int r_use_once:1; 2998c2ecf20Sopenharmony_ci unsigned int r_invalidate:1; 3008c2ecf20Sopenharmony_ci unsigned int r_write:1; 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci struct rds_sock *r_sock; /* back pointer to the socket that owns us */ 3038c2ecf20Sopenharmony_ci struct rds_transport *r_trans; 3048c2ecf20Sopenharmony_ci void *r_trans_private; 3058c2ecf20Sopenharmony_ci}; 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_cistatic inline rds_rdma_cookie_t rds_rdma_make_cookie(u32 r_key, u32 offset) 3088c2ecf20Sopenharmony_ci{ 3098c2ecf20Sopenharmony_ci return r_key | (((u64) offset) << 32); 3108c2ecf20Sopenharmony_ci} 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_cistatic inline u32 rds_rdma_cookie_key(rds_rdma_cookie_t cookie) 3138c2ecf20Sopenharmony_ci{ 3148c2ecf20Sopenharmony_ci return cookie; 3158c2ecf20Sopenharmony_ci} 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_cistatic inline u32 rds_rdma_cookie_offset(rds_rdma_cookie_t cookie) 3188c2ecf20Sopenharmony_ci{ 3198c2ecf20Sopenharmony_ci return cookie >> 32; 3208c2ecf20Sopenharmony_ci} 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci/* atomic operation types */ 3238c2ecf20Sopenharmony_ci#define RDS_ATOMIC_TYPE_CSWP 0 3248c2ecf20Sopenharmony_ci#define RDS_ATOMIC_TYPE_FADD 1 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci/* 3278c2ecf20Sopenharmony_ci * m_sock_item and m_conn_item are on lists that are serialized under 3288c2ecf20Sopenharmony_ci * conn->c_lock. m_sock_item has additional meaning in that once it is empty 3298c2ecf20Sopenharmony_ci * the message will not be put back on the retransmit list after being sent. 3308c2ecf20Sopenharmony_ci * messages that are canceled while being sent rely on this. 3318c2ecf20Sopenharmony_ci * 3328c2ecf20Sopenharmony_ci * m_inc is used by loopback so that it can pass an incoming message straight 3338c2ecf20Sopenharmony_ci * back up into the rx path. It embeds a wire header which is also used by 3348c2ecf20Sopenharmony_ci * the send path, which is kind of awkward. 3358c2ecf20Sopenharmony_ci * 3368c2ecf20Sopenharmony_ci * m_sock_item indicates the message's presence on a socket's send or receive 3378c2ecf20Sopenharmony_ci * queue. m_rs will point to that socket. 3388c2ecf20Sopenharmony_ci * 3398c2ecf20Sopenharmony_ci * m_daddr is used by cancellation to prune messages to a given destination. 3408c2ecf20Sopenharmony_ci * 3418c2ecf20Sopenharmony_ci * The RDS_MSG_ON_SOCK and RDS_MSG_ON_CONN flags are used to avoid lock 3428c2ecf20Sopenharmony_ci * nesting. As paths iterate over messages on a sock, or conn, they must 3438c2ecf20Sopenharmony_ci * also lock the conn, or sock, to remove the message from those lists too. 3448c2ecf20Sopenharmony_ci * Testing the flag to determine if the message is still on the lists lets 3458c2ecf20Sopenharmony_ci * us avoid testing the list_head directly. That means each path can use 3468c2ecf20Sopenharmony_ci * the message's list_head to keep it on a local list while juggling locks 3478c2ecf20Sopenharmony_ci * without confusing the other path. 3488c2ecf20Sopenharmony_ci * 3498c2ecf20Sopenharmony_ci * m_ack_seq is an optional field set by transports who need a different 3508c2ecf20Sopenharmony_ci * sequence number range to invalidate. They can use this in a callback 3518c2ecf20Sopenharmony_ci * that they pass to rds_send_drop_acked() to see if each message has been 3528c2ecf20Sopenharmony_ci * acked. The HAS_ACK_SEQ flag can be used to detect messages which haven't 3538c2ecf20Sopenharmony_ci * had ack_seq set yet. 3548c2ecf20Sopenharmony_ci */ 3558c2ecf20Sopenharmony_ci#define RDS_MSG_ON_SOCK 1 3568c2ecf20Sopenharmony_ci#define RDS_MSG_ON_CONN 2 3578c2ecf20Sopenharmony_ci#define RDS_MSG_HAS_ACK_SEQ 3 3588c2ecf20Sopenharmony_ci#define RDS_MSG_ACK_REQUIRED 4 3598c2ecf20Sopenharmony_ci#define RDS_MSG_RETRANSMITTED 5 3608c2ecf20Sopenharmony_ci#define RDS_MSG_MAPPED 6 3618c2ecf20Sopenharmony_ci#define RDS_MSG_PAGEVEC 7 3628c2ecf20Sopenharmony_ci#define RDS_MSG_FLUSH 8 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_cistruct rds_znotifier { 3658c2ecf20Sopenharmony_ci struct mmpin z_mmp; 3668c2ecf20Sopenharmony_ci u32 z_cookie; 3678c2ecf20Sopenharmony_ci}; 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_cistruct rds_msg_zcopy_info { 3708c2ecf20Sopenharmony_ci struct list_head rs_zcookie_next; 3718c2ecf20Sopenharmony_ci union { 3728c2ecf20Sopenharmony_ci struct rds_znotifier znotif; 3738c2ecf20Sopenharmony_ci struct rds_zcopy_cookies zcookies; 3748c2ecf20Sopenharmony_ci }; 3758c2ecf20Sopenharmony_ci}; 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_cistruct rds_msg_zcopy_queue { 3788c2ecf20Sopenharmony_ci struct list_head zcookie_head; 3798c2ecf20Sopenharmony_ci spinlock_t lock; /* protects zcookie_head queue */ 3808c2ecf20Sopenharmony_ci}; 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_cistatic inline void rds_message_zcopy_queue_init(struct rds_msg_zcopy_queue *q) 3838c2ecf20Sopenharmony_ci{ 3848c2ecf20Sopenharmony_ci spin_lock_init(&q->lock); 3858c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&q->zcookie_head); 3868c2ecf20Sopenharmony_ci} 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_cistruct rds_iov_vector { 3898c2ecf20Sopenharmony_ci struct rds_iovec *iov; 3908c2ecf20Sopenharmony_ci int len; 3918c2ecf20Sopenharmony_ci}; 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_cistruct rds_iov_vector_arr { 3948c2ecf20Sopenharmony_ci struct rds_iov_vector *vec; 3958c2ecf20Sopenharmony_ci int len; 3968c2ecf20Sopenharmony_ci int indx; 3978c2ecf20Sopenharmony_ci int incr; 3988c2ecf20Sopenharmony_ci}; 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_cistruct rds_message { 4018c2ecf20Sopenharmony_ci refcount_t m_refcount; 4028c2ecf20Sopenharmony_ci struct list_head m_sock_item; 4038c2ecf20Sopenharmony_ci struct list_head m_conn_item; 4048c2ecf20Sopenharmony_ci struct rds_incoming m_inc; 4058c2ecf20Sopenharmony_ci u64 m_ack_seq; 4068c2ecf20Sopenharmony_ci struct in6_addr m_daddr; 4078c2ecf20Sopenharmony_ci unsigned long m_flags; 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_ci /* Never access m_rs without holding m_rs_lock. 4108c2ecf20Sopenharmony_ci * Lock nesting is 4118c2ecf20Sopenharmony_ci * rm->m_rs_lock 4128c2ecf20Sopenharmony_ci * -> rs->rs_lock 4138c2ecf20Sopenharmony_ci */ 4148c2ecf20Sopenharmony_ci spinlock_t m_rs_lock; 4158c2ecf20Sopenharmony_ci wait_queue_head_t m_flush_wait; 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ci struct rds_sock *m_rs; 4188c2ecf20Sopenharmony_ci 4198c2ecf20Sopenharmony_ci /* cookie to send to remote, in rds header */ 4208c2ecf20Sopenharmony_ci rds_rdma_cookie_t m_rdma_cookie; 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci unsigned int m_used_sgs; 4238c2ecf20Sopenharmony_ci unsigned int m_total_sgs; 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ci void *m_final_op; 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci struct { 4288c2ecf20Sopenharmony_ci struct rm_atomic_op { 4298c2ecf20Sopenharmony_ci int op_type; 4308c2ecf20Sopenharmony_ci union { 4318c2ecf20Sopenharmony_ci struct { 4328c2ecf20Sopenharmony_ci uint64_t compare; 4338c2ecf20Sopenharmony_ci uint64_t swap; 4348c2ecf20Sopenharmony_ci uint64_t compare_mask; 4358c2ecf20Sopenharmony_ci uint64_t swap_mask; 4368c2ecf20Sopenharmony_ci } op_m_cswp; 4378c2ecf20Sopenharmony_ci struct { 4388c2ecf20Sopenharmony_ci uint64_t add; 4398c2ecf20Sopenharmony_ci uint64_t nocarry_mask; 4408c2ecf20Sopenharmony_ci } op_m_fadd; 4418c2ecf20Sopenharmony_ci }; 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci u32 op_rkey; 4448c2ecf20Sopenharmony_ci u64 op_remote_addr; 4458c2ecf20Sopenharmony_ci unsigned int op_notify:1; 4468c2ecf20Sopenharmony_ci unsigned int op_recverr:1; 4478c2ecf20Sopenharmony_ci unsigned int op_mapped:1; 4488c2ecf20Sopenharmony_ci unsigned int op_silent:1; 4498c2ecf20Sopenharmony_ci unsigned int op_active:1; 4508c2ecf20Sopenharmony_ci struct scatterlist *op_sg; 4518c2ecf20Sopenharmony_ci struct rds_notifier *op_notifier; 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ci struct rds_mr *op_rdma_mr; 4548c2ecf20Sopenharmony_ci } atomic; 4558c2ecf20Sopenharmony_ci struct rm_rdma_op { 4568c2ecf20Sopenharmony_ci u32 op_rkey; 4578c2ecf20Sopenharmony_ci u64 op_remote_addr; 4588c2ecf20Sopenharmony_ci unsigned int op_write:1; 4598c2ecf20Sopenharmony_ci unsigned int op_fence:1; 4608c2ecf20Sopenharmony_ci unsigned int op_notify:1; 4618c2ecf20Sopenharmony_ci unsigned int op_recverr:1; 4628c2ecf20Sopenharmony_ci unsigned int op_mapped:1; 4638c2ecf20Sopenharmony_ci unsigned int op_silent:1; 4648c2ecf20Sopenharmony_ci unsigned int op_active:1; 4658c2ecf20Sopenharmony_ci unsigned int op_bytes; 4668c2ecf20Sopenharmony_ci unsigned int op_nents; 4678c2ecf20Sopenharmony_ci unsigned int op_count; 4688c2ecf20Sopenharmony_ci struct scatterlist *op_sg; 4698c2ecf20Sopenharmony_ci struct rds_notifier *op_notifier; 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_ci struct rds_mr *op_rdma_mr; 4728c2ecf20Sopenharmony_ci 4738c2ecf20Sopenharmony_ci u64 op_odp_addr; 4748c2ecf20Sopenharmony_ci struct rds_mr *op_odp_mr; 4758c2ecf20Sopenharmony_ci } rdma; 4768c2ecf20Sopenharmony_ci struct rm_data_op { 4778c2ecf20Sopenharmony_ci unsigned int op_active:1; 4788c2ecf20Sopenharmony_ci unsigned int op_nents; 4798c2ecf20Sopenharmony_ci unsigned int op_count; 4808c2ecf20Sopenharmony_ci unsigned int op_dmasg; 4818c2ecf20Sopenharmony_ci unsigned int op_dmaoff; 4828c2ecf20Sopenharmony_ci struct rds_znotifier *op_mmp_znotifier; 4838c2ecf20Sopenharmony_ci struct scatterlist *op_sg; 4848c2ecf20Sopenharmony_ci } data; 4858c2ecf20Sopenharmony_ci }; 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_ci struct rds_conn_path *m_conn_path; 4888c2ecf20Sopenharmony_ci}; 4898c2ecf20Sopenharmony_ci 4908c2ecf20Sopenharmony_ci/* 4918c2ecf20Sopenharmony_ci * The RDS notifier is used (optionally) to tell the application about 4928c2ecf20Sopenharmony_ci * completed RDMA operations. Rather than keeping the whole rds message 4938c2ecf20Sopenharmony_ci * around on the queue, we allocate a small notifier that is put on the 4948c2ecf20Sopenharmony_ci * socket's notifier_list. Notifications are delivered to the application 4958c2ecf20Sopenharmony_ci * through control messages. 4968c2ecf20Sopenharmony_ci */ 4978c2ecf20Sopenharmony_cistruct rds_notifier { 4988c2ecf20Sopenharmony_ci struct list_head n_list; 4998c2ecf20Sopenharmony_ci uint64_t n_user_token; 5008c2ecf20Sopenharmony_ci int n_status; 5018c2ecf20Sopenharmony_ci}; 5028c2ecf20Sopenharmony_ci 5038c2ecf20Sopenharmony_ci/* Available as part of RDS core, so doesn't need to participate 5048c2ecf20Sopenharmony_ci * in get_preferred transport etc 5058c2ecf20Sopenharmony_ci */ 5068c2ecf20Sopenharmony_ci#define RDS_TRANS_LOOP 3 5078c2ecf20Sopenharmony_ci 5088c2ecf20Sopenharmony_ci/** 5098c2ecf20Sopenharmony_ci * struct rds_transport - transport specific behavioural hooks 5108c2ecf20Sopenharmony_ci * 5118c2ecf20Sopenharmony_ci * @xmit: .xmit is called by rds_send_xmit() to tell the transport to send 5128c2ecf20Sopenharmony_ci * part of a message. The caller serializes on the send_sem so this 5138c2ecf20Sopenharmony_ci * doesn't need to be reentrant for a given conn. The header must be 5148c2ecf20Sopenharmony_ci * sent before the data payload. .xmit must be prepared to send a 5158c2ecf20Sopenharmony_ci * message with no data payload. .xmit should return the number of 5168c2ecf20Sopenharmony_ci * bytes that were sent down the connection, including header bytes. 5178c2ecf20Sopenharmony_ci * Returning 0 tells the caller that it doesn't need to perform any 5188c2ecf20Sopenharmony_ci * additional work now. This is usually the case when the transport has 5198c2ecf20Sopenharmony_ci * filled the sending queue for its connection and will handle 5208c2ecf20Sopenharmony_ci * triggering the rds thread to continue the send when space becomes 5218c2ecf20Sopenharmony_ci * available. Returning -EAGAIN tells the caller to retry the send 5228c2ecf20Sopenharmony_ci * immediately. Returning -ENOMEM tells the caller to retry the send at 5238c2ecf20Sopenharmony_ci * some point in the future. 5248c2ecf20Sopenharmony_ci * 5258c2ecf20Sopenharmony_ci * @conn_shutdown: conn_shutdown stops traffic on the given connection. Once 5268c2ecf20Sopenharmony_ci * it returns the connection can not call rds_recv_incoming(). 5278c2ecf20Sopenharmony_ci * This will only be called once after conn_connect returns 5288c2ecf20Sopenharmony_ci * non-zero success and will The caller serializes this with 5298c2ecf20Sopenharmony_ci * the send and connecting paths (xmit_* and conn_*). The 5308c2ecf20Sopenharmony_ci * transport is responsible for other serialization, including 5318c2ecf20Sopenharmony_ci * rds_recv_incoming(). This is called in process context but 5328c2ecf20Sopenharmony_ci * should try hard not to block. 5338c2ecf20Sopenharmony_ci */ 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_cistruct rds_transport { 5368c2ecf20Sopenharmony_ci char t_name[TRANSNAMSIZ]; 5378c2ecf20Sopenharmony_ci struct list_head t_item; 5388c2ecf20Sopenharmony_ci struct module *t_owner; 5398c2ecf20Sopenharmony_ci unsigned int t_prefer_loopback:1, 5408c2ecf20Sopenharmony_ci t_mp_capable:1; 5418c2ecf20Sopenharmony_ci unsigned int t_type; 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ci int (*laddr_check)(struct net *net, const struct in6_addr *addr, 5448c2ecf20Sopenharmony_ci __u32 scope_id); 5458c2ecf20Sopenharmony_ci int (*conn_alloc)(struct rds_connection *conn, gfp_t gfp); 5468c2ecf20Sopenharmony_ci void (*conn_free)(void *data); 5478c2ecf20Sopenharmony_ci int (*conn_path_connect)(struct rds_conn_path *cp); 5488c2ecf20Sopenharmony_ci void (*conn_path_shutdown)(struct rds_conn_path *conn); 5498c2ecf20Sopenharmony_ci void (*xmit_path_prepare)(struct rds_conn_path *cp); 5508c2ecf20Sopenharmony_ci void (*xmit_path_complete)(struct rds_conn_path *cp); 5518c2ecf20Sopenharmony_ci int (*xmit)(struct rds_connection *conn, struct rds_message *rm, 5528c2ecf20Sopenharmony_ci unsigned int hdr_off, unsigned int sg, unsigned int off); 5538c2ecf20Sopenharmony_ci int (*xmit_rdma)(struct rds_connection *conn, struct rm_rdma_op *op); 5548c2ecf20Sopenharmony_ci int (*xmit_atomic)(struct rds_connection *conn, struct rm_atomic_op *op); 5558c2ecf20Sopenharmony_ci int (*recv_path)(struct rds_conn_path *cp); 5568c2ecf20Sopenharmony_ci int (*inc_copy_to_user)(struct rds_incoming *inc, struct iov_iter *to); 5578c2ecf20Sopenharmony_ci void (*inc_free)(struct rds_incoming *inc); 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci int (*cm_handle_connect)(struct rdma_cm_id *cm_id, 5608c2ecf20Sopenharmony_ci struct rdma_cm_event *event, bool isv6); 5618c2ecf20Sopenharmony_ci int (*cm_initiate_connect)(struct rdma_cm_id *cm_id, bool isv6); 5628c2ecf20Sopenharmony_ci void (*cm_connect_complete)(struct rds_connection *conn, 5638c2ecf20Sopenharmony_ci struct rdma_cm_event *event); 5648c2ecf20Sopenharmony_ci 5658c2ecf20Sopenharmony_ci unsigned int (*stats_info_copy)(struct rds_info_iterator *iter, 5668c2ecf20Sopenharmony_ci unsigned int avail); 5678c2ecf20Sopenharmony_ci void (*exit)(void); 5688c2ecf20Sopenharmony_ci void *(*get_mr)(struct scatterlist *sg, unsigned long nr_sg, 5698c2ecf20Sopenharmony_ci struct rds_sock *rs, u32 *key_ret, 5708c2ecf20Sopenharmony_ci struct rds_connection *conn, 5718c2ecf20Sopenharmony_ci u64 start, u64 length, int need_odp); 5728c2ecf20Sopenharmony_ci void (*sync_mr)(void *trans_private, int direction); 5738c2ecf20Sopenharmony_ci void (*free_mr)(void *trans_private, int invalidate); 5748c2ecf20Sopenharmony_ci void (*flush_mrs)(void); 5758c2ecf20Sopenharmony_ci bool (*t_unloading)(struct rds_connection *conn); 5768c2ecf20Sopenharmony_ci u8 (*get_tos_map)(u8 tos); 5778c2ecf20Sopenharmony_ci}; 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci/* Bind hash table key length. It is the sum of the size of a struct 5808c2ecf20Sopenharmony_ci * in6_addr, a scope_id and a port. 5818c2ecf20Sopenharmony_ci */ 5828c2ecf20Sopenharmony_ci#define RDS_BOUND_KEY_LEN \ 5838c2ecf20Sopenharmony_ci (sizeof(struct in6_addr) + sizeof(__u32) + sizeof(__be16)) 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_cistruct rds_sock { 5868c2ecf20Sopenharmony_ci struct sock rs_sk; 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci u64 rs_user_addr; 5898c2ecf20Sopenharmony_ci u64 rs_user_bytes; 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_ci /* 5928c2ecf20Sopenharmony_ci * bound_addr used for both incoming and outgoing, no INADDR_ANY 5938c2ecf20Sopenharmony_ci * support. 5948c2ecf20Sopenharmony_ci */ 5958c2ecf20Sopenharmony_ci struct rhash_head rs_bound_node; 5968c2ecf20Sopenharmony_ci u8 rs_bound_key[RDS_BOUND_KEY_LEN]; 5978c2ecf20Sopenharmony_ci struct sockaddr_in6 rs_bound_sin6; 5988c2ecf20Sopenharmony_ci#define rs_bound_addr rs_bound_sin6.sin6_addr 5998c2ecf20Sopenharmony_ci#define rs_bound_addr_v4 rs_bound_sin6.sin6_addr.s6_addr32[3] 6008c2ecf20Sopenharmony_ci#define rs_bound_port rs_bound_sin6.sin6_port 6018c2ecf20Sopenharmony_ci#define rs_bound_scope_id rs_bound_sin6.sin6_scope_id 6028c2ecf20Sopenharmony_ci struct in6_addr rs_conn_addr; 6038c2ecf20Sopenharmony_ci#define rs_conn_addr_v4 rs_conn_addr.s6_addr32[3] 6048c2ecf20Sopenharmony_ci __be16 rs_conn_port; 6058c2ecf20Sopenharmony_ci struct rds_transport *rs_transport; 6068c2ecf20Sopenharmony_ci 6078c2ecf20Sopenharmony_ci /* 6088c2ecf20Sopenharmony_ci * rds_sendmsg caches the conn it used the last time around. 6098c2ecf20Sopenharmony_ci * This helps avoid costly lookups. 6108c2ecf20Sopenharmony_ci */ 6118c2ecf20Sopenharmony_ci struct rds_connection *rs_conn; 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_ci /* flag indicating we were congested or not */ 6148c2ecf20Sopenharmony_ci int rs_congested; 6158c2ecf20Sopenharmony_ci /* seen congestion (ENOBUFS) when sending? */ 6168c2ecf20Sopenharmony_ci int rs_seen_congestion; 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_ci /* rs_lock protects all these adjacent members before the newline */ 6198c2ecf20Sopenharmony_ci spinlock_t rs_lock; 6208c2ecf20Sopenharmony_ci struct list_head rs_send_queue; 6218c2ecf20Sopenharmony_ci u32 rs_snd_bytes; 6228c2ecf20Sopenharmony_ci int rs_rcv_bytes; 6238c2ecf20Sopenharmony_ci struct list_head rs_notify_queue; /* currently used for failed RDMAs */ 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_ci /* Congestion wake_up. If rs_cong_monitor is set, we use cong_mask 6268c2ecf20Sopenharmony_ci * to decide whether the application should be woken up. 6278c2ecf20Sopenharmony_ci * If not set, we use rs_cong_track to find out whether a cong map 6288c2ecf20Sopenharmony_ci * update arrived. 6298c2ecf20Sopenharmony_ci */ 6308c2ecf20Sopenharmony_ci uint64_t rs_cong_mask; 6318c2ecf20Sopenharmony_ci uint64_t rs_cong_notify; 6328c2ecf20Sopenharmony_ci struct list_head rs_cong_list; 6338c2ecf20Sopenharmony_ci unsigned long rs_cong_track; 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_ci /* 6368c2ecf20Sopenharmony_ci * rs_recv_lock protects the receive queue, and is 6378c2ecf20Sopenharmony_ci * used to serialize with rds_release. 6388c2ecf20Sopenharmony_ci */ 6398c2ecf20Sopenharmony_ci rwlock_t rs_recv_lock; 6408c2ecf20Sopenharmony_ci struct list_head rs_recv_queue; 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_ci /* just for stats reporting */ 6438c2ecf20Sopenharmony_ci struct list_head rs_item; 6448c2ecf20Sopenharmony_ci 6458c2ecf20Sopenharmony_ci /* these have their own lock */ 6468c2ecf20Sopenharmony_ci spinlock_t rs_rdma_lock; 6478c2ecf20Sopenharmony_ci struct rb_root rs_rdma_keys; 6488c2ecf20Sopenharmony_ci 6498c2ecf20Sopenharmony_ci /* Socket options - in case there will be more */ 6508c2ecf20Sopenharmony_ci unsigned char rs_recverr, 6518c2ecf20Sopenharmony_ci rs_cong_monitor; 6528c2ecf20Sopenharmony_ci u32 rs_hash_initval; 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_ci /* Socket receive path trace points*/ 6558c2ecf20Sopenharmony_ci u8 rs_rx_traces; 6568c2ecf20Sopenharmony_ci u8 rs_rx_trace[RDS_MSG_RX_DGRAM_TRACE_MAX]; 6578c2ecf20Sopenharmony_ci struct rds_msg_zcopy_queue rs_zcookie_queue; 6588c2ecf20Sopenharmony_ci u8 rs_tos; 6598c2ecf20Sopenharmony_ci}; 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_cistatic inline struct rds_sock *rds_sk_to_rs(const struct sock *sk) 6628c2ecf20Sopenharmony_ci{ 6638c2ecf20Sopenharmony_ci return container_of(sk, struct rds_sock, rs_sk); 6648c2ecf20Sopenharmony_ci} 6658c2ecf20Sopenharmony_cistatic inline struct sock *rds_rs_to_sk(struct rds_sock *rs) 6668c2ecf20Sopenharmony_ci{ 6678c2ecf20Sopenharmony_ci return &rs->rs_sk; 6688c2ecf20Sopenharmony_ci} 6698c2ecf20Sopenharmony_ci 6708c2ecf20Sopenharmony_ci/* 6718c2ecf20Sopenharmony_ci * The stack assigns sk_sndbuf and sk_rcvbuf to twice the specified value 6728c2ecf20Sopenharmony_ci * to account for overhead. We don't account for overhead, we just apply 6738c2ecf20Sopenharmony_ci * the number of payload bytes to the specified value. 6748c2ecf20Sopenharmony_ci */ 6758c2ecf20Sopenharmony_cistatic inline int rds_sk_sndbuf(struct rds_sock *rs) 6768c2ecf20Sopenharmony_ci{ 6778c2ecf20Sopenharmony_ci return rds_rs_to_sk(rs)->sk_sndbuf / 2; 6788c2ecf20Sopenharmony_ci} 6798c2ecf20Sopenharmony_cistatic inline int rds_sk_rcvbuf(struct rds_sock *rs) 6808c2ecf20Sopenharmony_ci{ 6818c2ecf20Sopenharmony_ci return rds_rs_to_sk(rs)->sk_rcvbuf / 2; 6828c2ecf20Sopenharmony_ci} 6838c2ecf20Sopenharmony_ci 6848c2ecf20Sopenharmony_cistruct rds_statistics { 6858c2ecf20Sopenharmony_ci uint64_t s_conn_reset; 6868c2ecf20Sopenharmony_ci uint64_t s_recv_drop_bad_checksum; 6878c2ecf20Sopenharmony_ci uint64_t s_recv_drop_old_seq; 6888c2ecf20Sopenharmony_ci uint64_t s_recv_drop_no_sock; 6898c2ecf20Sopenharmony_ci uint64_t s_recv_drop_dead_sock; 6908c2ecf20Sopenharmony_ci uint64_t s_recv_deliver_raced; 6918c2ecf20Sopenharmony_ci uint64_t s_recv_delivered; 6928c2ecf20Sopenharmony_ci uint64_t s_recv_queued; 6938c2ecf20Sopenharmony_ci uint64_t s_recv_immediate_retry; 6948c2ecf20Sopenharmony_ci uint64_t s_recv_delayed_retry; 6958c2ecf20Sopenharmony_ci uint64_t s_recv_ack_required; 6968c2ecf20Sopenharmony_ci uint64_t s_recv_rdma_bytes; 6978c2ecf20Sopenharmony_ci uint64_t s_recv_ping; 6988c2ecf20Sopenharmony_ci uint64_t s_send_queue_empty; 6998c2ecf20Sopenharmony_ci uint64_t s_send_queue_full; 7008c2ecf20Sopenharmony_ci uint64_t s_send_lock_contention; 7018c2ecf20Sopenharmony_ci uint64_t s_send_lock_queue_raced; 7028c2ecf20Sopenharmony_ci uint64_t s_send_immediate_retry; 7038c2ecf20Sopenharmony_ci uint64_t s_send_delayed_retry; 7048c2ecf20Sopenharmony_ci uint64_t s_send_drop_acked; 7058c2ecf20Sopenharmony_ci uint64_t s_send_ack_required; 7068c2ecf20Sopenharmony_ci uint64_t s_send_queued; 7078c2ecf20Sopenharmony_ci uint64_t s_send_rdma; 7088c2ecf20Sopenharmony_ci uint64_t s_send_rdma_bytes; 7098c2ecf20Sopenharmony_ci uint64_t s_send_pong; 7108c2ecf20Sopenharmony_ci uint64_t s_page_remainder_hit; 7118c2ecf20Sopenharmony_ci uint64_t s_page_remainder_miss; 7128c2ecf20Sopenharmony_ci uint64_t s_copy_to_user; 7138c2ecf20Sopenharmony_ci uint64_t s_copy_from_user; 7148c2ecf20Sopenharmony_ci uint64_t s_cong_update_queued; 7158c2ecf20Sopenharmony_ci uint64_t s_cong_update_received; 7168c2ecf20Sopenharmony_ci uint64_t s_cong_send_error; 7178c2ecf20Sopenharmony_ci uint64_t s_cong_send_blocked; 7188c2ecf20Sopenharmony_ci uint64_t s_recv_bytes_added_to_socket; 7198c2ecf20Sopenharmony_ci uint64_t s_recv_bytes_removed_from_socket; 7208c2ecf20Sopenharmony_ci uint64_t s_send_stuck_rm; 7218c2ecf20Sopenharmony_ci}; 7228c2ecf20Sopenharmony_ci 7238c2ecf20Sopenharmony_ci/* af_rds.c */ 7248c2ecf20Sopenharmony_civoid rds_sock_addref(struct rds_sock *rs); 7258c2ecf20Sopenharmony_civoid rds_sock_put(struct rds_sock *rs); 7268c2ecf20Sopenharmony_civoid rds_wake_sk_sleep(struct rds_sock *rs); 7278c2ecf20Sopenharmony_cistatic inline void __rds_wake_sk_sleep(struct sock *sk) 7288c2ecf20Sopenharmony_ci{ 7298c2ecf20Sopenharmony_ci wait_queue_head_t *waitq = sk_sleep(sk); 7308c2ecf20Sopenharmony_ci 7318c2ecf20Sopenharmony_ci if (!sock_flag(sk, SOCK_DEAD) && waitq) 7328c2ecf20Sopenharmony_ci wake_up(waitq); 7338c2ecf20Sopenharmony_ci} 7348c2ecf20Sopenharmony_ciextern wait_queue_head_t rds_poll_waitq; 7358c2ecf20Sopenharmony_ci 7368c2ecf20Sopenharmony_ci 7378c2ecf20Sopenharmony_ci/* bind.c */ 7388c2ecf20Sopenharmony_ciint rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len); 7398c2ecf20Sopenharmony_civoid rds_remove_bound(struct rds_sock *rs); 7408c2ecf20Sopenharmony_cistruct rds_sock *rds_find_bound(const struct in6_addr *addr, __be16 port, 7418c2ecf20Sopenharmony_ci __u32 scope_id); 7428c2ecf20Sopenharmony_ciint rds_bind_lock_init(void); 7438c2ecf20Sopenharmony_civoid rds_bind_lock_destroy(void); 7448c2ecf20Sopenharmony_ci 7458c2ecf20Sopenharmony_ci/* cong.c */ 7468c2ecf20Sopenharmony_ciint rds_cong_get_maps(struct rds_connection *conn); 7478c2ecf20Sopenharmony_civoid rds_cong_add_conn(struct rds_connection *conn); 7488c2ecf20Sopenharmony_civoid rds_cong_remove_conn(struct rds_connection *conn); 7498c2ecf20Sopenharmony_civoid rds_cong_set_bit(struct rds_cong_map *map, __be16 port); 7508c2ecf20Sopenharmony_civoid rds_cong_clear_bit(struct rds_cong_map *map, __be16 port); 7518c2ecf20Sopenharmony_ciint rds_cong_wait(struct rds_cong_map *map, __be16 port, int nonblock, struct rds_sock *rs); 7528c2ecf20Sopenharmony_civoid rds_cong_queue_updates(struct rds_cong_map *map); 7538c2ecf20Sopenharmony_civoid rds_cong_map_updated(struct rds_cong_map *map, uint64_t); 7548c2ecf20Sopenharmony_ciint rds_cong_updated_since(unsigned long *recent); 7558c2ecf20Sopenharmony_civoid rds_cong_add_socket(struct rds_sock *); 7568c2ecf20Sopenharmony_civoid rds_cong_remove_socket(struct rds_sock *); 7578c2ecf20Sopenharmony_civoid rds_cong_exit(void); 7588c2ecf20Sopenharmony_cistruct rds_message *rds_cong_update_alloc(struct rds_connection *conn); 7598c2ecf20Sopenharmony_ci 7608c2ecf20Sopenharmony_ci/* connection.c */ 7618c2ecf20Sopenharmony_ciextern u32 rds_gen_num; 7628c2ecf20Sopenharmony_ciint rds_conn_init(void); 7638c2ecf20Sopenharmony_civoid rds_conn_exit(void); 7648c2ecf20Sopenharmony_cistruct rds_connection *rds_conn_create(struct net *net, 7658c2ecf20Sopenharmony_ci const struct in6_addr *laddr, 7668c2ecf20Sopenharmony_ci const struct in6_addr *faddr, 7678c2ecf20Sopenharmony_ci struct rds_transport *trans, 7688c2ecf20Sopenharmony_ci u8 tos, gfp_t gfp, 7698c2ecf20Sopenharmony_ci int dev_if); 7708c2ecf20Sopenharmony_cistruct rds_connection *rds_conn_create_outgoing(struct net *net, 7718c2ecf20Sopenharmony_ci const struct in6_addr *laddr, 7728c2ecf20Sopenharmony_ci const struct in6_addr *faddr, 7738c2ecf20Sopenharmony_ci struct rds_transport *trans, 7748c2ecf20Sopenharmony_ci u8 tos, gfp_t gfp, int dev_if); 7758c2ecf20Sopenharmony_civoid rds_conn_shutdown(struct rds_conn_path *cpath); 7768c2ecf20Sopenharmony_civoid rds_conn_destroy(struct rds_connection *conn); 7778c2ecf20Sopenharmony_civoid rds_conn_drop(struct rds_connection *conn); 7788c2ecf20Sopenharmony_civoid rds_conn_path_drop(struct rds_conn_path *cpath, bool destroy); 7798c2ecf20Sopenharmony_civoid rds_conn_connect_if_down(struct rds_connection *conn); 7808c2ecf20Sopenharmony_civoid rds_conn_path_connect_if_down(struct rds_conn_path *cp); 7818c2ecf20Sopenharmony_civoid rds_check_all_paths(struct rds_connection *conn); 7828c2ecf20Sopenharmony_civoid rds_for_each_conn_info(struct socket *sock, unsigned int len, 7838c2ecf20Sopenharmony_ci struct rds_info_iterator *iter, 7848c2ecf20Sopenharmony_ci struct rds_info_lengths *lens, 7858c2ecf20Sopenharmony_ci int (*visitor)(struct rds_connection *, void *), 7868c2ecf20Sopenharmony_ci u64 *buffer, 7878c2ecf20Sopenharmony_ci size_t item_len); 7888c2ecf20Sopenharmony_ci 7898c2ecf20Sopenharmony_ci__printf(2, 3) 7908c2ecf20Sopenharmony_civoid __rds_conn_path_error(struct rds_conn_path *cp, const char *, ...); 7918c2ecf20Sopenharmony_ci#define rds_conn_path_error(cp, fmt...) \ 7928c2ecf20Sopenharmony_ci __rds_conn_path_error(cp, KERN_WARNING "RDS: " fmt) 7938c2ecf20Sopenharmony_ci 7948c2ecf20Sopenharmony_cistatic inline int 7958c2ecf20Sopenharmony_cirds_conn_path_transition(struct rds_conn_path *cp, int old, int new) 7968c2ecf20Sopenharmony_ci{ 7978c2ecf20Sopenharmony_ci return atomic_cmpxchg(&cp->cp_state, old, new) == old; 7988c2ecf20Sopenharmony_ci} 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_cistatic inline int 8018c2ecf20Sopenharmony_cirds_conn_transition(struct rds_connection *conn, int old, int new) 8028c2ecf20Sopenharmony_ci{ 8038c2ecf20Sopenharmony_ci WARN_ON(conn->c_trans->t_mp_capable); 8048c2ecf20Sopenharmony_ci return rds_conn_path_transition(&conn->c_path[0], old, new); 8058c2ecf20Sopenharmony_ci} 8068c2ecf20Sopenharmony_ci 8078c2ecf20Sopenharmony_cistatic inline int 8088c2ecf20Sopenharmony_cirds_conn_path_state(struct rds_conn_path *cp) 8098c2ecf20Sopenharmony_ci{ 8108c2ecf20Sopenharmony_ci return atomic_read(&cp->cp_state); 8118c2ecf20Sopenharmony_ci} 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_cistatic inline int 8148c2ecf20Sopenharmony_cirds_conn_state(struct rds_connection *conn) 8158c2ecf20Sopenharmony_ci{ 8168c2ecf20Sopenharmony_ci WARN_ON(conn->c_trans->t_mp_capable); 8178c2ecf20Sopenharmony_ci return rds_conn_path_state(&conn->c_path[0]); 8188c2ecf20Sopenharmony_ci} 8198c2ecf20Sopenharmony_ci 8208c2ecf20Sopenharmony_cistatic inline int 8218c2ecf20Sopenharmony_cirds_conn_path_up(struct rds_conn_path *cp) 8228c2ecf20Sopenharmony_ci{ 8238c2ecf20Sopenharmony_ci return atomic_read(&cp->cp_state) == RDS_CONN_UP; 8248c2ecf20Sopenharmony_ci} 8258c2ecf20Sopenharmony_ci 8268c2ecf20Sopenharmony_cistatic inline int 8278c2ecf20Sopenharmony_cirds_conn_path_down(struct rds_conn_path *cp) 8288c2ecf20Sopenharmony_ci{ 8298c2ecf20Sopenharmony_ci return atomic_read(&cp->cp_state) == RDS_CONN_DOWN; 8308c2ecf20Sopenharmony_ci} 8318c2ecf20Sopenharmony_ci 8328c2ecf20Sopenharmony_cistatic inline int 8338c2ecf20Sopenharmony_cirds_conn_up(struct rds_connection *conn) 8348c2ecf20Sopenharmony_ci{ 8358c2ecf20Sopenharmony_ci WARN_ON(conn->c_trans->t_mp_capable); 8368c2ecf20Sopenharmony_ci return rds_conn_path_up(&conn->c_path[0]); 8378c2ecf20Sopenharmony_ci} 8388c2ecf20Sopenharmony_ci 8398c2ecf20Sopenharmony_cistatic inline int 8408c2ecf20Sopenharmony_cirds_conn_path_connecting(struct rds_conn_path *cp) 8418c2ecf20Sopenharmony_ci{ 8428c2ecf20Sopenharmony_ci return atomic_read(&cp->cp_state) == RDS_CONN_CONNECTING; 8438c2ecf20Sopenharmony_ci} 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_cistatic inline int 8468c2ecf20Sopenharmony_cirds_conn_connecting(struct rds_connection *conn) 8478c2ecf20Sopenharmony_ci{ 8488c2ecf20Sopenharmony_ci WARN_ON(conn->c_trans->t_mp_capable); 8498c2ecf20Sopenharmony_ci return rds_conn_path_connecting(&conn->c_path[0]); 8508c2ecf20Sopenharmony_ci} 8518c2ecf20Sopenharmony_ci 8528c2ecf20Sopenharmony_ci/* message.c */ 8538c2ecf20Sopenharmony_cistruct rds_message *rds_message_alloc(unsigned int nents, gfp_t gfp); 8548c2ecf20Sopenharmony_cistruct scatterlist *rds_message_alloc_sgs(struct rds_message *rm, int nents); 8558c2ecf20Sopenharmony_ciint rds_message_copy_from_user(struct rds_message *rm, struct iov_iter *from, 8568c2ecf20Sopenharmony_ci bool zcopy); 8578c2ecf20Sopenharmony_cistruct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned int total_len); 8588c2ecf20Sopenharmony_civoid rds_message_populate_header(struct rds_header *hdr, __be16 sport, 8598c2ecf20Sopenharmony_ci __be16 dport, u64 seq); 8608c2ecf20Sopenharmony_ciint rds_message_add_extension(struct rds_header *hdr, 8618c2ecf20Sopenharmony_ci unsigned int type, const void *data, unsigned int len); 8628c2ecf20Sopenharmony_ciint rds_message_next_extension(struct rds_header *hdr, 8638c2ecf20Sopenharmony_ci unsigned int *pos, void *buf, unsigned int *buflen); 8648c2ecf20Sopenharmony_ciint rds_message_add_rdma_dest_extension(struct rds_header *hdr, u32 r_key, u32 offset); 8658c2ecf20Sopenharmony_ciint rds_message_inc_copy_to_user(struct rds_incoming *inc, struct iov_iter *to); 8668c2ecf20Sopenharmony_civoid rds_message_inc_free(struct rds_incoming *inc); 8678c2ecf20Sopenharmony_civoid rds_message_addref(struct rds_message *rm); 8688c2ecf20Sopenharmony_civoid rds_message_put(struct rds_message *rm); 8698c2ecf20Sopenharmony_civoid rds_message_wait(struct rds_message *rm); 8708c2ecf20Sopenharmony_civoid rds_message_unmapped(struct rds_message *rm); 8718c2ecf20Sopenharmony_civoid rds_notify_msg_zcopy_purge(struct rds_msg_zcopy_queue *info); 8728c2ecf20Sopenharmony_ci 8738c2ecf20Sopenharmony_cistatic inline void rds_message_make_checksum(struct rds_header *hdr) 8748c2ecf20Sopenharmony_ci{ 8758c2ecf20Sopenharmony_ci hdr->h_csum = 0; 8768c2ecf20Sopenharmony_ci hdr->h_csum = ip_fast_csum((void *) hdr, sizeof(*hdr) >> 2); 8778c2ecf20Sopenharmony_ci} 8788c2ecf20Sopenharmony_ci 8798c2ecf20Sopenharmony_cistatic inline int rds_message_verify_checksum(const struct rds_header *hdr) 8808c2ecf20Sopenharmony_ci{ 8818c2ecf20Sopenharmony_ci return !hdr->h_csum || ip_fast_csum((void *) hdr, sizeof(*hdr) >> 2) == 0; 8828c2ecf20Sopenharmony_ci} 8838c2ecf20Sopenharmony_ci 8848c2ecf20Sopenharmony_ci 8858c2ecf20Sopenharmony_ci/* page.c */ 8868c2ecf20Sopenharmony_ciint rds_page_remainder_alloc(struct scatterlist *scat, unsigned long bytes, 8878c2ecf20Sopenharmony_ci gfp_t gfp); 8888c2ecf20Sopenharmony_civoid rds_page_exit(void); 8898c2ecf20Sopenharmony_ci 8908c2ecf20Sopenharmony_ci/* recv.c */ 8918c2ecf20Sopenharmony_civoid rds_inc_init(struct rds_incoming *inc, struct rds_connection *conn, 8928c2ecf20Sopenharmony_ci struct in6_addr *saddr); 8938c2ecf20Sopenharmony_civoid rds_inc_path_init(struct rds_incoming *inc, struct rds_conn_path *conn, 8948c2ecf20Sopenharmony_ci struct in6_addr *saddr); 8958c2ecf20Sopenharmony_civoid rds_inc_put(struct rds_incoming *inc); 8968c2ecf20Sopenharmony_civoid rds_recv_incoming(struct rds_connection *conn, struct in6_addr *saddr, 8978c2ecf20Sopenharmony_ci struct in6_addr *daddr, 8988c2ecf20Sopenharmony_ci struct rds_incoming *inc, gfp_t gfp); 8998c2ecf20Sopenharmony_ciint rds_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, 9008c2ecf20Sopenharmony_ci int msg_flags); 9018c2ecf20Sopenharmony_civoid rds_clear_recv_queue(struct rds_sock *rs); 9028c2ecf20Sopenharmony_ciint rds_notify_queue_get(struct rds_sock *rs, struct msghdr *msg); 9038c2ecf20Sopenharmony_civoid rds_inc_info_copy(struct rds_incoming *inc, 9048c2ecf20Sopenharmony_ci struct rds_info_iterator *iter, 9058c2ecf20Sopenharmony_ci __be32 saddr, __be32 daddr, int flip); 9068c2ecf20Sopenharmony_civoid rds6_inc_info_copy(struct rds_incoming *inc, 9078c2ecf20Sopenharmony_ci struct rds_info_iterator *iter, 9088c2ecf20Sopenharmony_ci struct in6_addr *saddr, struct in6_addr *daddr, 9098c2ecf20Sopenharmony_ci int flip); 9108c2ecf20Sopenharmony_ci 9118c2ecf20Sopenharmony_ci/* send.c */ 9128c2ecf20Sopenharmony_ciint rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len); 9138c2ecf20Sopenharmony_civoid rds_send_path_reset(struct rds_conn_path *conn); 9148c2ecf20Sopenharmony_ciint rds_send_xmit(struct rds_conn_path *cp); 9158c2ecf20Sopenharmony_cistruct sockaddr_in; 9168c2ecf20Sopenharmony_civoid rds_send_drop_to(struct rds_sock *rs, struct sockaddr_in6 *dest); 9178c2ecf20Sopenharmony_citypedef int (*is_acked_func)(struct rds_message *rm, uint64_t ack); 9188c2ecf20Sopenharmony_civoid rds_send_drop_acked(struct rds_connection *conn, u64 ack, 9198c2ecf20Sopenharmony_ci is_acked_func is_acked); 9208c2ecf20Sopenharmony_civoid rds_send_path_drop_acked(struct rds_conn_path *cp, u64 ack, 9218c2ecf20Sopenharmony_ci is_acked_func is_acked); 9228c2ecf20Sopenharmony_civoid rds_send_ping(struct rds_connection *conn, int cp_index); 9238c2ecf20Sopenharmony_ciint rds_send_pong(struct rds_conn_path *cp, __be16 dport); 9248c2ecf20Sopenharmony_ci 9258c2ecf20Sopenharmony_ci/* rdma.c */ 9268c2ecf20Sopenharmony_civoid rds_rdma_unuse(struct rds_sock *rs, u32 r_key, int force); 9278c2ecf20Sopenharmony_ciint rds_get_mr(struct rds_sock *rs, sockptr_t optval, int optlen); 9288c2ecf20Sopenharmony_ciint rds_get_mr_for_dest(struct rds_sock *rs, sockptr_t optval, int optlen); 9298c2ecf20Sopenharmony_ciint rds_free_mr(struct rds_sock *rs, sockptr_t optval, int optlen); 9308c2ecf20Sopenharmony_civoid rds_rdma_drop_keys(struct rds_sock *rs); 9318c2ecf20Sopenharmony_ciint rds_rdma_extra_size(struct rds_rdma_args *args, 9328c2ecf20Sopenharmony_ci struct rds_iov_vector *iov); 9338c2ecf20Sopenharmony_ciint rds_cmsg_rdma_dest(struct rds_sock *rs, struct rds_message *rm, 9348c2ecf20Sopenharmony_ci struct cmsghdr *cmsg); 9358c2ecf20Sopenharmony_ciint rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm, 9368c2ecf20Sopenharmony_ci struct cmsghdr *cmsg, 9378c2ecf20Sopenharmony_ci struct rds_iov_vector *vec); 9388c2ecf20Sopenharmony_ciint rds_cmsg_rdma_map(struct rds_sock *rs, struct rds_message *rm, 9398c2ecf20Sopenharmony_ci struct cmsghdr *cmsg); 9408c2ecf20Sopenharmony_civoid rds_rdma_free_op(struct rm_rdma_op *ro); 9418c2ecf20Sopenharmony_civoid rds_atomic_free_op(struct rm_atomic_op *ao); 9428c2ecf20Sopenharmony_civoid rds_rdma_send_complete(struct rds_message *rm, int wc_status); 9438c2ecf20Sopenharmony_civoid rds_atomic_send_complete(struct rds_message *rm, int wc_status); 9448c2ecf20Sopenharmony_ciint rds_cmsg_atomic(struct rds_sock *rs, struct rds_message *rm, 9458c2ecf20Sopenharmony_ci struct cmsghdr *cmsg); 9468c2ecf20Sopenharmony_ci 9478c2ecf20Sopenharmony_civoid __rds_put_mr_final(struct kref *kref); 9488c2ecf20Sopenharmony_ci 9498c2ecf20Sopenharmony_cistatic inline bool rds_destroy_pending(struct rds_connection *conn) 9508c2ecf20Sopenharmony_ci{ 9518c2ecf20Sopenharmony_ci return !check_net(rds_conn_net(conn)) || 9528c2ecf20Sopenharmony_ci (conn->c_trans->t_unloading && conn->c_trans->t_unloading(conn)); 9538c2ecf20Sopenharmony_ci} 9548c2ecf20Sopenharmony_ci 9558c2ecf20Sopenharmony_cienum { 9568c2ecf20Sopenharmony_ci ODP_NOT_NEEDED, 9578c2ecf20Sopenharmony_ci ODP_ZEROBASED, 9588c2ecf20Sopenharmony_ci ODP_VIRTUAL 9598c2ecf20Sopenharmony_ci}; 9608c2ecf20Sopenharmony_ci 9618c2ecf20Sopenharmony_ci/* stats.c */ 9628c2ecf20Sopenharmony_ciDECLARE_PER_CPU_SHARED_ALIGNED(struct rds_statistics, rds_stats); 9638c2ecf20Sopenharmony_ci#define rds_stats_inc_which(which, member) do { \ 9648c2ecf20Sopenharmony_ci per_cpu(which, get_cpu()).member++; \ 9658c2ecf20Sopenharmony_ci put_cpu(); \ 9668c2ecf20Sopenharmony_ci} while (0) 9678c2ecf20Sopenharmony_ci#define rds_stats_inc(member) rds_stats_inc_which(rds_stats, member) 9688c2ecf20Sopenharmony_ci#define rds_stats_add_which(which, member, count) do { \ 9698c2ecf20Sopenharmony_ci per_cpu(which, get_cpu()).member += count; \ 9708c2ecf20Sopenharmony_ci put_cpu(); \ 9718c2ecf20Sopenharmony_ci} while (0) 9728c2ecf20Sopenharmony_ci#define rds_stats_add(member, count) rds_stats_add_which(rds_stats, member, count) 9738c2ecf20Sopenharmony_ciint rds_stats_init(void); 9748c2ecf20Sopenharmony_civoid rds_stats_exit(void); 9758c2ecf20Sopenharmony_civoid rds_stats_info_copy(struct rds_info_iterator *iter, 9768c2ecf20Sopenharmony_ci uint64_t *values, const char *const *names, 9778c2ecf20Sopenharmony_ci size_t nr); 9788c2ecf20Sopenharmony_ci 9798c2ecf20Sopenharmony_ci/* sysctl.c */ 9808c2ecf20Sopenharmony_ciint rds_sysctl_init(void); 9818c2ecf20Sopenharmony_civoid rds_sysctl_exit(void); 9828c2ecf20Sopenharmony_ciextern unsigned long rds_sysctl_sndbuf_min; 9838c2ecf20Sopenharmony_ciextern unsigned long rds_sysctl_sndbuf_default; 9848c2ecf20Sopenharmony_ciextern unsigned long rds_sysctl_sndbuf_max; 9858c2ecf20Sopenharmony_ciextern unsigned long rds_sysctl_reconnect_min_jiffies; 9868c2ecf20Sopenharmony_ciextern unsigned long rds_sysctl_reconnect_max_jiffies; 9878c2ecf20Sopenharmony_ciextern unsigned int rds_sysctl_max_unacked_packets; 9888c2ecf20Sopenharmony_ciextern unsigned int rds_sysctl_max_unacked_bytes; 9898c2ecf20Sopenharmony_ciextern unsigned int rds_sysctl_ping_enable; 9908c2ecf20Sopenharmony_ciextern unsigned long rds_sysctl_trace_flags; 9918c2ecf20Sopenharmony_ciextern unsigned int rds_sysctl_trace_level; 9928c2ecf20Sopenharmony_ci 9938c2ecf20Sopenharmony_ci/* threads.c */ 9948c2ecf20Sopenharmony_ciint rds_threads_init(void); 9958c2ecf20Sopenharmony_civoid rds_threads_exit(void); 9968c2ecf20Sopenharmony_ciextern struct workqueue_struct *rds_wq; 9978c2ecf20Sopenharmony_civoid rds_queue_reconnect(struct rds_conn_path *cp); 9988c2ecf20Sopenharmony_civoid rds_connect_worker(struct work_struct *); 9998c2ecf20Sopenharmony_civoid rds_shutdown_worker(struct work_struct *); 10008c2ecf20Sopenharmony_civoid rds_send_worker(struct work_struct *); 10018c2ecf20Sopenharmony_civoid rds_recv_worker(struct work_struct *); 10028c2ecf20Sopenharmony_civoid rds_connect_path_complete(struct rds_conn_path *conn, int curr); 10038c2ecf20Sopenharmony_civoid rds_connect_complete(struct rds_connection *conn); 10048c2ecf20Sopenharmony_ciint rds_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2); 10058c2ecf20Sopenharmony_ci 10068c2ecf20Sopenharmony_ci/* transport.c */ 10078c2ecf20Sopenharmony_civoid rds_trans_register(struct rds_transport *trans); 10088c2ecf20Sopenharmony_civoid rds_trans_unregister(struct rds_transport *trans); 10098c2ecf20Sopenharmony_cistruct rds_transport *rds_trans_get_preferred(struct net *net, 10108c2ecf20Sopenharmony_ci const struct in6_addr *addr, 10118c2ecf20Sopenharmony_ci __u32 scope_id); 10128c2ecf20Sopenharmony_civoid rds_trans_put(struct rds_transport *trans); 10138c2ecf20Sopenharmony_ciunsigned int rds_trans_stats_info_copy(struct rds_info_iterator *iter, 10148c2ecf20Sopenharmony_ci unsigned int avail); 10158c2ecf20Sopenharmony_cistruct rds_transport *rds_trans_get(int t_type); 10168c2ecf20Sopenharmony_ciint rds_trans_init(void); 10178c2ecf20Sopenharmony_civoid rds_trans_exit(void); 10188c2ecf20Sopenharmony_ci 10198c2ecf20Sopenharmony_ci#endif 1020