From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by dpdk.org (Postfix) with ESMTP id 159A81B1B9 for ; Fri, 6 Oct 2017 16:07:02 +0200 (CEST) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v96E3bY8053877 for ; Fri, 6 Oct 2017 10:07:02 -0400 Received: from smtp.notes.na.collabserv.com (smtp.notes.na.collabserv.com [192.155.248.82]) by mx0b-001b2d01.pphosted.com with ESMTP id 2deab33pd8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 06 Oct 2017 10:07:02 -0400 Received: from localhost by smtp.notes.na.collabserv.com with smtp.notes.na.collabserv.com ESMTP for from ; Fri, 6 Oct 2017 14:07:01 -0000 Received: from us1a3-smtp05.a3.dal06.isc4sb.com (10.146.71.159) by smtp.notes.na.collabserv.com (10.106.227.105) with smtp.notes.na.collabserv.com ESMTP; Fri, 6 Oct 2017 14:06:55 -0000 Received: from us1a3-mail173.a3.dal06.isc4sb.com ([10.146.71.126]) by us1a3-smtp05.a3.dal06.isc4sb.com with ESMTP id 2017100614065426-563584 ; Fri, 6 Oct 2017 14:06:54 +0000 MIME-Version: 1.0 In-Reply-To: <37567ebc-ddb2-98fe-3e52-a27ec572de66@intel.com> To: "Burakov, Anatoly" Cc: dev@dpdk.org From: "Jonas Pfefferle1" Date: Fri, 6 Oct 2017 16:06:53 +0200 References: <1506351857-32234-1-git-send-email-jpf@zurich.ibm.com> <37567ebc-ddb2-98fe-3e52-a27ec572de66@intel.com> X-KeepSent: 43B8B9DB:CCC045E2-C12581B1:004D5F59; type=4; name=$KeepSent X-Mailer: IBM Notes Release 9.0.1 October 14, 2013 X-LLNOutbound: False X-Disclaimed: 29595 X-TNEFEvaluated: 1 x-cbid: 17100614-5101-0000-0000-000006788324 X-IBM-SpamModules-Scores: BY=0.03524; FL=0; FP=0; FZ=0; HX=0; KW=0; PH=0; SC=0.417846; ST=0; TS=0; UL=0; ISC=; MB=0.000507 X-IBM-SpamModules-Versions: BY=3.00007849; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000235; SDB=6.00927284; UDB=6.00466580; IPR=6.00707542; BA=6.00005623; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017420; XFM=3.00000015; UTC=2017-10-06 14:06:59 X-IBM-AV-DETECTION: SAVI=unsuspicious REMOTE=unsuspicious XFE=unused X-IBM-AV-VERSION: SAVI=2017-10-06 11:17:45 - 6.00007420 x-cbparentid: 17100614-5102-0000-0000-0000DE99C904 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-06_04:, , signatures=0 X-Proofpoint-Spam-Reason: safe Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v2] vfio: refactor PCI BAR mapping X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Oct 2017 14:07:03 -0000 Hi Anatoly, "Burakov, Anatoly" wrote on 10/04/2017 03:13:22 PM: > From: "Burakov, Anatoly" > To: Jonas Pfefferle , dev@dpdk.org > Date: 10/04/2017 03:14 PM > Subject: Re: [PATCH v2] vfio: refactor PCI BAR mapping > > On 25-Sep-17 4:04 PM, Jonas Pfefferle wrote: > > Split pci=5Fvfio=5Fmap=5Fresource for primary and secondary processes. > > Save all relevant mapping data in primary process to allow > > the secondary process to perform mappings. > > > > Signed-off-by: Jonas Pfefferle > > --- > > v2: > > * fix zero size and offset when trying to mmap non msix bar > > > > lib/librte=5Feal/common/include/rte=5Fpci.h | 7 + > > lib/librte=5Feal/linuxapp/eal/eal=5Fpci=5Fvfio.c | 446 +++++++++++++++ > ++------------ > > 2 files changed, 271 insertions(+), 182 deletions(-) > > > > diff --git a/lib/librte=5Feal/common/include/rte=5Fpci.h b/lib/ > librte=5Feal/common/include/rte=5Fpci.h > > index 8b12339..0821af9 100644 > > --- a/lib/librte=5Feal/common/include/rte=5Fpci.h > > +++ b/lib/librte=5Feal/common/include/rte=5Fpci.h > > @@ -214,6 +214,12 @@ struct pci=5Fmap { > > uint64=5Ft phaddr; > > }; > > > > +struct pci=5Fmsix=5Ftable { > > + int bar=5Findex; > > + uint32=5Ft offset; > > + uint32=5Ft size; > > +}; > > + > > /** > > * A structure describing a mapped PCI resource. > > * For multi-process we need to reproduce all PCI mappings in secondary > > @@ -226,6 +232,7 @@ struct mapped=5Fpci=5Fresource { > > char path[PATH=5FMAX]; > > int nb=5Fmaps; > > struct pci=5Fmap maps[PCI=5FMAX=5FRESOURCE]; > > + struct pci=5Fmsix=5Ftable msix=5Ftable; > > }; > > > > /** mapped pci device list */ > > diff --git a/lib/librte=5Feal/linuxapp/eal/eal=5Fpci=5Fvfio.c b/lib/ > librte=5Feal/linuxapp/eal/eal=5Fpci=5Fvfio.c > > index aa9d96e..6443bd5 100644 > > --- a/lib/librte=5Feal/linuxapp/eal/eal=5Fpci=5Fvfio.c > > +++ b/lib/librte=5Feal/linuxapp/eal/eal=5Fpci=5Fvfio.c > > @@ -88,8 +88,7 @@ pci=5Fvfio=5Fwrite=5Fconfig(const struct > rte=5Fintr=5Fhandle *intr=5Fhandle, > > > > /* get PCI BAR number where MSI-X interrupts are */ > > static int > > -pci=5Fvfio=5Fget=5Fmsix=5Fbar(int fd, int *msix=5Fbar, uint32=5Ft *msix=5Ftable=5Foffset, > > - uint32=5Ft *msix=5Ftable=5Fsize) > > +pci=5Fvfio=5Fget=5Fmsix=5Fbar(int fd, struct pci=5Fmsix=5Ftable *msix= =5Ftable) > > { > > int ret; > > uint32=5Ft reg; > > @@ -161,9 +160,10 @@ pci=5Fvfio=5Fget=5Fmsix=5Fbar(int fd, int *msix=5F= bar, > uint32=5Ft *msix=5Ftable=5Foffset, > > return -1; > > } > > > > - *msix=5Fbar =3D reg & RTE=5FPCI=5FMSIX=5FTABLE=5FBIR; > > - *msix=5Ftable=5Foffset =3D reg & RTE=5FPCI=5FMSIX=5FTABLE=5FO= FFSET; > > - *msix=5Ftable=5Fsize =3D 16 * (1 + (flags & RTE=5FPCI=5FMSIX=5FFLAGS=5FQSIZE)); > > + msix=5Ftable->bar=5Findex =3D reg & RTE=5FPCI=5FMSIX=5FTABLE= =5FBIR; > > + msix=5Ftable->offset =3D reg & RTE=5FPCI=5FMSIX=5FTABLE=5FOFF= SET; > > + msix=5Ftable->size =3D > > + 16 * (1 + (flags & RTE=5FPCI=5FMSIX=5FFLAGS=5FQSIZE)); > > > > return 0; > > } > > @@ -300,25 +300,150 @@ pci=5Fvfio=5Fsetup=5Finterrupts(struct > rte=5Fpci=5Fdevice *dev, int vfio=5Fdev=5Ffd) > > return -1; > > } > > > > -/* > > - * map the PCI resources of a PCI device in virtual memory (VFIO version). > > - * primary and secondary processes follow almost exactly the same path > > - */ > > -int > > -pci=5Fvfio=5Fmap=5Fresource(struct rte=5Fpci=5Fdevice *dev) > > +static int > > +pci=5Fvfio=5Fis=5Fioport=5Fbar(int vfio=5Fdev=5Ffd, int bar=5Findex) > > +{ > > + uint32=5Ft ioport=5Fbar; > > + int ret; > > + > > + ret =3D pread64(vfio=5Fdev=5Ffd, &ioport=5Fbar, sizeof(ioport=5Fbar= ), > > + VFIO=5FGET=5FREGION=5FADDR(VFIO=5FPCI=5FCONFIG=5FREGION=5FI= NDEX) > > + + PCI=5FBASE=5FADDRESS=5F0 + bar=5Findex*4); > > + if (ret !=3D sizeof(ioport=5Fbar)) { > > + RTE=5FLOG(ERR, EAL, "Cannot read command (%x) from config space!\n", > > + PCI=5FBASE=5FADDRESS=5F0 + bar=5Findex*4); > > + return -1; > > + } > > + > > + return ioport=5Fbar & PCI=5FBASE=5FADDRESS=5FSPACE=5FIO; > > Not sure i like this. I think it's better to be explicit, e.g. > return ioport=5Fbar & PCI=5FBASE=5FADDRESS=5FSPACE=5FIO !=3D 0; > > Makes no difference (both because return value is non-zero and because > PCI=5FBASE=5FADDRESS=5FSPACE=5FIO is 0x01), but still, better to make int= entions > clear i think. I agree. I wanted to change this anyway but forgot. V3 is going out in a sec. Thanks for the ack ;) > > Otherwise, did a quick smoke-test and it works, so > > Acked-by: Anatoly Burakov > > Keep the ack if you decide to submit a v3 :) >