Browse Source

[infiniband] Add "ibstat" command

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
299fdabe48
5 changed files with 165 additions and 0 deletions
  1. 7
    0
      src/config/config_infiniband.c
  2. 1
    0
      src/config/general.h
  3. 79
    0
      src/hci/commands/ibmgmt_cmd.c
  4. 16
    0
      src/include/usr/ibmgmt.h
  5. 62
    0
      src/usr/ibmgmt.c

+ 7
- 0
src/config/config_infiniband.c View File

@@ -37,3 +37,10 @@ PROVIDE_REQUIRING_SYMBOL();
37 37
 #ifdef SANBOOT_PROTO_IB_SRP
38 38
 REQUIRE_OBJECT ( ib_srp );
39 39
 #endif
40
+
41
+/*
42
+ * Drag in Infiniband-specific commands
43
+ */
44
+#ifdef IBMGMT_CMD
45
+REQUIRE_OBJECT ( ibmgmt_cmd );
46
+#endif

+ 1
- 0
src/config/general.h View File

@@ -120,6 +120,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
120 120
 #define	CONFIG_CMD		/* Option configuration console */
121 121
 #define	IFMGMT_CMD		/* Interface management commands */
122 122
 #define	IWMGMT_CMD		/* Wireless interface management commands */
123
+#define IBMGMT_CMD		/* Infiniband management commands */
123 124
 #define FCMGMT_CMD		/* Fibre Channel management commands */
124 125
 #define	ROUTE_CMD		/* Routing table management commands */
125 126
 #define IMAGE_CMD		/* Image management commands */

+ 79
- 0
src/hci/commands/ibmgmt_cmd.c View File

@@ -0,0 +1,79 @@
1
+/*
2
+ * Copyright (C) 2016 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
+ * 02110-1301, USA.
18
+ *
19
+ * You can also choose to distribute this program under the terms of
20
+ * the Unmodified Binary Distribution Licence (as given in the file
21
+ * COPYING.UBDL), provided that you have satisfied its requirements.
22
+ */
23
+
24
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25
+
26
+#include <stdio.h>
27
+#include <errno.h>
28
+#include <getopt.h>
29
+#include <ipxe/command.h>
30
+#include <ipxe/parseopt.h>
31
+#include <ipxe/infiniband.h>
32
+#include <usr/ibmgmt.h>
33
+
34
+/** @file
35
+ *
36
+ * Infiniband device management commands
37
+ *
38
+ */
39
+
40
+/** "ibstat" options */
41
+struct ibstat_options {};
42
+
43
+/** "ibstat" option list */
44
+static struct option_descriptor ibstat_opts[] = {};
45
+
46
+/** "ibstat" command descriptor */
47
+static struct command_descriptor ibstat_cmd =
48
+	COMMAND_DESC ( struct ibstat_options, ibstat_opts, 0, 0, "" );
49
+
50
+/**
51
+ * The "ibstat" command
52
+ *
53
+ * @v argc		Argument count
54
+ * @v argv		Argument list
55
+ * @ret rc		Return status code
56
+ */
57
+static int ibstat_exec ( int argc, char **argv ) {
58
+	struct ibstat_options opts;
59
+	struct ib_device *ibdev;
60
+	int rc;
61
+
62
+	/* Parse options */
63
+	if ( ( rc = parse_options ( argc, argv, &ibstat_cmd, &opts ) ) != 0 )
64
+		return rc;
65
+
66
+	/* Show all Infiniband devices */
67
+	for_each_ibdev ( ibdev )
68
+		ibstat ( ibdev );
69
+
70
+	return 0;
71
+}
72
+
73
+/** Infiniband commands */
74
+struct command ibmgmt_commands[] __command = {
75
+	{
76
+		.name = "ibstat",
77
+		.exec = ibstat_exec,
78
+	},
79
+};

+ 16
- 0
src/include/usr/ibmgmt.h View File

@@ -0,0 +1,16 @@
1
+#ifndef _USR_IBMGMT_H
2
+#define _USR_IBMGMT_H
3
+
4
+/** @file
5
+ *
6
+ * Infiniband device management
7
+ *
8
+ */
9
+
10
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
+
12
+struct ib_device;
13
+
14
+extern void ibstat ( struct ib_device *ibdev );
15
+
16
+#endif /* _USR_IBMGMT_H */

+ 62
- 0
src/usr/ibmgmt.c View File

@@ -0,0 +1,62 @@
1
+/*
2
+ * Copyright (C) 2016 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
+ * 02110-1301, USA.
18
+ *
19
+ * You can also choose to distribute this program under the terms of
20
+ * the Unmodified Binary Distribution Licence (as given in the file
21
+ * COPYING.UBDL), provided that you have satisfied its requirements.
22
+ */
23
+
24
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25
+
26
+#include <string.h>
27
+#include <stdio.h>
28
+#include <errno.h>
29
+#include <byteswap.h>
30
+#include <ipxe/infiniband.h>
31
+#include <usr/ibmgmt.h>
32
+
33
+/** @file
34
+ *
35
+ * Infiniband device management
36
+ *
37
+ */
38
+
39
+/**
40
+ * Print status of Infiniband device
41
+ *
42
+ * @v ibdev		Infiniband device
43
+ */
44
+void ibstat ( struct ib_device *ibdev ) {
45
+	struct ib_queue_pair *qp;
46
+
47
+	printf ( "%s: " IB_GUID_FMT " using %s on %s port %d (%s)\n",
48
+		 ibdev->name, IB_GUID_ARGS ( &ibdev->gid.s.guid ),
49
+		 ibdev->dev->driver_name, ibdev->dev->name, ibdev->port,
50
+		 ( ib_is_open ( ibdev ) ? "open" : "closed" ) );
51
+	if ( ib_link_ok ( ibdev ) ) {
52
+		printf ( "  [Link:up LID %d prefix " IB_GUID_FMT "]\n",
53
+			 ibdev->lid, IB_GUID_ARGS ( &ibdev->gid.s.prefix ) );
54
+	} else {
55
+		printf ( "  [Link:down, port state %d]\n", ibdev->port_state );
56
+	}
57
+	list_for_each_entry ( qp, &ibdev->qps, list ) {
58
+		printf ( "  QPN %#lx send %d/%d recv %d/%d %s\n",
59
+			 qp->qpn, qp->send.fill, qp->send.num_wqes,
60
+			 qp->recv.fill, qp->recv.num_wqes, qp->name );
61
+	}
62
+}

Loading…
Cancel
Save