1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2019-2021 Xilinx, Inc.
4 * Copyright(c) 2017-2019 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
10 #include <sys/queue.h>
15 #include <rte_mbuf_dyn.h>
23 sfc_dp_queue_init(struct sfc_dp_queue *dpq, uint16_t port_id, uint16_t queue_id,
24 const struct rte_pci_addr *pci_addr)
26 dpq->port_id = port_id;
27 dpq->queue_id = queue_id;
28 dpq->pci_addr = *pci_addr;
32 sfc_dp_find_by_name(struct sfc_dp_list *head, enum sfc_dp_type type,
37 TAILQ_FOREACH(entry, head, links) {
38 if (entry->type != type)
41 if (strcmp(entry->name, name) == 0)
49 sfc_dp_find_by_caps(struct sfc_dp_list *head, enum sfc_dp_type type,
50 unsigned int avail_caps)
54 TAILQ_FOREACH(entry, head, links) {
55 if (entry->type != type)
58 /* Take the first matching */
59 if (sfc_dp_match_hw_fw_caps(entry, avail_caps))
67 sfc_dp_register(struct sfc_dp_list *head, struct sfc_dp *entry)
69 if (sfc_dp_find_by_name(head, entry->type, entry->name) != NULL) {
71 "sfc %s dapapath '%s' already registered",
72 entry->type == SFC_DP_RX ? "Rx" :
73 entry->type == SFC_DP_TX ? "Tx" :
79 TAILQ_INSERT_TAIL(head, entry, links);
84 uint64_t sfc_dp_mport_override;
85 int sfc_dp_mport_offset = -1;
88 sfc_dp_mport_register(void)
90 static const struct rte_mbuf_dynfield mport = {
91 .name = "rte_net_sfc_dynfield_mport",
92 .size = sizeof(efx_mport_id_t),
93 .align = __alignof__(efx_mport_id_t),
95 static const struct rte_mbuf_dynflag mport_override = {
96 .name = "rte_net_sfc_dynflag_mport_override",
102 if (sfc_dp_mport_override != 0) {
103 SFC_GENERIC_LOG(INFO, "%s() already registered", __func__);
107 field_offset = rte_mbuf_dynfield_register(&mport);
108 if (field_offset < 0) {
109 SFC_GENERIC_LOG(ERR, "%s() failed to register mport dynfield",
114 flag = rte_mbuf_dynflag_register(&mport_override);
116 SFC_GENERIC_LOG(ERR, "%s() failed to register mport dynflag",
121 sfc_dp_mport_offset = field_offset;
122 sfc_dp_mport_override = UINT64_C(1) << flag;