15084Sjohnlev /* 25084Sjohnlev * CDDL HEADER START 35084Sjohnlev * 45084Sjohnlev * The contents of this file are subject to the terms of the 55084Sjohnlev * Common Development and Distribution License (the "License"). 65084Sjohnlev * You may not use this file except in compliance with the License. 75084Sjohnlev * 85084Sjohnlev * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 95084Sjohnlev * or http://www.opensolaris.org/os/licensing. 105084Sjohnlev * See the License for the specific language governing permissions 115084Sjohnlev * and limitations under the License. 125084Sjohnlev * 135084Sjohnlev * When distributing Covered Code, include this CDDL HEADER in each 145084Sjohnlev * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 155084Sjohnlev * If applicable, add the following below this CDDL HEADER, with the 165084Sjohnlev * fields enclosed by brackets "[]" replaced with your own identifying 175084Sjohnlev * information: Portions Copyright [yyyy] [name of copyright owner] 185084Sjohnlev * 195084Sjohnlev * CDDL HEADER END 205084Sjohnlev */ 215084Sjohnlev /* 22*11878SVenu.Iyer@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 235084Sjohnlev * Use is subject to license terms. 245084Sjohnlev */ 255084Sjohnlev 265084Sjohnlev #ifndef _SYS_VNIC_H 275084Sjohnlev #define _SYS_VNIC_H 285084Sjohnlev 295084Sjohnlev #include <sys/types.h> 305084Sjohnlev #include <sys/ethernet.h> 315084Sjohnlev #include <sys/param.h> 325084Sjohnlev #include <sys/mac.h> 338275SEric Cheng #include <sys/mac_flow.h> 347408SSebastien.Roy@Sun.COM #include <sys/dld_ioc.h> 358275SEric Cheng #include <inet/ip.h> 368275SEric Cheng #include <inet/ip6.h> 375084Sjohnlev 385084Sjohnlev #ifdef __cplusplus 395084Sjohnlev extern "C" { 405084Sjohnlev #endif 415084Sjohnlev 427408SSebastien.Roy@Sun.COM /* 438275SEric Cheng * Extended diagnostic codes that can be returned by the various 447408SSebastien.Roy@Sun.COM */ 458275SEric Cheng typedef enum { 468275SEric Cheng VNIC_IOC_DIAG_NONE, 478275SEric Cheng VNIC_IOC_DIAG_MACADDR_NIC, 488275SEric Cheng VNIC_IOC_DIAG_MACADDR_INUSE, 498275SEric Cheng VNIC_IOC_DIAG_MACADDR_INVALID, 508275SEric Cheng VNIC_IOC_DIAG_MACADDRLEN_INVALID, 518275SEric Cheng VNIC_IOC_DIAG_MACFACTORYSLOTINVALID, 528275SEric Cheng VNIC_IOC_DIAG_MACFACTORYSLOTUSED, 538275SEric Cheng VNIC_IOC_DIAG_MACFACTORYSLOTALLUSED, 548275SEric Cheng VNIC_IOC_DIAG_MACFACTORYNOTSUP, 558275SEric Cheng VNIC_IOC_DIAG_MACPREFIX_INVALID, 568275SEric Cheng VNIC_IOC_DIAG_MACPREFIXLEN_INVALID, 578275SEric Cheng VNIC_IOC_DIAG_MACMARGIN_INVALID, 588275SEric Cheng VNIC_IOC_DIAG_NO_HWRINGS 598275SEric Cheng } vnic_ioc_diag_t; 605084Sjohnlev 615084Sjohnlev /* 628275SEric Cheng * Allowed VNIC MAC address types. 638275SEric Cheng * 648275SEric Cheng * - VNIC_MAC_ADDR_TYPE_FIXED, VNIC_MAC_ADDR_TYPE_RANDOM: 658275SEric Cheng * The MAC address is specified by value by the caller, which 668275SEric Cheng * itself can obtain it from the user directly, 678275SEric Cheng * or pick it in a random fashion. Which method is used by the 688275SEric Cheng * caller is irrelevant to the VNIC driver. However two different 698275SEric Cheng * types are provided so that the information can be made available 708275SEric Cheng * back to user-space when listing the kernel defined VNICs. 718275SEric Cheng * 728275SEric Cheng * When a VNIC is created, the address in passed through the 738275SEric Cheng * vc_mac_addr and vc_mac_len fields of the vnic_ioc_create_t 748275SEric Cheng * structure. 758275SEric Cheng * 768275SEric Cheng * - VNIC_MAC_ADDR_TYPE_FACTORY: the MAC address is obtained from 778275SEric Cheng * one of the MAC factory MAC addresses of the underyling NIC. 788275SEric Cheng * 798275SEric Cheng * - VNIC_MAC_ADDR_TYPE_AUTO: the VNIC driver attempts to 808275SEric Cheng * obtain the address from one of the factory MAC addresses of 818275SEric Cheng * the underlying NIC. If none is available, the specified 828275SEric Cheng * MAC address value is used. 838275SEric Cheng * 848275SEric Cheng * - VNIC_MAC_ADDR_TYPE_PRIMARY: this is a VNIC based VLAN. The 858275SEric Cheng * address for this is the address of the primary MAC client. 868275SEric Cheng * 875084Sjohnlev */ 885084Sjohnlev 895084Sjohnlev typedef enum { 9011076SCathy.Zhou@Sun.COM VNIC_MAC_ADDR_TYPE_UNKNOWN = -1, 918275SEric Cheng VNIC_MAC_ADDR_TYPE_FIXED, 928275SEric Cheng VNIC_MAC_ADDR_TYPE_RANDOM, 938275SEric Cheng VNIC_MAC_ADDR_TYPE_FACTORY, 948275SEric Cheng VNIC_MAC_ADDR_TYPE_AUTO, 9511076SCathy.Zhou@Sun.COM VNIC_MAC_ADDR_TYPE_PRIMARY, 9611076SCathy.Zhou@Sun.COM VNIC_MAC_ADDR_TYPE_VRID 975084Sjohnlev } vnic_mac_addr_type_t; 985084Sjohnlev 998275SEric Cheng #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 1008275SEric Cheng #pragma pack(4) 1018275SEric Cheng #endif 1028275SEric Cheng 1037408SSebastien.Roy@Sun.COM #define VNIC_IOC_CREATE VNICIOC(1) 1045084Sjohnlev 1058275SEric Cheng #define VNIC_IOC_CREATE_NODUPCHECK 0x00000001 1068275SEric Cheng #define VNIC_IOC_CREATE_ANCHOR 0x00000002 1078275SEric Cheng 1088275SEric Cheng /* 1098275SEric Cheng * Force creation of VLAN based VNIC without checking if the 1108275SEric Cheng * undelying MAC supports the margin size. 1118275SEric Cheng */ 1128275SEric Cheng #define VNIC_IOC_CREATE_FORCE 0x00000004 1138275SEric Cheng 1145084Sjohnlev typedef struct vnic_ioc_create { 1155895Syz147064 datalink_id_t vc_vnic_id; 1165895Syz147064 datalink_id_t vc_link_id; 1178275SEric Cheng vnic_mac_addr_type_t vc_mac_addr_type; 1185084Sjohnlev uint_t vc_mac_len; 1195084Sjohnlev uchar_t vc_mac_addr[MAXMACADDRLEN]; 1208275SEric Cheng uint_t vc_mac_prefix_len; 1218275SEric Cheng int vc_mac_slot; 1228275SEric Cheng uint16_t vc_vid; 12311076SCathy.Zhou@Sun.COM vrid_t vc_vrid; 12411076SCathy.Zhou@Sun.COM int vc_af; 1258275SEric Cheng uint_t vc_status; 1268275SEric Cheng uint_t vc_flags; 1278275SEric Cheng vnic_ioc_diag_t vc_diag; 1288275SEric Cheng mac_resource_props_t vc_resource_props; 1295084Sjohnlev } vnic_ioc_create_t; 1305084Sjohnlev 1317408SSebastien.Roy@Sun.COM #define VNIC_IOC_DELETE VNICIOC(2) 1325084Sjohnlev 1335084Sjohnlev typedef struct vnic_ioc_delete { 1345895Syz147064 datalink_id_t vd_vnic_id; 1355084Sjohnlev } vnic_ioc_delete_t; 1365084Sjohnlev 1377408SSebastien.Roy@Sun.COM #define VNIC_IOC_INFO VNICIOC(3) 1385084Sjohnlev 1398275SEric Cheng typedef struct vnic_info { 1405895Syz147064 datalink_id_t vn_vnic_id; 1415895Syz147064 datalink_id_t vn_link_id; 1428275SEric Cheng vnic_mac_addr_type_t vn_mac_addr_type; 1438275SEric Cheng uint_t vn_mac_len; 1445084Sjohnlev uchar_t vn_mac_addr[MAXMACADDRLEN]; 1458275SEric Cheng uint_t vn_mac_slot; 1468275SEric Cheng uint32_t vn_mac_prefix_len; 1478275SEric Cheng uint16_t vn_vid; 14811076SCathy.Zhou@Sun.COM vrid_t vn_vrid; 14911076SCathy.Zhou@Sun.COM int vn_af; 1508275SEric Cheng boolean_t vn_force; 1518275SEric Cheng mac_resource_props_t vn_resource_props; 1528275SEric Cheng } vnic_info_t; 1535084Sjohnlev 1545084Sjohnlev typedef struct vnic_ioc_info { 1558275SEric Cheng vnic_info_t vi_info; 1565084Sjohnlev } vnic_ioc_info_t; 1575084Sjohnlev 1587408SSebastien.Roy@Sun.COM #define VNIC_IOC_MODIFY VNICIOC(4) 1595084Sjohnlev 1605084Sjohnlev #define VNIC_IOC_MODIFY_ADDR 0x01 1618275SEric Cheng #define VNIC_IOC_MODIFY_RESOURCE_CTL 0x02 1625084Sjohnlev 1635084Sjohnlev typedef struct vnic_ioc_modify { 1645895Syz147064 datalink_id_t vm_vnic_id; 1655084Sjohnlev uint_t vm_modify_mask; 1668275SEric Cheng uint_t vm_mac_len; 1678275SEric Cheng int vm_mac_slot; 1685084Sjohnlev uchar_t vm_mac_addr[MAXMACADDRLEN]; 1695084Sjohnlev vnic_mac_addr_type_t vm_mac_addr_type; 1708275SEric Cheng mac_resource_props_t vm_resource_props; 1718275SEric Cheng vnic_ioc_diag_t vm_diag; 1725084Sjohnlev } vnic_ioc_modify_t; 1735084Sjohnlev 1748275SEric Cheng #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 1758275SEric Cheng #pragma pack() 1768275SEric Cheng #endif 1778275SEric Cheng 1785084Sjohnlev #ifdef __cplusplus 1795084Sjohnlev } 1805084Sjohnlev #endif 1815084Sjohnlev 1825084Sjohnlev #endif /* _SYS_VNIC_H */ 183