mac_provider.h revision f71804b40936663bf3cba489497c7b779e6f1f0a
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009-2010 Oracle Corporation. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_MAC_PROVIDER_H
#define _SYS_MAC_PROVIDER_H
#include <sys/mac_flow.h>
/*
* MAC Provider Interface
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* MAC version identifier. This is used by mac_alloc() mac_register() to
* verify that incompatible drivers don't register.
*/
#define MAC_VERSION 0x2
/*
* Opaque handle types
*/
typedef struct __mac_rule_handle *mac_rule_handle_t;
/*
* Statistics
*/
#define XCVR_UNDEFINED 0
#define XCVR_NONE 1
#define XCVR_10 2
#define XCVR_100T4 3
#define XCVR_100X 4
#define XCVR_100T2 5
#define XCVR_1000X 6
#define XCVR_1000T 7
#ifdef _KERNEL
/*
* Definitions for MAC Drivers Capabilities
*/
/*
* MAC layer capabilities. These capabilities are handled by the drivers'
* mc_capab_get() callbacks. Some capabilities require the driver to fill
* in a given data structure, and others are simply boolean capabilities.
* Note that capability values must be powers of 2 so that consumers and
* providers of this interface can keep track of which capabilities they
* care about by keeping a bitfield of these things around somewhere.
*/
typedef enum {
/*
* Capabilities reserved for internal use only
*/
/*
* Public Capabilities
*/
/* add new capabilities here */
} mac_capab_t;
/*
* LSO capability
*/
typedef struct lso_basic_tcp_ipv4_s {
/*
* Currently supported flags for LSO.
*/
/*
* Future LSO capabilities can be added at the end of the mac_capab_lso_t.
* When such capability is added to the GLDv3 framework, the size of the
* mac_capab_lso_t it allocates and passes to the drivers increases. Older
* drivers wil access only the (upper) sections of that structure, that is the
* sections carrying the capabilities they understand. This ensures the
* interface can be safely extended in a binary compatible way.
*/
typedef struct mac_capab_lso_s {
/* Add future lso capabilities here */
/*
* Multiple Factory MAC Addresses Capability
*/
typedef struct mac_capab_multifactaddr_s {
/*
* Number of factory addresses
*/
/*
* Callbacks to query all the factory addresses.
*/
/*
* Info and callbacks of legacy devices.
*/
typedef struct mac_capab_legacy_s {
/*
* Notifications that the legacy device does not support.
*/
/*
* dev_t of the legacy device; can be held to force attach.
*/
boolean_t (*ml_active_set)(void *);
void (*ml_active_clear)(void *);
int (*ml_fastpath_disable)(void *);
void (*ml_fastpath_enable)(void *);
/*
* MAC driver entry point types.
*/
typedef int (*mac_start_t)(void *);
typedef void (*mac_stop_t)(void *);
typedef int (*mac_setpromisc_t)(void *, boolean_t);
typedef int (*mac_unicst_t)(void *, const uint8_t *);
typedef void (*mac_resources_t)(void *);
typedef int (*mac_open_t)(void *);
typedef void (*mac_close_t)(void *);
typedef int (*mac_set_prop_t)(void *, const char *, mac_prop_id_t,
uint_t, const void *);
typedef int (*mac_get_prop_t)(void *, const char *, mac_prop_id_t,
/*
* Drivers must set all of these callbacks except for mc_resources,
* mc_ioctl, and mc_getcapab, which are optional. If any of these optional
* callbacks are set, their appropriate flags must be set in mc_callbacks.
* Any future additions to this list must also be accompanied by an
* associated mc_callbacks flag so that the framework can grow without
* affecting the binary compatibility of the interface.
*/
typedef struct mac_callbacks_s {
typedef struct mac_priv_prop_s {
char mpp_name[MAXLINKPROPNAME];
/*
* Virtualization Capabilities
*/
/*
* The ordering of entries below is important. MAC_HW_CLASSIFIER
* is the cutoff below which are entries which don't depend on
* H/W. MAC_HW_CLASSIFIER and entries after that are cases where
*/
typedef enum {
MAC_NO_CLASSIFIER = 0,
/*
* The virtualization level conveys the extent of the NIC hardware assistance
* for traffic steering employed for virtualization:
*
* MAC_VIRT_NONE: No assist for v12n.
*
* MAC_VIRT_LEVEL1: Multiple Rx rings with MAC address level
* classification between groups of rings.
* Requires the support of the MAC_CAPAB_RINGS
* capability.
*
* MAC_VIRT_HIO: Hybrid I/O capable MAC. Require the support
* of the MAC_CAPAB_SHARES capability.
*
* MAC_VIRT_SERIALIZE: Temporary flag *ONLY* for nxge. Mac layer
* uses this to enable mac Tx serializer on
* outbound traffic and to always enqueue
* incoming traffic on Rx soft rings in mac.
*/
#define MAC_VIRT_NONE 0x0
#define MAC_VIRT_LEVEL1 0x1
#define MAC_VIRT_HIO 0x2
#define MAC_VIRT_SERIALIZE 0x4
typedef enum {
MAC_RING_TYPE_TX /* Transmit ring */
#define MAX_RINGS_PER_GROUP 128
/*
* Grouping type of a ring group
*
* MAC_GROUP_TYPE_STATIC: The ring group can not be re-grouped.
* MAC_GROUP_TYPE_DYNAMIC: The ring group support dynamic re-grouping
*/
typedef enum {
MAC_GROUP_TYPE_DYNAMIC /* Dynamic ring group */
typedef struct __mac_ring_driver *mac_ring_driver_t;
typedef struct __mac_group_driver *mac_group_driver_t;
typedef struct mac_ring_info_s mac_ring_info_t;
typedef struct mac_group_info_s mac_group_info_t;
typedef void (*mac_get_ring_t)(void *, mac_ring_type_t, const int, const int,
typedef void (*mac_get_group_t)(void *, mac_ring_type_t, const int,
typedef void (*mac_group_add_ring_t)(mac_group_driver_t,
typedef void (*mac_group_rem_ring_t)(mac_group_driver_t,
/*
* Multiple Rings Capability
*/
typedef struct mac_capab_rings_s {
/*
* Common ring functions and driver interfaces
*/
typedef void (*mac_ring_stop_t)(mac_ring_driver_t);
typedef mblk_t *(*mac_ring_poll_t)(void *, int);
typedef struct mac_ring_info_s {
union {
} mrfunion;
typedef int (*mac_group_start_t)(mac_group_driver_t);
typedef void (*mac_group_stop_t)(mac_group_driver_t);
typedef int (*mac_add_mac_addr_t)(void *, const uint8_t *);
typedef int (*mac_rem_mac_addr_t)(void *, const uint8_t *);
struct mac_group_info_s {
/* Only used for rx groups */
};
/*
* Share management functions.
*/
typedef uint64_t mac_share_handle_t;
/*
* Allocate and free a share. Returns ENOSPC if all shares have been
* previously allocated.
*/
typedef int (*mac_alloc_share_t)(void *, mac_share_handle_t *);
typedef void (*mac_free_share_t)(mac_share_handle_t);
/*
* Bind and unbind a share. Binding a share allows a domain
* to have direct access to the groups and rings associated with
* that share.
*/
typedef void (*mac_unbind_share_t)(mac_share_handle_t);
/*
* Return information on about a share.
*/
mac_ring_handle_t *, uint_t *);
/*
* Basic idea, bind previously created ring groups to shares
* for them to be exported (or shared) by another domain.
* The groups and their rings will be shared with the guest
* as soon as the share is bound.
*/
typedef int (*mac_share_add_group_t)(mac_share_handle_t,
typedef int (*mac_share_rem_group_t)(mac_share_handle_t,
typedef struct mac_capab_share_s {
void *ms_handle; /* Handle to driver. */
typedef struct mac_capab_vrrp_s {
/* IPv6 or IPv4? */
int mcv_af;
/*
* MAC registration interface
*/
typedef struct mac_register_s {
const char *m_type_ident;
void *m_driver; /* Driver private data */
void *m_pdata;
/*
* Flags for mc_callbacks. Requiring drivers to set the flags associated
* with optional callbacks initialized in the structure allows the mac
* module to add optional callbacks in the future without requiring drivers
* to recompile.
*/
#define MC_IOCTL 0x001
#define MC_GETCAPAB 0x002
#define MC_OPEN 0x004
#define MC_CLOSE 0x008
#define MC_SETPROP 0x010
#define MC_GETPROP 0x020
/*
* Driver interface functions.
*/
extern void mac_free(mac_register_t *);
extern int mac_disable_nowait(mac_handle_t);
extern int mac_disable(mac_handle_t);
extern int mac_unregister(mac_handle_t);
mblk_t *);
extern void mac_unicst_update(mac_handle_t,
const uint8_t *);
extern void mac_tx_update(mac_handle_t);
extern void mac_tx_ring_update(mac_handle_t,
extern void mac_capab_update(mac_handle_t);
extern int mac_pdata_update(mac_handle_t, void *,
size_t);
extern void mac_multicast_refresh(mac_handle_t,
mac_multicst_t, void *, boolean_t);
void *);
extern void mac_promisc_refresh(mac_handle_t,
mac_setpromisc_t, void *);
extern void mac_init_ops(struct dev_ops *, const char *);
extern void mac_fini_ops(struct dev_ops *);
extern int mac_devt_to_instance(dev_t);
extern minor_t mac_private_minor(void);
extern void mactype_free(mactype_register_t *);
extern int mactype_register(mactype_register_t *);
extern int mactype_unregister(const char *);
extern int mac_group_add_ring(mac_group_handle_t, int);
extern void mac_group_rem_ring(mac_group_handle_t,
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_MAC_PROVIDER_H */