WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ppc-devel

[XenPPC] [linux-ppc-2.6] [LINUX][XEN][POWERPC] Enable PowerPC use of net

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Subject: [XenPPC] [linux-ppc-2.6] [LINUX][XEN][POWERPC] Enable PowerPC use of netback
From: Xen patchbot-linux-ppc-2.6 <patchbot-linux-ppc-2.6@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 10 Oct 2006 14:03:22 +0000
Delivery-date: Tue, 10 Oct 2006 07:22:08 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ppc-devel-request@lists.xensource.com?subject=help>
List-id: Xen PPC development <xen-ppc-devel.lists.xensource.com>
List-post: <mailto:xen-ppc-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
# Node ID d2b37a151f5b27924e5aa59b4701ae8a7a623b25
# Parent  f18ec562c11cabed94d448a12754660c63497fac
[LINUX][XEN][POWERPC] Enable PowerPC use of netback

This patch uses ifdefs heavilty simply to identify areas of change so
that arch independent interfaces can be introduced later as we update
with upstream changes.

Signed-off-by: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
---
 drivers/xen/netback/netback.c |   72 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 60 insertions(+), 12 deletions(-)

diff -r f18ec562c11c -r d2b37a151f5b drivers/xen/netback/netback.c
--- a/drivers/xen/netback/netback.c     Tue Oct 10 09:48:33 2006 -0400
+++ b/drivers/xen/netback/netback.c     Tue Oct 10 09:57:12 2006 -0400
@@ -71,9 +71,35 @@ static struct sk_buff_head rx_queue;
 static struct sk_buff_head rx_queue;
 
 static unsigned long mmap_vstart;
+#ifdef CONFIG_PPC_XEN
+
+
+static ulong mmap_vaddrs[MAX_PENDING_REQS];
+#define MMAP_VADDR(_req) (mmap_vaddrs[(_req)])
+
+static inline void PPC_map_vaddrs(int idx, gnttab_map_grant_ref_t *mop)
+{
+       struct page *page;
+       ulong virt = mop->host_addr;
+
+       page = virt_to_page(virt);
+       get_page(page);
+
+#if 0
+       SetPageForeign(page, netif_page_release);
+#else
+       (void)netif_page_release;
+#endif
+       mmap_vaddrs[idx] = virt;
+}
+#define _mmap_vaddrs(i,op) do { mmap_vaddrs[(i)] = mop->host_addr;
+#else
 #define MMAP_VADDR(_req) (mmap_vstart + ((_req) * PAGE_SIZE))
-
+#endif
+
+#ifndef CONFIG_PPC_XEN
 static void *rx_mmap_area;
+#endif
 
 #define PKT_PROT_LEN 64
 
@@ -939,9 +965,13 @@ static int netbk_tx_check_mop(struct sk_
                pending_ring[MASK_PEND_IDX(pending_prod++)] = pending_idx;
                netif_put(netif);
        } else {
+#ifdef CONFIG_PPC_XEN
+               PPC_map_vaddrs(pending_idx, mop);
+#else
                set_phys_to_machine(
                        __pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT,
                        FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT));
+#endif
                grant_tx_handle[pending_idx] = mop->handle;
        }
 
@@ -956,9 +986,13 @@ static int netbk_tx_check_mop(struct sk_
                /* Check error status: if okay then remember grant handle. */
                newerr = (++mop)->status;
                if (likely(!newerr)) {
+#ifdef CONFIG_PPC_XEN
+                       PPC_map_vaddrs(pending_idx, mop);
+#else
                        set_phys_to_machine(
                                __pa(MMAP_VADDR(pending_idx))>>PAGE_SHIFT,
                                FOREIGN_FRAME(mop->dev_bus_addr>>PAGE_SHIFT));
+#endif
                        grant_tx_handle[pending_idx] = mop->handle;
                        /* Had a previous error? Invalidate this fragment. */
                        if (unlikely(err))
@@ -1317,17 +1351,20 @@ static void netif_page_release(struct pa
 {
        u16 pending_idx = page - virt_to_page(mmap_vstart);
 
+#ifdef CONFIG_PPC_XEN  /* Ready for next use. */
+       BUG();
+#endif 
+       init_page_count(page);
+       netif_idx_release(pending_idx);
+}
+
+#ifndef CONFIG_PPC_XEN
+static void netif_rx_page_release(struct page *page)
+{
        /* Ready for next use. */
        init_page_count(page);
-
-       netif_idx_release(pending_idx);
-}
-
-static void netif_rx_page_release(struct page *page)
-{
-       /* Ready for next use. */
-       init_page_count(page);
-}
+}
+#endif
 
 irqreturn_t netif_be_int(int irq, void *dev_id, struct pt_regs *regs)
 {
@@ -1437,6 +1474,10 @@ static int __init netback_init(void)
        if (!is_running_on_xen())
                return -ENODEV;
 
+#ifdef CONFIG_PPC_XEN
+       if (!(xen_start_info->flags & SIF_INITDOMAIN))
+               return -ENODEV;
+#endif
        /* We can increase reservation by this much in net_rx_action(). */
        balloon_update_driver_allowance(NET_RX_RING_SIZE);
 
@@ -1446,7 +1487,11 @@ static int __init netback_init(void)
        init_timer(&net_timer);
        net_timer.data = 0;
        net_timer.function = net_alarm;
-    
+
+#ifdef CONFIG_PPC_XEN
+       (void)page;
+       mmap_vstart = foreign_alloc_empty_page_range(MAX_PENDING_REQS);
+#else
        page = balloon_alloc_empty_page_range(MAX_PENDING_REQS);
        if (page == NULL)
                return -ENOMEM;
@@ -1458,7 +1503,9 @@ static int __init netback_init(void)
                init_page_count(page);
                SetPageForeign(page, netif_page_release);
        }
-
+#endif
+
+#ifndef CONFIG_PPC_XEN
        page = balloon_alloc_empty_page_range(NET_RX_RING_SIZE);
        BUG_ON(page == NULL);
        rx_mmap_area = pfn_to_kaddr(page_to_pfn(page));
@@ -1468,6 +1515,7 @@ static int __init netback_init(void)
                init_page_count(page);
                SetPageForeign(page, netif_rx_page_release);
        }
+#endif
 
        pending_cons = 0;
        pending_prod = MAX_PENDING_REQS;

_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel