aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIdo Shamay <idos@mellanox.com>2015-04-02 09:31:10 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-02 16:25:02 -0400
commit12a889c057504fbf307dd237aedb87263ef2848a (patch)
treeaa3f413fa9da99a37d70d69d1e568d8350ac504e
parent4abccb61578694372dc9b245afd41f55b5f1e546 (diff)
net/mlx4: New file for QoS related firmware commands
Create two new files fw_qos.h and fw_qos.c in mlx4_core module. It gathers all relevant QoS firmware related commands etc, thus improving encapsulation of the mlx4_core module. For now it contains the QoS existing commands: mlx4_SET_PORT_SCHEDULER and mlx4_SET_PORT_PRIO2TC. Signed-off-by: Ido Shamay <idos@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/Makefile5
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/fw_qos.c125
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/fw_qos.h75
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4.h15
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/port.c71
-rw-r--r--include/linux/mlx4/device.h5
7 files changed, 204 insertions, 93 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/Makefile b/drivers/net/ethernet/mellanox/mlx4/Makefile
index 3e9c70f15b42..c82217e0d22d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/Makefile
+++ b/drivers/net/ethernet/mellanox/mlx4/Makefile
@@ -1,7 +1,8 @@
1obj-$(CONFIG_MLX4_CORE) += mlx4_core.o 1obj-$(CONFIG_MLX4_CORE) += mlx4_core.o
2 2
3mlx4_core-y := alloc.o catas.o cmd.o cq.o eq.o fw.o icm.o intf.o main.o mcg.o \ 3mlx4_core-y := alloc.o catas.o cmd.o cq.o eq.o fw.o fw_qos.o icm.o intf.o \
4 mr.o pd.o port.o profile.o qp.o reset.o sense.o srq.o resource_tracker.o 4 main.o mcg.o mr.o pd.o port.o profile.o qp.o reset.o sense.o \
5 srq.o resource_tracker.o
5 6
6obj-$(CONFIG_MLX4_EN) += mlx4_en.o 7obj-$(CONFIG_MLX4_EN) += mlx4_en.o
7 8
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
index 8e3260c0eaa5..f01918c63f28 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
@@ -35,6 +35,7 @@
35#include <linux/math64.h> 35#include <linux/math64.h>
36 36
37#include "mlx4_en.h" 37#include "mlx4_en.h"
38#include "fw_qos.h"
38 39
39/* Definitions for QCN 40/* Definitions for QCN
40 */ 41 */
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw_qos.c b/drivers/net/ethernet/mellanox/mlx4/fw_qos.c
new file mode 100644
index 000000000000..0f5af7cf4547
--- /dev/null
+++ b/drivers/net/ethernet/mellanox/mlx4/fw_qos.c
@@ -0,0 +1,125 @@
1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies.
4 * All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
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 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - 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#include <linux/export.h>
36#include "fw_qos.h"
37
38struct mlx4_set_port_prio2tc_context {
39 u8 prio2tc[4];
40};
41
42struct mlx4_port_scheduler_tc_cfg_be {
43 __be16 pg;
44 __be16 bw_precentage;
45 __be16 max_bw_units; /* 3-100Mbps, 4-1Gbps, other values - reserved */
46 __be16 max_bw_value;
47};
48
49struct mlx4_set_port_scheduler_context {
50 struct mlx4_port_scheduler_tc_cfg_be tc[MLX4_NUM_TC];
51};
52
53int mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc)
54{
55 struct mlx4_cmd_mailbox *mailbox;
56 struct mlx4_set_port_prio2tc_context *context;
57 int err;
58 u32 in_mod;
59 int i;
60
61 mailbox = mlx4_alloc_cmd_mailbox(dev);
62 if (IS_ERR(mailbox))
63 return PTR_ERR(mailbox);
64
65 context = mailbox->buf;
66
67 for (i = 0; i < MLX4_NUM_UP; i += 2)
68 context->prio2tc[i >> 1] = prio2tc[i] << 4 | prio2tc[i + 1];
69
70 in_mod = MLX4_SET_PORT_PRIO2TC << 8 | port;
71 err = mlx4_cmd(dev, mailbox->dma, in_mod, 1, MLX4_CMD_SET_PORT,
72 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
73
74 mlx4_free_cmd_mailbox(dev, mailbox);
75 return err;
76}
77EXPORT_SYMBOL(mlx4_SET_PORT_PRIO2TC);
78
79int mlx4_SET_PORT_SCHEDULER(struct mlx4_dev *dev, u8 port, u8 *tc_tx_bw,
80 u8 *pg, u16 *ratelimit)
81{
82 struct mlx4_cmd_mailbox *mailbox;
83 struct mlx4_set_port_scheduler_context *context;
84 int err;
85 u32 in_mod;
86 int i;
87
88 mailbox = mlx4_alloc_cmd_mailbox(dev);
89 if (IS_ERR(mailbox))
90 return PTR_ERR(mailbox);
91
92 context = mailbox->buf;
93
94 for (i = 0; i < MLX4_NUM_TC; i++) {
95 struct mlx4_port_scheduler_tc_cfg_be *tc = &context->tc[i];
96 u16 r;
97
98 if (ratelimit && ratelimit[i]) {
99 if (ratelimit[i] <= MLX4_MAX_100M_UNITS_VAL) {
100 r = ratelimit[i];
101 tc->max_bw_units =
102 htons(MLX4_RATELIMIT_100M_UNITS);
103 } else {
104 r = ratelimit[i] / 10;
105 tc->max_bw_units =
106 htons(MLX4_RATELIMIT_1G_UNITS);
107 }
108 tc->max_bw_value = htons(r);
109 } else {
110 tc->max_bw_value = htons(MLX4_RATELIMIT_DEFAULT);
111 tc->max_bw_units = htons(MLX4_RATELIMIT_1G_UNITS);
112 }
113
114 tc->pg = htons(pg[i]);
115 tc->bw_precentage = htons(tc_tx_bw[i]);
116 }
117
118 in_mod = MLX4_SET_PORT_SCHEDULER << 8 | port;
119 err = mlx4_cmd(dev, mailbox->dma, in_mod, 1, MLX4_CMD_SET_PORT,
120 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
121
122 mlx4_free_cmd_mailbox(dev, mailbox);
123 return err;
124}
125EXPORT_SYMBOL(mlx4_SET_PORT_SCHEDULER);
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw_qos.h b/drivers/net/ethernet/mellanox/mlx4/fw_qos.h
new file mode 100644
index 000000000000..ab9be0fad9c8
--- /dev/null
+++ b/drivers/net/ethernet/mellanox/mlx4/fw_qos.h
@@ -0,0 +1,75 @@
1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies.
4 * All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
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 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - 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 MLX4_FW_QOS_H
36#define MLX4_FW_QOS_H
37
38#include <linux/mlx4/cmd.h>
39#include <linux/mlx4/device.h>
40
41#define MLX4_NUM_UP 8
42#define MLX4_NUM_TC 8
43
44/**
45 * mlx4_SET_PORT_PRIO2TC - This routine maps user priorities to traffic
46 * classes of a given port and device.
47 *
48 * @dev: mlx4_dev.
49 * @port: Physical port number.
50 * @prio2tc: Array of TC associated with each priorities.
51 *
52 * Returns 0 on success or a negative mlx4_core errno code.
53 **/
54int mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc);
55
56/**
57 * mlx4_SET_PORT_SCHEDULER - This routine configures the arbitration between
58 * traffic classes (ETS) and configured rate limit for traffic classes.
59 * tc_tx_bw, pg and ratelimit are arrays where each index represents a TC.
60 * The description for those parameters below refers to a single TC.
61 *
62 * @dev: mlx4_dev.
63 * @port: Physical port number.
64 * @tc_tx_bw: The percentage of the bandwidth allocated for traffic class
65 * within a TC group. The sum of the bw_percentage of all the traffic
66 * classes within a TC group must equal 100% for correct operation.
67 * @pg: The TC group the traffic class is associated with.
68 * @ratelimit: The maximal bandwidth allowed for the use by this traffic class.
69 *
70 * Returns 0 on success or a negative mlx4_core errno code.
71 **/
72int mlx4_SET_PORT_SCHEDULER(struct mlx4_dev *dev, u8 port, u8 *tc_tx_bw,
73 u8 *pg, u16 *ratelimit);
74
75#endif /* MLX4_FW_QOS_H */
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index 0b16db015745..9e5236b1b5f8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -64,21 +64,6 @@
64 64
65#define INIT_HCA_TPT_MW_ENABLE (1 << 7) 65#define INIT_HCA_TPT_MW_ENABLE (1 << 7)
66 66
67struct mlx4_set_port_prio2tc_context {
68 u8 prio2tc[4];
69};
70
71struct mlx4_port_scheduler_tc_cfg_be {
72 __be16 pg;
73 __be16 bw_precentage;
74 __be16 max_bw_units; /* 3-100Mbps, 4-1Gbps, other values - reserved */
75 __be16 max_bw_value;
76};
77
78struct mlx4_set_port_scheduler_context {
79 struct mlx4_port_scheduler_tc_cfg_be tc[MLX4_NUM_TC];
80};
81
82enum { 67enum {
83 MLX4_HCR_BASE = 0x80680, 68 MLX4_HCR_BASE = 0x80680,
84 MLX4_HCR_SIZE = 0x0001c, 69 MLX4_HCR_SIZE = 0x0001c,
diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c
index b97f173ab062..6a53d42db52f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/port.c
@@ -1016,77 +1016,6 @@ int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
1016} 1016}
1017EXPORT_SYMBOL(mlx4_SET_PORT_qpn_calc); 1017EXPORT_SYMBOL(mlx4_SET_PORT_qpn_calc);
1018 1018
1019int mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc)
1020{
1021 struct mlx4_cmd_mailbox *mailbox;
1022 struct mlx4_set_port_prio2tc_context *context;
1023 int err;
1024 u32 in_mod;
1025 int i;
1026
1027 mailbox = mlx4_alloc_cmd_mailbox(dev);
1028 if (IS_ERR(mailbox))
1029 return PTR_ERR(mailbox);
1030 context = mailbox->buf;
1031 for (i = 0; i < MLX4_NUM_UP; i += 2)
1032 context->prio2tc[i >> 1] = prio2tc[i] << 4 | prio2tc[i + 1];
1033
1034 in_mod = MLX4_SET_PORT_PRIO2TC << 8 | port;
1035 err = mlx4_cmd(dev, mailbox->dma, in_mod, 1, MLX4_CMD_SET_PORT,
1036 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
1037
1038 mlx4_free_cmd_mailbox(dev, mailbox);
1039 return err;
1040}
1041EXPORT_SYMBOL(mlx4_SET_PORT_PRIO2TC);
1042
1043int mlx4_SET_PORT_SCHEDULER(struct mlx4_dev *dev, u8 port, u8 *tc_tx_bw,
1044 u8 *pg, u16 *ratelimit)
1045{
1046 struct mlx4_cmd_mailbox *mailbox;
1047 struct mlx4_set_port_scheduler_context *context;
1048 int err;
1049 u32 in_mod;
1050 int i;
1051
1052 mailbox = mlx4_alloc_cmd_mailbox(dev);
1053 if (IS_ERR(mailbox))
1054 return PTR_ERR(mailbox);
1055 context = mailbox->buf;
1056
1057 for (i = 0; i < MLX4_NUM_TC; i++) {
1058 struct mlx4_port_scheduler_tc_cfg_be *tc = &context->tc[i];
1059 u16 r;
1060
1061 if (ratelimit && ratelimit[i]) {
1062 if (ratelimit[i] <= MLX4_MAX_100M_UNITS_VAL) {
1063 r = ratelimit[i];
1064 tc->max_bw_units =
1065 htons(MLX4_RATELIMIT_100M_UNITS);
1066 } else {
1067 r = ratelimit[i]/10;
1068 tc->max_bw_units =
1069 htons(MLX4_RATELIMIT_1G_UNITS);
1070 }
1071 tc->max_bw_value = htons(r);
1072 } else {
1073 tc->max_bw_value = htons(MLX4_RATELIMIT_DEFAULT);
1074 tc->max_bw_units = htons(MLX4_RATELIMIT_1G_UNITS);
1075 }
1076
1077 tc->pg = htons(pg[i]);
1078 tc->bw_precentage = htons(tc_tx_bw[i]);
1079 }
1080
1081 in_mod = MLX4_SET_PORT_SCHEDULER << 8 | port;
1082 err = mlx4_cmd(dev, mailbox->dma, in_mod, 1, MLX4_CMD_SET_PORT,
1083 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
1084
1085 mlx4_free_cmd_mailbox(dev, mailbox);
1086 return err;
1087}
1088EXPORT_SYMBOL(mlx4_SET_PORT_SCHEDULER);
1089
1090enum { 1019enum {
1091 VXLAN_ENABLE_MODIFY = 1 << 7, 1020 VXLAN_ENABLE_MODIFY = 1 << 7,
1092 VXLAN_STEERING_MODIFY = 1 << 6, 1021 VXLAN_STEERING_MODIFY = 1 << 6,
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 0f7f13d6a03e..b676d0c0111a 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -49,8 +49,6 @@
49#define MSIX_LEGACY_SZ 4 49#define MSIX_LEGACY_SZ 4
50#define MIN_MSIX_P_PORT 5 50#define MIN_MSIX_P_PORT 5
51 51
52#define MLX4_NUM_UP 8
53#define MLX4_NUM_TC 8
54#define MLX4_MAX_100M_UNITS_VAL 255 /* 52#define MLX4_MAX_100M_UNITS_VAL 255 /*
55 * work around: can't set values 53 * work around: can't set values
56 * greater then this value when 54 * greater then this value when
@@ -1311,9 +1309,6 @@ int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu,
1311 u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx); 1309 u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx);
1312int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, 1310int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
1313 u8 promisc); 1311 u8 promisc);
1314int mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc);
1315int mlx4_SET_PORT_SCHEDULER(struct mlx4_dev *dev, u8 port, u8 *tc_tx_bw,
1316 u8 *pg, u16 *ratelimit);
1317int mlx4_SET_PORT_VXLAN(struct mlx4_dev *dev, u8 port, u8 steering, int enable); 1312int mlx4_SET_PORT_VXLAN(struct mlx4_dev *dev, u8 port, u8 steering, int enable);
1318int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx); 1313int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx);
1319int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx); 1314int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);