mac.h revision aca118b711d5dc86653e0b3c1a122a6b93a0112d
/*
* 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 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_MAC_H
#define _SYS_MAC_H
#ifdef _KERNEL
#endif
/*
* MAC Services Module
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* MAC Information (text emitted by modinfo(1m))
*/
#define MAC_INFO "MAC Services v1.20"
/*
* 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
/*
* Opaque handle types
*/
typedef struct __mac_handle *mac_handle_t;
typedef struct __mac_resource_handle *mac_resource_handle_t;
typedef struct __mac_notify_handle *mac_notify_handle_t;
typedef struct __mac_tx_notify_handle *mac_tx_notify_handle_t;
typedef struct __mac_intr_handle *mac_intr_handle_t;
typedef struct __mac_ring_handle *mac_ring_handle_t;
typedef struct __mac_group_handle *mac_group_handle_t;
#define DATALINK_INVALID_LINKID 0
#define DATALINK_ALL_LINKID 0
#define DATALINK_MAX_LINKID 0xffffffff
#define MAC_MAX_MINOR 1000
typedef enum {
LINK_STATE_UNKNOWN = -1,
} link_state_t;
typedef enum {
LINK_DUPLEX_UNKNOWN = 0,
typedef enum {
LINK_FLOWCTRL_NONE = 0,
typedef enum {
/*
* Maximum MAC address length
*/
#define MAXMACADDRLEN 20
typedef enum {
MAC_LOGTYPE_LINK = 1,
/*
* 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
/*
* 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
#ifdef _KERNEL
/*
* 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;
/*
* When VNICs are created on top of the NIC, there are two levels
* of MAC layer, a lower MAC, which is the MAC layer at the level of the
* physical NIC, and an upper MAC, which is the MAC layer at the level
* of the VNIC. Each VNIC maps to a MAC client at the lower MAC, and
* the SRS and classification is done at the lower MAC level. The upper
* MAC is therefore for the most part pass-through, and therefore
* special processing needs to be done at the upper MAC layer when
* dealing with a VNIC.
*
* This capability allows the MAC layer to detect when a VNIC is being
* access, and implement the required shortcuts.
*/
typedef void *(*mac_client_handle_fn_t)(void *);
typedef struct mac_capab_vnic_s {
void *mcv_arg;
typedef void (*mac_rename_fn_t)(const char *, void *);
typedef struct mac_capab_aggr_s {
int (*mca_unicst)(void *, const uint8_t *);
typedef enum {
MAC_NNOTE /* must be the last entry */
typedef void (*mac_notify_t)(void *, mac_notify_type_t);
typedef mblk_t *(*mac_receive_t)(void *, int);
/*
* MAC promiscuous types
*/
typedef enum {
/*
* MAC resource types
*/
typedef enum {
MAC_RX_FIFO = 1
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 struct mac_rx_fifo_s {
void *mrf_rx_arg;
/*
* The CPU this flow is to be processed on. With intrd and future
* things, we should know which CPU the flow needs to be processed
* and get a squeue assigned on that CPU.
*/
typedef union mac_resource_u {
typedef enum {
typedef struct mac_header_info_s {
/*
* Function pointer to match dls client signature. Should be same as
* dls_rx_t to allow a soft ring to bypass DLS layer and call a DLS
* client directly.
*/
typedef void (*mac_direct_rx_t)(void *, mac_resource_handle_t,
mblk_t *, mac_header_info_t *);
typedef int (*mac_resource_bind_t)(void *,
typedef void (*mac_resource_remove_t)(void *, void *);
typedef void (*mac_resource_quiesce_t)(void *, void *);
typedef void (*mac_resource_restart_t)(void *, void *);
typedef int (*mac_resource_modify_t)(void *, void *,
mac_resource_t *);
typedef void (*mac_change_upcall_t)(void *, mac_direct_rx_t,
void *);
/*
* 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;
typedef struct mac_stat_info_s {
char *msi_name;
typedef struct mactype_register_s {
const char *mtr_ident;
typedef struct mac_prop_s {
char *mp_name;
} mac_prop_t;
/*
* Driver interface functions.
*/
extern int mac_open_by_linkid(datalink_id_t,
mac_handle_t *);
extern int mac_open_by_linkname(const char *,
mac_handle_t *);
extern const char *mac_name(mac_handle_t);
extern void mac_minor_rele(minor_t);
extern void mac_unicst_update(mac_handle_t,
const uint8_t *);
extern void mac_resource_update(mac_handle_t);
extern void mac_capab_update(mac_handle_t);
extern int mac_pdata_update(mac_handle_t, void *,
size_t);
extern int mac_fastpath_disable(mac_handle_t);
extern void mac_fastpath_enable(mac_handle_t);
extern void mactype_free(mactype_register_t *);
extern int mactype_register(mactype_register_t *);
extern int mactype_unregister(const char *);
extern void mac_stop_logusage(mac_logtype_t);
/*
* Packet hashing for distribution to multiple ports and rings.
*/
#define MAC_PKT_HASH_L2 0x01
#define MAC_PKT_HASH_L3 0x02
#define MAC_PKT_HASH_L4 0x04
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_MAC_H */