ia64/xen-unstable

view xen/include/public/io/netif.h @ 5755:be1153585cb0

Fix hgignore regexps some more.
author kaf24@firebug.cl.cam.ac.uk
date Tue Jul 12 16:19:59 2005 +0000 (2005-07-12)
parents 2b6c1a809807
children 79bb7dfb8fc1 a83ac0806d6b
line source
1 /******************************************************************************
2 * netif.h
3 *
4 * Unified network-device I/O interface for Xen guest OSes.
5 *
6 * Copyright (c) 2003-2004, Keir Fraser
7 */
9 #ifndef __XEN_PUBLIC_IO_NETIF_H__
10 #define __XEN_PUBLIC_IO_NETIF_H__
12 typedef struct netif_tx_request {
13 memory_t addr; /* Machine address of packet. */
14 u16 csum_blank:1; /* Proto csum field blank? */
15 u16 id:15; /* Echoed in response message. */
16 u16 size; /* Packet size in bytes. */
17 } netif_tx_request_t;
19 typedef struct netif_tx_response {
20 u16 id;
21 s8 status;
22 } netif_tx_response_t;
24 typedef struct {
25 u16 id; /* Echoed in response message. */
26 } netif_rx_request_t;
28 typedef struct {
29 memory_t addr; /* Machine address of packet. */
30 u16 csum_valid:1; /* Protocol checksum is validated? */
31 u16 id:15;
32 s16 status; /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
33 } netif_rx_response_t;
35 /*
36 * We use a special capitalised type name because it is _essential_ that all
37 * arithmetic on indexes is done on an integer type of the correct size.
38 */
39 typedef u32 NETIF_RING_IDX;
41 /*
42 * Ring indexes are 'free running'. That is, they are not stored modulo the
43 * size of the ring buffer. The following macros convert a free-running counter
44 * into a value that can directly index a ring-buffer array.
45 */
46 #define MASK_NETIF_RX_IDX(_i) ((_i)&(NETIF_RX_RING_SIZE-1))
47 #define MASK_NETIF_TX_IDX(_i) ((_i)&(NETIF_TX_RING_SIZE-1))
49 #define NETIF_TX_RING_SIZE 256
50 #define NETIF_RX_RING_SIZE 256
52 /* This structure must fit in a memory page. */
53 typedef struct netif_tx_interface {
54 /*
55 * Frontend places packets into ring at tx_req_prod.
56 * Frontend receives event when tx_resp_prod passes tx_event.
57 * 'req_cons' is a shadow of the backend's request consumer -- the frontend
58 * may use it to determine if all queued packets have been seen by the
59 * backend.
60 */
61 NETIF_RING_IDX req_prod;
62 NETIF_RING_IDX req_cons;
63 NETIF_RING_IDX resp_prod;
64 NETIF_RING_IDX event;
65 union {
66 netif_tx_request_t req;
67 netif_tx_response_t resp;
68 } ring[NETIF_TX_RING_SIZE];
69 } netif_tx_interface_t;
71 /* This structure must fit in a memory page. */
72 typedef struct netif_rx_interface {
73 /*
74 * Frontend places empty buffers into ring at rx_req_prod.
75 * Frontend receives event when rx_resp_prod passes rx_event.
76 */
77 NETIF_RING_IDX req_prod;
78 NETIF_RING_IDX resp_prod;
79 NETIF_RING_IDX event;
80 union {
81 netif_rx_request_t req;
82 netif_rx_response_t resp;
83 } ring[NETIF_RX_RING_SIZE];
84 } netif_rx_interface_t;
86 /* Descriptor status values */
87 #define NETIF_RSP_DROPPED -2
88 #define NETIF_RSP_ERROR -1
89 #define NETIF_RSP_OKAY 0
91 #endif