From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ob0-f180.google.com (mail-ob0-f180.google.com [209.85.214.180]) by dpdk.org (Postfix) with ESMTP id 287B2C43C for ; Wed, 17 Jun 2015 16:44:32 +0200 (CEST) Received: by obbkn5 with SMTP id kn5so5743766obb.0 for ; Wed, 17 Jun 2015 07:44:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=TCNaTEn2dZn5D8xxNOiVjxRvMUkg03pv+vgLqc/M2uY=; b=bBNbPXi/nFwUK73OLiTH3pZaQJQlHrzDdmHeStRosqa17ebBq+WzrdbU+ZwhbR1bwz i925qU+hD6DySlPVzYdx9LtrYimGbUNw5aMKJDHN/BWpjfjOUyBoEGiViItuvsCbLB5j g4948Sy8s8pj73Ps0TfDWLH3IV3cwvGCa4x5dE2gvHc5b1nJgYjnTy9IQ12YePfMuVT+ mnf8sfDJd9go+fo66R0OMQUFpE4xip7a0a9GBu24AYYOgEpld/neqESpsMrwV5lSQwiq z/uLiJ7kLao1jHa37WtTJpyGs1H31Amh8KMw2UCHHvT6jmr5eU9OyVLcaF2bUiDRrqhK SsgQ== X-Gm-Message-State: ALoCoQnt8+xjqR7a7oShGJzuDiII3sgaSXm1ufPpN68LnHiclW9AHpEl6AL9s9DN6/Jb6QHKe1ES MIME-Version: 1.0 X-Received: by 10.60.123.51 with SMTP id lx19mr4896971oeb.46.1434552271584; Wed, 17 Jun 2015 07:44:31 -0700 (PDT) Received: by 10.76.25.69 with HTTP; Wed, 17 Jun 2015 07:44:31 -0700 (PDT) In-Reply-To: <1434498700-8522-2-git-send-email-stephen@networkplumber.org> References: <1434498700-8522-1-git-send-email-stephen@networkplumber.org> <1434498700-8522-2-git-send-email-stephen@networkplumber.org> Date: Wed, 17 Jun 2015 16:44:31 +0200 Message-ID: From: David Marchand To: Stephen Hemminger Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: "dev@dpdk.org" , Stephen Hemminger Subject: Re: [dpdk-dev] [PATCH 1/4] eal: provide functions to access PCI config 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: Wed, 17 Jun 2015 14:44:32 -0000 On Wed, Jun 17, 2015 at 1:51 AM, Stephen Hemminger < stephen@networkplumber.org> wrote: > From: Stephen Hemminger > > Some drivers need ability to access PCI config (for example for power > management). This adds an abstraction to do this for both Linux > and BSD. > > Signed-off-by: Stephen Hemminger > --- > lib/librte_eal/bsdapp/eal/eal_pci.c | 83 > +++++++++++++++++++++++++ > lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 + > lib/librte_eal/common/include/rte_pci.h | 28 +++++++++ > lib/librte_eal/linuxapp/eal/eal_pci.c | 50 +++++++++++++++ > lib/librte_eal/linuxapp/eal/eal_pci_init.h | 11 ++++ > lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 14 +++++ > lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 16 +++++ > lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 + > 8 files changed, 206 insertions(+) > > diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c > b/lib/librte_eal/bsdapp/eal/eal_pci.c > index 61e8921..bf6bc93 100644 > --- a/lib/librte_eal/bsdapp/eal/eal_pci.c > +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c > @@ -490,6 +490,89 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver > *dr, struct rte_pci_device *d > return 1; > } > [snip] > + > + if (len == 3 || len > sizeof(pi.pi_data)) { > + RTE_LOG(ERR, EAL, "%s(): invalid pci read length\n", > __func__); > + goto error; > + } > A comment on length 3 would help to understand why it is refused. diff --git a/lib/librte_eal/common/include/rte_pci.h > b/lib/librte_eal/common/include/rte_pci.h > index b4f38bc..62fb0ea 100644 > --- a/lib/librte_eal/common/include/rte_pci.h > +++ b/lib/librte_eal/common/include/rte_pci.h > @@ -394,6 +394,34 @@ void rte_eal_pci_register(struct rte_pci_driver > *driver); > */ > void rte_eal_pci_unregister(struct rte_pci_driver *driver); > > +/** > + * Read PCI config space. > + * > + * @param device > + * A pointer to a rte_pci_device structure describing the device > + * to use > + * @param buf > + * A data buffer where the bytes should be read into > + * @param size > + * The length of the data buffer. > + */ > +int rte_eal_pci_read_config(const struct rte_pci_device *device, > + void *buf, size_t len, off_t offset); > + > Parameters do not match the description. > +/** > + * Write PCI config space. > + * > + * @param device > + * A pointer to a rte_pci_device structure describing the device > + * to use > + * @param buf > + * A data buffer containing the bytes should be written > + * @param size > + * The length of the data buffer. > + */ > +int rte_eal_pci_write_config(const struct rte_pci_device *device, > + const void *buf, size_t len, off_t offset); > + > Idem. The rest looks good to me. -- David Marchand