Skip to content
Snippets Groups Projects
Commit 91ac79b7 authored by Grzegorz Sluja's avatar Grzegorz Sluja Committed by Anjan Chanda
Browse files

Handle debug level by libs in easy_soc_libs


LIBWIFI_DEBUG_LEVEL env variable is created and can be set/get by the
ubus call. All libs in easy_soc_libs have been updated with new
functions
which are printed based on its level.

Debug_level is implemented with the following values
(the same as the linux kernel's log level):
ERR   = 3
WARN  = 4
INFO  = 6
DBG   = 7

Signed-off-by: default avatarGrzegorz Sluja <grzegorz.sluja@iopsys.eu>
parent 2a333afc
No related branches found
No related tags found
No related merge requests found
......@@ -65,7 +65,7 @@ static int bcm_eth_get_unit_port(const char *ifname, int *unit, int *port)
ret = eth_ioctl(ifname, SIOCETHSWCTLOPS, &data,
sizeof(struct ethswctl_data));
if (ret != 0) {
fprintf(stderr, "ioctl failed! ret = %d\n", ret);
libethernet_err("ioctl failed! ret = %d\n", ret);
return -1;
}
......@@ -83,7 +83,7 @@ static int bcm_eth_get_unit_port(const char *ifname, int *unit, int *port)
}
}
/* fprintf(stderr, "[%s] unit = %d port = %d portmap = 0x%x "
/* libethernet_dbg("[%s] unit = %d port = %d portmap = 0x%x "
"phyportmap = 0x%x\n",
ifname, *unit, *port, data.port_map,
data.phy_portmap); */
......@@ -111,7 +111,7 @@ int bcm_eth_get_link_settings(const char *ifname, struct eth_link *link)
ret = eth_ioctl(ifname, SIOCETHSWCTLOPS, &data,
sizeof(struct ethswctl_data));
if (ret != 0) {
fprintf(stderr, "ioctl failed!\n");
libethernet_err("ioctl failed!\n");
return -1;
}
......@@ -119,7 +119,7 @@ int bcm_eth_get_link_settings(const char *ifname, struct eth_link *link)
link->speed = data.speed;
link->fullduplex = data.duplex == 1 ? false : true;
/* fprintf(stderr, "port: %d speed = %d fullduplex = %d\n",
/* libethernet_dbg("port: %d speed = %d fullduplex = %d\n",
link->portid, link->speed, link->fullduplex); */
if (!!(data.phycfg & PHY_CFG_1000FD))
......@@ -156,12 +156,12 @@ int bcm_eth_get_link_settings(const char *ifname, struct eth_link *link)
ret = eth_ioctl(ifname, SIOCETHSWCTLOPS, &data,
sizeof(struct ethswctl_data));
if (ret != 0) {
fprintf(stderr, "ioctl failed! ret = %d\n", ret);
libethernet_err("ioctl failed! ret = %d\n", ret);
return -1;
}
link->autoneg = data.autoneg_info == 0 ? false : true;
/* fprintf(stderr, "autoneg = %d\n", link->autoneg); */
/* libethernet_dbg("autoneg = %d\n", link->autoneg); */
memset(&data, 0, sizeof(struct ethswctl_data));
data.op = ETHSWLINKSTATUS;
......@@ -172,7 +172,7 @@ int bcm_eth_get_link_settings(const char *ifname, struct eth_link *link)
ret = eth_ioctl(ifname, SIOCETHSWCTLOPS, &data,
sizeof(struct ethswctl_data));
if (ret != 0) {
fprintf(stderr, "ioctl failed!\n");
libethernet_err("ioctl failed!\n");
return -1;
}
......@@ -183,7 +183,7 @@ int bcm_eth_get_link_settings(const char *ifname, struct eth_link *link)
int bcm_eth_set_link_settings(const char *name, struct eth_link link)
{
fprintf(stderr, "%s(): TODO\n", __func__);
libethernet_err("%s(): TODO\n", __func__);
return 0;
}
......@@ -300,7 +300,7 @@ int bcm_eth_get_stats(const char *ifname, struct eth_stats *s)
ret = eth_ioctl(ifname, SIOCETHSWCTLOPS, &data,
sizeof(struct ethswctl_data));
if (ret != 0) {
fprintf(stderr, "ioctl failed! ret = %d\n", ret);
libethernet_err("ioctl failed! ret = %d\n", ret);
return ret_proc == 0 ? 0 : -1;
}
......@@ -354,7 +354,7 @@ int bcm_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon)
ret = eth_ioctl(ifname, SIOCETHSWCTLOPS, &data,
sizeof(struct ethswctl_data));
if (ret != 0) {
fprintf(stderr, "ioctl failed! ret = %d\n", ret);
libethernet_err("ioctl failed! ret = %d\n", ret);
return -1;
}
......
......@@ -186,7 +186,7 @@ int eth_ioctl(const char *ifname, int cmd, void *in, int len)
return -1;
if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
fprintf(stderr, "SIOCGIFINDEX failed!\n");
libethernet_err("SIOCGIFINDEX failed!\n");
close(s);
return -1;
}
......@@ -216,7 +216,7 @@ int eth_mii_get_phy_id(const char *ifname, int port, int *phy_id)
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
fprintf(stderr, "SIOCGIFINDEX failed!\n");
libethernet_err("SIOCGIFINDEX failed!\n");
close(s);
return -1;
}
......@@ -226,7 +226,7 @@ int eth_mii_get_phy_id(const char *ifname, int port, int *phy_id)
mii->val_in = port;
if (ioctl(s, SIOCGMIIPHY, &ifr) < 0) {
fprintf(stderr, "SIOCGMIIPHY failed!\n");
libethernet_err("SIOCGMIIPHY failed!\n");
close(s);
return -1;
}
......@@ -234,7 +234,7 @@ int eth_mii_get_phy_id(const char *ifname, int port, int *phy_id)
if (phy_id)
*phy_id = mii->phy_id;
//fprintf(stderr, "%s: phy_id = %d\n", ifname, *phy_id);
//libethernet_dbg("%s: phy_id = %d\n", ifname, *phy_id);
close(s);
return 0;
}
......@@ -253,7 +253,7 @@ static int eth_mii_ioctl(const char *ifname, int cmd, int phy_id, int reg,
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
fprintf(stderr, "SIOCGIFINDEX failed!\n");
libethernet_err("SIOCGIFINDEX failed!\n");
close(s);
return -1;
}
......@@ -267,7 +267,7 @@ static int eth_mii_ioctl(const char *ifname, int cmd, int phy_id, int reg,
mii->val_in = in;
if (ioctl(s, cmd, &ifr) < 0) {
fprintf(stderr, "MII cmd on %s failed\n", ifr.ifr_name);
libethernet_err("MII cmd on %s failed\n", ifr.ifr_name);
close(s);
return -1;
}
......
......@@ -30,6 +30,11 @@
extern "C" {
#endif
#define libethernet_err(...) err("libethernet: " __VA_ARGS__)
#define libethernet_warn(...) warn("libethernet: " __VA_ARGS__)
#define libethernet_info(...) info("libethernet: " __VA_ARGS__)
#define libethernet_dbg(...) dbg("libethernet: " __VA_ARGS__)
/* enum eth_duplex - duplex modes */
enum eth_duplex {
AUTO_DUPLEX,
......
......@@ -96,7 +96,7 @@ int ethsw_set_link_settings(char *name, struct eth_link link)
struct switch_port_link l;
int port = ETH_PORT_UNDEFINED;
fprintf(stderr, "%s(): name = %s\n", __func__, name);
libethernet_dbg("%s(): name = %s\n", __func__, name);
if (link.portid != ETH_PORT_UNDEFINED)
port = link.portid;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment