summaryrefslogtreecommitdiffstats
path: root/sys/contrib/octeon-sdk/cvmx-ilk.h
blob: 83e0b914d90448fab128ad5c8c6ca1ccaaa41636 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/***********************license start***************
 * Copyright (c) 2003-2010  Cavium Inc. (support@cavium.com). All rights
 * reserved.
 *
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.

 *   * Neither the name of Cavium Inc. nor the names of
 *     its contributors may be used to endorse or promote products
 *     derived from this software without specific prior written
 *     permission.

 * This Software, including technical data, may be subject to U.S. export  control
 * laws, including the U.S. Export Administration Act and its  associated
 * regulations, and may be subject to export or import  regulations in other
 * countries.

 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
 ***********************license end**************************************/

/**
 * @file
 *
 * This file contains defines for the ILK interface

 * <hr>$Revision: 49448 $<hr>
 *
 *
 */
#ifndef __CVMX_ILK_H__
#define __CVMX_ILK_H__

#ifdef	__cplusplus
extern "C" {
#endif

/* CSR typedefs have been moved to cvmx-ilk-defs.h */

#define CVMX_ILK_GBL_BASE  5
#define CVMX_ILK_QLM_BASE  1

typedef struct
{
    int intf_en      : 8;
    int lane_en_mask : 8;
    int lane_speed   : 16;
    /* add more here */
} cvmx_ilk_intf_t;

#define CVMX_NUM_ILK_INTF  2
#define CVMX_MAX_ILK_LANES 8
extern unsigned char cvmx_ilk_lane_mask[CVMX_NUM_ILK_INTF];

typedef struct
{
    unsigned int pipe;
    unsigned int chan;
} cvmx_ilk_pipe_chan_t;

#define CVMX_ILK_PIPE_BASE 72
#define CVMX_MAX_ILK_PIPES 45
#define CVMX_MAX_ILK_CHANS 8
extern unsigned char cvmx_ilk_chans[CVMX_NUM_ILK_INTF];
extern unsigned char cvmx_ilk_chan_map[CVMX_NUM_ILK_INTF][CVMX_MAX_ILK_CHANS];

typedef struct
{
    unsigned int chan;
    unsigned int pknd;
} cvmx_ilk_chan_pknd_t;

#define CVMX_ILK_PKND_BASE 20
#define CVMX_MAX_ILK_PKNDS 8 /* must be <45 */

typedef struct
{
    unsigned int *chan_list; /* for discrete channels. or, must be null */
    unsigned int num_chans;

    unsigned int chan_start; /* for continuous channels */
    unsigned int chan_end;
    unsigned int chan_step;

    unsigned int clr_on_rd;
} cvmx_ilk_stats_ctrl_t;

#define CVMX_ILK_MAX_CAL      288
#define CVMX_ILK_TX_MIN_CAL   1
#define CVMX_ILK_RX_MIN_CAL   1
#define CVMX_ILK_CAL_GRP_SZ   8
#define CVMX_ILK_PIPE_BPID_SZ 7
#define CVMX_ILK_ENT_CTRL_SZ  2
#define CVMX_ILK_RX_FIFO_WM   0x200

typedef enum
{
    PIPE_BPID = 0,
    LINK, 
    XOFF,
    XON
} cvmx_ilk_cal_ent_ctrl_t;

typedef struct
{
    unsigned char pipe_bpid;
    cvmx_ilk_cal_ent_ctrl_t ent_ctrl;
} cvmx_ilk_cal_entry_t;

/** Callbacks structure to customize ILK initialization sequence */
typedef struct
{
    /** Called to setup rx calendar */
    int (*calendar_setup_rx) (int interface, int cal_depth,
                              cvmx_ilk_cal_entry_t *pent, int hi_wm,
                              unsigned char cal_ena);

    /** add more here */
} cvmx_ilk_callbacks_t;

typedef enum
{
    CVMX_ILK_LPBK_DISA = 0,
    CVMX_ILK_LPBK_ENA
} cvmx_ilk_lpbk_ena_t;

typedef enum
{
    CVMX_ILK_LPBK_INT = 0,
    CVMX_ILK_LPBK_EXT
} cvmx_ilk_lpbk_mode_t;

extern void cvmx_ilk_get_callbacks(cvmx_ilk_callbacks_t * callbacks);
extern void cvmx_ilk_set_callbacks(cvmx_ilk_callbacks_t * new_callbacks);

extern int cvmx_ilk_start_interface (int interface, unsigned char num_lanes);
extern int cvmx_ilk_set_pipe (int interface, int pipe_base,
                              unsigned int pipe_len);
extern int cvmx_ilk_tx_set_channel (int interface, cvmx_ilk_pipe_chan_t *pch,
                                    unsigned int num_chs);
extern int cvmx_ilk_rx_set_pknd (int interface, cvmx_ilk_chan_pknd_t *chpknd,
                                 unsigned int num_pknd);
extern int cvmx_ilk_calendar_setup_cb (int interface, int num_ports);
extern int cvmx_ilk_calendar_sync_cb (int interface, int timeout);
extern int cvmx_ilk_enable (int interface);
extern int cvmx_ilk_disable (int interface);
extern int cvmx_ilk_get_intf_ena (int interface);
extern unsigned char cvmx_ilk_bit_count (unsigned char uc);
extern unsigned char cvmx_ilk_get_intf_ln_msk (int interface);
extern int cvmx_ilk_get_chan_info (int interface, unsigned char **chans,
                                   unsigned char *num_chan);
extern void cvmx_ilk_show_stats (int interface, cvmx_ilk_stats_ctrl_t *pstats);
extern int cvmx_ilk_cal_setup_rx (int interface, int cal_depth,
                                  cvmx_ilk_cal_entry_t *pent, int hi_wm,
                                  unsigned char cal_ena);
extern int cvmx_ilk_cal_setup_tx (int interface, int cal_depth,
                                  cvmx_ilk_cal_entry_t *pent,
                                  unsigned char cal_ena);
extern int cvmx_ilk_lpbk (int interface, cvmx_ilk_lpbk_ena_t enable,
                          cvmx_ilk_lpbk_mode_t mode);
#ifdef	__cplusplus
}
#endif

#endif  /* __CVMX_ILK_H__ */
OpenPOWER on IntegriCloud