18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * VMware vSockets Driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2009-2013 VMware, Inc. All rights reserved. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef __VMCI_TRANSPORT_NOTIFY_H__ 98c2ecf20Sopenharmony_ci#define __VMCI_TRANSPORT_NOTIFY_H__ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/types.h> 128c2ecf20Sopenharmony_ci#include <linux/vmw_vmci_defs.h> 138c2ecf20Sopenharmony_ci#include <linux/vmw_vmci_api.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "vmci_transport.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/* Comment this out to compare with old protocol. */ 188c2ecf20Sopenharmony_ci#define VSOCK_OPTIMIZATION_WAITING_NOTIFY 1 198c2ecf20Sopenharmony_ci#if defined(VSOCK_OPTIMIZATION_WAITING_NOTIFY) 208c2ecf20Sopenharmony_ci/* Comment this out to remove flow control for "new" protocol */ 218c2ecf20Sopenharmony_ci#define VSOCK_OPTIMIZATION_FLOW_CONTROL 1 228c2ecf20Sopenharmony_ci#endif 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define VMCI_TRANSPORT_MAX_DGRAM_RESENDS 10 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistruct vmci_transport_recv_notify_data { 278c2ecf20Sopenharmony_ci u64 consume_head; 288c2ecf20Sopenharmony_ci u64 produce_tail; 298c2ecf20Sopenharmony_ci bool notify_on_block; 308c2ecf20Sopenharmony_ci}; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistruct vmci_transport_send_notify_data { 338c2ecf20Sopenharmony_ci u64 consume_head; 348c2ecf20Sopenharmony_ci u64 produce_tail; 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* Socket notification callbacks. */ 388c2ecf20Sopenharmony_cistruct vmci_transport_notify_ops { 398c2ecf20Sopenharmony_ci void (*socket_init) (struct sock *sk); 408c2ecf20Sopenharmony_ci void (*socket_destruct) (struct vsock_sock *vsk); 418c2ecf20Sopenharmony_ci int (*poll_in) (struct sock *sk, size_t target, 428c2ecf20Sopenharmony_ci bool *data_ready_now); 438c2ecf20Sopenharmony_ci int (*poll_out) (struct sock *sk, size_t target, 448c2ecf20Sopenharmony_ci bool *space_avail_now); 458c2ecf20Sopenharmony_ci void (*handle_notify_pkt) (struct sock *sk, 468c2ecf20Sopenharmony_ci struct vmci_transport_packet *pkt, 478c2ecf20Sopenharmony_ci bool bottom_half, struct sockaddr_vm *dst, 488c2ecf20Sopenharmony_ci struct sockaddr_vm *src, 498c2ecf20Sopenharmony_ci bool *pkt_processed); 508c2ecf20Sopenharmony_ci int (*recv_init) (struct sock *sk, size_t target, 518c2ecf20Sopenharmony_ci struct vmci_transport_recv_notify_data *data); 528c2ecf20Sopenharmony_ci int (*recv_pre_block) (struct sock *sk, size_t target, 538c2ecf20Sopenharmony_ci struct vmci_transport_recv_notify_data *data); 548c2ecf20Sopenharmony_ci int (*recv_pre_dequeue) (struct sock *sk, size_t target, 558c2ecf20Sopenharmony_ci struct vmci_transport_recv_notify_data *data); 568c2ecf20Sopenharmony_ci int (*recv_post_dequeue) (struct sock *sk, size_t target, 578c2ecf20Sopenharmony_ci ssize_t copied, bool data_read, 588c2ecf20Sopenharmony_ci struct vmci_transport_recv_notify_data *data); 598c2ecf20Sopenharmony_ci int (*send_init) (struct sock *sk, 608c2ecf20Sopenharmony_ci struct vmci_transport_send_notify_data *data); 618c2ecf20Sopenharmony_ci int (*send_pre_block) (struct sock *sk, 628c2ecf20Sopenharmony_ci struct vmci_transport_send_notify_data *data); 638c2ecf20Sopenharmony_ci int (*send_pre_enqueue) (struct sock *sk, 648c2ecf20Sopenharmony_ci struct vmci_transport_send_notify_data *data); 658c2ecf20Sopenharmony_ci int (*send_post_enqueue) (struct sock *sk, ssize_t written, 668c2ecf20Sopenharmony_ci struct vmci_transport_send_notify_data *data); 678c2ecf20Sopenharmony_ci void (*process_request) (struct sock *sk); 688c2ecf20Sopenharmony_ci void (*process_negotiate) (struct sock *sk); 698c2ecf20Sopenharmony_ci}; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciextern const struct vmci_transport_notify_ops vmci_transport_notify_pkt_ops; 728c2ecf20Sopenharmony_ciextern const 738c2ecf20Sopenharmony_cistruct vmci_transport_notify_ops vmci_transport_notify_pkt_q_state_ops; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#endif /* __VMCI_TRANSPORT_NOTIFY_H__ */ 76