drivers: eth: Convert to use new logging

Convert the ethernet drivers to use the new logging system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2018-07-09 12:51:28 +03:00
commit 20295c821b
9 changed files with 170 additions and 165 deletions

View file

@ -8,19 +8,13 @@
menu "Ethernet Drivers"
config SYS_LOG_ETHERNET_LEVEL
int "Ethernet driver log level"
depends on SYS_LOG && NET_L2_ETHERNET
default 0
range 0 4
help
Sets log level for Ethernet Device Drivers.
Levels are:
0 OFF, do not write
1 ERROR, only write SYS_LOG_ERR
2 WARNING, write SYS_LOG_WRN in addition to previous level
3 INFO, write SYS_LOG_INF in addition to previous levels
4 DEBUG, write SYS_LOG_DBG in addition to previous levels
if NET_L2_ETHERNET
module=ETHERNET
module-dep=LOG
module-str=Log level for Ethernet driver
module-help=Sets log level for Ethernet Device Drivers.
source "subsys/net/Kconfig.template.log_config.net"
endif # NET_L2_ETHERNET
config ETH_INIT_PRIORITY
int "Ethernet driver init priority"

View file

@ -3,9 +3,11 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#define SYS_LOG_DOMAIN "ETH DW"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ETHERNET_LEVEL
#include <logging/sys_log.h>
#define LOG_MODULE_NAME eth_dw
#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <board.h>
#include <device.h>
@ -51,19 +53,19 @@ static void eth_rx(struct device *port)
* process the received frame or an error that may have occurred.
*/
if (context->rx_desc.own) {
SYS_LOG_ERR("Spurious receive interrupt from Ethernet MAC");
LOG_ERR("Spurious receive interrupt from Ethernet MAC");
return;
}
if (context->rx_desc.err_summary) {
SYS_LOG_ERR("Error receiving frame: RDES0 = %08x, RDES1 = %08x",
LOG_ERR("Error receiving frame: RDES0 = %08x, RDES1 = %08x",
context->rx_desc.rdes0, context->rx_desc.rdes1);
goto release_desc;
}
frm_len = context->rx_desc.frm_len;
if (frm_len > sizeof(context->rx_buf)) {
SYS_LOG_ERR("Frame too large: %u", frm_len);
LOG_ERR("Frame too large: %u", frm_len);
goto release_desc;
}
@ -77,7 +79,7 @@ static void eth_rx(struct device *port)
* received frame length by exactly 4 bytes.
*/
if (frm_len < sizeof(u32_t)) {
SYS_LOG_ERR("Frame too small: %u", frm_len);
LOG_ERR("Frame too small: %u", frm_len);
goto release_desc;
} else {
frm_len -= sizeof(u32_t);
@ -85,20 +87,20 @@ static void eth_rx(struct device *port)
pkt = net_pkt_get_reserve_rx(0, K_NO_WAIT);
if (!pkt) {
SYS_LOG_ERR("Failed to obtain RX buffer");
LOG_ERR("Failed to obtain RX buffer");
goto release_desc;
}
if (!net_pkt_append_all(pkt, frm_len, (u8_t *)context->rx_buf,
K_NO_WAIT)) {
SYS_LOG_ERR("Failed to append RX buffer to context buffer");
LOG_ERR("Failed to append RX buffer to context buffer");
net_pkt_unref(pkt);
goto release_desc;
}
r = net_recv_data(context->iface, pkt);
if (r < 0) {
SYS_LOG_ERR("Failed to enqueue frame into RX queue: %d", r);
LOG_ERR("Failed to enqueue frame into RX queue: %d", r);
net_pkt_unref(pkt);
}
@ -132,7 +134,7 @@ static void eth_tx_data(struct eth_runtime *context, u8_t *data, u16_t len)
#ifdef CONFIG_NET_DEBUG_L2_ETHERNET
/* Check whether an error occurred transmitting the previous frame. */
if (context->tx_desc.err_summary) {
SYS_LOG_ERR("Error transmitting frame: TDES0 = %08x,"
LOG_ERR("Error transmitting frame: TDES0 = %08x,"
"TDES1 = %08x", context->tx_desc.tdes0,
context->tx_desc.tdes1);
}
@ -313,7 +315,7 @@ static int eth_initialize_internal(struct net_if *iface)
/* Place the receiver state machine in the Running state. */
OP_MODE_1_START_RX);
SYS_LOG_INF("Enabled 100M full-duplex mode");
LOG_INF("Enabled 100M full-duplex mode");
config->config_func(port);
@ -325,7 +327,7 @@ static void eth_initialize(struct net_if *iface)
int r = eth_initialize_internal(iface);
if (r < 0) {
SYS_LOG_ERR("Could not initialize ethernet device: %d", r);
LOG_ERR("Could not initialize ethernet device: %d", r);
}
}

View file

@ -5,9 +5,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ETHERNET_LEVEL
#define SYS_LOG_DOMAIN "dev/enc28j60"
#include <logging/sys_log.h>
#define LOG_MODULE_NAME eth_enc28j60
#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <zephyr.h>
#include <device.h>
@ -69,7 +71,7 @@ static void eth_enc28j60_set_bank(struct device *dev, u16_t reg_addr)
spi_write(context->spi, &context->spi_cfg, &tx);
} else {
SYS_LOG_DBG("Failure while setting bank to 0x%04x", reg_addr);
LOG_DBG("Failure while setting bank to 0x%04x", reg_addr);
}
}
@ -127,7 +129,7 @@ static void eth_enc28j60_read_reg(struct device *dev, u16_t reg_addr,
if (!spi_transceive(context->spi, &context->spi_cfg, &tx, &rx)) {
*value = buf[rx_size - 1];
} else {
SYS_LOG_DBG("Failure while reading register 0x%04x", reg_addr);
LOG_DBG("Failure while reading register 0x%04x", reg_addr);
*value = 0;
}
}
@ -200,7 +202,7 @@ static void eth_enc28j60_write_mem(struct device *dev, u8_t *data_buffer,
tx_buf[1].len = MAX_BUFFER_LENGTH;
if (spi_write(context->spi, &context->spi_cfg, &tx)) {
SYS_LOG_ERR("Failed to write memory");
LOG_ERR("Failed to write memory");
return;
}
}
@ -210,7 +212,7 @@ static void eth_enc28j60_write_mem(struct device *dev, u8_t *data_buffer,
tx_buf[1].len = num_remaining;
if (spi_write(context->spi, &context->spi_cfg, &tx)) {
SYS_LOG_ERR("Failed to write memory");
LOG_ERR("Failed to write memory");
}
}
}
@ -251,7 +253,7 @@ static void eth_enc28j60_read_mem(struct device *dev, u8_t *data_buffer,
rx_buf[1].len = MAX_BUFFER_LENGTH;
if (spi_transceive(context->spi, &context->spi_cfg, &tx, &rx)) {
SYS_LOG_ERR("Failed to read memory");
LOG_ERR("Failed to read memory");
return;
}
}
@ -261,7 +263,7 @@ static void eth_enc28j60_read_mem(struct device *dev, u8_t *data_buffer,
rx_buf[1].len = num_remaining;
if (spi_transceive(context->spi, &context->spi_cfg, &tx, &rx)) {
SYS_LOG_ERR("Failed to read memory");
LOG_ERR("Failed to read memory");
}
}
}
@ -415,7 +417,7 @@ static int eth_enc28j60_tx(struct net_if *iface, struct net_pkt *pkt)
struct net_buf *frag;
u8_t tx_end;
SYS_LOG_DBG("pkt %p (len %u)", pkt, len);
LOG_DBG("pkt %p (len %u)", pkt, len);
k_sem_take(&context->tx_rx_sem, K_FOREVER);
@ -481,13 +483,13 @@ static int eth_enc28j60_tx(struct net_if *iface, struct net_pkt *pkt)
k_sem_give(&context->tx_rx_sem);
if (tx_end & ENC28J60_BIT_ESTAT_TXABRT) {
SYS_LOG_ERR("TX failed!");
LOG_ERR("TX failed!");
return -EIO;
}
net_pkt_unref(pkt);
SYS_LOG_DBG("Tx successful");
LOG_DBG("Tx successful");
return 0;
}
@ -509,8 +511,6 @@ static int eth_enc28j60_rx(struct device *dev)
return 0;
}
SYS_LOG_DBG("");
k_sem_take(&context->tx_rx_sem, K_FOREVER);
do {
@ -555,7 +555,7 @@ static int eth_enc28j60_rx(struct device *dev)
/* Get the frame from the buffer */
pkt = net_pkt_get_reserve_rx(0, config->timeout);
if (!pkt) {
SYS_LOG_ERR("Could not allocate rx buffer");
LOG_ERR("Could not allocate rx buffer");
goto done;
}
@ -567,7 +567,7 @@ static int eth_enc28j60_rx(struct device *dev)
/* Reserve a data frag to receive the frame */
pkt_buf = net_pkt_get_frag(pkt, config->timeout);
if (!pkt_buf) {
SYS_LOG_ERR("Could not allocate data buffer");
LOG_ERR("Could not allocate data buffer");
net_pkt_unref(pkt);
goto done;
@ -611,7 +611,7 @@ static int eth_enc28j60_rx(struct device *dev)
}
/* Feed buffer frame to IP stack */
SYS_LOG_DBG("Received packet of length %u", lengthfr);
LOG_DBG("Received packet of length %u", lengthfr);
net_recv_data(context->iface, pkt);
done:
/* Free buffer memory and decrement rx counter */
@ -664,8 +664,6 @@ static void eth_enc28j60_iface_init(struct net_if *iface)
struct device *dev = net_if_get_device(iface);
struct eth_enc28j60_runtime *context = dev->driver_data;
SYS_LOG_DBG("");
net_if_set_link_addr(iface, context->mac_address,
sizeof(context->mac_address),
NET_LINK_ETHERNET);
@ -692,7 +690,7 @@ static int eth_enc28j60_init(struct device *dev)
context->spi = device_get_binding((char *)config->spi_port);
if (!context->spi) {
SYS_LOG_ERR("SPI master port %s not found", config->spi_port);
LOG_ERR("SPI master port %s not found", config->spi_port);
return -EINVAL;
}
@ -700,7 +698,7 @@ static int eth_enc28j60_init(struct device *dev)
context->spi_cs.gpio_dev =
device_get_binding((char *)config->spi_cs_port);
if (!context->spi_cs.gpio_dev) {
SYS_LOG_ERR("SPI CS port %s not found", config->spi_cs_port);
LOG_ERR("SPI CS port %s not found", config->spi_cs_port);
return -EINVAL;
}
@ -711,14 +709,14 @@ static int eth_enc28j60_init(struct device *dev)
/* Initialize GPIO */
context->gpio = device_get_binding((char *)config->gpio_port);
if (!context->gpio) {
SYS_LOG_ERR("GPIO port %s not found", config->gpio_port);
LOG_ERR("GPIO port %s not found", config->gpio_port);
return -EINVAL;
}
if (gpio_pin_configure(context->gpio, config->gpio_pin,
(GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE
| GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE))) {
SYS_LOG_ERR("Unable to configure GPIO pin %u",
LOG_ERR("Unable to configure GPIO pin %u",
config->gpio_pin);
return -EINVAL;
}
@ -735,7 +733,7 @@ static int eth_enc28j60_init(struct device *dev)
}
if (eth_enc28j60_soft_reset(dev)) {
SYS_LOG_ERR("Soft-reset failed");
LOG_ERR("Soft-reset failed");
return -EIO;
}
@ -762,7 +760,7 @@ static int eth_enc28j60_init(struct device *dev)
K_PRIO_COOP(CONFIG_ETH_ENC28J60_RX_THREAD_PRIO),
0, K_NO_WAIT);
SYS_LOG_INF("ENC28J60 Initialized");
LOG_INF("ENC28J60 Initialized");
return 0;
}

View file

@ -13,9 +13,11 @@
* error behaviour.
*/
#define SYS_LOG_DOMAIN "dev/eth_mcux"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ETHERNET_LEVEL
#include <logging/sys_log.h>
#define LOG_MODULE_NAME eth_mcux
#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <board.h>
#include <device.h>
@ -194,7 +196,7 @@ static void eth_mcux_phy_enter_reset(struct eth_context *context)
static void eth_mcux_phy_start(struct eth_context *context)
{
#ifdef CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG
SYS_LOG_DBG("phy_state=%s", phy_state_name(context->phy_state));
LOG_DBG("phy_state=%s", phy_state_name(context->phy_state));
#endif
context->enabled = true;
@ -218,7 +220,7 @@ static void eth_mcux_phy_start(struct eth_context *context)
void eth_mcux_phy_stop(struct eth_context *context)
{
#ifdef CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG
SYS_LOG_DBG("phy_state=%s", phy_state_name(context->phy_state));
LOG_DBG("phy_state=%s", phy_state_name(context->phy_state));
#endif
context->enabled = false;
@ -255,7 +257,7 @@ static void eth_mcux_phy_event(struct eth_context *context)
const u32_t phy_addr = 0;
#ifdef CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG
SYS_LOG_DBG("phy_state=%s", phy_state_name(context->phy_state));
LOG_DBG("phy_state=%s", phy_state_name(context->phy_state));
#endif
switch (context->phy_state) {
case eth_mcux_phy_state_initial:
@ -305,7 +307,7 @@ static void eth_mcux_phy_event(struct eth_context *context)
context->phy_state = eth_mcux_phy_state_read_duplex;
net_eth_carrier_on(context->iface);
} else if (!link_up && context->link_up) {
SYS_LOG_INF("Link down");
LOG_INF("Link down");
context->link_up = link_up;
k_delayed_work_submit(&context->delayed_phy_work,
CONFIG_ETH_MCUX_PHY_TICK_MS);
@ -333,7 +335,7 @@ static void eth_mcux_phy_event(struct eth_context *context)
(enet_mii_duplex_t) phy_duplex);
}
SYS_LOG_INF("Enabled %sM %s-duplex mode.",
LOG_INF("Enabled %sM %s-duplex mode.",
(phy_speed ? "100" : "10"),
(phy_duplex ? "full" : "half"));
k_delayed_work_submit(&context->delayed_phy_work,
@ -413,12 +415,12 @@ static bool eth_get_ptp_data(struct net_if *iface, struct net_pkt *pkt,
ptpTsData->sequenceId = ntohs(hdr->sequence_id);
#ifdef CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG
SYS_LOG_DBG("PTP packet: ver %d type %d len %d "
"clk %02x%02x%02x%02x%02x%02x%02x%02x port %d "
"seq %d",
LOG_DBG("PTP packet: ver %d type %d len %d seq %d",
ptpTsData->version,
ptpTsData->messageType,
ntohs(hdr->message_length),
ptpTsData->sequenceId);
LOG_DBG(" clk %02x%02x%02x%02x%02x%02x%02x%02x port %d",
hdr->port_id.clk_id[0],
hdr->port_id.clk_id[1],
hdr->port_id.clk_id[2],
@ -427,8 +429,7 @@ static bool eth_get_ptp_data(struct net_if *iface, struct net_pkt *pkt,
hdr->port_id.clk_id[5],
hdr->port_id.clk_id[6],
hdr->port_id.clk_id[7],
ntohs(hdr->port_id.port_number),
ptpTsData->sequenceId);
ntohs(hdr->port_id.port_number));
#endif
}
@ -506,7 +507,7 @@ static int eth_tx(struct net_if *iface, struct net_pkt *pkt)
irq_unlock(imask);
if (status) {
SYS_LOG_ERR("ENET_SendFrame error: %d", (int)status);
LOG_ERR("ENET_SendFrame error: %d", (int)status);
return -1;
}
@ -535,7 +536,7 @@ static void eth_rx(struct device *iface)
if (status) {
enet_data_error_stats_t error_stats;
SYS_LOG_ERR("ENET_GetRxFrameSize return: %d", (int)status);
LOG_ERR("ENET_GetRxFrameSize return: %d", (int)status);
ENET_GetRxErrBeforeReadFrame(&context->enet_handle,
&error_stats);
@ -564,7 +565,7 @@ static void eth_rx(struct device *iface)
}
if (sizeof(context->frame_buf) < frame_length) {
SYS_LOG_ERR("frame too large (%d)", frame_length);
LOG_ERR("frame too large (%d)", frame_length);
net_pkt_unref(pkt);
status = ENET_ReadFrame(ENET, &context->enet_handle, NULL, 0);
assert(status == kStatus_Success);
@ -580,7 +581,7 @@ static void eth_rx(struct device *iface)
context->frame_buf, frame_length);
if (status) {
irq_unlock(imask);
SYS_LOG_ERR("ENET_ReadFrame failed: %d", (int)status);
LOG_ERR("ENET_ReadFrame failed: %d", (int)status);
net_pkt_unref(pkt);
return;
}
@ -594,7 +595,7 @@ static void eth_rx(struct device *iface)
pkt_buf = net_pkt_get_frag(pkt, K_NO_WAIT);
if (!pkt_buf) {
irq_unlock(imask);
SYS_LOG_ERR("Failed to get fragment buf");
LOG_ERR("Failed to get fragment buf");
net_pkt_unref(pkt);
assert(status == kStatus_Success);
return;
@ -690,7 +691,7 @@ static inline void ts_register_tx_event(struct eth_context *context)
net_pkt_unref(pkt);
} else {
if (IS_ENABLED(CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG) && pkt) {
SYS_LOG_ERR("pkt %p already freed", pkt);
LOG_ERR("pkt %p already freed", pkt);
}
}
@ -839,7 +840,7 @@ static int eth_0_init(struct device *dev)
ENET_SetSMI(ENET, sys_clock, false);
SYS_LOG_DBG("MAC %02x:%02x:%02x:%02x:%02x:%02x",
LOG_DBG("MAC %02x:%02x:%02x:%02x:%02x:%02x",
context->mac_addr[0], context->mac_addr[1],
context->mac_addr[2], context->mac_addr[3],
context->mac_addr[4], context->mac_addr[5]);

View file

@ -11,10 +11,12 @@
* connectivity between host and Zephyr.
*/
#define SYS_LOG_DOMAIN "eth-posix"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ETHERNET_LEVEL
#define LOG_MODULE_NAME eth_posix
#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <logging/sys_log.h>
#include <stdio.h>
#include <kernel.h>
@ -239,11 +241,11 @@ static int eth_send(struct net_if *iface, struct net_pkt *pkt)
update_gptp(iface, pkt, true);
SYS_LOG_DBG("Send pkt %p len %d", pkt, count);
LOG_DBG("Send pkt %p len %d", pkt, count);
ret = eth_write_data(ctx->dev_fd, ctx->send, count);
if (ret < 0) {
SYS_LOG_DBG("Cannot send pkt %p (%d)", pkt, ret);
LOG_DBG("Cannot send pkt %p (%d)", pkt, ret);
} else {
net_pkt_unref(pkt);
}
@ -359,7 +361,7 @@ static int read_data(struct eth_context *ctx, int fd)
}
}
SYS_LOG_DBG("Recv pkt %p len %d", pkt, pkt_len);
LOG_DBG("Recv pkt %p len %d", pkt, pkt_len);
update_gptp(iface, pkt, false);
@ -374,7 +376,7 @@ static void eth_rx(struct eth_context *ctx)
{
int ret;
SYS_LOG_DBG("Starting ZETH RX thread");
LOG_DBG("Starting ZETH RX thread");
while (1) {
if (net_if_is_up(ctx->iface)) {
@ -433,7 +435,7 @@ static void eth_iface_init(struct net_if *iface)
if (CONFIG_ETH_NATIVE_POSIX_MAC_ADDR[0] != 0) {
if (net_bytes_from_str(ctx->mac_addr, sizeof(ctx->mac_addr),
CONFIG_ETH_NATIVE_POSIX_MAC_ADDR) < 0) {
SYS_LOG_ERR("Invalid MAC address %s",
LOG_ERR("Invalid MAC address %s",
CONFIG_ETH_NATIVE_POSIX_MAC_ADDR);
}
}
@ -446,8 +448,7 @@ static void eth_iface_init(struct net_if *iface)
ctx->dev_fd = eth_iface_create(ctx->if_name, false);
if (ctx->dev_fd < 0) {
SYS_LOG_ERR("Cannot create %s (%d)", ctx->if_name,
ctx->dev_fd);
LOG_ERR("Cannot create %s (%d)", ctx->if_name, ctx->dev_fd);
} else {
/* Create a thread that will handle incoming data from host */
create_rx_handler(ctx);

View file

@ -34,12 +34,14 @@
/* Zephyr include files. Be very careful here and only include minimum
* things needed.
*/
#define SYS_LOG_DOMAIN "eth-posix-adapt"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ETHERNET_LEVEL
#define LOG_MODULE_NAME eth_posix_adapt
#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <zephyr/types.h>
#include <sys_clock.h>
#include <logging/sys_log.h>
#if defined(CONFIG_NET_GPTP)
#include <net/gptp.h>

View file

@ -20,9 +20,11 @@
* RAM regions in Zephyr.
*/
#define SYS_LOG_DOMAIN "dev/eth_sam"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ETHERNET_LEVEL
#include <logging/sys_log.h>
#define LOG_MODULE_NAME eth_sam
#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <kernel.h>
#include <device.h>
@ -275,7 +277,7 @@ static int rx_descriptors_init(Gmac *gmac, struct gmac_queue *queue)
rx_buf = net_pkt_get_reserve_rx_data(0, K_NO_WAIT);
if (rx_buf == NULL) {
free_rx_bufs(rx_frag_list);
SYS_LOG_ERR("Failed to reserve data net buffers");
LOG_ERR("Failed to reserve data net buffers");
return -ENOBUFS;
}
@ -550,7 +552,7 @@ static void tx_completed(Gmac *gmac, struct gmac_queue *queue)
}
#endif
net_pkt_unref(pkt);
SYS_LOG_DBG("Dropping pkt %p", pkt);
LOG_DBG("Dropping pkt %p", pkt);
break;
}
@ -575,7 +577,7 @@ static void tx_error_handler(Gmac *gmac, struct gmac_queue *queue)
/* Release net buffer to the buffer pool */
pkt = UINT_TO_POINTER(tx_frames->buf[tx_frames->tail]);
net_pkt_unref(pkt);
SYS_LOG_DBG("Dropping pkt %p", pkt);
LOG_DBG("Dropping pkt %p", pkt);
MODULO_INC(tx_frames->tail, tx_frames->len);
}
@ -644,7 +646,7 @@ static int get_mck_clock_divisor(u32_t mck)
} else if (mck <= 240000000) {
mck_divisor = GMAC_NCFGR_CLK_MCK_96;
} else {
SYS_LOG_ERR("No valid MDC clock");
LOG_ERR("No valid MDC clock");
mck_divisor = -ENOTSUP;
}
@ -987,7 +989,7 @@ static int nonpriority_queue_init(Gmac *gmac, struct gmac_queue *queue)
queue->err_rx_flushed_count = 0;
queue->err_tx_flushed_count = 0;
SYS_LOG_INF("Queue %d activated", queue->que_idx);
LOG_INF("Queue %d activated", queue->que_idx);
return 0;
}
@ -1194,7 +1196,7 @@ static struct net_pkt *frame_get(struct gmac_queue *queue)
}
rx_desc_list->tail = tail;
SYS_LOG_DBG("Frame complete: rx=%p, tail=%d", rx_frame, tail);
LOG_DBG("Frame complete: rx=%p, tail=%d", rx_frame, tail);
__ASSERT_NO_MSG(frame_is_complete);
return rx_frame;
@ -1219,7 +1221,7 @@ static void eth_rx(struct gmac_queue *queue)
*/
rx_frame = frame_get(queue);
while (rx_frame) {
SYS_LOG_DBG("ETH rx");
LOG_DBG("ETH rx");
#if defined(CONFIG_NET_VLAN)
/* FIXME: Instead of this, use the GMAC register to get
@ -1307,7 +1309,7 @@ static int eth_tx(struct net_if *iface, struct net_pkt *pkt)
__ASSERT(pkt, "buf pointer is NULL");
__ASSERT(pkt->frags, "Frame data missing");
SYS_LOG_DBG("ETH tx");
LOG_DBG("ETH tx");
/* Decide which queue should be used */
pkt_prio = net_pkt_priority(pkt);
@ -1429,7 +1431,7 @@ static void queue0_isr(void *arg)
/* Interrupt Status Register is cleared on read */
isr = gmac->GMAC_ISR;
SYS_LOG_DBG("GMAC_ISR=0x%08x", isr);
LOG_DBG("GMAC_ISR=0x%08x", isr);
queue = &dev_data->queue_list[0];
rx_desc_list = &queue->rx_desc_list;
@ -1440,7 +1442,7 @@ static void queue0_isr(void *arg)
rx_error_handler(gmac, queue);
} else if (isr & GMAC_ISR_RCOMP) {
tail_desc = &rx_desc_list->buf[rx_desc_list->tail];
SYS_LOG_DBG("rx.w1=0x%08x, tail=%d",
LOG_DBG("rx.w1=0x%08x, tail=%d",
gmac_desc_get_w1(tail_desc),
rx_desc_list->tail);
eth_rx(queue);
@ -1451,7 +1453,7 @@ static void queue0_isr(void *arg)
tx_error_handler(gmac, queue);
} else if (isr & GMAC_ISR_TCOMP) {
tail_desc = &tx_desc_list->buf[tx_desc_list->tail];
SYS_LOG_DBG("tx.w1=0x%08x, tail=%d",
LOG_DBG("tx.w1=0x%08x, tail=%d",
gmac_desc_get_w1(tail_desc),
tx_desc_list->tail);
@ -1462,7 +1464,7 @@ static void queue0_isr(void *arg)
}
if (isr & GMAC_IER_HRESP) {
SYS_LOG_DBG("IER HRESP");
LOG_DBG("IER HRESP");
}
}
@ -1480,7 +1482,7 @@ static inline void priority_queue_isr(void *arg, unsigned int queue_idx)
u32_t isrpq;
isrpq = gmac->GMAC_ISRPQ[queue_idx - 1];
SYS_LOG_DBG("GMAC_ISRPQ%d=0x%08x", queue_idx - 1, isrpq);
LOG_DBG("GMAC_ISRPQ%d=0x%08x", queue_idx - 1, isrpq);
queue = &dev_data->queue_list[queue_idx];
rx_desc_list = &queue->rx_desc_list;
@ -1491,7 +1493,7 @@ static inline void priority_queue_isr(void *arg, unsigned int queue_idx)
rx_error_handler(gmac, queue);
} else if (isrpq & GMAC_ISRPQ_RCOMP) {
tail_desc = &rx_desc_list->buf[rx_desc_list->tail];
SYS_LOG_DBG("rx.w1=0x%08x, tail=%d",
LOG_DBG("rx.w1=0x%08x, tail=%d",
gmac_desc_get_w1(tail_desc),
rx_desc_list->tail);
eth_rx(queue);
@ -1502,7 +1504,7 @@ static inline void priority_queue_isr(void *arg, unsigned int queue_idx)
tx_error_handler(gmac, queue);
} else if (isrpq & GMAC_ISRPQ_TCOMP) {
tail_desc = &tx_desc_list->buf[tx_desc_list->tail];
SYS_LOG_DBG("tx.w1=0x%08x, tail=%d",
LOG_DBG("tx.w1=0x%08x, tail=%d",
gmac_desc_get_w1(tail_desc),
tx_desc_list->tail);
@ -1513,7 +1515,7 @@ static inline void priority_queue_isr(void *arg, unsigned int queue_idx)
}
if (isrpq & GMAC_IERPQ_HRESP) {
SYS_LOG_DBG("IERPQ%d HRESP", queue_idx - 1);
LOG_DBG("IERPQ%d HRESP", queue_idx - 1);
}
}
#endif
@ -1555,7 +1557,7 @@ static void get_mac_addr_from_i2c_eeprom(u8_t mac_addr[6])
dev = device_get_binding(CONFIG_ETH_SAM_GMAC_MAC_I2C_DEV_NAME);
if (!dev) {
SYS_LOG_ERR("I2C: Device not found");
LOG_ERR("I2C: Device not found");
return;
}
@ -1626,12 +1628,13 @@ static void eth0_iface_init(struct net_if *iface)
| GMAC_NCFGR_RXCOEN; /* Receive Checksum Offload Enable */
result = gmac_init(cfg->regs, gmac_ncfgr_val);
if (result < 0) {
SYS_LOG_ERR("Unable to initialize ETH driver");
LOG_ERR("Unable to initialize ETH driver");
return;
}
generate_mac(dev_data->mac_addr);
SYS_LOG_INF("MAC: %x:%x:%x:%x:%x:%x",
LOG_INF("MAC: %x:%x:%x:%x:%x:%x",
dev_data->mac_addr[0], dev_data->mac_addr[1],
dev_data->mac_addr[2], dev_data->mac_addr[3],
dev_data->mac_addr[4], dev_data->mac_addr[5]);
@ -1648,7 +1651,7 @@ static void eth0_iface_init(struct net_if *iface)
for (i = 0; i < GMAC_QUEUE_NO; i++) {
result = queue_init(cfg->regs, &dev_data->queue_list[i]);
if (result < 0) {
SYS_LOG_ERR("Unable to initialize ETH queue%d", i);
LOG_ERR("Unable to initialize ETH queue%d", i);
return;
}
}
@ -1691,13 +1694,13 @@ static void eth0_iface_init(struct net_if *iface)
/* PHY initialize */
result = phy_sam_gmac_init(&cfg->phy);
if (result < 0) {
SYS_LOG_ERR("ETH PHY Initialization Error");
LOG_ERR("ETH PHY Initialization Error");
return;
}
/* PHY auto-negotiate link parameters */
result = phy_sam_gmac_auto_negotiate(&cfg->phy, &link_status);
if (result < 0) {
SYS_LOG_ERR("ETH PHY auto-negotiate sequence failed");
LOG_ERR("ETH PHY auto-negotiate sequence failed");
return;
}

View file

@ -3,9 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define SYS_LOG_DOMAIN "dev/eth_stm32_hal"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ETHERNET_LEVEL
#include <logging/sys_log.h>
#define LOG_MODULE_NAME eth_stm32_hal
#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <kernel.h>
#include <device.h>
@ -79,7 +81,7 @@ static int eth_tx(struct net_if *iface, struct net_pkt *pkt)
total_len = net_pkt_ll_reserve(pkt) + net_pkt_get_len(pkt);
if (total_len > ETH_TX_BUF_SIZE) {
SYS_LOG_ERR("PKT to big\n");
LOG_ERR("PKT to big");
res = -EIO;
goto error;
}
@ -103,7 +105,7 @@ static int eth_tx(struct net_if *iface, struct net_pkt *pkt)
}
if (HAL_ETH_TransmitFrame(heth, total_len) != HAL_OK) {
SYS_LOG_ERR("HAL_ETH_TransmitFrame failed\n");
LOG_ERR("HAL_ETH_TransmitFrame failed");
res = -EIO;
goto error;
}
@ -157,12 +159,12 @@ static struct net_pkt *eth_rx(struct device *dev)
pkt = net_pkt_get_reserve_rx(0, K_NO_WAIT);
if (!pkt) {
SYS_LOG_ERR("Failed to obtain RX buffer");
LOG_ERR("Failed to obtain RX buffer");
goto release_desc;
}
if (!net_pkt_append_all(pkt, total_len, dma_buffer, K_NO_WAIT)) {
SYS_LOG_ERR("Failed to append RX buffer to context buffer");
LOG_ERR("Failed to append RX buffer to context buffer");
net_pkt_unref(pkt);
pkt = NULL;
goto release_desc;
@ -218,7 +220,7 @@ static void rx_thread(void *arg1, void *unused1, void *unused2)
net_pkt_print_frags(pkt);
res = net_recv_data(dev_data->iface, pkt);
if (res < 0) {
SYS_LOG_ERR("Failed to enqueue frame "
LOG_ERR("Failed to enqueue frame "
"into RX queue: %d", res);
net_pkt_unref(pkt);
}
@ -337,9 +339,9 @@ static void eth_iface_init(struct net_if *iface)
/* HAL Init time out. This could be linked to */
/* a recoverable error. Log the issue and continue */
/* dirver initialisation */
SYS_LOG_ERR("HAL_ETH_Init Timed out\n");
LOG_ERR("HAL_ETH_Init Timed out");
} else if (hal_ret != HAL_OK) {
SYS_LOG_ERR("HAL_ETH_Init failed: %d\n", hal_ret);
LOG_ERR("HAL_ETH_Init failed: %d", hal_ret);
return;
}
@ -363,7 +365,7 @@ static void eth_iface_init(struct net_if *iface)
disable_mcast_filter(heth);
SYS_LOG_DBG("MAC %02x:%02x:%02x:%02x:%02x:%02x",
LOG_DBG("MAC %02x:%02x:%02x:%02x:%02x:%02x",
dev_data->mac_addr[0], dev_data->mac_addr[1],
dev_data->mac_addr[2], dev_data->mac_addr[3],
dev_data->mac_addr[4], dev_data->mac_addr[5]);

View file

@ -12,9 +12,11 @@
#include <net/mii.h>
#include "phy_sam_gmac.h"
#define SYS_LOG_DOMAIN "soc/soc_phy"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ETHERNET_LEVEL
#include <logging/sys_log.h>
#define LOG_MODULE_NAME eth_sam_phy
#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
/* Maximum time to establish a link through auto-negotiation for
* 10BASE-T, 100BASE-TX is 3.7s, to add an extra margin the timeout
@ -41,7 +43,7 @@ static int mdio_bus_wait(Gmac *gmac)
while (!(gmac->GMAC_NSR & GMAC_NSR_IDLE)) {
if (retries-- == 0) {
SYS_LOG_ERR("timeout");
LOG_ERR("timeout");
return -ETIMEDOUT;
}
@ -143,17 +145,17 @@ int phy_sam_gmac_init(const struct phy_sam_gmac_dev *phy)
mdio_bus_enable(gmac);
SYS_LOG_INF("Soft Reset of ETH PHY");
LOG_INF("Soft Reset of ETH PHY");
phy_soft_reset(phy);
/* Verify that the PHY device is responding */
phy_id = phy_sam_gmac_id_get(phy);
if (phy_id == 0xFFFFFFFF) {
SYS_LOG_ERR("Unable to detect a valid PHY");
LOG_ERR("Unable to detect a valid PHY");
return -1;
}
SYS_LOG_INF("PHYID: 0x%X at addr: %d", phy_id, phy->address);
LOG_INF("PHYID: 0x%X at addr: %d", phy_id, phy->address);
mdio_bus_disable(gmac);
@ -197,7 +199,7 @@ int phy_sam_gmac_auto_negotiate(const struct phy_sam_gmac_dev *phy,
mdio_bus_enable(gmac);
SYS_LOG_DBG("Starting ETH PHY auto-negotiate sequence");
LOG_DBG("Starting ETH PHY auto-negotiate sequence");
/* Read PHY default advertising parameters */
retval = phy_read(phy, MII_ANAR, &ability_adv);
@ -234,7 +236,7 @@ int phy_sam_gmac_auto_negotiate(const struct phy_sam_gmac_dev *phy,
}
} while (!(val & MII_BMSR_AUTONEG_COMPLETE));
SYS_LOG_DBG("PHY auto-negotiate sequence completed");
LOG_DBG("PHY auto-negotiate sequence completed");
/* Read abilities of the remote device */
retval = phy_read(phy, MII_ANLPAR, &ability_rcvd);
@ -253,7 +255,7 @@ int phy_sam_gmac_auto_negotiate(const struct phy_sam_gmac_dev *phy,
*status = PHY_DUPLEX_HALF | PHY_SPEED_10M;
}
SYS_LOG_INF("common abilities: speed %s Mb, %s duplex",
LOG_INF("common abilities: speed %s Mb, %s duplex",
*status & PHY_SPEED_100M ? "100" : "10",
*status & PHY_DUPLEX_FULL ? "full" : "half");