// SPDX-License-Identifier: GPL-2.0-or-later/* * (c) 2017 Stefano Stabellini <stefano@aporeto.com> */#include<linux/inet.h>#include<linux/kthread.h>#include<linux/list.h>#include<linux/radix-tree.h>#include<linux/module.h>#include<linux/semaphore.h>#include<linux/wait.h>#include<net/sock.h>#include<net/inet_common.h>#include<net/inet_connection_sock.h>#include<net/request_sock.h>#include<trace/events/sock.h>#include<xen/events.h>#include<xen/grant_table.h>#include<xen/xen.h>#include<xen/xenbus.h>#include<xen/interface/io/pvcalls.h>#define PVCALLS_VERSIONS "1"#define MAX_RING_ORDER XENBUS_MAX_RING_GRANT_ORDERstaticstructpvcalls_back_global{structlist_headfrontends;structsemaphorefrontends_lock;}pvcalls_back_global;/* * Per-frontend data structure. It contains pointers to the command * ring, its event channel, a list of active sockets and a tree of * passive sockets. */structpvcalls_fedata{structlist_headlist;structxenbus_device*dev;structxen_pvcalls_sring*sring;structxen_pvcalls_back_ringring;intirq;structlist_headsocket_mappings;structradix_tree_rootsocketpass_mappings;structsemaphoresocket_lock;};structpvcalls_ioworker{structwork_structregister_work;structworkqueue_struct*wq;};structsock_mapping{structlist_headlist;structpvcalls_fedata*fedata;structsockpass_mapping*sockpass;structsocket*sock;uint64_tid;grant_ref_tref;structpvcalls_data_intf*ring;void*bytes;structpvcalls_datadata;uint32_tring_order;intirq;atomic_tread;atomic_twrite;atomic_tio;atomic_trelease;atomic_teoi;void(*saved_data_ready)(structsock*sk);structpvcalls_ioworkerioworker;};structsockpass_mapping{structlist_headlist;structpvcalls_fedata*fedata;structsocket*sock;uint64_tid;structxen_pvcalls_requestreqcopy;spinlock_tcopy_lock;structworkqueue_struct*wq;structwork_structregister_work;void(*saved_data_ready)(structsock*sk);};staticirqreturn_tpvcalls_back_conn_event(intirq,void*sock_map);staticintpvcalls_back_release_active(structxenbus_device*dev,structpvcalls_fedata*fedata,structsock_mapping*map);staticboolpvcalls_conn_back_read(void*opaque){structsock_mapping*map=(structsock_mapping*)opaque;structmsghdrmsg;structkvec