message.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #ifndef _LINUX_RXRPC_MESSAGE_H
  12. #define _LINUX_RXRPC_MESSAGE_H
  13. #include <rxrpc/packet.h>
  14. /*****************************************************************************/
  15. /*
  16. * Rx message record
  17. */
  18. struct rxrpc_message
  19. {
  20. atomic_t usage;
  21. struct list_head link; /* list link */
  22. struct timeval stamp; /* time received or last sent */
  23. rxrpc_seq_t seq; /* message sequence number */
  24. int state; /* the state the message is currently in */
  25. #define RXRPC_MSG_PREPARED 0
  26. #define RXRPC_MSG_SENT 1
  27. #define RXRPC_MSG_ACKED 2 /* provisionally ACK'd */
  28. #define RXRPC_MSG_DONE 3 /* definitively ACK'd (msg->seq<ack.firstPacket) */
  29. #define RXRPC_MSG_RECEIVED 4
  30. #define RXRPC_MSG_ERROR -1
  31. char rttdone; /* used for RTT */
  32. struct rxrpc_transport *trans; /* transport received through */
  33. struct rxrpc_connection *conn; /* connection received over */
  34. struct sk_buff *pkt; /* received packet */
  35. off_t offset; /* offset into pkt of next byte of data */
  36. struct rxrpc_header hdr; /* message header */
  37. int dcount; /* data part count */
  38. size_t dsize; /* data size */
  39. #define RXRPC_MSG_MAX_IOCS 8
  40. struct kvec data[RXRPC_MSG_MAX_IOCS]; /* message data */
  41. unsigned long dfree; /* bit mask indicating kfree(data[x]) if T */
  42. };
  43. #define rxrpc_get_message(M) do { atomic_inc(&(M)->usage); } while(0)
  44. extern void __rxrpc_put_message(struct rxrpc_message *msg);
  45. static inline void rxrpc_put_message(struct rxrpc_message *msg)
  46. {
  47. BUG_ON(atomic_read(&msg->usage)<=0);
  48. if (atomic_dec_and_test(&msg->usage))
  49. __rxrpc_put_message(msg);
  50. }
  51. extern int rxrpc_conn_newmsg(struct rxrpc_connection *conn,
  52. struct rxrpc_call *call,
  53. uint8_t type,
  54. int count,
  55. struct kvec *diov,
  56. gfp_t alloc_flags,
  57. struct rxrpc_message **_msg);
  58. extern int rxrpc_conn_sendmsg(struct rxrpc_connection *conn, struct rxrpc_message *msg);
  59. #endif /* _LINUX_RXRPC_MESSAGE_H */