]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/s2io.c
S2io: Removed rx_lock and put_lock
[linux-2.6-omap-h63xx.git] / drivers / net / s2io.c
index 6d8e5c4cf8580e31c4d62c3d2a2f71d4b79cf3c3..157fd932e95140ce54936e3d0a79bdb30cd25048 100644 (file)
@@ -86,7 +86,7 @@
 #include "s2io.h"
 #include "s2io-regs.h"
 
-#define DRV_VERSION "2.0.26.19"
+#define DRV_VERSION "2.0.26.22"
 
 /* S2io Driver name & version. */
 static char s2io_driver_name[] = "Neterion";
@@ -117,20 +117,6 @@ static inline int RXD_IS_UP2DT(struct RxD_t *rxdp)
 
 #define LINK_IS_UP(val64) (!(val64 & (ADAPTER_STATUS_RMAC_REMOTE_FAULT | \
                                      ADAPTER_STATUS_RMAC_LOCAL_FAULT)))
-#define TASKLET_IN_USE test_and_set_bit(0, (&sp->tasklet_status))
-#define PANIC  1
-#define LOW    2
-static inline int rx_buffer_level(struct s2io_nic * sp, int rxb_size, int ring)
-{
-       struct mac_info *mac_control;
-
-       mac_control = &sp->mac_control;
-       if (rxb_size <= rxd_count[sp->rxd_mode])
-               return PANIC;
-       else if ((mac_control->rings[ring].pkt_cnt - rxb_size) > 16)
-               return  LOW;
-       return 0;
-}
 
 static inline int is_s2io_card_up(const struct s2io_nic * sp)
 {
@@ -2458,7 +2444,7 @@ static void free_tx_buffers(struct s2io_nic *nic)
        for (i = 0; i < config->tx_fifo_num; i++) {
                unsigned long flags;
                spin_lock_irqsave(&mac_control->fifos[i].tx_lock, flags);
-               for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) {
+               for (j = 0; j < config->tx_cfg[i].fifo_len; j++) {
                        txdp = (struct TxD *) \
                        mac_control->fifos[i].list_info[j].list_virt_addr;
                        skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j);
@@ -2544,7 +2530,6 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
        struct config_param *config;
        u64 tmp;
        struct buffAdd *ba;
-       unsigned long flags;
        struct RxD_t *first_rxdp = NULL;
        u64 Buffer0_ptr = 0, Buffer1_ptr = 0;
        struct RxD1 *rxdp1;
@@ -2592,15 +2577,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
                        DBG_PRINT(INTR_DBG, "%s: Next block at: %p\n",
                                  dev->name, rxdp);
                }
-               if(!napi) {
-                       spin_lock_irqsave(&nic->put_lock, flags);
-                       mac_control->rings[ring_no].put_pos =
-                       (block_no * (rxd_count[nic->rxd_mode] + 1)) + off;
-                       spin_unlock_irqrestore(&nic->put_lock, flags);
-               } else {
-                       mac_control->rings[ring_no].put_pos =
-                       (block_no * (rxd_count[nic->rxd_mode] + 1)) + off;
-               }
+
                if ((rxdp->Control_1 & RXD_OWN_XENA) &&
                        ((nic->rxd_mode == RXD_MODE_3B) &&
                                (rxdp->Control_2 & s2BIT(0)))) {
@@ -2978,7 +2955,7 @@ static void rx_intr_handler(struct ring_info *ring_data)
 {
        struct s2io_nic *nic = ring_data->nic;
        struct net_device *dev = (struct net_device *) nic->dev;
-       int get_block, put_block, put_offset;
+       int get_block, put_block;
        struct rx_curr_get_info get_info, put_info;
        struct RxD_t *rxdp;
        struct sk_buff *skb;
@@ -2987,19 +2964,11 @@ static void rx_intr_handler(struct ring_info *ring_data)
        struct RxD1* rxdp1;
        struct RxD3* rxdp3;
 
-       spin_lock(&nic->rx_lock);
-
        get_info = ring_data->rx_curr_get_info;
        get_block = get_info.block_index;
        memcpy(&put_info, &ring_data->rx_curr_put_info, sizeof(put_info));
        put_block = put_info.block_index;
        rxdp = ring_data->rx_blocks[get_block].rxds[get_info.offset].virt_addr;
-       if (!napi) {
-               spin_lock(&nic->put_lock);
-               put_offset = ring_data->put_pos;
-               spin_unlock(&nic->put_lock);
-       } else
-               put_offset = ring_data->put_pos;
 
        while (RXD_IS_UP2DT(rxdp)) {
                /*
@@ -3016,7 +2985,6 @@ static void rx_intr_handler(struct ring_info *ring_data)
                        DBG_PRINT(ERR_DBG, "%s: The skb is ",
                                  dev->name);
                        DBG_PRINT(ERR_DBG, "Null in Rx Intr\n");
-                       spin_unlock(&nic->rx_lock);
                        return;
                }
                if (nic->rxd_mode == RXD_MODE_1) {
@@ -3072,8 +3040,6 @@ static void rx_intr_handler(struct ring_info *ring_data)
                        }
                }
        }
-
-       spin_unlock(&nic->rx_lock);
 }
 
 /**
@@ -4105,7 +4071,6 @@ static int s2io_close(struct net_device *dev)
                        do_s2io_delete_unicast_mc(sp, tmp64);
        }
 
-       /* Reset card, kill tasklet and free Tx and Rx buffers. */
        s2io_card_down(sp);
 
        return 0;
@@ -4267,11 +4232,12 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
                txdp->Control_1 |= TXD_UFO_MSS(ufo_size);
                txdp->Control_1 |= TXD_BUFFER0_SIZE(8);
 #ifdef __BIG_ENDIAN
+               /* both variants do cpu_to_be64(be32_to_cpu(...)) */
                fifo->ufo_in_band_v[put_off] =
-                               (u64)skb_shinfo(skb)->ip6_frag_id;
+                               (__force u64)skb_shinfo(skb)->ip6_frag_id;
 #else
                fifo->ufo_in_band_v[put_off] =
-                               (u64)skb_shinfo(skb)->ip6_frag_id << 32;
+                               (__force u64)skb_shinfo(skb)->ip6_frag_id << 32;
 #endif
                txdp->Host_Control = (unsigned long)fifo->ufo_in_band_v;
                txdp->Buffer_Pointer = pci_map_single(sp->pdev,
@@ -4344,6 +4310,9 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
        dev->trans_start = jiffies;
        spin_unlock_irqrestore(&fifo->tx_lock, flags);
 
+       if (sp->config.intr_type == MSI_X)
+               tx_intr_handler(fifo);
+
        return 0;
 pci_map_failed:
        stats->pci_map_fail_cnt++;
@@ -4366,29 +4335,9 @@ s2io_alarm_handle(unsigned long data)
 
 static int s2io_chk_rx_buffers(struct s2io_nic *sp, int rng_n)
 {
-       int rxb_size, level;
-
-       if (!sp->lro) {
-               rxb_size = atomic_read(&sp->rx_bufs_left[rng_n]);
-               level = rx_buffer_level(sp, rxb_size, rng_n);
-
-               if ((level == PANIC) && (!TASKLET_IN_USE)) {
-                       int ret;
-                       DBG_PRINT(INTR_DBG, "%s: Rx BD hit ", __FUNCTION__);
-                       DBG_PRINT(INTR_DBG, "PANIC levels\n");
-                       if ((ret = fill_rx_buffers(sp, rng_n)) == -ENOMEM) {
-                               DBG_PRINT(INFO_DBG, "Out of memory in %s",
-                                         __FUNCTION__);
-                               clear_bit(0, (&sp->tasklet_status));
-                               return -1;
-                       }
-                       clear_bit(0, (&sp->tasklet_status));
-               } else if (level == LOW)
-                       tasklet_schedule(&sp->task);
-
-       } else if (fill_rx_buffers(sp, rng_n) == -ENOMEM) {
-                       DBG_PRINT(INFO_DBG, "%s:Out of memory", sp->dev->name);
-                       DBG_PRINT(INFO_DBG, " in Rx Intr!!\n");
+       if (fill_rx_buffers(sp, rng_n) == -ENOMEM) {
+               DBG_PRINT(INFO_DBG, "%s:Out of memory", sp->dev->name);
+               DBG_PRINT(INFO_DBG, " in Rx Intr!!\n");
        }
        return 0;
 }
@@ -6765,49 +6714,6 @@ static int s2io_change_mtu(struct net_device *dev, int new_mtu)
        return ret;
 }
 
-/**
- *  s2io_tasklet - Bottom half of the ISR.
- *  @dev_adr : address of the device structure in dma_addr_t format.
- *  Description:
- *  This is the tasklet or the bottom half of the ISR. This is
- *  an extension of the ISR which is scheduled by the scheduler to be run
- *  when the load on the CPU is low. All low priority tasks of the ISR can
- *  be pushed into the tasklet. For now the tasklet is used only to
- *  replenish the Rx buffers in the Rx buffer descriptors.
- *  Return value:
- *  void.
- */
-
-static void s2io_tasklet(unsigned long dev_addr)
-{
-       struct net_device *dev = (struct net_device *) dev_addr;
-       struct s2io_nic *sp = dev->priv;
-       int i, ret;
-       struct mac_info *mac_control;
-       struct config_param *config;
-
-       mac_control = &sp->mac_control;
-       config = &sp->config;
-
-       if (!TASKLET_IN_USE) {
-               for (i = 0; i < config->rx_ring_num; i++) {
-                       ret = fill_rx_buffers(sp, i);
-                       if (ret == -ENOMEM) {
-                               DBG_PRINT(INFO_DBG, "%s: Out of ",
-                                         dev->name);
-                               DBG_PRINT(INFO_DBG, "memory in tasklet\n");
-                               break;
-                       } else if (ret == -EFILL) {
-                               DBG_PRINT(INFO_DBG,
-                                         "%s: Rx Ring %d is full\n",
-                                         dev->name, i);
-                               break;
-                       }
-               }
-               clear_bit(0, (&sp->tasklet_status));
-       }
-}
-
 /**
  * s2io_set_link - Set the LInk status
  * @data: long pointer to device private structue
@@ -7089,11 +6995,11 @@ static int s2io_add_isr(struct s2io_nic * sp)
                                if(!(sp->msix_info[i].addr &&
                                        sp->msix_info[i].data)) {
                                        DBG_PRINT(ERR_DBG, "%s @ Addr:0x%llx "
-                                               "Data:0x%lx\n",sp->desc[i],
+                                               "Data:0x%llx\n",sp->desc[i],
                                                (unsigned long long)
                                                sp->msix_info[i].addr,
-                                               (unsigned long)
-                                               ntohl(sp->msix_info[i].data));
+                                               (unsigned long long)
+                                               sp->msix_info[i].data);
                                } else {
                                        msix_tx_cnt++;
                                }
@@ -7107,11 +7013,11 @@ static int s2io_add_isr(struct s2io_nic * sp)
                                if(!(sp->msix_info[i].addr &&
                                        sp->msix_info[i].data)) {
                                        DBG_PRINT(ERR_DBG, "%s @ Addr:0x%llx "
-                                               "Data:0x%lx\n",sp->desc[i],
+                                               "Data:0x%llx\n",sp->desc[i],
                                                (unsigned long long)
                                                sp->msix_info[i].addr,
-                                               (unsigned long)
-                                               ntohl(sp->msix_info[i].data));
+                                               (unsigned long long)
+                                               sp->msix_info[i].data);
                                } else {
                                        msix_rx_cnt++;
                                }
@@ -7157,7 +7063,6 @@ static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
 {
        int cnt = 0;
        struct XENA_dev_config __iomem *bar0 = sp->bar0;
-       unsigned long flags;
        register u64 val64 = 0;
        struct config_param *config;
        config = &sp->config;
@@ -7182,9 +7087,6 @@ static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
 
        s2io_rem_isr(sp);
 
-       /* Kill tasklet. */
-       tasklet_kill(&sp->task);
-
        /* Check if the device is Quiescent and then Reset the NIC */
        while(do_io) {
                /* As per the HW requirement we need to replenish the
@@ -7219,9 +7121,7 @@ static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
        free_tx_buffers(sp);
 
        /* Free all Rx buffers */
-       spin_lock_irqsave(&sp->rx_lock, flags);
        free_rx_buffers(sp);
-       spin_unlock_irqrestore(&sp->rx_lock, flags);
 
        clear_bit(__S2IO_STATE_LINK_TASK, &(sp->state));
 }
@@ -7310,9 +7210,6 @@ static int s2io_card_up(struct s2io_nic * sp)
 
        S2IO_TIMER_CONF(sp->alarm_timer, s2io_alarm_handle, sp, (HZ/2));
 
-       /* Enable tasklet for the device */
-       tasklet_init(&sp->task, s2io_tasklet, (unsigned long) dev);
-
        /*  Enable select interrupts */
        en_dis_err_alarms(sp, ENA_ALL_INTRS, ENABLE_INTRS);
        if (sp->config.intr_type != INTA)
@@ -8115,20 +8012,15 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
        s2io_reset(sp);
 
        /*
-        * Initialize the tasklet status and link state flags
+        * Initialize link state flags
         * and the card state parameter
         */
-       sp->tasklet_status = 0;
        sp->state = 0;
 
        /* Initialize spinlocks */
        for (i = 0; i < sp->config.tx_fifo_num; i++)
                spin_lock_init(&mac_control->fifos[i].tx_lock);
 
-       if (!napi)
-               spin_lock_init(&sp->put_lock);
-       spin_lock_init(&sp->rx_lock);
-
        /*
         * SXE-002: Configure link and activity LED to init state
         * on driver load.