1*3833Sxw161283 /* 2*3833Sxw161283 * CDDL HEADER START 3*3833Sxw161283 * 4*3833Sxw161283 * The contents of this file are subject to the terms of the 5*3833Sxw161283 * Common Development and Distribution License (the "License"). 6*3833Sxw161283 * You may not use this file except in compliance with the License. 7*3833Sxw161283 * 8*3833Sxw161283 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*3833Sxw161283 * or http://www.opensolaris.org/os/licensing. 10*3833Sxw161283 * See the License for the specific language governing permissions 11*3833Sxw161283 * and limitations under the License. 12*3833Sxw161283 * 13*3833Sxw161283 * When distributing Covered Code, include this CDDL HEADER in each 14*3833Sxw161283 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*3833Sxw161283 * If applicable, add the following below this CDDL HEADER, with the 16*3833Sxw161283 * fields enclosed by brackets "[]" replaced with your own identifying 17*3833Sxw161283 * information: Portions Copyright [yyyy] [name of copyright owner] 18*3833Sxw161283 * 19*3833Sxw161283 * CDDL HEADER END 20*3833Sxw161283 */ 21*3833Sxw161283 22*3833Sxw161283 /* 23*3833Sxw161283 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*3833Sxw161283 * Use is subject to license terms. 25*3833Sxw161283 */ 26*3833Sxw161283 27*3833Sxw161283 /* 28*3833Sxw161283 * This file is part of the Chelsio T1 Ethernet driver. 29*3833Sxw161283 * 30*3833Sxw161283 * Copyright (C) 2003-2005 Chelsio Communications. All rights reserved. 31*3833Sxw161283 */ 32*3833Sxw161283 33*3833Sxw161283 #ifndef _CHELSIO_SGE_H 34*3833Sxw161283 #define _CHELSIO_SGE_H 35*3833Sxw161283 36*3833Sxw161283 #pragma ident "%Z%%M% %I% %E% SMI" 37*3833Sxw161283 38*3833Sxw161283 #ifdef __cplusplus 39*3833Sxw161283 extern "C" { 40*3833Sxw161283 #endif 41*3833Sxw161283 42*3833Sxw161283 #include <sys/types.h> 43*3833Sxw161283 44*3833Sxw161283 #include "osdep.h" 45*3833Sxw161283 46*3833Sxw161283 #define MBLK_MAX 8 47*3833Sxw161283 48*3833Sxw161283 #define spin_lock mutex_enter 49*3833Sxw161283 #define spin_unlock mutex_exit 50*3833Sxw161283 #define atomic_sub(a, b) atomic_add_32(b, -(a)) 51*3833Sxw161283 #define atomic_add(a, b) atomic_add_32(b, (a)) 52*3833Sxw161283 #define atomic_read(a) (a) 53*3833Sxw161283 #define atomic_set(a, b) (*(a) = b) 54*3833Sxw161283 #define spinlock_t kmutex_t 55*3833Sxw161283 #define dma_addr_t uint64_t 56*3833Sxw161283 #define wmb() membar_producer() 57*3833Sxw161283 #define doorbell_pio(sge, cmd) sge_ring_doorbell(sge, cmd) 58*3833Sxw161283 #define skb_reserve(skb, offset) (skb->b_rptr += offset) 59*3833Sxw161283 #define __skb_pull(skb, len) (skb->b_rptr += len) 60*3833Sxw161283 #define skb_put(skb, len) ((skb)->b_wptr = (skb)->b_rptr + (len)) 61*3833Sxw161283 #define skb_pull(skb, len) (skb->b_rptr += len) 62*3833Sxw161283 #define unlikely(a) (a) 63*3833Sxw161283 #define likely(a) (a) 64*3833Sxw161283 #define SKB_DATA_ALIGN(X) (((X) + (sizeof (long)-1)) & ~(sizeof (long)-1)) 65*3833Sxw161283 #define t1_is_T1B(adap) adapter_matches_type(adap, CHBT_TERM_T1, TERM_T1B) 66*3833Sxw161283 #define t1_is_T1C(adap) adapter_matches_type(adap, CHBT_TERM_T1, TERM_T1C) 67*3833Sxw161283 68*3833Sxw161283 #define SGE_SM_BUF_SZ(sa) (sa->ch_sm_buf_sz) 69*3833Sxw161283 #define SGE_BG_BUF_SZ(sa) (sa->ch_bg_buf_sz) 70*3833Sxw161283 71*3833Sxw161283 #define SGE_CMDQ_N 2 72*3833Sxw161283 #define SGE_FREELQ_N 2 73*3833Sxw161283 #ifdef CONFIG_CHELSIO_T1_OFFLOAD 74*3833Sxw161283 #define SGE_CMDQ0_E_N 4096 75*3833Sxw161283 #define SGE_CMDQ1_E_N 128 76*3833Sxw161283 #define SGE_FREELQ0_E_N 2048 77*3833Sxw161283 #define SGE_FREELQ1_E_N 1024 78*3833Sxw161283 #define SGE_RESPQ_E_N 7168 /* |CMDQ0| + |FREELQ0| + |FREELQ1| */ 79*3833Sxw161283 #else 80*3833Sxw161283 #define SGE_CMDQ0_E_N 2048 81*3833Sxw161283 #define SGE_CMDQ1_E_N 128 82*3833Sxw161283 #define SGE_FREELQ0_E_N 4096 83*3833Sxw161283 #define SGE_FREELQ1_E_N 1024 84*3833Sxw161283 #define SGE_RESPQ_E_N 7168 /* |CMDQ0| + |FREELQ0| + |FREELQ1| */ 85*3833Sxw161283 #endif /* CONFIG_CHELSIO_T1_OFFLOAD */ 86*3833Sxw161283 #define SGE_BATCH_THRESH 16 87*3833Sxw161283 #define SGE_INTR_BUCKETSIZE 100 88*3833Sxw161283 #define SGE_INTR_MAXBUCKETS 11 89*3833Sxw161283 #define SGE_INTRTIMER0 1 90*3833Sxw161283 #define SGE_INTRTIMER1 30 91*3833Sxw161283 #define SGE_INTRTIMER_NRES 10000 92*3833Sxw161283 #define SGE_RX_COPY_THRESHOLD 256 93*3833Sxw161283 #define SGE_RX_OFFSET 2 94*3833Sxw161283 #ifdef CONFIG_CHELSIO_T1_OFFLOAD 95*3833Sxw161283 #define SGE_RX_SM_BUF_SIZE(sa) 1536 96*3833Sxw161283 #else 97*3833Sxw161283 #define SGE_RX_SM_BUF_SIZE(sa) (sa->ch_sm_buf_sz) 98*3833Sxw161283 #endif 99*3833Sxw161283 100*3833Sxw161283 /* 101*3833Sxw161283 * CPL5 Defines 102*3833Sxw161283 */ 103*3833Sxw161283 #define FLITSTOBYTES 8 104*3833Sxw161283 105*3833Sxw161283 #define CPL_FORMAT_0_SIZE 8 106*3833Sxw161283 #define CPL_FORMAT_1_SIZE 16 107*3833Sxw161283 #define CPL_FORMAT_2_SIZE 24 108*3833Sxw161283 #define CPL_FORMAT_3_SIZE 32 109*3833Sxw161283 #define CPL_FORMAT_4_SIZE 40 110*3833Sxw161283 #define CPL_FORMAT_5_SIZE 48 111*3833Sxw161283 112*3833Sxw161283 #define TID_MASK 0xffffff 113*3833Sxw161283 114*3833Sxw161283 #define SZ_CPL_RX_PKT CPL_FORMAT_0_SIZE 115*3833Sxw161283 116*3833Sxw161283 #if BYTE_ORDER == BIG_ENDIAN 117*3833Sxw161283 118*3833Sxw161283 typedef struct { 119*3833Sxw161283 u32 AddrLow; 120*3833Sxw161283 u32 GenerationBit: 1; 121*3833Sxw161283 u32 BufferLength: 31; 122*3833Sxw161283 u32 RespQueueSelector: 4; 123*3833Sxw161283 u32 ResponseTokens: 12; 124*3833Sxw161283 u32 CmdId: 8; 125*3833Sxw161283 u32 Reserved: 3; 126*3833Sxw161283 u32 TokenValid: 1; 127*3833Sxw161283 u32 Eop: 1; 128*3833Sxw161283 u32 Sop: 1; 129*3833Sxw161283 u32 DataValid: 1; 130*3833Sxw161283 u32 GenerationBit2: 1; 131*3833Sxw161283 u32 AddrHigh; 132*3833Sxw161283 } CmdQueueEntry; 133*3833Sxw161283 134*3833Sxw161283 135*3833Sxw161283 #elif BYTE_ORDER == LITTLE_ENDIAN 136*3833Sxw161283 137*3833Sxw161283 138*3833Sxw161283 typedef struct { 139*3833Sxw161283 u32 BufferLength: 31; 140*3833Sxw161283 u32 GenerationBit: 1; 141*3833Sxw161283 u32 AddrLow; 142*3833Sxw161283 u32 AddrHigh; 143*3833Sxw161283 u32 GenerationBit2: 1; 144*3833Sxw161283 u32 DataValid: 1; 145*3833Sxw161283 u32 Sop: 1; 146*3833Sxw161283 u32 Eop: 1; 147*3833Sxw161283 u32 TokenValid: 1; 148*3833Sxw161283 u32 Reserved: 3; 149*3833Sxw161283 u32 CmdId: 8; 150*3833Sxw161283 u32 ResponseTokens: 12; 151*3833Sxw161283 u32 RespQueueSelector: 4; 152*3833Sxw161283 } CmdQueueEntry; 153*3833Sxw161283 154*3833Sxw161283 #endif 155*3833Sxw161283 156*3833Sxw161283 157*3833Sxw161283 typedef CmdQueueEntry cmdQ_e; 158*3833Sxw161283 159*3833Sxw161283 #if BYTE_ORDER == BIG_ENDIAN 160*3833Sxw161283 161*3833Sxw161283 typedef struct { 162*3833Sxw161283 u32 Qsleeping: 4; 163*3833Sxw161283 u32 Cmdq1CreditReturn: 5; 164*3833Sxw161283 u32 Cmdq1DmaComplete: 5; 165*3833Sxw161283 u32 Cmdq0CreditReturn: 5; 166*3833Sxw161283 u32 Cmdq0DmaComplete: 5; 167*3833Sxw161283 u32 FreelistQid: 2; 168*3833Sxw161283 u32 CreditValid: 1; 169*3833Sxw161283 u32 DataValid: 1; 170*3833Sxw161283 u32 Offload: 1; 171*3833Sxw161283 u32 Eop: 1; 172*3833Sxw161283 u32 Sop: 1; 173*3833Sxw161283 u32 GenerationBit: 1; 174*3833Sxw161283 u32 BufferLength; 175*3833Sxw161283 } ResponseQueueEntry; 176*3833Sxw161283 177*3833Sxw161283 178*3833Sxw161283 #elif BYTE_ORDER == LITTLE_ENDIAN 179*3833Sxw161283 180*3833Sxw161283 181*3833Sxw161283 typedef struct { 182*3833Sxw161283 u32 BufferLength; 183*3833Sxw161283 u32 GenerationBit: 1; 184*3833Sxw161283 u32 Sop: 1; 185*3833Sxw161283 u32 Eop: 1; 186*3833Sxw161283 u32 Offload: 1; 187*3833Sxw161283 u32 DataValid: 1; 188*3833Sxw161283 u32 CreditValid: 1; 189*3833Sxw161283 u32 FreelistQid: 2; 190*3833Sxw161283 u32 Cmdq0DmaComplete: 5; 191*3833Sxw161283 u32 Cmdq0CreditReturn: 5; 192*3833Sxw161283 u32 Cmdq1DmaComplete: 5; 193*3833Sxw161283 u32 Cmdq1CreditReturn: 5; 194*3833Sxw161283 u32 Qsleeping: 4; 195*3833Sxw161283 } ResponseQueueEntry; 196*3833Sxw161283 197*3833Sxw161283 #endif 198*3833Sxw161283 199*3833Sxw161283 typedef ResponseQueueEntry respQ_e; 200*3833Sxw161283 201*3833Sxw161283 #if BYTE_ORDER == BIG_ENDIAN 202*3833Sxw161283 203*3833Sxw161283 204*3833Sxw161283 typedef struct { 205*3833Sxw161283 u32 AddrLow; 206*3833Sxw161283 u32 GenerationBit: 1; 207*3833Sxw161283 u32 BufferLength: 31; 208*3833Sxw161283 u32 Reserved: 31; 209*3833Sxw161283 u32 GenerationBit2: 1; 210*3833Sxw161283 u32 AddrHigh; 211*3833Sxw161283 } FLQueueEntry; 212*3833Sxw161283 213*3833Sxw161283 214*3833Sxw161283 #elif BYTE_ORDER == LITTLE_ENDIAN 215*3833Sxw161283 216*3833Sxw161283 217*3833Sxw161283 typedef struct { 218*3833Sxw161283 u32 BufferLength: 31; 219*3833Sxw161283 u32 GenerationBit: 1; 220*3833Sxw161283 u32 AddrLow; 221*3833Sxw161283 u32 AddrHigh; 222*3833Sxw161283 u32 GenerationBit2: 1; 223*3833Sxw161283 u32 Reserved: 31; 224*3833Sxw161283 } FLQueueEntry; 225*3833Sxw161283 226*3833Sxw161283 227*3833Sxw161283 #endif 228*3833Sxw161283 229*3833Sxw161283 typedef FLQueueEntry freelQ_e; 230*3833Sxw161283 231*3833Sxw161283 /* 232*3833Sxw161283 * Command QUEUE meta entry format. 233*3833Sxw161283 */ 234*3833Sxw161283 typedef struct cmdQ_ce { 235*3833Sxw161283 void *ce_mp; /* head mblk of pkt */ 236*3833Sxw161283 free_dh_t *ce_dh; /* ddi dma handle */ 237*3833Sxw161283 uint_t ce_flg; /* flag 0 - NIC descriptor; 1 - TOE */ 238*3833Sxw161283 uint_t ce_len; /* length of mblk component */ 239*3833Sxw161283 uint64_t ce_pa; /* physical address */ 240*3833Sxw161283 } cmdQ_ce_t; 241*3833Sxw161283 242*3833Sxw161283 /* 243*3833Sxw161283 * command queue control structure 244*3833Sxw161283 */ 245*3833Sxw161283 typedef struct cmdQ { 246*3833Sxw161283 u32 cq_credits; /* # available descriptors for Xmit */ 247*3833Sxw161283 u32 cq_asleep; /* HW DMA Fetch status */ 248*3833Sxw161283 u32 cq_pio_pidx; /* Variable updated on Doorbell */ 249*3833Sxw161283 u32 cq_entries_n; /* # entries for Xmit */ 250*3833Sxw161283 u32 cq_pidx; /* producer index (SW) */ 251*3833Sxw161283 u32 cq_complete; /* Shadow consumer index (HW) */ 252*3833Sxw161283 u32 cq_cidx; /* consumer index (HW) */ 253*3833Sxw161283 u32 cq_genbit; /* current generation (=valid) bit */ 254*3833Sxw161283 cmdQ_e *cq_entries; 255*3833Sxw161283 cmdQ_ce_t *cq_centries; 256*3833Sxw161283 spinlock_t cq_qlock; 257*3833Sxw161283 uint64_t cq_pa; /* may not be needed */ 258*3833Sxw161283 ulong_t cq_dh; 259*3833Sxw161283 ulong_t cq_ah; /* may not be needed */ 260*3833Sxw161283 } cmdQ_t; 261*3833Sxw161283 262*3833Sxw161283 /* 263*3833Sxw161283 * free list queue control structure 264*3833Sxw161283 */ 265*3833Sxw161283 typedef struct freelQ { 266*3833Sxw161283 u32 fq_id; /* 0 queue 0, 1 queue 1 */ 267*3833Sxw161283 u32 fq_credits; /* # available RX buffer descriptors */ 268*3833Sxw161283 u32 fq_entries_n; /* # RX buffer descriptors */ 269*3833Sxw161283 u32 fq_pidx; /* producer index (SW) */ 270*3833Sxw161283 u32 fq_cidx; /* consumer index (HW) */ 271*3833Sxw161283 u32 fq_genbit; /* current generation (=valid) bit */ 272*3833Sxw161283 u32 fq_rx_buffer_size; /* size buffer on this freelist */ 273*3833Sxw161283 freelQ_e *fq_entries; /* HW freelist descriptor Q */ 274*3833Sxw161283 struct freelQ_ce *fq_centries; /* SW freelist conext descriptor Q */ 275*3833Sxw161283 uint64_t fq_pa; /* may not be needed */ 276*3833Sxw161283 ulong_t fq_dh; 277*3833Sxw161283 ulong_t fq_ah; 278*3833Sxw161283 u32 fq_pause_on_thresh; 279*3833Sxw161283 u32 fq_pause_off_thresh; 280*3833Sxw161283 } freelQ_t; 281*3833Sxw161283 282*3833Sxw161283 /* 283*3833Sxw161283 * response queue control structure 284*3833Sxw161283 */ 285*3833Sxw161283 typedef struct respQ { 286*3833Sxw161283 u32 rq_credits; /* # avail response Q entries */ 287*3833Sxw161283 u32 rq_credits_pend; /* # not yet returned entries */ 288*3833Sxw161283 u32 rq_credits_thresh; /* return threshold */ 289*3833Sxw161283 u32 rq_entries_n; /* # response Q descriptors */ 290*3833Sxw161283 u32 rq_pidx; /* producer index (HW) */ 291*3833Sxw161283 u32 rq_cidx; /* consumer index (SW) */ 292*3833Sxw161283 u32 rq_genbit; /* current generation(=valid) bit */ 293*3833Sxw161283 respQ_e *rq_entries; /* HW response Q */ 294*3833Sxw161283 uint64_t rq_pa; /* may not be needed */ 295*3833Sxw161283 ulong_t rq_dh; 296*3833Sxw161283 ulong_t rq_ah; 297*3833Sxw161283 } reapQ_t; 298*3833Sxw161283 299*3833Sxw161283 struct sge_intr_counts { 300*3833Sxw161283 uint32_t respQ_empty; /* # times respQ empty */ 301*3833Sxw161283 uint32_t respQ_overflow; /* # respQ overflow (fatal) */ 302*3833Sxw161283 uint32_t freelistQ_empty; /* # times freelist empty */ 303*3833Sxw161283 uint32_t pkt_too_big; /* packet too large (fatal) */ 304*3833Sxw161283 uint32_t pkt_mismatch; 305*3833Sxw161283 uint32_t cmdQ_full[2]; /* not HW intr, host cmdQ[] full */ 306*3833Sxw161283 uint32_t tx_reclaims[2]; 307*3833Sxw161283 uint32_t tx_msg_pullups; /* # of tx pkt coelescing events */ 308*3833Sxw161283 uint32_t tx_hdr_pullups; /* # of tx hdr coelescing events */ 309*3833Sxw161283 uint32_t tx_tcp_ip_frag; /* # of ip fragmentes for tcp data */ 310*3833Sxw161283 uint32_t tx_udp_ip_frag; /* # of ip fragmentes for udp data */ 311*3833Sxw161283 uint32_t tx_soft_cksums; /* # of Software checksums done. */ 312*3833Sxw161283 uint32_t tx_need_cpl_space; /* # of allocs for cpl header */ 313*3833Sxw161283 uint32_t tx_multi_mblks; /* # of Multi mblk packets */ 314*3833Sxw161283 uint32_t tx_no_dvma1; /* # of dvma mapping failures */ 315*3833Sxw161283 uint32_t tx_no_dvma2; /* # of dvma mapping failures */ 316*3833Sxw161283 uint32_t tx_no_dma1; /* # of dma mapping failures */ 317*3833Sxw161283 uint32_t tx_no_dma2; /* # of dma mapping failures */ 318*3833Sxw161283 uint32_t rx_cmdq0; /* # of Qsleeping CMDQ0's */ 319*3833Sxw161283 uint32_t rx_cmdq1; /* # of Qsleeping CMDQ1's */ 320*3833Sxw161283 uint32_t rx_flq0; /* # of Qsleeping FL0's */ 321*3833Sxw161283 uint32_t rx_flq1; /* # of Qsleeping FL1's */ 322*3833Sxw161283 uint32_t rx_flq0_sz; /* size of freelist-0 buffers */ 323*3833Sxw161283 uint32_t rx_flq1_sz; /* size of freelist-1 buffers */ 324*3833Sxw161283 uint32_t rx_pkt_drops; /* # intentionally dropped packets */ 325*3833Sxw161283 uint32_t rx_pkt_copied; /* # times packets copied by sge */ 326*3833Sxw161283 uint32_t rx_pause_on; /* # of system pause on's required. */ 327*3833Sxw161283 uint32_t rx_pause_off; /* # of system pauses off's required. */ 328*3833Sxw161283 uint32_t rx_pause_ms; /* micro seconds while paused */ 329*3833Sxw161283 uint32_t rx_pause_spike; /* maximum time paused */ 330*3833Sxw161283 uint32_t rx_fl_credits; /* Current free list credit usage. */ 331*3833Sxw161283 uint32_t rx_flbuf_fails; /* # of freelist buf alloc fails. */ 332*3833Sxw161283 uint32_t rx_flbuf_allocs; /* # of freelist buf allocs. */ 333*3833Sxw161283 uint32_t rx_badEopSop; /* # of times bad Eop/Sop received */ 334*3833Sxw161283 uint32_t rx_flq0_cnt; /* # of times free list Q 0 entry used */ 335*3833Sxw161283 uint32_t rx_flq1_cnt; /* # of times free list Q 1 entry used */ 336*3833Sxw161283 uint32_t arp_sent; /* # times arp packet sent */ 337*3833Sxw161283 #ifdef SUN_KSTATS 338*3833Sxw161283 uint32_t tx_doorbells; 339*3833Sxw161283 uint32_t intr_doorbells; 340*3833Sxw161283 uint32_t intr1_doorbells; 341*3833Sxw161283 uint32_t sleep_cnt; 342*3833Sxw161283 uint32_t pe_allocb_cnt; 343*3833Sxw161283 uint32_t tx_descs[MBLK_MAX]; 344*3833Sxw161283 #endif 345*3833Sxw161283 }; 346*3833Sxw161283 347*3833Sxw161283 #ifdef SUN_KSTATS 348*3833Sxw161283 typedef struct sge_intr_counts *p_ch_stats_t; 349*3833Sxw161283 350*3833Sxw161283 /* 351*3833Sxw161283 * Driver maintained kernel statistics. 352*3833Sxw161283 */ 353*3833Sxw161283 typedef struct _ch_kstat_t { 354*3833Sxw161283 /* 355*3833Sxw161283 * Link Input/Output stats 356*3833Sxw161283 */ 357*3833Sxw161283 kstat_named_t respQ_empty; /* # times respQ empty */ 358*3833Sxw161283 kstat_named_t respQ_overflow; /* # respQ overflow (fatal) */ 359*3833Sxw161283 kstat_named_t freelistQ_empty; /* # times freelist empty */ 360*3833Sxw161283 kstat_named_t pkt_too_big; /* packet too large (fatal) */ 361*3833Sxw161283 kstat_named_t pkt_mismatch; 362*3833Sxw161283 kstat_named_t cmdQ_full[2]; /* not HW intr, host cmdQ[] full */ 363*3833Sxw161283 kstat_named_t tx_reclaims[2]; /* # of tx reclaims called */ 364*3833Sxw161283 kstat_named_t tx_msg_pullups; /* # of tx pkt coelescing events */ 365*3833Sxw161283 kstat_named_t tx_hdr_pullups; /* # of tx hdr coelescing events */ 366*3833Sxw161283 kstat_named_t tx_tcp_ip_frag; /* # of ip fragmentes for tcp data */ 367*3833Sxw161283 kstat_named_t tx_udp_ip_frag; /* # of ip fragmentes for udp data */ 368*3833Sxw161283 kstat_named_t tx_soft_cksums; /* # of Software checksums done. */ 369*3833Sxw161283 kstat_named_t tx_need_cpl_space; /* # of allocs for cpl header */ 370*3833Sxw161283 kstat_named_t tx_multi_mblks; /* # of multi fragment packets */ 371*3833Sxw161283 kstat_named_t tx_no_dvma1; /* # of dvma mapping failures */ 372*3833Sxw161283 kstat_named_t tx_no_dvma2; /* # of dvma mapping failures */ 373*3833Sxw161283 kstat_named_t tx_no_dma1; /* # of dma mapping failures */ 374*3833Sxw161283 kstat_named_t tx_no_dma2; /* # of dma mapping failures */ 375*3833Sxw161283 kstat_named_t rx_cmdq0; /* # times Qsleeping cmdq0 */ 376*3833Sxw161283 kstat_named_t rx_cmdq1; /* # times Qsleeping cmdq1 */ 377*3833Sxw161283 kstat_named_t rx_flq0; /* # times Qsleeping flq0 */ 378*3833Sxw161283 kstat_named_t rx_flq0_sz; /* size of freelist-0 buffers */ 379*3833Sxw161283 kstat_named_t rx_flq1; /* # times Qsleeping flq1 */ 380*3833Sxw161283 kstat_named_t rx_flq1_sz; /* size of freelist-1 buffers */ 381*3833Sxw161283 kstat_named_t rx_pkt_drops; /* # times packets dropped by sge */ 382*3833Sxw161283 kstat_named_t rx_pkt_copied; /* # intentionally copied packets */ 383*3833Sxw161283 kstat_named_t rx_pause_on; /* # of system pause on's required. */ 384*3833Sxw161283 kstat_named_t rx_pause_off; /* # of system pauses off's required. */ 385*3833Sxw161283 kstat_named_t rx_pause_ms; /* micro seconds while paused. */ 386*3833Sxw161283 kstat_named_t rx_pause_spike; /* maximum time paused. */ 387*3833Sxw161283 kstat_named_t rx_fl_credits; /* Current free list credit usage. */ 388*3833Sxw161283 kstat_named_t rx_flbuf_fails; /* # of freelist buf alloc fails. */ 389*3833Sxw161283 kstat_named_t rx_flbuf_allocs; /* # of freelist buf allocs. */ 390*3833Sxw161283 kstat_named_t rx_badEopSop; /* # of times bad Eop/Sop received */ 391*3833Sxw161283 kstat_named_t rx_flq0_cnt; /* # of times free list Q 0 entry used */ 392*3833Sxw161283 kstat_named_t rx_flq1_cnt; /* # of times free list Q 1 entry used */ 393*3833Sxw161283 kstat_named_t arp_sent; /* # times arp packet sent */ 394*3833Sxw161283 395*3833Sxw161283 kstat_named_t tx_doorbells; 396*3833Sxw161283 kstat_named_t intr_doorbells; 397*3833Sxw161283 kstat_named_t intr1_doorbells; 398*3833Sxw161283 kstat_named_t sleep_cnt; 399*3833Sxw161283 kstat_named_t pe_allocb_cnt; 400*3833Sxw161283 kstat_named_t tx_descs[MBLK_MAX]; 401*3833Sxw161283 } ch_kstat_t; 402*3833Sxw161283 typedef ch_kstat_t *p_ch_kstat_t; 403*3833Sxw161283 #endif 404*3833Sxw161283 405*3833Sxw161283 typedef struct _pesge { 406*3833Sxw161283 peobj *obj; /* adapter backpointer */ 407*3833Sxw161283 struct freelQ freelQ[2]; /* freelist Q(s) */ 408*3833Sxw161283 struct respQ respQ; /* response Q instatiation */ 409*3833Sxw161283 uint32_t rx_pkt_pad; /* RX padding for T2 packets (hw) */ 410*3833Sxw161283 uint32_t rx_offset; /* RX padding for T1 packets (sw) */ 411*3833Sxw161283 uint32_t jumbo_fl; /* jumbo freelist Q index */ 412*3833Sxw161283 uint32_t intrtimer[SGE_INTR_MAXBUCKETS]; /* timer values */ 413*3833Sxw161283 uint32_t currIndex; /* current index into intrtimer[] */ 414*3833Sxw161283 uint32_t intrtimer_nres; /* no resource interrupt timer value */ 415*3833Sxw161283 uint32_t sge_control; /* shadow content of sge control reg */ 416*3833Sxw161283 struct sge_intr_counts intr_cnt; 417*3833Sxw161283 #ifdef SUN_KSTATS 418*3833Sxw161283 p_kstat_t ksp; 419*3833Sxw161283 #endif 420*3833Sxw161283 ch_cyclic_t espi_wa_cyclic; 421*3833Sxw161283 uint32_t ptimeout; 422*3833Sxw161283 void *pskb; 423*3833Sxw161283 struct cmdQ cmdQ[2]; /* command Q(s) */ 424*3833Sxw161283 int do_udp_csum; 425*3833Sxw161283 int do_tcp_csum; 426*3833Sxw161283 } _pesge; 427*3833Sxw161283 428*3833Sxw161283 /* 429*3833Sxw161283 * ce_flg flag values 430*3833Sxw161283 */ 431*3833Sxw161283 #define DH_DMA 1 432*3833Sxw161283 #define DH_DVMA 2 433*3833Sxw161283 #define DH_TOE 3 434*3833Sxw161283 #define DH_ARP 8 435*3833Sxw161283 436*3833Sxw161283 typedef struct freelQ_ce { 437*3833Sxw161283 void *fe_mp; /* head mblk of pkt */ 438*3833Sxw161283 ulong_t fe_dh; /* ddi dma handle */ 439*3833Sxw161283 uint_t fe_len; /* length of mblk component */ 440*3833Sxw161283 uint64_t fe_pa; /* physical address */ 441*3833Sxw161283 } freelQ_ce_t; 442*3833Sxw161283 443*3833Sxw161283 pesge *t1_sge_create(ch_t *, struct sge_params *); 444*3833Sxw161283 445*3833Sxw161283 extern int t1_sge_destroy(pesge* sge); 446*3833Sxw161283 extern int sge_data_out(pesge*, int, mblk_t *, cmdQ_ce_t *, int, uint32_t); 447*3833Sxw161283 extern int sge_data_in(pesge *); 448*3833Sxw161283 extern int sge_start(pesge*); 449*3833Sxw161283 extern int sge_stop(pesge *); 450*3833Sxw161283 extern int t1_sge_configure(pesge *sge, struct sge_params *p); 451*3833Sxw161283 452*3833Sxw161283 extern int t1_sge_intr_error_handler(pesge*); 453*3833Sxw161283 extern int t1_sge_intr_enable(pesge*); 454*3833Sxw161283 extern int t1_sge_intr_disable(pesge*); 455*3833Sxw161283 extern int t1_sge_intr_clear(pesge*); 456*3833Sxw161283 extern u32 t1_sge_get_ptimeout(ch_t *); 457*3833Sxw161283 extern void t1_sge_set_ptimeout(ch_t *, u32); 458*3833Sxw161283 459*3833Sxw161283 extern struct sge_intr_counts *sge_get_stat(pesge *); 460*3833Sxw161283 extern void sge_add_fake_arp(pesge *, void *); 461*3833Sxw161283 462*3833Sxw161283 /* 463*3833Sxw161283 * Default SGE settings 464*3833Sxw161283 */ 465*3833Sxw161283 #define SGE_CMDQ0_CNT (512) 466*3833Sxw161283 #define SGE_FLQ0_CNT (512) 467*3833Sxw161283 #define SGE_RESPQ_CNT (1024) 468*3833Sxw161283 469*3833Sxw161283 /* 470*3833Sxw161283 * the structures below were taken from cpl5_cmd.h. It turns out that there 471*3833Sxw161283 * is a number of #includes that causes build problems. For now, we're 472*3833Sxw161283 * putting a private copy here. When the sge code is made common, then this 473*3833Sxw161283 * problem will need to be resolved. 474*3833Sxw161283 */ 475*3833Sxw161283 476*3833Sxw161283 typedef uint8_t __u8; 477*3833Sxw161283 typedef uint32_t __u32; 478*3833Sxw161283 typedef uint16_t __u16; 479*3833Sxw161283 480*3833Sxw161283 union opcode_tid { 481*3833Sxw161283 __u32 opcode_tid; 482*3833Sxw161283 __u8 opcode; 483*3833Sxw161283 }; 484*3833Sxw161283 485*3833Sxw161283 /* 486*3833Sxw161283 * We want this header's alignment to be no more stringent than 2-byte aligned. 487*3833Sxw161283 * All fields are u8 or u16 except for the length. However that field is not 488*3833Sxw161283 * used so we break it into 2 16-bit parts to easily meet our alignment needs. 489*3833Sxw161283 */ 490*3833Sxw161283 struct cpl_tx_pkt { 491*3833Sxw161283 __u8 opcode; 492*3833Sxw161283 #if BYTE_ORDER == BIG_ENDIAN 493*3833Sxw161283 __u8 rsvd:1; 494*3833Sxw161283 __u8 vlan_valid:1; 495*3833Sxw161283 __u8 l4_csum_dis:1; 496*3833Sxw161283 __u8 ip_csum_dis:1; 497*3833Sxw161283 __u8 iff:4; 498*3833Sxw161283 #else 499*3833Sxw161283 __u8 iff:4; 500*3833Sxw161283 __u8 ip_csum_dis:1; 501*3833Sxw161283 __u8 l4_csum_dis:1; 502*3833Sxw161283 __u8 vlan_valid:1; 503*3833Sxw161283 __u8 rsvd:1; 504*3833Sxw161283 #endif 505*3833Sxw161283 __u16 vlan; 506*3833Sxw161283 __u16 len_hi; 507*3833Sxw161283 __u16 len_lo; 508*3833Sxw161283 }; 509*3833Sxw161283 510*3833Sxw161283 #define CPL_TX_PKT 0xb2 511*3833Sxw161283 #define SZ_CPL_TX_PKT CPL_FORMAT_0_SIZE 512*3833Sxw161283 513*3833Sxw161283 struct cpl_rx_data { 514*3833Sxw161283 union opcode_tid ot; 515*3833Sxw161283 __u32 len; 516*3833Sxw161283 __u32 seq; 517*3833Sxw161283 __u16 urg; 518*3833Sxw161283 __u8 rsvd; 519*3833Sxw161283 __u8 status; 520*3833Sxw161283 }; 521*3833Sxw161283 522*3833Sxw161283 struct cpl_rx_pkt { 523*3833Sxw161283 __u8 opcode; 524*3833Sxw161283 #if BYTE_ORDER == LITTLE_ENDIAN 525*3833Sxw161283 __u8 iff:4; 526*3833Sxw161283 __u8 csum_valid:1; 527*3833Sxw161283 __u8 bad_pkt:1; 528*3833Sxw161283 __u8 vlan_valid:1; 529*3833Sxw161283 __u8 rsvd:1; 530*3833Sxw161283 #else 531*3833Sxw161283 __u8 rsvd:1; 532*3833Sxw161283 __u8 vlan_valid:1; 533*3833Sxw161283 __u8 bad_pkt:1; 534*3833Sxw161283 __u8 csum_valid:1; 535*3833Sxw161283 __u8 iff:4; 536*3833Sxw161283 #endif 537*3833Sxw161283 __u16 csum; 538*3833Sxw161283 __u16 vlan; 539*3833Sxw161283 __u16 len; 540*3833Sxw161283 }; 541*3833Sxw161283 542*3833Sxw161283 #ifdef __cplusplus 543*3833Sxw161283 } 544*3833Sxw161283 #endif 545*3833Sxw161283 546*3833Sxw161283 #endif /* _CHELSIO_SGE_H */ 547