/* <:copyright-broadcom Copyright (c) 2002 Broadcom Corporation All Rights Reserved No portions of this material may be reproduced in any form without the written permission of: Broadcom Corporation 16215 Alton Parkway Irvine, California 92619 All information contained in this document is Broadcom Corporation company private, proprietary, and trade secret. :> */ //************************************************************************** // File Name : Adsl.c // // Description: This file contains API for ADSL PHY // //************************************************************************** #ifdef _WIN32_WCE #include <windows.h> #include <types.h> #include <ceddk.h> #include <memory.h> #include <linklist.h> #include <nkintr.h> #include <hwcomapi.h> #include <devload.h> #include <pm.h> #elif defined(_CFE_) #include "lib_types.h" #include "lib_string.h" #include "lib_printf.h" #include "boardparms.h" #elif defined(TARG_OS_RTEMS) #include <alloc.h> #include <xapi.h> #include "types.h" #include "bspcfg.h" #define ulong unsigned long #else #include <linux/version.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/wait.h> #include <linux/timer.h> #include <linux/interrupt.h> #include <linux/jiffies.h> #include "boardparms.h" #endif #ifndef _WIN32_WCE #include "bcmtypes.h" #endif #include "softdsl/AdslCoreDefs.h" #include "BcmOs.h" #include "board.h" #if defined(CONFIG_BCM96338) #include "6338_map.h" #endif #if defined(CONFIG_BCM96358) #include "6358_map.h" #endif #if defined(CONFIG_BCM96348) #include "6348_map.h" #endif #if !defined(TARG_OS_RTEMS) #include "bcm_intr.h" #endif #include "bcmadsl.h" #include "BcmAdslCore.h" #if !defined(__KERNEL__) #define KERNEL_VERSION(a,b,c) 0x7fffffff #endif extern void BcmAdslCoreDiagWriteStatusString(char *fmt, ...); #if !defined(TARG_OS_RTEMS) LOCAL void *g_TimerHandle; LOCAL void BcmAdsl_Status(void); LOCAL void BcmAdsl_Timer(void * arg); #else #define calloc(L,X) xmalloc(L) #define free(P) xfree(P) extern void AdslLinkReset(void); LOCAL OS_SEMID g_StatusSemId; LOCAL OS_TASKID g_StatusTid; LOCAL void StatusTask(void); #endif #ifdef VDF_SPAIN int g_ulAdslCuts = 0; int g_ulAdslOnLineStart = 0; #endif LOCAL void IdleNotifyCallback (ADSL_LINK_STATE AdslLinkState, UINT32 ulParm) { } #define ADSL_RJ11_INNER_PAIR 0 #define ADSL_RJ11_OUTER_PAIR 1 LOCAL void SetRj11Pair( UINT16 usPairToEnable, UINT16 usPairToDisable ); LOCAL ADSL_FN_NOTIFY_CB g_pFnNotifyCallback = IdleNotifyCallback; LOCAL UINT32 g_ulNotifyCallbackParm; ADSL_LINK_STATE g_LinkState; LOCAL unsigned short g_GpioInnerPair = 0xffff; LOCAL unsigned short g_GpioOuterPair = 0xffff; LOCAL unsigned short g_BoardType; LOCAL int g_RJ11Pair = ADSL_RJ11_INNER_PAIR; #ifndef DYING_GASP_API #if defined(__KERNEL__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) LOCAL irqreturn_t BcmDyingGaspIsr(int irq, void * dev_id, struct pt_regs * regs); #else LOCAL unsigned int BcmDyingGaspIsr( void ); #endif #endif int g_nAdslExit = 0; int g_nAdslInitialized = 0; //LGD_FOR_TR098 unsigned long g_ShowtimeStartTicks = 0; #ifdef _WIN32_WCE BCMADSL_STATUS BcmAdsl_Initialize(ADSL_FN_NOTIFY_CB pFnNotifyCb, UINT32 ulParm, adslCfgProfile *pAdslCfg) { DEBUGMSG (DBG_MSG, (TEXT("BcmAdsl_Initialize=0x%08X, &g_nAdslExit=0x%08X\n"), (int)BcmAdsl_Initialize, (int) &g_nAdslExit)); BcmOsInitialize (); g_pFnNotifyCallback = (pFnNotifyCb != NULL) ? pFnNotifyCb : IdleNotifyCallback; g_ulNotifyCallbackParm = ulParm; //BcmAdslCoreSetSDRAMBaseAddr((void *) (((ulong) kerSysGetSdramSize() - 0x40000) | 0xA0000000)); BcmAdslCoreSetSDRAMBaseAddr((void *) ((0x800000 - 0x40000) | 0xA0000000)); BcmAdslCoreConfigure(pAdslCfg); BcmAdslCoreInit(); g_LinkState = BCM_ADSL_LINK_DOWN; g_nAdslExit = 0; g_nAdslInitialized = 1; g_TimerHandle = bcmOsTimerCreate(BcmAdsl_Timer, NULL); if (NULL != g_TimerHandle) bcmOsTimerStart(g_TimerHandle, 1000); return BCMADSL_STATUS_SUCCESS; } #elif !defined(TARG_OS_RTEMS) //************************************************************************** // Function Name: BcmAdsl_Initialize // Description : Initializes ADSL PHY. // Returns : STS_SUCCESS if successful or error status. //************************************************************************** BCMADSL_STATUS BcmAdsl_Initialize(ADSL_FN_NOTIFY_CB pFnNotifyCb, UINT32 ulParm, adslCfgProfile *pAdslCfg) { printk("BcmAdsl_Initialize=0x%08X, g_pFnNotifyCallback=0x%08X\n", (int)BcmAdsl_Initialize, (int) &g_pFnNotifyCallback); if (g_nAdslInitialized != 0) { BcmAdslCoreConfigure(pAdslCfg); return BCMADSL_STATUS_SUCCESS; } BcmOsInitialize (); #ifndef DYING_GASP_API { unsigned long ulIntr; #if defined(CONFIG_BCM963x8) #if defined(__KERNEL__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) if( BpGetAdslDyingGaspExtIntr( &ulIntr ) == BP_SUCCESS ) #endif { BcmHalMapInterrupt((void *)BcmDyingGaspIsr, 0, INTERRUPT_ID_DG); BcmHalInterruptEnable( INTERRUPT_ID_DG ); } #endif } #endif if( BpGetRj11InnerOuterPairGpios(&g_GpioInnerPair, &g_GpioOuterPair) == BP_SUCCESS ) { g_GpioInnerPair = GPIO_NUM_TO_MASK(g_GpioInnerPair); g_GpioOuterPair = GPIO_NUM_TO_MASK(g_GpioOuterPair); } else { g_GpioInnerPair = 0xffff; g_GpioOuterPair = 0xffff; } g_BoardType = 0; g_pFnNotifyCallback = (pFnNotifyCb != NULL) ? pFnNotifyCb : IdleNotifyCallback; g_ulNotifyCallbackParm = ulParm; BcmAdslCoreSetSDRAMBaseAddr((void *) (((unsigned long) kerSysGetSdramSize() - 0x40000) | 0xA0000000)); BcmAdslCoreConfigure(pAdslCfg); BcmAdslCoreInit(); g_LinkState = BCM_ADSL_LINK_DOWN; g_nAdslExit = 0; g_nAdslInitialized = 1; g_TimerHandle = bcmOsTimerCreate(BcmAdsl_Timer, NULL); if (NULL != g_TimerHandle) bcmOsTimerStart(g_TimerHandle, 1000); return BCMADSL_STATUS_SUCCESS; } #else /* defined(TARG_OS_RTEMS) */ BCMADSL_STATUS BcmAdsl_Initialize(ADSL_FN_NOTIFY_CB pFnNotifyCb, UINT32 ulParm, adslCfgProfile *pAdslCfg) { typedef void (*FN_HDLR) (unsigned long); BcmOsInitialize (); #if 0 /* The interrupt handling of the Dying gasp is controlled external */ BcmHalMapInterrupt((FN_HDLR)BcmDyingGaspIsr, 0, INTERRUPT_ID_DYING_GASP); BcmHalInterruptEnable( INTERRUPT_ID_DYING_GASP ); #if defined(BOARD_bcm96348) || defined(BOARD_bcm96338) BcmHalMapInterrupt((FN_HDLR)BcmDyingGaspIsr, 0, INTERRUPT_ID_DG); BcmHalInterruptEnable( INTERRUPT_ID_DG ); #endif #endif g_pFnNotifyCallback = (pFnNotifyCb != NULL) ? pFnNotifyCb : IdleNotifyCallback; g_BoardType = 0; g_ulNotifyCallbackParm = ulParm; bcmOsSemCreate(NULL, &g_StatusSemId); /* kerSysGetSdramSize subtracts the size reserved for the ADSL MIPS */ BcmAdslCoreSetSDRAMBaseAddr((void *) ((unsigned long) kerSysGetSdramSize() | 0xA0000000)); BcmAdslCoreConfigure(pAdslCfg); BcmAdslCoreInit(); g_LinkState = BCM_ADSL_LINK_DOWN; g_nAdslExit = 0; g_nAdslInitialized = 1; bcmOsTaskCreate("ADSL", 20*1024, 50, StatusTask, 0, &g_StatusTid); return BCMADSL_STATUS_SUCCESS; }
/* Only called from the Host MIPS - Sept 2010 */ void bcmPktDma_BcmHalInterruptEnable(int channel, int irq) { #if !(defined(CONFIG_BCM_FAP) || defined(CONFIG_BCM_FAP_MODULE)) BcmHalInterruptEnable(irq); #else #if defined(CONFIG_BCM_PKTDMA_RX_SPLITTING) if(g_Eth_rx_iudma_ownership[channel] == HOST_OWNED) { BcmHalInterruptEnable(irq); } #endif #endif return; }
//************************************************************************** // Function Name: BcmAdsl_Initialize // Description : Initializes ADSL PHY. // Returns : STS_SUCCESS if successful or error status. //************************************************************************** BCMADSL_STATUS BcmAdsl_Initialize(ADSL_FN_NOTIFY_CB pFnNotifyCb, UINT32 ulParm, adslCfgProfile *pAdslCfg) { printk("BcmAdsl_Initialize=0x%08X, g_pFnNotifyCallback=0x%08X\n", (int)BcmAdsl_Initialize, (int) &g_pFnNotifyCallback); if (g_nAdslInitialized != 0) { BcmAdslCoreConfigure(pAdslCfg); return BCMADSL_STATUS_SUCCESS; } BcmOsInitialize (); #ifndef DYING_GASP_API { unsigned long ulIntr; #if defined(CONFIG_BCM963x8) #if defined(__KERNEL__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) if( BpGetAdslDyingGaspExtIntr( &ulIntr ) == BP_SUCCESS ) #endif { BcmHalMapInterrupt((void *)BcmDyingGaspIsr, 0, INTERRUPT_ID_DG); BcmHalInterruptEnable( INTERRUPT_ID_DG ); } #endif } #endif if( BpGetRj11InnerOuterPairGpios(&g_GpioInnerPair, &g_GpioOuterPair) == BP_SUCCESS ) { g_GpioInnerPair = GPIO_NUM_TO_MASK(g_GpioInnerPair); g_GpioOuterPair = GPIO_NUM_TO_MASK(g_GpioOuterPair); } else { g_GpioInnerPair = 0xffff; g_GpioOuterPair = 0xffff; } g_BoardType = 0; g_pFnNotifyCallback = (pFnNotifyCb != NULL) ? pFnNotifyCb : IdleNotifyCallback; g_ulNotifyCallbackParm = ulParm; BcmAdslCoreSetSDRAMBaseAddr((void *) (((unsigned long) kerSysGetSdramSize() - 0x40000) | 0xA0000000)); BcmAdslCoreConfigure(pAdslCfg); BcmAdslCoreInit(); g_LinkState = BCM_ADSL_LINK_DOWN; g_nAdslExit = 0; g_nAdslInitialized = 1; g_TimerHandle = bcmOsTimerCreate(BcmAdsl_Timer, NULL); if (NULL != g_TimerHandle) bcmOsTimerStart(g_TimerHandle, 1000); return BCMADSL_STATUS_SUCCESS; }
int spu_process_ipsec(struct spu_trans_req *trans_req, BCM_CRYPTOOP *op) { CCH_SCTX cch_sctx; #ifdef SPU_DEBUG SCTX *sctx = &cch_sctx.sctx; #endif CCH *cch = &cch_sctx.cch; uint16_t sctxSize = 0, sauSize = 0, spdSize = 0; uint16_t tunnelSize = 0, encapSize = 0; uint16_t supdtFrag = 0, spsFrag = 0, bctFrag = 0; #if 0 SCTX_OUTSAU *outsau = NULL; SCTX_INSAU *insau = NULL; #endif SACTX DEV_SA; SACTX *devsa = &DEV_SA; int status = 0; BDESC bufDesc; int spu_cmd_offset = 0; u_int8_t *spu_cmd_ptr = NULL; unsigned long irq_flags; int offset; SPU_DATA_DUMP("spu_process_ipsec-sbuf", trans_req->sfrags_list->buf, trans_req->sfrags_list->len); SPU_DATA_DUMP("spu_process_ipsec-dbuf", trans_req->dfrags_list->buf, trans_req->dfrags_list->len); SPU_DATA_DUMP("ency/decrypt", op->encrKey, op->encrKeyLen); SPU_DATA_DUMP("auth", op->authKey, op->authKeyLen); memset(devsa, 0, sizeof(SACTX)); devsa->flags.proto = op->flags.proto; devsa->flags.dir = op->flags.dir; if(devsa->flags.dir == BCMSAD_DIR_INBOUND) pdev_ctrl->stats.numOfDecryptions++; else pdev_ctrl->stats.numOfEncryptions++; status = spu_SCTXSA_getsize (op, &sctxSize); if(status != BCM_STATUS_OK) { SPU_TRACE(("spu_SCTXSA_getsize error %d\n", status)); return status;; } status = spu_cch_sctx_init (op, &cch_sctx, devsa, sctxSize, &supdtFrag, &spsFrag, &tunnelSize, &encapSize, &sauSize, &spdSize); if(status != BCM_STATUS_OK) { SPU_TRACE(("spu_cch_sctx_init error %d\n", status)); return status; } cch->ech = (uint32)trans_req; /* Estimate the size of the BCT input fragment */ if (op->flags.dir == BCMSAD_DIR_INBOUND) { if (op->encrAlg != BCMSAD_ENCR_ALG_NULL) { bctFrag = 2 * devsa->ivLen; } else if (op->flags.proto == BCMSAD_PROTOCOL_ESP) { /* esp but not ah ie esp_null */ bctFrag = 16; } } SPU_TRACE(("Creating SA sizes: total %d sctxSize %d " "sauSize %d spdSize %d tunnelSize %d encapSize %d\n", sctx->protocol.ipsec_flags.SCTX_size * 4, sctxSize, sauSize, spdSize, tunnelSize, encapSize)); spu_cmd_ptr = (unsigned char *)&trans_req->cmd_buf[0]; devsa->dmaStatus = (void *)(spu_cmd_ptr + BCM_XTRA_DMA_HDR_SIZE); /* Copy the DMA context for this SA */ /* Copy SCTX proto, SCTX cipher, SCTX ecf words */ spu_cmd_offset = sizeof (CCH_SCTX); status = spu_auth_init (spu_cmd_ptr, &spu_cmd_offset, op); if(status != BCM_STATUS_OK) { SPU_TRACE(("spu_auth_init error %d\n", status)); return status; } /* Copy the encryption keys */ if (op->encrKeyLen) { if (op->encrKeyLen <= BCMSAD_ENCR_KEYLEN_MAX) { CTX_COPY ((uint8_t *) spu_cmd_ptr + spu_cmd_offset, op->encrKey, op->encrKeyLen); } else { status = BCM_STATUS_INVALID_INPUT; printk (KERN_ERR "bad encrKeyLen %d\n", op->encrKeyLen); return status; } spu_cmd_offset += op->encrKeyLen; } #if 0 status = spu_sa_init (spu_cmd_ptr, &spu_cmd_offset, op, insau, &sauSize); if(status != BCM_STATUS_OK) { SPU_TRACE(("spu_sa_init error %d\n", status)); return status; } #endif status = spu_spd_init (spu_cmd_ptr, &spu_cmd_offset, op, &spdSize, devsa); if(status != BCM_STATUS_OK) { SPU_TRACE(("spu_spd_init error %d\n", status)); return status; } /* Copy the tunnel header for outbound tunnel mode only */ if (tunnelSize) { CTX_COPY ((uint8_t *) spu_cmd_ptr + spu_cmd_offset, devsa->out.tunnelHeader, tunnelSize); spu_cmd_offset += tunnelSize; SPU_DATA_DUMP("Tunnel header", devsa->out.tunnelHeader, tunnelSize); } /* Copy CCH words */ memcpy ((uint8_t *) spu_cmd_ptr, (uint8_t *) &cch_sctx, sizeof (CCH_SCTX)); /* Add input fragments */ if (bctFrag) { devsa->bctIFrag = 1; devsa->bctLen = bctFrag; } devsa->inputFrags = devsa->bctIFrag; /* Add output fragments */ /* Always have a status fragment */ devsa->statusOFrag = 1; #ifdef BCMAPI_USE_SPS_FRAGMENT /* Add the SPS context for inbound SA only */ if (spsFrag) { devsa->spsOFrag = 1; devsa->spsFragLen = spsFrag; } #endif /* Add the SUPDT fragment context if any */ if (supdtFrag) { devsa->updateOFrag = 1; devsa->updateFragLen = supdtFrag; } #ifdef BCMAPI_USE_HASH_FRAGMENT if (op->authAlg != BCMSAD_AUTH_ALG_NONE) { if (op->flags.dir == BCMSAD_DIR_INBOUND) { devsa->authOFrag = 1; } } #endif devsa->outputFrags = devsa->authOFrag + devsa->statusOFrag + devsa->updateOFrag + devsa->icvOFrag + devsa->spsOFrag; /* Sanity check */ if (spu_cmd_offset != (sctxSize + sizeof(CCH))) { status = BCM_STATUS_INVALID_INPUT; SPU_TRACE(("context size mismatch %d:%d\n", spu_cmd_offset, (sctxSize + sizeof(CCH)))); return status; } SPU_TRACE(("Static Context at %p current size %d currentDmaOfst %d\n", spu_cmd_ptr, cch_sctx.cch.length, spu_cmd_offset)); #if 0 status = spu_ipsec_hdr_init (spu_cmd_ptr, &spu_cmd_offset, op, &encapSize, insau, outsau, devsa); if(status != BCM_STATUS_OK) { SPU_TRACE(("spu_ipsec_hdr_init error %d\n", status)); return status; } #endif if (op->flags.proto == BCMSAD_PROTOCOL_ESP) { /* for ESP this is the offset to the MAC */ offset = trans_req->headerLen - devsa->ivLen - SIZE_ESP_HEADER; } else { /* for AH this is the offset to the ICV for inbound */ offset = trans_req->headerLen; } status = spu_buff_desc_init (spu_cmd_ptr, &spu_cmd_offset, &bufDesc, op, offset, trans_req->slen, devsa, cch); if(status != BCM_STATUS_OK) { SPU_TRACE(("spu_buff_desc_init error %d\n", status)); return status; } WARN_ON(spu_cmd_offset >= BCM_XTRA_DMA_HDR_SIZE); SPU_TRACE(("Message header length %d hdrLen %d\n", cch_sctx.cch.length, spu_cmd_offset)); spin_lock_irqsave (&pdev_ctrl->spin_lock, irq_flags); /* verify there are enough RX and TX descriptors */ if ( 0 == spu_avail_desc(trans_req) ) { spin_unlock_irqrestore (&pdev_ctrl->spin_lock, irq_flags); return BCM_STATUS_RESOURCE; } status = spu_format_output (trans_req->dfrags_list, trans_req->dfrags, devsa, op); if(status != BCM_STATUS_OK) { SPU_TRACE(("spu_format_output error %d\n", status)); spin_unlock_irqrestore (&pdev_ctrl->spin_lock, irq_flags); return status; } status = spu_format_input (spu_cmd_ptr, &spu_cmd_offset, trans_req->sfrags_list, trans_req->sfrags, devsa); if(status != BCM_STATUS_OK) { SPU_TRACE(("spu_format_input error %d\n", status)); spin_unlock_irqrestore (&pdev_ctrl->spin_lock, irq_flags); return status; } trans_req->numtxbds = (trans_req->sfrags + 2); spin_unlock_irqrestore (&pdev_ctrl->spin_lock, irq_flags); BcmHalInterruptEnable(pdev_ctrl->rx_irq); pdev_ctrl->tx_dma->cfg |= DMA_ENABLE; pdev_ctrl->rx_dma->cfg |= DMA_ENABLE; return status; }/* spu_process_ipsec_esp */
/*************************************************************************** * Function Name: spu_perform_test * Description : Tests for the hardware to do encrypt * or decrypt operation * Returns : N/A ***************************************************************************/ void spu_perform_test(uint32 tx_pkt_id, uint32 num_pkts) { int ntries = 0; #ifdef DISABLE_ENGINES unsigned long aes_enable; #endif uint16 rx_index; int done = 1; printk (KERN_ERR "IPSEC SPU: do_encrypt\n"); #if AES_MD5 printk (KERN_ERR "IPSEC SPU: AES MD5 TEST\n"); #endif #if AES_SHA1 printk (KERN_ERR "IPSEC SPU: AES SHA1 TEST\n"); #endif #if DES_MD5 printk (KERN_ERR "IPSEC SPU: DES MD5 TEST\n"); #endif #if DES_SHA1 printk (KERN_ERR "IPSEC SPU: DES SHA1 TEST\n"); #endif #if DES3_MD5 printk (KERN_ERR "IPSEC SPU: DES3 MD5 TEST\n"); #endif #if DES3_SHA1 printk (KERN_ERR "IPSEC SPU: DES3 SHA1 TEST\n"); #endif if (tx_pkt_id > MAX_PKT_ID || num_pkts > MAX_PKTS_PER_TEST) { return; } #ifdef DISABLE_ENGINES printk (KERN_ERR "IPSEC SPU: Disabling AES, DES, HASH engines 0x%08x\n", SPU_CTRL); aes_enable = SPU_CTRL; /* Disable AES, DES/3DES and HASH */ //aes_enable = (1 << 8) | (1 << 9) | (1 << 10); /* Disable DES/3DES and HASH */ aes_enable = (1 << 9) | (1 << 10); SPU_CTRL = aes_enable; printk (KERN_ERR "IPSEC SPU: AES, DES, HASH Disabled 0x%08x\n", SPU_CTRL); #endif num_tests_failed = num_tests_passed = 0; do { /* * Setup the rx and tx buffer. */ rx_index = ipsec_setup_tx_rx (tx_pkt_id, &done); /* * Enable the DMA. */ //retry: pdev_ctrl->rx_dma->cfg |= DMA_ENABLE; pdev_ctrl->tx_dma->cfg |= DMA_ENABLE; BcmHalInterruptEnable (pdev_ctrl->rx_irq); #ifdef SPU_DEBUG printk (KERN_ERR "IPSEC SPU: Done Enabling Tx %p %lx and Rx %p %lx DMA\n", &(pdev_ctrl->tx_dma->cfg), pdev_ctrl->tx_dma->cfg, &(pdev_ctrl->rx_dma->cfg), pdev_ctrl->rx_dma->cfg); printk (KERN_ERR "IPSEC SPU: Tx Chn BaseDesc %lx st data %lx " "len status %lx bufptr %lx\n", pdev_ctrl->dma_ctrl->stram.s[1].baseDescPtr, pdev_ctrl->dma_ctrl->stram.s[1].state_data, pdev_ctrl->dma_ctrl->stram.s[1].desc_len_status, pdev_ctrl->dma_ctrl->stram.s[1].desc_base_bufptr); printk (KERN_ERR "IPSEC SPU: Rx Chn BaseDesc %lx st data %lx " "len status %lx bufptr %lx\n", pdev_ctrl->dma_ctrl->stram.s[0].baseDescPtr, pdev_ctrl->dma_ctrl->stram.s[0].state_data, pdev_ctrl->dma_ctrl->stram.s[0].desc_len_status, pdev_ctrl->dma_ctrl->stram.s[0].desc_base_bufptr); printk (KERN_ERR "IPSEC SPU: DMA CTRL Global Interrupt Status %lx " "Mask %lx\n", pdev_ctrl->dma_ctrl->ctrl_global_interrupt_status, pdev_ctrl->dma_ctrl->ctrl_global_interrupt_mask); #endif start = spu_get_cycle_count(); /* * Unblocked so check the Rx with the template and * print the verdict. But first compute the elapsed * time in usecs. */ if (end < start) { proc_time = (0xFFFFFFFF - start) + end; } else { proc_time = end - start; } proc_time = proc_time / spu_cycle_per_us; encrypt_decrypt_verify(tx_pkt_id, rx_index); dump_output (rx_index); start = end = proc_time = 0; xmit_pkt_len = recv_pkt_len = 0; ntries = 0; num_pkts--; tx_pkt_id++; } while (done && num_pkts); printk("Num Tests %d Failed %d Passed %d\n", (num_tests_passed + num_tests_failed), num_tests_failed, num_tests_passed); }
void ethsw_phy_read_reg(int phy_id, int reg, uint16 *data, int ext_bit) { uint32 reg_value; int is6829 = 0, in_interrupt = 0; #if defined(CONFIG_BCM96816) if ( IsExt6829(phy_id) ) { is6829 = 1; } #endif phy_id &= BCM_PHY_ID_M; reg_value = 0; if (in_interrupt()) { in_interrupt = 1; } /* Disable Phy interrupt so Phy ISR will not enter this function while a transaction is in progress. Will need similar protection if there is ever a need to access phy in another interrupt context (like the packet rx isr (napi)). We can use spin_lock_irqsave but the phy access takes >50uS and it disables all the interrupts on the local CPU(not just the Phy interrupt) */ if (!in_interrupt) { #if !defined(CONFIG_BCM96818) || (defined(CONFIG_BCM96818) && defined(CONFIG_BRCM_6818_ON_6816)) BcmHalInterruptDisable(INTERRUPT_ID_EPHY); #endif #if defined(CONFIG_BCM963268) BcmHalInterruptDisable(INTERRUPT_ID_GPHY); #endif #if defined(CONFIG_BCM96828) BcmHalInterruptDisable(INTERRUPT_ID_GPHY0); BcmHalInterruptDisable(INTERRUPT_ID_GPHY1); #endif } atomic_inc(&phy_read_ref_cnt); spin_lock(&bcm_ethlock_phy_access); ethsw_wreg_ext(PAGE_CONTROL, REG_MDIO_CTRL_ADDR, (uint8 *)®_value, 4, is6829); reg_value = (ext_bit? REG_MDIO_CTRL_EXT: 0) | (REG_MDIO_CTRL_READ) | ((phy_id << REG_MDIO_CTRL_ID_SHIFT) & REG_MDIO_CTRL_ID_MASK) | (reg << REG_MDIO_CTRL_ADDR_SHIFT); ethsw_wreg_ext(PAGE_CONTROL, REG_MDIO_CTRL_ADDR, (uint8 *)®_value, 4, is6829); if (irqs_disabled() || (preempt_count() != 0)) { udelay(60); } else { msleep(1); } ethsw_rreg_ext(PAGE_CONTROL, REG_MDIO_DATA_ADDR, (uint8 *)data, 2, is6829); spin_unlock(&bcm_ethlock_phy_access); atomic_dec(&phy_read_ref_cnt); if (!in_interrupt) { if (atomic_read(&phy_read_ref_cnt) == 0) { #if !defined(CONFIG_BCM96818) || (defined(CONFIG_BCM96818) && defined(CONFIG_BRCM_6818_ON_6816)) BcmHalInterruptEnable(INTERRUPT_ID_EPHY); #endif #if defined(CONFIG_BCM963268) BcmHalInterruptEnable(INTERRUPT_ID_GPHY); #endif #if defined(CONFIG_BCM96828) BcmHalInterruptEnable(INTERRUPT_ID_GPHY0); BcmHalInterruptEnable(INTERRUPT_ID_GPHY1); #endif } } }