diff --git a/dde_linux/src/lib/usb/arm/platform_arndale/platform.cc b/dde_linux/src/lib/usb/arm/platform_arndale/platform.cc index b31f50f237..9c57b7f2b2 100644 --- a/dde_linux/src/lib/usb/arm/platform_arndale/platform.cc +++ b/dde_linux/src/lib/usb/arm/platform_arndale/platform.cc @@ -294,6 +294,8 @@ extern "C" void module_dwc3_exynos_driver_init(); extern "C" void module_dwc3_driver_init(); extern "C" void module_xhci_hcd_init(); +extern "C" void module_asix_init(); + void ehci_setup(Services *services) { diff --git a/dde_linux/src/lib/usb/dummies.c b/dde_linux/src/lib/usb/dummies.c index 2133bb4e72..c23285ede8 100644 --- a/dde_linux/src/lib/usb/dummies.c +++ b/dde_linux/src/lib/usb/dummies.c @@ -23,7 +23,7 @@ #define SKIP_VERBOSE 0 -#if VERBOSE_LX_EMUL +#if DEBUG_TRACE #define TRACE dde_kit_printf("\033[32m%s\033[0m called, not implemented\n", __PRETTY_FUNCTION__) #else #define TRACE @@ -383,6 +383,7 @@ void device_remove_file(struct device *dev, const struct device_attribute *attr) { TRACE; } void put_device(struct device *dev) { TRACE; } +struct device *get_device(struct device *dev) { TRACE; return dev; } void driver_unregister(struct device_driver *drv) { TRACE; } int driver_attach(struct device_driver *drv) { TRACE; return 0; } @@ -670,6 +671,8 @@ void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size, enum dma_data_direction direction) { SKIP;; } int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) { SKIP; return 0; } +int dma_set_mask(struct device *dev, u64 mask) { TRACE; return 0; } + /***************** ** linux/pid.h ** @@ -890,9 +893,10 @@ void netif_tx_wake_all_queues(struct net_device *dev) { TRACE; } void netif_device_attach(struct net_device *dev) { TRACE; } void unregister_netdev(struct net_device *dev) { TRACE; } void free_netdev(struct net_device *dev) { TRACE; } -void netif_carrier_off(struct net_device *dev) { TRACE; } int netdev_mc_empty(struct net_device *dev) { TRACE; return 1; } +unsigned netdev_mc_count(struct net_device * dev) { TRACE; return 1; } + /***************** ** linux/mii.h ** diff --git a/dde_linux/src/lib/usb/include/lx_emul.h b/dde_linux/src/lib/usb/include/lx_emul.h index 43879309ed..9d2defbdb4 100644 --- a/dde_linux/src/lib/usb/include/lx_emul.h +++ b/dde_linux/src/lib/usb/include/lx_emul.h @@ -32,32 +32,18 @@ extern "C" { #include -#define VERBOSE_LX_EMUL 0 - - -#if VERBOSE_LX_EMUL #define DEBUG_COMPLETION 0 #define DEBUG_DMA 0 -#define DEBUG_DRIVER 1 -#define DEBUG_IRQ 1 -#define DEBUG_KREF 0 -#define DEBUG_PCI 0 -#define DEBUG_SKB 0 -#define DEBUG_SLAB 0 -#define DEBUG_TIMER 0 -#define DEBUG_THREAD 0 -#else -#define DEBUG_COMPLETION 0 #define DEBUG_DRIVER 0 -#define DEBUG_DMA 0 #define DEBUG_IRQ 0 #define DEBUG_KREF 0 +#define DEBUG_PRINTK 0 #define DEBUG_PCI 0 #define DEBUG_SKB 0 #define DEBUG_SLAB 0 #define DEBUG_TIMER 0 #define DEBUG_THREAD 0 -#endif +#define DEBUG_TRACE 0 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) #define LINUX_VERSION_CODE KERNEL_VERSION(3,9,0) @@ -500,15 +486,15 @@ enum { /* * Debug macros */ -#if VERBOSE_LX_EMUL +#if DEBUG_PRINTK #define printk dde_kit_printf #define vprintk dde_kit_vprintf #define panic dde_kit_panic -#else /* VERBOSE_LX_EMUL */ +#else #define printk(...) #define vprintk(...) #define panic(...) -#endif /* VERBOSE_LX_EMUL */ +#endif /* * Bits and types @@ -1439,7 +1425,7 @@ bool device_can_wakeup(struct device *dev); #define dev_err( dev, format, arg...) dde_kit_printf("dev_error: " format, ## arg) #define dev_notice(dev, format, arg...) dde_kit_printf("dev_notice: " format, ## arg) -#if VERBOSE_LX_EMUL +#if DEBUG_PRINTK #define dev_dbg(dev, format, arg...) dde_kit_printf("dev_dbg: " format, ## arg) #else #define dev_dbg( dev, format, arg...) @@ -3148,7 +3134,7 @@ int ethtool_op_get_ts_info(struct net_device *, struct ethtool_ts_info *); #define netdev_for_each_mc_addr(a, b) if (0) -#if VERBOSE_LX_EMUL +#if DEBUG_PRINTK #define netif_dbg(priv, type, dev, fmt, args...) dde_kit_printf("netif_dbg: " fmt, ## args) #define netdev_dbg(dev, fmt, args...) dde_kit_printf("netdev_dbg: " fmt, ##args) #else @@ -3247,21 +3233,18 @@ enum netdev_state_t { #define netif_msg_tx_err(p) ({ printk("netif_msg_tx_err called not implemented\n"); 0; }) #define netif_msg_rx_err(p) ({ printk("netif_msg_rx_err called not implemented\n"); 0; }) #define netif_msg_tx_queued(p) ({ printk("netif_msg_tx_queued called not implemented\n"); 0; }) -static inline int netif_carrier_ok(const struct net_device *dev) { - return !test_bit(__LINK_STATE_NOCARRIER, &dev->state); -} -#define netif_carrier_on(p) ({ printk("netif_carrier_on called not implemented\n"); 0; }) -static inline unsigned netdev_mc_count(struct net_device * dev) { - printk("netdev_mc_count called not implemented\n"); - return 0; -} u32 netif_msg_init(int, int); static inline void *netdev_priv(const struct net_device *dev) { return dev->priv; } int netif_running(const struct net_device *); +int netif_carrier_ok(const struct net_device *dev); int netif_device_present(struct net_device *); + +void netif_carrier_on(struct net_device *dev); +void netif_carrier_off(struct net_device *dev); + void netif_device_detach(struct net_device *); void netif_start_queue(struct net_device *); void netif_stop_queue(struct net_device *); @@ -3271,9 +3254,9 @@ void unregister_netdev(struct net_device *); void free_netdev(struct net_device *); int netif_rx(struct sk_buff *); void netif_tx_wake_all_queues(struct net_device *); -void netif_carrier_off(struct net_device *); int netdev_mc_empty(struct net_device *); +unsigned netdev_mc_count(struct net_device * dev); int register_netdev(struct net_device *); /***************** diff --git a/dde_linux/src/lib/usb/lx_emul.cc b/dde_linux/src/lib/usb/lx_emul.cc index 7954192670..2c4a7789d2 100644 --- a/dde_linux/src/lib/usb/lx_emul.cc +++ b/dde_linux/src/lib/usb/lx_emul.cc @@ -36,12 +36,6 @@ extern "C" { } -#if VERBOSE_LX_EMUL -#define TRACE dde_kit_printf("\033[35m%s\033[0m called\n", __PRETTY_FUNCTION__) -#else -#define TRACE -#endif - namespace Genode { class Slab_backend_alloc; class Slab_alloc; @@ -56,7 +50,7 @@ class Genode::Slab_backend_alloc : public Genode::Allocator, private: enum { - VM_SIZE = 10 * 1024 * 1024, /* size of VM region to reserve */ + VM_SIZE = 24 * 1024 * 1024, /* size of VM region to reserve */ BLOCK_SIZE = 1024 * 1024, /* 1 MB */ ELEMENTS = VM_SIZE / BLOCK_SIZE, /* MAX number of dataspaces in VM */ }; @@ -787,7 +781,6 @@ int dev_set_drvdata(struct device *dev, void *data) } -struct device *get_device(struct device *dev) { TRACE; return dev; } const char *dev_name(const struct device *dev) { return dev->name; } @@ -1011,7 +1004,6 @@ int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir, struct dma_attrs *attrs) { return nents; } -int dma_set_mask(struct device *dev, u64 mask) { TRACE; return 0; } /********************* ** linux/kthread.h ** diff --git a/dde_linux/src/lib/usb/nic/nic.cc b/dde_linux/src/lib/usb/nic/nic.cc index 6613933fda..aaacb134e3 100644 --- a/dde_linux/src/lib/usb/nic/nic.cc +++ b/dde_linux/src/lib/usb/nic/nic.cc @@ -32,7 +32,6 @@ extern "C" { static Signal_helper *_signal = 0; enum { - START = 0x1, /* device flag */ HEAD_ROOM = 8, /* head room in skb in bytes */ MAC_LEN = 17, /* 12 number and 6 colons */ }; @@ -74,7 +73,7 @@ class Skb Genode::memset(_free, 0xff, size * sizeof(_free[0])); for (unsigned i = 0; i < _entries; i++) - _buf[i].start = (unsigned char *)kmalloc(buffer_size, GFP_NOIO); + _buf[i].start = (unsigned char *)kmalloc(buffer_size + NET_IP_ALIGN, GFP_NOIO); } sk_buff *alloc() @@ -166,7 +165,7 @@ class Nic_device : public Nic::Device /* initialize skb allocators */ skb_rx(64, dev->rx_urb_size); - skb_tx(32, dev->rx_urb_size); + skb_tx(64, dev->rx_urb_size); if (!burst()) return; @@ -294,6 +293,7 @@ int register_netdev(struct net_device *ndev) { using namespace Genode; static bool announce = false; + int err = -ENODEV; Nic_device *nic = Nic_device::add(ndev); @@ -305,21 +305,45 @@ int register_netdev(struct net_device *ndev) announce = true; - ndev->state |= START; - int err = ndev->netdev_ops->ndo_open(ndev); + ndev->state |= 1 << __LINK_STATE_START; + netif_carrier_off(ndev); + + if ((err = ndev->netdev_ops->ndo_open(ndev))) + return err; + + if (ndev->netdev_ops->ndo_set_rx_mode) + ndev->netdev_ops->ndo_set_rx_mode(ndev); + _nic = nic; env()->parent()->announce(ep_nic.manage(&root)); - - return err; } - return -ENODEV; + return err; } -int netif_running(const struct net_device *dev) { return dev->state & START; } +int netif_running(const struct net_device *dev) +{ + return dev->state & (1 << __LINK_STATE_START); +} + int netif_device_present(struct net_device *dev) { return 1; } +int netif_carrier_ok(const struct net_device *dev) +{ + return !(dev->state & (1 << __LINK_STATE_NOCARRIER)); +} + +void netif_carrier_on(struct net_device *dev) +{ + dev->state &= ~(1 << __LINK_STATE_NOCARRIER); +} + +void netif_carrier_off(struct net_device *dev) +{ + dev->state |= 1 << __LINK_STATE_NOCARRIER; +} + #ifdef GENODE_NET_STAT #include static Timer::Connection _timer; @@ -332,8 +356,13 @@ int netif_rx(struct sk_buff *skb) _nic->rx(skb); } #ifdef GENODE_NET_STAT - else if (_nic) + else if (_nic) { + try { _stat.data(new (skb->data) Net::Ethernet_frame(skb->len), skb->len); + } catch(Net::Ethernet_frame::No_ethernet_frame) { + PWRN("No ether frame"); + } + } #endif dev_kfree_skb(skb); @@ -370,7 +399,11 @@ struct sk_buff *alloc_skb(unsigned int size, gfp_t priority) struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, unsigned int length) { - return _alloc_skb(length + NET_IP_ALIGN, false); + struct usbnet *d = (usbnet *)netdev_priv(dev); + struct sk_buff *s = _alloc_skb(length + NET_IP_ALIGN, false); + s->data += NET_IP_ALIGN; + s->tail += NET_IP_ALIGN; + return s; }