[PATCH] Driver Core: remove driver model detach_state
[linux-2.6] / include / rxrpc / message.h
1 /* message.h: Rx message caching
2  *
3  * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
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.
10  */
11
12 #ifndef _LINUX_RXRPC_MESSAGE_H
13 #define _LINUX_RXRPC_MESSAGE_H
14
15 #include <rxrpc/packet.h>
16
17 /*****************************************************************************/
18 /*
19  * Rx message record
20  */
21 struct rxrpc_message
22 {
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 */
27
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 */
36
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 */
41
42         struct rxrpc_header     hdr;            /* message header */
43
44         int                     dcount;         /* data part count */
45         size_t                  dsize;          /* data size */
46 #define RXRPC_MSG_MAX_IOCS 8
47         struct kvec             data[RXRPC_MSG_MAX_IOCS]; /* message data */
48         unsigned long           dfree;          /* bit mask indicating kfree(data[x]) if T */
49 };
50
51 #define rxrpc_get_message(M) do { atomic_inc(&(M)->usage); } while(0)
52
53 extern void __rxrpc_put_message(struct rxrpc_message *msg);
54 static inline void rxrpc_put_message(struct rxrpc_message *msg)
55 {
56         BUG_ON(atomic_read(&msg->usage)<=0);
57         if (atomic_dec_and_test(&msg->usage))
58                 __rxrpc_put_message(msg);
59 }
60
61 extern int rxrpc_conn_newmsg(struct rxrpc_connection *conn,
62                              struct rxrpc_call *call,
63                              uint8_t type,
64                              int count,
65                              struct kvec *diov,
66                              int alloc_flags,
67                              struct rxrpc_message **_msg);
68
69 extern int rxrpc_conn_sendmsg(struct rxrpc_connection *conn, struct rxrpc_message *msg);
70
71 #endif /* _LINUX_RXRPC_MESSAGE_H */