aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/ethtool.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/ethtool.c')
-rw-r--r--net/core/ethtool.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index d9d5160610d5..4c12ddb5f5ee 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -30,10 +30,17 @@ u32 ethtool_op_get_link(struct net_device *dev)
30 return netif_carrier_ok(dev) ? 1 : 0; 30 return netif_carrier_ok(dev) ? 1 : 0;
31} 31}
32 32
33u32 ethtool_op_get_rx_csum(struct net_device *dev)
34{
35 return (dev->features & NETIF_F_ALL_CSUM) != 0;
36}
37EXPORT_SYMBOL(ethtool_op_get_rx_csum);
38
33u32 ethtool_op_get_tx_csum(struct net_device *dev) 39u32 ethtool_op_get_tx_csum(struct net_device *dev)
34{ 40{
35 return (dev->features & NETIF_F_ALL_CSUM) != 0; 41 return (dev->features & NETIF_F_ALL_CSUM) != 0;
36} 42}
43EXPORT_SYMBOL(ethtool_op_get_tx_csum);
37 44
38int ethtool_op_set_tx_csum(struct net_device *dev, u32 data) 45int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
39{ 46{
@@ -891,6 +898,19 @@ static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
891 return actor(dev, edata.data); 898 return actor(dev, edata.data);
892} 899}
893 900
901static int ethtool_flash_device(struct net_device *dev, char __user *useraddr)
902{
903 struct ethtool_flash efl;
904
905 if (copy_from_user(&efl, useraddr, sizeof(efl)))
906 return -EFAULT;
907
908 if (!dev->ethtool_ops->flash_device)
909 return -EOPNOTSUPP;
910
911 return dev->ethtool_ops->flash_device(dev, &efl);
912}
913
894/* The main entry point in this file. Called from net/core/dev.c */ 914/* The main entry point in this file. Called from net/core/dev.c */
895 915
896int dev_ethtool(struct net *net, struct ifreq *ifr) 916int dev_ethtool(struct net *net, struct ifreq *ifr)
@@ -1004,7 +1024,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1004 break; 1024 break;
1005 case ETHTOOL_GRXCSUM: 1025 case ETHTOOL_GRXCSUM:
1006 rc = ethtool_get_value(dev, useraddr, ethcmd, 1026 rc = ethtool_get_value(dev, useraddr, ethcmd,
1007 dev->ethtool_ops->get_rx_csum); 1027 (dev->ethtool_ops->get_rx_csum ?
1028 dev->ethtool_ops->get_rx_csum :
1029 ethtool_op_get_rx_csum));
1008 break; 1030 break;
1009 case ETHTOOL_SRXCSUM: 1031 case ETHTOOL_SRXCSUM:
1010 rc = ethtool_set_rx_csum(dev, useraddr); 1032 rc = ethtool_set_rx_csum(dev, useraddr);
@@ -1068,7 +1090,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1068 break; 1090 break;
1069 case ETHTOOL_GFLAGS: 1091 case ETHTOOL_GFLAGS:
1070 rc = ethtool_get_value(dev, useraddr, ethcmd, 1092 rc = ethtool_get_value(dev, useraddr, ethcmd,
1071 dev->ethtool_ops->get_flags); 1093 (dev->ethtool_ops->get_flags ?
1094 dev->ethtool_ops->get_flags :
1095 ethtool_op_get_flags));
1072 break; 1096 break;
1073 case ETHTOOL_SFLAGS: 1097 case ETHTOOL_SFLAGS:
1074 rc = ethtool_set_value(dev, useraddr, 1098 rc = ethtool_set_value(dev, useraddr,
@@ -1100,6 +1124,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1100 case ETHTOOL_SGRO: 1124 case ETHTOOL_SGRO:
1101 rc = ethtool_set_gro(dev, useraddr); 1125 rc = ethtool_set_gro(dev, useraddr);
1102 break; 1126 break;
1127 case ETHTOOL_FLASHDEV:
1128 rc = ethtool_flash_device(dev, useraddr);
1129 break;
1103 default: 1130 default:
1104 rc = -EOPNOTSUPP; 1131 rc = -EOPNOTSUPP;
1105 } 1132 }
@@ -1116,7 +1143,6 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1116EXPORT_SYMBOL(ethtool_op_get_link); 1143EXPORT_SYMBOL(ethtool_op_get_link);
1117EXPORT_SYMBOL(ethtool_op_get_sg); 1144EXPORT_SYMBOL(ethtool_op_get_sg);
1118EXPORT_SYMBOL(ethtool_op_get_tso); 1145EXPORT_SYMBOL(ethtool_op_get_tso);
1119EXPORT_SYMBOL(ethtool_op_get_tx_csum);
1120EXPORT_SYMBOL(ethtool_op_set_sg); 1146EXPORT_SYMBOL(ethtool_op_set_sg);
1121EXPORT_SYMBOL(ethtool_op_set_tso); 1147EXPORT_SYMBOL(ethtool_op_set_tso);
1122EXPORT_SYMBOL(ethtool_op_set_tx_csum); 1148EXPORT_SYMBOL(ethtool_op_set_tx_csum);