Whamcloud - gitweb
LU-9121 lnet: UDSP storage and marshalled structs
authorAmir Shehata <ashehata@whamcloud.com>
Wed, 13 Feb 2019 23:21:54 +0000 (15:21 -0800)
committerAmir Shehata <ashehata@whamcloud.com>
Mon, 22 Feb 2021 17:10:56 +0000 (09:10 -0800)
Commit the structures which will be used by kernel space
to store the UDSPs. This commit also adds the IOCTL structures
which are used for marshalling the UDSPs between user and
kernel space.

Test-Parameters: trivial testlist=lnet-selftest,sanity-lnet
Signed-off-by: Amir Shehata <ashehata@whamcloud.com>
Change-Id: I490fa9a050cb1f8debc381be773cda4ce8abe29b
Reviewed-on: https://review.whamcloud.com/34253
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
lnet/include/lnet/lib-types.h
lnet/include/uapi/linux/lnet/lnet-dlc.h
lnet/include/uapi/linux/lnet/lnet-types.h
lnet/lnet/api-ni.c

index 9500550..dc85f34 100644 (file)
@@ -979,6 +979,49 @@ struct lnet_msg_container {
        void                    **msc_resenders;
 };
 
        void                    **msc_resenders;
 };
 
+/* This UDSP structures need to match the user space liblnetconfig structures
+ * in order for the marshall and unmarshall functions to be common.
+ */
+
+/* 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;
+       __u32 ud_mem_size;
+};
+
+/* 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;
+};
+
 /* Peer Discovery states */
 #define LNET_DC_STATE_SHUTDOWN         0       /* not started */
 #define LNET_DC_STATE_RUNNING          1       /* started up OK */
 /* Peer Discovery states */
 #define LNET_DC_STATE_SHUTDOWN         0       /* not started */
 #define LNET_DC_STATE_RUNNING          1       /* started up OK */
@@ -1154,6 +1197,8 @@ struct lnet {
         * work loops
         */
        struct completion               ln_started;
         * work loops
         */
        struct completion               ln_started;
+       /* UDSP list */
+       struct list_head                ln_udsp_list;
 };
 
 #endif
 };
 
 #endif
index bba8aa3..c37edc8 100644 (file)
@@ -293,4 +293,88 @@ struct lnet_ioctl_lnet_stats {
        struct lnet_counters st_cntrs;
 };
 
        struct lnet_counters st_cntrs;
 };
 
+/* An IP, numeric NID or a Net number is composed of 1 or more of these
+ * descriptor structures.
+ */
+struct lnet_range_expr {
+       __u32 re_lo;
+       __u32 re_hi;
+       __u32 re_stride;
+};
+
+/* le_count identifies the number of lnet_range_expr in the bulk
+ * which follows
+ */
+struct lnet_expressions {
+       __u32 le_count;
+};
+
+/* A net descriptor has the net type, IE: O2IBLND, SOCKLND, etc and an
+ * expression describing a net number range.
+ */
+struct lnet_ioctl_udsp_net_descr {
+       __u32 ud_net_type;
+       struct lnet_expressions ud_net_num_expr;
+};
+
+/* The UDSP descriptor header contains the type of matching criteria, SRC,
+ * DST, RTE, etc and how many lnet_expressions compose the LNet portion of
+ * the LNet NID. For example an IP can be
+ * composed of 4 lnet_expressions , a gni can be composed of 1
+ */
+struct lnet_ioctl_udsp_descr_hdr {
+       /* The literals SRC, DST and RTE are encoded
+        * here.
+        */
+       __u32 ud_descr_type;
+       __u32 ud_descr_count;
+};
+
+/* each matching expression in the UDSP is described with this.
+ * The bulk format is as follows:
+ *     1. 1x struct lnet_ioctl_udsp_net_descr
+ *             -> the net part of the NID
+ *     2. >=0 struct lnet_expressions
+ *             -> the address part of the NID
+ */
+struct lnet_ioctl_udsp_descr {
+       struct lnet_ioctl_udsp_descr_hdr iud_src_hdr;
+       struct lnet_ioctl_udsp_net_descr iud_net;
+};
+
+/* The cumulative UDSP descriptor
+ * The bulk format is as follows:
+ *     1. >=1 struct lnet_ioctl_udsp_descr
+ *
+ * The size indicated in iou_hdr is the total size of the UDSP.
+ *
+ */
+struct lnet_ioctl_udsp {
+       struct libcfs_ioctl_hdr iou_hdr;
+       __s32 iou_idx;
+       __u32 iou_action_type;
+       __u32 iou_bulk_size;
+       union {
+               __u32 priority;
+       } iou_action;
+       void __user *iou_bulk;
+};
+
+/* structure used to request udsp instantiation information on the
+ * specified construct.
+ *   cud_nid: the NID of the local or remote NI to pull info on.
+ *   cud_nid_priority: NID prio of the requested NID.
+ *   cud_net_priority: net prio of network of the requested NID.
+ *   cud_pref_nid: array of preferred NIDs if it exists.
+ */
+struct lnet_ioctl_construct_udsp_info {
+       struct libcfs_ioctl_hdr cud_hdr;
+       __u32 cud_peer:1;
+       lnet_nid_t cud_nid;
+       __u32 cud_nid_priority;
+       __u32 cud_net_priority;
+       lnet_nid_t cud_pref_nid[LNET_MAX_SHOW_NUM_NID];
+       lnet_nid_t cud_pref_rtr_nid[LNET_MAX_SHOW_NUM_NID];
+};
+
 #endif /* _LNET_DLC_H_ */
 #endif /* _LNET_DLC_H_ */
index 2a478ef..cc9ec76 100644 (file)
@@ -701,6 +701,20 @@ enum lnet_ack_req {
        /** Request that no acknowledgment should be generated. */
        LNET_NOACK_REQ
 };
        /** Request that no acknowledgment should be generated. */
        LNET_NOACK_REQ
 };
+
+/**
+ * UDSP action types. There are two available actions:
+ *     1. PRIORITY - set priority of matching LNet constructs
+ *     2. PREFERRED LIST - set preferred list of matching LNet constructs
+ */
+enum lnet_udsp_action_type {
+       EN_LNET_UDSP_ACTION_NONE = 0,
+       /** assign a priority to matching constructs */
+       EN_LNET_UDSP_ACTION_PRIORITY = 1,
+       /** assign a preferred list of NIDs to matching constructs */
+       EN_LNET_UDSP_ACTION_PREFERRED_LIST = 2,
+};
+
 /** @} lnet_data */
 
 /** @} lnet */
 /** @} lnet_data */
 
 /** @} lnet */
index 2297772..fea321c 100644 (file)
@@ -1228,6 +1228,7 @@ lnet_prepare(lnet_pid_t requested_pid)
        INIT_LIST_HEAD(&the_lnet.ln_dc_expired);
        INIT_LIST_HEAD(&the_lnet.ln_mt_localNIRecovq);
        INIT_LIST_HEAD(&the_lnet.ln_mt_peerNIRecovq);
        INIT_LIST_HEAD(&the_lnet.ln_dc_expired);
        INIT_LIST_HEAD(&the_lnet.ln_mt_localNIRecovq);
        INIT_LIST_HEAD(&the_lnet.ln_mt_peerNIRecovq);
+       INIT_LIST_HEAD(&the_lnet.ln_udsp_list);
        init_waitqueue_head(&the_lnet.ln_dc_waitq);
        the_lnet.ln_mt_handler = NULL;
        init_completion(&the_lnet.ln_started);
        init_waitqueue_head(&the_lnet.ln_dc_waitq);
        the_lnet.ln_mt_handler = NULL;
        init_completion(&the_lnet.ln_started);