4 * Copyright (C) Cavium networks Ltd. 2017.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Cavium networks nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_debug.h>
37 #include <rte_lcore.h>
39 #include <rte_malloc.h>
40 #include <rte_memory.h>
41 #include <rte_memzone.h>
44 #include "ssovf_evdev.h"
46 /* SSOPF Mailbox messages */
48 struct ssovf_mbox_dev_info {
49 uint64_t min_deq_timeout_ns;
50 uint64_t max_deq_timeout_ns;
51 uint32_t max_num_events;
55 ssovf_mbox_dev_info(struct ssovf_mbox_dev_info *info)
57 struct octeontx_mbox_hdr hdr = {0};
58 uint16_t len = sizeof(struct ssovf_mbox_dev_info);
60 hdr.coproc = SSO_COPROC;
61 hdr.msg = SSO_GET_DEV_INFO;
65 return octeontx_ssovf_mbox_send(&hdr, NULL, 0, info, len);
69 ssovf_vdev_probe(const char *name, const char *params)
71 struct octeontx_ssovf_info oinfo;
72 struct ssovf_mbox_dev_info info;
73 struct ssovf_evdev *edev;
74 struct rte_eventdev *eventdev;
75 static int ssovf_init_once;
80 /* More than one instance is not supported */
81 if (ssovf_init_once) {
82 ssovf_log_err("Request to create >1 %s instance", name);
86 eventdev = rte_event_pmd_vdev_init(name, sizeof(struct ssovf_evdev),
88 if (eventdev == NULL) {
89 ssovf_log_err("Failed to create eventdev vdev %s", name);
92 eventdev->dev_ops = NULL;
94 /* For secondary processes, the primary has done all the work */
95 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
98 ret = octeontx_ssovf_info(&oinfo);
100 ssovf_log_err("Failed to probe and validate ssovfs %d", ret);
104 edev = ssovf_pmd_priv(eventdev);
105 edev->max_event_ports = oinfo.total_ssowvfs;
106 edev->max_event_queues = oinfo.total_ssovfs;
107 edev->is_timeout_deq = 0;
109 ret = ssovf_mbox_dev_info(&info);
110 if (ret < 0 || ret != sizeof(struct ssovf_mbox_dev_info)) {
111 ssovf_log_err("Failed to get mbox devinfo %d", ret);
115 edev->min_deq_timeout_ns = info.min_deq_timeout_ns;
116 edev->max_deq_timeout_ns = info.max_deq_timeout_ns;
117 edev->max_num_events = info.max_num_events;
118 ssovf_log_dbg("min_deq_tmo=%"PRId64" max_deq_tmo=%"PRId64" max_evts=%d",
119 info.min_deq_timeout_ns, info.max_deq_timeout_ns,
120 info.max_num_events);
122 if (!edev->max_event_ports || !edev->max_event_queues) {
123 ssovf_log_err("Not enough eventdev resource queues=%d ports=%d",
124 edev->max_event_queues, edev->max_event_ports);
129 ssovf_log_info("Initializing %s domain=%d max_queues=%d max_ports=%d",
130 name, oinfo.domain, edev->max_event_queues,
131 edev->max_event_ports);
137 rte_event_pmd_vdev_uninit(name);
142 ssovf_vdev_remove(const char *name)
144 ssovf_log_info("Closing %s", name);
145 return rte_event_pmd_vdev_uninit(name);
148 static struct rte_vdev_driver vdev_ssovf_pmd = {
149 .probe = ssovf_vdev_probe,
150 .remove = ssovf_vdev_remove
153 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_OCTEONTX_PMD, vdev_ssovf_pmd);