+struct lnet_match_table *
+lnet_mt_of_attach(unsigned int index, lnet_process_id_t id,
+ __u64 mbits, __u64 ignore_bits, lnet_ins_pos_t pos)
+{
+ struct lnet_portal *ptl;
+
+ LASSERT(index < the_lnet.ln_nportals);
+
+ if (!lnet_ptl_match_type(index, id, mbits, ignore_bits))
+ return NULL;
+
+ ptl = the_lnet.ln_portals[index];
+ /* NB: Now we only have one match-table for each portal,
+ * and will have match-table per CPT in upcoming changes,
+ * ME will be scattered to different match-tables based
+ * on attaching information */
+ return ptl->ptl_mtable;
+}
+
+struct lnet_match_table *
+lnet_mt_of_match(unsigned int index, lnet_process_id_t id, __u64 mbits)
+{
+ struct lnet_portal *ptl;
+
+ LASSERT(index < the_lnet.ln_nportals);
+
+ ptl = the_lnet.ln_portals[index];
+ if (!lnet_ptl_is_unique(ptl) &&
+ !lnet_ptl_is_wildcard(ptl) && !lnet_ptl_is_lazy(ptl))
+ return NULL;
+
+ /* NB: Now we only have one match-table for each portal,
+ * and will have match-table per CPT in upcoming changes,
+ * request will be scattered to different match-tables based
+ * on matching information */
+ return ptl->ptl_mtable;
+}
+
+cfs_list_t *
+lnet_mt_match_head(struct lnet_match_table *mtable,
+ lnet_process_id_t id, __u64 mbits)
+{
+ struct lnet_portal *ptl = the_lnet.ln_portals[mtable->mt_portal];
+
+ if (lnet_ptl_is_wildcard(ptl)) {
+ return &mtable->mt_mlist;
+
+ } else if (lnet_ptl_is_unique(ptl)) {
+ unsigned long hash = mbits + id.nid + id.pid;
+
+ hash = cfs_hash_long(hash, LNET_MT_HASH_BITS);
+ return &mtable->mt_mhash[hash];
+ }
+
+ return NULL;
+}
+