softmac_impl.h revision 79eeb64527c881659e23b60088c32ae3736a7a2c
/*
* 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_SOFTMAC_IMPL_H
#define _SYS_SOFTMAC_IMPL_H
#include <sys/ethernet.h>
#include <sys/mac_provider.h>
#include <sys/mac_client.h>
#include <sys/mac_client_priv.h>
#include <sys/mac_ether.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct softmac_lower_rxinfo_s {
void *slr_arg;
typedef struct softmac_lower_s {
struct softmac *sl_softmac;
struct softmac_upper_s *sl_sup;
/*
* When a control message is processed, either sl_pending_prim or
* sl_pending_ioctl will be set. They will be cleared when the
* acknowledgement of the specific control message is received
* from the underlying legacy driver.
*/
typedef enum {
typedef enum {
typedef struct softmac_dev_s {
/*
* smac_flag values.
*/
#define SOFTMAC_GLDV3 0x01
#define SOFTMAC_NOSUPP 0x02
#define SOFTMAC_NEED_RECREATE 0x04
#define SOFTMAC_NOTIFY_QUIT 0x08
#define SMAC_NONZERO_NODECNT(softmac) \
/*
* The softmac structure allows all minor nodes (at most two, style-1 and
* style-2) for the same device to be processed. A softmac_dev_t will be
* created for each minor node.
*
* We try to "register" the mac after all the softmac_dev_t's are processed so
* that even if DLPI operations fail (because of driver bugs) for one minor
* node, the other minor node can still be used to register the mac.
* (Specifically, an incorrect xxx_getinfo() implementation will cause style-2
* minor node mac registration to fail.)
*
* Locking description:
* WO: write once, valid the life time.
*/
typedef struct softmac {
int smac_uppa; /* WO */
/*
* The smac_hold_cnt field increases when softmac_hold_device() is
* called to force the dls_vlan_t of the device to be created. The
* device pre-detach fails if this counter is not 0.
*/
int smac_attacherr; /* smac_mutex */
/*
* Number of minor nodes whose post-attach routine has succeeded.
* This should be the same as the numbers of softmac_dev_t.
* Note that it does not imply SOFTMAC_ATTACH_DONE as the taskq might
* be still ongoing.
*/
/*
* Number of softmac_dev_t left when pre-detach fails. This is used
* to indicate whether postattach is called because of a failed
* pre-detach.
*/
/*
* Thread handles the DL_NOTIFY_IND message from the lower stream.
*/
/*
* Head and tail of the DL_NOTIFY_IND messsages.
*/
/*
* The remaining fields are used to register the MAC for a legacy
* device. They are set in softmac_mac_register() and do not change.
* One can access them when mac_register() is done without locks.
*/
/*
* media type is needed for create <link name, linkid> mapping, so
* it is set for GLDv3 device as well
*/
/* DLPI style of the underlying device */
int smac_style;
/* Notifications the underlying driver can support. */
/*
* Capabilities of the underlying driver.
*/
/*
* Lower stream structure, accessed by the MAC provider API. The GLDv3
* framework assures it's validity.
*/
/*
* Set by xxx_active_set() when aggregation is created.
*/
/*
* Numbers of the bounded streams in the fast-path mode.
*/
/*
* numbers of clients that request to disable fastpath.
*/
/*
* stream list over this softmac.
*/
} softmac_t;
typedef struct smac_ioc_start_s {
/*
* stream is either SLOWPATH or FASTPATH.
*/
#define SOFTMAC_UNKNOWN 0x00
#define SOFTMAC_SLOWPATH 0x01
#define SOFTMAC_FASTPATH 0x02
typedef struct softmac_switch_req_s {
#define DATAPATH_MODE(softmac) \
((((softmac)->smac_fp_disable_clients != 0) || \
/*
* Locking description:
*
* WO: Set once and valid for life;
* SL: Serialized by the control path (softmac_wput_nondata_task())
*/
typedef struct softmac_upper_s {
/*
* List of upper streams that has pending DLPI messages to be processed.
*/
/*
*/
/*
* the ones in both data-path modes).
*/
/*
* List of datapath switch requests.
*/
/*
* Place holder of RX callbacks used to handles data messages comes
* Another RX callback is softmac_drop_rxinfo, which is a global
* variable.
*/
/*
* Used to serialize the DLPI operation and fastpath<->slowpath
* switching over operation.
*/
/*
* Used for fastpath data path.
*/
/*
* Number of softmac_srv() operation in fastpath processing.
*/
/*
* SOFTMAC_SLOWPATH or SOFTMAC_FASTPATH
*/
/*
* Whether this stream is already scheduled in softmac_taskq_list.
*/
/*
* The DLD_CAPAB_DIRECT related notify callback.
*/
void *su_tx_notify_arg; /* su_mutex */
} else { \
} \
}
} else { \
} \
}
/*
* A macro to check whether the write-queue of the lower stream is full
* and packets need to be enqueued.
*
* Because softmac is pushed right above the underlying device and
* _I_INSERT/_I_REMOVE is not processed in the lower stream, it is
* safe to directly access the q_next pointer.
*/
#define SOFTMAC_CANPUTNEXT(q) \
extern dev_info_t *softmac_dip;
#define SOFTMAC_DEV_NAME "softmac"
extern int softmac_send_unbind_req(softmac_lower_t *);
extern void softmac_init();
extern void softmac_fini();
extern void softmac_fp_init();
extern void softmac_fp_fini();
extern boolean_t softmac_busy();
extern int softmac_capab_enable(softmac_lower_t *);
mblk_t *);
t_uscalar_t, mblk_t **);
extern int softmac_m_promisc(void *, boolean_t);
extern int softmac_m_unicst(void *, const uint8_t *);
extern void softmac_notify_thread(void *);
extern void softmac_rele(softmac_t *);
softmac_lower_t **);
extern boolean_t softmac_active_set(void *);
extern void softmac_active_clear(void *);
extern int softmac_fastpath_disable(void *);
extern void softmac_fastpath_enable(void *);
extern void softmac_upperstream_close(softmac_upper_t *);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SOFTMAC_IMPL_H */