2005-04-21 16:53:53 +02:00
|
|
|
/*
|
|
|
|
inet/mnx_eth.c
|
|
|
|
|
|
|
|
Created: Jan 2, 1992 by Philip Homburg
|
|
|
|
|
|
|
|
Copyright 1995 Philip Homburg
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "inet.h"
|
2006-07-10 14:55:33 +02:00
|
|
|
#include <minix/safecopies.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "proto.h"
|
|
|
|
#include "osdep_eth.h"
|
|
|
|
#include "generic/type.h"
|
|
|
|
|
|
|
|
#include "generic/assert.h"
|
|
|
|
#include "generic/buf.h"
|
|
|
|
#include "generic/clock.h"
|
|
|
|
#include "generic/eth.h"
|
|
|
|
#include "generic/eth_int.h"
|
|
|
|
#include "generic/sr.h"
|
|
|
|
|
|
|
|
THIS_FILE
|
|
|
|
|
|
|
|
FORWARD _PROTOTYPE( void setup_read, (eth_port_t *eth_port) );
|
|
|
|
FORWARD _PROTOTYPE( void read_int, (eth_port_t *eth_port, int count) );
|
2007-04-23 16:49:20 +02:00
|
|
|
FORWARD _PROTOTYPE( void eth_issue_send, (eth_port_t *eth_port) );
|
2005-04-21 16:53:53 +02:00
|
|
|
FORWARD _PROTOTYPE( void write_int, (eth_port_t *eth_port) );
|
2010-04-08 15:41:35 +02:00
|
|
|
FORWARD _PROTOTYPE( void eth_restart, (eth_port_t *eth_port,
|
|
|
|
endpoint_t endpoint) );
|
2007-04-23 16:49:20 +02:00
|
|
|
FORWARD _PROTOTYPE( void send_getstat, (eth_port_t *eth_port) );
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
PUBLIC void osdep_eth_init()
|
|
|
|
{
|
2010-05-18 00:22:53 +02:00
|
|
|
int i, j, rport;
|
2005-04-21 16:53:53 +02:00
|
|
|
struct eth_conf *ecp;
|
2005-06-28 17:19:58 +02:00
|
|
|
eth_port_t *eth_port, *rep;
|
2006-07-10 14:55:33 +02:00
|
|
|
cp_grant_id_t gid;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
/* First initialize normal ethernet interfaces */
|
|
|
|
for (i= 0, ecp= eth_conf, eth_port= eth_port_table;
|
|
|
|
i<eth_conf_nr; i++, ecp++, eth_port++)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2006-07-10 14:55:33 +02:00
|
|
|
/* Set all grants to invalid */
|
|
|
|
for (j= 0; j<IOVEC_NR; j++)
|
|
|
|
eth_port->etp_osdep.etp_wr_iovec[j].iov_grant= -1;
|
|
|
|
eth_port->etp_osdep.etp_wr_vec_grant= -1;
|
|
|
|
for (j= 0; j<RD_IOVEC; j++)
|
|
|
|
eth_port->etp_osdep.etp_rd_iovec[j].iov_grant= -1;
|
|
|
|
eth_port->etp_osdep.etp_rd_vec_grant= -1;
|
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
eth_port->etp_osdep.etp_state= OEPS_INIT;
|
|
|
|
eth_port->etp_osdep.etp_flags= OEPF_EMPTY;
|
|
|
|
eth_port->etp_osdep.etp_stat_gid= -1;
|
|
|
|
eth_port->etp_osdep.etp_stat_buf= NULL;
|
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
if (eth_is_vlan(ecp))
|
|
|
|
continue;
|
2006-07-10 14:55:33 +02:00
|
|
|
|
|
|
|
/* Allocate grants */
|
|
|
|
for (j= 0; j<IOVEC_NR; j++)
|
|
|
|
{
|
|
|
|
if (cpf_getgrants(&gid, 1) != 1)
|
|
|
|
{
|
|
|
|
ip_panic((
|
|
|
|
"osdep_eth_init: cpf_getgrants failed: %d\n",
|
|
|
|
errno));
|
|
|
|
}
|
|
|
|
eth_port->etp_osdep.etp_wr_iovec[j].iov_grant= gid;
|
|
|
|
}
|
|
|
|
if (cpf_getgrants(&gid, 1) != 1)
|
|
|
|
{
|
|
|
|
ip_panic((
|
|
|
|
"osdep_eth_init: cpf_getgrants failed: %d\n",
|
|
|
|
errno));
|
|
|
|
}
|
|
|
|
eth_port->etp_osdep.etp_wr_vec_grant= gid;
|
|
|
|
for (j= 0; j<RD_IOVEC; j++)
|
|
|
|
{
|
|
|
|
if (cpf_getgrants(&gid, 1) != 1)
|
|
|
|
{
|
|
|
|
ip_panic((
|
|
|
|
"osdep_eth_init: cpf_getgrants failed: %d\n",
|
|
|
|
errno));
|
|
|
|
}
|
|
|
|
eth_port->etp_osdep.etp_rd_iovec[j].iov_grant= gid;
|
|
|
|
}
|
|
|
|
if (cpf_getgrants(&gid, 1) != 1)
|
|
|
|
{
|
|
|
|
ip_panic((
|
|
|
|
"osdep_eth_init: cpf_getgrants failed: %d\n",
|
|
|
|
errno));
|
|
|
|
}
|
|
|
|
eth_port->etp_osdep.etp_rd_vec_grant= gid;
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
eth_port->etp_osdep.etp_task= NONE;
|
2009-11-28 14:28:55 +01:00
|
|
|
eth_port->etp_osdep.etp_recvconf= 0;
|
2005-04-21 16:53:53 +02:00
|
|
|
ev_init(ð_port->etp_osdep.etp_recvev);
|
|
|
|
|
|
|
|
sr_add_minor(if2minor(ecp->ec_ifno, ETH_DEV_OFF),
|
|
|
|
i, eth_open, eth_close, eth_read,
|
2005-06-28 17:19:58 +02:00
|
|
|
eth_write, eth_ioctl, eth_cancel, eth_select);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
eth_port->etp_flags |= EPF_ENABLED;
|
2005-06-28 17:19:58 +02:00
|
|
|
eth_port->etp_vlan= 0;
|
|
|
|
eth_port->etp_vlan_port= NULL;
|
2005-04-21 16:53:53 +02:00
|
|
|
eth_port->etp_wr_pack= 0;
|
|
|
|
eth_port->etp_rd_pack= 0;
|
2005-06-28 17:19:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* And now come the VLANs */
|
|
|
|
for (i= 0, ecp= eth_conf, eth_port= eth_port_table;
|
|
|
|
i<eth_conf_nr; i++, ecp++, eth_port++)
|
|
|
|
{
|
|
|
|
if (!eth_is_vlan(ecp))
|
|
|
|
continue;
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
eth_port->etp_osdep.etp_task= NONE;
|
2005-06-28 17:19:58 +02:00
|
|
|
ev_init(ð_port->etp_osdep.etp_recvev);
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
rport= ecp->ec_port;
|
2005-06-28 17:19:58 +02:00
|
|
|
assert(rport >= 0 && rport < eth_conf_nr);
|
|
|
|
rep= ð_port_table[rport];
|
2005-07-05 13:08:15 +02:00
|
|
|
if (!(rep->etp_flags & EPF_ENABLED))
|
2005-06-28 17:19:58 +02:00
|
|
|
{
|
|
|
|
printf(
|
|
|
|
"eth%d: underlying ethernet device %d not enabled",
|
|
|
|
i, rport);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (rep->etp_vlan != 0)
|
|
|
|
{
|
|
|
|
printf(
|
|
|
|
"eth%d: underlying ethernet device %d is a VLAN",
|
|
|
|
i, rport);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-12-09 14:25:30 +01:00
|
|
|
if (rep->etp_flags & EPF_GOT_ADDR)
|
|
|
|
{
|
|
|
|
eth_port->etp_ethaddr= rep->etp_ethaddr;
|
2007-04-23 16:49:20 +02:00
|
|
|
printf("osdep_eth_init: setting EPF_GOT_ADDR\n");
|
2005-12-09 14:25:30 +01:00
|
|
|
eth_port->etp_flags |= EPF_GOT_ADDR;
|
|
|
|
}
|
2005-06-28 17:19:58 +02:00
|
|
|
|
|
|
|
sr_add_minor(if2minor(ecp->ec_ifno, ETH_DEV_OFF),
|
|
|
|
i, eth_open, eth_close, eth_read,
|
|
|
|
eth_write, eth_ioctl, eth_cancel, eth_select);
|
|
|
|
|
|
|
|
eth_port->etp_flags |= EPF_ENABLED;
|
|
|
|
eth_port->etp_vlan= ecp->ec_vlan;
|
|
|
|
eth_port->etp_vlan_port= rep;
|
|
|
|
assert(eth_port->etp_vlan != 0);
|
|
|
|
eth_port->etp_wr_pack= 0;
|
|
|
|
eth_port->etp_rd_pack= 0;
|
|
|
|
eth_reg_vlan(rep, eth_port);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PUBLIC void eth_write_port(eth_port, pack)
|
|
|
|
eth_port_t *eth_port;
|
|
|
|
acc_t *pack;
|
|
|
|
{
|
2005-06-28 17:19:58 +02:00
|
|
|
assert(!no_ethWritePort);
|
|
|
|
assert(!eth_port->etp_vlan);
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
assert(eth_port->etp_wr_pack == NULL);
|
|
|
|
eth_port->etp_wr_pack= pack;
|
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
if (eth_port->etp_osdep.etp_state != OEPS_IDLE)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
eth_port->etp_osdep.etp_flags |= OEPF_NEED_SEND;
|
|
|
|
return;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
eth_issue_send(eth_port);
|
|
|
|
}
|
|
|
|
|
2010-01-14 14:53:12 +01:00
|
|
|
PUBLIC void eth_rec(message *m)
|
2007-04-23 16:49:20 +02:00
|
|
|
{
|
2010-05-18 00:22:53 +02:00
|
|
|
int i, r, m_type, flags;
|
2007-04-23 16:49:20 +02:00
|
|
|
eth_port_t *loc_port, *vlan_port;
|
|
|
|
|
|
|
|
m_type= m->m_type;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
assert(m_type == DL_CONF_REPLY || m_type == DL_TASK_REPLY ||
|
|
|
|
m_type == DL_STAT_REPLY);
|
2006-07-10 14:55:33 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
for (i=0, loc_port= eth_port_table; i<eth_conf_nr; i++, loc_port++)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2010-05-18 00:22:53 +02:00
|
|
|
if (loc_port->etp_osdep.etp_task == m->m_source)
|
2007-04-23 16:49:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i >= eth_conf_nr)
|
|
|
|
{
|
2010-05-18 00:22:53 +02:00
|
|
|
printf("eth_rec: message 0x%x from unknown driver %d\n",
|
|
|
|
m_type, m->m_source);
|
2007-04-23 16:49:20 +02:00
|
|
|
return;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
if (loc_port->etp_osdep.etp_state == OEPS_CONF_SENT)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
if (m_type == DL_TASK_REPLY)
|
|
|
|
{
|
2010-05-18 00:22:53 +02:00
|
|
|
flags= m->DL_FLAGS;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
if (flags & DL_PACK_SEND)
|
2007-04-23 16:49:20 +02:00
|
|
|
write_int(loc_port);
|
2010-05-18 00:22:53 +02:00
|
|
|
if (flags & DL_PACK_RECV)
|
2007-04-23 16:49:20 +02:00
|
|
|
read_int(loc_port, m->DL_COUNT);
|
|
|
|
return;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
if (m_type != DL_CONF_REPLY)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
printf(
|
|
|
|
"eth_rec: got bad message type 0x%x from %d in CONF state\n",
|
|
|
|
m_type, m->m_source);
|
|
|
|
return;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
r= m->DL_STAT;
|
2007-04-23 16:49:20 +02:00
|
|
|
if (r < 0)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2010-05-18 00:22:53 +02:00
|
|
|
ip_warning(("eth_rec: DL_CONF returned error %d\n",
|
|
|
|
r));
|
|
|
|
|
|
|
|
/* Just leave it in limbo. Nothing more we can do. */
|
2007-04-23 16:49:20 +02:00
|
|
|
return;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
|
|
|
|
loc_port->etp_osdep.etp_flags &= ~OEPF_NEED_CONF;
|
|
|
|
loc_port->etp_osdep.etp_state= OEPS_IDLE;
|
|
|
|
loc_port->etp_flags |= EPF_ENABLED;
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
loc_port->etp_ethaddr= *(ether_addr_t *)m->DL_HWADDR;
|
2007-04-23 16:49:20 +02:00
|
|
|
if (!(loc_port->etp_flags & EPF_GOT_ADDR))
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
loc_port->etp_flags |= EPF_GOT_ADDR;
|
2008-11-19 13:26:10 +01:00
|
|
|
#if 0
|
2007-04-23 16:49:20 +02:00
|
|
|
printf("eth_rec: calling eth_restart_ioctl\n");
|
2008-11-19 13:26:10 +01:00
|
|
|
#endif
|
2007-04-23 16:49:20 +02:00
|
|
|
eth_restart_ioctl(loc_port);
|
|
|
|
|
|
|
|
/* Also update any VLANs on this device */
|
|
|
|
for (i=0, vlan_port= eth_port_table; i<eth_conf_nr;
|
|
|
|
i++, vlan_port++)
|
2005-06-28 17:19:58 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
if (!(vlan_port->etp_flags & EPF_ENABLED))
|
|
|
|
continue;
|
|
|
|
if (vlan_port->etp_vlan_port != loc_port)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
vlan_port->etp_ethaddr= loc_port->etp_ethaddr;
|
|
|
|
vlan_port->etp_flags |= EPF_GOT_ADDR;
|
|
|
|
eth_restart_ioctl(vlan_port);
|
2005-06-28 17:19:58 +02:00
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
if (!(loc_port->etp_flags & EPF_READ_IP))
|
|
|
|
setup_read (loc_port);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
#if 0
|
2007-04-23 16:49:20 +02:00
|
|
|
if (loc_port->etp_osdep.etp_flags & OEPF_NEED_SEND)
|
|
|
|
{
|
|
|
|
printf("eth_rec(conf): OEPF_NEED_SEND is set\n");
|
|
|
|
}
|
|
|
|
if (loc_port->etp_osdep.etp_flags & OEPF_NEED_RECV)
|
|
|
|
{
|
|
|
|
printf("eth_rec(conf): OEPF_NEED_RECV is set\n");
|
|
|
|
}
|
|
|
|
if (loc_port->etp_osdep.etp_flags & OEPF_NEED_STAT)
|
|
|
|
{
|
|
|
|
printf("eth_rec(conf): OEPF_NEED_STAT is set\n");
|
|
|
|
}
|
2008-11-19 13:26:10 +01:00
|
|
|
#endif
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2006-08-28 14:59:36 +02:00
|
|
|
return;
|
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
if (loc_port->etp_osdep.etp_state == OEPS_GETSTAT_SENT)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
if (m_type != DL_STAT_REPLY)
|
2005-06-28 17:19:58 +02:00
|
|
|
{
|
|
|
|
printf(
|
2007-04-23 16:49:20 +02:00
|
|
|
"eth_rec: got bad message type 0x%x from %d in GETSTAT state\n",
|
|
|
|
m_type, m->m_source);
|
|
|
|
return;
|
2005-06-28 17:19:58 +02:00
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
loc_port->etp_osdep.etp_state= OEPS_IDLE;
|
|
|
|
loc_port->etp_osdep.etp_flags &= ~OEPF_NEED_STAT;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
assert(loc_port->etp_osdep.etp_stat_gid != -1);
|
|
|
|
cpf_revoke(loc_port->etp_osdep.etp_stat_gid);
|
|
|
|
loc_port->etp_osdep.etp_stat_gid= -1;
|
|
|
|
loc_port->etp_osdep.etp_stat_buf= NULL;
|
|
|
|
|
|
|
|
/* Finish ioctl */
|
|
|
|
assert(loc_port->etp_flags & EPF_GOT_ADDR);
|
|
|
|
eth_restart_ioctl(loc_port);
|
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
#if 0
|
2007-04-23 16:49:20 +02:00
|
|
|
if (loc_port->etp_osdep.etp_flags & OEPF_NEED_SEND)
|
|
|
|
{
|
|
|
|
printf("eth_rec(stat): OEPF_NEED_SEND is set\n");
|
|
|
|
}
|
|
|
|
if (loc_port->etp_osdep.etp_flags & OEPF_NEED_RECV)
|
|
|
|
{
|
|
|
|
printf("eth_rec(stat): OEPF_NEED_RECV is set\n");
|
|
|
|
}
|
|
|
|
if (loc_port->etp_osdep.etp_flags & OEPF_NEED_CONF)
|
|
|
|
{
|
|
|
|
printf("eth_rec(stat): OEPF_NEED_CONF is set\n");
|
|
|
|
}
|
2008-11-19 13:26:10 +01:00
|
|
|
#endif
|
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
#if 0
|
|
|
|
if (loc_port->etp_osdep.etp_state == OEPS_IDLE &&
|
|
|
|
(loc_port->etp_osdep.etp_flags & OEPF_NEED_CONF))
|
|
|
|
{
|
|
|
|
eth_set_rec_conf(loc_port,
|
|
|
|
loc_port->etp_osdep.etp_recvconf);
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-21 16:53:53 +02:00
|
|
|
return;
|
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
assert(loc_port->etp_osdep.etp_state == OEPS_IDLE ||
|
|
|
|
loc_port->etp_osdep.etp_state == OEPS_RECV_SENT ||
|
|
|
|
loc_port->etp_osdep.etp_state == OEPS_SEND_SENT ||
|
|
|
|
(printf("etp_state = %d\n", loc_port->etp_osdep.etp_state), 0));
|
|
|
|
loc_port->etp_osdep.etp_state= OEPS_IDLE;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
flags= m->DL_FLAGS;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
if (flags & DL_PACK_SEND)
|
2005-04-21 16:53:53 +02:00
|
|
|
write_int(loc_port);
|
2010-05-18 00:22:53 +02:00
|
|
|
if (flags & DL_PACK_RECV)
|
2005-04-21 16:53:53 +02:00
|
|
|
read_int(loc_port, m->DL_COUNT);
|
2007-04-23 16:49:20 +02:00
|
|
|
|
|
|
|
if (loc_port->etp_osdep.etp_state == OEPS_IDLE &&
|
|
|
|
loc_port->etp_osdep.etp_flags & OEPF_NEED_SEND)
|
|
|
|
{
|
|
|
|
loc_port->etp_osdep.etp_flags &= ~OEPF_NEED_SEND;
|
|
|
|
if (loc_port->etp_wr_pack)
|
|
|
|
eth_issue_send(loc_port);
|
|
|
|
}
|
|
|
|
if (loc_port->etp_osdep.etp_state == OEPS_IDLE &&
|
|
|
|
(loc_port->etp_osdep.etp_flags & OEPF_NEED_RECV))
|
|
|
|
{
|
|
|
|
loc_port->etp_osdep.etp_flags &= ~OEPF_NEED_RECV;
|
|
|
|
if (!(loc_port->etp_flags & EPF_READ_IP))
|
|
|
|
setup_read (loc_port);
|
|
|
|
}
|
|
|
|
if (loc_port->etp_osdep.etp_flags & OEPF_NEED_CONF)
|
|
|
|
{
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
#if 0
|
2007-04-23 16:49:20 +02:00
|
|
|
printf("eth_rec: OEPF_NEED_CONF is set\n");
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
#endif
|
2007-04-23 16:49:20 +02:00
|
|
|
}
|
|
|
|
if (loc_port->etp_osdep.etp_state == OEPS_IDLE &&
|
|
|
|
(loc_port->etp_osdep.etp_flags & OEPF_NEED_STAT))
|
|
|
|
{
|
|
|
|
send_getstat(loc_port);
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
PUBLIC void eth_check_driver(char *label, endpoint_t endpoint)
|
2005-10-21 13:51:45 +02:00
|
|
|
{
|
2010-05-18 00:22:53 +02:00
|
|
|
int i;
|
|
|
|
eth_port_t *loc_port;
|
|
|
|
struct eth_conf *ecp;
|
2010-04-08 15:41:35 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
/* Re-init ethernet interface */
|
|
|
|
for (i= 0, ecp= eth_conf, loc_port= eth_port_table;
|
|
|
|
i<eth_conf_nr; i++, ecp++, loc_port++)
|
2005-10-21 13:51:45 +02:00
|
|
|
{
|
2010-05-18 00:22:53 +02:00
|
|
|
if (eth_is_vlan(ecp))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strcmp(ecp->ec_label, label) != 0)
|
|
|
|
{
|
|
|
|
/* Wrong driver */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
eth_restart(loc_port, endpoint);
|
2005-10-21 13:51:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
PUBLIC int eth_get_stat(eth_port, eth_stat)
|
|
|
|
eth_port_t *eth_port;
|
|
|
|
eth_stat_t *eth_stat;
|
|
|
|
{
|
2006-07-10 14:55:33 +02:00
|
|
|
cp_grant_id_t gid;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
assert(!eth_port->etp_vlan);
|
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
if (eth_port->etp_osdep.etp_flags & OEPF_NEED_STAT)
|
|
|
|
ip_panic(( "eth_get_stat: getstat already in progress" ));
|
|
|
|
|
2006-07-10 14:55:33 +02:00
|
|
|
gid= cpf_grant_direct(eth_port->etp_osdep.etp_task,
|
|
|
|
(vir_bytes)eth_stat, sizeof(*eth_stat), CPF_WRITE);
|
|
|
|
if (gid == -1)
|
|
|
|
{
|
|
|
|
ip_panic(( "eth_get_stat: cpf_grant_direct failed: %d\n",
|
|
|
|
errno));
|
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
assert(eth_port->etp_osdep.etp_stat_gid == -1);
|
|
|
|
eth_port->etp_osdep.etp_stat_gid= gid;
|
|
|
|
eth_port->etp_osdep.etp_stat_buf= eth_stat;
|
2006-07-10 14:55:33 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
if (eth_port->etp_osdep.etp_state != OEPS_IDLE)
|
2005-10-21 18:51:21 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
eth_port->etp_osdep.etp_flags |= OEPF_NEED_STAT;
|
|
|
|
return SUSPEND;
|
2005-10-21 18:51:21 +02:00
|
|
|
}
|
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
send_getstat(eth_port);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
return SUSPEND;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PUBLIC void eth_set_rec_conf (eth_port, flags)
|
|
|
|
eth_port_t *eth_port;
|
|
|
|
u32_t flags;
|
|
|
|
{
|
2005-10-21 18:51:21 +02:00
|
|
|
int r;
|
2009-11-28 14:28:55 +01:00
|
|
|
unsigned dl_flags, mask;
|
2010-01-14 14:53:12 +01:00
|
|
|
message mess;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
assert(!eth_port->etp_vlan);
|
|
|
|
|
2005-12-09 14:25:30 +01:00
|
|
|
if (!(eth_port->etp_flags & EPF_GOT_ADDR))
|
|
|
|
{
|
|
|
|
/* We have never seen the device. */
|
2008-11-19 13:26:10 +01:00
|
|
|
#if 0
|
2005-12-09 14:25:30 +01:00
|
|
|
printf("eth_set_rec_conf: waiting for device to appear\n");
|
2008-11-19 13:26:10 +01:00
|
|
|
#endif
|
2005-12-09 14:25:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
if (eth_port->etp_osdep.etp_state != OEPS_IDLE)
|
|
|
|
{
|
|
|
|
printf(
|
|
|
|
"eth_set_rec_conf: setting OEPF_NEED_CONF, state = %d\n",
|
|
|
|
eth_port->etp_osdep.etp_state);
|
|
|
|
eth_port->etp_osdep.etp_flags |= OEPF_NEED_CONF;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-28 14:28:55 +01:00
|
|
|
mask = NWEO_EN_BROAD | NWEO_EN_MULTI | NWEO_EN_PROMISC;
|
|
|
|
if ((eth_port->etp_osdep.etp_recvconf & mask) == (flags & mask))
|
|
|
|
{
|
|
|
|
/* No change for the driver, so don't send an update */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-10-21 18:51:21 +02:00
|
|
|
eth_port->etp_osdep.etp_recvconf= flags;
|
2005-04-21 16:53:53 +02:00
|
|
|
dl_flags= DL_NOMODE;
|
|
|
|
if (flags & NWEO_EN_BROAD)
|
|
|
|
dl_flags |= DL_BROAD_REQ;
|
|
|
|
if (flags & NWEO_EN_MULTI)
|
|
|
|
dl_flags |= DL_MULTI_REQ;
|
|
|
|
if (flags & NWEO_EN_PROMISC)
|
|
|
|
dl_flags |= DL_PROMISC_REQ;
|
|
|
|
|
2006-07-10 14:55:33 +02:00
|
|
|
mess.m_type= DL_CONF;
|
2005-04-21 16:53:53 +02:00
|
|
|
mess.DL_MODE= dl_flags;
|
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
assert(eth_port->etp_osdep.etp_state == OEPS_IDLE);
|
|
|
|
r= asynsend(eth_port->etp_osdep.etp_task, &mess);
|
|
|
|
eth_port->etp_osdep.etp_state= OEPS_CONF_SENT;
|
|
|
|
|
|
|
|
if (r < 0)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
printf("eth_set_rec_conf: asynsend to %d failed: %d\n",
|
|
|
|
eth_port->etp_osdep.etp_task, r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void eth_issue_send(eth_port)
|
|
|
|
eth_port_t *eth_port;
|
|
|
|
{
|
|
|
|
int i, r, pack_size;
|
|
|
|
acc_t *pack, *pack_ptr;
|
|
|
|
iovec_s_t *iovec;
|
|
|
|
message m;
|
|
|
|
|
|
|
|
iovec= eth_port->etp_osdep.etp_wr_iovec;
|
|
|
|
pack= eth_port->etp_wr_pack;
|
|
|
|
pack_size= 0;
|
|
|
|
for (i=0, pack_ptr= pack; i<IOVEC_NR && pack_ptr; i++,
|
|
|
|
pack_ptr= pack_ptr->acc_next)
|
|
|
|
{
|
|
|
|
r= cpf_setgrant_direct(iovec[i].iov_grant,
|
|
|
|
eth_port->etp_osdep.etp_task,
|
|
|
|
(vir_bytes)ptr2acc_data(pack_ptr),
|
|
|
|
(vir_bytes)pack_ptr->acc_length,
|
|
|
|
CPF_READ);
|
|
|
|
if (r != 0)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
ip_panic((
|
|
|
|
"eth_write_port: cpf_setgrant_direct failed: %d\n",
|
|
|
|
errno));
|
|
|
|
}
|
|
|
|
pack_size += iovec[i].iov_size= pack_ptr->acc_length;
|
|
|
|
}
|
|
|
|
if (i>= IOVEC_NR)
|
|
|
|
{
|
|
|
|
pack= bf_pack(pack); /* packet is too fragmented */
|
|
|
|
eth_port->etp_wr_pack= pack;
|
|
|
|
pack_size= 0;
|
|
|
|
for (i=0, pack_ptr= pack; i<IOVEC_NR && pack_ptr;
|
|
|
|
i++, pack_ptr= pack_ptr->acc_next)
|
|
|
|
{
|
|
|
|
r= cpf_setgrant_direct(iovec[i].iov_grant,
|
|
|
|
eth_port->etp_osdep.etp_task,
|
|
|
|
(vir_bytes)ptr2acc_data(pack_ptr),
|
|
|
|
(vir_bytes)pack_ptr->acc_length,
|
|
|
|
CPF_READ);
|
|
|
|
if (r != 0)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
ip_panic((
|
|
|
|
"eth_write_port: cpf_setgrant_direct failed: %d\n",
|
|
|
|
errno));
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
pack_size += iovec[i].iov_size= pack_ptr->acc_length;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
}
|
|
|
|
assert (i< IOVEC_NR);
|
|
|
|
assert (pack_size >= ETH_MIN_PACK_SIZE);
|
|
|
|
|
|
|
|
r= cpf_setgrant_direct(eth_port->etp_osdep.etp_wr_vec_grant,
|
|
|
|
eth_port->etp_osdep.etp_task,
|
|
|
|
(vir_bytes)iovec,
|
|
|
|
(vir_bytes)(i * sizeof(iovec[0])),
|
|
|
|
CPF_READ);
|
|
|
|
if (r != 0)
|
2005-10-21 18:51:21 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
ip_panic((
|
|
|
|
"eth_write_port: cpf_setgrant_direct failed: %d\n",
|
|
|
|
errno));
|
2005-10-21 18:51:21 +02:00
|
|
|
}
|
2010-05-18 00:22:53 +02:00
|
|
|
m.m_type= DL_WRITEV_S;
|
|
|
|
m.DL_ENDPT= this_proc;
|
2007-04-23 16:49:20 +02:00
|
|
|
m.DL_COUNT= i;
|
|
|
|
m.DL_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);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
if (r < 0)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
printf("eth_issue_send: send to %d failed: %d\n",
|
|
|
|
eth_port->etp_osdep.etp_task, r);
|
|
|
|
return;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
eth_port->etp_osdep.etp_state= OEPS_SEND_SENT;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
2010-03-30 16:07:15 +02:00
|
|
|
PRIVATE void write_int(eth_port_t *eth_port)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
acc_t *pack;
|
|
|
|
int multicast;
|
|
|
|
u8_t *eth_dst_ptr;
|
|
|
|
|
|
|
|
pack= eth_port->etp_wr_pack;
|
2006-08-28 14:59:36 +02:00
|
|
|
if (pack == NULL)
|
|
|
|
{
|
|
|
|
printf("write_int: strange no packet on eth port %d\n",
|
2010-05-18 00:22:53 +02:00
|
|
|
(int)(eth_port-eth_port_table));
|
2006-08-28 14:59:36 +02:00
|
|
|
eth_restart_write(eth_port);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
eth_port->etp_wr_pack= NULL;
|
|
|
|
|
|
|
|
eth_dst_ptr= (u8_t *)ptr2acc_data(pack);
|
|
|
|
multicast= (*eth_dst_ptr & 1); /* low order bit indicates multicast */
|
|
|
|
if (multicast || (eth_port->etp_osdep.etp_recvconf & NWEO_EN_PROMISC))
|
2005-06-28 17:19:58 +02:00
|
|
|
{
|
|
|
|
assert(!no_ethWritePort);
|
|
|
|
no_ethWritePort= 1;
|
2005-04-21 16:53:53 +02:00
|
|
|
eth_arrive(eth_port, pack, bf_bufsize(pack));
|
2005-06-28 17:19:58 +02:00
|
|
|
assert(no_ethWritePort);
|
|
|
|
no_ethWritePort= 0;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
else
|
|
|
|
bf_afree(pack);
|
|
|
|
|
|
|
|
eth_restart_write(eth_port);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void read_int(eth_port, count)
|
|
|
|
eth_port_t *eth_port;
|
|
|
|
int count;
|
|
|
|
{
|
|
|
|
acc_t *pack, *cut_pack;
|
|
|
|
|
|
|
|
pack= eth_port->etp_rd_pack;
|
|
|
|
eth_port->etp_rd_pack= NULL;
|
|
|
|
|
2006-08-28 14:59:36 +02:00
|
|
|
if (count < ETH_MIN_PACK_SIZE)
|
|
|
|
{
|
|
|
|
printf("mnx_eth`read_int: packet size too small (%d)\n",
|
|
|
|
count);
|
|
|
|
bf_afree(pack);
|
|
|
|
}
|
|
|
|
else if (count > ETH_MAX_PACK_SIZE_TAGGED)
|
|
|
|
{
|
|
|
|
printf("mnx_eth`read_int: packet size too big (%d)\n",
|
|
|
|
count);
|
|
|
|
bf_afree(pack);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cut_pack= bf_cut(pack, 0, count);
|
|
|
|
bf_afree(pack);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2006-08-28 14:59:36 +02:00
|
|
|
assert(!no_ethWritePort);
|
|
|
|
no_ethWritePort= 1;
|
|
|
|
eth_arrive(eth_port, cut_pack, count);
|
|
|
|
assert(no_ethWritePort);
|
|
|
|
no_ethWritePort= 0;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
eth_port->etp_flags &= ~(EPF_READ_IP|EPF_READ_SP);
|
|
|
|
setup_read(eth_port);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void setup_read(eth_port)
|
|
|
|
eth_port_t *eth_port;
|
|
|
|
{
|
|
|
|
acc_t *pack, *pack_ptr;
|
2010-05-18 00:22:53 +02:00
|
|
|
message mess;
|
2006-07-10 14:55:33 +02:00
|
|
|
iovec_s_t *iovec;
|
2005-04-21 16:53:53 +02:00
|
|
|
int i, r;
|
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
assert(!eth_port->etp_vlan);
|
2005-04-21 16:53:53 +02:00
|
|
|
assert(!(eth_port->etp_flags & (EPF_READ_IP|EPF_READ_SP)));
|
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
if (eth_port->etp_osdep.etp_state != OEPS_IDLE)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2007-04-23 16:49:20 +02:00
|
|
|
eth_port->etp_osdep.etp_flags |= OEPF_NEED_RECV;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
return;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
assert (!eth_port->etp_rd_pack);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
iovec= eth_port->etp_osdep.etp_rd_iovec;
|
|
|
|
pack= bf_memreq (ETH_MAX_PACK_SIZE_TAGGED);
|
|
|
|
|
|
|
|
for (i=0, pack_ptr= pack; i<RD_IOVEC && pack_ptr;
|
|
|
|
i++, pack_ptr= pack_ptr->acc_next)
|
|
|
|
{
|
|
|
|
r= cpf_setgrant_direct(iovec[i].iov_grant,
|
2006-07-10 14:55:33 +02:00
|
|
|
eth_port->etp_osdep.etp_task,
|
2007-04-23 16:49:20 +02:00
|
|
|
(vir_bytes)ptr2acc_data(pack_ptr),
|
|
|
|
(vir_bytes)pack_ptr->acc_length,
|
|
|
|
CPF_WRITE);
|
2006-07-10 14:55:33 +02:00
|
|
|
if (r != 0)
|
|
|
|
{
|
|
|
|
ip_panic((
|
|
|
|
"mnx_eth`setup_read: cpf_setgrant_direct failed: %d\n",
|
|
|
|
errno));
|
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
iovec[i].iov_size= (vir_bytes)pack_ptr->acc_length;
|
|
|
|
}
|
|
|
|
assert (!pack_ptr);
|
2006-07-10 14:55:33 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
r= cpf_setgrant_direct(eth_port->etp_osdep.etp_rd_vec_grant,
|
|
|
|
eth_port->etp_osdep.etp_task,
|
|
|
|
(vir_bytes)iovec,
|
|
|
|
(vir_bytes)(i * sizeof(iovec[0])),
|
|
|
|
CPF_READ);
|
|
|
|
if (r != 0)
|
|
|
|
{
|
|
|
|
ip_panic((
|
|
|
|
"mnx_eth`setup_read: cpf_setgrant_direct failed: %d\n",
|
|
|
|
errno));
|
|
|
|
}
|
2006-08-28 14:59:36 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
mess.m_type= DL_READV_S;
|
|
|
|
mess.DL_ENDPT= this_proc;
|
|
|
|
mess.DL_COUNT= i;
|
|
|
|
mess.DL_GRANT= eth_port->etp_osdep.etp_rd_vec_grant;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
assert(eth_port->etp_osdep.etp_state == OEPS_IDLE);
|
2006-08-28 14:59:36 +02:00
|
|
|
|
2010-05-18 00:22:53 +02:00
|
|
|
r= asynsend(eth_port->etp_osdep.etp_task, &mess);
|
2007-04-23 16:49:20 +02:00
|
|
|
eth_port->etp_osdep.etp_state= OEPS_RECV_SENT;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
if (r < 0)
|
|
|
|
{
|
|
|
|
printf(
|
|
|
|
"mnx_eth`setup_read: asynsend to %d failed: %d\n",
|
|
|
|
eth_port->etp_osdep.etp_task, r);
|
|
|
|
}
|
|
|
|
eth_port->etp_rd_pack= pack;
|
|
|
|
eth_port->etp_flags |= EPF_READ_IP;
|
2005-04-21 16:53:53 +02:00
|
|
|
eth_port->etp_flags |= EPF_READ_SP;
|
|
|
|
}
|
|
|
|
|
2010-04-08 15:41:35 +02:00
|
|
|
static void eth_restart(eth_port_t *eth_port, endpoint_t endpoint)
|
2005-10-21 13:51:45 +02:00
|
|
|
{
|
2010-01-14 14:53:12 +01:00
|
|
|
int r;
|
2005-10-21 18:51:21 +02:00
|
|
|
unsigned flags, dl_flags;
|
2007-04-23 16:49:20 +02:00
|
|
|
cp_grant_id_t gid;
|
2005-10-21 13:51:45 +02:00
|
|
|
message mess;
|
|
|
|
|
2010-04-08 15:41:35 +02:00
|
|
|
eth_port->etp_osdep.etp_task= endpoint;
|
2005-10-21 13:51:45 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
switch(eth_port->etp_osdep.etp_state)
|
|
|
|
{
|
2009-10-01 23:24:12 +02:00
|
|
|
case OEPS_INIT:
|
2007-04-23 16:49:20 +02:00
|
|
|
case OEPS_CONF_SENT:
|
|
|
|
case OEPS_RECV_SENT:
|
|
|
|
case OEPS_SEND_SENT:
|
|
|
|
/* We can safely ignore the pending CONF, RECV, and SEND
|
2009-10-01 23:24:12 +02:00
|
|
|
* requests. If this is the first time that we see this
|
|
|
|
* driver at all, that's fine too.
|
2007-04-23 16:49:20 +02:00
|
|
|
*/
|
|
|
|
eth_port->etp_osdep.etp_state= OEPS_IDLE;
|
|
|
|
break;
|
|
|
|
case OEPS_GETSTAT_SENT:
|
|
|
|
/* Set the OEPF_NEED_STAT to trigger a new request */
|
|
|
|
eth_port->etp_osdep.etp_flags |= OEPF_NEED_STAT;
|
|
|
|
eth_port->etp_osdep.etp_state= OEPS_IDLE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If there is a pending GETSTAT request then we have to create a
|
|
|
|
* new grant.
|
|
|
|
*/
|
|
|
|
if (eth_port->etp_osdep.etp_flags & OEPF_NEED_STAT)
|
|
|
|
{
|
|
|
|
assert(eth_port->etp_osdep.etp_stat_gid != -1);
|
|
|
|
cpf_revoke(eth_port->etp_osdep.etp_stat_gid);
|
|
|
|
|
|
|
|
gid= cpf_grant_direct(eth_port->etp_osdep.etp_task,
|
|
|
|
(vir_bytes)eth_port->etp_osdep.etp_stat_buf,
|
|
|
|
sizeof(*eth_port->etp_osdep.etp_stat_buf), CPF_WRITE);
|
|
|
|
if (gid == -1)
|
|
|
|
{
|
|
|
|
ip_panic((
|
|
|
|
"eth_restart: cpf_grant_direct failed: %d\n",
|
|
|
|
errno));
|
|
|
|
}
|
|
|
|
eth_port->etp_osdep.etp_stat_gid= gid;
|
|
|
|
}
|
|
|
|
|
2005-10-21 18:51:21 +02:00
|
|
|
flags= eth_port->etp_osdep.etp_recvconf;
|
|
|
|
dl_flags= DL_NOMODE;
|
|
|
|
if (flags & NWEO_EN_BROAD)
|
|
|
|
dl_flags |= DL_BROAD_REQ;
|
|
|
|
if (flags & NWEO_EN_MULTI)
|
|
|
|
dl_flags |= DL_MULTI_REQ;
|
|
|
|
if (flags & NWEO_EN_PROMISC)
|
|
|
|
dl_flags |= DL_PROMISC_REQ;
|
2006-07-10 14:55:33 +02:00
|
|
|
mess.m_type= DL_CONF;
|
2005-10-21 18:51:21 +02:00
|
|
|
mess.DL_MODE= dl_flags;
|
2005-10-21 13:51:45 +02:00
|
|
|
|
2007-04-23 16:49:20 +02:00
|
|
|
compare(eth_port->etp_osdep.etp_state, ==, OEPS_IDLE);
|
|
|
|
r= asynsend(eth_port->etp_osdep.etp_task, &mess);
|
2005-10-21 13:51:45 +02:00
|
|
|
if (r<0)
|
|
|
|
{
|
|
|
|
printf(
|
2007-04-23 16:49:20 +02:00
|
|
|
"eth_restart: send to ethernet task %d failed: %d\n",
|
2005-10-21 18:51:21 +02:00
|
|
|
eth_port->etp_osdep.etp_task, r);
|
2005-10-21 13:51:45 +02:00
|
|
|
return;
|
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
eth_port->etp_osdep.etp_state= OEPS_CONF_SENT;
|
2005-10-21 13:51:45 +02:00
|
|
|
|
|
|
|
if (eth_port->etp_wr_pack)
|
2005-10-21 18:51:21 +02:00
|
|
|
{
|
|
|
|
bf_afree(eth_port->etp_wr_pack);
|
|
|
|
eth_port->etp_wr_pack= NULL;
|
|
|
|
eth_restart_write(eth_port);
|
|
|
|
}
|
2005-10-21 13:51:45 +02:00
|
|
|
if (eth_port->etp_rd_pack)
|
2005-10-21 18:51:21 +02:00
|
|
|
{
|
|
|
|
bf_afree(eth_port->etp_rd_pack);
|
|
|
|
eth_port->etp_rd_pack= NULL;
|
|
|
|
eth_port->etp_flags &= ~(EPF_READ_IP|EPF_READ_SP);
|
|
|
|
}
|
2007-04-23 16:49:20 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE void send_getstat(eth_port)
|
|
|
|
eth_port_t *eth_port;
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
message mess;
|
|
|
|
|
|
|
|
mess.m_type= DL_GETSTAT_S;
|
2010-05-18 00:22:53 +02:00
|
|
|
mess.DL_ENDPT= this_proc;
|
2007-04-23 16:49:20 +02:00
|
|
|
mess.DL_GRANT= eth_port->etp_osdep.etp_stat_gid;
|
|
|
|
|
|
|
|
assert(eth_port->etp_osdep.etp_state == OEPS_IDLE);
|
|
|
|
|
|
|
|
r= asynsend(eth_port->etp_osdep.etp_task, &mess);
|
|
|
|
eth_port->etp_osdep.etp_state= OEPS_GETSTAT_SENT;
|
|
|
|
|
|
|
|
if (r != OK)
|
|
|
|
ip_panic(( "eth_get_stat: asynsend failed: %d", r));
|
|
|
|
}
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*
|
2005-06-28 17:19:58 +02:00
|
|
|
* $PchId: mnx_eth.c,v 1.16 2005/06/28 14:24:37 philip Exp $
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|