Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/ethernet/eth_native_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define _ETH_MTU 1500
#endif

#define NET_BUF_TIMEOUT MSEC(10)
#define NET_BUF_TIMEOUT K_MSEC(100)

#if defined(CONFIG_NET_VLAN)
#define ETH_HDR_LEN sizeof(struct net_eth_vlan_hdr)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static int loopback_send(struct net_if *iface, struct net_pkt *pkt)
* must be dropped. This is very much needed for TCP packets where
* the packet is reference counted in various stages of sending.
*/
cloned = net_pkt_clone(pkt, MSEC(100));
cloned = net_pkt_clone(pkt, K_MSEC(100));
if (!cloned) {
res = -ENOMEM;
goto out;
Expand Down
2 changes: 1 addition & 1 deletion subsys/net/ip/6lo_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@
* that can cause the stack to deadlock. This can happen if RX side is flooding
* incoming data and we cannot get process the packet in 6lo side.
*/
#define NET_6LO_RX_PKT_TIMEOUT 100 /* in ms */
#define NET_6LO_RX_PKT_TIMEOUT K_MSEC(100) /* in ms */
12 changes: 5 additions & 7 deletions subsys/net/ip/dhcpv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,7 @@ static void send_request(struct net_if *iface)
timeout = DHCPV4_INITIAL_RETRY_TIMEOUT <<
iface->config.dhcpv4.attempts;

k_delayed_work_submit(&iface->config.dhcpv4.timer,
timeout * MSEC_PER_SEC);
k_delayed_work_submit(&iface->config.dhcpv4.timer, K_SECONDS(timeout));

iface->config.dhcpv4.attempts++;

Expand Down Expand Up @@ -491,8 +490,7 @@ static void send_discover(struct net_if *iface)

timeout = DHCPV4_INITIAL_RETRY_TIMEOUT << iface->config.dhcpv4.attempts;

k_delayed_work_submit(&iface->config.dhcpv4.timer,
timeout * MSEC_PER_SEC);
k_delayed_work_submit(&iface->config.dhcpv4.timer, K_SECONDS(timeout));

iface->config.dhcpv4.attempts++;

Expand Down Expand Up @@ -621,11 +619,11 @@ static void enter_bound(struct net_if *iface)

/* Start renewal time */
k_delayed_work_submit(&iface->config.dhcpv4.t1_timer,
renewal_time * MSEC_PER_SEC);
K_SECONDS(renewal_time));

/* Start rebinding time */
k_delayed_work_submit(&iface->config.dhcpv4.t2_timer,
rebinding_time * MSEC_PER_SEC);
K_SECONDS(rebinding_time));
}

static void dhcpv4_timeout(struct k_work *work)
Expand Down Expand Up @@ -1117,7 +1115,7 @@ void net_dhcpv4_start(struct net_if *iface)
NET_DBG("wait timeout=%"PRIu32"s", timeout);

k_delayed_work_submit(&iface->config.dhcpv4.timer,
timeout * MSEC_PER_SEC);
K_SECONDS(timeout));
break;
case NET_DHCPV4_INIT:
case NET_DHCPV4_SELECTING:
Expand Down
14 changes: 7 additions & 7 deletions subsys/net/ip/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/* Timeout value to be used when allocating net buffer during various
* neighbor discovery procedures.
*/
#define ND_NET_BUF_TIMEOUT MSEC(100)
#define ND_NET_BUF_TIMEOUT K_MSEC(100)

/* Maximum reachable time value specified in RFC 4861 section
* 6.2.1. Router Configuration Variables, AdvReachableTime
Expand All @@ -65,8 +65,8 @@ static void nd_reachable_timeout(struct k_work *work);

#define MAX_MULTICAST_SOLICIT 3
#define MAX_UNICAST_SOLICIT 3
#define DELAY_FIRST_PROBE_TIME (5 * MSEC_PER_SEC) /* RFC 4861 ch 10 */
#define RETRANS_TIMER 1000 /* in ms, RFC 4861 ch 10 */
#define DELAY_FIRST_PROBE_TIME K_SECONDS(5) /* RFC 4861 ch 10 */
#define RETRANS_TIMER K_MSEC(1000) /* in ms, RFC 4861 ch 10 */

extern void net_neighbor_data_remove(struct net_nbr *nbr);
extern void net_neighbor_table_clear(struct net_nbr_table *table);
Expand Down Expand Up @@ -318,7 +318,7 @@ bool net_ipv6_nbr_rm(struct net_if *iface, struct in6_addr *addr)
return true;
}

#define NS_REPLY_TIMEOUT MSEC_PER_SEC
#define NS_REPLY_TIMEOUT K_SECONDS(1)

static void ns_reply_timeout(struct k_work *work)
{
Expand Down Expand Up @@ -2398,7 +2398,7 @@ static inline void handle_prefix_onlink(struct net_pkt *pkt,

static inline u32_t remaining(struct k_delayed_work *work)
{
return k_delayed_work_remaining_get(work) / MSEC_PER_SEC;
return k_delayed_work_remaining_get(work) / K_SECONDS(1);
}

static inline void handle_prefix_autonomous(struct net_pkt *pkt,
Expand Down Expand Up @@ -3087,7 +3087,7 @@ static struct net_icmpv6_handler ra_input_handler = {
#define IPV6_REASSEMBLY_TIMEOUT K_SECONDS(5)
#endif /* CONFIG_NET_IPV6_FRAGMENT_TIMEOUT */

#define FRAG_BUF_WAIT 10 /* how long to max wait for a buffer */
#define FRAG_BUF_WAIT K_MSEC(10) /* how long to max wait for a buffer */

static void reassembly_timeout(struct k_work *work);
static bool reassembly_init_done;
Expand Down Expand Up @@ -3764,7 +3764,7 @@ static int send_ipv6_fragment(struct net_if *iface,
return ret;
}

#define BUF_ALLOC_TIMEOUT 100
#define BUF_ALLOC_TIMEOUT K_MSEC(100)

int net_ipv6_send_fragmented_pkt(struct net_if *iface, struct net_pkt *pkt,
u16_t pkt_len)
Expand Down
2 changes: 1 addition & 1 deletion subsys/net/ip/l2/ethernet/arp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <net/arp.h>
#include "net_private.h"

#define NET_BUF_TIMEOUT MSEC(100)
#define NET_BUF_TIMEOUT K_MSEC(100)

static struct arp_entry arp_table[CONFIG_NET_ARP_TABLE_SIZE];

Expand Down
4 changes: 2 additions & 2 deletions subsys/net/ip/l2/ieee802154/ieee802154_fragment.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include "6lo.h"
#include "6lo_private.h"

#define FRAG_REASSEMBLY_TIMEOUT (MSEC_PER_SEC * \
CONFIG_NET_L2_IEEE802154_REASSEMBLY_TIMEOUT)
#define FRAG_REASSEMBLY_TIMEOUT \
K_SECONDS(CONFIG_NET_L2_IEEE802154_REASSEMBLY_TIMEOUT)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should convert this to msecs for better granularity. In a separate PR apparently.

#define REASS_CACHE_SIZE CONFIG_NET_L2_IEEE802154_FRAGMENT_REASS_CACHE_SIZE

static u16_t datagram_tag;
Expand Down
21 changes: 9 additions & 12 deletions subsys/net/ip/net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "net_stats.h"

#define REACHABLE_TIME (30 * MSEC_PER_SEC) /* in ms */
#define REACHABLE_TIME K_SECONDS(30) /* in ms */
/*
* split the min/max random reachable factors into numerator/denominator
* so that integer-based math works better
Expand Down Expand Up @@ -504,7 +504,7 @@ static void leave_mcast_all(struct net_if *iface)
#endif /* CONFIG_NET_IPV6_MLD */

#if defined(CONFIG_NET_IPV6_DAD)
#define DAD_TIMEOUT (MSEC_PER_SEC / 10)
#define DAD_TIMEOUT K_MSEC(100)

static void dad_timeout(struct k_work *work)
{
Expand Down Expand Up @@ -621,7 +621,7 @@ static inline void net_if_ipv6_start_dad(struct net_if *iface,
#endif /* CONFIG_NET_IPV6_DAD */

#if defined(CONFIG_NET_IPV6_ND)
#define RS_TIMEOUT MSEC_PER_SEC
#define RS_TIMEOUT K_SECONDS(1)
#define RS_COUNT 3

static void rs_timeout(struct k_work *work)
Expand Down Expand Up @@ -723,8 +723,7 @@ void net_if_ipv6_addr_update_lifetime(struct net_if_addr *ifaddr,
net_sprint_ipv6_addr(&ifaddr->address.in6_addr),
vlifetime);

k_delayed_work_submit(&ifaddr->lifetime,
vlifetime * MSEC_PER_SEC);
k_delayed_work_submit(&ifaddr->lifetime, K_SECONDS(vlifetime));
}

static struct net_if_addr *ipv6_addr_find(struct net_if *iface,
Expand Down Expand Up @@ -1240,18 +1239,18 @@ void net_if_ipv6_prefix_set_timer(struct net_if_ipv6_prefix *prefix,
* all bits set means infinite and that value is never set
* to timer.
*/
u32_t timeout = lifetime * MSEC_PER_SEC;
u32_t timeout = K_SECONDS(lifetime);

NET_ASSERT(lifetime != 0xffffffff);

if (lifetime > (0xfffffffe / MSEC_PER_SEC)) {
if (lifetime > (0xfffffffe / K_SECONDS(1))) {
timeout = 0xfffffffe;

NET_ERR("Prefix %s/%d lifetime %u overflow, "
"setting it to %u secs",
net_sprint_ipv6_addr(&prefix->prefix),
prefix->len,
lifetime, timeout / MSEC_PER_SEC);
lifetime, timeout / K_SECONDS(1));
}

NET_DBG("Prefix lifetime %u ms", timeout);
Expand Down Expand Up @@ -1329,8 +1328,7 @@ void net_if_ipv6_router_update_lifetime(struct net_if_router *router,
net_sprint_ipv6_addr(&router->address.in6_addr),
lifetime);

k_delayed_work_submit(&router->lifetime,
lifetime * MSEC_PER_SEC);
k_delayed_work_submit(&router->lifetime, K_SECONDS(lifetime));
}

static inline void net_if_router_init(struct net_if_router *router,
Expand All @@ -1350,8 +1348,7 @@ static inline void net_if_router_init(struct net_if_router *router,
router->is_infinite = false;

k_delayed_work_init(&router->lifetime, ipv6_router_expired);
k_delayed_work_submit(&router->lifetime,
lifetime * MSEC_PER_SEC);
k_delayed_work_submit(&router->lifetime, K_SECONDS(lifetime));

NET_DBG("Expiring %s in %u secs", net_sprint_ipv6_addr(addr),
lifetime);
Expand Down
2 changes: 1 addition & 1 deletion subsys/net/ip/net_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,7 @@ static void print_dns_info(struct dns_resolve_context *ctx)
int net_shell_cmd_dns(int argc, char *argv[])
{
#if defined(CONFIG_DNS_RESOLVER)
#define DNS_TIMEOUT 2000 /* ms */
#define DNS_TIMEOUT K_MSEC(2000) /* ms */

struct dns_resolve_context *ctx;
enum dns_query_type qtype = DNS_QUERY_TYPE_A;
Expand Down
27 changes: 13 additions & 14 deletions subsys/net/ip/rpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static void net_rpl_print_parents(void)
parent == rpl_default_instance->current_dag->
preferred_parent ? '*' : ' ',
(unsigned)((now - parent->last_tx_time) /
(60 * MSEC_PER_SEC)));
K_SECONDS(60)));
}
}

Expand Down Expand Up @@ -604,7 +604,7 @@ int net_rpl_dio_send(struct net_if *iface,
return ret;
}

#define DIO_TIMEOUT (MSEC_PER_SEC)
#define DIO_TIMEOUT K_SECONDS(1)

static void dio_timer(struct k_work *work)
{
Expand Down Expand Up @@ -828,11 +828,11 @@ static struct net_rpl_instance *net_rpl_get_instance(u8_t instance_id)
#if defined(CONFIG_NET_RPL_PROBING)

#if !defined(NET_RPL_PROBING_INTERVAL)
#define NET_RPL_PROBING_INTERVAL (120 * MSEC_PER_SEC)
#define NET_RPL_PROBING_INTERVAL K_SECONDS(120)
#endif

#if !defined(NET_RPL_PROBING_EXPIRATION_TIME)
#define NET_RPL_PROBING_EXPIRATION_TIME ((10 * 60) * MSEC_PER_SEC)
#define NET_RPL_PROBING_EXPIRATION_TIME K_SECONDS(10 * 60)
#endif

static void net_rpl_schedule_probing(struct net_rpl_instance *instance);
Expand Down Expand Up @@ -962,7 +962,7 @@ static void net_rpl_schedule_probing(struct net_rpl_instance *instance)

expiration = ((NET_RPL_PROBING_INTERVAL / 2) +
sys_rand32_get() % NET_RPL_PROBING_INTERVAL) *
MSEC_PER_SEC;
K_SECONDS(1);

NET_DBG("Send probe in %d ms, instance %p (%d)",
expiration, instance, instance->instance_id);
Expand Down Expand Up @@ -1643,8 +1643,7 @@ static void set_dao_lifetime_timer(struct net_rpl_instance *instance)
u32_t expiration_time;

expiration_time = (u32_t)instance->default_lifetime *
(u32_t)instance->lifetime_unit *
MSEC_PER_SEC / 2;
(u32_t)instance->lifetime_unit * K_SECONDS(1) / 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe K_MSEC(500) after all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment few lines above says "Set up another DAO within half the expiration time" so in this respect it makes sense to leave the division in place.


instance->dao_lifetime_timer_active = true;

Expand All @@ -1669,7 +1668,7 @@ static void dao_send_timer(struct k_work *work)

instance->dao_timer_active = true;

k_delayed_work_submit(&instance->dao_timer, MSEC_PER_SEC);
k_delayed_work_submit(&instance->dao_timer, K_SECONDS(1));
return;
}

Expand All @@ -1690,7 +1689,7 @@ static void schedule_dao(struct net_rpl_instance *instance, int latency)
}

if (latency != 0) {
latency = latency * MSEC_PER_SEC;
latency = K_SECONDS(latency);
expiration = latency / 2 + (sys_rand32_get() % latency);
} else {
expiration = 0;
Expand Down Expand Up @@ -4191,7 +4190,7 @@ static void dis_timeout(struct k_work *work)

net_rpl_dis_send(NULL, rpl_default_iface);

dis_interval = CONFIG_NET_RPL_DIS_INTERVAL * MSEC_PER_SEC;
dis_interval = K_SECONDS(CONFIG_NET_RPL_DIS_INTERVAL);

k_delayed_work_submit(&dis_timer, dis_interval);
}
Expand All @@ -4203,10 +4202,10 @@ static inline void net_rpl_init_timers(void)
/* Randomize the first DIS sending*/
u32_t dis_interval;

dis_interval = (CONFIG_NET_RPL_DIS_INTERVAL / 2 +
((u32_t)CONFIG_NET_RPL_DIS_INTERVAL *
(u32_t)sys_rand32_get()) / UINT_MAX -
NET_RPL_DIS_START_DELAY) * MSEC_PER_SEC;
dis_interval = K_SECONDS(CONFIG_NET_RPL_DIS_INTERVAL / 2 +
((u32_t)CONFIG_NET_RPL_DIS_INTERVAL *
(u32_t)sys_rand32_get()) / UINT_MAX -
NET_RPL_DIS_START_DELAY);

k_delayed_work_init(&dis_timer, dis_timeout);
k_delayed_work_submit(&dis_timer, dis_interval);
Expand Down
2 changes: 1 addition & 1 deletion subsys/net/ip/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "tcp_internal.h"
#include "net_stats.h"

#define ALLOC_TIMEOUT 500
#define ALLOC_TIMEOUT K_MSEC(500)

/*
* Each TCP connection needs to be tracked by net_context, so
Expand Down
2 changes: 1 addition & 1 deletion subsys/net/lib/dns/mdns_responder.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
static struct net_context *ipv4;
static struct net_context *ipv6;

#define BUF_ALLOC_TIMEOUT MSEC(100)
#define BUF_ALLOC_TIMEOUT K_MSEC(100)

/* This value is recommended by RFC 1035 */
#define DNS_RESOLVER_MAX_BUF_SIZE 512
Expand Down