summaryrefslogtreecommitdiffstats
path: root/include/rxrpc/message.h
blob: 983d9f9eee1a8bbdcccf01405cb40f03abbd6e99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* message.h: Rx message caching
 *
 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
 * Written by David Howells (dhowells@redhat.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 */

#ifndef _LINUX_RXRPC_MESSAGE_H
#define _LINUX_RXRPC_MESSAGE_H

#include <rxrpc/packet.h>

/*****************************************************************************/
/*
 * Rx message record
 */
struct rxrpc_message
{
	atomic_t		usage;
	struct list_head	link;		/* list link */
	struct timeval		stamp;		/* time received or last sent */
	rxrpc_seq_t		seq;		/* message sequence number */

	int			state;		/* the state the message is currently in */
#define RXRPC_MSG_PREPARED	0
#define RXRPC_MSG_SENT		1
#define RXRPC_MSG_ACKED		2		/* provisionally ACK'd */
#define RXRPC_MSG_DONE		3		/* definitively ACK'd (msg->seq<ack.firstPacket) */
#define RXRPC_MSG_RECEIVED	4
#define RXRPC_MSG_ERROR		-1
	char			rttdone;	/* used for RTT */

	struct rxrpc_transport	*trans;		/* transport received through */
	struct rxrpc_connection	*conn;		/* connection received over */
	struct sk_buff		*pkt;		/* received packet */
	off_t			offset;		/* offset into pkt of next byte of data */

	struct rxrpc_header	hdr;		/* message header */

	int			dcount;		/* data part count */
	size_t			dsize;		/* data size */
#define RXRPC_MSG_MAX_IOCS 8
	struct kvec		data[RXRPC_MSG_MAX_IOCS]; /* message data */
	unsigned long		dfree;		/* bit mask indicating kfree(data[x]) if T */
};

#define rxrpc_get_message(M) do { atomic_inc(&(M)->usage); } while(0)

extern void __rxrpc_put_message(struct rxrpc_message *msg);
static inline void rxrpc_put_message(struct rxrpc_message *msg)
{
	BUG_ON(atomic_read(&msg->usage)<=0);
	if (atomic_dec_and_test(&msg->usage))
		__rxrpc_put_message(msg);
}

extern int rxrpc_conn_newmsg(struct rxrpc_connection *conn,
			     struct rxrpc_call *call,
			     uint8_t type,
			     int count,
			     struct kvec *diov,
			     unsigned int __nocast alloc_flags,
			     struct rxrpc_message **_msg);

extern int rxrpc_conn_sendmsg(struct rxrpc_connection *conn, struct rxrpc_message *msg);

#endif /* _LINUX_RXRPC_MESSAGE_H */