aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/qla3xxx.c
diff options
context:
space:
mode:
authorRon Mercer <ron.mercer@qlogic.com>2007-02-26 14:06:37 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-27 04:21:44 -0500
commit1357bfcf71063637d16a7014639d675b5cbf5189 (patch)
treeceddef8001201bcc1a84af6421f052923d5270c6 /drivers/net/qla3xxx.c
parentcb8bac12ec92ec469ecfe0967429bf9032f835c1 (diff)
qla3xxx: Dynamically size the rx buffer queue based on the MTU.
This change removes use of constants for rx buffer queue size and instead calculates the queue length based on what he MTU is set to. Signed-off-by: Ron Mercer <ron.mercer@qlogic.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/qla3xxx.c')
-rwxr-xr-xdrivers/net/qla3xxx.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index c25a1f728715..7d68d1f2df69 100755
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -1700,11 +1700,11 @@ static void ql_update_lrg_bufq_prod_index(struct ql3_adapter *qdev)
1700 1700
1701 qdev->lrg_buf_q_producer_index++; 1701 qdev->lrg_buf_q_producer_index++;
1702 1702
1703 if (qdev->lrg_buf_q_producer_index == NUM_LBUFQ_ENTRIES) 1703 if (qdev->lrg_buf_q_producer_index == qdev->num_lbufq_entries)
1704 qdev->lrg_buf_q_producer_index = 0; 1704 qdev->lrg_buf_q_producer_index = 0;
1705 1705
1706 if (qdev->lrg_buf_q_producer_index == 1706 if (qdev->lrg_buf_q_producer_index ==
1707 (NUM_LBUFQ_ENTRIES - 1)) { 1707 (qdev->num_lbufq_entries - 1)) {
1708 lrg_buf_q_ele = qdev->lrg_buf_q_virt_addr; 1708 lrg_buf_q_ele = qdev->lrg_buf_q_virt_addr;
1709 } 1709 }
1710 } 1710 }
@@ -1785,7 +1785,7 @@ static void ql_process_mac_rx_intr(struct ql3_adapter *qdev,
1785 lrg_buf_phy_addr_low = le32_to_cpu(*curr_ial_ptr); 1785 lrg_buf_phy_addr_low = le32_to_cpu(*curr_ial_ptr);
1786 lrg_buf_cb1 = &qdev->lrg_buf[qdev->lrg_buf_index]; 1786 lrg_buf_cb1 = &qdev->lrg_buf[qdev->lrg_buf_index];
1787 qdev->lrg_buf_release_cnt++; 1787 qdev->lrg_buf_release_cnt++;
1788 if (++qdev->lrg_buf_index == NUM_LARGE_BUFFERS) { 1788 if (++qdev->lrg_buf_index == qdev->num_large_buffers) {
1789 qdev->lrg_buf_index = 0; 1789 qdev->lrg_buf_index = 0;
1790 } 1790 }
1791 curr_ial_ptr++; /* 64-bit pointers require two incs. */ 1791 curr_ial_ptr++; /* 64-bit pointers require two incs. */
@@ -1800,7 +1800,7 @@ static void ql_process_mac_rx_intr(struct ql3_adapter *qdev,
1800 * Second buffer gets sent up the stack. 1800 * Second buffer gets sent up the stack.
1801 */ 1801 */
1802 qdev->lrg_buf_release_cnt++; 1802 qdev->lrg_buf_release_cnt++;
1803 if (++qdev->lrg_buf_index == NUM_LARGE_BUFFERS) 1803 if (++qdev->lrg_buf_index == qdev->num_large_buffers)
1804 qdev->lrg_buf_index = 0; 1804 qdev->lrg_buf_index = 0;
1805 skb = lrg_buf_cb2->skb; 1805 skb = lrg_buf_cb2->skb;
1806 1806
@@ -1855,7 +1855,7 @@ static void ql_process_macip_rx_intr(struct ql3_adapter *qdev,
1855 lrg_buf_phy_addr_low = le32_to_cpu(*curr_ial_ptr); 1855 lrg_buf_phy_addr_low = le32_to_cpu(*curr_ial_ptr);
1856 lrg_buf_cb1 = &qdev->lrg_buf[qdev->lrg_buf_index]; 1856 lrg_buf_cb1 = &qdev->lrg_buf[qdev->lrg_buf_index];
1857 qdev->lrg_buf_release_cnt++; 1857 qdev->lrg_buf_release_cnt++;
1858 if (++qdev->lrg_buf_index == NUM_LARGE_BUFFERS) 1858 if (++qdev->lrg_buf_index == qdev->num_large_buffers)
1859 qdev->lrg_buf_index = 0; 1859 qdev->lrg_buf_index = 0;
1860 skb1 = lrg_buf_cb1->skb; 1860 skb1 = lrg_buf_cb1->skb;
1861 curr_ial_ptr++; /* 64-bit pointers require two incs. */ 1861 curr_ial_ptr++; /* 64-bit pointers require two incs. */
@@ -1870,7 +1870,7 @@ static void ql_process_macip_rx_intr(struct ql3_adapter *qdev,
1870 lrg_buf_cb2 = &qdev->lrg_buf[qdev->lrg_buf_index]; 1870 lrg_buf_cb2 = &qdev->lrg_buf[qdev->lrg_buf_index];
1871 skb2 = lrg_buf_cb2->skb; 1871 skb2 = lrg_buf_cb2->skb;
1872 qdev->lrg_buf_release_cnt++; 1872 qdev->lrg_buf_release_cnt++;
1873 if (++qdev->lrg_buf_index == NUM_LARGE_BUFFERS) 1873 if (++qdev->lrg_buf_index == qdev->num_large_buffers)
1874 qdev->lrg_buf_index = 0; 1874 qdev->lrg_buf_index = 0;
1875 1875
1876 skb_put(skb2, length); /* Just the second buffer length here. */ 1876 skb_put(skb2, length); /* Just the second buffer length here. */
@@ -2347,12 +2347,19 @@ static int ql_alloc_buffer_queues(struct ql3_adapter *qdev)
2347{ 2347{
2348 /* Create Large Buffer Queue */ 2348 /* Create Large Buffer Queue */
2349 qdev->lrg_buf_q_size = 2349 qdev->lrg_buf_q_size =
2350 NUM_LBUFQ_ENTRIES * sizeof(struct lrg_buf_q_entry); 2350 qdev->num_lbufq_entries * sizeof(struct lrg_buf_q_entry);
2351 if (qdev->lrg_buf_q_size < PAGE_SIZE) 2351 if (qdev->lrg_buf_q_size < PAGE_SIZE)
2352 qdev->lrg_buf_q_alloc_size = PAGE_SIZE; 2352 qdev->lrg_buf_q_alloc_size = PAGE_SIZE;
2353 else 2353 else
2354 qdev->lrg_buf_q_alloc_size = qdev->lrg_buf_q_size * 2; 2354 qdev->lrg_buf_q_alloc_size = qdev->lrg_buf_q_size * 2;
2355 2355
2356 qdev->lrg_buf = kmalloc(qdev->num_large_buffers * sizeof(struct ql_rcv_buf_cb),GFP_KERNEL);
2357 if (qdev->lrg_buf == NULL) {
2358 printk(KERN_ERR PFX
2359 "%s: qdev->lrg_buf alloc failed.\n", qdev->ndev->name);
2360 return -ENOMEM;
2361 }
2362
2356 qdev->lrg_buf_q_alloc_virt_addr = 2363 qdev->lrg_buf_q_alloc_virt_addr =
2357 pci_alloc_consistent(qdev->pdev, 2364 pci_alloc_consistent(qdev->pdev,
2358 qdev->lrg_buf_q_alloc_size, 2365 qdev->lrg_buf_q_alloc_size,
@@ -2402,6 +2409,7 @@ static void ql_free_buffer_queues(struct ql3_adapter *qdev)
2402 "%s: Already done.\n", qdev->ndev->name); 2409 "%s: Already done.\n", qdev->ndev->name);
2403 return; 2410 return;
2404 } 2411 }
2412 if(qdev->lrg_buf) kfree(qdev->lrg_buf);
2405 2413
2406 pci_free_consistent(qdev->pdev, 2414 pci_free_consistent(qdev->pdev,
2407 qdev->lrg_buf_q_alloc_size, 2415 qdev->lrg_buf_q_alloc_size,
@@ -2485,7 +2493,7 @@ static void ql_free_large_buffers(struct ql3_adapter *qdev)
2485 int i = 0; 2493 int i = 0;
2486 struct ql_rcv_buf_cb *lrg_buf_cb; 2494 struct ql_rcv_buf_cb *lrg_buf_cb;
2487 2495
2488 for (i = 0; i < NUM_LARGE_BUFFERS; i++) { 2496 for (i = 0; i < qdev->num_large_buffers; i++) {
2489 lrg_buf_cb = &qdev->lrg_buf[i]; 2497 lrg_buf_cb = &qdev->lrg_buf[i];
2490 if (lrg_buf_cb->skb) { 2498 if (lrg_buf_cb->skb) {
2491 dev_kfree_skb(lrg_buf_cb->skb); 2499 dev_kfree_skb(lrg_buf_cb->skb);
@@ -2506,7 +2514,7 @@ static void ql_init_large_buffers(struct ql3_adapter *qdev)
2506 struct ql_rcv_buf_cb *lrg_buf_cb; 2514 struct ql_rcv_buf_cb *lrg_buf_cb;
2507 struct bufq_addr_element *buf_addr_ele = qdev->lrg_buf_q_virt_addr; 2515 struct bufq_addr_element *buf_addr_ele = qdev->lrg_buf_q_virt_addr;
2508 2516
2509 for (i = 0; i < NUM_LARGE_BUFFERS; i++) { 2517 for (i = 0; i < qdev->num_large_buffers; i++) {
2510 lrg_buf_cb = &qdev->lrg_buf[i]; 2518 lrg_buf_cb = &qdev->lrg_buf[i];
2511 buf_addr_ele->addr_high = lrg_buf_cb->buf_phy_addr_high; 2519 buf_addr_ele->addr_high = lrg_buf_cb->buf_phy_addr_high;
2512 buf_addr_ele->addr_low = lrg_buf_cb->buf_phy_addr_low; 2520 buf_addr_ele->addr_low = lrg_buf_cb->buf_phy_addr_low;
@@ -2523,7 +2531,7 @@ static int ql_alloc_large_buffers(struct ql3_adapter *qdev)
2523 struct sk_buff *skb; 2531 struct sk_buff *skb;
2524 u64 map; 2532 u64 map;
2525 2533
2526 for (i = 0; i < NUM_LARGE_BUFFERS; i++) { 2534 for (i = 0; i < qdev->num_large_buffers; i++) {
2527 skb = netdev_alloc_skb(qdev->ndev, 2535 skb = netdev_alloc_skb(qdev->ndev,
2528 qdev->lrg_buffer_len); 2536 qdev->lrg_buffer_len);
2529 if (unlikely(!skb)) { 2537 if (unlikely(!skb)) {
@@ -2602,9 +2610,15 @@ static int ql_create_send_free_list(struct ql3_adapter *qdev)
2602 2610
2603static int ql_alloc_mem_resources(struct ql3_adapter *qdev) 2611static int ql_alloc_mem_resources(struct ql3_adapter *qdev)
2604{ 2612{
2605 if (qdev->ndev->mtu == NORMAL_MTU_SIZE) 2613 if (qdev->ndev->mtu == NORMAL_MTU_SIZE) {
2614 qdev->num_lbufq_entries = NUM_LBUFQ_ENTRIES;
2606 qdev->lrg_buffer_len = NORMAL_MTU_SIZE; 2615 qdev->lrg_buffer_len = NORMAL_MTU_SIZE;
2616 }
2607 else if (qdev->ndev->mtu == JUMBO_MTU_SIZE) { 2617 else if (qdev->ndev->mtu == JUMBO_MTU_SIZE) {
2618 /*
2619 * Bigger buffers, so less of them.
2620 */
2621 qdev->num_lbufq_entries = JUMBO_NUM_LBUFQ_ENTRIES;
2608 qdev->lrg_buffer_len = JUMBO_MTU_SIZE; 2622 qdev->lrg_buffer_len = JUMBO_MTU_SIZE;
2609 } else { 2623 } else {
2610 printk(KERN_ERR PFX 2624 printk(KERN_ERR PFX
@@ -2612,6 +2626,7 @@ static int ql_alloc_mem_resources(struct ql3_adapter *qdev)
2612 qdev->ndev->name); 2626 qdev->ndev->name);
2613 return -ENOMEM; 2627 return -ENOMEM;
2614 } 2628 }
2629 qdev->num_large_buffers = qdev->num_lbufq_entries * QL_ADDR_ELE_PER_BUFQ_ENTRY;
2615 qdev->lrg_buffer_len += VLAN_ETH_HLEN + VLAN_ID_LEN + QL_HEADER_SPACE; 2630 qdev->lrg_buffer_len += VLAN_ETH_HLEN + VLAN_ID_LEN + QL_HEADER_SPACE;
2616 qdev->max_frame_size = 2631 qdev->max_frame_size =
2617 (qdev->lrg_buffer_len - QL_HEADER_SPACE) + ETHERNET_CRC_SIZE; 2632 (qdev->lrg_buffer_len - QL_HEADER_SPACE) + ETHERNET_CRC_SIZE;
@@ -2844,7 +2859,7 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
2844 &hmem_regs->rxLargeQBaseAddrLow, 2859 &hmem_regs->rxLargeQBaseAddrLow,
2845 LS_64BITS(qdev->lrg_buf_q_phy_addr)); 2860 LS_64BITS(qdev->lrg_buf_q_phy_addr));
2846 2861
2847 ql_write_page1_reg(qdev, &hmem_regs->rxLargeQLength, NUM_LBUFQ_ENTRIES); 2862 ql_write_page1_reg(qdev, &hmem_regs->rxLargeQLength, qdev->num_lbufq_entries);
2848 2863
2849 ql_write_page1_reg(qdev, 2864 ql_write_page1_reg(qdev,
2850 &hmem_regs->rxLargeBufferLength, 2865 &hmem_regs->rxLargeBufferLength,
@@ -2866,7 +2881,7 @@ static int ql_adapter_initialize(struct ql3_adapter *qdev)
2866 2881
2867 qdev->small_buf_q_producer_index = NUM_SBUFQ_ENTRIES - 1; 2882 qdev->small_buf_q_producer_index = NUM_SBUFQ_ENTRIES - 1;
2868 qdev->small_buf_release_cnt = 8; 2883 qdev->small_buf_release_cnt = 8;
2869 qdev->lrg_buf_q_producer_index = NUM_LBUFQ_ENTRIES - 1; 2884 qdev->lrg_buf_q_producer_index = qdev->num_lbufq_entries - 1;
2870 qdev->lrg_buf_release_cnt = 8; 2885 qdev->lrg_buf_release_cnt = 8;
2871 qdev->lrg_buf_next_free = 2886 qdev->lrg_buf_next_free =
2872 (struct bufq_addr_element *)qdev->lrg_buf_q_virt_addr; 2887 (struct bufq_addr_element *)qdev->lrg_buf_q_virt_addr;