1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2019-2021 Xilinx, Inc.
4 * Copyright(c) 2016-2019 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
10 #include "sfc_efx_mcdi.h"
13 #include "sfc_debug.h"
17 static sfc_efx_mcdi_dma_alloc_cb sfc_mcdi_dma_alloc;
19 sfc_mcdi_dma_alloc(void *cookie, const char *name, size_t len,
22 const struct sfc_adapter *sa = cookie;
24 return sfc_dma_alloc(sa, name, 0, len, sa->socket_id, esmp);
27 static sfc_efx_mcdi_dma_free_cb sfc_mcdi_dma_free;
29 sfc_mcdi_dma_free(void *cookie, efsys_mem_t *esmp)
31 const struct sfc_adapter *sa = cookie;
33 sfc_dma_free(sa, esmp);
36 static sfc_efx_mcdi_sched_restart_cb sfc_mcdi_sched_restart;
38 sfc_mcdi_sched_restart(void *cookie)
40 struct sfc_adapter *sa = cookie;
42 sfc_schedule_restart(sa);
45 static sfc_efx_mcdi_mgmt_evq_poll_cb sfc_mcdi_mgmt_evq_poll;
47 sfc_mcdi_mgmt_evq_poll(void *cookie)
49 struct sfc_adapter *sa = cookie;
51 sfc_ev_mgmt_qpoll(sa);
54 static const struct sfc_efx_mcdi_ops sfc_mcdi_ops = {
55 .dma_alloc = sfc_mcdi_dma_alloc,
56 .dma_free = sfc_mcdi_dma_free,
57 .sched_restart = sfc_mcdi_sched_restart,
58 .mgmt_evq_poll = sfc_mcdi_mgmt_evq_poll,
62 sfc_mcdi_init(struct sfc_adapter *sa)
66 sfc_log_init(sa, "entry");
68 logtype = sfc_register_logtype(&sa->priv.shared->pci_addr,
72 return sfc_efx_mcdi_init(&sa->mcdi, logtype,
73 sa->priv.shared->log_prefix, sa->nic,
78 sfc_mcdi_fini(struct sfc_adapter *sa)
80 sfc_log_init(sa, "entry");
81 sfc_efx_mcdi_fini(&sa->mcdi);