1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2017-2018 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>
24 #define SFC_DIV_ROUND_UP(a, b) \
29 (_a + (_b - 1)) / _b; \
33 * Datapath exception handler to be provided by the control path.
35 typedef void (sfc_dp_exception_t)(void *ctrl);
38 SFC_DP_RX = 0, /**< Receive datapath */
39 SFC_DP_TX, /**< Transmit datapath */
43 /** Datapath queue run-time information */
47 struct rte_pci_addr pci_addr;
50 void sfc_dp_queue_init(struct sfc_dp_queue *dpq,
51 uint16_t port_id, uint16_t queue_id,
52 const struct rte_pci_addr *pci_addr);
55 * Helper macro to define datapath logging macros and have uniform
58 #define SFC_DP_LOG(dp_name, level, dpq, ...) \
60 const struct sfc_dp_queue *_dpq = (dpq); \
61 const struct rte_pci_addr *_addr = &(_dpq)->pci_addr; \
63 SFC_GENERIC_LOG(level, \
64 RTE_FMT("%s " PCI_PRI_FMT \
65 " #%" PRIu16 ".%" PRIu16 ": " \
66 RTE_FMT_HEAD(__VA_ARGS__ ,), \
68 _addr->domain, _addr->bus, \
69 _addr->devid, _addr->function, \
70 _dpq->port_id, _dpq->queue_id, \
71 RTE_FMT_TAIL(__VA_ARGS__,))); \
75 /** Datapath definition */
77 TAILQ_ENTRY(sfc_dp) links;
79 enum sfc_dp_type type;
80 /* Mask of required hardware/firmware capabilities */
81 unsigned int hw_fw_caps;
82 #define SFC_DP_HW_FW_CAP_EF10 0x1
83 #define SFC_DP_HW_FW_CAP_RX_ES_SUPER_BUFFER 0x2
86 /** List of datapath variants */
87 TAILQ_HEAD(sfc_dp_list, sfc_dp);
89 /* Check if available HW/FW capabilities are sufficient for the datapath */
91 sfc_dp_match_hw_fw_caps(const struct sfc_dp *dp, unsigned int avail_caps)
93 return (dp->hw_fw_caps & avail_caps) == dp->hw_fw_caps;
96 struct sfc_dp *sfc_dp_find_by_name(struct sfc_dp_list *head,
97 enum sfc_dp_type type, const char *name);
98 struct sfc_dp *sfc_dp_find_by_caps(struct sfc_dp_list *head,
99 enum sfc_dp_type type,
100 unsigned int avail_caps);
101 int sfc_dp_register(struct sfc_dp_list *head, struct sfc_dp *entry);
106 #endif /* _SFC_DP_H */