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_RXDMA_H 276349Sqs148142 #define _HPI_RXDMA_H 286349Sqs148142 296349Sqs148142 #ifdef __cplusplus 306349Sqs148142 extern "C" { 316349Sqs148142 #endif 326349Sqs148142 336349Sqs148142 #include <hpi.h> 346349Sqs148142 #include <hxge_defs.h> 356349Sqs148142 #include <hxge_pfc.h> 366349Sqs148142 #include <hxge_pfc_hw.h> 376349Sqs148142 #include <hxge_rdc_hw.h> 386349Sqs148142 396349Sqs148142 #define RXDMA_CFIG2_MBADDR_L_SHIFT 6 /* bit 31:6 */ 406349Sqs148142 #define RXDMA_CFIG2_MBADDR_L_MASK 0x00000000ffffffc0ULL 416349Sqs148142 426349Sqs148142 #define RBR_CFIG_A_STDADDR_MASK 0x000000000003ffc0ULL 436349Sqs148142 #define RBR_CFIG_A_STDADDR_BASE_MASK 0x00000ffffffc0000ULL 446349Sqs148142 456349Sqs148142 #define RCRCFIG_A_STADDR_SHIFT 6 /* bit 18:6 */ 466349Sqs148142 #define RCRCFIG_A_STADDR_MASK 0x000000000007FFC0ULL 476349Sqs148142 #define RCRCFIG_A_STADDR_BASE_SHIF 19 /* bit 43:19 */ 486349Sqs148142 #define RCRCFIG_A_STADDR_BASE_MASK 0x00000FFFFFF80000ULL 496349Sqs148142 #define RCRCFIG_A_LEN_SHIF 48 /* bit 63:48 */ 506349Sqs148142 #define RCRCFIG_A_LEN_MASK 0xFFFF000000000000ULL 516349Sqs148142 526349Sqs148142 #define RCR_FLSH_SHIFT 0 /* RW, bit 0:0 */ 536349Sqs148142 #define RCR_FLSH_SET 0x0000000000000001ULL 546349Sqs148142 #define RCR_FLSH_MASK 0x0000000000000001ULL 556349Sqs148142 566349Sqs148142 #define RBR_CFIG_A_LEN_SHIFT 48 /* bits 63:48 */ 576349Sqs148142 #define RBR_CFIG_A_LEN_MASK 0xFFFF000000000000ULL 586349Sqs148142 596349Sqs148142 /* 606349Sqs148142 * Buffer block descriptor 616349Sqs148142 */ 626349Sqs148142 typedef struct _rx_desc_t { 636349Sqs148142 uint32_t block_addr; 646349Sqs148142 } rx_desc_t, *p_rx_desc_t; 656349Sqs148142 666349Sqs148142 typedef enum _bsize { 676349Sqs148142 SIZE_0B = 0x0, 686349Sqs148142 SIZE_64B, 696349Sqs148142 SIZE_128B, 706349Sqs148142 SIZE_192B, 716349Sqs148142 SIZE_256B, 726349Sqs148142 SIZE_512B, 736349Sqs148142 SIZE_1KB, 746349Sqs148142 SIZE_2KB, 756349Sqs148142 SIZE_4KB, 766349Sqs148142 SIZE_8KB, 776349Sqs148142 SIZE_16KB, 786349Sqs148142 SIZE_32KB 796349Sqs148142 } bsize_t; 806349Sqs148142 816349Sqs148142 typedef struct _rdc_desc_cfg_t { 826349Sqs148142 uint8_t mbox_enable; /* Enable full (18b) header */ 836349Sqs148142 uint8_t full_hdr; /* Enable full (18b) header */ 846349Sqs148142 uint8_t offset; /* 64 byte offsets */ 856349Sqs148142 uint8_t valid2; /* size 2 is valid */ 866349Sqs148142 bsize_t size2; /* Size 2 length */ 876349Sqs148142 uint8_t valid1; /* size 1 is valid */ 886349Sqs148142 bsize_t size1; /* Size 1 length */ 896349Sqs148142 uint8_t valid0; /* size 0 is valid */ 906349Sqs148142 bsize_t size0; /* Size 1 length */ 916349Sqs148142 bsize_t page_size; /* Page or buffer Size */ 926349Sqs148142 uint8_t rcr_timeout_enable; 936349Sqs148142 uint8_t rcr_timeout; 946349Sqs148142 uint16_t rcr_threshold; 956349Sqs148142 uint16_t rcr_len; /* RBR Descriptor size (entries) */ 966349Sqs148142 uint16_t rbr_len; /* RBR Descriptor size (entries) */ 976349Sqs148142 uint64_t mbox_addr; /* Mailbox Address */ 986349Sqs148142 uint64_t rcr_addr; /* RCR Address */ 996349Sqs148142 uint64_t rbr_addr; /* RBB Address */ 1006349Sqs148142 } rdc_desc_cfg_t; 1016349Sqs148142 1026349Sqs148142 1036349Sqs148142 /* 1046349Sqs148142 * Register offset (0x800 bytes for each channel) for receive ring registers. 1056349Sqs148142 */ 1066349Sqs148142 #define HXGE_RXDMA_OFFSET(x, v, channel) (x + \ 1076349Sqs148142 (!v ? DMC_OFFSET(channel) : \ 1086349Sqs148142 RDMC_PIOVADDR_OFFSET(channel))) 1096349Sqs148142 1106349Sqs148142 #define RXDMA_REG_READ64(handle, reg, channel, data_p) {\ 1116349Sqs148142 HXGE_REG_RD64(handle, (HXGE_RXDMA_OFFSET(reg, handle.is_vraddr,\ 1126349Sqs148142 channel)), (data_p))\ 1136349Sqs148142 } 1146349Sqs148142 1156864Sqs148142 #define RXDMA_REG_READ32(handle, reg, channel, data_p) \ 1166864Sqs148142 HXGE_REG_RD32(handle, (HXGE_RXDMA_OFFSET(reg, handle.is_vraddr,\ 1176864Sqs148142 channel)), (data_p)) 1186349Sqs148142 1196349Sqs148142 #define RXDMA_REG_WRITE64(handle, reg, channel, data) {\ 1206349Sqs148142 HXGE_REG_WR64(handle, (HXGE_RXDMA_OFFSET(reg, handle.is_vraddr,\ 1216349Sqs148142 channel)), (data))\ 1226349Sqs148142 } 1236349Sqs148142 1246349Sqs148142 /* 1256349Sqs148142 * RX HPI error codes 1266349Sqs148142 */ 1276349Sqs148142 #define RXDMA_ER_ST (RXDMA_BLK_ID << HPI_BLOCK_ID_SHIFT) 1286349Sqs148142 #define RXDMA_ID_SHIFT(n) (n << HPI_PORT_CHAN_SHIFT) 1296349Sqs148142 1306349Sqs148142 #define HPI_RXDMA_ERROR RXDMA_ER_ST 1316349Sqs148142 1326349Sqs148142 #define HPI_RXDMA_SW_PARAM_ERROR (HPI_RXDMA_ERROR | 0x40) 1336349Sqs148142 #define HPI_RXDMA_HW_ERROR (HPI_RXDMA_ERROR | 0x80) 1346349Sqs148142 1356349Sqs148142 #define HPI_RXDMA_RDC_INVALID (HPI_RXDMA_ERROR | CHANNEL_INVALID) 1366349Sqs148142 #define HPI_RXDMA_RESET_ERR (HPI_RXDMA_HW_ERROR | RESET_FAILED) 1376349Sqs148142 #define HPI_RXDMA_BUFSZIE_INVALID (HPI_RXDMA_SW_PARAM_ERROR | 0x0000b) 1386349Sqs148142 #define HPI_RXDMA_RBRSZIE_INVALID (HPI_RXDMA_SW_PARAM_ERROR | 0x0000c) 1396349Sqs148142 #define HPI_RXDMA_RCRSZIE_INVALID (HPI_RXDMA_SW_PARAM_ERROR | 0x0000d) 1406349Sqs148142 1416349Sqs148142 #define HPI_RXDMA_CHANNEL_INVALID(n) (RXDMA_ID_SHIFT(n) | \ 1426349Sqs148142 HPI_RXDMA_ERROR | CHANNEL_INVALID) 1436349Sqs148142 #define HPI_RXDMA_OPCODE_INVALID(n) (RXDMA_ID_SHIFT(n) | \ 1446349Sqs148142 HPI_RXDMA_ERROR | OPCODE_INVALID) 1456349Sqs148142 1466349Sqs148142 #define HPI_RXDMA_ERROR_ENCODE(err, rdc) \ 1476349Sqs148142 (RXDMA_ID_SHIFT(rdc) | RXDMA_ER_ST | err) 1486349Sqs148142 1496349Sqs148142 #define RXDMA_CHANNEL_VALID(rdc) \ 1506349Sqs148142 ((rdc < HXGE_MAX_RDCS)) 1516349Sqs148142 1526349Sqs148142 #define RXDMA_BUFF_OFFSET_VALID(offset) \ 1536349Sqs148142 ((offset == SW_OFFSET_NO_OFFSET) || \ 1546349Sqs148142 (offset == SW_OFFSET_64) || \ 1556349Sqs148142 (offset == SW_OFFSET_128)) 1566349Sqs148142 1576349Sqs148142 #define RXDMA_RCR_TO_VALID(tov) ((tov) && (tov < 64)) 1586864Sqs148142 #define RXDMA_RCR_THRESH_VALID(thresh) ((thresh <= 0x8000)) 1596349Sqs148142 1606349Sqs148142 #define hpi_rxdma_rdc_rcr_flush(handle, rdc) \ 1616349Sqs148142 RXDMA_REG_WRITE64(handle, RDC_RCR_FLUSH, rdc, \ 1626349Sqs148142 (RCR_FLSH_SET << RCR_FLSH_SHIFT)) 1636349Sqs148142 #define hpi_rxdma_rdc_rbr_kick(handle, rdc, num_buffers) \ 1646349Sqs148142 RXDMA_REG_WRITE64(handle, RDC_RBR_KICK, rdc, num_buffers) 1656349Sqs148142 166*7959SMichael.Speer@Sun.COM hpi_status_t hpi_rxdma_cfg_rdc_wait_for_qst(hpi_handle_t handle, uint8_t rdc); 1676349Sqs148142 hpi_status_t hpi_rxdma_cfg_rdc_ring(hpi_handle_t handle, uint8_t rdc, 1686349Sqs148142 rdc_desc_cfg_t *rdc_desc_params); 1696349Sqs148142 hpi_status_t hpi_rxdma_cfg_clock_div_set(hpi_handle_t handle, uint16_t count); 1706349Sqs148142 hpi_status_t hpi_rxdma_cfg_logical_page_handle(hpi_handle_t handle, uint8_t rdc, 1716349Sqs148142 uint64_t pg_handle); 1726349Sqs148142 1736349Sqs148142 hpi_status_t hpi_rxdma_rdc_rbr_stat_get(hpi_handle_t handle, uint8_t rdc, 1746349Sqs148142 rdc_rbr_qlen_t *rbr_stat); 1756349Sqs148142 hpi_status_t hpi_rxdma_cfg_rdc_reset(hpi_handle_t handle, uint8_t rdc); 1766349Sqs148142 hpi_status_t hpi_rxdma_cfg_rdc_enable(hpi_handle_t handle, uint8_t rdc); 1776349Sqs148142 hpi_status_t hpi_rxdma_cfg_rdc_disable(hpi_handle_t handle, uint8_t rdc); 1786349Sqs148142 hpi_status_t hpi_rxdma_cfg_rdc_rcr_timeout(hpi_handle_t handle, uint8_t rdc, 1796349Sqs148142 uint8_t rcr_timeout); 1806349Sqs148142 1816349Sqs148142 hpi_status_t hpi_rxdma_cfg_rdc_rcr_threshold(hpi_handle_t handle, uint8_t rdc, 1826349Sqs148142 uint16_t rcr_threshold); 1836349Sqs148142 hpi_status_t hpi_rxdma_rdc_rcr_qlen_get(hpi_handle_t handle, 1846349Sqs148142 uint8_t rdc, uint16_t *qlen); 1856349Sqs148142 1866349Sqs148142 hpi_status_t hpi_rxdma_ring_perr_stat_get(hpi_handle_t handle, 1876349Sqs148142 rdc_pref_par_log_t *pre_log, rdc_pref_par_log_t *sha_log); 1886349Sqs148142 1896349Sqs148142 hpi_status_t hpi_rxdma_control_status(hpi_handle_t handle, io_op_t op_mode, 1906349Sqs148142 uint8_t channel, rdc_stat_t *cs_p); 1916349Sqs148142 hpi_status_t hpi_rxdma_event_mask(hpi_handle_t handle, io_op_t op_mode, 1926349Sqs148142 uint8_t channel, rdc_int_mask_t *mask_p); 1936349Sqs148142 hpi_status_t hpi_rxdma_channel_rbr_empty_clear(hpi_handle_t handle, 1946349Sqs148142 uint8_t channel); 1956349Sqs148142 1966349Sqs148142 #ifdef __cplusplus 1976349Sqs148142 } 1986349Sqs148142 #endif 1996349Sqs148142 2006349Sqs148142 #endif /* _HPI_RXDMA_H */ 201