blob: dc8d745d68575f019ca96c706efc77125552a5d2 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Andy Grover70041082009-08-21 12:28:31 +00002#ifndef _RDS_TCP_H
3#define _RDS_TCP_H
4
5#define RDS_TCP_PORT 16385
6
7struct rds_tcp_incoming {
8 struct rds_incoming ti_inc;
9 struct sk_buff_head ti_skb_list;
10};
11
12struct rds_tcp_connection {
13
14 struct list_head t_tcp_node;
Sowmini Varadhanf10b4cf2017-11-30 11:11:29 -080015 bool t_tcp_node_detached;
Sowmini Varadhan02105b22016-06-30 16:11:12 -070016 struct rds_conn_path *t_cpath;
17 /* t_conn_path_lock synchronizes the connection establishment between
Sowmini Varadhanb04e8552016-06-30 16:11:16 -070018 * rds_tcp_accept_one and rds_tcp_conn_path_connect
Sowmini Varadhanbd7c5f92016-05-02 11:24:52 -070019 */
Sowmini Varadhan02105b22016-06-30 16:11:12 -070020 struct mutex t_conn_path_lock;
Andy Grover70041082009-08-21 12:28:31 +000021 struct socket *t_sock;
22 void *t_orig_write_space;
23 void *t_orig_data_ready;
24 void *t_orig_state_change;
25
26 struct rds_tcp_incoming *t_tinc;
27 size_t t_tinc_hdr_rem;
28 size_t t_tinc_data_rem;
29
30 /* XXX error report? */
31 struct work_struct t_conn_w;
32 struct work_struct t_send_w;
33 struct work_struct t_down_w;
34 struct work_struct t_recv_w;
35
36 /* for info exporting only */
37 struct list_head t_list_item;
38 u32 t_last_sent_nxt;
39 u32 t_last_expected_una;
40 u32 t_last_seen_una;
41};
42
43struct rds_tcp_statistics {
44 uint64_t s_tcp_data_ready_calls;
45 uint64_t s_tcp_write_space_calls;
46 uint64_t s_tcp_sndbuf_full;
47 uint64_t s_tcp_connect_raced;
48 uint64_t s_tcp_listen_closed_stale;
49};
50
51/* tcp.c */
Andy Grover70041082009-08-21 12:28:31 +000052void rds_tcp_tune(struct socket *sock);
Sowmini Varadhanea3b1ea2016-06-30 16:11:14 -070053void rds_tcp_set_callbacks(struct socket *sock, struct rds_conn_path *cp);
54void rds_tcp_reset_callbacks(struct socket *sock, struct rds_conn_path *cp);
Andy Grover70041082009-08-21 12:28:31 +000055void rds_tcp_restore_callbacks(struct socket *sock,
56 struct rds_tcp_connection *tc);
Sowmini Varadhanb5895132018-01-18 13:11:07 -080057u32 rds_tcp_write_seq(struct rds_tcp_connection *tc);
Andy Grover70041082009-08-21 12:28:31 +000058u32 rds_tcp_snd_una(struct rds_tcp_connection *tc);
59u64 rds_tcp_map_seq(struct rds_tcp_connection *tc, u32 seq);
60extern struct rds_transport rds_tcp_transport;
Sowmini Varadhan467fa152015-08-05 01:43:26 -040061void rds_tcp_accept_work(struct sock *sk);
Rao Shoaibaced3ce52021-05-21 11:08:06 -070062int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr,
63 __u32 scope_id);
Andy Grover70041082009-08-21 12:28:31 +000064/* tcp_connect.c */
Sowmini Varadhanb04e8552016-06-30 16:11:16 -070065int rds_tcp_conn_path_connect(struct rds_conn_path *cp);
Sowmini Varadhan226f7a72016-06-30 16:11:10 -070066void rds_tcp_conn_path_shutdown(struct rds_conn_path *conn);
Andy Grover70041082009-08-21 12:28:31 +000067void rds_tcp_state_change(struct sock *sk);
68
69/* tcp_listen.c */
Ka-Cheong Poon1e2b44e2018-07-23 20:51:22 -070070struct socket *rds_tcp_listen_init(struct net *net, bool isv6);
Sowmini Varadhanb21dd452017-03-04 08:57:35 -080071void rds_tcp_listen_stop(struct socket *sock, struct work_struct *acceptor);
David S. Miller676d2362014-04-11 16:15:36 -040072void rds_tcp_listen_data_ready(struct sock *sk);
Sowmini Varadhan467fa152015-08-05 01:43:26 -040073int rds_tcp_accept_one(struct socket *sock);
Christoph Hellwig480aeb92020-05-28 07:12:25 +020074void rds_tcp_keepalive(struct socket *sock);
Sowmini Varadhana93d01f2016-07-14 03:51:01 -070075void *rds_tcp_listen_sock_def_readable(struct net *net);
Andy Grover70041082009-08-21 12:28:31 +000076
77/* tcp_recv.c */
Zach Brownef87b7e2010-07-09 12:26:20 -070078int rds_tcp_recv_init(void);
Andy Grover70041082009-08-21 12:28:31 +000079void rds_tcp_recv_exit(void);
David S. Miller676d2362014-04-11 16:15:36 -040080void rds_tcp_data_ready(struct sock *sk);
Sowmini Varadhan2da43c42016-06-30 16:11:15 -070081int rds_tcp_recv_path(struct rds_conn_path *cp);
Andy Grover70041082009-08-21 12:28:31 +000082void rds_tcp_inc_free(struct rds_incoming *inc);
Al Viroc310e722014-11-20 09:21:14 -050083int rds_tcp_inc_copy_to_user(struct rds_incoming *inc, struct iov_iter *to);
Andy Grover70041082009-08-21 12:28:31 +000084
85/* tcp_send.c */
Sowmini Varadhan226f7a72016-06-30 16:11:10 -070086void rds_tcp_xmit_path_prepare(struct rds_conn_path *cp);
87void rds_tcp_xmit_path_complete(struct rds_conn_path *cp);
Andy Grover70041082009-08-21 12:28:31 +000088int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm,
Joshua Houghton5c3da572016-06-18 15:46:31 +000089 unsigned int hdr_off, unsigned int sg, unsigned int off);
Andy Grover70041082009-08-21 12:28:31 +000090void rds_tcp_write_space(struct sock *sk);
Andy Grover70041082009-08-21 12:28:31 +000091
92/* tcp_stats.c */
93DECLARE_PER_CPU(struct rds_tcp_statistics, rds_tcp_stats);
94#define rds_tcp_stats_inc(member) rds_stats_inc_which(rds_tcp_stats, member)
95unsigned int rds_tcp_stats_info_copy(struct rds_info_iterator *iter,
96 unsigned int avail);
97
98#endif