Пример #1
0
Файл: dma.c Проект: ariavie/bcm
uint32
pcid_dcb_store(pcid_info_t *pcid_info, uint32 addr, dcb_t *dcb)
{
    int	    size, i;
    uint32  *temp;

    size = SOC_DCB_SIZE(pcid_info->unit);
    
    /* Convert to CPU endian-ness */
    temp = (uint32 *)dcb;
    for (i=0; i < (size/sizeof(uint32)); i++) {
        *(temp + i) = soc_internal_endian_swap(pcid_info, *(temp + i), 
                                               MF_ES_DMA_OTHER);
    }

    soc_internal_bytes_store(pcid_info, addr, (void *)dcb, size);
    
    /* Convert back to chip(host) endian-ness */
    for (i=0; i < (size/sizeof(uint32)); i++) {
        *(temp + i) = soc_internal_endian_swap(pcid_info, *(temp + i), 
                                               MF_ES_DMA_OTHER);
    }

#ifdef BROADCOM_DEBUG
    if (LOG_CHECK(BSL_LS_SOC_DMA | BSL_INFO)) {
	SOC_DCB_DUMP(pcid_info->unit, dcb, "PCID Store", 1);
    }
#endif /* BROADCOM_DEBUG */

    return addr + size;
}
Пример #2
0
Файл: dma.c Проект: ariavie/bcm
uint32
pcid_dcb_fetch(pcid_info_t *pcid_info, uint32 addr, dcb_t *dcb)
{
    int     size, i;
    uint32  *temp;

    LOG_INFO(BSL_LS_SOC_DMA,
             (BSL_META("Reading descriptor at 0x%08x\n"), addr));

    size = SOC_DCB_SIZE(pcid_info->unit);
    soc_internal_bytes_fetch(pcid_info, addr, (uint8 *)dcb, size);

    /* Convert to chip(same as host for sim mode) endian-ness */
    temp = (uint32 *)dcb;
    for (i=0; i < (size/sizeof(uint32)); i++) {
        *(temp + i) = soc_internal_endian_swap(pcid_info, *(temp + i), 
                                               MF_ES_DMA_OTHER);
    }

#ifdef BROADCOM_DEBUG
    if (LOG_CHECK(BSL_LS_SOC_DMA | BSL_INFO)) {
	SOC_DCB_DUMP(pcid_info->unit, dcb, "PCID Fetch", 0);
    }
#endif /* BROADCOM_DEBUG */

    return addr + size;
}
Пример #3
0
/*
 * Configure MACSEC print function for debug.
 */
int bcm_common_macsec_config_print(uint32 level)
{
    int rv = BCM_E_NONE;
    uint32  flag = BMACSEC_PRINT_PRINTF;

#if defined(BROADCOM_DEBUG)
    if (LOG_CHECK(BSL_LS_BCM_MACSEC | BSL_INFO)) {
        flag |= BMACSEC_PRINT_DEBUG;
    }
#endif /* BROADCOM_DEBUG */

    rv = bmacsec_config_print_set(flag, bsl_printf);
    return BCM_ERROR(rv);
}
Пример #4
0
NS_IMETHODIMP
nsContentPolicy::ShouldProcess(PRUint32          contentType,
                               nsIURI           *contentLocation,
                               nsIURI           *requestingLocation,
                               nsISupports      *requestingContext,
                               const nsACString &mimeType,
                               nsISupports      *extra,
                               PRInt16          *decision)
{
    nsresult rv = CheckPolicy(&nsIContentPolicy::ShouldProcess, contentType,
                              contentLocation, requestingLocation,
                              requestingContext, mimeType, extra, decision);
    LOG_CHECK("ShouldProcess");

    return rv;
}
Пример #5
0
NS_IMETHODIMP
nsContentPolicy::ShouldLoad(PRUint32          contentType,
                            nsIURI           *contentLocation,
                            nsIURI           *requestingLocation,
                            nsISupports      *requestingContext,
                            const nsACString &mimeType,
                            nsISupports      *extra,
                            PRInt16          *decision)
{
    // ShouldProcess does not need a content location, but we do
    NS_PRECONDITION(contentLocation, "Must provide request location");
    nsresult rv = CheckPolicy(&nsIContentPolicy::ShouldLoad, contentType,
                              contentLocation, requestingLocation,
                              requestingContext, mimeType, extra, decision);
    LOG_CHECK("ShouldLoad");

    return rv;
}
Пример #6
0
STATUS
socend_send(_END_OBJ_PAR *p, M_BLK_ID mb)
/*
 * Function: 	socend_send
 * Purpose:	SENS send packet interface to SOC device.
 * Parameters:	p - pointer to VxWorks end_obj structure for device
 *		mb - mBlk containing packet.
 * Returns:	OK/ERROR
 *
 * Notes: Since since we don't have scatter/gather capability right
 *	  now, we must copy up the data into one clustered buffer.
 *	  If Possible, we simply hand off the buffer.
 */
{
    int			rv;
    struct end_object 	*eo = (struct end_object *)p;
    socend_t 		*se = (socend_t *)eo->devObject.pDevice;
    char		*packet;
    int			l;
    enet_hdr_t		*eh;
    void *cookie;
    bcm_pkt_t *pkt;

    if (NULL == (pkt = sal_alloc(sizeof(bcm_pkt_t), "bcm pkt"))) {
        return(ENOMEM);
    }

    /*
     * If there is more than one cluster, we must allocate another
     * buffer and copy the data.
     *
     * Note: Requires entire ethernet header to be in first mblk.
     */

    if (mb->mBlkHdr.mNext|| !ENET_TAGGED((enet_hdr_t *)mb->mBlkHdr.mData)) {
        if (SOC_IS_ESW(se->se_unit)) {
            socend_packet_alloc(se->se_unit,SOC_END_PK_SZ, 0, (void*)&packet);
        } else {
            packet = soc_cm_salloc(se->se_unit, SOC_END_PK_SZ, 
                            "SOCEND_TX");
        }
        if (NULL == (packet)) {
            END_ERR_ADD(eo, MIB2_OUT_ERRS, +1);
            netMblkClChainFree(mb);
            return(ENOMEM);
        }

	cookie = NULL;
	/*
	 * If packet is not tagged, build a tag now.
	 */
	eh = (enet_hdr_t *)packet;
	if (!ENET_TAGGED((enet_hdr_t *)mb->mBlkHdr.mData)) {

	  
	  /* Set COS to default here */
	    l = ENET_TAG_SIZE +
		netMblkToBufCopy(mb, packet + ENET_TAG_SIZE, NULL);
	    /* Copy MAC addresses */
	    sal_memcpy(eh, mb->mBlkHdr.mData, sizeof(sal_mac_addr_t) * 2);

	    /* Set VLAN info */
	    eh->en_tag_tpid = htons(ENET_DEFAULT_TPID);
	    eh->en_tag_ctrl = htons(VLAN_CTRL(0,0,se->se_vlan));
	    eh->en_tag_len  =
		((enet_hdr_t *)mb->mBlkHdr.mData)->en_untagged_len;
	} else {
	    /* Just copy entire packet */
	  
	  /* Extract priority and map to COS here */
	    l = netMblkToBufCopy(mb, packet, NULL);
	}

	if (set_target_broadcast &&
	    sal_memcmp(eh->en_dhost, eh->en_shost, 6) == 0) {
	    sal_memcpy(eh->en_dhost, mac_ones, 6);
	}
	netMblkClChainFree(mb);		/* Free MBLK */
    } else {
	l = mb->mBlkHdr.mLen;
	packet = mb->mBlkHdr.mData;
	cookie = (void *)mb;
    }

#if defined(BROADCOM_DEBUG)
    if (LOG_CHECK(BSL_LS_SYS_END | BSL_INFO) &&
        LOG_CHECK(BSL_LS_SOC_PACKET | BSL_INFO)) {
	d_packet_format("socend TX", DECODE_ETHER, packet, l, NULL);
    }
#endif /* defined(BROADCOM_DEBUG) */

    if (snoop_ip_tx != NULL) {
	snoop_ip_tx(se->se_unit, packet, l);
    }

    sal_memset(pkt, 0, sizeof(bcm_pkt_t));
    pkt->pkt_data = &(pkt->_pkt_data);
    pkt->_pkt_data.len = l;
    pkt->_pkt_data.data = (uint8 *)packet;
    pkt->blk_count = 1;
    pkt->unit = se->se_unit;
    pkt->pkt_len = l;
    SOC_PBMP_CLEAR(pkt->tx_pbmp);
    SOC_PBMP_CLEAR(pkt->tx_upbmp);
    SOC_PBMP_CLEAR(pkt->tx_l3pbmp);

    /* get tx_pbmp, tx_upbmp */
    eh = (enet_hdr_t *)packet;
    rv = _socend_l2_lookup(se->se_unit,
                      eh->en_dhost,
                      VLAN_CTRL_ID(se->se_vlan),
                      pkt);
    if(rv == ERROR){
        LOG_CLI((BSL_META("socend_send : can't get egress port(s) by _socend_l2_lookup.\n")));
        return(ERROR);
        }

    pkt->cookie = cookie;
    pkt->call_back = socend_send_done;
    pkt->flags &= ~BCM_TX_CRC_FLD;
    pkt->flags |= BCM_TX_CRC_APPEND;

    if ((rv = bcm_tx(se->se_unit, pkt, cookie)) != BCM_E_NONE) {
        LOG_ERROR(BSL_LS_SOC_COMMON,
                  (BSL_META("bcm_tx failed: Unit %d: %s\n"),
                   se->se_unit, bcm_errmsg(rv)));
        return(ERROR);
    }

    return(OK);
}
Пример #7
0
void
socend_receive_netjob(int pi, int pckti, int pckt_size)
/*
 * Function: 	socend_receive_netjob
 * Purpose:	Called from netjob after packet arrives.
 * Parameters:	p - pointer to (se), cookied passed on registration
 *		pckpi - pointer to packet data (int form).
 *		pckt_size - received length of packet.
 * Returns:	Nothing
 */
{
    socend_t		*se = (socend_t *)pi;
    struct end_object 	*eo = &se->se_eo;
    void		*pckt = (void *)pckti;
    bcm_vlan_t		vid;
    CL_BLK_ID		cb = NULL;
    M_BLK_ID		mb = NULL;

    /* Check the DCB for errors */
#if defined(BROADCOM_DEBUG)			/* Only compile in for debug */
    if (LOG_CHECK(BSL_LS_SYS_END | BSL_INFO) &&
        LOG_CHECK(BSL_LS_SOC_PACKET | BSL_INFO)) {
	d_packet_format("socend RX", DECODE_ETHER, pckt, pckt_size, NULL);
    }
#endif /* BROADCOM_DEBUG */
    /*
     * Build Cluster - then attach to mblks, 1 for each interface that
     * should get the packet. Broadcast/Multicast packets go up all the stacks.
     *
     * For multicast, it should only go up stacks that have registered for that
     * address, but for now, this will allow multiple interfaces to work.
     */

    if ((NULL == (cb = netClBlkGet(eo->pNetPool, M_DONTWAIT)))) {
	if (mb) netMblkFree(eo->pNetPool, mb);
	netClFree(eo->pNetPool, pckt);	/* Free packet */
	END_ERR_ADD(eo, MIB2_IN_ERRS, +1);
	return;
    }

#if defined(__mips__)
    if (SOC_IS_ESW(se->se_unit)) 
    {
        seu_t *seu = &socend_seu[se->se_unit];
        void  *tmp;
	
        sal_memcpy((UINT8 *)seu->pkt_align_buf + 2, (UINT8 *)pckt, pckt_size);
	
        tmp = seu->pkt_align_buf;
        seu->pkt_align_buf = pckt;
        pckt = tmp;
    }
#endif /* __mips__ */

    /* 1 MBLK for each interface */

    if ((mb = mBlkGet(eo->pNetPool, M_DONTWAIT, MT_DATA))) {
	netClBlkJoin(cb, pckt, SOC_END_PK_SZ, NULL, 0, 0, 0);
	netMblkClJoin(mb, cb);
	mb->mBlkPktHdr.len = mb->mBlkHdr.mLen = pckt_size;
	mb->mBlkHdr.mFlags |= M_PKTHDR;
#if defined(__mips__)
        if (SOC_IS_ESW(se->se_unit)) {
            mb->mBlkHdr.mData +=2;
        }
#endif /* __mips__ */
	vid = VLAN_CTRL_ID(soc_ntohs(((enet_hdr_t *)mb->mBlkHdr.mData)->en_tag_ctrl));
        if (SOC_IS_ESW(se->se_unit)) {
            socend_untag(mb);		/* Untag packet for now */
        } else {
            robo_socend_untag(mb);		/* Untag packet for now */
        }
    } else {
	netClBlkFree(eo->pNetPool, cb);
	netClFree(eo->pNetPool, pckt);	/* Free packet */
	return;
    }

    {
	M_BLK_ID	tmb, fmb = mb;
	seu_t		*seu = &socend_seu[se->se_unit];
	/*
	 * Duplicate MBLK, and point to same cluster.
	 */
	for (se = seu->seu_devices; se != NULL; se = se->se_next) {

	    if (vid != se->se_vlan) {
		continue;
	    }

	    eo = &se->se_eo;

	    if (se->se_next != NULL) {
		tmb = mBlkGet(eo->pNetPool, M_DONTWAIT, MT_DATA);
		netMblkDup(mb, tmb);
	    } else {
		fmb = NULL;
		tmb = mb;
	    }

	    END_RCV_RTN_CALL(eo, tmb);
	}

	if (fmb) {
	    netMblkClFree(fmb);
	}
    }
}
Пример #8
0
STATUS
socend_mcast_add(_END_OBJ_PAR *p, char *a)
/*
 * Function: 	socend_mcast_add
 * Purpose:	SENS interface to add a multicast address for the interface.
 * Parameters:	p - pointer to VxWorks end_obj structure for device
 *		a - pointer to address to add
 * Returns:	OK/ERROR
 */
{
    struct end_object 	*eo = (struct end_object *)p;
    socend_t 		*se = (socend_t *)eo->devObject.pDevice;
    int ret;
    pbmp_t pbmp, ubmp;
    bcm_mcast_addr_t mcaddr;
    char mac_str[MACADDR_STR_LEN];
    int unit = se->se_unit;

    if (LOG_CHECK(BSL_LS_SYS_END | BSL_INFO)) {
	format_macaddr(mac_str, (uint8 *)a);
	LOG_INFO(BSL_LS_SYS_END,
                 (BSL_META_U(unit,
                             "socend_mcast_add: %s%d %s\n"),
                  eo->devObject.name, eo->devObject.unit, mac_str));
    }
    /*soc_ioctl(ADD_MULTICAST)*/
    if (ENETRESET == etherMultiAdd(&eo->multiList, a)) {
	BCM_PBMP_CLEAR(pbmp);
	BCM_PBMP_PORT_ADD(pbmp, CMIC_PORT(unit));
#if 0   
	BCM_PBMP_PORT_ADD(pbmp, eo->devObject.unit);
#endif
	BCM_PBMP_ASSIGN(ubmp, pbmp);
	bcm_mcast_addr_t_init(&mcaddr, (uint8 *)a, se->se_vlan);
	mcaddr.cos_dst = 0;
	BCM_PBMP_ASSIGN(mcaddr.pbmp, pbmp);
	BCM_PBMP_ASSIGN(mcaddr.ubmp, ubmp);
	ret = bcm_mcast_addr_add(se->se_unit, &mcaddr);
	if (ret >= BCM_E_NONE) {
#if 0	
	    ret = bcm_amux_register(se->se_unit, a, se->se_vlan,
				    socend_receive, (void *)se);
#endif
	    if (ret < 0) {
		LOG_CLI((BSL_META_U(unit,
                                    "socend_mcast_add: %s%d bcm_amux_register failed: %s\n"),
                         eo->devObject.name, eo->devObject.unit,
                         bcm_errmsg(ret)));
		 bcm_mcast_addr_remove(se->se_unit,
				       (uint8 *)a, se->se_vlan);
	    }
	    return (OK);
	} else {
	    LOG_CLI((BSL_META_U(unit,
                                "bcm_mcast_addr_add failed ERROR : %s\n"),
                     bcm_errmsg(ret)));
	    LOG_INFO(BSL_LS_SYS_END,
                     (BSL_META_U(unit,
                                 "socend_mcast_add: Unit %d Device %s%d "
                                 "Software RESET\n"),
                      se->se_unit, eo->devObject.name, eo->devObject.unit));
	    return (ERROR);
	}
    }
    return(ERROR);
}