4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * CDDL HEADER START
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * The contents of this file are subject to the terms of the
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * Common Development and Distribution License (the "License").
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * You may not use this file except in compliance with the License.
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * or http://www.opensolaris.org/os/licensing.
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * See the License for the specific language governing permissions
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * and limitations under the License.
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * When distributing Covered Code, include this CDDL HEADER in each
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * If applicable, add the following below this CDDL HEADER, with the
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * fields enclosed by brackets "[]" replaced with your own identifying
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * information: Portions Copyright [yyyy] [name of copyright owner]
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * CDDL HEADER END
3abb112f8485b33b6b9b52b340bede0a333c10bfGarrett D'Amore/* Copyright © 2003-2011 Emulex. All rights reserved. */
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * Header file defining the driver buffer management interface
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define GET_Q_NEXT(_START, _STEP, _END) \
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan (((_START) + (_STEP)) < (_END) ? ((_START) + (_STEP)) \
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define OCE_TX_MAX_FRAGS (OCE_MAX_TX_HDL * OCE_MAX_TXDMA_COOKIES)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan/* helper structure to access OS addresses */
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan /* size of the memory */
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define DBUF_PA(obj) (((oce_dma_buf_t *)(obj))->addr)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define DBUF_VA(obj) (((oce_dma_buf_t *)(obj))->base)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define DBUF_DHDL(obj) (((oce_dma_buf_t *)(obj))->dma_handle)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define DBUF_AHDL(obj) (((oce_dma_buf_t *)obj))->acc_handle)
5b9d3151a4426af9ad6ef2c2a178f13476b884b3Sukumar Swaminathan#define DBUF_SYNC(obj, flags) (void) ddi_dma_sync(DBUF_DHDL(obj), 0,\
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan struct oce_nic_frag_wqe frag[OCE_TX_MAX_FRAGS];
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan/* Always keep it 2 mod 4 */
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan /* ether_vlan_header_t vhdr; */
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define RING_NUM_PENDING(ring) ring->num_used
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan (uint32_t)(ring->num_items - ring->num_used)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define RING_FULL(ring) (ring->num_used == ring->num_items)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define RING_EMPTY(ring) (ring->num_used == 0)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan ring->cidx = GET_Q_NEXT(ring->cidx, n, ring->num_items)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan ring->pidx = GET_Q_NEXT(ring->pidx, n, ring->num_items)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define RING_GET_CONSUMER_ITEM_VA(ring, type) \
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan (void*)(((type *)DBUF_VA(ring->dbuf)) + ring->cidx)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define RING_GET_CONSUMER_ITEM_PA(ring, type) \
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan (uint64_t)(((type *)DBUF_PA(ring->dbuf)) + ring->cidx)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define RING_GET_PRODUCER_ITEM_VA(ring, type) \
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan (void *)(((type *)DBUF_VA(ring->dbuf)) + ring->pidx)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#define RING_GET_PRODUCER_ITEM_PA(ring, type) \
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan (uint64_t)(((type *)DBUF_PA(ring->dbuf)) + ring->pidx)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanint oce_rqb_cache_create(struct oce_rq *rq, size_t buf_size);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanvoid oce_rqb_cache_destroy(struct oce_rq *rq);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanint oce_wqe_desc_ctor(void *buf, void *arg, int kmflags);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanvoid oce_wqe_desc_dtor(void *buf, void *arg);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanint oce_wqb_cache_create(struct oce_wq *wq, size_t buf_size);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanvoid oce_wqb_cache_destroy(struct oce_wq *wq);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanvoid oce_wqm_cache_destroy(struct oce_wq *wq);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanint oce_wqm_cache_create(struct oce_wq *wq);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan struct phys_addr *pa_list, int list_size);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan#endif /* _OCE_BUF_H_ */