Staging: octeon-ethernet: Fix race freeing transmit buffers.
[pandora-kernel.git] / drivers / staging / octeon / ethernet-tx.h
1 /*********************************************************************
2  * Author: Cavium Networks
3  *
4  * Contact: support@caviumnetworks.com
5  * This file is part of the OCTEON SDK
6  *
7  * Copyright (c) 2003-2007 Cavium Networks
8  *
9  * This file is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License, Version 2, as
11  * published by the Free Software Foundation.
12  *
13  * This file is distributed in the hope that it will be useful, but
14  * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16  * NONINFRINGEMENT.  See the GNU General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this file; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22  * or visit http://www.gnu.org/licenses/.
23  *
24  * This file may also be available under a different license from Cavium.
25  * Contact Cavium Networks for more information
26 *********************************************************************/
27
28 int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev);
29 int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev);
30 int cvm_oct_transmit_qos(struct net_device *dev, void *work_queue_entry,
31                          int do_free, int qos);
32 void cvm_oct_tx_shutdown(struct net_device *dev);
33
34 /**
35  * Free dead transmit skbs.
36  *
37  * @priv:               The driver data
38  * @skb_to_free:        The number of SKBs to free (free none if negative).
39  * @qos:                The queue to free from.
40  * @take_lock:          If true, acquire the skb list lock.
41  */
42 static inline void cvm_oct_free_tx_skbs(struct octeon_ethernet *priv,
43                                         int skb_to_free,
44                                         int qos, int take_lock)
45 {
46         /* Free skbuffs not in use by the hardware.  */
47         if (skb_to_free > 0) {
48                 if (take_lock)
49                         spin_lock(&priv->tx_free_list[qos].lock);
50                 while (skb_to_free > 0) {
51                         dev_kfree_skb(__skb_dequeue(&priv->tx_free_list[qos]));
52                         skb_to_free--;
53                 }
54                 if (take_lock)
55                         spin_unlock(&priv->tx_free_list[qos].lock);
56         }
57 }