X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Futils%2Flnetconfig%2Fliblnetconfig.h;h=32a985f48c9c09d8c4ab0fb3141418b55c6948f7;hb=17a3b5688435ab5f78baef2fbdb7545d44a80aac;hp=b843b3e1f46cb77db944cc94785e3d6c04b1779f;hpb=d92bd22523aa9bb1cdb91ded3d46fb180f68a93c;p=fs%2Flustre-release.git diff --git a/lnet/utils/lnetconfig/liblnetconfig.h b/lnet/utils/lnetconfig/liblnetconfig.h index b843b3e..32a985f 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.h +++ b/lnet/utils/lnetconfig/liblnetconfig.h @@ -18,7 +18,7 @@ * * LGPL HEADER END * - * Copyright (c) 2014, 2016, Intel Corporation. + * Copyright (c) 2014, 2017, Intel Corporation. * * Author: * Amir Shehata @@ -27,6 +27,16 @@ #ifndef LIB_LNET_CONFIG_API_H #define LIB_LNET_CONFIG_API_H +#include +#include +#include +#include +#include +#include +#include +#include + +#include #include #include #include @@ -39,6 +49,40 @@ #define LUSTRE_CFG_RC_GENERIC_ERR -5 #define LUSTRE_CFG_RC_NO_MATCH -6 #define LUSTRE_CFG_RC_MATCH -7 +#define LUSTRE_CFG_RC_SKIP -8 +#define LUSTRE_CFG_RC_LAST_ELEM -9 +#define LUSTRE_CFG_RC_MARSHAL_FAIL -10 + +#define CONFIG_CMD "configure" +#define UNCONFIG_CMD "unconfigure" +#define ADD_CMD "add" +#define DEL_CMD "del" +#define SHOW_CMD "show" +#define DBG_CMD "dbg" +#define MANAGE_CMD "manage" + +#define MAX_NUM_IPS 128 + +#define modparam_path "/sys/module/lnet/parameters/" +#define o2ib_modparam_path "/sys/module/ko2iblnd/parameters/" +#define gni_nid_path "/proc/cray_xt/" + +enum lnetctl_cmd { + LNETCTL_CONFIG_CMD = 1, + LNETCTL_UNCONFIG_CMD = 2, + LNETCTL_ADD_CMD = 3, + LNETCTL_DEL_CMD = 4, + LNETCTL_SHOW_CMD = 5, + LNETCTL_DBG_CMD = 6, + LNETCTL_MANAGE_CMD = 7, + LNETCTL_LAST_CMD +}; + +/* + * Max number of nids we'll configure for a single peer via a single DLC + * operation + */ +#define LNET_MAX_NIDS_PER_PEER 128 struct lnet_dlc_network_descr { struct list_head network_on_rule; @@ -48,10 +92,61 @@ struct lnet_dlc_network_descr { struct lnet_dlc_intf_descr { struct list_head intf_on_network; - char intf_name[LNET_MAX_STR_LEN]; + char intf_name[IFNAMSIZ]; struct cfs_expr_list *cpt_expr; }; +/* This UDSP structures need to match the kernel space structures + * in order for the marshall and unmarshall functions to be the same. + */ + +/* Net is described as a + * 1. net type + * 2. num range + */ +struct lnet_ud_net_descr { + __u32 udn_net_type; + struct list_head udn_net_num_range; +}; + +/* each NID range is defined as + * 1. net descriptor + * 2. address range descriptor + */ +struct lnet_ud_nid_descr { + struct lnet_ud_net_descr ud_net_id; + struct list_head ud_addr_range; +}; + +/* a UDSP rule can have up to three user defined NID descriptors + * - src: defines the local NID range for the rule + * - dst: defines the peer NID range for the rule + * - rte: defines the router NID range for the rule + * + * An action union defines the action to take when the rule + * is matched + */ +struct lnet_udsp { + struct list_head udsp_on_list; + __u32 udsp_idx; + struct lnet_ud_nid_descr udsp_src; + struct lnet_ud_nid_descr udsp_dst; + struct lnet_ud_nid_descr udsp_rte; + enum lnet_udsp_action_type udsp_action_type; + union { + __u32 udsp_priority; + } udsp_action; +}; + +/* This union is passed from lnetctl to fill the action union in udsp + * structure + * TODO: The idea here is if we add extra actions, ex: drop, it can be + * added to the union + */ +union lnet_udsp_action { + int udsp_priority; +}; + /* forward declaration of the cYAML structure. */ struct cYAML; @@ -89,11 +184,12 @@ int lustre_lnet_config_ni_system(bool up, bool load_ni_from_mod, * gw - gateway * hops - number of hops passed down by the user * prio - priority of the route + * sen - health sensitivity value for the gateway * seq_no - sequence number of the request * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller */ int lustre_lnet_config_route(char *nw, char *gw, int hops, int prio, - int seq_no, struct cYAML **err_rc); + int sen, int seq_no, struct cYAML **err_rc); /* * lustre_lnet_del_route @@ -123,11 +219,13 @@ int lustre_lnet_del_route(char *nw, char *gw, int seq_no, * seq_no - sequence number of the request * show_rc - [OUT] The show output in YAML. Must be freed by caller. * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller + * backup - true to output only what's necessary for reconfiguring + * a node. */ int lustre_lnet_show_route(char *nw, char *gw, int hops, int prio, int detail, int seq_no, struct cYAML **show_rc, - struct cYAML **err_rc); + struct cYAML **err_rc, bool backup); /* * lustre_lnet_config_ni @@ -172,9 +270,12 @@ int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw, * seq_no - sequence number of the request * show_rc - [OUT] The show output in YAML. Must be freed by caller. * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller + * backup - true to output only what's necessary for reconfiguring + * a node. */ int lustre_lnet_show_net(char *nw, int detail, int seq_no, - struct cYAML **show_rc, struct cYAML **err_rc); + struct cYAML **show_rc, struct cYAML **err_rc, + bool backup); /* * lustre_lnet_enable_routing @@ -217,6 +318,283 @@ int lustre_lnet_show_numa_range(int seq_no, struct cYAML **show_rc, struct cYAML **err_rc); /* + * lustre_lnet_config_ni_healthv + * set the health value of the NI. -1 resets the value to maximum. + * + * value: health value to set. + * all: true to set all local NIs to that value. + * ni_nid: NI NID to set its health value. all parameter always takes + * precedence + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_config_ni_healthv(int value, bool all, char *ni_nid, + int seq_no, struct cYAML **err_rc); + + +/* lustre_lnet_config_ni_conns_per_peer + * set the conns_per_peer value of the NI. Valid range is specific to + * network type. + * + * value: conns_per_peer value to set. + * all: true to set all local NIs to that value. + * ni_nid: NI NID to set its conns_per_peer value. 'all' parameter always + * takes precedence + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_config_ni_conns_per_peer(int value, bool all, char *ni_nid, + int seq_no, struct cYAML **err_rc); + +/* + * lustre_lnet_config_peer_ni_healthv + * set the health value of the peer NI. -1 resets the value to maximum. + * + * value: health value to set. + * all: true to set all local NIs to that value. + * pni_nid: Peer NI NID to set its health value. all parameter always takes + * precedence + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_config_peer_ni_healthv(int value, bool all, char *pni_nid, + int seq_no, struct cYAML **err_rc); + +/* + * lustre_lnet_config_recov_intrv + * set the recovery interval in seconds. That's the interval to ping an + * unhealthy interface. + * + * intrv - recovery interval value to configure + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_config_recov_intrv(int intrv, int seq_no, struct cYAML **err_rc); + +/* + * lustre_lnet_show_recov_intrv + * show the recovery interval set in the system + * + * seq_no - sequence number of the request + * show_rc - [OUT] struct cYAML tree containing health sensitivity info + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_show_recov_intrv(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + +/* + * lustre_lnet_config_rtr_sensitivity + * sets the router sensitivity percentage. If the percentage health + * of a router interface drops below that it's considered failed + * + * sen - sensitivity value to configure + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_config_rtr_sensitivity(int sen, int seq_no, struct cYAML **err_rc); + +/* + * lustre_lnet_config_hsensitivity + * sets the health sensitivity; the value by which to decrement the + * health value of a local or peer NI. If 0 then health is turned off + * + * sen - sensitivity value to configure + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_config_hsensitivity(int sen, int seq_no, struct cYAML **err_rc); + +/* + * lustre_lnet_show_hsensitivity + * show the health sensitivity in the system + * + * seq_no - sequence number of the request + * show_rc - [OUT] struct cYAML tree containing health sensitivity info + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_show_hsensitivity(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + +/* + * lustre_lnet_show_rtr_sensitivity + * show the router sensitivity percentage in the system + * + * seq_no - sequence number of the request + * show_rc - [OUT] struct cYAML tree containing health sensitivity info + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_show_rtr_sensitivity(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + +/* + * lustre_lnet_config_transaction_to + * sets the timeout after which a message expires or a timeout event is + * propagated for an expired response. + * + * timeout - timeout value to configure + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_config_transaction_to(int timeout, int seq_no, struct cYAML **err_rc); + +/* + * lustre_lnet_show_transaction_to + * show the transaction timeout in the system + * + * seq_no - sequence number of the request + * show_rc - [OUT] struct cYAML tree containing transaction timeout info + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_show_transaction_to(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + +/* + * lustre_lnet_config_retry_count + * sets the maximum number of retries to resend a message + * + * count - maximum value to configure + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_config_retry_count(int count, int seq_no, struct cYAML **err_rc); + +/* + * lustre_lnet_show_retry_count + * show current maximum number of retries in the system + * + * seq_no - sequence number of the request + * show_rc - [OUT] struct cYAML tree containing retry count info + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_show_retry_count(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + +int lustre_lnet_show_lnd_timeout(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + +int lustre_lnet_show_local_ni_recovq(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + +int lustre_lnet_show_peer_ni_recovq(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); +int lustre_lnet_config_response_tracking(int count, int seq_no, + struct cYAML **err_rc); +int lustre_lnet_show_response_tracking(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); +int lustre_lnet_config_recovery_limit(int val, int seq_no, + struct cYAML **err_rc); +int lustre_lnet_show_recovery_limit(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); +int lustre_lnet_show_max_recovery_ping_interval(int seq_no, + struct cYAML **show_rc, + struct cYAML **err_rc); + +/* + * lustre_lnet_config_max_intf + * Sets the maximum number of interfaces per node. this tunable is + * primarily useful for sanity checks prior to allocating memory. + * + * max - maximum value to configure + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_config_max_intf(int max, int seq_no, struct cYAML **err_rc); + +/* + * lustre_lnet_show_max_intf + * show current maximum interface setting + * + * seq_no - sequence number of the request + * show_rc - [OUT] struct cYAML tree containing NUMA range info + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_show_max_intf(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + +/* + * lustre_lnet_calc_service_id + * Calculate the lustre service id to be used for qos + */ +int lustre_lnet_calc_service_id(__u64 *service_id); + +/* + * lustre_lnet_setup_mrrouting + * configure linux routing tables for tcp interfaces + * + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_setup_mrrouting(struct cYAML **err_rc); + +/* + * lustre_lnet_calc_cpt_of_nid + * Return the cpt number of the NID provided + */ +int lustre_lnet_calc_cpt_of_nid(char *nidc, long int ncpts); + +/* + * lustre_lnet_config_discovery + * Enable or disable peer discovery. Peer discovery is enabled by default. + * + * enable - non-0 enables, 0 disables + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_config_discovery(int enable, int seq_no, struct cYAML **err_rc); + +/* + * lustre_lnet_show_discovery + * show current peer discovery setting + * + * seq_no - sequence number of the request + * show_rc - [OUT] struct cYAML tree containing NUMA range info + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_show_discovery(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + +/* + * lustre_lnet_config_drop_asym_route + * Drop or accept asymmetrical route messages. Accept by default. + * + * drop - non-0 drops, 0 accepts + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_config_drop_asym_route(int drop, int seq_no, + struct cYAML **err_rc); + +/* + * lustre_lnet_show_drop_asym_route + * show current drop asym route setting + * + * seq_no - sequence number of the request + * show_rc - [OUT] struct cYAML tree containing NUMA range info + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_show_drop_asym_route(int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + +/* * lustre_lnet_config_buffers * Send down an IOCTL to configure routing buffer sizes. A value of 0 means * default that particular buffer to default size. A value of -1 means @@ -232,6 +610,17 @@ int lustre_lnet_config_buffers(int tiny, int small, int large, int seq_no, struct cYAML **err_rc); /* + * lustre_lnet_config_max_recovery_ping_interval + * Set the maximum recovery ping interval. + * + * interval - interval value in seconds + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller + */ +int lustre_lnet_config_max_recovery_ping_interval(int interval, int seq_no, + struct cYAML **err_rc); + +/* * lustre_lnet_show_routing * Send down an IOCTL to dump buffers and routing status * This function is used to dump buffers for all CPU partitions. @@ -239,9 +628,11 @@ int lustre_lnet_config_buffers(int tiny, int small, int large, * seq_no - sequence number of the request * show_rc - [OUT] The show output in YAML. Must be freed by caller. * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller + * backup - true to output only what's necessary for reconfiguring + * a node. */ int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc, - struct cYAML **err_rc); + struct cYAML **err_rc, bool backup); /* * lustre_lnet_show_stats @@ -256,43 +647,42 @@ int lustre_lnet_show_stats(int seq_no, struct cYAML **show_rc, struct cYAML **err_rc); /* - * lustre_lnet_config_peer_nid - * Add a peer nid to a peer with primary nid pnid. If no pnid is given - * then the first nid in the nid list becomes the primary nid for - * a newly created peer. - * Otherwise if pnid is provided and it's unique then a new peer is - * created with pnid as the primary NID and the nids in the nid list as - * secondary nids. - * If any of the peers nids provided in with exception to the pnid is - * not unique the operation fails. Some peer nids might have already - * been added. It's the role of the caller of this API to remove the - * added NIDs if they wish. - * - * pnid - Primary NID of the peer - * nid - list of nids to add - * num_nids - number of nids in the nid array - * mr - true if this peer is MR capable. - * seq_no - sequence number of the command + * lustre_lnet_reset_stats + * Resets internal LNET statistics. + * * err_rc - YAML strucutre of the resultant return code. */ -int lustre_lnet_config_peer_nid(char *pnid, char **nid, int num_nids, - bool mr, int seq_no, struct cYAML **err_rc); +int lustre_lnet_reset_stats(int seq_no, struct cYAML **err_rc); /* - * lustre_lnet_del_peer_nid - * Delete the nids given in the nid list from the peer with primary NID - * pnid. If pnid is NULL or it doesn't identify a peer the operation - * fails and no change happens to the system. + * lustre_lnet_modify_peer + * Handle a peer config or delete operation. + * + * Config Operation: + * Add a peer NID to a peer with primary NID pnid. + * If the provided primary NID is unique, then a new peer is + * created with this primary NID, and the NIDs in the NID list are added as + * secondary NIDs to this new peer. + * If any of the NIDs in the NID list are not unique then the operation + * fails. Some peer NIDs might have already been added. It's the responsibility + * of the caller of this API to remove the added NIDs if so desired. + * + * Delete Operation: + * Delete the NIDs given in the NID list from the peer with the primary NID + * pnid. If pnid is NULL, or it doesn't identify a peer, the operation fails, + * and no change happens to the system. * The operation is aborted on the first NID that fails to be deleted. * - * pnid - Primary NID of the peer - * nid - list of nids to add - * num_nids - number of nids in the nid array - * seq_no - sequence number of the command - * err_rc - YAML strucutre of the resultant return code. + * prim_nid - The desired primary NID of a new peer, or the primary NID of + * an existing peer. + * nids - a comma separated string of nids + * is_mr - Specifies whether this peer is MR capable. + * cmd - CONFIG or DELETE + * seq_no - sequence number of the command + * err_rc - YAML structure of the resultant return code */ -int lustre_lnet_del_peer_nid(char *pnid, char **nid, int num_nids, - int seq_no, struct cYAML **err_rc); +int lustre_lnet_modify_peer(char *prim_nid, char *nids, bool is_mr, + int cmd, int seq_no, struct cYAML **err_rc); /* * lustre_lnet_show_peer @@ -304,11 +694,53 @@ int lustre_lnet_del_peer_nid(char *pnid, char **nid, int num_nids, * seq_no - sequence number of the command * show_rc - YAML structure of the resultant show * err_rc - YAML strucutre of the resultant return code. + * backup - true to output only what's necessary for reconfiguring + * a node. * */ int lustre_lnet_show_peer(char *knid, int detail, int seq_no, + struct cYAML **show_rc, struct cYAML **err_rc, + bool backup); + +/* + * lustre_lnet_list_peer + * List the known peers. + * + * seq_no - sequence number of the command + * show_rc - YAML structure of the resultant show + * err_rc - YAML strucutre of the resultant return code. + * + */ +int lustre_lnet_list_peer(int seq_no, struct cYAML **show_rc, struct cYAML **err_rc); +/* lustre_lnet_ping_nid + * Ping the nid list, pnids. + * + * pnids - NID list to ping. + * src_nidstr - source NID + * timeout - timeout(seconds) for ping. + * seq_no - sequence number of the command. + * show_rc - YAML structure of the resultant show. + * err_rc - YAML strucutre of the resultant return code. + * + */ +int lustre_lnet_ping_nid(char *pnid, char *src_nidstr, int timeout, int seq_no, + struct cYAML **show_rc, struct cYAML **err_rc); + +/* lustre_lnet_discover_nid + * Discover the nid list, pnids. + * + * pnids - NID list to discover. + * force - force discovery. + * seq_no - sequence number of the command. + * show_rc - YAML structure of the resultant show. + * err_rc - YAML strucutre of the resultant return code. + * + */ +int lustre_lnet_discover_nid(char *pnid, int force, int seq_no, + struct cYAML **show_rc, struct cYAML **err_rc); + /* * lustre_yaml_config * Parses the provided YAML file and then calls the specific APIs @@ -342,6 +774,95 @@ int lustre_yaml_show(char *f, struct cYAML **show_rc, struct cYAML **err_rc); /* + * lustre_yaml_exec + * Parses the provided YAML file and then calls the specific APIs + * to execute the entities identified in the file + * + * f - YAML file + * show_rc - [OUT] The show output in YAML. Must be freed by caller. + * err_rc - [OUT] struct cYAML tree describing the error. Freed by caller + */ +int lustre_yaml_exec(char *f, struct cYAML **show_rc, + struct cYAML **err_rc); + +/** + * yaml_emitter_set_output_netlink + * + * Special handling to integrate LNet handling into libyaml. + * This function sets up the ability to take the data stored in @emitter + * and formats into a netlink packet to send to the kernel. + * + * emitter - YAML emitter containing what the user specified + * nl - Netlink socket to be used by libyaml + * family - Netlink family + * version - notify kernel what version user land supports + * cmd - Netlink command to execute + * flags - Netlink flags + */ +int yaml_emitter_set_output_netlink(yaml_emitter_t *emitter, struct nl_sock *nl, + char *family, int version, int cmd, + int flags); + +/** + * yaml_parser_set_input_netlink + * + * Special handling to LNet handling into libyaml. + * This function sets up the ability to receive the Netlink data + * from the Linux kernel. That data is formated into a YAML document. + * + * parser - YAML parser that is used to present the data received + * from the kernel in Netlink format. + * nl - should be the Netlink socket receiving data from + * the kernel. + * stream - Handle the case of continuous data coming in. + */ +int yaml_parser_set_input_netlink(yaml_parser_t *parser, struct nl_sock *nl, + bool stream); + +/** + * yaml_parser_get_reader_proto_version + * + * This function retrieves the Neltink version the kernel module + * is set to. + * + * parser - YAML parser being used for Netlink communication. + */ +int yaml_parser_get_reader_proto_version(yaml_parser_t *parser); + +/** + * yaml_parser_get_reader_error + * + * By default libyaml reports a generic write error. We need a way + * to report better parser errors so we can track down problems. + * + * parser - YAML parser that has reported an error. + */ +const char *yaml_parser_get_reader_error(yaml_parser_t *parser); + +/** + * yaml_parser_log_error + * + * Helper function to report the parser error to @log. + * + * parser - YAML parser that has reported an error. + * log - file descriptor to write the error message out to. + * errmsg - Special extra string to append to error message. + */ +void yaml_parser_log_error(yaml_parser_t *parser, FILE *log, + const char *errmsg); + +/** + * yaml_emitter_log_error + * + * Helper function to report the emitter error to @log. + * + * emitter - YAML emitter that has reported an error. + * log - file descriptor to write the error message out to. + */ +void yaml_emitter_log_error(yaml_emitter_t *emitter, FILE *log); + + +/* * lustre_lnet_init_nw_descr * initialize the network descriptor structure for use */ @@ -359,21 +880,80 @@ int lustre_lnet_parse_interfaces(char *intf_str, struct lnet_dlc_network_descr *nw_descr); /* - * lustre_lnet_parse_nids - * Parse a set of nids into a locally allocated array and return the - * pointer of the array to the caller. The caller is responsible for - * freeing the array. If an initial array is provided then copy over - * the contents of that array into the new array and append to it the - * new content. - * The nids can be of the form "nid [,nid, nid, nid]" - * nids: nids string to be parsed - * array: initial array of content - * size: num of elements in the array - * out_array: [OUT] new allocated array. - * Returns size of array - * sets the out_array to NULL on failure. - */ -int lustre_lnet_parse_nids(char *nids, char **array, int size, - char ***out_array); + * lustre_lnet_parse_nidstr + * This is a small wrapper around cfs_parse_nidlist. + * nidstr - A string parseable by cfs_parse_nidlist + * lnet_nidlist - An array of lnet_nid_t to hold the nids specified + * by the nidstring. + * max_nids - Size of the lnet_nidlist array, and the maximum number of + * nids that can be expressed by the nidstring. If the + * nidstring expands to a larger number of nids than max_nids + * then an error is returned. + * err_str - char pointer where we store an informative error + * message when an error is encountered + * Returns: + * The number (> 0) of lnet_nid_t stored in the supplied array, or + * LUSTRE_CFG_RC_BAD_PARAM if: + * - nidstr is NULL + * - nidstr contains an asterisk. This character is not allowed + * because it would cause the size of the expanded nidlist to exceed + * the maximum number of nids that is supported by expected callers + * of this function. + * - cfs_parse_nidlist fails to parse the nidstring + * - The nidlist populated by cfs_parse_nidlist is empty + * - The nidstring expands to a larger number of nids than max_nids + * - The nidstring expands to zero nids + * LUSTRE_CFG_RC_OUT_OF_MEM if: + * - cfs_expand_nidlist can return ENOMEM. We return out of mem in + * this case. + */ +int lustre_lnet_parse_nidstr(char *nidstr, lnet_nid_t *lnet_nidlist, + int max_nids, char *err_str); + +/* lustre_lnet_add_udsp + * Add a selection policy. + * src - source NID descriptor + * dst - destination NID descriptor + * rte - router NID descriptor + * type - action type + * action - union of the action + * idx - the index to delete + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_add_udsp(char *src, char *dst, char *rte, char *type, + union lnet_udsp_action *action, int idx, + int seq_no, struct cYAML **err_rc); + +/* lustre_lnet_del_udsp + * Delete a net selection policy. + * idx - the index to delete + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_del_udsp(unsigned int idx, int seq_no, struct cYAML **err_rc); + +/* lustre_lnet_show_udsp + * show selection policy. + * idx - the index to show. -1 to show all policies + * seq_no - sequence number of the request + * err_rc - [IN/OUT] struct cYAML tree containing udsp info + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_show_udsp(int idx, int seq_no, struct cYAML **show_rc, + struct cYAML **err_rc); + +/* lustre_lnet_show_peer_debug_info + * dump peer debug info + * peer_nid - nid of the peer to show + * seq_no - sequence number of the request + * err_rc - [OUT] struct cYAML tree describing the error. Freed by + * caller + */ +int lustre_lnet_show_peer_debug_info(char *peer_nid, int seq_no, + struct cYAML **err_rc); #endif /* LIB_LNET_CONFIG_API_H */