rge.h revision aa81749390e332985277568edab1ee6132326b42
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _RGE_H
#define _RGE_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>
/*
* Reconfiguring the network devices requires the net_config privilege
* in Solaris 10+.
*/
#include "rge_hw.h"
/*
* Name of the driver
*/
#define RGE_DRIVER_NAME "rge"
/*
*
* These are the values to use with LD_SET_MODE.
*/
#define RGE_LOOP_NONE 0
#define RGE_LOOP_INTERNAL_PHY 1
#define RGE_LOOP_INTERNAL_MAC 2
/*
* RGE-specific ioctls ...
*/
/*
*/
struct rge_mii_rw {
};
/*
* These diagnostic IOCTLS are enabled only in DEBUG drivers
*/
typedef struct {
/* input for poke */
#define RGE_PP_SPACE_CFG 0 /* PCI config space */
/*
* RTL8169 CRC poly
*/
#define RGE_HASH_CRC 0xFFFFFFFFU
/*
*/
#define RGE_BUF_SLOTS 2048
#define RGE_RECV_COPY_SIZE 256
#define RGE_HEADROOM 6
/*
* Driver chip operation parameters
*/
#define CHIP_RESET_LOOP 1000
#define PHY_RESET_LOOP 1000
#define STATS_DUMP_LOOP 1000
#define RXBUFF_FREE_LOOP 1000
#define RGE_RX_INT_TIME 128
#define RGE_RX_INT_PKTS 8
/*
* Named Data (ND) Parameter Management Structure
*/
typedef struct {
int ndp_info;
int ndp_min;
int ndp_max;
int ndp_val;
char *ndp_name;
} nd_param_t; /* 0x18 (24) bytes */
/*
* NDD parameter indexes, divided into:
*
* read-only parameters describing the hardware's capabilities
* read-write parameters controlling the advertised capabilities
* read-only parameters describing the partner's capabilities
* read-only parameters describing the link state
*/
enum {
PARAM_AUTONEG_CAP = 0,
};
enum rge_chip_state {
RGE_CHIP_ERROR, /* error, want reset */
RGE_CHIP_INITIAL, /* Initial state only */
RGE_CHIP_RESET, /* reset, need init */
RGE_CHIP_STOPPED, /* Tx/Rx stopped */
RGE_CHIP_RUNNING /* with interrupts */
};
enum rge_mac_state {
RGE_MAC_ATTACH = 0,
};
enum rge_sync_op {
RGE_GET_MAC, /* get mac address operation */
RGE_SET_MAC, /* set mac address operation */
RGE_SET_MUL, /* set multicast address op */
RGE_SET_PROMISC /* set promisc mode */
};
/*
* (Internal) return values from ioctl subroutines
*/
enum ioc_reply {
IOC_DONE, /* OK, reply sent */
IOC_ACK, /* OK, just send ACK */
IOC_REPLY, /* OK, just send reply */
IOC_RESTART_ACK, /* OK, restart & ACK */
IOC_RESTART_REPLY /* OK, restart & reply */
};
/*
* (Internal) enumeration of this driver's kstats
*/
enum {
RGE_KSTAT_PARAMS = 0,
};
/*
* Basic data types, for clarity in distinguishing 'numbers'
* used for different purposes ...
*
* A <rge_regno_t> is a register 'address' (offset) in any one of
* various address spaces (PCI config space, PCI memory-mapped I/O
* register space, MII registers, etc). None of these exceeds 64K,
* so we could use a 16-bit representation but pointer-sized objects
* are more "natural" in most architectures; they seem to be handled
* more efficiently on SPARC and no worse on x86.
*
* RGE_REGNO_NONE represents the non-existent value in this space.
*/
#define RGE_REGNO_NONE (~(uintptr_t)0u)
/*
* Describes one chunk of allocated DMA-able memory
*
* In some cases, this is a single chunk as allocated from the system;
* but we also use this structure to represent slices carved off such
* a chunk. Even when we don't really need all the information, we
* use this structure as a convenient way of correlating the various
* ways of looking at a piece of memory (kernel VA, IO space DVMA,
* handle+offset, etc).
*/
typedef struct {
void *mem_va; /* CPU VA of memory */
} dma_area_t;
/*
* Software version of the Receive Buffer Descriptor
*/
typedef struct {
/* buffer area */
} dma_buf_t;
typedef struct sw_rbd {
} sw_rbd_t;
/*
* Software version of the Send Buffer Descriptor
*/
typedef struct sw_sbd {
/* descriptor area */
/* buffer area */
} sw_sbd_t;
/*
* Describes the characteristics of a specific chip
*/
typedef struct {
} chip_id_t;
typedef struct rge_stats {
} rge_stats_t;
/*
* Per-instance soft-state structure
*/
typedef struct rge {
int intr_type; /* What type of interrupt */
int intr_rqst; /* # of request intrs count */
int intr_cnt; /* # of intrs count returned */
int intr_cap; /* Interrupt capabilities */
/*
* These structures describe the blocks of memory allocated during
* attach(). They remain unchanged thereafter, although the memory
* they describe is carved up into various separate regions and may
* therefore be described by other structures as well.
*/
/* describes hardware statistics area */
char mcast_refs[RGE_MCAST_BUF_SIZE];
/* used for recv */
/* used for send */
/* mutex */
/*
* Miscellaneous operating variables (not synchronised)
*/
/*
* Link state data (protected by genlock)
*/
const char *link_down_msg; /* reason for link DOWN */
const char *link_up_msg; /* comment on link UP */
/*
* Physical layer state data (protected by genlock)
*/
/*
* Physical layer
*/
/*
* NDD parameters (protected by genlock)
*/
/*
* Driver kstats, protected by <genlock> where necessary
*/
/* H/W statistics */
} rge_t;
/*
* 'Progress' bit flags ...
*/
/* and mutexen initialised */
/*
* Special chip flags
*/
#define CHIP_FLAG_FORCE_BCOPY 0x10000000
/*
* Shorthand for the NDD parameters
*/
/*
* Sync a DMA area described by a dma_area_t
*/
/*
* Find the (kernel virtual) address of block of memory
* described by a dma_area_t
*/
/*
* Zero a block of memory described by a dma_area_t
*/
/*
*/
/*
* Property lookups
*/
DDI_PROP_DONTPASS, (n))
DDI_PROP_DONTPASS, (n), -1)
/*
* Endian swap
*/
#ifdef _BIG_ENDIAN
(((x) & 0x00ff) << 8))
(((x) & 0x00ff0000) >> 8) | \
(((x) & 0x0000ff00) << 8) | \
(((x) & 0x000000ff) << 24))
(RGE_BSWAP_32(x) << 32))
#else
#define RGE_BSWAP_16(x) (x)
#define RGE_BSWAP_32(x) (x)
#define RGE_BSWAP_64(x) (x)
#endif
/*
* Bit test macros, returning boolean_t values
*/
/*
* Bit flags in the 'debug' word ...
*/
/*
* Debugging ...
*/
#ifdef DEBUG
#define RGE_DEBUGGING 1
#else
#define RGE_DEBUGGING 0
#endif /* DEBUG */
/*
* 'Do-if-debugging' macro. The parameter <command> should be one or more
* C statements (but without the *final* semicolon), which will either be
* compiled inline or completely ignored, depending on the RGE_DEBUGGING
* compile-time flag.
*
* You should get a compile-time error (at least on a DEBUG build) if
* your statement isn't actually a statement, rather than unexpected
* run-time behaviour caused by unintended matching of if-then-elses etc.
*
* Note that the RGE_DDB() macro itself can only be used as a statement,
* not an expression, and should always be followed by a semicolon.
*/
#if RGE_DEBUGGING
{ command; } \
} while (0)
#else /* RGE_DEBUGGING */
} while (0)
#endif /* RGE_DEBUGGING */
/*
* These provide the primitive conditional-call capability required.
* Note: the parameter <args> is a parenthesised list of the actual
* printf-style arguments to be passed to the debug function ...
*/
/*
* Conditional-print macros.
*
* Define RGE_DBG to be the relevant member of the set of RGE_DBG_* values
* above before using the RGE_GDEBUG() or RGE_DEBUG() macros. The 'G'
* versions look at the Global debug flag word (rge_debug); the non-G
* versions look in the per-instance data (rgep->debug) and so require a
* variable called 'rgep' to be in scope (and initialised!) before use.
*
* You could redefine RGE_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.
*
* Note: the parameter <args> is a parenthesised list of the actual
* arguments to be passed to the debug function, usually a printf-style
* format string and corresponding values to be formatted.
*/
/*
* Debug-only action macros
*/
/*
* Inter-source-file linkage ...
*/
/* rge_chip.c */
void rge_chip_cyclic(void *arg);
/* rge_kstats.c */
/* rge_log.c */
#if RGE_DEBUGGING
#endif /* RGE_DEBUGGING */
/* rge_main.c */
/* rge_ndd.c */
/* rge_rxtx.c */
#ifdef __cplusplus
}
#endif
#endif /* _RGE_H */