svc_xprt.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * linux/include/linux/sunrpc/svc_xprt.h
  3. *
  4. * RPC server transport I/O
  5. */
  6. #ifndef SUNRPC_SVC_XPRT_H
  7. #define SUNRPC_SVC_XPRT_H
  8. #include <linux/sunrpc/svc.h>
  9. #include <linux/module.h>
  10. struct svc_xprt_ops {
  11. struct svc_xprt *(*xpo_create)(struct svc_serv *,
  12. struct sockaddr *, int,
  13. int);
  14. struct svc_xprt *(*xpo_accept)(struct svc_xprt *);
  15. int (*xpo_has_wspace)(struct svc_xprt *);
  16. int (*xpo_recvfrom)(struct svc_rqst *);
  17. void (*xpo_prep_reply_hdr)(struct svc_rqst *);
  18. int (*xpo_sendto)(struct svc_rqst *);
  19. void (*xpo_release_rqst)(struct svc_rqst *);
  20. void (*xpo_detach)(struct svc_xprt *);
  21. void (*xpo_free)(struct svc_xprt *);
  22. };
  23. struct svc_xprt_class {
  24. const char *xcl_name;
  25. struct module *xcl_owner;
  26. struct svc_xprt_ops *xcl_ops;
  27. struct list_head xcl_list;
  28. u32 xcl_max_payload;
  29. };
  30. struct svc_xprt {
  31. struct svc_xprt_class *xpt_class;
  32. struct svc_xprt_ops *xpt_ops;
  33. struct kref xpt_ref;
  34. struct list_head xpt_list;
  35. struct list_head xpt_ready;
  36. unsigned long xpt_flags;
  37. #define XPT_BUSY 0 /* enqueued/receiving */
  38. #define XPT_CONN 1 /* conn pending */
  39. #define XPT_CLOSE 2 /* dead or dying */
  40. #define XPT_DATA 3 /* data pending */
  41. #define XPT_TEMP 4 /* connected transport */
  42. #define XPT_DEAD 6 /* transport closed */
  43. #define XPT_CHNGBUF 7 /* need to change snd/rcv buf sizes */
  44. #define XPT_DEFERRED 8 /* deferred request pending */
  45. #define XPT_OLD 9 /* used for xprt aging mark+sweep */
  46. #define XPT_DETACHED 10 /* detached from tempsocks list */
  47. #define XPT_LISTENER 11 /* listening endpoint */
  48. struct svc_pool *xpt_pool; /* current pool iff queued */
  49. struct svc_serv *xpt_server; /* service for transport */
  50. atomic_t xpt_reserved; /* space on outq that is rsvd */
  51. struct mutex xpt_mutex; /* to serialize sending data */
  52. };
  53. int svc_reg_xprt_class(struct svc_xprt_class *);
  54. void svc_unreg_xprt_class(struct svc_xprt_class *);
  55. void svc_xprt_init(struct svc_xprt_class *, struct svc_xprt *,
  56. struct svc_serv *);
  57. int svc_create_xprt(struct svc_serv *, char *, unsigned short, int);
  58. void svc_xprt_received(struct svc_xprt *);
  59. void svc_xprt_put(struct svc_xprt *xprt);
  60. static inline void svc_xprt_get(struct svc_xprt *xprt)
  61. {
  62. kref_get(&xprt->xpt_ref);
  63. }
  64. #endif /* SUNRPC_SVC_XPRT_H */