提交 942d6984 编写于 作者: J Julian Wiedmann 提交者: David S. Miller

s390/qeth: move common ioctl handling to core

There's a number of layer-independent ioctls that we can handle
in core, and reduce code duplication. For layer-specific ioctls,
add a do_ioctl() discipline hook.
Signed-off-by: NJulian Wiedmann <jwi@linux.vnet.ibm.com>
Acked-by: NUrsula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 40077e0c
...@@ -716,6 +716,7 @@ struct qeth_discipline { ...@@ -716,6 +716,7 @@ struct qeth_discipline {
int (*freeze)(struct ccwgroup_device *); int (*freeze)(struct ccwgroup_device *);
int (*thaw) (struct ccwgroup_device *); int (*thaw) (struct ccwgroup_device *);
int (*restore)(struct ccwgroup_device *); int (*restore)(struct ccwgroup_device *);
int (*do_ioctl)(struct net_device *dev, struct ifreq *rq, int cmd);
int (*control_event_handler)(struct qeth_card *card, int (*control_event_handler)(struct qeth_card *card,
struct qeth_ipa_cmd *cmd); struct qeth_ipa_cmd *cmd);
}; };
...@@ -936,9 +937,6 @@ void qeth_prepare_control_data(struct qeth_card *, int, ...@@ -936,9 +937,6 @@ void qeth_prepare_control_data(struct qeth_card *, int,
void qeth_release_buffer(struct qeth_channel *, struct qeth_cmd_buffer *); void qeth_release_buffer(struct qeth_channel *, struct qeth_cmd_buffer *);
void qeth_prepare_ipa_cmd(struct qeth_card *, struct qeth_cmd_buffer *, char); void qeth_prepare_ipa_cmd(struct qeth_card *, struct qeth_cmd_buffer *, char);
struct qeth_cmd_buffer *qeth_wait_for_buffer(struct qeth_channel *); struct qeth_cmd_buffer *qeth_wait_for_buffer(struct qeth_channel *);
int qeth_mdio_read(struct net_device *, int, int);
int qeth_snmp_command(struct qeth_card *, char __user *);
int qeth_query_oat_command(struct qeth_card *, char __user *);
int qeth_query_switch_attributes(struct qeth_card *card, int qeth_query_switch_attributes(struct qeth_card *card,
struct qeth_switch_info *sw_info); struct qeth_switch_info *sw_info);
int qeth_send_control_data(struct qeth_card *, int, struct qeth_cmd_buffer *, int qeth_send_control_data(struct qeth_card *, int, struct qeth_cmd_buffer *,
...@@ -956,6 +954,7 @@ int qeth_do_send_packet_fast(struct qeth_card *, struct qeth_qdio_out_q *, ...@@ -956,6 +954,7 @@ int qeth_do_send_packet_fast(struct qeth_card *, struct qeth_qdio_out_q *,
struct sk_buff *, struct qeth_hdr *, int, int, int); struct sk_buff *, struct qeth_hdr *, int, int, int);
int qeth_do_send_packet(struct qeth_card *, struct qeth_qdio_out_q *, int qeth_do_send_packet(struct qeth_card *, struct qeth_qdio_out_q *,
struct sk_buff *, struct qeth_hdr *, int); struct sk_buff *, struct qeth_hdr *, int);
int qeth_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
int qeth_core_get_sset_count(struct net_device *, int); int qeth_core_get_sset_count(struct net_device *, int);
void qeth_core_get_ethtool_stats(struct net_device *, void qeth_core_get_ethtool_stats(struct net_device *,
struct ethtool_stats *, u64 *); struct ethtool_stats *, u64 *);
......
...@@ -4417,7 +4417,7 @@ void qeth_tx_timeout(struct net_device *dev) ...@@ -4417,7 +4417,7 @@ void qeth_tx_timeout(struct net_device *dev)
} }
EXPORT_SYMBOL_GPL(qeth_tx_timeout); EXPORT_SYMBOL_GPL(qeth_tx_timeout);
int qeth_mdio_read(struct net_device *dev, int phy_id, int regnum) static int qeth_mdio_read(struct net_device *dev, int phy_id, int regnum)
{ {
struct qeth_card *card = dev->ml_priv; struct qeth_card *card = dev->ml_priv;
int rc = 0; int rc = 0;
...@@ -4480,7 +4480,6 @@ int qeth_mdio_read(struct net_device *dev, int phy_id, int regnum) ...@@ -4480,7 +4480,6 @@ int qeth_mdio_read(struct net_device *dev, int phy_id, int regnum)
} }
return rc; return rc;
} }
EXPORT_SYMBOL_GPL(qeth_mdio_read);
static int qeth_send_ipa_snmp_cmd(struct qeth_card *card, static int qeth_send_ipa_snmp_cmd(struct qeth_card *card,
struct qeth_cmd_buffer *iob, int len, struct qeth_cmd_buffer *iob, int len,
...@@ -4570,7 +4569,7 @@ static int qeth_snmp_command_cb(struct qeth_card *card, ...@@ -4570,7 +4569,7 @@ static int qeth_snmp_command_cb(struct qeth_card *card,
return 0; return 0;
} }
int qeth_snmp_command(struct qeth_card *card, char __user *udata) static int qeth_snmp_command(struct qeth_card *card, char __user *udata)
{ {
struct qeth_cmd_buffer *iob; struct qeth_cmd_buffer *iob;
struct qeth_ipa_cmd *cmd; struct qeth_ipa_cmd *cmd;
...@@ -4630,7 +4629,6 @@ int qeth_snmp_command(struct qeth_card *card, char __user *udata) ...@@ -4630,7 +4629,6 @@ int qeth_snmp_command(struct qeth_card *card, char __user *udata)
kfree(qinfo.udata); kfree(qinfo.udata);
return rc; return rc;
} }
EXPORT_SYMBOL_GPL(qeth_snmp_command);
static int qeth_setadpparms_query_oat_cb(struct qeth_card *card, static int qeth_setadpparms_query_oat_cb(struct qeth_card *card,
struct qeth_reply *reply, unsigned long data) struct qeth_reply *reply, unsigned long data)
...@@ -4662,7 +4660,7 @@ static int qeth_setadpparms_query_oat_cb(struct qeth_card *card, ...@@ -4662,7 +4660,7 @@ static int qeth_setadpparms_query_oat_cb(struct qeth_card *card,
return 0; return 0;
} }
int qeth_query_oat_command(struct qeth_card *card, char __user *udata) static int qeth_query_oat_command(struct qeth_card *card, char __user *udata)
{ {
int rc = 0; int rc = 0;
struct qeth_cmd_buffer *iob; struct qeth_cmd_buffer *iob;
...@@ -4732,7 +4730,6 @@ int qeth_query_oat_command(struct qeth_card *card, char __user *udata) ...@@ -4732,7 +4730,6 @@ int qeth_query_oat_command(struct qeth_card *card, char __user *udata)
out: out:
return rc; return rc;
} }
EXPORT_SYMBOL_GPL(qeth_query_oat_command);
static int qeth_query_card_info_cb(struct qeth_card *card, static int qeth_query_card_info_cb(struct qeth_card *card,
struct qeth_reply *reply, unsigned long data) struct qeth_reply *reply, unsigned long data)
...@@ -5759,6 +5756,60 @@ static const struct attribute_group *qeth_drv_attr_groups[] = { ...@@ -5759,6 +5756,60 @@ static const struct attribute_group *qeth_drv_attr_groups[] = {
NULL, NULL,
}; };
int qeth_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct qeth_card *card = dev->ml_priv;
struct mii_ioctl_data *mii_data;
int rc = 0;
if (!card)
return -ENODEV;
if (!qeth_card_hw_is_reachable(card))
return -ENODEV;
if (card->info.type == QETH_CARD_TYPE_OSN)
return -EPERM;
switch (cmd) {
case SIOC_QETH_ADP_SET_SNMP_CONTROL:
rc = qeth_snmp_command(card, rq->ifr_ifru.ifru_data);
break;
case SIOC_QETH_GET_CARD_TYPE:
if ((card->info.type == QETH_CARD_TYPE_OSD ||
card->info.type == QETH_CARD_TYPE_OSM ||
card->info.type == QETH_CARD_TYPE_OSX) &&
!card->info.guestlan)
return 1;
else
return 0;
case SIOCGMIIPHY:
mii_data = if_mii(rq);
mii_data->phy_id = 0;
break;
case SIOCGMIIREG:
mii_data = if_mii(rq);
if (mii_data->phy_id != 0)
rc = -EINVAL;
else
mii_data->val_out = qeth_mdio_read(dev,
mii_data->phy_id, mii_data->reg_num);
break;
case SIOC_QETH_QUERY_OAT:
rc = qeth_query_oat_command(card, rq->ifr_ifru.ifru_data);
break;
default:
if (card->discipline->do_ioctl)
rc = card->discipline->do_ioctl(dev, rq, cmd);
else
rc = -EOPNOTSUPP;
}
if (rc)
QETH_CARD_TEXT_(card, 2, "ioce%x", rc);
return rc;
}
EXPORT_SYMBOL_GPL(qeth_do_ioctl);
static struct { static struct {
const char str[ETH_GSTRING_LEN]; const char str[ETH_GSTRING_LEN];
} qeth_ethtool_stats_keys[] = { } qeth_ethtool_stats_keys[] = {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/mii.h>
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/hash.h> #include <linux/hash.h>
...@@ -34,56 +33,6 @@ static void qeth_bridge_state_change(struct qeth_card *card, ...@@ -34,56 +33,6 @@ static void qeth_bridge_state_change(struct qeth_card *card,
static void qeth_bridge_host_event(struct qeth_card *card, static void qeth_bridge_host_event(struct qeth_card *card,
struct qeth_ipa_cmd *cmd); struct qeth_ipa_cmd *cmd);
static int qeth_l2_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct qeth_card *card = dev->ml_priv;
struct mii_ioctl_data *mii_data;
int rc = 0;
if (!card)
return -ENODEV;
if (!qeth_card_hw_is_reachable(card))
return -ENODEV;
if (card->info.type == QETH_CARD_TYPE_OSN)
return -EPERM;
switch (cmd) {
case SIOC_QETH_ADP_SET_SNMP_CONTROL:
rc = qeth_snmp_command(card, rq->ifr_ifru.ifru_data);
break;
case SIOC_QETH_GET_CARD_TYPE:
if ((card->info.type == QETH_CARD_TYPE_OSD ||
card->info.type == QETH_CARD_TYPE_OSM ||
card->info.type == QETH_CARD_TYPE_OSX) &&
!card->info.guestlan)
return 1;
return 0;
break;
case SIOCGMIIPHY:
mii_data = if_mii(rq);
mii_data->phy_id = 0;
break;
case SIOCGMIIREG:
mii_data = if_mii(rq);
if (mii_data->phy_id != 0)
rc = -EINVAL;
else
mii_data->val_out = qeth_mdio_read(dev,
mii_data->phy_id, mii_data->reg_num);
break;
case SIOC_QETH_QUERY_OAT:
rc = qeth_query_oat_command(card, rq->ifr_ifru.ifru_data);
break;
default:
rc = -EOPNOTSUPP;
}
if (rc)
QETH_CARD_TEXT_(card, 2, "ioce%d", rc);
return rc;
}
static int qeth_l2_verify_dev(struct net_device *dev) static int qeth_l2_verify_dev(struct net_device *dev)
{ {
struct qeth_card *card; struct qeth_card *card;
...@@ -1059,7 +1008,7 @@ static const struct net_device_ops qeth_l2_netdev_ops = { ...@@ -1059,7 +1008,7 @@ static const struct net_device_ops qeth_l2_netdev_ops = {
.ndo_start_xmit = qeth_l2_hard_start_xmit, .ndo_start_xmit = qeth_l2_hard_start_xmit,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
.ndo_set_rx_mode = qeth_l2_set_rx_mode, .ndo_set_rx_mode = qeth_l2_set_rx_mode,
.ndo_do_ioctl = qeth_l2_do_ioctl, .ndo_do_ioctl = qeth_do_ioctl,
.ndo_set_mac_address = qeth_l2_set_mac_address, .ndo_set_mac_address = qeth_l2_set_mac_address,
.ndo_change_mtu = qeth_change_mtu, .ndo_change_mtu = qeth_change_mtu,
.ndo_vlan_rx_add_vid = qeth_l2_vlan_rx_add_vid, .ndo_vlan_rx_add_vid = qeth_l2_vlan_rx_add_vid,
...@@ -1417,6 +1366,7 @@ struct qeth_discipline qeth_l2_discipline = { ...@@ -1417,6 +1366,7 @@ struct qeth_discipline qeth_l2_discipline = {
.freeze = qeth_l2_pm_suspend, .freeze = qeth_l2_pm_suspend,
.thaw = qeth_l2_pm_resume, .thaw = qeth_l2_pm_resume,
.restore = qeth_l2_pm_resume, .restore = qeth_l2_pm_resume,
.do_ioctl = NULL,
.control_event_handler = qeth_l2_control_event, .control_event_handler = qeth_l2_control_event,
}; };
EXPORT_SYMBOL_GPL(qeth_l2_discipline); EXPORT_SYMBOL_GPL(qeth_l2_discipline);
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/mii.h>
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/ipv6.h> #include <linux/ipv6.h>
#include <linux/inetdevice.h> #include <linux/inetdevice.h>
...@@ -2457,15 +2456,8 @@ static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -2457,15 +2456,8 @@ static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ {
struct qeth_card *card = dev->ml_priv; struct qeth_card *card = dev->ml_priv;
struct qeth_arp_cache_entry arp_entry; struct qeth_arp_cache_entry arp_entry;
struct mii_ioctl_data *mii_data;
int rc = 0; int rc = 0;
if (!card)
return -ENODEV;
if (!qeth_card_hw_is_reachable(card))
return -ENODEV;
switch (cmd) { switch (cmd) {
case SIOC_QETH_ARP_SET_NO_ENTRIES: case SIOC_QETH_ARP_SET_NO_ENTRIES:
if (!capable(CAP_NET_ADMIN)) { if (!capable(CAP_NET_ADMIN)) {
...@@ -2510,37 +2502,9 @@ static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -2510,37 +2502,9 @@ static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
} }
rc = qeth_l3_arp_flush_cache(card); rc = qeth_l3_arp_flush_cache(card);
break; break;
case SIOC_QETH_ADP_SET_SNMP_CONTROL:
rc = qeth_snmp_command(card, rq->ifr_ifru.ifru_data);
break;
case SIOC_QETH_GET_CARD_TYPE:
if ((card->info.type == QETH_CARD_TYPE_OSD ||
card->info.type == QETH_CARD_TYPE_OSX) &&
!card->info.guestlan)
return 1;
return 0;
break;
case SIOCGMIIPHY:
mii_data = if_mii(rq);
mii_data->phy_id = 0;
break;
case SIOCGMIIREG:
mii_data = if_mii(rq);
if (mii_data->phy_id != 0)
rc = -EINVAL;
else
mii_data->val_out = qeth_mdio_read(dev,
mii_data->phy_id,
mii_data->reg_num);
break;
case SIOC_QETH_QUERY_OAT:
rc = qeth_query_oat_command(card, rq->ifr_ifru.ifru_data);
break;
default: default:
rc = -EOPNOTSUPP; rc = -EOPNOTSUPP;
} }
if (rc)
QETH_CARD_TEXT_(card, 2, "ioce%d", rc);
return rc; return rc;
} }
...@@ -3056,7 +3020,7 @@ static const struct net_device_ops qeth_l3_netdev_ops = { ...@@ -3056,7 +3020,7 @@ static const struct net_device_ops qeth_l3_netdev_ops = {
.ndo_start_xmit = qeth_l3_hard_start_xmit, .ndo_start_xmit = qeth_l3_hard_start_xmit,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
.ndo_set_rx_mode = qeth_l3_set_multicast_list, .ndo_set_rx_mode = qeth_l3_set_multicast_list,
.ndo_do_ioctl = qeth_l3_do_ioctl, .ndo_do_ioctl = qeth_do_ioctl,
.ndo_change_mtu = qeth_change_mtu, .ndo_change_mtu = qeth_change_mtu,
.ndo_fix_features = qeth_fix_features, .ndo_fix_features = qeth_fix_features,
.ndo_set_features = qeth_set_features, .ndo_set_features = qeth_set_features,
...@@ -3072,7 +3036,7 @@ static const struct net_device_ops qeth_l3_osa_netdev_ops = { ...@@ -3072,7 +3036,7 @@ static const struct net_device_ops qeth_l3_osa_netdev_ops = {
.ndo_start_xmit = qeth_l3_hard_start_xmit, .ndo_start_xmit = qeth_l3_hard_start_xmit,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
.ndo_set_rx_mode = qeth_l3_set_multicast_list, .ndo_set_rx_mode = qeth_l3_set_multicast_list,
.ndo_do_ioctl = qeth_l3_do_ioctl, .ndo_do_ioctl = qeth_do_ioctl,
.ndo_change_mtu = qeth_change_mtu, .ndo_change_mtu = qeth_change_mtu,
.ndo_fix_features = qeth_fix_features, .ndo_fix_features = qeth_fix_features,
.ndo_set_features = qeth_set_features, .ndo_set_features = qeth_set_features,
...@@ -3439,6 +3403,7 @@ struct qeth_discipline qeth_l3_discipline = { ...@@ -3439,6 +3403,7 @@ struct qeth_discipline qeth_l3_discipline = {
.freeze = qeth_l3_pm_suspend, .freeze = qeth_l3_pm_suspend,
.thaw = qeth_l3_pm_resume, .thaw = qeth_l3_pm_resume,
.restore = qeth_l3_pm_resume, .restore = qeth_l3_pm_resume,
.do_ioctl = qeth_l3_do_ioctl,
.control_event_handler = qeth_l3_control_event, .control_event_handler = qeth_l3_control_event,
}; };
EXPORT_SYMBOL_GPL(qeth_l3_discipline); EXPORT_SYMBOL_GPL(qeth_l3_discipline);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册