mcdi.c (7592d754c09c6cf0f1758ddba41cdb4e5c16b0b2) mcdi.c (98ff4c7c8ac7f5339aac6114105395fea19f992e)
1// SPDX-License-Identifier: GPL-2.0-only
2/****************************************************************************
3 * Driver for Solarflare network controllers and boards
4 * Copyright 2008-2013 Solarflare Communications Inc.
5 */
6
7#include <linux/delay.h>
8#include <linux/moduleparam.h>

--- 85 unchanged lines hidden (view full) ---

94 if (rc)
95 goto fail2;
96
97 /* Let the MC (and BMC, if this is a LOM) know that the driver
98 * is loaded. We should do this before we reset the NIC.
99 */
100 rc = efx_mcdi_drv_attach(efx, true, &already_attached);
101 if (rc) {
1// SPDX-License-Identifier: GPL-2.0-only
2/****************************************************************************
3 * Driver for Solarflare network controllers and boards
4 * Copyright 2008-2013 Solarflare Communications Inc.
5 */
6
7#include <linux/delay.h>
8#include <linux/moduleparam.h>

--- 85 unchanged lines hidden (view full) ---

94 if (rc)
95 goto fail2;
96
97 /* Let the MC (and BMC, if this is a LOM) know that the driver
98 * is loaded. We should do this before we reset the NIC.
99 */
100 rc = efx_mcdi_drv_attach(efx, true, &already_attached);
101 if (rc) {
102 netif_err(efx, probe, efx->net_dev,
103 "Unable to register driver with MCPU\n");
102 pci_err(efx->pci_dev, "Unable to register driver with MCPU\n");
104 goto fail2;
105 }
106 if (already_attached)
107 /* Not a fatal error */
103 goto fail2;
104 }
105 if (already_attached)
106 /* Not a fatal error */
108 netif_err(efx, probe, efx->net_dev,
109 "Host already registered with MCPU\n");
107 pci_err(efx->pci_dev, "Host already registered with MCPU\n");
110
111 if (efx->mcdi->fn_flags &
112 (1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_PRIMARY))
113 efx->primary = efx;
114
115 return 0;
116fail2:
117#ifdef CONFIG_SFC_MCDI_LOGGING

--- 1324 unchanged lines hidden (view full) ---

1442 * components are short enough that this doesn't happen.
1443 */
1444 if (WARN_ON(offset >= len))
1445 buf[0] = 0;
1446
1447 return;
1448
1449fail:
108
109 if (efx->mcdi->fn_flags &
110 (1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_PRIMARY))
111 efx->primary = efx;
112
113 return 0;
114fail2:
115#ifdef CONFIG_SFC_MCDI_LOGGING

--- 1324 unchanged lines hidden (view full) ---

1440 * components are short enough that this doesn't happen.
1441 */
1442 if (WARN_ON(offset >= len))
1443 buf[0] = 0;
1444
1445 return;
1446
1447fail:
1450 netif_err(efx, probe, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
1448 pci_err(efx->pci_dev, "%s: failed rc=%d\n", __func__, rc);
1451 buf[0] = 0;
1452}
1453
1454static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
1455 bool *was_attached)
1456{
1457 MCDI_DECLARE_BUF(inbuf, MC_CMD_DRV_ATTACH_IN_LEN);
1458 MCDI_DECLARE_BUF(outbuf, MC_CMD_DRV_ATTACH_EXT_OUT_LEN);

--- 7 unchanged lines hidden (view full) ---

1466
1467 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_DRV_ATTACH, inbuf, sizeof(inbuf),
1468 outbuf, sizeof(outbuf), &outlen);
1469 /* If we're not the primary PF, trying to ATTACH with a FIRMWARE_ID
1470 * specified will fail with EPERM, and we have to tell the MC we don't
1471 * care what firmware we get.
1472 */
1473 if (rc == -EPERM) {
1449 buf[0] = 0;
1450}
1451
1452static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
1453 bool *was_attached)
1454{
1455 MCDI_DECLARE_BUF(inbuf, MC_CMD_DRV_ATTACH_IN_LEN);
1456 MCDI_DECLARE_BUF(outbuf, MC_CMD_DRV_ATTACH_EXT_OUT_LEN);

--- 7 unchanged lines hidden (view full) ---

1464
1465 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_DRV_ATTACH, inbuf, sizeof(inbuf),
1466 outbuf, sizeof(outbuf), &outlen);
1467 /* If we're not the primary PF, trying to ATTACH with a FIRMWARE_ID
1468 * specified will fail with EPERM, and we have to tell the MC we don't
1469 * care what firmware we get.
1470 */
1471 if (rc == -EPERM) {
1474 netif_dbg(efx, probe, efx->net_dev,
1475 "%s with fw-variant setting failed EPERM, trying without it\n",
1476 __func__);
1472 pci_dbg(efx->pci_dev,
1473 "%s with fw-variant setting failed EPERM, trying without it\n",
1474 __func__);
1477 MCDI_SET_DWORD(inbuf, DRV_ATTACH_IN_FIRMWARE_ID,
1478 MC_CMD_FW_DONT_CARE);
1479 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_DRV_ATTACH, inbuf,
1480 sizeof(inbuf), outbuf, sizeof(outbuf),
1481 &outlen);
1482 }
1483 if (rc) {
1484 efx_mcdi_display_error(efx, MC_CMD_DRV_ATTACH, sizeof(inbuf),

--- 25 unchanged lines hidden (view full) ---

1510 * if that's not true for this function.
1511 */
1512
1513 if (was_attached != NULL)
1514 *was_attached = MCDI_DWORD(outbuf, DRV_ATTACH_OUT_OLD_STATE);
1515 return 0;
1516
1517fail:
1475 MCDI_SET_DWORD(inbuf, DRV_ATTACH_IN_FIRMWARE_ID,
1476 MC_CMD_FW_DONT_CARE);
1477 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_DRV_ATTACH, inbuf,
1478 sizeof(inbuf), outbuf, sizeof(outbuf),
1479 &outlen);
1480 }
1481 if (rc) {
1482 efx_mcdi_display_error(efx, MC_CMD_DRV_ATTACH, sizeof(inbuf),

--- 25 unchanged lines hidden (view full) ---

1508 * if that's not true for this function.
1509 */
1510
1511 if (was_attached != NULL)
1512 *was_attached = MCDI_DWORD(outbuf, DRV_ATTACH_OUT_OLD_STATE);
1513 return 0;
1514
1515fail:
1518 netif_err(efx, probe, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
1516 pci_err(efx->pci_dev, "%s: failed rc=%d\n", __func__, rc);
1519 return rc;
1520}
1521
1522int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
1523 u16 *fw_subtype_list, u32 *capabilities)
1524{
1525 MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_BOARD_CFG_OUT_LENMAX);
1526 size_t outlen, i;

--- 850 unchanged lines hidden ---
1517 return rc;
1518}
1519
1520int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
1521 u16 *fw_subtype_list, u32 *capabilities)
1522{
1523 MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_BOARD_CFG_OUT_LENMAX);
1524 size_t outlen, i;

--- 850 unchanged lines hidden ---