Skip to content

Commit d3e2cef

Browse files
committed
Import feature-vepci-v2.2
1 parent 2fb0b1c commit d3e2cef

File tree

15 files changed

+551
-63
lines changed

15 files changed

+551
-63
lines changed

include/comm_request.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,14 @@ struct userdma {
567567
uint64_t dmactl;
568568
};
569569

570+
/**
571+
* @brief Structure to store to store information for PCI operation.
572+
*/
573+
struct pcicmd {
574+
uint64_t addr;
575+
size_t size;
576+
};
577+
570578
/**
571579
* @brief command ID's used to communicate b/w VEOS and PSEUDO side
572580
*/
@@ -630,6 +638,10 @@ enum pseudo_veos_msg_id {
630638
CMD_VHSHM,
631639
MAP_DMADES,
632640
UNMAP_DMADES,
641+
REGIS_PCIATB,
642+
UNREG_PCIATB,
643+
REGIS_DMAATB,
644+
UNREG_DMAATB,
633645
PSEUDO_VEOS_MAX_MSG_NUM,
634646
CMD_INVALID = -1,
635647
};

include/sysve.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ enum sysve_command {
4343
VE_SYSVE_ACCELERATED_IO_INIT,
4444
VE_SYSVE_ACCELERATED_IO_REGISTER_DMAATB,
4545
VE_SYSVE_SYSTEM,
46-
VE_SYSVE_SYSTEM2
46+
VE_SYSVE_SYSTEM2,
47+
VE_SYSVE_REGISTER_VEMVA_TO_PCIATB = 0x70,
48+
VE_SYSVE_UNREGISTER_VHSAA_FROM_PCIATB,
49+
VE_SYSVE_REGISTER_VHSAA_TO_DMAATB,
50+
VE_SYSVE_UNREGISTER_VEHVA_FROM_DMAATB
4751
};
4852

4953
#endif

lib/libvepseudo/common/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ libpseudocommon_la_SOURCES = \
1414
sysve_os.h \
1515
list.h \
1616
sys_veaio.c \
17-
sys_veaio.h
17+
sys_veaio.h \
18+
sys_pci.c \
19+
sys_pci.h
1820

1921
BUILT_SOURCES = \
2022
ve_syscall_no.h \

lib/libvepseudo/common/sys_common.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "pseudo_vhshm.h"
4343
#include "sys_veaio.h"
4444
#include "sys_accelerated_io.h"
45+
#include "sys_pci.h"
4546

4647
/**
4748
* @brief This function will be invoked to handle the MONC interrupt
@@ -1477,6 +1478,22 @@ ret_t ve_sysve(int syscall_num, char *syscall_name, veos_handle *handle)
14771478
retval = sys_system2(handle, args[1], args[2], args[3]);
14781479
break;
14791480

1481+
case VE_SYSVE_REGISTER_VEMVA_TO_PCIATB:
1482+
retval = ve_sys_pcireq(handle,(uint64_t)args[1],
1483+
(size_t)args[2], REGIS_PCIATB);
1484+
break;
1485+
case VE_SYSVE_UNREGISTER_VHSAA_FROM_PCIATB:
1486+
retval = ve_sys_pcireq(handle,(uint64_t)args[1],
1487+
(size_t)args[2], UNREG_PCIATB);
1488+
break;
1489+
case VE_SYSVE_REGISTER_VHSAA_TO_DMAATB:
1490+
retval = ve_sys_pcireq(handle,(uint64_t)args[1],
1491+
(size_t)args[2], REGIS_DMAATB);
1492+
break;
1493+
case VE_SYSVE_UNREGISTER_VEHVA_FROM_DMAATB:
1494+
retval = ve_sys_pcireq(handle,(uint64_t)args[1],
1495+
(size_t)args[2], UNREG_DMAATB);
1496+
break;
14801497
default:
14811498
/* write return value */
14821499
retval = -EINVAL;

lib/libvepseudo/common/sys_pci.c

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/**
2+
* Copyright (C) 2018 by NEC Corporation
3+
* This file is part of the VEOS.]
4+
*
5+
*
6+
* The VEOS is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either version
9+
* 2.1 of the License, or (at your option) any later version.
10+
* The VEOS is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with the VEOS; if not, see * <http://www.gnu.org/licenses/>.
17+
*/
18+
/**
19+
* @file sys_vepci.c
20+
* @brief Handle PCI operation system call on VE
21+
*
22+
* @internal
23+
* @author VEPCI
24+
*/
25+
26+
#include <stdio.h>
27+
#include <stdlib.h>
28+
#include <sys/types.h>
29+
#include <unistd.h>
30+
#include <errno.h>
31+
#include "handle.h"
32+
#include "libvepseudo.h"
33+
#include "sysve_os.h"
34+
35+
/**
36+
* @brief This function is handler of ve_register/unregister_mem_to/from_pci
37+
* and ve_register/unregister_pci_to/from_vehva
38+
* @param[in] handle Handle for VE driver interface
39+
* @param[in] addr Address to register or unregister
40+
* @param[in] size Size of address
41+
* @param[in] msg_id Identifier of request operation
42+
*
43+
* @return Return Address or 0 on success. Negative value on failure.
44+
*/
45+
int64_t ve_sys_pcireq(veos_handle *handle, uint64_t addr, size_t size,
46+
enum pseudo_veos_msg_id msg_id)
47+
{
48+
int64_t ret = 0;
49+
PseudoVeosMessage *reply_msg = NULL;
50+
struct pcicmd *cmd = NULL;
51+
ProtobufCBinaryData request_msg = {0};
52+
53+
PSEUDO_TRACE("invoked");
54+
55+
cmd = (struct pcicmd *)calloc(1, sizeof(struct pcicmd));
56+
if (NULL == cmd) {
57+
PSEUDO_DEBUG("Fail to allocate memory for "
58+
"amm request block\n");
59+
return -ENOMEM;
60+
}
61+
62+
/* Populating struct ve_mmap_cmd buffer to Generate IPC Command */
63+
cmd->addr = addr;
64+
cmd->size = size;
65+
66+
PSEUDO_DEBUG("Sending request for PCI operation to VEOS for addr(0x%lx) "
67+
"size(0x%lx)",
68+
cmd->addr, cmd->size);
69+
70+
/* Populate parameters for ve_mmap req */
71+
request_msg.len = sizeof(struct pcicmd);
72+
request_msg.data = (uint8_t *)cmd;
73+
ret = ve_request_veos(handle, msg_id, &request_msg, &reply_msg);
74+
if (ret < 0) {
75+
PSEUDO_ERROR("Failed to request PCI operation to VEOS: %s",
76+
strerror(-ret));
77+
goto hndl_return;
78+
}
79+
80+
ret = (int64_t)reply_msg->syscall_retval;
81+
if (reply_msg->syscall_retval < 0) {
82+
PSEUDO_DEBUG("Error(%s) occurred on VE OS while PCI operation for addr(0x%lx)",
83+
strerror(-ret), addr);
84+
} else {
85+
PSEUDO_DEBUG("retval:0x%lx PCI operation successfully done on VE",
86+
reply_msg->syscall_retval);
87+
}
88+
pseudo_veos_message__free_unpacked(reply_msg, NULL);
89+
hndl_return:
90+
if (cmd)
91+
free(cmd);
92+
PSEUDO_TRACE("returned(%ld)", ret);
93+
return ret;
94+
}

lib/libvepseudo/common/sys_pci.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright (C) 2018 NEC Corporation
3+
* This file is part of the VEOS.
4+
*
5+
* The VEOS is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either version
8+
* 2.1 of the License, or (at your option) any later version.
9+
*
10+
* The VEOS is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with the VEOS; if not, see
16+
* <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
/**
20+
* @file pseudo_vepci.h
21+
* @brief Header for VEPCI in psedo process
22+
*
23+
* @internal
24+
* @author VEPCI
25+
*/
26+
27+
#ifndef __PSEUDO_VEPCI_H
28+
#define __PSEUDO_VEPCI_H
29+
30+
#include <sys/types.h>
31+
#include "sys_common.h"
32+
#include "comm_request.h"
33+
34+
int64_t ve_sys_pcireq(veos_handle *, uint64_t, size_t, enum pseudo_veos_msg_id);
35+
int ve_sys_pciunmap(veos_handle *, uint64_t, size_t);
36+
int64_t ve_sys_map_pciatb(veos_handle *, uint64_t, size_t);
37+
int ve_sys_unmap_pciatb(veos_handle *, uint64_t, size_t);
38+
39+
#endif

lib/libvepseudo/common/sysve_os.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,12 @@ static int ve_sys_map_reg(uint64_t reg)
597597
*
598598
* @author libsysve
599599
*/
600-
int ve_request_veos(veos_handle *handle,
600+
int64_t ve_request_veos(veos_handle *handle,
601601
enum pseudo_veos_msg_id id,
602602
ProtobufCBinaryData *data,
603603
PseudoVeosMessage **reply_msg)
604604
{
605-
int ret;
605+
int64_t ret;
606606
PseudoVeosMessage msg = PSEUDO_VEOS_MESSAGE__INIT;
607607
PseudoVeosMessage *recv_msg;
608608
size_t msg_len;

lib/libvepseudo/common/sysve_os.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@
2626

2727
#include "sys_common.h"
2828
#include <veos_defs.h>
29+
#include "proto_buff_schema.pb-c.h"
30+
#include "comm_request.h"
2931

3032
int ve_sys_get_pci_sync(veos_handle *, uint8_t, uint64_t *, uint64_t *);
3133
int ve_sys_get_fixed_vehva(veos_handle *, uint64_t, uint64_t *);
3234
int ve_sys_set_user_reg(veos_handle *, uint64_t, uint64_t);
3335
ssize_t ve_sys_get_ve_info(veos_handle *, char *, char *, size_t);
3436
int ve_sys_map_dmades(veos_handle *, uint64_t * ,uint64_t *);
3537
int ve_sys_unmap_dmades(veos_handle *, uint64_t );
38+
int64_t ve_request_veos(veos_handle *, enum pseudo_veos_msg_id, ProtobufCBinaryData *, PseudoVeosMessage **reply_msg);
3639

3740
#endif

src/veos/main/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ libvemain_a_SOURCES = \
44
veos.h \
55
veos_init.c \
66
veos_ipc.c \
7+
veos_ipc.h \
78
veos_handler.c \
89
veos_handler.h \
910
veos_main.c \
1011
sysve.c \
11-
userdma.c
12+
userdma.c \
13+
pci.c
1214

1315
libvemain_a_CFLAGS = \
1416
-g -Wall -Werror -D_GNU_SOURCE -std=gnu99 \

0 commit comments

Comments
 (0)