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 enum nfp_mbox_cmd { 64 NFP_MBOX_NO_CMD = 0x00, 65 66 NFP_MBOX_POOL_GET = 0x01, 67 NFP_MBOX_POOL_SET = 0x02, 68 }; 69 70 #define NFP_SHARED_BUF_COUNT_SYM_NAME "_abi_nfd_pf%u_sb_cnt" 71 #define NFP_SHARED_BUF_TABLE_SYM_NAME "_abi_nfd_pf%u_sb_tbl" 72 73 /** 74 * struct nfp_shared_buf - NFP shared buffer description 75 * @id: numerical user-visible id of the shared buffer 76 * @size: size in bytes of the buffer 77 * @ingress_pools_count: number of ingress pools 78 * @egress_pools_count: number of egress pools 79 * @ingress_tc_count: number of ingress trafic classes 80 * @egress_tc_count: number of egress trafic classes 81 * @pool_size_unit: pool size may be in credits, each credit is 82 * @pool_size_unit bytes 83 */ 84 struct nfp_shared_buf { 85 __le32 id; 86 __le32 size; 87 __le16 ingress_pools_count; 88 __le16 egress_pools_count; 89 __le16 ingress_tc_count; 90 __le16 egress_tc_count; 91 92 __le32 pool_size_unit; 93 }; 94 95 /** 96 * struct nfp_shared_buf_pool_id - shared buffer pool identification 97 * @shared_buf: shared buffer id 98 * @pool: pool index 99 */ 100 struct nfp_shared_buf_pool_id { 101 __le32 shared_buf; 102 __le32 pool; 103 }; 104 105 /** 106 * struct nfp_shared_buf_pool_info_get - struct devlink_sb_pool_info mirror 107 * @pool_type: one of enum devlink_sb_pool_type 108 * @size: pool size in units of SB's @pool_size_unit 109 * @threshold_type: one of enum devlink_sb_threshold_type 110 */ 111 struct nfp_shared_buf_pool_info_get { 112 __le32 pool_type; 113 __le32 size; 114 __le32 threshold_type; 115 }; 116 117 /** 118 * struct nfp_shared_buf_pool_info_set - packed args of sb_pool_set 119 * @id: pool identification info 120 * @size: pool size in units of SB's @pool_size_unit 121 * @threshold_type: one of enum devlink_sb_threshold_type 122 */ 123 struct nfp_shared_buf_pool_info_set { 124 struct nfp_shared_buf_pool_id id; 125 __le32 size; 126 __le32 threshold_type; 127 }; 128 129 #endif 130