vmci_transport_notify.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * VMware vSockets Driver
  3. *
  4. * Copyright (C) 2009-2013 VMware, Inc. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation version 2 and no later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. */
  15. #ifndef __VMCI_TRANSPORT_NOTIFY_H__
  16. #define __VMCI_TRANSPORT_NOTIFY_H__
  17. #include <linux/types.h>
  18. #include <linux/vmw_vmci_defs.h>
  19. #include <linux/vmw_vmci_api.h>
  20. #include <linux/vm_sockets.h>
  21. #include "vmci_transport.h"
  22. /* Comment this out to compare with old protocol. */
  23. #define VSOCK_OPTIMIZATION_WAITING_NOTIFY 1
  24. #if defined(VSOCK_OPTIMIZATION_WAITING_NOTIFY)
  25. /* Comment this out to remove flow control for "new" protocol */
  26. #define VSOCK_OPTIMIZATION_FLOW_CONTROL 1
  27. #endif
  28. #define VMCI_TRANSPORT_MAX_DGRAM_RESENDS 10
  29. struct vmci_transport_recv_notify_data {
  30. u64 consume_head;
  31. u64 produce_tail;
  32. bool notify_on_block;
  33. };
  34. struct vmci_transport_send_notify_data {
  35. u64 consume_head;
  36. u64 produce_tail;
  37. };
  38. /* Socket notification callbacks. */
  39. struct vmci_transport_notify_ops {
  40. void (*socket_init) (struct sock *sk);
  41. void (*socket_destruct) (struct vsock_sock *vsk);
  42. int (*poll_in) (struct sock *sk, size_t target,
  43. bool *data_ready_now);
  44. int (*poll_out) (struct sock *sk, size_t target,
  45. bool *space_avail_now);
  46. void (*handle_notify_pkt) (struct sock *sk,
  47. struct vmci_transport_packet *pkt,
  48. bool bottom_half, struct sockaddr_vm *dst,
  49. struct sockaddr_vm *src,
  50. bool *pkt_processed);
  51. int (*recv_init) (struct sock *sk, size_t target,
  52. struct vmci_transport_recv_notify_data *data);
  53. int (*recv_pre_block) (struct sock *sk, size_t target,
  54. struct vmci_transport_recv_notify_data *data);
  55. int (*recv_pre_dequeue) (struct sock *sk, size_t target,
  56. struct vmci_transport_recv_notify_data *data);
  57. int (*recv_post_dequeue) (struct sock *sk, size_t target,
  58. ssize_t copied, bool data_read,
  59. struct vmci_transport_recv_notify_data *data);
  60. int (*send_init) (struct sock *sk,
  61. struct vmci_transport_send_notify_data *data);
  62. int (*send_pre_block) (struct sock *sk,
  63. struct vmci_transport_send_notify_data *data);
  64. int (*send_pre_enqueue) (struct sock *sk,
  65. struct vmci_transport_send_notify_data *data);
  66. int (*send_post_enqueue) (struct sock *sk, ssize_t written,
  67. struct vmci_transport_send_notify_data *data);
  68. void (*process_request) (struct sock *sk);
  69. void (*process_negotiate) (struct sock *sk);
  70. };
  71. extern const struct vmci_transport_notify_ops vmci_transport_notify_pkt_ops;
  72. extern const
  73. struct vmci_transport_notify_ops vmci_transport_notify_pkt_q_state_ops;
  74. #endif /* __VMCI_TRANSPORT_NOTIFY_H__ */