1678453a8Sspeer /* 2678453a8Sspeer * CDDL HEADER START 3678453a8Sspeer * 4678453a8Sspeer * The contents of this file are subject to the terms of the 5678453a8Sspeer * Common Development and Distribution License (the "License"). 6678453a8Sspeer * You may not use this file except in compliance with the License. 7678453a8Sspeer * 8678453a8Sspeer * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9678453a8Sspeer * or http://www.opensolaris.org/os/licensing. 10678453a8Sspeer * See the License for the specific language governing permissions 11678453a8Sspeer * and limitations under the License. 12678453a8Sspeer * 13678453a8Sspeer * When distributing Covered Code, include this CDDL HEADER in each 14678453a8Sspeer * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15678453a8Sspeer * If applicable, add the following below this CDDL HEADER, with the 16678453a8Sspeer * fields enclosed by brackets "[]" replaced with your own identifying 17678453a8Sspeer * information: Portions Copyright [yyyy] [name of copyright owner] 18678453a8Sspeer * 19678453a8Sspeer * CDDL HEADER END 20678453a8Sspeer */ 21678453a8Sspeer 22678453a8Sspeer /* 23678453a8Sspeer * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24678453a8Sspeer * Use is subject to license terms. 25678453a8Sspeer */ 26678453a8Sspeer 27678453a8Sspeer #ifndef _VNET_RES_H 28678453a8Sspeer #define _VNET_RES_H 29678453a8Sspeer 30678453a8Sspeer #ifdef __cplusplus 31678453a8Sspeer extern "C" { 32678453a8Sspeer #endif 33678453a8Sspeer 34*da14cebeSEric Cheng #include <sys/mac_provider.h> 35*da14cebeSEric Cheng 36678453a8Sspeer /* 37678453a8Sspeer * Vio network resource types. 38678453a8Sspeer * VIO_NET_RES_LDC_SERVICE: 39678453a8Sspeer * An LDC based resource corresonding to vswitch 40678453a8Sspeer * service. This means, all broadcast pakets need 41678453a8Sspeer * to be sent via this resource. Unicast packets 42678453a8Sspeer * that have no known end point will also be sent 43678453a8Sspeer * via this resource, but only if no Hybrid resource 44678453a8Sspeer * is available. 45678453a8Sspeer * 46678453a8Sspeer * VIO_NET_RES_LDC_GUEST: 47678453a8Sspeer * An LDC based resource corresponding to another 48678453a8Sspeer * guest domain. This means, unicast packets to that 49678453a8Sspeer * guest's mac addres will be sent via this resource. 50678453a8Sspeer * 51678453a8Sspeer * VIO_NET_RES_HYBRID: 52678453a8Sspeer * A Hybrid resource. Even though this resource may 53678453a8Sspeer * be capable of transmitting the broadcast/multicast 54678453a8Sspeer * traffic, it will be used only for transmitting 55678453a8Sspeer * uni-cast traffic. 56678453a8Sspeer * This is because the broadcast/multicast traffic needs 57678453a8Sspeer * to be sent to the vswitch so that those packets 58678453a8Sspeer * are sent to other guest domains and vswitch interface. 59678453a8Sspeer */ 60678453a8Sspeer typedef enum { 61678453a8Sspeer VIO_NET_RES_LDC_SERVICE, 62678453a8Sspeer VIO_NET_RES_LDC_GUEST, 63678453a8Sspeer VIO_NET_RES_HYBRID 64678453a8Sspeer } vio_net_res_type_t; 65678453a8Sspeer 66678453a8Sspeer /* A handle returned by vio_net_resource_reg() interface */ 67678453a8Sspeer typedef void *vio_net_handle_t; 68678453a8Sspeer 69678453a8Sspeer 70678453a8Sspeer /* 71678453a8Sspeer * Callback functions returned via the reg() interfce. 72678453a8Sspeer * 73678453a8Sspeer * vio_net_rx_cb: Used for passing the packets that are received 74678453a8Sspeer * by a device. This is equivalent of mac_rx(). 75678453a8Sspeer * 76678453a8Sspeer * vio_net_tx_update: Used for re-starting the transmission. This 77678453a8Sspeer * is an equivalent of mac_tx_update(). 78678453a8Sspeer * 79678453a8Sspeer * vio_net_report_err: Used for reporting any errors with the resource. 80678453a8Sspeer */ 81678453a8Sspeer typedef void (*vio_net_rx_cb_t)(vio_net_handle_t, mblk_t *); 82678453a8Sspeer typedef void (*vio_net_tx_update_t)(vio_net_handle_t); 83678453a8Sspeer 84678453a8Sspeer typedef enum { 85678453a8Sspeer VIO_NET_RES_DOWN, /* Resource down */ 86678453a8Sspeer VIO_VNET_RES_ERR /* Resource encountered an error */ 87678453a8Sspeer } vio_net_err_val_t; 88678453a8Sspeer 89678453a8Sspeer typedef void (*vio_net_report_err_t)(vio_net_handle_t, vio_net_err_val_t err); 90678453a8Sspeer 91678453a8Sspeer typedef struct vio_net_callbacks_s { 92678453a8Sspeer vio_net_rx_cb_t vio_net_rx_cb; 93678453a8Sspeer vio_net_tx_update_t vio_net_tx_update; 94678453a8Sspeer vio_net_report_err_t vio_net_report_err; 95678453a8Sspeer } vio_net_callbacks_t; 96678453a8Sspeer 97678453a8Sspeer 98678453a8Sspeer /* 99678453a8Sspeer * vio_net_resource_reg -- An interface to register a resource with vnet. 100678453a8Sspeer * 101678453a8Sspeer * macp: A mac_register_t structure representing the 102678453a8Sspeer * device and its MAC driver callbacks. 103678453a8Sspeer * type: Type of the device. 104678453a8Sspeer * 105678453a8Sspeer * local-macaddr: A MAC address to which this resource belongs to. 106678453a8Sspeer * 107678453a8Sspeer * rem_macaddr: A MAC address of the peer. This is only applicable 108678453a8Sspeer * to LDC based resource. This argument is ignored 109678453a8Sspeer * for HYBRID resource. 110678453a8Sspeer * vhp: A handle returned by this interface. After a 111678453a8Sspeer * successful return of this interface, 112678453a8Sspeer * all other interaction will use this handle. 113678453a8Sspeer * 114678453a8Sspeer * vcb: A set of callbacks returned by this interface 115678453a8Sspeer * for the use of the devices to pass packets etc. 116678453a8Sspeer * 117678453a8Sspeer * Return value: 0 for success, non-zero errno value appropriate for the error. 118678453a8Sspeer */ 119678453a8Sspeer int vio_net_resource_reg(mac_register_t *macp, 120678453a8Sspeer vio_net_res_type_t type, ether_addr_t local_maddr, ether_addr_t rem_maddr, 121678453a8Sspeer vio_net_handle_t *vhp, vio_net_callbacks_t *vcb); 122678453a8Sspeer 123678453a8Sspeer /* A useful typedef for consumers of this interface */ 124678453a8Sspeer typedef int (*vio_net_resource_reg_t)(mac_register_t *macp, 125678453a8Sspeer vio_net_res_type_t type, ether_addr_t local_maddr, ether_addr_t rem_maddr, 126678453a8Sspeer vio_net_handle_t *vhp, vio_net_callbacks_t *vcb); 127678453a8Sspeer 128678453a8Sspeer 129678453a8Sspeer 130678453a8Sspeer /* 131678453a8Sspeer * vio_net_resource_unreg -- Unregisters a resource. 132678453a8Sspeer * 133678453a8Sspeer * vhp: handle that was returned by the resource_reg() interface. 134678453a8Sspeer */ 135678453a8Sspeer void vio_net_resource_unreg(vio_net_handle_t vhp); 136678453a8Sspeer 137678453a8Sspeer /* A useful typedef for consumers of this interface */ 138678453a8Sspeer typedef void (*vio_net_resource_unreg_t)(vio_net_handle_t vhp); 139678453a8Sspeer 140678453a8Sspeer #ifdef __cplusplus 141678453a8Sspeer } 142678453a8Sspeer #endif 143678453a8Sspeer 144678453a8Sspeer #endif /* _VNET_RES_H */ 145