diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/net/vxge/vxge-ethtool.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/net/vxge/vxge-ethtool.c')
-rw-r--r-- | drivers/net/vxge/vxge-ethtool.c | 142 |
1 files changed, 63 insertions, 79 deletions
diff --git a/drivers/net/vxge/vxge-ethtool.c b/drivers/net/vxge/vxge-ethtool.c index 05679e306fdd..92dd72d3f9de 100644 --- a/drivers/net/vxge/vxge-ethtool.c +++ b/drivers/net/vxge/vxge-ethtool.c | |||
@@ -11,7 +11,7 @@ | |||
11 | * Virtualized Server Adapter. | 11 | * Virtualized Server Adapter. |
12 | * Copyright(c) 2002-2010 Exar Corp. | 12 | * Copyright(c) 2002-2010 Exar Corp. |
13 | ******************************************************************************/ | 13 | ******************************************************************************/ |
14 | #include<linux/ethtool.h> | 14 | #include <linux/ethtool.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/pci.h> | 16 | #include <linux/pci.h> |
17 | #include <linux/etherdevice.h> | 17 | #include <linux/etherdevice.h> |
@@ -29,12 +29,12 @@ | |||
29 | * Return value: | 29 | * Return value: |
30 | * 0 on success. | 30 | * 0 on success. |
31 | */ | 31 | */ |
32 | |||
33 | static int vxge_ethtool_sset(struct net_device *dev, struct ethtool_cmd *info) | 32 | static int vxge_ethtool_sset(struct net_device *dev, struct ethtool_cmd *info) |
34 | { | 33 | { |
35 | /* We currently only support 10Gb/FULL */ | 34 | /* We currently only support 10Gb/FULL */ |
36 | if ((info->autoneg == AUTONEG_ENABLE) || | 35 | if ((info->autoneg == AUTONEG_ENABLE) || |
37 | (info->speed != SPEED_10000) || (info->duplex != DUPLEX_FULL)) | 36 | (ethtool_cmd_speed(info) != SPEED_10000) || |
37 | (info->duplex != DUPLEX_FULL)) | ||
38 | return -EINVAL; | 38 | return -EINVAL; |
39 | 39 | ||
40 | return 0; | 40 | return 0; |
@@ -59,10 +59,10 @@ static int vxge_ethtool_gset(struct net_device *dev, struct ethtool_cmd *info) | |||
59 | info->transceiver = XCVR_EXTERNAL; | 59 | info->transceiver = XCVR_EXTERNAL; |
60 | 60 | ||
61 | if (netif_carrier_ok(dev)) { | 61 | if (netif_carrier_ok(dev)) { |
62 | info->speed = SPEED_10000; | 62 | ethtool_cmd_speed_set(info, SPEED_10000); |
63 | info->duplex = DUPLEX_FULL; | 63 | info->duplex = DUPLEX_FULL; |
64 | } else { | 64 | } else { |
65 | info->speed = -1; | 65 | ethtool_cmd_speed_set(info, -1); |
66 | info->duplex = -1; | 66 | info->duplex = -1; |
67 | } | 67 | } |
68 | 68 | ||
@@ -79,10 +79,9 @@ static int vxge_ethtool_gset(struct net_device *dev, struct ethtool_cmd *info) | |||
79 | * Returns driver specefic information like name, version etc.. to ethtool. | 79 | * Returns driver specefic information like name, version etc.. to ethtool. |
80 | */ | 80 | */ |
81 | static void vxge_ethtool_gdrvinfo(struct net_device *dev, | 81 | static void vxge_ethtool_gdrvinfo(struct net_device *dev, |
82 | struct ethtool_drvinfo *info) | 82 | struct ethtool_drvinfo *info) |
83 | { | 83 | { |
84 | struct vxgedev *vdev; | 84 | struct vxgedev *vdev = netdev_priv(dev); |
85 | vdev = (struct vxgedev *)netdev_priv(dev); | ||
86 | strlcpy(info->driver, VXGE_DRIVER_NAME, sizeof(VXGE_DRIVER_NAME)); | 85 | strlcpy(info->driver, VXGE_DRIVER_NAME, sizeof(VXGE_DRIVER_NAME)); |
87 | strlcpy(info->version, DRV_VERSION, sizeof(DRV_VERSION)); | 86 | strlcpy(info->version, DRV_VERSION, sizeof(DRV_VERSION)); |
88 | strlcpy(info->fw_version, vdev->fw_version, VXGE_HW_FW_STRLEN); | 87 | strlcpy(info->fw_version, vdev->fw_version, VXGE_HW_FW_STRLEN); |
@@ -104,15 +103,14 @@ static void vxge_ethtool_gdrvinfo(struct net_device *dev, | |||
104 | * buffer area. | 103 | * buffer area. |
105 | */ | 104 | */ |
106 | static void vxge_ethtool_gregs(struct net_device *dev, | 105 | static void vxge_ethtool_gregs(struct net_device *dev, |
107 | struct ethtool_regs *regs, void *space) | 106 | struct ethtool_regs *regs, void *space) |
108 | { | 107 | { |
109 | int index, offset; | 108 | int index, offset; |
110 | enum vxge_hw_status status; | 109 | enum vxge_hw_status status; |
111 | u64 reg; | 110 | u64 reg; |
112 | u64 *reg_space = (u64 *) space; | 111 | u64 *reg_space = (u64 *)space; |
113 | struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev); | 112 | struct vxgedev *vdev = netdev_priv(dev); |
114 | struct __vxge_hw_device *hldev = (struct __vxge_hw_device *) | 113 | struct __vxge_hw_device *hldev = vdev->devh; |
115 | pci_get_drvdata(vdev->pdev); | ||
116 | 114 | ||
117 | regs->len = sizeof(struct vxge_hw_vpath_reg) * vdev->no_of_vpath; | 115 | regs->len = sizeof(struct vxge_hw_vpath_reg) * vdev->no_of_vpath; |
118 | regs->version = vdev->pdev->subsystem_device; | 116 | regs->version = vdev->pdev->subsystem_device; |
@@ -137,23 +135,29 @@ static void vxge_ethtool_gregs(struct net_device *dev, | |||
137 | /** | 135 | /** |
138 | * vxge_ethtool_idnic - To physically identify the nic on the system. | 136 | * vxge_ethtool_idnic - To physically identify the nic on the system. |
139 | * @dev : device pointer. | 137 | * @dev : device pointer. |
140 | * @id : pointer to the structure with identification parameters given by | 138 | * @state : requested LED state |
141 | * ethtool. | ||
142 | * | 139 | * |
143 | * Used to physically identify the NIC on the system. | 140 | * Used to physically identify the NIC on the system. |
144 | * The Link LED will blink for a time specified by the user. | ||
145 | * Return value: | ||
146 | * 0 on success | 141 | * 0 on success |
147 | */ | 142 | */ |
148 | static int vxge_ethtool_idnic(struct net_device *dev, u32 data) | 143 | static int vxge_ethtool_idnic(struct net_device *dev, |
144 | enum ethtool_phys_id_state state) | ||
149 | { | 145 | { |
150 | struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev); | 146 | struct vxgedev *vdev = netdev_priv(dev); |
151 | struct __vxge_hw_device *hldev = (struct __vxge_hw_device *) | 147 | struct __vxge_hw_device *hldev = vdev->devh; |
152 | pci_get_drvdata(vdev->pdev); | 148 | |
149 | switch (state) { | ||
150 | case ETHTOOL_ID_ACTIVE: | ||
151 | vxge_hw_device_flick_link_led(hldev, VXGE_FLICKER_ON); | ||
152 | break; | ||
153 | |||
154 | case ETHTOOL_ID_INACTIVE: | ||
155 | vxge_hw_device_flick_link_led(hldev, VXGE_FLICKER_OFF); | ||
156 | break; | ||
153 | 157 | ||
154 | vxge_hw_device_flick_link_led(hldev, VXGE_FLICKER_ON); | 158 | default: |
155 | msleep_interruptible(data ? (data * HZ) : VXGE_MAX_FLICKER_TIME); | 159 | return -EINVAL; |
156 | vxge_hw_device_flick_link_led(hldev, VXGE_FLICKER_OFF); | 160 | } |
157 | 161 | ||
158 | return 0; | 162 | return 0; |
159 | } | 163 | } |
@@ -168,11 +172,10 @@ static int vxge_ethtool_idnic(struct net_device *dev, u32 data) | |||
168 | * void | 172 | * void |
169 | */ | 173 | */ |
170 | static void vxge_ethtool_getpause_data(struct net_device *dev, | 174 | static void vxge_ethtool_getpause_data(struct net_device *dev, |
171 | struct ethtool_pauseparam *ep) | 175 | struct ethtool_pauseparam *ep) |
172 | { | 176 | { |
173 | struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev); | 177 | struct vxgedev *vdev = netdev_priv(dev); |
174 | struct __vxge_hw_device *hldev = (struct __vxge_hw_device *) | 178 | struct __vxge_hw_device *hldev = vdev->devh; |
175 | pci_get_drvdata(vdev->pdev); | ||
176 | 179 | ||
177 | vxge_hw_device_getpause_data(hldev, 0, &ep->tx_pause, &ep->rx_pause); | 180 | vxge_hw_device_getpause_data(hldev, 0, &ep->tx_pause, &ep->rx_pause); |
178 | } | 181 | } |
@@ -188,11 +191,10 @@ static void vxge_ethtool_getpause_data(struct net_device *dev, | |||
188 | * int, returns 0 on Success | 191 | * int, returns 0 on Success |
189 | */ | 192 | */ |
190 | static int vxge_ethtool_setpause_data(struct net_device *dev, | 193 | static int vxge_ethtool_setpause_data(struct net_device *dev, |
191 | struct ethtool_pauseparam *ep) | 194 | struct ethtool_pauseparam *ep) |
192 | { | 195 | { |
193 | struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev); | 196 | struct vxgedev *vdev = netdev_priv(dev); |
194 | struct __vxge_hw_device *hldev = (struct __vxge_hw_device *) | 197 | struct __vxge_hw_device *hldev = vdev->devh; |
195 | pci_get_drvdata(vdev->pdev); | ||
196 | 198 | ||
197 | vxge_hw_device_setpause_data(hldev, 0, ep->tx_pause, ep->rx_pause); | 199 | vxge_hw_device_setpause_data(hldev, 0, ep->tx_pause, ep->rx_pause); |
198 | 200 | ||
@@ -209,9 +211,8 @@ static void vxge_get_ethtool_stats(struct net_device *dev, | |||
209 | enum vxge_hw_status status; | 211 | enum vxge_hw_status status; |
210 | enum vxge_hw_status swstatus; | 212 | enum vxge_hw_status swstatus; |
211 | struct vxge_vpath *vpath = NULL; | 213 | struct vxge_vpath *vpath = NULL; |
212 | 214 | struct vxgedev *vdev = netdev_priv(dev); | |
213 | struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev); | 215 | struct __vxge_hw_device *hldev = vdev->devh; |
214 | struct __vxge_hw_device *hldev = vdev->devh; | ||
215 | struct vxge_hw_xmac_stats *xmac_stats; | 216 | struct vxge_hw_xmac_stats *xmac_stats; |
216 | struct vxge_hw_device_stats_sw_info *sw_stats; | 217 | struct vxge_hw_device_stats_sw_info *sw_stats; |
217 | struct vxge_hw_device_stats_hw_info *hw_stats; | 218 | struct vxge_hw_device_stats_hw_info *hw_stats; |
@@ -574,12 +575,12 @@ static void vxge_get_ethtool_stats(struct net_device *dev, | |||
574 | kfree(hw_stats); | 575 | kfree(hw_stats); |
575 | } | 576 | } |
576 | 577 | ||
577 | static void vxge_ethtool_get_strings(struct net_device *dev, | 578 | static void vxge_ethtool_get_strings(struct net_device *dev, u32 stringset, |
578 | u32 stringset, u8 *data) | 579 | u8 *data) |
579 | { | 580 | { |
580 | int stat_size = 0; | 581 | int stat_size = 0; |
581 | int i, j; | 582 | int i, j; |
582 | struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev); | 583 | struct vxgedev *vdev = netdev_priv(dev); |
583 | switch (stringset) { | 584 | switch (stringset) { |
584 | case ETH_SS_STATS: | 585 | case ETH_SS_STATS: |
585 | vxge_add_string("VPATH STATISTICS%s\t\t\t", | 586 | vxge_add_string("VPATH STATISTICS%s\t\t\t", |
@@ -1066,43 +1067,14 @@ static void vxge_ethtool_get_strings(struct net_device *dev, | |||
1066 | 1067 | ||
1067 | static int vxge_ethtool_get_regs_len(struct net_device *dev) | 1068 | static int vxge_ethtool_get_regs_len(struct net_device *dev) |
1068 | { | 1069 | { |
1069 | struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev); | 1070 | struct vxgedev *vdev = netdev_priv(dev); |
1070 | 1071 | ||
1071 | return sizeof(struct vxge_hw_vpath_reg) * vdev->no_of_vpath; | 1072 | return sizeof(struct vxge_hw_vpath_reg) * vdev->no_of_vpath; |
1072 | } | 1073 | } |
1073 | 1074 | ||
1074 | static u32 vxge_get_rx_csum(struct net_device *dev) | ||
1075 | { | ||
1076 | struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev); | ||
1077 | |||
1078 | return vdev->rx_csum; | ||
1079 | } | ||
1080 | |||
1081 | static int vxge_set_rx_csum(struct net_device *dev, u32 data) | ||
1082 | { | ||
1083 | struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev); | ||
1084 | |||
1085 | if (data) | ||
1086 | vdev->rx_csum = 1; | ||
1087 | else | ||
1088 | vdev->rx_csum = 0; | ||
1089 | |||
1090 | return 0; | ||
1091 | } | ||
1092 | |||
1093 | static int vxge_ethtool_op_set_tso(struct net_device *dev, u32 data) | ||
1094 | { | ||
1095 | if (data) | ||
1096 | dev->features |= (NETIF_F_TSO | NETIF_F_TSO6); | ||
1097 | else | ||
1098 | dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); | ||
1099 | |||
1100 | return 0; | ||
1101 | } | ||
1102 | |||
1103 | static int vxge_ethtool_get_sset_count(struct net_device *dev, int sset) | 1075 | static int vxge_ethtool_get_sset_count(struct net_device *dev, int sset) |
1104 | { | 1076 | { |
1105 | struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev); | 1077 | struct vxgedev *vdev = netdev_priv(dev); |
1106 | 1078 | ||
1107 | switch (sset) { | 1079 | switch (sset) { |
1108 | case ETH_SS_STATS: | 1080 | case ETH_SS_STATS: |
@@ -1119,6 +1091,25 @@ static int vxge_ethtool_get_sset_count(struct net_device *dev, int sset) | |||
1119 | } | 1091 | } |
1120 | } | 1092 | } |
1121 | 1093 | ||
1094 | static int vxge_fw_flash(struct net_device *dev, struct ethtool_flash *parms) | ||
1095 | { | ||
1096 | struct vxgedev *vdev = netdev_priv(dev); | ||
1097 | |||
1098 | if (vdev->max_vpath_supported != VXGE_HW_MAX_VIRTUAL_PATHS) { | ||
1099 | printk(KERN_INFO "Single Function Mode is required to flash the" | ||
1100 | " firmware\n"); | ||
1101 | return -EINVAL; | ||
1102 | } | ||
1103 | |||
1104 | if (netif_running(dev)) { | ||
1105 | printk(KERN_INFO "Interface %s must be down to flash the " | ||
1106 | "firmware\n", dev->name); | ||
1107 | return -EBUSY; | ||
1108 | } | ||
1109 | |||
1110 | return vxge_fw_upgrade(vdev, parms->data, 1); | ||
1111 | } | ||
1112 | |||
1122 | static const struct ethtool_ops vxge_ethtool_ops = { | 1113 | static const struct ethtool_ops vxge_ethtool_ops = { |
1123 | .get_settings = vxge_ethtool_gset, | 1114 | .get_settings = vxge_ethtool_gset, |
1124 | .set_settings = vxge_ethtool_sset, | 1115 | .set_settings = vxge_ethtool_sset, |
@@ -1128,21 +1119,14 @@ static const struct ethtool_ops vxge_ethtool_ops = { | |||
1128 | .get_link = ethtool_op_get_link, | 1119 | .get_link = ethtool_op_get_link, |
1129 | .get_pauseparam = vxge_ethtool_getpause_data, | 1120 | .get_pauseparam = vxge_ethtool_getpause_data, |
1130 | .set_pauseparam = vxge_ethtool_setpause_data, | 1121 | .set_pauseparam = vxge_ethtool_setpause_data, |
1131 | .get_rx_csum = vxge_get_rx_csum, | ||
1132 | .set_rx_csum = vxge_set_rx_csum, | ||
1133 | .get_tx_csum = ethtool_op_get_tx_csum, | ||
1134 | .set_tx_csum = ethtool_op_set_tx_hw_csum, | ||
1135 | .get_sg = ethtool_op_get_sg, | ||
1136 | .set_sg = ethtool_op_set_sg, | ||
1137 | .get_tso = ethtool_op_get_tso, | ||
1138 | .set_tso = vxge_ethtool_op_set_tso, | ||
1139 | .get_strings = vxge_ethtool_get_strings, | 1122 | .get_strings = vxge_ethtool_get_strings, |
1140 | .phys_id = vxge_ethtool_idnic, | 1123 | .set_phys_id = vxge_ethtool_idnic, |
1141 | .get_sset_count = vxge_ethtool_get_sset_count, | 1124 | .get_sset_count = vxge_ethtool_get_sset_count, |
1142 | .get_ethtool_stats = vxge_get_ethtool_stats, | 1125 | .get_ethtool_stats = vxge_get_ethtool_stats, |
1126 | .flash_device = vxge_fw_flash, | ||
1143 | }; | 1127 | }; |
1144 | 1128 | ||
1145 | void initialize_ethtool_ops(struct net_device *ndev) | 1129 | void vxge_initialize_ethtool_ops(struct net_device *ndev) |
1146 | { | 1130 | { |
1147 | SET_ETHTOOL_OPS(ndev, &vxge_ethtool_ops); | 1131 | SET_ETHTOOL_OPS(ndev, &vxge_ethtool_ops); |
1148 | } | 1132 | } |