libertas: add access functions for mesh open/connect status
[safe/jmp/linux-2.6] / drivers / net / wireless / libertas / tx.c
index 8a1a396..52d244e 100644 (file)
@@ -3,8 +3,9 @@
   */
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/sched.h>
 
-#include "hostcmd.h"
+#include "host.h"
 #include "radiotap.h"
 #include "decl.h"
 #include "defs.h"
@@ -57,19 +58,17 @@ static u32 convert_radiotap_rate_to_mv(u8 rate)
  *  @param skb     A pointer to skb which includes TX packet
  *  @return       0 or -1
  */
-int lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+netdev_tx_t lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        unsigned long flags;
-       struct lbs_private *priv = dev->priv;
+       struct lbs_private *priv = dev->ml_priv;
        struct txpd *txpd;
        char *p802x_hdr;
        uint16_t pkt_len;
-       int ret;
+       netdev_tx_t ret = NETDEV_TX_OK;
 
        lbs_deb_enter(LBS_DEB_TX);
 
-       ret = NETDEV_TX_OK;
-
        /* We need to protect against the queues being restarted before
           we get round to stopping them */
        spin_lock_irqsave(&priv->driver_lock, flags);
@@ -82,8 +81,8 @@ int lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
                       skb->len, MRVDRV_ETH_TX_PACKET_BUFFER_SIZE);
                /* We'll never manage to send this one; drop it and return 'OK' */
 
-               priv->stats.tx_dropped++;
-               priv->stats.tx_errors++;
+               dev->stats.tx_dropped++;
+               dev->stats.tx_errors++;
                goto free;
        }
 
@@ -93,8 +92,8 @@ int lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
                netif_stop_queue(priv->mesh_dev);
 
        if (priv->tx_pending_len) {
-               /* This can happen if packets come in on the mesh and eth 
-                  device simultaneously -- there's no mutual exclusion on 
+               /* This can happen if packets come in on the mesh and eth
+                  device simultaneously -- there's no mutual exclusion on
                   hard_start_xmit() calls between devices. */
                lbs_deb_tx("Packet on %s while busy\n", dev->name);
                ret = NETDEV_TX_BUSY;
@@ -132,8 +131,7 @@ int lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
        txpd->tx_packet_length = cpu_to_le16(pkt_len);
        txpd->tx_packet_location = cpu_to_le32(sizeof(struct txpd));
 
-       if (dev == priv->mesh_dev)
-               txpd->tx_control |= cpu_to_le32(TxPD_MESH_FRAME);
+       lbs_mesh_set_txpd(priv, dev, txpd);
 
        lbs_deb_hex(LBS_DEB_TX, "txpd", (u8 *) &txpd, sizeof(struct txpd));
 
@@ -146,12 +144,12 @@ int lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        lbs_deb_tx("%s lined up packet\n", __func__);
 
-       priv->stats.tx_packets++;
-       priv->stats.tx_bytes += skb->len;
+       dev->stats.tx_packets++;
+       dev->stats.tx_bytes += skb->len;
 
        dev->trans_start = jiffies;
 
-       if (priv->monitormode != LBS_MONITOR_OFF) {
+       if (priv->monitormode) {
                /* Keep the skb to echo it back once Tx feedback is
                   received from FW */
                skb_orphan(skb);
@@ -179,32 +177,17 @@ int lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
  *
  *  @returns void
  */
-void lbs_send_tx_feedback(struct lbs_private *priv)
+void lbs_send_tx_feedback(struct lbs_private *priv, u32 try_count)
 {
        struct tx_radiotap_hdr *radiotap_hdr;
-       u32 status = priv->eventcause;
-       int txfail;
-       int try_count;
 
-       if (priv->monitormode == LBS_MONITOR_OFF ||
-           priv->currenttxskb == NULL)
+       if (!priv->monitormode || priv->currenttxskb == NULL)
                return;
 
        radiotap_hdr = (struct tx_radiotap_hdr *)priv->currenttxskb->data;
 
-       txfail = (status >> 24);
-
-#if 0
-       /* The version of roofnet that we've tested does not use this yet
-        * But it may be used in the future.
-        */
-       if (txfail)
-               radiotap_hdr->flags &= IEEE80211_RADIOTAP_F_TX_FAIL;
-#endif
-       try_count = (status >> 16) & 0xff;
-       radiotap_hdr->data_retries = (try_count) ?
-           (1 + priv->txretrycount - try_count) : 0;
-
+       radiotap_hdr->data_retries = try_count ?
+               (1 + priv->txretrycount - try_count) : 0;
 
        priv->currenttxskb->protocol = eth_type_trans(priv->currenttxskb,
                                                      priv->rtap_net_dev);
@@ -215,7 +198,7 @@ void lbs_send_tx_feedback(struct lbs_private *priv)
        if (priv->connect_status == LBS_CONNECTED)
                netif_wake_queue(priv->dev);
 
-       if (priv->mesh_dev && (priv->mesh_connect_status == LBS_CONNECTED))
+       if (priv->mesh_dev && lbs_mesh_connected(priv))
                netif_wake_queue(priv->mesh_dev);
 }
 EXPORT_SYMBOL_GPL(lbs_send_tx_feedback);