16349Sqs148142 /* 26349Sqs148142 * CDDL HEADER START 36349Sqs148142 * 46349Sqs148142 * The contents of this file are subject to the terms of the 56349Sqs148142 * Common Development and Distribution License (the "License"). 66349Sqs148142 * You may not use this file except in compliance with the License. 76349Sqs148142 * 86349Sqs148142 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 96349Sqs148142 * or http://www.opensolaris.org/os/licensing. 106349Sqs148142 * See the License for the specific language governing permissions 116349Sqs148142 * and limitations under the License. 126349Sqs148142 * 136349Sqs148142 * When distributing Covered Code, include this CDDL HEADER in each 146349Sqs148142 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 156349Sqs148142 * If applicable, add the following below this CDDL HEADER, with the 166349Sqs148142 * fields enclosed by brackets "[]" replaced with your own identifying 176349Sqs148142 * information: Portions Copyright [yyyy] [name of copyright owner] 186349Sqs148142 * 196349Sqs148142 * CDDL HEADER END 206349Sqs148142 */ 216349Sqs148142 /* 226349Sqs148142 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 236349Sqs148142 * Use is subject to license terms. 246349Sqs148142 */ 256349Sqs148142 266349Sqs148142 #ifndef _HPI_TXDMA_H 276349Sqs148142 #define _HPI_TXDMA_H 286349Sqs148142 296349Sqs148142 #pragma ident "%Z%%M% %I% %E% SMI" 306349Sqs148142 316349Sqs148142 #ifdef __cplusplus 326349Sqs148142 extern "C" { 336349Sqs148142 #endif 346349Sqs148142 356349Sqs148142 #include <hpi.h> 366349Sqs148142 #include <hxge_txdma_hw.h> 376349Sqs148142 #include <hxge_tdc_hw.h> 386349Sqs148142 396349Sqs148142 typedef enum _txdma_cs_cntl_e { 406349Sqs148142 TXDMA_INIT_RESET = 0x1, 416349Sqs148142 TXDMA_INIT_START = 0x2, 426349Sqs148142 TXDMA_START = 0x3, 436349Sqs148142 TXDMA_RESET = 0x4, 446349Sqs148142 TXDMA_STOP = 0x5, 456349Sqs148142 TXDMA_MBOX_ENABLE = 0x6 466349Sqs148142 } txdma_cs_cntl_t; 476349Sqs148142 486349Sqs148142 #define HXGE_TXDMA_OFFSET(x, v, channel) (x + \ 496349Sqs148142 (!v ? DMC_OFFSET(channel) : TDMC_PIOVADDR_OFFSET(channel))) 506349Sqs148142 /* 516349Sqs148142 * PIO macros to read and write the transmit registers. 526349Sqs148142 */ 536349Sqs148142 #define TXDMA_REG_READ64(handle, reg, channel, val_p) \ 546349Sqs148142 HXGE_REG_RD64(handle, \ 556349Sqs148142 (HXGE_TXDMA_OFFSET(reg, handle.is_vraddr, channel)), val_p) 566349Sqs148142 576349Sqs148142 #define TXDMA_REG_WRITE64(handle, reg, channel, data) \ 586349Sqs148142 HXGE_REG_WR64(handle, \ 596349Sqs148142 HXGE_TXDMA_OFFSET(reg, handle.is_vraddr, channel), data) 606349Sqs148142 616349Sqs148142 #define HPI_TXDMA_GATHER_INDEX(index) \ 626349Sqs148142 ((index <= TX_MAX_GATHER_POINTERS)) ? HPI_SUCCESS : \ 636349Sqs148142 (HPI_TXDMA_GATHER_INVALID) 646349Sqs148142 656349Sqs148142 /* 666349Sqs148142 * Transmit HPI error codes 676349Sqs148142 */ 686349Sqs148142 #define TXDMA_ER_ST (TXDMA_BLK_ID << HPI_BLOCK_ID_SHIFT) 696349Sqs148142 #define TXDMA_ID_SHIFT(n) (n << HPI_PORT_CHAN_SHIFT) 706349Sqs148142 716349Sqs148142 #define TXDMA_HW_STOP_FAILED (HPI_BK_HW_ER_START | 0x1) 726349Sqs148142 #define TXDMA_HW_RESUME_FAILED (HPI_BK_HW_ER_START | 0x2) 736349Sqs148142 746349Sqs148142 #define TXDMA_GATHER_INVALID (HPI_BK_ERROR_START | 0x1) 756349Sqs148142 #define TXDMA_XFER_LEN_INVALID (HPI_BK_ERROR_START | 0x2) 766349Sqs148142 776349Sqs148142 #define HPI_TXDMA_OPCODE_INVALID(n) (TXDMA_ID_SHIFT(n) | \ 786349Sqs148142 TXDMA_ER_ST | OPCODE_INVALID) 796349Sqs148142 806349Sqs148142 #define HPI_TXDMA_FUNC_INVALID(n) (TXDMA_ID_SHIFT(n) | \ 816349Sqs148142 TXDMA_ER_ST | PORT_INVALID) 826349Sqs148142 #define HPI_TXDMA_CHANNEL_INVALID(n) (TXDMA_ID_SHIFT(n) | \ 836349Sqs148142 TXDMA_ER_ST | CHANNEL_INVALID) 846349Sqs148142 856349Sqs148142 #define HPI_TXDMA_PAGE_INVALID(n) (TXDMA_ID_SHIFT(n) | \ 866349Sqs148142 TXDMA_ER_ST | LOGICAL_PAGE_INVALID) 876349Sqs148142 886349Sqs148142 #define HPI_TXDMA_REGISTER_INVALID (TXDMA_ER_ST | REGISTER_INVALID) 896349Sqs148142 #define HPI_TXDMA_COUNTER_INVALID (TXDMA_ER_ST | COUNTER_INVALID) 906349Sqs148142 #define HPI_TXDMA_CONFIG_INVALID (TXDMA_ER_ST | CONFIG_INVALID) 916349Sqs148142 926349Sqs148142 936349Sqs148142 #define HPI_TXDMA_GATHER_INVALID (TXDMA_ER_ST | TXDMA_GATHER_INVALID) 946349Sqs148142 #define HPI_TXDMA_XFER_LEN_INVALID (TXDMA_ER_ST | TXDMA_XFER_LEN_INVALID) 956349Sqs148142 966349Sqs148142 #define HPI_TXDMA_RESET_FAILED (TXDMA_ER_ST | RESET_FAILED) 976349Sqs148142 #define HPI_TXDMA_STOP_FAILED (TXDMA_ER_ST | TXDMA_HW_STOP_FAILED) 986349Sqs148142 #define HPI_TXDMA_RESUME_FAILED (TXDMA_ER_ST | TXDMA_HW_RESUME_FAILED) 996349Sqs148142 1006349Sqs148142 /* 1016349Sqs148142 * Transmit DMA Channel HPI Prototypes. 1026349Sqs148142 */ 1036349Sqs148142 hpi_status_t hpi_txdma_log_page_handle_set(hpi_handle_t handle, 1046349Sqs148142 uint8_t channel, tdc_page_handle_t *hdl_p); 1056349Sqs148142 hpi_status_t hpi_txdma_channel_reset(hpi_handle_t handle, uint8_t channel); 1066349Sqs148142 hpi_status_t hpi_txdma_channel_init_enable(hpi_handle_t handle, 1076349Sqs148142 uint8_t channel); 1086349Sqs148142 hpi_status_t hpi_txdma_channel_enable(hpi_handle_t handle, uint8_t channel); 1096349Sqs148142 hpi_status_t hpi_txdma_channel_disable(hpi_handle_t handle, uint8_t channel); 1106349Sqs148142 hpi_status_t hpi_txdma_channel_mbox_enable(hpi_handle_t handle, 1116349Sqs148142 uint8_t channel); 1126349Sqs148142 hpi_status_t hpi_txdma_channel_control(hpi_handle_t handle, 1136349Sqs148142 txdma_cs_cntl_t control, uint8_t channel); 1146349Sqs148142 hpi_status_t hpi_txdma_control_status(hpi_handle_t handle, io_op_t op_mode, 1156349Sqs148142 uint8_t channel, tdc_stat_t *cs_p); 1166349Sqs148142 1176349Sqs148142 hpi_status_t hpi_txdma_event_mask(hpi_handle_t handle, io_op_t op_mode, 1186349Sqs148142 uint8_t channel, tdc_int_mask_t *mask_p); 1196349Sqs148142 1206349Sqs148142 hpi_status_t hpi_txdma_ring_config(hpi_handle_t handle, io_op_t op_mode, 1216349Sqs148142 uint8_t channel, uint64_t *reg_data); 1226349Sqs148142 hpi_status_t hpi_txdma_mbox_config(hpi_handle_t handle, io_op_t op_mode, 1236349Sqs148142 uint8_t channel, uint64_t *mbox_addr); 1246349Sqs148142 hpi_status_t hpi_txdma_desc_gather_set(hpi_handle_t handle, 1256349Sqs148142 p_tx_desc_t desc_p, uint8_t gather_index, 1266349Sqs148142 boolean_t mark, uint8_t ngathers, 1276349Sqs148142 uint64_t dma_ioaddr, uint32_t transfer_len); 128*6864Sqs148142 hpi_status_t hpi_txdma_control_stop_wait(hpi_handle_t handle, 129*6864Sqs148142 uint8_t channel); 1306349Sqs148142 1316349Sqs148142 hpi_status_t hpi_txdma_desc_set_xfer_len(hpi_handle_t handle, 1326349Sqs148142 p_tx_desc_t desc_p, uint32_t transfer_len); 1336349Sqs148142 1346349Sqs148142 hpi_status_t hpi_txdma_desc_set_zero(hpi_handle_t handle, uint16_t entries); 1356349Sqs148142 hpi_status_t hpi_txdma_ring_head_get(hpi_handle_t handle, uint8_t channel, 1366349Sqs148142 tdc_tdr_head_t *hdl_p); 1376349Sqs148142 void hpi_txdma_dump_desc_one(hpi_handle_t handle, p_tx_desc_t desc_p, 1386349Sqs148142 int desc_index); 1396349Sqs148142 1406349Sqs148142 #ifdef __cplusplus 1416349Sqs148142 } 1426349Sqs148142 #endif 1436349Sqs148142 1446349Sqs148142 #endif /* _HPI_TXDMA_H */ 145