/kernel/2.6.32_froyo_photon_nightly/include/xen/interface/io/netif.h

http://photon-android.googlecode.com/ · C++ Header · 158 lines · 71 code · 29 blank · 58 comment · 0 complexity · 4d2b6296e5129ff4cd40b37e010555aa MD5 · raw file

  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. */
  8. #ifndef __XEN_PUBLIC_IO_NETIF_H__
  9. #define __XEN_PUBLIC_IO_NETIF_H__
  10. #include "ring.h"
  11. #include "../grant_table.h"
  12. /*
  13. * Notifications after enqueuing any type of message should be conditional on
  14. * the appropriate req_event or rsp_event field in the shared ring.
  15. * If the client sends notification for rx requests then it should specify
  16. * feature 'feature-rx-notify' via xenbus. Otherwise the backend will assume
  17. * that it cannot safely queue packets (as it may not be kicked to send them).
  18. */
  19. /*
  20. * This is the 'wire' format for packets:
  21. * Request 1: netif_tx_request -- NETTXF_* (any flags)
  22. * [Request 2: netif_tx_extra] (only if request 1 has NETTXF_extra_info)
  23. * [Request 3: netif_tx_extra] (only if request 2 has XEN_NETIF_EXTRA_MORE)
  24. * Request 4: netif_tx_request -- NETTXF_more_data
  25. * Request 5: netif_tx_request -- NETTXF_more_data
  26. * ...
  27. * Request N: netif_tx_request -- 0
  28. */
  29. /* Protocol checksum field is blank in the packet (hardware offload)? */
  30. #define _NETTXF_csum_blank (0)
  31. #define NETTXF_csum_blank (1U<<_NETTXF_csum_blank)
  32. /* Packet data has been validated against protocol checksum. */
  33. #define _NETTXF_data_validated (1)
  34. #define NETTXF_data_validated (1U<<_NETTXF_data_validated)
  35. /* Packet continues in the next request descriptor. */
  36. #define _NETTXF_more_data (2)
  37. #define NETTXF_more_data (1U<<_NETTXF_more_data)
  38. /* Packet to be followed by extra descriptor(s). */
  39. #define _NETTXF_extra_info (3)
  40. #define NETTXF_extra_info (1U<<_NETTXF_extra_info)
  41. struct xen_netif_tx_request {
  42. grant_ref_t gref; /* Reference to buffer page */
  43. uint16_t offset; /* Offset within buffer page */
  44. uint16_t flags; /* NETTXF_* */
  45. uint16_t id; /* Echoed in response message. */
  46. uint16_t size; /* Packet size in bytes. */
  47. };
  48. /* Types of netif_extra_info descriptors. */
  49. #define XEN_NETIF_EXTRA_TYPE_NONE (0) /* Never used - invalid */
  50. #define XEN_NETIF_EXTRA_TYPE_GSO (1) /* u.gso */
  51. #define XEN_NETIF_EXTRA_TYPE_MAX (2)
  52. /* netif_extra_info flags. */
  53. #define _XEN_NETIF_EXTRA_FLAG_MORE (0)
  54. #define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)
  55. /* GSO types - only TCPv4 currently supported. */
  56. #define XEN_NETIF_GSO_TYPE_TCPV4 (1)
  57. /*
  58. * This structure needs to fit within both netif_tx_request and
  59. * netif_rx_response for compatibility.
  60. */
  61. struct xen_netif_extra_info {
  62. uint8_t type; /* XEN_NETIF_EXTRA_TYPE_* */
  63. uint8_t flags; /* XEN_NETIF_EXTRA_FLAG_* */
  64. union {
  65. struct {
  66. /*
  67. * Maximum payload size of each segment. For
  68. * example, for TCP this is just the path MSS.
  69. */
  70. uint16_t size;
  71. /*
  72. * GSO type. This determines the protocol of
  73. * the packet and any extra features required
  74. * to segment the packet properly.
  75. */
  76. uint8_t type; /* XEN_NETIF_GSO_TYPE_* */
  77. /* Future expansion. */
  78. uint8_t pad;
  79. /*
  80. * GSO features. This specifies any extra GSO
  81. * features required to process this packet,
  82. * such as ECN support for TCPv4.
  83. */
  84. uint16_t features; /* XEN_NETIF_GSO_FEAT_* */
  85. } gso;
  86. uint16_t pad[3];
  87. } u;
  88. };
  89. struct xen_netif_tx_response {
  90. uint16_t id;
  91. int16_t status; /* NETIF_RSP_* */
  92. };
  93. struct xen_netif_rx_request {
  94. uint16_t id; /* Echoed in response message. */
  95. grant_ref_t gref; /* Reference to incoming granted frame */
  96. };
  97. /* Packet data has been validated against protocol checksum. */
  98. #define _NETRXF_data_validated (0)
  99. #define NETRXF_data_validated (1U<<_NETRXF_data_validated)
  100. /* Protocol checksum field is blank in the packet (hardware offload)? */
  101. #define _NETRXF_csum_blank (1)
  102. #define NETRXF_csum_blank (1U<<_NETRXF_csum_blank)
  103. /* Packet continues in the next request descriptor. */
  104. #define _NETRXF_more_data (2)
  105. #define NETRXF_more_data (1U<<_NETRXF_more_data)
  106. /* Packet to be followed by extra descriptor(s). */
  107. #define _NETRXF_extra_info (3)
  108. #define NETRXF_extra_info (1U<<_NETRXF_extra_info)
  109. struct xen_netif_rx_response {
  110. uint16_t id;
  111. uint16_t offset; /* Offset in page of start of received packet */
  112. uint16_t flags; /* NETRXF_* */
  113. int16_t status; /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
  114. };
  115. /*
  116. * Generate netif ring structures and types.
  117. */
  118. DEFINE_RING_TYPES(xen_netif_tx,
  119. struct xen_netif_tx_request,
  120. struct xen_netif_tx_response);
  121. DEFINE_RING_TYPES(xen_netif_rx,
  122. struct xen_netif_rx_request,
  123. struct xen_netif_rx_response);
  124. #define NETIF_RSP_DROPPED -2
  125. #define NETIF_RSP_ERROR -1
  126. #define NETIF_RSP_OKAY 0
  127. /* No response: used for auxiliary requests (e.g., netif_tx_extra). */
  128. #define NETIF_RSP_NULL 1
  129. #endif