From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, ferruh.yigit@amd.com, chenbo.xia@intel.com,
nipun.gupta@amd.com, bruce.richardson@intel.com,
Julien Aube <julien_dpdk@jaube.fr>, Gaetan Rivet <grive@u256.net>
Subject: [PATCH v3 09/15] pci: define some PM constants
Date: Thu, 14 Sep 2023 14:36:08 +0200 [thread overview]
Message-ID: <20230914123615.1705654-10-david.marchand@redhat.com> (raw)
In-Reply-To: <20230914123615.1705654-1-david.marchand@redhat.com>
Define some PCI Power Management constants and use them in existing
drivers.
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
---
drivers/net/bnx2x/bnx2x.c | 17 +++++++++--------
drivers/net/bnx2x/bnx2x.h | 5 -----
lib/pci/rte_pci.h | 6 ++++++
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index e3f14400cc..faf061beba 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -5843,17 +5843,17 @@ static int bnx2x_set_power_state(struct bnx2x_softc *sc, uint8_t state)
return 0;
}
- pci_read(sc, (sc->devinfo.pcie_pm_cap_reg + PCIR_POWER_STATUS), &pmcsr,
+ pci_read(sc, (sc->devinfo.pcie_pm_cap_reg + RTE_PCI_PM_CTRL), &pmcsr,
2);
switch (state) {
case PCI_PM_D0:
pci_write_word(sc,
(sc->devinfo.pcie_pm_cap_reg +
- PCIR_POWER_STATUS),
- ((pmcsr & ~PCIM_PSTAT_DMASK) | PCIM_PSTAT_PME));
+ RTE_PCI_PM_CTRL),
+ ((pmcsr & ~RTE_PCI_PM_CTRL_STATE_MASK) | RTE_PCI_PM_CTRL_PME_STATUS));
- if (pmcsr & PCIM_PSTAT_DMASK) {
+ if (pmcsr & RTE_PCI_PM_CTRL_STATE_MASK) {
/* delay required during transition out of D3hot */
DELAY(20000);
}
@@ -5866,16 +5866,17 @@ static int bnx2x_set_power_state(struct bnx2x_softc *sc, uint8_t state)
return 0;
}
- pmcsr &= ~PCIM_PSTAT_DMASK;
- pmcsr |= PCIM_PSTAT_D3;
+ pmcsr &= ~RTE_PCI_PM_CTRL_STATE_MASK;
+ /* D3 power state */
+ pmcsr |= 0x3;
if (sc->wol) {
- pmcsr |= PCIM_PSTAT_PMEENABLE;
+ pmcsr |= RTE_PCI_PM_CTRL_PME_ENABLE;
}
pci_write_long(sc,
(sc->devinfo.pcie_pm_cap_reg +
- PCIR_POWER_STATUS), pmcsr);
+ RTE_PCI_PM_CTRL), pmcsr);
/*
* No more memory access after this point until device is brought back
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 60af75d336..1efa166316 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -41,11 +41,6 @@
#define PCIR_EXPRESS_DEVICE_CTL PCI_EXP_DEVCTL
#define PCIM_EXP_CTL_MAX_PAYLOAD PCI_EXP_DEVCTL_PAYLOAD
#define PCIM_EXP_CTL_MAX_READ_REQUEST PCI_EXP_DEVCTL_READRQ
-#define PCIR_POWER_STATUS PCI_PM_CTRL
-#define PCIM_PSTAT_DMASK PCI_PM_CTRL_STATE_MASK
-#define PCIM_PSTAT_PME PCI_PM_CTRL_PME_STATUS
-#define PCIM_PSTAT_D3 0x3
-#define PCIM_PSTAT_PMEENABLE PCI_PM_CTRL_PME_ENABLE
#else
#include <dev/pci/pcireg.h>
#endif
diff --git a/lib/pci/rte_pci.h b/lib/pci/rte_pci.h
index 12866be5d5..90d734f0ad 100644
--- a/lib/pci/rte_pci.h
+++ b/lib/pci/rte_pci.h
@@ -58,6 +58,12 @@ extern "C" {
#define RTE_PCI_CAP_SIZEOF 4
#define RTE_PCI_CAP_NEXT 1
+/* Power Management Registers (RTE_PCI_CAP_ID_PM) */
+#define RTE_PCI_PM_CTRL 4 /* PM control and status register */
+#define RTE_PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */
+#define RTE_PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */
+#define RTE_PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */
+
/* MSI-X registers (RTE_PCI_CAP_ID_MSIX) */
#define RTE_PCI_MSIX_FLAGS 2 /* Message Control */
#define RTE_PCI_MSIX_FLAGS_QSIZE 0x07ff /* Table size */
--
2.41.0
next prev parent reply other threads:[~2023-09-14 12:37 UTC|newest]
Thread overview: 98+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-03 7:50 [PATCH 00/14] Cleanup PCI(e) drivers David Marchand
2023-08-03 7:50 ` [PATCH 01/14] drivers: remove duplicated PCI master control David Marchand
2023-08-03 9:45 ` Bruce Richardson
2023-10-07 2:53 ` fengchengwen
2023-08-03 7:50 ` [PATCH 02/14] bus/pci: add const to some experimental API David Marchand
2023-08-03 9:46 ` Bruce Richardson
2023-08-03 11:50 ` David Marchand
2023-08-03 7:50 ` [PATCH 03/14] bus/pci: find PCI capability David Marchand
2023-08-03 9:49 ` Bruce Richardson
2023-08-03 9:52 ` Bruce Richardson
2023-08-03 11:49 ` David Marchand
2023-08-03 7:50 ` [PATCH 04/14] pci: define some capability constants David Marchand
2023-08-03 9:51 ` Bruce Richardson
2023-08-03 7:50 ` [PATCH 05/14] pci: define some MSIX constants David Marchand
2023-08-03 9:53 ` Bruce Richardson
2023-08-03 7:50 ` [PATCH 06/14] pci: define some command constants David Marchand
2023-08-03 9:57 ` Bruce Richardson
2023-08-03 11:51 ` David Marchand
2023-08-08 9:20 ` David Marchand
2023-08-08 10:08 ` Bruce Richardson
2023-08-22 19:23 ` Adam Hassick
2023-08-03 7:50 ` [PATCH 07/14] pci: define some BAR constants David Marchand
2023-08-03 9:58 ` Bruce Richardson
2023-08-03 7:50 ` [PATCH 08/14] pci: define some PM constants David Marchand
2023-08-03 9:59 ` Bruce Richardson
2023-08-03 7:50 ` [PATCH 09/14] pci: define some PCIe constants David Marchand
2023-08-03 10:01 ` Bruce Richardson
2023-08-03 7:50 ` [PATCH 10/14] pci: define some extended capability constants David Marchand
2023-08-03 7:50 ` [PATCH 11/14] pci: define some ACS constants David Marchand
2023-08-03 7:50 ` [PATCH 12/14] pci: define some PRI constants David Marchand
2023-08-03 7:50 ` [PATCH 13/14] pci: define some AER constants David Marchand
2023-08-03 7:50 ` [PATCH 14/14] devtools: forbid inclusion of Linux header for PCI David Marchand
2023-08-03 10:03 ` [PATCH 00/14] Cleanup PCI(e) drivers Bruce Richardson
2023-08-21 11:35 ` [PATCH v2 00/15] " David Marchand
2023-08-21 11:35 ` [PATCH v2 01/15] drivers: remove duplicated PCI master control David Marchand
2023-09-06 13:02 ` Xia, Chenbo
2023-08-21 11:35 ` [PATCH v2 02/15] bus/pci: add const to some experimental API David Marchand
2023-08-21 16:14 ` Tyler Retzlaff
2023-09-06 13:02 ` Xia, Chenbo
2023-08-21 11:35 ` [PATCH v2 03/15] bus/pci: rework MSIX discovery with VFIO David Marchand
2023-09-06 13:03 ` Xia, Chenbo
2023-08-21 11:35 ` [PATCH v2 04/15] bus/pci: find PCI capability David Marchand
2023-09-07 12:43 ` Xia, Chenbo
2023-09-14 12:29 ` David Marchand
2023-09-19 2:19 ` Xia, Chenbo
2023-09-19 9:00 ` David Marchand
2023-08-21 11:35 ` [PATCH v2 05/15] pci: define some capability constants David Marchand
2023-09-07 13:15 ` Xia, Chenbo
2023-08-21 11:35 ` [PATCH v2 06/15] pci: define some MSIX constants David Marchand
2023-09-07 13:15 ` Xia, Chenbo
2023-08-21 11:35 ` [PATCH v2 07/15] pci: define some command constants David Marchand
2023-09-07 13:15 ` Xia, Chenbo
2023-08-21 11:35 ` [PATCH v2 08/15] pci: define some BAR constants David Marchand
2023-09-07 13:16 ` Xia, Chenbo
2023-08-21 11:35 ` [PATCH v2 09/15] pci: define some PM constants David Marchand
2023-09-07 13:16 ` Xia, Chenbo
2023-08-21 11:35 ` [PATCH v2 10/15] pci: define some PCIe constants David Marchand
2023-09-07 13:16 ` Xia, Chenbo
2023-08-21 11:35 ` [PATCH v2 11/15] pci: define some extended capability constants David Marchand
2023-09-07 13:23 ` Xia, Chenbo
2023-08-21 11:35 ` [PATCH v2 12/15] pci: define some ACS constants David Marchand
2023-08-21 11:35 ` [PATCH v2 13/15] pci: define some PRI constants David Marchand
2023-08-21 11:35 ` [PATCH v2 14/15] pci: define some AER constants David Marchand
2023-08-21 11:35 ` [PATCH v2 15/15] devtools: forbid inclusion of Linux header for PCI David Marchand
2023-08-21 16:24 ` Tyler Retzlaff
2023-09-07 13:33 ` Xia, Chenbo
2023-08-22 15:30 ` [PATCH v2 00/15] Cleanup PCI(e) drivers Patrick Robb
2023-08-22 16:09 ` [PATCH 00/14] " Adam Hassick
2023-08-22 16:48 ` Adam Hassick
2023-08-24 15:44 ` Adam Hassick
2023-09-14 12:35 ` [PATCH v3 00/15] " David Marchand
2023-09-14 12:36 ` [PATCH v3 01/15] drivers: remove duplicated PCI master control David Marchand
2023-09-14 12:36 ` [PATCH v3 02/15] bus/pci: add const to some experimental API David Marchand
2023-09-14 12:36 ` [PATCH v3 03/15] bus/pci: rework MSIX discovery with VFIO David Marchand
2023-09-14 12:36 ` [PATCH v3 04/15] bus/pci: find PCI capability David Marchand
2023-09-19 2:33 ` Xia, Chenbo
2023-09-14 12:36 ` [PATCH v3 05/15] pci: define some capability constants David Marchand
2023-09-15 16:27 ` Sevincer, Abdullah
2023-09-14 12:36 ` [PATCH v3 06/15] pci: define some MSIX constants David Marchand
2023-09-14 12:36 ` [PATCH v3 07/15] pci: define some command constants David Marchand
2023-09-14 12:36 ` [PATCH v3 08/15] pci: define some BAR constants David Marchand
2023-09-14 12:36 ` David Marchand [this message]
2023-09-14 12:36 ` [PATCH v3 10/15] pci: define some PCIe constants David Marchand
2023-09-15 16:26 ` Sevincer, Abdullah
2023-09-14 12:36 ` [PATCH v3 11/15] pci: define some extended capability constants David Marchand
2023-09-15 16:27 ` Sevincer, Abdullah
2023-09-14 12:36 ` [PATCH v3 12/15] pci: define some ACS constants David Marchand
2023-09-15 16:25 ` Sevincer, Abdullah
2023-09-19 2:35 ` Xia, Chenbo
2023-09-14 12:36 ` [PATCH v3 13/15] pci: define some PRI constants David Marchand
2023-09-15 16:21 ` Sevincer, Abdullah
2023-09-19 2:36 ` Xia, Chenbo
2023-09-14 12:36 ` [PATCH v3 14/15] pci: define some AER constants David Marchand
2023-09-15 16:26 ` Sevincer, Abdullah
2023-09-19 2:36 ` Xia, Chenbo
2023-09-14 12:36 ` [PATCH v3 15/15] devtools: forbid inclusion of Linux header for PCI David Marchand
2023-09-15 15:14 ` [PATCH v3 00/15] Cleanup PCI(e) drivers Stephen Hemminger
2023-09-19 12:41 ` David Marchand
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=20230914123615.1705654-10-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=bruce.richardson@intel.com \
--cc=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=grive@u256.net \
--cc=julien_dpdk@jaube.fr \
--cc=nipun.gupta@amd.com \
--cc=thomas@monjalon.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).