dmfe_impl.h revision 0d2a8e5eea8ac6ea0f5c517f0c481329b57d5459
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_DMFE_IMPL_H
#define _SYS_DMFE_IMPL_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/ethernet.h>
#include <sys/dditypes.h>
#include <sys/mac_ether.h>
#define DRIVER_NAME "dmfe"
/*
* Describes the identity of a specific chip
*/
typedef struct {
} chip_id_t;
/*
* Describes the state of a descriptor ring
*
* NOTE: n_free and next_busy are only used for the Tx descriptors
* and are not valid on the receive side.
*/
typedef struct {
} desc_state_t;
/*
* Describes one chunk of allocated DMA-able memory
*/
typedef struct {
int spare3;
int ncookies;
} dma_area_t;
/*
* Named Data (ND) Parameter Management Structure
*/
typedef struct {
char *ndp_name;
} nd_param_t;
/*
* NDD parameter indexes, divided into:
*
* read-only parameters describing the link state
* read-write parameters controlling the advertised link capabilities
* read-only parameters describing the device link capabilities
* read-only parameters describing the link-partner's link capabilities
*/
enum {
};
/*
* Indexes into the driver-specific kstats, divided into:
*
* cyclic activity
* reasons for waking the factotum
* the factotum's activities
* link state updates
* MII-level register values
*/
enum {
};
/*
* Actual state of the DM9102A chip
*/
enum chip_state {
CHIP_UNKNOWN, /* Initial state only */
CHIP_RESET, /* reset, need init */
CHIP_STOPPED, /* Tx/Rx stopped */
CHIP_TX_ONLY, /* Tx (re)started */
CHIP_TX_RX, /* Tx & Rx (re)started */
CHIP_RUNNING /* with interrupts */
};
/*
* Required state according to MAC
*/
enum mac_state {
};
/*
* (Internal) return values from ioctl subroutines
*/
enum ioc_reply {
IOC_DONE, /* OK, reply sent */
IOC_REPLY, /* OK, just send reply */
IOC_ACK, /* OK, just send ACK */
IOC_RESTART, /* OK, restart & reply */
IOC_RESTART_ACK /* OK, restart & ACK */
};
/*
* Per-instance soft-state structure
*/
typedef struct {
/*
* These fields are set by attach() and unchanged thereafter ...
*/
/*
* Locks:
*
* <milock> is used only by the MII (PHY) level code, to ensure
* exclusive access during the bit-twiddling needed to send
* signals along the MII serial bus. These operations are
* --S--L--O--W-- so we keep this lock separate, so that
* faster operations (e.g. interrupts) aren't delayed by
* waiting for it.
*
* <oplock> is a general "outer" lock, protecting most r/w data
* and chip state. It is also acquired by the interrupt
* handler.
*
* <rxlock> is used to protect the Rx-side buffers, descriptors,
* and statistics during a single call to dmfe_getp().
* This is called from inside the interrupt handler, but
* <oplock> is not held across this call.
*
* <txlock> is an "inner" lock, and protects only the Tx-side
* data below and in the ring buffers/descriptors. The
* Tx-side code uses only this lock, avoiding contention
* with the receive-side code.
*
* Any of the locks can be acquired singly, but where multiple
* locks are acquired, they *must* be in the order:
*
* milock >>> oplock >>> rxlock >>> txlock.
*
* *None* of these locks may be held across calls out to the
* MAC routines mac_rx() or mac_tx_notify(); MAC locks must
* be regarded as *outermost* locks in all cases, as they will
* already be held before calling the ioctl() or get_stats()
* entry points - which then have to acquire multiple locks, in
* the order described here.
*/
/*
* DMFE Extended kstats, protected by <oplock>
*/
/*
* GLD statistics; the prefix tells which lock each is protected by.
*/
/*
* These two sets of desciptors are manipulated during
*/
/*
* Miscellaneous Tx-side variables (protected by txlock)
*/
/*
* Miscellaneous operating variables (protected by oplock)
*/
/*
* Physical link state data (protected by oplock)
*/
/*
* PHYceiver state data (protected by milock)
*/
int phy_inuse;
int phy_addr; /* should be -1! */
/*
* Current Ethernet address & multicast map ...
*/
/*
* NDD parameters
*/
/*
* Guard element used to check data integrity
*/
} dmfe_t;
/*
* 'Progress' bit flags ...
*/
/*
* Type of transceiver currently in use
*/
#define PHY_TYPE_UNDEFINED 0
#define PHY_TYPE_10BASE_MNCHSTR 2
#define PHY_TYPE_100BASE_X 4
/*
* Shorthand for the NDD parameters
*/
/*
* Sync a DMA area described by a dma_area_t
*/
/*
* Next value of a cyclic index
*/
/*
* Utility Macros
*/
/*
* Copy an ethernet address
*/
do { \
} while (0)
do { \
} while (0)
/*
*/
do { \
} while (0)
do { \
} while (0)
/*
* Bit test macros, returning boolean_t values
*/
#define BIS(w, b) ((w) & (b))
#define DMFE_GUARD 0x1919603003090218
/*
* 'Debug' bit flags ...
*/
/*
* Debugging ...
*/
#define DMFEDEBUG 1
#else
#define DMFEDEBUG 0
#endif
#if DMFEDEBUG
extern uint32_t dmfe_debug;
/*
* Define DMFE_DBG to be the relevant flag from the set above before
* using the DMFE_GDEBUG() or DMFE_DEBUG() macros. The 'G' versions
* look at the Global debug flag word (dmfe_debug); the non-G versions
* look in the per-instance data (dmfep->debug) and so require a variable
* called 'dmfep' to be in scope (and initialised!)
*
* You could redefine DMFE_TRC too if you really need two different
* flavours of debugging output in the same area of code, but I don't
* really recommend it.
*/
#define DMFE_GDEBUG(args) do { \
if (dmfe_debug & (DMFE_DBG)) \
} while (0)
#define DMFE_GTRACE(args) do { \
if (dmfe_debug & (DMFE_TRC)) \
} while (0)
#define DMFE_DEBUG(args) do { \
} while (0)
#define DMFE_TRACE(args) do { \
} while (0)
#else
#endif /* DMFEDEBUG */
/*
* Inter-source-file linkage ...
*/
/* dmfe_log.c */
void dmfe_log_init(void);
void dmfe_log_fini(void);
/* dmfe_main.c */
/* dmfe_mii.c */
/* dmfe_ndd.c */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_DMFE_IMPL_H */