rdsv3.h revision 6e18d381c642549b8bb1774a803d3510aec6baaf
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#ifndef _RDSV3_RDSV3_H
#define _RDSV3_RDSV3_H
/*
* The name of this file is rds.h in ofed.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/socketvar.h>
/*
* RDS Network protocol version
*/
#define RDS_PROTOCOL_3_0 0x0300
#define RDS_PROTOCOL_3_1 0x0301
#define RDS_PROTOCOL_VERSION RDS_PROTOCOL_3_1
#define RDS_PROTOCOL_MAJOR(v) ((v) >> 8)
#define RDS_PROTOCOL_MINOR(v) ((v) & 255)
/*
* XXX randomly chosen, but at least seems to be unused:
* # 18464-18768 Unassigned
* We should do better. We want a reserved port to discourage unpriv'ed
* userspace from listening.
*
* port 18633 was the version that had ack frames on the wire.
*/
#define RDSV3_PORT 18634
/*
* RDS trace facilities
*/
enum {
RDSV3_BIND = 0,
};
enum {
RDSV3_ALWAYS = 0,
};
/*
* This is the sad making. Some kernels have a bug in the per_cpu() api which
* makes DEFINE_PER_CPU trigger an oops on insmod because the per-cpu section
* in the module is not cacheline-aligned. As much as we'd like to tell users
* with older kernels to stuff it, that's not reasonable. We'll roll our own
* until this doesn't have to build against older kernels.
*/
static inline ulong_t
{
return ((x + y - 1) / y);
}
#define RDSV3_FRAG_SHIFT 12
#define RDSV3_CONG_MAP_LONGS (RDSV3_CONG_MAP_BYTES / sizeof (unsigned long))
struct rdsv3_cong_map {
struct list m_conn_list;
unsigned long m_page_addrs[RDSV3_CONG_MAP_PAGES];
};
/*
* This is how we will track the connection state:
* A connection is always in one of the following
* states. Updates to the state are atomic and imply
* a memory barrier.
*/
enum {
RDSV3_CONN_DOWN = 0,
};
/* Bits for c_flags */
#define RDSV3_LL_SEND_FULL 0
#define RDSV3_RECONNECT_PENDING 1
struct rdsv3_connection {
struct avl_node c_hash_node;
unsigned int c_loopback:1;
struct rdsv3_connection *c_passive;
struct rdsv3_cong_map *c_lcong;
struct rdsv3_cong_map *c_fcong;
struct rdsv3_message *c_xmit_rm;
unsigned long c_xmit_sg;
unsigned int c_xmit_hdr_off;
unsigned int c_xmit_data_off;
unsigned int c_xmit_rdma_sent;
struct list c_send_queue;
struct rdsv3_transport *c_trans;
void *c_transport_data;
unsigned long c_flags;
unsigned long c_reconnect_jiffies;
struct rdsv3_delayed_work_s c_send_w;
struct rdsv3_delayed_work_s c_recv_w;
struct rdsv3_delayed_work_s c_conn_w;
struct rdsv3_work_s c_down_w;
struct list_node c_map_item;
unsigned long c_map_queued;
unsigned long c_map_offset;
unsigned long c_map_bytes;
unsigned int c_unacked_packets;
unsigned int c_unacked_bytes;
/* Protocol version */
unsigned int c_version;
};
#define RDSV3_FLAG_CONG_BITMAP 0x01
#define RDSV3_FLAG_ACK_REQUIRED 0x02
#define RDSV3_FLAG_RETRANSMITTED 0x04
#define RDSV3_MAX_ADV_CREDIT 255
/*
* Maximum space available for extension headers.
*/
#define RDSV3_HEADER_EXT_SPACE 16
struct rdsv3_header {
};
/* Reserved - indicates end of extensions */
#define RDSV3_EXTHDR_NONE 0
/*
* This extension header is included in the very
* first message that is sent on a new connection,
* and identifies the protocol level. This will help
* rolling updates if a future change requires breaking
* the protocol.
*/
#define RDSV3_EXTHDR_VERSION 1
struct rdsv3_ext_header_version {
};
/*
* This extension header is included in the RDS message
* chasing an RDMA operation.
*/
#define RDSV3_EXTHDR_RDMA 2
struct rdsv3_ext_header_rdma {
};
/*
* This extension header tells the peer about the
* destination <R_Key,offset> of the requested RDMA
* operation.
*/
#define RDSV3_EXTHDR_RDMA_DEST 3
struct rdsv3_ext_header_rdma_dest {
};
struct rdsv3_incoming {
struct rdsv3_connection *i_conn;
struct rdsv3_header i_hdr;
unsigned long i_rx_jiffies;
};
/*
* m_sock_item and m_conn_item are on lists that are serialized under
* conn->c_lock. m_sock_item has additional meaning in that once it is empty
* the message will not be put back on the retransmit list after being sent.
* messages that are canceled while being sent rely on this.
*
* m_inc is used by loopback so that it can pass an incoming message straight
* back up into the rx path. It embeds a wire header which is also used by
* the send path, which is kind of awkward.
*
* m_sock_item indicates the message's presence on a socket's send or receive
* queue. m_rs will point to that socket.
*
* m_daddr is used by cancellation to prune messages to a given destination.
*
* The RDS_MSG_ON_SOCK and RDS_MSG_ON_CONN flags are used to avoid lock
* nesting. As paths iterate over messages on a sock, or conn, they must
* also lock the conn, or sock, to remove the message from those lists too.
* Testing the flag to determine if the message is still on the lists lets
* us avoid testing the list_head directly. That means each path can use
* the message's list_head to keep it on a local list while juggling locks
* without confusing the other path.
*
* m_ack_seq is an optional field set by transports who need a different
* sequence number range to invalidate. They can use this in a callback
* that they pass to rdsv3_send_drop_acked() to see if each message has been
* acked. The HAS_ACK_SEQ flag can be used to detect messages which haven't
* had ack_seq set yet.
*/
#define RDSV3_MSG_ON_SOCK 1
#define RDSV3_MSG_ON_CONN 2
#define RDSV3_MSG_HAS_ACK_SEQ 3
#define RDSV3_MSG_ACK_REQUIRED 4
#define RDSV3_MSG_RETRANSMITTED 5
#define RDSV3_MSG_MAPPED 6
#define RDSV3_MSG_PAGEVEC 7
struct rdsv3_message {
struct list_node m_sock_item;
struct list_node m_conn_item;
struct rdsv3_incoming m_inc;
unsigned long m_flags;
/*
* Never access m_rs without holding m_rs_lock.
* Lock nesting is
* rm->m_rs_lock
* -> rs->rs_lock
*/
struct rdsv3_sock *m_rs;
struct rdsv3_rdma_op *m_rdma_op;
unsigned int m_nents;
unsigned int m_count;
};
/*
* The RDS notifier is used (optionally) to tell the application about
* completed RDMA operations. Rather than keeping the whole rds message
* around on the queue, we allocate a small notifier that is put on the
* socket's notifier_list. Notifications are delivered to the application
* through control messages.
*/
struct rdsv3_notifier {
int n_status;
};
/*
* struct rdsv3_transport - transport specific behavioural hooks
*
* @xmit: .xmit is called by rdsv3_send_xmit() to tell the transport to send
* part of a message. The caller serializes on the send_sem so this
* doesn't need to be reentrant for a given conn. The header must be
* sent before the data payload. .xmit must be prepared to send a
* message with no data payload. .xmit should return the number of
* bytes that were sent down the connection, including header bytes.
* Returning 0 tells the caller that it doesn't need to perform any
* additional work now. This is usually the case when the transport has
* filled the sending queue for its connection and will handle
* triggering the rds thread to continue the send when space becomes
* available. Returning -EAGAIN tells the caller to retry the send
* immediately. Returning -ENOMEM tells the caller to retry the send at
* some point in the future.
*
* @conn_shutdown: conn_shutdown stops traffic on the given connection. Once
* it returns the connection can not call rdsv3_recv_incoming().
* This will only be called once after conn_connect returns
* non-zero success and will The caller serializes this with
* the send and connecting paths (xmit_* and conn_*). The
* transport is responsible for other serialization, including
* rdsv3_recv_incoming(). This is called in process context but
* should try hard not to block.
*
* @xmit_cong_map: This asks the transport to send the local bitmap down the
* given connection. XXX get a better story about the bitmap
* flag and header.
*/
struct rdsv3_transport {
char *t_name;
unsigned int t_prefer_loopback:1;
struct rdsv3_rdma_op *op);
struct rdma_cm_event *event);
struct rdma_cm_event *event);
unsigned int avail);
void (*exit)(void);
void (*flush_mrs)(void);
};
struct rdsv3_sock {
/*
* bound_addr used for both incoming and outgoing, no INADDR_ANY
* support.
*/
struct avl_node rs_bound_node;
/*
* This is only used to communicate the transport between bind and
* initiating connections. All other trans use is referenced through
* the connection.
*/
struct rdsv3_transport *rs_transport;
/*
* rdsv3_sendmsg caches the conn it used the last time around.
* This helps avoid costly lookups.
*/
struct rdsv3_connection *rs_conn;
/* flag indicating we were congested or not */
int rs_congested;
/* rs_lock protects all these adjacent members before the newline */
struct list rs_send_queue;
int rs_rcv_bytes;
/* currently used for failed RDMAs */
struct list rs_notify_queue;
/*
* Congestion wake_up. If rs_cong_monitor is set, we use cong_mask
* to decide whether the application should be woken up.
* If not set, we use rs_cong_track to find out whether a cong map
* update arrived.
*/
struct list_node rs_cong_list;
unsigned long rs_cong_track;
/*
* rs_recv_lock protects the receive queue, and is
* used to serialize with rdsv3_release.
*/
struct list rs_recv_queue;
/* just for stats reporting */
/* these have their own lock */
struct avl_tree rs_rdma_keys;
/* Socket options - in case there will be more */
unsigned char rs_recverr,
};
static inline struct rdsv3_sock *
{
}
static inline struct rsock *
{
}
/*
* The stack assigns sk_sndbuf and sk_rcvbuf to twice the specified value
* to account for overhead. We don't account for overhead, we just apply
* the number of payload bytes to the specified value.
*/
static inline int
{
/* XXX */
}
static inline int
{
/* XXX */
}
struct rdsv3_statistics {
};
/* af_rds.c */
/* bind.c */
/* conn.c */
int rdsv3_conn_init(void);
void rdsv3_conn_exit(void);
struct rdsv3_info_iterator *iter,
struct rdsv3_info_lengths *lens,
int (*visitor)(struct rdsv3_connection *, void *),
static inline int
{
}
static inline int
{
}
static inline int
{
}
static inline int
{
}
/* recv.c */
struct rdsv3_info_iterator *iter,
/* page.c */
/* send.c */
struct sockaddr_in;
struct rdsv3_rdma_op *);
/* rdma.c */
/* cong.c */
void rdsv3_cong_init(void);
struct rdsv3_sock *rs);
int rdsv3_cong_updated_since(unsigned long *recent);
void rdsv3_cong_add_socket(struct rdsv3_sock *);
void rdsv3_cong_remove_socket(struct rdsv3_sock *);
void rdsv3_cong_exit(void);
/* stats.c */
put_cpu(); \
} while (0)
put_cpu(); \
} while (0)
int rdsv3_stats_init(void);
void rdsv3_stats_exit(void);
/* sysctl.c */
int rdsv3_sysctl_init(void);
void rdsv3_sysctl_exit(void);
extern unsigned long rdsv3_sysctl_sndbuf_min;
extern unsigned long rdsv3_sysctl_sndbuf_default;
extern unsigned long rdsv3_sysctl_sndbuf_max;
extern unsigned long rdsv3_sysctl_reconnect_min_jiffies;
extern unsigned long rdsv3_sysctl_reconnect_max_jiffies;
extern unsigned int rdsv3_sysctl_max_unacked_packets;
extern unsigned int rdsv3_sysctl_max_unacked_bytes;
extern unsigned int rdsv3_sysctl_ping_enable;
extern unsigned long rdsv3_sysctl_trace_flags;
extern unsigned int rdsv3_sysctl_trace_level;
/* threads.c */
int rdsv3_threads_init();
void rdsv3_threads_exit(void);
extern struct rdsv3_workqueue_struct_s *rdsv3_wq;
void rdsv3_connect_worker(struct rdsv3_work_s *);
void rdsv3_shutdown_worker(struct rdsv3_work_s *);
void rdsv3_send_worker(struct rdsv3_work_s *);
void rdsv3_recv_worker(struct rdsv3_work_s *);
/* transport.c */
unsigned int avail);
void rdsv3_trans_exit(void);
/* message.c */
unsigned int total_len);
unsigned int version);
unsigned int *version);
static inline void
{
}
static inline int
{
}
/* rdsv3_sc.c */
#ifdef __cplusplus
}
#endif
#endif /* _RDSV3_RDSV3_H */