3
* This is the hypervisor end of the network code. The net_ring structure
4
* stored in each vif is placed on a shared page to interact with the guest VM.
6
* Copyright (c) 2002-2003, A K Warfield and K A Fraser
10
#define __XENO_VIF_H__
12
/* virtual network interface struct and associated defines. */
13
/* net_vif_st is the larger struct that describes a virtual network interface
14
* it contains a pointer to the net_ring_t structure that needs to be on a
15
* shared page between the hypervisor and guest. The vif struct is private
16
* to the hypervisor and is used primarily as a container to allow routing
17
* and interface administration. This define should eventually be moved to
18
* a non-shared interface file, as it is of no relevance to the guest.
21
#include <hypervisor-ifs/network.h>
23
#include <xeno/if_ether.h>
25
extern struct net_device *the_dev;
28
* shadow ring structures are used to protect the descriptors from
29
* tampering after they have been passed to the hypervisor.
31
* TX_RING_SIZE and RX_RING_SIZE are defined in the shared network.h.
34
typedef struct rx_shadow_entry_st
37
unsigned short flush_count; /* 16 bits should be enough */
38
unsigned long pte_ptr;
39
unsigned long buf_pfn;
42
typedef struct tx_shadow_entry_st
47
unsigned long payload;
50
typedef struct net_vif_st {
51
/* The shared rings and indexes. */
52
net_ring_t *shared_rings;
53
net_idx_t *shared_idxs;
55
/* The private rings and indexes. */
56
rx_shadow_entry_t rx_shadow_ring[RX_RING_SIZE];
57
unsigned int rx_prod; /* More buffers for filling go here. */
58
unsigned int rx_cons; /* Next buffer to fill is here. */
59
tx_shadow_entry_t tx_shadow_ring[TX_RING_SIZE];
60
unsigned int tx_prod; /* More packets for sending go here. */
61
unsigned int tx_cons; /* Next packet to send is here. */
63
/* Private indexes into shared ring. */
64
unsigned int rx_req_cons;
65
unsigned int rx_resp_prod; /* private version of shared variable */
66
unsigned int tx_req_cons;
67
unsigned int tx_resp_prod; /* private version of shared variable */
69
/* Usage accounting */
70
long long total_bytes_sent;
71
long long total_bytes_received;
72
long long total_packets_sent;
73
long long total_packets_received;
75
/* Trasnmit shaping: allow 'credit_bytes' everu 'credit_usec'. */
76
unsigned long credit_bytes;
77
unsigned long credit_usec;
78
unsigned long remaining_credit;
79
struct ac_timer credit_timeout;
81
/* Miscellaneous private stuff. */
82
struct task_struct *domain;
83
unsigned int idx; /* index within domain */
84
struct list_head list; /* scheduling list */
86
spinlock_t rx_lock, tx_lock;
87
unsigned char vmac[ETH_ALEN];
90
#define get_vif(_v) (atomic_inc(&(_v)->refcnt))
93
if ( atomic_dec_and_test(&(_v)->refcnt) ) destroy_net_vif(_v); \
97
net_vif_t *create_net_vif(int domain);
98
void destroy_net_vif(net_vif_t *vif);
99
void unlink_net_vif(net_vif_t *vif);
100
net_vif_t *net_get_target_vif(u8 *data, unsigned int len, net_vif_t *src_vif);
101
net_vif_t *find_vif_by_id(unsigned long id);
104
* Return values from net_get_target_vif:
105
* VIF_PHYS -- Send to physical NIC
106
* VIF_DROP -- Drop this packet
107
* others -- Send to specified VIF (reference held on return)
109
#define VIF_PHYS ((net_vif_t *)0)
110
#define VIF_DROP ((net_vif_t *)1)
111
#define VIF_LOCAL(_vif) ((unsigned long)(_vif) > 1)
113
#endif /* __XENO_VIF_H__ */