xref: /openbmc/linux/net/rxrpc/ar-internal.h (revision 70790dbe)
117926a79SDavid Howells /* AF_RXRPC internal definitions
217926a79SDavid Howells  *
317926a79SDavid Howells  * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
417926a79SDavid Howells  * Written by David Howells (dhowells@redhat.com)
517926a79SDavid Howells  *
617926a79SDavid Howells  * This program is free software; you can redistribute it and/or
717926a79SDavid Howells  * modify it under the terms of the GNU General Public License
817926a79SDavid Howells  * as published by the Free Software Foundation; either version
917926a79SDavid Howells  * 2 of the License, or (at your option) any later version.
1017926a79SDavid Howells  */
1117926a79SDavid Howells 
12be6e6707SDavid Howells #include <linux/atomic.h>
138496af50SDavid Howells #include <linux/seqlock.h>
14e0e4d82fSDavid Howells #include <net/sock.h>
15be6e6707SDavid Howells #include <net/af_rxrpc.h>
1617926a79SDavid Howells #include <rxrpc/packet.h>
1717926a79SDavid Howells 
1817926a79SDavid Howells #if 0
1917926a79SDavid Howells #define CHECK_SLAB_OKAY(X)				     \
2017926a79SDavid Howells 	BUG_ON(atomic_read((X)) >> (sizeof(atomic_t) - 2) == \
2117926a79SDavid Howells 	       (POISON_FREE << 8 | POISON_FREE))
2217926a79SDavid Howells #else
2317926a79SDavid Howells #define CHECK_SLAB_OKAY(X) do {} while (0)
2417926a79SDavid Howells #endif
2517926a79SDavid Howells 
2617926a79SDavid Howells #define FCRYPT_BSIZE 8
2717926a79SDavid Howells struct rxrpc_crypt {
2817926a79SDavid Howells 	union {
2917926a79SDavid Howells 		u8	x[FCRYPT_BSIZE];
3091e916cfSAl Viro 		__be32	n[2];
3117926a79SDavid Howells 	};
3217926a79SDavid Howells } __attribute__((aligned(8)));
3317926a79SDavid Howells 
34651350d1SDavid Howells #define rxrpc_queue_work(WS)	queue_work(rxrpc_workqueue, (WS))
35651350d1SDavid Howells #define rxrpc_queue_delayed_work(WS,D)	\
36651350d1SDavid Howells 	queue_delayed_work(rxrpc_workqueue, (WS), (D))
37651350d1SDavid Howells 
38cc8feb8eSDavid Howells struct rxrpc_connection;
39cc8feb8eSDavid Howells 
4017926a79SDavid Howells /*
41d001648eSDavid Howells  * Mark applied to socket buffers.
42d001648eSDavid Howells  */
43d001648eSDavid Howells enum rxrpc_skb_mark {
44d001648eSDavid Howells 	RXRPC_SKB_MARK_DATA,		/* data message */
45d001648eSDavid Howells 	RXRPC_SKB_MARK_FINAL_ACK,	/* final ACK received message */
46d001648eSDavid Howells 	RXRPC_SKB_MARK_BUSY,		/* server busy message */
47d001648eSDavid Howells 	RXRPC_SKB_MARK_REMOTE_ABORT,	/* remote abort message */
48d001648eSDavid Howells 	RXRPC_SKB_MARK_LOCAL_ABORT,	/* local abort message */
49d001648eSDavid Howells 	RXRPC_SKB_MARK_NET_ERROR,	/* network error message */
50d001648eSDavid Howells 	RXRPC_SKB_MARK_LOCAL_ERROR,	/* local error message */
51d001648eSDavid Howells 	RXRPC_SKB_MARK_NEW_CALL,	/* local error message */
52d001648eSDavid Howells };
53d001648eSDavid Howells 
54d001648eSDavid Howells /*
5517926a79SDavid Howells  * sk_state for RxRPC sockets
5617926a79SDavid Howells  */
5717926a79SDavid Howells enum {
582341e077SDavid Howells 	RXRPC_UNBOUND = 0,
592341e077SDavid Howells 	RXRPC_CLIENT_UNBOUND,		/* Unbound socket used as client */
6017926a79SDavid Howells 	RXRPC_CLIENT_BOUND,		/* client local address bound */
6117926a79SDavid Howells 	RXRPC_SERVER_BOUND,		/* server local address bound */
6217926a79SDavid Howells 	RXRPC_SERVER_LISTENING,		/* server listening for connections */
6317926a79SDavid Howells 	RXRPC_CLOSE,			/* socket is being closed */
6417926a79SDavid Howells };
6517926a79SDavid Howells 
6617926a79SDavid Howells /*
6700e90712SDavid Howells  * Service backlog preallocation.
6800e90712SDavid Howells  *
6900e90712SDavid Howells  * This contains circular buffers of preallocated peers, connections and calls
7000e90712SDavid Howells  * for incoming service calls and their head and tail pointers.  This allows
7100e90712SDavid Howells  * calls to be set up in the data_ready handler, thereby avoiding the need to
7200e90712SDavid Howells  * shuffle packets around so much.
7300e90712SDavid Howells  */
7400e90712SDavid Howells struct rxrpc_backlog {
7500e90712SDavid Howells 	unsigned short		peer_backlog_head;
7600e90712SDavid Howells 	unsigned short		peer_backlog_tail;
7700e90712SDavid Howells 	unsigned short		conn_backlog_head;
7800e90712SDavid Howells 	unsigned short		conn_backlog_tail;
7900e90712SDavid Howells 	unsigned short		call_backlog_head;
8000e90712SDavid Howells 	unsigned short		call_backlog_tail;
8100e90712SDavid Howells #define RXRPC_BACKLOG_MAX	32
8200e90712SDavid Howells 	struct rxrpc_peer	*peer_backlog[RXRPC_BACKLOG_MAX];
8300e90712SDavid Howells 	struct rxrpc_connection	*conn_backlog[RXRPC_BACKLOG_MAX];
8400e90712SDavid Howells 	struct rxrpc_call	*call_backlog[RXRPC_BACKLOG_MAX];
8500e90712SDavid Howells };
8600e90712SDavid Howells 
8700e90712SDavid Howells /*
8817926a79SDavid Howells  * RxRPC socket definition
8917926a79SDavid Howells  */
9017926a79SDavid Howells struct rxrpc_sock {
9117926a79SDavid Howells 	/* WARNING: sk has to be the first member */
9217926a79SDavid Howells 	struct sock		sk;
93d001648eSDavid Howells 	rxrpc_notify_new_call_t	notify_new_call; /* Func to notify of new call */
9400e90712SDavid Howells 	rxrpc_discard_new_call_t discard_new_call; /* Func to discard a new call */
9517926a79SDavid Howells 	struct rxrpc_local	*local;		/* local endpoint */
96de8d6c74SDavid Howells 	struct hlist_node	listen_link;	/* link in the local endpoint's listen list */
9700e90712SDavid Howells 	struct rxrpc_backlog	*backlog;	/* Preallocation for services */
98248f219cSDavid Howells 	spinlock_t		incoming_lock;	/* Incoming call vs service shutdown lock */
99248f219cSDavid Howells 	struct list_head	sock_calls;	/* List of calls owned by this socket */
100248f219cSDavid Howells 	struct list_head	to_be_accepted;	/* calls awaiting acceptance */
101248f219cSDavid Howells 	struct list_head	recvmsg_q;	/* Calls awaiting recvmsg's attention  */
102248f219cSDavid Howells 	rwlock_t		recvmsg_lock;	/* Lock for recvmsg_q */
10317926a79SDavid Howells 	struct key		*key;		/* security for this socket */
10417926a79SDavid Howells 	struct key		*securities;	/* list of server security descriptors */
10500e90712SDavid Howells 	struct rb_root		calls;		/* User ID -> call mapping */
10617926a79SDavid Howells 	unsigned long		flags;
1072341e077SDavid Howells #define RXRPC_SOCK_CONNECTED		0	/* connect_srx is set */
10817926a79SDavid Howells 	rwlock_t		call_lock;	/* lock for calls */
10917926a79SDavid Howells 	u32			min_sec_level;	/* minimum security level */
11017926a79SDavid Howells #define RXRPC_SECURITY_MAX	RXRPC_SECURITY_ENCRYPT
111cc8feb8eSDavid Howells 	bool			exclusive;	/* Exclusive connection for a client socket */
112cc8feb8eSDavid Howells 	sa_family_t		family;		/* Protocol family created with */
11317926a79SDavid Howells 	struct sockaddr_rxrpc	srx;		/* local address */
1142341e077SDavid Howells 	struct sockaddr_rxrpc	connect_srx;	/* Default client address from connect() */
11517926a79SDavid Howells };
11617926a79SDavid Howells 
11717926a79SDavid Howells #define rxrpc_sk(__sk) container_of((__sk), struct rxrpc_sock, sk)
11817926a79SDavid Howells 
11917926a79SDavid Howells /*
1200d12f8a4SDavid Howells  * CPU-byteorder normalised Rx packet header.
1210d12f8a4SDavid Howells  */
1220d12f8a4SDavid Howells struct rxrpc_host_header {
1230d12f8a4SDavid Howells 	u32		epoch;		/* client boot timestamp */
1240d12f8a4SDavid Howells 	u32		cid;		/* connection and channel ID */
1250d12f8a4SDavid Howells 	u32		callNumber;	/* call ID (0 for connection-level packets) */
1260d12f8a4SDavid Howells 	u32		seq;		/* sequence number of pkt in call stream */
1270d12f8a4SDavid Howells 	u32		serial;		/* serial number of pkt sent to network */
1280d12f8a4SDavid Howells 	u8		type;		/* packet type */
1290d12f8a4SDavid Howells 	u8		flags;		/* packet flags */
1300d12f8a4SDavid Howells 	u8		userStatus;	/* app-layer defined status */
1310d12f8a4SDavid Howells 	u8		securityIndex;	/* security protocol ID */
1320d12f8a4SDavid Howells 	union {
1330d12f8a4SDavid Howells 		u16	_rsvd;		/* reserved */
1340d12f8a4SDavid Howells 		u16	cksum;		/* kerberos security checksum */
1350d12f8a4SDavid Howells 	};
1360d12f8a4SDavid Howells 	u16		serviceId;	/* service ID */
1370d12f8a4SDavid Howells } __packed;
1380d12f8a4SDavid Howells 
1390d12f8a4SDavid Howells /*
14017926a79SDavid Howells  * RxRPC socket buffer private variables
14117926a79SDavid Howells  * - max 48 bytes (struct sk_buff::cb)
14217926a79SDavid Howells  */
14317926a79SDavid Howells struct rxrpc_skb_priv {
144248f219cSDavid Howells 	union {
145248f219cSDavid Howells 		u8		nr_jumbo;	/* Number of jumbo subpackets */
146248f219cSDavid Howells 	};
14717926a79SDavid Howells 	union {
14895c96174SEric Dumazet 		unsigned int	offset;		/* offset into buffer of next read */
14917926a79SDavid Howells 		int		remain;		/* amount of space remaining for next write */
15017926a79SDavid Howells 		u32		error;		/* network error code */
15117926a79SDavid Howells 	};
15217926a79SDavid Howells 
1530d12f8a4SDavid Howells 	struct rxrpc_host_header hdr;		/* RxRPC packet header from this packet */
15417926a79SDavid Howells };
15517926a79SDavid Howells 
15617926a79SDavid Howells #define rxrpc_skb(__skb) ((struct rxrpc_skb_priv *) &(__skb)->cb)
15717926a79SDavid Howells 
15817926a79SDavid Howells /*
15917926a79SDavid Howells  * RxRPC security module interface
16017926a79SDavid Howells  */
16117926a79SDavid Howells struct rxrpc_security {
16217926a79SDavid Howells 	const char		*name;		/* name of this service */
16317926a79SDavid Howells 	u8			security_index;	/* security type provided */
16417926a79SDavid Howells 
165648af7fcSDavid Howells 	/* Initialise a security service */
166648af7fcSDavid Howells 	int (*init)(void);
167648af7fcSDavid Howells 
168648af7fcSDavid Howells 	/* Clean up a security service */
169648af7fcSDavid Howells 	void (*exit)(void);
170648af7fcSDavid Howells 
17117926a79SDavid Howells 	/* initialise a connection's security */
17217926a79SDavid Howells 	int (*init_connection_security)(struct rxrpc_connection *);
17317926a79SDavid Howells 
17417926a79SDavid Howells 	/* prime a connection's packet security */
175a263629dSHerbert Xu 	int (*prime_packet_security)(struct rxrpc_connection *);
17617926a79SDavid Howells 
17717926a79SDavid Howells 	/* impose security on a packet */
178a263629dSHerbert Xu 	int (*secure_packet)(struct rxrpc_call *,
17917926a79SDavid Howells 			     struct sk_buff *,
18017926a79SDavid Howells 			     size_t,
18117926a79SDavid Howells 			     void *);
18217926a79SDavid Howells 
18317926a79SDavid Howells 	/* verify the security on a received packet */
1845a42976dSDavid Howells 	int (*verify_packet)(struct rxrpc_call *, struct sk_buff *,
185248f219cSDavid Howells 			     unsigned int, unsigned int, rxrpc_seq_t, u16);
186248f219cSDavid Howells 
187248f219cSDavid Howells 	/* Locate the data in a received packet that has been verified. */
188248f219cSDavid Howells 	void (*locate_data)(struct rxrpc_call *, struct sk_buff *,
189248f219cSDavid Howells 			    unsigned int *, unsigned int *);
19017926a79SDavid Howells 
19117926a79SDavid Howells 	/* issue a challenge */
19217926a79SDavid Howells 	int (*issue_challenge)(struct rxrpc_connection *);
19317926a79SDavid Howells 
19417926a79SDavid Howells 	/* respond to a challenge */
19517926a79SDavid Howells 	int (*respond_to_challenge)(struct rxrpc_connection *,
19617926a79SDavid Howells 				    struct sk_buff *,
19717926a79SDavid Howells 				    u32 *);
19817926a79SDavid Howells 
19917926a79SDavid Howells 	/* verify a response */
20017926a79SDavid Howells 	int (*verify_response)(struct rxrpc_connection *,
20117926a79SDavid Howells 			       struct sk_buff *,
20217926a79SDavid Howells 			       u32 *);
20317926a79SDavid Howells 
20417926a79SDavid Howells 	/* clear connection security */
20517926a79SDavid Howells 	void (*clear)(struct rxrpc_connection *);
20617926a79SDavid Howells };
20717926a79SDavid Howells 
20817926a79SDavid Howells /*
2094f95dd78SDavid Howells  * RxRPC local transport endpoint description
2104f95dd78SDavid Howells  * - owned by a single AF_RXRPC socket
2114f95dd78SDavid Howells  * - pointed to by transport socket struct sk_user_data
21217926a79SDavid Howells  */
21317926a79SDavid Howells struct rxrpc_local {
2144f95dd78SDavid Howells 	struct rcu_head		rcu;
2154f95dd78SDavid Howells 	atomic_t		usage;
2164f95dd78SDavid Howells 	struct list_head	link;
21717926a79SDavid Howells 	struct socket		*socket;	/* my UDP socket */
2184f95dd78SDavid Howells 	struct work_struct	processor;
219de8d6c74SDavid Howells 	struct hlist_head	services;	/* services listening on this endpoint */
22017926a79SDavid Howells 	struct rw_semaphore	defrag_sem;	/* control re-enablement of IP DF bit */
22117926a79SDavid Howells 	struct sk_buff_head	reject_queue;	/* packets awaiting rejection */
22244ba0698SDavid Howells 	struct sk_buff_head	event_queue;	/* endpoint event packets awaiting processing */
223999b69f8SDavid Howells 	struct rb_root		client_conns;	/* Client connections by socket params */
224999b69f8SDavid Howells 	spinlock_t		client_conns_lock; /* Lock for client_conns */
22517926a79SDavid Howells 	spinlock_t		lock;		/* access lock */
22617926a79SDavid Howells 	rwlock_t		services_lock;	/* lock for services list */
22717926a79SDavid Howells 	int			debug_id;	/* debug ID for printks */
2284f95dd78SDavid Howells 	bool			dead;
22917926a79SDavid Howells 	struct sockaddr_rxrpc	srx;		/* local address */
23017926a79SDavid Howells };
23117926a79SDavid Howells 
23217926a79SDavid Howells /*
23317926a79SDavid Howells  * RxRPC remote transport endpoint definition
234be6e6707SDavid Howells  * - matched by local endpoint, remote port, address and protocol type
23517926a79SDavid Howells  */
23617926a79SDavid Howells struct rxrpc_peer {
237be6e6707SDavid Howells 	struct rcu_head		rcu;		/* This must be first */
238be6e6707SDavid Howells 	atomic_t		usage;
239be6e6707SDavid Howells 	unsigned long		hash_key;
240be6e6707SDavid Howells 	struct hlist_node	hash_link;
241be6e6707SDavid Howells 	struct rxrpc_local	*local;
242f66d7490SDavid Howells 	struct hlist_head	error_targets;	/* targets for net error distribution */
243f66d7490SDavid Howells 	struct work_struct	error_distributor;
244aa390bbeSDavid Howells 	struct rb_root		service_conns;	/* Service connections */
2458496af50SDavid Howells 	seqlock_t		service_conn_lock;
24617926a79SDavid Howells 	spinlock_t		lock;		/* access lock */
24795c96174SEric Dumazet 	unsigned int		if_mtu;		/* interface MTU for this peer */
24895c96174SEric Dumazet 	unsigned int		mtu;		/* network MTU for this peer */
24995c96174SEric Dumazet 	unsigned int		maxdata;	/* data size (MTU - hdrsize) */
25017926a79SDavid Howells 	unsigned short		hdrsize;	/* header size (IP + UDP + RxRPC) */
25117926a79SDavid Howells 	int			debug_id;	/* debug ID for printks */
252f66d7490SDavid Howells 	int			error_report;	/* Net (+0) or local (+1000000) to distribute */
253f66d7490SDavid Howells #define RXRPC_LOCAL_ERROR_OFFSET 1000000
25417926a79SDavid Howells 	struct sockaddr_rxrpc	srx;		/* remote address */
25517926a79SDavid Howells 
25617926a79SDavid Howells 	/* calculated RTT cache */
25717926a79SDavid Howells #define RXRPC_RTT_CACHE_SIZE 32
2580d4b103cSDavid Howells 	ktime_t			rtt_last_req;	/* Time of last RTT request */
259cf1a6474SDavid Howells 	u64			rtt;		/* Current RTT estimate (in nS) */
260cf1a6474SDavid Howells 	u64			rtt_sum;	/* Sum of cache contents */
261cf1a6474SDavid Howells 	u64			rtt_cache[RXRPC_RTT_CACHE_SIZE]; /* Determined RTT cache */
262cf1a6474SDavid Howells 	u8			rtt_cursor;	/* next entry at which to insert */
263cf1a6474SDavid Howells 	u8			rtt_usage;	/* amount of cache actually used */
26417926a79SDavid Howells };
26517926a79SDavid Howells 
26617926a79SDavid Howells /*
26719ffa01cSDavid Howells  * Keys for matching a connection.
26819ffa01cSDavid Howells  */
26919ffa01cSDavid Howells struct rxrpc_conn_proto {
270e8d70ce1SDavid Howells 	union {
271e8d70ce1SDavid Howells 		struct {
27219ffa01cSDavid Howells 			u32	epoch;		/* epoch of this connection */
27319ffa01cSDavid Howells 			u32	cid;		/* connection ID */
274e8d70ce1SDavid Howells 		};
275e8d70ce1SDavid Howells 		u64		index_key;
27619ffa01cSDavid Howells 	};
27719ffa01cSDavid Howells };
27819ffa01cSDavid Howells 
27919ffa01cSDavid Howells struct rxrpc_conn_parameters {
28019ffa01cSDavid Howells 	struct rxrpc_local	*local;		/* Representation of local endpoint */
28119ffa01cSDavid Howells 	struct rxrpc_peer	*peer;		/* Remote endpoint */
28219ffa01cSDavid Howells 	struct key		*key;		/* Security details */
28319ffa01cSDavid Howells 	bool			exclusive;	/* T if conn is exclusive */
28419ffa01cSDavid Howells 	u16			service_id;	/* Service ID for this connection */
28519ffa01cSDavid Howells 	u32			security_level;	/* Security level selected */
28619ffa01cSDavid Howells };
28719ffa01cSDavid Howells 
28819ffa01cSDavid Howells /*
289bba304dbSDavid Howells  * Bits in the connection flags.
290bba304dbSDavid Howells  */
291bba304dbSDavid Howells enum rxrpc_conn_flag {
292bba304dbSDavid Howells 	RXRPC_CONN_HAS_IDR,		/* Has a client conn ID assigned */
293001c1122SDavid Howells 	RXRPC_CONN_IN_SERVICE_CONNS,	/* Conn is in peer->service_conns */
294001c1122SDavid Howells 	RXRPC_CONN_IN_CLIENT_CONNS,	/* Conn is in local->client_conns */
29545025bceSDavid Howells 	RXRPC_CONN_EXPOSED,		/* Conn has extra ref for exposure */
29645025bceSDavid Howells 	RXRPC_CONN_DONT_REUSE,		/* Don't reuse this connection */
29745025bceSDavid Howells 	RXRPC_CONN_COUNTED,		/* Counted by rxrpc_nr_client_conns */
298bba304dbSDavid Howells };
299bba304dbSDavid Howells 
300bba304dbSDavid Howells /*
301bba304dbSDavid Howells  * Events that can be raised upon a connection.
302bba304dbSDavid Howells  */
303bba304dbSDavid Howells enum rxrpc_conn_event {
304bba304dbSDavid Howells 	RXRPC_CONN_EV_CHALLENGE,	/* Send challenge packet */
305bba304dbSDavid Howells };
306bba304dbSDavid Howells 
307bba304dbSDavid Howells /*
30845025bceSDavid Howells  * The connection cache state.
30945025bceSDavid Howells  */
31045025bceSDavid Howells enum rxrpc_conn_cache_state {
31145025bceSDavid Howells 	RXRPC_CONN_CLIENT_INACTIVE,	/* Conn is not yet listed */
31245025bceSDavid Howells 	RXRPC_CONN_CLIENT_WAITING,	/* Conn is on wait list, waiting for capacity */
31345025bceSDavid Howells 	RXRPC_CONN_CLIENT_ACTIVE,	/* Conn is on active list, doing calls */
31445025bceSDavid Howells 	RXRPC_CONN_CLIENT_CULLED,	/* Conn is culled and delisted, doing calls */
31545025bceSDavid Howells 	RXRPC_CONN_CLIENT_IDLE,		/* Conn is on idle list, doing mostly nothing */
316363deeabSDavid Howells 	RXRPC_CONN__NR_CACHE_STATES
31745025bceSDavid Howells };
31845025bceSDavid Howells 
31945025bceSDavid Howells /*
320bba304dbSDavid Howells  * The connection protocol state.
321bba304dbSDavid Howells  */
322bba304dbSDavid Howells enum rxrpc_conn_proto_state {
323bba304dbSDavid Howells 	RXRPC_CONN_UNUSED,		/* Connection not yet attempted */
324bba304dbSDavid Howells 	RXRPC_CONN_CLIENT,		/* Client connection */
32500e90712SDavid Howells 	RXRPC_CONN_SERVICE_PREALLOC,	/* Service connection preallocation */
326bba304dbSDavid Howells 	RXRPC_CONN_SERVICE_UNSECURED,	/* Service unsecured connection */
327bba304dbSDavid Howells 	RXRPC_CONN_SERVICE_CHALLENGING,	/* Service challenging for security */
328bba304dbSDavid Howells 	RXRPC_CONN_SERVICE,		/* Service secured connection */
329bba304dbSDavid Howells 	RXRPC_CONN_REMOTELY_ABORTED,	/* Conn aborted by peer */
330bba304dbSDavid Howells 	RXRPC_CONN_LOCALLY_ABORTED,	/* Conn aborted locally */
331bba304dbSDavid Howells 	RXRPC_CONN__NR_STATES
332bba304dbSDavid Howells };
333bba304dbSDavid Howells 
334bba304dbSDavid Howells /*
33517926a79SDavid Howells  * RxRPC connection definition
336aa390bbeSDavid Howells  * - matched by { local, peer, epoch, conn_id, direction }
33717926a79SDavid Howells  * - each connection can only handle four simultaneous calls
33817926a79SDavid Howells  */
33917926a79SDavid Howells struct rxrpc_connection {
34019ffa01cSDavid Howells 	struct rxrpc_conn_proto	proto;
34119ffa01cSDavid Howells 	struct rxrpc_conn_parameters params;
34219ffa01cSDavid Howells 
34345025bceSDavid Howells 	atomic_t		usage;
34445025bceSDavid Howells 	struct rcu_head		rcu;
34545025bceSDavid Howells 	struct list_head	cache_link;
346a1399f8bSDavid Howells 
34745025bceSDavid Howells 	spinlock_t		channel_lock;
34845025bceSDavid Howells 	unsigned char		active_chans;	/* Mask of active channels */
34945025bceSDavid Howells #define RXRPC_ACTIVE_CHANS_MASK	((1 << RXRPC_MAXCALLS) - 1)
35045025bceSDavid Howells 	struct list_head	waiting_calls;	/* Calls waiting for channels */
351a1399f8bSDavid Howells 	struct rxrpc_channel {
352a1399f8bSDavid Howells 		struct rxrpc_call __rcu	*call;		/* Active call */
353a1399f8bSDavid Howells 		u32			call_id;	/* ID of current call */
354a1399f8bSDavid Howells 		u32			call_counter;	/* Call ID counter */
355a1399f8bSDavid Howells 		u32			last_call;	/* ID of last call */
35618bfeba5SDavid Howells 		u8			last_type;	/* Type of last packet */
35718bfeba5SDavid Howells 		u16			last_service_id;
35818bfeba5SDavid Howells 		union {
35918bfeba5SDavid Howells 			u32		last_seq;
36018bfeba5SDavid Howells 			u32		last_abort;
36118bfeba5SDavid Howells 		};
362a1399f8bSDavid Howells 	} channels[RXRPC_MAXCALLS];
363999b69f8SDavid Howells 
36417926a79SDavid Howells 	struct work_struct	processor;	/* connection event processor */
365999b69f8SDavid Howells 	union {
366999b69f8SDavid Howells 		struct rb_node	client_node;	/* Node in local->client_conns */
367aa390bbeSDavid Howells 		struct rb_node	service_node;	/* Node in peer->service_conns */
368999b69f8SDavid Howells 	};
3694d028b2cSDavid Howells 	struct list_head	proc_link;	/* link in procfs list */
37017926a79SDavid Howells 	struct list_head	link;		/* link in master connection list */
37117926a79SDavid Howells 	struct sk_buff_head	rx_queue;	/* received conn-level packets */
372648af7fcSDavid Howells 	const struct rxrpc_security *security;	/* applied security module */
37317926a79SDavid Howells 	struct key		*server_key;	/* security for this service */
3741afe593bSHerbert Xu 	struct crypto_skcipher	*cipher;	/* encryption handle */
37517926a79SDavid Howells 	struct rxrpc_crypt	csum_iv;	/* packet checksum base */
3764a3388c8SDavid Howells 	unsigned long		flags;
37717926a79SDavid Howells 	unsigned long		events;
378f51b4480SDavid Howells 	unsigned long		idle_timestamp;	/* Time at which last became idle */
37917926a79SDavid Howells 	spinlock_t		state_lock;	/* state-change lock */
380cf13258fSDavid Howells 	enum rxrpc_conn_cache_state cache_state;
381cf13258fSDavid Howells 	enum rxrpc_conn_proto_state state;	/* current state of connection */
382dc44b3a0SDavid Howells 	u32			local_abort;	/* local abort code */
383dc44b3a0SDavid Howells 	u32			remote_abort;	/* remote abort code */
38417926a79SDavid Howells 	int			debug_id;	/* debug ID for printks */
38517926a79SDavid Howells 	atomic_t		serial;		/* packet serial number counter */
386563ea7d5SDavid Howells 	unsigned int		hi_serial;	/* highest serial number received */
38717926a79SDavid Howells 	u32			security_nonce;	/* response re-use preventer */
3885a924b89SDavid Howells 	u8			size_align;	/* data size alignment (for security) */
3895a924b89SDavid Howells 	u8			security_size;	/* security header size */
39017926a79SDavid Howells 	u8			security_ix;	/* security type */
39117926a79SDavid Howells 	u8			out_clientflag;	/* RXRPC_CLIENT_INITIATED if we are client */
39217926a79SDavid Howells };
39317926a79SDavid Howells 
39417926a79SDavid Howells /*
3955b8848d1SDavid Howells  * Flags in call->flags.
3965b8848d1SDavid Howells  */
3975b8848d1SDavid Howells enum rxrpc_call_flag {
3985b8848d1SDavid Howells 	RXRPC_CALL_RELEASED,		/* call has been released - no more message to userspace */
3995b8848d1SDavid Howells 	RXRPC_CALL_HAS_USERID,		/* has a user ID attached */
400dabe5a79SDavid Howells 	RXRPC_CALL_IS_SERVICE,		/* Call is service call */
40145025bceSDavid Howells 	RXRPC_CALL_EXPOSED,		/* The call was exposed to the world */
402248f219cSDavid Howells 	RXRPC_CALL_RX_LAST,		/* Received the last packet (at rxtx_top) */
403248f219cSDavid Howells 	RXRPC_CALL_TX_LAST,		/* Last packet in Tx buffer (at rxtx_top) */
4048e83134dSDavid Howells 	RXRPC_CALL_PINGING,		/* Ping in process */
4055b8848d1SDavid Howells };
4065b8848d1SDavid Howells 
4075b8848d1SDavid Howells /*
4085b8848d1SDavid Howells  * Events that can be raised on a call.
4095b8848d1SDavid Howells  */
4105b8848d1SDavid Howells enum rxrpc_call_event {
4114c198ad1SDavid Howells 	RXRPC_CALL_EV_ACK,		/* need to generate ACK */
4124c198ad1SDavid Howells 	RXRPC_CALL_EV_ABORT,		/* need to generate abort */
413248f219cSDavid Howells 	RXRPC_CALL_EV_TIMER,		/* Timer expired */
4144c198ad1SDavid Howells 	RXRPC_CALL_EV_RESEND,		/* Tx resend required */
4155b8848d1SDavid Howells };
4165b8848d1SDavid Howells 
4175b8848d1SDavid Howells /*
4185b8848d1SDavid Howells  * The states that a call can be in.
4195b8848d1SDavid Howells  */
4205b8848d1SDavid Howells enum rxrpc_call_state {
421999b69f8SDavid Howells 	RXRPC_CALL_UNINITIALISED,
422999b69f8SDavid Howells 	RXRPC_CALL_CLIENT_AWAIT_CONN,	/* - client waiting for connection to become available */
4235b8848d1SDavid Howells 	RXRPC_CALL_CLIENT_SEND_REQUEST,	/* - client sending request phase */
4245b8848d1SDavid Howells 	RXRPC_CALL_CLIENT_AWAIT_REPLY,	/* - client awaiting reply */
4255b8848d1SDavid Howells 	RXRPC_CALL_CLIENT_RECV_REPLY,	/* - client receiving reply phase */
42600e90712SDavid Howells 	RXRPC_CALL_SERVER_PREALLOC,	/* - service preallocation */
4275b8848d1SDavid Howells 	RXRPC_CALL_SERVER_SECURING,	/* - server securing request connection */
4285b8848d1SDavid Howells 	RXRPC_CALL_SERVER_ACCEPTING,	/* - server accepting request */
4295b8848d1SDavid Howells 	RXRPC_CALL_SERVER_RECV_REQUEST,	/* - server receiving request */
4305b8848d1SDavid Howells 	RXRPC_CALL_SERVER_ACK_REQUEST,	/* - server pending ACK of request */
4315b8848d1SDavid Howells 	RXRPC_CALL_SERVER_SEND_REPLY,	/* - server sending reply */
4325b8848d1SDavid Howells 	RXRPC_CALL_SERVER_AWAIT_ACK,	/* - server awaiting final ACK */
433f5c17aaeSDavid Howells 	RXRPC_CALL_COMPLETE,		/* - call complete */
434f5c17aaeSDavid Howells 	NR__RXRPC_CALL_STATES
435f5c17aaeSDavid Howells };
436f5c17aaeSDavid Howells 
437f5c17aaeSDavid Howells /*
438f5c17aaeSDavid Howells  * Call completion condition (state == RXRPC_CALL_COMPLETE).
439f5c17aaeSDavid Howells  */
440f5c17aaeSDavid Howells enum rxrpc_call_completion {
441f5c17aaeSDavid Howells 	RXRPC_CALL_SUCCEEDED,		/* - Normal termination */
4425b8848d1SDavid Howells 	RXRPC_CALL_REMOTELY_ABORTED,	/* - call aborted by peer */
4435b8848d1SDavid Howells 	RXRPC_CALL_LOCALLY_ABORTED,	/* - call aborted locally on error or close */
444f5c17aaeSDavid Howells 	RXRPC_CALL_LOCAL_ERROR,		/* - call failed due to local error */
4455b8848d1SDavid Howells 	RXRPC_CALL_NETWORK_ERROR,	/* - call terminated by network error */
446f5c17aaeSDavid Howells 	NR__RXRPC_CALL_COMPLETIONS
4475b8848d1SDavid Howells };
4485b8848d1SDavid Howells 
4495b8848d1SDavid Howells /*
45017926a79SDavid Howells  * RxRPC call definition
45117926a79SDavid Howells  * - matched by { connection, call_id }
45217926a79SDavid Howells  */
45317926a79SDavid Howells struct rxrpc_call {
454dee46364SDavid Howells 	struct rcu_head		rcu;
45517926a79SDavid Howells 	struct rxrpc_connection	*conn;		/* connection carrying call */
456df5d8bf7SDavid Howells 	struct rxrpc_peer	*peer;		/* Peer record for remote address */
4578d94aa38SDavid Howells 	struct rxrpc_sock __rcu	*socket;	/* socket responsible */
458248f219cSDavid Howells 	unsigned long		ack_at;		/* When deferred ACK needs to happen */
459248f219cSDavid Howells 	unsigned long		resend_at;	/* When next resend needs to happen */
460248f219cSDavid Howells 	unsigned long		expire_at;	/* When the call times out */
461248f219cSDavid Howells 	struct timer_list	timer;		/* Combined event timer */
462248f219cSDavid Howells 	struct work_struct	processor;	/* Event processor */
463d001648eSDavid Howells 	rxrpc_notify_rx_t	notify_rx;	/* kernel service Rx notification function */
46417926a79SDavid Howells 	struct list_head	link;		/* link in master call list */
46545025bceSDavid Howells 	struct list_head	chan_wait_link;	/* Link in conn->waiting_calls */
466f66d7490SDavid Howells 	struct hlist_node	error_link;	/* link in error distribution list */
467248f219cSDavid Howells 	struct list_head	accept_link;	/* Link in rx->acceptq */
468248f219cSDavid Howells 	struct list_head	recvmsg_link;	/* Link in rx->recvmsg_q */
469248f219cSDavid Howells 	struct list_head	sock_link;	/* Link in rx->sock_calls */
470248f219cSDavid Howells 	struct rb_node		sock_node;	/* Node in rx->calls */
47117926a79SDavid Howells 	struct sk_buff		*tx_pending;	/* Tx socket buffer being filled */
47245025bceSDavid Howells 	wait_queue_head_t	waitq;		/* Wait queue for channel or Tx */
473a263629dSHerbert Xu 	__be32			crypto_buf[2];	/* Temporary packet crypto buffer */
47417926a79SDavid Howells 	unsigned long		user_call_ID;	/* user-defined call ID */
47517926a79SDavid Howells 	unsigned long		flags;
47617926a79SDavid Howells 	unsigned long		events;
47717926a79SDavid Howells 	spinlock_t		lock;
47817926a79SDavid Howells 	rwlock_t		state_lock;	/* lock for state transition */
479f5c17aaeSDavid Howells 	u32			abort_code;	/* Local/remote abort code */
480f5c17aaeSDavid Howells 	int			error;		/* Local error incurred */
481cf13258fSDavid Howells 	enum rxrpc_call_state	state;		/* current state of call */
482cf13258fSDavid Howells 	enum rxrpc_call_completion completion;	/* Call completion condition */
48317926a79SDavid Howells 	atomic_t		usage;
484dabe5a79SDavid Howells 	u16			service_id;	/* service ID */
485278ac0cdSDavid Howells 	u8			security_ix;	/* Security type */
486dabe5a79SDavid Howells 	u32			call_id;	/* call ID on connection  */
487dabe5a79SDavid Howells 	u32			cid;		/* connection ID plus channel index */
488dabe5a79SDavid Howells 	int			debug_id;	/* debug ID for printks */
4898e83134dSDavid Howells 	unsigned short		rx_pkt_offset;	/* Current recvmsg packet offset */
4908e83134dSDavid Howells 	unsigned short		rx_pkt_len;	/* Current recvmsg packet len */
49117926a79SDavid Howells 
492248f219cSDavid Howells 	/* Rx/Tx circular buffer, depending on phase.
493248f219cSDavid Howells 	 *
494248f219cSDavid Howells 	 * In the Rx phase, packets are annotated with 0 or the number of the
495248f219cSDavid Howells 	 * segment of a jumbo packet each buffer refers to.  There can be up to
496248f219cSDavid Howells 	 * 47 segments in a maximum-size UDP packet.
497248f219cSDavid Howells 	 *
498248f219cSDavid Howells 	 * In the Tx phase, packets are annotated with which buffers have been
499248f219cSDavid Howells 	 * acked.
50017926a79SDavid Howells 	 */
501248f219cSDavid Howells #define RXRPC_RXTX_BUFF_SIZE	64
502248f219cSDavid Howells #define RXRPC_RXTX_BUFF_MASK	(RXRPC_RXTX_BUFF_SIZE - 1)
50375e42126SDavid Howells #define RXRPC_INIT_RX_WINDOW_SIZE 32
504248f219cSDavid Howells 	struct sk_buff		**rxtx_buffer;
505248f219cSDavid Howells 	u8			*rxtx_annotations;
506248f219cSDavid Howells #define RXRPC_TX_ANNO_ACK	0
507248f219cSDavid Howells #define RXRPC_TX_ANNO_UNACK	1
508248f219cSDavid Howells #define RXRPC_TX_ANNO_NAK	2
509248f219cSDavid Howells #define RXRPC_TX_ANNO_RETRANS	3
510f07373eaSDavid Howells #define RXRPC_TX_ANNO_MASK	0x03
51170790dbeSDavid Howells #define RXRPC_TX_ANNO_LAST	0x04
51270790dbeSDavid Howells #define RXRPC_TX_ANNO_RESENT	0x08
51370790dbeSDavid Howells 
514248f219cSDavid Howells #define RXRPC_RX_ANNO_JUMBO	0x3f		/* Jumbo subpacket number + 1 if not zero */
515248f219cSDavid Howells #define RXRPC_RX_ANNO_JLAST	0x40		/* Set if last element of a jumbo packet */
516248f219cSDavid Howells #define RXRPC_RX_ANNO_VERIFIED	0x80		/* Set if verified and decrypted */
517248f219cSDavid Howells 	rxrpc_seq_t		tx_hard_ack;	/* Dead slot in buffer; the first transmitted but
518248f219cSDavid Howells 						 * not hard-ACK'd packet follows this.
519248f219cSDavid Howells 						 */
520248f219cSDavid Howells 	rxrpc_seq_t		tx_top;		/* Highest Tx slot allocated. */
521248f219cSDavid Howells 	rxrpc_seq_t		rx_hard_ack;	/* Dead slot in buffer; the first received but not
522248f219cSDavid Howells 						 * consumed packet follows this.
523248f219cSDavid Howells 						 */
524248f219cSDavid Howells 	rxrpc_seq_t		rx_top;		/* Highest Rx slot allocated. */
525248f219cSDavid Howells 	rxrpc_seq_t		rx_expect_next;	/* Expected next packet sequence number */
526248f219cSDavid Howells 	u8			rx_winsize;	/* Size of Rx window */
527248f219cSDavid Howells 	u8			tx_winsize;	/* Maximum size of Tx window */
52871f3ca40SDavid Howells 	bool			tx_phase;	/* T if transmission phase, F if receive phase */
52975e42126SDavid Howells 	u8			nr_jumbo_bad;	/* Number of jumbo dups/exceeds-windows */
53017926a79SDavid Howells 
53117926a79SDavid Howells 	/* receive-phase ACK management */
5324e36a95eSDavid Howells 	u8			ackr_reason;	/* reason to ACK */
533563ea7d5SDavid Howells 	u16			ackr_skew;	/* skew on packet being ACK'd */
5340d12f8a4SDavid Howells 	rxrpc_serial_t		ackr_serial;	/* serial of packet being ACK'd */
535248f219cSDavid Howells 	rxrpc_seq_t		ackr_prev_seq;	/* previous sequence number received */
5368e83134dSDavid Howells 	rxrpc_serial_t		ackr_ping;	/* Last ping sent */
5378e83134dSDavid Howells 	ktime_t			ackr_ping_time;	/* Time last ping sent */
53817926a79SDavid Howells 
539248f219cSDavid Howells 	/* transmission-phase ACK management */
540248f219cSDavid Howells 	rxrpc_serial_t		acks_latest;	/* serial number of latest ACK received */
54117926a79SDavid Howells };
54217926a79SDavid Howells 
54371f3ca40SDavid Howells enum rxrpc_skb_trace {
54471f3ca40SDavid Howells 	rxrpc_skb_rx_cleaned,
54571f3ca40SDavid Howells 	rxrpc_skb_rx_freed,
54671f3ca40SDavid Howells 	rxrpc_skb_rx_got,
54771f3ca40SDavid Howells 	rxrpc_skb_rx_lost,
54871f3ca40SDavid Howells 	rxrpc_skb_rx_received,
54971f3ca40SDavid Howells 	rxrpc_skb_rx_rotated,
55071f3ca40SDavid Howells 	rxrpc_skb_rx_purged,
55171f3ca40SDavid Howells 	rxrpc_skb_rx_seen,
55271f3ca40SDavid Howells 	rxrpc_skb_tx_cleaned,
55371f3ca40SDavid Howells 	rxrpc_skb_tx_freed,
55471f3ca40SDavid Howells 	rxrpc_skb_tx_got,
55571f3ca40SDavid Howells 	rxrpc_skb_tx_lost,
55671f3ca40SDavid Howells 	rxrpc_skb_tx_new,
55771f3ca40SDavid Howells 	rxrpc_skb_tx_rotated,
55871f3ca40SDavid Howells 	rxrpc_skb_tx_seen,
55971f3ca40SDavid Howells 	rxrpc_skb__nr_trace
56071f3ca40SDavid Howells };
56171f3ca40SDavid Howells 
56271f3ca40SDavid Howells extern const char rxrpc_skb_traces[rxrpc_skb__nr_trace][7];
56371f3ca40SDavid Howells 
564363deeabSDavid Howells enum rxrpc_conn_trace {
565363deeabSDavid Howells 	rxrpc_conn_new_client,
566363deeabSDavid Howells 	rxrpc_conn_new_service,
567363deeabSDavid Howells 	rxrpc_conn_queued,
568363deeabSDavid Howells 	rxrpc_conn_seen,
569363deeabSDavid Howells 	rxrpc_conn_got,
570363deeabSDavid Howells 	rxrpc_conn_put_client,
571363deeabSDavid Howells 	rxrpc_conn_put_service,
572363deeabSDavid Howells 	rxrpc_conn__nr_trace
573363deeabSDavid Howells };
574363deeabSDavid Howells 
575363deeabSDavid Howells extern const char rxrpc_conn_traces[rxrpc_conn__nr_trace][4];
576363deeabSDavid Howells 
577363deeabSDavid Howells enum rxrpc_client_trace {
578363deeabSDavid Howells 	rxrpc_client_activate_chans,
579363deeabSDavid Howells 	rxrpc_client_alloc,
580363deeabSDavid Howells 	rxrpc_client_chan_activate,
581363deeabSDavid Howells 	rxrpc_client_chan_disconnect,
582363deeabSDavid Howells 	rxrpc_client_chan_pass,
583363deeabSDavid Howells 	rxrpc_client_chan_unstarted,
584363deeabSDavid Howells 	rxrpc_client_cleanup,
585363deeabSDavid Howells 	rxrpc_client_count,
586363deeabSDavid Howells 	rxrpc_client_discard,
587363deeabSDavid Howells 	rxrpc_client_duplicate,
588363deeabSDavid Howells 	rxrpc_client_exposed,
589363deeabSDavid Howells 	rxrpc_client_replace,
590363deeabSDavid Howells 	rxrpc_client_to_active,
591363deeabSDavid Howells 	rxrpc_client_to_culled,
592363deeabSDavid Howells 	rxrpc_client_to_idle,
593363deeabSDavid Howells 	rxrpc_client_to_inactive,
594363deeabSDavid Howells 	rxrpc_client_to_waiting,
595363deeabSDavid Howells 	rxrpc_client_uncount,
596363deeabSDavid Howells 	rxrpc_client__nr_trace
597363deeabSDavid Howells };
598363deeabSDavid Howells 
599363deeabSDavid Howells extern const char rxrpc_client_traces[rxrpc_client__nr_trace][7];
600363deeabSDavid Howells extern const char rxrpc_conn_cache_states[RXRPC_CONN__NR_CACHE_STATES][5];
601363deeabSDavid Howells 
602fff72429SDavid Howells enum rxrpc_call_trace {
603fff72429SDavid Howells 	rxrpc_call_new_client,
604fff72429SDavid Howells 	rxrpc_call_new_service,
605fff72429SDavid Howells 	rxrpc_call_queued,
606fff72429SDavid Howells 	rxrpc_call_queued_ref,
607fff72429SDavid Howells 	rxrpc_call_seen,
608a84a46d7SDavid Howells 	rxrpc_call_connected,
609a84a46d7SDavid Howells 	rxrpc_call_release,
610fff72429SDavid Howells 	rxrpc_call_got,
611fff72429SDavid Howells 	rxrpc_call_got_userid,
612cbd00891SDavid Howells 	rxrpc_call_got_kernel,
613fff72429SDavid Howells 	rxrpc_call_put,
614fff72429SDavid Howells 	rxrpc_call_put_userid,
615cbd00891SDavid Howells 	rxrpc_call_put_kernel,
616fff72429SDavid Howells 	rxrpc_call_put_noqueue,
617a84a46d7SDavid Howells 	rxrpc_call_error,
618fff72429SDavid Howells 	rxrpc_call__nr_trace
619fff72429SDavid Howells };
620fff72429SDavid Howells 
621fff72429SDavid Howells extern const char rxrpc_call_traces[rxrpc_call__nr_trace][4];
622fff72429SDavid Howells 
623a124fe3eSDavid Howells enum rxrpc_transmit_trace {
624a124fe3eSDavid Howells 	rxrpc_transmit_wait,
625a124fe3eSDavid Howells 	rxrpc_transmit_queue,
626a124fe3eSDavid Howells 	rxrpc_transmit_queue_last,
627a124fe3eSDavid Howells 	rxrpc_transmit_rotate,
62870790dbeSDavid Howells 	rxrpc_transmit_rotate_last,
62970790dbeSDavid Howells 	rxrpc_transmit_await_reply,
630a124fe3eSDavid Howells 	rxrpc_transmit_end,
631a124fe3eSDavid Howells 	rxrpc_transmit__nr_trace
632a124fe3eSDavid Howells };
633a124fe3eSDavid Howells 
634a124fe3eSDavid Howells extern const char rxrpc_transmit_traces[rxrpc_transmit__nr_trace][4];
635a124fe3eSDavid Howells 
63658dc63c9SDavid Howells enum rxrpc_receive_trace {
63758dc63c9SDavid Howells 	rxrpc_receive_incoming,
63858dc63c9SDavid Howells 	rxrpc_receive_queue,
63958dc63c9SDavid Howells 	rxrpc_receive_queue_last,
64058dc63c9SDavid Howells 	rxrpc_receive_front,
64158dc63c9SDavid Howells 	rxrpc_receive_rotate,
64258dc63c9SDavid Howells 	rxrpc_receive_end,
64358dc63c9SDavid Howells 	rxrpc_receive__nr_trace
64458dc63c9SDavid Howells };
64558dc63c9SDavid Howells 
64658dc63c9SDavid Howells extern const char rxrpc_receive_traces[rxrpc_receive__nr_trace][4];
64758dc63c9SDavid Howells 
64884997905SDavid Howells enum rxrpc_recvmsg_trace {
64984997905SDavid Howells 	rxrpc_recvmsg_enter,
65084997905SDavid Howells 	rxrpc_recvmsg_wait,
65184997905SDavid Howells 	rxrpc_recvmsg_dequeue,
65284997905SDavid Howells 	rxrpc_recvmsg_hole,
65384997905SDavid Howells 	rxrpc_recvmsg_next,
65484997905SDavid Howells 	rxrpc_recvmsg_cont,
65584997905SDavid Howells 	rxrpc_recvmsg_full,
65684997905SDavid Howells 	rxrpc_recvmsg_data_return,
65784997905SDavid Howells 	rxrpc_recvmsg_terminal,
65884997905SDavid Howells 	rxrpc_recvmsg_to_be_accepted,
65984997905SDavid Howells 	rxrpc_recvmsg_return,
66084997905SDavid Howells 	rxrpc_recvmsg__nr_trace
66184997905SDavid Howells };
66284997905SDavid Howells 
66384997905SDavid Howells extern const char rxrpc_recvmsg_traces[rxrpc_recvmsg__nr_trace][5];
66484997905SDavid Howells 
665cf1a6474SDavid Howells enum rxrpc_rtt_tx_trace {
666cf1a6474SDavid Howells 	rxrpc_rtt_tx_ping,
66750235c4bSDavid Howells 	rxrpc_rtt_tx_data,
668cf1a6474SDavid Howells 	rxrpc_rtt_tx__nr_trace
669cf1a6474SDavid Howells };
670cf1a6474SDavid Howells 
671cf1a6474SDavid Howells extern const char rxrpc_rtt_tx_traces[rxrpc_rtt_tx__nr_trace][5];
672cf1a6474SDavid Howells 
673cf1a6474SDavid Howells enum rxrpc_rtt_rx_trace {
674cf1a6474SDavid Howells 	rxrpc_rtt_rx_ping_response,
67550235c4bSDavid Howells 	rxrpc_rtt_rx_requested_ack,
676cf1a6474SDavid Howells 	rxrpc_rtt_rx__nr_trace
677cf1a6474SDavid Howells };
678cf1a6474SDavid Howells 
679cf1a6474SDavid Howells extern const char rxrpc_rtt_rx_traces[rxrpc_rtt_rx__nr_trace][5];
680cf1a6474SDavid Howells 
681a3868bfcSDavid Howells extern const char *const rxrpc_pkts[];
682a3868bfcSDavid Howells extern const char *rxrpc_acks(u8 reason);
683a3868bfcSDavid Howells 
684df844fd4SDavid Howells #include <trace/events/rxrpc.h>
685df844fd4SDavid Howells 
68617926a79SDavid Howells /*
687651350d1SDavid Howells  * af_rxrpc.c
68817926a79SDavid Howells  */
68971f3ca40SDavid Howells extern atomic_t rxrpc_n_tx_skbs, rxrpc_n_rx_skbs;
6900d12f8a4SDavid Howells extern u32 rxrpc_epoch;
691651350d1SDavid Howells extern atomic_t rxrpc_debug_id;
692651350d1SDavid Howells extern struct workqueue_struct *rxrpc_workqueue;
69317926a79SDavid Howells 
69417926a79SDavid Howells /*
6950d81a51aSDavid Howells  * call_accept.c
69617926a79SDavid Howells  */
69700e90712SDavid Howells int rxrpc_service_prealloc(struct rxrpc_sock *, gfp_t);
69800e90712SDavid Howells void rxrpc_discard_prealloc(struct rxrpc_sock *);
699248f219cSDavid Howells struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *,
700248f219cSDavid Howells 					   struct rxrpc_connection *,
701248f219cSDavid Howells 					   struct sk_buff *);
7024f95dd78SDavid Howells void rxrpc_accept_incoming_calls(struct rxrpc_local *);
703d001648eSDavid Howells struct rxrpc_call *rxrpc_accept_call(struct rxrpc_sock *, unsigned long,
704d001648eSDavid Howells 				     rxrpc_notify_rx_t);
705c1b1203dSJoe Perches int rxrpc_reject_call(struct rxrpc_sock *);
70617926a79SDavid Howells 
70717926a79SDavid Howells /*
7080d81a51aSDavid Howells  * call_event.c
70917926a79SDavid Howells  */
710dfc3da44SDavid Howells void rxrpc_set_timer(struct rxrpc_call *);
711248f219cSDavid Howells void rxrpc_propose_ACK(struct rxrpc_call *, u8, u16, u32, bool, bool);
712c1b1203dSJoe Perches void rxrpc_process_call(struct work_struct *);
71317926a79SDavid Howells 
71417926a79SDavid Howells /*
7150d81a51aSDavid Howells  * call_object.c
71617926a79SDavid Howells  */
717f5c17aaeSDavid Howells extern const char *const rxrpc_call_states[];
718f5c17aaeSDavid Howells extern const char *const rxrpc_call_completions[];
719dad8aff7SDavid Howells extern unsigned int rxrpc_max_call_lifetime;
72017926a79SDavid Howells extern struct kmem_cache *rxrpc_call_jar;
72117926a79SDavid Howells extern struct list_head rxrpc_calls;
72217926a79SDavid Howells extern rwlock_t rxrpc_call_lock;
72317926a79SDavid Howells 
7242341e077SDavid Howells struct rxrpc_call *rxrpc_find_call_by_user_ID(struct rxrpc_sock *, unsigned long);
72500e90712SDavid Howells struct rxrpc_call *rxrpc_alloc_call(gfp_t);
7262341e077SDavid Howells struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *,
72719ffa01cSDavid Howells 					 struct rxrpc_conn_parameters *,
728999b69f8SDavid Howells 					 struct sockaddr_rxrpc *,
7292341e077SDavid Howells 					 unsigned long, gfp_t);
730248f219cSDavid Howells void rxrpc_incoming_call(struct rxrpc_sock *, struct rxrpc_call *,
73142886ffeSDavid Howells 			 struct sk_buff *);
7328d94aa38SDavid Howells void rxrpc_release_call(struct rxrpc_sock *, struct rxrpc_call *);
733c1b1203dSJoe Perches void rxrpc_release_calls_on_socket(struct rxrpc_sock *);
7348d94aa38SDavid Howells bool __rxrpc_queue_call(struct rxrpc_call *);
7358d94aa38SDavid Howells bool rxrpc_queue_call(struct rxrpc_call *);
736e34d4234SDavid Howells void rxrpc_see_call(struct rxrpc_call *);
737fff72429SDavid Howells void rxrpc_get_call(struct rxrpc_call *, enum rxrpc_call_trace);
738fff72429SDavid Howells void rxrpc_put_call(struct rxrpc_call *, enum rxrpc_call_trace);
73900e90712SDavid Howells void rxrpc_cleanup_call(struct rxrpc_call *);
740c1b1203dSJoe Perches void __exit rxrpc_destroy_all_calls(void);
74117926a79SDavid Howells 
742dabe5a79SDavid Howells static inline bool rxrpc_is_service_call(const struct rxrpc_call *call)
743dabe5a79SDavid Howells {
744dabe5a79SDavid Howells 	return test_bit(RXRPC_CALL_IS_SERVICE, &call->flags);
745dabe5a79SDavid Howells }
746dabe5a79SDavid Howells 
747dabe5a79SDavid Howells static inline bool rxrpc_is_client_call(const struct rxrpc_call *call)
748dabe5a79SDavid Howells {
749dabe5a79SDavid Howells 	return !rxrpc_is_service_call(call);
750dabe5a79SDavid Howells }
751dabe5a79SDavid Howells 
75217926a79SDavid Howells /*
753f5c17aaeSDavid Howells  * Transition a call to the complete state.
754f5c17aaeSDavid Howells  */
755f5c17aaeSDavid Howells static inline bool __rxrpc_set_call_completion(struct rxrpc_call *call,
756f5c17aaeSDavid Howells 					       enum rxrpc_call_completion compl,
757f5c17aaeSDavid Howells 					       u32 abort_code,
758f5c17aaeSDavid Howells 					       int error)
759f5c17aaeSDavid Howells {
760f5c17aaeSDavid Howells 	if (call->state < RXRPC_CALL_COMPLETE) {
761f5c17aaeSDavid Howells 		call->abort_code = abort_code;
762f5c17aaeSDavid Howells 		call->error = error;
763f5c17aaeSDavid Howells 		call->completion = compl,
764f5c17aaeSDavid Howells 		call->state = RXRPC_CALL_COMPLETE;
765c0d058c2SDavid Howells 		wake_up(&call->waitq);
766f5c17aaeSDavid Howells 		return true;
767f5c17aaeSDavid Howells 	}
768f5c17aaeSDavid Howells 	return false;
769f5c17aaeSDavid Howells }
770f5c17aaeSDavid Howells 
771f5c17aaeSDavid Howells static inline bool rxrpc_set_call_completion(struct rxrpc_call *call,
772f5c17aaeSDavid Howells 					     enum rxrpc_call_completion compl,
773f5c17aaeSDavid Howells 					     u32 abort_code,
774f5c17aaeSDavid Howells 					     int error)
775f5c17aaeSDavid Howells {
776e8d6bbb0SDavid Howells 	bool ret;
777f5c17aaeSDavid Howells 
778f5c17aaeSDavid Howells 	write_lock_bh(&call->state_lock);
779f5c17aaeSDavid Howells 	ret = __rxrpc_set_call_completion(call, compl, abort_code, error);
780f5c17aaeSDavid Howells 	write_unlock_bh(&call->state_lock);
781f5c17aaeSDavid Howells 	return ret;
782f5c17aaeSDavid Howells }
783f5c17aaeSDavid Howells 
784f5c17aaeSDavid Howells /*
785f5c17aaeSDavid Howells  * Record that a call successfully completed.
786f5c17aaeSDavid Howells  */
787e8d6bbb0SDavid Howells static inline bool __rxrpc_call_completed(struct rxrpc_call *call)
788f5c17aaeSDavid Howells {
789e8d6bbb0SDavid Howells 	return __rxrpc_set_call_completion(call, RXRPC_CALL_SUCCEEDED, 0, 0);
790f5c17aaeSDavid Howells }
791f5c17aaeSDavid Howells 
792e8d6bbb0SDavid Howells static inline bool rxrpc_call_completed(struct rxrpc_call *call)
793f5c17aaeSDavid Howells {
794e8d6bbb0SDavid Howells 	bool ret;
795e8d6bbb0SDavid Howells 
796f5c17aaeSDavid Howells 	write_lock_bh(&call->state_lock);
797e8d6bbb0SDavid Howells 	ret = __rxrpc_call_completed(call);
798f5c17aaeSDavid Howells 	write_unlock_bh(&call->state_lock);
799e8d6bbb0SDavid Howells 	return ret;
800f5c17aaeSDavid Howells }
801f5c17aaeSDavid Howells 
802f5c17aaeSDavid Howells /*
803f5c17aaeSDavid Howells  * Record that a call is locally aborted.
804f5c17aaeSDavid Howells  */
8055a42976dSDavid Howells static inline bool __rxrpc_abort_call(const char *why, struct rxrpc_call *call,
8065a42976dSDavid Howells 				      rxrpc_seq_t seq,
807f5c17aaeSDavid Howells 				      u32 abort_code, int error)
808f5c17aaeSDavid Howells {
8095a42976dSDavid Howells 	trace_rxrpc_abort(why, call->cid, call->call_id, seq,
8105a42976dSDavid Howells 			  abort_code, error);
811248f219cSDavid Howells 	return __rxrpc_set_call_completion(call, RXRPC_CALL_LOCALLY_ABORTED,
812248f219cSDavid Howells 					   abort_code, error);
813f5c17aaeSDavid Howells }
814f5c17aaeSDavid Howells 
8155a42976dSDavid Howells static inline bool rxrpc_abort_call(const char *why, struct rxrpc_call *call,
8165a42976dSDavid Howells 				    rxrpc_seq_t seq, u32 abort_code, int error)
817f5c17aaeSDavid Howells {
818f5c17aaeSDavid Howells 	bool ret;
819f5c17aaeSDavid Howells 
820f5c17aaeSDavid Howells 	write_lock_bh(&call->state_lock);
8215a42976dSDavid Howells 	ret = __rxrpc_abort_call(why, call, seq, abort_code, error);
822f5c17aaeSDavid Howells 	write_unlock_bh(&call->state_lock);
823f5c17aaeSDavid Howells 	return ret;
824f5c17aaeSDavid Howells }
825f5c17aaeSDavid Howells 
826f5c17aaeSDavid Howells /*
8274a3388c8SDavid Howells  * conn_client.c
8284a3388c8SDavid Howells  */
82945025bceSDavid Howells extern unsigned int rxrpc_max_client_connections;
83045025bceSDavid Howells extern unsigned int rxrpc_reap_client_connections;
83145025bceSDavid Howells extern unsigned int rxrpc_conn_idle_client_expiry;
83245025bceSDavid Howells extern unsigned int rxrpc_conn_idle_client_fast_expiry;
8334a3388c8SDavid Howells extern struct idr rxrpc_client_conn_ids;
8344a3388c8SDavid Howells 
835eb9b9d22SDavid Howells void rxrpc_destroy_client_conn_ids(void);
836c6d2b8d7SDavid Howells int rxrpc_connect_call(struct rxrpc_call *, struct rxrpc_conn_parameters *,
837c6d2b8d7SDavid Howells 		       struct sockaddr_rxrpc *, gfp_t);
83845025bceSDavid Howells void rxrpc_expose_client_call(struct rxrpc_call *);
83945025bceSDavid Howells void rxrpc_disconnect_client_call(struct rxrpc_call *);
84045025bceSDavid Howells void rxrpc_put_client_conn(struct rxrpc_connection *);
84145025bceSDavid Howells void __exit rxrpc_destroy_all_client_connections(void);
8424a3388c8SDavid Howells 
8434a3388c8SDavid Howells /*
8440d81a51aSDavid Howells  * conn_event.c
8450d81a51aSDavid Howells  */
8460d81a51aSDavid Howells void rxrpc_process_connection(struct work_struct *);
8470d81a51aSDavid Howells 
8480d81a51aSDavid Howells /*
8490d81a51aSDavid Howells  * conn_object.c
85017926a79SDavid Howells  */
851dad8aff7SDavid Howells extern unsigned int rxrpc_connection_expiry;
85217926a79SDavid Howells extern struct list_head rxrpc_connections;
8534d028b2cSDavid Howells extern struct list_head rxrpc_connection_proc_list;
85417926a79SDavid Howells extern rwlock_t rxrpc_connection_lock;
85517926a79SDavid Howells 
8568496af50SDavid Howells int rxrpc_extract_addr_from_skb(struct sockaddr_rxrpc *, struct sk_buff *);
857c6d2b8d7SDavid Howells struct rxrpc_connection *rxrpc_alloc_connection(gfp_t);
8588496af50SDavid Howells struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *,
859aa390bbeSDavid Howells 						   struct sk_buff *);
86045025bceSDavid Howells void __rxrpc_disconnect_call(struct rxrpc_connection *, struct rxrpc_call *);
861999b69f8SDavid Howells void rxrpc_disconnect_call(struct rxrpc_call *);
86245025bceSDavid Howells void rxrpc_kill_connection(struct rxrpc_connection *);
863363deeabSDavid Howells bool rxrpc_queue_conn(struct rxrpc_connection *);
864363deeabSDavid Howells void rxrpc_see_connection(struct rxrpc_connection *);
865363deeabSDavid Howells void rxrpc_get_connection(struct rxrpc_connection *);
866363deeabSDavid Howells struct rxrpc_connection *rxrpc_get_connection_maybe(struct rxrpc_connection *);
867363deeabSDavid Howells void rxrpc_put_service_conn(struct rxrpc_connection *);
868c1b1203dSJoe Perches void __exit rxrpc_destroy_all_connections(void);
86917926a79SDavid Howells 
87019ffa01cSDavid Howells static inline bool rxrpc_conn_is_client(const struct rxrpc_connection *conn)
87119ffa01cSDavid Howells {
87219ffa01cSDavid Howells 	return conn->out_clientflag;
87319ffa01cSDavid Howells }
87419ffa01cSDavid Howells 
87519ffa01cSDavid Howells static inline bool rxrpc_conn_is_service(const struct rxrpc_connection *conn)
87619ffa01cSDavid Howells {
877e8d70ce1SDavid Howells 	return !rxrpc_conn_is_client(conn);
87819ffa01cSDavid Howells }
87919ffa01cSDavid Howells 
880f51b4480SDavid Howells static inline void rxrpc_put_connection(struct rxrpc_connection *conn)
881f51b4480SDavid Howells {
88245025bceSDavid Howells 	if (!conn)
88345025bceSDavid Howells 		return;
88445025bceSDavid Howells 
885363deeabSDavid Howells 	if (rxrpc_conn_is_client(conn))
88645025bceSDavid Howells 		rxrpc_put_client_conn(conn);
887363deeabSDavid Howells 	else
888363deeabSDavid Howells 		rxrpc_put_service_conn(conn);
8895acbee46SDavid Howells }
8905acbee46SDavid Howells 
89117926a79SDavid Howells /*
8927877a4a4SDavid Howells  * conn_service.c
8937877a4a4SDavid Howells  */
8948496af50SDavid Howells struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *,
8958496af50SDavid Howells 						     struct sk_buff *);
89600e90712SDavid Howells struct rxrpc_connection *rxrpc_prealloc_service_connection(gfp_t);
897248f219cSDavid Howells void rxrpc_new_incoming_connection(struct rxrpc_connection *, struct sk_buff *);
898001c1122SDavid Howells void rxrpc_unpublish_service_conn(struct rxrpc_connection *);
8997877a4a4SDavid Howells 
9007877a4a4SDavid Howells /*
9010d81a51aSDavid Howells  * input.c
90217926a79SDavid Howells  */
903676d2369SDavid S. Miller void rxrpc_data_ready(struct sock *);
90417926a79SDavid Howells 
90517926a79SDavid Howells /*
9060d81a51aSDavid Howells  * insecure.c
90717926a79SDavid Howells  */
9080d81a51aSDavid Howells extern const struct rxrpc_security rxrpc_no_security;
90917926a79SDavid Howells 
91017926a79SDavid Howells /*
9110d81a51aSDavid Howells  * key.c
91217926a79SDavid Howells  */
91317926a79SDavid Howells extern struct key_type key_type_rxrpc;
91417926a79SDavid Howells extern struct key_type key_type_rxrpc_s;
91517926a79SDavid Howells 
916c1b1203dSJoe Perches int rxrpc_request_key(struct rxrpc_sock *, char __user *, int);
917c1b1203dSJoe Perches int rxrpc_server_keyring(struct rxrpc_sock *, char __user *, int);
918c1b1203dSJoe Perches int rxrpc_get_server_data_key(struct rxrpc_connection *, const void *, time_t,
919c1b1203dSJoe Perches 			      u32);
92017926a79SDavid Howells 
92117926a79SDavid Howells /*
92287563616SDavid Howells  * local_event.c
92387563616SDavid Howells  */
9244f95dd78SDavid Howells extern void rxrpc_process_local_events(struct rxrpc_local *);
92587563616SDavid Howells 
92687563616SDavid Howells /*
9270d81a51aSDavid Howells  * local_object.c
92817926a79SDavid Howells  */
9294f95dd78SDavid Howells struct rxrpc_local *rxrpc_lookup_local(const struct sockaddr_rxrpc *);
9304f95dd78SDavid Howells void __rxrpc_put_local(struct rxrpc_local *);
9310d81a51aSDavid Howells void __exit rxrpc_destroy_all_locals(void);
932e0e4d82fSDavid Howells 
9334f95dd78SDavid Howells static inline void rxrpc_get_local(struct rxrpc_local *local)
9344f95dd78SDavid Howells {
9354f95dd78SDavid Howells 	atomic_inc(&local->usage);
9364f95dd78SDavid Howells }
9374f95dd78SDavid Howells 
9384f95dd78SDavid Howells static inline
9394f95dd78SDavid Howells struct rxrpc_local *rxrpc_get_local_maybe(struct rxrpc_local *local)
9404f95dd78SDavid Howells {
9414f95dd78SDavid Howells 	return atomic_inc_not_zero(&local->usage) ? local : NULL;
9424f95dd78SDavid Howells }
9434f95dd78SDavid Howells 
9444f95dd78SDavid Howells static inline void rxrpc_put_local(struct rxrpc_local *local)
9454f95dd78SDavid Howells {
9465627cc8bSDavid Howells 	if (local && atomic_dec_and_test(&local->usage))
9474f95dd78SDavid Howells 		__rxrpc_put_local(local);
9484f95dd78SDavid Howells }
9494f95dd78SDavid Howells 
9505acbee46SDavid Howells static inline void rxrpc_queue_local(struct rxrpc_local *local)
9515acbee46SDavid Howells {
9525acbee46SDavid Howells 	rxrpc_queue_work(&local->processor);
9535acbee46SDavid Howells }
9545acbee46SDavid Howells 
955e0e4d82fSDavid Howells /*
9568e688d9cSDavid Howells  * misc.c
9578e688d9cSDavid Howells  */
9580e119b41SDavid Howells extern unsigned int rxrpc_max_backlog __read_mostly;
9598e688d9cSDavid Howells extern unsigned int rxrpc_requested_ack_delay;
9608e688d9cSDavid Howells extern unsigned int rxrpc_soft_ack_delay;
9618e688d9cSDavid Howells extern unsigned int rxrpc_idle_ack_delay;
9628e688d9cSDavid Howells extern unsigned int rxrpc_rx_window_size;
9638e688d9cSDavid Howells extern unsigned int rxrpc_rx_mtu;
9648e688d9cSDavid Howells extern unsigned int rxrpc_rx_jumbo_max;
9650b58b8a1SDavid Howells extern unsigned int rxrpc_resend_timeout;
9668e688d9cSDavid Howells 
9678e688d9cSDavid Howells extern const s8 rxrpc_ack_priority[];
9688e688d9cSDavid Howells 
9698e688d9cSDavid Howells /*
9700d81a51aSDavid Howells  * output.c
9710d81a51aSDavid Howells  */
9728d94aa38SDavid Howells int rxrpc_send_call_packet(struct rxrpc_call *, u8);
9735a924b89SDavid Howells int rxrpc_send_data_packet(struct rxrpc_call *, struct sk_buff *);
974248f219cSDavid Howells void rxrpc_reject_packets(struct rxrpc_local *);
9750d81a51aSDavid Howells 
9760d81a51aSDavid Howells /*
977abe89ef0SDavid Howells  * peer_event.c
9780d81a51aSDavid Howells  */
979abe89ef0SDavid Howells void rxrpc_error_report(struct sock *);
980f66d7490SDavid Howells void rxrpc_peer_error_distributor(struct work_struct *);
981cf1a6474SDavid Howells void rxrpc_peer_add_rtt(struct rxrpc_call *, enum rxrpc_rtt_rx_trace,
982cf1a6474SDavid Howells 			rxrpc_serial_t, rxrpc_serial_t, ktime_t, ktime_t);
9830d81a51aSDavid Howells 
9840d81a51aSDavid Howells /*
9850d81a51aSDavid Howells  * peer_object.c
9860d81a51aSDavid Howells  */
987be6e6707SDavid Howells struct rxrpc_peer *rxrpc_lookup_peer_rcu(struct rxrpc_local *,
988be6e6707SDavid Howells 					 const struct sockaddr_rxrpc *);
989be6e6707SDavid Howells struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_local *,
990be6e6707SDavid Howells 				     struct sockaddr_rxrpc *, gfp_t);
991be6e6707SDavid Howells struct rxrpc_peer *rxrpc_alloc_peer(struct rxrpc_local *, gfp_t);
992248f219cSDavid Howells struct rxrpc_peer *rxrpc_lookup_incoming_peer(struct rxrpc_local *,
993248f219cSDavid Howells 					      struct rxrpc_peer *);
994be6e6707SDavid Howells 
995df5d8bf7SDavid Howells static inline struct rxrpc_peer *rxrpc_get_peer(struct rxrpc_peer *peer)
996be6e6707SDavid Howells {
997be6e6707SDavid Howells 	atomic_inc(&peer->usage);
998df5d8bf7SDavid Howells 	return peer;
999be6e6707SDavid Howells }
1000be6e6707SDavid Howells 
1001be6e6707SDavid Howells static inline
1002be6e6707SDavid Howells struct rxrpc_peer *rxrpc_get_peer_maybe(struct rxrpc_peer *peer)
1003be6e6707SDavid Howells {
1004be6e6707SDavid Howells 	return atomic_inc_not_zero(&peer->usage) ? peer : NULL;
1005be6e6707SDavid Howells }
1006be6e6707SDavid Howells 
1007be6e6707SDavid Howells extern void __rxrpc_put_peer(struct rxrpc_peer *peer);
1008be6e6707SDavid Howells static inline void rxrpc_put_peer(struct rxrpc_peer *peer)
1009be6e6707SDavid Howells {
10105627cc8bSDavid Howells 	if (peer && atomic_dec_and_test(&peer->usage))
1011be6e6707SDavid Howells 		__rxrpc_put_peer(peer);
1012be6e6707SDavid Howells }
10130d81a51aSDavid Howells 
10140d81a51aSDavid Howells /*
10150d81a51aSDavid Howells  * proc.c
10160d81a51aSDavid Howells  */
10170d81a51aSDavid Howells extern const struct file_operations rxrpc_call_seq_fops;
10180d81a51aSDavid Howells extern const struct file_operations rxrpc_connection_seq_fops;
10190d81a51aSDavid Howells 
10200d81a51aSDavid Howells /*
10210d81a51aSDavid Howells  * recvmsg.c
10220d81a51aSDavid Howells  */
1023248f219cSDavid Howells void rxrpc_notify_socket(struct rxrpc_call *);
10240d81a51aSDavid Howells int rxrpc_recvmsg(struct socket *, struct msghdr *, size_t, int);
10250d81a51aSDavid Howells 
10260d81a51aSDavid Howells /*
1027648af7fcSDavid Howells  * rxkad.c
1028648af7fcSDavid Howells  */
1029648af7fcSDavid Howells #ifdef CONFIG_RXKAD
1030648af7fcSDavid Howells extern const struct rxrpc_security rxkad;
1031648af7fcSDavid Howells #endif
1032648af7fcSDavid Howells 
1033648af7fcSDavid Howells /*
10340d81a51aSDavid Howells  * security.c
10350d81a51aSDavid Howells  */
10360d81a51aSDavid Howells int __init rxrpc_init_security(void);
10370d81a51aSDavid Howells void rxrpc_exit_security(void);
10380d81a51aSDavid Howells int rxrpc_init_client_conn_security(struct rxrpc_connection *);
10390d81a51aSDavid Howells int rxrpc_init_server_conn_security(struct rxrpc_connection *);
10400d81a51aSDavid Howells 
10410d81a51aSDavid Howells /*
10420b58b8a1SDavid Howells  * sendmsg.c
10430b58b8a1SDavid Howells  */
10440b58b8a1SDavid Howells int rxrpc_do_sendmsg(struct rxrpc_sock *, struct msghdr *, size_t);
10450b58b8a1SDavid Howells 
10460b58b8a1SDavid Howells /*
10470d81a51aSDavid Howells  * skbuff.c
10480d81a51aSDavid Howells  */
1049d001648eSDavid Howells void rxrpc_kernel_data_consumed(struct rxrpc_call *, struct sk_buff *);
10500d81a51aSDavid Howells void rxrpc_packet_destructor(struct sk_buff *);
105171f3ca40SDavid Howells void rxrpc_new_skb(struct sk_buff *, enum rxrpc_skb_trace);
105271f3ca40SDavid Howells void rxrpc_see_skb(struct sk_buff *, enum rxrpc_skb_trace);
105371f3ca40SDavid Howells void rxrpc_get_skb(struct sk_buff *, enum rxrpc_skb_trace);
105471f3ca40SDavid Howells void rxrpc_free_skb(struct sk_buff *, enum rxrpc_skb_trace);
105571f3ca40SDavid Howells void rxrpc_lose_skb(struct sk_buff *, enum rxrpc_skb_trace);
1056df844fd4SDavid Howells void rxrpc_purge_queue(struct sk_buff_head *);
10570d81a51aSDavid Howells 
10580d81a51aSDavid Howells /*
10595873c083SDavid Howells  * sysctl.c
10605873c083SDavid Howells  */
10615873c083SDavid Howells #ifdef CONFIG_SYSCTL
10625873c083SDavid Howells extern int __init rxrpc_sysctl_init(void);
10635873c083SDavid Howells extern void rxrpc_sysctl_exit(void);
10645873c083SDavid Howells #else
10655873c083SDavid Howells static inline int __init rxrpc_sysctl_init(void) { return 0; }
10665873c083SDavid Howells static inline void rxrpc_sysctl_exit(void) {}
10675873c083SDavid Howells #endif
10685873c083SDavid Howells 
10695873c083SDavid Howells /*
1070be6e6707SDavid Howells  * utils.c
1071be6e6707SDavid Howells  */
1072d991b4a3SDavid Howells int rxrpc_extract_addr_from_skb(struct sockaddr_rxrpc *, struct sk_buff *);
1073be6e6707SDavid Howells 
1074248f219cSDavid Howells static inline bool before(u32 seq1, u32 seq2)
1075248f219cSDavid Howells {
1076248f219cSDavid Howells         return (s32)(seq1 - seq2) < 0;
1077248f219cSDavid Howells }
1078248f219cSDavid Howells static inline bool before_eq(u32 seq1, u32 seq2)
1079248f219cSDavid Howells {
1080248f219cSDavid Howells         return (s32)(seq1 - seq2) <= 0;
1081248f219cSDavid Howells }
1082248f219cSDavid Howells static inline bool after(u32 seq1, u32 seq2)
1083248f219cSDavid Howells {
1084248f219cSDavid Howells         return (s32)(seq1 - seq2) > 0;
1085248f219cSDavid Howells }
1086248f219cSDavid Howells static inline bool after_eq(u32 seq1, u32 seq2)
1087248f219cSDavid Howells {
1088248f219cSDavid Howells         return (s32)(seq1 - seq2) >= 0;
1089248f219cSDavid Howells }
1090248f219cSDavid Howells 
1091be6e6707SDavid Howells /*
109217926a79SDavid Howells  * debug tracing
109317926a79SDavid Howells  */
109495c96174SEric Dumazet extern unsigned int rxrpc_debug;
109517926a79SDavid Howells 
109617926a79SDavid Howells #define dbgprintk(FMT,...) \
10979f389f4bSSven Schnelle 	printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
109817926a79SDavid Howells 
10990dc47877SHarvey Harrison #define kenter(FMT,...)	dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
11000dc47877SHarvey Harrison #define kleave(FMT,...)	dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
110117926a79SDavid Howells #define kdebug(FMT,...)	dbgprintk("    "FMT ,##__VA_ARGS__)
110217926a79SDavid Howells #define kproto(FMT,...)	dbgprintk("### "FMT ,##__VA_ARGS__)
110317926a79SDavid Howells #define knet(FMT,...)	dbgprintk("@@@ "FMT ,##__VA_ARGS__)
110417926a79SDavid Howells 
110517926a79SDavid Howells 
110617926a79SDavid Howells #if defined(__KDEBUG)
110717926a79SDavid Howells #define _enter(FMT,...)	kenter(FMT,##__VA_ARGS__)
110817926a79SDavid Howells #define _leave(FMT,...)	kleave(FMT,##__VA_ARGS__)
110917926a79SDavid Howells #define _debug(FMT,...)	kdebug(FMT,##__VA_ARGS__)
111017926a79SDavid Howells #define _proto(FMT,...)	kproto(FMT,##__VA_ARGS__)
111117926a79SDavid Howells #define _net(FMT,...)	knet(FMT,##__VA_ARGS__)
111217926a79SDavid Howells 
111317926a79SDavid Howells #elif defined(CONFIG_AF_RXRPC_DEBUG)
111417926a79SDavid Howells #define RXRPC_DEBUG_KENTER	0x01
111517926a79SDavid Howells #define RXRPC_DEBUG_KLEAVE	0x02
111617926a79SDavid Howells #define RXRPC_DEBUG_KDEBUG	0x04
111717926a79SDavid Howells #define RXRPC_DEBUG_KPROTO	0x08
111817926a79SDavid Howells #define RXRPC_DEBUG_KNET	0x10
111917926a79SDavid Howells 
112017926a79SDavid Howells #define _enter(FMT,...)					\
112117926a79SDavid Howells do {							\
112217926a79SDavid Howells 	if (unlikely(rxrpc_debug & RXRPC_DEBUG_KENTER))	\
112317926a79SDavid Howells 		kenter(FMT,##__VA_ARGS__);		\
112417926a79SDavid Howells } while (0)
112517926a79SDavid Howells 
112617926a79SDavid Howells #define _leave(FMT,...)					\
112717926a79SDavid Howells do {							\
112817926a79SDavid Howells 	if (unlikely(rxrpc_debug & RXRPC_DEBUG_KLEAVE))	\
112917926a79SDavid Howells 		kleave(FMT,##__VA_ARGS__);		\
113017926a79SDavid Howells } while (0)
113117926a79SDavid Howells 
113217926a79SDavid Howells #define _debug(FMT,...)					\
113317926a79SDavid Howells do {							\
113417926a79SDavid Howells 	if (unlikely(rxrpc_debug & RXRPC_DEBUG_KDEBUG))	\
113517926a79SDavid Howells 		kdebug(FMT,##__VA_ARGS__);		\
113617926a79SDavid Howells } while (0)
113717926a79SDavid Howells 
113817926a79SDavid Howells #define _proto(FMT,...)					\
113917926a79SDavid Howells do {							\
114017926a79SDavid Howells 	if (unlikely(rxrpc_debug & RXRPC_DEBUG_KPROTO))	\
114117926a79SDavid Howells 		kproto(FMT,##__VA_ARGS__);		\
114217926a79SDavid Howells } while (0)
114317926a79SDavid Howells 
114417926a79SDavid Howells #define _net(FMT,...)					\
114517926a79SDavid Howells do {							\
114617926a79SDavid Howells 	if (unlikely(rxrpc_debug & RXRPC_DEBUG_KNET))	\
114717926a79SDavid Howells 		knet(FMT,##__VA_ARGS__);		\
114817926a79SDavid Howells } while (0)
114917926a79SDavid Howells 
115017926a79SDavid Howells #else
115112fdff3fSDavid Howells #define _enter(FMT,...)	no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
115212fdff3fSDavid Howells #define _leave(FMT,...)	no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
115312fdff3fSDavid Howells #define _debug(FMT,...)	no_printk("    "FMT ,##__VA_ARGS__)
115412fdff3fSDavid Howells #define _proto(FMT,...)	no_printk("### "FMT ,##__VA_ARGS__)
115512fdff3fSDavid Howells #define _net(FMT,...)	no_printk("@@@ "FMT ,##__VA_ARGS__)
115617926a79SDavid Howells #endif
115717926a79SDavid Howells 
115817926a79SDavid Howells /*
115917926a79SDavid Howells  * debug assertion checking
116017926a79SDavid Howells  */
116117926a79SDavid Howells #if 1 // defined(__KDEBUGALL)
116217926a79SDavid Howells 
116317926a79SDavid Howells #define ASSERT(X)						\
116417926a79SDavid Howells do {								\
116517926a79SDavid Howells 	if (unlikely(!(X))) {					\
11669b6d5398SJoe Perches 		pr_err("Assertion failed\n");			\
116717926a79SDavid Howells 		BUG();						\
116817926a79SDavid Howells 	}							\
116917926a79SDavid Howells } while (0)
117017926a79SDavid Howells 
117117926a79SDavid Howells #define ASSERTCMP(X, OP, Y)						\
117217926a79SDavid Howells do {									\
1173cf13258fSDavid Howells 	__typeof__(X) _x = (X);						\
1174cf13258fSDavid Howells 	__typeof__(Y) _y = (__typeof__(X))(Y);				\
11759b6d5398SJoe Perches 	if (unlikely(!(_x OP _y))) {					\
11769b6d5398SJoe Perches 		pr_err("Assertion failed - %lu(0x%lx) %s %lu(0x%lx) is false\n", \
1177cf13258fSDavid Howells 		       (unsigned long)_x, (unsigned long)_x, #OP,	\
1178cf13258fSDavid Howells 		       (unsigned long)_y, (unsigned long)_y);		\
117917926a79SDavid Howells 		BUG();							\
118017926a79SDavid Howells 	}								\
118117926a79SDavid Howells } while (0)
118217926a79SDavid Howells 
118317926a79SDavid Howells #define ASSERTIF(C, X)						\
118417926a79SDavid Howells do {								\
118517926a79SDavid Howells 	if (unlikely((C) && !(X))) {				\
11869b6d5398SJoe Perches 		pr_err("Assertion failed\n");			\
118717926a79SDavid Howells 		BUG();						\
118817926a79SDavid Howells 	}							\
118917926a79SDavid Howells } while (0)
119017926a79SDavid Howells 
119117926a79SDavid Howells #define ASSERTIFCMP(C, X, OP, Y)					\
119217926a79SDavid Howells do {									\
1193cf13258fSDavid Howells 	__typeof__(X) _x = (X);						\
1194cf13258fSDavid Howells 	__typeof__(Y) _y = (__typeof__(X))(Y);				\
11959b6d5398SJoe Perches 	if (unlikely((C) && !(_x OP _y))) {				\
11969b6d5398SJoe Perches 		pr_err("Assertion failed - %lu(0x%lx) %s %lu(0x%lx) is false\n", \
1197cf13258fSDavid Howells 		       (unsigned long)_x, (unsigned long)_x, #OP,	\
1198cf13258fSDavid Howells 		       (unsigned long)_y, (unsigned long)_y);		\
119917926a79SDavid Howells 		BUG();							\
120017926a79SDavid Howells 	}								\
120117926a79SDavid Howells } while (0)
120217926a79SDavid Howells 
120317926a79SDavid Howells #else
120417926a79SDavid Howells 
120517926a79SDavid Howells #define ASSERT(X)				\
120617926a79SDavid Howells do {						\
120717926a79SDavid Howells } while (0)
120817926a79SDavid Howells 
120917926a79SDavid Howells #define ASSERTCMP(X, OP, Y)			\
121017926a79SDavid Howells do {						\
121117926a79SDavid Howells } while (0)
121217926a79SDavid Howells 
121317926a79SDavid Howells #define ASSERTIF(C, X)				\
121417926a79SDavid Howells do {						\
121517926a79SDavid Howells } while (0)
121617926a79SDavid Howells 
121717926a79SDavid Howells #define ASSERTIFCMP(C, X, OP, Y)		\
121817926a79SDavid Howells do {						\
121917926a79SDavid Howells } while (0)
122017926a79SDavid Howells 
122117926a79SDavid Howells #endif /* __KDEBUGALL */
1222