@@ -1746,6 +1746,23 @@ static void ql_process_mac_tx_intr(struct ql3_adapter *qdev,
17461746 atomic_inc (& qdev -> tx_count );
17471747}
17481748
1749+ void ql_get_sbuf (struct ql3_adapter * qdev )
1750+ {
1751+ if (++ qdev -> small_buf_index == NUM_SMALL_BUFFERS )
1752+ qdev -> small_buf_index = 0 ;
1753+ qdev -> small_buf_release_cnt ++ ;
1754+ }
1755+
1756+ struct ql_rcv_buf_cb * ql_get_lbuf (struct ql3_adapter * qdev )
1757+ {
1758+ struct ql_rcv_buf_cb * lrg_buf_cb = NULL ;
1759+ lrg_buf_cb = & qdev -> lrg_buf [qdev -> lrg_buf_index ];
1760+ qdev -> lrg_buf_release_cnt ++ ;
1761+ if (++ qdev -> lrg_buf_index == qdev -> num_large_buffers )
1762+ qdev -> lrg_buf_index = 0 ;
1763+ return (lrg_buf_cb );
1764+ }
1765+
17491766/*
17501767 * The difference between 3022 and 3032 for inbound completions:
17511768 * 3022 uses two buffers per completion. The first buffer contains
@@ -1761,47 +1778,21 @@ static void ql_process_mac_tx_intr(struct ql3_adapter *qdev,
17611778static void ql_process_mac_rx_intr (struct ql3_adapter * qdev ,
17621779 struct ib_mac_iocb_rsp * ib_mac_rsp_ptr )
17631780{
1764- long int offset ;
1765- u32 lrg_buf_phy_addr_low = 0 ;
17661781 struct ql_rcv_buf_cb * lrg_buf_cb1 = NULL ;
17671782 struct ql_rcv_buf_cb * lrg_buf_cb2 = NULL ;
1768- u32 * curr_ial_ptr ;
17691783 struct sk_buff * skb ;
17701784 u16 length = le16_to_cpu (ib_mac_rsp_ptr -> length );
17711785
17721786 /*
17731787 * Get the inbound address list (small buffer).
17741788 */
1775- offset = qdev -> small_buf_index * QL_SMALL_BUFFER_SIZE ;
1776- if (++ qdev -> small_buf_index == NUM_SMALL_BUFFERS )
1777- qdev -> small_buf_index = 0 ;
1778-
1779- curr_ial_ptr = (u32 * ) (qdev -> small_buf_virt_addr + offset );
1780- qdev -> last_rsp_offset = qdev -> small_buf_phy_addr_low + offset ;
1781- qdev -> small_buf_release_cnt ++ ;
1789+ ql_get_sbuf (qdev );
17821790
1783- if (qdev -> device_id == QL3022_DEVICE_ID ) {
1784- /* start of first buffer (3022 only) */
1785- lrg_buf_phy_addr_low = le32_to_cpu (* curr_ial_ptr );
1786- lrg_buf_cb1 = & qdev -> lrg_buf [qdev -> lrg_buf_index ];
1787- qdev -> lrg_buf_release_cnt ++ ;
1788- if (++ qdev -> lrg_buf_index == qdev -> num_large_buffers ) {
1789- qdev -> lrg_buf_index = 0 ;
1790- }
1791- curr_ial_ptr ++ ; /* 64-bit pointers require two incs. */
1792- curr_ial_ptr ++ ;
1793- }
1791+ if (qdev -> device_id == QL3022_DEVICE_ID )
1792+ lrg_buf_cb1 = ql_get_lbuf (qdev );
17941793
17951794 /* start of second buffer */
1796- lrg_buf_phy_addr_low = le32_to_cpu (* curr_ial_ptr );
1797- lrg_buf_cb2 = & qdev -> lrg_buf [qdev -> lrg_buf_index ];
1798-
1799- /*
1800- * Second buffer gets sent up the stack.
1801- */
1802- qdev -> lrg_buf_release_cnt ++ ;
1803- if (++ qdev -> lrg_buf_index == qdev -> num_large_buffers )
1804- qdev -> lrg_buf_index = 0 ;
1795+ lrg_buf_cb2 = ql_get_lbuf (qdev );
18051796 skb = lrg_buf_cb2 -> skb ;
18061797
18071798 qdev -> stats .rx_packets ++ ;
@@ -1829,11 +1820,8 @@ static void ql_process_mac_rx_intr(struct ql3_adapter *qdev,
18291820static void ql_process_macip_rx_intr (struct ql3_adapter * qdev ,
18301821 struct ib_ip_iocb_rsp * ib_ip_rsp_ptr )
18311822{
1832- long int offset ;
1833- u32 lrg_buf_phy_addr_low = 0 ;
18341823 struct ql_rcv_buf_cb * lrg_buf_cb1 = NULL ;
18351824 struct ql_rcv_buf_cb * lrg_buf_cb2 = NULL ;
1836- u32 * curr_ial_ptr ;
18371825 struct sk_buff * skb1 = NULL , * skb2 ;
18381826 struct net_device * ndev = qdev -> ndev ;
18391827 u16 length = le16_to_cpu (ib_ip_rsp_ptr -> length );
@@ -1843,35 +1831,20 @@ static void ql_process_macip_rx_intr(struct ql3_adapter *qdev,
18431831 * Get the inbound address list (small buffer).
18441832 */
18451833
1846- offset = qdev -> small_buf_index * QL_SMALL_BUFFER_SIZE ;
1847- if (++ qdev -> small_buf_index == NUM_SMALL_BUFFERS )
1848- qdev -> small_buf_index = 0 ;
1849- curr_ial_ptr = (u32 * ) (qdev -> small_buf_virt_addr + offset );
1850- qdev -> last_rsp_offset = qdev -> small_buf_phy_addr_low + offset ;
1851- qdev -> small_buf_release_cnt ++ ;
1834+ ql_get_sbuf (qdev );
18521835
18531836 if (qdev -> device_id == QL3022_DEVICE_ID ) {
18541837 /* start of first buffer on 3022 */
1855- lrg_buf_phy_addr_low = le32_to_cpu (* curr_ial_ptr );
1856- lrg_buf_cb1 = & qdev -> lrg_buf [qdev -> lrg_buf_index ];
1857- qdev -> lrg_buf_release_cnt ++ ;
1858- if (++ qdev -> lrg_buf_index == qdev -> num_large_buffers )
1859- qdev -> lrg_buf_index = 0 ;
1838+ lrg_buf_cb1 = ql_get_lbuf (qdev );
18601839 skb1 = lrg_buf_cb1 -> skb ;
1861- curr_ial_ptr ++ ; /* 64-bit pointers require two incs. */
1862- curr_ial_ptr ++ ;
18631840 size = ETH_HLEN ;
18641841 if (* ((u16 * ) skb1 -> data ) != 0xFFFF )
18651842 size += VLAN_ETH_HLEN - ETH_HLEN ;
18661843 }
18671844
18681845 /* start of second buffer */
1869- lrg_buf_phy_addr_low = le32_to_cpu (* curr_ial_ptr );
1870- lrg_buf_cb2 = & qdev -> lrg_buf [qdev -> lrg_buf_index ];
1846+ lrg_buf_cb2 = ql_get_lbuf (qdev );
18711847 skb2 = lrg_buf_cb2 -> skb ;
1872- qdev -> lrg_buf_release_cnt ++ ;
1873- if (++ qdev -> lrg_buf_index == qdev -> num_large_buffers )
1874- qdev -> lrg_buf_index = 0 ;
18751848
18761849 skb_put (skb2 , length ); /* Just the second buffer length here. */
18771850 pci_unmap_single (qdev -> pdev ,
@@ -2410,7 +2383,6 @@ static void ql_free_buffer_queues(struct ql3_adapter *qdev)
24102383 return ;
24112384 }
24122385 if (qdev -> lrg_buf ) kfree (qdev -> lrg_buf );
2413-
24142386 pci_free_consistent (qdev -> pdev ,
24152387 qdev -> lrg_buf_q_alloc_size ,
24162388 qdev -> lrg_buf_q_alloc_virt_addr ,
@@ -2455,8 +2427,6 @@ static int ql_alloc_small_buffers(struct ql3_adapter *qdev)
24552427
24562428 small_buf_q_entry = qdev -> small_buf_q_virt_addr ;
24572429
2458- qdev -> last_rsp_offset = qdev -> small_buf_phy_addr_low ;
2459-
24602430 /* Initialize the small buffer queue. */
24612431 for (i = 0 ; i < (QL_ADDR_ELE_PER_BUFQ_ENTRY * NUM_SBUFQ_ENTRIES ); i ++ ) {
24622432 small_buf_q_entry -> addr_high =
0 commit comments