aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/cnic.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/cnic.c')
-rw-r--r--drivers/net/cnic.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 4869d77cbe91..039900c41699 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -742,6 +742,26 @@ static int cnic_alloc_context(struct cnic_dev *dev)
742 return 0; 742 return 0;
743} 743}
744 744
745static int cnic_alloc_l2_rings(struct cnic_dev *dev, int pages)
746{
747 struct cnic_local *cp = dev->cnic_priv;
748
749 cp->l2_ring_size = pages * BCM_PAGE_SIZE;
750 cp->l2_ring = pci_alloc_consistent(dev->pcidev, cp->l2_ring_size,
751 &cp->l2_ring_map);
752 if (!cp->l2_ring)
753 return -ENOMEM;
754
755 cp->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size;
756 cp->l2_buf_size = PAGE_ALIGN(cp->l2_buf_size);
757 cp->l2_buf = pci_alloc_consistent(dev->pcidev, cp->l2_buf_size,
758 &cp->l2_buf_map);
759 if (!cp->l2_buf)
760 return -ENOMEM;
761
762 return 0;
763}
764
745static int cnic_alloc_bnx2_resc(struct cnic_dev *dev) 765static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
746{ 766{
747 struct cnic_local *cp = dev->cnic_priv; 767 struct cnic_local *cp = dev->cnic_priv;
@@ -762,17 +782,8 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev)
762 if (ret) 782 if (ret)
763 goto error; 783 goto error;
764 784
765 cp->l2_ring_size = 2 * BCM_PAGE_SIZE; 785 ret = cnic_alloc_l2_rings(dev, 2);
766 cp->l2_ring = pci_alloc_consistent(dev->pcidev, cp->l2_ring_size, 786 if (ret)
767 &cp->l2_ring_map);
768 if (!cp->l2_ring)
769 goto error;
770
771 cp->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size;
772 cp->l2_buf_size = PAGE_ALIGN(cp->l2_buf_size);
773 cp->l2_buf = pci_alloc_consistent(dev->pcidev, cp->l2_buf_size,
774 &cp->l2_buf_map);
775 if (!cp->l2_buf)
776 goto error; 787 goto error;
777 788
778 uinfo = kzalloc(sizeof(*uinfo), GFP_ATOMIC); 789 uinfo = kzalloc(sizeof(*uinfo), GFP_ATOMIC);