f-stack/dpdk/drivers/net/sfc/sfc_mcdi.c

83 lines
1.8 KiB
C
Raw Normal View History

2019-06-25 11:12:58 +00:00
/* SPDX-License-Identifier: BSD-3-Clause
*
2021-02-05 08:48:47 +00:00
* Copyright(c) 2019-2020 Xilinx, Inc.
* Copyright(c) 2016-2019 Solarflare Communications Inc.
*
* This software was jointly developed between OKTET Labs (under contract
* for Solarflare) and Solarflare Communications, Inc.
*/
2021-02-05 08:48:47 +00:00
#include "sfc_efx_mcdi.h"
#include "sfc.h"
2021-02-05 08:48:47 +00:00
#include "sfc_debug.h"
#include "sfc_log.h"
#include "sfc_ev.h"
2021-02-05 08:48:47 +00:00
static sfc_efx_mcdi_dma_alloc_cb sfc_mcdi_dma_alloc;
static int
sfc_mcdi_dma_alloc(void *cookie, const char *name, size_t len,
efsys_mem_t *esmp)
{
2021-02-05 08:48:47 +00:00
const struct sfc_adapter *sa = cookie;
2021-02-05 08:48:47 +00:00
return sfc_dma_alloc(sa, name, 0, len, sa->socket_id, esmp);
}
2021-02-05 08:48:47 +00:00
static sfc_efx_mcdi_dma_free_cb sfc_mcdi_dma_free;
static void
2021-02-05 08:48:47 +00:00
sfc_mcdi_dma_free(void *cookie, efsys_mem_t *esmp)
{
2021-02-05 08:48:47 +00:00
const struct sfc_adapter *sa = cookie;
2021-02-05 08:48:47 +00:00
sfc_dma_free(sa, esmp);
}
2021-02-05 08:48:47 +00:00
static sfc_efx_mcdi_sched_restart_cb sfc_mcdi_sched_restart;
static void
2021-02-05 08:48:47 +00:00
sfc_mcdi_sched_restart(void *cookie)
{
2021-02-05 08:48:47 +00:00
struct sfc_adapter *sa = cookie;
2019-06-25 11:12:58 +00:00
sfc_schedule_restart(sa);
}
2021-02-05 08:48:47 +00:00
static sfc_efx_mcdi_mgmt_evq_poll_cb sfc_mcdi_mgmt_evq_poll;
static void
2021-02-05 08:48:47 +00:00
sfc_mcdi_mgmt_evq_poll(void *cookie)
{
2021-02-05 08:48:47 +00:00
struct sfc_adapter *sa = cookie;
2021-02-05 08:48:47 +00:00
sfc_ev_mgmt_qpoll(sa);
}
2021-02-05 08:48:47 +00:00
static const struct sfc_efx_mcdi_ops sfc_mcdi_ops = {
.dma_alloc = sfc_mcdi_dma_alloc,
.dma_free = sfc_mcdi_dma_free,
.sched_restart = sfc_mcdi_sched_restart,
.mgmt_evq_poll = sfc_mcdi_mgmt_evq_poll,
};
int
sfc_mcdi_init(struct sfc_adapter *sa)
{
2021-02-05 08:48:47 +00:00
uint32_t logtype;
sfc_log_init(sa, "entry");
2021-02-05 08:48:47 +00:00
logtype = sfc_register_logtype(&sa->priv.shared->pci_addr,
SFC_LOGTYPE_MCDI_STR,
RTE_LOG_NOTICE);
2021-02-05 08:48:47 +00:00
return sfc_efx_mcdi_init(&sa->mcdi, logtype,
sa->priv.shared->log_prefix, sa->nic,
&sfc_mcdi_ops, sa);
}
void
sfc_mcdi_fini(struct sfc_adapter *sa)
{
sfc_log_init(sa, "entry");
2021-02-05 08:48:47 +00:00
sfc_efx_mcdi_fini(&sa->mcdi);
}