Sponsored Content
Top Forums Programming Compiling virtual network adapter driver problem (net_device struct) Post 302465852 by Chrisdot on Sunday 24th of October 2010 03:48:27 PM
Old 10-24-2010
Yes, I have made a little research and found that net_device struct is a little bit different since 2009. I am trying to fit this code to new net_device struct that is no so easy.
Have you got any samples of network drivers basic source code?

I got now:

Code:
#include <linux/module.h>
#include <linux/config.h>
#include <linux/netdevice.h>


int virtualNIC_open(struct net_device *dev) {
 printk("virtualNIC_open called\n");
 netif_start_queue(dev);
 return 0;
}

int virtualNIC_release(struct net_device *dev) {
 printk("virtualNIC_release called\n");
 netif_stop_queue(dev);
 return 0;
}

static int virtualNIC_xmit(struct sk_buff *skb, struct net_device *dev) {
 printk("dummy xmit function called...\n");
 dev_kfree_skb(skb);
 return 0;
}

int virtualNIC_init(struct net_device *dev);


static const struct net_device_ops my_netdev_ops = {
 .ndo_init = virtualNIC_init,
 .ndo_open = virtualNIC_open,
 .ndo_stop = virtualNIC_release,
 .ndo_start_xmit = virtualNIC_xmit,
};

int virtualNIC_init(struct net_device *dev) {
 dev->netdev_ops = &my_netdev_ops;
 printk("virtualNIC device initialized\n");

struct net_device virtualNIC = {
 .netdev_ops = &my_netdev_ops
/* .netdev_ops.ndo_init: virtualNIC_init*/
};

int virtualNIC_init_module(void) {
 int result;
 strcpy(virtualNIC.name, "virtual network adapter");
 if((result = register_netdev(&virtualNIC))) {
  printk("virtualNIC: Error %d initalizing card ...", result);
  return result;
 }
 return 0;
}

I can compile it, but if I type 'insmod mymodule' then segmentation fault occurs. Don't know solution.

Last edited by Chrisdot; 10-24-2010 at 05:42 PM..
 

10 More Discussions You Might Find Interesting

1. Programming

freeBSD device driver (use struct uio)

Hi, everybody I have next problem... 1) My Example program code void main() { int fd; int len; int buf; fd=open("mydev", O_RDONLY); lseek(fd, 0, SEEK_SET); len=read(fd, buf, sizeof(buf)); } 2) My Example Driver code static int mydev_read(dev_t dev, ?, ?, struct uio* uio) {... (0 Replies)
Discussion started by: Alex_T
0 Replies

2. AIX

Power6 Virtual Fibre Channel Adapter

Hello, Searched in all IBM Redbooks and on the internet and couldn't find anything about the new feature of POWER 6 which Virtual Fibre ( Fiber ) channel adapter. It is similar to virtual scsi adapter. In my client partition I created the virtual Fibre Adapter mapped it with the VIO... (1 Reply)
Discussion started by: filosophizer
1 Replies

3. AIX

How to active this network adapter?

When I configure two VIO Servers, VIOS1 used to ping its gateway, after I configured second VIOS2, VIOS1 cannpt ping its gateway, when I run this command: entstat -all ent#|grep -i priority Priority: 5 Active: False How to make Active to True? (1 Reply)
Discussion started by: rainbow_bean
1 Replies

4. UNIX for Dummies Questions & Answers

Simulated driver for Network Interface Adapter

Hi all, I got sort of a task to do. I have to write in C "simulated network driver". What does it mean? - It has to run on all network adapters - It has to be as simple as it can be - It has to run on all linux distributions (or at least most of them) - It does not have to run a network... (4 Replies)
Discussion started by: Chrisdot
4 Replies

5. AIX

Setting up an Integrated Virtual Ethernet adapter

All I am trying allocate an IVE to an LPAR (not a VIO) running AIX 7.1. I am getting the error: HSCL068A Explanation Logical port can not be assigned to Logical Partition because this Logical Partition is not the promiscuous LPAR for the physical port. Has anyone encountered this... (1 Reply)
Discussion started by: johnf
1 Replies

6. Programming

Storing C++-struct in file - problem when adding new item in struct

Hi, I have received an application that stores some properties in a file. The existing struct looks like this: struct TData { UINT uSizeIncludingStrings; // copy of Telnet data struct UINT uSize; // basic properties: TCHAR szHost; //defined in Sshconfig UINT iPortNr; TCHAR... (2 Replies)
Discussion started by: Powerponken
2 Replies

7. AIX

Adding Virtual Adapter to LPAR

Hello, hopefully someone can help me out with this, I have created a virtual Ethernet adapter on the VIO but would like to add it to my new LPAR. On my VIO only my disk is mapped. $ lsmap -all SVSA Physloc Client Partition ID --------------- --------------------------------------------... (5 Replies)
Discussion started by: audis$
5 Replies

8. IP Networking

Virtual Adapter MAC address..

Hi, I just want to know whether two MAC address can exist in a adapter.. I mean one there will be mandatory one And another as user defined one.. Any replies will be more helpful.. Please help.. :wall: (0 Replies)
Discussion started by: Priya Amaresh
0 Replies

9. Hardware

Need Sun 10-Gigabit Ethernet Adapter CD or ixge driver

Hi, Does anybody have a "Sun 10-Gigabit Ethernet Adapter installation CD" or driver ixge for Sun 10-Gigabit Ethernet PCI-X adapter? I need it but can't find it anywhere. So if you know where I can download it or purchase it, please let me know. (Already tried Oracle's website, don't have it) ... (5 Replies)
Discussion started by: Lhao
5 Replies

10. Solaris

Attach Solaris 11.1 rwn driver to RaLink RT8200/8260 Wi Fi Adapter

I installed Solaris 11.1 on a X86 PC. It's working except for one glaring problem : I cannot get a driver attached to the RaLink RT2800 (Wi Fi Adapter). Can someone point me in the direction where " the correct" driver exists, or let me know how I can tell Solaris to attach the device to the... (1 Reply)
Discussion started by: JWH
1 Replies
STRUCT 
WIRELESS_DEV(9) Device registration STRUCT WIRELESS_DEV(9) NAME
struct_wireless_dev - wireless device state SYNOPSIS
struct wireless_dev { struct wiphy * wiphy; enum nl80211_iftype iftype; struct list_head list; struct net_device * netdev; u32 identifier; struct list_head mgmt_registrations; spinlock_t mgmt_registrations_lock; struct mutex mtx; struct work_struct cleanup_work; bool use_4addr; bool p2p_started; u8 address[ETH_ALEN]; u8 ssid[IEEE80211_MAX_SSID_LEN]; u8 ssid_len; u8 mesh_id_len; u8 mesh_id_up_len; enum wext; #endif }; MEMBERS
wiphy pointer to hardware description iftype interface type list (private) Used to collect the interfaces netdev (private) Used to reference back to the netdev, may be NULL identifier (private) Identifier used in nl80211 to identify this wireless device if it has no netdev mgmt_registrations list of registrations for management frames mgmt_registrations_lock lock for the list mtx mutex used to lock data in this struct cleanup_work work struct used for cleanup that can't be done directly use_4addr indicates 4addr mode is used on this interface, must be set by driver (if supported) on add_interface BEFORE registering the netdev and may otherwise be used by driver read-only, will be update by cfg80211 on change_interface p2p_started true if this is a P2P Device that has been started address[ETH_ALEN] The address for this device, valid only if netdev is NULL ssid[IEEE80211_MAX_SSID_LEN] (private) Used by the internal configuration code ssid_len (private) Used by the internal configuration code mesh_id_len (private) Used by the internal configuration code mesh_id_up_len (private) Used by the internal configuration code wext (private) Used by the internal wireless extensions compat code DESCRIPTION
For netdevs, this structure must be allocated by the driver that uses the ieee80211_ptr field in struct net_device (this is intentional so it can be allocated along with the netdev.) It need not be registered then as netdev registration will be intercepted by cfg80211 to see the new wireless device. For non-netdev uses, it must also be allocated by the driver in response to the cfg80211 callbacks that require it, as there's no netdev registration in that case it may not be allocated outside of callback operations that return it. AUTHOR
Johannes Berg <johannes@sipsolutions.net> Author. COPYRIGHT
Kernel Hackers Manual 3.10 June 2014 STRUCT WIRELESS_DEV(9)
All times are GMT -4. The time now is 10:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy