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 #include <linux/vm_sockets.h> 15 16 #include "vmci_transport.h" 17 18 /* Comment this out to compare with old protocol. */ 19 #define VSOCK_OPTIMIZATION_WAITING_NOTIFY 1 20 #if defined(VSOCK_OPTIMIZATION_WAITING_NOTIFY) 21 /* Comment this out to remove flow control for "new" protocol */ 22 #define VSOCK_OPTIMIZATION_FLOW_CONTROL 1 23 #endif 24 25 #define VMCI_TRANSPORT_MAX_DGRAM_RESENDS 10 26 27 struct vmci_transport_recv_notify_data { 28 u64 consume_head; 29 u64 produce_tail; 30 bool notify_on_block; 31 }; 32 33 struct vmci_transport_send_notify_data { 34 u64 consume_head; 35 u64 produce_tail; 36 }; 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 72 extern const struct vmci_transport_notify_ops vmci_transport_notify_pkt_ops; 73 extern const 74 struct vmci_transport_notify_ops vmci_transport_notify_pkt_q_state_ops; 75 76 #endif /* __VMCI_TRANSPORT_NOTIFY_H__ */ 77