18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 38c2ecf20Sopenharmony_ci * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. 48c2ecf20Sopenharmony_ci * All rights reserved. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two 78c2ecf20Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 88c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 98c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the 108c2ecf20Sopenharmony_ci * OpenIB.org BSD license below: 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or 138c2ecf20Sopenharmony_ci * without modification, are permitted provided that the following 148c2ecf20Sopenharmony_ci * conditions are met: 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * - Redistributions of source code must retain the above 178c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 188c2ecf20Sopenharmony_ci * disclaimer. 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * - Redistributions in binary form must reproduce the above 218c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 228c2ecf20Sopenharmony_ci * disclaimer in the documentation and/or other materials 238c2ecf20Sopenharmony_ci * provided with the distribution. 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 268c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 278c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 288c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 298c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 308c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 318c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 328c2ecf20Sopenharmony_ci * SOFTWARE. 338c2ecf20Sopenharmony_ci */ 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#ifndef MLX4_FW_QOS_H 368c2ecf20Sopenharmony_ci#define MLX4_FW_QOS_H 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#include <linux/mlx4/cmd.h> 398c2ecf20Sopenharmony_ci#include <linux/mlx4/device.h> 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define MLX4_NUM_UP 8 428c2ecf20Sopenharmony_ci#define MLX4_NUM_TC 8 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* Default supported priorities for VPP allocation */ 458c2ecf20Sopenharmony_ci#define MLX4_DEFAULT_QOS_PRIO (0) 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* Derived from FW feature definition, 0 is the default vport fo all QPs */ 488c2ecf20Sopenharmony_ci#define MLX4_VPP_DEFAULT_VPORT (0) 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistruct mlx4_vport_qos_param { 518c2ecf20Sopenharmony_ci u32 bw_share; 528c2ecf20Sopenharmony_ci u32 max_avg_bw; 538c2ecf20Sopenharmony_ci u8 enable; 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/** 578c2ecf20Sopenharmony_ci * mlx4_SET_PORT_PRIO2TC - This routine maps user priorities to traffic 588c2ecf20Sopenharmony_ci * classes of a given port and device. 598c2ecf20Sopenharmony_ci * 608c2ecf20Sopenharmony_ci * @dev: mlx4_dev. 618c2ecf20Sopenharmony_ci * @port: Physical port number. 628c2ecf20Sopenharmony_ci * @prio2tc: Array of TC associated with each priorities. 638c2ecf20Sopenharmony_ci * 648c2ecf20Sopenharmony_ci * Returns 0 on success or a negative mlx4_core errno code. 658c2ecf20Sopenharmony_ci **/ 668c2ecf20Sopenharmony_ciint mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc); 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/** 698c2ecf20Sopenharmony_ci * mlx4_SET_PORT_SCHEDULER - This routine configures the arbitration between 708c2ecf20Sopenharmony_ci * traffic classes (ETS) and configured rate limit for traffic classes. 718c2ecf20Sopenharmony_ci * tc_tx_bw, pg and ratelimit are arrays where each index represents a TC. 728c2ecf20Sopenharmony_ci * The description for those parameters below refers to a single TC. 738c2ecf20Sopenharmony_ci * 748c2ecf20Sopenharmony_ci * @dev: mlx4_dev. 758c2ecf20Sopenharmony_ci * @port: Physical port number. 768c2ecf20Sopenharmony_ci * @tc_tx_bw: The percentage of the bandwidth allocated for traffic class 778c2ecf20Sopenharmony_ci * within a TC group. The sum of the bw_percentage of all the traffic 788c2ecf20Sopenharmony_ci * classes within a TC group must equal 100% for correct operation. 798c2ecf20Sopenharmony_ci * @pg: The TC group the traffic class is associated with. 808c2ecf20Sopenharmony_ci * @ratelimit: The maximal bandwidth allowed for the use by this traffic class. 818c2ecf20Sopenharmony_ci * 828c2ecf20Sopenharmony_ci * Returns 0 on success or a negative mlx4_core errno code. 838c2ecf20Sopenharmony_ci **/ 848c2ecf20Sopenharmony_ciint mlx4_SET_PORT_SCHEDULER(struct mlx4_dev *dev, u8 port, u8 *tc_tx_bw, 858c2ecf20Sopenharmony_ci u8 *pg, u16 *ratelimit); 868c2ecf20Sopenharmony_ci/** 878c2ecf20Sopenharmony_ci * mlx4_ALLOCATE_VPP_get - Query port VPP available resources and allocation. 888c2ecf20Sopenharmony_ci * Before distribution of VPPs to priorities, only available_vpp is returned. 898c2ecf20Sopenharmony_ci * After initialization it returns the distribution of VPPs among priorities. 908c2ecf20Sopenharmony_ci * 918c2ecf20Sopenharmony_ci * @dev: mlx4_dev. 928c2ecf20Sopenharmony_ci * @port: Physical port number. 938c2ecf20Sopenharmony_ci * @available_vpp: Pointer to variable where number of available VPPs is stored 948c2ecf20Sopenharmony_ci * @vpp_p_up: Distribution of VPPs to priorities is stored in this array 958c2ecf20Sopenharmony_ci * 968c2ecf20Sopenharmony_ci * Returns 0 on success or a negative mlx4_core errno code. 978c2ecf20Sopenharmony_ci **/ 988c2ecf20Sopenharmony_ciint mlx4_ALLOCATE_VPP_get(struct mlx4_dev *dev, u8 port, 998c2ecf20Sopenharmony_ci u16 *available_vpp, u8 *vpp_p_up); 1008c2ecf20Sopenharmony_ci/** 1018c2ecf20Sopenharmony_ci * mlx4_ALLOCATE_VPP_set - Distribution of VPPs among differnt priorities. 1028c2ecf20Sopenharmony_ci * The total number of VPPs assigned to all for a port must not exceed 1038c2ecf20Sopenharmony_ci * the value reported by available_vpp in mlx4_ALLOCATE_VPP_get. 1048c2ecf20Sopenharmony_ci * VPP allocation is allowed only after the port type has been set, 1058c2ecf20Sopenharmony_ci * and while no QPs are open for this port. 1068c2ecf20Sopenharmony_ci * 1078c2ecf20Sopenharmony_ci * @dev: mlx4_dev. 1088c2ecf20Sopenharmony_ci * @port: Physical port number. 1098c2ecf20Sopenharmony_ci * @vpp_p_up: Allocation of VPPs to different priorities. 1108c2ecf20Sopenharmony_ci * 1118c2ecf20Sopenharmony_ci * Returns 0 on success or a negative mlx4_core errno code. 1128c2ecf20Sopenharmony_ci **/ 1138c2ecf20Sopenharmony_ciint mlx4_ALLOCATE_VPP_set(struct mlx4_dev *dev, u8 port, u8 *vpp_p_up); 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci/** 1168c2ecf20Sopenharmony_ci * mlx4_SET_VPORT_QOS_get - Query QoS proporties of a Vport. 1178c2ecf20Sopenharmony_ci * Each priority allowed for the Vport is assigned with a share of the BW, 1188c2ecf20Sopenharmony_ci * and a BW limitation. This commands query the current QoS values. 1198c2ecf20Sopenharmony_ci * 1208c2ecf20Sopenharmony_ci * @dev: mlx4_dev. 1218c2ecf20Sopenharmony_ci * @port: Physical port number. 1228c2ecf20Sopenharmony_ci * @vport: Vport id. 1238c2ecf20Sopenharmony_ci * @out_param: Array of mlx4_vport_qos_param that will contain the values. 1248c2ecf20Sopenharmony_ci * 1258c2ecf20Sopenharmony_ci * Returns 0 on success or a negative mlx4_core errno code. 1268c2ecf20Sopenharmony_ci **/ 1278c2ecf20Sopenharmony_ciint mlx4_SET_VPORT_QOS_get(struct mlx4_dev *dev, u8 port, u8 vport, 1288c2ecf20Sopenharmony_ci struct mlx4_vport_qos_param *out_param); 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci/** 1318c2ecf20Sopenharmony_ci * mlx4_SET_VPORT_QOS_set - Set QoS proporties of a Vport. 1328c2ecf20Sopenharmony_ci * QoS parameters can be modified at any time, but must be initialized 1338c2ecf20Sopenharmony_ci * before any QP is associated with the VPort. 1348c2ecf20Sopenharmony_ci * 1358c2ecf20Sopenharmony_ci * @dev: mlx4_dev. 1368c2ecf20Sopenharmony_ci * @port: Physical port number. 1378c2ecf20Sopenharmony_ci * @vport: Vport id. 1388c2ecf20Sopenharmony_ci * @out_param: Array of mlx4_vport_qos_param which holds the requested values. 1398c2ecf20Sopenharmony_ci * 1408c2ecf20Sopenharmony_ci * Returns 0 on success or a negative mlx4_core errno code. 1418c2ecf20Sopenharmony_ci **/ 1428c2ecf20Sopenharmony_ciint mlx4_SET_VPORT_QOS_set(struct mlx4_dev *dev, u8 port, u8 vport, 1438c2ecf20Sopenharmony_ci struct mlx4_vport_qos_param *in_param); 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci#endif /* MLX4_FW_QOS_H */ 146