mirror of
https://github.com/fpganinja/taxi.git
synced 2026-01-18 01:30:36 -08:00
cndm_proto: Support changing MAC address
Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
@@ -10,6 +10,8 @@ Authors:
|
|||||||
|
|
||||||
#include "cndm_proto.h"
|
#include "cndm_proto.h"
|
||||||
|
|
||||||
|
#include <linux/version.h>
|
||||||
|
|
||||||
static int cndm_proto_open(struct net_device *ndev)
|
static int cndm_proto_open(struct net_device *ndev)
|
||||||
{
|
{
|
||||||
struct cndm_proto_priv *priv = netdev_priv(ndev);
|
struct cndm_proto_priv *priv = netdev_priv(ndev);
|
||||||
@@ -50,10 +52,30 @@ static int cndm_proto_close(struct net_device *ndev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cndm_proto_set_mac(struct net_device *ndev, void *addr)
|
||||||
|
{
|
||||||
|
struct sockaddr *saddr = addr;
|
||||||
|
|
||||||
|
if (!is_valid_ether_addr(saddr->sa_data))
|
||||||
|
return -EADDRNOTAVAIL;
|
||||||
|
|
||||||
|
netif_addr_lock_bh(ndev);
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
|
||||||
|
eth_hw_addr_set(ndev, saddr->sa_data);
|
||||||
|
#else
|
||||||
|
memcpy(ndev->dev_addr, saddr->sa_data, ETH_ALEN);
|
||||||
|
#endif
|
||||||
|
netif_addr_unlock_bh(ndev);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct net_device_ops cndm_proto_netdev_ops = {
|
static const struct net_device_ops cndm_proto_netdev_ops = {
|
||||||
.ndo_open = cndm_proto_open,
|
.ndo_open = cndm_proto_open,
|
||||||
.ndo_stop = cndm_proto_close,
|
.ndo_stop = cndm_proto_close,
|
||||||
.ndo_start_xmit = cndm_proto_start_xmit,
|
.ndo_start_xmit = cndm_proto_start_xmit,
|
||||||
|
.ndo_validate_addr = eth_validate_addr,
|
||||||
|
.ndo_set_mac_address = cndm_proto_set_mac,
|
||||||
};
|
};
|
||||||
|
|
||||||
irqreturn_t cndm_proto_irq(int irqn, void *data)
|
irqreturn_t cndm_proto_irq(int irqn, void *data)
|
||||||
|
|||||||
Reference in New Issue
Block a user