linux/net/vmw_vsock/virtio_transport_common.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * common code for virtio vsock
 *
 * Copyright (C) 2013-2015 Red Hat, Inc.
 * Author: Asias He <[email protected]>
 *         Stefan Hajnoczi <[email protected]>
 */
#include <linux/spinlock.h>
#include <linux/module.h>
#include <linux/sched/signal.h>
#include <linux/ctype.h>
#include <linux/list.h>
#include <linux/virtio_vsock.h>
#include <uapi/linux/vsockmon.h>

#include <net/sock.h>
#include <net/af_vsock.h>

#define CREATE_TRACE_POINTS
#include <trace/events/vsock_virtio_transport_common.h>

/* How long to wait for graceful shutdown of a connection */
#define VSOCK_CLOSE_TIMEOUT

/* Threshold for detecting small packets to copy */
#define GOOD_COPY_LEN

static const struct virtio_transport *
virtio_transport_get_ops(struct vsock_sock *vsk)
{}

static bool virtio_transport_can_zcopy(const struct virtio_transport *t_ops,
				       struct virtio_vsock_pkt_info *info,
				       size_t pkt_len)
{}

static int virtio_transport_init_zcopy_skb(struct vsock_sock *vsk,
					   struct sk_buff *skb,
					   struct msghdr *msg,
					   bool zerocopy)
{}

static int virtio_transport_fill_skb(struct sk_buff *skb,
				     struct virtio_vsock_pkt_info *info,
				     size_t len,
				     bool zcopy)
{}

static void virtio_transport_init_hdr(struct sk_buff *skb,
				      struct virtio_vsock_pkt_info *info,
				      size_t payload_len,
				      u32 src_cid,
				      u32 src_port,
				      u32 dst_cid,
				      u32 dst_port)
{}

static void virtio_transport_copy_nonlinear_skb(const struct sk_buff *skb,
						void *dst,
						size_t len)
{}

/* Packet capture */
static struct sk_buff *virtio_transport_build_skb(void *opaque)
{}

void virtio_transport_deliver_tap_pkt(struct sk_buff *skb)
{}
EXPORT_SYMBOL_GPL();

static u16 virtio_transport_get_type(struct sock *sk)
{}

/* Returns new sk_buff on success, otherwise returns NULL. */
static struct sk_buff *virtio_transport_alloc_skb(struct virtio_vsock_pkt_info *info,
						  size_t payload_len,
						  bool zcopy,
						  u32 src_cid,
						  u32 src_port,
						  u32 dst_cid,
						  u32 dst_port)
{}

/* This function can only be used on connecting/connected sockets,
 * since a socket assigned to a transport is required.
 *
 * Do not use on listener sockets!
 */
static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
					  struct virtio_vsock_pkt_info *info)
{}

static bool virtio_transport_inc_rx_pkt(struct virtio_vsock_sock *vvs,
					u32 len)
{}

static void virtio_transport_dec_rx_pkt(struct virtio_vsock_sock *vvs,
					u32 len)
{}

void virtio_transport_inc_tx_pkt(struct virtio_vsock_sock *vvs, struct sk_buff *skb)
{}
EXPORT_SYMBOL_GPL();

u32 virtio_transport_get_credit(struct virtio_vsock_sock *vvs, u32 credit)
{}
EXPORT_SYMBOL_GPL();

void virtio_transport_put_credit(struct virtio_vsock_sock *vvs, u32 credit)
{}
EXPORT_SYMBOL_GPL();

static int virtio_transport_send_credit_update(struct vsock_sock *vsk)
{}

static ssize_t
virtio_transport_stream_do_peek(struct vsock_sock *vsk,
				struct msghdr *msg,
				size_t len)
{}

static ssize_t
virtio_transport_stream_do_dequeue(struct vsock_sock *vsk,
				   struct msghdr *msg,
				   size_t len)
{}

static ssize_t
virtio_transport_seqpacket_do_peek(struct vsock_sock *vsk,
				   struct msghdr *msg)
{}

static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk,
						 struct msghdr *msg,
						 int flags)
{}

ssize_t
virtio_transport_stream_dequeue(struct vsock_sock *vsk,
				struct msghdr *msg,
				size_t len, int flags)
{}
EXPORT_SYMBOL_GPL();

ssize_t
virtio_transport_seqpacket_dequeue(struct vsock_sock *vsk,
				   struct msghdr *msg,
				   int flags)
{}
EXPORT_SYMBOL_GPL();

int
virtio_transport_seqpacket_enqueue(struct vsock_sock *vsk,
				   struct msghdr *msg,
				   size_t len)
{}
EXPORT_SYMBOL_GPL();

int
virtio_transport_dgram_dequeue(struct vsock_sock *vsk,
			       struct msghdr *msg,
			       size_t len, int flags)
{}
EXPORT_SYMBOL_GPL();

s64 virtio_transport_stream_has_data(struct vsock_sock *vsk)
{}
EXPORT_SYMBOL_GPL();

u32 virtio_transport_seqpacket_has_data(struct vsock_sock *vsk)
{}
EXPORT_SYMBOL_GPL();

static s64 virtio_transport_has_space(struct vsock_sock *vsk)
{}

s64 virtio_transport_stream_has_space(struct vsock_sock *vsk)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_do_socket_init(struct vsock_sock *vsk,
				    struct vsock_sock *psk)
{}
EXPORT_SYMBOL_GPL();

/* sk_lock held by the caller */
void virtio_transport_notify_buffer_size(struct vsock_sock *vsk, u64 *val)
{}
EXPORT_SYMBOL_GPL();

int
virtio_transport_notify_poll_in(struct vsock_sock *vsk,
				size_t target,
				bool *data_ready_now)
{}
EXPORT_SYMBOL_GPL();

int
virtio_transport_notify_poll_out(struct vsock_sock *vsk,
				 size_t target,
				 bool *space_avail_now)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_notify_recv_init(struct vsock_sock *vsk,
	size_t target, struct vsock_transport_recv_notify_data *data)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_notify_recv_pre_block(struct vsock_sock *vsk,
	size_t target, struct vsock_transport_recv_notify_data *data)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_notify_recv_pre_dequeue(struct vsock_sock *vsk,
	size_t target, struct vsock_transport_recv_notify_data *data)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_notify_recv_post_dequeue(struct vsock_sock *vsk,
	size_t target, ssize_t copied, bool data_read,
	struct vsock_transport_recv_notify_data *data)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_notify_send_init(struct vsock_sock *vsk,
	struct vsock_transport_send_notify_data *data)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_notify_send_pre_block(struct vsock_sock *vsk,
	struct vsock_transport_send_notify_data *data)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_notify_send_pre_enqueue(struct vsock_sock *vsk,
	struct vsock_transport_send_notify_data *data)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_notify_send_post_enqueue(struct vsock_sock *vsk,
	ssize_t written, struct vsock_transport_send_notify_data *data)
{}
EXPORT_SYMBOL_GPL();

u64 virtio_transport_stream_rcvhiwat(struct vsock_sock *vsk)
{}
EXPORT_SYMBOL_GPL();

bool virtio_transport_stream_is_active(struct vsock_sock *vsk)
{}
EXPORT_SYMBOL_GPL();

bool virtio_transport_stream_allow(u32 cid, u32 port)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_dgram_bind(struct vsock_sock *vsk,
				struct sockaddr_vm *addr)
{}
EXPORT_SYMBOL_GPL();

bool virtio_transport_dgram_allow(u32 cid, u32 port)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_connect(struct vsock_sock *vsk)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_shutdown(struct vsock_sock *vsk, int mode)
{}
EXPORT_SYMBOL_GPL();

int
virtio_transport_dgram_enqueue(struct vsock_sock *vsk,
			       struct sockaddr_vm *remote_addr,
			       struct msghdr *msg,
			       size_t dgram_len)
{}
EXPORT_SYMBOL_GPL();

ssize_t
virtio_transport_stream_enqueue(struct vsock_sock *vsk,
				struct msghdr *msg,
				size_t len)
{}
EXPORT_SYMBOL_GPL();

void virtio_transport_destruct(struct vsock_sock *vsk)
{}
EXPORT_SYMBOL_GPL();

static int virtio_transport_reset(struct vsock_sock *vsk,
				  struct sk_buff *skb)
{}

/* Normally packets are associated with a socket.  There may be no socket if an
 * attempt was made to connect to a socket that does not exist.
 */
static int virtio_transport_reset_no_sock(const struct virtio_transport *t,
					  struct sk_buff *skb)
{}

/* This function should be called with sk_lock held and SOCK_DONE set */
static void virtio_transport_remove_sock(struct vsock_sock *vsk)
{}

static void virtio_transport_wait_close(struct sock *sk, long timeout)
{}

static void virtio_transport_do_close(struct vsock_sock *vsk,
				      bool cancel_timeout)
{}

static void virtio_transport_close_timeout(struct work_struct *work)
{}

/* User context, vsk->sk is locked */
static bool virtio_transport_close(struct vsock_sock *vsk)
{}

void virtio_transport_release(struct vsock_sock *vsk)
{}
EXPORT_SYMBOL_GPL();

static int
virtio_transport_recv_connecting(struct sock *sk,
				 struct sk_buff *skb)
{}

static void
virtio_transport_recv_enqueue(struct vsock_sock *vsk,
			      struct sk_buff *skb)
{}

static int
virtio_transport_recv_connected(struct sock *sk,
				struct sk_buff *skb)
{}

static void
virtio_transport_recv_disconnecting(struct sock *sk,
				    struct sk_buff *skb)
{}

static int
virtio_transport_send_response(struct vsock_sock *vsk,
			       struct sk_buff *skb)
{}

static bool virtio_transport_space_update(struct sock *sk,
					  struct sk_buff *skb)
{}

/* Handle server socket */
static int
virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
			     struct virtio_transport *t)
{}

static bool virtio_transport_valid_type(u16 type)
{}

/* We are under the virtio-vsock's vsock->rx_lock or vhost-vsock's vq->mutex
 * lock.
 */
void virtio_transport_recv_pkt(struct virtio_transport *t,
			       struct sk_buff *skb)
{}
EXPORT_SYMBOL_GPL();

/* Remove skbs found in a queue that have a vsk that matches.
 *
 * Each skb is freed.
 *
 * Returns the count of skbs that were reply packets.
 */
int virtio_transport_purge_skbs(void *vsk, struct sk_buff_head *queue)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_read_skb(struct vsock_sock *vsk, skb_read_actor_t recv_actor)
{}
EXPORT_SYMBOL_GPL();

int virtio_transport_notify_set_rcvlowat(struct vsock_sock *vsk, int val)
{}
EXPORT_SYMBOL_GPL();

MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();