diff options
Diffstat (limited to 'drivers/net/netxen')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 11 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_ethtool.c | 5 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hw.c | 294 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_init.c | 237 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_ioctl.h | 77 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 45 |
6 files changed, 1 insertions, 668 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index b5410bee5f21..b4c4fc0c7218 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -1027,14 +1027,6 @@ int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data, | |||
1027 | int len); | 1027 | int len); |
1028 | int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data, | 1028 | int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data, |
1029 | int len); | 1029 | int len); |
1030 | int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1031 | void *data, int len); | ||
1032 | int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1033 | void *data, int len); | ||
1034 | int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter, | ||
1035 | u64 off, void *data, int size); | ||
1036 | int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter, | ||
1037 | u64 off, void *data, int size); | ||
1038 | void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, | 1030 | void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, |
1039 | unsigned long off, int data); | 1031 | unsigned long off, int data); |
1040 | 1032 | ||
@@ -1067,9 +1059,6 @@ void netxen_tso_check(struct netxen_adapter *adapter, | |||
1067 | struct cmd_desc_type0 *desc, struct sk_buff *skb); | 1059 | struct cmd_desc_type0 *desc, struct sk_buff *skb); |
1068 | int netxen_nic_hw_resources(struct netxen_adapter *adapter); | 1060 | int netxen_nic_hw_resources(struct netxen_adapter *adapter); |
1069 | void netxen_nic_clear_stats(struct netxen_adapter *adapter); | 1061 | void netxen_nic_clear_stats(struct netxen_adapter *adapter); |
1070 | int | ||
1071 | netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data, | ||
1072 | struct netxen_port *port); | ||
1073 | int netxen_nic_rx_has_work(struct netxen_adapter *adapter); | 1062 | int netxen_nic_rx_has_work(struct netxen_adapter *adapter); |
1074 | int netxen_nic_tx_has_work(struct netxen_adapter *adapter); | 1063 | int netxen_nic_tx_has_work(struct netxen_adapter *adapter); |
1075 | void netxen_watchdog_task(struct work_struct *work); | 1064 | void netxen_watchdog_task(struct work_struct *work); |
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index 2ab4885cc950..34044616b3c8 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include "netxen_nic_hw.h" | 42 | #include "netxen_nic_hw.h" |
43 | #include "netxen_nic.h" | 43 | #include "netxen_nic.h" |
44 | #include "netxen_nic_phan_reg.h" | 44 | #include "netxen_nic_phan_reg.h" |
45 | #include "netxen_nic_ioctl.h" | ||
46 | 45 | ||
47 | struct netxen_nic_stats { | 46 | struct netxen_nic_stats { |
48 | char stat_string[ETH_GSTRING_LEN]; | 47 | char stat_string[ETH_GSTRING_LEN]; |
@@ -79,8 +78,7 @@ static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = { | |||
79 | {"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)}, | 78 | {"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)}, |
80 | }; | 79 | }; |
81 | 80 | ||
82 | #define NETXEN_NIC_STATS_LEN \ | 81 | #define NETXEN_NIC_STATS_LEN ARRAY_SIZE(netxen_nic_gstrings_stats) |
83 | sizeof(netxen_nic_gstrings_stats) / sizeof(struct netxen_nic_stats) | ||
84 | 82 | ||
85 | static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = { | 83 | static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = { |
86 | "Register_Test_offline", "EEPROM_Test_offline", | 84 | "Register_Test_offline", "EEPROM_Test_offline", |
@@ -711,7 +709,6 @@ netxen_nic_get_ethtool_stats(struct net_device *dev, | |||
711 | (netxen_nic_gstrings_stats[index].sizeof_stat == | 709 | (netxen_nic_gstrings_stats[index].sizeof_stat == |
712 | sizeof(u64)) ? *(u64 *) p : *(u32 *) p; | 710 | sizeof(u64)) ? *(u64 *) p : *(u32 *) p; |
713 | } | 711 | } |
714 | |||
715 | } | 712 | } |
716 | 713 | ||
717 | struct ethtool_ops netxen_nic_ethtool_ops = { | 714 | struct ethtool_ops netxen_nic_ethtool_ops = { |
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index 9147b6048dfb..5dac50c87075 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c | |||
@@ -997,297 +997,3 @@ void netxen_nic_flash_print(struct netxen_adapter *adapter) | |||
997 | fw_major, fw_minor); | 997 | fw_major, fw_minor); |
998 | } | 998 | } |
999 | 999 | ||
1000 | int netxen_crb_read_val(struct netxen_adapter *adapter, unsigned long off) | ||
1001 | { | ||
1002 | int data; | ||
1003 | netxen_nic_hw_read_wx(adapter, off, &data, 4); | ||
1004 | return data; | ||
1005 | } | ||
1006 | |||
1007 | int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1008 | void *data, int len) | ||
1009 | { | ||
1010 | void *addr; | ||
1011 | u64 offset = off; | ||
1012 | u8 *mem_ptr = NULL; | ||
1013 | unsigned long mem_base; | ||
1014 | unsigned long mem_page; | ||
1015 | |||
1016 | if (ADDR_IN_WINDOW1(off)) { | ||
1017 | addr = NETXEN_CRB_NORMALIZE(adapter, off); | ||
1018 | if (!addr) { | ||
1019 | mem_base = pci_resource_start(adapter->ahw.pdev, 0); | ||
1020 | offset = NETXEN_CRB_NORMAL(off); | ||
1021 | mem_page = offset & PAGE_MASK; | ||
1022 | if (mem_page != ((offset + len - 1) & PAGE_MASK)) | ||
1023 | mem_ptr = | ||
1024 | ioremap(mem_base + mem_page, PAGE_SIZE * 2); | ||
1025 | else | ||
1026 | mem_ptr = | ||
1027 | ioremap(mem_base + mem_page, PAGE_SIZE); | ||
1028 | if (mem_ptr == 0UL) { | ||
1029 | return 1; | ||
1030 | } | ||
1031 | addr = mem_ptr; | ||
1032 | addr += offset & (PAGE_SIZE - 1); | ||
1033 | } | ||
1034 | } else { | ||
1035 | addr = pci_base_offset(adapter, off); | ||
1036 | if (!addr) { | ||
1037 | mem_base = pci_resource_start(adapter->ahw.pdev, 0); | ||
1038 | mem_page = off & PAGE_MASK; | ||
1039 | if (mem_page != ((off + len - 1) & PAGE_MASK)) | ||
1040 | mem_ptr = | ||
1041 | ioremap(mem_base + mem_page, PAGE_SIZE * 2); | ||
1042 | else | ||
1043 | mem_ptr = | ||
1044 | ioremap(mem_base + mem_page, PAGE_SIZE); | ||
1045 | if (mem_ptr == 0UL) { | ||
1046 | return 1; | ||
1047 | } | ||
1048 | addr = mem_ptr; | ||
1049 | addr += off & (PAGE_SIZE - 1); | ||
1050 | } | ||
1051 | netxen_nic_pci_change_crbwindow(adapter, 0); | ||
1052 | } | ||
1053 | switch (len) { | ||
1054 | case 1: | ||
1055 | writeb(*(u8 *) data, addr); | ||
1056 | break; | ||
1057 | case 2: | ||
1058 | writew(*(u16 *) data, addr); | ||
1059 | break; | ||
1060 | case 4: | ||
1061 | writel(*(u32 *) data, addr); | ||
1062 | break; | ||
1063 | case 8: | ||
1064 | writeq(*(u64 *) data, addr); | ||
1065 | break; | ||
1066 | default: | ||
1067 | DPRINTK(INFO, | ||
1068 | "writing data %lx to offset %llx, num words=%d\n", | ||
1069 | *(unsigned long *)data, off, (len >> 3)); | ||
1070 | |||
1071 | netxen_nic_hw_block_write64((u64 __iomem *) data, addr, | ||
1072 | (len >> 3)); | ||
1073 | break; | ||
1074 | } | ||
1075 | |||
1076 | if (!ADDR_IN_WINDOW1(off)) | ||
1077 | netxen_nic_pci_change_crbwindow(adapter, 1); | ||
1078 | if (mem_ptr) | ||
1079 | iounmap(mem_ptr); | ||
1080 | return 0; | ||
1081 | } | ||
1082 | |||
1083 | int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1084 | void *data, int len) | ||
1085 | { | ||
1086 | void *addr; | ||
1087 | u64 offset; | ||
1088 | u8 *mem_ptr = NULL; | ||
1089 | unsigned long mem_base; | ||
1090 | unsigned long mem_page; | ||
1091 | |||
1092 | if (ADDR_IN_WINDOW1(off)) { | ||
1093 | addr = NETXEN_CRB_NORMALIZE(adapter, off); | ||
1094 | if (!addr) { | ||
1095 | mem_base = pci_resource_start(adapter->ahw.pdev, 0); | ||
1096 | offset = NETXEN_CRB_NORMAL(off); | ||
1097 | mem_page = offset & PAGE_MASK; | ||
1098 | if (mem_page != ((offset + len - 1) & PAGE_MASK)) | ||
1099 | mem_ptr = | ||
1100 | ioremap(mem_base + mem_page, PAGE_SIZE * 2); | ||
1101 | else | ||
1102 | mem_ptr = | ||
1103 | ioremap(mem_base + mem_page, PAGE_SIZE); | ||
1104 | if (mem_ptr == 0UL) { | ||
1105 | *(u8 *) data = 0; | ||
1106 | return 1; | ||
1107 | } | ||
1108 | addr = mem_ptr; | ||
1109 | addr += offset & (PAGE_SIZE - 1); | ||
1110 | } | ||
1111 | } else { | ||
1112 | addr = pci_base_offset(adapter, off); | ||
1113 | if (!addr) { | ||
1114 | mem_base = pci_resource_start(adapter->ahw.pdev, 0); | ||
1115 | mem_page = off & PAGE_MASK; | ||
1116 | if (mem_page != ((off + len - 1) & PAGE_MASK)) | ||
1117 | mem_ptr = | ||
1118 | ioremap(mem_base + mem_page, PAGE_SIZE * 2); | ||
1119 | else | ||
1120 | mem_ptr = | ||
1121 | ioremap(mem_base + mem_page, PAGE_SIZE); | ||
1122 | if (mem_ptr == 0UL) | ||
1123 | return 1; | ||
1124 | addr = mem_ptr; | ||
1125 | addr += off & (PAGE_SIZE - 1); | ||
1126 | } | ||
1127 | netxen_nic_pci_change_crbwindow(adapter, 0); | ||
1128 | } | ||
1129 | switch (len) { | ||
1130 | case 1: | ||
1131 | *(u8 *) data = readb(addr); | ||
1132 | break; | ||
1133 | case 2: | ||
1134 | *(u16 *) data = readw(addr); | ||
1135 | break; | ||
1136 | case 4: | ||
1137 | *(u32 *) data = readl(addr); | ||
1138 | break; | ||
1139 | case 8: | ||
1140 | *(u64 *) data = readq(addr); | ||
1141 | break; | ||
1142 | default: | ||
1143 | netxen_nic_hw_block_read64((u64 __iomem *) data, addr, | ||
1144 | (len >> 3)); | ||
1145 | break; | ||
1146 | } | ||
1147 | if (!ADDR_IN_WINDOW1(off)) | ||
1148 | netxen_nic_pci_change_crbwindow(adapter, 1); | ||
1149 | if (mem_ptr) | ||
1150 | iounmap(mem_ptr); | ||
1151 | return 0; | ||
1152 | } | ||
1153 | |||
1154 | int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1155 | void *data, int size) | ||
1156 | { | ||
1157 | void *addr; | ||
1158 | int ret = 0; | ||
1159 | u8 *mem_ptr = NULL; | ||
1160 | unsigned long mem_base; | ||
1161 | unsigned long mem_page; | ||
1162 | |||
1163 | if (data == NULL || off > (128 * 1024 * 1024)) { | ||
1164 | printk(KERN_ERR "%s: data: %p off:%llx\n", | ||
1165 | netxen_nic_driver_name, data, off); | ||
1166 | return 1; | ||
1167 | } | ||
1168 | off = netxen_nic_pci_set_window(adapter, off); | ||
1169 | /* Corner case : Malicious user tried to break the driver by reading | ||
1170 | last few bytes in ranges and tries to read further addresses. | ||
1171 | */ | ||
1172 | if (!pci_base(adapter, off + size - 1) && pci_base(adapter, off)) { | ||
1173 | printk(KERN_ERR "%s: Invalid access to memory address range" | ||
1174 | " 0x%llx - 0x%llx\n", netxen_nic_driver_name, off, | ||
1175 | off + size); | ||
1176 | return 1; | ||
1177 | } | ||
1178 | addr = pci_base_offset(adapter, off); | ||
1179 | DPRINTK(INFO, "writing data %llx to offset %llx\n", | ||
1180 | *(unsigned long long *)data, off); | ||
1181 | if (!addr) { | ||
1182 | mem_base = pci_resource_start(adapter->ahw.pdev, 0); | ||
1183 | mem_page = off & PAGE_MASK; | ||
1184 | /* Map two pages whenever user tries to access addresses in two | ||
1185 | consecutive pages. | ||
1186 | */ | ||
1187 | if (mem_page != ((off + size - 1) & PAGE_MASK)) | ||
1188 | mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2); | ||
1189 | else | ||
1190 | mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE); | ||
1191 | if (mem_ptr == 0UL) { | ||
1192 | return 1; | ||
1193 | } | ||
1194 | addr = mem_ptr; | ||
1195 | addr += off & (PAGE_SIZE - 1); | ||
1196 | } | ||
1197 | switch (size) { | ||
1198 | case 1: | ||
1199 | writeb(*(u8 *) data, addr); | ||
1200 | break; | ||
1201 | case 2: | ||
1202 | writew(*(u16 *) data, addr); | ||
1203 | break; | ||
1204 | case 4: | ||
1205 | writel(*(u32 *) data, addr); | ||
1206 | break; | ||
1207 | case 8: | ||
1208 | writeq(*(u64 *) data, addr); | ||
1209 | break; | ||
1210 | default: | ||
1211 | DPRINTK(INFO, | ||
1212 | "writing data %lx to offset %llx, num words=%d\n", | ||
1213 | *(unsigned long *)data, off, (size >> 3)); | ||
1214 | |||
1215 | netxen_nic_hw_block_write64((u64 __iomem *) data, addr, | ||
1216 | (size >> 3)); | ||
1217 | break; | ||
1218 | } | ||
1219 | |||
1220 | if (mem_ptr) | ||
1221 | iounmap(mem_ptr); | ||
1222 | DPRINTK(INFO, "wrote %llx\n", *(unsigned long long *)data); | ||
1223 | |||
1224 | return ret; | ||
1225 | } | ||
1226 | |||
1227 | int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter, | ||
1228 | u64 off, void *data, int size) | ||
1229 | { | ||
1230 | void *addr; | ||
1231 | int ret = 0; | ||
1232 | u8 *mem_ptr = NULL; | ||
1233 | unsigned long mem_base; | ||
1234 | unsigned long mem_page; | ||
1235 | |||
1236 | if (data == NULL || off > (128 * 1024 * 1024)) { | ||
1237 | printk(KERN_ERR "%s: data: %p off:%llx\n", | ||
1238 | netxen_nic_driver_name, data, off); | ||
1239 | return 1; | ||
1240 | } | ||
1241 | off = netxen_nic_pci_set_window(adapter, off); | ||
1242 | /* Corner case : Malicious user tried to break the driver by reading | ||
1243 | last few bytes in ranges and tries to read further addresses. | ||
1244 | */ | ||
1245 | if (!pci_base(adapter, off + size - 1) && pci_base(adapter, off)) { | ||
1246 | printk(KERN_ERR "%s: Invalid access to memory address range" | ||
1247 | " 0x%llx - 0x%llx\n", netxen_nic_driver_name, off, | ||
1248 | off + size); | ||
1249 | return 1; | ||
1250 | } | ||
1251 | addr = pci_base_offset(adapter, off); | ||
1252 | if (!addr) { | ||
1253 | mem_base = pci_resource_start(adapter->ahw.pdev, 0); | ||
1254 | mem_page = off & PAGE_MASK; | ||
1255 | /* Map two pages whenever user tries to access addresses in two | ||
1256 | consecutive pages. | ||
1257 | */ | ||
1258 | if (mem_page != ((off + size - 1) & PAGE_MASK)) | ||
1259 | mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2); | ||
1260 | else | ||
1261 | mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE); | ||
1262 | if (mem_ptr == 0UL) { | ||
1263 | *(u8 *) data = 0; | ||
1264 | return 1; | ||
1265 | } | ||
1266 | addr = mem_ptr; | ||
1267 | addr += off & (PAGE_SIZE - 1); | ||
1268 | } | ||
1269 | switch (size) { | ||
1270 | case 1: | ||
1271 | *(u8 *) data = readb(addr); | ||
1272 | break; | ||
1273 | case 2: | ||
1274 | *(u16 *) data = readw(addr); | ||
1275 | break; | ||
1276 | case 4: | ||
1277 | *(u32 *) data = readl(addr); | ||
1278 | break; | ||
1279 | case 8: | ||
1280 | *(u64 *) data = readq(addr); | ||
1281 | break; | ||
1282 | default: | ||
1283 | netxen_nic_hw_block_read64((u64 __iomem *) data, addr, | ||
1284 | (size >> 3)); | ||
1285 | break; | ||
1286 | } | ||
1287 | |||
1288 | if (mem_ptr) | ||
1289 | iounmap(mem_ptr); | ||
1290 | DPRINTK(INFO, "read %llx\n", *(unsigned long long *)data); | ||
1291 | |||
1292 | return ret; | ||
1293 | } | ||
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index 869725f0bb18..deacc61e199c 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include "netxen_nic.h" | 36 | #include "netxen_nic.h" |
37 | #include "netxen_nic_hw.h" | 37 | #include "netxen_nic_hw.h" |
38 | #include "netxen_nic_ioctl.h" | ||
39 | #include "netxen_nic_phan_reg.h" | 38 | #include "netxen_nic_phan_reg.h" |
40 | 39 | ||
41 | struct crb_addr_pair { | 40 | struct crb_addr_pair { |
@@ -1273,52 +1272,6 @@ int netxen_nic_tx_has_work(struct netxen_adapter *adapter) | |||
1273 | return 0; | 1272 | return 0; |
1274 | } | 1273 | } |
1275 | 1274 | ||
1276 | int | ||
1277 | netxen_nic_fill_statistics(struct netxen_adapter *adapter, | ||
1278 | struct netxen_port *port, | ||
1279 | struct netxen_statistics *netxen_stats) | ||
1280 | { | ||
1281 | void __iomem *addr; | ||
1282 | |||
1283 | if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { | ||
1284 | netxen_nic_pci_change_crbwindow(adapter, 0); | ||
1285 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_TX_BYTE_CNT, | ||
1286 | &(netxen_stats->tx_bytes)); | ||
1287 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_TX_FRAME_CNT, | ||
1288 | &(netxen_stats->tx_packets)); | ||
1289 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_RX_BYTE_CNT, | ||
1290 | &(netxen_stats->rx_bytes)); | ||
1291 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_RX_FRAME_CNT, | ||
1292 | &(netxen_stats->rx_packets)); | ||
1293 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_AGGR_ERROR_CNT, | ||
1294 | &(netxen_stats->rx_errors)); | ||
1295 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_CRC_ERROR_CNT, | ||
1296 | &(netxen_stats->rx_crc_errors)); | ||
1297 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR, | ||
1298 | &(netxen_stats-> | ||
1299 | rx_long_length_error)); | ||
1300 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR, | ||
1301 | &(netxen_stats-> | ||
1302 | rx_short_length_error)); | ||
1303 | |||
1304 | netxen_nic_pci_change_crbwindow(adapter, 1); | ||
1305 | } else { | ||
1306 | spin_lock_bh(&adapter->tx_lock); | ||
1307 | netxen_stats->tx_bytes = port->stats.txbytes; | ||
1308 | netxen_stats->tx_packets = port->stats.xmitedframes + | ||
1309 | port->stats.xmitfinished; | ||
1310 | netxen_stats->rx_bytes = port->stats.rxbytes; | ||
1311 | netxen_stats->rx_packets = port->stats.no_rcv; | ||
1312 | netxen_stats->rx_errors = port->stats.rcvdbadskb; | ||
1313 | netxen_stats->tx_errors = port->stats.nocmddescriptor; | ||
1314 | netxen_stats->rx_short_length_error = port->stats.uplcong; | ||
1315 | netxen_stats->rx_long_length_error = port->stats.uphcong; | ||
1316 | netxen_stats->rx_crc_errors = 0; | ||
1317 | netxen_stats->rx_mac_errors = 0; | ||
1318 | spin_unlock_bh(&adapter->tx_lock); | ||
1319 | } | ||
1320 | return 0; | ||
1321 | } | ||
1322 | 1275 | ||
1323 | void netxen_nic_clear_stats(struct netxen_adapter *adapter) | 1276 | void netxen_nic_clear_stats(struct netxen_adapter *adapter) |
1324 | { | 1277 | { |
@@ -1332,193 +1285,3 @@ void netxen_nic_clear_stats(struct netxen_adapter *adapter) | |||
1332 | } | 1285 | } |
1333 | } | 1286 | } |
1334 | 1287 | ||
1335 | int | ||
1336 | netxen_nic_clear_statistics(struct netxen_adapter *adapter, | ||
1337 | struct netxen_port *port) | ||
1338 | { | ||
1339 | int data = 0; | ||
1340 | |||
1341 | netxen_nic_pci_change_crbwindow(adapter, 0); | ||
1342 | |||
1343 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_TX_BYTE_CNT, &data); | ||
1344 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_TX_FRAME_CNT, | ||
1345 | &data); | ||
1346 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_RX_BYTE_CNT, &data); | ||
1347 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_RX_FRAME_CNT, | ||
1348 | &data); | ||
1349 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_AGGR_ERROR_CNT, | ||
1350 | &data); | ||
1351 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_CRC_ERROR_CNT, | ||
1352 | &data); | ||
1353 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR, | ||
1354 | &data); | ||
1355 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR, | ||
1356 | &data); | ||
1357 | |||
1358 | netxen_nic_pci_change_crbwindow(adapter, 1); | ||
1359 | netxen_nic_clear_stats(adapter); | ||
1360 | return 0; | ||
1361 | } | ||
1362 | |||
1363 | int | ||
1364 | netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data, | ||
1365 | struct netxen_port *port) | ||
1366 | { | ||
1367 | struct netxen_nic_ioctl_data data; | ||
1368 | struct netxen_nic_ioctl_data *up_data; | ||
1369 | int retval = 0; | ||
1370 | struct netxen_statistics netxen_stats; | ||
1371 | |||
1372 | up_data = (void *)u_data; | ||
1373 | |||
1374 | DPRINTK(INFO, "doing ioctl for %p\n", adapter); | ||
1375 | if (copy_from_user(&data, (void __user *)up_data, sizeof(data))) { | ||
1376 | /* evil user tried to crash the kernel */ | ||
1377 | DPRINTK(ERR, "bad copy from userland: %d\n", (int)sizeof(data)); | ||
1378 | retval = -EFAULT; | ||
1379 | goto error_out; | ||
1380 | } | ||
1381 | |||
1382 | /* Shouldn't access beyond legal limits of "char u[64];" member */ | ||
1383 | if (!data.ptr && (data.size > sizeof(data.u))) { | ||
1384 | /* evil user tried to crash the kernel */ | ||
1385 | DPRINTK(ERR, "bad size: %d\n", data.size); | ||
1386 | retval = -EFAULT; | ||
1387 | goto error_out; | ||
1388 | } | ||
1389 | |||
1390 | switch (data.cmd) { | ||
1391 | case netxen_nic_cmd_pci_read: | ||
1392 | if ((retval = netxen_nic_hw_read_ioctl(adapter, data.off, | ||
1393 | &(data.u), data.size))) | ||
1394 | goto error_out; | ||
1395 | if (copy_to_user | ||
1396 | ((void __user *)&(up_data->u), &(data.u), data.size)) { | ||
1397 | DPRINTK(ERR, "bad copy to userland: %d\n", | ||
1398 | (int)sizeof(data)); | ||
1399 | retval = -EFAULT; | ||
1400 | goto error_out; | ||
1401 | } | ||
1402 | data.rv = 0; | ||
1403 | break; | ||
1404 | |||
1405 | case netxen_nic_cmd_pci_write: | ||
1406 | if ((retval = netxen_nic_hw_write_ioctl(adapter, data.off, | ||
1407 | &(data.u), data.size))) | ||
1408 | goto error_out; | ||
1409 | data.rv = 0; | ||
1410 | break; | ||
1411 | |||
1412 | case netxen_nic_cmd_pci_mem_read: | ||
1413 | if (netxen_nic_pci_mem_read_ioctl(adapter, data.off, &(data.u), | ||
1414 | data.size)) { | ||
1415 | DPRINTK(ERR, "Failed to read the data.\n"); | ||
1416 | retval = -EFAULT; | ||
1417 | goto error_out; | ||
1418 | } | ||
1419 | if (copy_to_user | ||
1420 | ((void __user *)&(up_data->u), &(data.u), data.size)) { | ||
1421 | DPRINTK(ERR, "bad copy to userland: %d\n", | ||
1422 | (int)sizeof(data)); | ||
1423 | retval = -EFAULT; | ||
1424 | goto error_out; | ||
1425 | } | ||
1426 | data.rv = 0; | ||
1427 | break; | ||
1428 | |||
1429 | case netxen_nic_cmd_pci_mem_write: | ||
1430 | if ((retval = netxen_nic_pci_mem_write_ioctl(adapter, data.off, | ||
1431 | &(data.u), | ||
1432 | data.size))) | ||
1433 | goto error_out; | ||
1434 | data.rv = 0; | ||
1435 | break; | ||
1436 | |||
1437 | case netxen_nic_cmd_pci_config_read: | ||
1438 | switch (data.size) { | ||
1439 | case 1: | ||
1440 | data.rv = pci_read_config_byte(adapter->ahw.pdev, | ||
1441 | data.off, | ||
1442 | (char *)&(data.u)); | ||
1443 | break; | ||
1444 | case 2: | ||
1445 | data.rv = pci_read_config_word(adapter->ahw.pdev, | ||
1446 | data.off, | ||
1447 | (short *)&(data.u)); | ||
1448 | break; | ||
1449 | case 4: | ||
1450 | data.rv = pci_read_config_dword(adapter->ahw.pdev, | ||
1451 | data.off, | ||
1452 | (u32 *) & (data.u)); | ||
1453 | break; | ||
1454 | } | ||
1455 | if (copy_to_user | ||
1456 | ((void __user *)&(up_data->u), &(data.u), data.size)) { | ||
1457 | DPRINTK(ERR, "bad copy to userland: %d\n", | ||
1458 | (int)sizeof(data)); | ||
1459 | retval = -EFAULT; | ||
1460 | goto error_out; | ||
1461 | } | ||
1462 | break; | ||
1463 | |||
1464 | case netxen_nic_cmd_pci_config_write: | ||
1465 | switch (data.size) { | ||
1466 | case 1: | ||
1467 | data.rv = pci_write_config_byte(adapter->ahw.pdev, | ||
1468 | data.off, | ||
1469 | *(char *)&(data.u)); | ||
1470 | break; | ||
1471 | case 2: | ||
1472 | data.rv = pci_write_config_word(adapter->ahw.pdev, | ||
1473 | data.off, | ||
1474 | *(short *)&(data.u)); | ||
1475 | break; | ||
1476 | case 4: | ||
1477 | data.rv = pci_write_config_dword(adapter->ahw.pdev, | ||
1478 | data.off, | ||
1479 | *(u32 *) & (data.u)); | ||
1480 | break; | ||
1481 | } | ||
1482 | break; | ||
1483 | |||
1484 | case netxen_nic_cmd_get_stats: | ||
1485 | data.rv = | ||
1486 | netxen_nic_fill_statistics(adapter, port, &netxen_stats); | ||
1487 | if (copy_to_user | ||
1488 | ((void __user *)(up_data->ptr), (void *)&netxen_stats, | ||
1489 | sizeof(struct netxen_statistics))) { | ||
1490 | DPRINTK(ERR, "bad copy to userland: %d\n", | ||
1491 | (int)sizeof(netxen_stats)); | ||
1492 | retval = -EFAULT; | ||
1493 | goto error_out; | ||
1494 | } | ||
1495 | up_data->rv = data.rv; | ||
1496 | break; | ||
1497 | |||
1498 | case netxen_nic_cmd_clear_stats: | ||
1499 | data.rv = netxen_nic_clear_statistics(adapter, port); | ||
1500 | up_data->rv = data.rv; | ||
1501 | break; | ||
1502 | |||
1503 | case netxen_nic_cmd_get_version: | ||
1504 | if (copy_to_user | ||
1505 | ((void __user *)&(up_data->u), NETXEN_NIC_LINUX_VERSIONID, | ||
1506 | sizeof(NETXEN_NIC_LINUX_VERSIONID))) { | ||
1507 | DPRINTK(ERR, "bad copy to userland: %d\n", | ||
1508 | (int)sizeof(data)); | ||
1509 | retval = -EFAULT; | ||
1510 | goto error_out; | ||
1511 | } | ||
1512 | break; | ||
1513 | |||
1514 | default: | ||
1515 | DPRINTK(INFO, "bad command %d for %p\n", data.cmd, adapter); | ||
1516 | retval = -EOPNOTSUPP; | ||
1517 | goto error_out; | ||
1518 | } | ||
1519 | put_user(data.rv, (&(up_data->rv))); | ||
1520 | DPRINTK(INFO, "done ioctl for %p well.\n", adapter); | ||
1521 | |||
1522 | error_out: | ||
1523 | return retval; | ||
1524 | } | ||
diff --git a/drivers/net/netxen/netxen_nic_ioctl.h b/drivers/net/netxen/netxen_nic_ioctl.h deleted file mode 100644 index 1221fa527552..000000000000 --- a/drivers/net/netxen/netxen_nic_ioctl.h +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2003 - 2006 NetXen, Inc. | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version 2 | ||
8 | * of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | ||
18 | * MA 02111-1307, USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution | ||
21 | * in the file called LICENSE. | ||
22 | * | ||
23 | * Contact Information: | ||
24 | * info@netxen.com | ||
25 | * NetXen, | ||
26 | * 3965 Freedom Circle, Fourth floor, | ||
27 | * Santa Clara, CA 95054 | ||
28 | */ | ||
29 | |||
30 | #ifndef __NETXEN_NIC_IOCTL_H__ | ||
31 | #define __NETXEN_NIC_IOCTL_H__ | ||
32 | |||
33 | #include <linux/sockios.h> | ||
34 | |||
35 | #define NETXEN_CMD_START SIOCDEVPRIVATE | ||
36 | #define NETXEN_NIC_CMD (NETXEN_CMD_START + 1) | ||
37 | #define NETXEN_NIC_NAME (NETXEN_CMD_START + 2) | ||
38 | #define NETXEN_NIC_NAME_LEN 16 | ||
39 | #define NETXEN_NIC_NAME_RSP "NETXEN-UNM" | ||
40 | |||
41 | typedef enum { | ||
42 | netxen_nic_cmd_none = 0, | ||
43 | netxen_nic_cmd_pci_read, | ||
44 | netxen_nic_cmd_pci_write, | ||
45 | netxen_nic_cmd_pci_mem_read, | ||
46 | netxen_nic_cmd_pci_mem_write, | ||
47 | netxen_nic_cmd_pci_config_read, | ||
48 | netxen_nic_cmd_pci_config_write, | ||
49 | netxen_nic_cmd_get_stats, | ||
50 | netxen_nic_cmd_clear_stats, | ||
51 | netxen_nic_cmd_get_version | ||
52 | } netxen_nic_ioctl_cmd_t; | ||
53 | |||
54 | struct netxen_nic_ioctl_data { | ||
55 | u32 cmd; | ||
56 | u32 unused1; | ||
57 | u64 off; | ||
58 | u32 size; | ||
59 | u32 rv; | ||
60 | char u[64]; | ||
61 | void *ptr; | ||
62 | }; | ||
63 | |||
64 | struct netxen_statistics { | ||
65 | u64 rx_packets; | ||
66 | u64 tx_packets; | ||
67 | u64 rx_bytes; | ||
68 | u64 rx_errors; | ||
69 | u64 tx_bytes; | ||
70 | u64 tx_errors; | ||
71 | u64 rx_crc_errors; | ||
72 | u64 rx_short_length_error; | ||
73 | u64 rx_long_length_error; | ||
74 | u64 rx_mac_errors; | ||
75 | }; | ||
76 | |||
77 | #endif /* __NETXEN_NIC_IOCTL_H_ */ | ||
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 575b71b67202..1658ca1fa230 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include "netxen_nic.h" | 38 | #include "netxen_nic.h" |
39 | #define DEFINE_GLOBAL_RECV_CRB | 39 | #define DEFINE_GLOBAL_RECV_CRB |
40 | #include "netxen_nic_phan_reg.h" | 40 | #include "netxen_nic_phan_reg.h" |
41 | #include "netxen_nic_ioctl.h" | ||
42 | 41 | ||
43 | #include <linux/dma-mapping.h> | 42 | #include <linux/dma-mapping.h> |
44 | #include <linux/vmalloc.h> | 43 | #include <linux/vmalloc.h> |
@@ -75,8 +74,6 @@ static void netxen_tx_timeout(struct net_device *netdev); | |||
75 | static void netxen_tx_timeout_task(struct work_struct *work); | 74 | static void netxen_tx_timeout_task(struct work_struct *work); |
76 | static void netxen_watchdog(unsigned long); | 75 | static void netxen_watchdog(unsigned long); |
77 | static int netxen_handle_int(struct netxen_adapter *, struct net_device *); | 76 | static int netxen_handle_int(struct netxen_adapter *, struct net_device *); |
78 | static int netxen_nic_ioctl(struct net_device *netdev, | ||
79 | struct ifreq *ifr, int cmd); | ||
80 | static int netxen_nic_poll(struct net_device *dev, int *budget); | 77 | static int netxen_nic_poll(struct net_device *dev, int *budget); |
81 | #ifdef CONFIG_NET_POLL_CONTROLLER | 78 | #ifdef CONFIG_NET_POLL_CONTROLLER |
82 | static void netxen_nic_poll_controller(struct net_device *netdev); | 79 | static void netxen_nic_poll_controller(struct net_device *netdev); |
@@ -383,7 +380,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
383 | netdev->set_multicast_list = netxen_nic_set_multi; | 380 | netdev->set_multicast_list = netxen_nic_set_multi; |
384 | netdev->set_mac_address = netxen_nic_set_mac; | 381 | netdev->set_mac_address = netxen_nic_set_mac; |
385 | netdev->change_mtu = netxen_nic_change_mtu; | 382 | netdev->change_mtu = netxen_nic_change_mtu; |
386 | netdev->do_ioctl = netxen_nic_ioctl; | ||
387 | netdev->tx_timeout = netxen_tx_timeout; | 383 | netdev->tx_timeout = netxen_tx_timeout; |
388 | netdev->watchdog_timeo = HZ; | 384 | netdev->watchdog_timeo = HZ; |
389 | 385 | ||
@@ -1137,47 +1133,6 @@ static void netxen_nic_poll_controller(struct net_device *netdev) | |||
1137 | enable_irq(adapter->irq); | 1133 | enable_irq(adapter->irq); |
1138 | } | 1134 | } |
1139 | #endif | 1135 | #endif |
1140 | /* | ||
1141 | * netxen_nic_ioctl () We provide the tcl/phanmon support through these | ||
1142 | * ioctls. | ||
1143 | */ | ||
1144 | static int | ||
1145 | netxen_nic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) | ||
1146 | { | ||
1147 | int err = 0; | ||
1148 | unsigned long nr_bytes = 0; | ||
1149 | struct netxen_port *port = netdev_priv(netdev); | ||
1150 | struct netxen_adapter *adapter = port->adapter; | ||
1151 | char dev_name[NETXEN_NIC_NAME_LEN]; | ||
1152 | |||
1153 | DPRINTK(INFO, "doing ioctl for %s\n", netdev->name); | ||
1154 | switch (cmd) { | ||
1155 | case NETXEN_NIC_CMD: | ||
1156 | err = netxen_nic_do_ioctl(adapter, (void *)ifr->ifr_data, port); | ||
1157 | break; | ||
1158 | |||
1159 | case NETXEN_NIC_NAME: | ||
1160 | DPRINTK(INFO, "ioctl cmd for NetXen\n"); | ||
1161 | if (ifr->ifr_data) { | ||
1162 | sprintf(dev_name, "%s-%d", NETXEN_NIC_NAME_RSP, | ||
1163 | port->portnum); | ||
1164 | nr_bytes = | ||
1165 | copy_to_user((char __user *)ifr->ifr_data, dev_name, | ||
1166 | NETXEN_NIC_NAME_LEN); | ||
1167 | if (nr_bytes) | ||
1168 | err = -EIO; | ||
1169 | |||
1170 | } | ||
1171 | break; | ||
1172 | |||
1173 | default: | ||
1174 | DPRINTK(INFO, "ioctl cmd %x not supported\n", cmd); | ||
1175 | err = -EOPNOTSUPP; | ||
1176 | break; | ||
1177 | } | ||
1178 | |||
1179 | return err; | ||
1180 | } | ||
1181 | 1136 | ||
1182 | static struct pci_driver netxen_driver = { | 1137 | static struct pci_driver netxen_driver = { |
1183 | .name = netxen_nic_driver_name, | 1138 | .name = netxen_nic_driver_name, |