Commit fd1c08f7 authored by Vikram Narayanan's avatar Vikram Narayanan

lcd/liblcd: Add netdev helpers

struct net_device instance of the driver is heavily modified by the kernel. In
order to keep things in sync, we need some internal helpers so as to avoid
volunteering memory for various structures and marshalling lists.These files
pull in a minimal set of helper functions from the kernel to keep things
intact.
Signed-off-by: Vikram Narayanan's avatarVikram Narayanan <vikram186@gmail.com>
parent 15e9218c
#ifndef _LIBLCD_NETDEV_HELPER_H_
#define _LIBLCD_NETDEV_HELPER_H_
int liblcd__hw_addr_sync_dev(struct netdev_hw_addr_list *list,
struct net_device *dev,
int (*sync)(struct net_device *, const unsigned char *),
int (*unsync)(struct net_device *,
const unsigned char *));
void liblcd__hw_addr_unsync_dev(struct netdev_hw_addr_list *list,
struct net_device *dev,
int (*unsync)(struct net_device *,
const unsigned char *));
int netif_alloc_netdev_queues(struct net_device *dev);
int liblcd_dev_addr_add(struct net_device *dev,
const unsigned char *addr,
unsigned char addr_type);
int liblcd_dev_addr_del(struct net_device *dev,
const unsigned char *addr,
unsigned char addr_type);
int netif_alloc_netdev_queues(struct net_device *dev);
#endif /* _LIBLCD_NETDEV_HELPER_H_ */
#include <lcd_config/pre_hook.h>
#include <linux/netdevice.h>
#include <liblcd/netdev_helper.h>
#include <lcd_config/post_hook.h>
static void netdev_init_one_queue(struct net_device *dev,
struct netdev_queue *queue, void *_unused)
{
/* Initialize queue lock */
spin_lock_init(&queue->_xmit_lock);
#ifndef LCD_ISOLATE
netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type);
#endif
queue->xmit_lock_owner = -1;
netdev_queue_numa_node_write(queue, NUMA_NO_NODE);
queue->dev = dev;
#ifdef CONFIG_BQL
dql_init(&queue->dql, HZ);
#endif
}
int netif_alloc_netdev_queues(struct net_device *dev)
{
unsigned int count = dev->num_tx_queues;
struct netdev_queue *tx;
size_t sz = count * sizeof(*tx);
if (count < 1 || count > 0xffff)
return -EINVAL;
tx = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
#ifndef LCD_ISOLATE
if (!tx) {
tx = vzalloc(sz);
#endif
if (!tx)
return -ENOMEM;
#ifndef LCD_ISOLATE
}
#endif
dev->_tx = tx;
netdev_for_each_tx_queue(dev, netdev_init_one_queue, NULL);
spin_lock_init(&dev->tx_global_lock);
return 0;
}
EXPORT_SYMBOL(netif_alloc_netdev_queues);
This diff is collapsed.
......@@ -61,6 +61,11 @@ lib-y += $(addprefix liblcd/arch/x86/dma/, \
pci-dma.o \
)
lib-y += $(addprefix liblcd/net/, \
dev_addr_lists.o \
dev.o \
)
lib-y += liblcd/resolve.o
# code shared by kliblcd and isolated liblcd
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment