d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * See the License for the specific language governing permissions
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * and limitations under the License.
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 * CDDL HEADER END
193974072f41a843678abf5f61979c748687e66bSherry Moore * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Use is subject to license terms.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * This file is part of the Chelsio T1 Ethernet driver.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Copyright (C) 2003-2005 Chelsio Communications. All rights reserved.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Solaris Multithreaded STREAMS DLPI Chelsio PCI Ethernet Driver
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/* #define CH_DEBUG 1 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Function prototypes.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#if defined(__sparc)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/* GLD interfaces */
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_get_stats(gld_mac_info_t *, struct gld_stats *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Data access requirements.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * No swap mapping device attributes
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * STREAMS driver identification struture module_info(9s)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * driver limit values
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * STREAMS queue processiong procedures qinit(9s)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * read queue procedures
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * STREAMS queue processiong procedures qinit(9s)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * write queue procedures
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * STREAMS entity declaration structure - streamtab(9s)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Device driver ops vector - cb_ops(9s)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * charater/block entry points structure.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * chinfo identifies driver as a STREAMS driver.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ddi_prop_op, /* report driver property information - prop_op(9e) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#if defined(__sparc)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * dev_ops(9S) structure
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Device Operations table, for autoconfiguration
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw 0, /* Initial driver reference count */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw gld_getinfo, /* funcp: get driver information - getinfo(9e) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw nulldev, /* funcp: entry point obsolute - identify(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) */
193974072f41a843678abf5f61979c748687e66bSherry Moore NULL, /* funp: change device power level - power(9e) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * modldrv(9s) structure
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Definition for module specific device driver linkage structures (modctl.h)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * modlinkage(9s) structure
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * module linkage base structure (modctl.h)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw &modldrv, /* NULL terminated list of linkage strucures */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/* ===================== start of STREAMS driver code ================== */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * global pointer to toe per-driver control structure.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Ethernet broadcast address definition.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Module initialization functions.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Routine Called by
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * _init(9E) modload(9F)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * _info(9E) modinfo(9F)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * _fini(9E) modunload(9F)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * _init(9E):
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Initial, one-time, resource allocation and data initialization.
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 for (i = 0; i < SZ_INUSE; i++)
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 * 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 * 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 /* Solaris TOE support */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * map in PCI register spaces
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * PCI register set 0 - PCI configuration space
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * PCI register set 1 - T101 card register space #1
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* map in T101 PCI configuration space */
193974072f41a843678abf5f61979c748687e66bSherry Moore &chp->ch_hpci); /* ptr to data access handle */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * do a power reset of card
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 1. set PwrState to D3hot (3)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 2. clear PwrState flags
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* delay .5 sec */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PRINT(("IDs: %x,%x,%x\n", VendorID, DeviceID, SubDeviceID));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* map in T101 register space (BAR0) */
193974072f41a843678abf5f61979c748687e66bSherry Moore 0, /* offset into register address space */
193974072f41a843678abf5f61979c748687e66bSherry Moore 0, /* length mapped (everything) */
193974072f41a843678abf5f61979c748687e66bSherry Moore &chp->ch_hbar0); /* ptr to data access handle */
193974072f41a843678abf5f61979c748687e66bSherry Moore "%s: ddi_regs_map_setup BAR0 error %d\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Add interrupt to system.
193974072f41a843678abf5f61979c748687e66bSherry Moore 0, /* interrupt # (0) */
193974072f41a843678abf5f61979c748687e66bSherry Moore &chp->ch_icookp); /* ptr to interrupt block cookie */
193974072f41a843678abf5f61979c748687e66bSherry Moore "%s: ddi_get_iblock_cookie error %d\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * add interrupt handler before card setup.
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 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* initalize all the remaining per-card locks */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* ------- initialize Chelsio card ------- */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* ------- done with Chelsio card ------- */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* now can set mac address */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * We only active checksum offload for T2 architectures.
193974072f41a843678abf5f61979c748687e66bSherry Moore (char *)ddi_driver_name(dip), /* driver name */
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.
193974072f41a843678abf5f61979c748687e66bSherry Moore (char *)ddi_driver_name(dip), /* driver name */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * print a banner at boot time (verbose mode), announcing
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * the device pointed to by dip
193974072f41a843678abf5f61979c748687e66bSherry Moore * quiesce(9E) entry point.
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 * 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 /* Set driver state for this card to IDLE */
193974072f41a843678abf5f61979c748687e66bSherry Moore * Do a power reset of card
193974072f41a843678abf5f61979c748687e66bSherry Moore * 1. set PwrState to D3hot (3)
193974072f41a843678abf5f61979c748687e66bSherry Moore * 2. clear PwrState flags
193974072f41a843678abf5f61979c748687e66bSherry Moore /* Wait 0.5 sec */
193974072f41a843678abf5f61979c748687e66bSherry Moore * Now stop the chip
193974072f41a843678abf5f61979c748687e66bSherry Moore /* Disables all interrupts */
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);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * fail detach if there are outstanding mblks still
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * in use somewhere.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * set driver state for this card to IDLE. We're
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * shutting down.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * do a power reset of card
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 1. set PwrState to D3hot (3)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 2. clear PwrState flags
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* delay .5 sec */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* free register resources */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* make sure no interrupts while shutting down card */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * reset device and recover resources
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#if defined(__sparc)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else if ((cmd == DDI_SUSPEND) || (cmd == DDI_PM_SUSPEND)) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* Un-initialize (STOP) T101 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_alloc_dma_mem
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * allocates DMA handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * allocates kernel memory
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * allocates DMA access handle
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
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_alloc_dma_mem(ch_t *chp, int type, int flags, int size, uint64_t *paddr,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw mapping = (flags&DMA_STREAM)?DDI_DMA_STREAMING:DDI_DMA_CONSISTENT;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cmn_err(CE_WARN, "ch_alloc_dma_mem(%s): bad alignment flag\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * dynamically create a dma attribute structure
193974072f41a843678abf5f61979c748687e66bSherry Moore "%s: ch_alloc_dma_mem: ddi_dma_alloc_handle error %d\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* set byte order for data xfer */
193974072f41a843678abf5f61979c748687e66bSherry Moore "%s: ch_alloc_dma_mem: ddi_dma_mem_alloc error %d\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: ch_alloc_dma_mem: ddi_dma_addr_bind_handle error %d\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: ch_alloc_dma_mem: ch_alloc_dma_mem cookie count %d\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return ((void *)ch_vaddr);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_free_dma_mem
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees resources allocated by ch_alloc_dma_mem()
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees DMA handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees kernel memory
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees DMA access handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * create a dma handle and return a dma handle entry.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: ch_get_dma_handle: ddi_dma_alloc_handle error %d\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return ((free_dh_t *)0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * free the linked list of dma descriptor entries.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic void
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_bind_dma_handle()
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * returns # of entries used off of cmdQ_ce_t array to hold physical addrs.
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
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_bind_dma_handle(ch_t *chp, int size, caddr_t vaddr, cmdQ_ce_t *cmp,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* return dma header descriptor back to free list */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: ch_bind_dma_handle: ddi_dma_addr_bind_handle err %d\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * abort if we've run out of space
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* return dma header descriptor back to free list */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw while (--count) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (n);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_unbind_dma_handle()
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees resources alloacted by ch_bind_dma_handle().
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees DMA handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#if defined(__sparc)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * DVMA stuff. Solaris only.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * create a dvma handle and return a dma handle entry.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * DVMA is on sparc only!
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: ch_get_dvma_handle: dvma_reserve() error %d\n",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return ((free_dh_t *)0);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * free the linked list of dvma descriptor entries.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * DVMA is only on sparc!
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic void
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_bind_dvma_handle()
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * returns # of entries used off of cmdQ_ce_t array to hold physical addrs.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * DVMA in sparc only
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
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_bind_dvma_handle(ch_t *chp, int size, caddr_t vaddr, cmdQ_ce_t *cmp,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (0);
193974072f41a843678abf5f61979c748687e66bSherry Moore 0, /* start at index 0 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return (n);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ch_unbind_dvma_handle()
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees resources alloacted by ch_bind_dvma_handle().
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * frees DMA handle
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif /* defined(__sparc) */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * send received packet up stream.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * if driver has been stopped, then we drop the message.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_send_up(ch_t *chp, mblk_t *mp, uint32_t cksum, int flg)
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 * note that flg will not be set unless enable_checksum_offload
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * set in /etc/system (see sge.c).
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * unblock gld driver.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * reset the card.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Note: we only do this after the card has been initialized.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * do a reset of card
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 1. set PwrState to D3hot (3)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * 2. clear PwrState flags
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 /* delay .5 sec */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* only initialize card on first attempt */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* go to running state, we're being started */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * can only stop the chip if it's been initialized
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_set_multicast(gld_mac_info_t *mp, uint8_t *ep, int flg)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* pe_ioctl() does qreply() */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * cmn_err(CE_NOTE, "ch_ioctl not M_IOCTL\n");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * debug_enter("bad ch_ioctl");
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw switch (flag) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * race looks benign here.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif /* TX_CKSUM_FIX */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * race looks benign here.
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 } while (nmp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#define MAX_ALL_HDRLEN SZ_CPL_TX_PKT + sizeof (struct ether_header) + \
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 * 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 * 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 ihdr = (ipha_t *)&mp->b_rptr[sizeof (struct ether_header)];
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif /* TX_CKSUM_FIX */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * return 0 - data send successfully
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * return 1 - no resources, reschedule
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * generate name of driver with unit# postpended.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw chp->ch_name = (char *)kmem_alloc(sizeof ("chxge00"), KM_SLEEP);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw bcopy("chxge00", (void *)chp->ch_name, sizeof ("chxge00"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw bcopy("chxge0", (void *)chp->ch_name, sizeof ("chxge0"));
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * register toe offload.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwch_register(void *instp, void *toe_rcv, void *toe_free, void *toe_tunnel,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* start up adapter if first user */
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 for (i = 0; i < MAX_CARDS; i++) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif /* CONFIG_CHELSIO_T1_OFFLOAD */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * get properties from chxge.conf
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic void
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (val == 0) {
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 * Now get the 'Vendor id' properties
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, pdip, 0, "vendor-id",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Now get the 'Device id' properties
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, pdip, 0, "device-id",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Now get the 'Revision id' properties
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, pdip, 0, "revision-id",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * set default values based on node above us.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if ((vendor_id == AMD_VENDOR_ID) && (device_id == AMD_BRIDGE) &&
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* if 133 Mhz not enabled, then do nothing - we're not PCIx */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* check burst size and transaction count */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw switch (burst) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 0: /* 512 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* 512 burst size legal with split cnts 1,2,3 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* 1024 burst size legal with split cnts 1,2 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* 2048 burst size legal with split cnts 1 */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (cnt == 0) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * if illegal burst size seen, then default to 1024 burst size
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * if illegal transaction cnt seen, then default to 2
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * alter the burstsize parameter via an entry
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw switch (val) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 0: /* use default */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 1024:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 2048:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 4096:
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * set transaction count
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw switch (val) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw case 0: /* use default */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * set relaxed ordering bit?
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * default is to use system default value.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * default maximum Jumbo Frame size.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "maximum_mtu value %d > 9582. Value set to 9582",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "maximum_mtu value %d < 1500. Value set to 1500",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * default value for this instance mtu
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw } else if ((chp->ch_mtu > 0x1000) && (chp->ch_mtu <= 0x2000)) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Provides a tuning capability for the command queue 0 size.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: sge-cmdQ0-cnt > 65535 - resetting value to default",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Provides a tuning capability for the command queue 1 size.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: sge-cmdQ0-cnt > 65535 - resetting value to default",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Provides a tuning capability for the free list 0 size.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: sge-flq0-cnt > 65535 - resetting value to default",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Provides a tuning capability for the free list 1 size.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: sge-flq1-cnt > 65535 - resetting value to default",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Provides a tuning capability for the responce queue size.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: sge-respq-cnt > 65535 - resetting value to default",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: sge-respq-cnt < %d - setting value to %d (cmdQ+flq0+flq1)",
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw "%s: Q sizes invalid - resetting to default values",