vmci_transport_notify.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * VMware vSockets Driver
  4. *
  5. * Copyright (C) 2009-2013 VMware, Inc. All rights reserved.
  6. */
  7. #ifndef __VMCI_TRANSPORT_NOTIFY_H__
  8. #define __VMCI_TRANSPORT_NOTIFY_H__
  9. #include <linux/types.h>
  10. #include <linux/vmw_vmci_defs.h>
  11. #include <linux/vmw_vmci_api.h>
  12. #include "vmci_transport.h"
  13. /* Comment this out to compare with old protocol. */
  14. #define VSOCK_OPTIMIZATION_WAITING_NOTIFY 1
  15. #if defined(VSOCK_OPTIMIZATION_WAITING_NOTIFY)
  16. /* Comment this out to remove flow control for "new" protocol */
  17. #define VSOCK_OPTIMIZATION_FLOW_CONTROL 1
  18. #endif
  19. #define VMCI_TRANSPORT_MAX_DGRAM_RESENDS 10
  20. struct vmci_transport_recv_notify_data {
  21. u64 consume_head;
  22. u64 produce_tail;
  23. bool notify_on_block;
  24. };
  25. struct vmci_transport_send_notify_data {
  26. u64 consume_head;
  27. u64 produce_tail;
  28. };
  29. /* Socket notification callbacks. */
  30. struct vmci_transport_notify_ops {
  31. void (*socket_init) (struct sock *sk);
  32. void (*socket_destruct) (struct vsock_sock *vsk);
  33. int (*poll_in) (struct sock *sk, size_t target,
  34. bool *data_ready_now);
  35. int (*poll_out) (struct sock *sk, size_t target,
  36. bool *space_avail_now);
  37. void (*handle_notify_pkt) (struct sock *sk,
  38. struct vmci_transport_packet *pkt,
  39. bool bottom_half, struct sockaddr_vm *dst,
  40. struct sockaddr_vm *src,
  41. bool *pkt_processed);
  42. int (*recv_init) (struct sock *sk, size_t target,
  43. struct vmci_transport_recv_notify_data *data);
  44. int (*recv_pre_block) (struct sock *sk, size_t target,
  45. struct vmci_transport_recv_notify_data *data);
  46. int (*recv_pre_dequeue) (struct sock *sk, size_t target,
  47. struct vmci_transport_recv_notify_data *data);
  48. int (*recv_post_dequeue) (struct sock *sk, size_t target,
  49. ssize_t copied, bool data_read,
  50. struct vmci_transport_recv_notify_data *data);
  51. int (*send_init) (struct sock *sk,
  52. struct vmci_transport_send_notify_data *data);
  53. int (*send_pre_block) (struct sock *sk,
  54. struct vmci_transport_send_notify_data *data);
  55. int (*send_pre_enqueue) (struct sock *sk,
  56. struct vmci_transport_send_notify_data *data);
  57. int (*send_post_enqueue) (struct sock *sk, ssize_t written,
  58. struct vmci_transport_send_notify_data *data);
  59. void (*process_request) (struct sock *sk);
  60. void (*process_negotiate) (struct sock *sk);
  61. };
  62. extern const struct vmci_transport_notify_ops vmci_transport_notify_pkt_ops;
  63. extern const
  64. struct vmci_transport_notify_ops vmci_transport_notify_pkt_q_state_ops;
  65. #endif /* __VMCI_TRANSPORT_NOTIFY_H__ */