162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
362306a36Sopenharmony_ci * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies.
462306a36Sopenharmony_ci * All rights reserved.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * This software is available to you under a choice of one of two
762306a36Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
862306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
962306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the
1062306a36Sopenharmony_ci * OpenIB.org BSD license below:
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
1362306a36Sopenharmony_ci *     without modification, are permitted provided that the following
1462306a36Sopenharmony_ci *     conditions are met:
1562306a36Sopenharmony_ci *
1662306a36Sopenharmony_ci *      - Redistributions of source code must retain the above
1762306a36Sopenharmony_ci *        copyright notice, this list of conditions and the following
1862306a36Sopenharmony_ci *        disclaimer.
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
2162306a36Sopenharmony_ci *        copyright notice, this list of conditions and the following
2262306a36Sopenharmony_ci *        disclaimer in the documentation and/or other materials
2362306a36Sopenharmony_ci *        provided with the distribution.
2462306a36Sopenharmony_ci *
2562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2662306a36Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2762306a36Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2862306a36Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2962306a36Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3062306a36Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3162306a36Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3262306a36Sopenharmony_ci * SOFTWARE.
3362306a36Sopenharmony_ci */
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#ifndef MLX4_FW_QOS_H
3662306a36Sopenharmony_ci#define MLX4_FW_QOS_H
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#include <linux/mlx4/cmd.h>
3962306a36Sopenharmony_ci#include <linux/mlx4/device.h>
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define MLX4_NUM_UP 8
4262306a36Sopenharmony_ci#define MLX4_NUM_TC 8
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci/* Default supported priorities for VPP allocation */
4562306a36Sopenharmony_ci#define MLX4_DEFAULT_QOS_PRIO (0)
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci/* Derived from FW feature definition, 0 is the default vport fo all QPs */
4862306a36Sopenharmony_ci#define MLX4_VPP_DEFAULT_VPORT (0)
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_cistruct mlx4_vport_qos_param {
5162306a36Sopenharmony_ci	u32 bw_share;
5262306a36Sopenharmony_ci	u32 max_avg_bw;
5362306a36Sopenharmony_ci	u8 enable;
5462306a36Sopenharmony_ci};
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/**
5762306a36Sopenharmony_ci * mlx4_SET_PORT_PRIO2TC - This routine maps user priorities to traffic
5862306a36Sopenharmony_ci * classes of a given port and device.
5962306a36Sopenharmony_ci *
6062306a36Sopenharmony_ci * @dev: mlx4_dev.
6162306a36Sopenharmony_ci * @port: Physical port number.
6262306a36Sopenharmony_ci * @prio2tc: Array of TC associated with each priorities.
6362306a36Sopenharmony_ci *
6462306a36Sopenharmony_ci * Returns 0 on success or a negative mlx4_core errno code.
6562306a36Sopenharmony_ci **/
6662306a36Sopenharmony_ciint mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc);
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci/**
6962306a36Sopenharmony_ci * mlx4_SET_PORT_SCHEDULER - This routine configures the arbitration between
7062306a36Sopenharmony_ci * traffic classes (ETS) and configured rate limit for traffic classes.
7162306a36Sopenharmony_ci * tc_tx_bw, pg and ratelimit are arrays where each index represents a TC.
7262306a36Sopenharmony_ci * The description for those parameters below refers to a single TC.
7362306a36Sopenharmony_ci *
7462306a36Sopenharmony_ci * @dev: mlx4_dev.
7562306a36Sopenharmony_ci * @port: Physical port number.
7662306a36Sopenharmony_ci * @tc_tx_bw: The percentage of the bandwidth allocated for traffic class
7762306a36Sopenharmony_ci *  within a TC group. The sum of the bw_percentage of all the traffic
7862306a36Sopenharmony_ci *  classes within a TC group must equal 100% for correct operation.
7962306a36Sopenharmony_ci * @pg: The TC group the traffic class is associated with.
8062306a36Sopenharmony_ci * @ratelimit: The maximal bandwidth allowed for the use by this traffic class.
8162306a36Sopenharmony_ci *
8262306a36Sopenharmony_ci * Returns 0 on success or a negative mlx4_core errno code.
8362306a36Sopenharmony_ci **/
8462306a36Sopenharmony_ciint mlx4_SET_PORT_SCHEDULER(struct mlx4_dev *dev, u8 port, u8 *tc_tx_bw,
8562306a36Sopenharmony_ci			    u8 *pg, u16 *ratelimit);
8662306a36Sopenharmony_ci/**
8762306a36Sopenharmony_ci * mlx4_ALLOCATE_VPP_get - Query port VPP available resources and allocation.
8862306a36Sopenharmony_ci * Before distribution of VPPs to priorities, only available_vpp is returned.
8962306a36Sopenharmony_ci * After initialization it returns the distribution of VPPs among priorities.
9062306a36Sopenharmony_ci *
9162306a36Sopenharmony_ci * @dev: mlx4_dev.
9262306a36Sopenharmony_ci * @port: Physical port number.
9362306a36Sopenharmony_ci * @available_vpp: Pointer to variable where number of available VPPs is stored
9462306a36Sopenharmony_ci * @vpp_p_up: Distribution of VPPs to priorities is stored in this array
9562306a36Sopenharmony_ci *
9662306a36Sopenharmony_ci * Returns 0 on success or a negative mlx4_core errno code.
9762306a36Sopenharmony_ci **/
9862306a36Sopenharmony_ciint mlx4_ALLOCATE_VPP_get(struct mlx4_dev *dev, u8 port,
9962306a36Sopenharmony_ci			  u16 *available_vpp, u8 *vpp_p_up);
10062306a36Sopenharmony_ci/**
10162306a36Sopenharmony_ci * mlx4_ALLOCATE_VPP_set - Distribution of VPPs among differnt priorities.
10262306a36Sopenharmony_ci * The total number of VPPs assigned to all for a port must not exceed
10362306a36Sopenharmony_ci * the value reported by available_vpp in mlx4_ALLOCATE_VPP_get.
10462306a36Sopenharmony_ci * VPP allocation is allowed only after the port type has been set,
10562306a36Sopenharmony_ci * and while no QPs are open for this port.
10662306a36Sopenharmony_ci *
10762306a36Sopenharmony_ci * @dev: mlx4_dev.
10862306a36Sopenharmony_ci * @port: Physical port number.
10962306a36Sopenharmony_ci * @vpp_p_up: Allocation of VPPs to different priorities.
11062306a36Sopenharmony_ci *
11162306a36Sopenharmony_ci * Returns 0 on success or a negative mlx4_core errno code.
11262306a36Sopenharmony_ci **/
11362306a36Sopenharmony_ciint mlx4_ALLOCATE_VPP_set(struct mlx4_dev *dev, u8 port, u8 *vpp_p_up);
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci/**
11662306a36Sopenharmony_ci * mlx4_SET_VPORT_QOS_get - Query QoS proporties of a Vport.
11762306a36Sopenharmony_ci * Each priority allowed for the Vport is assigned with a share of the BW,
11862306a36Sopenharmony_ci * and a BW limitation. This commands query the current QoS values.
11962306a36Sopenharmony_ci *
12062306a36Sopenharmony_ci * @dev: mlx4_dev.
12162306a36Sopenharmony_ci * @port: Physical port number.
12262306a36Sopenharmony_ci * @vport: Vport id.
12362306a36Sopenharmony_ci * @out_param: Array of mlx4_vport_qos_param that will contain the values.
12462306a36Sopenharmony_ci *
12562306a36Sopenharmony_ci * Returns 0 on success or a negative mlx4_core errno code.
12662306a36Sopenharmony_ci **/
12762306a36Sopenharmony_ciint mlx4_SET_VPORT_QOS_get(struct mlx4_dev *dev, u8 port, u8 vport,
12862306a36Sopenharmony_ci			   struct mlx4_vport_qos_param *out_param);
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci/**
13162306a36Sopenharmony_ci * mlx4_SET_VPORT_QOS_set - Set QoS proporties of a Vport.
13262306a36Sopenharmony_ci * QoS parameters can be modified at any time, but must be initialized
13362306a36Sopenharmony_ci * before any QP is associated with the VPort.
13462306a36Sopenharmony_ci *
13562306a36Sopenharmony_ci * @dev: mlx4_dev.
13662306a36Sopenharmony_ci * @port: Physical port number.
13762306a36Sopenharmony_ci * @vport: Vport id.
13862306a36Sopenharmony_ci * @in_param: Array of mlx4_vport_qos_param which holds the requested values.
13962306a36Sopenharmony_ci *
14062306a36Sopenharmony_ci * Returns 0 on success or a negative mlx4_core errno code.
14162306a36Sopenharmony_ci **/
14262306a36Sopenharmony_ciint mlx4_SET_VPORT_QOS_set(struct mlx4_dev *dev, u8 port, u8 vport,
14362306a36Sopenharmony_ci			   struct mlx4_vport_qos_param *in_param);
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci#endif /* MLX4_FW_QOS_H */
146