cvmx-ilk.h revision 256281
1/***********************license start*************** 2 * Copyright (c) 2003-2010 Cavium Inc. (support@cavium.com). All rights 3 * reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 18 * * Neither the name of Cavium Inc. nor the names of 19 * its contributors may be used to endorse or promote products 20 * derived from this software without specific prior written 21 * permission. 22 23 * This Software, including technical data, may be subject to U.S. export control 24 * laws, including the U.S. Export Administration Act and its associated 25 * regulations, and may be subject to export or import regulations in other 26 * countries. 27 28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR 30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO 31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR 32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM 33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, 34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF 35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR 36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR 37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 38 ***********************license end**************************************/ 39 40/** 41 * @file 42 * 43 * This file contains defines for the ILK interface 44 45 * <hr>$Revision: 49448 $<hr> 46 * 47 * 48 */ 49#ifndef __CVMX_ILK_H__ 50#define __CVMX_ILK_H__ 51 52#ifdef __cplusplus 53extern "C" { 54#endif 55 56/* CSR typedefs have been moved to cvmx-ilk-defs.h */ 57 58#define CVMX_ILK_GBL_BASE 5 59#define CVMX_ILK_QLM_BASE 1 60 61typedef struct 62{ 63 int intf_en : 8; 64 int lane_en_mask : 8; 65 int lane_speed : 16; 66 /* add more here */ 67} cvmx_ilk_intf_t; 68 69#define CVMX_NUM_ILK_INTF 2 70#define CVMX_MAX_ILK_LANES 8 71extern unsigned char cvmx_ilk_lane_mask[CVMX_NUM_ILK_INTF]; 72 73typedef struct 74{ 75 unsigned int pipe; 76 unsigned int chan; 77} cvmx_ilk_pipe_chan_t; 78 79#define CVMX_ILK_PIPE_BASE 72 80#define CVMX_MAX_ILK_PIPES 45 81#define CVMX_MAX_ILK_CHANS 8 82extern unsigned char cvmx_ilk_chans[CVMX_NUM_ILK_INTF]; 83extern unsigned char cvmx_ilk_chan_map[CVMX_NUM_ILK_INTF][CVMX_MAX_ILK_CHANS]; 84 85typedef struct 86{ 87 unsigned int chan; 88 unsigned int pknd; 89} cvmx_ilk_chan_pknd_t; 90 91#define CVMX_ILK_PKND_BASE 20 92#define CVMX_MAX_ILK_PKNDS 8 /* must be <45 */ 93 94typedef struct 95{ 96 unsigned int *chan_list; /* for discrete channels. or, must be null */ 97 unsigned int num_chans; 98 99 unsigned int chan_start; /* for continuous channels */ 100 unsigned int chan_end; 101 unsigned int chan_step; 102 103 unsigned int clr_on_rd; 104} cvmx_ilk_stats_ctrl_t; 105 106#define CVMX_ILK_MAX_CAL 288 107#define CVMX_ILK_TX_MIN_CAL 1 108#define CVMX_ILK_RX_MIN_CAL 1 109#define CVMX_ILK_CAL_GRP_SZ 8 110#define CVMX_ILK_PIPE_BPID_SZ 7 111#define CVMX_ILK_ENT_CTRL_SZ 2 112#define CVMX_ILK_RX_FIFO_WM 0x200 113 114typedef enum 115{ 116 PIPE_BPID = 0, 117 LINK, 118 XOFF, 119 XON 120} cvmx_ilk_cal_ent_ctrl_t; 121 122typedef struct 123{ 124 unsigned char pipe_bpid; 125 cvmx_ilk_cal_ent_ctrl_t ent_ctrl; 126} cvmx_ilk_cal_entry_t; 127 128/** Callbacks structure to customize ILK initialization sequence */ 129typedef struct 130{ 131 /** Called to setup rx calendar */ 132 int (*calendar_setup_rx) (int interface, int cal_depth, 133 cvmx_ilk_cal_entry_t *pent, int hi_wm, 134 unsigned char cal_ena); 135 136 /** add more here */ 137} cvmx_ilk_callbacks_t; 138 139typedef enum 140{ 141 CVMX_ILK_LPBK_DISA = 0, 142 CVMX_ILK_LPBK_ENA 143} cvmx_ilk_lpbk_ena_t; 144 145typedef enum 146{ 147 CVMX_ILK_LPBK_INT = 0, 148 CVMX_ILK_LPBK_EXT 149} cvmx_ilk_lpbk_mode_t; 150 151extern void cvmx_ilk_get_callbacks(cvmx_ilk_callbacks_t * callbacks); 152extern void cvmx_ilk_set_callbacks(cvmx_ilk_callbacks_t * new_callbacks); 153 154extern int cvmx_ilk_start_interface (int interface, unsigned char num_lanes); 155extern int cvmx_ilk_set_pipe (int interface, int pipe_base, 156 unsigned int pipe_len); 157extern int cvmx_ilk_tx_set_channel (int interface, cvmx_ilk_pipe_chan_t *pch, 158 unsigned int num_chs); 159extern int cvmx_ilk_rx_set_pknd (int interface, cvmx_ilk_chan_pknd_t *chpknd, 160 unsigned int num_pknd); 161extern int cvmx_ilk_calendar_setup_cb (int interface, int num_ports); 162extern int cvmx_ilk_calendar_sync_cb (int interface, int timeout); 163extern int cvmx_ilk_enable (int interface); 164extern int cvmx_ilk_disable (int interface); 165extern int cvmx_ilk_get_intf_ena (int interface); 166extern unsigned char cvmx_ilk_bit_count (unsigned char uc); 167extern unsigned char cvmx_ilk_get_intf_ln_msk (int interface); 168extern int cvmx_ilk_get_chan_info (int interface, unsigned char **chans, 169 unsigned char *num_chan); 170extern void cvmx_ilk_show_stats (int interface, cvmx_ilk_stats_ctrl_t *pstats); 171extern int cvmx_ilk_cal_setup_rx (int interface, int cal_depth, 172 cvmx_ilk_cal_entry_t *pent, int hi_wm, 173 unsigned char cal_ena); 174extern int cvmx_ilk_cal_setup_tx (int interface, int cal_depth, 175 cvmx_ilk_cal_entry_t *pent, 176 unsigned char cal_ena); 177extern int cvmx_ilk_lpbk (int interface, cvmx_ilk_lpbk_ena_t enable, 178 cvmx_ilk_lpbk_mode_t mode); 179#ifdef __cplusplus 180} 181#endif 182 183#endif /* __CVMX_ILK_H__ */ 184