From: "Michael S. Tsirkin" <mst@redhat•com>
To: Tony Nguyen <anthony.l.nguyen@intel•com>
Cc: davem@davemloft•net, kuba@kernel•org, pabeni@redhat•com,
edumazet@google•com, netdev@vger•kernel.org,
Phani Burra <phani.r.burra@intel•com>,
pavan.kumar.linga@intel•com, emil.s.tantilov@intel•com,
jesse.brandeburg@intel•com, sridhar.samudrala@intel•com,
shiraz.saleem@intel•com, sindhu.devale@intel•com,
willemb@google•com, decot@google•com, andrew@lunn•ch,
leon@kernel•org, simon.horman@corigine•com,
shannon.nelson@amd•com, stephen@networkplumber•org,
Alan Brady <alan.brady@intel•com>,
Madhu Chittim <madhu.chittim@intel•com>,
Shailendra Bhatnagar <shailendra.bhatnagar@intel•com>,
Krishneil Singh <krishneil.k.singh@intel•com>
Subject: Re: [PATCH net-next 02/15] idpf: add module register and probe functionality
Date: Wed, 31 May 2023 02:05:42 -0400 [thread overview]
Message-ID: <20230531015711-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20230530234501.2680230-3-anthony.l.nguyen@intel.com>
On Tue, May 30, 2023 at 04:44:48PM -0700, Tony Nguyen wrote:
> From: Phani Burra <phani.r.burra@intel•com>
>
> Add the required support to register IDPF PCI driver, as well as
> probe and remove call backs. Enable the PCI device and request
> the kernel to reserve the memory resources that will be used by the
> driver. Finally map the BAR0 address space.
>
> Signed-off-by: Phani Burra <phani.r.burra@intel•com>
> Co-developed-by: Alan Brady <alan.brady@intel•com>
> Signed-off-by: Alan Brady <alan.brady@intel•com>
> Co-developed-by: Madhu Chittim <madhu.chittim@intel•com>
> Signed-off-by: Madhu Chittim <madhu.chittim@intel•com>
> Co-developed-by: Shailendra Bhatnagar <shailendra.bhatnagar@intel•com>
> Signed-off-by: Shailendra Bhatnagar <shailendra.bhatnagar@intel•com>
> Co-developed-by: Pavan Kumar Linga <pavan.kumar.linga@intel•com>
> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel•com>
> Reviewed-by: Sridhar Samudrala <sridhar.samudrala@intel•com>
> Reviewed-by: Willem de Bruijn <willemb@google•com>
> Tested-by: Krishneil Singh <krishneil.k.singh@intel•com>
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel•com>
> ---
> drivers/net/ethernet/intel/idpf/Makefile | 9 ++
> drivers/net/ethernet/intel/idpf/idpf.h | 22 +++
> .../net/ethernet/intel/idpf/idpf_controlq.h | 14 ++
> drivers/net/ethernet/intel/idpf/idpf_devids.h | 10 ++
> drivers/net/ethernet/intel/idpf/idpf_main.c | 136 ++++++++++++++++++
> 5 files changed, 191 insertions(+)
> create mode 100644 drivers/net/ethernet/intel/idpf/Makefile
> create mode 100644 drivers/net/ethernet/intel/idpf/idpf.h
> create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq.h
> create mode 100644 drivers/net/ethernet/intel/idpf/idpf_devids.h
> create mode 100644 drivers/net/ethernet/intel/idpf/idpf_main.c
>
> diff --git a/drivers/net/ethernet/intel/idpf/Makefile b/drivers/net/ethernet/intel/idpf/Makefile
> new file mode 100644
> index 000000000000..77f5500d7707
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/idpf/Makefile
> @@ -0,0 +1,9 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +# Copyright (C) 2023 Intel Corporation
> +
> +# Makefile for Infrastructure Data Path Function Linux Driver
> +
> +obj-$(CONFIG_IDPF) += idpf.o
> +
> +idpf-y := \
> + idpf_main.o
> diff --git a/drivers/net/ethernet/intel/idpf/idpf.h b/drivers/net/ethernet/intel/idpf/idpf.h
> new file mode 100644
> index 000000000000..08be5621140f
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/idpf/idpf.h
> @@ -0,0 +1,22 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/* Copyright (C) 2023 Intel Corporation */
> +
> +#ifndef _IDPF_H_
> +#define _IDPF_H_
> +
> +#include <linux/aer.h>
> +#include <linux/etherdevice.h>
> +#include <linux/pci.h>
> +
> +#include "idpf_controlq.h"
> +
> +/* available message levels */
> +#define IDPF_AVAIL_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
> +
> +struct idpf_adapter {
> + struct pci_dev *pdev;
> + u32 msg_enable;
> + struct idpf_hw hw;
> +};
> +
> +#endif /* !_IDPF_H_ */
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_controlq.h b/drivers/net/ethernet/intel/idpf/idpf_controlq.h
> new file mode 100644
> index 000000000000..11388834cf64
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/idpf/idpf_controlq.h
> @@ -0,0 +1,14 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/* Copyright (C) 2023 Intel Corporation */
> +
> +#ifndef _IDPF_CONTROLQ_H_
> +#define _IDPF_CONTROLQ_H_
> +
> +struct idpf_hw {
> + void __iomem *hw_addr;
> + resource_size_t hw_addr_len;
> +
> + struct idpf_adapter *back;
> +};
> +
> +#endif /* _IDPF_CONTROLQ_H_ */
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_devids.h b/drivers/net/ethernet/intel/idpf/idpf_devids.h
> new file mode 100644
> index 000000000000..5154a52ae61c
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/idpf/idpf_devids.h
> @@ -0,0 +1,10 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/* Copyright (C) 2023 Intel Corporation */
> +
> +#ifndef _IDPF_DEVIDS_H_
> +#define _IDPF_DEVIDS_H_
> +
> +#define IDPF_DEV_ID_PF 0x1452
> +#define IDPF_DEV_ID_VF 0x145C
> +
> +#endif /* _IDPF_DEVIDS_H_ */
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_main.c b/drivers/net/ethernet/intel/idpf/idpf_main.c
> new file mode 100644
> index 000000000000..e290f560ce14
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/idpf/idpf_main.c
> @@ -0,0 +1,136 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright (C) 2023 Intel Corporation */
> +
> +#include "idpf.h"
> +#include "idpf_devids.h"
> +
> +#define DRV_SUMMARY "Infrastructure Data Path Function Linux Driver"
Do you want to stick Intel(R) here as well?
And did you say you wanted to add a version?
The point being making it possible to distinguish
between this one and the one we'll hopefully have down
the road binding to the IDPF class/prog ifc.
> +
> +MODULE_DESCRIPTION(DRV_SUMMARY);
> +MODULE_LICENSE("GPL");
> +
> +/**
> + * idpf_remove - Device removal routine
> + * @pdev: PCI device information struct
> + */
> +static void idpf_remove(struct pci_dev *pdev)
> +{
> + struct idpf_adapter *adapter = pci_get_drvdata(pdev);
> +
> + pci_disable_pcie_error_reporting(pdev);
> + pci_set_drvdata(pdev, NULL);
> + kfree(adapter);
> +}
> +
> +/**
> + * idpf_shutdown - PCI callback for shutting down device
> + * @pdev: PCI device information struct
> + */
> +static void idpf_shutdown(struct pci_dev *pdev)
> +{
> + idpf_remove(pdev);
> +
> + if (system_state == SYSTEM_POWER_OFF)
> + pci_set_power_state(pdev, PCI_D3hot);
> +}
> +
> +/**
> + * idpf_cfg_hw - Initialize HW struct
> + * @adapter: adapter to setup hw struct for
> + *
> + * Returns 0 on success, negative on failure
> + */
> +static int idpf_cfg_hw(struct idpf_adapter *adapter)
> +{
> + struct pci_dev *pdev = adapter->pdev;
> + struct idpf_hw *hw = &adapter->hw;
> +
> + hw->hw_addr = pcim_iomap_table(pdev)[0];
> + if (!hw->hw_addr) {
> + pci_err(pdev, "failed to allocate PCI iomap table\n");
> +
> + return -ENOMEM;
> + }
> +
> + hw->back = adapter;
> +
> + return 0;
> +}
> +
> +/**
> + * idpf_probe - Device initialization routine
> + * @pdev: PCI device information struct
> + * @ent: entry in idpf_pci_tbl
> + *
> + * Returns 0 on success, negative on failure
> + */
> +static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> +{
> + struct device *dev = &pdev->dev;
> + struct idpf_adapter *adapter;
> + int err;
> +
> + adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
> + if (!adapter)
> + return -ENOMEM;
> + adapter->pdev = pdev;
> +
> + err = pcim_enable_device(pdev);
> + if (err)
> + goto err_free;
> +
> + err = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev));
> + if (err) {
> + pci_err(pdev, "pcim_iomap_regions failed %pe\n", ERR_PTR(err));
> +
> + goto err_free;
> + }
> +
> + /* set up for high or low dma */
> + err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
> + if (err) {
> + pci_err(pdev, "DMA configuration failed: %pe\n", ERR_PTR(err));
> +
> + goto err_free;
> + }
> +
> + pci_enable_pcie_error_reporting(pdev);
> + pci_set_master(pdev);
> + pci_set_drvdata(pdev, adapter);
> +
> + /* setup msglvl */
> + adapter->msg_enable = netif_msg_init(-1, IDPF_AVAIL_NETIF_M);
> +
> + err = idpf_cfg_hw(adapter);
> + if (err) {
> + dev_err(dev, "Failed to configure HW structure for adapter: %d\n",
> + err);
> + goto err_cfg_hw;
> + }
> +
> + return 0;
> +
> +err_cfg_hw:
> + pci_disable_pcie_error_reporting(pdev);
> +err_free:
> + kfree(adapter);
> + return err;
> +}
> +
> +/* idpf_pci_tbl - PCI Dev idpf ID Table
> + */
> +static const struct pci_device_id idpf_pci_tbl[] = {
> + { PCI_VDEVICE(INTEL, IDPF_DEV_ID_PF)},
> + { PCI_VDEVICE(INTEL, IDPF_DEV_ID_VF)},
> + { /* Sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(pci, idpf_pci_tbl);
> +
> +static struct pci_driver idpf_driver = {
> + .name = KBUILD_MODNAME,
> + .id_table = idpf_pci_tbl,
> + .probe = idpf_probe,
> + .remove = idpf_remove,
> + .shutdown = idpf_shutdown,
> +};
> +module_pci_driver(idpf_driver);
> --
> 2.38.1
next prev parent reply other threads:[~2023-05-31 6:05 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 23:44 [PATCH net-next 00/15][pull request] Introduce Intel IDPF driver Tony Nguyen
2023-05-30 23:44 ` [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops Tony Nguyen
2023-05-30 23:44 ` [PATCH net-next 02/15] idpf: add module register and probe functionality Tony Nguyen
2023-05-31 6:05 ` Michael S. Tsirkin [this message]
2023-05-31 18:34 ` Jesse Brandeburg
2023-05-31 20:25 ` Tony Nguyen
2023-06-11 17:54 ` Leon Romanovsky
2023-05-30 23:44 ` [PATCH net-next 03/15] idpf: add controlq init and reset checks Tony Nguyen
2023-05-30 23:44 ` [PATCH net-next 04/15] idpf: add core init and interrupt request Tony Nguyen
2023-05-30 23:44 ` [PATCH net-next 05/15] idpf: add create vport and netdev configuration Tony Nguyen
2023-06-01 6:22 ` Jakub Kicinski
2023-06-01 23:47 ` Linga, Pavan Kumar
2023-06-07 18:20 ` Willem de Bruijn
2023-06-07 19:10 ` Jakub Kicinski
2023-06-07 19:39 ` Willem de Bruijn
2023-05-30 23:44 ` [PATCH net-next 06/15] idpf: continue expanding init task Tony Nguyen
2023-05-30 23:44 ` [PATCH net-next 07/15] idpf: configure resources for TX queues Tony Nguyen
2023-05-30 23:44 ` [PATCH net-next 08/15] idpf: configure resources for RX queues Tony Nguyen
2023-05-30 23:44 ` [PATCH net-next 09/15] idpf: initialize interrupts and enable vport Tony Nguyen
2023-05-30 23:44 ` [PATCH net-next 10/15] idpf: add splitq start_xmit Tony Nguyen
2023-05-30 23:44 ` [PATCH net-next 11/15] idpf: add TX splitq napi poll support Tony Nguyen
2023-05-30 23:44 ` [PATCH net-next 12/15] idpf: add RX " Tony Nguyen
2023-05-30 23:44 ` [PATCH net-next 13/15] idpf: add singleq start_xmit and napi poll Tony Nguyen
2023-05-30 23:45 ` [PATCH net-next 14/15] idpf: add ethtool callbacks Tony Nguyen
2023-05-30 23:45 ` [PATCH net-next 15/15] idpf: configure SRIOV and add other ndo_ops Tony Nguyen
2023-06-01 6:23 ` Jakub Kicinski
2023-06-01 23:40 ` Linga, Pavan Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230531015711-mutt-send-email-mst@kernel.org \
--to=mst@redhat$(echo .)com \
--cc=alan.brady@intel$(echo .)com \
--cc=andrew@lunn$(echo .)ch \
--cc=anthony.l.nguyen@intel$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=decot@google$(echo .)com \
--cc=edumazet@google$(echo .)com \
--cc=emil.s.tantilov@intel$(echo .)com \
--cc=jesse.brandeburg@intel$(echo .)com \
--cc=krishneil.k.singh@intel$(echo .)com \
--cc=kuba@kernel$(echo .)org \
--cc=leon@kernel$(echo .)org \
--cc=madhu.chittim@intel$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
--cc=pavan.kumar.linga@intel$(echo .)com \
--cc=phani.r.burra@intel$(echo .)com \
--cc=shailendra.bhatnagar@intel$(echo .)com \
--cc=shannon.nelson@amd$(echo .)com \
--cc=shiraz.saleem@intel$(echo .)com \
--cc=simon.horman@corigine$(echo .)com \
--cc=sindhu.devale@intel$(echo .)com \
--cc=sridhar.samudrala@intel$(echo .)com \
--cc=stephen@networkplumber$(echo .)org \
--cc=willemb@google$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox