replace tcpip_input by ethernet_input/ip_input

All MetalSVM drivers guarantee that the input function will be called in the context of the tcpip thread.
Therefore, we are able to use ethernet_input/ip_input instead of tcpip_input
This commit is contained in:
Stefan Lankes 2012-09-11 10:36:29 +02:00
parent bffaf0bd57
commit 2f64a5c772
5 changed files with 16 additions and 109 deletions

View file

@ -199,39 +199,6 @@ static err_t e1000if_output(struct netif* netif, struct pbuf* p)
return ERR_OK;
}
static void e1000if_input(struct netif* netif, struct pbuf* p)
{
struct eth_hdr *ethhdr;
err_t err;
/* points to packet payload, which starts with an Ethernet header */
ethhdr = p->payload;
switch (htons(ethhdr->type)) {
/* IP or ARP packet? */
case ETHTYPE_ARP:
case ETHTYPE_IP:
#if PPPOE_SUPPORT
/* PPPoE packet? */
case ETHTYPE_PPPOEDISC:
case ETHTYPE_PPPOE:
#endif /* PPPOE_SUPPORT */
/*
* This function is called in the context of the tcpip thread.
* Therefore, we are able to call directly the input functions.
*/
err = ethernet_input(p, netif);
if (err != ERR_OK) {
LWIP_DEBUGF(NETIF_DEBUG, ("e1000if_input: ethernet_input failed %d\n", err));
}
break;
default:
LWIP_DEBUGF(NETIF_DEBUG, ("e1000if_input: invalid ethernet header 0x%x\n", htons(ethhdr->type)));
pbuf_free(p);
break;
}
}
static void e1000_rx_inthandler(struct netif* netif)
{
e1000if_t* e1000if = netif->state;
@ -268,7 +235,7 @@ static void e1000_rx_inthandler(struct netif* netif)
LINK_STATS_INC(link.recv);
// forward packet to LwIP
e1000if_input(netif, p);
netif->input(p, netif);
} else {
LWIP_DEBUGF(NETIF_DEBUG, ("e1000if_rx_inthandler: not enough memory!\n"));
LINK_STATS_INC(link.memerr);

View file

@ -1175,7 +1175,7 @@ anotherpacket:
* This function is called in the context of the tcpip thread.
* Therefore, we are able to call directly the input functions.
*/
if ((err = ip_input(p, mmnif_dev)) != ERR_OK)
if ((err = mmnif_dev->input(p, mmnif_dev)) != ERR_OK)
{
DEBUGPRINTF("mmnif_rx: IP input error\n");
pbuf_free(p);

View file

@ -334,39 +334,6 @@ again:
return ERR_OK;
}
static void rckemacif_input(struct netif* netif, struct pbuf* p)
{
struct eth_hdr *ethhdr;
err_t err;
/* points to packet payload, which starts with an Ethernet header */
ethhdr = (struct eth_hdr *) p->payload;
switch (htons(ethhdr->type)) {
/* IP or ARP packet? */
case ETHTYPE_ARP:
case ETHTYPE_IP:
#if PPPOE_SUPPORT
/* PPPoE packet? */
case ETHTYPE_PPPOEDISC:
case ETHTYPE_PPPOE:
#endif /* PPPOE_SUPPORT */
/*
* This function is called in the context of the tcpip thread.
* Therefore, we are able to call directly the input functions.
*/
err = ethernet_input(p, netif);
if (err != ERR_OK) {
LWIP_DEBUGF(NETIF_DEBUG, ("rckemacif_input: ethernet_input failed %d\n", err));
}
break;
default:
LWIP_DEBUGF(NETIF_DEBUG, ("rckemacif_input: invalid ethernet header 0x%x\n", htons(ethhdr->type)));
pbuf_free(p);
break;
}
}
static void rckemacif_rx_handler(struct netif* netif, unsigned int write_offset)
{
rckemacif_t* rckemacif = netif->state;
@ -501,7 +468,7 @@ rxDone:
rckemacif->rx_read_offset = read_offset;
if (p) {
rckemacif_input(netif, p);
netif->input(p, netif);
p = NULL;
}

View file

@ -133,39 +133,6 @@ static err_t rtl8139if_output(struct netif* netif, struct pbuf* p)
return ERR_OK;
}
static void rtl8139if_input(struct netif* netif, struct pbuf* p)
{
struct eth_hdr *ethhdr;
err_t err;
/* points to packet payload, which starts with an Ethernet header */
ethhdr = p->payload;
switch (htons(ethhdr->type)) {
/* IP or ARP packet? */
case ETHTYPE_ARP:
case ETHTYPE_IP:
#if PPPOE_SUPPORT
/* PPPoE packet? */
case ETHTYPE_PPPOEDISC:
case ETHTYPE_PPPOE:
#endif /* PPPOE_SUPPORT */
/*
* This function is called in the context of the tcpip thread.
* Therefore, we are able to call directly the input functions.
*/
err = ethernet_input(p, netif);
if (err != ERR_OK) {
LWIP_DEBUGF(NETIF_DEBUG, ("rtl8139if_input: ethernet_input failed %d\n", err));
}
break;
default:
LWIP_DEBUGF(NETIF_DEBUG, ("rtl8139_input: invalid ethernet header 0x%x\n", htons(ethhdr->type)));
pbuf_free(p);
break;
}
}
static void rtl_rx_inthandler(struct netif* netif)
{
rtl1839if_t* rtl8139if = netif->state;
@ -205,7 +172,7 @@ static void rtl_rx_inthandler(struct netif* netif)
LINK_STATS_INC(link.recv);
// forward packet to LwIP
rtl8139if_input(netif, p);
netif->input(p, netif);
} else {
LWIP_DEBUGF(NETIF_DEBUG, ("rtl8139if_rx_inthandler: not enough memory!\n"));
rtl8139if->rx_pos += (rtl8139if->rx_pos + length) % RX_BUF_LEN;

View file

@ -109,7 +109,9 @@ static int init_netifs(void)
netif_set_default(&default_netif);
netif_set_up(&default_netif);
#else
if ((err = netifapi_netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, rckemacif_init, tcpip_input)) != ERR_OK) {
/* Note: Our drivers guarantee that the input function will be called in the context of the tcpip thread.
* => Therefore, we are able to use ethernet_input instead of tcpip_input */
if ((err = netifapi_netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, rckemacif_init, ethernet_input)) != ERR_OK) {
kprintf("Unable to add the network interface: err = %d\n", err);
return -ENODEV;
}
@ -133,15 +135,17 @@ static int init_netifs(void)
* - ipaddr : the ip address wich should be used
* - gw : the gateway wicht should be used
* - mmnif_init : the initialization which has to be done in order to use our interface
* - ethernet_input : tells him that he should get ethernet input (inclusice ARP)
* - ip_input : tells him that he should use ip_input
*/
#if NO_SYS
netif_add(&mmnif_netif, &intra_ipaddr, &intra_netmask, &intra_gw, NULL, mmnif_init, ethernet_input);
netif_add(&mmnif_netif, &intra_ipaddr, &intra_netmask, &intra_gw, NULL, mmnif_init, ip_input);
/* tell lwip all initialization is done and we want to set it ab */
netif_set_up(&mmnif_netif);
#else
if ((err = netifapi_netif_add(&mmnif_netif, &intra_ipaddr, &intra_netmask, &intra_gw, NULL, mmnif_init, tcpip_input)) != ERR_OK)
/* Note: Our drivers guarantee that the input function will be called in the context of the tcpip thread.
* => Therefore, we are able to use ip_input instead of tcpip_input */
if ((err = netifapi_netif_add(&mmnif_netif, &intra_ipaddr, &intra_netmask, &intra_gw, NULL, mmnif_init, ip_input)) != ERR_OK)
{
kprintf("Unable to add the intra network interface: err = %d\n", err);
return -ENODEV;
@ -162,9 +166,11 @@ static int init_netifs(void)
netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, rtl8139if_init, ethernet_input);
netif_set_default(&default_netif);
#else
if ((err = netifapi_netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, rtl8139if_init, tcpip_input)) == ERR_OK)
/* Note: Our drivers guarantee that the input function will be called in the context of the tcpip thread.
* => Therefore, we are able to use ethernet_input instead of tcpip_input */
if ((err = netifapi_netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, rtl8139if_init, ethernet_input)) == ERR_OK)
goto success;
if ((err = netifapi_netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, e1000if_init, tcpip_input)) == ERR_OK)
if ((err = netifapi_netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, e1000if_init, ethernet_input)) == ERR_OK)
goto success;
kprintf("Unable to add the network interface: err = %d\n", err);