xref: /freebsd/sys/dev/mlx5/mlx5_core/mlx5_fc_cmd.h (revision 35bbcf09)
135bbcf09SRaed Salem /*
235bbcf09SRaed Salem  * Copyright (c) 2023, NVIDIA Technologies. All rights reserved.
335bbcf09SRaed Salem  *
435bbcf09SRaed Salem  * This software is available to you under a choice of one of two
535bbcf09SRaed Salem  * licenses.  You may choose to be licensed under the terms of the GNU
635bbcf09SRaed Salem  * General Public License (GPL) Version 2, available from the file
735bbcf09SRaed Salem  * COPYING in the main directory of this source tree, or the
835bbcf09SRaed Salem  * OpenIB.org BSD license below:
935bbcf09SRaed Salem  *
1035bbcf09SRaed Salem  *     Redistribution and use in source and binary forms, with or
1135bbcf09SRaed Salem  *     without modification, are permitted provided that the following
1235bbcf09SRaed Salem  *     conditions are met:
1335bbcf09SRaed Salem  *
1435bbcf09SRaed Salem  *      - Redistributions of source code must retain the above
1535bbcf09SRaed Salem  *        copyright notice, this list of conditions and the following
1635bbcf09SRaed Salem  *        disclaimer.
1735bbcf09SRaed Salem  *
1835bbcf09SRaed Salem  *      - Redistributions in binary form must reproduce the above
1935bbcf09SRaed Salem  *        copyright notice, this list of conditions and the following
2035bbcf09SRaed Salem  *        disclaimer in the documentation and/or other materials
2135bbcf09SRaed Salem  *        provided with the distribution.
2235bbcf09SRaed Salem  *
2335bbcf09SRaed Salem  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2435bbcf09SRaed Salem  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2535bbcf09SRaed Salem  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2635bbcf09SRaed Salem  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2735bbcf09SRaed Salem  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2835bbcf09SRaed Salem  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2935bbcf09SRaed Salem  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3035bbcf09SRaed Salem  * SOFTWARE.
3135bbcf09SRaed Salem  */
3235bbcf09SRaed Salem 
3335bbcf09SRaed Salem #ifndef _MLX5_FC_CMD_
3435bbcf09SRaed Salem #define _MLX5_FC_CMD_
3535bbcf09SRaed Salem 
3635bbcf09SRaed Salem #include "fs_core.h"
3735bbcf09SRaed Salem 
3835bbcf09SRaed Salem int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id);
3935bbcf09SRaed Salem int mlx5_cmd_fc_bulk_alloc(struct mlx5_core_dev *dev,
4035bbcf09SRaed Salem 			   enum mlx5_fc_bulk_alloc_bitmask alloc_bitmask,
4135bbcf09SRaed Salem 			   u32 *id);
4235bbcf09SRaed Salem int mlx5_cmd_fc_free(struct mlx5_core_dev *dev, u32 id);
4335bbcf09SRaed Salem int mlx5_cmd_fc_query(struct mlx5_core_dev *dev, u32 id,
4435bbcf09SRaed Salem 		      u64 *packets, u64 *bytes);
4535bbcf09SRaed Salem 
4635bbcf09SRaed Salem int mlx5_cmd_fc_bulk_query(struct mlx5_core_dev *dev, u32 base_id, int bulk_len,
4735bbcf09SRaed Salem 			   u32 *out);
mlx5_cmd_fc_get_bulk_query_out_len(int bulk_len)4835bbcf09SRaed Salem static inline int mlx5_cmd_fc_get_bulk_query_out_len(int bulk_len)
4935bbcf09SRaed Salem {
5035bbcf09SRaed Salem 	return MLX5_ST_SZ_BYTES(query_flow_counter_out) +
5135bbcf09SRaed Salem 		MLX5_ST_SZ_BYTES(traffic_counter) * bulk_len;
5235bbcf09SRaed Salem }
5335bbcf09SRaed Salem 
5435bbcf09SRaed Salem #endif
55