From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Liu, Jijiang" Subject: Re: could not l2fwd in DOM0 Date: Thu, 29 May 2014 10:12:21 +0000 Message-ID: <1ED644BD7E0A5F4091CF203DAFB8E4CC01C7AB55@SHSMSX101.ccr.corp.intel.com> References: <1ED644BD7E0A5F4091CF203DAFB8E4CC01C77421@SHSMSX101.ccr.corp.intel.com> <1815026.ZOX21DlnhJ@xps13> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "dev-VfR2kkLFssw@public.gmane.org" , "SMonderer-FQHY9aGUihGE8VeLPBfq+Q@public.gmane.org" , "xen-devel-GuqFBffKawuEi8DpZVb4nw@public.gmane.org" To: Thomas Monjalon Return-path: In-Reply-To: <1815026.ZOX21DlnhJ@xps13> Content-Language: en-US List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Ok, I will send a patch for fixing this. -----Original Message----- From: Thomas Monjalon [mailto:thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org]=20 Sent: Thursday, May 29, 2014 5:59 PM To: Liu, Jijiang Cc: dev-VfR2kkLFssw@public.gmane.org; SMonderer-FQHY9aGUihGE8VeLPBfq+Q@public.gmane.org; xen-devel-GuqFBffKawuEi8DpZVb4nw@public.gmane.org Subject: Re: [dpdk-dev] could not l2fwd in DOM0 Jijiang, I'm not sure to understand. Could you send a proper patch for this issue? Thanks --=20 Thomas 2014-05-17 07:48, Liu, Jijiang: > In Linux kernel versions < 3.14 , the vstart is kernel virtual address, t= he > API prototype below. int xen_create_contiguous_region(unsigned long vstar= t, > unsigned int order, unsigned int address_bits) >=20 > In Linux kernel 3.14, the pstart is kernel physical address, the API > prototype below. int xen_create_contiguous_region(phys_addr_t pstart, > unsigned int order, unsigned int address_bits, > dma_addr_t *dma_handle) >=20 > ,so the mm_data->block_info[i].vir_addr cannot pass to > xen_create_contiguous_region() directly for Linux kernel 3.14, the pstart > should be mm_data->block_info[i].pfn * PAGE_SIZE in the Dom0 Driver. >=20 > #include > #include > #include >=20 > #include > #include > @@ -309,6 +310,7 @@ dom0_prepare_memsegs(struct memory_info* meminfo, str= uct > dom0_mm_data uint64_t pfn, vstart, vaddr; > uint32_t i, num_block, size; > int idx; > + dma_addr_t dma_handle; >=20 > /* Allocate 2M memory once */ > num_block =3D meminfo->size / 2; > @@ -344,7 +346,7 @@ dom0_prepare_memsegs(struct memory_info* meminfo, str= uct > dom0_mm_data * contiguous physical addresses, its maximum size is 2M. */ > if (xen_create_contiguous_region(mm_data->block_info[i].p= fn > * 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); >=20 > Thanks > Frank Liu >=20 > -----Original Message----- > From: dev [mailto:dev-bounces-VfR2kkLFssw@public.gmane.org] On Behalf Of Samuel Monderer > Sent: Wednesday, May 07, 2014 8:44 PM > To: Liu, Jijiang > Cc: dev-VfR2kkLFssw@public.gmane.org > Subject: Re: [dpdk-dev] could not l2fwd in DOM0 >=20 > > -----Original Message----- > > From: dev [mailto:dev-bounces-VfR2kkLFssw@public.gmane.org] On Behalf Of Liu, Jijiang > > Sent: Wednesday, May 07, 2014 7:36 AM > > To: dev-VfR2kkLFssw@public.gmane.org > > Subject: Re: [dpdk-dev] could not l2fwd in DOM0 > >=20 > > Hi, > >=20 > > I have checked source codes of xen_create_contiguous_region function > > 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= , > >=20 > > unsigned int address_bits, > > dma_addr_t *dma_handle) { > > =20 > > unsigned long *in_frames =3D discontig_frames, out_frame; > > unsigned long flags; > > int success; > > unsigned long vstart =3D (unsigned long)phys_to_virt(pstart); > > =20 > > ... > > =20 > > *dma_handle =3D virt_to_machine(vstart).maddr; > > return success ? 0 : -ENOMEM; > >=20 > > } > >=20 > > Thanks > > Frank Liu >=20 > Thanks Frank, >=20 > I've changed the code as following but now the kernel module crashes. >=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 >=20 > #include > #include > @@ -309,6 +310,7 @@ dom0_prepare_memsegs(struct memory_info* meminfo, str= uct > dom0_mm_data uint64_t pfn, vstart, vaddr; > uint32_t i, num_block, size; > int idx; > + dma_addr_t dma_handle; >=20 > /* Allocate 2M memory once */ > num_block =3D meminfo->size / 2; > @@ -344,7 +346,7 @@ dom0_prepare_memsegs(struct memory_info* meminfo, str= uct > dom0_mm_data * contiguous physical addresses, its maximum size is 2M. */ > if > (xen_create_contiguous_region(mm_data->block_info[i].vir_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 > pfn_to_mfn(mm_data->block_info[i].pfn); >=20 > Samuel >=20 > > -----Original Message----- > > From: dev [mailto:dev-bounces-VfR2kkLFssw@public.gmane.org] On Behalf Of Samuel Monderer > > Sent: Wednesday, April 30, 2014 1:54 AM > > To: dev-VfR2kkLFssw@public.gmane.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 > > to prototype change of the function xen_create_contiguous_region I > > 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 @@ > >=20 > > #include > > #include > > #include > >=20 > > +//#include > >=20 > > #include > > #include > >=20 > > @@ -309,6 +310,7 @@ dom0_prepare_memsegs(struct memory_info* meminfo, > > struct dom0_mm_data > >=20 > > uint64_t pfn, vstart, vaddr; > > uint32_t i, num_block, size; > > int idx; > >=20 > > + 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 > >=20 > > * contiguous physical addresses, its maximum size is 2= M. > > */ > > =20 > > if > > (xen_create_contiguous_region(mm_data->block_info[i].vi= r_ > > addr, > >=20 > > - DOM0_CONTIG_NUM_ORDER, 0) =3D=3D 0)= { > > + DOM0_CONTIG_NUM_ORDER, 0, > > + dma_handle) =3D=3D 0) { > >=20 > > 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 > > root@Smart:~/samuelm/dpdk/dpdk# insmod ./x86_64-default-linuxapp- > > gcc/kmod/igb_uio.ko root@Smart:~/samuelm/dpdk/dpdk# insmod > > ./x86_64-default-linuxapp- gcc/kmod/rte_dom0_mm.ko > > root@Smart:~/samuelm/dpdk/dpdk# cd examples/l2fwd/build/ > > root@Smart:~/samuelm/dpdk/dpdk/examples/l2fwd/build# echo 2048 > > > /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