16495Sspeer /* 26495Sspeer * CDDL HEADER START 36495Sspeer * 46495Sspeer * The contents of this file are subject to the terms of the 56495Sspeer * Common Development and Distribution License (the "License"). 66495Sspeer * You may not use this file except in compliance with the License. 76495Sspeer * 86495Sspeer * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 96495Sspeer * or http://www.opensolaris.org/os/licensing. 106495Sspeer * See the License for the specific language governing permissions 116495Sspeer * and limitations under the License. 126495Sspeer * 136495Sspeer * When distributing Covered Code, include this CDDL HEADER in each 146495Sspeer * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 156495Sspeer * If applicable, add the following below this CDDL HEADER, with the 166495Sspeer * fields enclosed by brackets "[]" replaced with your own identifying 176495Sspeer * information: Portions Copyright [yyyy] [name of copyright owner] 186495Sspeer * 196495Sspeer * CDDL HEADER END 206495Sspeer */ 216495Sspeer 226495Sspeer /* 236495Sspeer * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 246495Sspeer * Use is subject to license terms. 256495Sspeer */ 266495Sspeer 276495Sspeer #ifndef _VNET_RES_H 286495Sspeer #define _VNET_RES_H 296495Sspeer 306495Sspeer #ifdef __cplusplus 316495Sspeer extern "C" { 326495Sspeer #endif 336495Sspeer 34*8275SEric Cheng #include <sys/mac_provider.h> 35*8275SEric Cheng 366495Sspeer /* 376495Sspeer * Vio network resource types. 386495Sspeer * VIO_NET_RES_LDC_SERVICE: 396495Sspeer * An LDC based resource corresonding to vswitch 406495Sspeer * service. This means, all broadcast pakets need 416495Sspeer * to be sent via this resource. Unicast packets 426495Sspeer * that have no known end point will also be sent 436495Sspeer * via this resource, but only if no Hybrid resource 446495Sspeer * is available. 456495Sspeer * 466495Sspeer * VIO_NET_RES_LDC_GUEST: 476495Sspeer * An LDC based resource corresponding to another 486495Sspeer * guest domain. This means, unicast packets to that 496495Sspeer * guest's mac addres will be sent via this resource. 506495Sspeer * 516495Sspeer * VIO_NET_RES_HYBRID: 526495Sspeer * A Hybrid resource. Even though this resource may 536495Sspeer * be capable of transmitting the broadcast/multicast 546495Sspeer * traffic, it will be used only for transmitting 556495Sspeer * uni-cast traffic. 566495Sspeer * This is because the broadcast/multicast traffic needs 576495Sspeer * to be sent to the vswitch so that those packets 586495Sspeer * are sent to other guest domains and vswitch interface. 596495Sspeer */ 606495Sspeer typedef enum { 616495Sspeer VIO_NET_RES_LDC_SERVICE, 626495Sspeer VIO_NET_RES_LDC_GUEST, 636495Sspeer VIO_NET_RES_HYBRID 646495Sspeer } vio_net_res_type_t; 656495Sspeer 666495Sspeer /* A handle returned by vio_net_resource_reg() interface */ 676495Sspeer typedef void *vio_net_handle_t; 686495Sspeer 696495Sspeer 706495Sspeer /* 716495Sspeer * Callback functions returned via the reg() interfce. 726495Sspeer * 736495Sspeer * vio_net_rx_cb: Used for passing the packets that are received 746495Sspeer * by a device. This is equivalent of mac_rx(). 756495Sspeer * 766495Sspeer * vio_net_tx_update: Used for re-starting the transmission. This 776495Sspeer * is an equivalent of mac_tx_update(). 786495Sspeer * 796495Sspeer * vio_net_report_err: Used for reporting any errors with the resource. 806495Sspeer */ 816495Sspeer typedef void (*vio_net_rx_cb_t)(vio_net_handle_t, mblk_t *); 826495Sspeer typedef void (*vio_net_tx_update_t)(vio_net_handle_t); 836495Sspeer 846495Sspeer typedef enum { 856495Sspeer VIO_NET_RES_DOWN, /* Resource down */ 866495Sspeer VIO_VNET_RES_ERR /* Resource encountered an error */ 876495Sspeer } vio_net_err_val_t; 886495Sspeer 896495Sspeer typedef void (*vio_net_report_err_t)(vio_net_handle_t, vio_net_err_val_t err); 906495Sspeer 916495Sspeer typedef struct vio_net_callbacks_s { 926495Sspeer vio_net_rx_cb_t vio_net_rx_cb; 936495Sspeer vio_net_tx_update_t vio_net_tx_update; 946495Sspeer vio_net_report_err_t vio_net_report_err; 956495Sspeer } vio_net_callbacks_t; 966495Sspeer 976495Sspeer 986495Sspeer /* 996495Sspeer * vio_net_resource_reg -- An interface to register a resource with vnet. 1006495Sspeer * 1016495Sspeer * macp: A mac_register_t structure representing the 1026495Sspeer * device and its MAC driver callbacks. 1036495Sspeer * type: Type of the device. 1046495Sspeer * 1056495Sspeer * local-macaddr: A MAC address to which this resource belongs to. 1066495Sspeer * 1076495Sspeer * rem_macaddr: A MAC address of the peer. This is only applicable 1086495Sspeer * to LDC based resource. This argument is ignored 1096495Sspeer * for HYBRID resource. 1106495Sspeer * vhp: A handle returned by this interface. After a 1116495Sspeer * successful return of this interface, 1126495Sspeer * all other interaction will use this handle. 1136495Sspeer * 1146495Sspeer * vcb: A set of callbacks returned by this interface 1156495Sspeer * for the use of the devices to pass packets etc. 1166495Sspeer * 1176495Sspeer * Return value: 0 for success, non-zero errno value appropriate for the error. 1186495Sspeer */ 1196495Sspeer int vio_net_resource_reg(mac_register_t *macp, 1206495Sspeer vio_net_res_type_t type, ether_addr_t local_maddr, ether_addr_t rem_maddr, 1216495Sspeer vio_net_handle_t *vhp, vio_net_callbacks_t *vcb); 1226495Sspeer 1236495Sspeer /* A useful typedef for consumers of this interface */ 1246495Sspeer typedef int (*vio_net_resource_reg_t)(mac_register_t *macp, 1256495Sspeer vio_net_res_type_t type, ether_addr_t local_maddr, ether_addr_t rem_maddr, 1266495Sspeer vio_net_handle_t *vhp, vio_net_callbacks_t *vcb); 1276495Sspeer 1286495Sspeer 1296495Sspeer 1306495Sspeer /* 1316495Sspeer * vio_net_resource_unreg -- Unregisters a resource. 1326495Sspeer * 1336495Sspeer * vhp: handle that was returned by the resource_reg() interface. 1346495Sspeer */ 1356495Sspeer void vio_net_resource_unreg(vio_net_handle_t vhp); 1366495Sspeer 1376495Sspeer /* A useful typedef for consumers of this interface */ 1386495Sspeer typedef void (*vio_net_resource_unreg_t)(vio_net_handle_t vhp); 1396495Sspeer 1406495Sspeer #ifdef __cplusplus 1416495Sspeer } 1426495Sspeer #endif 1436495Sspeer 1446495Sspeer #endif /* _VNET_RES_H */ 145