aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic_init.c
diff options
context:
space:
mode:
authorMithlesh Thukral <mithlesh@netxen.com>2007-04-20 10:52:37 -0400
committerJeff Garzik <jeff@garzik.org>2007-04-28 11:01:05 -0400
commit3176ff3ee71bddbd1d68e6a9e28dbcf0a2960c95 (patch)
tree260ba783bbd24bf21f17c11f9a6f06a7c50a9fc6 /drivers/net/netxen/netxen_nic_init.c
parentd52df4a35af569071fda3f4eb08e47cc7023f094 (diff)
NetXen: Use multiple PCI functions
NetXen: Make driver use multiple PCI functions. This patch will make NetXen driver work with multiple PCI functions. This will make the usage of memory resources as well as interrupts more independent among different functions which results in better throughput. This change has been done after the multiport support is added in firmware. Signed-off by: Mithlesh Thukral <mithlesh@netxen.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/netxen/netxen_nic_init.c')
-rw-r--r--drivers/net/netxen/netxen_nic_init.c117
1 files changed, 41 insertions, 76 deletions
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 5cd40562da7c..4df38c7e71ac 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -139,7 +139,7 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
139 return err; 139 return err;
140 } 140 }
141 /* Window 1 call */ 141 /* Window 1 call */
142 writel(MPORT_SINGLE_FUNCTION_MODE, 142 writel(MPORT_MULTI_FUNCTION_MODE,
143 NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE)); 143 NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE));
144 writel(PHAN_INITIALIZE_ACK, 144 writel(PHAN_INITIALIZE_ACK,
145 NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); 145 NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
@@ -990,9 +990,7 @@ int netxen_nic_rx_has_work(struct netxen_adapter *adapter)
990 990
991static inline int netxen_nic_check_temp(struct netxen_adapter *adapter) 991static inline int netxen_nic_check_temp(struct netxen_adapter *adapter)
992{ 992{
993 int port_num; 993 struct net_device *netdev = adapter->netdev;
994 struct netxen_port *port;
995 struct net_device *netdev;
996 uint32_t temp, temp_state, temp_val; 994 uint32_t temp, temp_state, temp_val;
997 int rv = 0; 995 int rv = 0;
998 996
@@ -1006,14 +1004,9 @@ static inline int netxen_nic_check_temp(struct netxen_adapter *adapter)
1006 "%s: Device temperature %d degrees C exceeds" 1004 "%s: Device temperature %d degrees C exceeds"
1007 " maximum allowed. Hardware has been shut down.\n", 1005 " maximum allowed. Hardware has been shut down.\n",
1008 netxen_nic_driver_name, temp_val); 1006 netxen_nic_driver_name, temp_val);
1009 for (port_num = 0; port_num < adapter->ahw.max_ports;
1010 port_num++) {
1011 port = adapter->port[port_num];
1012 netdev = port->netdev;
1013 1007
1014 netif_carrier_off(netdev); 1008 netif_carrier_off(netdev);
1015 netif_stop_queue(netdev); 1009 netif_stop_queue(netdev);
1016 }
1017 rv = 1; 1010 rv = 1;
1018 } else if (temp_state == NX_TEMP_WARN) { 1011 } else if (temp_state == NX_TEMP_WARN) {
1019 if (adapter->temp == NX_TEMP_NORMAL) { 1012 if (adapter->temp == NX_TEMP_NORMAL) {
@@ -1037,8 +1030,6 @@ static inline int netxen_nic_check_temp(struct netxen_adapter *adapter)
1037 1030
1038void netxen_watchdog_task(struct work_struct *work) 1031void netxen_watchdog_task(struct work_struct *work)
1039{ 1032{
1040 int port_num;
1041 struct netxen_port *port;
1042 struct net_device *netdev; 1033 struct net_device *netdev;
1043 struct netxen_adapter *adapter = 1034 struct netxen_adapter *adapter =
1044 container_of(work, struct netxen_adapter, watchdog_task); 1035 container_of(work, struct netxen_adapter, watchdog_task);
@@ -1046,20 +1037,16 @@ void netxen_watchdog_task(struct work_struct *work)
1046 if (netxen_nic_check_temp(adapter)) 1037 if (netxen_nic_check_temp(adapter))
1047 return; 1038 return;
1048 1039
1049 for (port_num = 0; port_num < adapter->ahw.max_ports; port_num++) { 1040 netdev = adapter->netdev;
1050 port = adapter->port[port_num]; 1041 if ((netif_running(netdev)) && !netif_carrier_ok(netdev)) {
1051 netdev = port->netdev; 1042 printk(KERN_INFO "%s port %d, %s carrier is now ok\n",
1052 1043 netxen_nic_driver_name, adapter->portnum, netdev->name);
1053 if ((netif_running(netdev)) && !netif_carrier_ok(netdev)) { 1044 netif_carrier_on(netdev);
1054 printk(KERN_INFO "%s port %d, %s carrier is now ok\n",
1055 netxen_nic_driver_name, port_num, netdev->name);
1056 netif_carrier_on(netdev);
1057 }
1058
1059 if (netif_queue_stopped(netdev))
1060 netif_wake_queue(netdev);
1061 } 1045 }
1062 1046
1047 if (netif_queue_stopped(netdev))
1048 netif_wake_queue(netdev);
1049
1063 if (adapter->handle_phy_intr) 1050 if (adapter->handle_phy_intr)
1064 adapter->handle_phy_intr(adapter); 1051 adapter->handle_phy_intr(adapter);
1065 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); 1052 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
@@ -1074,9 +1061,8 @@ void
1074netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, 1061netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1075 struct status_desc *desc) 1062 struct status_desc *desc)
1076{ 1063{
1077 struct netxen_port *port = adapter->port[netxen_get_sts_port(desc)]; 1064 struct pci_dev *pdev = adapter->pdev;
1078 struct pci_dev *pdev = port->pdev; 1065 struct net_device *netdev = adapter->netdev;
1079 struct net_device *netdev = port->netdev;
1080 int index = netxen_get_sts_refhandle(desc); 1066 int index = netxen_get_sts_refhandle(desc);
1081 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); 1067 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]);
1082 struct netxen_rx_buffer *buffer; 1068 struct netxen_rx_buffer *buffer;
@@ -1126,7 +1112,7 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1126 skb = (struct sk_buff *)buffer->skb; 1112 skb = (struct sk_buff *)buffer->skb;
1127 1113
1128 if (likely(netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) { 1114 if (likely(netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) {
1129 port->stats.csummed++; 1115 adapter->stats.csummed++;
1130 skb->ip_summed = CHECKSUM_UNNECESSARY; 1116 skb->ip_summed = CHECKSUM_UNNECESSARY;
1131 } 1117 }
1132 if (desc_ctx == RCV_DESC_LRO_CTXID) { 1118 if (desc_ctx == RCV_DESC_LRO_CTXID) {
@@ -1146,27 +1132,27 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1146 */ 1132 */
1147 switch (ret) { 1133 switch (ret) {
1148 case NET_RX_SUCCESS: 1134 case NET_RX_SUCCESS:
1149 port->stats.uphappy++; 1135 adapter->stats.uphappy++;
1150 break; 1136 break;
1151 1137
1152 case NET_RX_CN_LOW: 1138 case NET_RX_CN_LOW:
1153 port->stats.uplcong++; 1139 adapter->stats.uplcong++;
1154 break; 1140 break;
1155 1141
1156 case NET_RX_CN_MOD: 1142 case NET_RX_CN_MOD:
1157 port->stats.upmcong++; 1143 adapter->stats.upmcong++;
1158 break; 1144 break;
1159 1145
1160 case NET_RX_CN_HIGH: 1146 case NET_RX_CN_HIGH:
1161 port->stats.uphcong++; 1147 adapter->stats.uphcong++;
1162 break; 1148 break;
1163 1149
1164 case NET_RX_DROP: 1150 case NET_RX_DROP:
1165 port->stats.updropped++; 1151 adapter->stats.updropped++;
1166 break; 1152 break;
1167 1153
1168 default: 1154 default:
1169 port->stats.updunno++; 1155 adapter->stats.updunno++;
1170 break; 1156 break;
1171 } 1157 }
1172 1158
@@ -1178,14 +1164,13 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1178 /* 1164 /*
1179 * We just consumed one buffer so post a buffer. 1165 * We just consumed one buffer so post a buffer.
1180 */ 1166 */
1181 adapter->stats.post_called++;
1182 buffer->skb = NULL; 1167 buffer->skb = NULL;
1183 buffer->state = NETXEN_BUFFER_FREE; 1168 buffer->state = NETXEN_BUFFER_FREE;
1184 buffer->lro_current_frags = 0; 1169 buffer->lro_current_frags = 0;
1185 buffer->lro_expected_frags = 0; 1170 buffer->lro_expected_frags = 0;
1186 1171
1187 port->stats.no_rcv++; 1172 adapter->stats.no_rcv++;
1188 port->stats.rxbytes += length; 1173 adapter->stats.rxbytes += length;
1189} 1174}
1190 1175
1191/* Process Receive status ring */ 1176/* Process Receive status ring */
@@ -1226,7 +1211,6 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
1226 1211
1227 /* update the consumer index in phantom */ 1212 /* update the consumer index in phantom */
1228 if (count) { 1213 if (count) {
1229 adapter->stats.process_rcv++;
1230 recv_ctx->status_rx_consumer = consumer; 1214 recv_ctx->status_rx_consumer = consumer;
1231 recv_ctx->status_rx_producer = producer; 1215 recv_ctx->status_rx_producer = producer;
1232 1216
@@ -1249,13 +1233,10 @@ int netxen_process_cmd_ring(unsigned long data)
1249 int count1 = 0; 1233 int count1 = 0;
1250 int count2 = 0; 1234 int count2 = 0;
1251 struct netxen_cmd_buffer *buffer; 1235 struct netxen_cmd_buffer *buffer;
1252 struct netxen_port *port; /* port #1 */
1253 struct netxen_port *nport;
1254 struct pci_dev *pdev; 1236 struct pci_dev *pdev;
1255 struct netxen_skb_frag *frag; 1237 struct netxen_skb_frag *frag;
1256 u32 i; 1238 u32 i;
1257 struct sk_buff *skb = NULL; 1239 struct sk_buff *skb = NULL;
1258 int p;
1259 int done; 1240 int done;
1260 1241
1261 spin_lock(&adapter->tx_lock); 1242 spin_lock(&adapter->tx_lock);
@@ -1276,7 +1257,6 @@ int netxen_process_cmd_ring(unsigned long data)
1276 } 1257 }
1277 1258
1278 adapter->proc_cmd_buf_counter++; 1259 adapter->proc_cmd_buf_counter++;
1279 adapter->stats.process_xmit++;
1280 /* 1260 /*
1281 * Not needed - does not seem to be used anywhere. 1261 * Not needed - does not seem to be used anywhere.
1282 * adapter->cmd_consumer = consumer; 1262 * adapter->cmd_consumer = consumer;
@@ -1285,8 +1265,7 @@ int netxen_process_cmd_ring(unsigned long data)
1285 1265
1286 while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) { 1266 while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) {
1287 buffer = &adapter->cmd_buf_arr[last_consumer]; 1267 buffer = &adapter->cmd_buf_arr[last_consumer];
1288 port = adapter->port[buffer->port]; 1268 pdev = adapter->pdev;
1289 pdev = port->pdev;
1290 frag = &buffer->frag_array[0]; 1269 frag = &buffer->frag_array[0];
1291 skb = buffer->skb; 1270 skb = buffer->skb;
1292 if (skb && (cmpxchg(&buffer->skb, skb, 0) == skb)) { 1271 if (skb && (cmpxchg(&buffer->skb, skb, 0) == skb)) {
@@ -1299,24 +1278,23 @@ int netxen_process_cmd_ring(unsigned long data)
1299 PCI_DMA_TODEVICE); 1278 PCI_DMA_TODEVICE);
1300 } 1279 }
1301 1280
1302 port->stats.skbfreed++; 1281 adapter->stats.skbfreed++;
1303 dev_kfree_skb_any(skb); 1282 dev_kfree_skb_any(skb);
1304 skb = NULL; 1283 skb = NULL;
1305 } else if (adapter->proc_cmd_buf_counter == 1) { 1284 } else if (adapter->proc_cmd_buf_counter == 1) {
1306 port->stats.txnullskb++; 1285 adapter->stats.txnullskb++;
1307 } 1286 }
1308 if (unlikely(netif_queue_stopped(port->netdev) 1287 if (unlikely(netif_queue_stopped(adapter->netdev)
1309 && netif_carrier_ok(port->netdev)) 1288 && netif_carrier_ok(adapter->netdev))
1310 && ((jiffies - port->netdev->trans_start) > 1289 && ((jiffies - adapter->netdev->trans_start) >
1311 port->netdev->watchdog_timeo)) { 1290 adapter->netdev->watchdog_timeo)) {
1312 SCHEDULE_WORK(&port->tx_timeout_task); 1291 SCHEDULE_WORK(&adapter->tx_timeout_task);
1313 } 1292 }
1314 1293
1315 last_consumer = get_next_index(last_consumer, 1294 last_consumer = get_next_index(last_consumer,
1316 adapter->max_tx_desc_count); 1295 adapter->max_tx_desc_count);
1317 count1++; 1296 count1++;
1318 } 1297 }
1319 adapter->stats.noxmitdone += count1;
1320 1298
1321 count2 = 0; 1299 count2 = 0;
1322 spin_lock(&adapter->tx_lock); 1300 spin_lock(&adapter->tx_lock);
@@ -1336,13 +1314,10 @@ int netxen_process_cmd_ring(unsigned long data)
1336 } 1314 }
1337 } 1315 }
1338 if (count1 || count2) { 1316 if (count1 || count2) {
1339 for (p = 0; p < adapter->ahw.max_ports; p++) { 1317 if (netif_queue_stopped(adapter->netdev)
1340 nport = adapter->port[p]; 1318 && (adapter->flags & NETXEN_NETDEV_STATUS)) {
1341 if (netif_queue_stopped(nport->netdev) 1319 netif_wake_queue(adapter->netdev);
1342 && (nport->flags & NETXEN_NETDEV_STATUS)) { 1320 adapter->flags &= ~NETXEN_NETDEV_STATUS;
1343 netif_wake_queue(nport->netdev);
1344 nport->flags &= ~NETXEN_NETDEV_STATUS;
1345 }
1346 } 1321 }
1347 } 1322 }
1348 /* 1323 /*
@@ -1388,7 +1363,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1388 netxen_ctx_msg msg = 0; 1363 netxen_ctx_msg msg = 0;
1389 dma_addr_t dma; 1364 dma_addr_t dma;
1390 1365
1391 adapter->stats.post_called++;
1392 rcv_desc = &recv_ctx->rcv_desc[ringid]; 1366 rcv_desc = &recv_ctx->rcv_desc[ringid];
1393 1367
1394 producer = rcv_desc->producer; 1368 producer = rcv_desc->producer;
@@ -1441,8 +1415,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1441 if (count) { 1415 if (count) {
1442 rcv_desc->begin_alloc = index; 1416 rcv_desc->begin_alloc = index;
1443 rcv_desc->rcv_pending += count; 1417 rcv_desc->rcv_pending += count;
1444 adapter->stats.lastposted = count;
1445 adapter->stats.posted += count;
1446 rcv_desc->producer = producer; 1418 rcv_desc->producer = producer;
1447 if (rcv_desc->rcv_free >= 32) { 1419 if (rcv_desc->rcv_free >= 32) {
1448 rcv_desc->rcv_free = 0; 1420 rcv_desc->rcv_free = 0;
@@ -1450,7 +1422,8 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1450 writel((producer - 1) & 1422 writel((producer - 1) &
1451 (rcv_desc->max_rx_desc_count - 1), 1423 (rcv_desc->max_rx_desc_count - 1),
1452 NETXEN_CRB_NORMALIZE(adapter, 1424 NETXEN_CRB_NORMALIZE(adapter,
1453 recv_crb_registers[0]. 1425 recv_crb_registers[
1426 adapter->portnum].
1454 rcv_desc_crb[ringid]. 1427 rcv_desc_crb[ringid].
1455 crb_rcv_producer_offset)); 1428 crb_rcv_producer_offset));
1456 /* 1429 /*
@@ -1463,7 +1436,7 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1463 ((producer - 1436 ((producer -
1464 1) & (rcv_desc-> 1437 1) & (rcv_desc->
1465 max_rx_desc_count - 1))); 1438 max_rx_desc_count - 1)));
1466 netxen_set_msg_ctxid(msg, 0); 1439 netxen_set_msg_ctxid(msg, adapter->portnum);
1467 netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid)); 1440 netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid));
1468 writel(msg, 1441 writel(msg,
1469 DB_NORMALIZE(adapter, 1442 DB_NORMALIZE(adapter,
@@ -1485,7 +1458,6 @@ void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx,
1485 int count = 0; 1458 int count = 0;
1486 int index = 0; 1459 int index = 0;
1487 1460
1488 adapter->stats.post_called++;
1489 rcv_desc = &recv_ctx->rcv_desc[ringid]; 1461 rcv_desc = &recv_ctx->rcv_desc[ringid];
1490 1462
1491 producer = rcv_desc->producer; 1463 producer = rcv_desc->producer;
@@ -1532,8 +1504,6 @@ void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx,
1532 if (count) { 1504 if (count) {
1533 rcv_desc->begin_alloc = index; 1505 rcv_desc->begin_alloc = index;
1534 rcv_desc->rcv_pending += count; 1506 rcv_desc->rcv_pending += count;
1535 adapter->stats.lastposted = count;
1536 adapter->stats.posted += count;
1537 rcv_desc->producer = producer; 1507 rcv_desc->producer = producer;
1538 if (rcv_desc->rcv_free >= 32) { 1508 if (rcv_desc->rcv_free >= 32) {
1539 rcv_desc->rcv_free = 0; 1509 rcv_desc->rcv_free = 0;
@@ -1541,7 +1511,8 @@ void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx,
1541 writel((producer - 1) & 1511 writel((producer - 1) &
1542 (rcv_desc->max_rx_desc_count - 1), 1512 (rcv_desc->max_rx_desc_count - 1),
1543 NETXEN_CRB_NORMALIZE(adapter, 1513 NETXEN_CRB_NORMALIZE(adapter,
1544 recv_crb_registers[0]. 1514 recv_crb_registers[
1515 adapter->portnum].
1545 rcv_desc_crb[ringid]. 1516 rcv_desc_crb[ringid].
1546 crb_rcv_producer_offset)); 1517 crb_rcv_producer_offset));
1547 wmb(); 1518 wmb();
@@ -1562,13 +1533,7 @@ int netxen_nic_tx_has_work(struct netxen_adapter *adapter)
1562 1533
1563void netxen_nic_clear_stats(struct netxen_adapter *adapter) 1534void netxen_nic_clear_stats(struct netxen_adapter *adapter)
1564{ 1535{
1565 struct netxen_port *port;
1566 int port_num;
1567
1568 memset(&adapter->stats, 0, sizeof(adapter->stats)); 1536 memset(&adapter->stats, 0, sizeof(adapter->stats));
1569 for (port_num = 0; port_num < adapter->ahw.max_ports; port_num++) { 1537 return;
1570 port = adapter->port[port_num];
1571 memset(&port->stats, 0, sizeof(port->stats));
1572 }
1573} 1538}
1574 1539