nvethernet: Add save/restore command

Add a new private IOCTL command to
configure MAC register save and
restore operations from user space.

Bug 200596517

Change-Id: Ic0e7069e064e277b842b5fd3ceb7ea17327687d5
Signed-off-by: Mohan Thadikamalla <mohant@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2315790
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Mohan Thadikamalla
2020-03-18 16:30:50 +05:30
committed by Revanth Kumar Uppala
parent b18ab27659
commit c547794a00
2 changed files with 45 additions and 2 deletions

View File

@@ -577,6 +577,45 @@ static int ether_config_l2_da_filter(struct net_device *dev,
return ret;
}
/**
* @brief This function is invoked by ioctl when user issues an ioctl command
* to save/restore MAC registers.
*
* Algorithm: Call osi_save_registers and osi_restore_registers
* based on user flags.
*
* @param[in] ndev: network device structure
* @param[in] flags: flags to indicate whether to save and restore MAC registers
*
* @note Ethernet interface need to be up.
*
* @retval 0 on Success
* @retval "negative value" on Failure
*/
static int ether_reg_save_restore(struct net_device *ndev,
unsigned int flags)
{
struct ether_priv_data *pdata = netdev_priv(ndev);
struct osi_core_priv_data *osi_core = pdata->osi_core;
if (flags == OSI_ENABLE) {
if (osi_restore_registers(osi_core)) {
dev_err(pdata->dev, "Restore MAC registers fail\n");
return -EBUSY;
}
} else if (flags == OSI_DISABLE) {
if (osi_save_registers(osi_core)) {
dev_err(pdata->dev, "Save MAC registers fail\n");
return -EBUSY;
}
} else {
dev_err(pdata->dev, "Invalid flag values:%d\n", flags);
return -EINVAL;
}
return 0;
}
/**
* @brief This function is invoked by ioctl when user issues an ioctl command
* to enable/disable MAC loopback mode.
@@ -591,7 +630,7 @@ static int ether_config_l2_da_filter(struct net_device *dev,
*
* @note MAC and PHY need to be initialized.
*
* @retval 0 on Sucess
* @retval 0 on Success
* @retval "negative value" on Failure
*/
static int ether_config_loopback_mode(struct net_device *ndev,
@@ -750,6 +789,9 @@ int ether_handle_priv_ioctl(struct net_device *ndev,
case ETHER_CONFIG_LOOPBACK_MODE:
ret = ether_config_loopback_mode(ndev, ifdata.if_flags);
break;
case ETHER_SAVE_RESTORE:
ret = ether_reg_save_restore(ndev, ifdata.if_flags);
break;
default:
break;
}