GNU Linux-libre 4.19.281-gnu1
[releases.git] / drivers / net / ethernet / netronome / nfp / nfp_abi.h
1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) */
2 /*
3  * Copyright (C) 2018 Netronome Systems, Inc.
4  *
5  * This software is dual licensed under the GNU General License Version 2,
6  * June 1991 as shown in the file COPYING in the top-level directory of this
7  * source tree or the BSD 2-Clause License provided below.  You have the
8  * option to license this software under the complete terms of either license.
9  *
10  * The BSD 2-Clause License:
11  *
12  *     Redistribution and use in source and binary forms, with or
13  *     without modification, are permitted provided that the following
14  *     conditions are met:
15  *
16  *      1. Redistributions of source code must retain the above
17  *         copyright notice, this list of conditions and the following
18  *         disclaimer.
19  *
20  *      2. Redistributions in binary form must reproduce the above
21  *         copyright notice, this list of conditions and the following
22  *         disclaimer in the documentation and/or other materials
23  *         provided with the distribution.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32  * SOFTWARE.
33  */
34
35 #ifndef __NFP_ABI__
36 #define __NFP_ABI__ 1
37
38 #include <linux/types.h>
39
40 #define NFP_MBOX_SYM_NAME               "_abi_nfd_pf%u_mbox"
41 #define NFP_MBOX_SYM_MIN_SIZE           16 /* When no data needed */
42
43 #define NFP_MBOX_CMD            0x00
44 #define NFP_MBOX_RET            0x04
45 #define NFP_MBOX_DATA_LEN       0x08
46 #define NFP_MBOX_RESERVED       0x0c
47 #define NFP_MBOX_DATA           0x10
48
49 /**
50  * enum nfp_mbox_cmd - PF mailbox commands
51  *
52  * @NFP_MBOX_NO_CMD:    null command
53  * Used to indicate previous command has finished.
54  *
55  * @NFP_MBOX_POOL_GET:  get shared buffer pool info/config
56  * Input  - struct nfp_shared_buf_pool_id
57  * Output - struct nfp_shared_buf_pool_info_get
58  *
59  * @NFP_MBOX_POOL_SET:  set shared buffer pool info/config
60  * Input  - struct nfp_shared_buf_pool_info_set
61  * Output - None
62  *
63  * @NFP_MBOX_PCIE_ABM_ENABLE:   enable PCIe-side advanced buffer management
64  * Enable advanced buffer management of the PCIe block.  If ABM is disabled
65  * PCIe block maintains a very short queue of buffers and does tail drop.
66  * ABM allows more advanced buffering and priority control.
67  * Input  - None
68  * Output - None
69  *
70  * @NFP_MBOX_PCIE_ABM_DISABLE:  disable PCIe-side advanced buffer management
71  * Input  - None
72  * Output - None
73  */
74 enum nfp_mbox_cmd {
75         NFP_MBOX_NO_CMD                 = 0x00,
76
77         NFP_MBOX_POOL_GET               = 0x01,
78         NFP_MBOX_POOL_SET               = 0x02,
79
80         NFP_MBOX_PCIE_ABM_ENABLE        = 0x03,
81         NFP_MBOX_PCIE_ABM_DISABLE       = 0x04,
82 };
83
84 #define NFP_SHARED_BUF_COUNT_SYM_NAME   "_abi_nfd_pf%u_sb_cnt"
85 #define NFP_SHARED_BUF_TABLE_SYM_NAME   "_abi_nfd_pf%u_sb_tbl"
86
87 /**
88  * struct nfp_shared_buf - NFP shared buffer description
89  * @id:                         numerical user-visible id of the shared buffer
90  * @size:                       size in bytes of the buffer
91  * @ingress_pools_count:        number of ingress pools
92  * @egress_pools_count:         number of egress pools
93  * @ingress_tc_count:           number of ingress trafic classes
94  * @egress_tc_count:            number of egress trafic classes
95  * @pool_size_unit:             pool size may be in credits, each credit is
96  *                              @pool_size_unit bytes
97  */
98 struct nfp_shared_buf {
99         __le32 id;
100         __le32 size;
101         __le16 ingress_pools_count;
102         __le16 egress_pools_count;
103         __le16 ingress_tc_count;
104         __le16 egress_tc_count;
105
106         __le32 pool_size_unit;
107 };
108
109 /**
110  * struct nfp_shared_buf_pool_id - shared buffer pool identification
111  * @shared_buf:         shared buffer id
112  * @pool:               pool index
113  */
114 struct nfp_shared_buf_pool_id {
115         __le32 shared_buf;
116         __le32 pool;
117 };
118
119 /**
120  * struct nfp_shared_buf_pool_info_get - struct devlink_sb_pool_info mirror
121  * @pool_type:          one of enum devlink_sb_pool_type
122  * @size:               pool size in units of SB's @pool_size_unit
123  * @threshold_type:     one of enum devlink_sb_threshold_type
124  */
125 struct nfp_shared_buf_pool_info_get {
126         __le32 pool_type;
127         __le32 size;
128         __le32 threshold_type;
129 };
130
131 /**
132  * struct nfp_shared_buf_pool_info_set - packed args of sb_pool_set
133  * @id:                 pool identification info
134  * @size:               pool size in units of SB's @pool_size_unit
135  * @threshold_type:     one of enum devlink_sb_threshold_type
136  */
137 struct nfp_shared_buf_pool_info_set {
138         struct nfp_shared_buf_pool_id id;
139         __le32 size;
140         __le32 threshold_type;
141 };
142
143 #endif