Small network device interface changes
Subsystems (2)
cover Small network device interface changes
These cleanups should go in 2.6.24. Hope they don't conflict too bad with the NAPI stuff.
PATCH 1/4 net: cleanup left over decl
Remove unneeded declaration.
Signed-off-by Stephen Hemminger <[email protected]>
include/linux/netdevice.h +0 -2
@@ -833,8 +833,6 @@ extern int dev_set_mac_address(struct nextern int dev_hard_start_xmit (struct sk_buff *skb,struct net_device *dev); -extern void dev_init (void ); -extern int netdev_budget;/* Called by rtnetlink.c:rtnl_unlock() */
PATCH 2/4 net: deinline dev_kfree_skb_irq
In reply to Stephen HemmingerDeinline dev_kfree_skb_irq. This saves about 100bytes per call site on UP, probably more on SMP.
Signed-off-by Stephen Hemminger <[email protected]>
include/linux/netdevice.h +0 -23
@@ -793,29 +793,6 @@ static inline int netif_is_multiqueue(co#endif } -/* Use this variant when it is known for sure that it -* is executing from interrupt context. -*/ -static inline void dev_kfree_skb_irq (struct sk_buff *skb) -{ -if (atomic_dec_and_test (&skb->users)) { -struct softnet_data *sd; -unsigned long flags; - -local_irq_save (flags); - sd = &__get_cpu_var (softnet_data); - skb->next = sd->completion_queue; - sd->completion_queue = skb; -raise_softirq_irqoff (NET_TX_SOFTIRQ ); -local_irq_restore (flags); - } -} - -/* Use this variant in places where it could be invoked -* either from interrupt or non-interrupt context. -*/ -extern void dev_kfree_skb_any (struct sk_buff *skb); -#define HAVE_NETIF_RX 1extern int netif_rx (struct sk_buff *skb);extern int netif_rx_ni (struct sk_buff *skb);
include/linux/skbuff.h +2 -0
@@ -378,6 +378,8 @@ extern int skb_cow_data(struct sk struct sk_buff **trailer);extern int skb_pad (struct sk_buff *skb,int pad);#define dev_kfree_skb (a) kfree_skb(a) +extern void dev_kfree_skb_any (struct sk_buff *skb); +extern void dev_kfree_skb_irq (struct sk_buff *skb);extern void skb_over_panic (struct sk_buff *skb,int len,void *here); extern void skb_under_panic(struct sk_buff *skb, int len,
net/core/dev.c +30 -0
@@ -1249,6 +1249,36 @@ void __netif_rx_schedule(struct net_devi }EXPORT_SYMBOL (__netif_rx_schedule); +/** +* dev_kfree_skb_irq - free skb from IRQ context +* @skb: skb to free +* +* Queue skb for later release. Used when skb needs to be +* free but executing in IRQ context. +*/ +void dev_kfree_skb_irq (struct sk_buff *skb) +{ +if (atomic_dec_and_test (&skb->users)) { +struct softnet_data *sd; +unsigned long flags; + +local_irq_save (flags); + sd = &__get_cpu_var (softnet_data); + skb->next = sd->completion_queue; + sd->completion_queue = skb; +raise_softirq_irqoff (NET_TX_SOFTIRQ ); +local_irq_restore (flags); + } +} +EXPORT_SYMBOL (dev_kfree_skb_irq); + +/** +* dev_kfree_skb_any - free skb from any context +* @skb: skb to free +* +* Free skb from interrupt or non-interrupt context. +* Use this variant in places where context is not easily determined. +*/ void dev_kfree_skb_any (struct sk_buff *skb) {if (in_irq () ||irqs_disabled ())
PATCH 3/4 net: add dev_get_stats
In reply to Stephen HemmingerSince we now have internal stats, it cleans up code to have a dev_get_stats() interface. This allows for future patches where 'network device ops' patch where get_stats is immutable.
Signed-off-by Stephen Hemminger <[email protected]>
include/linux/netdevice.h +1 -0
@@ -809,6 +809,7 @@ extern int dev_set_mac_address(struct n struct sockaddr *);extern int dev_hard_start_xmit (struct sk_buff *skb,struct net_device *dev); +extern struct net_device_stats *dev_get_stats (struct net_device *dev);extern int netdev_budget;
net/core/dev.c +14 -4
@@ -2304,7 +2304,7 @@ void dev_seq_stop(struct seq_file *seq,static void dev_seq_printf_stats (struct seq_file *seq,struct net_device *dev) { -struct net_device_stats *stats = dev->get_stats (dev); +struct net_device_stats *stats =dev_get_stats (dev); seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu " "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
@@ -3682,10 +3682,21 @@ out:mutex_unlock (&net_todo_run_mutex); } -static struct net_device_stats *internal_stats (struct net_device *dev) +/** +* dev_get_stats - get network device statistics +* @dev: network device +* +* Get standard network device statistics. +* Use internal stastics unless device overides +*/ +struct net_device_stats *dev_get_stats (struct net_device *dev) { -return &dev->stats; +if (!dev->get_stats) +return &dev->stats; + +return dev->get_stats (dev); } +EXPORT_SYMBOL (dev_get_stats);/** * alloc_netdev_mq - allocate network device
@@ -3733,7 +3744,6 @@ struct net_device *alloc_netdev_mq(int s dev->egress_subqueue_count = queue_count; - dev->get_stats = internal_stats;setup (dev);strcpy (dev->name, name);return dev;
net/core/net-sysfs.c +2 -4
@@ -264,8 +264,7 @@ static ssize_t netstat_show(const structWARN_ON (1 );read_lock (&dev_base_lock); -if (dev_isalive (dev) && dev->get_stats && - (stats = (*dev->get_stats)(dev))) +if (dev_isalive (dev) && (stats =dev_get_stats (dev))) ret =sprintf (buf, fmt_ulong, *(unsigned long *)(((u8 *) stats) + offset));
@@ -481,8 +480,7 @@ int netdev_register_sysfs(struct net_devBUILD_BUG_ON (BUS_ID_SIZE <IFNAMSIZ );strlcpy (dev->bus_id, net->name,BUS_ID_SIZE ); -if (net->get_stats) - *groups++ = &netstat_group; + *groups++ = &netstat_group;#ifdef CONFIG_WIRELESS_EXT if (net->wireless_handlers && net->wireless_handlers->get_wireless_stats)
net/core/rtnetlink.c +7 -11
@@ -619,6 +619,7 @@ static int rtnl_fill_ifinfo(struct sk_bu {struct ifinfomsg *ifm;struct nlmsghdr *nlh; +struct net_device_stats *stats; nlh =nlmsg_put (skb, pid, seq, type,sizeof (*ifm), flags);if (nlh ==NULL )
@@ -666,18 +667,13 @@ static int rtnl_fill_ifinfo(struct sk_buNLA_PUT (skb,IFLA_BROADCAST , dev->addr_len, dev->broadcast); } -if (dev->get_stats) { -struct net_device_stats *stats = dev->get_stats (dev); -if (stats) { -struct nlattr *attr; - - attr =nla_reserve (skb,IFLA_STATS , -sizeof (struct rtnl_link_stats )); -if (attr ==NULL ) - goto nla_put_failure; +if ((stats =dev_get_stats (dev))) { +struct nlattr *attr =nla_reserve (skb,IFLA_STATS , +sizeof (struct rtnl_link_stats )); +if (attr ==NULL ) + goto nla_put_failure; -copy_rtnl_link_stats (nla_data (attr), stats); - } +copy_rtnl_link_stats (nla_data (attr), stats); }if (dev->rtnl_link_ops) {
PATCH 4/4 net: netdev_budget rearrangement
In reply to Stephen HemmingerTrivial patch, move netdev_budget declaration out of netdevice.h to a new home with the other sysctl externs.
Signed-off-by Stephen Hemminger <[email protected]>
include/linux/netdevice.h +0 -2
@@ -811,8 +811,6 @@ extern int dev_hard_start_xmit(struct s struct net_device *dev);extern struct net_device_stats *dev_get_stats (struct net_device *dev); -extern int netdev_budget; -/* Called by rtnetlink.c:rtnl_unlock() */ extern void netdev_run_todo (void );
net/core/sysctl_net_core.c +1 -0
@@ -13,6 +13,7 @@#ifdef CONFIG_SYSCTL +extern int netdev_budget;extern int netdev_max_backlog;extern int weight_p;