# include <sys/time.h>
#endif
-#ifndef PTL_USE_DESC_LISTS
-static int ptl_slab_users;
-
-atomic_t md_in_use_count = ATOMIC_INIT(0);
-atomic_t msg_in_use_count = ATOMIC_INIT(0);
-atomic_t me_in_use_count = ATOMIC_INIT(0);
-atomic_t eq_in_use_count = ATOMIC_INIT(0);
+#ifndef PTL_USE_LIB_FREELIST
int
-kportal_descriptor_setup (nal_cb_t *nal)
+kportal_descriptor_setup (nal_cb_t *nal,
+ ptl_ni_limits_t *requested_limits,
+ ptl_ni_limits_t *actual_limits)
{
- ptl_slab_users++;
- RETURN(PTL_OK);
+ /* Ignore requested limits! */
+ actual_limits->max_mes = INT_MAX;
+ actual_limits->max_mds = INT_MAX;
+ actual_limits->max_eqs = INT_MAX;
+
+ return PTL_OK;
}
void
kportal_descriptor_cleanup (nal_cb_t *nal)
{
- if (--ptl_slab_users != 0)
- return;
-
- LASSERT (atomic_read (&md_in_use_count) == 0);
- LASSERT (atomic_read (&me_in_use_count) == 0);
- LASSERT (atomic_read (&eq_in_use_count) == 0);
- LASSERT (atomic_read (&msg_in_use_count) == 0);
}
#else
space = nal->cb_malloc (nal, n * size);
if (space == NULL)
- return (PTL_NOSPACE);
+ return (PTL_NO_SPACE);
INIT_LIST_HEAD (&fl->fl_list);
fl->fl_objs = space;
}
int
-kportal_descriptor_setup (nal_cb_t *nal)
+kportal_descriptor_setup (nal_cb_t *nal,
+ ptl_ni_limits_t *requested_limits,
+ ptl_ni_limits_t *actual_limits)
{
/* NB on failure caller must still call kportal_descriptor_cleanup */
/* ****** */
memset (&nal->ni.ni_free_mds, 0, sizeof (nal->ni.ni_free_mds));
memset (&nal->ni.ni_free_eqs, 0, sizeof (nal->ni.ni_free_eqs));
+ /* Ignore requested limits! */
+ actual_limits->max_mes = MAX_MES;
+ actual_limits->max_mds = MAX_MDS;
+ actual_limits->max_eqs = MAX_EQS;
+ /* Hahahah what a load of bollocks. There's nowhere to
+ * specify the max # messages in-flight */
+
rc = lib_freelist_init (nal, &nal->ni.ni_free_mes,
MAX_MES, sizeof (lib_me_t));
if (rc != PTL_OK)
(struct list_head *)nal->cb_malloc (nal, ni->ni_lh_hash_size
* sizeof (struct list_head));
if (ni->ni_lh_hash_table == NULL)
- return (PTL_NOSPACE);
+ return (PTL_NO_SPACE);
for (i = 0; i < ni->ni_lh_hash_size; i++)
INIT_LIST_HEAD (&ni->ni_lh_hash_table[i]);
}
int
-lib_init(nal_cb_t * nal, ptl_nid_t nid, ptl_pid_t pid, int gsize,
- ptl_pt_index_t ptl_size, ptl_ac_index_t acl_size)
+lib_init(nal_cb_t *nal, ptl_process_id_t process_id,
+ ptl_ni_limits_t *requested_limits,
+ ptl_ni_limits_t *actual_limits)
{
int rc = PTL_OK;
lib_ni_t *ni = &nal->ni;
+ int ptl_size;
int i;
ENTRY;
/* NB serialised in PtlNIInit() */
- if (ni->refcnt != 0) { /* already initialised */
- ni->refcnt++;
- goto out;
- }
-
lib_assert_wire_constants ();
/*
*/
memset(&ni->counters, 0, sizeof(lib_counters_t));
- rc = kportal_descriptor_setup (nal);
+ rc = kportal_descriptor_setup (nal, requested_limits,
+ &ni->actual_limits);
if (rc != PTL_OK)
goto out;
if (rc != PTL_OK)
goto out;
- ni->nid = nid;
- ni->pid = pid;
+ ni->nid = process_id.nid;
+ ni->pid = process_id.pid;
- ni->num_nodes = gsize;
- ni->tbl.size = ptl_size;
+ if (requested_limits != NULL)
+ ptl_size = requested_limits->max_pt_index + 1;
+ else
+ ptl_size = 64;
+ ni->tbl.size = ptl_size;
ni->tbl.tbl = nal->cb_malloc(nal, sizeof(struct list_head) * ptl_size);
if (ni->tbl.tbl == NULL) {
- rc = PTL_NOSPACE;
+ rc = PTL_NO_SPACE;
goto out;
}
for (i = 0; i < ptl_size; i++)
INIT_LIST_HEAD(&(ni->tbl.tbl[i]));
- ni->debug = PTL_DEBUG_NONE;
- ni->up = 1;
- ni->refcnt++;
+ /* max_{mes,mds,eqs} set in kportal_descriptor_setup */
+
+ /* We don't have an access control table! */
+ ni->actual_limits.max_ac_index = -1;
+
+ ni->actual_limits.max_pt_index = ptl_size - 1;
+ ni->actual_limits.max_md_iovecs = PTL_MD_MAX_IOV;
+ ni->actual_limits.max_me_list = INT_MAX;
+
+ /* We don't support PtlGetPut! */
+ ni->actual_limits.max_getput_md = 0;
+
+ if (actual_limits != NULL)
+ *actual_limits = ni->actual_limits;
out:
if (rc != PTL_OK) {
lib_ni_t *ni = &nal->ni;
int idx;
- ni->refcnt--;
-
- if (ni->refcnt != 0)
- goto out;
-
- /* NB no stat_lock() since this is the last reference. The NAL
+ /* NB no state_lock() since this is the last reference. The NAL
* should have shut down already, so it should be safe to unlink
* and free all descriptors, even those that appear committed to a
* network op (eg MD with non-zero pending count)
}
nal->cb_free(nal, ni->tbl.tbl, sizeof(struct list_head) * ni->tbl.size);
- ni->up = 0;
lib_cleanup_handle_hash (nal);
kportal_descriptor_cleanup (nal);
- out:
return (PTL_OK);
}