From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by dpdk.org (Postfix) with ESMTP id 156C7B102 for ; Sat, 17 May 2014 09:48:31 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 17 May 2014 00:48:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,1071,1392192000"; d="scan'208";a="433355145" Received: from fmsmsx107.amr.corp.intel.com ([10.19.9.54]) by azsmga001.ch.intel.com with ESMTP; 17 May 2014 00:48:38 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX107.amr.corp.intel.com (10.19.9.54) with Microsoft SMTP Server (TLS) id 14.3.123.3; Sat, 17 May 2014 00:48:37 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.123.3; Sat, 17 May 2014 00:48:37 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.7]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.7]) with mapi id 14.03.0123.003; Sat, 17 May 2014 15:48:35 +0800 From: "Liu, Jijiang" To: "dev@dpdk.org" , "SMonderer@advaoptical.com" Thread-Topic: [dpdk-dev] could not l2fwd in DOM0 Thread-Index: Ac9xoCQ5KTTnc1T/Rc2f6eZFw/0KuQ== Date: Sat, 17 May 2014 07:48:34 +0000 Message-ID: <1ED644BD7E0A5F4091CF203DAFB8E4CC01C77421@SHSMSX101.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "xen-devel@lists.xen.org" Subject: [dpdk-dev] could not l2fwd in DOM0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 May 2014 07:48:33 -0000 In Linux kernel versions < 3.14 , the vstart is kernel virtual address, the= API prototype below. int xen_create_contiguous_region(unsigned long vstart, unsigned int order, unsigned int address_bits) In Linux kernel 3.14, the pstart is kernel physical address, the API protot= ype below. int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order, unsigned int address_bits, dma_addr_t *dma_handle) ,so the mm_data->block_info[i].vir_addr cannot pass to xen_create_contiguou= s_region() directly for Linux kernel 3.14, the pstart should be mm_data->bl= ock_info[i].pfn * PAGE_SIZE in the Dom0 Driver. #include #include #include #include #include @@ -309,6 +310,7 @@ dom0_prepare_memsegs(struct memory_info* meminfo, struc= t dom0_mm_data uint64_t pfn, vstart, vaddr; uint32_t i, num_block, size; int idx; + dma_addr_t dma_handle; /* Allocate 2M memory once */ num_block =3D meminfo->size / 2; @@ -344,7 +346,7 @@ dom0_prepare_memsegs(struct memory_info* meminfo, struc= t dom0_mm_data * contiguous physical addresses, its maximum size is 2M. */ if (xen_create_contiguous_region(mm_data->block_info[i].pfn= * PAGE_SIZE, - DOM0_CONTIG_NUM_ORDER, 0) =3D=3D 0) { + DOM0_CONTIG_NUM_ORDER, 0, + &dma_handle) =3D=3D 0) { mm_data->block_info[i].exchange_flag =3D 1; mm_data->block_info[i].mfn =3D pfn_to_mfn(mm_data->block_info[i].pfn); Thanks Frank Liu -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Samuel Monderer Sent: Wednesday, May 07, 2014 8:44 PM To: Liu, Jijiang Cc: dev@dpdk.org Subject: Re: [dpdk-dev] could not l2fwd in DOM0 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Liu, Jijiang > Sent: Wednesday, May 07, 2014 7:36 AM > To: dev@dpdk.org > Subject: Re: [dpdk-dev] could not l2fwd in DOM0 >=20 > Hi, >=20 > I have checked source codes of xen_create_contiguous_region function=20 > in kernel 3.14, and found the dma_handle cannot be NULL. >=20 > int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order, > unsigned int address_bits, > dma_addr_t *dma_handle) { > unsigned long *in_frames =3D discontig_frames, out_frame; > unsigned long flags; > int success; > unsigned long vstart =3D (unsigned long)phys_to_virt(pstart); > ... > *dma_handle =3D virt_to_machine(vstart).maddr; > return success ? 0 : -ENOMEM; > } >=20 > Thanks > Frank Liu >=20 Thanks Frank, I've changed the code as following but now the kernel module crashes. diff --git a/lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c b/lib/librte_eal/linuxapp/xen index 87fa3e6..8addc21 100644 --- a/lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c +++ b/lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c @@ -64,6 +64,7 @@ =A0#include =A0#include =A0#include =A0#include =A0#include @@ -309,6 +310,7 @@ dom0_prepare_memsegs(struct memory_info* meminfo, struc= t dom0_mm_data =A0=A0=A0=A0=A0=A0=A0=A0uint64_t pfn, vstart, vaddr; =A0=A0=A0=A0=A0=A0=A0=A0uint32_t i, num_block, size; =A0=A0=A0=A0=A0=A0=A0=A0int idx; +=A0=A0=A0=A0=A0=A0=A0dma_addr_t dma_handle; =A0=A0=A0=A0=A0=A0=A0=A0/* Allocate 2M memory once */ =A0=A0=A0=A0=A0=A0=A0=A0num_block =3D meminfo->size / 2; @@ -344,7 +346,7 @@ dom0_prepare_memsegs(struct memory_info* meminfo, struc= t dom0_mm_data =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0* contiguous physical ad= dresses, its maximum size is 2M. =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0*/ =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (xen_create_contiguous_r= egion(mm_data->block_info[i].vir_addr, -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DOM0_CONTIG_NUM_ORDER, 0) =3D=3D 0) { +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0DOM0_CONTIG_NUM_ORDER, 0, + &dma_handle) =3D=3D 0) { =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0mm_= data->block_info[i].exchange_flag =3D 1; =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0mm_= data->block_info[i].mfn =3D =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0pfn_to_mfn(mm_data->block_info[i].pfn); Samuel > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Samuel Monderer > Sent: Wednesday, April 30, 2014 1:54 AM > To: dev@dpdk.org > Cc: Shimon Zadok > Subject: [dpdk-dev] could not l2fwd in DOM0 >=20 > Hi, >=20 > First I've encountered a compiling problem when compiling for DOM0 due=20 > to prototype change of the function xen_create_contiguous_region I=20 > made the following changes: >=20 > diff --git a/lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c > b/lib/librte_eal/linuxapp/xen index 87fa3e6..8addc21 100644 > --- a/lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c > +++ b/lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c > @@ -64,6 +64,7 @@ > #include > #include > #include > +//#include >=20 > #include > #include > @@ -309,6 +310,7 @@ dom0_prepare_memsegs(struct memory_info* meminfo,=20 > struct dom0_mm_data > uint64_t pfn, vstart, vaddr; > uint32_t i, num_block, size; > int idx; > + dma_addr_t *dma_handle =3D NULL; >=20 > /* Allocate 2M memory once */ > num_block =3D meminfo->size / 2; @@ -344,7 +346,7 @@=20 > dom0_prepare_memsegs(struct memory_info* meminfo, struct dom0_mm_data > * contiguous physical addresses, its maximum size is 2M. > */ > if (xen_create_contiguous_region(mm_data->block_info[i].v= ir_addr, > - DOM0_CONTIG_NUM_ORDER, 0) =3D=3D 0) { > + DOM0_CONTIG_NUM_ORDER, 0, > + dma_handle) =3D=3D 0) { > mm_data->block_info[i].exchange_flag =3D 1; > mm_data->block_info[i].mfn =3D > =20 > pfn_to_mfn(mm_data->block_info[i].pfn); >=20 > After that I tried to run l2fwd example and got a segmentation fault >=20 > root@Smart:~/samuelm/dpdk/dpdk# modprobe uio=20 > root@Smart:~/samuelm/dpdk/dpdk# insmod ./x86_64-default-linuxapp-=20 > gcc/kmod/igb_uio.ko root@Smart:~/samuelm/dpdk/dpdk# insmod=20 > ./x86_64-default-linuxapp- gcc/kmod/rte_dom0_mm.ko=20 > root@Smart:~/samuelm/dpdk/dpdk# cd examples/l2fwd/build/=20 > root@Smart:~/samuelm/dpdk/dpdk/examples/l2fwd/build# echo 2048 >=20 > /sys/kernel/mm/dom0-mm/memsize-mB/memsize > root@Smart:~/samuelm/dpdk/dpdk/examples/l2fwd/build# ./l2fwd -c 3 -n 4 > --xen-dom0 -- -q 1 -p 3 > EAL: Detected lcore 0 as core 0 on socket 0 > EAL: Detected lcore 1 as core 0 on socket 0 > EAL: Setting up memory... > Segmentation fault > root@Smart:~/samuelm/dpdk/dpdk/examples/l2fwd/build# >=20 > Has anyone already encountered this problem? >=20 > Samuelm