netdev
[Top] [All Lists]

Re: Patch submission for S2io Xframe driver to 2.6 kernel

To: Ravinandan Arakali <ravinandan.arakali@xxxxxxxx>
Subject: Re: Patch submission for S2io Xframe driver to 2.6 kernel
From: Francois Romieu <romieu@xxxxxxxxxxxxx>
Date: Sun, 22 Aug 2004 01:43:12 +0200
Cc: jgarzik@xxxxxxxxx, netdev@xxxxxxxxxxx, leonid.grossman@xxxxxxxx, raghavendra.koushik@xxxxxxxx
In-reply-to: <001401c48194$62497260$9610100a@S2IOtech.com>
References: <001401c48194$62497260$9610100a@S2IOtech.com>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.4.1i
diff -Naur orig/drivers/net/s2io.c new/drivers/net/s2io.c
--- orig/drivers/net/s2io.c     2004-08-06 06:55:01.000000000 -0700
+++ new/drivers/net/s2io.c      2004-08-06 06:58:44.000000000 -0700
[...]
@@ -432,14 +507,29 @@
        mac_control = &nic->mac_control;
        config = &nic->config;
 
-       if (mac_control->txd_list_mem) {
-               pci_free_consistent(nic->pdev,
-                                   mac_control->txd_list_mem_sz,
-                                   mac_control->txd_list_mem,
-                                   mac_control->txd_list_mem_phy);
+       lst_size = (sizeof(TxD_t) * config->MaxTxDs);
+       lst_per_page = PAGE_SIZE / lst_size;
+
+       for(i=0; i<config->TxFIFONum; i++) {
+               int tmp =  config->TxCfg[i].FifoLen / lst_per_page;
+               int tmp1 =  config->TxCfg[i].FifoLen % lst_per_page;
+               int page_num = tmp1?(tmp+1) : tmp;
+               for(j=0; j<page_num; j++) {
+                       int mem_blks = (j * lst_per_page);
+                       if(!nic->list_info[i][mem_blks].list_virt_addr)
+                               break;
+                       pci_free_consistent(nic->pdev, PAGE_SIZE,
+                               nic->list_info[i][mem_blks].list_virt_addr,
+                               nic->list_info[i][mem_blks].list_phy_addr);
+               }
+               kfree(nic->list_info[i]);
        }

-> Give it more room and avoid some arithmetic:

        for (i = 0; i < config->TxFIFONum; i++) {
                int blk, blk_max = config->TxCfg[i].FifoLen;

                for (blk = 0; blk < blk_max; blk += lst_per_page) {
                        struct list_info_hold *lih = &nic->list_info[i][blk];

                        if (!lih->list_virt_addr)
                                break;
                        pci_free_consistent(nic->pdev, PAGE_SIZE,
                                lih->list_virt_addr, lih->list_phy_addr);
                }
                kfree(nic->list_info[i]);
        }

[...]
@@ -858,22 +963,57 @@
        writel((u32) (val64 >> 32), (add + 4));
        val64 = readq(&bar0->mac_cfg);
 
+       /*Set the time value  to be inserted in the pause frame generated by 
xena */
+       val64 = readq(&bar0->rmac_pause_cfg);
+       val64 &= ~(RMAC_PAUSE_HG_PTIME(0xffff));
+       val64 |= RMAC_PAUSE_HG_PTIME(nic->mac_control.rmac_pause_time);
+       writeq(val64, &bar0->rmac_pause_cfg);
+
+       /* Set the Threshold Limit for Generating the pause frame
+        * If the amount of data in any Queue exceeds ratio of
+        * (mac_control.mc_pause_threshold_q0q3 or q4q7)/256
+        * pause frame is generated
+        */
+       val64 = 0;
+       for (i = 0; i < 4; i++) {
+               val64 |=
+                   (((u64) 0xFF00 | nic->mac_control.
+                     mc_pause_threshold_q0q3)
+                    << (i * 2 * 8));
+       }

-> (internal parser panic) keep 'mc_pause_threshold_q0q3' on its containing
   struct line ?

-> May be it's not worth it but you can save an iteration:
   val64 = (u64) 0xFF00 | nic->mac_control.mc_pause_threshold_q0q3;
   val64 |= val64 << 16;
   val64 |= val64 << 32;

   You can wrap the whole thing behind an inlined function if it tends
   to appear several times.

--
Ueimor

<Prev in Thread] Current Thread [Next in Thread>