Message type for DL_{READ,WRITE}V_S

Change-Id: I6e25e8e994b0bdec2bb54f50e6db08e6e935c819
This commit is contained in:
Lionel Sambuc 2014-05-20 11:19:27 +02:00
parent 992b76139f
commit 1576ef5542
16 changed files with 128 additions and 96 deletions

View file

@ -777,12 +777,13 @@ static void atl2_readv(const message *m, int from_int)
left = count;
pos = rxd->data;
for (i = 0; i < m->DL_COUNT && left > 0; i += batch) {
for (i = 0; i < m->m_net_netdrv_dl_readv_s.count && left > 0; i += batch) {
/* Copy in the next batch. */
batch = MIN(m->DL_COUNT - i, NR_IOREQS);
batch = MIN(m->m_net_netdrv_dl_readv_s.count - i, NR_IOREQS);
r = sys_safecopyfrom(m->m_source, m->DL_GRANT, off,
(vir_bytes) iovec, batch * sizeof(iovec[0]));
r = sys_safecopyfrom(m->m_source,
m->m_net_netdrv_dl_readv_s.grant, off, (vir_bytes) iovec,
batch * sizeof(iovec[0]));
if (r != OK)
panic("vector copy failed: %d", r);
@ -874,12 +875,13 @@ static void atl2_writev(const message *m, int from_int)
pos = (state.txd_tail + state.txd_num +
sizeof(u32_t)) % ATL2_TXD_BUFSIZE;
for (i = 0; i < m->DL_COUNT; i += batch) {
for (i = 0; i < m->m_net_netdrv_dl_writev_s.count; i += batch) {
/* Copy in the next batch. */
batch = MIN(m->DL_COUNT - i, NR_IOREQS);
batch = MIN(m->m_net_netdrv_dl_writev_s.count - i, NR_IOREQS);
r = sys_safecopyfrom(m->m_source, m->DL_GRANT, off,
(vir_bytes) iovec, batch * sizeof(iovec[0]));
r = sys_safecopyfrom(m->m_source,
m->m_net_netdrv_dl_writev_s.grant, off, (vir_bytes) iovec,
batch * sizeof(iovec[0]));
if (r != OK)
panic("vector copy failed: %d", r);

View file

@ -470,10 +470,11 @@ static void do_vread_s(const message * mp, int from_int)
client layer
*/
dep->de_read_iovec.iod_proc_nr = mp->m_source;
de_get_userdata_s(mp->m_source, (cp_grant_id_t) mp->DL_GRANT, 0,
mp->DL_COUNT, dep->de_read_iovec.iod_iovec);
dep->de_read_iovec.iod_iovec_s = mp->DL_COUNT;
dep->de_read_iovec.iod_grant = (cp_grant_id_t) mp->DL_GRANT;
de_get_userdata_s(mp->m_source, mp->m_net_netdrv_dl_readv_s.grant, 0,
mp->m_net_netdrv_dl_readv_s.count,
dep->de_read_iovec.iod_iovec);
dep->de_read_iovec.iod_iovec_s = mp->m_net_netdrv_dl_readv_s.count;
dep->de_read_iovec.iod_grant = mp->m_net_netdrv_dl_readv_s.grant;
dep->de_read_iovec.iod_iovec_offset = 0;
size = de_calc_iov_size(&dep->de_read_iovec);
if (size < ETH_MAX_PACK_SIZE)
@ -823,10 +824,10 @@ static void do_vwrite_s(const message * mp, int from_int){
buffer = descr->buf1;
iovp = &dep->de_write_iovec;
iovp->iod_proc_nr = mp->m_source;
de_get_userdata_s(mp->m_source, mp->DL_GRANT, 0,
mp->DL_COUNT, iovp->iod_iovec);
iovp->iod_iovec_s = mp->DL_COUNT;
iovp->iod_grant = (cp_grant_id_t) mp->DL_GRANT;
de_get_userdata_s(mp->m_source, mp->m_net_netdrv_dl_writev_s.grant, 0,
mp->m_net_netdrv_dl_writev_s.count, iovp->iod_iovec);
iovp->iod_iovec_s = mp->m_net_netdrv_dl_writev_s.count;
iovp->iod_grant = mp->m_net_netdrv_dl_writev_s.grant;
iovp->iod_iovec_offset = 0;
totalsize = size = de_calc_iov_size(iovp);
if (size < ETH_MIN_PACK_SIZE || size > ETH_MAX_PACK_SIZE)

View file

@ -364,7 +364,7 @@ int from_int;
dep= &de_state;
count = mp->DL_COUNT;
count = mp->m_net_netdrv_dl_writev_s.count;
dep->de_client= mp->m_source;
if (dep->de_mode == DEM_SINK)
@ -391,13 +391,13 @@ int from_int;
}
assert(!(dep->de_flags & DEF_PACK_SEND));
get_userdata_s(mp->m_source, mp->DL_GRANT, 0,
get_userdata_s(mp->m_source, mp->m_net_netdrv_dl_writev_s.grant, 0,
(count > IOVEC_NR ? IOVEC_NR : count) *
sizeof(dep->de_write_iovec_s.iod_iovec[0]),
dep->de_write_iovec_s.iod_iovec);
dep->de_write_iovec_s.iod_iovec_s = count;
dep->de_write_iovec_s.iod_proc_nr = mp->m_source;
dep->de_write_iovec_s.iod_grant = mp->DL_GRANT;
dep->de_write_iovec_s.iod_grant = mp->m_net_netdrv_dl_writev_s.grant;
dep->de_write_iovec_s.iod_iovec_offset = 0;
dep->de_tmp_iovec_s = dep->de_write_iovec_s;
@ -451,7 +451,7 @@ message *mp;
dep= &de_state;
count = mp->DL_COUNT;
count = mp->m_net_netdrv_dl_readv_s.count;
dep->de_client= mp->m_source;
if (dep->de_mode == DEM_SINK)
{
@ -464,13 +464,13 @@ message *mp;
if(dep->de_flags & DEF_READING)
panic("dp8390: read already in progress");
get_userdata_s(mp->m_source, mp->DL_GRANT, 0,
get_userdata_s(mp->m_source, mp->m_net_netdrv_dl_readv_s.grant, 0,
(count > IOVEC_NR ? IOVEC_NR : count) *
sizeof(dep->de_read_iovec_s.iod_iovec[0]),
dep->de_read_iovec_s.iod_iovec);
dep->de_read_iovec_s.iod_iovec_s = count;
dep->de_read_iovec_s.iod_proc_nr = mp->m_source;
dep->de_read_iovec_s.iod_grant = mp->DL_GRANT;
dep->de_read_iovec_s.iod_grant = mp->m_net_netdrv_dl_readv_s.grant;
dep->de_read_iovec_s.iod_iovec_offset = 0;
dep->de_tmp_iovec_s = dep->de_read_iovec_s;

View file

@ -363,10 +363,10 @@ static void do_vwrite_s(const message * mp)
panic("send already in progress ");
dep->de_write_iovec.iod_proc_nr = mp->m_source;
get_userdata_s(mp->m_source, mp->DL_GRANT, 0,
mp->DL_COUNT, dep->de_write_iovec.iod_iovec);
dep->de_write_iovec.iod_iovec_s = mp->DL_COUNT;
dep->de_write_iovec.iod_grant = (cp_grant_id_t) mp->DL_GRANT;
get_userdata_s(mp->m_source, mp->m_net_netdrv_dl_writev_s.grant, 0,
mp->m_net_netdrv_dl_writev_s.count, dep->de_write_iovec.iod_iovec);
dep->de_write_iovec.iod_iovec_s = mp->m_net_netdrv_dl_writev_s.count;
dep->de_write_iovec.iod_grant = mp->m_net_netdrv_dl_writev_s.grant;
dep->de_write_iovec.iod_iovec_offset = 0;
size = calc_iovec_size(&dep->de_write_iovec);
if (size < ETH_MIN_PACK_SIZE || size > ETH_MAX_PACK_SIZE)
@ -401,10 +401,10 @@ static void do_vread_s(const message * mp)
panic("read already in progress");
dep->de_read_iovec.iod_proc_nr = mp->m_source;
get_userdata_s(mp->m_source, (cp_grant_id_t) mp->DL_GRANT, 0,
mp->DL_COUNT, dep->de_read_iovec.iod_iovec);
dep->de_read_iovec.iod_iovec_s = mp->DL_COUNT;
dep->de_read_iovec.iod_grant = (cp_grant_id_t) mp->DL_GRANT;
get_userdata_s(mp->m_source, mp->m_net_netdrv_dl_readv_s.grant, 0,
mp->m_net_netdrv_dl_readv_s.count, dep->de_read_iovec.iod_iovec);
dep->de_read_iovec.iod_iovec_s = mp->m_net_netdrv_dl_readv_s.count;
dep->de_read_iovec.iod_grant = mp->m_net_netdrv_dl_readv_s.grant;
dep->de_read_iovec.iod_iovec_offset = 0;
size = calc_iovec_size(&dep->de_read_iovec);
if (size < ETH_MAX_PACK_SIZE) panic(SizeErrMsg, size);

View file

@ -607,15 +607,16 @@ int from_int;
e->status |= E1000_WRITING;
/* Must be a sane vector count. */
assert(e->tx_message.DL_COUNT > 0);
assert(e->tx_message.DL_COUNT < E1000_IOVEC_NR);
assert(e->tx_message.m_net_netdrv_dl_writev_s.count > 0);
assert(e->tx_message.m_net_netdrv_dl_writev_s.count < E1000_IOVEC_NR);
/*
* Copy the I/O vector table.
*/
if ((r = sys_safecopyfrom(e->tx_message.m_source,
e->tx_message.DL_GRANT, 0,
(vir_bytes) iovec, e->tx_message.DL_COUNT *
e->tx_message.m_net_netdrv_dl_writev_s.grant, 0,
(vir_bytes) iovec,
e->tx_message.m_net_netdrv_dl_writev_s.count *
sizeof(iovec_s_t))) != OK)
{
panic("sys_safecopyfrom() failed: %d", r);
@ -629,7 +630,7 @@ int from_int;
e->name, head, tail));
/* Loop vector elements. */
for (i = 0; i < e->tx_message.DL_COUNT; i++)
for (i = 0; i < e->tx_message.m_net_netdrv_dl_writev_s.count; i++)
{
size = iovec[i].iov_size < (E1000_IOBUF_SIZE - bytes) ?
iovec[i].iov_size : (E1000_IOBUF_SIZE - bytes);
@ -651,7 +652,7 @@ int from_int;
desc->length = size;
/* Marks End-of-Packet. */
if (i == e->tx_message.DL_COUNT - 1)
if (i == e->tx_message.m_net_netdrv_dl_writev_s.count - 1)
{
desc->command = E1000_TX_CMD_EOP |
E1000_TX_CMD_FCS |
@ -696,8 +697,8 @@ int from_int;
e->status |= E1000_READING;
e->rx_size = 0;
assert(e->rx_message.DL_COUNT > 0);
assert(e->rx_message.DL_COUNT < E1000_IOVEC_NR);
assert(e->rx_message.m_net_netdrv_dl_readv_s.count > 0);
assert(e->rx_message.m_net_netdrv_dl_readv_s.count < E1000_IOVEC_NR);
}
if (e->status & E1000_READING)
{
@ -705,8 +706,9 @@ int from_int;
* Copy the I/O vector table first.
*/
if ((r = sys_safecopyfrom(e->rx_message.m_source,
e->rx_message.DL_GRANT, 0,
(vir_bytes) iovec, e->rx_message.DL_COUNT *
e->rx_message.m_net_netdrv_dl_readv_s.grant, 0,
(vir_bytes) iovec,
e->rx_message.m_net_netdrv_dl_readv_s.count *
sizeof(iovec_s_t))) != OK)
{
panic("sys_safecopyfrom() failed: %d", r);
@ -731,7 +733,8 @@ int from_int;
/*
* Copy to vector elements.
*/
for (i = 0; i < e->rx_message.DL_COUNT && bytes < desc->length; i++)
for (i = 0; i < e->rx_message.m_net_netdrv_dl_readv_s.count &&
bytes < desc->length; i++)
{
size = iovec[i].iov_size < (desc->length - bytes) ?
iovec[i].iov_size : (desc->length - bytes);

View file

@ -938,7 +938,7 @@ static void fxp_writev_s(const message *mp, int from_int)
fp= fxp_state;
count = mp->DL_COUNT;
count = mp->m_net_netdrv_dl_writev_s.count;
fp->fxp_client= mp->m_source;
assert(fp->fxp_mode == FM_ENABLED);
@ -982,7 +982,7 @@ static void fxp_writev_s(const message *mp, int from_int)
assert(!(fp->fxp_flags & FF_PACK_SENT));
iov_endpt= mp->m_source;
iov_grant= mp->DL_GRANT;
iov_grant= mp->m_net_netdrv_dl_writev_s.grant;
size= 0;
o= 0;
@ -1081,7 +1081,7 @@ int from_int;
fp= fxp_state;
count = mp->DL_COUNT;
count = mp->m_net_netdrv_dl_readv_s.count;
fp->fxp_client= mp->m_source;
assert(fp->fxp_mode == FM_ENABLED);
@ -1117,7 +1117,7 @@ int from_int;
packlen= rfd_res & RFDSZ_SIZE;
iov_endpt = mp->m_source;
iov_grant = mp->DL_GRANT;
iov_grant = mp->m_net_netdrv_dl_readv_s.grant;
size= 0;
o= 0;

View file

@ -254,7 +254,7 @@ message *m;
reply.m_type = DL_CONF_REPLY;
reply.m_netdrv_net_dl_conf.stat = OK;
memcpy(reply.m_netdrv_net_dl_conf.hw_addr,
lan8710a_state.address,
lan8710a_state.address.ea_addr,
sizeof(reply.m_netdrv_net_dl_conf.hw_addr));
mess_reply(m, &reply);
}
@ -849,15 +849,17 @@ int from_int;
e->status |= LAN8710A_WRITING;
/* verify vector count */
assert(mp->DL_COUNT > 0);
assert(mp->DL_COUNT < LAN8710A_IOVEC_NR);
assert(mp->m_net_netdrv_dl_writev_s.count > 0);
assert(mp->m_net_netdrv_dl_writev_s.count < LAN8710A_IOVEC_NR);
/*
* Copy the I/O vector table.
*/
if ((r = sys_safecopyfrom(mp->m_source, mp->DL_GRANT, 0,
if ((r = sys_safecopyfrom(mp->m_source,
mp->m_net_netdrv_dl_writev_s.grant, 0,
(vir_bytes) iovec,
mp->DL_COUNT * sizeof(iovec_s_t))) != OK) {
mp->m_net_netdrv_dl_writev_s.count *
sizeof(iovec_s_t))) != OK) {
panic("sys_safecopyfrom() failed: %d", r);
}
/* setup descriptors */
@ -874,7 +876,7 @@ int from_int;
/* virtual address of buffer */
p_buf = e->p_tx_buf + e->tx_desc_idx * LAN8710A_IOBUF_SIZE;
buf_data_len = 0;
for (i = 0; i < mp->DL_COUNT; i++) {
for (i = 0; i < mp->m_net_netdrv_dl_writev_s.count; i++) {
if ((buf_data_len + iovec[i].iov_size)
> LAN8710A_IOBUF_SIZE) {
panic("packet too long");
@ -943,16 +945,17 @@ int from_int;
e->status |= LAN8710A_READING;
e->rx_size = 0;
assert(e->rx_message.DL_COUNT > 0);
assert(e->rx_message.DL_COUNT < LAN8710A_IOVEC_NR);
assert(e->rx_message.m_net_netdrv_dl_readv_s.count > 0);
assert(e->rx_message.m_net_netdrv_dl_readv_s.count < LAN8710A_IOVEC_NR);
}
if (e->status & LAN8710A_READING) {
/*
* Copy the I/O vector table first.
*/
if ((r = sys_safecopyfrom(e->rx_message.m_source,
e->rx_message.DL_GRANT, 0, (vir_bytes) iovec,
e->rx_message.DL_COUNT *
e->rx_message.m_net_netdrv_dl_readv_s.grant, 0,
(vir_bytes) iovec,
e->rx_message.m_net_netdrv_dl_readv_s.count *
sizeof(iovec_s_t))) != OK) {
panic("sys_safecopyfrom() failed: %d", r);
}
@ -987,7 +990,7 @@ int from_int;
pkt_data_len = 0;
buf_bytes = 0;
p_buf = e->p_rx_buf + e->rx_desc_idx * LAN8710A_IOBUF_SIZE;
for (i = 0; i < e->rx_message.DL_COUNT; i++) {
for (i = 0; i < e->rx_message.m_net_netdrv_dl_readv_s.count; i++) {
buf_len = p_rx_desc->buffer_length_off & 0xFFFF;
if (buf_bytes == buf_len) {
/* Whole buffer move to the next descriptor */

View file

@ -1006,9 +1006,9 @@ static void do_vread_s(const message *mp)
ec= &ec_state;
ec->client= mp->m_source;
count = mp->DL_COUNT;
count = mp->m_net_netdrv_dl_readv_s.count;
r = sys_safecopyfrom(mp->m_source, mp->DL_GRANT, 0,
r = sys_safecopyfrom(mp->m_source, mp->m_net_netdrv_dl_readv_s.grant, 0,
(vir_bytes)ec->read_iovec.iod_iovec,
(count > IOVEC_NR ? IOVEC_NR : count) *
sizeof(iovec_s_t));
@ -1016,7 +1016,7 @@ static void do_vread_s(const message *mp)
panic("do_vread_s: sys_safecopyfrom failed: %d", r);
ec->read_iovec.iod_iovec_s = count;
ec->read_iovec.iod_proc_nr = mp->m_source;
ec->read_iovec.iod_grant = (cp_grant_id_t) mp->DL_GRANT;
ec->read_iovec.iod_grant = mp->m_net_netdrv_dl_readv_s.grant;
ec->read_iovec.iod_iovec_offset = 0;
ec->tmp_iovec = ec->read_iovec;
@ -1114,7 +1114,7 @@ int from_int;
ec = &ec_state;
ec->client= mp->m_source;
count = mp->DL_COUNT;
count = mp->m_net_netdrv_dl_writev_s.count;
if (isstored[tx_slot_nr]==1)
{
@ -1126,7 +1126,7 @@ int from_int;
}
/* convert the message to write_iovec */
r = sys_safecopyfrom(mp->m_source, mp->DL_GRANT, 0,
r = sys_safecopyfrom(mp->m_source, mp->m_net_netdrv_dl_writev_s.grant, 0,
(vir_bytes)ec->write_iovec.iod_iovec,
(count > IOVEC_NR ? IOVEC_NR : count) *
sizeof(iovec_s_t));
@ -1134,7 +1134,7 @@ int from_int;
panic("do_vwrite_s: sys_safecopyfrom failed: %d", r);
ec->write_iovec.iod_iovec_s = count;
ec->write_iovec.iod_proc_nr = mp->m_source;
ec->write_iovec.iod_grant = mp->DL_GRANT;
ec->write_iovec.iod_grant = mp->m_net_netdrv_dl_writev_s.grant;
ec->write_iovec.iod_iovec_offset = 0;
ec->tmp_iovec = ec->write_iovec;

View file

@ -1165,7 +1165,7 @@ static void or_writev_s (message * mp, int from_int) {
orp = &or_state;
count = mp->DL_COUNT;
count = mp->m_net_netdrv_dl_writev_s.count;
orp->or_client = mp->m_source;
hw = &(orp->hw);
@ -1210,7 +1210,8 @@ static void or_writev_s (message * mp, int from_int) {
if (i + n > count)
n = count - i;
cps = sys_safecopyfrom(mp->m_source, mp->DL_GRANT, iov_offset,
cps = sys_safecopyfrom(mp->m_source,
mp->m_net_netdrv_dl_writev_s.grant, iov_offset,
(vir_bytes) orp->or_iovec_s,
n * sizeof(orp->or_iovec_s[0]));
if (cps != OK)
@ -1563,7 +1564,7 @@ static void or_readv_s (message * mp, int from_int)
orp = &or_state;
orp->or_client = mp->m_source;
count = mp->DL_COUNT;
count = mp->m_net_netdrv_dl_readv_s.count;
assert (orp->or_mode == OR_M_ENABLED);
assert (orp->or_flags & OR_F_ENABLED);
@ -1601,7 +1602,8 @@ static void or_readv_s (message * mp, int from_int)
if (i + n > count)
n = count - i;
cps = sys_safecopyfrom(mp->m_source, mp->DL_GRANT, iov_offset,
cps = sys_safecopyfrom(mp->m_source,
mp->m_net_netdrv_dl_readv_s.grant, iov_offset,
(vir_bytes)orp->or_iovec_s,
n * sizeof(orp->or_iovec_s[0]));
if (cps != OK)

View file

@ -781,7 +781,7 @@ static void rl_readv_s(const message *mp, int from_int)
rep= &re_state;
rep->re_client= mp->m_source;
count = mp->DL_COUNT;
count = mp->m_net_netdrv_dl_readv_s.count;
if (rep->re_clear_rx)
goto suspend; /* Buffer overflow */
@ -871,7 +871,8 @@ static void rl_readv_s(const message *mp, int from_int)
if (i+n > count)
n= count-i;
cps = sys_safecopyfrom(mp->m_source, mp->DL_GRANT, iov_offset,
cps = sys_safecopyfrom(mp->m_source,
mp->m_net_netdrv_dl_readv_s.grant, iov_offset,
(vir_bytes) rep->re_iovec_s,
n * sizeof(rep->re_iovec_s[0]));
if (cps != OK) {
@ -1003,7 +1004,7 @@ static void rl_writev_s(const message *mp, int from_int)
rep= &re_state;
rep->re_client= mp->m_source;
count = mp->DL_COUNT;
count = mp->m_net_netdrv_dl_writev_s.count;
assert(rep->re_mode == REM_ENABLED);
assert(rep->re_flags & REF_ENABLED);
@ -1035,7 +1036,8 @@ static void rl_writev_s(const message *mp, int from_int)
n= IOVEC_NR;
if (i+n > count)
n= count-i;
cps = sys_safecopyfrom(mp->m_source, mp->DL_GRANT, iov_offset,
cps = sys_safecopyfrom(mp->m_source,
mp->m_net_netdrv_dl_writev_s.grant, iov_offset,
(vir_bytes) rep->re_iovec_s,
n * sizeof(rep->re_iovec_s[0]));
if (cps != OK) {

View file

@ -1168,7 +1168,7 @@ static void rl_readv_s(const message *mp, int from_int)
rep = &re_state;
rep->re_client = mp->m_source;
count = mp->DL_COUNT;
count = mp->m_net_netdrv_dl_readv_s.count;
assert(rep->re_mode == REM_ENABLED);
assert(rep->re_flags & REF_ENABLED);
@ -1228,7 +1228,8 @@ readvs_loop:
n = IOVEC_NR;
if (i + n > count)
n = count-i;
cps = sys_safecopyfrom(mp->m_source, mp->DL_GRANT, iov_offset,
cps = sys_safecopyfrom(mp->m_source,
mp->m_net_netdrv_dl_readv_s.grant, iov_offset,
(vir_bytes) rep->re_iovec_s,
n * sizeof(rep->re_iovec_s[0]));
if (cps != OK) {
@ -1307,7 +1308,7 @@ static void rl_writev_s(const message *mp, int from_int)
rep = &re_state;
rep->re_client = mp->m_source;
count = mp->DL_COUNT;
count = mp->m_net_netdrv_dl_writev_s.count;
assert(rep->setup);
assert(rep->re_mode == REM_ENABLED);
@ -1364,7 +1365,8 @@ static void rl_writev_s(const message *mp, int from_int)
n = IOVEC_NR;
if (i + n > count)
n = count - i;
cps = sys_safecopyfrom(mp->m_source, mp->DL_GRANT, iov_offset,
cps = sys_safecopyfrom(mp->m_source,
mp->m_net_netdrv_dl_writev_s.grant, iov_offset,
(vir_bytes) rep->re_iovec_s,
n * sizeof(rep->re_iovec_s[0]));
if (cps != OK) {

View file

@ -90,7 +90,8 @@ static void virtio_net_refill_rx_queue(void);
static void virtio_net_check_queues(void);
static void virtio_net_check_pending(void);
static void virtio_net_fetch_iovec(iovec_s_t *iov, message *m);
static void virtio_net_fetch_iovec(iovec_s_t *iov, message *m,
cp_grant_id_t grant, size_t count);
static int virtio_net_cpy_to_user(message *m);
static int virtio_net_cpy_from_user(message *m);
@ -318,11 +319,11 @@ virtio_net_check_pending(void)
}
static void
virtio_net_fetch_iovec(iovec_s_t *iov, message *m)
virtio_net_fetch_iovec(iovec_s_t *iov, message *m, cp_grant_id_t grant, size_t count)
{
int r;
r = sys_safecopyfrom(m->m_source, m->DL_GRANT, 0, (vir_bytes)iov,
m->DL_COUNT * sizeof(iov[0]));
r = sys_safecopyfrom(m->m_source, grant, 0, (vir_bytes)iov,
count * sizeof(iov[0]));
if (r != OK)
panic("%s: iovec fail for %d (%d)", name, m->m_source, r);
@ -344,9 +345,10 @@ virtio_net_cpy_to_user(message *m)
p = STAILQ_FIRST(&recv_list);
STAILQ_REMOVE_HEAD(&recv_list, next);
virtio_net_fetch_iovec(iovec, m);
virtio_net_fetch_iovec(iovec, m, m->m_net_netdrv_dl_readv_s.grant,
m->m_net_netdrv_dl_readv_s.count);
for (i = 0; i < m->DL_COUNT && left > 0; i++) {
for (i = 0; i < m->m_net_netdrv_dl_readv_s.count && left > 0; i++) {
ivsz = iovec[i].iov_size;
size = left > ivsz ? ivsz : left;
r = sys_safecopyto(m->m_source, iovec[i].iov_grant, 0,
@ -429,11 +431,12 @@ virtio_net_cpy_from_user(message *m)
p = STAILQ_FIRST(&free_list);
STAILQ_REMOVE_HEAD(&free_list, next);
virtio_net_fetch_iovec(iovec, m);
virtio_net_fetch_iovec(iovec, m, m->m_net_netdrv_dl_writev_s.grant,
m->m_net_netdrv_dl_writev_s.count);
r = sys_easy_vsafecopy_from(m->m_source, iovec, m->DL_COUNT,
(vir_bytes)p->vdata, MAX_PACK_SIZE,
&bytes);
r = sys_easy_vsafecopy_from(m->m_source, iovec,
m->m_net_netdrv_dl_writev_s.count, (vir_bytes)p->vdata,
MAX_PACK_SIZE, &bytes);
if (r != OK)
panic("%s: copy from %d failed", name, m->m_source);

View file

@ -178,10 +178,6 @@
#define DL_STAT_REPLY (DL_RS_BASE + 1)
#define DL_TASK_REPLY (DL_RS_BASE + 2)
/* Field names for data link layer messages. */
#define DL_COUNT m2_i3
#define DL_GRANT m2_l2
/* Bits in 'flags' field of DL replies. */
# define DL_NOFLAGS 0x00
# define DL_PACK_SEND 0x01

View file

@ -835,6 +835,22 @@ typedef struct {
} mess_net_netdrv_dl_getstat_s;
_ASSERT_MSG_SIZE(mess_net_netdrv_dl_getstat_s);
typedef struct {
cp_grant_id_t grant;
int count;
uint8_t padding[48];
} mess_net_netdrv_dl_readv_s;
_ASSERT_MSG_SIZE(mess_net_netdrv_dl_readv_s);
typedef struct {
cp_grant_id_t grant;
int count;
uint8_t padding[48];
} mess_net_netdrv_dl_writev_s;
_ASSERT_MSG_SIZE(mess_net_netdrv_dl_writev_s);
typedef struct {
int count;
uint32_t flags;
@ -1425,6 +1441,8 @@ typedef struct {
mess_net_netdrv_dl_conf m_net_netdrv_dl_conf;
mess_net_netdrv_dl_getstat_s m_net_netdrv_dl_getstat_s;
mess_net_netdrv_dl_readv_s m_net_netdrv_dl_readv_s;
mess_net_netdrv_dl_writev_s m_net_netdrv_dl_writev_s;
mess_netdrv_net_dl_conf m_netdrv_net_dl_conf;
mess_netdrv_net_dl_task m_netdrv_net_dl_task;

View file

@ -555,8 +555,8 @@ eth_port_t *eth_port;
errno));
}
m.m_type= DL_WRITEV_S;
m.DL_COUNT= i;
m.DL_GRANT= eth_port->etp_osdep.etp_wr_vec_grant;
m.m_net_netdrv_dl_writev_s.count= i;
m.m_net_netdrv_dl_writev_s.grant= eth_port->etp_osdep.etp_wr_vec_grant;
assert(eth_port->etp_osdep.etp_state == OEPS_IDLE);
r= asynsend(eth_port->etp_osdep.etp_task, &m);
@ -721,8 +721,8 @@ eth_port_t *eth_port;
}
mess.m_type= DL_READV_S;
mess.DL_COUNT= i;
mess.DL_GRANT= eth_port->etp_osdep.etp_rd_vec_grant;
mess.m_net_netdrv_dl_readv_s.count= i;
mess.m_net_netdrv_dl_readv_s.grant= eth_port->etp_osdep.etp_rd_vec_grant;
assert(eth_port->etp_osdep.etp_state == OEPS_IDLE);

View file

@ -147,8 +147,8 @@ static void driver_setup_read(struct nic * nic)
nic->rx_iovec[0].iov_size = nic->rx_pbuf->len;
m.m_type = DL_READV_S;
m.DL_COUNT = 1;
m.DL_GRANT = nic->rx_iogrant;
m.m_net_netdrv_dl_readv_s.count = 1;
m.m_net_netdrv_dl_readv_s.grant = nic->rx_iogrant;
if (asynsend(nic->drv_ep, &m) != OK)
panic("asynsend to the driver failed!");
@ -209,8 +209,8 @@ int driver_tx(struct nic * nic)
panic("Failed to set grant");
m.m_type = DL_WRITEV_S;
m.DL_COUNT = 1;
m.DL_GRANT = nic->tx_iogrant;
m.m_net_netdrv_dl_writev_s.count = 1;
m.m_net_netdrv_dl_writev_s.grant = nic->tx_iogrant;
if (asynsend(nic->drv_ep, &m) != OK)
panic("asynsend to the driver failed!");