Skip to content

Commit 54a2e8d

Browse files
Arkadi Sharshevskydavem330
authored andcommitted
mlxsw: pci: Add support for performing bus reset
This is a preparation stage before introducing hot reload. During the reload process the ASIC should be resetted by accessing the PCI BAR due to unavailability of the mailbox/emad interfaces. Signed-off-by: Arkadi Sharshevsky <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 56dc7cd commit 54a2e8d

File tree

2 files changed

+41
-13
lines changed

2 files changed

+41
-13
lines changed

drivers/net/ethernet/mellanox/mlxsw/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ struct mlxsw_bus {
332332
const struct mlxsw_config_profile *profile,
333333
struct mlxsw_res *res);
334334
void (*fini)(void *bus_priv);
335+
void (*reset)(void *bus_priv);
335336
bool (*skb_transmit_busy)(void *bus_priv,
336337
const struct mlxsw_tx_info *tx_info);
337338
int (*skb_transmit)(void *bus_priv, struct sk_buff *skb,

drivers/net/ethernet/mellanox/mlxsw/pci.c

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ struct mlxsw_pci {
154154
} comp;
155155
} cmd;
156156
struct mlxsw_bus_info bus_info;
157+
const struct pci_device_id *id;
157158
};
158159

159160
static void mlxsw_pci_queue_tasklet_schedule(struct mlxsw_pci_queue *q)
@@ -1622,16 +1623,6 @@ static int mlxsw_pci_cmd_exec(void *bus_priv, u16 opcode, u8 opcode_mod,
16221623
return err;
16231624
}
16241625

1625-
static const struct mlxsw_bus mlxsw_pci_bus = {
1626-
.kind = "pci",
1627-
.init = mlxsw_pci_init,
1628-
.fini = mlxsw_pci_fini,
1629-
.skb_transmit_busy = mlxsw_pci_skb_transmit_busy,
1630-
.skb_transmit = mlxsw_pci_skb_transmit,
1631-
.cmd_exec = mlxsw_pci_cmd_exec,
1632-
.features = MLXSW_BUS_F_TXRX,
1633-
};
1634-
16351626
static int mlxsw_pci_sw_reset(struct mlxsw_pci *mlxsw_pci,
16361627
const struct pci_device_id *id)
16371628
{
@@ -1660,6 +1651,41 @@ static int mlxsw_pci_sw_reset(struct mlxsw_pci *mlxsw_pci,
16601651
return 0;
16611652
}
16621653

1654+
static void mlxsw_pci_free_irq_vectors(struct mlxsw_pci *mlxsw_pci)
1655+
{
1656+
pci_free_irq_vectors(mlxsw_pci->pdev);
1657+
}
1658+
1659+
static int mlxsw_pci_alloc_irq_vectors(struct mlxsw_pci *mlxsw_pci)
1660+
{
1661+
int err;
1662+
1663+
err = pci_alloc_irq_vectors(mlxsw_pci->pdev, 1, 1, PCI_IRQ_MSIX);
1664+
if (err < 0)
1665+
dev_err(&mlxsw_pci->pdev->dev, "MSI-X init failed\n");
1666+
return err;
1667+
}
1668+
1669+
static void mlxsw_pci_reset(void *bus_priv)
1670+
{
1671+
struct mlxsw_pci *mlxsw_pci = bus_priv;
1672+
1673+
mlxsw_pci_free_irq_vectors(mlxsw_pci);
1674+
mlxsw_pci_sw_reset(mlxsw_pci, mlxsw_pci->id);
1675+
mlxsw_pci_alloc_irq_vectors(mlxsw_pci);
1676+
}
1677+
1678+
static const struct mlxsw_bus mlxsw_pci_bus = {
1679+
.kind = "pci",
1680+
.init = mlxsw_pci_init,
1681+
.fini = mlxsw_pci_fini,
1682+
.skb_transmit_busy = mlxsw_pci_skb_transmit_busy,
1683+
.skb_transmit = mlxsw_pci_skb_transmit,
1684+
.cmd_exec = mlxsw_pci_cmd_exec,
1685+
.features = MLXSW_BUS_F_TXRX,
1686+
.reset = mlxsw_pci_reset,
1687+
};
1688+
16631689
static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
16641690
{
16651691
const char *driver_name = pdev->driver->name;
@@ -1721,7 +1747,7 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
17211747
goto err_sw_reset;
17221748
}
17231749

1724-
err = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX);
1750+
err = mlxsw_pci_alloc_irq_vectors(mlxsw_pci);
17251751
if (err < 0) {
17261752
dev_err(&pdev->dev, "MSI-X init failed\n");
17271753
goto err_msix_init;
@@ -1730,6 +1756,7 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
17301756
mlxsw_pci->bus_info.device_kind = driver_name;
17311757
mlxsw_pci->bus_info.device_name = pci_name(mlxsw_pci->pdev);
17321758
mlxsw_pci->bus_info.dev = &pdev->dev;
1759+
mlxsw_pci->id = id;
17331760

17341761
err = mlxsw_core_bus_device_register(&mlxsw_pci->bus_info,
17351762
&mlxsw_pci_bus, mlxsw_pci);
@@ -1741,7 +1768,7 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
17411768
return 0;
17421769

17431770
err_bus_device_register:
1744-
pci_free_irq_vectors(mlxsw_pci->pdev);
1771+
mlxsw_pci_free_irq_vectors(mlxsw_pci);
17451772
err_msix_init:
17461773
err_sw_reset:
17471774
iounmap(mlxsw_pci->hw_addr);
@@ -1761,7 +1788,7 @@ static void mlxsw_pci_remove(struct pci_dev *pdev)
17611788
struct mlxsw_pci *mlxsw_pci = pci_get_drvdata(pdev);
17621789

17631790
mlxsw_core_bus_device_unregister(mlxsw_pci->core);
1764-
pci_free_irq_vectors(mlxsw_pci->pdev);
1791+
mlxsw_pci_free_irq_vectors(mlxsw_pci);
17651792
iounmap(mlxsw_pci->hw_addr);
17661793
pci_release_regions(mlxsw_pci->pdev);
17671794
pci_disable_device(mlxsw_pci->pdev);

0 commit comments

Comments
 (0)