User Tools

Site Tools


alloc_netdev_etherdev

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
alloc_netdev_etherdev [2018/08/28 07:43]
rpjday [alloc_etherdev_mqs()]
alloc_netdev_etherdev [2018/08/28 08:00] (current)
rpjday [netdev private data]
Line 5: Line 5:
 ===== netdev private data ===== ===== netdev private data =====
  
-From ''​netdevice.h'',​ optional private data is stored (aligned) after the end of the structure:+From ''​include/​linux/​netdevice.h'',​ optional private data is stored (aligned) after the end of the structure:
  
 <​code>​ <​code>​
Line 77: Line 77:
  
 Not a lot of drivers call this routine directly given that you can call more convenient wrappers (see below). Not a lot of drivers call this routine directly given that you can call more convenient wrappers (see below).
- 
  
 ===== Wrappers/​variations ===== ===== Wrappers/​variations =====
  
-==== alloc_etherdev_mqs() ====+==== alloc_netdev()/​alloc_netdev_mq() ==== 
 + 
 +From ''​include/​linux/​netdevice.h'':​ 
 + 
 +<​code>​ 
 + 
 +#define alloc_netdev(sizeof_priv,​ name, name_assign_type,​ setup) \ 
 + alloc_netdev_mqs(sizeof_priv,​ name, name_assign_type,​ setup, 1, 1) 
 + 
 +#define alloc_netdev_mq(sizeof_priv,​ name, name_assign_type,​ setup, count) \ 
 + alloc_netdev_mqs(sizeof_priv,​ name, name_assign_type,​ setup, count, \ 
 + count) 
 +</​code>​ 
 + 
 +==== alloc_etherdev(),​alloc_etherdev_mq(),​alloc_etherdev_mqs() ==== 
 + 
 +From ''​include/​linux/​etherdevice.h'':​ 
 + 
 +<​code>​ 
 +struct net_device *alloc_etherdev_mqs(int sizeof_priv,​ unsigned int txqs, 
 +     unsigned int rxqs); 
 +#define alloc_etherdev(sizeof_priv) alloc_etherdev_mq(sizeof_priv,​ 1) 
 +#define alloc_etherdev_mq(sizeof_priv,​ count) alloc_etherdev_mqs(sizeof_priv,​ count, count) 
 +</​code>​
  
 From ''​net/​ethernet/​net.c'':​ From ''​net/​ethernet/​net.c'':​
Line 94: Line 116:
 </​code>​ </​code>​
  
-==== alloc_netdev_mq[s]() ====+==== devm_alloc_etherdev*() ====
  
-From ''​include/​linux/​netdevice.h'':​+From ''​include/​linux/​etherdevice.h'':​
  
 <​code>​ <​code>​
 +struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv,​
 +    ​unsigned int txqs,
 +    ​unsigned int rxqs);
 +#define devm_alloc_etherdev(dev,​ sizeof_priv) devm_alloc_etherdev_mqs(dev,​ sizeof_priv,​ 1, 1)
 +</​code>​
  
-#define alloc_netdev(sizeof_priv,​ name, name_assign_type,​ setup) \ +From ''​net/​ethernet/​net.c'':​
- alloc_netdev_mqs(sizeof_priv,​ name, name_assign_type,​ setup, 1, 1)+
  
-#define alloc_netdev_mq(sizeof_priv, ​namename_assign_typesetupcount\ +<​code>​ 
- alloc_netdev_mqs(sizeof_priv, ​namename_assign_type,​ setup, count, \ +struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv,​ 
- count)+    ​unsigned int txqsunsigned int rxqs) 
 +
 + struct net_device **dr; 
 + struct net_device *netdev; 
 + 
 + dr = devres_alloc(devm_free_netdevsizeof(*dr)GFP_KERNEL); 
 + if (!dr) 
 + return NULL; 
 + 
 + netdev = alloc_etherdev_mqs(sizeof_priv, ​txqsrxqs); 
 + if (!netdev
 + devres_free(dr);​ 
 + return NULL; 
 +
 + 
 + *dr = netdev; 
 + devres_add(dev,​ dr); 
 + 
 + return netdev; 
 +}
 </​code>​ </​code>​
alloc_netdev_etherdev.1535442228.txt.gz · Last modified: 2018/08/28 07:43 by rpjday