Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec0248ea authored by Michael Chan's avatar Michael Chan Committed by David S. Miller
Browse files

cnic: Put rx/tx ring allocation in separate function.



This will allow the 10G iSCSI code to reuse the function.

Signed-off-by: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3d1427f8
Loading
Loading
Loading
Loading
+22 −11
Original line number Original line Diff line number Diff line
@@ -742,6 +742,26 @@ static int cnic_alloc_context(struct cnic_dev *dev)
	return 0;
	return 0;
}
}


static int cnic_alloc_l2_rings(struct cnic_dev *dev, int pages)
{
	struct cnic_local *cp = dev->cnic_priv;

	cp->l2_ring_size = pages * BCM_PAGE_SIZE;
	cp->l2_ring = pci_alloc_consistent(dev->pcidev, cp->l2_ring_size,
					   &cp->l2_ring_map);
	if (!cp->l2_ring)
		return -ENOMEM;

	cp->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size;
	cp->l2_buf_size = PAGE_ALIGN(cp->l2_buf_size);
	cp->l2_buf = pci_alloc_consistent(dev->pcidev, cp->l2_buf_size,
					   &cp->l2_buf_map);
	if (!cp->l2_buf)
		return -ENOMEM;

	return 0;
}

static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
{
{
	struct cnic_local *cp = dev->cnic_priv;
	struct cnic_local *cp = dev->cnic_priv;
@@ -762,17 +782,8 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
	if (ret)
	if (ret)
		goto error;
		goto error;


	cp->l2_ring_size = 2 * BCM_PAGE_SIZE;
	ret = cnic_alloc_l2_rings(dev, 2);
	cp->l2_ring = pci_alloc_consistent(dev->pcidev, cp->l2_ring_size,
	if (ret)
					   &cp->l2_ring_map);
	if (!cp->l2_ring)
		goto error;

	cp->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size;
	cp->l2_buf_size = PAGE_ALIGN(cp->l2_buf_size);
	cp->l2_buf = pci_alloc_consistent(dev->pcidev, cp->l2_buf_size,
					   &cp->l2_buf_map);
	if (!cp->l2_buf)
		goto error;
		goto error;


	uinfo = kzalloc(sizeof(*uinfo), GFP_ATOMIC);
	uinfo = kzalloc(sizeof(*uinfo), GFP_ATOMIC);