net/sfc/base: import 5xxx/6xxx family support
[dpdk.git] / drivers / net / sfc / base / siena_sram.c
1 /*
2  * Copyright (c) 2009-2016 Solarflare Communications Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  *    this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  *    this list of conditions and the following disclaimer in the documentation
12  *    and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * The views and conclusions contained in the software and documentation are
27  * those of the authors and should not be interpreted as representing official
28  * policies, either expressed or implied, of the FreeBSD Project.
29  */
30
31 #include "efx.h"
32 #include "efx_impl.h"
33
34 #if EFSYS_OPT_SIENA
35
36                         void
37 siena_sram_init(
38         __in            efx_nic_t *enp)
39 {
40         efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
41         efx_oword_t oword;
42         uint32_t rx_base, tx_base;
43
44         EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
45         EFSYS_ASSERT(enp->en_family == EFX_FAMILY_SIENA);
46
47         rx_base = encp->enc_buftbl_limit;
48         tx_base = rx_base + (encp->enc_rxq_limit *
49             EFX_RXQ_DC_NDESCS(EFX_RXQ_DC_SIZE));
50
51         /* Initialize the transmit descriptor cache */
52         EFX_POPULATE_OWORD_1(oword, FRF_AZ_SRM_TX_DC_BASE_ADR, tx_base);
53         EFX_BAR_WRITEO(enp, FR_AZ_SRM_TX_DC_CFG_REG, &oword);
54
55         EFX_POPULATE_OWORD_1(oword, FRF_AZ_TX_DC_SIZE, EFX_TXQ_DC_SIZE);
56         EFX_BAR_WRITEO(enp, FR_AZ_TX_DC_CFG_REG, &oword);
57
58         /* Initialize the receive descriptor cache */
59         EFX_POPULATE_OWORD_1(oword, FRF_AZ_SRM_RX_DC_BASE_ADR, rx_base);
60         EFX_BAR_WRITEO(enp, FR_AZ_SRM_RX_DC_CFG_REG, &oword);
61
62         EFX_POPULATE_OWORD_1(oword, FRF_AZ_RX_DC_SIZE, EFX_RXQ_DC_SIZE);
63         EFX_BAR_WRITEO(enp, FR_AZ_RX_DC_CFG_REG, &oword);
64
65         /* Set receive descriptor pre-fetch low water mark */
66         EFX_POPULATE_OWORD_1(oword, FRF_AZ_RX_DC_PF_LWM, 56);
67         EFX_BAR_WRITEO(enp, FR_AZ_RX_DC_PF_WM_REG, &oword);
68
69         /* Set the event queue to use for SRAM updates */
70         EFX_POPULATE_OWORD_1(oword, FRF_AZ_SRM_UPD_EVQ_ID, 0);
71         EFX_BAR_WRITEO(enp, FR_AZ_SRM_UPD_EVQ_REG, &oword);
72 }
73
74 #endif  /* EFSYS_OPT_SIENA */