nge.h revision 6de4f663f1451acc7a8968bb7891bc18eaba0db5
/*
* 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_NGE_H
#define _SYS_NGE_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/ethernet.h>
#include <sys/mac_ether.h>
/*
* Reconfiguring the network devices requires the net_config privilege
* in Solaris 10+.
*/
#include "nge_chip.h"
/*
* Copy an ethernet address
*/
#define NGE_DRIVER_NAME "nge"
/*
* 'Progress' bit flags ...
*/
/* and mutexen initialised */
#define PROGRESS_HWINT 0x0080
#define NGE_HW_ERR 0x00
#define NGE_HW_LINK 0x01
#define NGE_HW_BM 0x02
#define NGE_HW_RCHAN 0x03
#define NGE_HW_TCHAN 0x04
#define NGE_HW_ROM 0x05
#define NGE_SW_PROBLEM_ID 0x06
/*
* NOTES:
*
* #defines:
*
* NGE_PCI_CONFIG_RNUMBER and NGE_PCI_OPREGS_RNUMBER are the
* register-set numbers to use for the config space registers
* and the operating registers respectively. On an OBP-based
* machine, regset 0 refers to CONFIG space, and regset 1 will
* be the operating registers in MEMORY space. If an expansion
* ROM is fitted, it may appear as a further register set.
*
* NGE_DMA_MODE defines the mode (STREAMING/CONSISTENT) used
* for the data buffers. The descriptors are always set up
* in CONSISTENT mode.
*
* NGE_HEADROOM defines how much space we'll leave in allocated
* mblks before the first valid data byte. This should be chosen
* to be 2 modulo 4, so that once the ethernet header (14 bytes)
* has been stripped off, the packet data will be 4-byte aligned.
* The remaining space can be used by upstream modules to prepend
* any headers required.
*/
#define NGE_PCI_OPREGS_RNUMBER 1
#define NGE_DMA_MODE DDI_DMA_STREAMING
#define NGE_HEADROOM 6
#define ETHER_HEAD_LEN 14
#ifndef VTAG_SIZE
#define VTAG_SIZE 4
#endif
#define NGE_DEFAULT_MTU 1500
#define NGE_DEFAULT_SDU 1518
#define NGE_MTU_2500 2500
#define NGE_MTU_4500 4500
#define NGE_MAX_MTU 9000
#define NGE_MAX_SDU 9018
#define NGE_DESC_MIN 0x200
#define NGE_STD_BUFSZ 1792
#define NGE_SEND_SLOTS_DESC_1024 1024
#define NGE_SEND_SLOTS_DESC_3072 3072
#define NGE_SEND_JB2500_SLOTS_DESC 3072
#define NGE_SEND_JB4500_SLOTS_DESC 2048
#define NGE_SEND_JB9000_SLOTS_DESC 1024
#define NGE_SEND_LOWMEM_SLOTS_DESC 1024
#define NGE_SEND_SLOTS_BUF 3072
#define NGE_RECV_SLOTS_DESC_1024 1024
#define NGE_RECV_SLOTS_DESC_3072 3072
#define NGE_RECV_JB2500_SLOTS_DESC 3072
#define NGE_RECV_JB4500_SLOTS_DESC 2048
#define NGE_RECV_JB9000_SLOTS_DESC 1024
#define NGE_RECV_LOWMEM_SLOTS_DESC 1024
#define NGE_RECV_SLOTS_BUF 6144
#define NGE_SPLIT_32 32
#define NGE_SPLIT_96 96
#define NGE_SPLIT_256 256
#define NGE_RX_COPY_SIZE 512
#define NGE_TX_COPY_SIZE 512
#define NGE_MAP_FRAGS 3
#define NGE_MAX_COOKIES 3
/* Used by interrupt moderation */
#define NGE_POLL_QUIET_TIME 100
#define NGE_POLL_BUSY_TIME 2
#define NGE_TX_N_INTR 128
/*
* NGE-specific ioctls ...
*/
/*
*/
/*
*
* Note: SEEPROMs can only be accessed as 32-bit words, so <see_addr>
* must be a multiple of 4. Not all systems have a SEEPROM fitted!
*/
/*
* These diagnostic IOCTLS are enabled only in DEBUG drivers
*/
enum NGE_HW_OP {
NGE_CLEAR = 0,
};
/*
* Required state according to GLD
*/
enum nge_mac_state {
};
enum loop_type {
NGE_LOOP_NONE = 0,
};
/*
* (Internal) return values from send_msg subroutines
*/
enum send_status {
SEND_MAP_FAIL, /* => GLD_NORESOURCES */
SEND_COPY_SUCESS, /* OK, msg queued */
SEND_MAP_SUCCESS /* OK, free msg */
};
/*
* (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 */
};
enum nge_pp_type {
NGE_PP_SPACE_CFG = 0,
};
/*
* Flag to kstat type
*/
enum nge_kstat_type {
NGE_KSTAT_RAW = 0,
};
/*
* Actual state of the nvidia's chip
*/
enum nge_chip_state {
NGE_CHIP_ERROR, /* error, want reset */
NGE_CHIP_INITIAL, /* Initial state only */
NGE_CHIP_RESET, /* reset, need init */
NGE_CHIP_STOPPED, /* Tx/Rx stopped */
NGE_CHIP_RUNNING /* with interrupts */
};
enum nge_eeprom_size {
EEPROM_1K = 0,
};
enum nge_eeprom_access_wid {
ACCESS_8BIT = 0,
};
/*
* MDIO operation
*/
enum nge_mdio_operation {
NGE_MDIO_READ = 0,
};
/*
* Speed selection
*/
enum nge_speed {
UNKOWN_SPEED = 0,
};
/*
* Duplex selection
*/
enum nge_duplex {
UNKOWN_DUPLEX = 0,
};
typedef struct {
struct nge;
#define CHIP_FLAG_COPPER 0x40
/*
* Collection of physical-layer functions to:
* (re)initialise the physical layer
* update it to match software settings
* check for link status change
*/
typedef struct {
void (*phys_update)(struct nge *);
} phys_ops_t;
struct nge_see_rw {
};
typedef struct {
/* input for poke */
typedef struct _mul_list {
/*
* 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 dma_area
{
void *mem_va; /* CPU VA of memory */
/* >= product of above */
/* for deciding to free */
/* or to reuse buffers */
} dma_area_t;
#define HOST_OWN 0x00000000
#define CONTROLER_OWN 0x00000001
#define NGE_END_PACKET 0x00000002
typedef struct nge_dmah_node
{
struct nge_dmah_node *next;
typedef struct nge_dmah_list
{
/*
* Software version of the Recv Descriptor
* There's one of these for each recv buffer (up to 512 per ring)
*/
typedef struct sw_rx_sbd {
/* descriptor area */
/* buffer area */
} sw_rx_sbd_t;
/*
* Software version of the send Buffer Descriptor
* There's one of these for each send buffer (up to 512 per ring)
*/
typedef struct sw_tx_sbd {
/* descriptor area */
/* buffer area */
void (*tx_recycle)(struct sw_tx_sbd *);
} sw_tx_sbd_t;
/*
* Software Receive Buffer (Producer) Ring Control Block
* There's one of these for each receiver producer ring (up to 3),
* but each holds buffers of a different size.
*/
typedef struct buff_ring {
/* driver soft state */
/* initialise same */
/* for deciding to free */
/* or to reuse buffers */
} buff_ring_t;
/*
* Software Receive (Return) Ring Control Block
* There's one of these for each receiver return ring (up to 16).
*/
typedef struct recv_ring {
/*
* The elements flagged (const) in the comments below are
* set up once during initialiation and thereafter unchanged.
*/
/* descriptor area */
/* driver soft state */
/* "producer index" */
} recv_ring_t;
/*
* Software Send Ring Control Block
* There's one of these for each of (up to) 1 send rings
*/
typedef struct send_ring {
/*
* The elements flagged (const) in the comments below are
* set up once during initialiation and thereafter unchanged.
*/
/* descriptor area */
/* buffer area(s) */
/* driver soft state */
/*
* The tx_lock must be held when updating
* the s/w producer index
* (tx_next)
*/
/*
* path using atomics rather than mutexes for speed
*/
/*
* index (tc_next).
*/
/* ("consumer index") */
} send_ring_t;
typedef struct {
} chip_info_t;
typedef struct {
char *name;
typedef struct {
/*
* statistics parameters to tune the driver
*/
typedef struct {
typedef struct {
struct nge_desc_attr {
};
typedef struct nge_desc_attr nge_desc_attr_t;
/*
* Structure used to hold the device-specific config parameters.
* The setting of such parameters may not consistent with the
* hardware feature of the device. It's used for software purpose.
*/
typedef struct nge_dev_spec_param {
typedef struct nge {
/*
* These fields are set by attach() and unchanged thereafter ...
*/
void *io_regs; /* mapped registers */
int intr_type; /* type of interrupt */
int intr_actual_cnt; /* alloc intrs count */
int intr_req_cnt; /* request intrs count */
int intr_cap; /* interrupt capabilities */
int resched_needed;
/*
* Runtime read-write data starts here ...
* 1 Receive Rings
* 1 Send Rings
*
* Note: they're not necessarily all used.
*/
/*
* Link state data (protected by genlock)
*/
const phys_ops_t *physops;
int param_poll_busy_time;
int param_rx_intr_hwater;
int param_rx_intr_lwater;
int param_tx_n_intr;
} nge_t;
extern const nge_ksindex_t nge_statistics[];
/*
* 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)
/*
* Debugging ...
*/
#ifdef DEBUG
#define NGE_DEBUGGING 1
#else
#define NGE_DEBUGGING 0
#endif /* DEBUG */
/*
* Bit flags in the 'debug' word ...
*/
/*
* '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 NGE_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 NGE_DDB() macro itself can only be used as a statement,
* not an expression, and should always be followed by a semicolon.
*/
#if NGE_DEBUGGING
{ command; } \
} while (0)
#else /* NGE_DEBUGGING */
/*
* Old way of debugging. This is a poor way, as it leeaves empty
* statements that cause lint to croak.
* #define NGE_DDB(command) do { \
* { _NOTE(EMPTY); } \
* _NOTE(CONSTANTCONDITION) \
* } while (0)
*/
#endif /* NGE_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 NGE_DBG to be the relevant member of the set of NGE_DBG_* values
* above before using the NGE_GDEBUG() or NGE_DEBUG() macros. The 'G'
* versions look at the Global debug flag word (nge_debug); the non-G
* versions look in the per-instance data (ngep->debug) and so require a
* variable called 'ngep' to be in scope (and initialised!) before use.
*
* You could redefine NGE_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.
*/
#define NGE_TRC NGE_DBG_TRACE
/*
* Debug-only action macros
*/
void
/*
* DESC MODE 2
*/
extern void nge_sum_txd_fill(void *, const ddi_dma_cookie_t *,
/*
* DESC MODE 3
*/
extern void nge_hot_txd_fill(void *, const ddi_dma_cookie_t *,
#ifdef __cplusplus
}
#endif
#endif /* _SYS_NGE_H */