All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
Cc: willemb@google.com, pabeni@redhat.com,
	Shailendra Bhatnagar <shailendra.bhatnagar@intel.com>,
	netdev@vger.kernel.org, jesse.brandeburg@intel.com,
	kuba@kernel.org, edumazet@google.com,
	intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com,
	Phani Burra <phani.r.burra@intel.com>,
	decot@google.com, davem@davemloft.net
Subject: Re: [Intel-wired-lan] [PATCH net-next v2 02/15] idpf: add module register and probe functionality
Date: Tue, 11 Apr 2023 15:36:53 +0300	[thread overview]
Message-ID: <20230411123653.GW182481@unreal> (raw)
In-Reply-To: <20230411011354.2619359-3-pavan.kumar.linga@intel.com>

On Mon, Apr 10, 2023 at 06:13:41PM -0700, Pavan Kumar Linga 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.
> 
> PCI IDs table is intentionally left blank to prevent the kernel from
> probing the device with the incomplete driver. It will be added
> in the last patch of the series.
> 
> 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>
> ---
>  drivers/net/ethernet/intel/Kconfig            | 11 +++
>  drivers/net/ethernet/intel/Makefile           |  1 +
>  drivers/net/ethernet/intel/idpf/Makefile      | 10 ++
>  drivers/net/ethernet/intel/idpf/idpf.h        | 27 ++++++
>  .../net/ethernet/intel/idpf/idpf_controlq.h   | 14 +++
>  drivers/net/ethernet/intel/idpf/idpf_lib.c    | 96 +++++++++++++++++++
>  drivers/net/ethernet/intel/idpf/idpf_main.c   | 70 ++++++++++++++
>  7 files changed, 229 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_lib.c
>  create mode 100644 drivers/net/ethernet/intel/idpf/idpf_main.c

<...>

> +/**
> + * idpf_remove_common - Device removal routine
> + * @pdev: PCI device information struct
> + */
> +void idpf_remove_common(struct pci_dev *pdev)
> +{
> +	struct idpf_adapter *adapter = pci_get_drvdata(pdev);
> +
> +	if (!adapter)

How is it possible to have adapter be NULL here?

> +		return;
> +
> +	pci_disable_pcie_error_reporting(pdev);
> +}
> 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..617df9b924fa
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/idpf/idpf_main.c
> @@ -0,0 +1,70 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright (C) 2023 Intel Corporation */
> +
> +#include "idpf.h"
> +
> +#define DRV_SUMMARY	"Infrastructure Data Path Function Linux Driver"
> +
> +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);
> +
> +	if (!adapter)

Ditto

> +		return;
> +
> +	idpf_remove_common(pdev);
> +	pci_set_drvdata(pdev, NULL);
> +}
> +
> +/**
> + * 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_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 idpf_adapter *adapter;
> +
> +	adapter = devm_kzalloc(&pdev->dev, sizeof(*adapter), GFP_KERNEL);

Why devm_kzalloc() and not kzalloc?

> +	if (!adapter)
> +		return -ENOMEM;
> +
> +	return idpf_probe_common(pdev, adapter);

There is no need in idpf_probe_common/idpf_remove_common functions and
they better be embedded here. They called only once and just obfuscate
the code.

> +}
> +
> +/* idpf_pci_tbl - PCI Dev idpf ID Table
> + */
> +static const struct pci_device_id idpf_pci_tbl[] = {
> +	{ /* Sentinel */ }

What does it mean empty pci_device_id table?

> +};
> +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.37.3
> 
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

WARNING: multiple messages have this Message-ID (diff)
From: Leon Romanovsky <leon@kernel.org>
To: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	emil.s.tantilov@intel.com, joshua.a.hay@intel.com,
	sridhar.samudrala@intel.com, jesse.brandeburg@intel.com,
	anthony.l.nguyen@intel.com, willemb@google.com, decot@google.com,
	pabeni@redhat.com, kuba@kernel.org, edumazet@google.com,
	davem@davemloft.net, Phani Burra <phani.r.burra@intel.com>,
	Alan Brady <alan.brady@intel.com>,
	Madhu Chittim <madhu.chittim@intel.com>,
	Shailendra Bhatnagar <shailendra.bhatnagar@intel.com>
Subject: Re: [PATCH net-next v2 02/15] idpf: add module register and probe functionality
Date: Tue, 11 Apr 2023 15:36:53 +0300	[thread overview]
Message-ID: <20230411123653.GW182481@unreal> (raw)
In-Reply-To: <20230411011354.2619359-3-pavan.kumar.linga@intel.com>

On Mon, Apr 10, 2023 at 06:13:41PM -0700, Pavan Kumar Linga 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.
> 
> PCI IDs table is intentionally left blank to prevent the kernel from
> probing the device with the incomplete driver. It will be added
> in the last patch of the series.
> 
> 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>
> ---
>  drivers/net/ethernet/intel/Kconfig            | 11 +++
>  drivers/net/ethernet/intel/Makefile           |  1 +
>  drivers/net/ethernet/intel/idpf/Makefile      | 10 ++
>  drivers/net/ethernet/intel/idpf/idpf.h        | 27 ++++++
>  .../net/ethernet/intel/idpf/idpf_controlq.h   | 14 +++
>  drivers/net/ethernet/intel/idpf/idpf_lib.c    | 96 +++++++++++++++++++
>  drivers/net/ethernet/intel/idpf/idpf_main.c   | 70 ++++++++++++++
>  7 files changed, 229 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_lib.c
>  create mode 100644 drivers/net/ethernet/intel/idpf/idpf_main.c

<...>

> +/**
> + * idpf_remove_common - Device removal routine
> + * @pdev: PCI device information struct
> + */
> +void idpf_remove_common(struct pci_dev *pdev)
> +{
> +	struct idpf_adapter *adapter = pci_get_drvdata(pdev);
> +
> +	if (!adapter)

How is it possible to have adapter be NULL here?

> +		return;
> +
> +	pci_disable_pcie_error_reporting(pdev);
> +}
> 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..617df9b924fa
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/idpf/idpf_main.c
> @@ -0,0 +1,70 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright (C) 2023 Intel Corporation */
> +
> +#include "idpf.h"
> +
> +#define DRV_SUMMARY	"Infrastructure Data Path Function Linux Driver"
> +
> +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);
> +
> +	if (!adapter)

Ditto

> +		return;
> +
> +	idpf_remove_common(pdev);
> +	pci_set_drvdata(pdev, NULL);
> +}
> +
> +/**
> + * 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_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 idpf_adapter *adapter;
> +
> +	adapter = devm_kzalloc(&pdev->dev, sizeof(*adapter), GFP_KERNEL);

Why devm_kzalloc() and not kzalloc?

> +	if (!adapter)
> +		return -ENOMEM;
> +
> +	return idpf_probe_common(pdev, adapter);

There is no need in idpf_probe_common/idpf_remove_common functions and
they better be embedded here. They called only once and just obfuscate
the code.

> +}
> +
> +/* idpf_pci_tbl - PCI Dev idpf ID Table
> + */
> +static const struct pci_device_id idpf_pci_tbl[] = {
> +	{ /* Sentinel */ }

What does it mean empty pci_device_id table?

> +};
> +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.37.3
> 

  reply	other threads:[~2023-04-11 12:37 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11  1:13 [Intel-wired-lan] [PATCH net-next v2 00/15] Introduce Intel IDPF driver Pavan Kumar Linga
2023-04-11  1:13 ` Pavan Kumar Linga
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 01/15] virtchnl: add virtchnl version 2 ops Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  8:51   ` [Intel-wired-lan] " Simon Horman
2023-04-11  8:51     ` Simon Horman
2023-04-12 21:38     ` [Intel-wired-lan] " Tantilov, Emil S
2023-04-12 21:38       ` Tantilov, Emil S
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 02/15] idpf: add module register and probe functionality Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11 12:36   ` Leon Romanovsky [this message]
2023-04-11 12:36     ` Leon Romanovsky
2023-04-12 23:10     ` [Intel-wired-lan] " Tantilov, Emil S
2023-04-12 23:10       ` Tantilov, Emil S
2023-04-13  6:03       ` [Intel-wired-lan] " Leon Romanovsky
2023-04-13  6:03         ` Leon Romanovsky
2023-04-13 18:58         ` [Intel-wired-lan] " Tantilov, Emil S
2023-04-13 18:58           ` Tantilov, Emil S
2023-04-20 18:13       ` [Intel-wired-lan] " Tantilov, Emil S
2023-04-20 18:13         ` Tantilov, Emil S
2023-04-20 18:20         ` Leon Romanovsky
2023-04-20 18:20           ` Leon Romanovsky
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 03/15] idpf: add controlq init and reset checks Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  9:19   ` [Intel-wired-lan] " Simon Horman
2023-04-11  9:19     ` Simon Horman
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 04/15] idpf: add core init and interrupt request Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  9:52   ` [Intel-wired-lan] " Simon Horman
2023-04-11  9:52     ` Simon Horman
2023-04-13 19:10     ` [Intel-wired-lan] " Tantilov, Emil S
2023-04-13 19:10       ` Tantilov, Emil S
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 05/15] idpf: add create vport and netdev configuration Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 06/15] idpf: continue expanding init task Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  9:04   ` [Intel-wired-lan] " Simon Horman
2023-04-11  9:04     ` Simon Horman
2023-04-13 19:04     ` [Intel-wired-lan] " Tantilov, Emil S
2023-04-13 19:04       ` Tantilov, Emil S
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 07/15] idpf: configure resources for TX queues Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 08/15] idpf: configure resources for RX queues Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 09/15] idpf: initialize interrupts and enable vport Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 10/15] idpf: add splitq start_xmit Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 11/15] idpf: add TX splitq napi poll support Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 12/15] idpf: add RX " Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 13/15] idpf: add singleq start_xmit and napi poll Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 14/15] idpf: add ethtool callbacks Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-11  9:55   ` [Intel-wired-lan] " Simon Horman
2023-04-11  9:55     ` Simon Horman
2023-04-13 19:11     ` [Intel-wired-lan] " Tantilov, Emil S
2023-04-13 19:11       ` Tantilov, Emil S
2023-04-22  5:26       ` [Intel-wired-lan] " Tantilov, Emil S
2023-04-22  5:26         ` Tantilov, Emil S
2023-04-22  7:55         ` Simon Horman
2023-04-22  7:55           ` Simon Horman
2023-04-11  1:13 ` [Intel-wired-lan] [PATCH net-next v2 15/15] idpf: configure SRIOV and add other ndo_ops Pavan Kumar Linga
2023-04-11  1:13   ` Pavan Kumar Linga
2023-04-12 18:25 ` [Intel-wired-lan] [PATCH net-next v2 00/15] Introduce Intel IDPF driver Sasha Levin
2023-04-12 18:25   ` Sasha Levin
2023-04-12 19:16   ` Willem de Bruijn
2023-04-12 19:16     ` Willem de Bruijn
2023-04-13  0:03     ` Samudrala, Sridhar
2023-04-13  0:03       ` Samudrala, Sridhar
2023-04-13  2:24       ` Jakub Kicinski
2023-04-13  2:24         ` Jakub Kicinski
2023-04-13  7:15         ` Leon Romanovsky
2023-04-13  7:15           ` Leon Romanovsky
2023-04-14 22:01         ` Sasha Levin
2023-04-14 22:01           ` Sasha Levin
2023-04-14 22:27           ` Jakub Kicinski
2023-04-14 22:27             ` Jakub Kicinski
2023-04-15 17:16             ` Sasha Levin
2023-04-15 17:16               ` Sasha Levin
2023-04-17 16:38               ` Jakub Kicinski
2023-04-17 16:38                 ` Jakub Kicinski

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=20230411123653.GW182481@unreal \
    --to=leon@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=decot@google.com \
    --cc=edumazet@google.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jesse.brandeburg@intel.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.kumar.linga@intel.com \
    --cc=phani.r.burra@intel.com \
    --cc=shailendra.bhatnagar@intel.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.