summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2022-11-08 07:10:02 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-11-08 11:11:24 +0100
commit90682050d1492cf3cae14ca839409db6307cb6ec (patch)
tree88a87eefa80e097b2beccb91408474c0b58bf0c6
parentfdcfd76ee4fec9d348f29320ad413099b5fe1b6d (diff)
downloadbarebox-90682050d1492cf3cae14ca839409db6307cb6ec.tar.gz
barebox-90682050d1492cf3cae14ca839409db6307cb6ec.tar.xz
net: add promiscuous mode configuration support
This configuration is mostly needed for controllers attached to switches with different MAC address configurations or for debugging networking issues. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20221108061009.4168735-1-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--include/net.h3
-rw-r--r--net/eth.c8
2 files changed, 11 insertions, 0 deletions
diff --git a/include/net.h b/include/net.h
index 338033d698..f9d1fbfc18 100644
--- a/include/net.h
+++ b/include/net.h
@@ -49,6 +49,8 @@ struct eth_device {
int *length);
void (*rx_monitor) (struct eth_device*, void *packet, int length);
void (*tx_monitor) (struct eth_device*, void *packet, int length);
+ /* Set promiscuous mode */
+ int (*set_promisc) (struct eth_device*, bool enable);
struct eth_device *next;
void *priv;
@@ -113,6 +115,7 @@ int eth_send(struct eth_device *edev, void *packet, int length); /* Send a pa
int eth_rx(void); /* Check for received packets */
void eth_open_all(void);
struct eth_device *of_find_eth_device_by_node(struct device_node *np);
+int eth_set_promisc(struct eth_device *edev, bool enable);
/* associate a MAC address to a ethernet device. Should be called by
* board code for boards which store their MAC address at some unusual
diff --git a/net/eth.c b/net/eth.c
index 8f6ff7db3a..19654cdd51 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -31,6 +31,14 @@ struct eth_ethaddr {
static LIST_HEAD(ethaddr_list);
+int eth_set_promisc(struct eth_device *edev, bool enable)
+{
+ if (!edev->set_promisc)
+ return -EOPNOTSUPP;
+
+ return edev->set_promisc(edev, enable);
+}
+
int eth_set_ethaddr(struct eth_device *edev, const char *ethaddr)
{
int ret;