18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _RDS_TCP_H 38c2ecf20Sopenharmony_ci#define _RDS_TCP_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#define RDS_TCP_PORT 16385 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_cistruct rds_tcp_incoming { 88c2ecf20Sopenharmony_ci struct rds_incoming ti_inc; 98c2ecf20Sopenharmony_ci struct sk_buff_head ti_skb_list; 108c2ecf20Sopenharmony_ci}; 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cistruct rds_tcp_connection { 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci struct list_head t_tcp_node; 158c2ecf20Sopenharmony_ci bool t_tcp_node_detached; 168c2ecf20Sopenharmony_ci struct rds_conn_path *t_cpath; 178c2ecf20Sopenharmony_ci /* t_conn_path_lock synchronizes the connection establishment between 188c2ecf20Sopenharmony_ci * rds_tcp_accept_one and rds_tcp_conn_path_connect 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci struct mutex t_conn_path_lock; 218c2ecf20Sopenharmony_ci struct socket *t_sock; 228c2ecf20Sopenharmony_ci void *t_orig_write_space; 238c2ecf20Sopenharmony_ci void *t_orig_data_ready; 248c2ecf20Sopenharmony_ci void *t_orig_state_change; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci struct rds_tcp_incoming *t_tinc; 278c2ecf20Sopenharmony_ci size_t t_tinc_hdr_rem; 288c2ecf20Sopenharmony_ci size_t t_tinc_data_rem; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci /* XXX error report? */ 318c2ecf20Sopenharmony_ci struct work_struct t_conn_w; 328c2ecf20Sopenharmony_ci struct work_struct t_send_w; 338c2ecf20Sopenharmony_ci struct work_struct t_down_w; 348c2ecf20Sopenharmony_ci struct work_struct t_recv_w; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci /* for info exporting only */ 378c2ecf20Sopenharmony_ci struct list_head t_list_item; 388c2ecf20Sopenharmony_ci u32 t_last_sent_nxt; 398c2ecf20Sopenharmony_ci u32 t_last_expected_una; 408c2ecf20Sopenharmony_ci u32 t_last_seen_una; 418c2ecf20Sopenharmony_ci}; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistruct rds_tcp_statistics { 448c2ecf20Sopenharmony_ci uint64_t s_tcp_data_ready_calls; 458c2ecf20Sopenharmony_ci uint64_t s_tcp_write_space_calls; 468c2ecf20Sopenharmony_ci uint64_t s_tcp_sndbuf_full; 478c2ecf20Sopenharmony_ci uint64_t s_tcp_connect_raced; 488c2ecf20Sopenharmony_ci uint64_t s_tcp_listen_closed_stale; 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/* tcp.c */ 528c2ecf20Sopenharmony_civoid rds_tcp_tune(struct socket *sock); 538c2ecf20Sopenharmony_civoid rds_tcp_set_callbacks(struct socket *sock, struct rds_conn_path *cp); 548c2ecf20Sopenharmony_civoid rds_tcp_reset_callbacks(struct socket *sock, struct rds_conn_path *cp); 558c2ecf20Sopenharmony_civoid rds_tcp_restore_callbacks(struct socket *sock, 568c2ecf20Sopenharmony_ci struct rds_tcp_connection *tc); 578c2ecf20Sopenharmony_ciu32 rds_tcp_write_seq(struct rds_tcp_connection *tc); 588c2ecf20Sopenharmony_ciu32 rds_tcp_snd_una(struct rds_tcp_connection *tc); 598c2ecf20Sopenharmony_ciu64 rds_tcp_map_seq(struct rds_tcp_connection *tc, u32 seq); 608c2ecf20Sopenharmony_ciextern struct rds_transport rds_tcp_transport; 618c2ecf20Sopenharmony_civoid rds_tcp_accept_work(struct sock *sk); 628c2ecf20Sopenharmony_ciint rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr, 638c2ecf20Sopenharmony_ci __u32 scope_id); 648c2ecf20Sopenharmony_ci/* tcp_connect.c */ 658c2ecf20Sopenharmony_ciint rds_tcp_conn_path_connect(struct rds_conn_path *cp); 668c2ecf20Sopenharmony_civoid rds_tcp_conn_path_shutdown(struct rds_conn_path *conn); 678c2ecf20Sopenharmony_civoid rds_tcp_state_change(struct sock *sk); 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* tcp_listen.c */ 708c2ecf20Sopenharmony_cistruct socket *rds_tcp_listen_init(struct net *net, bool isv6); 718c2ecf20Sopenharmony_civoid rds_tcp_listen_stop(struct socket *sock, struct work_struct *acceptor); 728c2ecf20Sopenharmony_civoid rds_tcp_listen_data_ready(struct sock *sk); 738c2ecf20Sopenharmony_ciint rds_tcp_accept_one(struct socket *sock); 748c2ecf20Sopenharmony_civoid rds_tcp_keepalive(struct socket *sock); 758c2ecf20Sopenharmony_civoid *rds_tcp_listen_sock_def_readable(struct net *net); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci/* tcp_recv.c */ 788c2ecf20Sopenharmony_ciint rds_tcp_recv_init(void); 798c2ecf20Sopenharmony_civoid rds_tcp_recv_exit(void); 808c2ecf20Sopenharmony_civoid rds_tcp_data_ready(struct sock *sk); 818c2ecf20Sopenharmony_ciint rds_tcp_recv_path(struct rds_conn_path *cp); 828c2ecf20Sopenharmony_civoid rds_tcp_inc_free(struct rds_incoming *inc); 838c2ecf20Sopenharmony_ciint rds_tcp_inc_copy_to_user(struct rds_incoming *inc, struct iov_iter *to); 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* tcp_send.c */ 868c2ecf20Sopenharmony_civoid rds_tcp_xmit_path_prepare(struct rds_conn_path *cp); 878c2ecf20Sopenharmony_civoid rds_tcp_xmit_path_complete(struct rds_conn_path *cp); 888c2ecf20Sopenharmony_ciint rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm, 898c2ecf20Sopenharmony_ci unsigned int hdr_off, unsigned int sg, unsigned int off); 908c2ecf20Sopenharmony_civoid rds_tcp_write_space(struct sock *sk); 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* tcp_stats.c */ 938c2ecf20Sopenharmony_ciDECLARE_PER_CPU(struct rds_tcp_statistics, rds_tcp_stats); 948c2ecf20Sopenharmony_ci#define rds_tcp_stats_inc(member) rds_stats_inc_which(rds_tcp_stats, member) 958c2ecf20Sopenharmony_ciunsigned int rds_tcp_stats_info_copy(struct rds_info_iterator *iter, 968c2ecf20Sopenharmony_ci unsigned int avail); 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#endif 99