Cleanup CSMA logging

This commit is contained in:
Simon Duquennoy 2017-06-21 16:16:18 +02:00
parent 1dcba2a700
commit 07765f8e70
2 changed files with 23 additions and 23 deletions

View File

@ -57,7 +57,7 @@
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE_STR "CSMA"
#define LOG_MODULE_STR "
#define LOG_LEVEL MAC_LOG_LEVEL
/* Constants of the IEEE 802.15.4 standard */
@ -172,7 +172,7 @@ send_one_packet(mac_callback_t sent, void *ptr)
if(NETSTACK_FRAMER.create() < 0) {
/* Failed to allocate space for headers */
LOG_ERR("csma: send failed, too large header\n");
LOG_ERR("send failed, too large header\n");
ret = MAC_TX_ERR_FATAL;
} else {
#if CSMA_802154_AUTOACK
@ -244,7 +244,7 @@ send_one_packet(mac_callback_t sent, void *ptr)
}
}
} else {
LOG_WARN("csma tx noack\n");
LOG_WARN("tx noack\n");
}
}
break;
@ -290,7 +290,7 @@ transmit_from_queue(void *ptr)
if(n) {
struct packet_queue *q = list_head(n->packet_queue);
if(q != NULL) {
LOG_INFO("csma: preparing number %d %p, queue len %d\n", n->transmissions, q,
LOG_INFO("preparing number %d %p, queue len %d\n", n->transmissions, q,
list_length(n->packet_queue));
/* Send first packet in the neighbor queue */
queuebuf_to_packetbuf(q->buf);
@ -314,7 +314,7 @@ schedule_transmission(struct neighbor_queue *n)
delay = random_rand() % delay;
}
LOG_INFO("csma: scheduling transmission in %u ticks, NB=%u, BE=%u\n",
LOG_INFO("scheduling transmission in %u ticks, NB=%u, BE=%u\n",
(unsigned)delay, n->collisions, backoff_exponent);
ctimer_set(&n->transmit_timer, delay, transmit_from_queue, n);
}
@ -329,7 +329,7 @@ free_packet(struct neighbor_queue *n, struct packet_queue *p, int status)
queuebuf_free(p->buf);
memb_free(&metadata_memb, p->ptr);
memb_free(&packet_memb, p);
LOG_INFO("csma: free_queued_packet, queue length %d, free packets %d\n",
LOG_INFO("free_queued_packet, queue length %d, free packets %d\n",
list_length(n->packet_queue), memb_numfree(&packet_memb));
if(list_head(n->packet_queue) != NULL) {
/* There is a next packet. We reset current tx information */
@ -361,15 +361,15 @@ tx_done(int status, struct packet_queue *q, struct neighbor_queue *n)
switch(status) {
case MAC_TX_OK:
LOG_INFO("csma: tx ok %d\n", n->transmissions);
LOG_INFO("tx ok %d\n", n->transmissions);
break;
case MAC_TX_COLLISION:
case MAC_TX_NOACK:
LOG_WARN("csma: drop with status %d after %d transmissions, %d collisions\n",
LOG_WARN("drop with status %d after %d transmissions, %d collisions\n",
status, n->transmissions, n->collisions);
break;
default:
LOG_ERR("csma: tx failed %d: %d\n", n->transmissions, status);
LOG_ERR("tx failed %d: %d\n", n->transmissions, status);
break;
}
@ -405,7 +405,7 @@ collision(struct packet_queue *q, struct neighbor_queue *n,
if(n->transmissions >= metadata->max_transmissions) {
tx_done(MAC_TX_COLLISION, q, n);
} else {
LOG_INFO("csma: tx collision %d\n", n->transmissions);
LOG_INFO("tx collision %d\n", n->transmissions);
rexmit(q, n);
}
}
@ -423,7 +423,7 @@ noack(struct packet_queue *q, struct neighbor_queue *n, int num_transmissions)
if(n->transmissions >= metadata->max_transmissions) {
tx_done(MAC_TX_NOACK, q, n);
} else {
LOG_INFO("csma: tx noack %d\n", n->transmissions);
LOG_INFO("tx noack %d\n", n->transmissions);
rexmit(q, n);
}
}
@ -457,11 +457,11 @@ packet_sent(void *ptr, int status, int num_transmissions)
}
if(q == NULL) {
LOG_WARN("csma: seqno %d not found\n",
LOG_WARN("seqno %d not found\n",
packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO));
return;
} else if(q->ptr == NULL) {
LOG_WARN("csma: no metadata\n");
LOG_WARN("no metadata\n");
return;
}
@ -539,7 +539,7 @@ csma_output_packet(mac_callback_t sent, void *ptr)
metadata->cptr = ptr;
list_add(n->packet_queue, q);
LOG_INFO("csma: send_packet, queue length %d, free packets %d\n",
LOG_INFO("send_packet, queue length %d, free packets %d\n",
list_length(n->packet_queue), memb_numfree(&packet_memb));
/* If q is the first packet in the neighbor's queue, send asap */
if(list_head(n->packet_queue) == q) {
@ -548,10 +548,10 @@ csma_output_packet(mac_callback_t sent, void *ptr)
return;
}
memb_free(&metadata_memb, q->ptr);
LOG_WARN("csma: could not allocate queuebuf, dropping packet\n");
LOG_WARN("could not allocate queuebuf, dropping packet\n");
}
memb_free(&packet_memb, q);
LOG_WARN("csma: could not allocate queuebuf, dropping packet\n");
LOG_WARN("could not allocate queuebuf, dropping packet\n");
}
/* The packet allocation failed. Remove and free neighbor entry if empty. */
if(list_length(n->packet_queue) == 0) {
@ -559,11 +559,11 @@ csma_output_packet(mac_callback_t sent, void *ptr)
memb_free(&neighbor_memb, n);
}
} else {
LOG_WARN("csma: Neighbor queue full\n");
LOG_WARN("Neighbor queue full\n");
}
LOG_WARN("csma: could not allocate packet, dropping packet\n");
LOG_WARN("could not allocate packet, dropping packet\n");
} else {
LOG_WARN("csma: could not allocate neighbor, dropping packet\n");
LOG_WARN("could not allocate neighbor, dropping packet\n");
}
mac_call_sent_callback(sent, ptr, MAC_TX_ERR, 1);
}

View File

@ -70,15 +70,15 @@ input_packet(void)
#if CSMA_802154_AUTOACK
if(packetbuf_datalen() == CSMA_ACK_LEN) {
/* Ignore ack packets */
LOG_INFO("csma: ignored ack\n");
LOG_INFO("ignored ack\n");
} else
#endif /* CSMA_802154_AUTOACK */
if(NETSTACK_FRAMER.parse() < 0) {
LOG_ERR("csma: failed to parse %u\n", packetbuf_datalen());
LOG_ERR("failed to parse %u\n", packetbuf_datalen());
} else if(!linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
&linkaddr_node_addr) &&
!packetbuf_holds_broadcast()) {
LOG_WARN("csma: not for us\n");
LOG_WARN("not for us\n");
} else {
int duplicate = 0;
@ -87,7 +87,7 @@ input_packet(void)
duplicate = mac_sequence_is_duplicate();
if(duplicate) {
/* Drop the packet. */
LOG_WARN("csma: drop duplicate link layer packet %u\n",
LOG_WARN("drop duplicate link layer packet %u\n",
packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO));
} else {
mac_sequence_register_seqno();