net/bnx2x: update HSI
[dpdk.git] / drivers / net / bnx2x / bnx2x.c
index 5f353a7..010e160 100644 (file)
@@ -2015,6 +2015,8 @@ bnx2x_nic_unload(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_link
        uint8_t global = FALSE;
        uint32_t val;
 
+       PMD_INIT_FUNC_TRACE(sc);
+
        PMD_DRV_LOG(DEBUG, sc, "Starting NIC unload...");
 
        /* mark driver as unloaded in shmem2 */
@@ -2118,6 +2120,9 @@ bnx2x_nic_unload(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_link
                bnx2x_free_mem(sc);
        }
 
+       /* free the host hardware/software hsi structures */
+       bnx2x_free_hsi_mem(sc);
+
        bnx2x_free_fw_stats_mem(sc);
 
        sc->state = BNX2X_STATE_CLOSED;
@@ -2177,8 +2182,10 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf *m0)
 
        tx_start_bd = &txq->tx_ring[TX_BD(bd_prod, txq)].start_bd;
 
-       tx_start_bd->addr =
-           rte_cpu_to_le_64(rte_mbuf_data_iova(m0));
+       tx_start_bd->addr_lo =
+           rte_cpu_to_le_32(U64_LO(rte_mbuf_data_iova(m0)));
+       tx_start_bd->addr_hi =
+           rte_cpu_to_le_32(U64_HI(rte_mbuf_data_iova(m0)));
        tx_start_bd->nbytes = rte_cpu_to_le_16(m0->data_len);
        tx_start_bd->bd_flags.as_bitfield = ETH_TX_BD_FLAGS_START_BD;
        tx_start_bd->general_data =
@@ -4090,7 +4097,7 @@ static void bnx2x_attn_int_deasserted0(struct bnx2x_softc *sc, uint32_t attn)
                REG_WR(sc, reg_offset, val);
 
                rte_panic("FATAL HW block attention set0 0x%lx",
-                         (attn & HW_INTERRUT_ASSERT_SET_0));
+                         (attn & (unsigned long)HW_INTERRUT_ASSERT_SET_0));
        }
 }
 
@@ -5010,13 +5017,14 @@ static void
 bnx2x_update_rx_prod(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
                   uint16_t rx_bd_prod, uint16_t rx_cq_prod)
 {
-       union ustorm_eth_rx_producers rx_prods;
+       struct ustorm_eth_rx_producers rx_prods;
        uint32_t i;
 
+       memset(&rx_prods, 0, sizeof(rx_prods));
+
        /* update producers */
-       rx_prods.prod.bd_prod = rx_bd_prod;
-       rx_prods.prod.cqe_prod = rx_cq_prod;
-       rx_prods.prod.reserved = 0;
+       rx_prods.bd_prod = rx_bd_prod;
+       rx_prods.cqe_prod = rx_cq_prod;
 
        /*
         * Make sure that the BD and SGE data is updated before updating the
@@ -5029,9 +5037,8 @@ bnx2x_update_rx_prod(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
        wmb();
 
        for (i = 0; i < (sizeof(rx_prods) / 4); i++) {
-               REG_WR(sc,
-                      (fp->ustorm_rx_prods_offset + (i * 4)),
-                      rx_prods.raw_data[i]);
+               REG_WR(sc, (fp->ustorm_rx_prods_offset + (i * 4)),
+                      ((uint32_t *)&rx_prods)[i]);
        }
 
        wmb();                  /* keep prod updates ordered */
@@ -7230,6 +7237,14 @@ int bnx2x_nic_load(struct bnx2x_softc *sc)
                }
        }
 
+       /* allocate the host hardware/software hsi structures */
+       if (bnx2x_alloc_hsi_mem(sc) != 0) {
+               PMD_DRV_LOG(ERR, sc, "bnx2x_alloc_hsi_mem was failed");
+               sc->state = BNX2X_STATE_CLOSED;
+               rc = -ENOMEM;
+               goto bnx2x_nic_load_error0;
+       }
+
        if (bnx2x_alloc_fw_stats_mem(sc) != 0) {
                sc->state = BNX2X_STATE_CLOSED;
                rc = -ENOMEM;
@@ -7445,6 +7460,7 @@ bnx2x_nic_load_error1:
 bnx2x_nic_load_error0:
 
        bnx2x_free_fw_stats_mem(sc);
+       bnx2x_free_hsi_mem(sc);
        bnx2x_free_mem(sc);
 
        return rc;
@@ -8890,9 +8906,9 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
        uint32_t i;
 
        if (IS_PF(sc)) {
-/************************/
-/* DEFAULT STATUS BLOCK */
-/************************/
+               /************************/
+               /* DEFAULT STATUS BLOCK */
+               /************************/
 
                if (bnx2x_dma_alloc(sc, sizeof(struct host_sp_status_block),
                                  &sc->def_sb_dma, "def_sb",
@@ -8902,9 +8918,9 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
 
                sc->def_sb =
                    (struct host_sp_status_block *)sc->def_sb_dma.vaddr;
-/***************/
-/* EVENT QUEUE */
-/***************/
+               /***************/
+               /* EVENT QUEUE */
+               /***************/
 
                if (bnx2x_dma_alloc(sc, BNX2X_PAGE_SIZE,
                                  &sc->eq_dma, "ev_queue",
@@ -8915,9 +8931,9 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
 
                sc->eq = (union event_ring_elem *)sc->eq_dma.vaddr;
 
-/*************/
-/* SLOW PATH */
-/*************/
+               /*************/
+               /* SLOW PATH */
+               /*************/
 
                if (bnx2x_dma_alloc(sc, sizeof(struct bnx2x_slowpath),
                                  &sc->sp_dma, "sp",
@@ -8929,9 +8945,9 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
 
                sc->sp = (struct bnx2x_slowpath *)sc->sp_dma.vaddr;
 
-/*******************/
-/* SLOW PATH QUEUE */
-/*******************/
+               /*******************/
+               /* SLOW PATH QUEUE */
+               /*******************/
 
                if (bnx2x_dma_alloc(sc, BNX2X_PAGE_SIZE,
                                  &sc->spq_dma, "sp_queue",
@@ -8944,9 +8960,9 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
 
                sc->spq = (struct eth_spe *)sc->spq_dma.vaddr;
 
-/***************************/
-/* FW DECOMPRESSION BUFFER */
-/***************************/
+               /***************************/
+               /* FW DECOMPRESSION BUFFER */
+               /***************************/
 
                if (bnx2x_dma_alloc(sc, FW_BUF_SIZE, &sc->gz_buf_dma,
                                  "fw_buf", RTE_CACHE_LINE_SIZE) != 0) {
@@ -8970,9 +8986,9 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
                fp->sc = sc;
                fp->index = i;
 
-/*******************/
-/* FP STATUS BLOCK */
-/*******************/
+               /*******************/
+               /* FP STATUS BLOCK */
+               /*******************/
 
                snprintf(buf, sizeof(buf), "fp_%d_sb", i);
                if (bnx2x_dma_alloc(sc, sizeof(union bnx2x_host_hc_status_block),
@@ -9003,43 +9019,50 @@ void bnx2x_free_hsi_mem(struct bnx2x_softc *sc)
        for (i = 0; i < sc->num_queues; i++) {
                fp = &sc->fp[i];
 
-/*******************/
-/* FP STATUS BLOCK */
-/*******************/
+               /*******************/
+               /* FP STATUS BLOCK */
+               /*******************/
 
                memset(&fp->status_block, 0, sizeof(fp->status_block));
+               bnx2x_dma_free(&fp->sb_dma);
        }
 
-       /***************************/
-       /* FW DECOMPRESSION BUFFER */
-       /***************************/
+       if (IS_PF(sc)) {
+               /***************************/
+               /* FW DECOMPRESSION BUFFER */
+               /***************************/
 
-       sc->gz_buf = NULL;
+               bnx2x_dma_free(&sc->gz_buf_dma);
+               sc->gz_buf = NULL;
 
-       /*******************/
-       /* SLOW PATH QUEUE */
-       /*******************/
+               /*******************/
+               /* SLOW PATH QUEUE */
+               /*******************/
 
-       sc->spq = NULL;
+               bnx2x_dma_free(&sc->spq_dma);
+               sc->spq = NULL;
 
-       /*************/
-       /* SLOW PATH */
-       /*************/
+               /*************/
+               /* SLOW PATH */
+               /*************/
 
-       sc->sp = NULL;
+               bnx2x_dma_free(&sc->sp_dma);
+               sc->sp = NULL;
 
-       /***************/
-       /* EVENT QUEUE */
-       /***************/
+               /***************/
+               /* EVENT QUEUE */
+               /***************/
 
-       sc->eq = NULL;
+               bnx2x_dma_free(&sc->eq_dma);
+               sc->eq = NULL;
 
-       /************************/
-       /* DEFAULT STATUS BLOCK */
-       /************************/
-
-       sc->def_sb = NULL;
+               /************************/
+               /* DEFAULT STATUS BLOCK */
+               /************************/
 
+               bnx2x_dma_free(&sc->def_sb_dma);
+               sc->def_sb = NULL;
+       }
 }
 
 /*
@@ -10373,7 +10396,6 @@ static int bnx2x_init_hw_common(struct bnx2x_softc *sc)
                ecore_init_block(sc, BLOCK_TM, PHASE_COMMON);
 
        ecore_init_block(sc, BLOCK_DORQ, PHASE_COMMON);
-       REG_WR(sc, DORQ_REG_DPM_CID_OFST, BNX2X_DB_SHIFT);
 
        if (!CHIP_REV_IS_SLOW(sc)) {
 /* enable hw interrupt from doorbell Q */