ia64/xen-unstable

view xen/include/public/io/netif.h @ 5786:79bb7dfb8fc1

Temporary fix for netif ring overflow, until we move
netfront/netback to grant tables.
author kaf24@firebug.cl.cam.ac.uk
date Fri Jul 15 08:22:18 2005 +0000 (2005-07-15)
parents 2b6c1a809807
children 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 #ifdef __x86_64__
50 /*
51 * This restriction can be lifted when we move netfront/netback to use
52 * grant tables. This will remove memory_t fields from the above structures
53 * and thus relax natural alignment restrictions.
54 */
55 #define NETIF_TX_RING_SIZE 128
56 #define NETIF_RX_RING_SIZE 128
57 #else
58 #define NETIF_TX_RING_SIZE 256
59 #define NETIF_RX_RING_SIZE 256
60 #endif
62 /* This structure must fit in a memory page. */
63 typedef struct netif_tx_interface {
64 /*
65 * Frontend places packets into ring at tx_req_prod.
66 * Frontend receives event when tx_resp_prod passes tx_event.
67 * 'req_cons' is a shadow of the backend's request consumer -- the frontend
68 * may use it to determine if all queued packets have been seen by the
69 * backend.
70 */
71 NETIF_RING_IDX req_prod;
72 NETIF_RING_IDX req_cons;
73 NETIF_RING_IDX resp_prod;
74 NETIF_RING_IDX event;
75 union {
76 netif_tx_request_t req;
77 netif_tx_response_t resp;
78 } ring[NETIF_TX_RING_SIZE];
79 } netif_tx_interface_t;
81 /* This structure must fit in a memory page. */
82 typedef struct netif_rx_interface {
83 /*
84 * Frontend places empty buffers into ring at rx_req_prod.
85 * Frontend receives event when rx_resp_prod passes rx_event.
86 */
87 NETIF_RING_IDX req_prod;
88 NETIF_RING_IDX resp_prod;
89 NETIF_RING_IDX event;
90 union {
91 netif_rx_request_t req;
92 netif_rx_response_t resp;
93 } ring[NETIF_RX_RING_SIZE];
94 } netif_rx_interface_t;
96 /* Descriptor status values */
97 #define NETIF_RSP_DROPPED -2
98 #define NETIF_RSP_ERROR -1
99 #define NETIF_RSP_OKAY 0
101 #endif