Exemple #1
0
static int enic_rq_alloc_buf_a1(struct vnic_rq *rq)
{
	struct rq_enet_desc *desc = vnic_rq_next_desc(rq);

	if (vnic_rq_posting_soon(rq)) {

		

		rq_enet_desc_enc(desc, 0, RQ_ENET_TYPE_RESV2, 0);
		vnic_rq_post(rq, 0, 0, 0, 0);
	} else {
		return enic_rq_alloc_buf(rq);
	}

	return 0;
}
Exemple #2
0
static int enic_rq_alloc_buf(struct vnic_rq *rq)
{
	struct enic *enic = vnic_dev_priv(rq->vdev);
	dma_addr_t dma_addr;
	struct rq_enet_desc *desc = vnic_rq_next_desc(rq);
	uint8_t type = RQ_ENET_TYPE_ONLY_SOP;
	u16 split_hdr_size = vnic_get_hdr_split_size(enic->vdev);
	struct rte_mbuf *mbuf = enic_rxmbuf_alloc(rq->mp);
	struct rte_mbuf *hdr_mbuf = NULL;

	if (!mbuf) {
		dev_err(enic, "mbuf alloc in enic_rq_alloc_buf failed\n");
		return -1;
	}

	if (unlikely(split_hdr_size)) {
		if (vnic_rq_desc_avail(rq) < 2) {
			rte_mempool_put(mbuf->pool, mbuf);
			return -1;
		}
		hdr_mbuf = enic_rxmbuf_alloc(rq->mp);
		if (!hdr_mbuf) {
			rte_mempool_put(mbuf->pool, mbuf);
			dev_err(enic,
				"hdr_mbuf alloc in enic_rq_alloc_buf failed\n");
			return -1;
		}

		hdr_mbuf->data_off = RTE_PKTMBUF_HEADROOM;

		hdr_mbuf->nb_segs = 2;
		hdr_mbuf->port = rq->index;
		hdr_mbuf->next = mbuf;

		dma_addr = (dma_addr_t)
		    (hdr_mbuf->buf_physaddr + hdr_mbuf->data_off);

		rq_enet_desc_enc(desc, dma_addr, type, split_hdr_size);

		vnic_rq_post(rq, (void *)hdr_mbuf, 0 /*os_buf_index*/, dma_addr,
			(unsigned int)split_hdr_size, 0 /*wrid*/);

		desc = vnic_rq_next_desc(rq);
		type = RQ_ENET_TYPE_NOT_SOP;
	} else {
		mbuf->nb_segs = 1;
		mbuf->port = rq->index;
	}

	mbuf->data_off = RTE_PKTMBUF_HEADROOM;
	mbuf->next = NULL;

	dma_addr = (dma_addr_t)
	    (mbuf->buf_physaddr + mbuf->data_off);

	rq_enet_desc_enc(desc, dma_addr, type, mbuf->buf_len);

	vnic_rq_post(rq, (void *)mbuf, 0 /*os_buf_index*/, dma_addr,
		(unsigned int)mbuf->buf_len, 0 /*wrid*/);

	return 0;
}