diff options
author | Mandy Lavi <mandy.lavi@freescale.com> | 2013-04-24 07:56:04 (GMT) |
---|---|---|
committer | Fleming Andrew-AFLEMING <AFLEMING@freescale.com> | 2013-04-29 20:22:02 (GMT) |
commit | 5045184a0cc3283bcd30d3bbebff6188d30e9fce (patch) | |
tree | f47057a56b74a822fe8329767802f4ff59711e3f /drivers/net/ethernet/freescale/fman/Peripherals/FM/SP | |
parent | 56206bd9f58df8e2a1640c523d6f7fa392e580d1 (diff) | |
download | linux-fsl-qoriq-5045184a0cc3283bcd30d3bbebff6188d30e9fce.tar.xz |
fmd21 integration
Signed-off-by: Mandy Lavi <mandy.lavi@freescale.com>
Prev fmd integration was fmd19
Diffs from fmd19 to fmd21:
Added kgHashShift to t_FmPcdHashTableParams
Added nonConsistentSp to t_FmPcdManipReassemIpStats
sp - 2 layers separation - for future flib integration
rtc - 2 layers separation - for future flib integration
PFC enhancement (B4 Rev2 FMAN)
API addition (for B4 rev 2): FM_PORT_SetPfcPrioritiesMappingToQmanWQ
File fsl_fman.h renamed to lnxwrp_fsl_fman.h
The name fsl_fman.h has been applied to other fman internal header file
In dpaa_eth:
Due to renaming of fsl_fman.h to lnxwrp_fsl_fman.h
The relevant include lines in some of the files had to change accordingly
Change-Id: I8f25c758963a44a75ca8676aad45f7f96767b0b5
Reviewed-on: http://git.am.freescale.net:8181/2069
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Diffstat (limited to 'drivers/net/ethernet/freescale/fman/Peripherals/FM/SP')
4 files changed, 244 insertions, 194 deletions
diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/Makefile b/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/Makefile index 977583a..669e940 100644 --- a/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/Makefile +++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/Makefile @@ -12,4 +12,4 @@ EXTRA_CFLAGS += -I$(NCSW_FM_INC) obj-y += fsl-ncsw-sp.o -fsl-ncsw-sp-objs := fm_sp.o +fsl-ncsw-sp-objs := fm_sp.o fman_sp.o diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/fm_sp.c b/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/fm_sp.c index a457078..1f1cdf2 100644 --- a/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/fm_sp.c +++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/fm_sp.c @@ -46,133 +46,10 @@ #include "fm_vsp_ext.h" #include "fm_sp.h" #include "fm_common.h" - +#include "fsl_fman_sp.h" #if (DPAA_VERSION >= 11) -static void fm_vsp_fill_entry(fm_pcd_storage_profile_regs *regs, - uint16_t index, - fm_storage_profile_params *fm_vsp_params) -{ - int i = 0, j = 0; - fm_pcd_storage_profile_regs *sp_regs; - uint32_t tmp_reg, vector; - t_FmExtPools *ext_buf_pools = fm_vsp_params->fm_ext_pools; - t_FmBufPoolDepletion *buf_pool_depletion= fm_vsp_params->buf_pool_depletion; - t_FmBackupBmPools *backup_pools = fm_vsp_params->backup_pools; - t_FmSpIntContextDataCopy *int_context_data_copy = fm_vsp_params->int_context; - t_FmSpBufMargins *external_buffer_margins = fm_vsp_params->buf_margins; - bool no_scather_gather = fm_vsp_params->no_scather_gather; - uint16_t liodn_offset = fm_vsp_params->liodn_offset; - - ASSERT_COND(regs); - ASSERT_COND(ext_buf_pools); - ASSERT_COND(int_context_data_copy); - ASSERT_COND(external_buffer_margins); - ASSERT_COND(IN_RANGE(0, index, FM_VSP_MAX_NUM_OF_ENTRIES)); - - sp_regs = ®s[index]; - - /* fill external buffers manager pool information register*/ - for (i=0;i<ext_buf_pools->numOfPoolsUsed;i++) - { - tmp_reg = FM_SP_EXT_BUF_POOL_VALID | FM_SP_EXT_BUF_POOL_EN_COUNTER; - tmp_reg |= ((uint32_t)ext_buf_pools->extBufPool[i].id << FM_SP_EXT_BUF_POOL_ID_SHIFT); - tmp_reg |= ext_buf_pools->extBufPool[i].size; - /* functionality available only for some deriviatives (limited by config) */ - if (backup_pools) - for (j=0;j<backup_pools->numOfBackupPools;j++) - if (ext_buf_pools->extBufPool[i].id == backup_pools->poolIds[j]) - { - tmp_reg |= FM_SP_EXT_BUF_POOL_BACKUP; - break; - } - - WRITE_UINT32(sp_regs->fm_sp_ebmpi[i], tmp_reg); - } - - /* clear unused pools */ - for (i=ext_buf_pools->numOfPoolsUsed;i<FM_PORT_MAX_NUM_OF_EXT_POOLS;i++) - WRITE_UINT32(sp_regs->fm_sp_ebmpi[i], 0); - - /* fill pool depletion register*/ - tmp_reg = 0; - - if (buf_pool_depletion && buf_pool_depletion->poolsGrpModeEnable) - { - /* calculate vector for number of pools depletion */ - vector = 0; - for (i=0;i<BM_MAX_NUM_OF_POOLS;i++) - if (buf_pool_depletion->poolsToConsider[i]) - for (j=0;j<ext_buf_pools->numOfPoolsUsed;j++) - if (i == ext_buf_pools->extBufPool[j].id) - { - vector |= 0x80000000 >> j; - break; - } - - /* configure num of pools and vector for number of pools mode */ - tmp_reg |= (((uint32_t)buf_pool_depletion->numOfPools - 1) << FM_SP_POOL_DEP_NUM_OF_POOLS_SHIFT); - tmp_reg |= vector; - } - - if (buf_pool_depletion && buf_pool_depletion->singlePoolModeEnable) - { - /* calculate vector for number of pools depletion */ - vector = 0; - for (i=0;i<BM_MAX_NUM_OF_POOLS;i++) - if (buf_pool_depletion->poolsToConsiderForSingleMode[i]) - for (j=0;j<ext_buf_pools->numOfPoolsUsed;j++) - if (i == ext_buf_pools->extBufPool[j].id) - { - vector |= 0x00000080 >> j; - break; - } - - /* configure num of pools and vector for number of pools mode */ - tmp_reg |= vector; - } - - /* fill QbbPEV */ - if (buf_pool_depletion) - { - vector = 0; - for (i=0; i<FM_MAX_NUM_OF_PFC_PRIORITIES; i++) - if (buf_pool_depletion->pfcPrioritiesEn[i] == TRUE) - vector|= 0x00008000 >> i; - tmp_reg |= vector; - } - WRITE_UINT32(sp_regs->fm_sp_mpd, tmp_reg); - - /* fill dma attributes register */ - tmp_reg = 0; - tmp_reg |= (uint32_t)fm_vsp_params->dma_swap_data << FM_SP_DMA_ATTR_SWP_SHIFT; - tmp_reg |= (uint32_t)fm_vsp_params->int_context_cache_attr << FM_SP_DMA_ATTR_IC_CACHE_SHIFT; - tmp_reg |= (uint32_t)fm_vsp_params->header_cache_attr << FM_SP_DMA_ATTR_HDR_CACHE_SHIFT; - tmp_reg |= (uint32_t)fm_vsp_params->scatter_gather_cache_attr << FM_SP_DMA_ATTR_SG_CACHE_SHIFT; - if (fm_vsp_params->dma_write_optimize) - tmp_reg |= FM_SP_DMA_ATTR_WRITE_OPTIMIZE; - WRITE_UINT32(sp_regs->fm_sp_da, tmp_reg); - - /* IC parameters - fill internal context parameters register */ - tmp_reg = 0; - tmp_reg |= (((uint32_t)int_context_data_copy->extBufOffset/OFFSET_UNITS) << FM_SP_IC_TO_EXT_SHIFT); - tmp_reg |= (((uint32_t)int_context_data_copy->intContextOffset/OFFSET_UNITS) << FM_SP_IC_FROM_INT_SHIFT); - tmp_reg |= (((uint32_t)int_context_data_copy->size/OFFSET_UNITS) << FM_SP_IC_SIZE_SHIFT); - WRITE_UINT32(sp_regs->fm_sp_icp, tmp_reg); - - /* buffer margins - fill external buffer margins register */ - tmp_reg = 0; - tmp_reg |= (((uint32_t)external_buffer_margins->startMargins) << FM_SP_EXT_BUF_MARG_START_SHIFT); - tmp_reg |= (((uint32_t)external_buffer_margins->endMargins) << FM_SP_EXT_BUF_MARG_END_SHIFT); - if (no_scather_gather) - tmp_reg |= FM_SP_SG_DISABLE; - WRITE_UINT32(sp_regs->fm_sp_ebm, tmp_reg); - - /* buffer margins - fill spliodn register */ - WRITE_UINT32(sp_regs->fm_sp_spliodn, liodn_offset); -} - static t_Error CheckParamsGeneratedInternally(t_FmVspEntry *p_FmVspEntry) { t_Error err = E_OK; @@ -530,6 +407,7 @@ t_Error FmSpBuildBufferStructure(t_FmSpIntContextDataCopy *p_FmSpIntContextDat t_Handle FM_VSP_Config(t_FmVspParams *p_FmVspParams) { t_FmVspEntry *p_FmVspEntry = NULL; + struct fm_storage_profile_params fm_vsp_params; p_FmVspEntry = (t_FmVspEntry *)XX_Malloc(sizeof(t_FmVspEntry)); if (!p_FmVspEntry) @@ -547,29 +425,25 @@ t_Handle FM_VSP_Config(t_FmVspParams *p_FmVspParams) return NULL; } memset(p_FmVspEntry->p_FmVspEntryDriverParams, 0, sizeof(t_FmVspEntryDriverParams)); - + fman_vsp_defconfig(&fm_vsp_params); + p_FmVspEntry->p_FmVspEntryDriverParams->dmaHeaderCacheAttr = fm_vsp_params.header_cache_attr; + p_FmVspEntry->p_FmVspEntryDriverParams->dmaIntContextCacheAttr = fm_vsp_params.int_context_cache_attr; + p_FmVspEntry->p_FmVspEntryDriverParams->dmaScatterGatherCacheAttr = fm_vsp_params.scatter_gather_cache_attr; + p_FmVspEntry->p_FmVspEntryDriverParams->dmaSwapData = fm_vsp_params.dma_swap_data; + p_FmVspEntry->p_FmVspEntryDriverParams->dmaWriteOptimize = fm_vsp_params.dma_write_optimize; + p_FmVspEntry->p_FmVspEntryDriverParams->noScatherGather = fm_vsp_params.no_scather_gather; p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.privDataSize = DEFAULT_FM_SP_bufferPrefixContent_privDataSize; p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.passPrsResult= DEFAULT_FM_SP_bufferPrefixContent_passPrsResult; p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.passTimeStamp= DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp; p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.passAllOtherPCDInfo = DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp; p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.dataAlign = DEFAULT_FM_SP_bufferPrefixContent_dataAlign; - - p_FmVspEntry->p_FmVspEntryDriverParams->dmaSwapData = DEFAULT_FM_SP_dmaSwapData; - p_FmVspEntry->p_FmVspEntryDriverParams->dmaIntContextCacheAttr = DEFAULT_FM_SP_dmaIntContextCacheAttr; - p_FmVspEntry->p_FmVspEntryDriverParams->dmaHeaderCacheAttr = DEFAULT_FM_SP_dmaHeaderCacheAttr; - p_FmVspEntry->p_FmVspEntryDriverParams->dmaScatterGatherCacheAttr = DEFAULT_FM_SP_dmaScatterGatherCacheAttr; - p_FmVspEntry->p_FmVspEntryDriverParams->dmaWriteOptimize = DEFAULT_FM_SP_dmaWriteOptimize; - - p_FmVspEntry->p_FmVspEntryDriverParams->noScatherGather = DEFAULT_FM_SP_noScatherGather; - p_FmVspEntry->p_FmVspEntryDriverParams->liodnOffset = p_FmVspParams->liodnOffset; memcpy(&p_FmVspEntry->p_FmVspEntryDriverParams->extBufPools, &p_FmVspParams->extBufPools, sizeof(t_FmExtPools)); - p_FmVspEntry->h_Fm = p_FmVspParams->h_Fm; p_FmVspEntry->portType = p_FmVspParams->portParams.portType; - p_FmVspEntry->portId = p_FmVspParams->portParams.portId ; + p_FmVspEntry->portId = p_FmVspParams->portParams.portId; p_FmVspEntry->relativeProfileId = p_FmVspParams->relativeProfileId; @@ -580,7 +454,7 @@ t_Error FM_VSP_Init(t_Handle h_FmVsp) { t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry *)h_FmVsp; - fm_storage_profile_params fm_vsp_params; + struct fm_storage_profile_params fm_vsp_params; uint8_t orderedArray[FM_PORT_MAX_NUM_OF_EXT_POOLS]; uint16_t sizesArray[BM_MAX_NUM_OF_POOLS]; t_Error err; @@ -610,7 +484,7 @@ t_Error FM_VSP_Init(t_Handle h_FmVsp) p_FmVspEntry->p_FmSpRegsBase = - (fm_pcd_storage_profile_regs *)FmGetVSPBaseAddr(p_FmVspEntry->h_Fm); + (struct fm_pcd_storage_profile_regs *)FmGetVSPBaseAddr(p_FmVspEntry->h_Fm); if (!p_FmVspEntry->p_FmSpRegsBase) RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("impossible to initialize SpRegsBase")); @@ -628,7 +502,7 @@ t_Error FM_VSP_Init(t_Handle h_FmVsp) } /* on user responsibility to fill it according requirement */ - memset(&fm_vsp_params, 0, sizeof(fm_storage_profile_params)); + memset(&fm_vsp_params, 0, sizeof(struct fm_storage_profile_params)); fm_vsp_params.dma_swap_data = p_FmVspEntry->p_FmVspEntryDriverParams->dmaSwapData; fm_vsp_params.int_context_cache_attr = p_FmVspEntry->p_FmVspEntryDriverParams->dmaIntContextCacheAttr; fm_vsp_params.header_cache_attr = p_FmVspEntry->p_FmVspEntryDriverParams->dmaHeaderCacheAttr; @@ -637,12 +511,32 @@ t_Error FM_VSP_Init(t_Handle h_FmVsp) fm_vsp_params.liodn_offset = p_FmVspEntry->p_FmVspEntryDriverParams->liodnOffset; fm_vsp_params.no_scather_gather = p_FmVspEntry->p_FmVspEntryDriverParams->noScatherGather; - fm_vsp_params.buf_pool_depletion = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion; - fm_vsp_params.backup_pools = p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools; - fm_vsp_params.fm_ext_pools = &p_FmVspEntry->extBufPools; + if (p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion) + { + fm_vsp_params.buf_pool_depletion.buf_pool_depletion_enabled = TRUE; + fm_vsp_params.buf_pool_depletion.pools_grp_mode_enable = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->poolsGrpModeEnable; + fm_vsp_params.buf_pool_depletion.num_pools = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->numOfPools; + fm_vsp_params.buf_pool_depletion.pools_to_consider = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->poolsToConsider; + fm_vsp_params.buf_pool_depletion.single_pool_mode_enable = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->singlePoolModeEnable; + fm_vsp_params.buf_pool_depletion.pools_to_consider_for_single_mode = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->poolsToConsiderForSingleMode; + fm_vsp_params.buf_pool_depletion.has_pfc_priorities = TRUE; + fm_vsp_params.buf_pool_depletion.pfc_priorities_en = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->pfcPrioritiesEn; + } + else + fm_vsp_params.buf_pool_depletion.buf_pool_depletion_enabled = FALSE; + + if (p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools) + { + fm_vsp_params.backup_pools.num_backup_pools = p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools->numOfBackupPools; + fm_vsp_params.backup_pools.pool_ids = p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools->poolIds; + } + else + fm_vsp_params.backup_pools.num_backup_pools = 0; - fm_vsp_params.buf_margins = &p_FmVspEntry->bufMargins; - fm_vsp_params.int_context = &p_FmVspEntry->intContext; + fm_vsp_params.fm_ext_pools.num_pools_used = p_FmVspEntry->extBufPools.numOfPoolsUsed; + fm_vsp_params.fm_ext_pools.ext_buf_pool = (struct fman_ext_pool_params*)&p_FmVspEntry->extBufPools.extBufPool; + fm_vsp_params.buf_margins = (struct fman_sp_buf_margins*)&p_FmVspEntry->bufMargins; + fm_vsp_params.int_context = (struct fman_sp_int_context_data_copy*)&p_FmVspEntry->intContext; /*no check on err - it was checked earlier*/ FmVSPGetAbsoluteProfileId(p_FmVspEntry->h_Fm, @@ -651,8 +545,13 @@ t_Error FM_VSP_Init(t_Handle h_FmVsp) p_FmVspEntry->relativeProfileId, &absoluteProfileId); - /*set all registers related to VSP*/ - fm_vsp_fill_entry(p_FmVspEntry->p_FmSpRegsBase, absoluteProfileId, &fm_vsp_params); + + ASSERT_COND(p_FmVspEntry->p_FmSpRegsBase); + ASSERT_COND(fm_vsp_params.int_context); + ASSERT_COND(fm_vsp_params.buf_margins); + ASSERT_COND(IN_RANGE(0, absoluteProfileId, FM_VSP_MAX_NUM_OF_ENTRIES)); + /* Set all registers related to VSP */ + fman_vsp_init(p_FmVspEntry->p_FmSpRegsBase, absoluteProfileId, &fm_vsp_params,FM_PORT_MAX_NUM_OF_EXT_POOLS, BM_MAX_NUM_OF_POOLS, FM_MAX_NUM_OF_PFC_PRIORITIES); p_FmVspEntry->absoluteSpId = absoluteProfileId; diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/fm_sp.h b/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/fm_sp.h index 30b41b6..9c171d8 100644 --- a/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/fm_sp.h +++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/fm_sp.h @@ -49,52 +49,6 @@ #define __ERR_MODULE__ MODULE_FM_SP - - -/***********************************************************************/ -/* Memory map */ -/***********************************************************************/ -#if defined(__MWERKS__) && !defined(__GNUC__) -#pragma pack(push,1) -#endif /* defined(__MWERKS__) && ... */ - -typedef _Packed struct { - volatile uint32_t fm_sp_ebmpi[FM_PORT_MAX_NUM_OF_EXT_POOLS]; - /*offset 0 - 0xc*/ - /**< Buffer Manager pool Information-*/ - - volatile uint32_t res[8-FM_PORT_MAX_NUM_OF_EXT_POOLS]; - /*offset 0x10 - 0xc*/ - volatile uint32_t fm_sp_acnt; /*offset 0x20*/ - volatile uint32_t fm_sp_ebm; /*offset 0x24*/ - volatile uint32_t fm_sp_da; /*offset 0x28*/ - volatile uint32_t fm_sp_icp; /*offset 0x2c*/ - volatile uint32_t fm_sp_mpd; /*offset 0x30*/ - volatile uint32_t res1[2]; /*offset 0x34 - 0x38*/ - volatile uint32_t fm_sp_spliodn; /*offset 0x3c*/ -} _PackedType fm_pcd_storage_profile_regs; - -#if defined(__MWERKS__) && !defined(__GNUC__) -#pragma pack(pop) -#endif /* defined(__MWERKS__) && ... */ - - -typedef struct fm_storage_profile_params { - t_FmExtPools *fm_ext_pools; - t_FmBackupBmPools *backup_pools; - t_FmSpIntContextDataCopy *int_context; - t_FmSpBufMargins *buf_margins; - - e_FmDmaSwapOption dma_swap_data; - e_FmDmaCacheOption int_context_cache_attr; - e_FmDmaCacheOption header_cache_attr; - e_FmDmaCacheOption scatter_gather_cache_attr; - bool dma_write_optimize; - uint16_t liodn_offset; - bool no_scather_gather; - t_FmBufPoolDepletion *buf_pool_depletion; -} fm_storage_profile_params; - typedef struct { t_FmBufferPrefixContent bufferPrefixContent; e_FmDmaSwapOption dmaSwapData; @@ -122,7 +76,7 @@ typedef struct { e_FmPortType portType; /**< Port type */ uint8_t portId; /**< Port Id - relative to type */ uint8_t relativeProfileId; - fm_pcd_storage_profile_regs *p_FmSpRegsBase; + struct fm_pcd_storage_profile_regs *p_FmSpRegsBase; t_FmExtPools extBufPools; t_FmVspEntryDriverParams *p_FmVspEntryDriverParams; } t_FmVspEntry; diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/fman_sp.c b/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/fman_sp.c new file mode 100755 index 0000000..d1f1467 --- /dev/null +++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/SP/fman_sp.c @@ -0,0 +1,197 @@ +/* + * Copyright 2013 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Freescale Semiconductor nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "fsl_fman_sp.h" + + +uint32_t fman_vsp_get_statistics(struct fm_pcd_storage_profile_regs *regs, + uint16_t index) +{ + struct fm_pcd_storage_profile_regs *sp_regs; + sp_regs = ®s[index]; + return ioread32be(&sp_regs->fm_sp_acnt); +} + +void fman_vsp_set_statistics(struct fm_pcd_storage_profile_regs *regs, + uint16_t index, uint32_t value) +{ + struct fm_pcd_storage_profile_regs *sp_regs; + sp_regs = ®s[index]; + iowrite32be(value, &sp_regs->fm_sp_acnt); +} + +void fman_vsp_defconfig(struct fm_storage_profile_params *cfg) +{ + cfg->dma_swap_data = + DEFAULT_FMAN_SP_DMA_SWAP_DATA; + cfg->int_context_cache_attr = + DEFAULT_FMAN_SP_DMA_INT_CONTEXT_CACHE_ATTR; + cfg->header_cache_attr = + DEFAULT_FMAN_SP_DMA_HEADER_CACHE_ATTR; + cfg->scatter_gather_cache_attr = + DEFAULT_FMAN_SP_DMA_SCATTER_GATHER_CACHE_ATTR; + cfg->dma_write_optimize = + DEFAULT_FMAN_SP_DMA_WRITE_OPTIMIZE; + cfg->no_scather_gather = + DEFAULT_FMAN_SP_NO_SCATTER_GATHER; +} + +static inline uint32_t calc_vec_dep(int max_pools, bool *pools, + struct fman_ext_pools *ext_buf_pools, uint32_t mask) +{ + int i, j; + uint32_t vector = 0; + for (i = 0; i < max_pools; i++) + if (pools[i]) + for (j = 0; j < ext_buf_pools->num_pools_used; j++) + if (i == ext_buf_pools->ext_buf_pool[j].id) { + vector |= mask >> j; + break; + } + return vector; +} + +void fman_vsp_init(struct fm_pcd_storage_profile_regs *regs, + uint16_t index, struct fm_storage_profile_params *fm_vsp_params, + int port_max_num_of_ext_pools, int bm_max_num_of_pools, + int max_num_of_pfc_priorities) +{ + int i = 0, j = 0; + struct fm_pcd_storage_profile_regs *sp_regs; + uint32_t tmp_reg, vector; + struct fman_ext_pools *ext_buf_pools = &fm_vsp_params->fm_ext_pools; + struct fman_buf_pool_depletion *buf_pool_depletion = + &fm_vsp_params->buf_pool_depletion; + struct fman_backup_bm_pools *backup_pools = + &fm_vsp_params->backup_pools; + struct fman_sp_int_context_data_copy *int_context_data_copy = + fm_vsp_params->int_context; + struct fman_sp_buf_margins *external_buffer_margins = + fm_vsp_params->buf_margins; + bool no_scather_gather = fm_vsp_params->no_scather_gather; + uint16_t liodn_offset = fm_vsp_params->liodn_offset; + + sp_regs = ®s[index]; + + /* fill external buffers manager pool information register*/ + for (i = 0; i < ext_buf_pools->num_pools_used; i++) { + tmp_reg = FMAN_SP_EXT_BUF_POOL_VALID | + FMAN_SP_EXT_BUF_POOL_EN_COUNTER; + tmp_reg |= ((uint32_t)ext_buf_pools->ext_buf_pool[i].id << + FMAN_SP_EXT_BUF_POOL_ID_SHIFT); + tmp_reg |= ext_buf_pools->ext_buf_pool[i].size; + /* functionality available only for some deriviatives + (limited by config) */ + for (j = 0; j < backup_pools->num_backup_pools; j++) + if (ext_buf_pools->ext_buf_pool[i].id == + backup_pools->pool_ids[j]) { + tmp_reg |= FMAN_SP_EXT_BUF_POOL_BACKUP; + break; + } + iowrite32be(tmp_reg, &sp_regs->fm_sp_ebmpi[i]); + } + + /* clear unused pools */ + for (i = ext_buf_pools->num_pools_used; + i < port_max_num_of_ext_pools; i++) + iowrite32be(0, &sp_regs->fm_sp_ebmpi[i]); + + /* fill pool depletion register*/ + tmp_reg = 0; + if (buf_pool_depletion->buf_pool_depletion_enabled && buf_pool_depletion->pools_grp_mode_enable) { + /* calculate vector for number of pools depletion */ + vector = calc_vec_dep(bm_max_num_of_pools, buf_pool_depletion-> + pools_to_consider, ext_buf_pools, 0x80000000); + + /* configure num of pools and vector for number of pools mode */ + tmp_reg |= (((uint32_t)buf_pool_depletion->num_pools - 1) << + FMAN_SP_POOL_DEP_NUM_OF_POOLS_SHIFT); + tmp_reg |= vector; + } + + if (buf_pool_depletion->buf_pool_depletion_enabled && buf_pool_depletion->single_pool_mode_enable) { + /* calculate vector for number of pools depletion */ + vector = calc_vec_dep(bm_max_num_of_pools, buf_pool_depletion-> + pools_to_consider_for_single_mode, + ext_buf_pools, 0x00000080); + + /* configure num of pools and vector for number of pools mode */ + tmp_reg |= vector; + } + + /* fill QbbPEV */ + if (buf_pool_depletion->buf_pool_depletion_enabled) { + vector = 0; + for (i = 0; i < max_num_of_pfc_priorities; i++) + if (buf_pool_depletion->pfc_priorities_en[i] == TRUE) + vector |= 0x00008000 >> i; + tmp_reg |= vector; + } + iowrite32be(tmp_reg, &sp_regs->fm_sp_mpd); + + /* fill dma attributes register */ + tmp_reg = 0; + tmp_reg |= (uint32_t)fm_vsp_params->dma_swap_data << + FMAN_SP_DMA_ATTR_SWP_SHIFT; + tmp_reg |= (uint32_t)fm_vsp_params->int_context_cache_attr << + FMAN_SP_DMA_ATTR_IC_CACHE_SHIFT; + tmp_reg |= (uint32_t)fm_vsp_params->header_cache_attr << + FMAN_SP_DMA_ATTR_HDR_CACHE_SHIFT; + tmp_reg |= (uint32_t)fm_vsp_params->scatter_gather_cache_attr << + FMAN_SP_DMA_ATTR_SG_CACHE_SHIFT; + if (fm_vsp_params->dma_write_optimize) + tmp_reg |= FMAN_SP_DMA_ATTR_WRITE_OPTIMIZE; + iowrite32be(tmp_reg, &sp_regs->fm_sp_da); + + /* IC parameters - fill internal context parameters register */ + tmp_reg = 0; + tmp_reg |= (((uint32_t)int_context_data_copy->ext_buf_offset/ + OFFSET_UNITS) << FMAN_SP_IC_TO_EXT_SHIFT); + tmp_reg |= (((uint32_t)int_context_data_copy->int_context_offset/ + OFFSET_UNITS) << FMAN_SP_IC_FROM_INT_SHIFT); + tmp_reg |= (((uint32_t)int_context_data_copy->size/OFFSET_UNITS) << + FMAN_SP_IC_SIZE_SHIFT); + iowrite32be(tmp_reg, &sp_regs->fm_sp_icp); + + /* buffer margins - fill external buffer margins register */ + tmp_reg = 0; + tmp_reg |= (((uint32_t)external_buffer_margins->start_margins) << + FMAN_SP_EXT_BUF_MARG_START_SHIFT); + tmp_reg |= (((uint32_t)external_buffer_margins->end_margins) << + FMAN_SP_EXT_BUF_MARG_END_SHIFT); + if (no_scather_gather) + tmp_reg |= FMAN_SP_SG_DISABLE; + iowrite32be(tmp_reg, &sp_regs->fm_sp_ebm); + + /* buffer margins - fill spliodn register */ + iowrite32be(liodn_offset, &sp_regs->fm_sp_spliodn); +} |