1843e1988Sjohnlev /* 2843e1988Sjohnlev * CDDL HEADER START 3843e1988Sjohnlev * 4843e1988Sjohnlev * The contents of this file are subject to the terms of the 5843e1988Sjohnlev * Common Development and Distribution License (the "License"). 6843e1988Sjohnlev * You may not use this file except in compliance with the License. 7843e1988Sjohnlev * 8843e1988Sjohnlev * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9843e1988Sjohnlev * or http://www.opensolaris.org/os/licensing. 10843e1988Sjohnlev * See the License for the specific language governing permissions 11843e1988Sjohnlev * and limitations under the License. 12843e1988Sjohnlev * 13843e1988Sjohnlev * When distributing Covered Code, include this CDDL HEADER in each 14843e1988Sjohnlev * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15843e1988Sjohnlev * If applicable, add the following below this CDDL HEADER, with the 16843e1988Sjohnlev * fields enclosed by brackets "[]" replaced with your own identifying 17843e1988Sjohnlev * information: Portions Copyright [yyyy] [name of copyright owner] 18843e1988Sjohnlev * 19843e1988Sjohnlev * CDDL HEADER END 20843e1988Sjohnlev */ 21843e1988Sjohnlev 22843e1988Sjohnlev /* 2356567907SDavid Edmondson * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24843e1988Sjohnlev * Use is subject to license terms. 25843e1988Sjohnlev */ 26843e1988Sjohnlev 27843e1988Sjohnlev #ifndef _SYS_XNF_H 28843e1988Sjohnlev #define _SYS_XNF_H 29843e1988Sjohnlev 30843e1988Sjohnlev #ifdef __cplusplus 31843e1988Sjohnlev extern "C" { 32843e1988Sjohnlev #endif 33843e1988Sjohnlev 34*87308b74SRichard Lowe #define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGESIZE) 35*87308b74SRichard Lowe #define NET_RX_RING_SIZE __CONST_RING_SIZE(netif_rx, PAGESIZE) 36843e1988Sjohnlev 37843e1988Sjohnlev #define XNF_MAXPKT 1500 /* MTU size */ 38843e1988Sjohnlev #define XNF_FRAMESIZE 1514 /* frame size including MAC header */ 39843e1988Sjohnlev 40843e1988Sjohnlev /* DEBUG flags */ 41843e1988Sjohnlev #define XNF_DEBUG_DDI 0x01 42843e1988Sjohnlev #define XNF_DEBUG_TRACE 0x02 43843e1988Sjohnlev 4456567907SDavid Edmondson /* 4556567907SDavid Edmondson * Information about each receive buffer and any transmit look-aside 4656567907SDavid Edmondson * buffers. 4756567907SDavid Edmondson */ 4856567907SDavid Edmondson typedef struct xnf_buf { 4956567907SDavid Edmondson frtn_t free_rtn; 50843e1988Sjohnlev struct xnf *xnfp; 51843e1988Sjohnlev ddi_dma_handle_t dma_handle; 52843e1988Sjohnlev caddr_t buf; /* DMA-able data buffer */ 53843e1988Sjohnlev paddr_t buf_phys; 5456567907SDavid Edmondson mfn_t buf_mfn; 5556567907SDavid Edmondson size_t len; 5656567907SDavid Edmondson struct xnf_buf *next; /* For linking into free list */ 57843e1988Sjohnlev ddi_acc_handle_t acc_handle; 58843e1988Sjohnlev grant_ref_t grant_ref; /* grant table reference */ 59843e1988Sjohnlev uint16_t id; /* buffer id */ 6056567907SDavid Edmondson unsigned int gen; 6156567907SDavid Edmondson } xnf_buf_t; 62843e1988Sjohnlev 6356567907SDavid Edmondson /* 6456567907SDavid Edmondson * Information about each transmit buffer. 6556567907SDavid Edmondson */ 6656567907SDavid Edmondson typedef struct xnf_txbuf { 6756567907SDavid Edmondson struct xnf_txbuf *tx_next; 6856567907SDavid Edmondson mblk_t *tx_mp; /* mblk associated with packet */ 6956567907SDavid Edmondson netif_tx_request_t tx_txreq; 7056567907SDavid Edmondson caddr_t tx_bufp; 7156567907SDavid Edmondson ddi_dma_handle_t tx_dma_handle; 7256567907SDavid Edmondson mfn_t tx_mfn; 7356567907SDavid Edmondson xnf_buf_t *tx_bdesc; /* Look-aside buffer, if used. */ 7456567907SDavid Edmondson unsigned char tx_type; 7556567907SDavid Edmondson int16_t tx_status; 7656567907SDavid Edmondson RING_IDX tx_slot; 77843e1988Sjohnlev 7856567907SDavid Edmondson #define TX_DATA 1 7956567907SDavid Edmondson #define TX_MCAST_REQ 2 8056567907SDavid Edmondson #define TX_MCAST_RSP 3 8156567907SDavid Edmondson } xnf_txbuf_t; 8256567907SDavid Edmondson 8356567907SDavid Edmondson /* 8456567907SDavid Edmondson * Information about each outstanding transmit operation. 8556567907SDavid Edmondson */ 8656567907SDavid Edmondson typedef struct xnf_txid { 8756567907SDavid Edmondson uint16_t id; /* Id of this transmit buffer. */ 8856567907SDavid Edmondson uint16_t next; /* Freelist of ids. */ 8956567907SDavid Edmondson xnf_txbuf_t *txbuf; /* Buffer details. */ 9056567907SDavid Edmondson } xnf_txid_t; 9156567907SDavid Edmondson 9256567907SDavid Edmondson /* 9356567907SDavid Edmondson * Per-instance data. 9456567907SDavid Edmondson */ 95843e1988Sjohnlev typedef struct xnf { 96843e1988Sjohnlev /* most interesting stuff first to assist debugging */ 9756567907SDavid Edmondson dev_info_t *xnf_devinfo; 9856567907SDavid Edmondson mac_handle_t xnf_mh; 99551bc2a6Smrj unsigned char xnf_mac_addr[ETHERADDRL]; 10056567907SDavid Edmondson 10156567907SDavid Edmondson unsigned int xnf_gen; /* Increments on resume. */ 102843e1988Sjohnlev 103551bc2a6Smrj boolean_t xnf_connected; 104551bc2a6Smrj boolean_t xnf_running; 105843e1988Sjohnlev 10656567907SDavid Edmondson boolean_t xnf_be_rx_copy; 10756567907SDavid Edmondson boolean_t xnf_be_mcast_control; 108843e1988Sjohnlev 109551bc2a6Smrj uint64_t xnf_stat_interrupts; 110551bc2a6Smrj uint64_t xnf_stat_unclaimed_interrupts; 111551bc2a6Smrj uint64_t xnf_stat_norxbuf; 112a390c5f4Scz147101 uint64_t xnf_stat_drop; 113551bc2a6Smrj uint64_t xnf_stat_errrx; 114843e1988Sjohnlev 115551bc2a6Smrj uint64_t xnf_stat_tx_attempt; 116551bc2a6Smrj uint64_t xnf_stat_tx_pullup; 117551bc2a6Smrj uint64_t xnf_stat_tx_pagebndry; 118551bc2a6Smrj uint64_t xnf_stat_tx_defer; 119551bc2a6Smrj uint64_t xnf_stat_mac_rcv_error; 120551bc2a6Smrj uint64_t xnf_stat_runt; 121843e1988Sjohnlev 122551bc2a6Smrj uint64_t xnf_stat_ipackets; 123551bc2a6Smrj uint64_t xnf_stat_opackets; 124551bc2a6Smrj uint64_t xnf_stat_rbytes; 125551bc2a6Smrj uint64_t xnf_stat_obytes; 126843e1988Sjohnlev 127551bc2a6Smrj uint64_t xnf_stat_tx_cksum_deferred; 128551bc2a6Smrj uint64_t xnf_stat_rx_cksum_no_need; 12956567907SDavid Edmondson 13056567907SDavid Edmondson uint64_t xnf_stat_buf_allocated; 13156567907SDavid Edmondson uint64_t xnf_stat_buf_outstanding; 13256567907SDavid Edmondson uint64_t xnf_stat_gref_outstanding; 13356567907SDavid Edmondson uint64_t xnf_stat_gref_failure; 13456567907SDavid Edmondson uint64_t xnf_stat_gref_peak; 13556567907SDavid Edmondson uint64_t xnf_stat_rx_allocb_fail; 13656567907SDavid Edmondson uint64_t xnf_stat_rx_desballoc_fail; 137843e1988Sjohnlev 138551bc2a6Smrj kstat_t *xnf_kstat_aux; 139843e1988Sjohnlev 140551bc2a6Smrj ddi_iblock_cookie_t xnf_icookie; 141843e1988Sjohnlev 14256567907SDavid Edmondson netif_tx_front_ring_t xnf_tx_ring; 143551bc2a6Smrj ddi_dma_handle_t xnf_tx_ring_dma_handle; 144551bc2a6Smrj ddi_acc_handle_t xnf_tx_ring_dma_acchandle; 145551bc2a6Smrj paddr_t xnf_tx_ring_phys_addr; 146551bc2a6Smrj grant_ref_t xnf_tx_ring_ref; 147843e1988Sjohnlev 14856567907SDavid Edmondson xnf_txid_t xnf_tx_pkt_id[NET_TX_RING_SIZE]; 14956567907SDavid Edmondson uint16_t xnf_tx_pkt_id_head; 15056567907SDavid Edmondson kmutex_t xnf_txlock; 15156567907SDavid Edmondson kmutex_t xnf_schedlock; 15256567907SDavid Edmondson boolean_t xnf_need_sched; 15356567907SDavid Edmondson kcondvar_t xnf_cv_tx_slots; 15456567907SDavid Edmondson kmem_cache_t *xnf_tx_buf_cache; 15556567907SDavid Edmondson 15656567907SDavid Edmondson netif_rx_front_ring_t xnf_rx_ring; 157551bc2a6Smrj ddi_dma_handle_t xnf_rx_ring_dma_handle; 158551bc2a6Smrj ddi_acc_handle_t xnf_rx_ring_dma_acchandle; 159551bc2a6Smrj paddr_t xnf_rx_ring_phys_addr; 160551bc2a6Smrj grant_ref_t xnf_rx_ring_ref; 161843e1988Sjohnlev 16256567907SDavid Edmondson xnf_buf_t *xnf_rx_pkt_info[NET_RX_RING_SIZE]; 16356567907SDavid Edmondson kmutex_t xnf_rxlock; 16456567907SDavid Edmondson mblk_t *xnf_rx_head; 16556567907SDavid Edmondson mblk_t *xnf_rx_tail; 16656567907SDavid Edmondson boolean_t xnf_rx_new_buffers_posted; 16756567907SDavid Edmondson kmem_cache_t *xnf_buf_cache; 168551bc2a6Smrj 16956567907SDavid Edmondson uint16_t xnf_evtchn; 17056567907SDavid Edmondson 17156567907SDavid Edmondson kmutex_t xnf_gref_lock; 17256567907SDavid Edmondson grant_ref_t xnf_gref_head; 17356567907SDavid Edmondson 17456567907SDavid Edmondson kcondvar_t xnf_cv_state; 17556567907SDavid Edmondson kcondvar_t xnf_cv_multicast; 17656567907SDavid Edmondson uint_t xnf_pending_multicast; 177843e1988Sjohnlev } xnf_t; 178843e1988Sjohnlev 179843e1988Sjohnlev #ifdef __cplusplus 180843e1988Sjohnlev } 181843e1988Sjohnlev #endif 182843e1988Sjohnlev 183843e1988Sjohnlev #endif /* _SYS_XNF_H */ 184