4 * Copyright (C) Cavium Inc. 2017. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Cavium networks nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef __OCTEONTX_PKO_H__
34 #define __OCTEONTX_PKO_H__
36 /* PKO maximum constants */
37 #define PKO_VF_MAX (32)
38 #define PKO_VF_NUM_DQ (8)
39 #define PKO_MAX_NUM_DQ (8)
40 #define PKO_DQ_DRAIN_TO (1000)
42 #define PKO_DQ_FC_SKID (4)
43 #define PKO_DQ_FC_DEPTH_PAGES (2048)
44 #define PKO_DQ_FC_STRIDE_16 (16)
45 #define PKO_DQ_FC_STRIDE_128 (128)
46 #define PKO_DQ_FC_STRIDE PKO_DQ_FC_STRIDE_16
48 #define PKO_DQ_KIND_BIT 49
49 #define PKO_DQ_STATUS_BIT 60
50 #define PKO_DQ_OP_BIT 48
52 /* PKO VF register offsets from VF_BAR0 */
53 #define PKO_VF_DQ_SW_XOFF(gdq) (0x000100 | (gdq) << 17)
54 #define PKO_VF_DQ_WM_CTL(gdq) (0x000130 | (gdq) << 17)
55 #define PKO_VF_DQ_WM_CNT(gdq) (0x000150 | (gdq) << 17)
56 #define PKO_VF_DQ_FC_CONFIG (0x000160)
57 #define PKO_VF_DQ_FC_STATUS(gdq) (0x000168 | (gdq) << 17)
58 #define PKO_VF_DQ_OP_SEND(gdq, op) (0x001000 | (gdq) << 17 | (op) << 3)
59 #define PKO_VF_DQ_OP_OPEN(gdq) (0x001100 | (gdq) << 17)
60 #define PKO_VF_DQ_OP_CLOSE(gdq) (0x001200 | (gdq) << 17)
61 #define PKO_VF_DQ_OP_QUERY(gdq) (0x001300 | (gdq) << 17)
63 /* pko_send_hdr_s + pko_send_link */
64 #define PKO_CMD_SZ (2 << 1)
65 #define PKO_SEND_GATHER_SUBDC (0x0ull << 60)
66 #define PKO_SEND_GATHER_LDTYPE(x) ((x) << 58)
67 #define PKO_SEND_GATHER_GAUAR(x) ((x) << 24)
69 typedef struct octeontx_dq_s {
76 * Function for extracting information out of a given DQ.
78 * It is intended to be used in slow path (configuration) in
79 * octeontx_pko_channel_query().
81 * @param dq The DQ to extract information from.
82 * @param out Pointer to the user's structure he wants to fill.
84 typedef void (*octeontx_pko_dq_getter_t)(octeontx_dq_t *dq, void *out);
87 octeontx_pko_channel_query_dqs(int chanid, void *out, size_t out_elem_size,
88 size_t dq_num, octeontx_pko_dq_getter_t getter);
89 int octeontx_pko_channel_open(int dq_base, int dq_num, int chanid);
90 int octeontx_pko_channel_close(int chanid);
91 int octeontx_pko_channel_start(int chanid);
92 int octeontx_pko_channel_stop(int chanid);
93 int octeontx_pko_vf_count(void);
94 int octeontx_pko_init_fc(const size_t pko_vf_count);
95 void octeontx_pko_fc_free(void);
97 #endif /* __OCTEONTX_PKO_H__ */