d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * CDDL HEADER START
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * The contents of this file are subject to the terms of the
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Common Development and Distribution License (the "License").
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * You may not use this file except in compliance with the License.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * or http://www.opensolaris.org/os/licensing.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * See the License for the specific language governing permissions
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * and limitations under the License.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * When distributing Covered Code, include this CDDL HEADER in each
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * If applicable, add the following below this CDDL HEADER, with the
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * fields enclosed by brackets "[]" replaced with your own identifying
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * information: Portions Copyright [yyyy] [name of copyright owner]
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * CDDL HEADER END
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
193974072f41a843678abf5f61979c748687e66bSherry Moore * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Use is subject to license terms.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * This file is part of the Chelsio T1 Ethernet driver.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Copyright (C) 2003-2005 Chelsio Communications. All rights reserved.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Solaris Multithreaded STREAMS DLPI Chelsio PCI Ethernet Driver
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/* #define CH_DEBUG 1 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CH_DEBUG
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#define DEBUG_ENTER(a) debug_enter(a)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#define PRINT(a) printf a
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#define DEBUG_ENTER(a)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#define PRINT(a)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/types.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/conf.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/debug.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/stropts.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/stream.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/strlog.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/kmem.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/stat.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/kstat.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/modctl.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/errno.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/cmn_err.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/ddi.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/sunddi.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/dlpi.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/ethernet.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/strsun.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/strsubr.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <inet/common.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <inet/nd.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <inet/ip.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <inet/tcp.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/pattr.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include <sys/gld.h>
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include "ostypes.h"
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include "common.h"
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include "oschtoe.h"
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include "sge.h"
193974072f41a843678abf5f61979c748687e66bSherry Moore#include "regs.h"
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include "ch.h" /* Chelsio Driver specific parameters */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include "version.h"
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Function prototypes.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int ch_attach(dev_info_t *, ddi_attach_cmd_t);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int ch_detach(dev_info_t *, ddi_detach_cmd_t);
193974072f41a843678abf5f61979c748687e66bSherry Moorestatic int ch_quiesce(dev_info_t *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic void ch_free_dma_handles(ch_t *chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic void ch_set_name(ch_t *chp, int unit);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic void ch_free_name(ch_t *chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic void ch_get_prop(ch_t *chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#if defined(__sparc)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic void ch_free_dvma_handles(ch_t *chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/* GLD interfaces */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int ch_reset(gld_mac_info_t *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int ch_start(gld_mac_info_t *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int ch_stop(gld_mac_info_t *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int ch_set_mac_address(gld_mac_info_t *, uint8_t *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int ch_set_multicast(gld_mac_info_t *, uint8_t *, int);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int ch_ioctl(gld_mac_info_t *, queue_t *, mblk_t *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int ch_set_promiscuous(gld_mac_info_t *, int);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int ch_get_stats(gld_mac_info_t *, struct gld_stats *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int ch_send(gld_mac_info_t *, mblk_t *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic uint_t ch_intr(gld_mac_info_t *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Data access requirements.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic struct ddi_device_acc_attr le_attr = {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DDI_DEVICE_ATTR_V0,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DDI_STRUCTURE_LE_ACC,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DDI_STRICTORDER_ACC
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * No swap mapping device attributes
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic struct ddi_device_acc_attr null_attr = {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DDI_DEVICE_ATTR_V0,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DDI_NEVERSWAP_ACC,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DDI_STRICTORDER_ACC
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * STREAMS driver identification struture module_info(9s)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * driver limit values
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic struct module_info ch_minfo = {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw CHIDNUM, /* mi_idnum */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw CHNAME, /* mi_idname */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw CHMINPSZ, /* mi_minpsz */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw CHMAXPSZ, /* mi_maxpsz */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw CHHIWAT, /* mi_hiwat */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw CHLOWAT /* mi_lowat */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * STREAMS queue processiong procedures qinit(9s)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * read queue procedures
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic struct qinit ch_rinit = {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (int (*)()) NULL, /* qi_putp */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_rsrv, /* qi_srvp */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_open, /* qi_qopen */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_close, /* qi_qclose */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (int (*)()) NULL, /* qi_qadmin */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &ch_minfo, /* qi_minfo */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw NULL /* qi_mstat */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * STREAMS queue processiong procedures qinit(9s)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * write queue procedures
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic struct qinit ch_winit = {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_wput, /* qi_putp */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_wsrv, /* qi_srvp */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (int (*)()) NULL, /* qi_qopen */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (int (*)()) NULL, /* qi_qclose */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (int (*)()) NULL, /* qi_qadmin */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &ch_minfo, /* qi_minfo */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw NULL /* qi_mstat */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * STREAMS entity declaration structure - streamtab(9s)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic struct streamtab chinfo = {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &ch_rinit, /* read queue information */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &ch_winit, /* write queue information */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw NULL, /* st_muxrinit */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw NULL /* st_muxwrinit */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Device driver ops vector - cb_ops(9s)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * charater/block entry points structure.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * chinfo identifies driver as a STREAMS driver.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic struct cb_ops cb_ch_ops = {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nulldev, /* cb_open */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nulldev, /* cb_close */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nodev, /* cb_strategy */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nodev, /* cb_print */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nodev, /* cb_dump */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nodev, /* cb_read */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nodev, /* cb_write */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nodev, /* cb_ioctl */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nodev, /* cb_devmap */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nodev, /* cb_mmap */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nodev, /* cb_segmap */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nochpoll, /* cb_chpoll */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_prop_op, /* report driver property information - prop_op(9e) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &chinfo, /* cb_stream */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#if defined(__sparc)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw D_MP | D_64BIT,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw D_MP, /* cb_flag (supports multi-threading) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw CB_REV, /* cb_rev */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nodev, /* cb_aread */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nodev /* cb_awrite */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * dev_ops(9S) structure
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Device Operations table, for autoconfiguration
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic struct dev_ops ch_ops = {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEVO_REV, /* Driver build version */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw 0, /* Initial driver reference count */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_getinfo, /* funcp: get driver information - getinfo(9e) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nulldev, /* funcp: entry point obsolute - identify(9e) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nulldev, /* funp: probe for device - probe(9e) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_attach, /* funp: attach driver to dev_info - attach(9e) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_detach, /* funp: detach driver to unload - detach(9e) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nodev, /* funp: reset device (not supported) - dev_ops(9s) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &cb_ch_ops, /* ptr to cb_ops structure */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw NULL, /* ptr to nexus bus operations structure (leaf) */
193974072f41a843678abf5f61979c748687e66bSherry Moore NULL, /* funp: change device power level - power(9e) */
193974072f41a843678abf5f61979c748687e66bSherry Moore ch_quiesce, /* devo_quiesce */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * modldrv(9s) structure
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Definition for module specific device driver linkage structures (modctl.h)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic struct modldrv modldrv = {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &mod_driverops, /* driver module */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw VERSION,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &ch_ops, /* driver ops */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * modlinkage(9s) structure
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * module linkage base structure (modctl.h)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic struct modlinkage modlinkage = {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw MODREV_1, /* revision # of system */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &modldrv, /* NULL terminated list of linkage strucures */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw NULL
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/* ===================== start of STREAMS driver code ================== */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CONFIG_CHELSIO_T1_OFFLOAD
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * global pointer to toe per-driver control structure.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#define MAX_CARDS 4
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_t *gchp[MAX_CARDS];
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwkmutex_t in_use_l;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwuint32_t buffers_in_use[SZ_INUSE];
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwuint32_t in_use_index;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Ethernet broadcast address definition.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic struct ether_addr etherbroadcastaddr = {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Module initialization functions.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Routine Called by
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * _init(9E) modload(9F)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * _info(9E) modinfo(9F)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * _fini(9E) modunload(9F)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * _init(9E):
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Initial, one-time, resource allocation and data initialization.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwint
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw_init(void)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int status;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw status = mod_install(&modlinkage);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_init(&in_use_l, NULL, MUTEX_DRIVER, NULL);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (status);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * _fini(9E): It is here that any device information that was allocated
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * during the _init(9E) routine should be released and the module removed
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * from the system. In the case of per-instance information, that information
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * should be released in the _detach(9E) routine.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwint
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw_fini(void)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int status;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int i;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t t = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw for (i = 0; i < SZ_INUSE; i++)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw t += buffers_in_use[i];
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (t != NULL)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw status = mod_remove(&modlinkage);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (status == DDI_SUCCESS)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&in_use_l);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (status);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwint
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw_info(struct modinfo *modinfop)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int status;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw status = mod_info(&modlinkage, modinfop);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (status);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Attach(9E) - This is called on the open to the device. It creates
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * an instance of the driver. In this routine we create the minor
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * device node. The routine also initializes all per-unit
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * mutex's and conditional variables.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * If we were resuming a suspended instance of a device due to power
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * management, then that would be handled here as well. For more on
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * that subject see the man page for pm(9E)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Interface exists: make available by filling in network interface
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * record. System will initialize the interface when it is ready
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * to accept packets.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwint chdebug = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwint ch_abort_debug = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_t *chp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int rv;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int unit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CH_DEBUG
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int Version;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int VendorID;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int DeviceID;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int SubDeviceID;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int Command;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_mac_info_t *macinfo; /* GLD stuff follows */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw char *driver;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (ch_abort_debug)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw debug_enter("ch_attach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chdebug)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (cmd == DDI_ATTACH) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw unit = ddi_get_instance(dip);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw driver = (char *)ddi_driver_name(dip);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("driver %s unit: %d\n", driver, unit));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo = gld_mac_alloc(dip);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (macinfo == NULL) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("macinfo allocation failed\n"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("ch_attach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp = (ch_t *)kmem_zalloc(sizeof (ch_t), KM_SLEEP);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp == NULL) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("zalloc of chp failed\n"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("ch_attach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_mac_free(macinfo);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CONFIG_CHELSIO_T1_OFFLOAD
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* Solaris TOE support */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gchp[unit] = chp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("attach macinfo: %p chp: %p\n", macinfo, chp));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_dip = dip;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_macp = macinfo;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_unit = unit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_set_name(chp, unit);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * map in PCI register spaces
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * PCI register set 0 - PCI configuration space
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * PCI register set 1 - T101 card register space #1
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* map in T101 PCI configuration space */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rv = pci_config_setup(
193974072f41a843678abf5f61979c748687e66bSherry Moore dip, /* ptr to dev's dev_info struct */
193974072f41a843678abf5f61979c748687e66bSherry Moore &chp->ch_hpci); /* ptr to data access handle */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (rv != DDI_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("PCI config setup failed\n"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("ch_attach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CONFIG_CHELSIO_T1_OFFLOAD
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gchp[unit] = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN, "%s: ddi_config_setup PCI error %d\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name, rv);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_free_name(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmem_free(chp, sizeof (ch_t));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_mac_free(macinfo);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_get_prop(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_devinfo = dip;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_private = (caddr_t)chp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_reset = ch_reset;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_start = ch_start;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_stop = ch_stop;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_set_mac_addr = ch_set_mac_address;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_send = ch_send;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_set_promiscuous = ch_set_promiscuous;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_get_stats = ch_get_stats;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_ioctl = ch_ioctl;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_set_multicast = ch_set_multicast;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_intr = ch_intr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_mctl = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_ident = driver;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_type = DL_ETHER;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_minpkt = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_maxpkt = chp->ch_mtu;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_addrlen = ETHERADDRL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_saplen = -2;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_ppa = unit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_broadcast_addr =
193974072f41a843678abf5f61979c748687e66bSherry Moore etherbroadcastaddr.ether_addr_octet;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * do a power reset of card
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 1. set PwrState to D3hot (3)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 2. clear PwrState flags
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pci_config_put32(chp->ch_hpci, 0x44, 3);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pci_config_put32(chp->ch_hpci, 0x44, 0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* delay .5 sec */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DELAY(500000);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CH_DEBUG
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw VendorID = pci_config_get16(chp->ch_hpci, 0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DeviceID = pci_config_get16(chp->ch_hpci, 2);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw SubDeviceID = pci_config_get16(chp->ch_hpci, 0x2e);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw Command = pci_config_get16(chp->ch_hpci, 4);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("IDs: %x,%x,%x\n", VendorID, DeviceID, SubDeviceID));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("Command: %x\n", Command));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* map in T101 register space (BAR0) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rv = ddi_regs_map_setup(
193974072f41a843678abf5f61979c748687e66bSherry Moore dip, /* ptr to dev's dev_info struct */
193974072f41a843678abf5f61979c748687e66bSherry Moore BAR0, /* register address space */
193974072f41a843678abf5f61979c748687e66bSherry Moore &chp->ch_bar0, /* address of offset */
193974072f41a843678abf5f61979c748687e66bSherry Moore 0, /* offset into register address space */
193974072f41a843678abf5f61979c748687e66bSherry Moore 0, /* length mapped (everything) */
193974072f41a843678abf5f61979c748687e66bSherry Moore &le_attr, /* ptr to device attr structure */
193974072f41a843678abf5f61979c748687e66bSherry Moore &chp->ch_hbar0); /* ptr to data access handle */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (rv != DDI_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("map registers failed\n"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("ch_attach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CONFIG_CHELSIO_T1_OFFLOAD
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gchp[unit] = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
193974072f41a843678abf5f61979c748687e66bSherry Moore "%s: ddi_regs_map_setup BAR0 error %d\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name, rv);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pci_config_teardown(&chp->ch_hpci);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_free_name(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmem_free(chp, sizeof (ch_t));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_mac_free(macinfo);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CH_DEBUG
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw Version = ddi_get32(chp->ch_hbar0,
193974072f41a843678abf5f61979c748687e66bSherry Moore (uint32_t *)(chp->ch_bar0+0x6c));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (void) ddi_dev_regsize(dip, 1, &chp->ch_bar0sz);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("PCI BAR0 space addr: %p\n", chp->ch_bar0));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("PCI BAR0 space size: %x\n", chp->ch_bar0sz));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("PE Version: %x\n", Version));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Add interrupt to system.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rv = ddi_get_iblock_cookie(
193974072f41a843678abf5f61979c748687e66bSherry Moore dip, /* ptr to dev's dev_info struct */
193974072f41a843678abf5f61979c748687e66bSherry Moore 0, /* interrupt # (0) */
193974072f41a843678abf5f61979c748687e66bSherry Moore &chp->ch_icookp); /* ptr to interrupt block cookie */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (rv != DDI_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("iblock cookie failed\n"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("ch_attach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CONFIG_CHELSIO_T1_OFFLOAD
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gchp[unit] = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
193974072f41a843678abf5f61979c748687e66bSherry Moore "%s: ddi_get_iblock_cookie error %d\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name, rv);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_regs_map_free(&chp->ch_hbar0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pci_config_teardown(&chp->ch_hpci);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_free_name(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmem_free(chp, sizeof (ch_t));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_mac_free(macinfo);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * add interrupt handler before card setup.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rv = ddi_add_intr(
193974072f41a843678abf5f61979c748687e66bSherry Moore dip, /* ptr to dev's dev_info struct */
193974072f41a843678abf5f61979c748687e66bSherry Moore 0, /* interrupt # (0) */
193974072f41a843678abf5f61979c748687e66bSherry Moore 0, /* iblock cookie ptr (NULL) */
193974072f41a843678abf5f61979c748687e66bSherry Moore 0, /* idevice cookie ptr (NULL) */
193974072f41a843678abf5f61979c748687e66bSherry Moore gld_intr, /* function ptr to interrupt handler */
193974072f41a843678abf5f61979c748687e66bSherry Moore (caddr_t)macinfo); /* handler argument */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (rv != DDI_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("add_intr failed\n"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("ch_attach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CONFIG_CHELSIO_T1_OFFLOAD
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gchp[unit] = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN, "%s: ddi_add_intr error %d\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name, rv);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_regs_map_free(&chp->ch_hbar0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pci_config_teardown(&chp->ch_hpci);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_free_name(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmem_free(chp, sizeof (ch_t));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_mac_free(macinfo);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* initalize all the remaining per-card locks */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_init(&chp->ch_lock, NULL, MUTEX_DRIVER,
193974072f41a843678abf5f61979c748687e66bSherry Moore (void *)chp->ch_icookp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_init(&chp->ch_intr, NULL, MUTEX_DRIVER,
193974072f41a843678abf5f61979c748687e66bSherry Moore (void *)chp->ch_icookp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_init(&chp->ch_mc_lck, NULL, MUTEX_DRIVER, NULL);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_init(&chp->ch_dh_lck, NULL, MUTEX_DRIVER, NULL);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_init(&chp->mac_lock, NULL, MUTEX_DRIVER, NULL);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* ------- initialize Chelsio card ------- */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (pe_attach(chp)) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("card initialization failed\n"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("ch_attach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CONFIG_CHELSIO_T1_OFFLOAD
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gchp[unit] = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN, "%s: pe_attach failed\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->ch_intr);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->ch_mc_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->mac_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_remove_intr(dip, 0, chp->ch_icookp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_regs_map_free(&chp->ch_hbar0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pci_config_teardown(&chp->ch_hpci);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_free_name(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmem_free(chp, sizeof (ch_t));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_mac_free(macinfo);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* ------- done with Chelsio card ------- */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* now can set mac address */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_vendor_addr = pe_get_mac(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_cookie = chp->ch_icookp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * We only active checksum offload for T2 architectures.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (is_T2(chp)) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_config.cksum_enabled)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_capabilities |=
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw GLD_CAP_CKSUM_FULL_V4;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.cksum_enabled = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rv = gld_register(
193974072f41a843678abf5f61979c748687e66bSherry Moore dip, /* ptr to dev's dev_info struct */
193974072f41a843678abf5f61979c748687e66bSherry Moore (char *)ddi_driver_name(dip), /* driver name */
193974072f41a843678abf5f61979c748687e66bSherry Moore macinfo); /* ptr to gld macinfo buffer */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * The Jumbo frames capability is not yet available
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * in Solaris 10 so registration will fail. MTU > 1500 is
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * supported in Update 1.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (rv != DDI_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_NOTE, "MTU > 1500 not supported by GLD.\n");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_NOTE, "Setting MTU to 1500. \n");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo->gldm_maxpkt = chp->ch_mtu = 1500;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rv = gld_register(
193974072f41a843678abf5f61979c748687e66bSherry Moore dip, /* ptr to dev's dev_info struct */
193974072f41a843678abf5f61979c748687e66bSherry Moore (char *)ddi_driver_name(dip), /* driver name */
193974072f41a843678abf5f61979c748687e66bSherry Moore macinfo); /* ptr to gld macinfo buffer */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (rv != DDI_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("gld_register failed\n"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("ch_attach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN, "%s: gld_register error %d\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name, rv);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_detach(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->ch_intr);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->ch_mc_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->mac_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_remove_intr(dip, 0, chp->ch_icookp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_regs_map_free(&chp->ch_hbar0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pci_config_teardown(&chp->ch_hpci);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_free_name(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmem_free(chp, sizeof (ch_t));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_mac_free(macinfo);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * print a banner at boot time (verbose mode), announcing
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * the device pointed to by dip
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_report_dev(dip);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (ch_abort_debug)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw debug_enter("ch_attach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else if (cmd == DDI_RESUME) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("attach resume\n"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("ch_attach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if ((chp = (ch_t *)ddi_get_driver_private(dip)) == NULL)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_flags &= ~PESUSPENDED;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("attach: bad command\n"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("ch_attach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
193974072f41a843678abf5f61979c748687e66bSherry Moore/*
193974072f41a843678abf5f61979c748687e66bSherry Moore * quiesce(9E) entry point.
193974072f41a843678abf5f61979c748687e66bSherry Moore *
193974072f41a843678abf5f61979c748687e66bSherry Moore * This function is called when the system is single-threaded at high
193974072f41a843678abf5f61979c748687e66bSherry Moore * PIL with preemption disabled. Therefore, this function must not be
193974072f41a843678abf5f61979c748687e66bSherry Moore * blocked.
193974072f41a843678abf5f61979c748687e66bSherry Moore *
193974072f41a843678abf5f61979c748687e66bSherry Moore * This function returns DDI_SUCCESS on success, or DDI_FAILURE on failure.
193974072f41a843678abf5f61979c748687e66bSherry Moore * DDI_FAILURE indicates an error condition and should almost never happen.
193974072f41a843678abf5f61979c748687e66bSherry Moore */
193974072f41a843678abf5f61979c748687e66bSherry Moorestatic int
193974072f41a843678abf5f61979c748687e66bSherry Moorech_quiesce(dev_info_t *dip)
193974072f41a843678abf5f61979c748687e66bSherry Moore{
193974072f41a843678abf5f61979c748687e66bSherry Moore ch_t *chp;
193974072f41a843678abf5f61979c748687e66bSherry Moore gld_mac_info_t *macinfo =
193974072f41a843678abf5f61979c748687e66bSherry Moore (gld_mac_info_t *)ddi_get_driver_private(dip);
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore chp = (ch_t *)macinfo->gldm_private;
193974072f41a843678abf5f61979c748687e66bSherry Moore chdebug = 0;
193974072f41a843678abf5f61979c748687e66bSherry Moore ch_abort_debug = 0;
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore#ifdef CONFIG_CHELSIO_T1_OFFLOAD
193974072f41a843678abf5f61979c748687e66bSherry Moore gchp[chp->ch_unit] = NULL;
193974072f41a843678abf5f61979c748687e66bSherry Moore#endif
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore /* Set driver state for this card to IDLE */
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_state = PEIDLE;
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore /*
193974072f41a843678abf5f61979c748687e66bSherry Moore * Do a power reset of card
193974072f41a843678abf5f61979c748687e66bSherry Moore * 1. set PwrState to D3hot (3)
193974072f41a843678abf5f61979c748687e66bSherry Moore * 2. clear PwrState flags
193974072f41a843678abf5f61979c748687e66bSherry Moore */
193974072f41a843678abf5f61979c748687e66bSherry Moore pci_config_put32(chp->ch_hpci, 0x44, 3);
193974072f41a843678abf5f61979c748687e66bSherry Moore pci_config_put32(chp->ch_hpci, 0x44, 0);
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore /* Wait 0.5 sec */
193974072f41a843678abf5f61979c748687e66bSherry Moore drv_usecwait(500000);
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore /*
193974072f41a843678abf5f61979c748687e66bSherry Moore * Now stop the chip
193974072f41a843678abf5f61979c748687e66bSherry Moore */
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_refcnt = 0;
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_state = PESTOP;
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore /* Disables all interrupts */
193974072f41a843678abf5f61979c748687e66bSherry Moore t1_interrupts_disable(chp);
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore /* Disables SGE queues */
193974072f41a843678abf5f61979c748687e66bSherry Moore t1_write_reg_4(chp->sge->obj, A_SG_CONTROL, 0x0);
193974072f41a843678abf5f61979c748687e66bSherry Moore t1_write_reg_4(chp->sge->obj, A_SG_INT_CAUSE, 0x0);
193974072f41a843678abf5f61979c748687e66bSherry Moore
193974072f41a843678abf5f61979c748687e66bSherry Moore return (DDI_SUCCESS);
193974072f41a843678abf5f61979c748687e66bSherry Moore}
193974072f41a843678abf5f61979c748687e66bSherry Moore
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_mac_info_t *macinfo;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_t *chp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (cmd == DDI_DETACH) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw macinfo = (gld_mac_info_t *)ddi_get_driver_private(dip);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp = (ch_t *)macinfo->gldm_private;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * fail detach if there are outstanding mblks still
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * in use somewhere.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("ch_detach");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CONFIG_CHELSIO_T1_OFFLOAD
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_refcnt > 0) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gchp[chp->ch_unit] = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * set driver state for this card to IDLE. We're
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * shutting down.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_state = PEIDLE;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * do a power reset of card
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 1. set PwrState to D3hot (3)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 2. clear PwrState flags
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pci_config_put32(chp->ch_hpci, 0x44, 3);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pci_config_put32(chp->ch_hpci, 0x44, 0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* delay .5 sec */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DELAY(500000);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* free register resources */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (void) gld_unregister(macinfo);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* make sure no interrupts while shutting down card */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_remove_intr(dip, 0, chp->ch_icookp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * reset device and recover resources
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_detach(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_regs_map_free(&chp->ch_hbar0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pci_config_teardown(&chp->ch_hpci);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->ch_intr);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->ch_mc_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_destroy(&chp->mac_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_free_dma_handles(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#if defined(__sparc)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_free_dvma_handles(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_free_name(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmem_free(chp, sizeof (ch_t));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_mac_free(macinfo);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("ch_detach end");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else if ((cmd == DDI_SUSPEND) || (cmd == DDI_PM_SUSPEND)) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DEBUG_ENTER("suspend");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if ((chp = (ch_t *)ddi_get_driver_private(dip)) == NULL)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_flags |= PESUSPENDED;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef TODO
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* Un-initialize (STOP) T101 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (DDI_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_alloc_dma_mem
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * allocates DMA handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * allocates kernel memory
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * allocates DMA access handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * chp - per-board descriptor
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * type - byteswap mapping?
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * flags - type of mapping
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * size - # bytes mapped
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * paddr - physical address
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * dh - ddi dma handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ah - ddi access handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwvoid *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_alloc_dma_mem(ch_t *chp, int type, int flags, int size, uint64_t *paddr,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ulong_t *dh, ulong_t *ah)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_attr_t ch_dma_attr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_cookie_t cookie;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_handle_t ch_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_acc_handle_t ch_ah;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_device_acc_attr_t *dev_attrp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw caddr_t ch_vaddr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw size_t rlen;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint_t count;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint_t mapping;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint_t align;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint_t rv;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint_t direction;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mapping = (flags&DMA_STREAM)?DDI_DMA_STREAMING:DDI_DMA_CONSISTENT;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (flags & DMA_4KALN)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw align = 0x4000;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw else if (flags & DMA_SMALN)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw align = chp->ch_sm_buf_aln;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw else if (flags & DMA_BGALN)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw align = chp->ch_bg_buf_aln;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw else {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN, "ch_alloc_dma_mem(%s): bad alignment flag\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_name);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw direction = (flags&DMA_OUT)?DDI_DMA_WRITE:DDI_DMA_READ;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * dynamically create a dma attribute structure
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_version = DMA_ATTR_V0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_addr_lo = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_addr_hi = 0xffffffffffffffff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_count_max = 0x00ffffff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_align = align;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_burstsizes = 0xfff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_minxfer = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_maxxfer = 0x00ffffff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_seg = 0xffffffff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_sgllen = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_granular = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_flags = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rv = ddi_dma_alloc_handle(
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_dip, /* device dev_info structure */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &ch_dma_attr, /* DMA attributes */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DDI_DMA_SLEEP, /* Wait if no memory */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw NULL, /* no argument to callback */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &ch_dh); /* DMA handle */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (rv != DDI_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
193974072f41a843678abf5f61979c748687e66bSherry Moore "%s: ch_alloc_dma_mem: ddi_dma_alloc_handle error %d\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name, rv);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* set byte order for data xfer */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (type)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dev_attrp = &null_attr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dev_attrp = &le_attr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rv = ddi_dma_mem_alloc(
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dh, /* dma handle */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw size, /* size desired allocate */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dev_attrp, /* access attributes */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mapping,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DDI_DMA_SLEEP, /* wait for resources */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw NULL, /* no argument */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &ch_vaddr, /* allocated memory */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &rlen, /* real size allocated */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &ch_ah); /* data access handle */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (rv != DDI_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_free_handle(&ch_dh);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
193974072f41a843678abf5f61979c748687e66bSherry Moore "%s: ch_alloc_dma_mem: ddi_dma_mem_alloc error %d\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name, rv);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rv = ddi_dma_addr_bind_handle(
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dh, /* dma handle */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (struct as *)0, /* kernel address space */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_vaddr, /* virtual address */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rlen, /* length of object */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw direction|mapping,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DDI_DMA_SLEEP, /* Wait for resources */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw NULL, /* no argument */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &cookie, /* dma cookie */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &count);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (rv != DDI_DMA_MAPPED) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_mem_free(&ch_ah);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_free_handle(&ch_dh);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: ch_alloc_dma_mem: ddi_dma_addr_bind_handle error %d\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name, rv);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (count != 1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: ch_alloc_dma_mem: ch_alloc_dma_mem cookie count %d\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name, count);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("ch_alloc_dma_mem cookie count %d\n", count));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_mem_free(&ch_ah);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_free_handle(&ch_dh);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *paddr = cookie.dmac_laddress;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *(ddi_dma_handle_t *)dh = ch_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *(ddi_acc_handle_t *)ah = ch_ah;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return ((void *)ch_vaddr);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_free_dma_mem
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees resources allocated by ch_alloc_dma_mem()
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees DMA handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees kernel memory
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees DMA access handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwvoid
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_free_dma_mem(ulong_t dh, ulong_t ah)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_handle_t ch_dh = (ddi_dma_handle_t)dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_acc_handle_t ch_ah = (ddi_acc_handle_t)ah;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (void) ddi_dma_unbind_handle(ch_dh);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_mem_free(&ch_ah);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_free_handle(&ch_dh);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * create a dma handle and return a dma handle entry.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwfree_dh_t *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_get_dma_handle(ch_t *chp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_handle_t ch_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_attr_t ch_dma_attr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw free_dh_t *dhe;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int rv;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dhe = (free_dh_t *)kmem_zalloc(sizeof (*dhe), KM_SLEEP);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_version = DMA_ATTR_V0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_addr_lo = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_addr_hi = 0xffffffffffffffff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_count_max = 0x00ffffff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_align = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_burstsizes = 0xfff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_minxfer = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_maxxfer = 0x00ffffff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_seg = 0xffffffff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_sgllen = 5;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_granular = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dma_attr.dma_attr_flags = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rv = ddi_dma_alloc_handle(
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_dip, /* device dev_info */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &ch_dma_attr, /* DMA attributes */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DDI_DMA_SLEEP, /* Wait if no memory */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw NULL, /* no argument */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &ch_dh); /* DMA handle */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (rv != DDI_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: ch_get_dma_handle: ddi_dma_alloc_handle error %d\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name, rv);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmem_free(dhe, sizeof (*dhe));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return ((free_dh_t *)0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dhe->dhe_dh = (ulong_t)ch_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (dhe);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * free the linked list of dma descriptor entries.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic void
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_free_dma_handles(ch_t *chp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw free_dh_t *dhe, *the;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dhe = chp->ch_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw while (dhe) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_free_handle((ddi_dma_handle_t *)&dhe->dhe_dh);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw the = dhe;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dhe = dhe->dhe_next;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmem_free(the, sizeof (*the));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_dh = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_bind_dma_handle()
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * returns # of entries used off of cmdQ_ce_t array to hold physical addrs.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * chp - per-board descriptor
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * size - # bytes mapped
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * vaddr - virtual address
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * cmp - array of cmdQ_ce_t entries
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * cnt - # free entries in cmp array
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwuint32_t
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_bind_dma_handle(ch_t *chp, int size, caddr_t vaddr, cmdQ_ce_t *cmp,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t cnt)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_cookie_t cookie;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_handle_t ch_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint_t count;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t n = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw free_dh_t *dhe;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint_t rv;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if ((dhe = chp->ch_dh) != NULL) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_dh = dhe->dhe_next;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (dhe == NULL) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dh = (ddi_dma_handle_t)dhe->dhe_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rv = ddi_dma_addr_bind_handle(
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dh, /* dma handle */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (struct as *)0, /* kernel address space */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw vaddr, /* virtual address */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw size, /* length of object */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DDI_DMA_WRITE|DDI_DMA_STREAMING,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DDI_DMA_SLEEP, /* Wait for resources */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw NULL, /* no argument */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &cookie, /* dma cookie */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &count);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (rv != DDI_DMA_MAPPED) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* return dma header descriptor back to free list */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dhe->dhe_next = chp->ch_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_dh = dhe;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: ch_bind_dma_handle: ddi_dma_addr_bind_handle err %d\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name, rv);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * abort if we've run out of space
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (count > cnt) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* return dma header descriptor back to free list */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dhe->dhe_next = chp->ch_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_dh = dhe;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_pa = cookie.dmac_laddress;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_dh = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_len = cookie.dmac_size;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_mp = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_flg = DH_DMA;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw while (--count) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp++;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw n++;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_nextcookie(ch_dh, &cookie);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_pa = cookie.dmac_laddress;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_dh = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_len = cookie.dmac_size;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_mp = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_flg = DH_DMA;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_dh = dhe;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (n);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_unbind_dma_handle()
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees resources alloacted by ch_bind_dma_handle().
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees DMA handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwvoid
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_unbind_dma_handle(ch_t *chp, free_dh_t *dhe)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_handle_t ch_dh = (ddi_dma_handle_t)dhe->dhe_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (ddi_dma_unbind_handle(ch_dh))
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN, "%s: ddi_dma_unbind_handle failed",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dhe->dhe_next = chp->ch_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_dh = dhe;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#if defined(__sparc)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * DVMA stuff. Solaris only.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * create a dvma handle and return a dma handle entry.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * DVMA is on sparc only!
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwfree_dh_t *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_get_dvma_handle(ch_t *chp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_handle_t ch_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_lim_t ch_dvma_attr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw free_dh_t *dhe;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int rv;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dhe = (free_dh_t *)kmem_zalloc(sizeof (*dhe), KM_SLEEP);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dvma_attr.dlim_addr_lo = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dvma_attr.dlim_addr_hi = 0xffffffff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dvma_attr.dlim_cntr_max = 0xffffffff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dvma_attr.dlim_burstsizes = 0xfff;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dvma_attr.dlim_minxfer = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dvma_attr.dlim_dmaspeed = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw rv = dvma_reserve(
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_dip, /* device dev_info */
193974072f41a843678abf5f61979c748687e66bSherry Moore &ch_dvma_attr, /* DVMA attributes */
193974072f41a843678abf5f61979c748687e66bSherry Moore 3, /* number of pages */
193974072f41a843678abf5f61979c748687e66bSherry Moore &ch_dh); /* DVMA handle */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (rv != DDI_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: ch_get_dvma_handle: dvma_reserve() error %d\n",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name, rv);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmem_free(dhe, sizeof (*dhe));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return ((free_dh_t *)0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dhe->dhe_dh = (ulong_t)ch_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (dhe);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * free the linked list of dvma descriptor entries.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * DVMA is only on sparc!
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic void
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_free_dvma_handles(ch_t *chp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw free_dh_t *dhe, *the;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dhe = chp->ch_vdh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw while (dhe) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dvma_release((ddi_dma_handle_t)dhe->dhe_dh);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw the = dhe;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dhe = dhe->dhe_next;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmem_free(the, sizeof (*the));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_vdh = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_bind_dvma_handle()
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * returns # of entries used off of cmdQ_ce_t array to hold physical addrs.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * DVMA in sparc only
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * chp - per-board descriptor
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * size - # bytes mapped
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * vaddr - virtual address
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * cmp - array of cmdQ_ce_t entries
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * cnt - # free entries in cmp array
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwuint32_t
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_bind_dvma_handle(ch_t *chp, int size, caddr_t vaddr, cmdQ_ce_t *cmp,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t cnt)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_cookie_t cookie;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_handle_t ch_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t n = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw free_dh_t *dhe;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if ((dhe = chp->ch_vdh) != NULL) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_vdh = dhe->dhe_next;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (dhe == NULL) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_dh = (ddi_dma_handle_t)dhe->dhe_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw n = cnt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dvma_kaddr_load(
193974072f41a843678abf5f61979c748687e66bSherry Moore ch_dh, /* dvma handle */
193974072f41a843678abf5f61979c748687e66bSherry Moore vaddr, /* virtual address */
193974072f41a843678abf5f61979c748687e66bSherry Moore size, /* length of object */
193974072f41a843678abf5f61979c748687e66bSherry Moore 0, /* start at index 0 */
193974072f41a843678abf5f61979c748687e66bSherry Moore &cookie);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dvma_sync(ch_dh, 0, DDI_DMA_SYNC_FORDEV);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cookie.dmac_notused = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw n = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_pa = cookie.dmac_laddress;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_dh = dhe;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_len = cookie.dmac_size;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_mp = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmp->ce_flg = DH_DVMA; /* indicate a dvma descriptor */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (n);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_unbind_dvma_handle()
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees resources alloacted by ch_bind_dvma_handle().
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees DMA handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwvoid
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_unbind_dvma_handle(ch_t *chp, free_dh_t *dhe)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_dma_handle_t ch_dh = (ddi_dma_handle_t)dhe->dhe_dh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dvma_unload(ch_dh, 0, -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dhe->dhe_next = chp->ch_vdh;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_vdh = dhe;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_dh_lck);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif /* defined(__sparc) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * send received packet up stream.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * if driver has been stopped, then we drop the message.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwvoid
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_send_up(ch_t *chp, mblk_t *mp, uint32_t cksum, int flg)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * probably do not need a lock here. When we set PESTOP in
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_stop() a packet could have just passed here and gone
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * upstream. The next one will be dropped.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_state == PERUNNING) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * note that flg will not be set unless enable_checksum_offload
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * set in /etc/system (see sge.c).
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (flg)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (void) hcksum_assoc(mp, NULL, NULL, 0, 0, 0, cksum,
193974072f41a843678abf5f61979c748687e66bSherry Moore HCK_FULLCKSUM, 0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_recv(chp->ch_macp, mp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw freemsg(mp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * unblock gld driver.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwvoid
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_gld_ok(ch_t *chp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_sched(chp->ch_macp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * reset the card.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Note: we only do this after the card has been initialized.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_reset(gld_mac_info_t *mp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_t *chp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (mp == NULL) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp = (ch_t *)mp->gldm_private;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp == NULL) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef NOTYET
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * do a reset of card
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 1. set PwrState to D3hot (3)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 2. clear PwrState flags
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * When we did this, the card didn't start. First guess is that
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * the initialization is not quite correct. For now, we don't
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * reset things.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_hpci) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pci_config_put32(chp->ch_hpci, 0x44, 3);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pci_config_put32(chp->ch_hpci, 0x44, 0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* delay .5 sec */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw DELAY(500000);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_start(gld_mac_info_t *macinfo)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_t *chp = (ch_t *)macinfo->gldm_private;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CONFIG_CHELSIO_T1_OFFLOAD
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* only initialize card on first attempt */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_refcnt++;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_refcnt == 1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_state = PERUNNING;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_init((void *)chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_init((void *)chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* go to running state, we're being started */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_state = PERUNNING;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_stop(gld_mac_info_t *mp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_t *chp = (ch_t *)mp->gldm_private;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * can only stop the chip if it's been initialized
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_state == PEIDLE) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CONFIG_CHELSIO_T1_OFFLOAD
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_refcnt--;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_refcnt == 0) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_state = PESTOP;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_stop(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_state = PESTOP;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_stop(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_set_mac_address(gld_mac_info_t *mp, uint8_t *mac)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_t *chp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (mp) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp = (ch_t *)mp->gldm_private;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_set_mac(chp, mac);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_set_multicast(gld_mac_info_t *mp, uint8_t *ep, int flg)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_t *chp = (ch_t *)mp->gldm_private;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (pe_set_mc(chp, ep, flg));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_ioctl(gld_mac_info_t *macinfo, queue_t *q, mblk_t *mp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw struct iocblk *iocp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw switch (mp->b_datap->db_type) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case M_IOCTL:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* pe_ioctl() does qreply() */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_ioctl((ch_t *)(macinfo->gldm_private), q, mp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw default:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * cmn_err(CE_NOTE, "ch_ioctl not M_IOCTL\n");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * debug_enter("bad ch_ioctl");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw iocp = (struct iocblk *)mp->b_rptr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (mp->b_cont)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw freemsg(mp->b_cont);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mp->b_cont = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mp->b_datap->db_type = M_IOCNAK;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw iocp->ioc_error = EINVAL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw qreply(q, mp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_set_promiscuous(gld_mac_info_t *mp, int flag)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_t *chp = (ch_t *)mp->gldm_private;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw switch (flag) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case GLD_MAC_PROMISC_MULTI:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_set_promiscuous(chp, 2);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case GLD_MAC_PROMISC_NONE:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_set_promiscuous(chp, 0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case GLD_MAC_PROMISC_PHYS:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw default:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_set_promiscuous(chp, 1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_get_stats(gld_mac_info_t *mp, struct gld_stats *gs)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_t *chp = (ch_t *)mp->gldm_private;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint64_t speed;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t intrcnt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t norcvbuf;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t oerrors;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t ierrors;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t underrun;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t overrun;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t framing;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t crc;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t carrier;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t collisions;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t xcollisions;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t late;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t defer;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t xerrs;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t rerrs;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t toolong;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t runt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ulong_t multixmt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ulong_t multircv;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ulong_t brdcstxmt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ulong_t brdcstrcv;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * race looks benign here.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_state != PERUNNING) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (void) pe_get_stats(chp,
193974072f41a843678abf5f61979c748687e66bSherry Moore &speed,
193974072f41a843678abf5f61979c748687e66bSherry Moore &intrcnt,
193974072f41a843678abf5f61979c748687e66bSherry Moore &norcvbuf,
193974072f41a843678abf5f61979c748687e66bSherry Moore &oerrors,
193974072f41a843678abf5f61979c748687e66bSherry Moore &ierrors,
193974072f41a843678abf5f61979c748687e66bSherry Moore &underrun,
193974072f41a843678abf5f61979c748687e66bSherry Moore &overrun,
193974072f41a843678abf5f61979c748687e66bSherry Moore &framing,
193974072f41a843678abf5f61979c748687e66bSherry Moore &crc,
193974072f41a843678abf5f61979c748687e66bSherry Moore &carrier,
193974072f41a843678abf5f61979c748687e66bSherry Moore &collisions,
193974072f41a843678abf5f61979c748687e66bSherry Moore &xcollisions,
193974072f41a843678abf5f61979c748687e66bSherry Moore &late,
193974072f41a843678abf5f61979c748687e66bSherry Moore &defer,
193974072f41a843678abf5f61979c748687e66bSherry Moore &xerrs,
193974072f41a843678abf5f61979c748687e66bSherry Moore &rerrs,
193974072f41a843678abf5f61979c748687e66bSherry Moore &toolong,
193974072f41a843678abf5f61979c748687e66bSherry Moore &runt,
193974072f41a843678abf5f61979c748687e66bSherry Moore &multixmt,
193974072f41a843678abf5f61979c748687e66bSherry Moore &multircv,
193974072f41a843678abf5f61979c748687e66bSherry Moore &brdcstxmt,
193974072f41a843678abf5f61979c748687e66bSherry Moore &brdcstrcv);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_speed = speed;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_media = GLDM_UNKNOWN;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_intr = intrcnt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_norcvbuf = norcvbuf;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_errxmt = oerrors;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_errrcv = ierrors;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_missed = ierrors; /* ??? */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_underflow = underrun;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_overflow = overrun;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_frame = framing;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_crc = crc;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_duplex = GLD_DUPLEX_FULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_nocarrier = carrier;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_collisions = collisions;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_excoll = xcollisions;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_xmtlatecoll = late;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_defer = defer;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_dot3_first_coll = 0; /* Not available */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_dot3_multi_coll = 0; /* Not available */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_dot3_sqe_error = 0; /* Not available */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_dot3_mac_xmt_error = xerrs;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_dot3_mac_rcv_error = rerrs;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_dot3_frame_too_long = toolong;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_short = runt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_noxmtbuf = 0; /* not documented */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_xmtretry = 0; /* not documented */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_multixmt = multixmt; /* not documented */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_multircv = multircv; /* not documented */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_brdcstxmt = brdcstxmt; /* not documented */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gs->glds_brdcstrcv = brdcstrcv; /* not documented */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic int
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_send(gld_mac_info_t *macinfo, mblk_t *mp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_t *chp = (ch_t *)macinfo->gldm_private;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t flg;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t msg_flg;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef TX_CKSUM_FIX
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mblk_t *nmp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int frags;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw size_t msg_len;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw struct ether_header *ehdr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ipha_t *ihdr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int tflg = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif /* TX_CKSUM_FIX */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * race looks benign here.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_state != PERUNNING) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_FAILURE);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw msg_flg = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_config.cksum_enabled) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (is_T2(chp)) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw hcksum_retrieve(mp, NULL, NULL, NULL, NULL, NULL,
193974072f41a843678abf5f61979c748687e66bSherry Moore NULL, &msg_flg);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw flg = (msg_flg & HCK_FULLCKSUM)?
193974072f41a843678abf5f61979c748687e66bSherry Moore CH_NO_CPL: CH_NO_HWCKSUM|CH_NO_CPL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw flg = CH_NO_CPL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw flg = CH_NO_HWCKSUM | CH_NO_CPL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef TX_CKSUM_FIX
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Check if the message spans more than one mblk or
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * if it does and the ip header is not in the first
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * fragment then pull up the message. This case is
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * expected to be rare.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw frags = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw msg_len = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nmp = mp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw do {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw frags++;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw msg_len += MBLKL(nmp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nmp = nmp->b_cont;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } while (nmp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#define MAX_ALL_HDRLEN SZ_CPL_TX_PKT + sizeof (struct ether_header) + \
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw TCP_MAX_COMBINED_HEADER_LENGTH
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * If the first mblk has enough space at the beginning of
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * the data buffer to hold a CPL header, then, we'll expancd
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * the front of the buffer so a pullup will leave space for
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * pe_start() to add the CPL header in line. We need to remember
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * that we've done this so we can undo it after the pullup.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Note that if we decide to do an allocb to hold the CPL header,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * we need to catch the case where we've added an empty mblk for
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * the header but never did a pullup. This would result in the
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * tests for etherheader, etc. being done on the initial, empty,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * mblk instead of the one with data. See PR3646 for further
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * details. (note this PR is closed since it is no longer relevant).
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Another point is that if we do add an allocb to add space for
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * a CPL header, after a pullup, the initial pointer, mp, in GLD will
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * no longer point to a valid mblk. When we get the mblk (by allocb),
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * we need to switch the mblk structure values between it and the
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * mp structure values referenced by GLD. This handles the case where
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * we've run out of cmdQ entries and report GLD_NORESOURCES back to
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * GLD. The pointer to the mblk data will have been modified to hold
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * an empty 8 bytes for the CPL header, For now, we let the pe_start()
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * routine prepend an 8 byte mblk.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (MBLKHEAD(mp) >= SZ_CPL_TX_PKT) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mp->b_rptr -= SZ_CPL_TX_PKT;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw tflg = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (frags > 3) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->sge->intr_cnt.tx_msg_pullups++;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (pullupmsg(mp, -1) == 0) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw freemsg(mp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else if ((msg_len > MAX_ALL_HDRLEN) &&
193974072f41a843678abf5f61979c748687e66bSherry Moore (MBLKL(mp) < MAX_ALL_HDRLEN)) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->sge->intr_cnt.tx_hdr_pullups++;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (pullupmsg(mp, MAX_ALL_HDRLEN) == 0) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw freemsg(mp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (tflg)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mp->b_rptr += SZ_CPL_TX_PKT;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ehdr = (struct ether_header *)mp->b_rptr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (ehdr->ether_type == htons(ETHERTYPE_IP)) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ihdr = (ipha_t *)&mp->b_rptr[sizeof (struct ether_header)];
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if ((ihdr->ipha_fragment_offset_and_flags & IPH_MF)) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (ihdr->ipha_protocol == IPPROTO_UDP) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw flg |= CH_UDP_MF;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->sge->intr_cnt.tx_udp_ip_frag++;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else if (ihdr->ipha_protocol == IPPROTO_TCP) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw flg |= CH_TCP_MF;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->sge->intr_cnt.tx_tcp_ip_frag++;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else if (ihdr->ipha_protocol == IPPROTO_UDP)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw flg |= CH_UDP;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif /* TX_CKSUM_FIX */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * return 0 - data send successfully
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * return 1 - no resources, reschedule
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (pe_start(chp, mp, flg))
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_NORESOURCES);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (GLD_SUCCESS);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic uint_t
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_intr(gld_mac_info_t *mp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (pe_intr((ch_t *)mp->gldm_private));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * generate name of driver with unit# postpended.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwvoid
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_set_name(ch_t *chp, int unit)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_name = (char *)kmem_alloc(sizeof ("chxge00"), KM_SLEEP);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (unit > 9) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw bcopy("chxge00", (void *)chp->ch_name, sizeof ("chxge00"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_name[5] += unit/10;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_name[6] += unit%10;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw bcopy("chxge0", (void *)chp->ch_name, sizeof ("chxge0"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_name[5] += unit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwvoid
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_free_name(ch_t *chp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_name)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmem_free(chp->ch_name, sizeof ("chxge00"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_name = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CONFIG_CHELSIO_T1_OFFLOAD
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * register toe offload.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwvoid *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_register(void *instp, void *toe_rcv, void *toe_free, void *toe_tunnel,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw kmutex_t *toe_tx_mx, kcondvar_t *toe_of_cv, int unit)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_t *chp = gchp[unit];
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp != NULL) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->toe_rcv = (void (*)(void *, mblk_t *))toe_rcv;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_toeinst = instp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->toe_free = (void (*)(void *, tbuf_t *))toe_free;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->toe_tunnel = (int (*)(void *, mblk_t *))toe_tunnel;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_tx_overflow_mutex = toe_tx_mx;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_tx_overflow_cv = toe_of_cv;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->open_device_map |= TOEDEV_DEVMAP_BIT;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* start up adapter if first user */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_refcnt++;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_refcnt == 1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_state = PERUNNING;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_init((void *)chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return ((void *)gchp[unit]);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * unregister toe offload.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * XXX Need to fix races here.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 1. turn off SGE interrupts.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 2. do update
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 3. re-enable SGE interrupts
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 4. SGE doorbell to make sure things get restarted.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwvoid
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_unregister(void)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int i;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_t *chp;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw for (i = 0; i < MAX_CARDS; i++) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp = gchp[i];
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp == NULL)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw continue;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_enter(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_refcnt--;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (chp->ch_refcnt == 0) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_state = PESTOP;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pe_stop(chp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mutex_exit(&chp->ch_lock);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->open_device_map &= ~TOEDEV_DEVMAP_BIT;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->toe_rcv = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_toeinst = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->toe_free = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->toe_tunnel = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_tx_overflow_mutex = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_tx_overflow_cv = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif /* CONFIG_CHELSIO_T1_OFFLOAD */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * get properties from chxge.conf
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic void
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_get_prop(ch_t *chp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int val;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int tval = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw extern int enable_latency_timer;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw extern uint32_t sge_cmdq0_cnt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw extern uint32_t sge_cmdq1_cnt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw extern uint32_t sge_flq0_cnt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw extern uint32_t sge_flq1_cnt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw extern uint32_t sge_respq_cnt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw extern uint32_t sge_cmdq0_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw extern uint32_t sge_cmdq1_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw extern uint32_t sge_flq0_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw extern uint32_t sge_flq1_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw extern uint32_t sge_respq_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw dev_info_t *pdip;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t vendor_id, device_id, revision_id;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t *prop_val = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t prop_len = NULL;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "enable_dvma", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "enable-dvma", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != 0)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.enable_dvma = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "amd_bug_workaround", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "amd-bug-workaround", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == 0) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw goto fail_exit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Step up to the parent node, That's the node above us
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * in the device tree. And will typically be the PCI host
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Controller.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw pdip = ddi_get_parent(chp->ch_dip);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Now get the 'Vendor id' properties
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, pdip, 0, "vendor-id",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (int **)&prop_val, &prop_len) != DDI_PROP_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw goto fail_exit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw vendor_id = *(uint32_t *)prop_val;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_prop_free(prop_val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Now get the 'Device id' properties
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, pdip, 0, "device-id",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (int **)&prop_val, &prop_len) != DDI_PROP_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw goto fail_exit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw device_id = *(uint32_t *)prop_val;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_prop_free(prop_val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Now get the 'Revision id' properties
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, pdip, 0, "revision-id",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (int **)&prop_val, &prop_len) != DDI_PROP_SUCCESS) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw goto fail_exit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw revision_id = *(uint32_t *)prop_val;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_prop_free(prop_val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * set default values based on node above us.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if ((vendor_id == AMD_VENDOR_ID) && (device_id == AMD_BRIDGE) &&
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw (revision_id <= AMD_BRIDGE_REV)) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t v;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t burst;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw uint32_t cnt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* if 133 Mhz not enabled, then do nothing - we're not PCIx */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw v = pci_config_get32(chp->ch_hpci, 0x64);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if ((v & 0x20000) == NULL) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw goto fail_exit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* check burst size and transaction count */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw v = pci_config_get32(chp->ch_hpci, 0x60);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw burst = (v >> 18) & 3;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cnt = (v >> 20) & 7;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw switch (burst) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 0: /* 512 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* 512 burst size legal with split cnts 1,2,3 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (cnt <= 2) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw goto fail_exit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 1: /* 1024 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* 1024 burst size legal with split cnts 1,2 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (cnt <= 1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw goto fail_exit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 2: /* 2048 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* 2048 burst size legal with split cnts 1 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (cnt == 0) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw goto fail_exit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 3: /* 4096 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw goto fail_exit;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * if illegal burst size seen, then default to 1024 burst size
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize_set = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * if illegal transaction cnt seen, then default to 2
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwfail_exit:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * alter the burstsize parameter via an entry
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * in chxge.conf
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "pci_burstsize", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "pci-burstsize", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw switch (val) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 0: /* use default */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 1024:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize_set = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 2048:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize_set = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.burstsize = 2;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 4096:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN, "%s not supported %d\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_name, val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw default:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN, "%s illegal burst size %d\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_name, val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * set transaction count
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "pci_split_transaction_cnt", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "pci-split-transaction-cnt", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw switch (val) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 0: /* use default */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 1:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 2:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 3:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt = 2;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 4:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt = 3;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 8:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt = 4;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 12:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt = 5;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 16:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt = 6;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 32:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt_set = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.transaction_cnt = 7;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw default:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN, "%s illegal transaction cnt %d\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_name, val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw break;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * set relaxed ordering bit?
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "pci_relaxed_ordering_on", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "pci-relaxed-ordering-on", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * default is to use system default value.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.relaxed_ordering = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.relaxed_ordering = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "enable_latency_timer", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "enable-latency-timer", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw enable_latency_timer = (val == 0)? 0: 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * default maximum Jumbo Frame size.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_maximum_mtu = 9198; /* tunable via chxge.conf */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "maximum_mtu", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "maximum-mtu", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val > 9582) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "maximum_mtu value %d > 9582. Value set to 9582",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = 9582;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else if (val < 1500) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "maximum_mtu value %d < 1500. Value set to 1500",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = 1500;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_maximum_mtu = val;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * default value for this instance mtu
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_mtu = ETHERMTU;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "accept_jumbo", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "accept-jumbo", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_mtu = chp->ch_maximum_mtu;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifdef CONFIG_CHELSIO_T1_OFFLOAD
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_sm_buf_sz = 0x800;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_sm_buf_aln = 0x800;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_bg_buf_sz = 0x4000;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_bg_buf_aln = 0x4000;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#else
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_sm_buf_sz = 0x200;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_sm_buf_aln = 0x200;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_bg_buf_sz = 0x800;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_bg_buf_aln = 0x800;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if ((chp->ch_mtu > 0x800) && (chp->ch_mtu <= 0x1000)) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_sm_buf_sz = 0x400;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_sm_buf_aln = 0x400;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_bg_buf_sz = 0x1000;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_bg_buf_aln = 0x1000;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else if ((chp->ch_mtu > 0x1000) && (chp->ch_mtu <= 0x2000)) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_sm_buf_sz = 0x400;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_sm_buf_aln = 0x400;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_bg_buf_sz = 0x2000;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_bg_buf_aln = 0x2000;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else if (chp->ch_mtu > 0x2000) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_sm_buf_sz = 0x400;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_sm_buf_aln = 0x400;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_bg_buf_sz = 0x3000;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_bg_buf_aln = 0x4000;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.cksum_enabled = 1;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "enable_checksum_offload", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "enable-checksum-offload", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == NULL)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_config.cksum_enabled = 0;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Provides a tuning capability for the command queue 0 size.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "sge_cmdq0_cnt", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "sge-cmdq0-cnt", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val > 10)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_cmdq0_cnt = val;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (sge_cmdq0_cnt > 65535) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: sge-cmdQ0-cnt > 65535 - resetting value to default",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_cmdq0_cnt = sge_cmdq0_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw tval += sge_cmdq0_cnt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Provides a tuning capability for the command queue 1 size.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "sge_cmdq1_cnt", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "sge-cmdq1-cnt", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val > 10)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_cmdq1_cnt = val;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (sge_cmdq1_cnt > 65535) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: sge-cmdQ0-cnt > 65535 - resetting value to default",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_cmdq1_cnt = sge_cmdq1_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Provides a tuning capability for the free list 0 size.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "sge_flq0_cnt", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "sge-flq0-cnt", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val > 512)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_flq0_cnt = val;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (sge_flq0_cnt > 65535) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: sge-flq0-cnt > 65535 - resetting value to default",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_flq0_cnt = sge_flq0_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw tval += sge_flq0_cnt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Provides a tuning capability for the free list 1 size.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "sge_flq1_cnt", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "sge-flq1-cnt", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val > 512)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_flq1_cnt = val;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (sge_flq1_cnt > 65535) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: sge-flq1-cnt > 65535 - resetting value to default",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_flq1_cnt = sge_flq1_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw tval += sge_flq1_cnt;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Provides a tuning capability for the responce queue size.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "sge_respq_cnt", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == -1)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
193974072f41a843678abf5f61979c748687e66bSherry Moore "sge-respq-cnt", -1);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val != -1) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val > 30)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_respq_cnt = val;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (sge_respq_cnt > 65535) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: sge-respq-cnt > 65535 - resetting value to default",
193974072f41a843678abf5f61979c748687e66bSherry Moore chp->ch_name);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_respq_cnt = sge_respq_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (tval > sge_respq_cnt) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (tval <= 65535) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: sge-respq-cnt < %d - setting value to %d (cmdQ+flq0+flq1)",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_name, tval, tval);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_respq_cnt = tval;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: Q sizes invalid - resetting to default values",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_name);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_cmdq0_cnt = sge_cmdq0_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_cmdq1_cnt = sge_cmdq1_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_flq0_cnt = sge_flq0_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_flq1_cnt = sge_flq1_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw sge_respq_cnt = sge_respq_cnt_orig;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}