]> err.no Git - linux-2.6/blobdiff - drivers/net/wireless/libertas/tx.c
libertas: implement new scanning logic
[linux-2.6] / drivers / net / wireless / libertas / tx.c
index d4b13478c9a7efaf3c48c5fda957c2df46b73d21..b423ce1ff42bf238fc21a0dfaebb3fd50db3c810 100644 (file)
@@ -5,7 +5,6 @@
 
 #include "hostcmd.h"
 #include "radiotap.h"
-#include "sbi.h"
 #include "decl.h"
 #include "defs.h"
 #include "dev.h"
@@ -53,13 +52,12 @@ static u32 convert_radiotap_rate_to_mv(u8 rate)
  *  @brief This function processes a single packet and sends
  *  to IF layer
  *
- *  @param priv    A pointer to wlan_private structure
+ *  @param priv    A pointer to struct lbs_private structure
  *  @param skb     A pointer to skb which includes TX packet
  *  @return       0 or -1
  */
-static int SendSinglePacket(wlan_private * priv, struct sk_buff *skb)
+static int SendSinglePacket(struct lbs_private *priv, struct sk_buff *skb)
 {
-       wlan_adapter *adapter = priv->adapter;
        int ret = 0;
        struct txpd localtxpd;
        struct txpd *plocaltxpd = &localtxpd;
@@ -68,17 +66,13 @@ static int SendSinglePacket(wlan_private * priv, struct sk_buff *skb)
        u32 new_rate;
        u8 *ptr = priv->adapter->tmptxbuf;
 
-       ENTER();
+       lbs_deb_enter(LBS_DEB_TX);
 
        if (priv->adapter->surpriseremoved)
                return -1;
 
-       if ((priv->adapter->debugmode & MRVDRV_DEBUG_TX_PATH) != 0)
-               lbs_dbg_hex("TX packet: ", skb->data,
-                        min_t(unsigned int, skb->len, 100));
-
        if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) {
-               lbs_pr_debug(1, "Tx error: Bad skb length %d : %zd\n",
+               lbs_deb_tx("tx err: skb length %d 0 or > %zd\n",
                       skb->len, MRVDRV_ETH_TX_PACKET_BUFFER_SIZE);
                ret = -1;
                goto done;
@@ -86,16 +80,13 @@ static int SendSinglePacket(wlan_private * priv, struct sk_buff *skb)
 
        memset(plocaltxpd, 0, sizeof(struct txpd));
 
-       plocaltxpd->tx_packet_length = skb->len;
+       plocaltxpd->tx_packet_length = cpu_to_le16(skb->len);
 
        /* offset of actual data */
-       plocaltxpd->tx_packet_location = sizeof(struct txpd);
-
-       /* TxCtrl set by user or default */
-       plocaltxpd->tx_control = adapter->pkttxctrl;
+       plocaltxpd->tx_packet_location = cpu_to_le32(sizeof(struct txpd));
 
        p802x_hdr = skb->data;
-       if (priv->adapter->radiomode == WLAN_RADIOMODE_RADIOTAP) {
+       if (priv->adapter->monitormode != LBS_MONITOR_OFF) {
 
                /* locate radiotap header */
                pradiotap_hdr = (struct tx_radiotap_hdr *)skb->data;
@@ -103,48 +94,48 @@ static int SendSinglePacket(wlan_private * priv, struct sk_buff *skb)
                /* set txpd fields from the radiotap header */
                new_rate = convert_radiotap_rate_to_mv(pradiotap_hdr->rate);
                if (new_rate != 0) {
-                       /* erase tx_control[4:0] */
-                       plocaltxpd->tx_control &= ~0x1f;
-                       /* write new tx_control[4:0] */
-                       plocaltxpd->tx_control |= new_rate;
+                       /* use new tx_control[4:0] */
+                       plocaltxpd->tx_control = cpu_to_le32(new_rate);
                }
 
                /* skip the radiotap header */
                p802x_hdr += sizeof(struct tx_radiotap_hdr);
-               plocaltxpd->tx_packet_length -= sizeof(struct tx_radiotap_hdr);
+               plocaltxpd->tx_packet_length =
+                       cpu_to_le16(le16_to_cpu(plocaltxpd->tx_packet_length)
+                                   - sizeof(struct tx_radiotap_hdr));
 
        }
        /* copy destination address from 802.3 or 802.11 header */
-       if (priv->adapter->linkmode == WLAN_LINKMODE_802_11)
+       if (priv->adapter->monitormode != LBS_MONITOR_OFF)
                memcpy(plocaltxpd->tx_dest_addr_high, p802x_hdr + 4, ETH_ALEN);
        else
                memcpy(plocaltxpd->tx_dest_addr_high, p802x_hdr, ETH_ALEN);
 
-       lbs_dbg_hex("txpd", (u8 *) plocaltxpd, sizeof(struct txpd));
+       lbs_deb_hex(LBS_DEB_TX, "txpd", (u8 *) plocaltxpd, sizeof(struct txpd));
 
        if (IS_MESH_FRAME(skb)) {
-               plocaltxpd->tx_control |= TxPD_MESH_FRAME;
+               plocaltxpd->tx_control |= cpu_to_le32(TxPD_MESH_FRAME);
        }
 
        memcpy(ptr, plocaltxpd, sizeof(struct txpd));
 
        ptr += sizeof(struct txpd);
 
-       lbs_dbg_hex("Tx Data", (u8 *) p802x_hdr, plocaltxpd->tx_packet_length);
-       memcpy(ptr, p802x_hdr, plocaltxpd->tx_packet_length);
-       ret = libertas_sbi_host_to_card(priv, MVMS_DAT,
-                              priv->adapter->tmptxbuf,
-                              plocaltxpd->tx_packet_length +
-                              sizeof(struct txpd));
+       lbs_deb_hex(LBS_DEB_TX, "Tx Data", (u8 *) p802x_hdr, le16_to_cpu(plocaltxpd->tx_packet_length));
+       memcpy(ptr, p802x_hdr, le16_to_cpu(plocaltxpd->tx_packet_length));
+       ret = priv->hw_host_to_card(priv, MVMS_DAT,
+                                   priv->adapter->tmptxbuf,
+                                   le16_to_cpu(plocaltxpd->tx_packet_length) +
+                                   sizeof(struct txpd));
 
        if (ret) {
-               lbs_pr_debug(1, "Tx error: libertas_sbi_host_to_card failed: 0x%X\n", ret);
+               lbs_deb_tx("tx err: hw_host_to_card returned 0x%X\n", ret);
                goto done;
        }
 
-       lbs_pr_debug(1, "SendSinglePacket succeeds\n");
+       lbs_deb_tx("SendSinglePacket succeeds\n");
 
-      done:
+done:
        if (!ret) {
                priv->stats.tx_packets++;
                priv->stats.tx_bytes += skb->len;
@@ -153,12 +144,14 @@ static int SendSinglePacket(wlan_private * priv, struct sk_buff *skb)
                priv->stats.tx_errors++;
        }
 
-       if (!ret && priv->adapter->radiomode == WLAN_RADIOMODE_RADIOTAP) {
+       if (!ret && priv->adapter->monitormode != LBS_MONITOR_OFF) {
                /* Keep the skb to echo it back once Tx feedback is
                   received from FW */
                skb_orphan(skb);
                /* stop processing outgoing pkts */
-               netif_stop_queue(priv->wlan_dev.netdev);
+               netif_stop_queue(priv->dev);
+               if (priv->mesh_dev)
+                       netif_stop_queue(priv->mesh_dev);
                /* freeze any packets already in our queues */
                priv->adapter->TxLockFlag = 1;
        } else {
@@ -166,14 +159,14 @@ static int SendSinglePacket(wlan_private * priv, struct sk_buff *skb)
                priv->adapter->currenttxskb = NULL;
        }
 
-       LEAVE();
+       lbs_deb_leave_args(LBS_DEB_TX, "ret %d", ret);
        return ret;
 }
 
 
-void libertas_tx_runqueue(wlan_private *priv)
+void lbs_tx_runqueue(struct lbs_private *priv)
 {
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_adapter *adapter = priv->adapter;
        int i;
 
        spin_lock(&adapter->txqueue_lock);
@@ -187,18 +180,23 @@ void libertas_tx_runqueue(wlan_private *priv)
        spin_unlock(&adapter->txqueue_lock);
 }
 
-static void wlan_tx_queue(wlan_private *priv, struct sk_buff *skb)
+static void lbs_tx_queue(struct lbs_private *priv, struct sk_buff *skb)
 {
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_adapter *adapter = priv->adapter;
 
        spin_lock(&adapter->txqueue_lock);
 
        WARN_ON(priv->adapter->tx_queue_idx >= NR_TX_QUEUE);
        adapter->tx_queue_ps[adapter->tx_queue_idx++] = skb;
-       if (adapter->tx_queue_idx == NR_TX_QUEUE)
-               netif_stop_queue(priv->wlan_dev.netdev);
-       else
-               netif_start_queue(priv->wlan_dev.netdev);
+       if (adapter->tx_queue_idx == NR_TX_QUEUE) {
+               netif_stop_queue(priv->dev);
+               if (priv->mesh_dev)
+                       netif_stop_queue(priv->mesh_dev);
+       } else {
+               netif_start_queue(priv->dev);
+               if (priv->mesh_dev)
+                       netif_start_queue(priv->mesh_dev);
+       }
 
        spin_unlock(&adapter->txqueue_lock);
 }
@@ -207,26 +205,25 @@ static void wlan_tx_queue(wlan_private *priv, struct sk_buff *skb)
  *  @brief This function checks the conditions and sends packet to IF
  *  layer if everything is ok.
  *
- *  @param priv    A pointer to wlan_private structure
+ *  @param priv    A pointer to struct lbs_private structure
  *  @return       n/a
  */
-int libertas_process_tx(wlan_private * priv, struct sk_buff *skb)
+int lbs_process_tx(struct lbs_private *priv, struct sk_buff *skb)
 {
        int ret = -1;
 
-       ENTER();
-
-       lbs_dbg_hex("TX Data", skb->data, min_t(unsigned int, skb->len, 100));
+       lbs_deb_enter(LBS_DEB_TX);
+       lbs_deb_hex(LBS_DEB_TX, "TX Data", skb->data, min_t(unsigned int, skb->len, 100));
 
-       if (priv->wlan_dev.dnld_sent) {
+       if (priv->dnld_sent) {
                lbs_pr_alert( "TX error: dnld_sent = %d, not sending\n",
-                      priv->wlan_dev.dnld_sent);
+                      priv->dnld_sent);
                goto done;
        }
 
        if ((priv->adapter->psstate == PS_STATE_SLEEP) ||
            (priv->adapter->psstate == PS_STATE_PRE_SLEEP)) {
-               wlan_tx_queue(priv, skb);
+               lbs_tx_queue(priv, skb);
                return ret;
        }
 
@@ -234,7 +231,7 @@ int libertas_process_tx(wlan_private * priv, struct sk_buff *skb)
 
        ret = SendSinglePacket(priv, skb);
 done:
-       LEAVE();
+       lbs_deb_leave_args(LBS_DEB_TX, "ret %d", ret);
        return ret;
 }
 
@@ -242,29 +239,25 @@ done:
  *  @brief This function sends to the host the last transmitted packet,
  *  filling the radiotap headers with transmission information.
  *
- *  @param priv     A pointer to wlan_private structure
+ *  @param priv     A pointer to struct lbs_private structure
  *  @param status   A 32 bit value containing transmission status.
  *
  *  @returns void
  */
-void libertas_send_tx_feedback(wlan_private * priv)
+void lbs_send_tx_feedback(struct lbs_private *priv)
 {
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_adapter *adapter = priv->adapter;
        struct tx_radiotap_hdr *radiotap_hdr;
        u32 status = adapter->eventcause;
        int txfail;
        int try_count;
 
-       if (adapter->radiomode != WLAN_RADIOMODE_RADIOTAP ||
+       if (adapter->monitormode == LBS_MONITOR_OFF ||
            adapter->currenttxskb == NULL)
                return;
 
        radiotap_hdr = (struct tx_radiotap_hdr *)adapter->currenttxskb->data;
 
-       if ((adapter->debugmode & MRVDRV_DEBUG_TX_PATH) != 0)
-               lbs_dbg_hex("TX feedback: ", (u8 *) radiotap_hdr,
-                       min_t(unsigned int, adapter->currenttxskb->len, 100));
-
        txfail = (status >> 24);
 
 #if 0
@@ -277,9 +270,14 @@ void libertas_send_tx_feedback(wlan_private * priv)
        try_count = (status >> 16) & 0xff;
        radiotap_hdr->data_retries = (try_count) ?
            (1 + adapter->txretrycount - try_count) : 0;
-       libertas_upload_rx_packet(priv, adapter->currenttxskb);
+       lbs_upload_rx_packet(priv, adapter->currenttxskb);
        adapter->currenttxskb = NULL;
        priv->adapter->TxLockFlag = 0;
-       if (priv->adapter->connect_status == libertas_connected)
-               netif_wake_queue(priv->wlan_dev.netdev);
+
+       if (adapter->connect_status == LBS_CONNECTED)
+               netif_wake_queue(priv->dev);
+
+       if (priv->mesh_dev && (adapter->mesh_connect_status == LBS_CONNECTED))
+               netif_wake_queue(priv->mesh_dev);
 }
+EXPORT_SYMBOL_GPL(lbs_send_tx_feedback);