Re: hi Question about construct the sk_buff
hi all: I fix it. I make a error with: ### skb_reset_tail_pointer(skb); send_skb-end = skb-tail + len + NUM; kmemcheck_annotate_bitfield(skb, flags1); kmemcheck_annotate_bitfield(skb, flags2); //send_skb-ip_summed = CHECKSUM_PARTIAL; struct skb_shared_info *shinfo; shinfo = skb_shinfo(skb); atomic_set(shinfo-dataref, 2); shinfo-nr_frags = 0; shinfo-gso_size = 0; shinfo-gso_segs = 0; shinfo-gso_type = 0; shinfo-ip6_frag_id = 0; shinfo-tx_flags.flags = 0; skb_frag_list_init(skb); ### I should use send_skb instead of skb. 2014-09-25 17:58 GMT+08:00 lx lxlenovos...@gmail.com: hi all: I have a mmap memory area, so I don't want to use alloc_skb(). I use this way: 1. use kmem_cache_alloc_node() for sk_buff struct. 2. the mmap memory area of mmap_buf for data area of packet. the codes is: alloc data memory area: ### mmap_buf = vmalloc(mmap_size); printk(vmalloc mmap_buf=%p mmap_size=%ld\n, (void *)mmap_buf, mmap_size); if (!mmap_buf ) { printk(vmalloc failed!\n); return -1; } for (i = 0; i mmap_size; i += PAGE_SIZE) { SetPageReserved(vmalloc_to_page(mmap_buf + i)); } ### I will mmap the mmap_buf area, in this way: ### while (size 0) { pfn = vmalloc_to_pfn(ptmp); if ((ret = remap_pfn_range(vma, start, pfn, PAGE_SIZE, PAGE_SHARED)) 0) { return ret; } start += PAGE_SIZE; ptmp += PAGE_SIZE; size -= PAGE_SIZE; } ### construct packet /* * send packet */ spin_lock(lock); int eth_len, udph_len, iph_len, len; eth_len = sizeof(struct ethhdr); iph_len = sizeof(struct iphdr); udph_len = sizeof(struct udphdr); len = eth_len + iph_len + udph_len; /* * build a new sk_buff */ struct sk_buff *send_skb = kmem_cache_alloc_node(skbuff_head_cache, GFP_ATOMIC ~__GFP_DMA, NUMA_NO_NODE); if (!send_skb) { return NF_DROP; } memset(send_skb, 0, offsetof(struct sk_buff, tail)); atomic_set(send_skb-users, 2); send_skb-head = mmap_buf + 1024; send_skb-data = mmap_buf + 1024; skb_reset_tail_pointer(skb); send_skb-end = skb-tail + len + NUM; kmemcheck_annotate_bitfield(skb, flags1); kmemcheck_annotate_bitfield(skb, flags2); //send_skb-ip_summed = CHECKSUM_PARTIAL; struct skb_shared_info *shinfo; shinfo = skb_shinfo(skb); atomic_set(shinfo-dataref, 2); shinfo-nr_frags = 0; shinfo-gso_size = 0; shinfo-gso_segs = 0; shinfo-gso_type = 0; shinfo-ip6_frag_id = 0; shinfo-tx_flags.flags = 0; skb_frag_list_init(skb); memset(shinfo-hwtstamps, 0, sizeof(shinfo-hwtstamps)); printk(mmap_buf + 1024 is %p\n, mmap_buf + 1024); skb_reserve(send_skb, len); printk(data %p, len is %d\n, send_skb-data, len); skb_push(send_skb, sizeof(struct udphdr)); printk(udp data %p\n, send_skb-data); skb_reset_transport_header(send_skb); /* * just instead of copy datas. */ //send_skb-tail = send_skb-end; udph = udp_hdr(send_skb); udph-source = dport; udph-dest = htons(ntohs(dport) + 1); udph-len = htons(udph_len); udph-check = 0; udph-check = csum_tcpudp_magic(daddr, in_aton(dest_addr), udph_len, IPPROTO_UDP, csum_partial(udph, udph_len, 0)); if (udph-check == 0) udph-check = CSUM_MANGLED_0; skb_push(send_skb, sizeof(struct iphdr)); printk(ip data %p\n, send_skb-data); skb_reset_network_header(send_skb); send_iph = ip_hdr(send_skb); // iph-version = 4; iph-ihl = 5; put_unaligned(0x45, (unsigned char *)send_iph); send_iph-tos = 0; put_unaligned(htons(iph_len) + htons(udph_len), (send_iph-tot_len)); //send_iph-id = htons(atomic_inc_return(ip_ident)); send_iph-id = 0; send_iph-frag_off = 0; send_iph-ttl = 64; send_iph-protocol = IPPROTO_UDP; send_iph-check = 0; put_unaligned(daddr, (send_iph-saddr)); put_unaligned(in_aton(dest_addr), (send_iph-daddr)); send_iph-check= ip_fast_csum((unsigned char *)send_iph, send_iph-ihl); struct net_device *dev = skb-dev; eth = (struct ethhdr *)skb_push(send_skb, ETH_HLEN); printk(eth data %p\n, send_skb-data); skb_reset_mac_header(send_skb); send_skb-protocol = eth-h_proto = htons(ETH_P_IP); //printk(dev_addr is %p, len is %d, dev-dev_addr, ETH_ALEN); printk(h_source is %p, dev_addr is %p, len is %d, eth-h_source, dev-dev_addr, ETH_ALEN); memcpy(eth-h_source, dev-dev_addr, ETH_ALEN); u8 dst_mac[ETH_ALEN] = DST_MAC; memcpy(eth-h_dest, dst_mac, ETH_ALEN); send_skb-dev = dev; int result = dev_queue_xmit(send_skb); printk(result is %d\n, result); spin_unlock(lock); But I think construct packet is wrong, and Oops is: 1BUG: unable to handle kernel paging request at
Doubt in USB Drivers
Hi to all I am new to Linux Kernel Programming .I want to develop usb drivers so i read LDD3 Chapter 14. i didn't find /sbin/hotplug in Ubuntu 12.04.And my doubt is how kernel handles the usb devices i.e who detects usb events ,then who fires hotplug script to run ,where kernel searches corresponding module ,who loads the modules etc... Any resources are helpful to me Thanks to all ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Doubt in USB Drivers
On Sep 28, 2014 4:28 PM, me storage me.storage...@gmail.com wrote: Hi to all I am new to Linux Kernel Programming .I want to develop usb drivers so i read LDD3 Chapter 14. i didn't find /sbin/hotplug in Ubuntu 12.04.And my doubt is how kernel handles the usb devices i.e who detects usb events ,then who fires hotplug script to run ,where kernel searches corresponding module ,who loads the modules etc... is it related to the task of Eudyptula Challenge?? looks like Any resources are helpful to me Thanks to all ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Doubt in USB Drivers
Yes it is a task in Eudyptula Challenge, I read the chapter which little mentioned ,after searching on google i found some solutions but i don't want to copy those solutions i want to solve my self .So that's why i asked for resources not any solution ? Please try to understand . Thanks to all On 28 September 2014 19:27, Sudip Mukherjee sudipm.mukher...@gmail.com wrote: On Sep 28, 2014 4:28 PM, me storage me.storage...@gmail.com wrote: Hi to all I am new to Linux Kernel Programming .I want to develop usb drivers so i read LDD3 Chapter 14. i didn't find /sbin/hotplug in Ubuntu 12.04.And my doubt is how kernel handles the usb devices i.e who detects usb events ,then who fires hotplug script to run ,where kernel searches corresponding module ,who loads the modules etc... is it related to the task of Eudyptula Challenge?? looks like Any resources are helpful to me Thanks to all ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Doubt in USB Drivers
Little will remove you from the challenge if you ask questions in public. If this hasn't already happened... keep reading, take your time, and figure it out yourself! Good luck. On Sun, Sep 28, 2014 at 11:35 AM, me storage me.storage...@gmail.com wrote: Yes it is a task in Eudyptula Challenge, I read the chapter which little mentioned ,after searching on google i found some solutions but i don't want to copy those solutions i want to solve my self .So that's why i asked for resources not any solution ? Please try to understand . Thanks to all On 28 September 2014 19:27, Sudip Mukherjee sudipm.mukher...@gmail.com wrote: On Sep 28, 2014 4:28 PM, me storage me.storage...@gmail.com wrote: Hi to all I am new to Linux Kernel Programming .I want to develop usb drivers so i read LDD3 Chapter 14. i didn't find /sbin/hotplug in Ubuntu 12.04.And my doubt is how kernel handles the usb devices i.e who detects usb events ,then who fires hotplug script to run ,where kernel searches corresponding module ,who loads the modules etc... is it related to the task of Eudyptula Challenge?? looks like Any resources are helpful to me Thanks to all ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Doubt in USB Drivers
On Sun, 28 Sep 2014 16:27:06 +0530, me storage said: I am new to Linux Kernel Programming .I want to develop usb drivers so i read LDD3 Chapter 14. i didn't find /sbin/hotplug in Ubuntu 12.04.And my LDD3 is about a 2.6.10 kernel. Ubuntu 12.04 shipped a 3.2.14 kernel. % git diff --shortstat v2.6.11 v3.12 54000 files changed, 15378914 insertions(+), 4279326 deletions(-) LDD3 is only about 15 million lines out of date. Have a nice day. (2.6.11 was the first release in the git world, and my linux-next tree doesn't have the 3.2.14 tag in it, but I think that made the point) Now go off and figure out *what* changed on your own, lest you be punted from the Eucalyptus Challenge pgphzENLODWO6.pgp Description: PGP signature ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Query on IIO consumer driver and device tree
Hello, Any pointers?. Regards, Sanchayan. On Sat, Sep 27, 2014 at 12:24 PM, sanchayan maity victorascr...@gmail.com wrote: Hello, There is an ADC driver following the IIO framework. I am using Kernel 3.17 rc5 in an embedded device. I am in the process of writing a consumer IIO touchscreen driver which uses the ADC channels. http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/iio/iio-bindings.txt I am following this document and my device tree node is as follows for the touchscreen driver. vf_touchctrl { compatible = vf-touch; io-channels = adc0 0, adc0 1, adc1 0, adc1 2; pinctrl-names = idle, default; pinctrl-0 = pinctrl_default; pinctrl-1 = pinctrl_idle; gpio-xp = gpio0 8 0 /* Few more gpio entries like this */ }; In the touchscreen driver, i will be using the IIO consumer functions from http://lxr.free-electrons.com/source/include/linux/iio/consumer.h. When i call iio_channel_get_all(), i am expecting to get pointers to the four channels in order specified in the DT above. Is my understanding correct? Then specify these four channel pointers with iio_read_channel_raw() to get the ADC readings. My other question is related to the GPIO entry in the DT above. When using of_get_named_gpio(), i do it like below. int ret = of_get_named_gpio(node, gpio-xp, 0); I do not get the correct values, but negative error values. Also, i can see a argument longer than property error for the device tree parsing in dmesg log. Can someone point out what i am doing wrong here? Thanks Regards, Victor aka Sanchayan. ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies