diff options
author | Matan Barak <matanb@mellanox.com> | 2014-11-13 07:45:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-13 15:16:19 -0500 |
commit | e8c4265bea8437f5583d0c2f272058200ebc10ff (patch) | |
tree | 8751f8838a7423c86e9246c49dde7039b834a6db | |
parent | a0eacca948d2d4531a393d82a736ff19b7b8fa0b (diff) |
net/mlx4_core: Add QUERY_FUNC firmware command
QUERY_FUNC firmware command could be used in order to query the
number of EQs, reserved EQs, etc for a specific function.
Signed-off-by: Matan Barak <matanb@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/fw.c | 56 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/fw.h | 11 |
2 files changed, 67 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c index f1a6718968fe..b3bbeb97da14 100644 --- a/drivers/net/ethernet/mellanox/mlx4/fw.c +++ b/drivers/net/ethernet/mellanox/mlx4/fw.c | |||
@@ -177,6 +177,62 @@ int mlx4_MOD_STAT_CFG(struct mlx4_dev *dev, struct mlx4_mod_stat_cfg *cfg) | |||
177 | return err; | 177 | return err; |
178 | } | 178 | } |
179 | 179 | ||
180 | int mlx4_QUERY_FUNC(struct mlx4_dev *dev, struct mlx4_func *func, int slave) | ||
181 | { | ||
182 | struct mlx4_cmd_mailbox *mailbox; | ||
183 | u32 *outbox; | ||
184 | u8 in_modifier; | ||
185 | u8 field; | ||
186 | u16 field16; | ||
187 | int err; | ||
188 | |||
189 | #define QUERY_FUNC_BUS_OFFSET 0x00 | ||
190 | #define QUERY_FUNC_DEVICE_OFFSET 0x01 | ||
191 | #define QUERY_FUNC_FUNCTION_OFFSET 0x01 | ||
192 | #define QUERY_FUNC_PHYSICAL_FUNCTION_OFFSET 0x03 | ||
193 | #define QUERY_FUNC_RSVD_EQS_OFFSET 0x04 | ||
194 | #define QUERY_FUNC_MAX_EQ_OFFSET 0x06 | ||
195 | #define QUERY_FUNC_RSVD_UARS_OFFSET 0x0b | ||
196 | |||
197 | mailbox = mlx4_alloc_cmd_mailbox(dev); | ||
198 | if (IS_ERR(mailbox)) | ||
199 | return PTR_ERR(mailbox); | ||
200 | outbox = mailbox->buf; | ||
201 | |||
202 | in_modifier = slave; | ||
203 | mlx4_dbg(dev, "%s for VF %d\n", __func__, in_modifier); | ||
204 | |||
205 | err = mlx4_cmd_box(dev, 0, mailbox->dma, in_modifier, 0, | ||
206 | MLX4_CMD_QUERY_FUNC, | ||
207 | MLX4_CMD_TIME_CLASS_A, | ||
208 | MLX4_CMD_NATIVE); | ||
209 | if (err) | ||
210 | goto out; | ||
211 | |||
212 | MLX4_GET(field, outbox, QUERY_FUNC_BUS_OFFSET); | ||
213 | func->bus = field & 0xf; | ||
214 | MLX4_GET(field, outbox, QUERY_FUNC_DEVICE_OFFSET); | ||
215 | func->device = field & 0xf1; | ||
216 | MLX4_GET(field, outbox, QUERY_FUNC_FUNCTION_OFFSET); | ||
217 | func->function = field & 0x7; | ||
218 | MLX4_GET(field, outbox, QUERY_FUNC_PHYSICAL_FUNCTION_OFFSET); | ||
219 | func->physical_function = field & 0xf; | ||
220 | MLX4_GET(field16, outbox, QUERY_FUNC_RSVD_EQS_OFFSET); | ||
221 | func->rsvd_eqs = field16 & 0xffff; | ||
222 | MLX4_GET(field16, outbox, QUERY_FUNC_MAX_EQ_OFFSET); | ||
223 | func->max_eq = field16 & 0xffff; | ||
224 | MLX4_GET(field, outbox, QUERY_FUNC_RSVD_UARS_OFFSET); | ||
225 | func->rsvd_uars = field & 0x0f; | ||
226 | |||
227 | mlx4_dbg(dev, "Bus: %d, Device: %d, Function: %d, Physical function: %d, Max EQs: %d, Reserved EQs: %d, Reserved UARs: %d\n", | ||
228 | func->bus, func->device, func->function, func->physical_function, | ||
229 | func->max_eq, func->rsvd_eqs, func->rsvd_uars); | ||
230 | |||
231 | out: | ||
232 | mlx4_free_cmd_mailbox(dev, mailbox); | ||
233 | return err; | ||
234 | } | ||
235 | |||
180 | int mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave, | 236 | int mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave, |
181 | struct mlx4_vhcr *vhcr, | 237 | struct mlx4_vhcr *vhcr, |
182 | struct mlx4_cmd_mailbox *inbox, | 238 | struct mlx4_cmd_mailbox *inbox, |
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.h b/drivers/net/ethernet/mellanox/mlx4/fw.h index 694557e5f4fb..48c11b5e73e7 100644 --- a/drivers/net/ethernet/mellanox/mlx4/fw.h +++ b/drivers/net/ethernet/mellanox/mlx4/fw.h | |||
@@ -145,6 +145,16 @@ struct mlx4_func_cap { | |||
145 | u64 phys_port_id; | 145 | u64 phys_port_id; |
146 | }; | 146 | }; |
147 | 147 | ||
148 | struct mlx4_func { | ||
149 | int bus; | ||
150 | int device; | ||
151 | int function; | ||
152 | int physical_function; | ||
153 | int rsvd_eqs; | ||
154 | int max_eq; | ||
155 | int rsvd_uars; | ||
156 | }; | ||
157 | |||
148 | struct mlx4_adapter { | 158 | struct mlx4_adapter { |
149 | char board_id[MLX4_BOARD_ID_LEN]; | 159 | char board_id[MLX4_BOARD_ID_LEN]; |
150 | u8 inta_pin; | 160 | u8 inta_pin; |
@@ -211,6 +221,7 @@ int mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave, | |||
211 | struct mlx4_cmd_mailbox *inbox, | 221 | struct mlx4_cmd_mailbox *inbox, |
212 | struct mlx4_cmd_mailbox *outbox, | 222 | struct mlx4_cmd_mailbox *outbox, |
213 | struct mlx4_cmd_info *cmd); | 223 | struct mlx4_cmd_info *cmd); |
224 | int mlx4_QUERY_FUNC(struct mlx4_dev *dev, struct mlx4_func *func, int slave); | ||
214 | int mlx4_MAP_FA(struct mlx4_dev *dev, struct mlx4_icm *icm); | 225 | int mlx4_MAP_FA(struct mlx4_dev *dev, struct mlx4_icm *icm); |
215 | int mlx4_UNMAP_FA(struct mlx4_dev *dev); | 226 | int mlx4_UNMAP_FA(struct mlx4_dev *dev); |
216 | int mlx4_RUN_FW(struct mlx4_dev *dev); | 227 | int mlx4_RUN_FW(struct mlx4_dev *dev); |