This is the fifth patch of a set of patches that enables DLC.
This patch adds the new structures which will be used
in the IOCTL communication. It also added a set of
show operations to show buffers, networks, statistics
and peer information.
Signed-off-by: Amir Shehata <amir.shehata@intel.com>
Change-Id: I96e5cb3dcf07289c6cd1deb46f4acb3c263ae21e
Reviewed-on: http://review.whamcloud.com/8022
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Doug Oucharek <doug.s.oucharek@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
#define __LIBCFS_IOCTL_H__
#define LIBCFS_IOCTL_VERSION 0x0001000a
+#define LIBCFS_IOCTL_VERSION2 0x0001000b
struct libcfs_ioctl_hdr {
__u32 ioc_len;
data.ioc_hdr.ioc_len = sizeof(data); \
} while (0)
+#define LIBCFS_IOC_INIT_V2(data, hdr) \
+do { \
+ memset(&(data), 0, sizeof(data)); \
+ (data).hdr.ioc_version = LIBCFS_IOCTL_VERSION2; \
+ (data).hdr.ioc_len = sizeof(data); \
+} while (0)
+
+
#ifdef __KERNEL__
struct libcfs_ioctl_handler {
#define IOCTL_LIBCFS_TYPE long
/* ioctls for manipulating snapshots 30- */
-#define IOC_LIBCFS_TYPE 'e'
-#define IOC_LIBCFS_MIN_NR 30
+#define IOC_LIBCFS_TYPE ('e')
+#define IOC_LIBCFS_MIN_NR 30
/* libcfs ioctls */
#define IOC_LIBCFS_PANIC _IOWR('e', 30, IOCTL_LIBCFS_TYPE)
#define IOC_LIBCFS_CLEAR_DEBUG _IOWR('e', 31, IOCTL_LIBCFS_TYPE)
#define IOC_LIBCFS_MEMHOG _IOWR('e', 36, IOCTL_LIBCFS_TYPE)
#define IOC_LIBCFS_PING_TEST _IOWR('e', 37, IOCTL_LIBCFS_TYPE)
/* lnet ioctls */
-#define IOC_LIBCFS_GET_NI _IOWR('e', 50, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_ADD_ROUTE _IOWR('e', 52, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_DEL_ROUTE _IOWR('e', 53, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_GET_ROUTE _IOWR('e', 54, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_NOTIFY_ROUTER _IOWR('e', 55, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_UNCONFIGURE _IOWR('e', 56, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_NI _IOWR('e', 50, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_NOTIFY_ROUTER _IOWR('e', 55, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_UNCONFIGURE _IOWR('e', 56, IOCTL_LIBCFS_TYPE)
#define IOC_LIBCFS_PORTALS_COMPATIBILITY _IOWR('e', 57, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_LNET_DIST _IOWR('e', 58, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_CONFIGURE _IOWR('e', 59, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_TESTPROTOCOMPAT _IOWR('e', 60, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_PING _IOWR('e', 61, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_DEBUG_PEER _IOWR('e', 62, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_LNETST _IOWR('e', 63, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_LNET_DIST _IOWR('e', 58, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_CONFIGURE _IOWR('e', 59, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_TESTPROTOCOMPAT _IOWR('e', 60, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_PING _IOWR('e', 61, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_DEBUG_PEER _IOWR('e', 62, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_LNETST _IOWR('e', 63, IOCTL_LIBCFS_TYPE)
/* lnd ioctls */
-#define IOC_LIBCFS_REGISTER_MYNID _IOWR('e', 70, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_CLOSE_CONNECTION _IOWR('e', 71, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_PUSH_CONNECTION _IOWR('e', 72, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_GET_CONN _IOWR('e', 73, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_DEL_PEER _IOWR('e', 74, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_ADD_PEER _IOWR('e', 75, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_GET_PEER _IOWR('e', 76, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_GET_TXDESC _IOWR('e', 77, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_ADD_INTERFACE _IOWR('e', 78, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_DEL_INTERFACE _IOWR('e', 79, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_GET_INTERFACE _IOWR('e', 80, IOCTL_LIBCFS_TYPE)
-
-#define IOC_LIBCFS_MAX_NR 80
+#define IOC_LIBCFS_REGISTER_MYNID _IOWR('e', 70, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_CLOSE_CONNECTION _IOWR('e', 71, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_PUSH_CONNECTION _IOWR('e', 72, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_CONN _IOWR('e', 73, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_DEL_PEER _IOWR('e', 74, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_ADD_PEER _IOWR('e', 75, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_PEER _IOWR('e', 76, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_TXDESC _IOWR('e', 77, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_ADD_INTERFACE _IOWR('e', 78, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_DEL_INTERFACE _IOWR('e', 79, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_INTERFACE _IOWR('e', 80, IOCTL_LIBCFS_TYPE)
+
+
+/*
+ * DLC Speicif IOCTL numbers.
+ * In order to maintain backward compatibility with any possible external
+ * tools which might be accessing the IOCTL numbers, a new group of IOCTL
+ * number have been allocated.
+ */
+#define IOCTL_CONFIG_SIZE struct lnet_ioctl_config_data
+#define IOC_LIBCFS_ADD_ROUTE _IOWR(IOC_LIBCFS_TYPE, 81, \
+ IOCTL_CONFIG_SIZE)
+#define IOC_LIBCFS_DEL_ROUTE _IOWR(IOC_LIBCFS_TYPE, 82, \
+ IOCTL_CONFIG_SIZE)
+#define IOC_LIBCFS_GET_ROUTE _IOWR(IOC_LIBCFS_TYPE, 83, \
+ IOCTL_CONFIG_SIZE)
+#define IOC_LIBCFS_ADD_NET _IOWR(IOC_LIBCFS_TYPE, 84, \
+ IOCTL_CONFIG_SIZE)
+#define IOC_LIBCFS_DEL_NET _IOWR(IOC_LIBCFS_TYPE, 85, \
+ IOCTL_CONFIG_SIZE)
+#define IOC_LIBCFS_GET_NET _IOWR(IOC_LIBCFS_TYPE, 86, \
+ IOCTL_CONFIG_SIZE)
+#define IOC_LIBCFS_CONFIG_RTR _IOWR(IOC_LIBCFS_TYPE, 87, \
+ IOCTL_CONFIG_SIZE)
+#define IOC_LIBCFS_ADD_BUF _IOWR(IOC_LIBCFS_TYPE, 88, \
+ IOCTL_CONFIG_SIZE)
+#define IOC_LIBCFS_GET_BUF _IOWR(IOC_LIBCFS_TYPE, 89, \
+ IOCTL_CONFIG_SIZE)
+#define IOC_LIBCFS_GET_PEER_INFO _IOWR(IOC_LIBCFS_TYPE, 90, \
+ IOCTL_CONFIG_SIZE)
+#define IOC_LIBCFS_GET_LNET_STATS _IOWR(IOC_LIBCFS_TYPE, 91, \
+ IOCTL_CONFIG_SIZE)
+#define IOC_LIBCFS_MAX_NR 91
static inline int libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
{
if (copy_from_user(&hdr, arg, sizeof(hdr)))
RETURN(-EFAULT);
- if (hdr.ioc_version != LIBCFS_IOCTL_VERSION) {
+ if (hdr.ioc_version != LIBCFS_IOCTL_VERSION &&
+ hdr.ioc_version != LIBCFS_IOCTL_VERSION2) {
CERROR("LNET: version mismatch expected %#x, got %#x\n",
LIBCFS_IOCTL_VERSION, hdr.ioc_version);
RETURN(-EINVAL);
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- if ( _IOC_TYPE(cmd) != IOC_LIBCFS_TYPE ||
- _IOC_NR(cmd) < IOC_LIBCFS_MIN_NR ||
- _IOC_NR(cmd) > IOC_LIBCFS_MAX_NR ) {
+ if (_IOC_TYPE(cmd) != IOC_LIBCFS_TYPE ||
+ _IOC_NR(cmd) < IOC_LIBCFS_MIN_NR ||
+ _IOC_NR(cmd) > IOC_LIBCFS_MAX_NR) {
CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n",
_IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd));
return (-EINVAL);
*/
#define DEBUG_SUBSYSTEM S_LNET
-/* TODO - This will be completed in the subsequent patches.
- * For this patch the MAX is hardcoded, in the next patch
- * the value will be set to the largest data structure that
- * can be sent from user space */
-#define LIBCFS_MAX_IOCTL_BUF_LEN 2048
+#define LNET_MAX_IOCTL_BUF_LEN (sizeof(struct lnet_ioctl_net_config) + \
+ sizeof(struct lnet_ioctl_config_data))
#include <libcfs/libcfs.h>
#include <libcfs/libcfs_crypto.h>
#include <lnet/lib-lnet.h>
+#include <lnet/lib-dlc.h>
#include <lnet/lnet.h>
#include "tracefile.h"
int err;
ENTRY;
- /* TODO: this is going to change in subsequent patches
- * to exclude messages which use the new data structures */
- if ((cmd <= IOC_LIBCFS_LNETST) ||
- (cmd >= IOC_LIBCFS_REGISTER_MYNID)) {
+ /* The libcfs_ioctl_data_adjust() function performs adjustment
+ * operations on the libcfs_ioctl_data structure to make
+ * it usable by the code. This doesn't need to be called
+ * for new data structures added. */
+ if (hdr->ioc_version == LIBCFS_IOCTL_VERSION) {
data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr);
err = libcfs_ioctl_data_adjust(data);
if (err != 0) {
* do a check here to restrict the size of the memory
* to allocate to guard against DoS attacks.
*/
- if (buf_len > LIBCFS_MAX_IOCTL_BUF_LEN) {
+ if (buf_len > LNET_MAX_IOCTL_BUF_LEN) {
CERROR("LNET: user buffer exceeds kernel buffer\n");
RETURN(-EINVAL);
}
DIST_SUBDIRS = linux
EXTRA_DIST = api.h api-support.h \
- lib-lnet.h lib-types.h lnet.h lnetctl.h types.h \
+ lib-dlc.h lib-lnet.h lib-types.h lnet.h lnetctl.h types.h \
socklnd.h lnetst.h
--- /dev/null
+/*
+ * LGPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright (c) 2013, Intel Corporation, All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3.0 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.
+ *
+ * LGPL HEADER END
+ *
+ * Contributers:
+ * Amir Shehata
+ */
+
+#ifndef LNET_DLC_H
+#define LNET_DLC_H
+
+#include <libcfs/libcfs_ioctl.h>
+#include <lnet/lib-types.h>
+
+#define MAX_NUM_SHOW_ENTRIES 32
+#define LNET_MAX_STR_LEN 128
+#define LNET_MAX_SHOW_NUM_CPT 128
+
+struct lnet_ioctl_net_config {
+ char ni_interfaces[LNET_MAX_INTERFACES][LNET_MAX_STR_LEN];
+ __u32 ni_status;
+ __u32 ni_cpts[LNET_MAX_SHOW_NUM_CPT];
+};
+
+struct lnet_ioctl_pool_cfg {
+ struct {
+ __u32 pl_npages;
+ __u32 pl_nbuffers;
+ __u32 pl_credits;
+ __u32 pl_mincredits;
+ } pl_pools[LNET_NRBPOOLS];
+ __u32 pl_routing;
+};
+
+struct lnet_ioctl_config_data {
+ struct libcfs_ioctl_hdr cfg_hdr;
+
+ __u32 cfg_net;
+ __u32 cfg_count;
+ __u64 cfg_nid;
+ __u32 cfg_ncpts;
+
+ union {
+ struct {
+ __u32 rtr_hop;
+ __u32 rtr_priority;
+ __u32 rtr_flags;
+ } cfg_route;
+ struct {
+ char net_intf[LNET_MAX_STR_LEN];
+ __s32 net_peer_timeout;
+ __s32 net_peer_tx_credits;
+ __s32 net_peer_rtr_credits;
+ __s32 net_max_tx_credits;
+ } cfg_net;
+ struct {
+ __u32 buf_enable;
+ __s32 buf_tiny;
+ __s32 buf_small;
+ __s32 buf_large;
+ } cfg_buffers;
+ } cfg_config_u;
+
+ char cfg_bulk[0];
+};
+
+struct lnet_ioctl_peer {
+ struct libcfs_ioctl_hdr pr_hdr;
+ __u32 pr_count;
+ __u32 pr_pad;
+ __u64 pr_nid;
+
+ union {
+ struct {
+ char cr_aliveness[LNET_MAX_STR_LEN];
+ __u32 cr_refcount;
+ __u32 cr_ni_peer_tx_credits;
+ __u32 cr_peer_tx_credits;
+ __u32 cr_peer_rtr_credits;
+ __u32 cr_peer_min_rtr_credits;
+ __u32 cr_peer_tx_qnob;
+ __u32 cr_ncpt;
+ } pr_peer_credits;
+ } pr_lnd_u;
+};
+
+struct lnet_ioctl_lnet_stats {
+ struct libcfs_ioctl_hdr st_hdr;
+ struct lnet_counters st_cntrs;
+};
+
+#endif /* LNET_DLC_H */
void lnet_peer_tables_destroy(void);
int lnet_peer_tables_create(void);
void lnet_debug_peer(lnet_nid_t nid);
+int lnet_get_peers(int count, __u64 *nid, char *alivness,
+ int *ncpt, int *refcount,
+ int *ni_peer_tx_credits, int *peer_tx_credits,
+ int *peer_rtr_credits, int *peer_min_rtr_credtis,
+ int *peer_tx_qnob);
#ifndef __KERNEL__
static inline int
struct list_head tq_delayed; /* delayed TXs */
};
-#define LNET_MAX_INTERFACES 16
+#define LNET_MAX_INTERFACES 16
typedef struct lnet_ni {
#ifdef __KERNEL__
lnet_kiov_t rb_kiov[0]; /* the buffer space */
} lnet_rtrbuf_t;
-typedef struct {
- __u32 msgs_alloc;
- __u32 msgs_max;
- __u32 errors;
- __u32 send_count;
- __u32 recv_count;
- __u32 route_count;
- __u32 drop_count;
- __u64 send_length;
- __u64 recv_length;
- __u64 route_length;
- __u64 drop_length;
+typedef struct lnet_counters {
+ __u32 msgs_alloc;
+ __u32 msgs_max;
+ __u32 errors;
+ __u32 send_count;
+ __u32 recv_count;
+ __u32 route_count;
+ __u32 drop_count;
+ __u64 send_length;
+ __u64 recv_length;
+ __u64 route_length;
+ __u64 drop_length;
} WIRE_ATTR lnet_counters_t;
#define LNET_PEER_HASHSIZE 503 /* prime! */
#define DEBUG_SUBSYSTEM S_LNET
#include <lnet/lib-lnet.h>
+#include <lnet/lib-dlc.h>
#ifdef __KERNEL__
#include <linux/log2.h>
#endif
LNetCtl(unsigned int cmd, void *arg)
{
struct libcfs_ioctl_data *data = arg;
+ struct lnet_ioctl_config_data *config;
lnet_process_id_t id = {0};
lnet_ni_t *ni;
int rc;
return (rc != 0) ? rc : lnet_check_routes();
case IOC_LIBCFS_DEL_ROUTE:
+ config = arg;
LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex);
- rc = lnet_del_route(data->ioc_net, data->ioc_nid);
+ rc = lnet_del_route(config->cfg_net, config->cfg_nid);
LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex);
return rc;
case IOC_LIBCFS_GET_ROUTE:
- return lnet_get_route(data->ioc_count,
- &data->ioc_net, &data->ioc_count,
- &data->ioc_nid, &data->ioc_flags,
- &data->ioc_priority);
+ config = arg;
+ return lnet_get_route(config->cfg_count,
+ &config->cfg_net,
+ &config->cfg_config_u.cfg_route.rtr_hop,
+ &config->cfg_nid,
+ &config->cfg_config_u.cfg_route.rtr_flags,
+ &config->cfg_config_u.cfg_route.
+ rtr_priority);
+
+ case IOC_LIBCFS_ADD_NET:
+ return 0;
+
+ case IOC_LIBCFS_DEL_NET:
+ return 0;
+
+ case IOC_LIBCFS_GET_NET:
+ return 0;
+
+ case IOC_LIBCFS_GET_LNET_STATS:
+ {
+ struct lnet_ioctl_lnet_stats *lnet_stats = arg;
+
+ lnet_counters_get(&lnet_stats->st_cntrs);
+ return 0;
+ }
+
+#if defined(__KERNEL__) && defined(LNET_ROUTER)
+ case IOC_LIBCFS_CONFIG_RTR:
+ return 0;
+
+ case IOC_LIBCFS_ADD_BUF:
+ return 0;
+#endif
+
+ case IOC_LIBCFS_GET_BUF:
+ return 0;
+
+ case IOC_LIBCFS_GET_PEER_INFO:
+ return 0;
+
case IOC_LIBCFS_NOTIFY_ROUTER:
return lnet_notify(NULL, data->ioc_nid, data->ioc_flags,
cfs_time_current() -
#define DEBUG_SUBSYSTEM S_LNET
#include <lnet/lib-lnet.h>
+#include <lnet/lib-dlc.h>
static int config_on_load = 0;
CFS_MODULE_PARM(config_on_load, "i", int, 0444,
case IOC_LIBCFS_UNCONFIGURE:
return lnet_unconfigure();
+ case IOC_LIBCFS_ADD_NET:
+ return LNetCtl(cmd, hdr);
+
default:
/* Passing LNET_PID_ANY only gives me a ref if the net is up
* already; I'll need it to ensure the net can't go down while
#define DEBUG_SUBSYSTEM S_LNET
#include <lnet/lib-lnet.h>
+#include <lnet/lib-dlc.h>
int
lnet_peer_tables_create(void)
lnet_net_unlock(cpt);
}
+
+int lnet_get_peers(int count, __u64 *nid, char *aliveness,
+ int *ncpt, int *refcount,
+ int *ni_peer_tx_credits, int *peer_tx_credits,
+ int *peer_rtr_credits, int *peer_min_rtr_credits,
+ int *peer_tx_qnob)
+{
+ struct lnet_peer_table *peer_table;
+ lnet_peer_t *lp;
+ int j;
+ int lncpt, found = 0;
+
+ /* get the number of CPTs */
+ lncpt = cfs_percpt_number(the_lnet.ln_peer_tables);
+ /* if the cpt number to be examined is >= the number of cpts in
+ * the system then indicate that there are no more cpts to examin
+ */
+ if (*ncpt > lncpt)
+ return -1;
+
+ /* get the current table */
+ peer_table = the_lnet.ln_peer_tables[*ncpt];
+ /* if the ptable is NULL then there are no more cpts to examine */
+ if (peer_table == NULL)
+ return -1;
+
+ lnet_net_lock(*ncpt);
+
+ for (j = 0; j < LNET_PEER_HASH_SIZE && !found; j++) {
+ struct list_head *peers = &peer_table->pt_hash[j];
+
+ list_for_each_entry(lp, peers, lp_hashlist) {
+ if (count-- > 0)
+ continue;
+
+ snprintf(aliveness, LNET_MAX_STR_LEN, "NA");
+ if (lnet_isrouter(lp) ||
+ lnet_peer_aliveness_enabled(lp))
+ snprintf(aliveness, LNET_MAX_STR_LEN,
+ lp->lp_alive ? "up" : "down");
+
+ *nid = lp->lp_nid;
+ *refcount = lp->lp_refcount;
+ *ni_peer_tx_credits = lp->lp_ni->ni_peertxcredits;
+ *peer_tx_credits = lp->lp_txcredits;
+ *peer_rtr_credits = lp->lp_rtrcredits;
+ *peer_min_rtr_credits = lp->lp_mintxcredits;
+ *peer_tx_qnob = lp->lp_txqnob;
+
+ found = 1;
+ }
+
+ }
+ lnet_net_unlock(*ncpt);
+
+ *ncpt = lncpt;
+
+ return found ? 0 : -ENOENT;
+}
#include <lnet/api-support.h>
#include <lnet/lnetctl.h>
#include <lnet/socklnd.h>
+#include <lnet/lib-dlc.h>
unsigned int libcfs_debug;
unsigned int libcfs_printk = D_CANTMASK;
int
jt_ptl_add_route (int argc, char **argv)
{
- struct libcfs_ioctl_data data;
- lnet_nid_t gateway_nid;
- unsigned int hops = 1;
+ struct lnet_ioctl_config_data data;
+ lnet_nid_t gateway_nid;
+ unsigned int hops = 1;
unsigned int priority = 0;
- char *end;
- int rc;
+ char *end;
+ int rc;
if (argc < 2 || argc > 4) {
fprintf(stderr, "usage: %s gateway [hopcount [priority]]\n",
return -1;
}
- if (!g_net_is_set(argv[0]))
- return (-1);
+ if (g_net_is_set(argv[0]) == 0)
+ return -1;
- gateway_nid = libcfs_str2nid(argv[1]);
- if (gateway_nid == LNET_NID_ANY) {
- fprintf (stderr, "Can't parse gateway NID \"%s\"\n", argv[1]);
- return (-1);
- }
+ gateway_nid = libcfs_str2nid(argv[1]);
+ if (gateway_nid == LNET_NID_ANY) {
+ fprintf(stderr, "Can't parse gateway NID \"%s\"\n", argv[1]);
+ return -1;
+ }
if (argc > 2) {
hops = strtoul(argv[2], &end, 0);
}
}
- LIBCFS_IOC_INIT(data);
- data.ioc_net = g_net;
- data.ioc_count = hops;
- data.ioc_nid = gateway_nid;
- data.ioc_priority = priority;
+ LIBCFS_IOC_INIT_V2(data, cfg_hdr);
+ data.cfg_net = g_net;
+ data.cfg_config_u.cfg_route.rtr_hop = hops;
+ data.cfg_nid = gateway_nid;
+ data.cfg_config_u.cfg_route.rtr_priority = priority;
- rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_ADD_ROUTE, &data);
- if (rc != 0) {
- fprintf (stderr, "IOC_LIBCFS_ADD_ROUTE failed: %s\n", strerror (errno));
- return (-1);
- }
+ rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_ADD_ROUTE, &data);
+ if (rc != 0) {
+ fprintf(stderr, "IOC_LIBCFS_ADD_ROUTE failed: %s\n",
+ strerror(errno));
+ return -1;
+ }
- return (0);
+ return 0;
}
int
jt_ptl_del_route (int argc, char **argv)
{
- struct libcfs_ioctl_data data;
- lnet_nid_t nid;
- int rc;
+ struct lnet_ioctl_config_data data;
+ lnet_nid_t nid;
+ int rc;
- if (argc != 2) {
- fprintf (stderr, "usage: %s gatewayNID\n", argv[0]);
- return (0);
- }
+ if (argc != 2) {
+ fprintf(stderr, "usage: %s gatewayNID\n", argv[0]);
+ return 0;
+ }
- if (!libcfs_str2anynid(&nid, argv[1])) {
- fprintf (stderr, "Can't parse gateway NID "
- "\"%s\"\n", argv[1]);
- return -1;
- }
+ if (libcfs_str2anynid(&nid, argv[1]) == 0) {
+ fprintf(stderr, "Can't parse gateway NID "
+ "\"%s\"\n", argv[1]);
+ return -1;
+ }
- LIBCFS_IOC_INIT(data);
- data.ioc_net = g_net_set ? g_net : LNET_NIDNET(LNET_NID_ANY);
- data.ioc_nid = nid;
+ LIBCFS_IOC_INIT_V2(data, cfg_hdr);
+ data.cfg_net = g_net_set ? g_net : LNET_NIDNET(LNET_NID_ANY);
+ data.cfg_nid = nid;
- rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_DEL_ROUTE, &data);
- if (rc != 0) {
- fprintf (stderr, "IOC_LIBCFS_DEL_ROUTE (%s) failed: %s\n",
- libcfs_nid2str(nid), strerror (errno));
- return (-1);
- }
+ rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_DEL_ROUTE, &data);
+ if (rc != 0) {
+ fprintf(stderr, "IOC_LIBCFS_DEL_ROUTE (%s) failed: %s\n",
+ libcfs_nid2str(nid), strerror(errno));
+ return -1;
+ }
- return (0);
+ return 0;
}
int
int
jt_ptl_print_routes (int argc, char **argv)
{
- struct libcfs_ioctl_data data;
- int rc;
- int index;
- __u32 net;
- lnet_nid_t nid;
- unsigned int hops;
- int alive;
+ struct lnet_ioctl_config_data data;
+ int rc;
+ int index;
+ __u32 net;
+ lnet_nid_t nid;
+ unsigned int hops;
+ int alive;
unsigned int pri;
- for (index = 0;;index++)
- {
- LIBCFS_IOC_INIT(data);
- data.ioc_count = index;
+ for (index = 0; ; index++) {
+ LIBCFS_IOC_INIT_V2(data, cfg_hdr);
+ data.cfg_count = index;
- rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_ROUTE, &data);
- if (rc != 0)
- break;
+ rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_ROUTE, &data);
+ if (rc != 0)
+ break;
- net = data.ioc_net;
- hops = data.ioc_count;
- nid = data.ioc_nid;
- alive = data.ioc_flags;
- pri = data.ioc_priority;
+ net = data.cfg_net;
+ hops = data.cfg_config_u.cfg_route.rtr_hop;
+ nid = data.cfg_nid;
+ alive = data.cfg_config_u.cfg_route.rtr_flags;
+ pri = data.cfg_config_u.cfg_route.rtr_priority;
printf("net %18s hops %u gw %32s %s pri %u\n",
libcfs_net2str(net), hops,
libcfs_nid2str(nid), alive ? "up" : "down", pri);
- }
+ }
- if (errno != ENOENT)
- fprintf(stderr, "Error getting routes: %s: check dmesg.\n",
- strerror(errno));
+ if (errno != ENOENT)
+ fprintf(stderr, "Error getting routes: %s: check dmesg.\n",
+ strerror(errno));
- return (0);
+ return 0;
}
double