Sending Ethernet packets using dev_queue_xmit from device driver module

598 views
Skip to first unread message

Girish Bopaiah

unread,
Aug 3, 2016, 3:51:36 AM8/3/16
to inside_linux
Dear All,

I have to send some Ethernet packets from my device driver module.
Have completely created Ethernet packet(including mac, IP and data)
By googling I got some API's like dev_queue_xmit.

Could you please guide me on this with example if you have any

--
Regards,
Girish

Anil Kumar Pugalia

unread,
Aug 3, 2016, 10:16:38 AM8/3/16
to inside...@googlegroups.com
Check on of the usage examples in the files listed at http://lxr.free-electrons.com/ident?i=dev_queue_xmit

Regards
Anil
Passion: http://sysplay.in (Playing with Systems)
--
You received this message because you are subscribed to the Google Groups "SysPlay's Inside Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inside_linux...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Girish Bopaiah

unread,
Aug 4, 2016, 1:05:11 PM8/4/16
to inside_linux
Thank you very much Anil for the info. I was able send the Ethernet packets

Have few questions, please clarify
  • when we do "skb = dev_alloc_skb()",  does the memory allocation happens at  tcp/ip stack?
  • If I  call the API  "dev_queue_xmit"  does it communicate with   tcp/ip stack first and then network driver  or directly network driver
  • In the standard Ethernet driver the transmit function is igb_xmit_frame(). When I call  "dev_queue_xmit" API , does this call  igb_xmit_frame() of Ethernet driver 

Regards,
Girish

On Wed, Aug 3, 2016 at 7:46 PM, Anil Kumar Pugalia <em...@sarika-pugs.com> wrote:
Check on of the usage examples in the files listed at http://lxr.free-electrons.com/ident?i=dev_queue_xmit

Regards
Anil
Passion: http://sysplay.in (Playing with Systems)
Girish Bopaiah wrote on Wednesday 03 August 2016 01:21 PM:
Dear All,

I have to send some Ethernet packets from my device driver module.
Have completely created Ethernet packet(including mac, IP and data)
By googling I got some API's like dev_queue_xmit.

Could you please guide me on this with example if you have any

--
Regards,
Girish
--
You received this message because you are subscribed to the Google Groups "SysPlay's Inside Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inside_linux+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "SysPlay's Inside Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inside_linux+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Regards,
Girish

Anil Kumar Pugalia

unread,
Aug 5, 2016, 11:52:07 AM8/5/16
to inside...@googlegroups.com

How does it matter whether at tcp/ip stack or not, because finally it is memory from kernel space?

skb related management is provided the stack layer so what ever skb operations needs to done to transmit the pkt through driver would go through the skb APIs provided by the stack.

Not sure about what is this igb_xmit_frame. Typically the transmit function ptr in the driver is start_xmit.

Regards
Anil
Passion: http://sysplay.in (Playing with Systems)
To unsubscribe from this group and stop receiving emails from it, send an email to inside_linux...@googlegroups.com.

Girish Bopaiah

unread,
Aug 8, 2016, 12:04:09 AM8/8/16
to inside_linux
Thanks Anil.
whatever I mentioned "igb_xmit_frame" is   .ndo_start_xmit

static const struct net_device_ops igb_netdev_ops = {

.ndo_start_xmit     = igb_xmit_frame,
}

The question was does" start_xmit" gets called when I call API "dev_queue_xmit" from other driver module?

Anil Kumar Pugalia

unread,
Aug 8, 2016, 5:18:43 AM8/8/16
to inside...@googlegroups.com

Highly likely - may be you have to dig into the code further.

Regards
Anil
Passion: http://sysplay.in (Playing with Systems)
To unsubscribe from this group and stop receiving emails from it, send an email to inside_linux...@googlegroups.com.

Girish Bopaiah

unread,
Aug 9, 2016, 6:18:16 AM8/9/16
to inside_linux
Yes "igb_xmit_frame" is called. I started debugging code with prints and was able to get prints  for my network packet
I am referring your network training  code also. Its helping me a lot.

Finding out different ways to send packets. Want to use the fastest method since I have to send all the packets after the power failure of system. The hold is very less (9 ms after power failure).

Please let me know if any other alternative to send network packet apart from "dev_queue_xmit" API.  Will try all other probabilities

I  have one more question,  in system  there are many interfaces (eth0,  eth1,  eth2,  eth3). May i Know who assigns this number? Is the network module creating this interface ? which part of the code?

Regards,
Girish

Anil Kumar Pugalia

unread,
Aug 10, 2016, 1:20:58 AM8/10/16
to inside...@googlegroups.com

Seeing your exploration spree, I think that you may find many more ways than what I know.

The name assignment is done when we register using register_netdev based on the value filled in net_device structure by APIs like alloc_etherdev, ...

Regards
Anil
Passion: http://sysplay.in (Playing with Systems)
To unsubscribe from this group and stop receiving emails from it, send an email to inside_linux...@googlegroups.com.

Girish Bopaiah

unread,
Aug 10, 2016, 5:27:13 AM8/10/16
to inside_linux
Thanks a lot for info.
Reply all
Reply to author
Forward
0 new messages