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.
14 #include <sys/queue.h>
19 #include "sfc_stats.h"
25 #define SFC_DIV_ROUND_UP(a, b) \
30 (_a + (_b - 1)) / _b; \
34 * Datapath exception handler to be provided by the control path.
36 typedef void (sfc_dp_exception_t)(void *ctrl);
39 SFC_DP_RX = 0, /**< Receive datapath */
40 SFC_DP_TX, /**< Transmit datapath */
44 /** Datapath queue run-time information */
47 * Typically the structure is located at the end of Rx/Tx queue
48 * data structure and not used on datapath. So, it is not a
49 * problem to have extra fields even if not used. However,
50 * put stats at top of the structure to be closer to fields
51 * used on datapath or reap to have more chances to be cache-hot.
53 union sfc_pkts_bytes stats;
59 struct rte_pci_addr pci_addr;
62 void sfc_dp_queue_init(struct sfc_dp_queue *dpq,
63 uint16_t port_id, uint16_t queue_id,
64 const struct rte_pci_addr *pci_addr);
66 /* Maximum datapath log level to be included in build. */
67 #ifndef SFC_DP_LOG_LEVEL
68 #define SFC_DP_LOG_LEVEL RTE_LOG_NOTICE
72 * Helper macro to define datapath logging macros and have uniform
75 #define SFC_DP_LOG(dp_name, level, dpq, ...) \
77 const struct sfc_dp_queue *_dpq = (dpq); \
78 const struct rte_pci_addr *_addr = &(_dpq)->pci_addr; \
80 if (RTE_LOG_ ## level > SFC_DP_LOG_LEVEL) \
82 SFC_GENERIC_LOG(level, \
83 RTE_FMT("%s " PCI_PRI_FMT \
84 " #%" PRIu16 ".%" PRIu16 ": " \
85 RTE_FMT_HEAD(__VA_ARGS__ ,), \
87 _addr->domain, _addr->bus, \
88 _addr->devid, _addr->function, \
89 _dpq->port_id, _dpq->queue_id, \
90 RTE_FMT_TAIL(__VA_ARGS__,))); \
94 /** Datapath definition */
96 TAILQ_ENTRY(sfc_dp) links;
98 enum sfc_dp_type type;
99 /* Mask of required hardware/firmware capabilities */
100 unsigned int hw_fw_caps;
101 #define SFC_DP_HW_FW_CAP_EF10 0x1
102 #define SFC_DP_HW_FW_CAP_RX_ES_SUPER_BUFFER 0x2
103 #define SFC_DP_HW_FW_CAP_RX_EFX 0x4
104 #define SFC_DP_HW_FW_CAP_TX_EFX 0x8
105 #define SFC_DP_HW_FW_CAP_EF100 0x10
108 /** List of datapath variants */
109 TAILQ_HEAD(sfc_dp_list, sfc_dp);
111 typedef unsigned int sfc_sw_index_t;
112 #define SFC_SW_INDEX_INVALID ((sfc_sw_index_t)(UINT_MAX))
114 typedef int32_t sfc_ethdev_qid_t;
115 #define SFC_ETHDEV_QID_INVALID ((sfc_ethdev_qid_t)(-1))
117 /* Check if available HW/FW capabilities are sufficient for the datapath */
119 sfc_dp_match_hw_fw_caps(const struct sfc_dp *dp, unsigned int avail_caps)
121 return (dp->hw_fw_caps & avail_caps) == dp->hw_fw_caps;
124 struct sfc_dp *sfc_dp_find_by_name(struct sfc_dp_list *head,
125 enum sfc_dp_type type, const char *name);
126 struct sfc_dp *sfc_dp_find_by_caps(struct sfc_dp_list *head,
127 enum sfc_dp_type type,
128 unsigned int avail_caps);
129 int sfc_dp_register(struct sfc_dp_list *head, struct sfc_dp *entry);
132 * Dynamically registered mbuf flag "mport_override" (as a bitmask).
134 * If this flag is set in an mbuf then the dynamically registered
135 * mbuf field "mport" holds a valid value. This is used to direct
136 * port representor transmit traffic to the correct target port.
138 extern uint64_t sfc_dp_mport_override;
141 * Dynamically registered mbuf field "mport" (mbuf byte offset).
143 * If the dynamically registered "mport_override" flag is set in
144 * an mbuf then the mbuf "mport" field holds a valid value. This
145 * is used to direct port representor transmit traffic to the
146 * correct target port.
148 extern int sfc_dp_mport_offset;
151 * Register dynamic mbuf flag and field which can be used to require Tx override
152 * prefix descriptor with egress mport set.
154 int sfc_dp_mport_register(void);
159 #endif /* _SFC_DP_H */