Esempio n. 1
0
/**
 * DPDK callback to enable promiscuous mode.
 *
 * @param dev
 *   Pointer to Ethernet device structure.
 */
void
mlx5_promiscuous_enable(struct rte_eth_dev *dev)
{
	struct priv *priv = dev->data->dev_private;
	int ret;

	dev->data->promiscuous = 1;
	if (priv->isolated) {
		DRV_LOG(WARNING,
			"port %u cannot enable promiscuous mode"
			" in flow isolation mode",
			dev->data->port_id);
		return;
	}
	ret = mlx5_traffic_restart(dev);
	if (ret)
		DRV_LOG(ERR, "port %u cannot enable promiscuous mode: %s",
			dev->data->port_id, strerror(rte_errno));
}
Esempio n. 2
0
File: netdrv.c Progetto: ariavie/bcm
LOCAL STATUS
NetdrvPollRcv(END_DEVICE * pDrvCtrl, /* device to be polled */
              M_BLK_ID     pMblk)    /* ptr to buffer */
{
    u_short stat;
    char* pPacket;
    int len;

    DRV_LOG (DRV_DEBUG_POLL_RX,
            "NetdrvPollRcv ....... Not Implemented\n", 1, 2, 3, 4, 5, 6);

    stat = NetdrvStatusRead(pDrvCtrl);

    

    if (!(stat & NETDRV_RINT)) {
        printf("\r\nNetdrvPollRcv no data");
        return (EAGAIN);
    }

    /* Get packet and  length from device buffer/descriptor */

    pPacket = NULL; /* DUMMY CODE */
    len = 64;       /* DUMMY CODE */

    /* Upper layer must provide a valid buffer. */

    if ((pMblk->mBlkHdr.mLen < len) || (!(pMblk->mBlkHdr.mFlags & M_EXT))) {
#ifdef BOOTROM_DEBUG
        printf("\r\nPRX bad mblk");
#endif

        return (EAGAIN);
    }

    

    

    END_ERR_ADD(&pDrvCtrl->end, MIB2_IN_UCAST, +1);

    
    bcopy (pPacket, pMblk->m_data, len);
    pMblk->mBlkHdr.mFlags |= M_PKTHDR; /* set the packet header */
    pMblk->mBlkHdr.mLen    = len;      /* set the data len */
    pMblk->mBlkPktHdr.len  = len;      /* set the total len */

    
#ifdef BOOTROM_DEBUG
    printf("\r\nNetdrvPollRcv OK");
#endif

    return (OK);
}
Esempio n. 3
0
/**
 * DPDK callback to disable promiscuous mode.
 *
 * @param dev
 *   Pointer to Ethernet device structure.
 */
void
mlx5_promiscuous_disable(struct rte_eth_dev *dev)
{
	int ret;

	dev->data->promiscuous = 0;
	ret = mlx5_traffic_restart(dev);
	if (ret)
		DRV_LOG(ERR, "port %u cannot disable promiscuous mode: %s",
			dev->data->port_id, strerror(rte_errno));
}
Esempio n. 4
0
/**
 * DPDK callback to disable allmulti mode.
 *
 * @param dev
 *   Pointer to Ethernet device structure.
 */
void
mlx5_allmulticast_disable(struct rte_eth_dev *dev)
{
	int ret;

	dev->data->all_multicast = 0;
	ret = mlx5_traffic_restart(dev);
	if (ret)
		DRV_LOG(ERR, "port %u cannot disable allmulicast mode: %s",
			dev->data->port_id, strerror(rte_errno));
}
Esempio n. 5
0
File: netdrv.c Progetto: ariavie/bcm
/*
 * Send the received packet to END driver
 */
int
NetdrvSendToEnd(bcm_pkt_t *pPkt)
{
    int         len;
    M_BLK_ID    pMblk;
    char*       pCluster = NULL;
    CL_BLK_ID   pClBlk;
    END_DEVICE  *pDrvCtrl = __netDriver;

    if (pDrvCtrl == NULL) {
        return ERROR;
    }

    /* Add one to our unicast data. */
    END_ERR_ADD (&pDrvCtrl->end, MIB2_IN_UCAST, +1);

    /*
     * We implicitly are loaning here, if copying is necessary this
     * step may be skipped, but the data must be copied before being
     * passed up to the protocols.
     */
    pCluster = netClusterGet (pDrvCtrl->end.pNetPool, pDrvCtrl->pClPoolId);

    if (pCluster == NULL) {
        DRV_LOG (1, "Cannot loan!\n",1,2,3,4,5,6);
        END_ERR_ADD (&pDrvCtrl->end, MIB2_IN_ERRS, +1);
        goto cleanRXD;
    }

    /* Grab a cluster block to marry to the cluster we received. */
    if ((pClBlk = netClBlkGet (pDrvCtrl->end.pNetPool, M_DONTWAIT)) == NULL) {
        netClFree (pDrvCtrl->end.pNetPool, (UCHAR *)pCluster);
        DRV_LOG (DRV_DEBUG_RX, "Out of Cluster Blocks!\n", 1, 2, 3, 4, 5, 6);
        END_ERR_ADD (&pDrvCtrl->end, MIB2_IN_ERRS, +1);
        goto cleanRXD;
    }

    /*
     * OK we've got a spare, let's get an M_BLK_ID and marry it to the
     * one in the ring.
     */
    if ((pMblk = mBlkGet (pDrvCtrl->end.pNetPool, M_DONTWAIT, MT_DATA)) == NULL) {
        netClBlkFree (pDrvCtrl->end.pNetPool, pClBlk);
        netClFree (pDrvCtrl->end.pNetPool, (UCHAR *)pCluster);
        DRV_LOG (DRV_DEBUG_RX, "Out of M Blocks!\n", 1, 2, 3, 4, 5, 6);
        END_ERR_ADD (&pDrvCtrl->end, MIB2_IN_ERRS, +1);
        goto cleanRXD;
    }

    /* remove tag */
    len = pPkt->tot_len - 8;

    memcpy(pCluster + 2, (unsigned char *)(&(pPkt->_pkt_data.data[0])), 12);
    memcpy(pCluster + 14, (unsigned char *)(&(pPkt->_pkt_data.data[16])), len-12);

    /* Free buffer previously stolen */
    bcm_rx_free(pPkt->unit, pPkt->_pkt_data.data);

    /* Join the cluster to the MBlock */
    netClBlkJoin (pClBlk, pCluster, len, NULL, 0, 0, 0);
    netMblkClJoin (pMblk, pClBlk);

    pMblk->mBlkHdr.mLen = len;
    pMblk->mBlkHdr.mData += 2;
    pMblk->mBlkHdr.mFlags |= M_PKTHDR;
    pMblk->mBlkPktHdr.len = len;

    /* Send the packet to END driver */
    END_RCV_RTN_CALL(&__netDriver->end, pMblk);
    g_ulPktUp++;

    return OK;

    cleanRXD:
    return (ERROR);
}
Esempio n. 6
0
File: netdrv.c Progetto: ariavie/bcm
END_OBJ*
NetdrvLoad(char* initString, void *ap)
{
    END_DEVICE    *pDrvCtrl;

    /* parse the init string, filling in the device structure */
    if(initString == NULL) {
        return (NULL);
    }

    if (initString[0] == 0) {
        strcpy(initString,"netdrv");
        return (NULL);
    }

    /* allocate the device structure */
    pDrvCtrl = (END_DEVICE *)calloc (sizeof(END_DEVICE), 1);
    if (pDrvCtrl == NULL) {
        goto errorExit;
    }

    /* Parse */
    pDrvCtrl->unit = 0;
    pDrvCtrl->ivec = 0;
    pDrvCtrl->ilevel = 7;

    /*Ask the BSP to provide the ethernet address.*/
    GetMacFromFlash(pDrvCtrl->enetAddr);

    /* initialize the END and MIB2 parts of the structure */
    /*
     * The M2 element must come from m2Lib.h
     * This Netdrv is set up for a DIX type ethernet device.
     */

    if ((END_OBJ_INIT (&pDrvCtrl->end, (DEV_OBJ *)pDrvCtrl, "netdrv",
        pDrvCtrl->unit, &NetdrvFuncTable,
        "END Net Driver.") == ERROR)
        || (END_MIB_INIT (&pDrvCtrl->end, M2_ifType_ethernet_csmacd,
        &pDrvCtrl->enetAddr[0], 6, ETHERMTU /*END_BUFSIZ*/, END_SPEED) == ERROR)) {
        goto errorExit;
    }

    /* Perform memory allocation/distribution */
    if (NetdrvMemInit (pDrvCtrl) == ERROR) {
        goto errorExit;
    }

    /* reset and reconfigure the device */
    /* NetdrvReset (pDrvCtrl);
       NetdrvConfig (pDrvCtrl);
    */

    /* set the flags to indicate readiness */
    END_OBJ_READY (&pDrvCtrl->end,
        IFF_UP | IFF_RUNNING | IFF_NOTRAILERS | IFF_BROADCAST
        | IFF_MULTICAST);

#ifdef POLLING_MODE
     /* NetdrvStart(pDrvCtrl); */
#endif
    DRV_LOG (1, "Net driver is loaded successfully!\n",1,2,3,4,5,6);

    return (&pDrvCtrl->end);

    errorExit:
    DRV_LOG (1, "FATAL ERROR :: fail to load net driver!\n",1,2,3,4,5,6);

    if (pDrvCtrl != NULL) {
        free ((char *)pDrvCtrl);
    }

    return NULL;
}