Deleted Added
full compact
mlx5tool.c (347831) mlx5tool.c (347840)
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/usr.sbin/mlx5tool/mlx5tool.c 347831 2019-05-16 17:36:18Z hselasky $");
27__FBSDID("$FreeBSD: stable/11/usr.sbin/mlx5tool/mlx5tool.c 347840 2019-05-16 17:50:15Z hselasky $");
28
29#include <sys/param.h>
30#include <sys/ioctl.h>
31#include <dev/mlx5/mlx5io.h>
32#include <ctype.h>
33#include <err.h>
34#include <errno.h>
35#include <fcntl.h>
36#include <paths.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40#include <unistd.h>
41
42/* stolen from pciconf.c: parsesel() */
43static int
28
29#include <sys/param.h>
30#include <sys/ioctl.h>
31#include <dev/mlx5/mlx5io.h>
32#include <ctype.h>
33#include <err.h>
34#include <errno.h>
35#include <fcntl.h>
36#include <paths.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40#include <unistd.h>
41
42/* stolen from pciconf.c: parsesel() */
43static int
44parse_pci_addr(const char *addrstr, struct mlx5_fwdump_addr *addr)
44parse_pci_addr(const char *addrstr, struct mlx5_tool_addr *addr)
45{
46 char *eppos;
47 unsigned long selarr[4];
48 int i;
49
50 if (addrstr == NULL) {
51 warnx("no pci address specified");
52 return (1);

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

68 return (0);
69 }
70 }
71 warnx("invalid pci address %s", addrstr);
72 return (1);
73}
74
75static int
45{
46 char *eppos;
47 unsigned long selarr[4];
48 int i;
49
50 if (addrstr == NULL) {
51 warnx("no pci address specified");
52 return (1);

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

68 return (0);
69 }
70 }
71 warnx("invalid pci address %s", addrstr);
72 return (1);
73}
74
75static int
76mlx5tool_save_dump(int ctldev, const struct mlx5_fwdump_addr *addr,
76mlx5tool_save_dump(int ctldev, const struct mlx5_tool_addr *addr,
77 const char *dumpname)
78{
79 struct mlx5_fwdump_get fdg;
80 struct mlx5_fwdump_reg *rege;
81 FILE *dump;
82 size_t cnt;
83 int error, res;
84

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

118 res = 0;
119out:
120 if (dump != stdout)
121 fclose(dump);
122 return (res);
123}
124
125static int
77 const char *dumpname)
78{
79 struct mlx5_fwdump_get fdg;
80 struct mlx5_fwdump_reg *rege;
81 FILE *dump;
82 size_t cnt;
83 int error, res;
84

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

118 res = 0;
119out:
120 if (dump != stdout)
121 fclose(dump);
122 return (res);
123}
124
125static int
126mlx5tool_dump_reset(int ctldev, const struct mlx5_fwdump_addr *addr)
126mlx5tool_dump_reset(int ctldev, const struct mlx5_tool_addr *addr)
127{
128
129 if (ioctl(ctldev, MLX5_FWDUMP_RESET, addr) == -1) {
130 warn("MLX5_FWDUMP_RESET");
131 return (1);
132 }
133 return (0);
134}
135
136static int
127{
128
129 if (ioctl(ctldev, MLX5_FWDUMP_RESET, addr) == -1) {
130 warn("MLX5_FWDUMP_RESET");
131 return (1);
132 }
133 return (0);
134}
135
136static int
137mlx5tool_dump_force(int ctldev, const struct mlx5_fwdump_addr *addr)
137mlx5tool_dump_force(int ctldev, const struct mlx5_tool_addr *addr)
138{
139
140 if (ioctl(ctldev, MLX5_FWDUMP_FORCE, addr) == -1) {
141 warn("MLX5_FWDUMP_FORCE");
142 return (1);
143 }
144 return (0);
145}

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

161 ACTION_DUMP_RESET,
162 ACTION_DUMP_FORCE,
163 ACTION_NONE,
164};
165
166int
167main(int argc, char *argv[])
168{
138{
139
140 if (ioctl(ctldev, MLX5_FWDUMP_FORCE, addr) == -1) {
141 warn("MLX5_FWDUMP_FORCE");
142 return (1);
143 }
144 return (0);
145}

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

161 ACTION_DUMP_RESET,
162 ACTION_DUMP_FORCE,
163 ACTION_NONE,
164};
165
166int
167main(int argc, char *argv[])
168{
169 struct mlx5_fwdump_addr addr;
169 struct mlx5_tool_addr addr;
170 char *dumpname;
171 char *addrstr;
172 int c, ctldev, res;
173 enum mlx5_action act;
174
175 act = ACTION_NONE;
176 addrstr = NULL;
177 dumpname = NULL;

--- 47 unchanged lines hidden ---
170 char *dumpname;
171 char *addrstr;
172 int c, ctldev, res;
173 enum mlx5_action act;
174
175 act = ACTION_NONE;
176 addrstr = NULL;
177 dumpname = NULL;

--- 47 unchanged lines hidden ---