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