diff options
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/cmd.c | 9 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/fw_qos.c | 89 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/fw_qos.h | 36 | ||||
-rw-r--r-- | include/linux/mlx4/cmd.h | 1 |
4 files changed, 135 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index 79cc5ec57dca..af95231ba3e2 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c | |||
@@ -1464,6 +1464,15 @@ static struct mlx4_cmd_info cmd_info[] = { | |||
1464 | .wrapper = mlx4_CMD_EPERM_wrapper, | 1464 | .wrapper = mlx4_CMD_EPERM_wrapper, |
1465 | }, | 1465 | }, |
1466 | { | 1466 | { |
1467 | .opcode = MLX4_CMD_SET_VPORT_QOS, | ||
1468 | .has_inbox = false, | ||
1469 | .has_outbox = true, | ||
1470 | .out_is_imm = false, | ||
1471 | .encode_slave_id = false, | ||
1472 | .verify = NULL, | ||
1473 | .wrapper = mlx4_CMD_EPERM_wrapper, | ||
1474 | }, | ||
1475 | { | ||
1467 | .opcode = MLX4_CMD_CONF_SPECIAL_QP, | 1476 | .opcode = MLX4_CMD_CONF_SPECIAL_QP, |
1468 | .has_inbox = false, | 1477 | .has_inbox = false, |
1469 | .has_outbox = false, | 1478 | .has_outbox = false, |
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw_qos.c b/drivers/net/ethernet/mellanox/mlx4/fw_qos.c index 5ce3440b99c7..8f2fde0487c4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/fw_qos.c +++ b/drivers/net/ethernet/mellanox/mlx4/fw_qos.c | |||
@@ -42,6 +42,12 @@ enum { | |||
42 | MLX4_ALLOCATE_VPP_QUERY = 0x1 | 42 | MLX4_ALLOCATE_VPP_QUERY = 0x1 |
43 | }; | 43 | }; |
44 | 44 | ||
45 | enum { | ||
46 | /* set vport qos opcode modifiers */ | ||
47 | MLX4_SET_VPORT_QOS_SET = 0x0, | ||
48 | MLX4_SET_VPORT_QOS_QUERY = 0x1 | ||
49 | }; | ||
50 | |||
45 | struct mlx4_set_port_prio2tc_context { | 51 | struct mlx4_set_port_prio2tc_context { |
46 | u8 prio2tc[4]; | 52 | u8 prio2tc[4]; |
47 | }; | 53 | }; |
@@ -63,6 +69,19 @@ struct mlx4_alloc_vpp_param { | |||
63 | __be32 vpp_p_up[MLX4_NUM_UP]; | 69 | __be32 vpp_p_up[MLX4_NUM_UP]; |
64 | }; | 70 | }; |
65 | 71 | ||
72 | struct mlx4_prio_qos_param { | ||
73 | __be32 bw_share; | ||
74 | __be32 max_avg_bw; | ||
75 | __be32 reserved; | ||
76 | __be32 enable; | ||
77 | __be32 reserved1[4]; | ||
78 | }; | ||
79 | |||
80 | struct mlx4_set_vport_context { | ||
81 | __be32 reserved[8]; | ||
82 | struct mlx4_prio_qos_param qos_p_up[MLX4_NUM_UP]; | ||
83 | }; | ||
84 | |||
66 | int mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc) | 85 | int mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc) |
67 | { | 86 | { |
68 | struct mlx4_cmd_mailbox *mailbox; | 87 | struct mlx4_cmd_mailbox *mailbox; |
@@ -198,3 +217,73 @@ int mlx4_ALLOCATE_VPP_set(struct mlx4_dev *dev, u8 port, u8 *vpp_p_up) | |||
198 | return err; | 217 | return err; |
199 | } | 218 | } |
200 | EXPORT_SYMBOL(mlx4_ALLOCATE_VPP_set); | 219 | EXPORT_SYMBOL(mlx4_ALLOCATE_VPP_set); |
220 | |||
221 | int mlx4_SET_VPORT_QOS_get(struct mlx4_dev *dev, u8 port, u8 vport, | ||
222 | struct mlx4_vport_qos_param *out_param) | ||
223 | { | ||
224 | int i; | ||
225 | int err; | ||
226 | struct mlx4_cmd_mailbox *mailbox; | ||
227 | struct mlx4_set_vport_context *ctx; | ||
228 | |||
229 | mailbox = mlx4_alloc_cmd_mailbox(dev); | ||
230 | if (IS_ERR(mailbox)) | ||
231 | return PTR_ERR(mailbox); | ||
232 | |||
233 | ctx = mailbox->buf; | ||
234 | |||
235 | err = mlx4_cmd_box(dev, 0, mailbox->dma, (vport << 8) | port, | ||
236 | MLX4_SET_VPORT_QOS_QUERY, | ||
237 | MLX4_CMD_SET_VPORT_QOS, | ||
238 | MLX4_CMD_TIME_CLASS_A, | ||
239 | MLX4_CMD_NATIVE); | ||
240 | if (err) | ||
241 | goto out; | ||
242 | |||
243 | for (i = 0; i < MLX4_NUM_UP; i++) { | ||
244 | out_param[i].bw_share = be32_to_cpu(ctx->qos_p_up[i].bw_share); | ||
245 | out_param[i].max_avg_bw = | ||
246 | be32_to_cpu(ctx->qos_p_up[i].max_avg_bw); | ||
247 | out_param[i].enable = | ||
248 | !!(be32_to_cpu(ctx->qos_p_up[i].enable) & 31); | ||
249 | } | ||
250 | |||
251 | out: | ||
252 | mlx4_free_cmd_mailbox(dev, mailbox); | ||
253 | |||
254 | return err; | ||
255 | } | ||
256 | EXPORT_SYMBOL(mlx4_SET_VPORT_QOS_get); | ||
257 | |||
258 | int mlx4_SET_VPORT_QOS_set(struct mlx4_dev *dev, u8 port, u8 vport, | ||
259 | struct mlx4_vport_qos_param *in_param) | ||
260 | { | ||
261 | int i; | ||
262 | int err; | ||
263 | struct mlx4_cmd_mailbox *mailbox; | ||
264 | struct mlx4_set_vport_context *ctx; | ||
265 | |||
266 | mailbox = mlx4_alloc_cmd_mailbox(dev); | ||
267 | if (IS_ERR(mailbox)) | ||
268 | return PTR_ERR(mailbox); | ||
269 | |||
270 | ctx = mailbox->buf; | ||
271 | |||
272 | for (i = 0; i < MLX4_NUM_UP; i++) { | ||
273 | ctx->qos_p_up[i].bw_share = cpu_to_be32(in_param[i].bw_share); | ||
274 | ctx->qos_p_up[i].max_avg_bw = | ||
275 | cpu_to_be32(in_param[i].max_avg_bw); | ||
276 | ctx->qos_p_up[i].enable = | ||
277 | cpu_to_be32(in_param[i].enable << 31); | ||
278 | } | ||
279 | |||
280 | err = mlx4_cmd(dev, mailbox->dma, (vport << 8) | port, | ||
281 | MLX4_SET_VPORT_QOS_SET, | ||
282 | MLX4_CMD_SET_VPORT_QOS, | ||
283 | MLX4_CMD_TIME_CLASS_A, | ||
284 | MLX4_CMD_NATIVE); | ||
285 | |||
286 | mlx4_free_cmd_mailbox(dev, mailbox); | ||
287 | return err; | ||
288 | } | ||
289 | EXPORT_SYMBOL(mlx4_SET_VPORT_QOS_set); | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw_qos.h b/drivers/net/ethernet/mellanox/mlx4/fw_qos.h index be79951c44ef..b3fffafff062 100644 --- a/drivers/net/ethernet/mellanox/mlx4/fw_qos.h +++ b/drivers/net/ethernet/mellanox/mlx4/fw_qos.h | |||
@@ -41,6 +41,12 @@ | |||
41 | #define MLX4_NUM_UP 8 | 41 | #define MLX4_NUM_UP 8 |
42 | #define MLX4_NUM_TC 8 | 42 | #define MLX4_NUM_TC 8 |
43 | 43 | ||
44 | struct mlx4_vport_qos_param { | ||
45 | u32 bw_share; | ||
46 | u32 max_avg_bw; | ||
47 | u8 enable; | ||
48 | }; | ||
49 | |||
44 | /** | 50 | /** |
45 | * mlx4_SET_PORT_PRIO2TC - This routine maps user priorities to traffic | 51 | * mlx4_SET_PORT_PRIO2TC - This routine maps user priorities to traffic |
46 | * classes of a given port and device. | 52 | * classes of a given port and device. |
@@ -100,4 +106,34 @@ int mlx4_ALLOCATE_VPP_get(struct mlx4_dev *dev, u8 port, | |||
100 | **/ | 106 | **/ |
101 | int mlx4_ALLOCATE_VPP_set(struct mlx4_dev *dev, u8 port, u8 *vpp_p_up); | 107 | int mlx4_ALLOCATE_VPP_set(struct mlx4_dev *dev, u8 port, u8 *vpp_p_up); |
102 | 108 | ||
109 | /** | ||
110 | * mlx4_SET_VPORT_QOS_get - Query QoS proporties of a Vport. | ||
111 | * Each priority allowed for the Vport is assigned with a share of the BW, | ||
112 | * and a BW limitation. This commands query the current QoS values. | ||
113 | * | ||
114 | * @dev: mlx4_dev. | ||
115 | * @port: Physical port number. | ||
116 | * @vport: Vport id. | ||
117 | * @out_param: Array of mlx4_vport_qos_param that will contain the values. | ||
118 | * | ||
119 | * Returns 0 on success or a negative mlx4_core errno code. | ||
120 | **/ | ||
121 | int mlx4_SET_VPORT_QOS_get(struct mlx4_dev *dev, u8 port, u8 vport, | ||
122 | struct mlx4_vport_qos_param *out_param); | ||
123 | |||
124 | /** | ||
125 | * mlx4_SET_VPORT_QOS_set - Set QoS proporties of a Vport. | ||
126 | * QoS parameters can be modified at any time, but must be initialized | ||
127 | * before any QP is associated with the VPort. | ||
128 | * | ||
129 | * @dev: mlx4_dev. | ||
130 | * @port: Physical port number. | ||
131 | * @vport: Vport id. | ||
132 | * @out_param: Array of mlx4_vport_qos_param which holds the requested values. | ||
133 | * | ||
134 | * Returns 0 on success or a negative mlx4_core errno code. | ||
135 | **/ | ||
136 | int mlx4_SET_VPORT_QOS_set(struct mlx4_dev *dev, u8 port, u8 vport, | ||
137 | struct mlx4_vport_qos_param *in_param); | ||
138 | |||
103 | #endif /* MLX4_FW_QOS_H */ | 139 | #endif /* MLX4_FW_QOS_H */ |
diff --git a/include/linux/mlx4/cmd.h b/include/linux/mlx4/cmd.h index e0f88a098fb8..88326ed0033a 100644 --- a/include/linux/mlx4/cmd.h +++ b/include/linux/mlx4/cmd.h | |||
@@ -69,6 +69,7 @@ enum { | |||
69 | MLX4_CMD_SET_ICM_SIZE = 0xffd, | 69 | MLX4_CMD_SET_ICM_SIZE = 0xffd, |
70 | MLX4_CMD_ACCESS_REG = 0x3b, | 70 | MLX4_CMD_ACCESS_REG = 0x3b, |
71 | MLX4_CMD_ALLOCATE_VPP = 0x80, | 71 | MLX4_CMD_ALLOCATE_VPP = 0x80, |
72 | MLX4_CMD_SET_VPORT_QOS = 0x81, | ||
72 | 73 | ||
73 | /*master notify fw on finish for slave's flr*/ | 74 | /*master notify fw on finish for slave's flr*/ |
74 | MLX4_CMD_INFORM_FLR_DONE = 0x5b, | 75 | MLX4_CMD_INFORM_FLR_DONE = 0x5b, |