aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/netxen/netxen_nic_init.c')
-rw-r--r--drivers/net/netxen/netxen_nic_init.c201
1 files changed, 25 insertions, 176 deletions
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 9e38bcb3fba..45fa33e0cb9 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -145,6 +145,8 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
145 /* Window 1 call */ 145 /* Window 1 call */
146 writel(INTR_SCHEME_PERPORT, 146 writel(INTR_SCHEME_PERPORT,
147 NETXEN_CRB_NORMALIZE(adapter, CRB_NIC_CAPABILITIES_HOST)); 147 NETXEN_CRB_NORMALIZE(adapter, CRB_NIC_CAPABILITIES_HOST));
148 writel(MSI_MODE_MULTIFUNC,
149 NETXEN_CRB_NORMALIZE(adapter, CRB_NIC_MSI_MODE_HOST));
148 writel(MPORT_MULTI_FUNCTION_MODE, 150 writel(MPORT_MULTI_FUNCTION_MODE,
149 NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE)); 151 NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE));
150 writel(PHAN_INITIALIZE_ACK, 152 writel(PHAN_INITIALIZE_ACK,
@@ -183,7 +185,6 @@ void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
183 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { 185 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
184 struct netxen_rx_buffer *rx_buf; 186 struct netxen_rx_buffer *rx_buf;
185 rcv_desc = &adapter->recv_ctx[ctxid].rcv_desc[ring]; 187 rcv_desc = &adapter->recv_ctx[ctxid].rcv_desc[ring];
186 rcv_desc->rcv_free = rcv_desc->max_rx_desc_count;
187 rcv_desc->begin_alloc = 0; 188 rcv_desc->begin_alloc = 0;
188 rx_buf = rcv_desc->rx_buf_arr; 189 rx_buf = rcv_desc->rx_buf_arr;
189 num_rx_bufs = rcv_desc->max_rx_desc_count; 190 num_rx_bufs = rcv_desc->max_rx_desc_count;
@@ -974,28 +975,6 @@ int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
974 return 0; 975 return 0;
975} 976}
976 977
977int netxen_nic_rx_has_work(struct netxen_adapter *adapter)
978{
979 int ctx;
980
981 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
982 struct netxen_recv_context *recv_ctx =
983 &(adapter->recv_ctx[ctx]);
984 u32 consumer;
985 struct status_desc *desc_head;
986 struct status_desc *desc;
987
988 consumer = recv_ctx->status_rx_consumer;
989 desc_head = recv_ctx->rcv_status_desc_head;
990 desc = &desc_head[consumer];
991
992 if (netxen_get_sts_owner(desc) & STATUS_OWNER_HOST)
993 return 1;
994 }
995
996 return 0;
997}
998
999static int netxen_nic_check_temp(struct netxen_adapter *adapter) 978static int netxen_nic_check_temp(struct netxen_adapter *adapter)
1000{ 979{
1001 struct net_device *netdev = adapter->netdev; 980 struct net_device *netdev = adapter->netdev;
@@ -1038,7 +1017,6 @@ static int netxen_nic_check_temp(struct netxen_adapter *adapter)
1038 1017
1039void netxen_watchdog_task(struct work_struct *work) 1018void netxen_watchdog_task(struct work_struct *work)
1040{ 1019{
1041 struct net_device *netdev;
1042 struct netxen_adapter *adapter = 1020 struct netxen_adapter *adapter =
1043 container_of(work, struct netxen_adapter, watchdog_task); 1021 container_of(work, struct netxen_adapter, watchdog_task);
1044 1022
@@ -1048,20 +1026,6 @@ void netxen_watchdog_task(struct work_struct *work)
1048 if (adapter->handle_phy_intr) 1026 if (adapter->handle_phy_intr)
1049 adapter->handle_phy_intr(adapter); 1027 adapter->handle_phy_intr(adapter);
1050 1028
1051 netdev = adapter->netdev;
1052 if ((netif_running(netdev)) && !netif_carrier_ok(netdev) &&
1053 netxen_nic_link_ok(adapter) ) {
1054 printk(KERN_INFO "%s %s (port %d), Link is up\n",
1055 netxen_nic_driver_name, netdev->name, adapter->portnum);
1056 netif_carrier_on(netdev);
1057 netif_wake_queue(netdev);
1058 } else if(!(netif_running(netdev)) && netif_carrier_ok(netdev)) {
1059 printk(KERN_ERR "%s %s Link is Down\n",
1060 netxen_nic_driver_name, netdev->name);
1061 netif_carrier_off(netdev);
1062 netif_stop_queue(netdev);
1063 }
1064
1065 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); 1029 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
1066} 1030}
1067 1031
@@ -1125,7 +1089,7 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1125 skb = (struct sk_buff *)buffer->skb; 1089 skb = (struct sk_buff *)buffer->skb;
1126 1090
1127 if (likely(adapter->rx_csum && 1091 if (likely(adapter->rx_csum &&
1128 netxen_get_sts_status(sts_data) == STATUS_CKSUM_OK)) { 1092 netxen_get_sts_status(sts_data) == STATUS_CKSUM_OK)) {
1129 adapter->stats.csummed++; 1093 adapter->stats.csummed++;
1130 skb->ip_summed = CHECKSUM_UNNECESSARY; 1094 skb->ip_summed = CHECKSUM_UNNECESSARY;
1131 } else 1095 } else
@@ -1142,40 +1106,8 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1142 skb->protocol = eth_type_trans(skb, netdev); 1106 skb->protocol = eth_type_trans(skb, netdev);
1143 1107
1144 ret = netif_receive_skb(skb); 1108 ret = netif_receive_skb(skb);
1145
1146 /*
1147 * RH: Do we need these stats on a regular basis. Can we get it from
1148 * Linux stats.
1149 */
1150 switch (ret) {
1151 case NET_RX_SUCCESS:
1152 adapter->stats.uphappy++;
1153 break;
1154
1155 case NET_RX_CN_LOW:
1156 adapter->stats.uplcong++;
1157 break;
1158
1159 case NET_RX_CN_MOD:
1160 adapter->stats.upmcong++;
1161 break;
1162
1163 case NET_RX_CN_HIGH:
1164 adapter->stats.uphcong++;
1165 break;
1166
1167 case NET_RX_DROP:
1168 adapter->stats.updropped++;
1169 break;
1170
1171 default:
1172 adapter->stats.updunno++;
1173 break;
1174 }
1175
1176 netdev->last_rx = jiffies; 1109 netdev->last_rx = jiffies;
1177 1110
1178 rcv_desc->rcv_free++;
1179 rcv_desc->rcv_pending--; 1111 rcv_desc->rcv_pending--;
1180 1112
1181 /* 1113 /*
@@ -1200,13 +1132,6 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
1200 u32 producer = 0; 1132 u32 producer = 0;
1201 int count = 0, ring; 1133 int count = 0, ring;
1202 1134
1203 DPRINTK(INFO, "procesing receive\n");
1204 /*
1205 * we assume in this case that there is only one port and that is
1206 * port #1...changes need to be done in firmware to indicate port
1207 * number as part of the descriptor. This way we will be able to get
1208 * the netdev which is associated with that device.
1209 */
1210 while (count < max) { 1135 while (count < max) {
1211 desc = &desc_head[consumer]; 1136 desc = &desc_head[consumer];
1212 if (!(netxen_get_sts_owner(desc) & STATUS_OWNER_HOST)) { 1137 if (!(netxen_get_sts_owner(desc) & STATUS_OWNER_HOST)) {
@@ -1219,11 +1144,8 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
1219 consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1); 1144 consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1);
1220 count++; 1145 count++;
1221 } 1146 }
1222 if (count) { 1147 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++)
1223 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { 1148 netxen_post_rx_buffers_nodb(adapter, ctxid, ring);
1224 netxen_post_rx_buffers_nodb(adapter, ctxid, ring);
1225 }
1226 }
1227 1149
1228 /* update the consumer index in phantom */ 1150 /* update the consumer index in phantom */
1229 if (count) { 1151 if (count) {
@@ -1233,108 +1155,60 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
1233 /* Window = 1 */ 1155 /* Window = 1 */
1234 writel(consumer, 1156 writel(consumer,
1235 NETXEN_CRB_NORMALIZE(adapter, 1157 NETXEN_CRB_NORMALIZE(adapter,
1236 recv_crb_registers[adapter->portnum]. 1158 recv_crb_registers[adapter->portnum].
1237 crb_rcv_status_consumer)); 1159 crb_rcv_status_consumer));
1238 wmb();
1239 } 1160 }
1240 1161
1241 return count; 1162 return count;
1242} 1163}
1243 1164
1244/* Process Command status ring */ 1165/* Process Command status ring */
1245int netxen_process_cmd_ring(unsigned long data) 1166int netxen_process_cmd_ring(struct netxen_adapter *adapter)
1246{ 1167{
1247 u32 last_consumer; 1168 u32 last_consumer, consumer;
1248 u32 consumer; 1169 int count = 0, i;
1249 struct netxen_adapter *adapter = (struct netxen_adapter *)data;
1250 int count1 = 0;
1251 int count2 = 0;
1252 struct netxen_cmd_buffer *buffer; 1170 struct netxen_cmd_buffer *buffer;
1253 struct pci_dev *pdev; 1171 struct pci_dev *pdev = adapter->pdev;
1172 struct net_device *netdev = adapter->netdev;
1254 struct netxen_skb_frag *frag; 1173 struct netxen_skb_frag *frag;
1255 u32 i; 1174 int done = 0;
1256 int done;
1257 1175
1258 spin_lock(&adapter->tx_lock);
1259 last_consumer = adapter->last_cmd_consumer; 1176 last_consumer = adapter->last_cmd_consumer;
1260 DPRINTK(INFO, "procesing xmit complete\n");
1261 /* we assume in this case that there is only one port and that is
1262 * port #1...changes need to be done in firmware to indicate port
1263 * number as part of the descriptor. This way we will be able to get
1264 * the netdev which is associated with that device.
1265 */
1266
1267 consumer = le32_to_cpu(*(adapter->cmd_consumer)); 1177 consumer = le32_to_cpu(*(adapter->cmd_consumer));
1268 if (last_consumer == consumer) { /* Ring is empty */
1269 DPRINTK(INFO, "last_consumer %d == consumer %d\n",
1270 last_consumer, consumer);
1271 spin_unlock(&adapter->tx_lock);
1272 return 1;
1273 }
1274
1275 adapter->proc_cmd_buf_counter++;
1276 /*
1277 * Not needed - does not seem to be used anywhere.
1278 * adapter->cmd_consumer = consumer;
1279 */
1280 spin_unlock(&adapter->tx_lock);
1281 1178
1282 while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) { 1179 while (last_consumer != consumer) {
1283 buffer = &adapter->cmd_buf_arr[last_consumer]; 1180 buffer = &adapter->cmd_buf_arr[last_consumer];
1284 pdev = adapter->pdev;
1285 if (buffer->skb) { 1181 if (buffer->skb) {
1286 frag = &buffer->frag_array[0]; 1182 frag = &buffer->frag_array[0];
1287 pci_unmap_single(pdev, frag->dma, frag->length, 1183 pci_unmap_single(pdev, frag->dma, frag->length,
1288 PCI_DMA_TODEVICE); 1184 PCI_DMA_TODEVICE);
1289 frag->dma = 0ULL; 1185 frag->dma = 0ULL;
1290 for (i = 1; i < buffer->frag_count; i++) { 1186 for (i = 1; i < buffer->frag_count; i++) {
1291 DPRINTK(INFO, "getting fragment no %d\n", i);
1292 frag++; /* Get the next frag */ 1187 frag++; /* Get the next frag */
1293 pci_unmap_page(pdev, frag->dma, frag->length, 1188 pci_unmap_page(pdev, frag->dma, frag->length,
1294 PCI_DMA_TODEVICE); 1189 PCI_DMA_TODEVICE);
1295 frag->dma = 0ULL; 1190 frag->dma = 0ULL;
1296 } 1191 }
1297 1192
1298 adapter->stats.skbfreed++; 1193 adapter->stats.xmitfinished++;
1299 dev_kfree_skb_any(buffer->skb); 1194 dev_kfree_skb_any(buffer->skb);
1300 buffer->skb = NULL; 1195 buffer->skb = NULL;
1301 } else if (adapter->proc_cmd_buf_counter == 1) {
1302 adapter->stats.txnullskb++;
1303 }
1304 if (unlikely(netif_queue_stopped(adapter->netdev)
1305 && netif_carrier_ok(adapter->netdev))
1306 && ((jiffies - adapter->netdev->trans_start) >
1307 adapter->netdev->watchdog_timeo)) {
1308 SCHEDULE_WORK(&adapter->tx_timeout_task);
1309 } 1196 }
1310 1197
1311 last_consumer = get_next_index(last_consumer, 1198 last_consumer = get_next_index(last_consumer,
1312 adapter->max_tx_desc_count); 1199 adapter->max_tx_desc_count);
1313 count1++; 1200 if (++count >= MAX_STATUS_HANDLE)
1201 break;
1314 } 1202 }
1315 1203
1316 count2 = 0; 1204 if (count) {
1317 spin_lock(&adapter->tx_lock);
1318 if ((--adapter->proc_cmd_buf_counter) == 0) {
1319 adapter->last_cmd_consumer = last_consumer; 1205 adapter->last_cmd_consumer = last_consumer;
1320 while ((adapter->last_cmd_consumer != consumer) 1206 smp_mb();
1321 && (count2 < MAX_STATUS_HANDLE)) { 1207 if (netif_queue_stopped(netdev) && netif_running(netdev)) {
1322 buffer = 1208 netif_tx_lock(netdev);
1323 &adapter->cmd_buf_arr[adapter->last_cmd_consumer]; 1209 netif_wake_queue(netdev);
1324 count2++; 1210 smp_mb();
1325 if (buffer->skb) 1211 netif_tx_unlock(netdev);
1326 break;
1327 else
1328 adapter->last_cmd_consumer =
1329 get_next_index(adapter->last_cmd_consumer,
1330 adapter->max_tx_desc_count);
1331 }
1332 }
1333 if (count1 || count2) {
1334 if (netif_queue_stopped(adapter->netdev)
1335 && (adapter->flags & NETXEN_NETDEV_STATUS)) {
1336 netif_wake_queue(adapter->netdev);
1337 adapter->flags &= ~NETXEN_NETDEV_STATUS;
1338 } 1212 }
1339 } 1213 }
1340 /* 1214 /*
@@ -1350,16 +1224,9 @@ int netxen_process_cmd_ring(unsigned long data)
1350 * There is still a possible race condition and the host could miss an 1224 * There is still a possible race condition and the host could miss an
1351 * interrupt. The card has to take care of this. 1225 * interrupt. The card has to take care of this.
1352 */ 1226 */
1353 if (adapter->last_cmd_consumer == consumer && 1227 consumer = le32_to_cpu(*(adapter->cmd_consumer));
1354 (((adapter->cmd_producer + 1) % 1228 done = (last_consumer == consumer);
1355 adapter->max_tx_desc_count) == adapter->last_cmd_consumer)) {
1356 consumer = le32_to_cpu(*(adapter->cmd_consumer));
1357 }
1358 done = (adapter->last_cmd_consumer == consumer);
1359 1229
1360 spin_unlock(&adapter->tx_lock);
1361 DPRINTK(INFO, "last consumer is %d in %s\n", last_consumer,
1362 __FUNCTION__);
1363 return (done); 1230 return (done);
1364} 1231}
1365 1232
@@ -1433,8 +1300,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1433 rcv_desc->begin_alloc = index; 1300 rcv_desc->begin_alloc = index;
1434 rcv_desc->rcv_pending += count; 1301 rcv_desc->rcv_pending += count;
1435 rcv_desc->producer = producer; 1302 rcv_desc->producer = producer;
1436 if (rcv_desc->rcv_free >= 32) {
1437 rcv_desc->rcv_free = 0;
1438 /* Window = 1 */ 1303 /* Window = 1 */
1439 writel((producer - 1) & 1304 writel((producer - 1) &
1440 (rcv_desc->max_rx_desc_count - 1), 1305 (rcv_desc->max_rx_desc_count - 1),
@@ -1458,8 +1323,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1458 writel(msg, 1323 writel(msg,
1459 DB_NORMALIZE(adapter, 1324 DB_NORMALIZE(adapter,
1460 NETXEN_RCV_PRODUCER_OFFSET)); 1325 NETXEN_RCV_PRODUCER_OFFSET));
1461 wmb();
1462 }
1463 } 1326 }
1464} 1327}
1465 1328
@@ -1523,8 +1386,6 @@ static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
1523 rcv_desc->begin_alloc = index; 1386 rcv_desc->begin_alloc = index;
1524 rcv_desc->rcv_pending += count; 1387 rcv_desc->rcv_pending += count;
1525 rcv_desc->producer = producer; 1388 rcv_desc->producer = producer;
1526 if (rcv_desc->rcv_free >= 32) {
1527 rcv_desc->rcv_free = 0;
1528 /* Window = 1 */ 1389 /* Window = 1 */
1529 writel((producer - 1) & 1390 writel((producer - 1) &
1530 (rcv_desc->max_rx_desc_count - 1), 1391 (rcv_desc->max_rx_desc_count - 1),
@@ -1534,21 +1395,9 @@ static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
1534 rcv_desc_crb[ringid]. 1395 rcv_desc_crb[ringid].
1535 crb_rcv_producer_offset)); 1396 crb_rcv_producer_offset));
1536 wmb(); 1397 wmb();
1537 }
1538 } 1398 }
1539} 1399}
1540 1400
1541int netxen_nic_tx_has_work(struct netxen_adapter *adapter)
1542{
1543 if (find_diff_among(adapter->last_cmd_consumer,
1544 adapter->cmd_producer,
1545 adapter->max_tx_desc_count) > 0)
1546 return 1;
1547
1548 return 0;
1549}
1550
1551
1552void netxen_nic_clear_stats(struct netxen_adapter *adapter) 1401void netxen_nic_clear_stats(struct netxen_adapter *adapter)
1553{ 1402{
1554 memset(&adapter->stats, 0, sizeof(adapter->stats)); 1403 memset(&adapter->stats, 0, sizeof(adapter->stats));