Re: [RESEND] [PATCH v2] [3/5] pasemi_mac: cleanups and rx performance improvements

2007-04-28 Thread Olof Johansson
On Sat, Apr 28, 2007 at 11:22:43AM -0400, Jeff Garzik wrote:
> Olof Johansson wrote:
> >NAPI fixes and cleanups for pasemi_mac:
> >
> >* Timer changes/fixes
> >* Abstract out the rx intr restart to a separate function
> >* Similar function for tx intr to reset to a known clear state even if
> >  firmware used the same interface
> >* Add a copy-break and recycle the SKB in the driver for small
> >  packets
> >* Other minor changes to rx path
> 
> Split out the "abstract out function foo" style changes into a separate 
> patch.
> 
> This creates a smaller and much more reviewable second patch as a 
> result.  Doing so also creates a nice, clean git-bisect point that can 
> be used to guarantee the validity of the first patch.

Ok, I was really asking for this one...

Even that didn't result in that much of a more readible patch.

I've split it up in a total of 5. I'll repost the series shortly.


Thanks,

-Olof
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND] [PATCH v2] [3/5] pasemi_mac: cleanups and rx performance improvements

2007-04-28 Thread Jeff Garzik

Olof Johansson wrote:

NAPI fixes and cleanups for pasemi_mac:

* Timer changes/fixes
* Abstract out the rx intr restart to a separate function
* Similar function for tx intr to reset to a known clear state even if
  firmware used the same interface
* Add a copy-break and recycle the SKB in the driver for small
  packets
* Other minor changes to rx path


Split out the "abstract out function foo" style changes into a separate 
patch.


This creates a smaller and much more reviewable second patch as a 
result.  Doing so also creates a nice, clean git-bisect point that can 
be used to guarantee the validity of the first patch.


Jeff



-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND] [PATCH v2] [3/5] pasemi_mac: cleanups and rx performance improvements

2007-04-27 Thread Olof Johansson
NAPI fixes and cleanups for pasemi_mac:

* Timer changes/fixes
* Abstract out the rx intr restart to a separate function
* Similar function for tx intr to reset to a known clear state even if
  firmware used the same interface
* Add a copy-break and recycle the SKB in the driver for small
  packets
* Other minor changes to rx path

Signed-off-by: Olof Johansson <[EMAIL PROTECTED]>

Index: powerpc/drivers/net/pasemi_mac.c
===
--- powerpc.orig/drivers/net/pasemi_mac.c
+++ powerpc/drivers/net/pasemi_mac.c
@@ -61,12 +61,6 @@
 
 #define BUF_SIZE 1646 /* 1500 MTU + ETH_HLEN + VLAN_HLEN + 2 64B cachelines */
 
-/* XXXOJN these should come out of the device tree some day */
-#define PAS_DMA_CAP_BASE   0xe00d0040
-#define PAS_DMA_CAP_SIZE   0x100
-#define PAS_DMA_COM_BASE   0xe00d0100
-#define PAS_DMA_COM_SIZE   0x100
-
 static struct pasdma_status *dma_status;
 
 static int pasemi_get_mac_addr(struct pasemi_mac *mac)
@@ -279,8 +273,8 @@ static void pasemi_mac_free_rx_resources
for (i = 0; i < RX_RING_SIZE; i++) {
info = &RX_DESC_INFO(mac, i);
dp = &RX_DESC(mac, i);
-   if (info->dma) {
-   if (info->skb) {
+   if (info->skb) {
+   if (info->dma) {
pci_unmap_single(mac->dma_pdev,
 info->dma,
 info->skb->len,
@@ -311,84 +305,122 @@ static void pasemi_mac_replenish_rx_ring
struct pasemi_mac *mac = netdev_priv(dev);
unsigned int i;
int start = mac->rx->next_to_fill;
-   unsigned int count;
+   unsigned int limit, count;
 
-   count = (mac->rx->next_to_clean + RX_RING_SIZE -
+   limit = (mac->rx->next_to_clean + RX_RING_SIZE -
 mac->rx->next_to_fill) & (RX_RING_SIZE - 1);
 
/* Check to see if we're doing first-time setup */
if (unlikely(mac->rx->next_to_clean == 0 && mac->rx->next_to_fill == 0))
-   count = RX_RING_SIZE;
+   limit = RX_RING_SIZE;
 
-   if (count <= 0)
+   if (limit <= 0)
return;
 
-   for (i = start; i < start + count; i++) {
+   i = start;
+
+   for (count = limit; count; count--) {
struct pasemi_mac_buffer *info = &RX_DESC_INFO(mac, i);
u64 *buff = &RX_BUFF(mac, i);
struct sk_buff *skb;
dma_addr_t dma;
 
-   skb = dev_alloc_skb(BUF_SIZE);
+   /* skb might still be in there for recycle on short receives */
+   if (info->skb)
+   skb = info->skb;
+   else
+   skb = dev_alloc_skb(BUF_SIZE);
 
-   if (!skb) {
-   count = i - start;
+   if (unlikely(!skb))
break;
-   }
 
skb->dev = dev;
 
dma = pci_map_single(mac->dma_pdev, skb->data, skb->len,
 PCI_DMA_FROMDEVICE);
 
-   if (dma_mapping_error(dma)) {
+   if (unlikely(dma_mapping_error(dma))) {
dev_kfree_skb_irq(info->skb);
-   count = i - start;
break;
}
 
info->skb = skb;
info->dma = dma;
*buff = XCT_RXB_LEN(BUF_SIZE) | XCT_RXB_ADDR(dma);
+   i++;
}
 
wmb();
 
pci_write_config_dword(mac->dma_pdev,
   PAS_DMA_RXCHAN_INCR(mac->dma_rxch),
-  count);
+  limit - count);
pci_write_config_dword(mac->dma_pdev,
   PAS_DMA_RXINT_INCR(mac->dma_if),
-  count);
+  limit - count);
+
+   mac->rx->next_to_fill += limit - count;
+}
+
+static void pasemi_mac_restart_rx_intr(struct pasemi_mac *mac)
+{
+   unsigned int reg, stat;
+   /* Re-enable packet count interrupts: finally
+* ack the packet count interrupt we got in rx_intr.
+*/
+
+   pci_read_config_dword(mac->iob_pdev,
+ PAS_IOB_DMA_RXCH_STAT(mac->dma_rxch),
+ &stat);
+
+   reg = PAS_IOB_DMA_RXCH_RESET_PCNT(stat & 
PAS_IOB_DMA_RXCH_STAT_CNTDEL_M) |
+ PAS_IOB_DMA_RXCH_RESET_PINTC;
+
+   pci_write_config_dword(mac->iob_pdev,
+  PAS_IOB_DMA_RXCH_RESET(mac->dma_rxch),
+  reg);
+}
+
+static void pasemi_mac_restart_tx_intr(struct pasemi_mac *mac)
+{
+   unsigned int reg, stat;
 
-   mac->rx->next_to_fill += count;
+   /* Re-enable packet count interrupts */
+   pci_read_config_dword(mac->iob_pdev,
+ PAS_IOB_DMA_TXCH_STAT(mac->dma_txch), &stat