13dec9fcdSqs148142 /* 23dec9fcdSqs148142 * CDDL HEADER START 33dec9fcdSqs148142 * 43dec9fcdSqs148142 * The contents of this file are subject to the terms of the 53dec9fcdSqs148142 * Common Development and Distribution License (the "License"). 63dec9fcdSqs148142 * You may not use this file except in compliance with the License. 73dec9fcdSqs148142 * 83dec9fcdSqs148142 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93dec9fcdSqs148142 * or http://www.opensolaris.org/os/licensing. 103dec9fcdSqs148142 * See the License for the specific language governing permissions 113dec9fcdSqs148142 * and limitations under the License. 123dec9fcdSqs148142 * 133dec9fcdSqs148142 * When distributing Covered Code, include this CDDL HEADER in each 143dec9fcdSqs148142 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153dec9fcdSqs148142 * If applicable, add the following below this CDDL HEADER, with the 163dec9fcdSqs148142 * fields enclosed by brackets "[]" replaced with your own identifying 173dec9fcdSqs148142 * information: Portions Copyright [yyyy] [name of copyright owner] 183dec9fcdSqs148142 * 193dec9fcdSqs148142 * CDDL HEADER END 203dec9fcdSqs148142 */ 213dec9fcdSqs148142 /* 223dec9fcdSqs148142 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 233dec9fcdSqs148142 * Use is subject to license terms. 243dec9fcdSqs148142 */ 253dec9fcdSqs148142 263dec9fcdSqs148142 #ifndef _HPI_RXDMA_H 273dec9fcdSqs148142 #define _HPI_RXDMA_H 283dec9fcdSqs148142 293dec9fcdSqs148142 #ifdef __cplusplus 303dec9fcdSqs148142 extern "C" { 313dec9fcdSqs148142 #endif 323dec9fcdSqs148142 333dec9fcdSqs148142 #include <hpi.h> 343dec9fcdSqs148142 #include <hxge_defs.h> 353dec9fcdSqs148142 #include <hxge_pfc.h> 363dec9fcdSqs148142 #include <hxge_pfc_hw.h> 373dec9fcdSqs148142 #include <hxge_rdc_hw.h> 383dec9fcdSqs148142 393dec9fcdSqs148142 #define RXDMA_CFIG2_MBADDR_L_SHIFT 6 /* bit 31:6 */ 403dec9fcdSqs148142 #define RXDMA_CFIG2_MBADDR_L_MASK 0x00000000ffffffc0ULL 413dec9fcdSqs148142 423dec9fcdSqs148142 #define RBR_CFIG_A_STDADDR_MASK 0x000000000003ffc0ULL 433dec9fcdSqs148142 #define RBR_CFIG_A_STDADDR_BASE_MASK 0x00000ffffffc0000ULL 443dec9fcdSqs148142 453dec9fcdSqs148142 #define RCRCFIG_A_STADDR_SHIFT 6 /* bit 18:6 */ 463dec9fcdSqs148142 #define RCRCFIG_A_STADDR_MASK 0x000000000007FFC0ULL 473dec9fcdSqs148142 #define RCRCFIG_A_STADDR_BASE_SHIF 19 /* bit 43:19 */ 483dec9fcdSqs148142 #define RCRCFIG_A_STADDR_BASE_MASK 0x00000FFFFFF80000ULL 493dec9fcdSqs148142 #define RCRCFIG_A_LEN_SHIF 48 /* bit 63:48 */ 503dec9fcdSqs148142 #define RCRCFIG_A_LEN_MASK 0xFFFF000000000000ULL 513dec9fcdSqs148142 523dec9fcdSqs148142 #define RCR_FLSH_SHIFT 0 /* RW, bit 0:0 */ 533dec9fcdSqs148142 #define RCR_FLSH_SET 0x0000000000000001ULL 543dec9fcdSqs148142 #define RCR_FLSH_MASK 0x0000000000000001ULL 553dec9fcdSqs148142 563dec9fcdSqs148142 #define RBR_CFIG_A_LEN_SHIFT 48 /* bits 63:48 */ 573dec9fcdSqs148142 #define RBR_CFIG_A_LEN_MASK 0xFFFF000000000000ULL 583dec9fcdSqs148142 593dec9fcdSqs148142 /* 603dec9fcdSqs148142 * Buffer block descriptor 613dec9fcdSqs148142 */ 623dec9fcdSqs148142 typedef struct _rx_desc_t { 633dec9fcdSqs148142 uint32_t block_addr; 643dec9fcdSqs148142 } rx_desc_t, *p_rx_desc_t; 653dec9fcdSqs148142 663dec9fcdSqs148142 typedef enum _bsize { 673dec9fcdSqs148142 SIZE_0B = 0x0, 683dec9fcdSqs148142 SIZE_64B, 693dec9fcdSqs148142 SIZE_128B, 703dec9fcdSqs148142 SIZE_192B, 713dec9fcdSqs148142 SIZE_256B, 723dec9fcdSqs148142 SIZE_512B, 733dec9fcdSqs148142 SIZE_1KB, 743dec9fcdSqs148142 SIZE_2KB, 753dec9fcdSqs148142 SIZE_4KB, 763dec9fcdSqs148142 SIZE_8KB, 773dec9fcdSqs148142 SIZE_16KB, 783dec9fcdSqs148142 SIZE_32KB 793dec9fcdSqs148142 } bsize_t; 803dec9fcdSqs148142 813dec9fcdSqs148142 typedef struct _rdc_desc_cfg_t { 823dec9fcdSqs148142 uint8_t mbox_enable; /* Enable full (18b) header */ 833dec9fcdSqs148142 uint8_t full_hdr; /* Enable full (18b) header */ 843dec9fcdSqs148142 uint8_t offset; /* 64 byte offsets */ 853dec9fcdSqs148142 uint8_t valid2; /* size 2 is valid */ 863dec9fcdSqs148142 bsize_t size2; /* Size 2 length */ 873dec9fcdSqs148142 uint8_t valid1; /* size 1 is valid */ 883dec9fcdSqs148142 bsize_t size1; /* Size 1 length */ 893dec9fcdSqs148142 uint8_t valid0; /* size 0 is valid */ 903dec9fcdSqs148142 bsize_t size0; /* Size 1 length */ 913dec9fcdSqs148142 bsize_t page_size; /* Page or buffer Size */ 923dec9fcdSqs148142 uint8_t rcr_timeout_enable; 933dec9fcdSqs148142 uint8_t rcr_timeout; 943dec9fcdSqs148142 uint16_t rcr_threshold; 953dec9fcdSqs148142 uint16_t rcr_len; /* RBR Descriptor size (entries) */ 963dec9fcdSqs148142 uint16_t rbr_len; /* RBR Descriptor size (entries) */ 973dec9fcdSqs148142 uint64_t mbox_addr; /* Mailbox Address */ 983dec9fcdSqs148142 uint64_t rcr_addr; /* RCR Address */ 993dec9fcdSqs148142 uint64_t rbr_addr; /* RBB Address */ 1003dec9fcdSqs148142 } rdc_desc_cfg_t; 1013dec9fcdSqs148142 1023dec9fcdSqs148142 1033dec9fcdSqs148142 /* 1043dec9fcdSqs148142 * Register offset (0x800 bytes for each channel) for receive ring registers. 1053dec9fcdSqs148142 */ 1063dec9fcdSqs148142 #define HXGE_RXDMA_OFFSET(x, v, channel) (x + \ 1073dec9fcdSqs148142 (!v ? DMC_OFFSET(channel) : \ 1083dec9fcdSqs148142 RDMC_PIOVADDR_OFFSET(channel))) 1093dec9fcdSqs148142 1103dec9fcdSqs148142 #define RXDMA_REG_READ64(handle, reg, channel, data_p) {\ 1113dec9fcdSqs148142 HXGE_REG_RD64(handle, (HXGE_RXDMA_OFFSET(reg, handle.is_vraddr,\ 1123dec9fcdSqs148142 channel)), (data_p))\ 1133dec9fcdSqs148142 } 1143dec9fcdSqs148142 115fe930412Sqs148142 #define RXDMA_REG_READ32(handle, reg, channel, data_p) \ 116fe930412Sqs148142 HXGE_REG_RD32(handle, (HXGE_RXDMA_OFFSET(reg, handle.is_vraddr,\ 117fe930412Sqs148142 channel)), (data_p)) 1183dec9fcdSqs148142 1193dec9fcdSqs148142 #define RXDMA_REG_WRITE64(handle, reg, channel, data) {\ 1203dec9fcdSqs148142 HXGE_REG_WR64(handle, (HXGE_RXDMA_OFFSET(reg, handle.is_vraddr,\ 1213dec9fcdSqs148142 channel)), (data))\ 1223dec9fcdSqs148142 } 1233dec9fcdSqs148142 1243dec9fcdSqs148142 /* 1253dec9fcdSqs148142 * RX HPI error codes 1263dec9fcdSqs148142 */ 1273dec9fcdSqs148142 #define RXDMA_ER_ST (RXDMA_BLK_ID << HPI_BLOCK_ID_SHIFT) 1283dec9fcdSqs148142 #define RXDMA_ID_SHIFT(n) (n << HPI_PORT_CHAN_SHIFT) 1293dec9fcdSqs148142 1303dec9fcdSqs148142 #define HPI_RXDMA_ERROR RXDMA_ER_ST 1313dec9fcdSqs148142 1323dec9fcdSqs148142 #define HPI_RXDMA_SW_PARAM_ERROR (HPI_RXDMA_ERROR | 0x40) 1333dec9fcdSqs148142 #define HPI_RXDMA_HW_ERROR (HPI_RXDMA_ERROR | 0x80) 1343dec9fcdSqs148142 1353dec9fcdSqs148142 #define HPI_RXDMA_RDC_INVALID (HPI_RXDMA_ERROR | CHANNEL_INVALID) 1363dec9fcdSqs148142 #define HPI_RXDMA_RESET_ERR (HPI_RXDMA_HW_ERROR | RESET_FAILED) 1373dec9fcdSqs148142 #define HPI_RXDMA_BUFSZIE_INVALID (HPI_RXDMA_SW_PARAM_ERROR | 0x0000b) 1383dec9fcdSqs148142 #define HPI_RXDMA_RBRSZIE_INVALID (HPI_RXDMA_SW_PARAM_ERROR | 0x0000c) 1393dec9fcdSqs148142 #define HPI_RXDMA_RCRSZIE_INVALID (HPI_RXDMA_SW_PARAM_ERROR | 0x0000d) 1403dec9fcdSqs148142 1413dec9fcdSqs148142 #define HPI_RXDMA_CHANNEL_INVALID(n) (RXDMA_ID_SHIFT(n) | \ 1423dec9fcdSqs148142 HPI_RXDMA_ERROR | CHANNEL_INVALID) 1433dec9fcdSqs148142 #define HPI_RXDMA_OPCODE_INVALID(n) (RXDMA_ID_SHIFT(n) | \ 1443dec9fcdSqs148142 HPI_RXDMA_ERROR | OPCODE_INVALID) 1453dec9fcdSqs148142 1463dec9fcdSqs148142 #define HPI_RXDMA_ERROR_ENCODE(err, rdc) \ 1473dec9fcdSqs148142 (RXDMA_ID_SHIFT(rdc) | RXDMA_ER_ST | err) 1483dec9fcdSqs148142 1493dec9fcdSqs148142 #define RXDMA_CHANNEL_VALID(rdc) \ 1503dec9fcdSqs148142 ((rdc < HXGE_MAX_RDCS)) 1513dec9fcdSqs148142 1523dec9fcdSqs148142 #define RXDMA_BUFF_OFFSET_VALID(offset) \ 1533dec9fcdSqs148142 ((offset == SW_OFFSET_NO_OFFSET) || \ 1543dec9fcdSqs148142 (offset == SW_OFFSET_64) || \ 1553dec9fcdSqs148142 (offset == SW_OFFSET_128)) 1563dec9fcdSqs148142 1573dec9fcdSqs148142 #define RXDMA_RCR_TO_VALID(tov) ((tov) && (tov < 64)) 158fe930412Sqs148142 #define RXDMA_RCR_THRESH_VALID(thresh) ((thresh <= 0x8000)) 1593dec9fcdSqs148142 1603dec9fcdSqs148142 #define hpi_rxdma_rdc_rcr_flush(handle, rdc) \ 1613dec9fcdSqs148142 RXDMA_REG_WRITE64(handle, RDC_RCR_FLUSH, rdc, \ 1623dec9fcdSqs148142 (RCR_FLSH_SET << RCR_FLSH_SHIFT)) 1633dec9fcdSqs148142 #define hpi_rxdma_rdc_rbr_kick(handle, rdc, num_buffers) \ 1643dec9fcdSqs148142 RXDMA_REG_WRITE64(handle, RDC_RBR_KICK, rdc, num_buffers) 1653dec9fcdSqs148142 166*069fd767SMichael Speer hpi_status_t hpi_rxdma_cfg_rdc_wait_for_qst(hpi_handle_t handle, uint8_t rdc); 1673dec9fcdSqs148142 hpi_status_t hpi_rxdma_cfg_rdc_ring(hpi_handle_t handle, uint8_t rdc, 1683dec9fcdSqs148142 rdc_desc_cfg_t *rdc_desc_params); 1693dec9fcdSqs148142 hpi_status_t hpi_rxdma_cfg_clock_div_set(hpi_handle_t handle, uint16_t count); 1703dec9fcdSqs148142 hpi_status_t hpi_rxdma_cfg_logical_page_handle(hpi_handle_t handle, uint8_t rdc, 1713dec9fcdSqs148142 uint64_t pg_handle); 1723dec9fcdSqs148142 1733dec9fcdSqs148142 hpi_status_t hpi_rxdma_rdc_rbr_stat_get(hpi_handle_t handle, uint8_t rdc, 1743dec9fcdSqs148142 rdc_rbr_qlen_t *rbr_stat); 1753dec9fcdSqs148142 hpi_status_t hpi_rxdma_cfg_rdc_reset(hpi_handle_t handle, uint8_t rdc); 1763dec9fcdSqs148142 hpi_status_t hpi_rxdma_cfg_rdc_enable(hpi_handle_t handle, uint8_t rdc); 1773dec9fcdSqs148142 hpi_status_t hpi_rxdma_cfg_rdc_disable(hpi_handle_t handle, uint8_t rdc); 1783dec9fcdSqs148142 hpi_status_t hpi_rxdma_cfg_rdc_rcr_timeout(hpi_handle_t handle, uint8_t rdc, 1793dec9fcdSqs148142 uint8_t rcr_timeout); 1803dec9fcdSqs148142 1813dec9fcdSqs148142 hpi_status_t hpi_rxdma_cfg_rdc_rcr_threshold(hpi_handle_t handle, uint8_t rdc, 1823dec9fcdSqs148142 uint16_t rcr_threshold); 1833dec9fcdSqs148142 hpi_status_t hpi_rxdma_rdc_rcr_qlen_get(hpi_handle_t handle, 1843dec9fcdSqs148142 uint8_t rdc, uint16_t *qlen); 1853dec9fcdSqs148142 1863dec9fcdSqs148142 hpi_status_t hpi_rxdma_ring_perr_stat_get(hpi_handle_t handle, 1873dec9fcdSqs148142 rdc_pref_par_log_t *pre_log, rdc_pref_par_log_t *sha_log); 1883dec9fcdSqs148142 1893dec9fcdSqs148142 hpi_status_t hpi_rxdma_control_status(hpi_handle_t handle, io_op_t op_mode, 1903dec9fcdSqs148142 uint8_t channel, rdc_stat_t *cs_p); 1913dec9fcdSqs148142 hpi_status_t hpi_rxdma_event_mask(hpi_handle_t handle, io_op_t op_mode, 1923dec9fcdSqs148142 uint8_t channel, rdc_int_mask_t *mask_p); 1933dec9fcdSqs148142 hpi_status_t hpi_rxdma_channel_rbr_empty_clear(hpi_handle_t handle, 1943dec9fcdSqs148142 uint8_t channel); 1953dec9fcdSqs148142 1963dec9fcdSqs148142 #ifdef __cplusplus 1973dec9fcdSqs148142 } 1983dec9fcdSqs148142 #endif 1993dec9fcdSqs148142 2003dec9fcdSqs148142 #endif /* _HPI_RXDMA_H */ 201