1*6833Sgd78059 /* 2*6833Sgd78059 * CDDL HEADER START 3*6833Sgd78059 * 4*6833Sgd78059 * The contents of this file are subject to the terms of the 5*6833Sgd78059 * Common Development and Distribution License (the "License"). 6*6833Sgd78059 * You may not use this file except in compliance with the License. 7*6833Sgd78059 * 8*6833Sgd78059 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*6833Sgd78059 * or http://www.opensolaris.org/os/licensing. 10*6833Sgd78059 * See the License for the specific language governing permissions 11*6833Sgd78059 * and limitations under the License. 12*6833Sgd78059 * 13*6833Sgd78059 * When distributing Covered Code, include this CDDL HEADER in each 14*6833Sgd78059 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*6833Sgd78059 * If applicable, add the following below this CDDL HEADER, with the 16*6833Sgd78059 * fields enclosed by brackets "[]" replaced with your own identifying 17*6833Sgd78059 * information: Portions Copyright [yyyy] [name of copyright owner] 18*6833Sgd78059 * 19*6833Sgd78059 * CDDL HEADER END 20*6833Sgd78059 */ 21*6833Sgd78059 /* 22*6833Sgd78059 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*6833Sgd78059 * Use is subject to license terms. 24*6833Sgd78059 */ 25*6833Sgd78059 26*6833Sgd78059 #ifndef _SYS_ERI_COMMON_H 27*6833Sgd78059 #define _SYS_ERI_COMMON_H 28*6833Sgd78059 29*6833Sgd78059 #pragma ident "%Z%%M% %I% %E% SMI" 30*6833Sgd78059 31*6833Sgd78059 #ifdef __cplusplus 32*6833Sgd78059 extern "C" { 33*6833Sgd78059 #endif 34*6833Sgd78059 35*6833Sgd78059 #ifdef _KERNEL 36*6833Sgd78059 37*6833Sgd78059 typedef void (*fptrv_t)(); 38*6833Sgd78059 39*6833Sgd78059 typedef enum { 40*6833Sgd78059 ERI_NO_MSG = 0, 41*6833Sgd78059 ERI_CON_MSG = 1, 42*6833Sgd78059 ERI_BUF_MSG = 2, 43*6833Sgd78059 ERI_VERB_MSG = 3, 44*6833Sgd78059 ERI_LOG_MSG = 4 45*6833Sgd78059 } msg_t; 46*6833Sgd78059 47*6833Sgd78059 48*6833Sgd78059 #ifdef DEBUG 49*6833Sgd78059 static msg_t eri_msg_out = ERI_VERB_MSG; 50*6833Sgd78059 #endif 51*6833Sgd78059 52*6833Sgd78059 #ifdef LATER 53*6833Sgd78059 static char *fault_msg_string[] = { 54*6833Sgd78059 "NONE ", 55*6833Sgd78059 "LOW ", 56*6833Sgd78059 "MID ", 57*6833Sgd78059 "HIGH ", 58*6833Sgd78059 "UNKNOWN " 59*6833Sgd78059 60*6833Sgd78059 }; 61*6833Sgd78059 #endif 62*6833Sgd78059 63*6833Sgd78059 #define SEVERITY_UNKNOWN 0 64*6833Sgd78059 #define SEVERITY_NONE 0 65*6833Sgd78059 #define SEVERITY_LOW 0 66*6833Sgd78059 #define SEVERITY_MID 1 67*6833Sgd78059 #define SEVERITY_HIGH 2 68*6833Sgd78059 69*6833Sgd78059 70*6833Sgd78059 #define ERI_FAULT_MSG1(p, t, f, a) \ 71*6833Sgd78059 eri_fault_msg((p), (t), (f), (a)); 72*6833Sgd78059 73*6833Sgd78059 #define ERI_FAULT_MSG2(p, t, f, a, b) \ 74*6833Sgd78059 eri_fault_msg((p), (t), (f), (a), (b)); 75*6833Sgd78059 76*6833Sgd78059 #define ERI_FAULT_MSG3(p, t, f, a, b, c) \ 77*6833Sgd78059 eri_fault_msg((p), (t), (f), (a), (b), (c)); 78*6833Sgd78059 79*6833Sgd78059 #define ERI_FAULT_MSG4(p, t, f, a, b, c, d) \ 80*6833Sgd78059 eri_fault_msg((p), (t), (f), (a), (b), (c), (d)); 81*6833Sgd78059 82*6833Sgd78059 #ifdef DEBUG 83*6833Sgd78059 typedef enum { 84*6833Sgd78059 NO_MSG = 0, 85*6833Sgd78059 AUTOCONFIG_MSG = 1, 86*6833Sgd78059 STREAMS_MSG = 2, 87*6833Sgd78059 IOCTL_MSG = 3, 88*6833Sgd78059 PROTO_MSG = 4, 89*6833Sgd78059 INIT_MSG = 5, 90*6833Sgd78059 TX_MSG = 6, 91*6833Sgd78059 RX_MSG = 7, 92*6833Sgd78059 INTR_MSG = 8, 93*6833Sgd78059 UNINIT_MSG = 9, 94*6833Sgd78059 CONFIG_MSG = 10, 95*6833Sgd78059 PROP_MSG = 11, 96*6833Sgd78059 ENTER_MSG = 12, 97*6833Sgd78059 RESUME_MSG = 13, 98*6833Sgd78059 AUTONEG_MSG = 14, 99*6833Sgd78059 NAUTONEG_MSG = 15, 100*6833Sgd78059 FATAL_ERR_MSG = 16, 101*6833Sgd78059 NONFATAL_MSG = 17, 102*6833Sgd78059 NDD_MSG = 18, 103*6833Sgd78059 PHY_MSG = 19, 104*6833Sgd78059 XCVR_MSG = 20, 105*6833Sgd78059 NSUPPORT_MSG = 21, 106*6833Sgd78059 ERX_MSG = 22, 107*6833Sgd78059 FREE_MSG = 23, 108*6833Sgd78059 IPG_MSG = 24, 109*6833Sgd78059 DDI_MSG = 25, 110*6833Sgd78059 DEFAULT_MSG = 26, 111*6833Sgd78059 DISPLAY_MSG = 27, 112*6833Sgd78059 DIAG_MSG = 28, 113*6833Sgd78059 END_TRACE1_MSG = 29, 114*6833Sgd78059 END_TRACE2_MSG = 30, 115*6833Sgd78059 ASSERT_MSG = 31, 116*6833Sgd78059 FRM_MSG = 32, 117*6833Sgd78059 MIF_MSG = 33, 118*6833Sgd78059 LINK_MSG = 34, 119*6833Sgd78059 RESOURCE_MSG = 35, 120*6833Sgd78059 LOOPBACK_MSG = 36, 121*6833Sgd78059 VERBOSE_MSG = 37, 122*6833Sgd78059 MODCTL_MSG = 38, 123*6833Sgd78059 HWCSUM_MSG = 39, 124*6833Sgd78059 CORRUPTION_MSG = 40, 125*6833Sgd78059 EXIT_MSG = 41, 126*6833Sgd78059 DLCAPAB_MSG = 42 127*6833Sgd78059 128*6833Sgd78059 } debug_msg_t; 129*6833Sgd78059 130*6833Sgd78059 static debug_msg_t eri_debug_level = NO_MSG; 131*6833Sgd78059 static debug_msg_t eri_debug_all = NO_MSG; 132*6833Sgd78059 133*6833Sgd78059 static char *debug_msg_string[] = { 134*6833Sgd78059 "NONE ", 135*6833Sgd78059 "AUTOCONFIG ", 136*6833Sgd78059 "STREAMS ", 137*6833Sgd78059 "IOCTL ", 138*6833Sgd78059 "PROTO ", 139*6833Sgd78059 "INIT ", 140*6833Sgd78059 "TX ", 141*6833Sgd78059 "RX ", 142*6833Sgd78059 "INTR ", 143*6833Sgd78059 "UNINIT ", 144*6833Sgd78059 "CONFIG ", 145*6833Sgd78059 "PROP ", 146*6833Sgd78059 "ENTER ", 147*6833Sgd78059 "RESUME ", 148*6833Sgd78059 "AUTONEG ", 149*6833Sgd78059 "NAUTONEG ", 150*6833Sgd78059 "FATAL_ERR ", 151*6833Sgd78059 "NFATAL_ERR ", 152*6833Sgd78059 "NDD ", 153*6833Sgd78059 "PHY ", 154*6833Sgd78059 "XCVR ", 155*6833Sgd78059 "NSUPPOR ", 156*6833Sgd78059 "ERX ", 157*6833Sgd78059 "FREE ", 158*6833Sgd78059 "IPG ", 159*6833Sgd78059 "DDI ", 160*6833Sgd78059 "DEFAULT ", 161*6833Sgd78059 "DISPLAY ", 162*6833Sgd78059 "DIAG ", 163*6833Sgd78059 "TRACE1 ", 164*6833Sgd78059 "TRACE2 ", 165*6833Sgd78059 "ASSERT", 166*6833Sgd78059 "FRM ", 167*6833Sgd78059 "MIF ", 168*6833Sgd78059 "LINK ", 169*6833Sgd78059 "RESOURCE", 170*6833Sgd78059 "LOOPBACK", 171*6833Sgd78059 "VERBOSE", 172*6833Sgd78059 "MODCTL", 173*6833Sgd78059 "HWCSUM", 174*6833Sgd78059 "CORRUPTION", 175*6833Sgd78059 "EXIT", 176*6833Sgd78059 "DLCAPAB" 177*6833Sgd78059 }; 178*6833Sgd78059 179*6833Sgd78059 static void eri_debug_msg(const char *, int, struct eri *, debug_msg_t, 180*6833Sgd78059 const char *, ...); 181*6833Sgd78059 182*6833Sgd78059 #define ERI_DEBUG_MSG1(t, f, a) \ 183*6833Sgd78059 eri_debug_msg(__FILE__, __LINE__, (t), (f), (a)); 184*6833Sgd78059 185*6833Sgd78059 #define ERI_DEBUG_MSG2(t, f, a, b) \ 186*6833Sgd78059 eri_debug_msg(__FILE__, __LINE__, (t), (f), (a), (b)); 187*6833Sgd78059 188*6833Sgd78059 #define ERI_DEBUG_MSG3(t, f, a, b, c) \ 189*6833Sgd78059 eri_debug_msg(__FILE__, __LINE__, (t), (f), (a), (b), (c)); 190*6833Sgd78059 191*6833Sgd78059 #define ERI_DEBUG_MSG4(t, f, a, b, c, d) \ 192*6833Sgd78059 eri_debug_msg(__FILE__, __LINE__, (t), (f), (a), (b), (c), (d)); 193*6833Sgd78059 194*6833Sgd78059 #define ERI_DEBUG_MSG5(t, f, a, b, c, d, e) \ 195*6833Sgd78059 eri_debug_msg(__FILE__, __LINE__, (t), (f), (a), (b), (c), (d), (e)); 196*6833Sgd78059 197*6833Sgd78059 #else 198*6833Sgd78059 199*6833Sgd78059 #define ERI_DEBUG_MSG1(t, f, a) 200*6833Sgd78059 #define ERI_DEBUG_MSG2(t, f, a, b) 201*6833Sgd78059 #define ERI_DEBUG_MSG3(t, f, a, b, c) 202*6833Sgd78059 #define ERI_DEBUG_MSG4(t, f, a, b, c, d) 203*6833Sgd78059 #define ERI_DEBUG_MSG5(t, f, a, b, c, d, e) 204*6833Sgd78059 #define ERI_DEBUG_MSG6(t, f, a, b, c, d, e, g, h) 205*6833Sgd78059 #endif 206*6833Sgd78059 207*6833Sgd78059 #define ERI_HWCSUM 208*6833Sgd78059 209*6833Sgd78059 /* 210*6833Sgd78059 * ERI REV 1.0 has some hardware bugs which doesn't alow it 211*6833Sgd78059 * to function to full features. We define this flag to disable 212*6833Sgd78059 * the features affected by these bugs. 213*6833Sgd78059 */ 214*6833Sgd78059 #ifdef ERI_ERI_REV_1_0 215*6833Sgd78059 #define RCV_OVRFLOW_CORRUPTION_BUG 216*6833Sgd78059 #endif 217*6833Sgd78059 218*6833Sgd78059 #define ERI_HDX_BUG_WORKAROUND 219*6833Sgd78059 #define ERI_TX_HUNG 220*6833Sgd78059 /* 221*6833Sgd78059 * In forced speed mode when changing mode from 10 (force) to 222*6833Sgd78059 * 10 (force), such as changing from 10/half to 10/full, 223*6833Sgd78059 * the driver does not receive a MIF interrupt even though 224*6833Sgd78059 * the XCVR status indicates that the link is up, and this 225*6833Sgd78059 * is probably caused by the link for some reason does not 226*6833Sgd78059 * go down. 227*6833Sgd78059 * 228*6833Sgd78059 * In forced mode, when changing speed/mode from 10 (force) to 229*6833Sgd78059 * 100 (force), the user needs to make sure that the link 230*6833Sgd78059 * partner is in forced mode as well by setting speed to 231*6833Sgd78059 * 100 and the mode to either full or half duplex or 232*6833Sgd78059 * else the link might not come up or come up with a mis-match mode. 233*6833Sgd78059 */ 234*6833Sgd78059 #define ERI_10_10_FORCE_SPEED_WORKAROUND 235*6833Sgd78059 /* 236*6833Sgd78059 * bits 15:0 of MIF status register contains 0 value 237*6833Sgd78059 * and it is not defined as described on GEM specification 238*6833Sgd78059 */ 239*6833Sgd78059 #define ERI_MIF_POLL_STATUS_WORKAROUND 240*6833Sgd78059 #define ERI_STRETCH_RCV_BUFFER 241*6833Sgd78059 242*6833Sgd78059 #ifdef ERI_STRETCH_RCV_BUFFER 243*6833Sgd78059 #undef ERIBUFSIZE 244*6833Sgd78059 #define ERIBUFSIZE 3904 245*6833Sgd78059 #endif 246*6833Sgd78059 247*6833Sgd78059 #ifdef notdef 248*6833Sgd78059 #define ERI_DONT_STRIP_CRC 249*6833Sgd78059 #endif 250*6833Sgd78059 251*6833Sgd78059 #ifdef ERI_HWCSUM 252*6833Sgd78059 #define ERI_RCV_CKSUM 253*6833Sgd78059 #endif 254*6833Sgd78059 255*6833Sgd78059 #ifdef notdef 256*6833Sgd78059 #define ERI_SERVICE_ROUTINE 257*6833Sgd78059 #endif 258*6833Sgd78059 #define ERIHIWAT (128 * 1024) /* hi-water mark */ 259*6833Sgd78059 #define ERIRINDEX(i) (i & erip->erirpending_mask) 260*6833Sgd78059 #define DONT_FLUSH -1 261*6833Sgd78059 262*6833Sgd78059 /* 263*6833Sgd78059 * ddi_dma_sync() a TMD or RMD descriptor. 264*6833Sgd78059 */ 265*6833Sgd78059 #define ERI_SYNCIOPB(erip, a, size, who) \ 266*6833Sgd78059 (void) ddi_dma_sync((erip)->md_h, \ 267*6833Sgd78059 ((uintptr_t)(a) - (erip)->iopbkbase), \ 268*6833Sgd78059 (size), \ 269*6833Sgd78059 (who)) 270*6833Sgd78059 271*6833Sgd78059 /* ------------------------------------------------------------------------- */ 272*6833Sgd78059 /* 273*6833Sgd78059 * Patchable debug flag. 274*6833Sgd78059 * Set this to nonzero to enable error messages. 275*6833Sgd78059 */ 276*6833Sgd78059 277*6833Sgd78059 /* 278*6833Sgd78059 * The following parameters may be configured by the user. If they are not 279*6833Sgd78059 * configured by the user, the values will be based on the capabilities of 280*6833Sgd78059 * the transceiver. 281*6833Sgd78059 * The value "ERI_NOTUSR" is ORed with the parameter value to indicate values 282*6833Sgd78059 * which are NOT configured by the user. 283*6833Sgd78059 */ 284*6833Sgd78059 285*6833Sgd78059 /* command */ 286*6833Sgd78059 287*6833Sgd78059 #define ND_BASE ('N' << 8) /* base */ 288*6833Sgd78059 #define ND_GET (ND_BASE + 0) /* Get a value */ 289*6833Sgd78059 #define ND_SET (ND_BASE + 1) /* Set a value */ 290*6833Sgd78059 291*6833Sgd78059 #define ERI_ND_GET ND_GET 292*6833Sgd78059 #define ERI_ND_SET ND_SET 293*6833Sgd78059 #define ERI_NOTUSR 0x0f000000 294*6833Sgd78059 #define ERI_MASK_1BIT 0x1 295*6833Sgd78059 #define ERI_MASK_2BIT 0x3 296*6833Sgd78059 #define ERI_MASK_8BIT 0xff 297*6833Sgd78059 298*6833Sgd78059 #define param_transceiver (erip->param_arr[0].param_val) 299*6833Sgd78059 #define param_linkup (erip->param_arr[1].param_val) 300*6833Sgd78059 #define param_speed (erip->param_arr[2].param_val) 301*6833Sgd78059 #define param_mode (erip->param_arr[3].param_val) 302*6833Sgd78059 #define param_ipg1 (erip->param_arr[4].param_val) 303*6833Sgd78059 #define param_ipg2 (erip->param_arr[5].param_val) 304*6833Sgd78059 #define param_use_intphy (erip->param_arr[6].param_val) 305*6833Sgd78059 #define param_pace_count (erip->param_arr[7].param_val) 306*6833Sgd78059 #define param_autoneg (erip->param_arr[8].param_val) 307*6833Sgd78059 #define param_anar_100T4 (erip->param_arr[9].param_val) 308*6833Sgd78059 309*6833Sgd78059 #define param_anar_100fdx (erip->param_arr[10].param_val) 310*6833Sgd78059 #define param_anar_100hdx (erip->param_arr[11].param_val) 311*6833Sgd78059 #define param_anar_10fdx (erip->param_arr[12].param_val) 312*6833Sgd78059 #define param_anar_10hdx (erip->param_arr[13].param_val) 313*6833Sgd78059 #define param_bmsr_ancap (erip->param_arr[14].param_val) 314*6833Sgd78059 #define param_bmsr_100T4 (erip->param_arr[15].param_val) 315*6833Sgd78059 #define param_bmsr_100fdx (erip->param_arr[16].param_val) 316*6833Sgd78059 #define param_bmsr_100hdx (erip->param_arr[17].param_val) 317*6833Sgd78059 #define param_bmsr_10fdx (erip->param_arr[18].param_val) 318*6833Sgd78059 #define param_bmsr_10hdx (erip->param_arr[19].param_val) 319*6833Sgd78059 320*6833Sgd78059 #define param_aner_lpancap (erip->param_arr[20].param_val) 321*6833Sgd78059 #define param_anlpar_100T4 (erip->param_arr[21].param_val) 322*6833Sgd78059 #define param_anlpar_100fdx (erip->param_arr[22].param_val) 323*6833Sgd78059 #define param_anlpar_100hdx (erip->param_arr[23].param_val) 324*6833Sgd78059 #define param_anlpar_10fdx (erip->param_arr[24].param_val) 325*6833Sgd78059 #define param_anlpar_10hdx (erip->param_arr[25].param_val) 326*6833Sgd78059 #define param_lance_mode (erip->param_arr[26].param_val) 327*6833Sgd78059 #define param_ipg0 (erip->param_arr[27].param_val) 328*6833Sgd78059 #define param_intr_blank_time (erip->param_arr[28].param_val) 329*6833Sgd78059 #define param_intr_blank_packets (erip->param_arr[29].param_val) 330*6833Sgd78059 #define param_serial_link (erip->param_arr[30].param_val) 331*6833Sgd78059 332*6833Sgd78059 #define param_non_serial_link (erip->param_arr[31].param_val) 333*6833Sgd78059 #define param_select_link (erip->param_arr[32].param_val) 334*6833Sgd78059 #define param_default_link (erip->param_arr[33].param_val) 335*6833Sgd78059 #define param_link_in_use (erip->param_arr[34].param_val) 336*6833Sgd78059 #define param_anar_asm_dir (erip->param_arr[35].param_val) 337*6833Sgd78059 #define param_anar_pause (erip->param_arr[36].param_val) 338*6833Sgd78059 #define param_bmsr_asm_dir (erip->param_arr[37].param_val) 339*6833Sgd78059 #define param_bmsr_pause (erip->param_arr[38].param_val) 340*6833Sgd78059 #define param_anlpar_pauseTX (erip->param_arr[49].param_val) 341*6833Sgd78059 #define param_anlpar_pauseRX (erip->param_arr[40].param_val) 342*6833Sgd78059 343*6833Sgd78059 /* <<<<<<<<<<<<<<<<<<<<<< Register operations >>>>>>>>>>>>>>>>>>>>> */ 344*6833Sgd78059 #define GET_PCSREG(reg) \ 345*6833Sgd78059 ddi_get32(erip->pcsregh, (uint32_t *)&erip->pcsregp->reg) 346*6833Sgd78059 #define PUT_PCSREG(reg, value) \ 347*6833Sgd78059 ddi_put32(erip->pcsregh, (uint32_t *)&erip->pcsregp->reg, value) 348*6833Sgd78059 #define GET_MIFREG(reg) \ 349*6833Sgd78059 ddi_get32(erip->mifregh, (uint32_t *)&erip->mifregp->reg) 350*6833Sgd78059 #define PUT_MIFREG(reg, value) \ 351*6833Sgd78059 ddi_put32(erip->mifregh, (uint32_t *)&erip->mifregp->reg, value) 352*6833Sgd78059 #define GET_ETXREG(reg) \ 353*6833Sgd78059 ddi_get32(erip->etxregh, (uint32_t *)&erip->etxregp->reg) 354*6833Sgd78059 #define PUT_ETXREG(reg, value) \ 355*6833Sgd78059 ddi_put32(erip->etxregh, (uint32_t *)&erip->etxregp->reg, value) 356*6833Sgd78059 #define GET_ERXREG(reg) \ 357*6833Sgd78059 ddi_get32(erip->erxregh, (uint32_t *)&erip->erxregp->reg) 358*6833Sgd78059 #define PUT_ERXREG(reg, value) \ 359*6833Sgd78059 ddi_put32(erip->erxregh, (uint32_t *)&erip->erxregp->reg, value) 360*6833Sgd78059 #define GET_MACREG(reg) \ 361*6833Sgd78059 ddi_get32(erip->bmacregh, (uint32_t *)&erip->bmacregp->reg) 362*6833Sgd78059 #define PUT_MACREG(reg, value) \ 363*6833Sgd78059 ddi_put32(erip->bmacregh, \ 364*6833Sgd78059 (uint32_t *)&erip->bmacregp->reg, value) 365*6833Sgd78059 #define GET_GLOBREG(reg) \ 366*6833Sgd78059 ddi_get32(erip->globregh, (uint32_t *)&erip->globregp->reg) 367*6833Sgd78059 #define PUT_GLOBREG(reg, value) \ 368*6833Sgd78059 ddi_put32(erip->globregh, \ 369*6833Sgd78059 (uint32_t *)&erip->globregp->reg, value) 370*6833Sgd78059 371*6833Sgd78059 #define GET_SWRSTREG(reg) \ 372*6833Sgd78059 ddi_get32(erip->sw_reset_regh, (uint32_t *)erip->sw_reset_reg) 373*6833Sgd78059 374*6833Sgd78059 #define PUT_SWRSTREG(reg, value) \ 375*6833Sgd78059 ddi_put32(erip->sw_reset_regh, \ 376*6833Sgd78059 (uint32_t *)erip->sw_reset_reg, value) 377*6833Sgd78059 378*6833Sgd78059 /* ********************** Descriptor OPerations ******************** */ 379*6833Sgd78059 380*6833Sgd78059 /* <<<<<<<<<<<<<<<<<<<<< for Solaris 2.6 and 2.7 >>>>>>>>>>>>>>>>>>>> */ 381*6833Sgd78059 382*6833Sgd78059 /* TMD and RMD Descriptor Operations */ 383*6833Sgd78059 #define PUT_TMD(ptr, cookie, len, flags) \ 384*6833Sgd78059 ddi_put64(erip->mdm_h, (uint64_t *)&ptr->tmd_addr, \ 385*6833Sgd78059 cookie.dmac_laddress); \ 386*6833Sgd78059 ddi_put64(erip->mdm_h, (uint64_t *)&ptr->tmd_flags, len | flags) 387*6833Sgd78059 388*6833Sgd78059 #define PUT_TMD_FAST(ptr, cookie, len, flags) \ 389*6833Sgd78059 ddi_put64(erip->mdm_h, (uint64_t *)&ptr->tmd_addr, \ 390*6833Sgd78059 cookie.dmac_address); \ 391*6833Sgd78059 ddi_put64(erip->mdm_h, (uint64_t *)&ptr->tmd_flags, len | flags) 392*6833Sgd78059 393*6833Sgd78059 #define GET_TMD_FLAGS(ptr) \ 394*6833Sgd78059 ddi_get64(erip->mdm_h, (uint64_t *)&ptr->tmd_flags) 395*6833Sgd78059 396*6833Sgd78059 #define PUT_RMD(ptr, cookie) \ 397*6833Sgd78059 ddi_put64(erip->mdm_h, (uint64_t *)&ptr->rmd_addr, \ 398*6833Sgd78059 cookie.dmac_laddress); \ 399*6833Sgd78059 ddi_put64(erip->mdm_h, (uint64_t *)&ptr->rmd_flags, \ 400*6833Sgd78059 (uint64_t)(ERI_BUFSIZE << ERI_RMD_BUFSIZE_SHIFT) | ERI_RMD_OWN) 401*6833Sgd78059 402*6833Sgd78059 #define UPDATE_RMD(ptr) \ 403*6833Sgd78059 ddi_put64(erip->mdm_h, (uint64_t *)&ptr->rmd_flags, \ 404*6833Sgd78059 (uint64_t)(ERI_BUFSIZE << ERI_RMD_BUFSIZE_SHIFT) | ERI_RMD_OWN) 405*6833Sgd78059 406*6833Sgd78059 #define PUT_RMD_FAST(ptr, cookie) \ 407*6833Sgd78059 ddi_put64(erip->mdm_h, (uint64_t *)&ptr->rmd_addr, \ 408*6833Sgd78059 cookie.dmac_address); \ 409*6833Sgd78059 ddi_put64(erip->mdm_h, (uint64_t *)&ptr->rmd_flags, \ 410*6833Sgd78059 (uint64_t)(ERI_BUFSIZE << ERI_RMD_BUFSIZE_SHIFT) | ERI_RMD_OWN) 411*6833Sgd78059 412*6833Sgd78059 #define GET_RMD_FLAGS(ptr) \ 413*6833Sgd78059 ddi_get64(erip->mdm_h, (uint64_t *)&ptr->rmd_flags) 414*6833Sgd78059 415*6833Sgd78059 #define ENABLE_TXMAC(erip) \ 416*6833Sgd78059 PUT_MACREG(txcfg, GET_MACREG(txcfg) | BMAC_TXCFG_ENAB) 417*6833Sgd78059 418*6833Sgd78059 #define ENABLE_RXMAC(erip) \ 419*6833Sgd78059 PUT_MACREG(rxcfg, GET_MACREG(rxcfg) | BMAC_RXCFG_ENAB) 420*6833Sgd78059 421*6833Sgd78059 #define DISABLE_RXMAC(erip) \ 422*6833Sgd78059 PUT_MACREG(rxcfg, GET_MACREG(rxcfg) & ~BMAC_RXCFG_ENAB) 423*6833Sgd78059 424*6833Sgd78059 #define DISABLE_TXMAC(erip) \ 425*6833Sgd78059 PUT_MACREG(txcfg, GET_MACREG(txcfg) & ~BMAC_TXCFG_ENAB) 426*6833Sgd78059 427*6833Sgd78059 #define ENABLE_MAC(erip) \ 428*6833Sgd78059 ENABLE_RXMAC(erip); \ 429*6833Sgd78059 ENABLE_TXMAC(erip) 430*6833Sgd78059 431*6833Sgd78059 #define DISABLE_MAC(erip) \ 432*6833Sgd78059 DISABLE_RXMAC(erip); \ 433*6833Sgd78059 DISABLE_TXMAC(erip) 434*6833Sgd78059 435*6833Sgd78059 #define ENABLE_TXDMA(erip) \ 436*6833Sgd78059 PUT_ETXREG(config, GET_ETXREG(config) | GET_CONFIG_TXDMA_EN) 437*6833Sgd78059 438*6833Sgd78059 /* TODO : MBE : GER? */ 439*6833Sgd78059 #define ENABLE_RXDMA(erip) \ 440*6833Sgd78059 PUT_ERXREG(config, GET_ERXREG(config) | GET_CONFIG_RXDMA_EN) 441*6833Sgd78059 442*6833Sgd78059 443*6833Sgd78059 /* 444*6833Sgd78059 * Ether-type is specifically big-endian, but data region is unknown endian 445*6833Sgd78059 * Ether-type lives at offset 12 from the start of the packet. 446*6833Sgd78059 */ 447*6833Sgd78059 448*6833Sgd78059 #define get_ether_type(ptr) \ 449*6833Sgd78059 (((((uint8_t *)ptr)[12] << 8) | (((uint8_t *)ptr)[13]))) 450*6833Sgd78059 451*6833Sgd78059 #endif /* _KERNEL */ 452*6833Sgd78059 453*6833Sgd78059 #ifdef __cplusplus 454*6833Sgd78059 } 455*6833Sgd78059 #endif 456*6833Sgd78059 457*6833Sgd78059 #endif /* _SYS_ERI_COMMON_H */ 458