Пример #1
0
int common_rmt_enqueue_scheduling_policy_tx(struct rmt_ps *ps,
					    struct rmt_n1_port *n1_port,
					    struct pdu *pdu)
{
	struct rmt_kqueue *q;
	struct rmt_qgroup *qg;
	struct rmt_ps_common_data *data = ps->priv;

	if (!ps || !n1_port || !pdu) {
		LOG_ERR("Wrong input parameters");
		return -1;
	}

	qg = rmt_qgroup_find(data->outqs, n1_port->port_id);
	if (!qg) {
		LOG_ERR("Could not find queue group for n1_port %u",
			n1_port->port_id);
		pdu_destroy(pdu);
		return -1;
	}
	q = rmt_kqueue_find(qg, 0);
	if (!q) {
		LOG_ERR("Could not find queue in the group for n1_port %u",
			n1_port->port_id);
		pdu_destroy(pdu);
		return -1;
	}

	rfifo_push_ni(q->queue, pdu);

	return 0;
}
Пример #2
0
static int
default_rmt_enqueue_scheduling_policy_tx(struct rmt_ps *      ps,
                                         struct rmt_n1_port * n1_port,
                                         struct pdu *         pdu)
{
        struct rmt_kqueue *  q;
        struct rmt_qgroup *  qg;
        struct rmt_ps_data * data = ps->priv;

        if (!ps || !n1_port || !pdu) {
                LOG_ERR("Wrong input parameters for "
                        "rmt_enqueu_scheduling_policy_tx");
                return -1;
        }

        /* NOTE: The policy is called with the n1_port lock taken */
        qg = rmt_qgroup_find(data->outqs, n1_port->port_id);
        if (!qg) {
                LOG_ERR("Could not find queue group for n1_port %u",
                        n1_port->port_id);
                pdu_destroy(pdu);
                return -1;
        }
        q = rmt_kqueue_find(qg, 0);
        if (!qg) {
                LOG_ERR("Could not find queue in the group for n1_port %u",
                        n1_port->port_id);
                pdu_destroy(pdu);
                return -1;
        }

        rfifo_push_ni(q->queue, pdu);
        return 0;
}
Пример #3
0
static int cas_rmt_enqueue_policy(struct rmt_ps      *ps,
				  struct rmt_n1_port *port,
				  struct du	     *du,
				  bool                must_enqueue)
{
        struct cas_rmt_queue *   q;
        struct cas_rmt_ps_data * data;
        ssize_t                  cur_qlen;
        struct reg_cycle_t *     prev_cycle, * cur_cycle;

        data = ps->priv;

        q = port->rmt_ps_queues;
        if (!q) {
                LOG_ERR("Monitoring: could not find CAS queue for N-1 port %u",
                        port->port_id);
                return RMT_PS_ENQ_ERR;
        }

        cur_qlen = rfifo_length(q->queue);
	if (cur_qlen >= data->q_max) {
		du_destroy(du);
		return RMT_PS_ENQ_DROP;
	}

        prev_cycle = &q->reg_cycles.prev_cycle;
        cur_cycle  = &q->reg_cycles.cur_cycle;

	if (update_cycles(prev_cycle, cur_cycle, cur_qlen, true)) {
		du_destroy(du);
		return RMT_PS_ENQ_ERR;
	}

        LOG_DBG("The length for N-1 port %u just calculated is: %lu",
                port->port_id, cur_cycle->avg_len);

        if (cur_cycle->avg_len >= 1)
		if (mark_pdu(du))
			return RMT_PS_ENQ_ERR;

	if (!must_enqueue && rfifo_is_empty(q->queue))
		return RMT_PS_ENQ_SEND;

	rfifo_push_ni(q->queue, du);
        return RMT_PS_ENQ_SCHED;
}