mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-23 17:55:05 +03:00
nvethernet: support to change MAC address
Adds support for dynamic MAC address change. Gets MAC address from userspace and update in OSI core structure. Automatically MAC address will be picked up from OSI core structure and program the same in HW registers. Bug 200512251 Change-Id: Ie49fd56c3d219637fc4bf33c818c380a8f1c7bf3 Signed-off-by: Bhadram Varka <vbhadram@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2080718 Reviewed-by: Rakesh Goyal <rgoyal@nvidia.com> Reviewed-by: Narayan Reddy <narayanr@nvidia.com> Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Srinivas Ramachandran <srinivasra@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Ashutosh Jha <ajha@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Revanth Kumar Uppala
parent
f9904e66af
commit
b023f0c0f8
@@ -1117,11 +1117,45 @@ static int ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ether_set_mac_addr - Set MAC address
|
||||||
|
* @ndev: Network device structure
|
||||||
|
* @addr: MAC address to be programmed.
|
||||||
|
*
|
||||||
|
* Algorithm:
|
||||||
|
* 1) Checks whether given MAC address is valid or not
|
||||||
|
* 2) Stores the MAC address in OSI core structure
|
||||||
|
*
|
||||||
|
* Dependencies: Ethernet interface need to be down to set MAC address
|
||||||
|
*
|
||||||
|
* Protection: None.
|
||||||
|
*
|
||||||
|
* Return: 0 - success, negative value - failure.
|
||||||
|
*/
|
||||||
|
static int ether_set_mac_addr(struct net_device *ndev, void *addr)
|
||||||
|
{
|
||||||
|
struct ether_priv_data *pdata = netdev_priv(ndev);
|
||||||
|
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
ret = eth_mac_addr(ndev, addr);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(pdata->dev, "failed to set MAC address\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* MAC address programmed in HW registers during osi_hw_core_init() */
|
||||||
|
memcpy(osi_core->mac_addr, ndev->dev_addr, ETH_ALEN);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct net_device_ops ether_netdev_ops = {
|
static const struct net_device_ops ether_netdev_ops = {
|
||||||
.ndo_open = ether_open,
|
.ndo_open = ether_open,
|
||||||
.ndo_stop = ether_close,
|
.ndo_stop = ether_close,
|
||||||
.ndo_start_xmit = ether_start_xmit,
|
.ndo_start_xmit = ether_start_xmit,
|
||||||
.ndo_do_ioctl = ether_ioctl,
|
.ndo_do_ioctl = ether_ioctl,
|
||||||
|
.ndo_set_mac_address = ether_set_mac_addr,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user