mac.h revision 3fd94f8c011031b38162a1db3b554de4371c167f
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_MAC_H
#define _SYS_MAC_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* MAC Services Module
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* MAC Information (text emitted by modinfo(1m))
*/
#define MAC_INFO "MAC Services"
/*
* MAC version identifier. This is used by mac_alloc() mac_register() to
* verify that incompatible drivers don't register.
*/
#define MAC_VERSION 0x1
/*
* MAC-Type version identifier. This is used by mactype_alloc() and
* mactype_register() to verify that incompatible MAC-Type plugins don't
* register.
*/
#define MACTYPE_VERSION 0x1
/*
* 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
typedef enum {
LINK_STATE_UNKNOWN = -1,
} link_state_t;
typedef enum {
LINK_DUPLEX_UNKNOWN = 0,
#define DATALINK_INVALID_LINKID 0
#define DATALINK_ALL_LINKID 0
#define DATALINK_MAX_LINKID 0xffffffff
typedef enum {
LINK_FLOWCTRL_NONE = 0,
typedef uint32_t datalink_id_t;
/*
* Encodings for public properties.
* A most significant bit value of 1 indicates private property, intended
* to allow private property implementations to use internal encodings
* if desired.
*
* Note that there are 2 sets of parameters: the *_EN_*
* values are those that the Administrator configures for autonegotiation.
* The _ADV_* values are those that are currently exposed over the wire.
*/
#define MAXLINKPROPNAME 256
#define MAC_PROP_DEFAULT 0x0001
typedef enum {
MAC_PROP_DUPLEX = 0x00000001,
MAC_PROP_PRIVATE = -1
/*
* Maximum MAC address length
*/
#define MAXMACADDRLEN 20
#ifdef _KERNEL
typedef struct mac_stat_info_s {
char *msi_name;
/*
* There are three ranges of statistics values. 0 to 1 - MAC_STAT_MIN are
* interface statistics maintained by the mac module. MAC_STAT_MIN to 1 -
* MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and
* maintained by each driver. MACTYPE_STAT_MIN and above are statistics
* defined by MAC-Type plugins and maintained by each driver.
*/
#define MAC_STAT_MIN 1000
#define MACTYPE_STAT_MIN 2000
#define IS_MAC_STAT(stat) \
/*
* Statistics maintained by the mac module, and possibly populated as link
* statistics.
*/
enum mac_mod_stat {
};
/*
* Do not reorder, and add only to the end of this list.
*/
enum mac_driver_stat {
/* MIB-II stats (RFC 1213 and RFC 1573) */
};
#define MAC_STAT_ISACOUNTER(_stat) ( \
(_stat) == MAC_STAT_MULTIRCV || \
(_stat) == MAC_STAT_BRDCSTRCV || \
(_stat) == MAC_STAT_MULTIXMT || \
(_stat) == MAC_STAT_BRDCSTXMT || \
(_stat) == MAC_STAT_NORCVBUF || \
(_stat) == MAC_STAT_IERRORS || \
(_stat) == MAC_STAT_UNKNOWNS || \
(_stat) == MAC_STAT_NOXMTBUF || \
(_stat) == MAC_STAT_OERRORS || \
(_stat) == MAC_STAT_COLLISIONS || \
(_stat) == MAC_STAT_RBYTES || \
(_stat) == MAC_STAT_IPACKETS || \
(_stat) == MAC_STAT_OBYTES || \
(_stat) == MAC_STAT_OPACKETS || \
(_stat) == MAC_STAT_UNDERFLOWS || \
(_stat) == MAC_STAT_OVERFLOWS)
/*
* Immutable information. (This may not be modified after registration).
*/
typedef struct mac_info_s {
} mac_info_t;
/*
* LSO capability
*/
typedef struct lso_basic_tcp_ipv4_s {
/*
* 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 */
/*
* Information for 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.
*/
/*
* 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 {
/* add new capabilities here */
/* The following capabilities are specific to softmac. */
} mac_capab_t;
typedef int mac_addr_slot_t;
/* mma_flags values */
typedef struct mac_multi_address_s {
typedef int (*maddr_reserve_t)(void *, mac_multi_addr_t *);
typedef int (*maddr_add_t)(void *, mac_multi_addr_t *);
typedef int (*maddr_remove_t)(void *, mac_addr_slot_t);
typedef int (*maddr_modify_t)(void *, mac_multi_addr_t *);
typedef int (*maddr_get_t)(void *, mac_multi_addr_t *);
/* maddr_flag values */
typedef struct multiaddress_capab_s {
int maddr_naddr; /* total addresses */
int maddr_naddrfree; /* free address slots */
/* driver entry points */
void *maddr_handle; /* cookie to be used for the calls */
/*
* 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];
/*
* Multiple Rings capability
*/
typedef enum {
/*
* 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 {
typedef struct __mac_ring_driver *mac_ring_driver_t;
typedef struct __mac_ring_handle *mac_ring_handle_t;
typedef struct __mac_group_driver *mac_group_driver_t;
typedef struct __mac_group_handle *mac_group_handle_t;
typedef struct __mac_intr_handle *mac_intr_handle_t;
typedef struct mac_ring_info_s mac_ring_info_t;
typedef struct mac_group_info_s mac_group_info_t;
typedef int (*mac_intr_enable_t)(mac_intr_handle_t);
typedef int (*mac_intr_disable_t)(mac_intr_handle_t);
typedef struct mac_intr_s {
} mac_intr_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 {
void *mr_handle; /* Group Driver Handle. */
/*
* Common ring functions and driver interfaces
*/
typedef int (*mac_ring_start_t)(mac_ring_driver_t);
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;
/*
* Returns a Share handle to the client calling from above.
*/
/*
* Destroys the share previously allocated and unallocates
* all share resources (e.g. DMA's assigned to the share).
*/
typedef void (*mac_free_share_t)(mac_share_handle_t);
/*
* Basic idea, bind previously created ring groups to shares
* for them to be exported (or shared) by another domain.
* of doing such causes the resources to be shared with the guest.
*/
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. */
/*
* 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_RESOURCES 0x001
#define MC_IOCTL 0x002
#define MC_GETCAPAB 0x004
#define MC_OPEN 0x008
#define MC_CLOSE 0x010
#define MC_SETPROP 0x020
#define MC_GETPROP 0x040
#define MAC_MAX_MINOR 1000
typedef struct mac_register_s {
const char *m_type_ident;
void *m_driver; /* Driver private data */
void *m_pdata;
/*
* Opaque handle types.
*/
typedef struct mac_t *mac_handle_t;
typedef struct __mac_notify_handle *mac_notify_handle_t;
typedef struct __mac_rx_handle *mac_rx_handle_t;
typedef struct __mac_txloop_handle *mac_txloop_handle_t;
typedef struct __mac_resource_handle *mac_resource_handle_t;
/*
* MAC interface callback types.
*/
typedef enum {
MAC_NNOTE /* must be the last entry */
typedef void (*mac_notify_t)(void *, mac_notify_type_t);
typedef void (*mac_txloop_t)(void *, mblk_t *);
/*
* MAC promiscuous types
*/
typedef enum {
/*
* MAC resource types
*/
typedef enum {
MAC_RX_FIFO = 1
typedef struct mac_rx_fifo_s {
void *mrf_arg;
typedef struct mac_txinfo_s {
void *mt_arg;
} mac_txinfo_t;
typedef union mac_resource_u {
typedef enum {
typedef struct mac_header_info_s {
/*
* MAC-Type plugin interfaces
*/
typedef int (*mtops_addr_verify_t)(const void *, void *);
typedef mblk_t *(*mtops_header_t)(const void *, const void *,
typedef int (*mtops_header_info_t)(mblk_t *, void *,
void *);
typedef struct mactype_ops_s {
/*
* mtops_unicst_verify() returns 0 if the given address is a valid
* unicast address, or a non-zero errno otherwise.
*/
/*
* mtops_multicst_verify() returns 0 if the given address is a
* valid multicast address, or a non-zero errno otherwise. If the
* media doesn't support multicast, ENOTSUP should be returned (for
* example).
*/
/*
* mtops_sap_verify() returns B_TRUE if the given SAP is a valid
* SAP value, or B_FALSE otherwise.
*/
/*
* mtops_header() is used to allocate and construct a MAC header.
*/
/*
* mtops_header_info() is used to gather information on a given MAC
* header.
*/
/*
* mtops_pdata_verify() is used to verify the validity of MAC
* plugin data. It is called by mac_register() if the driver has
* supplied MAC plugin data, and also by mac_pdata_update() when
* drivers update the data.
*/
/*
* mtops_header_cook() is an optional callback that converts (or
* "cooks") the given raw header (as sent by a raw DLPI consumer)
* into one that is appropriate to send down to the MAC driver.
* Following the example above, an Ethernet header sent down by a
* DLPI consumer would be converted to whatever header the MAC
* driver expects.
*/
/*
* mtops_header_uncook() is an optional callback that does the
* opposite of mtops_header_cook(). It "uncooks" a given MAC
* header (as received from the driver) for consumption by raw DLPI
* consumers. For example, for a non-Ethernet plugin that wants
* raw DLPI consumers to be fooled into thinking that the device
* provides Ethernet access, this callback would modify the given
* mblk_t such that the MAC header is converted to an Ethernet
* header.
*/
/*
* mtops_link_details() is an optional callback that provides
* extended information about the link state. Its primary purpose
* is to provide type-specific support for syslog contents on
* link up events. If no implementation is provided, then a default
* implementation will be used.
*/
/*
* mtops_ops exists for the plugin to enumerate the optional callback
* entrypoints it has defined. This allows the mac module to define
* additional plugin entrypoints in mactype_ops_t without breaking backward
* compatibility with old plugins.
*/
#define MTOPS_PDATA_VERIFY 0x001
#define MTOPS_HEADER_COOK 0x002
#define MTOPS_HEADER_UNCOOK 0x004
#define MTOPS_LINK_DETAILS 0x008
/*
* Provide mapping for legacy ndd ioctls relevant to that mactype.
* Note that the ndd ioctls are obsolete, and may be removed in a future
* release of Solaris. The ndd ioctls are not typically used in legacy
* ethernet drivers. New datalink drivers of all link-types should use
* dladm(1m) interfaces for administering tunables and not have to provide
* a mapping.
*/
typedef struct mac_ndd_mapping_s {
char *mp_name;
union {
} u_mp_id;
long mp_minval;
long mp_maxval;
int mp_flags;
/*
* Flags to figure out r/w status of legacy ndd props.
*/
#define MAC_PROP_PERM_READ 0x0001
#define MAC_PROP_PERM_WRITE 0x0010
#define MAC_PROP_MAP_KSTAT 0x0100
typedef struct mactype_register_s {
const char *mtr_ident;
typedef struct mac_prop_s {
char *mp_name;
} mac_prop_t;
/*
* Client interface functions.
*/
extern int mac_open(const char *, mac_handle_t *);
extern int mac_open_by_linkid(datalink_id_t,
mac_handle_t *);
extern int mac_open_by_linkname(const char *,
mac_handle_t *);
extern void mac_close(mac_handle_t);
extern int mac_start(mac_handle_t);
extern void mac_stop(mac_handle_t);
extern int mac_multicst_remove(mac_handle_t,
const uint8_t *);
extern void mac_resources(mac_handle_t);
void *);
extern void mac_notify_remove(mac_handle_t,
extern void mac_notify(mac_handle_t);
void *);
extern void mac_rx_remove_wait(mac_handle_t);
void *);
extern void mac_txloop_remove(mac_handle_t,
extern void mac_active_clear(mac_handle_t);
extern void mac_active_rx(void *, mac_resource_handle_t,
mblk_t *);
mac_getcapab_t, void *);
extern void mac_vnic_clear(mac_handle_t);
extern void mac_resource_set(mac_handle_t,
mac_resource_add_t, void *);
extern const char *mac_name(mac_handle_t);
void *);
void *);
uint32_t *);
extern void mac_minor_rele(minor_t);
/*
* Driver interface functions.
*/
extern void mac_free(mac_register_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_resource_update(mac_handle_t);
mac_resource_t *);
extern int mac_pdata_update(mac_handle_t, void *,
size_t);
extern void mac_multicst_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_hold_exclusive(mac_handle_t);
extern void mac_rele_exclusive(mac_handle_t);
extern void mactype_free(mactype_register_t *);
extern int mactype_register(mactype_register_t *);
extern int mactype_unregister(const char *);
void *, uint_t);
void *, uint_t);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_MAC_H */