diff options
Diffstat (limited to 'drivers/net/netxen/netxen_nic_main.c')
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 72 |
1 files changed, 26 insertions, 46 deletions
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index a80f0cd6b528..263b55e36c7a 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -732,11 +732,6 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) | |||
732 | 732 | ||
733 | unregister_netdev(netdev); | 733 | unregister_netdev(netdev); |
734 | 734 | ||
735 | if (adapter->stop_port) | ||
736 | adapter->stop_port(adapter); | ||
737 | |||
738 | netxen_nic_disable_int(adapter); | ||
739 | |||
740 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) { | 735 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) { |
741 | init_firmware_done++; | 736 | init_firmware_done++; |
742 | netxen_free_hw_resources(adapter); | 737 | netxen_free_hw_resources(adapter); |
@@ -919,6 +914,9 @@ static int netxen_nic_close(struct net_device *netdev) | |||
919 | netif_stop_queue(netdev); | 914 | netif_stop_queue(netdev); |
920 | napi_disable(&adapter->napi); | 915 | napi_disable(&adapter->napi); |
921 | 916 | ||
917 | if (adapter->stop_port) | ||
918 | adapter->stop_port(adapter); | ||
919 | |||
922 | netxen_nic_disable_int(adapter); | 920 | netxen_nic_disable_int(adapter); |
923 | 921 | ||
924 | cmd_buff = adapter->cmd_buf_arr; | 922 | cmd_buff = adapter->cmd_buf_arr; |
@@ -996,28 +994,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
996 | return NETDEV_TX_OK; | 994 | return NETDEV_TX_OK; |
997 | } | 995 | } |
998 | 996 | ||
999 | /* | ||
1000 | * Everything is set up. Now, we just need to transmit it out. | ||
1001 | * Note that we have to copy the contents of buffer over to | ||
1002 | * right place. Later on, this can be optimized out by de-coupling the | ||
1003 | * producer index from the buffer index. | ||
1004 | */ | ||
1005 | retry_getting_window: | ||
1006 | spin_lock_bh(&adapter->tx_lock); | ||
1007 | if (adapter->total_threads >= MAX_XMIT_PRODUCERS) { | ||
1008 | spin_unlock_bh(&adapter->tx_lock); | ||
1009 | /* | ||
1010 | * Yield CPU | ||
1011 | */ | ||
1012 | if (!in_atomic()) | ||
1013 | schedule(); | ||
1014 | else { | ||
1015 | for (i = 0; i < 20; i++) | ||
1016 | cpu_relax(); /*This a nop instr on i386 */ | ||
1017 | } | ||
1018 | goto retry_getting_window; | ||
1019 | } | ||
1020 | local_producer = adapter->cmd_producer; | ||
1021 | /* There 4 fragments per descriptor */ | 997 | /* There 4 fragments per descriptor */ |
1022 | no_of_desc = (frag_count + 3) >> 2; | 998 | no_of_desc = (frag_count + 3) >> 2; |
1023 | if (netdev->features & NETIF_F_TSO) { | 999 | if (netdev->features & NETIF_F_TSO) { |
@@ -1031,16 +1007,19 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1031 | } | 1007 | } |
1032 | } | 1008 | } |
1033 | } | 1009 | } |
1010 | |||
1011 | spin_lock_bh(&adapter->tx_lock); | ||
1012 | if (adapter->total_threads >= MAX_XMIT_PRODUCERS) { | ||
1013 | goto out_requeue; | ||
1014 | } | ||
1015 | local_producer = adapter->cmd_producer; | ||
1034 | k = adapter->cmd_producer; | 1016 | k = adapter->cmd_producer; |
1035 | max_tx_desc_count = adapter->max_tx_desc_count; | 1017 | max_tx_desc_count = adapter->max_tx_desc_count; |
1036 | last_cmd_consumer = adapter->last_cmd_consumer; | 1018 | last_cmd_consumer = adapter->last_cmd_consumer; |
1037 | if ((k + no_of_desc) >= | 1019 | if ((k + no_of_desc) >= |
1038 | ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count : | 1020 | ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count : |
1039 | last_cmd_consumer)) { | 1021 | last_cmd_consumer)) { |
1040 | netif_stop_queue(netdev); | 1022 | goto out_requeue; |
1041 | adapter->flags |= NETXEN_NETDEV_STATUS; | ||
1042 | spin_unlock_bh(&adapter->tx_lock); | ||
1043 | return NETDEV_TX_BUSY; | ||
1044 | } | 1023 | } |
1045 | k = get_index_range(k, max_tx_desc_count, no_of_desc); | 1024 | k = get_index_range(k, max_tx_desc_count, no_of_desc); |
1046 | adapter->cmd_producer = k; | 1025 | adapter->cmd_producer = k; |
@@ -1093,6 +1072,8 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1093 | adapter->max_tx_desc_count); | 1072 | adapter->max_tx_desc_count); |
1094 | hwdesc = &hw->cmd_desc_head[producer]; | 1073 | hwdesc = &hw->cmd_desc_head[producer]; |
1095 | memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); | 1074 | memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); |
1075 | pbuf = &adapter->cmd_buf_arr[producer]; | ||
1076 | pbuf->skb = NULL; | ||
1096 | } | 1077 | } |
1097 | frag = &skb_shinfo(skb)->frags[i - 1]; | 1078 | frag = &skb_shinfo(skb)->frags[i - 1]; |
1098 | len = frag->size; | 1079 | len = frag->size; |
@@ -1148,6 +1129,8 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1148 | } | 1129 | } |
1149 | /* copy the MAC/IP/TCP headers to the cmd descriptor list */ | 1130 | /* copy the MAC/IP/TCP headers to the cmd descriptor list */ |
1150 | hwdesc = &hw->cmd_desc_head[producer]; | 1131 | hwdesc = &hw->cmd_desc_head[producer]; |
1132 | pbuf = &adapter->cmd_buf_arr[producer]; | ||
1133 | pbuf->skb = NULL; | ||
1151 | 1134 | ||
1152 | /* copy the first 64 bytes */ | 1135 | /* copy the first 64 bytes */ |
1153 | memcpy(((void *)hwdesc) + 2, | 1136 | memcpy(((void *)hwdesc) + 2, |
@@ -1156,6 +1139,8 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1156 | 1139 | ||
1157 | if (more_hdr) { | 1140 | if (more_hdr) { |
1158 | hwdesc = &hw->cmd_desc_head[producer]; | 1141 | hwdesc = &hw->cmd_desc_head[producer]; |
1142 | pbuf = &adapter->cmd_buf_arr[producer]; | ||
1143 | pbuf->skb = NULL; | ||
1159 | /* copy the next 64 bytes - should be enough except | 1144 | /* copy the next 64 bytes - should be enough except |
1160 | * for pathological case | 1145 | * for pathological case |
1161 | */ | 1146 | */ |
@@ -1167,16 +1152,8 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1167 | } | 1152 | } |
1168 | } | 1153 | } |
1169 | 1154 | ||
1170 | i = netxen_get_cmd_desc_totallength(&hw->cmd_desc_head[saved_producer]); | ||
1171 | |||
1172 | hw->cmd_desc_head[saved_producer].flags_opcode = | ||
1173 | cpu_to_le16(hw->cmd_desc_head[saved_producer].flags_opcode); | ||
1174 | hw->cmd_desc_head[saved_producer].num_of_buffers_total_length = | ||
1175 | cpu_to_le32(hw->cmd_desc_head[saved_producer]. | ||
1176 | num_of_buffers_total_length); | ||
1177 | |||
1178 | spin_lock_bh(&adapter->tx_lock); | 1155 | spin_lock_bh(&adapter->tx_lock); |
1179 | adapter->stats.txbytes += i; | 1156 | adapter->stats.txbytes += skb->len; |
1180 | 1157 | ||
1181 | /* Code to update the adapter considering how many producer threads | 1158 | /* Code to update the adapter considering how many producer threads |
1182 | are currently working */ | 1159 | are currently working */ |
@@ -1189,14 +1166,17 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1189 | } | 1166 | } |
1190 | 1167 | ||
1191 | adapter->stats.xmitfinished++; | 1168 | adapter->stats.xmitfinished++; |
1192 | spin_unlock_bh(&adapter->tx_lock); | ||
1193 | |||
1194 | netdev->trans_start = jiffies; | 1169 | netdev->trans_start = jiffies; |
1195 | 1170 | ||
1196 | DPRINTK(INFO, "wrote CMD producer %x to phantom\n", producer); | 1171 | spin_unlock_bh(&adapter->tx_lock); |
1197 | |||
1198 | DPRINTK(INFO, "Done. Send\n"); | ||
1199 | return NETDEV_TX_OK; | 1172 | return NETDEV_TX_OK; |
1173 | |||
1174 | out_requeue: | ||
1175 | netif_stop_queue(netdev); | ||
1176 | adapter->flags |= NETXEN_NETDEV_STATUS; | ||
1177 | |||
1178 | spin_unlock_bh(&adapter->tx_lock); | ||
1179 | return NETDEV_TX_BUSY; | ||
1200 | } | 1180 | } |
1201 | 1181 | ||
1202 | static void netxen_watchdog(unsigned long v) | 1182 | static void netxen_watchdog(unsigned long v) |
@@ -1321,7 +1301,7 @@ static int netxen_nic_poll(struct napi_struct *napi, int budget) | |||
1321 | budget / MAX_RCV_CTX); | 1301 | budget / MAX_RCV_CTX); |
1322 | } | 1302 | } |
1323 | 1303 | ||
1324 | if (work_done >= budget && netxen_nic_rx_has_work(adapter) != 0) | 1304 | if (work_done >= budget) |
1325 | done = 0; | 1305 | done = 0; |
1326 | 1306 | ||
1327 | if (netxen_process_cmd_ring((unsigned long)adapter) == 0) | 1307 | if (netxen_process_cmd_ring((unsigned long)adapter) == 0) |