More cleaning ...
[linux-2.6/linux-mips.git] / include / rxrpc / message.h
blob2e43c03c6857afb8326cff2f3f117210fa4a1c6b
1 /* message.h: Rx message caching
3 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #ifndef _H_3AD3363A_3A9C_11D6_83D8_0002B3163499
13 #define _H_3AD3363A_3A9C_11D6_83D8_0002B3163499
15 #include <rxrpc/packet.h>
17 /*****************************************************************************/
19 * Rx message record
21 struct rxrpc_message
23 atomic_t usage;
24 struct list_head link; /* list link */
25 struct timeval stamp; /* time received or last sent */
26 rxrpc_seq_t seq; /* message sequence number */
28 int state; /* the state the message is currently in */
29 #define RXRPC_MSG_PREPARED 0
30 #define RXRPC_MSG_SENT 1
31 #define RXRPC_MSG_ACKED 2 /* provisionally ACK'd */
32 #define RXRPC_MSG_DONE 3 /* definitively ACK'd (msg->seq<ack.firstPacket) */
33 #define RXRPC_MSG_RECEIVED 4
34 #define RXRPC_MSG_ERROR -1
35 char rttdone; /* used for RTT */
37 struct rxrpc_transport *trans; /* transport received through */
38 struct rxrpc_connection *conn; /* connection received over */
39 struct sk_buff *pkt; /* received packet */
40 off_t offset; /* offset into pkt of next byte of data */
42 struct rxrpc_header hdr; /* message header */
44 int dcount; /* data part count */
45 size_t dsize; /* data size */
46 #define RXRPC_MSG_MAX_IOCS 8
47 struct iovec data[RXRPC_MSG_MAX_IOCS]; /* message data */
48 unsigned long dfree; /* bit mask indicating kfree(data[x]) if T */
51 #define rxrpc_get_message(M) do { atomic_inc(&(M)->usage); } while(0)
53 extern void __rxrpc_put_message(struct rxrpc_message *msg);
54 static inline void rxrpc_put_message(struct rxrpc_message *msg)
56 if (atomic_read(&msg->usage)<=0)
57 BUG();
58 if (atomic_dec_and_test(&msg->usage))
59 __rxrpc_put_message(msg);
62 extern int rxrpc_conn_newmsg(struct rxrpc_connection *conn,
63 struct rxrpc_call *call,
64 u8 type,
65 int count,
66 struct iovec diov[],
67 int alloc_flags,
68 struct rxrpc_message **_msg);
70 extern int rxrpc_conn_sendmsg(struct rxrpc_connection *conn, struct rxrpc_message *msg);
72 #endif /* _H_3AD3363A_3A9C_11D6_83D8_0002B3163499 */