diff options
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 99 |
1 files changed, 3 insertions, 96 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 7596fc9403c8..ac55d84d6255 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -167,25 +167,6 @@ static DEFINE_SPINLOCK(ptype_lock); | |||
167 | static struct list_head ptype_base[PTYPE_HASH_SIZE] __read_mostly; | 167 | static struct list_head ptype_base[PTYPE_HASH_SIZE] __read_mostly; |
168 | static struct list_head ptype_all __read_mostly; /* Taps */ | 168 | static struct list_head ptype_all __read_mostly; /* Taps */ |
169 | 169 | ||
170 | #ifdef CONFIG_NET_DMA | ||
171 | struct net_dma { | ||
172 | struct dma_client client; | ||
173 | spinlock_t lock; | ||
174 | cpumask_t channel_mask; | ||
175 | struct dma_chan **channels; | ||
176 | }; | ||
177 | |||
178 | static enum dma_state_client | ||
179 | netdev_dma_event(struct dma_client *client, struct dma_chan *chan, | ||
180 | enum dma_state state); | ||
181 | |||
182 | static struct net_dma net_dma = { | ||
183 | .client = { | ||
184 | .event_callback = netdev_dma_event, | ||
185 | }, | ||
186 | }; | ||
187 | #endif | ||
188 | |||
189 | /* | 170 | /* |
190 | * The @dev_base_head list is protected by @dev_base_lock and the rtnl | 171 | * The @dev_base_head list is protected by @dev_base_lock and the rtnl |
191 | * semaphore. | 172 | * semaphore. |
@@ -4826,81 +4807,6 @@ static int dev_cpu_callback(struct notifier_block *nfb, | |||
4826 | return NOTIFY_OK; | 4807 | return NOTIFY_OK; |
4827 | } | 4808 | } |
4828 | 4809 | ||
4829 | #ifdef CONFIG_NET_DMA | ||
4830 | /** | ||
4831 | * netdev_dma_event - event callback for the net_dma_client | ||
4832 | * @client: should always be net_dma_client | ||
4833 | * @chan: DMA channel for the event | ||
4834 | * @state: DMA state to be handled | ||
4835 | */ | ||
4836 | static enum dma_state_client | ||
4837 | netdev_dma_event(struct dma_client *client, struct dma_chan *chan, | ||
4838 | enum dma_state state) | ||
4839 | { | ||
4840 | int i, found = 0, pos = -1; | ||
4841 | struct net_dma *net_dma = | ||
4842 | container_of(client, struct net_dma, client); | ||
4843 | enum dma_state_client ack = DMA_DUP; /* default: take no action */ | ||
4844 | |||
4845 | spin_lock(&net_dma->lock); | ||
4846 | switch (state) { | ||
4847 | case DMA_RESOURCE_AVAILABLE: | ||
4848 | for (i = 0; i < nr_cpu_ids; i++) | ||
4849 | if (net_dma->channels[i] == chan) { | ||
4850 | found = 1; | ||
4851 | break; | ||
4852 | } else if (net_dma->channels[i] == NULL && pos < 0) | ||
4853 | pos = i; | ||
4854 | |||
4855 | if (!found && pos >= 0) { | ||
4856 | ack = DMA_ACK; | ||
4857 | net_dma->channels[pos] = chan; | ||
4858 | cpu_set(pos, net_dma->channel_mask); | ||
4859 | } | ||
4860 | break; | ||
4861 | case DMA_RESOURCE_REMOVED: | ||
4862 | for (i = 0; i < nr_cpu_ids; i++) | ||
4863 | if (net_dma->channels[i] == chan) { | ||
4864 | found = 1; | ||
4865 | pos = i; | ||
4866 | break; | ||
4867 | } | ||
4868 | |||
4869 | if (found) { | ||
4870 | ack = DMA_ACK; | ||
4871 | cpu_clear(pos, net_dma->channel_mask); | ||
4872 | net_dma->channels[i] = NULL; | ||
4873 | } | ||
4874 | break; | ||
4875 | default: | ||
4876 | break; | ||
4877 | } | ||
4878 | spin_unlock(&net_dma->lock); | ||
4879 | |||
4880 | return ack; | ||
4881 | } | ||
4882 | |||
4883 | /** | ||
4884 | * netdev_dma_register - register the networking subsystem as a DMA client | ||
4885 | */ | ||
4886 | static int __init netdev_dma_register(void) | ||
4887 | { | ||
4888 | net_dma.channels = kzalloc(nr_cpu_ids * sizeof(struct net_dma), | ||
4889 | GFP_KERNEL); | ||
4890 | if (unlikely(!net_dma.channels)) { | ||
4891 | printk(KERN_NOTICE | ||
4892 | "netdev_dma: no memory for net_dma.channels\n"); | ||
4893 | return -ENOMEM; | ||
4894 | } | ||
4895 | spin_lock_init(&net_dma.lock); | ||
4896 | dma_cap_set(DMA_MEMCPY, net_dma.client.cap_mask); | ||
4897 | dmaengine_get(); | ||
4898 | return 0; | ||
4899 | } | ||
4900 | |||
4901 | #else | ||
4902 | static int __init netdev_dma_register(void) { return -ENODEV; } | ||
4903 | #endif /* CONFIG_NET_DMA */ | ||
4904 | 4810 | ||
4905 | /** | 4811 | /** |
4906 | * netdev_increment_features - increment feature set by one | 4812 | * netdev_increment_features - increment feature set by one |
@@ -5120,14 +5026,15 @@ static int __init net_dev_init(void) | |||
5120 | if (register_pernet_device(&default_device_ops)) | 5026 | if (register_pernet_device(&default_device_ops)) |
5121 | goto out; | 5027 | goto out; |
5122 | 5028 | ||
5123 | netdev_dma_register(); | ||
5124 | |||
5125 | open_softirq(NET_TX_SOFTIRQ, net_tx_action); | 5029 | open_softirq(NET_TX_SOFTIRQ, net_tx_action); |
5126 | open_softirq(NET_RX_SOFTIRQ, net_rx_action); | 5030 | open_softirq(NET_RX_SOFTIRQ, net_rx_action); |
5127 | 5031 | ||
5128 | hotcpu_notifier(dev_cpu_callback, 0); | 5032 | hotcpu_notifier(dev_cpu_callback, 0); |
5129 | dst_init(); | 5033 | dst_init(); |
5130 | dev_mcast_init(); | 5034 | dev_mcast_init(); |
5035 | #ifdef CONFIG_NET_DMA | ||
5036 | dmaengine_get(); | ||
5037 | #endif | ||
5131 | rc = 0; | 5038 | rc = 0; |
5132 | out: | 5039 | out: |
5133 | return rc; | 5040 | return rc; |