From: Mike Christie <mchristi@redhat.com> Date: Fri, 13 Aug 2010 09:46:42 -0400 Subject: [net] cnic: select bug fixes from upstream for RHEL5.6 Message-id: <1281692802-2810-15-git-send-email-mchristi@redhat.com> Patchwork-id: 27550 O-Subject: [RHEL5.6 PATCH 14/14] cnic: Backport select bug fixes from upstream to RHEL5.6. Bugzilla: 595548 619767 RH-Acked-by: David S. Miller <davem@redhat.com> From: Eddie Wai <eddie.wai@broadcom.com> This is for bz 595548 and 619767. This patch updates the cnic driver. It consists of these upstream patches: commit 7b34a4644b4342896e0c1967b8f953213ea4a990 cnic: Fix cnic_cm_abort() error handling. commit 943189f1d564e69201f7d71e77f5608a701e3e55 cnic: Refactor and fix cnic_ready_to_close(). commit a1e621bf6d03621de207cd416f6a21969dd0601c cnic: Refactor code in cnic_cm_process_kcqe(). commit ed99daa5a0de4df9ed579ce36ff8b1373b6dbe47 cnic: Return error code in cnic_cm_close() if unsuccessful. commit b58ffb41fc09d1ffaca97e5ae801233575be2a7f cnic: Fix context memory init. on 5709. commit 1d9cfc4e354cd619d92bb938657dec3c533e6929 cnic: Update version to 2.1.1. commit a4dde3abbf87a495154a876576e1ab34b17b5ef1 cnic: Use union for the status blocks of different devices. commit c76284af9ec8a010c502a70249cb74b3bb69ec6f cnic: Simplify route checking during iSCSI connection. commit 66883e90eaa0dd55d395c0f9a0c6da5d50809804 cnic: Finetune iSCSI connection reset. commit a9736c086cc6221659e498f0855152c32dbc1396 cnic: Finetune iSCSI connection set up. commit 48f753d2ba94a4081400fa8d26bdbfbbf12b10de cnic: Return SPQ credit to bnx2x after ring setup and shutdown. commit 1f1332a3cb7ac73e3bcff6ea42ff965c90a29d12 cnic: Convert cnic_local_flags to atomic ops. Patch was made and tested by Broadcom. I have also tested with bnx2x and bnx2i by doing iscsi IO and login and logout tests. diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c index 2813c9a..31a308e 100644 --- a/drivers/net/cnic.c +++ b/drivers/net/cnic.c @@ -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 @@ -906,7 +906,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 @@ -1109,10 +1110,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; @@ -1149,12 +1149,12 @@ static int cnic_submit_bnx2_kwqes(struct cnic_dev *dev, struct kwqe *wqes[], spin_lock_bh(&cp->cnic_ulp_lock); if (num_wqes > cnic_kwq_avail(cp) && - !(cp->cnic_local_flags & CNIC_LCL_FL_KWQ_INIT)) { + !test_bit(CNIC_LCL_FL_KWQ_INIT, &cp->cnic_local_flags)) { spin_unlock_bh(&cp->cnic_ulp_lock); return -EAGAIN; } - cp->cnic_local_flags &= ~CNIC_LCL_FL_KWQ_INIT; + clear_bit(CNIC_LCL_FL_KWQ_INIT, &cp->cnic_local_flags); prod = cp->kwq_prod_idx; sw_prod = prod & MAX_KWQ_IDX; @@ -2099,7 +2099,6 @@ end: i += j; j = 1; } - return; } static u16 cnic_bnx2_next_idx(u16 idx) @@ -2153,17 +2152,56 @@ static int cnic_get_kcqes(struct cnic_dev *dev, u16 hw_prod, u16 *sw_prod) return last_cnt; } +static int cnic_l2_completion(struct cnic_local *cp) +{ + u16 hw_cons, sw_cons; + union eth_rx_cqe *cqe, *cqe_ring = (union eth_rx_cqe *) + (cp->l2_ring + (2 * BCM_PAGE_SIZE)); + u32 cmd; + int comp = 0; + + if (!test_bit(CNIC_F_BNX2X_CLASS, &cp->dev->flags)) + return 0; + + hw_cons = *cp->rx_cons_ptr; + if ((hw_cons & BNX2X_MAX_RCQ_DESC_CNT) == BNX2X_MAX_RCQ_DESC_CNT) + hw_cons++; + + sw_cons = cp->rx_cons; + while (sw_cons != hw_cons) { + u8 cqe_fp_flags; + + cqe = &cqe_ring[sw_cons & BNX2X_MAX_RCQ_DESC_CNT]; + cqe_fp_flags = cqe->fast_path_cqe.type_error_flags; + if (cqe_fp_flags & ETH_FAST_PATH_RX_CQE_TYPE) { + cmd = le32_to_cpu(cqe->ramrod_cqe.conn_and_cmd_data); + cmd >>= COMMON_RAMROD_ETH_RX_CQE_CMD_ID_SHIFT; + if (cmd == RAMROD_CMD_ID_ETH_CLIENT_SETUP || + cmd == RAMROD_CMD_ID_ETH_HALT) + comp++; + } + sw_cons = BNX2X_NEXT_RCQE(sw_cons); + } + return comp; +} + static void cnic_chk_pkt_rings(struct cnic_local *cp) { u16 rx_cons = *cp->rx_cons_ptr; u16 tx_cons = *cp->tx_cons_ptr; + int comp = 0; if (cp->tx_cons != tx_cons || cp->rx_cons != rx_cons) { + if (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags)) + comp = cnic_l2_completion(cp); + cp->tx_cons = tx_cons; cp->rx_cons = rx_cons; uio_event_notify(cp->cnic_uinfo); } + if (comp) + clear_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); } static int cnic_service_bnx2(void *data, void *status_blk) @@ -2212,7 +2250,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; @@ -2258,7 +2296,7 @@ static irqreturn_t cnic_irq(int irq, void *dev_instance, struct pt_regs *regs) 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))) @@ -2299,7 +2337,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; @@ -2332,7 +2370,6 @@ done: status_idx, IGU_INT_ENABLE, 1); cp->kcq_prod_idx = sw_prod; - return; } static int cnic_service_bnx2x(void *data, void *status_blk) @@ -2343,7 +2380,7 @@ static int cnic_service_bnx2x(void *data, void *status_blk) if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags))) { - prefetch(cp->status_blk); + prefetch(cp->status_blk.bnx2x); prefetch(&cp->kcq[KCQ_PG(prod)][KCQ_IDX(prod)]); tasklet_schedule(&cp->cnic_irq_task); @@ -2522,7 +2559,7 @@ static int cnic_cm_offload_pg(struct cnic_sock *csk) l4kwqe->sa5 = dev->mac_addr[5]; l4kwqe->etype = ETH_P_IP; - l4kwqe->ipid_count = DEF_IPID_COUNT; + l4kwqe->ipid_start = DEF_IPID_START; l4kwqe->host_opaque = csk->l5_cid; if (csk->vlan_id) { @@ -2874,8 +2911,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; @@ -2891,39 +2928,32 @@ 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) 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) { @@ -2941,9 +2971,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; @@ -2984,7 +3011,7 @@ err_out: static int cnic_cm_abort(struct cnic_sock *csk) { struct cnic_local *cp = csk->dev->cnic_priv; - u32 opcode; + u32 opcode = L4_KCQE_OPCODE_VALUE_RESET_COMP; if (!cnic_in_use(csk)) return -EINVAL; @@ -2996,12 +3023,9 @@ static int cnic_cm_abort(struct cnic_sock *csk) * connect was not successful. */ - csk->state = L4_KCQE_OPCODE_VALUE_RESET_COMP; - if (test_bit(SK_F_PG_OFFLD_COMPLETE, &csk->flags)) - opcode = csk->state; - else - opcode = L5CM_RAMROD_CMD_ID_TERMINATE_OFFLOAD; cp->close_conn(csk, opcode); + if (csk->state != opcode) + return -EALREADY; return 0; } @@ -3014,6 +3038,8 @@ static int cnic_cm_close(struct cnic_sock *csk) if (cnic_close_prep(csk)) { csk->state = L4_KCQE_OPCODE_VALUE_CLOSE_COMP; return cnic_cm_close_req(csk); + } else { + return -EALREADY; } return 0; } @@ -3067,6 +3093,14 @@ static void cnic_cm_process_offld_pg(struct cnic_dev *dev, struct l4_kcq *kcqe) clear_bit(SK_F_OFFLD_SCHED, &csk->flags); goto done; } + /* Possible PG kcqe status: SUCCESS, OFFLOADED_PG, or CTX_ALLOC_FAIL */ + if (kcqe->status == L4_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAIL) { + clear_bit(SK_F_OFFLD_SCHED, &csk->flags); + cnic_cm_upcall(cp, csk, + L4_KCQE_OPCODE_VALUE_CONNECT_COMPLETE); + goto done; + } + csk->pg_cid = kcqe->pg_cid; set_bit(SK_F_PG_OFFLD_COMPLETE, &csk->flags); cnic_cm_conn_req(csk); @@ -3104,6 +3138,13 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe) } switch (opcode) { + case L5CM_RAMROD_CMD_ID_TCP_CONNECT: + if (l4kcqe->status != 0) { + clear_bit(SK_F_OFFLD_SCHED, &csk->flags); + cnic_cm_upcall(cp, csk, + L4_KCQE_OPCODE_VALUE_CONNECT_COMPLETE); + } + break; case L4_KCQE_OPCODE_VALUE_CONNECT_COMPLETE: if (l4kcqe->status == 0) set_bit(SK_F_OFFLD_COMPLETE, &csk->flags); @@ -3114,9 +3155,6 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe) break; case L4_KCQE_OPCODE_VALUE_RESET_RECEIVED: - if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) - csk->state = opcode; - /* fall through */ case L4_KCQE_OPCODE_VALUE_CLOSE_COMP: case L4_KCQE_OPCODE_VALUE_RESET_COMP: case L5CM_RAMROD_CMD_ID_SEARCHER_DELETE: @@ -3172,11 +3210,24 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev) static int cnic_ready_to_close(struct cnic_sock *csk, u32 opcode) { - if ((opcode == csk->state) || - (opcode == L4_KCQE_OPCODE_VALUE_RESET_RECEIVED && - csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP)) { - if (!test_and_set_bit(SK_F_CLOSING, &csk->flags)) + if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) { + /* Unsolicited RESET_COMP or RESET_RECEIVED */ + opcode = L4_KCQE_OPCODE_VALUE_RESET_RECEIVED; + csk->state = opcode; + } + + /* 1. If event opcode matches the expected event in csk->state + * 2. If the expected event is CLOSE_COMP, we accept any event + * 3. If the expected event is 0, meaning the connection was never + * never established, we accept the opcode from cm_abort. + */ + if (opcode == csk->state || csk->state == 0 || + csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP) { + if (!test_and_set_bit(SK_F_CLOSING, &csk->flags)) { + if (csk->state == 0) + csk->state = opcode; return 1; + } } return 0; } @@ -3186,11 +3237,15 @@ static void cnic_close_bnx2_conn(struct cnic_sock *csk, u32 opcode) struct cnic_dev *dev = csk->dev; struct cnic_local *cp = dev->cnic_priv; - clear_bit(SK_F_CONNECT_START, &csk->flags); - if (cnic_ready_to_close(csk, opcode)) { - cnic_close_conn(csk); + if (opcode == L4_KCQE_OPCODE_VALUE_RESET_RECEIVED) { cnic_cm_upcall(cp, csk, opcode); + return; } + + clear_bit(SK_F_CONNECT_START, &csk->flags); + cnic_close_conn(csk); + csk->state = opcode; + cnic_cm_upcall(cp, csk, opcode); } static void cnic_cm_stop_bnx2_hw(struct cnic_dev *dev) @@ -3219,8 +3274,12 @@ static void cnic_close_bnx2x_conn(struct cnic_sock *csk, u32 opcode) case L4_KCQE_OPCODE_VALUE_RESET_RECEIVED: case L4_KCQE_OPCODE_VALUE_CLOSE_COMP: case L4_KCQE_OPCODE_VALUE_RESET_COMP: - if (cnic_ready_to_close(csk, opcode)) - cmd = L5CM_RAMROD_CMD_ID_SEARCHER_DELETE; + if (cnic_ready_to_close(csk, opcode)) { + if (test_bit(SK_F_PG_OFFLD_COMPLETE, &csk->flags)) + cmd = L5CM_RAMROD_CMD_ID_SEARCHER_DELETE; + else + close_complete = 1; + } break; case L5CM_RAMROD_CMD_ID_SEARCHER_DELETE: cmd = L5CM_RAMROD_CMD_ID_TERMINATE_OFFLOAD; @@ -3329,13 +3388,9 @@ static int cnic_cm_shutdown(struct cnic_dev *dev) static void cnic_init_context(struct cnic_dev *dev, u32 cid) { - struct cnic_local *cp = dev->cnic_priv; u32 cid_addr; int i; - if (CHIP_NUM(cp) == CHIP_NUM_5709) - return; - cid_addr = GET_CID_ADDR(cid); for (i = 0; i < CTX_SIZE; i += 4) @@ -3408,8 +3463,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, @@ -3418,7 +3472,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)); @@ -3426,13 +3480,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; @@ -3490,18 +3544,15 @@ 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; - cnic_init_context(dev, tx_cid); - 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); CNIC_WR(dev, BNX2_TSCH_TSS_CFG, (sb_id << 24) | (TX_TSS_CID << 7)); cp->tx_cons_ptr = &sblk->status_tx_quick_consumer_index; @@ -3520,6 +3571,9 @@ static void cnic_init_bnx2_tx_ring(struct cnic_dev *dev) offset2 = BNX2_L2CTX_TBDR_BHADDR_HI_XI; offset3 = BNX2_L2CTX_TBDR_BHADDR_LO_XI; } else { + cnic_init_context(dev, tx_cid); + cnic_init_context(dev, tx_cid + 1); + offset0 = BNX2_L2CTX_TYPE; offset1 = BNX2_L2CTX_CMD_TYPE; offset2 = BNX2_L2CTX_TBDR_BHADDR_HI; @@ -3554,7 +3608,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); @@ -3562,7 +3616,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; @@ -3661,7 +3715,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; @@ -3693,7 +3747,7 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev) cp->max_kwq_idx = MAX_KWQ_IDX; cp->kwq_prod_idx = 0; cp->kwq_con_idx = 0; - cp->cnic_local_flags |= CNIC_LCL_FL_KWQ_INIT; + set_bit(CNIC_LCL_FL_KWQ_INIT, &cp->cnic_local_flags); if (CHIP_NUM(cp) == CHIP_NUM_5706 || CHIP_NUM(cp) == CHIP_NUM_5708) cp->kwq_con_idx_ptr = &sblk->status_rx_quick_consumer_index15; @@ -4217,6 +4271,8 @@ static void cnic_init_rings(struct cnic_dev *dev) for (i = 0; i < sizeof(struct ustorm_eth_rx_producers) / 4; i++) CNIC_WR(dev, off + i * 4, ((u32 *) &rx_prods)[i]); + set_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); + cnic_init_bnx2x_tx_ring(dev); cnic_init_bnx2x_rx_ring(dev); @@ -4224,6 +4280,16 @@ static void cnic_init_rings(struct cnic_dev *dev) l5_data.phy_address.hi = 0; cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_CLIENT_SETUP, BNX2X_ISCSI_L2_CID, ETH_CONNECTION_TYPE, &l5_data); + i = 0; + while (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags) && + ++i < 10) + msleep(1); + + if (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags)) + printk(KERN_ERR PFX + "%s: iSCSI CLIENT_SETUP did not complete\n", + dev->netdev->name); + cnic_kwq_completion(dev, 1); cnic_ring_ctl(dev, BNX2X_ISCSI_L2_CID, cli, 1); } } @@ -4236,14 +4302,26 @@ static void cnic_shutdown_rings(struct cnic_dev *dev) struct cnic_local *cp = dev->cnic_priv; u32 cli = BNX2X_ISCSI_CL_ID(CNIC_E1HVN(cp)); union l5cm_specific_data l5_data; + int i; cnic_ring_ctl(dev, BNX2X_ISCSI_L2_CID, cli, 0); + set_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); + l5_data.phy_address.lo = cli; l5_data.phy_address.hi = 0; cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_HALT, BNX2X_ISCSI_L2_CID, ETH_CONNECTION_TYPE, &l5_data); - msleep(10); + i = 0; + while (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags) && + ++i < 10) + msleep(1); + + if (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags)) + printk(KERN_ERR PFX + "%s: iSCSI CLIENT_HALT did not complete\n", + dev->netdev->name); + cnic_kwq_completion(dev, 1); memset(&l5_data, 0, sizeof(l5_data)); cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_CFC_DEL, @@ -4266,7 +4344,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); @@ -4335,7 +4413,15 @@ static void cnic_stop_hw(struct cnic_dev *dev) { if (test_bit(CNIC_F_CNIC_UP, &dev->flags)) { struct cnic_local *cp = dev->cnic_priv; + int i = 0; + /* Need to wait for the ring shutdown event to complete + * before clearing the CNIC_UP flag. + */ + while (cp->uio_dev != -1 && i < 15) { + msleep(100); + i++; + } clear_bit(CNIC_F_CNIC_UP, &dev->flags); rcu_assign_pointer(cp->ulp_ops[CNIC_ULP_L4], NULL); synchronize_rcu(); @@ -4648,7 +4734,6 @@ static void __exit cnic_exit(void) { unregister_netdevice_notifier(&cnic_netdev_notifier); cnic_release(); - return; } module_init(cnic_init); diff --git a/drivers/net/cnic.h b/drivers/net/cnic.h index 3b2e380..4827719 100644 --- a/drivers/net/cnic.h +++ b/drivers/net/cnic.h @@ -1,6 +1,6 @@ /* cnic.h: Broadcom CNIC core network driver. * - * Copyright (c) 2006 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 @@ -102,7 +102,7 @@ struct cnic_redirect_entry { #define BNX2X_KWQ_DATA(cp, x) \ &(cp)->kwq_16_data[BNX2X_KWQ_DATA_PG(cp, x)][BNX2X_KWQ_DATA_IDX(cp, x)] -#define DEF_IPID_COUNT 0xc001 +#define DEF_IPID_START 0x8000 #define DEF_KA_TIMEOUT 10000 #define DEF_KA_INTERVAL 300000 @@ -180,9 +180,9 @@ struct cnic_local { #define ULP_F_CALL_PENDING 2 struct cnic_ulp_ops *ulp_ops[MAX_CNIC_ULP_TYPE]; - /* protected by ulp_lock */ - u32 cnic_local_flags; -#define CNIC_LCL_FL_KWQ_INIT 0x00000001 + unsigned long cnic_local_flags; +#define CNIC_LCL_FL_KWQ_INIT 0x0 +#define CNIC_LCL_FL_L2_WAIT 0x1 struct cnic_dev *dev; @@ -225,9 +225,12 @@ struct cnic_local { u16 kcq_prod_idx; u32 kcq_io_addr; - void *status_blk; - struct status_block_msix *bnx2_status_blk; - struct host_status_block *bnx2x_status_blk; + union { + void *gen; + struct status_block_msix *bnx2; + struct host_status_block *bnx2x; + } status_blk; + struct host_def_status_block *bnx2x_def_status_blk; u32 status_blk_num; @@ -347,6 +350,10 @@ struct bnx2x_bd_chain_next { #define BNX2X_RCQ_DESC_CNT (BCM_PAGE_SIZE / sizeof(union eth_rx_cqe)) #define BNX2X_MAX_RCQ_DESC_CNT (BNX2X_RCQ_DESC_CNT - 1) +#define BNX2X_NEXT_RCQE(x) (((x) & BNX2X_MAX_RCQ_DESC_CNT) == \ + (BNX2X_MAX_RCQ_DESC_CNT - 1)) ? \ + ((x) + 2) : ((x) + 1) + #define BNX2X_DEF_SB_ID 16 #define BNX2X_ISCSI_RX_SB_INDEX_NUM \ diff --git a/drivers/net/cnic_defs.h b/drivers/net/cnic_defs.h index bb56384..8353f39 100644 --- a/drivers/net/cnic_defs.h +++ b/drivers/net/cnic_defs.h @@ -1,3 +1,14 @@ + +/* cnic.c: Broadcom CNIC core network driver. + * + * 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 + * the Free Software Foundation. + * + */ + #ifndef CNIC_DEFS_H #define CNIC_DEFS_H /* KWQ (kernel work queue) request op codes */ diff --git a/drivers/net/cnic_if.h b/drivers/net/cnic_if.h index 32bb6f1..2f5f17f 100644 --- a/drivers/net/cnic_if.h +++ b/drivers/net/cnic_if.h @@ -1,6 +1,6 @@ /* cnic_if.h: Broadcom CNIC core network driver. * - * Copyright (c) 2006 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 @@ -15,8 +15,8 @@ #include <linux/in.h> #include <linux/in6.h> -#define CNIC_MODULE_VERSION "2.1.0" -#define CNIC_MODULE_RELDATE "Oct 10, 2009" +#define CNIC_MODULE_VERSION "2.1.2" +#define CNIC_MODULE_RELDATE "May 26, 2010" #define CNIC_ULP_RDMA 0 #define CNIC_ULP_ISCSI 1