--- zzzz-none-000/linux-2.6.28.10/net/core/dev.c 2009-05-02 18:54:43.000000000 +0000 +++ puma5-6360-529/linux-2.6.28.10/net/core/dev.c 2011-05-10 15:05:44.000000000 +0000 @@ -127,6 +127,10 @@ #include #include #include +#include +#ifdef CONFIG_AVM_PA +#include +#endif #include "net-sysfs.h" @@ -164,6 +168,8 @@ static DEFINE_SPINLOCK(ptype_lock); static struct list_head ptype_base[PTYPE_HASH_SIZE] __read_mostly; static struct list_head ptype_all __read_mostly; /* Taps */ +static int (*avm_recvhook)(struct sk_buff *skb); +static int (*avm_early_recvhook)(struct sk_buff *skb); #ifdef CONFIG_NET_DMA struct net_dma { @@ -262,6 +268,25 @@ DEFINE_PER_CPU(struct softnet_data, softnet_data); +#ifdef CONFIG_TI_DEVICE_PROTOCOL_HANDLING +extern int ti_protocol_handler (struct net_device* dev, struct sk_buff *skb); +#endif +#ifdef CONFIG_TI_EGRESS_HOOK +extern int ti_egress_hook_handler (struct net_device* dev, struct sk_buff *skb); +#endif +#ifdef CONFIG_TI_DOCSIS_EGRESS_HOOK +extern int ti_docsis_egress_hook_handler (struct net_device* dev, struct sk_buff *skb); +#endif + +#ifdef CONFIG_TI_DEVICE_INDEX_REUSE +extern int ti_dev_new_index(struct net *net); +#endif /* CONFIG_TI_DEVICE_INDEX_REUSE */ + +#ifdef CONFIG_TI_L2_SELECTIVE_FORWARDER +extern void ti_save_netdevice_info(struct net_device *dev); +extern void ti_free_netdevice_info(struct net_device *dev); +#endif /* CONFIG_TI_L2_SELECTIVE_FORWARDER */ + #ifdef CONFIG_LOCKDEP /* * register_netdevice() inits txq->_xmit_lock and sets lockdep class @@ -350,6 +375,16 @@ *******************************************************************************/ +void set_avm_recvhook(int (*recvhook)(struct sk_buff *skb)) +{ + avm_recvhook = recvhook; +} + +void set_avm_early_recvhook(int (*recvhook)(struct sk_buff *skb)) +{ + avm_early_recvhook = recvhook; +} + /* * Add a protocol ID to the list. Now that the input handler is * smarter we can dispense with all the messy stuff that used to be @@ -618,7 +653,12 @@ struct net_device *dev_get_by_name(struct net *net, const char *name) { struct net_device *dev; - + +#if defined(CONFIG_IFX_PPA_API) || defined(CONFIG_IFX_PPA_API_MODULE) + if (net == NULL) { + net = &init_net; + } +#endif read_lock(&dev_base_lock); dev = __dev_get_by_name(net, name); if (dev) @@ -1031,6 +1071,7 @@ void dev_load(struct net *net, const char *name) { +#ifdef CONFIG_NET_DEV_LOAD struct net_device *dev; read_lock(&dev_base_lock); @@ -1039,6 +1080,7 @@ if (!dev && capable(CAP_SYS_MODULE)) request_module("%s", name); +#endif } /** @@ -1792,6 +1834,8 @@ struct Qdisc *q; int rc = -ENOMEM; + skb_track_caller(skb); + /* GSO will handle the following emulations directly. */ if (netif_needs_gso(dev, skb)) goto gso; @@ -1820,7 +1864,27 @@ goto out_kfree_skb; } +#ifdef CONFIG_TI_META_DATA_CONSOLE_DUMP + if (skb->ti_meta_info != 0x0) + printk ("Core Networking Device Layer: %s SKB 0x%p has META Data 0x%x\n", skb->dev->name, skb, skb->ti_meta_info); +#endif /* CONFIG_TI_META_DATA_CONSOLE_DUMP */ + +#ifdef CONFIG_TI_EGRESS_HOOK + if (ti_egress_hook_handler(dev, skb) < 0) + return rc; +#endif /* CONFIG_TI_EGRESS_HOOK */ + +#ifdef CONFIG_TI_DOCSIS_EGRESS_HOOK + if (ti_docsis_egress_hook_handler(dev, skb) < 0) + return rc; +#endif /* CONFIG_TI_DOCSIS_EGRESS_HOOK */ + gso: + +#ifdef CONFIG_AVM_PA + (void)avm_pa_dev_snoop_transmit(AVM_PA_DEVINFO(dev), skb); +#endif + /* Disable soft irqs for various locks below. Also * stops preemption for RCU. */ @@ -1931,6 +1995,8 @@ struct softnet_data *queue; unsigned long flags; + skb_track_caller(skb); + /* if netpoll wants it, pretend we never saw it */ if (netpoll_rx(skb)) return NET_RX_DROP; @@ -2230,6 +2296,8 @@ if (!skb->iif) skb->iif = skb->dev->ifindex; + if (!skb->input_dev) + skb->input_dev = skb->dev; null_or_orig = NULL; orig_dev = skb->dev; @@ -2246,6 +2314,41 @@ skb_reset_transport_header(skb); skb->mac_len = skb->network_header - skb->mac_header; +#ifdef CONFIG_TI_PACKET_PROCESSOR_SIMULATION + /* Packet Processor Simulator Hook: This needs to be called only for devices + * which are PHYSICAL i.e. have a PID associated with them; since the PDSP + * will operate only at that layer. */ + if(skb->dev->pid_handle != -1) + { + extern int ti_pp_simulate_sr(struct sk_buff *skb); + + /* Pass the packet to the simulator and if the simulator + * captures the packet bypass the entire networking stack. */ + if (ti_pp_simulate_sr(skb) == 1) + return NET_RX_SUCCESS; + } +#endif /* CONFIG_TI_PACKET_PROCESSOR_SIMULATION */ + +#ifdef CONFIG_TI_DEVICE_PROTOCOL_HANDLING + { + struct net_device *dev = skb->dev; + /* Pass the packet to the device specific protocol handler */ + if (ti_protocol_handler (skb->dev, skb) < 0) + { +#if 0 + char buf[256]; + sprint_symbol(buf, dev->packet_handler); + printk(KERN_DEBUG "%s: packet from %s stolen by %s\n", + __FUNCTION__, dev->name, buf); +#endif + /* Device Specific Protocol handler has "captured" the packet + * and does not want to send it up the networking stack; so + * return immediately. */ + return NET_RX_SUCCESS; + } + } +#endif /* CONFIG_TI_DEVICE_PROTOCOL_HANDLING */ + pt_prev = NULL; rcu_read_lock(); @@ -2277,9 +2380,33 @@ ncls: #endif +#ifdef CONFIG_AVM_PA + if (avm_pa_dev_receive(AVM_PA_DEVINFO(skb->dev), skb) == 0) { + ret = NET_RX_SUCCESS; + goto out; + } +#endif + + if (avm_early_recvhook && (*avm_early_recvhook)(skb)) { + /* + * paket consumed by hook + */ + ret = NET_RX_SUCCESS; + goto out; + } + skb = handle_bridge(skb, &pt_prev, &ret, orig_dev); if (!skb) goto out; + + if (avm_recvhook && (*avm_recvhook)(skb)) { + /* + * paket consumed by hook + */ + ret = NET_RX_SUCCESS; + goto out; + } + skb = handle_macvlan(skb, &pt_prev, &ret, orig_dev); if (!skb) goto out; @@ -3864,13 +3991,29 @@ */ static int dev_new_index(struct net *net) { +#ifdef CONFIG_TI_DEVICE_INDEX_REUSE + /* Original implementation does not limit the number of indexes that + * can be allocated. This can cause data overflow. + * The "index reuse feature" limits the number of devices to 32 and reuses + * freed up indexes. + */ + return (ti_dev_new_index(net)); +#else static int ifindex; for (;;) { +//der FUSIV Source kommt nicht klar mit DEV Counter > 255 +//Absturz bei WLAN Autotest +#ifdef CONFIG_MACH_FUSIV + if (++ifindex >= 256) + ifindex = 1; +#else if (++ifindex <= 0) ifindex = 1; +#endif if (!__dev_get_by_index(net, ifindex)) return ifindex; } +#endif } /* Delayed registration/unregisteration */ @@ -4046,6 +4189,21 @@ } dev->ifindex = dev_new_index(net); + +#ifdef CONFIG_TI_DEVICE_INDEX_REUSE + /* Original dev_new_index() implementation gaurantees a unique device + * index by not limiting on the number of devices that can be registered. + * The "index reuse feature" limits the number of devices to 32. Free + * the allocated divert_blk + */ + + if (dev->ifindex == -1) + { + ret = -EINVAL; + goto err_uninit; + } +#endif /* CONFIG_TI_DEVICE_INDEX_REUSE */ + if (dev->iflink == -1) dev->iflink = dev->ifindex; @@ -4105,6 +4263,12 @@ rollback_registered(dev); dev->reg_state = NETREG_UNREGISTERED; } +#ifdef CONFIG_TI_L2_SELECTIVE_FORWARDER + else { + /* Store the netdevice pointer in global array */ + ti_save_netdevice_info(dev); + } +#endif /* CONFIG_TI_L2_SELECTIVE_FORWARDER */ out: return ret; @@ -4258,6 +4422,9 @@ WARN_ON(dev->ip_ptr); WARN_ON(dev->ip6_ptr); WARN_ON(dev->dn_ptr); +#ifdef CONFIG_AVM_PA + avm_pa_dev_unregister(AVM_PA_DEVINFO(dev)); +#endif if (dev->destructor) dev->destructor(dev); @@ -4351,6 +4518,21 @@ dev->get_stats = internal_stats; netpoll_netdev_init(dev); + +#ifdef CONFIG_TI_PACKET_PROCESSOR + /* Initialize the PID and VPID handle. By default the devices are not attached + * to the Packet Processor PDSP. The PID handle will be overwritten by the + * driver if this networking device is also a PHYSICAL device. The VPID handle + * is overwritten by the PROFILE if this networking device is a networking + * endpoint i.e. connected to the bridge or IP stack. */ + dev->pid_handle = -1; + dev->vpid_handle = -1; + memset ((void *)&dev->vpid_block, 0xFF, sizeof(TI_PP_VPID)); + dev->vpid_block.qos_clusters_count = 0; +#endif /* CONFIG_TI_PACKET_PROCESSOR */ +#ifdef CONFIG_AVM_PA + avm_pa_dev_init(AVM_PA_DEVINFO(dev)); +#endif setup(dev); strcpy(dev->name, name); return dev; @@ -4411,6 +4593,11 @@ { ASSERT_RTNL(); +#ifdef CONFIG_TI_L2_SELECTIVE_FORWARDER + /* Clear the netdevice pointer stored in the global array */ + ti_free_netdevice_info(dev); +#endif /* CONFIG_TI_L2_SELECTIVE_FORWARDER */ + rollback_registered(dev); /* Finish processing unregister after unlock */ net_set_todo(dev); @@ -4892,6 +5079,60 @@ if (register_pernet_device(&default_device_ops)) goto out; +#ifdef CONFIG_TI_PACKET_PROCESSOR_SIMULATION + { + extern int ti_pp_sys_initialize (unsigned int num_of_fw, TI_PP_FIRMWARE *firmware, TI_PPD_CONFIG *cfg); + + TI_PPD_CONFIG ppd_config; + unsigned int num_of_fw = 0; + TI_PP_FIRMWARE firmware; + + /* Initialize the PPD configuration block. */ + memset ((void *)&ppd_config, 0, sizeof(TI_PPD_CONFIG)); + + /* Initialize the firmware. */ + memset ((void *)&firmware, 0, sizeof(TI_PP_FIRMWARE)); + + /* Initialize the PP Subsystem. */ + if (ti_pp_sys_initialize (num_of_fw, &firmware, &ppd_config) < 0) + { + printk ("Error: Failed to initialize the PP Subsystem\n"); + return -1; + } + + /* Successful.. */ + printk ("Succesfully initialized the PP Subsystem.\n"); + } +#endif /* CONFIG_TI_PACKET_PROCESSOR_SIMULATION */ + +#ifdef CONFIG_TI_PACKET_PROCESSOR + /* Initialize the HIL Core Layer. */ + if (ti_hil_initialize() < 0) + { + printk ("Error: Unable to initialize the HIL Core\n"); + return -1; + } +#endif /* CONFIG_TI_PACKET_PROCESSOR */ + +#ifdef CONFIG_TI_HIL_PROFILE_INTRUSIVE + { + extern TI_HIL_PROFILE hil_intrusive_profile; + + /* Load the Intrusive mode HIL Profile for the system */ + if (ti_hil_register_profile(&hil_intrusive_profile) < 0) + return -1; + } +#endif /* CONFIG_TI_HIL_PROFILE_INTRUSIVE */ + +#ifdef CONFIG_TI_HIL_PROFILE_STATIC + { + extern TI_HIL_PROFILE hil_static_profile; + + /* Load the Static HIL Profile for the system */ + if (ti_hil_register_profile(&hil_static_profile) < 0) + return -1; + } +#endif /* CONFIG_TI_HIL_PROFILE_STATIC */ /* * Initialise the packet receive queues. */ @@ -4969,3 +5210,5 @@ EXPORT_SYMBOL(dev_load); EXPORT_PER_CPU_SYMBOL(softnet_data); +EXPORT_SYMBOL(set_avm_recvhook); +EXPORT_SYMBOL(set_avm_early_recvhook);