Merge commit 'tip/tracing/core' into oprofile/core
[safe/jmp/linux-2.6] / drivers / net / cnic.c
index 4558444..4b451a7 100644 (file)
@@ -1,6 +1,6 @@
 /* cnic.c: Broadcom CNIC core network driver.
  *
- * Copyright (c) 2006-2009 Broadcom Corporation
+ * Copyright (c) 2006-2010 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -900,7 +900,8 @@ static int cnic_alloc_uio(struct cnic_dev *dev) {
        uinfo->mem[0].memtype = UIO_MEM_PHYS;
 
        if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) {
-               uinfo->mem[1].addr = (unsigned long) cp->status_blk & PAGE_MASK;
+               uinfo->mem[1].addr = (unsigned long) cp->status_blk.gen &
+                       PAGE_MASK;
                if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX)
                        uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9;
                else
@@ -1103,10 +1104,9 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev)
        if (ret)
                goto error;
 
-       cp->bnx2x_status_blk = cp->status_blk;
        cp->bnx2x_def_status_blk = cp->ethdev->irq_arr[1].status_blk;
 
-       memset(cp->bnx2x_status_blk, 0, sizeof(struct host_status_block));
+       memset(cp->status_blk.bnx2x, 0, sizeof(*cp->status_blk.bnx2x));
 
        cp->l2_rx_ring_size = 15;
 
@@ -2205,7 +2205,7 @@ static void cnic_service_bnx2_msix(unsigned long data)
 {
        struct cnic_dev *dev = (struct cnic_dev *) data;
        struct cnic_local *cp = dev->cnic_priv;
-       struct status_block_msix *status_blk = cp->bnx2_status_blk;
+       struct status_block_msix *status_blk = cp->status_blk.bnx2;
        u32 status_idx = status_blk->status_idx;
        u16 hw_prod, sw_prod;
        int kcqe_cnt;
@@ -2251,7 +2251,7 @@ static irqreturn_t cnic_irq(int irq, void *dev_instance)
        if (cp->ack_int)
                cp->ack_int(dev);
 
-       prefetch(cp->status_blk);
+       prefetch(cp->status_blk.gen);
        prefetch(&cp->kcq[KCQ_PG(prod)][KCQ_IDX(prod)]);
 
        if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags)))
@@ -2292,7 +2292,7 @@ static void cnic_service_bnx2x_bh(unsigned long data)
        struct cnic_local *cp = dev->cnic_priv;
        u16 hw_prod, sw_prod;
        struct cstorm_status_block_c *sblk =
-               &cp->bnx2x_status_blk->c_status_block;
+               &cp->status_blk.bnx2x->c_status_block;
        u32 status_idx = sblk->status_block_index;
        int kcqe_cnt;
 
@@ -2334,13 +2334,13 @@ static int cnic_service_bnx2x(void *data, void *status_blk)
        struct cnic_local *cp = dev->cnic_priv;
        u16 prod = cp->kcq_prod_idx & MAX_KCQ_IDX;
 
-       prefetch(cp->status_blk);
-       prefetch(&cp->kcq[KCQ_PG(prod)][KCQ_IDX(prod)]);
+       if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags))) {
+               prefetch(cp->status_blk.bnx2x);
+               prefetch(&cp->kcq[KCQ_PG(prod)][KCQ_IDX(prod)]);
 
-       if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags)))
                tasklet_schedule(&cp->cnic_irq_task);
-
-       cnic_chk_pkt_rings(cp);
+               cnic_chk_pkt_rings(cp);
+       }
 
        return 0;
 }
@@ -2860,8 +2860,8 @@ static int cnic_get_route(struct cnic_sock *csk, struct cnic_sockaddr *saddr)
 {
        struct cnic_dev *dev = csk->dev;
        struct cnic_local *cp = dev->cnic_priv;
-       int is_v6, err, rc = -ENETUNREACH;
-       struct dst_entry *dst;
+       int is_v6, rc = 0;
+       struct dst_entry *dst = NULL;
        struct net_device *realdev;
        u32 local_port;
 
@@ -2877,39 +2877,31 @@ static int cnic_get_route(struct cnic_sock *csk, struct cnic_sockaddr *saddr)
        clear_bit(SK_F_IPV6, &csk->flags);
 
        if (is_v6) {
-#if defined(CONFIG_IPV6) || (defined(CONFIG_IPV6_MODULE) && defined(MODULE))
                set_bit(SK_F_IPV6, &csk->flags);
-               err = cnic_get_v6_route(&saddr->remote.v6, &dst);
-               if (err)
-                       return err;
-
-               if (!dst || dst->error || !dst->dev)
-                       goto err_out;
+               cnic_get_v6_route(&saddr->remote.v6, &dst);
 
                memcpy(&csk->dst_ip[0], &saddr->remote.v6.sin6_addr,
                       sizeof(struct in6_addr));
                csk->dst_port = saddr->remote.v6.sin6_port;
                local_port = saddr->local.v6.sin6_port;
-#else
-               return rc;
-#endif
 
        } else {
-               err = cnic_get_v4_route(&saddr->remote.v4, &dst);
-               if (err)
-                       return err;
-
-               if (!dst || dst->error || !dst->dev)
-                       goto err_out;
+               cnic_get_v4_route(&saddr->remote.v4, &dst);
 
                csk->dst_ip[0] = saddr->remote.v4.sin_addr.s_addr;
                csk->dst_port = saddr->remote.v4.sin_port;
                local_port = saddr->local.v4.sin_port;
        }
 
-       csk->vlan_id = cnic_get_vlan(dst->dev, &realdev);
-       if (realdev != dev->netdev)
-               goto err_out;
+       csk->vlan_id = 0;
+       csk->mtu = dev->netdev->mtu;
+       if (dst && dst->dev) {
+               u16 vlan = cnic_get_vlan(dst->dev, &realdev);
+               if (realdev == dev->netdev) {
+                       csk->vlan_id = vlan;
+                       csk->mtu = dst_mtu(dst);
+               }
+       }
 
        if (local_port >= CNIC_LOCAL_PORT_MIN &&
            local_port < CNIC_LOCAL_PORT_MAX) {
@@ -2927,9 +2919,6 @@ static int cnic_get_route(struct cnic_sock *csk, struct cnic_sockaddr *saddr)
        }
        csk->src_port = local_port;
 
-       csk->mtu = dst_mtu(dst);
-       rc = 0;
-
 err_out:
        dst_release(dst);
        return rc;
@@ -3420,8 +3409,7 @@ static int cnic_init_bnx2_irq(struct cnic_dev *dev)
                CNIC_WR(dev, base + BNX2_HC_COM_TICKS_OFF, (64 << 16) | 220);
                CNIC_WR(dev, base + BNX2_HC_CMD_TICKS_OFF, (64 << 16) | 220);
 
-               cp->bnx2_status_blk = cp->status_blk;
-               cp->last_status_idx = cp->bnx2_status_blk->status_idx;
+               cp->last_status_idx = cp->status_blk.bnx2->status_idx;
                tasklet_init(&cp->cnic_irq_task, cnic_service_bnx2_msix,
                             (unsigned long) dev);
                err = request_irq(ethdev->irq_arr[0].vector, cnic_irq, 0,
@@ -3430,7 +3418,7 @@ static int cnic_init_bnx2_irq(struct cnic_dev *dev)
                        tasklet_disable(&cp->cnic_irq_task);
                        return err;
                }
-               while (cp->bnx2_status_blk->status_completion_producer_index &&
+               while (cp->status_blk.bnx2->status_completion_producer_index &&
                       i < 10) {
                        CNIC_WR(dev, BNX2_HC_COALESCE_NOW,
                                1 << (11 + sblk_num));
@@ -3438,13 +3426,13 @@ static int cnic_init_bnx2_irq(struct cnic_dev *dev)
                        i++;
                        barrier();
                }
-               if (cp->bnx2_status_blk->status_completion_producer_index) {
+               if (cp->status_blk.bnx2->status_completion_producer_index) {
                        cnic_free_irq(dev);
                        goto failed;
                }
 
        } else {
-               struct status_block *sblk = cp->status_blk;
+               struct status_block *sblk = cp->status_blk.gen;
                u32 hc_cmd = CNIC_RD(dev, BNX2_HC_COMMAND);
                int i = 0;
 
@@ -3501,7 +3489,7 @@ static void cnic_init_bnx2_tx_ring(struct cnic_dev *dev)
        int i;
        struct tx_bd *txbd;
        dma_addr_t buf_map;
-       struct status_block *s_blk = cp->status_blk;
+       struct status_block *s_blk = cp->status_blk.gen;
 
        sb_id = cp->status_blk_num;
        tx_cid = 20;
@@ -3509,7 +3497,7 @@ static void cnic_init_bnx2_tx_ring(struct cnic_dev *dev)
        cnic_init_context(dev, tx_cid + 1);
        cp->tx_cons_ptr = &s_blk->status_tx_quick_consumer_index2;
        if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) {
-               struct status_block_msix *sblk = cp->status_blk;
+               struct status_block_msix *sblk = cp->status_blk.bnx2;
 
                tx_cid = TX_TSS_CID + sb_id - 1;
                cnic_init_context(dev, tx_cid);
@@ -3565,7 +3553,7 @@ static void cnic_init_bnx2_rx_ring(struct cnic_dev *dev)
        u32 cid_addr, sb_id, val, coal_reg, coal_val;
        int i;
        struct rx_bd *rxbd;
-       struct status_block *s_blk = cp->status_blk;
+       struct status_block *s_blk = cp->status_blk.gen;
 
        sb_id = cp->status_blk_num;
        cnic_init_context(dev, 2);
@@ -3573,7 +3561,7 @@ static void cnic_init_bnx2_rx_ring(struct cnic_dev *dev)
        coal_reg = BNX2_HC_COMMAND;
        coal_val = CNIC_RD(dev, coal_reg);
        if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) {
-               struct status_block_msix *sblk = cp->status_blk;
+               struct status_block_msix *sblk = cp->status_blk.bnx2;
 
                cp->rx_cons_ptr = &sblk->status_rx_quick_consumer_index;
                coal_reg = BNX2_HC_COALESCE_NOW;
@@ -3672,7 +3660,7 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev)
 {
        struct cnic_local *cp = dev->cnic_priv;
        struct cnic_eth_dev *ethdev = cp->ethdev;
-       struct status_block *sblk = cp->status_blk;
+       struct status_block *sblk = cp->status_blk.gen;
        u32 val;
        int err;
 
@@ -4261,7 +4249,7 @@ static int cnic_start_hw(struct cnic_dev *dev)
        cp->chip_id = ethdev->chip_id;
        pci_dev_get(dev->pcidev);
        cp->func = PCI_FUNC(dev->pcidev->devfn);
-       cp->status_blk = ethdev->irq_arr[0].status_blk;
+       cp->status_blk.gen = ethdev->irq_arr[0].status_blk;
        cp->status_blk_num = ethdev->irq_arr[0].status_blk_num;
 
        err = cp->alloc_resc(dev);