示例#1
0
文件: dm96xx.c 项目: dell-asm-ci/ipxe
/**
 * Close network device
 *
 * @v netdev		Network device
 */
static void dm96xx_close ( struct net_device *netdev ) {
	struct dm96xx_device *dm96xx = netdev->priv;

	/* Close USB network device */
	usbnet_close ( &dm96xx->usbnet );

	/* Reset device */
	dm96xx_reset ( dm96xx );
}
示例#2
0
/**
 * Close network device
 *
 * @v netdev		Network device
 */
static void smsc95xx_close ( struct net_device *netdev ) {
	struct smsc95xx_device *smsc95xx = netdev->priv;

	/* Close USB network device */
	usbnet_close ( &smsc95xx->usbnet );

	/* Dump statistics (for debugging) */
	smsc95xx_dump_statistics ( smsc95xx );

	/* Reset device */
	smsc95xx_reset ( smsc95xx );
}
示例#3
0
文件: acm.c 项目: dell-asm-ci/ipxe
/**
 * Open RNDIS device
 *
 * @v rndis		RNDIS device
 * @ret rc		Return status code
 */
static int acm_open ( struct rndis_device *rndis ) {
	struct acm_device *acm = rndis->priv;
	int rc;

	/* Open USB network device */
	if ( ( rc = usbnet_open ( &acm->usbnet ) ) != 0 )
		goto err_open;

	return 0;

	usbnet_close ( &acm->usbnet );
 err_open:
	return rc;
}
示例#4
0
文件: dm96xx.c 项目: dell-asm-ci/ipxe
/**
 * Open network device
 *
 * @v netdev		Network device
 * @ret rc		Return status code
 */
static int dm96xx_open ( struct net_device *netdev ) {
	struct dm96xx_device *dm96xx = netdev->priv;
	unsigned int rcr;
	int rc;

	/* Set DM9601-compatible RX header mode */
	if ( ( rc = dm96xx_rx_mode ( dm96xx ) ) != 0 )
		goto err_rx_mode;

	/* Write MAC address */
	if ( ( rc = dm96xx_write_mac ( dm96xx, netdev->ll_addr ) ) != 0 )
		goto err_write_mac;

	/* Open USB network device */
	if ( ( rc = usbnet_open ( &dm96xx->usbnet ) ) != 0 ) {
		DBGC ( dm96xx, "DM96XX %p could not open: %s\n",
		       dm96xx, strerror ( rc ) );
		goto err_open;
	}

	/* Set receive filters */
	rcr = ( DM96XX_RCR_ALL | DM96XX_RCR_RUNT | DM96XX_RCR_PRMSC |
		DM96XX_RCR_RXEN );
	if ( ( rc = dm96xx_write_register ( dm96xx, DM96XX_RCR, rcr ) ) != 0 ) {
		DBGC ( dm96xx, "DM96XX %p could not write receive filters: "
		       "%s\n", dm96xx, strerror ( rc ) );
		goto err_write_rcr;
	}

	/* Update link status */
	if ( ( rc = dm96xx_check_link ( dm96xx ) ) != 0 )
		goto err_check_link;

	return 0;

 err_check_link:
 err_write_rcr:
	usbnet_close ( &dm96xx->usbnet );
 err_open:
 err_write_mac:
 err_rx_mode:
	return rc;
}
示例#5
0
/**
 * Open network device
 *
 * @v netdev		Network device
 * @ret rc		Return status code
 */
static int smsc95xx_open ( struct net_device *netdev ) {
	struct smsc95xx_device *smsc95xx = netdev->priv;
	union smsc95xx_mac mac;
	int rc;

	/* Clear stored interrupt status */
	smsc95xx->int_sts = 0;

	/* Copy MAC address */
	memset ( &mac, 0, sizeof ( mac ) );
	memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN );

	/* Configure bulk IN empty response */
	if ( ( rc = smsc95xx_writel ( smsc95xx, SMSC95XX_HW_CFG,
				      SMSC95XX_HW_CFG_BIR ) ) != 0 )
		goto err_hw_cfg;

	/* Open USB network device */
	if ( ( rc = usbnet_open ( &smsc95xx->usbnet ) ) != 0 ) {
		DBGC ( smsc95xx, "SMSC95XX %p could not open: %s\n",
		       smsc95xx, strerror ( rc ) );
		goto err_open;
	}

	/* Configure interrupt endpoint */
	if ( ( rc = smsc95xx_writel ( smsc95xx, SMSC95XX_INT_EP_CTL,
				      ( SMSC95XX_INT_EP_CTL_RXDF_EN |
					SMSC95XX_INT_EP_CTL_PHY_EN ) ) ) != 0 )
		goto err_int_ep_ctl;

	/* Configure bulk IN delay */
	if ( ( rc = smsc95xx_writel ( smsc95xx, SMSC95XX_BULK_IN_DLY,
				      SMSC95XX_BULK_IN_DLY_SET ( 0 ) ) ) != 0 )
		goto err_bulk_in_dly;

	/* Configure MAC */
	if ( ( rc = smsc95xx_writel ( smsc95xx, SMSC95XX_MAC_CR,
				      ( SMSC95XX_MAC_CR_RXALL |
					SMSC95XX_MAC_CR_FDPX |
					SMSC95XX_MAC_CR_MCPAS |
					SMSC95XX_MAC_CR_PRMS |
					SMSC95XX_MAC_CR_PASSBAD |
					SMSC95XX_MAC_CR_TXEN |
					SMSC95XX_MAC_CR_RXEN ) ) ) != 0 )
		goto err_mac_cr;

	/* Configure transmit datapath */
	if ( ( rc = smsc95xx_writel ( smsc95xx, SMSC95XX_TX_CFG,
				      SMSC95XX_TX_CFG_ON ) ) != 0 )
		goto err_tx_cfg;

	/* Write MAC address high register */
	if ( ( rc = smsc95xx_raw_writel ( smsc95xx, SMSC95XX_ADDRH,
					  mac.addr.h ) ) != 0 )
		goto err_addrh;

	/* Write MAC address low register */
	if ( ( rc = smsc95xx_raw_writel ( smsc95xx, SMSC95XX_ADDRL,
					  mac.addr.l ) ) != 0 )
		goto err_addrl;

	/* Enable PHY interrupts */
	if ( ( rc = mii_write ( &smsc95xx->mii, SMSC95XX_MII_PHY_INTR_MASK,
				( SMSC95XX_PHY_INTR_ANEG_DONE |
				  SMSC95XX_PHY_INTR_LINK_DOWN ) ) ) != 0 ) {
		DBGC ( smsc95xx, "SMSC95XX %p could not set PHY interrupt "
		       "mask: %s\n", smsc95xx, strerror ( rc ) );
		goto err_phy_intr_mask;
	}

	/* Update link status */
	smsc95xx_check_link ( smsc95xx );

	return 0;

 err_phy_intr_mask:
 err_addrl:
 err_addrh:
 err_tx_cfg:
 err_mac_cr:
 err_bulk_in_dly:
 err_int_ep_ctl:
	usbnet_close ( &smsc95xx->usbnet );
 err_open:
 err_hw_cfg:
	smsc95xx_reset ( smsc95xx );
	return rc;
}
示例#6
0
文件: acm.c 项目: dell-asm-ci/ipxe
/**
 * Close RNDIS device
 *
 * @v rndis		RNDIS device
 */
static void acm_close ( struct rndis_device *rndis ) {
	struct acm_device *acm = rndis->priv;

	/* Close USB network device */
	usbnet_close ( &acm->usbnet );
}