From: Ido Schimmel <ido...@mellanox.com>

A subsequent patch will need to set the CPU policer for dropped packets
to 80% of available PCIe bandwidth. Query and store and PCIe bandwidth,
so that it can be used by the switch driver later on.

For I2C bus we simply return 0 as currently there is no use case for
which it is required.

Signed-off-by: Ido Schimmel <ido...@mellanox.com>
Acked-by: Jiri Pirko <j...@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core.h | 1 +
 drivers/net/ethernet/mellanox/mlxsw/pci.c  | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h 
b/drivers/net/ethernet/mellanox/mlxsw/core.h
index e3832cb5bdda..5add61a7514e 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
@@ -354,6 +354,7 @@ struct mlxsw_bus_info {
        u8 vsd[MLXSW_CMD_BOARDINFO_VSD_LEN];
        u8 psid[MLXSW_CMD_BOARDINFO_PSID_LEN];
        u8 low_frequency;
+       u32 bandwidth;  /* Mb/s */
 };
 
 struct mlxsw_hwmon;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c 
b/drivers/net/ethernet/mellanox/mlxsw/pci.c
index b40455f8293d..3184b8ea1632 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
@@ -1740,6 +1740,8 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
        mlxsw_pci->bus_info.device_kind = driver_name;
        mlxsw_pci->bus_info.device_name = pci_name(mlxsw_pci->pdev);
        mlxsw_pci->bus_info.dev = &pdev->dev;
+       mlxsw_pci->bus_info.bandwidth = pcie_bandwidth_available(pdev, NULL,
+                                                                NULL, NULL);
        mlxsw_pci->id = id;
 
        err = mlxsw_core_bus_device_register(&mlxsw_pci->bus_info,
-- 
2.20.1

Reply via email to