mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 17:25:35 +03:00
nvethernet: remove unnecessary ioctls
- Removed IPV4/IPV6/TCP/UDP ioctls. - Added support for single L3L4 ioctl which supports all of the above. Bug 3825731 Change-Id: Iae3cee595258abf8c908dae5a214d9da9bc8ae80 Signed-off-by: Hareesh Kesireddy <hkesireddy@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2819351 Reviewed-by: Narayan Reddy <narayanr@nvidia.com> Reviewed-by: Ashutosh Jha <ajha@nvidia.com> GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
46bc09119b
commit
32b805cab1
@@ -482,8 +482,7 @@ static int ether_config_frp_cmd(struct net_device *dev,
|
|||||||
* 2) OSI call to update register
|
* 2) OSI call to update register
|
||||||
*
|
*
|
||||||
* @param[in] dev: pointer to net device structure.
|
* @param[in] dev: pointer to net device structure.
|
||||||
* @param[in] filter_flags: flag to indicate whether L3/L4 filtering to be
|
* @param[in] ifdata: pointer to IOCTL specific structure.
|
||||||
* enabled/disabled.
|
|
||||||
*
|
*
|
||||||
* @note MAC and PHY need to be initialized.
|
* @note MAC and PHY need to be initialized.
|
||||||
*
|
*
|
||||||
@@ -492,13 +491,35 @@ static int ether_config_frp_cmd(struct net_device *dev,
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static int ether_config_l3_l4_filtering(struct net_device *dev,
|
static int ether_config_l3_l4_filtering(struct net_device *dev,
|
||||||
unsigned int filter_flags)
|
struct ether_exported_ifr_data *ifdata)
|
||||||
{
|
{
|
||||||
struct ether_priv_data *pdata = netdev_priv(dev);
|
struct ether_priv_data *pdata = netdev_priv(dev);
|
||||||
|
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||||
|
struct osi_l3_l4_filter *u_l3_filter;
|
||||||
|
struct osi_ioctl ioctl_data = { 0 };
|
||||||
|
int ret = -EINVAL;
|
||||||
|
|
||||||
dev_err(pdata->dev, "%s: This ioctl is deprecated, directly set the filter using ioctl command EQOS_IPV4/IPV6/TCP/UDP_FILTERING_CMD instead\n",
|
if (pdata->hw_feat.l3l4_filter_num == OSI_DISABLE) {
|
||||||
__func__);
|
dev_err(pdata->dev, "ip4 filter is not supported\n");
|
||||||
return -1;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ifdata->ptr) {
|
||||||
|
dev_err(pdata->dev, "%s: Invalid data for priv ioctl %d\n",
|
||||||
|
__func__, ifdata->ifcmd);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
u_l3_filter = (struct osi_l3_l4_filter *)ifdata->ptr;
|
||||||
|
|
||||||
|
if (copy_from_user(&ioctl_data.l3l4_filter, (void __user *)u_l3_filter,
|
||||||
|
sizeof(struct osi_l3_l4_filter)) != 0U) {
|
||||||
|
dev_err(pdata->dev, "%s copy from user failed\n", __func__);
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
ioctl_data.cmd = OSI_CMD_L3L4_FILTER;
|
||||||
|
return osi_handle_ioctl(osi_core, &ioctl_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -568,158 +589,6 @@ static int ether_config_l2_filters(struct net_device *dev,
|
|||||||
return osi_handle_ioctl(osi_core, &ioctl_data);
|
return osi_handle_ioctl(osi_core, &ioctl_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function is invoked by ioctl function when user issues an ioctl
|
|
||||||
* command to configure L3(IPv4) filtering.
|
|
||||||
*
|
|
||||||
* Algorithm:
|
|
||||||
* 1) Layer 3 and Layer 4 Filter Enable, if already not.
|
|
||||||
* 2) Enable/disable IPv4 filtering.
|
|
||||||
* 3) Select source/destination address matching.
|
|
||||||
* 4) Select perfect/inverse matching.
|
|
||||||
* 5) Update the IPv4 address into MAC register.
|
|
||||||
*
|
|
||||||
* @param[in] dev: Pointer to net device structure.
|
|
||||||
* @param[in] ifdata: pointer to IOCTL specific structure.
|
|
||||||
*
|
|
||||||
* @note MAC and PHY need to be initialized.
|
|
||||||
*
|
|
||||||
* @retval 0 on Success
|
|
||||||
* @retval "negative value" on Failure
|
|
||||||
*/
|
|
||||||
static int ether_config_ip4_filters(struct net_device *dev,
|
|
||||||
struct ether_exported_ifr_data *ifdata)
|
|
||||||
{
|
|
||||||
struct ether_priv_data *pdata = netdev_priv(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 = {};
|
|
||||||
int ret = -EINVAL;
|
|
||||||
|
|
||||||
if (pdata->hw_feat.l3l4_filter_num == OSI_DISABLE) {
|
|
||||||
dev_err(pdata->dev, "ip4 filter is not supported\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ifdata->ptr == NULL) {
|
|
||||||
dev_err(pdata->dev, "%s: Invalid data for priv ioctl %d\n",
|
|
||||||
__func__, ifdata->ifcmd);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (copy_from_user(&ioctl_data.l3l4_filter, (void __user *)u_l3_filter,
|
|
||||||
sizeof(struct osi_l3_l4_filter)) != 0U) {
|
|
||||||
dev_err(pdata->dev, "%s copy from user failed\n", __func__);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
ioctl_data.cmd = OSI_CMD_L3L4_FILTER;
|
|
||||||
return osi_handle_ioctl(osi_core, &ioctl_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function is invoked by ioctl when user issues an ioctl command
|
|
||||||
* to configure L3 (IPv6) filtering.
|
|
||||||
*
|
|
||||||
* Algorithm:
|
|
||||||
* 1) Enable/disable IPv6 filtering.
|
|
||||||
* 2) Select source/destination address matching.
|
|
||||||
* 3) Select perfect/inverse matching.
|
|
||||||
* 4) Update the IPv6 address into MAC register.
|
|
||||||
*
|
|
||||||
* @param[in] dev: net device structure instance.
|
|
||||||
* @param[in] ifdata: IOCTL specific structure instance.
|
|
||||||
*
|
|
||||||
* @note MAC and PHY need to be initialized.
|
|
||||||
*
|
|
||||||
* @retval 0 on Success
|
|
||||||
* @retval "negative value" on Failure
|
|
||||||
*/
|
|
||||||
static int ether_config_ip6_filters(struct net_device *dev,
|
|
||||||
struct ether_exported_ifr_data *ifdata)
|
|
||||||
{
|
|
||||||
struct ether_priv_data *pdata = netdev_priv(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 = {};
|
|
||||||
int ret = -EINVAL;
|
|
||||||
|
|
||||||
if (pdata->hw_feat.l3l4_filter_num == OSI_DISABLE) {
|
|
||||||
dev_err(pdata->dev, "ip6 filter is not supported in the HW\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ifdata->ptr == NULL) {
|
|
||||||
dev_err(pdata->dev, "%s: Invalid data for priv ioctl %d\n",
|
|
||||||
__func__, ifdata->ifcmd);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (copy_from_user(&ioctl_data.l3l4_filter, (void __user *)u_l3_filter,
|
|
||||||
sizeof(struct osi_l3_l4_filter)) != 0U) {
|
|
||||||
dev_err(pdata->dev, "%s copy from user failed\n", __func__);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
ioctl_data.cmd = OSI_CMD_L3L4_FILTER;
|
|
||||||
return osi_handle_ioctl(osi_core, &ioctl_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function is invoked by ioctl function when user issues an ioctl
|
|
||||||
* command to configure L4(TCP/UDP) filtering.
|
|
||||||
*
|
|
||||||
* Algorithm:
|
|
||||||
* 1) Enable/disable L4 filtering.
|
|
||||||
* 2) Select TCP/UDP filtering.
|
|
||||||
* 3) Select source/destination port matching.
|
|
||||||
* 4) select perfect/inverse matching.
|
|
||||||
* 5) Update the port number into MAC register.
|
|
||||||
*
|
|
||||||
* @param[in] dev: pointer to net device structure.
|
|
||||||
* @param[in] ifdata: pointer to IOCTL specific structure.
|
|
||||||
* @param[in] tcp_udp: flag to indicate TCP/UDP filtering.
|
|
||||||
*
|
|
||||||
* @note MAC and PHY need to be initialized.
|
|
||||||
*
|
|
||||||
* @retval 0 on Success
|
|
||||||
* @retval "negative value" on Failure
|
|
||||||
*/
|
|
||||||
static int ether_config_tcp_udp_filters(struct net_device *dev,
|
|
||||||
struct ether_exported_ifr_data *ifdata,
|
|
||||||
unsigned int tcp_udp)
|
|
||||||
{
|
|
||||||
struct ether_priv_data *pdata = netdev_priv(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 = {};
|
|
||||||
int ret = -EINVAL;
|
|
||||||
|
|
||||||
if (ifdata->ptr == NULL) {
|
|
||||||
dev_err(pdata->dev, "%s: Invalid data for priv ioctl %d\n",
|
|
||||||
__func__, ifdata->ifcmd);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pdata->hw_feat.l3l4_filter_num == OSI_DISABLE) {
|
|
||||||
dev_err(pdata->dev,
|
|
||||||
"L4 is not supported in the HW\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (copy_from_user(&ioctl_data.l3l4_filter, (void __user *)u_l4_filter,
|
|
||||||
sizeof(struct osi_l3_l4_filter)) != 0U) {
|
|
||||||
dev_err(pdata->dev, "%s copy from user failed", __func__);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
ioctl_data.cmd = OSI_CMD_L3L4_FILTER;
|
|
||||||
return osi_handle_ioctl(osi_core, &ioctl_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function is invoked by ioctl functio when user issues an ioctl
|
* @brief This function is invoked by ioctl functio when user issues an ioctl
|
||||||
* command to configure VALN filtering.
|
* command to configure VALN filtering.
|
||||||
@@ -1199,11 +1068,7 @@ int ether_handle_priv_ioctl(struct net_device *ndev,
|
|||||||
/* Enforce admin permission check */
|
/* Enforce admin permission check */
|
||||||
switch (ifdata.ifcmd) {
|
switch (ifdata.ifcmd) {
|
||||||
case ETHER_AVB_ALGORITHM:
|
case ETHER_AVB_ALGORITHM:
|
||||||
case EQOS_L3_L4_FILTER_CMD:
|
case EQOS_L3L4_FILTER_CMD:
|
||||||
case EQOS_IPV4_FILTERING_CMD:
|
|
||||||
case EQOS_IPV6_FILTERING_CMD:
|
|
||||||
case EQOS_UDP_FILTERING_CMD:
|
|
||||||
case EQOS_TCP_FILTERING_CMD:
|
|
||||||
case EQOS_VLAN_FILTERING_CMD:
|
case EQOS_VLAN_FILTERING_CMD:
|
||||||
case EQOS_L2_DA_FILTERING_CMD:
|
case EQOS_L2_DA_FILTERING_CMD:
|
||||||
case ETHER_CONFIG_ARP_OFFLOAD:
|
case ETHER_CONFIG_ARP_OFFLOAD:
|
||||||
@@ -1260,13 +1125,10 @@ int ether_handle_priv_ioctl(struct net_device *ndev,
|
|||||||
ret = -EOPNOTSUPP;
|
ret = -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EQOS_L3_L4_FILTER_CMD:
|
case EQOS_L3L4_FILTER_CMD:
|
||||||
/* flags should be 0x0 or 0x1, discard any other */
|
/* flags should be 0x0 or 0x1, discard any other */
|
||||||
if (pdata->hw_feat.l3l4_filter_num > 0U &&
|
if (pdata->hw_feat.l3l4_filter_num > 0U) {
|
||||||
((ifdata.if_flags == OSI_ENABLE) ||
|
ret = ether_config_l3_l4_filtering(ndev, &ifdata);
|
||||||
(ifdata.if_flags == OSI_DISABLE))) {
|
|
||||||
ret = ether_config_l3_l4_filtering(ndev,
|
|
||||||
ifdata.if_flags);
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = EQOS_CONFIG_SUCCESS;
|
ret = EQOS_CONFIG_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
@@ -1280,20 +1142,6 @@ int ether_handle_priv_ioctl(struct net_device *ndev,
|
|||||||
case ETHER_CONFIG_FRP_CMD:
|
case ETHER_CONFIG_FRP_CMD:
|
||||||
ret = ether_config_frp_cmd(ndev, &ifdata);
|
ret = ether_config_frp_cmd(ndev, &ifdata);
|
||||||
break;
|
break;
|
||||||
case EQOS_IPV4_FILTERING_CMD:
|
|
||||||
ret = ether_config_ip4_filters(ndev, &ifdata);
|
|
||||||
break;
|
|
||||||
case EQOS_IPV6_FILTERING_CMD:
|
|
||||||
ret = ether_config_ip6_filters(ndev, &ifdata);
|
|
||||||
break;
|
|
||||||
case EQOS_UDP_FILTERING_CMD:
|
|
||||||
ret = ether_config_tcp_udp_filters(ndev, &ifdata,
|
|
||||||
OSI_L4_FILTER_UDP);
|
|
||||||
break;
|
|
||||||
case EQOS_TCP_FILTERING_CMD:
|
|
||||||
ret = ether_config_tcp_udp_filters(ndev, &ifdata,
|
|
||||||
OSI_L4_FILTER_TCP);
|
|
||||||
break;
|
|
||||||
case EQOS_VLAN_FILTERING_CMD:
|
case EQOS_VLAN_FILTERING_CMD:
|
||||||
ret = ether_config_vlan_filter(ndev, &ifdata);
|
ret = ether_config_vlan_filter(ndev, &ifdata);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -34,12 +34,7 @@
|
|||||||
#define EQOS_GET_TX_QCNT 23
|
#define EQOS_GET_TX_QCNT 23
|
||||||
#define EQOS_GET_RX_QCNT 24
|
#define EQOS_GET_RX_QCNT 24
|
||||||
/* L3/L4 filter */
|
/* L3/L4 filter */
|
||||||
#define EQOS_L3_L4_FILTER_CMD 29
|
#define EQOS_L3L4_FILTER_CMD 29
|
||||||
/* IPv4/6 and TCP/UDP filtering */
|
|
||||||
#define EQOS_IPV4_FILTERING_CMD 30
|
|
||||||
#define EQOS_IPV6_FILTERING_CMD 31
|
|
||||||
#define EQOS_UDP_FILTERING_CMD 32
|
|
||||||
#define EQOS_TCP_FILTERING_CMD 33
|
|
||||||
/* VLAN filtering */
|
/* VLAN filtering */
|
||||||
#define EQOS_VLAN_FILTERING_CMD 34
|
#define EQOS_VLAN_FILTERING_CMD 34
|
||||||
/* L2 DA filtering */
|
/* L2 DA filtering */
|
||||||
|
|||||||
Reference in New Issue
Block a user