4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 * xnb.h - definitions for Xen dom0 network driver
32 #include <sys/types.h>
33 #include <sys/kstat.h>
34 #include <sys/stream.h>
35 #include <sys/ethernet.h>
36 #include <sys/hypervisor.h>
37 #include <sys/sysmacros.h>
38 #include <xen/public/io/netif.h>
44 #define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGESIZE)
45 #define NET_RX_RING_SIZE __CONST_RING_SIZE(netif_rx, PAGESIZE)
47 #define XNBMAXPKT 1500 /* MTU size */
58 #define XNB_STATE_INIT 0x01
59 #define XNB_STATE_READY 0x02
61 typedef struct xnb xnb_t
;
64 * The xnb module provides core inter-domain network protocol functionality.
65 * It is connected to the rest of Solaris in two ways:
66 * - as a GLDv3 driver (with xnbu),
67 * - as a GLDv3 consumer (with xnbo).
69 * The different modes of operation are termed "flavours" and each
70 * instance of an xnb based driver operates in one and only one mode.
71 * The common xnb driver exports a set of functions to these drivers
72 * (declarations at the foot of this file) and calls back into the
73 * drivers via the xnb_flavour_t structure.
75 typedef struct xnb_flavour
{
76 void (*xf_from_peer
)(xnb_t
*, mblk_t
*);
77 boolean_t (*xf_peer_connected
)(xnb_t
*);
78 void (*xf_peer_disconnected
)(xnb_t
*);
79 boolean_t (*xf_hotplug_connected
)(xnb_t
*);
80 boolean_t (*xf_start_connect
)(xnb_t
*);
81 mblk_t
*(*xf_cksum_from_peer
)(xnb_t
*, mblk_t
*, uint16_t);
82 uint16_t (*xf_cksum_to_peer
)(xnb_t
*, mblk_t
*);
83 boolean_t (*xf_mcast_add
)(xnb_t
*, ether_addr_t
*);
84 boolean_t (*xf_mcast_del
)(xnb_t
*, ether_addr_t
*);
87 typedef struct xnb_txbuf
{
90 struct xnb_txbuf
*xt_next
;
95 ddi_dma_handle_t xt_dma_handle
;
96 ddi_acc_handle_t xt_acc_handle
;
103 unsigned int xt_flags
;
105 #define XNB_TXBUF_INUSE 0x01
109 /* Per network-interface-controller driver private structure */
111 /* most interesting stuff first to assist debugging */
112 dev_info_t
*xnb_devinfo
; /* System per-device info. */
114 xnb_flavour_t
*xnb_flavour
;
115 void *xnb_flavour_data
;
118 unsigned char xnb_mac_addr
[ETHERADDRL
];
120 uint64_t xnb_stat_ipackets
;
121 uint64_t xnb_stat_opackets
;
122 uint64_t xnb_stat_rbytes
;
123 uint64_t xnb_stat_obytes
;
125 uint64_t xnb_stat_intr
;
126 uint64_t xnb_stat_rx_defer
;
128 uint64_t xnb_stat_rx_cksum_deferred
;
129 uint64_t xnb_stat_tx_cksum_no_need
;
131 uint64_t xnb_stat_rx_rsp_notok
;
133 uint64_t xnb_stat_tx_notify_sent
;
134 uint64_t xnb_stat_tx_notify_deferred
;
136 uint64_t xnb_stat_rx_notify_sent
;
137 uint64_t xnb_stat_rx_notify_deferred
;
139 uint64_t xnb_stat_tx_too_early
;
140 uint64_t xnb_stat_rx_too_early
;
141 uint64_t xnb_stat_rx_allocb_failed
;
142 uint64_t xnb_stat_tx_allocb_failed
;
143 uint64_t xnb_stat_rx_foreign_page
;
144 uint64_t xnb_stat_tx_overflow_page
;
145 uint64_t xnb_stat_tx_unexpected_flags
;
146 uint64_t xnb_stat_mac_full
;
147 uint64_t xnb_stat_spurious_intr
;
148 uint64_t xnb_stat_allocation_success
;
149 uint64_t xnb_stat_allocation_failure
;
150 uint64_t xnb_stat_small_allocation_success
;
151 uint64_t xnb_stat_small_allocation_failure
;
152 uint64_t xnb_stat_other_allocation_failure
;
154 uint64_t xnb_stat_rx_pagebndry_crossed
;
155 uint64_t xnb_stat_rx_cpoparea_grown
;
157 uint64_t xnb_stat_csum_hardware
;
158 uint64_t xnb_stat_csum_software
;
160 kstat_t
*xnb_kstat_aux
;
162 ddi_iblock_cookie_t xnb_icookie
;
164 kmutex_t xnb_rx_lock
;
165 kmutex_t xnb_tx_lock
;
166 kmutex_t xnb_state_lock
;
171 kmem_cache_t
*xnb_tx_buf_cache
;
172 uint32_t xnb_tx_buf_count
;
173 int xnb_tx_buf_outstanding
;
175 netif_rx_back_ring_t xnb_rx_ring
; /* rx interface struct ptr */
176 void *xnb_rx_ring_addr
;
177 grant_ref_t xnb_rx_ring_ref
;
178 grant_handle_t xnb_rx_ring_handle
;
180 netif_tx_back_ring_t xnb_tx_ring
; /* tx interface struct ptr */
181 void *xnb_tx_ring_addr
;
182 grant_ref_t xnb_tx_ring_ref
;
183 grant_handle_t xnb_tx_ring_handle
;
185 boolean_t xnb_connected
;
186 boolean_t xnb_hotplugged
;
187 boolean_t xnb_detachable
;
188 int xnb_evtchn
; /* channel to front end */
189 evtchn_port_t xnb_fe_evtchn
;
192 xnb_txbuf_t
*xnb_tx_bufp
[NET_TX_RING_SIZE
];
193 gnttab_copy_t xnb_tx_cop
[NET_TX_RING_SIZE
];
196 gnttab_transfer_t xnb_rx_top
[NET_RX_RING_SIZE
];
198 boolean_t xnb_rx_hv_copy
;
199 boolean_t xnb_multicast_control
;
200 boolean_t xnb_no_csum_offload
;
202 gnttab_copy_t
*xnb_rx_cpop
;
203 #define CPOP_DEFCNT 8
204 size_t xnb_rx_cpop_count
; /* in elements */
207 extern int xnb_attach(dev_info_t
*, xnb_flavour_t
*, void *);
208 extern void xnb_detach(dev_info_t
*);
209 extern mblk_t
*xnb_copy_to_peer(xnb_t
*, mblk_t
*);
210 extern mblk_t
*xnb_process_cksum_flags(xnb_t
*, mblk_t
*, uint32_t);
216 #endif /* _SYS_XNB_H */