f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * sfe_util.h: header to support the gem layer used by Masa Murayama
23d366e350386ec109bfa9b2cf91225729a1a26bduboff * Copyright (c) 2002-2008 Masayuki Murayama. All rights reserved.
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * Redistribution and use in source and binary forms, with or without
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * modification, are permitted provided that the following conditions are met:
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * 1. Redistributions of source code must retain the above copyright notice,
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * this list of conditions and the following disclaimer.
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * 2. Redistributions in binary form must reproduce the above copyright notice,
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * this list of conditions and the following disclaimer in the documentation
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * and/or other materials provided with the distribution.
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * 3. Neither the name of the author nor the names of its contributors may be
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * used to endorse or promote products derived from this software without
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * specific prior written permission.
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Use is subject to license terms.
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * Useful macros and typedefs
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff#define GEM_TX_TIMEOUT_INTERVAL (drv_usectohz(1*1000000))
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff#define GEM_LINK_WATCH_INTERVAL (drv_usectohz(1*1000000)) /* 1 sec */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff/* general return code */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff/* return code of gem_tx_done */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * I/O instructions
915ebf8da9f4ef3e7b2e34dd367f64d358a628d9Alan Duboff (void *)((caddr_t)((dp)->base_addr) + (p)), v); \
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff/* TX buffer management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* pointer to original mblk */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* dma mapping for current packet */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* bounce buffer management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* timeout management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* Hardware descriptor info */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff/* RX buffer management */
23d366e350386ec109bfa9b2cf91225729a1a26bduboff /* Hardware independent section */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* dma mapping management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* bounce buffer management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff#define GEM_MCALLOC (sizeof (struct mcast_addr) * GEM_MAXMC)
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff#define SLOT(seqnum, size) (((unsigned int)(seqnum)) & ((size)-1))
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * mac soft state
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* MAC address information */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* Descriptor rings, io area */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* caddr_t rx_buf; */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* RX slot ring management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* Rx buffer management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* TX descriptor ring management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* TX buffur ring management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* TX buffer resource management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* TX state management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* NIC state */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff volatile boolean_t mac_active; /* tx and rx are running */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* robustness: timer and watchdog */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* MII management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* multcast list management */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff#define RXMODE_ALLMULTI (RXMODE_ALLMULTI_REQ | RXMODE_MULTI_OVF)
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff "\004ENABLE" \
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff "\003MULTI_OVF" \
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff "\002ALLMULTI_REQ" \
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff "\001PROMISC"
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* statistcs */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* pointer to local structure */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* polling mode */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* descriptor area */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* configuration */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* specification on tx and rx dma engine */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* memory mapping attributes */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* dma attributes */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* tx time out parameters */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* auto negotiation capability */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* MII mode */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* MII link state watch parameters */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* MII configuration */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* I/O methods */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* mac operation */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff uint32_t (*gc_multicast_hash)(struct gem_dev *dp, uint8_t *);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* descriptor operation */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff int (*gc_tx_desc_write)(struct gem_dev *dp, int slot,
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff void (*gc_tx_start) (struct gem_dev *dp, int slot, int frags);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff void (*gc_rx_desc_write)(struct gem_dev *dp, int slot,
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff void (*gc_rx_start)(struct gem_dev *dp, int slot, int frags);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff void (*gc_tx_desc_init)(struct gem_dev *dp, int slot);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff void (*gc_rx_desc_init)(struct gem_dev *dp, int slot);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff void (*gc_tx_desc_clean)(struct gem_dev *dp, int slot);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff void (*gc_rx_desc_clean)(struct gem_dev *dp, int slot);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* mii operations */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff uint16_t (*gc_mii_read)(struct gem_dev *dp, uint_t reg);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* packet in/out operation for copy-style */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* hw checksum */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* performance tuning parameters */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* kstat stuff */
23d366e350386ec109bfa9b2cf91225729a1a26bduboff /* multiple port device support */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff struct gem_dev *next; /* pointer to next port on the same device */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff /* ndd stuff */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff * Exported functions
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboffvoid gem_mii_write(struct gem_dev *, uint_t, uint16_t);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboffint gem_restart_nic(struct gem_dev *dp, uint_t flags);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff struct gem_conf *, void *, ddi_acc_handle_t *, void *, int);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboffmblk_t *gem_send_common(struct gem_dev *, mblk_t *, uint32_t);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff#define GEM_SEND_CTRL 0x000000ff /* private flags for control packets */
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboffmblk_t *gem_get_packet_default(struct gem_dev *, struct rxbuf *, size_t);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboffuint32_t gem_ether_crc_le(const uint8_t *addr, int len);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboffuint32_t gem_ether_crc_be(const uint8_t *addr, int len);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboffvoid gem_rx_desc_dma_sync(struct gem_dev *, int, int, int);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboffvoid gem_tx_desc_dma_sync(struct gem_dev *, int, int, int);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboffuint8_t gem_search_pci_cap(dev_info_t *dip, ddi_acc_handle_t, uint8_t);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboffint gem_pci_set_power_state(dev_info_t *, ddi_acc_handle_t, uint_t);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboffint gem_pci_regs_map_setup(dev_info_t *, uint32_t, uint32_t,
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff struct ddi_device_acc_attr *, caddr_t *, ddi_acc_handle_t *);
f8919bdadda3ebb97bd55cc14a16e0271ed57615duboff#endif /* _SFE_UTIL_H_ */