Message type for DL_CONF{,_REPLY}

Change-Id: Ib0e435875b6f5cacdcbc8593f9a887b0a4c472c1
This commit is contained in:
Lionel Sambuc 2014-05-19 19:19:14 +02:00
parent ec130c9b4b
commit 50ab3b569d
17 changed files with 116 additions and 74 deletions

View file

@ -1026,7 +1026,7 @@ static void atl2_conf(message *m)
ether_addr_t addr;
int r;
state.mode = m->DL_MODE;
state.mode = m->m_net_netdrv_dl_conf.mode;
atl2_set_mode();
@ -1037,10 +1037,11 @@ static void atl2_conf(message *m)
addr.ea_addr[4] = (state.hwaddr[0] >> 8) & 0xff;
addr.ea_addr[5] = state.hwaddr[0] & 0xff;
memcpy(m->DL_HWADDR, &addr, sizeof(addr));
memcpy(m->m_netdrv_net_dl_conf.hw_addr, &addr,
sizeof(m->m_netdrv_net_dl_conf.hw_addr));
m->m_type = DL_CONF_REPLY;
m->DL_STAT = OK;
m->m_netdrv_net_dl_conf.stat = OK;
if ((r = ipc_send(m->m_source, m)) != OK)
printf("ATL2: unable to send reply (%d)\n", r);

View file

@ -230,10 +230,12 @@ static void do_conf(const message * mp)
/* TODO CHECK PROMISC AND MULTI */
dep->de_flags &= NOT(DEF_PROMISC | DEF_MULTI | DEF_BROAD);
if (mp->DL_MODE & DL_PROMISC_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_PROMISC_REQ)
dep->de_flags |= DEF_PROMISC | DEF_MULTI | DEF_BROAD;
if (mp->DL_MODE & DL_MULTI_REQ) dep->de_flags |= DEF_MULTI;
if (mp->DL_MODE & DL_BROAD_REQ) dep->de_flags |= DEF_BROAD;
if (mp->m_net_netdrv_dl_conf.mode & DL_MULTI_REQ)
dep->de_flags |= DEF_MULTI;
if (mp->m_net_netdrv_dl_conf.mode & DL_BROAD_REQ)
dep->de_flags |= DEF_BROAD;
break;
case DEM_SINK:
@ -246,9 +248,10 @@ static void do_conf(const message * mp)
}
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.DL_STAT = r;
reply_mess.m_netdrv_net_dl_conf.stat = r;
if(r == OK){
*(ether_addr_t *) reply_mess.DL_HWADDR = dep->de_address;
memcpy(reply_mess.m_netdrv_net_dl_conf.hw_addr, dep->de_address.ea_addr,
sizeof(reply_mess.m_netdrv_net_dl_conf.hw_addr));
}
if (ipc_send(mp->m_source, &reply_mess) != OK)

View file

@ -514,8 +514,8 @@ static void do_init(message *mp)
if (dep->de_mode == DEM_DISABLED)
{
/* Probe failed, or the device is configured off. */
reply_mess.m_type= DL_CONF_REPLY;
reply_mess.DL_STAT= ENXIO;
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.m_netdrv_net_dl_conf.stat = ENXIO;
mess_reply(mp, &reply_mess);
return;
}
@ -529,8 +529,10 @@ static void do_init(message *mp)
dep->de_address.ea_addr[5] = de_instance;
dp_confaddr(dep);
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.DL_STAT = OK;
*(ether_addr_t *) reply_mess.DL_HWADDR = dep->de_address;
reply_mess.m_netdrv_net_dl_conf.stat = OK;
memcpy(reply_mess.m_netdrv_net_dl_conf.hw_addr,
dep->de_address.ea_addr,
sizeof(reply_mess.m_netdrv_net_dl_conf.hw_addr));
mess_reply(mp, &reply_mess);
return;
}
@ -539,18 +541,20 @@ static void do_init(message *mp)
dep->de_flags &= ~(DEF_PROMISC | DEF_MULTI | DEF_BROAD);
if (mp->DL_MODE & DL_PROMISC_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_PROMISC_REQ)
dep->de_flags |= DEF_PROMISC | DEF_MULTI | DEF_BROAD;
if (mp->DL_MODE & DL_MULTI_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_MULTI_REQ)
dep->de_flags |= DEF_MULTI;
if (mp->DL_MODE & DL_BROAD_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_BROAD_REQ)
dep->de_flags |= DEF_BROAD;
dp_reinit(dep);
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.DL_STAT = OK;
*(ether_addr_t *) reply_mess.DL_HWADDR = dep->de_address;
reply_mess.m_netdrv_net_dl_conf.stat = OK;
memcpy(reply_mess.m_netdrv_net_dl_conf.hw_addr, dep->de_address.ea_addr,
sizeof(reply_mess.m_netdrv_net_dl_conf.hw_addr));
mess_reply(mp, &reply_mess);
}

View file

@ -278,10 +278,12 @@ static void do_init(const message * mp)
dep->de_flags |= DEF_ENABLED;
}
dep->de_flags &= NOT(DEF_PROMISC | DEF_MULTI | DEF_BROAD);
if (mp->DL_MODE & DL_PROMISC_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_PROMISC_REQ)
dep->de_flags |= DEF_PROMISC | DEF_MULTI | DEF_BROAD;
if (mp->DL_MODE & DL_MULTI_REQ) dep->de_flags |= DEF_MULTI;
if (mp->DL_MODE & DL_BROAD_REQ) dep->de_flags |= DEF_BROAD;
if (mp->m_net_netdrv_dl_conf.mode & DL_MULTI_REQ)
dep->de_flags |= DEF_MULTI;
if (mp->m_net_netdrv_dl_conf.mode & DL_BROAD_REQ)
dep->de_flags |= DEF_BROAD;
(*dep->de_flagsf) (dep);
break;
@ -295,9 +297,10 @@ static void do_init(const message * mp)
}
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.DL_STAT = r;
reply_mess.m_netdrv_net_dl_conf.stat = r;
if (r == OK)
*(ether_addr_t *) reply_mess.DL_HWADDR = dep->de_address;
memcpy(reply_mess.m_netdrv_net_dl_conf.hw_addr, dep->de_address.ea_addr,
sizeof(reply_mess.m_netdrv_net_dl_conf.hw_addr));
DEBUG(printf("\t reply %d\n", reply_mess.m_type));
if (ipc_send(mp->m_source, &reply_mess) != OK) /* Can't send */
panic(SendErrMsg, mp->m_source);

View file

@ -189,14 +189,15 @@ static void e1000_init(message *mp)
if (!(e->status & E1000_ENABLED) && !(e1000_init_hw(e)))
{
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.DL_STAT = ENXIO;
reply_mess.m_netdrv_net_dl_conf.stat = ENXIO;
mess_reply(mp, &reply_mess);
return;
}
/* Reply back to INET. */
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.DL_STAT = OK;
*(ether_addr_t *) reply_mess.DL_HWADDR = e->address;
reply_mess.m_netdrv_net_dl_conf.stat = OK;
memcpy(reply_mess.m_netdrv_net_dl_conf.hw_addr, e->address.ea_addr,
sizeof(reply_mess.m_netdrv_net_dl_conf.hw_addr));
mess_reply(mp, &reply_mess);
}

View file

@ -366,7 +366,7 @@ message *mp;
{
/* Probe failed, or the device is configured off. */
reply_mess.m_type= DL_CONF_REPLY;
reply_mess.DL_STAT= ENXIO;
reply_mess.m_netdrv_net_dl_conf.stat= ENXIO;
mess_reply(mp, &reply_mess);
return;
}
@ -380,18 +380,20 @@ message *mp;
fp->fxp_flags &= ~(FF_PROMISC | FF_MULTI | FF_BROAD);
if (mp->DL_MODE & DL_PROMISC_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_PROMISC_REQ)
fp->fxp_flags |= FF_PROMISC;
if (mp->DL_MODE & DL_MULTI_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_MULTI_REQ)
fp->fxp_flags |= FF_MULTI;
if (mp->DL_MODE & DL_BROAD_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_BROAD_REQ)
fp->fxp_flags |= FF_BROAD;
fxp_rec_mode(fp);
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.DL_STAT = OK;
*(ether_addr_t *) reply_mess.DL_HWADDR = fp->fxp_address;
reply_mess.m_netdrv_net_dl_conf.stat = OK;
memcpy(reply_mess.m_netdrv_net_dl_conf.hw_addr,
fp->fxp_address.ea_addr,
sizeof(reply_mess.m_netdrv_net_dl_conf.hw_addr));
mess_reply(mp, &reply_mess);
}

View file

@ -246,14 +246,16 @@ message *m;
if (!(lan8710a_state.status & LAN8710A_ENABLED) &&
!(lan8710a_init_hw())) {
reply.m_type = DL_CONF_REPLY;
reply.DL_STAT = ENXIO;
reply.m_netdrv_net_dl_conf.stat = ENXIO;
mess_reply(m, &reply);
return;
}
/* Reply back to INET. */
reply.m_type = DL_CONF_REPLY;
reply.DL_STAT = OK;
*(ether_addr_t *) reply.DL_HWADDR = lan8710a_state.address;
reply.m_netdrv_net_dl_conf.stat = OK;
memcpy(reply.m_netdrv_net_dl_conf.hw_addr,
lan8710a_state.address,
sizeof(reply.m_netdrv_net_dl_conf.hw_addr));
mess_reply(m, &reply);
}

View file

@ -485,7 +485,7 @@ message *mp;
{
/* Probe failed, or the device is configured off. */
reply_mess.m_type= DL_CONF_REPLY;
reply_mess.DL_STAT = ENXIO;
reply_mess.m_netdrv_net_dl_conf.stat = ENXIO;
mess_reply(mp, &reply_mess);
return;
}
@ -503,8 +503,9 @@ message *mp;
ec->mac_address.ea_addr[5] = 0;
ec_confaddr(ec);
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.DL_STAT = OK;
*(ether_addr_t *) reply_mess.DL_HWADDR = ec->mac_address;
reply_mess.m_netdrv_net_dl_conf.stat = OK;
memcpy(reply_mess.m_netdrv_net_dl_conf.hw_addr, ec->mac_address.ea_addr,
sizeof(reply_mess.m_netdrv_net_dl_conf.hw_addr));
mess_reply(mp, &reply_mess);
return;
}
@ -513,18 +514,19 @@ message *mp;
ec->flags &= ~(ECF_PROMISC | ECF_MULTI | ECF_BROAD);
if (mp->DL_MODE & DL_PROMISC_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_PROMISC_REQ)
ec->flags |= ECF_PROMISC | ECF_MULTI | ECF_BROAD;
if (mp->DL_MODE & DL_MULTI_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_MULTI_REQ)
ec->flags |= ECF_MULTI;
if (mp->DL_MODE & DL_BROAD_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_BROAD_REQ)
ec->flags |= ECF_BROAD;
ec_reinit(ec);
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.DL_STAT = OK;
*(ether_addr_t *) reply_mess.DL_HWADDR = ec->mac_address;
reply_mess.m_netdrv_net_dl_conf.stat = OK;
memcpy(reply_mess.m_netdrv_net_dl_conf.hw_addr, ec->mac_address.ea_addr,
sizeof(reply_mess.m_netdrv_net_dl_conf.hw_addr));
mess_reply(mp, &reply_mess);
}

View file

@ -434,7 +434,7 @@ static void or_init (message * mp) {
or_init_struct (orp);
if (orp->or_mode == OR_M_DISABLED) {
reply.m_type = DL_CONF_REPLY;
reply.DL_STAT = ENXIO;
reply.m_netdrv_net_dl_conf.stat = ENXIO;
mess_reply (mp, &reply);
return;
}
@ -452,19 +452,20 @@ static void or_init (message * mp) {
* multicasting, promiscuity, broadcasting, depending on the users
* needs */
orp->or_flags &= ~(OR_F_PROMISC | OR_F_MULTI | OR_F_BROAD);
if (mp->DL_MODE & DL_PROMISC_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_PROMISC_REQ)
orp->or_flags |= OR_F_PROMISC;
if (mp->DL_MODE & DL_MULTI_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_MULTI_REQ)
orp->or_flags |= OR_F_MULTI;
if (mp->DL_MODE & DL_BROAD_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_BROAD_REQ)
orp->or_flags |= OR_F_BROAD;
or_rec_mode (orp);
/* reply the caller that the configuration succeeded */
reply.m_type = DL_CONF_REPLY;
reply.DL_STAT = OK;
*(ether_addr_t *) reply.DL_HWADDR = orp->or_address;
reply.m_netdrv_net_dl_conf.stat = OK;
memcpy(reply.m_netdrv_net_dl_conf.hw_addr, orp->or_address.ea_addr,
sizeof(reply.m_netdrv_net_dl_conf.hw_addr));
mess_reply (mp, &reply);
}

View file

@ -350,7 +350,7 @@ message *mp;
{
/* Probe failed, or the device is configured off. */
reply_mess.m_type= DL_CONF_REPLY;
reply_mess.DL_STAT= ENXIO;
reply_mess.m_netdrv_net_dl_conf.stat= ENXIO;
mess_reply(mp, &reply_mess);
return;
}
@ -366,18 +366,20 @@ message *mp;
rep->re_flags &= ~(REF_PROMISC | REF_MULTI | REF_BROAD);
if (mp->DL_MODE & DL_PROMISC_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_PROMISC_REQ)
rep->re_flags |= REF_PROMISC;
if (mp->DL_MODE & DL_MULTI_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_MULTI_REQ)
rep->re_flags |= REF_MULTI;
if (mp->DL_MODE & DL_BROAD_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_BROAD_REQ)
rep->re_flags |= REF_BROAD;
rl_rec_mode(rep);
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.DL_STAT = OK;
*(ether_addr_t *) reply_mess.DL_HWADDR = rep->re_address;
reply_mess.m_netdrv_net_dl_conf.stat = OK;
memcpy(reply_mess.m_netdrv_net_dl_conf.hw_addr,
rep->re_address.ea_addr,
sizeof(reply_mess.m_netdrv_net_dl_conf.hw_addr));
mess_reply(mp, &reply_mess);
}

View file

@ -557,7 +557,7 @@ message *mp;
if (rep->re_mode == REM_DISABLED) {
/* Probe failed, or the device is configured off. */
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.DL_STAT = ENXIO;
reply_mess.m_netdrv_net_dl_conf.stat = ENXIO;
mess_reply(mp, &reply_mess);
return;
}
@ -570,18 +570,20 @@ message *mp;
rep->re_flags &= ~(REF_PROMISC | REF_MULTI | REF_BROAD);
if (mp->DL_MODE & DL_PROMISC_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_PROMISC_REQ)
rep->re_flags |= REF_PROMISC;
if (mp->DL_MODE & DL_MULTI_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_MULTI_REQ)
rep->re_flags |= REF_MULTI;
if (mp->DL_MODE & DL_BROAD_REQ)
if (mp->m_net_netdrv_dl_conf.mode & DL_BROAD_REQ)
rep->re_flags |= REF_BROAD;
rl_rec_mode(rep);
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.DL_STAT = OK;
*(ether_addr_t *) reply_mess.DL_HWADDR = rep->re_address;
reply_mess.m_netdrv_net_dl_conf.stat = OK;
memcpy(reply_mess.m_netdrv_net_dl_conf.hw_addr,
rep->re_address.ea_addr,
sizeof(reply_mess.m_netdrv_net_dl_conf.hw_addr));
mess_reply(mp, &reply_mess);
}

View file

@ -531,12 +531,11 @@ virtio_net_conf(message *m)
}
/* Prepare reply */
for (i = 0; i < sizeof(virtio_net_mac); i++)
((u8_t*)reply.DL_HWADDR)[i] = virtio_net_mac[i];
memcpy(reply.m_netdrv_net_dl_conf.hw_addr, virtio_net_mac,
sizeof(reply.m_netdrv_net_dl_conf.hw_addr));
reply.m_type = DL_CONF_REPLY;
reply.DL_STAT = OK;
reply.DL_COUNT = 0;
reply.m_netdrv_net_dl_conf.stat = OK;
if ((r = ipc_send(m->m_source, &reply)) != OK)
panic("%s: ipc_send to %d failed (%d)", name, m->m_source, r);

View file

@ -180,11 +180,9 @@
/* Field names for data link layer messages. */
#define DL_COUNT m2_i3
#define DL_MODE m2_l1
#define DL_FLAGS m2_l1
#define DL_GRANT m2_l2
#define DL_STAT m3_i1
#define DL_HWADDR m3_ca1
/* Bits in 'DL_FLAGS' field of DL replies. */
# define DL_NOFLAGS 0x00

View file

@ -813,6 +813,21 @@ typedef struct {
} mess_lsys_vfs_mapdriver;
_ASSERT_MSG_SIZE(mess_lsys_vfs_mapdriver);
typedef struct {
int mode;
uint8_t padding[52];
} mess_net_netdrv_dl_conf;
_ASSERT_MSG_SIZE(mess_net_netdrv_dl_conf);
typedef struct {
int stat;
uint8_t hw_addr[6];
uint8_t padding[46];
} mess_netdrv_net_dl_conf;
_ASSERT_MSG_SIZE(mess_netdrv_net_dl_conf);
typedef struct {
uid_t egid;
@ -1393,6 +1408,10 @@ typedef struct {
mess_lsys_vfs_copyfd m_lsys_vfs_copyfd;
mess_lsys_vfs_mapdriver m_lsys_vfs_mapdriver;
mess_net_netdrv_dl_conf m_net_netdrv_dl_conf;
mess_netdrv_net_dl_conf m_netdrv_net_dl_conf;
mess_pci_lsys_busc_get_bar m_pci_lsys_busc_get_bar;
mess_pm_lexec_exec_new m_pm_lexec_exec_new;

View file

@ -232,7 +232,9 @@ void eth_rec(message *m)
loc_port->etp_osdep.etp_state= OEPS_IDLE;
loc_port->etp_flags |= EPF_ENABLED;
loc_port->etp_ethaddr= *(ether_addr_t *)m->DL_HWADDR;
memcpy(loc_port->etp_ethaddr.ea_addr,
m->m_netdrv_net_dl_conf.hw_addr,
sizeof(loc_port->etp_ethaddr.ea_addr));
if (!(loc_port->etp_flags & EPF_GOT_ADDR))
{
loc_port->etp_flags |= EPF_GOT_ADDR;
@ -475,7 +477,7 @@ u32_t flags;
dl_flags |= DL_PROMISC_REQ;
mess.m_type= DL_CONF;
mess.DL_MODE= dl_flags;
mess.m_net_netdrv_dl_conf.mode = dl_flags;
assert(eth_port->etp_osdep.etp_state == OEPS_IDLE);
r= asynsend(eth_port->etp_osdep.etp_task, &mess);
@ -795,7 +797,7 @@ static void eth_restart(eth_port_t *eth_port, endpoint_t endpoint)
if (flags & NWEO_EN_PROMISC)
dl_flags |= DL_PROMISC_REQ;
mess.m_type= DL_CONF;
mess.DL_MODE= dl_flags;
mess.m_net_netdrv_dl_conf.mode= dl_flags;
compare(eth_port->etp_osdep.etp_state, ==, OEPS_IDLE);
r= asynsend(eth_port->etp_osdep.etp_task, &mess);

View file

@ -156,7 +156,8 @@ static void driver_setup_read(struct nic * nic)
static void nic_up(struct nic * nic, message * m)
{
memcpy(nic->netif.hwaddr, m->DL_HWADDR, NETIF_MAX_HWADDR_LEN);
memcpy(nic->netif.hwaddr, m->m_netdrv_net_dl_conf.hw_addr,
sizeof(nic->netif.hwaddr));
debug_print("device %s is up MAC : %02x:%02x:%02x:%02x:%02x:%02x",
nic->name,

View file

@ -103,13 +103,13 @@ static void low_level_init(struct netif *netif)
/* device capabilities */
netif->flags = NETIF_FLAG_ETHARP;
m.DL_MODE = DL_NOMODE;
m.m_net_netdrv_dl_conf.mode = DL_NOMODE;
if (nic->flags & NWEO_EN_BROAD)
m.DL_MODE |= DL_BROAD_REQ;
m.m_net_netdrv_dl_conf.mode |= DL_BROAD_REQ;
if (nic->flags & NWEO_EN_MULTI)
m.DL_MODE |= DL_MULTI_REQ;
m.m_net_netdrv_dl_conf.mode |= DL_MULTI_REQ;
if (nic->flags & NWEO_EN_PROMISC)
m.DL_MODE |= DL_PROMISC_REQ;
m.m_net_netdrv_dl_conf.mode |= DL_PROMISC_REQ;
m.m_type = DL_CONF;