Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 2 | #ifndef _RDS_TCP_H |
| 3 | #define _RDS_TCP_H |
| 4 | |
| 5 | #define RDS_TCP_PORT 16385 |
| 6 | |
| 7 | struct rds_tcp_incoming { |
| 8 | struct rds_incoming ti_inc; |
| 9 | struct sk_buff_head ti_skb_list; |
| 10 | }; |
| 11 | |
| 12 | struct rds_tcp_connection { |
| 13 | |
| 14 | struct list_head t_tcp_node; |
Sowmini Varadhan | f10b4cf | 2017-11-30 11:11:29 -0800 | [diff] [blame] | 15 | bool t_tcp_node_detached; |
Sowmini Varadhan | 02105b2 | 2016-06-30 16:11:12 -0700 | [diff] [blame] | 16 | struct rds_conn_path *t_cpath; |
| 17 | /* t_conn_path_lock synchronizes the connection establishment between |
Sowmini Varadhan | b04e855 | 2016-06-30 16:11:16 -0700 | [diff] [blame] | 18 | * rds_tcp_accept_one and rds_tcp_conn_path_connect |
Sowmini Varadhan | bd7c5f9 | 2016-05-02 11:24:52 -0700 | [diff] [blame] | 19 | */ |
Sowmini Varadhan | 02105b2 | 2016-06-30 16:11:12 -0700 | [diff] [blame] | 20 | struct mutex t_conn_path_lock; |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 21 | 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 | |
| 43 | struct 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 Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 52 | void rds_tcp_tune(struct socket *sock); |
Sowmini Varadhan | ea3b1ea | 2016-06-30 16:11:14 -0700 | [diff] [blame] | 53 | void rds_tcp_set_callbacks(struct socket *sock, struct rds_conn_path *cp); |
| 54 | void rds_tcp_reset_callbacks(struct socket *sock, struct rds_conn_path *cp); |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 55 | void rds_tcp_restore_callbacks(struct socket *sock, |
| 56 | struct rds_tcp_connection *tc); |
Sowmini Varadhan | b589513 | 2018-01-18 13:11:07 -0800 | [diff] [blame] | 57 | u32 rds_tcp_write_seq(struct rds_tcp_connection *tc); |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 58 | u32 rds_tcp_snd_una(struct rds_tcp_connection *tc); |
| 59 | u64 rds_tcp_map_seq(struct rds_tcp_connection *tc, u32 seq); |
| 60 | extern struct rds_transport rds_tcp_transport; |
Sowmini Varadhan | 467fa15 | 2015-08-05 01:43:26 -0400 | [diff] [blame] | 61 | void rds_tcp_accept_work(struct sock *sk); |
Rao Shoaib | aced3ce5 | 2021-05-21 11:08:06 -0700 | [diff] [blame] | 62 | int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr, |
| 63 | __u32 scope_id); |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 64 | /* tcp_connect.c */ |
Sowmini Varadhan | b04e855 | 2016-06-30 16:11:16 -0700 | [diff] [blame] | 65 | int rds_tcp_conn_path_connect(struct rds_conn_path *cp); |
Sowmini Varadhan | 226f7a7 | 2016-06-30 16:11:10 -0700 | [diff] [blame] | 66 | void rds_tcp_conn_path_shutdown(struct rds_conn_path *conn); |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 67 | void rds_tcp_state_change(struct sock *sk); |
| 68 | |
| 69 | /* tcp_listen.c */ |
Ka-Cheong Poon | 1e2b44e | 2018-07-23 20:51:22 -0700 | [diff] [blame] | 70 | struct socket *rds_tcp_listen_init(struct net *net, bool isv6); |
Sowmini Varadhan | b21dd45 | 2017-03-04 08:57:35 -0800 | [diff] [blame] | 71 | void rds_tcp_listen_stop(struct socket *sock, struct work_struct *acceptor); |
David S. Miller | 676d236 | 2014-04-11 16:15:36 -0400 | [diff] [blame] | 72 | void rds_tcp_listen_data_ready(struct sock *sk); |
Sowmini Varadhan | 467fa15 | 2015-08-05 01:43:26 -0400 | [diff] [blame] | 73 | int rds_tcp_accept_one(struct socket *sock); |
Christoph Hellwig | 480aeb9 | 2020-05-28 07:12:25 +0200 | [diff] [blame] | 74 | void rds_tcp_keepalive(struct socket *sock); |
Sowmini Varadhan | a93d01f | 2016-07-14 03:51:01 -0700 | [diff] [blame] | 75 | void *rds_tcp_listen_sock_def_readable(struct net *net); |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 76 | |
| 77 | /* tcp_recv.c */ |
Zach Brown | ef87b7e | 2010-07-09 12:26:20 -0700 | [diff] [blame] | 78 | int rds_tcp_recv_init(void); |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 79 | void rds_tcp_recv_exit(void); |
David S. Miller | 676d236 | 2014-04-11 16:15:36 -0400 | [diff] [blame] | 80 | void rds_tcp_data_ready(struct sock *sk); |
Sowmini Varadhan | 2da43c4 | 2016-06-30 16:11:15 -0700 | [diff] [blame] | 81 | int rds_tcp_recv_path(struct rds_conn_path *cp); |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 82 | void rds_tcp_inc_free(struct rds_incoming *inc); |
Al Viro | c310e72 | 2014-11-20 09:21:14 -0500 | [diff] [blame] | 83 | int rds_tcp_inc_copy_to_user(struct rds_incoming *inc, struct iov_iter *to); |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 84 | |
| 85 | /* tcp_send.c */ |
Sowmini Varadhan | 226f7a7 | 2016-06-30 16:11:10 -0700 | [diff] [blame] | 86 | void rds_tcp_xmit_path_prepare(struct rds_conn_path *cp); |
| 87 | void rds_tcp_xmit_path_complete(struct rds_conn_path *cp); |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 88 | int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm, |
Joshua Houghton | 5c3da57 | 2016-06-18 15:46:31 +0000 | [diff] [blame] | 89 | unsigned int hdr_off, unsigned int sg, unsigned int off); |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 90 | void rds_tcp_write_space(struct sock *sk); |
Andy Grover | 7004108 | 2009-08-21 12:28:31 +0000 | [diff] [blame] | 91 | |
| 92 | /* tcp_stats.c */ |
| 93 | DECLARE_PER_CPU(struct rds_tcp_statistics, rds_tcp_stats); |
| 94 | #define rds_tcp_stats_inc(member) rds_stats_inc_which(rds_tcp_stats, member) |
| 95 | unsigned int rds_tcp_stats_info_copy(struct rds_info_iterator *iter, |
| 96 | unsigned int avail); |
| 97 | |
| 98 | #endif |