Whamcloud - gitweb
LU-9121 lnet: Add a selection policy
[fs/lustre-release.git] / lnet / utils / lnetconfig / liblnetconfig.h
index 8152259..b3d5b0f 100644 (file)
 #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;
@@ -55,6 +87,57 @@ struct lnet_dlc_intf_descr {
        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;
 
@@ -374,11 +457,22 @@ int lustre_lnet_config_retry_count(int count, int seq_no, struct cYAML **err_rc)
 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);
 
 /*
  * lustre_lnet_config_max_intf
@@ -405,6 +499,12 @@ 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_config_discovery
  *   Enable or disable peer discovery. Peer discovery is enabled by default.
  *
@@ -493,47 +593,34 @@ 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.
- *     ip2nets - true if a list of nid expressions are given to configure
- *     multiple peers
- *     seq_no - sequence number of the command
- *     err_rc - YAML strucutre of the resultant return code.
- */
-int lustre_lnet_config_peer_nid(char *pnid, char **nid, int num_nids,
-                               bool mr, bool ip2nets, 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
- *     ip2nets - used to specify a range of nids
- *     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,
-                            bool ip2nets, 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
@@ -683,22 +770,20 @@ int lustre_lnet_parse_interfaces(char *intf_str,
 int lustre_lnet_parse_nidstr(char *nidstr, lnet_nid_t *lnet_nidlist,
                             int max_nids, char *err_str);
 
-/*
- * 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_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);
 
 #endif /* LIB_LNET_CONFIG_API_H */