Merge branch 'develop' into contrib/travis-deterministic-tests

This commit is contained in:
Simon Duquennoy 2017-11-17 16:44:35 +01:00 committed by GitHub
commit db437fde33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 139 additions and 139 deletions

View File

@ -212,10 +212,14 @@ lpm_exit()
/* Restore system clock to the 32 MHz XOSC */ /* Restore system clock to the 32 MHz XOSC */
select_32_mhz_xosc(); select_32_mhz_xosc();
if((REG(SYS_CTRL_PMCTL) & SYS_CTRL_PMCTL_PM3) == SYS_CTRL_PMCTL_PM1) {
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
} else {
ENERGEST_SWITCH(ENERGEST_TYPE_DEEP_LPM, ENERGEST_TYPE_CPU);
}
/* Restore PMCTL to PM0 for next pass */ /* Restore PMCTL to PM0 for next pass */
REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM0; REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM0;
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
@ -286,8 +290,6 @@ lpm_enter()
REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM1; REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM1;
} }
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
/* Remember the current time so we can keep stats when we wake up */ /* Remember the current time so we can keep stats when we wake up */
if(LPM_CONF_STATS) { if(LPM_CONF_STATS) {
sleep_enter_time = RTIMER_NOW(); sleep_enter_time = RTIMER_NOW();
@ -310,9 +312,13 @@ lpm_enter()
REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM0; REG(SYS_CTRL_PMCTL) = SYS_CTRL_PMCTL_PM0;
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
} else { } else {
/* All clear. Assert WFI and drop to PM1/2. This is now un-interruptible */ /* All clear. Assert WFI and drop to PM1/2. This is now un-interruptible */
if((REG(SYS_CTRL_PMCTL) & SYS_CTRL_PMCTL_PM3) == SYS_CTRL_PMCTL_PM1) {
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
} else {
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_DEEP_LPM);
}
assert_wfi(); assert_wfi();
} }

View File

@ -185,7 +185,7 @@ wake_up(void)
{ {
lpm_registered_module_t *module; lpm_registered_module_t *module;
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU); ENERGEST_SWITCH(ENERGEST_TYPE_DEEP_LPM, ENERGEST_TYPE_CPU);
/* Sync so that we get the latest values before adjusting recharge settings */ /* Sync so that we get the latest values before adjusting recharge settings */
ti_lib_sys_ctrl_aon_sync(); ti_lib_sys_ctrl_aon_sync();
@ -485,7 +485,7 @@ deep_sleep(void)
ti_lib_pwr_ctrl_source_set(PWRCTRL_PWRSRC_ULDO); ti_lib_pwr_ctrl_source_set(PWRCTRL_PWRSRC_ULDO);
} }
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM); ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_DEEP_LPM);
/* Sync the AON interface to ensure all writes have gone through. */ /* Sync the AON interface to ensure all writes have gone through. */
ti_lib_sys_ctrl_aon_sync(); ti_lib_sys_ctrl_aon_sync();

View File

@ -71,13 +71,6 @@
* @{ * @{
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_RED
#undef LEDS_CONF_ALL
#define LEDS_YELLOW 2 /**< LED2 (Yellow) -> PC1 */ #define LEDS_YELLOW 2 /**< LED2 (Yellow) -> PC1 */
#define LEDS_GREEN 4 /**< LED3 (Green) -> PC2 */ #define LEDS_GREEN 4 /**< LED3 (Green) -> PC2 */
#define LEDS_ORANGE 8 /**< LED4 (Orange) -> PC3 */ #define LEDS_ORANGE 8 /**< LED4 (Orange) -> PC3 */

View File

@ -87,8 +87,6 @@
#define NBR_TABLE_CONF_MAX_NEIGHBORS 300 #define NBR_TABLE_CONF_MAX_NEIGHBORS 300
#endif /* NBR_TABLE_CONF_MAX_NEIGHBORS */ #endif /* NBR_TABLE_CONF_MAX_NEIGHBORS */
#define TCPIP_CONF_ANNOTATE_TRANSMISSIONS 1
#ifndef UIP_CONF_IPV6_QUEUE_PKT #ifndef UIP_CONF_IPV6_QUEUE_PKT
#define UIP_CONF_IPV6_QUEUE_PKT 1 #define UIP_CONF_IPV6_QUEUE_PKT 1
#endif /* UIP_CONF_IPV6_QUEUE_PKT */ #endif /* UIP_CONF_IPV6_QUEUE_PKT */

View File

@ -63,13 +63,6 @@
* @{ * @{
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_RED
#undef LEDS_CONF_ALL
#define LEDS_RED 16 /**< LED1 (Red) -> PC4 */ #define LEDS_RED 16 /**< LED1 (Red) -> PC4 */
#define LEDS_YELLOW 64 /**< LED2 (Yellow) -> PC6 */ #define LEDS_YELLOW 64 /**< LED2 (Yellow) -> PC6 */
#define LEDS_GREEN 128 /**< LED3 (Green) -> PC7 */ #define LEDS_GREEN 128 /**< LED3 (Green) -> PC7 */

View File

@ -60,13 +60,6 @@
* Those values are not meant to be modified by the user * Those values are not meant to be modified by the user
* @{ * @{
*/ */
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_RED
#undef LEDS_CONF_ALL
#define LEDS_RED 1 #define LEDS_RED 1
#define LEDS_GREEN 2 #define LEDS_GREEN 2
#define LEDS_YELLOW LEDS_GREEN #define LEDS_YELLOW LEDS_GREEN

View File

@ -60,13 +60,6 @@
* Those values are not meant to be modified by the user * Those values are not meant to be modified by the user
* @{ * @{
*/ */
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_RED
#undef LEDS_CONF_ALL
#define LEDS_RED 1 #define LEDS_RED 1
#define LEDS_GREEN 2 #define LEDS_GREEN 2
#define LEDS_YELLOW LEDS_GREEN #define LEDS_YELLOW LEDS_GREEN

View File

@ -60,13 +60,6 @@
* Those values are not meant to be modified by the user * Those values are not meant to be modified by the user
* @{ * @{
*/ */
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_RED
#undef LEDS_CONF_ALL
#define LEDS_RED 1 #define LEDS_RED 1
#define LEDS_GREEN 2 #define LEDS_GREEN 2
#define LEDS_YELLOW LEDS_GREEN #define LEDS_YELLOW LEDS_GREEN

View File

@ -63,13 +63,6 @@
* Those values are not meant to be modified by the user * Those values are not meant to be modified by the user
* @{ * @{
*/ */
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_RED
#undef LEDS_CONF_ALL
#define LEDS_RED 1 #define LEDS_RED 1
#define LEDS_GREEN LEDS_RED #define LEDS_GREEN LEDS_RED
#define LEDS_YELLOW LEDS_RED #define LEDS_YELLOW LEDS_RED

View File

@ -63,13 +63,6 @@
* Those values are not meant to be modified by the user * Those values are not meant to be modified by the user
* @{ * @{
*/ */
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_RED
#undef LEDS_CONF_ALL
#define LEDS_RED 1 #define LEDS_RED 1
#define LEDS_GREEN 2 #define LEDS_GREEN 2
#define LEDS_YELLOW LEDS_GREEN #define LEDS_YELLOW LEDS_GREEN

View File

@ -63,13 +63,6 @@
* Those values are not meant to be modified by the user * Those values are not meant to be modified by the user
* @{ * @{
*/ */
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_RED
#undef LEDS_CONF_ALL
#define LEDS_RED 1 /**< LED1 (Red) */ #define LEDS_RED 1 /**< LED1 (Red) */
#define LEDS_YELLOW 2 /**< LED2 (Yellow) */ #define LEDS_YELLOW 2 /**< LED2 (Yellow) */
#define LEDS_GREEN 4 /**< LED3 (Green) */ #define LEDS_GREEN 4 /**< LED3 (Green) */

View File

@ -63,13 +63,6 @@
* Those values are not meant to be modified by the user * Those values are not meant to be modified by the user
* @{ * @{
*/ */
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_RED
#undef LEDS_CONF_ALL
#define LEDS_RED 1 /**< LED1 (Red) */ #define LEDS_RED 1 /**< LED1 (Red) */
#define LEDS_YELLOW 2 /**< LED2 (Yellow) */ #define LEDS_YELLOW 2 /**< LED2 (Yellow) */
#define LEDS_GREEN 4 /**< LED3 (Green) */ #define LEDS_GREEN 4 /**< LED3 (Green) */

View File

@ -98,14 +98,6 @@
* @{ * @{
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_BLUE
#undef LEDS_RED
#undef LEDS_CONF_ALL
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */ /* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
#define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */ #define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */
#define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */ #define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */

View File

@ -98,14 +98,6 @@
* @{ * @{
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_BLUE
#undef LEDS_RED
#undef LEDS_CONF_ALL
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */ /* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
#define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */ #define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */
#define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */ #define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */

View File

@ -67,14 +67,6 @@
* @{ * @{
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_BLUE
#undef LEDS_RED
#undef LEDS_CONF_ALL
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */ /* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
#define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */ #define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */
#define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */ #define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */

View File

@ -102,14 +102,6 @@
* @{ * @{
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Some files include leds.h before us, so we need to get rid of defaults in
* leds.h before we provide correct definitions */
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_BLUE
#undef LEDS_RED
#undef LEDS_CONF_ALL
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */ /* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
#define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */ #define LEDS_GREEN (1 << 4) /**< LED1 (Green) -> PD4 */
#define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */ #define LEDS_BLUE (1 << 3) /**< LED2 (Blue) -> PD3 */

View File

@ -105,12 +105,6 @@
* @{ * @{
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#undef LEDS_GREEN
#undef LEDS_YELLOW
#undef LEDS_BLUE
#undef LEDS_RED
#undef LEDS_CONF_ALL
#define LEDS_RED 1 /**< LED1 (Red) -> PD4 */ #define LEDS_RED 1 /**< LED1 (Red) -> PD4 */
#define LEDS_RED_PIN_MASK (1 << 4) #define LEDS_RED_PIN_MASK (1 << 4)
#define LEDS_RED_PORT_BASE GPIO_D_BASE #define LEDS_RED_PORT_BASE GPIO_D_BASE

View File

@ -121,6 +121,4 @@
#define LOG_CONF_LEVEL_6TOP LOG_LEVEL_DBG #define LOG_CONF_LEVEL_6TOP LOG_LEVEL_DBG
#define TSCH_LOG_CONF_PER_SLOT 1 #define TSCH_LOG_CONF_PER_SLOT 1
#define TCPIP_CONF_ANNOTATE_TRANSMISSIONS 0
#endif /* __PROJECT_CONF_H__ */ #endif /* __PROJECT_CONF_H__ */

View File

@ -33,19 +33,11 @@
#include "dev/leds.h" #include "dev/leds.h"
#include "sys/clock.h" #include "sys/clock.h"
static unsigned char leds;
/*---------------------------------------------------------------------------*/
static inline void
show_leds(unsigned char new_leds)
{
leds_arch_set(new_leds);
}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
leds_init(void) leds_init(void)
{ {
leds_arch_init(); leds_arch_init();
leds = 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
@ -53,7 +45,7 @@ leds_blink(void)
{ {
/* Blink all leds that were initially off. */ /* Blink all leds that were initially off. */
unsigned char blink; unsigned char blink;
blink = ~leds; blink = ~leds_arch_get();
leds_toggle(blink); leds_toggle(blink);
clock_delay(400); clock_delay(400);
@ -69,24 +61,24 @@ leds_get(void) {
void void
leds_set(unsigned char ledv) leds_set(unsigned char ledv)
{ {
show_leds(ledv); leds_arch_set(ledv);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
leds_on(unsigned char ledv) leds_on(unsigned char ledv)
{ {
show_leds(leds | ledv); leds_arch_set(leds_arch_get() | ledv);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
leds_off(unsigned char ledv) leds_off(unsigned char ledv)
{ {
show_leds(leds & ~ledv); leds_arch_set(leds_arch_get() & ~ledv);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
leds_toggle(unsigned char ledv) leds_toggle(unsigned char ledv)
{ {
show_leds(leds ^ ledv); leds_arch_set(leds_arch_get() ^ ledv);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -1504,6 +1504,17 @@ output(const linkaddr_t *localdest)
set_packet_attrs(); set_packet_attrs();
} }
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
{
uint8_t traffic_class = (UIP_IP_BUF->vtc << 4) | (UIP_IP_BUF->tcflow >> 4);
if(traffic_class & UIP_TC_MAC_TRANSMISSION_COUNTER_BIT) {
uint8_t max_mac_transmissions = traffic_class & UIP_TC_MAC_TRANSMISSION_COUNTER_MASK;
/* propagate the MAC transmission limit to lower layers */
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS, max_mac_transmissions);
}
}
#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */
/* /*
* The destination address will be tagged to each outbound * The destination address will be tagged to each outbound
* packet. If the argument localdest is NULL, we are sending a * packet. If the argument localdest is NULL, we are sending a

View File

@ -820,6 +820,18 @@ CCIF void uip_send(const void *data, int len);
*/ */
#define uip_mss() (uip_conn->mss) #define uip_mss() (uip_conn->mss)
/**
* Set the maximal number of MAC transmissions.
*
* \hideinitializer
*/
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
#define uip_set_max_mac_transmissions(conn, value) ((conn)->max_mac_transmissions = (value))
#else
#define uip_set_max_mac_transmissions(conn, value)
#endif
/** /**
* Set up a new UDP connection. * Set up a new UDP connection.
* *
@ -883,6 +895,7 @@ struct uip_udp_conn *uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport);
*/ */
#define uip_udp_send(len) uip_send((char *)uip_appdata, len) #define uip_udp_send(len) uip_send((char *)uip_appdata, len)
/** @} */ /** @} */
/* uIP convenience and converting functions. */ /* uIP convenience and converting functions. */
@ -1352,6 +1365,9 @@ struct uip_conn {
uint8_t timer; /**< The retransmission timer. */ uint8_t timer; /**< The retransmission timer. */
uint8_t nrtx; /**< The number of retransmissions for the last uint8_t nrtx; /**< The number of retransmissions for the last
segment sent. */ segment sent. */
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
uint8_t max_mac_transmissions; /**< Number of max MAC-layer transmissions. */
#endif
uip_tcp_appstate_t appstate; /** The application state. */ uip_tcp_appstate_t appstate; /** The application state. */
}; };
@ -1389,6 +1405,9 @@ struct uip_udp_conn {
uint16_t lport; /**< The local port number in network byte order. */ uint16_t lport; /**< The local port number in network byte order. */
uint16_t rport; /**< The remote port number in network byte order. */ uint16_t rport; /**< The remote port number in network byte order. */
uint8_t ttl; /**< Default time-to-live. */ uint8_t ttl; /**< Default time-to-live. */
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
uint8_t max_mac_transmissions; /**< Number of max MAC-layer transmissions. */
#endif
/** The application state. */ /** The application state. */
uip_udp_appstate_t appstate; uip_udp_appstate_t appstate;

View File

@ -508,6 +508,9 @@ uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport)
conn->rto = UIP_RTO; conn->rto = UIP_RTO;
conn->sa = 0; conn->sa = 0;
conn->sv = 16; /* Initial value of the RTT variance. */ conn->sv = 16; /* Initial value of the RTT variance. */
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
conn->max_mac_transmissions = UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED;
#endif
conn->lport = uip_htons(lastport); conn->lport = uip_htons(lastport);
conn->rport = rport; conn->rport = rport;
uip_ipaddr_copy(&conn->ripaddr, ripaddr); uip_ipaddr_copy(&conn->ripaddr, ripaddr);
@ -581,6 +584,9 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport)
uip_ipaddr_copy(&conn->ripaddr, ripaddr); uip_ipaddr_copy(&conn->ripaddr, ripaddr);
} }
conn->ttl = uip_ds6_if.cur_hop_limit; conn->ttl = uip_ds6_if.cur_hop_limit;
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
conn->max_mac_transmissions = UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED;
#endif
return conn; return conn;
} }
@ -1545,6 +1551,16 @@ uip_process(uint8_t flag)
UIP_IP_BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8); UIP_IP_BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
UIP_IP_BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff); UIP_IP_BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
UIP_IP_BUF->vtc = 0x60;
UIP_IP_BUF->tcflow = 0x00;
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
if(uip_udp_conn->max_mac_transmissions != UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED) {
/* Encapsulate the MAC transmission limit in the Traffic Class field */
UIP_IP_BUF->vtc = 0x60 | (UIP_TC_MAC_TRANSMISSION_COUNTER_BIT >> 4);
UIP_IP_BUF->tcflow = uip_udp_conn->max_mac_transmissions << 4;
}
#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */
UIP_IP_BUF->ttl = uip_udp_conn->ttl; UIP_IP_BUF->ttl = uip_udp_conn->ttl;
UIP_IP_BUF->proto = UIP_PROTO_UDP; UIP_IP_BUF->proto = UIP_PROTO_UDP;
@ -2249,6 +2265,16 @@ uip_process(uint8_t flag)
UIP_TCP_BUF->srcport = uip_connr->lport; UIP_TCP_BUF->srcport = uip_connr->lport;
UIP_TCP_BUF->destport = uip_connr->rport; UIP_TCP_BUF->destport = uip_connr->rport;
UIP_IP_BUF->vtc = 0x60;
UIP_IP_BUF->tcflow = 0x00;
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
if(uip_connr->max_mac_transmissions != UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED) {
/* Encapsulate the MAC transmission limit in the Traffic Class field */
UIP_IP_BUF->vtc = 0x60 | (UIP_TC_MAC_TRANSMISSION_COUNTER_BIT >> 4);
UIP_IP_BUF->tcflow = uip_connr->max_mac_transmissions << 4;
}
#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &uip_connr->ripaddr); uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &uip_connr->ripaddr);
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr); uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
LOG_INFO("Sending TCP packet to "); LOG_INFO("Sending TCP packet to ");
@ -2284,8 +2310,6 @@ uip_process(uint8_t flag)
#if UIP_UDP #if UIP_UDP
ip_send_nolen: ip_send_nolen:
#endif #endif
UIP_IP_BUF->vtc = 0x60;
UIP_IP_BUF->tcflow = 0x00;
UIP_IP_BUF->flow = 0x00; UIP_IP_BUF->flow = 0x00;
send: send:
LOG_INFO("Sending packet with length %d (%d)\n", uip_len, LOG_INFO("Sending packet with length %d (%d)\n", uip_len,

View File

@ -518,6 +518,35 @@ void uip_log(char *msg);
#define UIP_DEFAULT_PREFIX_LEN 64 #define UIP_DEFAULT_PREFIX_LEN 64
/**
* Enables selection of maximal MAC-layer transmission count at application layer
*/
#ifdef UIP_CONF_WITH_VARIABLE_RETRANSMISSIONS
#define UIP_WITH_VARIABLE_RETRANSMISSIONS UIP_CONF_WITH_VARIABLE_RETRANSMISSIONS
#else
#define UIP_WITH_VARIABLE_RETRANSMISSIONS 0
#endif
/**
* This is the default value of MAC-layer transmissons for uIPv6
*
* It means that the limit is selected by the MAC protocol instead of uIPv6.
*/
#define UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED 0
/**
* The MAC-layer transmissons limit is encapslated in "Traffic Class" field
*
* In Contiki, if the Traffic Class field in the IPv6 header has this bit set,
* the low-order bits are used as the MAC-layer transmissons limit.
*/
#define UIP_TC_MAC_TRANSMISSION_COUNTER_BIT 0x40
/**
* The bits in the "Traffic Class" field that describe the MAC transmission limit
*/
#define UIP_TC_MAC_TRANSMISSION_COUNTER_MASK 0x3F
/** @} */ /** @} */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/

View File

@ -85,9 +85,9 @@
/* macMaxFrameRetries: Maximum number of re-transmissions attampts. Range 0--7 */ /* macMaxFrameRetries: Maximum number of re-transmissions attampts. Range 0--7 */
#ifdef CSMA_CONF_MAX_FRAME_RETRIES #ifdef CSMA_CONF_MAX_FRAME_RETRIES
#define CSMA_MAX_MAX_FRAME_RETRIES CSMA_CONF_MAX_FRAME_RETRIES #define CSMA_MAX_FRAME_RETRIES CSMA_MAX_FRAME_RETRIES
#else #else
#define CSMA_MAX_MAX_FRAME_RETRIES 7 #define CSMA_MAX_FRAME_RETRIES 7
#endif #endif
/* Packet metadata */ /* Packet metadata */
@ -506,7 +506,15 @@ csma_output_packet(mac_callback_t sent, void *ptr)
if(q->buf != NULL) { if(q->buf != NULL) {
struct qbuf_metadata *metadata = (struct qbuf_metadata *)q->ptr; struct qbuf_metadata *metadata = (struct qbuf_metadata *)q->ptr;
/* Neighbor and packet successfully allocated */ /* Neighbor and packet successfully allocated */
metadata->max_transmissions = CSMA_MAX_MAX_FRAME_RETRIES + 1; #if UIP_WITH_VARIABLE_RETRANSMISSIONS
metadata->max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS);
if(metadata->max_transmissions == 0) {
/* If not set by the application, use the default CSMA value */
metadata->max_transmissions = CSMA_MAX_FRAME_RETRIES + 1;
}
#else
metadata->max_transmissions = CSMA_MAX_FRAME_RETRIES + 1;
#endif
metadata->sent = sent; metadata->sent = sent;
metadata->cptr = ptr; metadata->cptr = ptr;
list_add(n->packet_queue, q); list_add(n->packet_queue, q);

View File

@ -230,7 +230,8 @@ tsch_queue_remove_nbr(struct tsch_neighbor *n)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Add packet to neighbor queue. Use same lockfree implementation as ringbuf.c (put is atomic) */ /* Add packet to neighbor queue. Use same lockfree implementation as ringbuf.c (put is atomic) */
struct tsch_packet * struct tsch_packet *
tsch_queue_add_packet(const linkaddr_t *addr, mac_callback_t sent, void *ptr) tsch_queue_add_packet(const linkaddr_t *addr, uint8_t max_transmissions,
mac_callback_t sent, void *ptr)
{ {
struct tsch_neighbor *n = NULL; struct tsch_neighbor *n = NULL;
int16_t put_index = -1; int16_t put_index = -1;
@ -252,6 +253,7 @@ tsch_queue_add_packet(const linkaddr_t *addr, mac_callback_t sent, void *ptr)
p->ptr = ptr; p->ptr = ptr;
p->ret = MAC_TX_DEFERRED; p->ret = MAC_TX_DEFERRED;
p->transmissions = 0; p->transmissions = 0;
p->max_transmissions = max_transmissions;
/* Add to ringbuf (actual add committed through atomic operation) */ /* Add to ringbuf (actual add committed through atomic operation) */
n->tx_array[put_index] = p; n->tx_array[put_index] = p;
ringbufindex_put(&n->tx_ringbuf); ringbufindex_put(&n->tx_ringbuf);
@ -342,7 +344,7 @@ tsch_queue_packet_sent(struct tsch_neighbor *n, struct tsch_packet *p,
} }
} else { } else {
/* Failed transmission */ /* Failed transmission */
if(p->transmissions >= TSCH_MAC_MAX_FRAME_RETRIES + 1) { if(p->transmissions >= p->max_transmissions) {
/* Drop packet */ /* Drop packet */
tsch_queue_remove_packet_from_queue(n); tsch_queue_remove_packet_from_queue(n);
in_queue = 0; in_queue = 0;

View File

@ -135,6 +135,7 @@ struct tsch_packet {
mac_callback_t sent; /* callback for this packet */ mac_callback_t sent; /* callback for this packet */
void *ptr; /* MAC callback parameter */ void *ptr; /* MAC callback parameter */
uint8_t transmissions; /* #transmissions performed for this packet */ uint8_t transmissions; /* #transmissions performed for this packet */
uint8_t max_transmissions; /* maximal number of Tx before dropping the packet */
uint8_t ret; /* status -- MAC return code */ uint8_t ret; /* status -- MAC return code */
uint8_t header_len; /* length of header and header IEs (needed for link-layer security) */ uint8_t header_len; /* length of header and header IEs (needed for link-layer security) */
uint8_t tsch_sync_ie_offset; /* Offset within the frame used for quick update of EB ASN and join priority */ uint8_t tsch_sync_ie_offset; /* Offset within the frame used for quick update of EB ASN and join priority */
@ -176,7 +177,8 @@ struct tsch_neighbor *tsch_queue_get_time_source(void);
/* Update TSCH time source */ /* Update TSCH time source */
int tsch_queue_update_time_source(const linkaddr_t *new_addr); int tsch_queue_update_time_source(const linkaddr_t *new_addr);
/* Add packet to neighbor queue. Use same lockfree implementation as ringbuf.c (put is atomic) */ /* Add packet to neighbor queue. Use same lockfree implementation as ringbuf.c (put is atomic) */
struct tsch_packet *tsch_queue_add_packet(const linkaddr_t *addr, mac_callback_t sent, void *ptr); struct tsch_packet *tsch_queue_add_packet(const linkaddr_t *addr, uint8_t max_transmissions,
mac_callback_t sent, void *ptr);
/* Returns the number of packets currently in any TSCH queue */ /* Returns the number of packets currently in any TSCH queue */
int tsch_queue_global_packet_count(void); int tsch_queue_global_packet_count(void);
/* Returns the number of packets currently a given neighbor queue */ /* Returns the number of packets currently a given neighbor queue */

View File

@ -832,8 +832,8 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data)
/* Prepare the EB packet and schedule it to be sent */ /* Prepare the EB packet and schedule it to be sent */
if(tsch_packet_create_eb(&hdr_len, &tsch_sync_ie_offset) > 0) { if(tsch_packet_create_eb(&hdr_len, &tsch_sync_ie_offset) > 0) {
struct tsch_packet *p; struct tsch_packet *p;
/* Enqueue EB packet */ /* Enqueue EB packet, for a single transmission only */
if(!(p = tsch_queue_add_packet(&tsch_eb_address, NULL, NULL))) { if(!(p = tsch_queue_add_packet(&tsch_eb_address, 1, NULL, NULL))) {
LOG_ERR("! could not enqueue EB packet\n"); LOG_ERR("! could not enqueue EB packet\n");
} else { } else {
LOG_INFO("TSCH: enqueue EB packet %u %u\n", LOG_INFO("TSCH: enqueue EB packet %u %u\n",
@ -958,6 +958,7 @@ send_packet(mac_callback_t sent, void *ptr)
int ret = MAC_TX_DEFERRED; int ret = MAC_TX_DEFERRED;
int hdr_len = 0; int hdr_len = 0;
const linkaddr_t *addr = packetbuf_addr(PACKETBUF_ADDR_RECEIVER); const linkaddr_t *addr = packetbuf_addr(PACKETBUF_ADDR_RECEIVER);
uint8_t max_transmissions = 0;
if(!tsch_is_associated) { if(!tsch_is_associated) {
if(!tsch_is_initialized) { if(!tsch_is_initialized) {
@ -1006,13 +1007,21 @@ send_packet(mac_callback_t sent, void *ptr)
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr); packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
#endif #endif
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS);
#endif
if(max_transmissions == 0) {
/* If not set by the application, use the default TSCH value */
max_transmissions = TSCH_MAC_MAX_FRAME_RETRIES + 1;
}
if((hdr_len = NETSTACK_FRAMER.create()) < 0) { if((hdr_len = NETSTACK_FRAMER.create()) < 0) {
LOG_ERR("! can't send packet due to framer error\n"); LOG_ERR("! can't send packet due to framer error\n");
ret = MAC_TX_ERR; ret = MAC_TX_ERR;
} else { } else {
struct tsch_packet *p; struct tsch_packet *p;
/* Enqueue packet */ /* Enqueue packet */
p = tsch_queue_add_packet(addr, sent, ptr); p = tsch_queue_add_packet(addr, max_transmissions, sent, ptr);
if(p == NULL) { if(p == NULL) {
LOG_ERR("! can't send packet to "); LOG_ERR("! can't send packet to ");
LOG_ERR_LLADDR(addr); LOG_ERR_LLADDR(addr);

View File

@ -217,6 +217,9 @@ enum {
PACKETBUF_ATTR_LINK_QUALITY, PACKETBUF_ATTR_LINK_QUALITY,
PACKETBUF_ATTR_RSSI, PACKETBUF_ATTR_RSSI,
PACKETBUF_ATTR_TIMESTAMP, PACKETBUF_ATTR_TIMESTAMP,
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS,
#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */
PACKETBUF_ATTR_MAC_SEQNO, PACKETBUF_ATTR_MAC_SEQNO,
PACKETBUF_ATTR_MAC_ACK, PACKETBUF_ATTR_MAC_ACK,
PACKETBUF_ATTR_MAC_METADATA, PACKETBUF_ATTR_MAC_METADATA,

View File

@ -58,7 +58,7 @@ UNIT_TEST(test)
UNIT_TEST_BEGIN(); UNIT_TEST_BEGIN();
packet = tsch_queue_add_packet(TEST_PEER_ADDR, NULL, NULL); packet = tsch_queue_add_packet(TEST_PEER_ADDR, 1, NULL, NULL);
UNIT_TEST_ASSERT(packet != NULL); UNIT_TEST_ASSERT(packet != NULL);
nbr = tsch_queue_get_nbr(TEST_PEER_ADDR); nbr = tsch_queue_get_nbr(TEST_PEER_ADDR);
@ -68,14 +68,14 @@ UNIT_TEST(test)
* QUEUEBUF_CONF_NUM is set with 1; so another addition should fail due to * QUEUEBUF_CONF_NUM is set with 1; so another addition should fail due to
* lack of memory. * lack of memory.
*/ */
packet = tsch_queue_add_packet(TEST_PEER_ADDR, NULL, NULL); packet = tsch_queue_add_packet(TEST_PEER_ADDR, 1, NULL, NULL);
UNIT_TEST_ASSERT(packet == NULL); UNIT_TEST_ASSERT(packet == NULL);
/* tsch_queue_flush_nbr_queue() is called inside of tsch_queue_reset(). */ /* tsch_queue_flush_nbr_queue() is called inside of tsch_queue_reset(). */
tsch_queue_reset(); tsch_queue_reset();
/* After flushing the nbr queue, we should be able to add a new packet */ /* After flushing the nbr queue, we should be able to add a new packet */
packet = tsch_queue_add_packet(TEST_PEER_ADDR, NULL, NULL); packet = tsch_queue_add_packet(TEST_PEER_ADDR, 1, NULL, NULL);
UNIT_TEST_ASSERT(packet != NULL); UNIT_TEST_ASSERT(packet != NULL);
UNIT_TEST_END(); UNIT_TEST_END();