Added LWIP_SINGLE_NETIF for small targets with only one netif (see task #13515, there might be more optimizations to come with this option)

This commit is contained in:
goldsimon
2017-03-01 16:10:50 +01:00
parent f978a7ed31
commit 0d585d55d3
13 changed files with 92 additions and 89 deletions

View File

@@ -364,9 +364,9 @@ autoip_stop(struct netif *netif)
void
autoip_tmr(void)
{
struct netif *netif = netif_list;
struct netif *netif;
/* loop through netif's */
while (netif != NULL) {
NETIF_FOREACH(netif) {
struct autoip* autoip = netif_autoip_data(netif);
/* only act on AutoIP configured interfaces */
if (autoip != NULL) {
@@ -438,8 +438,6 @@ autoip_tmr(void)
break;
}
}
/* proceed to next network interface */
netif = netif->next;
}
}

View File

@@ -408,10 +408,10 @@ dhcp_select(struct netif *netif)
void
dhcp_coarse_tmr(void)
{
struct netif *netif = netif_list;
struct netif *netif;
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_coarse_tmr()\n"));
/* iterate through all network interfaces */
while (netif != NULL) {
NETIF_FOREACH(netif) {
/* only act on DHCP configured interfaces */
struct dhcp *dhcp = netif_dhcp_data(netif);
if ((dhcp != NULL) && (dhcp->state != DHCP_STATE_OFF)) {
@@ -433,8 +433,6 @@ dhcp_coarse_tmr(void)
dhcp_t1_timeout(netif);
}
}
/* proceed to next netif */
netif = netif->next;
}
}
@@ -448,9 +446,9 @@ dhcp_coarse_tmr(void)
void
dhcp_fine_tmr(void)
{
struct netif *netif = netif_list;
struct netif *netif;
/* loop through netif's */
while (netif != NULL) {
NETIF_FOREACH(netif) {
struct dhcp *dhcp = netif_dhcp_data(netif);
/* only act on DHCP configured interfaces */
if (dhcp != NULL) {
@@ -466,8 +464,6 @@ dhcp_fine_tmr(void)
dhcp_timeout(netif);
}
}
/* proceed to next network interface */
netif = netif->next;
}
}

View File

@@ -456,8 +456,7 @@ igmp_joingroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr)
LWIP_ERROR("igmp_joingroup: attempt to join allsystems address", (!ip4_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;);
/* loop through netif's */
netif = netif_list;
while (netif != NULL) {
NETIF_FOREACH(netif) {
/* Should we join this interface ? */
if ((netif->flags & NETIF_FLAG_IGMP) && ((ip4_addr_isany(ifaddr) || ip4_addr_cmp(netif_ip4_addr(netif), ifaddr)))) {
err = igmp_joingroup_netif(netif, groupaddr);
@@ -467,8 +466,6 @@ igmp_joingroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr)
return err;
}
}
/* proceed to next network interface */
netif = netif->next;
}
return err;
@@ -552,8 +549,7 @@ igmp_leavegroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr)
LWIP_ERROR("igmp_leavegroup: attempt to leave allsystems address", (!ip4_addr_cmp(groupaddr, &allsystems)), return ERR_VAL;);
/* loop through netif's */
netif = netif_list;
while (netif != NULL) {
NETIF_FOREACH(netif) {
/* Should we leave this interface ? */
if ((netif->flags & NETIF_FLAG_IGMP) && ((ip4_addr_isany(ifaddr) || ip4_addr_cmp(netif_ip4_addr(netif), ifaddr)))) {
err_t res = igmp_leavegroup_netif(netif, groupaddr);
@@ -562,8 +558,6 @@ igmp_leavegroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr)
err = res;
}
}
/* proceed to next network interface */
netif = netif->next;
}
return err;
@@ -638,9 +632,9 @@ igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr)
void
igmp_tmr(void)
{
struct netif *netif = netif_list;
struct netif *netif;
while (netif != NULL) {
NETIF_FOREACH(netif) {
struct igmp_group *group = netif_igmp_data(netif);
while (group != NULL) {
@@ -652,7 +646,6 @@ igmp_tmr(void)
}
group = group->next;
}
netif = netif->next;
}
}

View File

@@ -151,6 +151,7 @@ ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src)
struct netif *
ip4_route(const ip4_addr_t *dest)
{
#if !LWIP_SINGLE_NETIF
struct netif *netif;
#if LWIP_MULTICAST_TX_OPTIONS
@@ -205,6 +206,7 @@ ip4_route(const ip4_addr_t *dest)
return netif;
}
#endif
#endif /* !LWIP_SINGLE_NETIF */
if ((netif_default == NULL) || !netif_is_up(netif_default) || !netif_is_link_up(netif_default) ||
ip4_addr_isany_val(*netif_ip4_addr(netif_default))) {
@@ -534,7 +536,8 @@ ip4_input(struct pbuf *p, struct netif *inp)
if (!ip4_addr_isloopback(ip4_current_dest_addr()))
#endif /* !LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF */
{
for (netif = netif_list; netif != NULL; netif = netif->next) {
#if ! LWIP_SINGLE_NETIF
NETIF_FOREACH(netif) {
if (netif == inp) {
/* we checked that before already */
continue;
@@ -543,6 +546,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
break;
}
}
#endif /* !LWIP_SINGLE_NETIF */
}
}
}