~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to xen/include/xeno/vif.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* vif.h
2
 
 * 
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.
5
 
 *
6
 
 * Copyright (c) 2002-2003, A K Warfield and K A Fraser
7
 
 */
8
 
 
9
 
#ifndef __XENO_VIF_H__
10
 
#define __XENO_VIF_H__
11
 
 
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.
19
 
 */
20
 
 
21
 
#include <hypervisor-ifs/network.h>
22
 
 
23
 
#include <xeno/if_ether.h>
24
 
 
25
 
extern struct net_device *the_dev;
26
 
 
27
 
/* 
28
 
 * shadow ring structures are used to protect the descriptors from
29
 
 * tampering after they have been passed to the hypervisor.
30
 
 *
31
 
 * TX_RING_SIZE and RX_RING_SIZE are defined in the shared network.h.
32
 
 */
33
 
 
34
 
typedef struct rx_shadow_entry_st 
35
 
{
36
 
    unsigned short id;
37
 
    unsigned short flush_count; /* 16 bits should be enough */
38
 
    unsigned long  pte_ptr;
39
 
    unsigned long  buf_pfn;
40
 
} rx_shadow_entry_t;
41
 
 
42
 
typedef struct tx_shadow_entry_st 
43
 
{
44
 
    unsigned short id;
45
 
    unsigned short size;
46
 
    void          *header;
47
 
    unsigned long  payload;
48
 
} tx_shadow_entry_t;
49
 
 
50
 
typedef struct net_vif_st {
51
 
    /* The shared rings and indexes. */
52
 
    net_ring_t         *shared_rings;
53
 
    net_idx_t          *shared_idxs;
54
 
 
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. */
62
 
 
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 */
68
 
 
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;
74
 
 
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;
80
 
 
81
 
    /* Miscellaneous private stuff. */
82
 
    struct task_struct *domain;
83
 
    unsigned int idx; /* index within domain */
84
 
    struct list_head    list;     /* scheduling list */
85
 
    atomic_t            refcnt;
86
 
    spinlock_t          rx_lock, tx_lock;
87
 
    unsigned char       vmac[ETH_ALEN];
88
 
} net_vif_t;
89
 
 
90
 
#define get_vif(_v) (atomic_inc(&(_v)->refcnt))
91
 
#define put_vif(_v)                                                \
92
 
do {                                                               \
93
 
    if ( atomic_dec_and_test(&(_v)->refcnt) ) destroy_net_vif(_v); \
94
 
} while (0)                                                        \
95
 
 
96
 
/* vif prototypes */
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);
102
 
 
103
 
/*
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)
108
 
 */
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)
112
 
 
113
 
#endif /* __XENO_VIF_H__ */
114