2006-02-19 22:39:19 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
|
2009-02-17 22:15:58 +00:00
|
|
|
Copyright (c) 2006-2009, Myricom Inc.
|
2006-02-19 22:39:19 +00:00
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer.
|
|
|
|
|
2007-07-12 16:04:55 +00:00
|
|
|
2. Neither the name of the Myricom Inc, nor the names of its
|
2006-02-19 22:39:19 +00:00
|
|
|
contributors may be used to endorse or promote products derived from
|
|
|
|
this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
$FreeBSD$
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
2006-06-13 13:53:52 +00:00
|
|
|
#define MXGE_ETH_STOPPED 0
|
|
|
|
#define MXGE_ETH_STOPPING 1
|
|
|
|
#define MXGE_ETH_STARTING 2
|
|
|
|
#define MXGE_ETH_RUNNING 3
|
|
|
|
#define MXGE_ETH_OPEN_FAILED 4
|
2006-02-19 22:39:19 +00:00
|
|
|
|
2006-06-13 13:53:52 +00:00
|
|
|
#define MXGE_FW_OFFSET 1024*1024
|
|
|
|
#define MXGE_EEPROM_STRINGS_SIZE 256
|
2007-05-22 15:57:49 +00:00
|
|
|
#define MXGE_MAX_SEND_DESC 128
|
2006-02-19 22:39:19 +00:00
|
|
|
|
2008-08-21 16:35:34 +00:00
|
|
|
#if ((__FreeBSD_version > 800000 && __FreeBSD_version < 800005) \
|
|
|
|
|| __FreeBSD_version < 700111)
|
2008-01-22 22:04:31 +00:00
|
|
|
#define MXGE_VIRT_JUMBOS 1
|
|
|
|
#else
|
|
|
|
#define MXGE_VIRT_JUMBOS 0
|
|
|
|
#endif
|
|
|
|
|
2009-06-02 16:52:33 +00:00
|
|
|
#if (__FreeBSD_version > 800082)
|
|
|
|
#define IFNET_BUF_RING 1
|
|
|
|
#endif
|
|
|
|
|
2008-02-14 00:09:59 +00:00
|
|
|
#ifndef VLAN_CAPABILITIES
|
|
|
|
#define VLAN_CAPABILITIES(ifp)
|
|
|
|
#define mxge_vlans_active(sc) (sc)->ifp->if_nvlans
|
|
|
|
#else
|
|
|
|
#define mxge_vlans_active(sc) (sc)->ifp->if_vlantrunk
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef VLAN_TAG_VALUE
|
|
|
|
#define MXGE_NEW_VLAN_API
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef IFCAP_LRO
|
|
|
|
#define IFCAP_LRO 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef IFCAP_TSO
|
|
|
|
#define IFCAP_TSO 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef IFCAP_TSO4
|
|
|
|
#define IFCAP_TSO4 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CSUM_TSO
|
|
|
|
#define CSUM_TSO 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-02-19 22:39:19 +00:00
|
|
|
typedef struct {
|
|
|
|
void *addr;
|
|
|
|
bus_addr_t bus_addr;
|
|
|
|
bus_dma_tag_t dmat;
|
|
|
|
bus_dmamap_t map;
|
2006-06-13 13:53:52 +00:00
|
|
|
} mxge_dma_t;
|
2006-02-19 22:39:19 +00:00
|
|
|
|
|
|
|
|
2006-06-14 16:23:17 +00:00
|
|
|
typedef struct {
|
|
|
|
mcp_slot_t *entry;
|
|
|
|
mxge_dma_t dma;
|
|
|
|
int cnt;
|
|
|
|
int idx;
|
2007-05-22 15:57:49 +00:00
|
|
|
int mask;
|
2006-06-14 16:23:17 +00:00
|
|
|
} mxge_rx_done_t;
|
2006-02-19 22:39:19 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t data0;
|
|
|
|
uint32_t data1;
|
|
|
|
uint32_t data2;
|
2006-06-13 13:53:52 +00:00
|
|
|
} mxge_cmd_t;
|
2006-02-19 22:39:19 +00:00
|
|
|
|
2006-06-14 16:23:17 +00:00
|
|
|
struct mxge_rx_buffer_state {
|
2006-02-19 22:39:19 +00:00
|
|
|
struct mbuf *m;
|
|
|
|
bus_dmamap_t map;
|
|
|
|
};
|
|
|
|
|
2006-06-14 16:23:17 +00:00
|
|
|
struct mxge_tx_buffer_state {
|
|
|
|
struct mbuf *m;
|
|
|
|
bus_dmamap_t map;
|
|
|
|
int flag;
|
|
|
|
};
|
|
|
|
|
2006-02-19 22:39:19 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
volatile mcp_kreq_ether_recv_t *lanai; /* lanai ptr for recv ring */
|
|
|
|
mcp_kreq_ether_recv_t *shadow; /* host shadow of recv ring */
|
2006-06-14 16:23:17 +00:00
|
|
|
struct mxge_rx_buffer_state *info;
|
2006-02-19 22:39:19 +00:00
|
|
|
bus_dma_tag_t dmat;
|
|
|
|
bus_dmamap_t extra_map;
|
|
|
|
int cnt;
|
2007-05-21 18:32:27 +00:00
|
|
|
int nbufs;
|
|
|
|
int cl_size;
|
2006-02-19 22:39:19 +00:00
|
|
|
int alloc_fail;
|
|
|
|
int mask; /* number of rx slots -1 */
|
2009-06-01 19:16:57 +00:00
|
|
|
int mlen;
|
2008-01-15 20:34:49 +00:00
|
|
|
} mxge_rx_ring_t;
|
2006-02-19 22:39:19 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2008-01-15 20:34:49 +00:00
|
|
|
struct mtx mtx;
|
2009-04-27 17:24:47 +00:00
|
|
|
#ifdef IFNET_BUF_RING
|
2009-04-27 15:45:54 +00:00
|
|
|
struct buf_ring *br;
|
|
|
|
#endif
|
2006-02-19 22:39:19 +00:00
|
|
|
volatile mcp_kreq_ether_send_t *lanai; /* lanai ptr for sendq */
|
2009-04-27 15:45:54 +00:00
|
|
|
volatile uint32_t *send_go; /* doorbell for sendq */
|
|
|
|
volatile uint32_t *send_stop; /* doorbell for sendq */
|
2006-02-19 22:39:19 +00:00
|
|
|
mcp_kreq_ether_send_t *req_list; /* host shadow of sendq */
|
|
|
|
char *req_bytes;
|
2006-09-15 15:41:28 +00:00
|
|
|
bus_dma_segment_t *seg_list;
|
2006-06-14 16:23:17 +00:00
|
|
|
struct mxge_tx_buffer_state *info;
|
2006-02-19 22:39:19 +00:00
|
|
|
bus_dma_tag_t dmat;
|
|
|
|
int req; /* transmits submitted */
|
|
|
|
int mask; /* number of transmit slots -1 */
|
|
|
|
int done; /* transmits completed */
|
2006-06-14 16:23:17 +00:00
|
|
|
int pkt_done; /* packets completed */
|
2007-05-22 15:57:49 +00:00
|
|
|
int max_desc; /* max descriptors per xmit */
|
2009-04-27 15:45:54 +00:00
|
|
|
int queue_active; /* fw currently polling this queue*/
|
|
|
|
int activate;
|
|
|
|
int deactivate;
|
2007-01-30 08:39:44 +00:00
|
|
|
int stall; /* #times hw queue exhausted */
|
|
|
|
int wake; /* #times irq re-enabled xmit */
|
2007-01-31 19:53:36 +00:00
|
|
|
int watchdog_req; /* cache of req */
|
|
|
|
int watchdog_done; /* cache of done */
|
2007-08-22 13:22:12 +00:00
|
|
|
int watchdog_rx_pause; /* cache of pause rq recvd */
|
2008-01-15 20:34:49 +00:00
|
|
|
int defrag;
|
|
|
|
char mtx_name[16];
|
|
|
|
} mxge_tx_ring_t;
|
2006-02-19 22:39:19 +00:00
|
|
|
|
2007-05-21 18:32:27 +00:00
|
|
|
struct lro_entry;
|
|
|
|
struct lro_entry
|
|
|
|
{
|
|
|
|
SLIST_ENTRY(lro_entry) next;
|
|
|
|
struct mbuf *m_head;
|
|
|
|
struct mbuf *m_tail;
|
|
|
|
int timestamp;
|
|
|
|
struct ip *ip;
|
|
|
|
uint32_t tsval;
|
|
|
|
uint32_t tsecr;
|
|
|
|
uint32_t source_ip;
|
|
|
|
uint32_t dest_ip;
|
|
|
|
uint32_t next_seq;
|
|
|
|
uint32_t ack_seq;
|
|
|
|
uint32_t len;
|
|
|
|
uint32_t data_csum;
|
|
|
|
uint16_t window;
|
|
|
|
uint16_t source_port;
|
|
|
|
uint16_t dest_port;
|
|
|
|
uint16_t append_cnt;
|
|
|
|
uint16_t mss;
|
|
|
|
|
|
|
|
};
|
|
|
|
SLIST_HEAD(lro_head, lro_entry);
|
|
|
|
|
2008-01-15 20:34:49 +00:00
|
|
|
struct mxge_softc;
|
|
|
|
typedef struct mxge_softc mxge_softc_t;
|
|
|
|
|
|
|
|
struct mxge_slice_state {
|
|
|
|
mxge_softc_t *sc;
|
|
|
|
mxge_tx_ring_t tx; /* transmit ring */
|
|
|
|
mxge_rx_ring_t rx_small;
|
|
|
|
mxge_rx_ring_t rx_big;
|
2006-06-14 16:23:17 +00:00
|
|
|
mxge_rx_done_t rx_done;
|
|
|
|
mcp_irq_data_t *fw_stats;
|
2008-01-15 20:34:49 +00:00
|
|
|
volatile uint32_t *irq_claim;
|
|
|
|
u_long ipackets;
|
2009-04-27 15:45:54 +00:00
|
|
|
u_long opackets;
|
2009-06-23 19:04:25 +00:00
|
|
|
u_long obytes;
|
|
|
|
u_long omcasts;
|
2009-04-27 15:45:54 +00:00
|
|
|
u_long oerrors;
|
|
|
|
int if_drv_flags;
|
2007-05-21 18:32:27 +00:00
|
|
|
struct lro_head lro_active;
|
|
|
|
struct lro_head lro_free;
|
|
|
|
int lro_queued;
|
|
|
|
int lro_flushed;
|
|
|
|
int lro_bad_csum;
|
2008-01-15 20:34:49 +00:00
|
|
|
mxge_dma_t fw_stats_dma;
|
|
|
|
struct sysctl_oid *sysctl_tree;
|
|
|
|
struct sysctl_ctx_list sysctl_ctx;
|
|
|
|
char scratch[256];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mxge_softc {
|
|
|
|
struct ifnet* ifp;
|
|
|
|
struct mxge_slice_state *ss;
|
|
|
|
int csum_flag; /* rx_csums? */
|
|
|
|
int tx_boundary; /* boundary transmits cannot cross*/
|
2007-05-21 18:32:27 +00:00
|
|
|
int lro_cnt;
|
2008-01-15 20:34:49 +00:00
|
|
|
bus_dma_tag_t parent_dmat;
|
|
|
|
volatile uint8_t *sram;
|
2006-02-19 22:39:19 +00:00
|
|
|
int sram_size;
|
2006-06-14 16:23:17 +00:00
|
|
|
volatile uint32_t *irq_deassert;
|
2006-02-19 22:39:19 +00:00
|
|
|
mcp_cmd_response_t *cmd;
|
2006-06-13 13:53:52 +00:00
|
|
|
mxge_dma_t cmd_dma;
|
|
|
|
mxge_dma_t zeropad_dma;
|
2006-02-19 22:39:19 +00:00
|
|
|
struct pci_dev *pdev;
|
2008-02-14 16:24:14 +00:00
|
|
|
int legacy_irq;
|
2006-02-19 22:39:19 +00:00
|
|
|
int link_state;
|
|
|
|
unsigned int rdma_tags_available;
|
|
|
|
int intr_coal_delay;
|
2006-06-14 16:23:17 +00:00
|
|
|
volatile uint32_t *intr_coal_delay_ptr;
|
2006-02-19 22:39:19 +00:00
|
|
|
int wc;
|
2007-01-31 15:29:31 +00:00
|
|
|
struct mtx cmd_mtx;
|
|
|
|
struct mtx driver_mtx;
|
2006-02-19 22:39:19 +00:00
|
|
|
int wake_queue;
|
|
|
|
int stop_queue;
|
|
|
|
int down_cnt;
|
|
|
|
int watchdog_resets;
|
2008-01-15 20:34:49 +00:00
|
|
|
int watchdog_countdown;
|
2006-02-19 22:39:19 +00:00
|
|
|
int pause;
|
|
|
|
struct resource *mem_res;
|
|
|
|
struct resource *irq_res;
|
2008-01-15 20:34:49 +00:00
|
|
|
struct resource **msix_irq_res;
|
|
|
|
struct resource *msix_table_res;
|
|
|
|
struct resource *msix_pba_res;
|
2006-02-19 22:39:19 +00:00
|
|
|
void *ih;
|
2008-01-15 20:34:49 +00:00
|
|
|
void **msix_ih;
|
2006-02-19 22:39:19 +00:00
|
|
|
char *fw_name;
|
2006-06-13 13:53:52 +00:00
|
|
|
char eeprom_strings[MXGE_EEPROM_STRINGS_SIZE];
|
2006-02-19 22:39:19 +00:00
|
|
|
char fw_version[128];
|
2007-02-21 17:34:05 +00:00
|
|
|
int fw_ver_major;
|
|
|
|
int fw_ver_minor;
|
|
|
|
int fw_ver_tiny;
|
|
|
|
int adopted_rx_filter_bug;
|
2006-02-19 22:39:19 +00:00
|
|
|
device_t dev;
|
|
|
|
struct ifmedia media;
|
2006-06-14 16:23:17 +00:00
|
|
|
int read_dma;
|
|
|
|
int write_dma;
|
|
|
|
int read_write_dma;
|
2006-09-15 19:24:45 +00:00
|
|
|
int fw_multicast_support;
|
2006-11-22 16:33:40 +00:00
|
|
|
int link_width;
|
2007-05-21 18:32:27 +00:00
|
|
|
int max_mtu;
|
2009-09-21 14:41:07 +00:00
|
|
|
int throttle;
|
2007-05-22 15:57:49 +00:00
|
|
|
int tx_defrag;
|
2007-08-22 13:22:12 +00:00
|
|
|
int media_flags;
|
|
|
|
int need_media_probe;
|
2008-01-15 20:34:49 +00:00
|
|
|
int num_slices;
|
|
|
|
int rx_ring_size;
|
2009-06-24 21:09:56 +00:00
|
|
|
int dying;
|
2010-04-15 13:50:55 +00:00
|
|
|
int connector;
|
|
|
|
int current_media;
|
2007-01-31 15:29:31 +00:00
|
|
|
mxge_dma_t dmabench_dma;
|
2007-01-31 19:53:36 +00:00
|
|
|
struct callout co_hdl;
|
2009-10-19 20:51:27 +00:00
|
|
|
struct taskqueue *tq;
|
|
|
|
struct task watchdog_task;
|
2008-01-15 20:34:49 +00:00
|
|
|
struct sysctl_oid *slice_sysctl_tree;
|
|
|
|
struct sysctl_ctx_list slice_sysctl_ctx;
|
2006-06-14 16:23:17 +00:00
|
|
|
char *mac_addr_string;
|
2007-05-22 15:57:49 +00:00
|
|
|
uint8_t mac_addr[6]; /* eeprom mac address */
|
2009-09-30 14:42:06 +00:00
|
|
|
uint16_t pectl; /* save PCIe CTL state */
|
2006-06-14 16:23:17 +00:00
|
|
|
char product_code_string[64];
|
|
|
|
char serial_number_string[64];
|
2007-01-31 15:29:31 +00:00
|
|
|
char cmd_mtx_name[16];
|
|
|
|
char driver_mtx_name[16];
|
2008-01-15 20:34:49 +00:00
|
|
|
};
|
2006-02-19 22:39:19 +00:00
|
|
|
|
2006-06-13 13:53:52 +00:00
|
|
|
#define MXGE_PCI_VENDOR_MYRICOM 0x14c1
|
|
|
|
#define MXGE_PCI_DEVICE_Z8E 0x0008
|
2007-09-13 21:29:02 +00:00
|
|
|
#define MXGE_PCI_DEVICE_Z8E_9 0x0009
|
2009-02-17 22:15:58 +00:00
|
|
|
#define MXGE_PCI_REV_Z8E 0
|
|
|
|
#define MXGE_PCI_REV_Z8ES 1
|
2007-08-22 13:22:12 +00:00
|
|
|
#define MXGE_XFP_COMPLIANCE_BYTE 131
|
2009-02-17 22:15:58 +00:00
|
|
|
#define MXGE_SFP_COMPLIANCE_BYTE 3
|
2009-09-21 14:41:07 +00:00
|
|
|
#define MXGE_MIN_THROTTLE 416
|
|
|
|
#define MXGE_MAX_THROTTLE 4096
|
2006-02-19 22:39:19 +00:00
|
|
|
|
2010-04-15 13:50:55 +00:00
|
|
|
/* Types of connectors on NICs supported by this driver */
|
|
|
|
#define MXGE_CX4 0
|
|
|
|
#define MXGE_XFP 1
|
|
|
|
#define MXGE_SFP 2
|
|
|
|
#define MXGE_QRF 3
|
|
|
|
|
2006-06-13 13:53:52 +00:00
|
|
|
#define MXGE_HIGHPART_TO_U32(X) \
|
2006-02-19 22:39:19 +00:00
|
|
|
(sizeof (X) == 8) ? ((uint32_t)((uint64_t)(X) >> 32)) : (0)
|
2006-06-13 13:53:52 +00:00
|
|
|
#define MXGE_LOWPART_TO_U32(X) ((uint32_t)(X))
|
2006-02-19 22:39:19 +00:00
|
|
|
|
2007-08-22 13:22:12 +00:00
|
|
|
struct mxge_media_type
|
|
|
|
{
|
|
|
|
int flag;
|
|
|
|
uint8_t bitmask;
|
|
|
|
char *name;
|
|
|
|
};
|
2006-02-19 22:39:19 +00:00
|
|
|
|
|
|
|
/* implement our own memory barriers, since bus_space_barrier
|
|
|
|
cannot handle write-combining regions */
|
|
|
|
|
2008-11-22 05:55:56 +00:00
|
|
|
#if __FreeBSD_version < 800053
|
|
|
|
|
2006-02-19 22:39:19 +00:00
|
|
|
#if defined (__GNUC__)
|
|
|
|
#if #cpu(i386) || defined __i386 || defined i386 || defined __i386__ || #cpu(x86_64) || defined __x86_64__
|
2008-11-24 19:00:57 +00:00
|
|
|
#define wmb() __asm__ __volatile__ ("sfence;": : :"memory")
|
2006-02-19 22:39:19 +00:00
|
|
|
#elif #cpu(sparc64) || defined sparc64 || defined __sparcv9
|
2008-11-24 19:00:57 +00:00
|
|
|
#define wmb() __asm__ __volatile__ ("membar #MemIssue": : :"memory")
|
2006-02-19 22:39:19 +00:00
|
|
|
#elif #cpu(sparc) || defined sparc || defined __sparc__
|
2008-11-24 19:00:57 +00:00
|
|
|
#define wmb() __asm__ __volatile__ ("stbar;": : :"memory")
|
2006-02-19 22:39:19 +00:00
|
|
|
#else
|
2008-11-24 19:00:57 +00:00
|
|
|
#define wmb() /* XXX just to make this compile */
|
2006-02-19 22:39:19 +00:00
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#error "unknown compiler"
|
|
|
|
#endif
|
|
|
|
|
2008-11-22 05:55:56 +00:00
|
|
|
#endif
|
|
|
|
|
2006-02-19 22:39:19 +00:00
|
|
|
static inline void
|
2006-06-13 13:53:52 +00:00
|
|
|
mxge_pio_copy(volatile void *to_v, void *from_v, size_t size)
|
2006-02-19 22:39:19 +00:00
|
|
|
{
|
|
|
|
register volatile uintptr_t *to;
|
|
|
|
volatile uintptr_t *from;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
to = (volatile uintptr_t *) to_v;
|
|
|
|
from = from_v;
|
|
|
|
for (i = (size / sizeof (uintptr_t)); i; i--) {
|
|
|
|
*to = *from;
|
|
|
|
to++;
|
|
|
|
from++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-01-15 20:34:49 +00:00
|
|
|
void mxge_lro_flush(struct mxge_slice_state *ss, struct lro_entry *lro);
|
|
|
|
int mxge_lro_rx(struct mxge_slice_state *ss, struct mbuf *m_head,
|
|
|
|
uint32_t csum);
|
2007-05-21 18:32:27 +00:00
|
|
|
|
|
|
|
|
2006-02-19 22:39:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
This file uses Myri10GE driver indentation.
|
|
|
|
|
|
|
|
Local Variables:
|
|
|
|
c-file-style:"linux"
|
|
|
|
tab-width:8
|
|
|
|
End:
|
|
|
|
*/
|