[dpdk-dev] [PATCH v3 01/13] e1000: move pci device ids to driver

Neil Horman nhorman at tuxdriver.com
Wed Apr 20 15:29:08 CEST 2016


On Wed, Apr 20, 2016 at 02:43:44PM +0200, David Marchand wrote:
> test application and kni still want to know e1000 pci devices.
> So let's create headers in the driver that will be used by them.
> 
> I wanted to reuse base/ headers, but because of some headaches trying to resolve
> macros redefinition collisions in kni (with ixgbe next commit), I left it as is.
> 
> Signed-off-by: David Marchand <david.marchand at 6wind.com>
> ---
>  app/test/Makefile                               |   3 +
>  app/test/test_pci.c                             |   3 +-
>  drivers/net/e1000/em_ethdev.c                   |   2 +-
>  drivers/net/e1000/em_pci_dev_ids.h              | 208 +++++++++++++++++++
>  drivers/net/e1000/igb_ethdev.c                  |   4 +-
>  drivers/net/e1000/igb_pci_dev_ids.h             | 165 +++++++++++++++
>  lib/librte_eal/common/include/rte_pci_dev_ids.h | 254 ------------------------
>  lib/librte_eal/linuxapp/kni/Makefile            |   1 +
>  lib/librte_eal/linuxapp/kni/kni_misc.c          |   4 +-
>  9 files changed, 384 insertions(+), 260 deletions(-)
>  create mode 100644 drivers/net/e1000/em_pci_dev_ids.h
>  create mode 100644 drivers/net/e1000/igb_pci_dev_ids.h
> 
> diff --git a/app/test/Makefile b/app/test/Makefile
> index a4907d5..8a1f54c 100644
> --- a/app/test/Makefile
> +++ b/app/test/Makefile
> @@ -171,6 +171,9 @@ CFLAGS_test_memcpy_perf.o += -fno-var-tracking-assignments
>  endif
>  endif
>  
> +# pci tests want to know some pci devices ids
> +CFLAGS_test_pci.o += -I$(RTE_SDK)/drivers/net/e1000
> +
>  # this application needs libraries first
>  DEPDIRS-y += lib drivers
>  
> diff --git a/app/test/test_pci.c b/app/test/test_pci.c
> index 0ed357e..7215936 100644
> --- a/app/test/test_pci.c
> +++ b/app/test/test_pci.c
> @@ -77,8 +77,9 @@ struct rte_pci_id my_driver_id2[] = {
>  
>  /* IGB & EM NICS */
>  #define RTE_PCI_DEV_ID_DECL_EM(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
> +#include <em_pci_dev_ids.h>
>  #define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
> -#include <rte_pci_dev_ids.h>
> +#include <igb_pci_dev_ids.h>
>  
>  { .vendor_id = 0, /* sentinel */ },
>  };
> diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
> index 1f80c05..203a9e5 100644
> --- a/drivers/net/e1000/em_ethdev.c
> +++ b/drivers/net/e1000/em_ethdev.c
> @@ -139,7 +139,7 @@ static enum e1000_fc_mode em_fc_setting = e1000_fc_full;
>  static const struct rte_pci_id pci_id_em_map[] = {
>  
>  #define RTE_PCI_DEV_ID_DECL_EM(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
> -#include "rte_pci_dev_ids.h"
> +#include "em_pci_dev_ids.h"
>  
>  {0},
>  };
> diff --git a/drivers/net/e1000/em_pci_dev_ids.h b/drivers/net/e1000/em_pci_dev_ids.h
> new file mode 100644
> index 0000000..736a68e
> --- /dev/null
> +++ b/drivers/net/e1000/em_pci_dev_ids.h
> @@ -0,0 +1,208 @@
> +/*-
> + * This file is provided under a dual BSD/GPLv2 license.  When using or
> + *   redistributing this file, you may do so under either license.
> + *
> + *   GPL LICENSE SUMMARY
> + *
> + *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
> + *
> + *   This program is free software; you can redistribute it and/or modify
> + *   it under the terms of version 2 of the GNU General Public License as
> + *   published by the Free Software Foundation.
> + *
> + *   This program is distributed in the hope that it will be useful, but
> + *   WITHOUT ANY WARRANTY; without even the implied warranty of
> + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + *   General Public License for more details.
> + *
> + *   The full GNU General Public License is included in this distribution
> + *   in the file called LICENSE.GPL.
> + *
> + *   Contact Information:
> + *   Intel Corporation
> + *
> + *   BSD LICENSE
> + *
> + *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
> + *   All rights reserved.
> + *
> + *   Redistribution and use in source and binary forms, with or without
> + *   modification, are permitted provided that the following conditions
> + *   are met:
> + *
> + *     * Redistributions of source code must retain the above copyright
> + *       notice, this list of conditions and the following disclaimer.
> + *     * Redistributions in binary form must reproduce the above copyright
> + *       notice, this list of conditions and the following disclaimer in
> + *       the documentation and/or other materials provided with the
> + *       distribution.
> + *     * Neither the name of Intel Corporation nor the names of its
> + *       contributors may be used to endorse or promote products derived
> + *       from this software without specific prior written permission.
> + *
> + *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> + *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> + *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> + *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> + *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> + *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> + *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + */
> +
> +#ifndef RTE_PCI_DEV_ID_DECL_EM
> +#define RTE_PCI_DEV_ID_DECL_EM(vend, dev)
> +#endif
> +
> +#ifndef PCI_VENDOR_ID_INTEL
> +/** Vendor ID used by Intel devices */
> +#define PCI_VENDOR_ID_INTEL 0x8086
> +#endif
> +
This is broken, PCI_VENDOR_ID_INTEL should be defined in a central location for
all pci drivers, not redefined in every compilation unit.  And you can likely
just remvoe the RTE_PCI_DEV_ID_DECL_* macros from each patch and use the
RTE_PCI_DEV macro, as all the DECL macros just evaluate to that anyway.

><snip>

> +
> +#undef RTE_PCI_DEV_ID_DECL_EM
Why are you undefining this here?  Is it because its in a header file and you're
concerned about multiple inclusion?  You should use an ifdef guard instead, or
just define all the device id's in the header and ennumerate the pci table in
one of the C files for the driver.  That should apply to all the patches in this
series I think


Neil




More information about the dev mailing list