Deleted Added
full compact
mlx5_fwdump.c (347844) mlx5_fwdump.c (347869)
1/*-
2 * Copyright (c) 2018, Mellanox Technologies, Ltd. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2018, Mellanox Technologies, Ltd. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: stable/11/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c 347844 2019-05-16 17:57:09Z hselasky $");
27__FBSDID("$FreeBSD: stable/11/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c 347869 2019-05-16 18:20:14Z hselasky $");
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/conf.h>
32#include <sys/fcntl.h>
33#include <dev/mlx5/driver.h>
34#include <dev/mlx5/device.h>
35#include <dev/mlx5/mlx5_core/mlx5_core.h>

--- 185 unchanged lines hidden (view full) ---

221 }
222 }
223out:
224 fwg->reg_filled = i;
225 return (0);
226}
227
228static int
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/conf.h>
32#include <sys/fcntl.h>
33#include <dev/mlx5/driver.h>
34#include <dev/mlx5/device.h>
35#include <dev/mlx5/mlx5_core/mlx5_core.h>

--- 185 unchanged lines hidden (view full) ---

221 }
222 }
223out:
224 fwg->reg_filled = i;
225 return (0);
226}
227
228static int
229mlx5_fw_reset(struct mlx5_core_dev *mdev)
230{
231 device_t dev, bus;
232 int error;
233
234 error = -mlx5_set_mfrl_reg(mdev, MLX5_FRL_LEVEL3);
235 if (error == 0) {
236 dev = mdev->pdev->dev.bsddev;
237 mtx_lock(&Giant);
238 bus = device_get_parent(dev);
239 error = BUS_RESET_CHILD(device_get_parent(bus), bus,
240 DEVF_RESET_DETACH);
241 mtx_unlock(&Giant);
242 }
243 return (error);
244}
245
246static int
229mlx5_fwdump_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
230 struct thread *td)
231{
232 struct mlx5_core_dev *mdev;
233 struct mlx5_fwdump_get *fwg;
234 struct mlx5_tool_addr *devaddr;
235 struct mlx5_dump_data *dd;
236 struct mlx5_fw_update *fu;

--- 65 unchanged lines hidden (view full) ---

302 break;
303 }
304 error = copyin(fu->img_fw_data, __DECONST(void *, fake_fw.data),
305 fu->img_fw_data_len);
306 if (error == 0)
307 error = -mlx5_firmware_flash(mdev, &fake_fw);
308 kmem_free(kmem_arena, (vm_offset_t)fake_fw.data, fu->img_fw_data_len);
309 break;
247mlx5_fwdump_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
248 struct thread *td)
249{
250 struct mlx5_core_dev *mdev;
251 struct mlx5_fwdump_get *fwg;
252 struct mlx5_tool_addr *devaddr;
253 struct mlx5_dump_data *dd;
254 struct mlx5_fw_update *fu;

--- 65 unchanged lines hidden (view full) ---

320 break;
321 }
322 error = copyin(fu->img_fw_data, __DECONST(void *, fake_fw.data),
323 fu->img_fw_data_len);
324 if (error == 0)
325 error = -mlx5_firmware_flash(mdev, &fake_fw);
326 kmem_free(kmem_arena, (vm_offset_t)fake_fw.data, fu->img_fw_data_len);
327 break;
328 case MLX5_FW_RESET:
329 if ((fflag & FWRITE) == 0) {
330 error = EBADF;
331 break;
332 }
333 devaddr = (struct mlx5_tool_addr *)data;
334 error = mlx5_dbsf_to_core(devaddr, &mdev);
335 if (error != 0)
336 break;
337 error = mlx5_fw_reset(mdev);
338 break;
310 default:
311 error = ENOTTY;
312 break;
313 }
314 return (error);
315}
316
317static struct cdevsw mlx5_fwdump_devsw = {

--- 30 unchanged lines hidden ---
339 default:
340 error = ENOTTY;
341 break;
342 }
343 return (error);
344}
345
346static struct cdevsw mlx5_fwdump_devsw = {

--- 30 unchanged lines hidden ---