static int eth_open(struct net_device *net) { struct eth_dev *dev = netdev_priv(net); struct gether *link; DBG(dev, "%s\n", __func__); if (netif_carrier_ok(dev->net)) eth_start(dev, GFP_KERNEL); spin_lock_irq(&dev->lock); link = dev->port_usb; if (link && link->open) link->open(link); spin_unlock_irq(&dev->lock); return 0; }
/** * gether_connect - notify network layer that USB link is active * @link: the USB link, set up with endpoints, descriptors matching * current device speed, and any framing wrapper(s) set up. * Context: irqs blocked * * This is called to activate endpoints and let the network layer know * the connection is active ("carrier detect"). It may cause the I/O * queues to open and start letting network packets flow, but will in * any case activate the endpoints so that they respond properly to the * USB host. * * Verify net_device pointer returned using IS_ERR(). If it doesn't * indicate some error code (negative errno), ep->driver_data values * have been overwritten. */ struct net_device *gether_connect(struct gether *link) { struct eth_dev *dev = the_dev; int result = 0; if (!dev) return ERR_PTR(-EINVAL); link->in_ep->driver_data = dev; result = usb_ep_enable(link->in_ep, link->in); if (result != 0) { DBG(dev, "enable %s --> %d\n", link->in_ep->name, result); goto fail0; } link->out_ep->driver_data = dev; result = usb_ep_enable(link->out_ep, link->out); if (result != 0) { DBG(dev, "enable %s --> %d\n", link->out_ep->name, result); goto fail1; } if (result == 0) result = alloc_requests(dev, link, qlen(dev->gadget)); if (result == 0) { dev->zlp = link->is_zlp_ok; DBG(dev, "qlen %d\n", qlen(dev->gadget)); dev->header_len = link->header_len; dev->unwrap = link->unwrap; dev->wrap = link->wrap; spin_lock(&dev->lock); dev->port_usb = link; link->ioport = dev; if (netif_running(dev->net)) { if (link->open) link->open(link); } else { if (link->close) link->close(link); } spin_unlock(&dev->lock); netif_carrier_on(dev->net); if (netif_running(dev->net)) eth_start(dev, GFP_ATOMIC); /* on error, disable any endpoints */ } else { (void) usb_ep_disable(link->out_ep); fail1: (void) usb_ep_disable(link->in_ep); } fail0: /* caller is responsible for cleanup on error */ if (result < 0) return ERR_PTR(result); return dev->net; }
/** * Starts the initialization, the tasks and then the scheduler. */ int main(void) { /* disable ETM at very first */ PINSEL10 &= ~((unsigned int)(1 << 3)); /* Initialize BMC hardware */ global_data.bmc_resetcause = 0x00; /* IPMI message sequence counter */ global_data.seq_counter = 0x00; /* site number used for entity instance */ global_data.bmc_siteno = 0x00; /* reset sdr list */ sdr_list.sdr_count = 0; /* init PLL */ init_clock(); /* init interrupts */ init_irq(); /* get reset cause */ init_resetcause(); /* init port pins */ init_portpins(); /* CUSTOM BOARD INIT CODE LOCATION 1 */ custom_init_1(); /* get HW and IPMB address */ custom_get_hw_ipmb_address(); uptime_init(); /* init RTC */ rtc_init(); /* create the FreeRTOS queues */ create_queues(); uart_init(UART_DEBUG_CONNECTOR, 115200); uart_printf("Firmware started...\n"); /* init SPI/SSP controllers */ spi_init(); /* init SPI FLASH */ spi_flash_init_devices(); spi_flash_init(&spi_flash); #ifdef CFG_MMC_I2C_MASTER /* init BMC master I2C bus */ master_i2c_init(MASTER_BUS_I2C); #endif /* init EEPROM file system */ //spi_eeprom_init(&spi_eeprom); #ifdef CFG_FS if (fs_init(&efs, &spi_eeprom) != 0) { uart_printf("\nEEPROM not accesable!\n"); /* reboot bmc */ lpc_watchdog_start(CFG_BL_WATCHDOG_TIMEOUT, WD_RESET_MODE); while (1); } #endif /* init leds */ //led_init(); #ifndef CFG_ONCHIP_FLASH_GLOBAL_CONF /* check EEPROM areas */ //eeprom_integrity_check_areas(); #endif /* init CLI (and debug console) */ cli_uart_init(115200); /* handle reset type warm/cold? */ //fru_handle_reset_type(); #ifdef CFG_CM cm_fru_get_last_known_state(); #endif #ifdef CFG_EXT_INT /* init external interrupts */ external_interrupt_init(); #endif #ifdef CFG_HELPER /* init the helper task */ helper_init(); #endif #ifdef CFG_BIOS_FLASH /* init BIOS FLASH */ spi_flash_init(&bios_flash); /* init FPGA BIOS flash selection */ bios_restore_active_flash_from_eeprom(); #endif /* CUSTOM BOARD INIT CODE LOCATION 2 */ //custom_init_2(); /* get global configuration from EEPROM */ global_config(); /* CUSTOM BOARD INIT CODE LOCATION 3 */ //custom_init_3(); /* parse FRU */ fru_init(0); #if defined (CFG_CM) || defined (CFG_MMC) || defined (CFG_IRTM) || defined(CFG_MCMC) /* init the IPMB-L interface(s) */ ipmbl_init(); #endif #ifdef CFG_LAN /* read and set ncsi mac address from fru */ custom_set_ncsi_mac(); #endif /* create message pool for IPMI messages */ message_pool_init(); /* init board task */ board_init(); /* init the BMC task */ bmc_init(); #ifdef CFG_PI_SERIAL_BASIC /* init the payload interface */ pi_uart_b_init(CFG_PI_PORT_RATE); #endif /* CFG_PI_SERIAL_BASIC */ #ifdef CFG_PI_SERIAL_TERMINAL /* init the payload interface */ pi_uart_t_init(CFG_PI_PORT_RATE); #endif /* CFG_PI_SERIAL_TERMINAL */ #ifdef CFG_PI_KCS /* initialise kcs interface */ kcs_init(); #endif /* CFG_PI_KCS */ #ifdef CFG_ATCA if (global_conf.operation_mode == OPERATION_MODE_STANDALONE) { /* configure IPMB-A and IPMB-B as master only in stanalone mode */ master_i2c_init(IPMB0A_I2C); master_i2c_init(IPMB0B_I2C); /* enable IPMB-0 pull ups and buffer */ ipmb0_bus_ctrl(IPMB0_A, IPMB_ENABLE); ipmb0_bus_ctrl(IPMB0_B, IPMB_ENABLE); } else { /* init the IPMB-0 interface */ ipmb0_init(); } #endif #ifdef CFG_LAN_PLUS sol_init(); #endif #ifdef CFG_LAN /* init ethernet hardware and Task */ eth_start(); #endif /* init the SDR task */ /* PORT_NOTE: Needs to be started AFTER BMC task because of Semaphore dependency */ sdr_init(); /* parse all PICMG Records in FRU data and store relevant information */ //fru_parse_picmg(); /* init the IPMI message hub */ msg_hub_init(); /* init the event task */ event_init(); #ifdef CFG_CM /* init the CM task */ init_cm(); #endif #ifdef CFG_COOLING_MANAGER cool_init(); #endif /* do all post tests */ //post_test(); /* needs to be done after sdr initialization */ //hpm_check_bl_flags(); #ifdef CFG_BIOS_FLASH /* collect BIOS/NVRAM version info (if payload power is off) */ if (!(signal_read(&sig_payload_power_enable))) { bios_redundancy_get_versions(); } #endif #ifdef CFG_WATCHDOG /* start the FW watchdog */ lpc_watchdog_start(CFG_FW_WATCHDOG_TIMEOUT, WD_RESET_MODE); #endif /* set desired debug output mode before starting scheduler */ global_debug_uart_enabled = CFG_GLOBAL_DEBUG_UART; /* all tasks have been initialized, start the scheduler */ vTaskStartScheduler(); /* Should never reach here! */ while (1); }