8416 abd.h is not C++ friendly
[unleashed.git] / usr / src / uts / sun4v / sys / vnet_res.h
blobb5cd4472fb91c517bdcbe6682a82d677ac5152a4
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _VNET_RES_H
28 #define _VNET_RES_H
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 #include <sys/mac_provider.h>
37 * Vio network resource types.
38 * VIO_NET_RES_LDC_SERVICE:
39 * An LDC based resource corresonding to vswitch
40 * service. This means, all broadcast pakets need
41 * to be sent via this resource. Unicast packets
42 * that have no known end point will also be sent
43 * via this resource, but only if no Hybrid resource
44 * is available.
46 * VIO_NET_RES_LDC_GUEST:
47 * An LDC based resource corresponding to another
48 * guest domain. This means, unicast packets to that
49 * guest's mac addres will be sent via this resource.
51 * VIO_NET_RES_HYBRID:
52 * A Hybrid resource. Even though this resource may
53 * be capable of transmitting the broadcast/multicast
54 * traffic, it will be used only for transmitting
55 * uni-cast traffic.
56 * This is because the broadcast/multicast traffic needs
57 * to be sent to the vswitch so that those packets
58 * are sent to other guest domains and vswitch interface.
60 typedef enum {
61 VIO_NET_RES_LDC_SERVICE,
62 VIO_NET_RES_LDC_GUEST,
63 VIO_NET_RES_HYBRID
64 } vio_net_res_type_t;
66 /* A handle returned by vio_net_resource_reg() interface */
67 typedef void *vio_net_handle_t;
71 * Callback functions returned via the reg() interfce.
73 * vio_net_rx_cb: Used for passing the packets that are received
74 * by a device. This is equivalent of mac_rx().
76 * vio_net_tx_update: Used for re-starting the transmission. This
77 * is an equivalent of mac_tx_update().
79 * vio_net_report_err: Used for reporting any errors with the resource.
81 typedef void (*vio_net_rx_cb_t)(vio_net_handle_t, mblk_t *);
82 typedef void (*vio_net_tx_update_t)(vio_net_handle_t);
84 typedef enum {
85 VIO_NET_RES_DOWN, /* Resource down */
86 VIO_VNET_RES_ERR /* Resource encountered an error */
87 } vio_net_err_val_t;
89 typedef void (*vio_net_report_err_t)(vio_net_handle_t, vio_net_err_val_t err);
91 typedef struct vio_net_callbacks_s {
92 vio_net_rx_cb_t vio_net_rx_cb;
93 vio_net_tx_update_t vio_net_tx_update;
94 vio_net_report_err_t vio_net_report_err;
95 } vio_net_callbacks_t;
99 * vio_net_resource_reg -- An interface to register a resource with vnet.
101 * macp: A mac_register_t structure representing the
102 * device and its MAC driver callbacks.
103 * type: Type of the device.
105 * local-macaddr: A MAC address to which this resource belongs to.
107 * rem_macaddr: A MAC address of the peer. This is only applicable
108 * to LDC based resource. This argument is ignored
109 * for HYBRID resource.
110 * vhp: A handle returned by this interface. After a
111 * successful return of this interface,
112 * all other interaction will use this handle.
114 * vcb: A set of callbacks returned by this interface
115 * for the use of the devices to pass packets etc.
117 * Return value: 0 for success, non-zero errno value appropriate for the error.
119 int vio_net_resource_reg(mac_register_t *macp,
120 vio_net_res_type_t type, ether_addr_t local_maddr, ether_addr_t rem_maddr,
121 vio_net_handle_t *vhp, vio_net_callbacks_t *vcb);
123 /* A useful typedef for consumers of this interface */
124 typedef int (*vio_net_resource_reg_t)(mac_register_t *macp,
125 vio_net_res_type_t type, ether_addr_t local_maddr, ether_addr_t rem_maddr,
126 vio_net_handle_t *vhp, vio_net_callbacks_t *vcb);
131 * vio_net_resource_unreg -- Unregisters a resource.
133 * vhp: handle that was returned by the resource_reg() interface.
135 void vio_net_resource_unreg(vio_net_handle_t vhp);
137 /* A useful typedef for consumers of this interface */
138 typedef void (*vio_net_resource_unreg_t)(vio_net_handle_t vhp);
140 #ifdef __cplusplus
142 #endif
144 #endif /* _VNET_RES_H */