mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-25 02:32:08 +03:00
Revert "nvethernet: use single API for ioctl"
This reverts commit 5bbeaa61e89ee6375a15020f2ef533b5ed66d628.
This commit is contained in:
committed by
Revanth Kumar Uppala
parent
8c8eceeeb7
commit
93924a32f3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -122,9 +122,9 @@ static int ether_set_avb_algo(struct net_device *ndev,
|
||||
{
|
||||
struct ether_priv_data *pdata = netdev_priv(ndev);
|
||||
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||
struct osi_core_avb_algorithm l_avb_struct;
|
||||
struct osi_dma_priv_data *osi_dma = pdata->osi_dma;
|
||||
struct osi_tx_ring *tx_ring = NULL;
|
||||
struct osi_ioctl ioctl_data = {};
|
||||
int ret = -1;
|
||||
|
||||
if (ifdata->ptr == NULL) {
|
||||
@@ -133,7 +133,7 @@ static int ether_set_avb_algo(struct net_device *ndev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (copy_from_user(&ioctl_data.avb,
|
||||
if (copy_from_user(&l_avb_struct,
|
||||
(struct osi_core_avb_algorithm *)ifdata->ptr,
|
||||
sizeof(struct osi_core_avb_algorithm)) != 0U) {
|
||||
dev_err(pdata->dev,
|
||||
@@ -142,17 +142,16 @@ static int ether_set_avb_algo(struct net_device *ndev,
|
||||
}
|
||||
|
||||
/* Check AVB mode disable on slot function enable */
|
||||
tx_ring = osi_dma->tx_ring[ioctl_data.avb.qindex];
|
||||
tx_ring = osi_dma->tx_ring[l_avb_struct.qindex];
|
||||
if (tx_ring && tx_ring->slot_check == OSI_ENABLE &&
|
||||
ioctl_data.avb.oper_mode == OSI_MTL_QUEUE_ENABLE) {
|
||||
l_avb_struct.oper_mode == OSI_MTL_QUEUE_ENABLE) {
|
||||
dev_err(pdata->dev,
|
||||
"Can't disable queue:%d AVB mode when slot is enabled",
|
||||
ioctl_data.avb.qindex);
|
||||
l_avb_struct.qindex);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ioctl_data.cmd = OSI_CMD_SET_AVB;
|
||||
return osi_handle_ioctl(osi_core, &ioctl_data);
|
||||
return osi_set_avb(osi_core, &l_avb_struct);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +174,7 @@ static int ether_get_avb_algo(struct net_device *ndev,
|
||||
{
|
||||
struct ether_priv_data *pdata = netdev_priv(ndev);
|
||||
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||
struct osi_ioctl ioctl_data = {};
|
||||
struct osi_core_avb_algorithm avb_data;
|
||||
int ret;
|
||||
|
||||
if (ifdata->ptr == NULL) {
|
||||
@@ -184,7 +183,7 @@ static int ether_get_avb_algo(struct net_device *ndev,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (copy_from_user(&ioctl_data.avb,
|
||||
if (copy_from_user(&avb_data,
|
||||
(struct osi_core_avb_algorithm *)ifdata->ptr,
|
||||
sizeof(struct osi_core_avb_algorithm)) != 0U) {
|
||||
dev_err(pdata->dev,
|
||||
@@ -192,14 +191,13 @@ static int ether_get_avb_algo(struct net_device *ndev,
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
ioctl_data.cmd = OSI_CMD_GET_AVB;
|
||||
ret = osi_handle_ioctl(osi_core, &ioctl_data);
|
||||
ret = osi_get_avb(osi_core, &avb_data);
|
||||
if (ret != 0) {
|
||||
dev_err(pdata->dev,
|
||||
"Failed to get AVB Struct info from registers\n");
|
||||
return ret;
|
||||
}
|
||||
if (copy_to_user(ifdata->ptr, &ioctl_data.avb,
|
||||
if (copy_to_user(ifdata->ptr, &avb_data,
|
||||
sizeof(struct osi_core_avb_algorithm)) != 0U) {
|
||||
dev_err(pdata->dev, "%s: copy_to_user failed\n", __func__);
|
||||
return -EFAULT;
|
||||
@@ -230,8 +228,6 @@ static int ether_config_arp_offload(struct ether_priv_data *pdata,
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
struct arp_offload_param param;
|
||||
struct osi_ioctl ioctl_data = {};
|
||||
|
||||
/* TODO: Need Spin lock to prevent multiple apps from
|
||||
* requesting same ioctls to the same MAC instance
|
||||
*/
|
||||
@@ -252,10 +248,8 @@ static int ether_config_arp_offload(struct ether_priv_data *pdata,
|
||||
dev_err(pdata->dev, "%s: Invalid IP addr\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
ioctl_data.cmd = OSI_CMD_ARP_OFFLOAD;
|
||||
ioctl_data.arg1_u32 = ifrd_p->if_flags;
|
||||
ioctl_data.arg7_u8_p = param.ip_addr;
|
||||
ret = osi_handle_ioctl(pdata->osi_core, &ioctl_data);
|
||||
ret = osi_config_arp_offload(pdata->osi_core, ifrd_p->if_flags,
|
||||
param.ip_addr);
|
||||
dev_err(pdata->dev, "ARP offload: %s : %s\n",
|
||||
ifrd_p->if_flags ? "Enable" : "Disable",
|
||||
ret ? "Failed" : "Success");
|
||||
@@ -316,7 +310,7 @@ static int ether_config_ip4_filters(struct net_device *dev,
|
||||
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||
struct osi_l3_l4_filter *u_l3_filter =
|
||||
(struct osi_l3_l4_filter *)ifdata->ptr;
|
||||
struct osi_ioctl ioctl_data = {};
|
||||
struct osi_l3_l4_filter l_l3_filter;
|
||||
unsigned int is_l4_filter = OSI_DISABLE;
|
||||
int ret = -EINVAL;
|
||||
|
||||
@@ -331,26 +325,20 @@ static int ether_config_ip4_filters(struct net_device *dev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (copy_from_user(&ioctl_data.l3l4_filter, u_l3_filter,
|
||||
if (copy_from_user(&l_l3_filter, u_l3_filter,
|
||||
sizeof(struct osi_l3_l4_filter)) != 0U) {
|
||||
dev_err(pdata->dev, "%s copy from user failed\n", __func__);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (ioctl_data.l3l4_filter.filter_no >
|
||||
(pdata->hw_feat.l3l4_filter_num - 1U)) {
|
||||
if (l_l3_filter.filter_no > (pdata->hw_feat.l3l4_filter_num - 1U)) {
|
||||
dev_err(pdata->dev, "%d filter is not supported in the HW\n",
|
||||
ioctl_data.l3l4_filter.filter_no);
|
||||
l_l3_filter.filter_no);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ioctl_data.cmd = OSI_CMD_L3L4_FILTER;
|
||||
ioctl_data.arg1_u32 = OSI_IP4_FILTER;
|
||||
ioctl_data.arg2_u32 = OSI_DISABLE;
|
||||
ioctl_data.arg3_u32 = OSI_CHAN_ANY;
|
||||
ioctl_data.arg4_u32 = is_l4_filter;
|
||||
|
||||
return osi_handle_ioctl(osi_core, &ioctl_data);
|
||||
return osi_l3l4_filter(osi_core, l_l3_filter, OSI_IP4_FILTER,
|
||||
OSI_DISABLE, OSI_CHAN_ANY, is_l4_filter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,7 +366,7 @@ static int ether_config_ip6_filters(struct net_device *dev,
|
||||
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||
struct osi_l3_l4_filter *u_l3_filter =
|
||||
(struct osi_l3_l4_filter *)ifdata->ptr;
|
||||
struct osi_ioctl ioctl_data = {};
|
||||
struct osi_l3_l4_filter l_l3_filter;
|
||||
unsigned int is_l4_filter = OSI_DISABLE;
|
||||
int ret = -EINVAL;
|
||||
|
||||
@@ -393,26 +381,20 @@ static int ether_config_ip6_filters(struct net_device *dev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (copy_from_user(&ioctl_data.l3l4_filter, u_l3_filter,
|
||||
if (copy_from_user(&l_l3_filter, u_l3_filter,
|
||||
sizeof(struct osi_l3_l4_filter)) != 0U) {
|
||||
dev_err(pdata->dev, "%s copy from user failed\n", __func__);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (ioctl_data.l3l4_filter.filter_no >
|
||||
(pdata->hw_feat.l3l4_filter_num - 1U)) {
|
||||
if (l_l3_filter.filter_no > (pdata->hw_feat.l3l4_filter_num - 1U)) {
|
||||
dev_err(pdata->dev, "%d filter is not supported in the HW\n",
|
||||
ioctl_data.l3l4_filter.filter_no);
|
||||
l_l3_filter.filter_no);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ioctl_data.cmd = OSI_CMD_L3L4_FILTER;
|
||||
ioctl_data.arg1_u32 = OSI_IP6_FILTER;
|
||||
ioctl_data.arg2_u32 = OSI_DISABLE;
|
||||
ioctl_data.arg3_u32 = OSI_CHAN_ANY;
|
||||
ioctl_data.arg4_u32 = is_l4_filter;
|
||||
|
||||
return osi_handle_ioctl(osi_core, &ioctl_data);
|
||||
return osi_l3l4_filter(osi_core, l_l3_filter, OSI_IP6_FILTER,
|
||||
OSI_DISABLE, OSI_CHAN_ANY, is_l4_filter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -443,7 +425,7 @@ static int ether_config_tcp_udp_filters(struct net_device *dev,
|
||||
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||
struct osi_l3_l4_filter *u_l4_filter =
|
||||
(struct osi_l3_l4_filter *)ifdata->ptr;
|
||||
struct osi_ioctl ioctl_data = {};
|
||||
struct osi_l3_l4_filter l_l4_filter;
|
||||
unsigned int is_l4_filter = OSI_ENABLE;
|
||||
int ret = -EINVAL;
|
||||
|
||||
@@ -459,26 +441,20 @@ static int ether_config_tcp_udp_filters(struct net_device *dev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (copy_from_user(&ioctl_data.l3l4_filter, u_l4_filter,
|
||||
if (copy_from_user(&l_l4_filter, u_l4_filter,
|
||||
sizeof(struct osi_l3_l4_filter)) != 0U) {
|
||||
dev_err(pdata->dev, "%s copy from user failed", __func__);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (ioctl_data.l3l4_filter.filter_no >
|
||||
(pdata->hw_feat.l3l4_filter_num - 1U)) {
|
||||
if (l_l4_filter.filter_no > (pdata->hw_feat.l3l4_filter_num - 1U)) {
|
||||
dev_err(pdata->dev, "%d filter is not supported in the HW\n",
|
||||
ioctl_data.l3l4_filter.filter_no);
|
||||
l_l4_filter.filter_no);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ioctl_data.cmd = OSI_CMD_L3L4_FILTER;
|
||||
ioctl_data.arg1_u32 = tcp_udp;
|
||||
ioctl_data.arg2_u32 = OSI_DISABLE;
|
||||
ioctl_data.arg3_u32 = OSI_CHAN_ANY;
|
||||
ioctl_data.arg4_u32 = is_l4_filter;
|
||||
|
||||
return osi_handle_ioctl(osi_core, &ioctl_data);
|
||||
return osi_l3l4_filter(osi_core, l_l4_filter, tcp_udp,
|
||||
OSI_DISABLE, OSI_CHAN_ANY, is_l4_filter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -504,7 +480,7 @@ static int ether_config_vlan_filter(struct net_device *dev,
|
||||
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||
struct osi_vlan_filter *u_vlan_filter =
|
||||
(struct osi_vlan_filter *)ifdata->ptr;
|
||||
struct osi_ioctl ioctl_data = {};
|
||||
struct osi_vlan_filter l_vlan_filter;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (ifdata->ptr == NULL) {
|
||||
@@ -513,23 +489,23 @@ static int ether_config_vlan_filter(struct net_device *dev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (copy_from_user(&ioctl_data.vlan_filter, u_vlan_filter,
|
||||
if (copy_from_user(&l_vlan_filter, u_vlan_filter,
|
||||
sizeof(struct osi_vlan_filter)) != 0U) {
|
||||
dev_err(pdata->dev, "%s copy from user failed", __func__);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
/*0 - perfect and 1 - hash filtering */
|
||||
if (ioctl_data.vlan_filter.perfect_hash == OSI_HASH_FILTER_MODE) {
|
||||
if (l_vlan_filter.perfect_hash == OSI_HASH_FILTER_MODE) {
|
||||
dev_err(pdata->dev, "VLAN HASH filtering is not supported\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ioctl_data.cmd = OSI_CMD_VLAN_FILTER;
|
||||
ret = osi_handle_ioctl(osi_core, &ioctl_data);
|
||||
ret = osi_config_vlan_filtering(osi_core, l_vlan_filter.filter_enb_dis,
|
||||
l_vlan_filter.perfect_hash,
|
||||
l_vlan_filter.perfect_inverse_match);
|
||||
if (ret == 0) {
|
||||
pdata->vlan_hash_filtering =
|
||||
ioctl_data.vlan_filter.perfect_hash;
|
||||
pdata->vlan_hash_filtering = l_vlan_filter.perfect_hash;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -559,10 +535,10 @@ static int ether_config_l2_da_filter(struct net_device *dev,
|
||||
struct osi_l2_da_filter *u_l2_da_filter =
|
||||
(struct osi_l2_da_filter *)ifdata->ptr;
|
||||
struct osi_l2_da_filter l_l2_da_filter;
|
||||
struct osi_ioctl ioctl_data = {};
|
||||
struct osi_filter filter;
|
||||
int ret = -EINVAL;
|
||||
|
||||
memset(&ioctl_data.l2_filter, 0x0, sizeof(struct osi_filter));
|
||||
memset(&filter, 0x0, sizeof(struct osi_filter));
|
||||
|
||||
if (ifdata->ptr == NULL) {
|
||||
dev_err(pdata->dev, "%s: Invalid data for priv ioctl %d\n",
|
||||
@@ -588,13 +564,12 @@ static int ether_config_l2_da_filter(struct net_device *dev,
|
||||
|
||||
/* configure L2 DA perfect/inverse_matching */
|
||||
if (l_l2_da_filter.perfect_inverse_match == OSI_ENABLE) {
|
||||
ioctl_data.l2_filter.oper_mode |= OSI_OPER_EN_L2_DA_INV;
|
||||
filter.oper_mode |= OSI_OPER_EN_L2_DA_INV;
|
||||
} else {
|
||||
ioctl_data.l2_filter.oper_mode |= OSI_OPER_DIS_L2_DA_INV;
|
||||
filter.oper_mode |= OSI_OPER_DIS_L2_DA_INV;
|
||||
}
|
||||
|
||||
ioctl_data.cmd = OSI_CMD_L2_FILTER;
|
||||
ret = osi_handle_ioctl(osi_core, &ioctl_data);
|
||||
ret = osi_l2_filter(osi_core, &filter);
|
||||
if (ret != 0) {
|
||||
dev_err(pdata->dev, "setting L2_DA_INV failed\n");
|
||||
}
|
||||
@@ -622,17 +597,14 @@ static int ether_reg_save_restore(struct net_device *ndev,
|
||||
{
|
||||
struct ether_priv_data *pdata = netdev_priv(ndev);
|
||||
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||
struct osi_ioctl ioctl_data = {};
|
||||
|
||||
if (flags == OSI_ENABLE) {
|
||||
ioctl_data.cmd = OSI_CMD_RESTORE_REGISTER;
|
||||
if (osi_handle_ioctl(osi_core, &ioctl_data)) {
|
||||
if (osi_restore_registers(osi_core)) {
|
||||
dev_err(pdata->dev, "Restore MAC registers fail\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
} else if (flags == OSI_DISABLE) {
|
||||
ioctl_data.cmd = OSI_CMD_SAVE_REGISTER;
|
||||
if (osi_handle_ioctl(osi_core, &ioctl_data)) {
|
||||
if (osi_save_registers(osi_core)) {
|
||||
dev_err(pdata->dev, "Save MAC registers fail\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
@@ -667,7 +639,6 @@ static int ether_config_loopback_mode(struct net_device *ndev,
|
||||
struct ether_priv_data *pdata = netdev_priv(ndev);
|
||||
struct phy_device *phydev = ndev->phydev;
|
||||
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||
struct osi_ioctl ioctl_data = {};
|
||||
int ret = 0;
|
||||
|
||||
if ((flags && (pdata->mac_loopback_mode == OSI_ENABLE)) ||
|
||||
@@ -685,10 +656,7 @@ static int ether_config_loopback_mode(struct net_device *ndev,
|
||||
*/
|
||||
netif_carrier_on(ndev);
|
||||
}
|
||||
|
||||
ioctl_data.arg1_u32 = OSI_ENABLE;
|
||||
ioctl_data.cmd = OSI_CMD_MAC_LB;
|
||||
ret = osi_handle_ioctl(osi_core, &ioctl_data);
|
||||
ret = osi_config_mac_loopback(osi_core, OSI_ENABLE);
|
||||
if (ret < 0) {
|
||||
dev_err(pdata->dev,
|
||||
"Failed to enable MAC Loopback\n");
|
||||
@@ -705,10 +673,7 @@ static int ether_config_loopback_mode(struct net_device *ndev,
|
||||
*/
|
||||
netif_carrier_off(ndev);
|
||||
}
|
||||
|
||||
ioctl_data.arg1_u32 = OSI_DISABLE;
|
||||
ioctl_data.cmd = OSI_CMD_MAC_LB;
|
||||
ret = osi_handle_ioctl(osi_core, &ioctl_data);
|
||||
ret = osi_config_mac_loopback(osi_core, OSI_DISABLE);
|
||||
if (ret < 0) {
|
||||
dev_err(pdata->dev,
|
||||
"Failed to disable MAC Loopback\n");
|
||||
|
||||
Reference in New Issue
Block a user