1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2019 Marvell International Ltd.
13 #include "otx2_dpi_rawdev.h"
15 /* DPI PF DBDF information macro's */
16 #define DPI_PF_DBDF_DOMAIN 0
17 #define DPI_PF_DBDF_BUS 5
18 #define DPI_PF_DBDF_DEVICE 0
19 #define DPI_PF_DBDF_FUNCTION 0
21 #define DPI_PF_MBOX_SYSFS_ENTRY "dpi_device_config"
23 union dpi_mbox_message_u {
25 struct dpi_mbox_message_s {
26 /* VF ID to configure */
30 /* Command buffer size in 8-byte words */
32 /* aura of the command buffer */
35 uint64_t sso_pf_func :16;
37 uint64_t npa_pf_func :16;
42 send_msg_to_pf(const char *value, int size)
44 char buff[255] = { 0 };
47 res = snprintf(buff, sizeof(buff), "%s/" PCI_PRI_FMT "/%s",
48 rte_pci_get_sysfs_path(), DPI_PF_DBDF_DOMAIN,
49 DPI_PF_DBDF_BUS, DPI_PF_DBDF_DEVICE & 0x7,
50 DPI_PF_DBDF_FUNCTION & 0x7, DPI_PF_MBOX_SYSFS_ENTRY);
51 if ((res < 0) || ((size_t)res > sizeof(buff)))
54 fd = open(buff, O_WRONLY);
57 res = write(fd, value, size);
66 otx2_dpi_queue_open(uint16_t vf_id, uint32_t size, uint32_t gaura)
68 union dpi_mbox_message_u mbox_msg;
71 /* DPI PF driver expects vfid starts from index 0 */
72 mbox_msg.s.vfid = vf_id;
73 mbox_msg.s.cmd = DPI_QUEUE_OPEN;
74 mbox_msg.s.csize = size;
75 mbox_msg.s.aura = gaura;
76 mbox_msg.s.sso_pf_func = otx2_sso_pf_func_get();
77 mbox_msg.s.npa_pf_func = otx2_npa_pf_func_get();
79 ret = send_msg_to_pf((const char *)&mbox_msg,
82 otx2_dpi_dbg("Failed to send mbox message to dpi pf");
88 otx2_dpi_queue_close(uint16_t vf_id)
90 union dpi_mbox_message_u mbox_msg;
93 /* DPI PF driver expects vfid starts from index 0 */
94 mbox_msg.s.vfid = vf_id;
95 mbox_msg.s.cmd = DPI_QUEUE_CLOSE;
97 ret = send_msg_to_pf((const char *)&mbox_msg,
100 otx2_dpi_dbg("Failed to send mbox message to dpi pf");
105 #endif /* _DPI_MSG_H_ */