unm_nic.h revision dda0720a40a5b9892e9c96b39ff67c6f504656af
/*
* 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 NetXen, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _UNM_NIC_
#define _UNM_NIC_
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/inttypes.h>
#include <sys/ethernet.h>
#ifdef SOLARIS11
#include <sys/mac_provider.h>
#include <sys/mac_ether.h>
#else
#include "mac.h"
#include "mac_ether.h"
#endif
#include "unm_nic_hw.h"
#include "nic_cmn.h"
#include "unm_inc.h" /* For MAX_RCV_CTX */
#include "unm_brdcfg.h"
#include "unm_version.h"
#include "nic_phan_reg.h"
#include "unm_nic_ioctl.h"
#define MAX_ADDR_LEN 6
#define ADDR_IN_WINDOW1(off) \
typedef unsigned long uptr_t;
#define FIRST_PAGE_GROUP_START 0
#define FIRST_PAGE_GROUP_END 0x100000
#define SECOND_PAGE_GROUP_START 0x6000000
#define SECOND_PAGE_GROUP_END 0x68BC000
#define THIRD_PAGE_GROUP_START 0x70E4000
#define THIRD_PAGE_GROUP_END 0x8000000
/*
* normalize a 64MB crb address to 32MB PCI window
* To use CRB_NORMALIZE, window _must_ be set to 1
*/
#define CRB_NORMAL(reg) \
#define find_diff_among(a, b, range) \
((a) < (b)?((b)-(a)):((b)+(range)-(a)))
#define __FUNCTION__ __func__
#define HOST_TO_LE_64 LE_64
#define HOST_TO_LE_32 LE_32
#define LE_TO_HOST_32 LE_32
#define HOST_TO_LE_16 LE_16
#define LE_TO_HOST_16 LE_16
/*
* Following macros require the mapped addresses to access
* the Phantom memory.
*/
#define UNM_NIC_PCI_READ_8(ADDRESS) \
#define UNM_NIC_PCI_READ_16(ADDRESS) \
#define UNM_NIC_PCI_READ_32(ADDRESS) \
#define UNM_NIC_PCI_READ_64(ADDRESS) \
#ifdef DEBUG_LEVEL
#else
#endif
extern char unm_nic_driver_name[];
extern int verbmsg;
typedef struct unm_dmah_node {
struct unm_dmah_node *next;
typedef struct dma_area {
void *vaddr;
} dma_area_t;
struct unm_cmd_buffer {
};
typedef struct pkt_info {
} pktinfo_t;
typedef struct unm_rcv_desc_context_s unm_rcv_desc_ctx_t;
typedef struct unm_adapter_s unm_adapter;
typedef struct unm_rx_buffer {
struct unm_rx_buffer *next;
/* Board types */
#define UNM_NIC_GBE 0x01
#define UNM_NIC_XGBE 0x02
/*
* One hardware_context{} per adapter
* contains interrupt info as well shared hardware info.
*/
typedef struct _hardware_context {
unsigned long pci_base0;
unsigned long pci_len0;
unsigned long pci_base1;
unsigned long pci_len1;
unsigned long pci_base2;
unsigned long pci_len2;
unsigned long first_page_group_end;
unsigned long first_page_group_start;
int pci_func;
struct unm_adapter_s *adapter;
unsigned long db_base; /* base of mapped db memory */
unsigned long db_len; /* length of mapped db memory */
int qdr_sn_window, ddr_mn_window;
unsigned long mn_win_crb, ms_win_crb;
#define NX_CT_DEFAULT_RX_BUF_LEN 2048
#define MTU_SIZE 1500
#define MAX_COOKIES_PER_CMD 15
#define UNM_DB_MAPSIZE_BYTES 0x1000
#define EXTRA_HANDLES 512
#define UNM_TX_BCOPY_THRESHOLD 128
#define UNM_RX_BCOPY_THRESHOLD 128
#define NX_MIN_DRIVER_RDS_SIZE 64
typedef struct unm_pauseparam {
/*
*
* These are the values to use with LD_SET_MODE.
*/
#define UNM_LOOP_NONE 0
#define UNM_LOOP_INTERNAL_PHY 1
#define UNM_LOOP_INTERNAL_MAC 2
/*
* 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,
};
struct unm_adapter_stats {
};
/* descriptor types */
#define RCV_RING_STD RCV_DESC_NORMAL
#define RCV_RING_JUMBO RCV_DESC_JUMBO
#define RCV_RING_LRO RCV_DESC_LRO
/*
* Rcv Descriptor Context. One such per Rcv Descriptor. There may
* be one Rcv Descriptor for normal packets, one for jumbo,
* one for LRO and may be expanded.
*/
struct unm_rcv_desc_context_s {
/* address of rx ring in Phantom */
/* size of the receive buf */
/* rx buffers for receive */
};
/*
* Receive context. There is one such structure per instance of the
* receive processing. Any state information that is relevant to
* the receive, and is must be in this structure. The global data may be
* present elsewhere.
*/
typedef struct unm_recv_context_s {
#define UNM_NIC_MSI_ENABLED 0x02
#define UNM_NIC_MSIX_ENABLED 0x04
#define UNM_IS_MSI_FAMILY(ADAPTER) \
#define NX_USE_MSIX
/* msix defines */
#define MSIX_ENTRIES_PER_ADAPTER 8
#define UNM_MSIX_TBL_SPACE 8192
#define UNM_PCI_REG_MSIX_TBL 0x44
/*
* Bug: word or char write on MSI-X capcabilities register (0x40) in PCI config
* space has no effect on register values. Need to write dword.
*/
#define UNM_HWBUG_8_WORKAROUND
/*
* Bug: Can not reset bit 32 (msix enable bit) on MSI-X capcabilities
* register (0x40) independently.
* Need to write 0x0 (zero) to MSI-X capcabilities register in order to reset
* msix enable bit. On writing zero rest of the bits are not touched.
*/
#define UNM_HWBUG_9_WORKAROUND
/* Following structure is for specific port information */
struct unm_adapter_s {
struct unm_adapter_stats stats;
int rx_csum;
int status;
unsigned char mac_addr[MAX_ADDR_LEN];
int mtu; /* active mtu */
int maxmtu; /* max possible mtu value */
int flags;
int instance;
struct ddi_device_acc_attr gc_attr_desc;
const char *name;
int intr_type;
int tx_bcopy_threshold;
struct nx_legacy_intr_set legacy_intr;
short context_alloced;
int max_rds_rings;
/* Num of bufs posted in phantom */
/* Num of instances active on cmd buffer ring */
int resched_needed;
int driver_mismatch;
int rx_bcopy_threshold;
/*
* Receive instances. These can be either one per port,
* or one per peg, etc.
*/
int is_up;
/* context interface shared between card and host */
struct {
void *addr;
} dummy_dma;
void (*unm_nic_pci_change_crbwindow)(struct unm_adapter_s *,
uint32_t);
int (*unm_crb_writelit_adapter)(struct unm_adapter_s *,
unsigned long, int);
unsigned long long
(*unm_nic_pci_set_window)(struct unm_adapter_s *,
unsigned long long);
int (*unm_nic_fill_statistics)(struct unm_adapter_s *,
struct unm_statistics *);
int (*unm_nic_clear_statistics)(struct unm_adapter_s *);
void *, int);
int);
int);
int);
int);
u32 *);
u32 *);
u32);
}; /* unm_adapter structure */
#define UNM_HOST_DUMMY_DMA_SIZE 1024
/* Following structure is for specific port information */
((((off) < SECOND_PAGE_GROUP_END) && \
((off) >= SECOND_PAGE_GROUP_START)) ? \
(off) - SECOND_PAGE_GROUP_START) : \
((((off) < THIRD_PAGE_GROUP_END) && \
((off) >= THIRD_PAGE_GROUP_START)) ? \
0)))
{ \
&_v1_, 4)); \
}
/* Functions available from unm_nic_hw.c */
// int unm_nic_reg_read (unm_adapter *adapter, u64 off);
struct unm_adapter_s *adapter);
struct unm_adapter_s *adapter);
int unm_crb_read_val_adapter(unsigned long off,
struct unm_adapter_s *adapter);
/* unm_nic_hw.c */
int unm_crb_writelit_adapter_128M(struct unm_adapter_s *, unsigned long, int);
int len);
int len);
int len);
unsigned long long addr);
struct unm_statistics *unm_stats);
int unm_crb_writelit_adapter_2M(struct unm_adapter_s *, unsigned long, int);
unsigned long long addr);
struct unm_statistics *unm_stats);
/* unm_nic_init.c */
/* unm_nic_isr.c */
/* niu.c */
long unm_niu_gbe_init_port(long port);
long unm_niu_gbe_disable_phy_interrupts(struct unm_adapter_s *);
long unm_niu_gbe_phy_read(struct unm_adapter_s *,
/* unm_nic_ctx.c */
/* unm_nic_main.c */
/* unm_ndd.c */
/* unm_gem.c */
/*
* (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 */
};
/*
* Shorthand for the NDD parameters
*/
/*
* Property lookups
*/
#define UNM_PROP_EXISTS(d, n) \
#define UNM_PROP_GET_INT(d, n) \
/*
* Bit flags in the 'debug' word ...
*/
#define MBPS_10 10
#define MBPS_100 100
#define MBPS_1000 1000
#ifdef __cplusplus
}
#endif
#endif /* !_UNM_NIC_ */