Beispiel #1
0
int psmi_sysbuf_init(void)
{
	int i;
	uint32_t block_sizes[] = { 256, 512, 1024,
		2048, 4096, 8192, (uint32_t) -1 };
	uint32_t replenishing_rate[] = { 128, 64, 32, 16, 8, 4, 0 };

	if (psmi_sysbuf.is_initialized)
		return PSM_OK;

	for (i = 0; i < MM_NUM_OF_POOLS; i++) {
		psmi_sysbuf.handler_index[i].block_size = block_sizes[i];
		psmi_sysbuf.handler_index[i].current_available = 0;
		psmi_sysbuf.handler_index[i].free_list = NULL;
		psmi_sysbuf.handler_index[i].total_alloc = 0;
		psmi_sysbuf.handler_index[i].replenishing_rate =
			replenishing_rate[i];

		if (block_sizes[i] == -1) {
			psmi_assert_always(replenishing_rate[i] == 0);
			psmi_sysbuf.handler_index[i].flags =
				MM_FLAG_TRANSIENT;
		} else {
			psmi_assert_always(replenishing_rate[i] > 0);
			psmi_sysbuf.handler_index[i].flags = MM_FLAG_NONE;
		}
	}

	VALGRIND_CREATE_MEMPOOL(&psmi_sysbuf, PSM_VALGRIND_REDZONE_SZ,
				PSM_VALGRIND_MEM_UNDEFINED);

	/* Hit once on each block size so we have a pool that's allocated */
	for (i = 0; i < MM_NUM_OF_POOLS; i++) {
		void *ptr;
		if (block_sizes[i] == -1)
			continue;
		ptr = psmi_sysbuf_alloc(block_sizes[i]);
		psmi_sysbuf_free(ptr);
	}

	return PSM_OK;
}
Beispiel #2
0
static int
ips_proto_am_handle_outoforder_queue()
{
	struct ips_am_message *msg, *prev;
	int ret = IPS_RECVHDRQ_CONTINUE;

	prev = &ips_am_outoforder_q.head;
	msg = ips_am_outoforder_q.head.next;

	while (msg != NULL) {
		struct ips_epaddr *ipsaddr = msg->ipsaddr;
		if (ipsaddr->msgctl->am_recv_seqnum != msg->seqnum) {
			prev = msg;
			msg = msg->next;
			continue;
		}

		ipsaddr->msgctl->am_recv_seqnum++;

		if (ips_am_run_handler(&msg->p_hdr,
					ipsaddr, msg->proto_am,
					msg->payload, msg->paylen))
			ret = IPS_RECVHDRQ_BREAK;

		prev->next = msg->next;
		if (prev->next == NULL)
			ips_am_outoforder_q.tail = prev;

		psmi_sysbuf_free(msg->payload);
		psmi_mpool_put(msg);

		msg = prev->next;
	}

	return ret;
}