112a889c0SIdo Shamay /* 212a889c0SIdo Shamay * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 312a889c0SIdo Shamay * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. 412a889c0SIdo Shamay * All rights reserved. 512a889c0SIdo Shamay * 612a889c0SIdo Shamay * This software is available to you under a choice of one of two 712a889c0SIdo Shamay * licenses. You may choose to be licensed under the terms of the GNU 812a889c0SIdo Shamay * General Public License (GPL) Version 2, available from the file 912a889c0SIdo Shamay * COPYING in the main directory of this source tree, or the 1012a889c0SIdo Shamay * OpenIB.org BSD license below: 1112a889c0SIdo Shamay * 1212a889c0SIdo Shamay * Redistribution and use in source and binary forms, with or 1312a889c0SIdo Shamay * without modification, are permitted provided that the following 1412a889c0SIdo Shamay * conditions are met: 1512a889c0SIdo Shamay * 1612a889c0SIdo Shamay * - Redistributions of source code must retain the above 1712a889c0SIdo Shamay * copyright notice, this list of conditions and the following 1812a889c0SIdo Shamay * disclaimer. 1912a889c0SIdo Shamay * 2012a889c0SIdo Shamay * - Redistributions in binary form must reproduce the above 2112a889c0SIdo Shamay * copyright notice, this list of conditions and the following 2212a889c0SIdo Shamay * disclaimer in the documentation and/or other materials 2312a889c0SIdo Shamay * provided with the distribution. 2412a889c0SIdo Shamay * 2512a889c0SIdo Shamay * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2612a889c0SIdo Shamay * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2712a889c0SIdo Shamay * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2812a889c0SIdo Shamay * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2912a889c0SIdo Shamay * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 3012a889c0SIdo Shamay * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 3112a889c0SIdo Shamay * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3212a889c0SIdo Shamay * SOFTWARE. 3312a889c0SIdo Shamay */ 3412a889c0SIdo Shamay 3512a889c0SIdo Shamay #ifndef MLX4_FW_QOS_H 3612a889c0SIdo Shamay #define MLX4_FW_QOS_H 3712a889c0SIdo Shamay 3812a889c0SIdo Shamay #include <linux/mlx4/cmd.h> 3912a889c0SIdo Shamay #include <linux/mlx4/device.h> 4012a889c0SIdo Shamay 4112a889c0SIdo Shamay #define MLX4_NUM_UP 8 4212a889c0SIdo Shamay #define MLX4_NUM_TC 8 4312a889c0SIdo Shamay 44666672d4SIdo Shamay /* Default supported priorities for VPP allocation */ 45666672d4SIdo Shamay #define MLX4_DEFAULT_QOS_PRIO (0) 46666672d4SIdo Shamay 4708068cd5SIdo Shamay /* Derived from FW feature definition, 0 is the default vport fo all QPs */ 4808068cd5SIdo Shamay #define MLX4_VPP_DEFAULT_VPORT (0) 4908068cd5SIdo Shamay 501c29146dSIdo Shamay struct mlx4_vport_qos_param { 511c29146dSIdo Shamay u32 bw_share; 521c29146dSIdo Shamay u32 max_avg_bw; 531c29146dSIdo Shamay u8 enable; 541c29146dSIdo Shamay }; 551c29146dSIdo Shamay 5612a889c0SIdo Shamay /** 5712a889c0SIdo Shamay * mlx4_SET_PORT_PRIO2TC - This routine maps user priorities to traffic 5812a889c0SIdo Shamay * classes of a given port and device. 5912a889c0SIdo Shamay * 6012a889c0SIdo Shamay * @dev: mlx4_dev. 6112a889c0SIdo Shamay * @port: Physical port number. 6212a889c0SIdo Shamay * @prio2tc: Array of TC associated with each priorities. 6312a889c0SIdo Shamay * 6412a889c0SIdo Shamay * Returns 0 on success or a negative mlx4_core errno code. 6512a889c0SIdo Shamay **/ 6612a889c0SIdo Shamay int mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc); 6712a889c0SIdo Shamay 6812a889c0SIdo Shamay /** 6912a889c0SIdo Shamay * mlx4_SET_PORT_SCHEDULER - This routine configures the arbitration between 7012a889c0SIdo Shamay * traffic classes (ETS) and configured rate limit for traffic classes. 7112a889c0SIdo Shamay * tc_tx_bw, pg and ratelimit are arrays where each index represents a TC. 7212a889c0SIdo Shamay * The description for those parameters below refers to a single TC. 7312a889c0SIdo Shamay * 7412a889c0SIdo Shamay * @dev: mlx4_dev. 7512a889c0SIdo Shamay * @port: Physical port number. 7612a889c0SIdo Shamay * @tc_tx_bw: The percentage of the bandwidth allocated for traffic class 7712a889c0SIdo Shamay * within a TC group. The sum of the bw_percentage of all the traffic 7812a889c0SIdo Shamay * classes within a TC group must equal 100% for correct operation. 7912a889c0SIdo Shamay * @pg: The TC group the traffic class is associated with. 8012a889c0SIdo Shamay * @ratelimit: The maximal bandwidth allowed for the use by this traffic class. 8112a889c0SIdo Shamay * 8212a889c0SIdo Shamay * Returns 0 on success or a negative mlx4_core errno code. 8312a889c0SIdo Shamay **/ 8412a889c0SIdo Shamay int mlx4_SET_PORT_SCHEDULER(struct mlx4_dev *dev, u8 port, u8 *tc_tx_bw, 8512a889c0SIdo Shamay u8 *pg, u16 *ratelimit); 867e95bb99SIdo Shamay /** 87ba5c4dacSColin Ian King * mlx4_ALLOCATE_VPP_get - Query port VPP available resources and allocation. 88ba5c4dacSColin Ian King * Before distribution of VPPs to priorities, only available_vpp is returned. 897e95bb99SIdo Shamay * After initialization it returns the distribution of VPPs among priorities. 907e95bb99SIdo Shamay * 917e95bb99SIdo Shamay * @dev: mlx4_dev. 927e95bb99SIdo Shamay * @port: Physical port number. 93ba5c4dacSColin Ian King * @available_vpp: Pointer to variable where number of available VPPs is stored 947e95bb99SIdo Shamay * @vpp_p_up: Distribution of VPPs to priorities is stored in this array 957e95bb99SIdo Shamay * 967e95bb99SIdo Shamay * Returns 0 on success or a negative mlx4_core errno code. 977e95bb99SIdo Shamay **/ 987e95bb99SIdo Shamay int mlx4_ALLOCATE_VPP_get(struct mlx4_dev *dev, u8 port, 99ba5c4dacSColin Ian King u16 *available_vpp, u8 *vpp_p_up); 1007e95bb99SIdo Shamay /** 1017e95bb99SIdo Shamay * mlx4_ALLOCATE_VPP_set - Distribution of VPPs among differnt priorities. 1027e95bb99SIdo Shamay * The total number of VPPs assigned to all for a port must not exceed 103ba5c4dacSColin Ian King * the value reported by available_vpp in mlx4_ALLOCATE_VPP_get. 1047e95bb99SIdo Shamay * VPP allocation is allowed only after the port type has been set, 1057e95bb99SIdo Shamay * and while no QPs are open for this port. 1067e95bb99SIdo Shamay * 1077e95bb99SIdo Shamay * @dev: mlx4_dev. 1087e95bb99SIdo Shamay * @port: Physical port number. 1097e95bb99SIdo Shamay * @vpp_p_up: Allocation of VPPs to different priorities. 1107e95bb99SIdo Shamay * 1117e95bb99SIdo Shamay * Returns 0 on success or a negative mlx4_core errno code. 1127e95bb99SIdo Shamay **/ 1137e95bb99SIdo Shamay int mlx4_ALLOCATE_VPP_set(struct mlx4_dev *dev, u8 port, u8 *vpp_p_up); 11412a889c0SIdo Shamay 1151c29146dSIdo Shamay /** 1161c29146dSIdo Shamay * mlx4_SET_VPORT_QOS_get - Query QoS proporties of a Vport. 1171c29146dSIdo Shamay * Each priority allowed for the Vport is assigned with a share of the BW, 1181c29146dSIdo Shamay * and a BW limitation. This commands query the current QoS values. 1191c29146dSIdo Shamay * 1201c29146dSIdo Shamay * @dev: mlx4_dev. 1211c29146dSIdo Shamay * @port: Physical port number. 1221c29146dSIdo Shamay * @vport: Vport id. 1231c29146dSIdo Shamay * @out_param: Array of mlx4_vport_qos_param that will contain the values. 1241c29146dSIdo Shamay * 1251c29146dSIdo Shamay * Returns 0 on success or a negative mlx4_core errno code. 1261c29146dSIdo Shamay **/ 1271c29146dSIdo Shamay int mlx4_SET_VPORT_QOS_get(struct mlx4_dev *dev, u8 port, u8 vport, 1281c29146dSIdo Shamay struct mlx4_vport_qos_param *out_param); 1291c29146dSIdo Shamay 1301c29146dSIdo Shamay /** 1311c29146dSIdo Shamay * mlx4_SET_VPORT_QOS_set - Set QoS proporties of a Vport. 1321c29146dSIdo Shamay * QoS parameters can be modified at any time, but must be initialized 1331c29146dSIdo Shamay * before any QP is associated with the VPort. 1341c29146dSIdo Shamay * 1351c29146dSIdo Shamay * @dev: mlx4_dev. 1361c29146dSIdo Shamay * @port: Physical port number. 1371c29146dSIdo Shamay * @vport: Vport id. 138*7c36e785SSaeed Mahameed * @in_param: Array of mlx4_vport_qos_param which holds the requested values. 1391c29146dSIdo Shamay * 1401c29146dSIdo Shamay * Returns 0 on success or a negative mlx4_core errno code. 1411c29146dSIdo Shamay **/ 1421c29146dSIdo Shamay int mlx4_SET_VPORT_QOS_set(struct mlx4_dev *dev, u8 port, u8 vport, 1431c29146dSIdo Shamay struct mlx4_vport_qos_param *in_param); 1441c29146dSIdo Shamay 14512a889c0SIdo Shamay #endif /* MLX4_FW_QOS_H */ 146