]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mlxsw: Add bus capability flag
authorVadim Pasternak <vadimp@mellanox.com>
Wed, 16 Nov 2016 14:20:43 +0000 (15:20 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 17 Nov 2016 04:29:04 +0000 (23:29 -0500)
The mlxsw core infrastructure currently assumes that communication with
the ASIC is always possible using Ethernet management datagrams (EMADs),
but this is only possible when the PCI bus is used.

The bus capability flag is added to indicate EMAD support and make core
initialize EMAD communication only when it's set. Otherwise, register
access is done using command interface.

Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/core.c
drivers/net/ethernet/mellanox/mlxsw/core.h
drivers/net/ethernet/mellanox/mlxsw/pci.c

index 600481771c047458471192547911e03f3653f86e..4f7c478a595b2373d958e15be10669a16a38d31d 100644 (file)
@@ -598,6 +598,9 @@ static int mlxsw_emad_init(struct mlxsw_core *mlxsw_core)
        u64 tid;
        int err;
 
+       if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
+               return 0;
+
        /* Set the upper 32 bits of the transaction ID field to a random
         * number. This allows us to discard EMADs addressed to other
         * devices.
@@ -634,6 +637,9 @@ static void mlxsw_emad_fini(struct mlxsw_core *mlxsw_core)
 {
        char hpkt_pl[MLXSW_REG_HPKT_LEN];
 
+       if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
+               return;
+
        mlxsw_core->emad.use_emad = false;
        mlxsw_reg_hpkt_pack(hpkt_pl, MLXSW_REG_HPKT_ACTION_DISCARD,
                            MLXSW_TRAP_ID_ETHEMAD);
index c0acc1b9eb2fc5c855bcad9596b9fb6721896cdf..f7a4d83801eb8e9cd6cbc0bb0f4d921b1e12228e 100644 (file)
@@ -268,6 +268,8 @@ u64 mlxsw_core_res_get(struct mlxsw_core *mlxsw_core,
 #define MLXSW_CORE_RES_GET(res, short_res_id)                  \
        mlxsw_core_res_get(res, MLXSW_RES_ID_##short_res_id)
 
+#define MLXSW_BUS_F_TXRX       BIT(0)
+
 struct mlxsw_bus {
        const char *kind;
        int (*init)(void *bus_priv, struct mlxsw_core *mlxsw_core,
@@ -283,6 +285,7 @@ struct mlxsw_bus {
                        char *in_mbox, size_t in_mbox_size,
                        char *out_mbox, size_t out_mbox_size,
                        u8 *p_status);
+       u8 features;
 };
 
 struct mlxsw_bus_info {
index d5cf1ea1c89a472fb96a6521616591609012fe25..a223c85dfde064eee873eb6ffd6aae818a4f46ba 100644 (file)
@@ -1755,6 +1755,7 @@ static const struct mlxsw_bus mlxsw_pci_bus = {
        .skb_transmit_busy      = mlxsw_pci_skb_transmit_busy,
        .skb_transmit           = mlxsw_pci_skb_transmit,
        .cmd_exec               = mlxsw_pci_cmd_exec,
+       .features               = MLXSW_BUS_F_TXRX,
 };
 
 static int mlxsw_pci_sw_reset(struct mlxsw_pci *mlxsw_pci,