Exemple #1
0
void pfq_sock_init(struct pfq_sock *so, int id)
{
	so->id = id;

        /* memory mapped queues are allocated later, when the socket is enabled */

	so->egress_type   = pfq_endpoint_socket;
	so->egress_index  = 0;
	so->egress_queue  = 0;

	/* default weight */

	so->weight = 1;

        so->shmem.addr = NULL;
        so->shmem.size = 0;
        so->shmem.kind = 0;
        so->shmem.hugepages = NULL;
        so->shmem.npages = 0;

        /* reset stats */

        sparse_set(&so->stats.recv, 0);
        sparse_set(&so->stats.lost, 0);
        sparse_set(&so->stats.drop, 0);
        sparse_set(&so->stats.sent, 0);
        sparse_set(&so->stats.disc, 0);
}
Exemple #2
0
static void
__pfq_group_ctor(int gid)
{
        struct pfq_group * that = &pfq_groups[gid];
        int i;

        that->pid = -1;
        that->policy = Q_GROUP_UNDEFINED;

        for(i = 0; i < Q_CLASS_MAX; i++)
        {
                atomic_long_set(&that->sock_mask[i], 0);
        }

        /* note the = is for setting the limit to the function composition:
         * the last function pointer is always set to NULL
         * */

        for(i = 0; i <= Q_FUN_MAX; i++)
        {
                atomic_long_set(&that->fun_ctx[i].function, 0L);
                atomic_long_set(&that->fun_ctx[i].context,    0L);
                spin_lock_init (&that->fun_ctx[i].lock);
        }

        atomic_long_set(&that->filter,   0L);

        sparse_set(&that->recv, 0);
        sparse_set(&that->lost, 0);
        sparse_set(&that->drop, 0);
}
Exemple #3
0
void
pfq_reset_recycle_stats(void)
{
        sparse_set(&os_alloc, 0);
        sparse_set(&os_free, 0);
        sparse_set(&rc_alloc, 0);
        sparse_set(&rc_free, 0);
        sparse_set(&rc_error, 0);
}
Exemple #4
0
static void
__pfq_group_init(int gid)
{
        struct pfq_group * g = pfq_get_group(gid);
        int i;

        if (!g) {
                pr_devel("[PFQ] get_group: invalid group id %d!\n", gid);
                return;
        }

	g->pid = current->tgid;
        g->owner = -1;
        g->policy = Q_POLICY_GROUP_UNDEFINED;

        for(i = 0; i < Q_CLASS_MAX; i++)
        {
                atomic_long_set(&g->sock_mask[i], 0);
        }

        atomic_long_set(&g->bp_filter,0L);
        atomic_long_set(&g->comp,     0L);
        atomic_long_set(&g->comp_ctx, 0L);

	pfq_group_stats_reset(&g->stats);

        for(i = 0; i < Q_MAX_COUNTERS; i++)
        {
                sparse_set(&g->context.counter[i], 0);
        }

	for(i = 0; i < Q_MAX_PERSISTENT; i++)
	{
		spin_lock_init(&g->context.persistent[i].lock);
		memset(g->context.persistent[i].memory, 0, sizeof(g->context.persistent[i].memory));
	}
}