net/octeontx/base: add base PKO operations
[dpdk.git] / drivers / net / octeontx / base / octeontx_pkovf.h
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright (C) Cavium Inc. 2017. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
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
15  *       distribution.
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.
19  *
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.
31  */
32
33 #ifndef __OCTEONTX_PKO_H__
34 #define __OCTEONTX_PKO_H__
35
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)
41
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
47
48 #define PKO_DQ_KIND_BIT                 49
49 #define PKO_DQ_STATUS_BIT               60
50 #define PKO_DQ_OP_BIT                   48
51
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)
62
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)
68
69 typedef struct octeontx_dq_s {
70         void *lmtline_va;
71         void *ioreg_va;
72         void *fc_status_va;
73 } octeontx_dq_t;
74
75 int octeontx_pko_channel_open(int dq_base, int dq_num, int chanid);
76 int octeontx_pko_channel_close(int chanid);
77 int octeontx_pko_channel_start(int chanid);
78 int octeontx_pko_channel_stop(int chanid);
79
80 #endif /* __OCTEONTX_PKO_H__ */