]> git.karo-electronics.de Git - linux-beck.git/commitdiff
wil6210: Refactor rx init/fini
authorVladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Mon, 28 Jan 2013 16:30:59 +0000 (18:30 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 30 Jan 2013 20:07:12 +0000 (15:07 -0500)
Move WMI related operations to wmi.c as helper functions

Signed-off-by: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/wil6210/txrx.c
drivers/net/wireless/ath/wil6210/wil6210.h
drivers/net/wireless/ath/wil6210/wmi.c

index 241dd0e9054333d3c5b65237d0d89e37c62a62b1..f3b523b47060cbf0a6396a194df5f2c91002e218 100644 (file)
@@ -484,53 +484,18 @@ void wil_rx_handle(struct wil6210_priv *wil)
 
 int wil_rx_init(struct wil6210_priv *wil)
 {
-       struct net_device *ndev = wil_to_ndev(wil);
-       struct wireless_dev *wdev = wil->wdev;
        struct vring *vring = &wil->vring_rx;
        int rc;
-       struct wmi_cfg_rx_chain_cmd cmd = {
-               .action = WMI_RX_CHAIN_ADD,
-               .rx_sw_ring = {
-                       .max_mpdu_size = cpu_to_le16(RX_BUF_LEN),
-               },
-               .mid = 0, /* TODO - what is it? */
-               .decap_trans_type = WMI_DECAP_TYPE_802_3,
-       };
-       struct {
-               struct wil6210_mbox_hdr_wmi wmi;
-               struct wmi_cfg_rx_chain_done_event evt;
-       } __packed evt;
 
        vring->size = WIL6210_RX_RING_SIZE;
        rc = wil_vring_alloc(wil, vring);
        if (rc)
                return rc;
 
-       cmd.rx_sw_ring.ring_mem_base = cpu_to_le64(vring->pa);
-       cmd.rx_sw_ring.ring_size = cpu_to_le16(vring->size);
-       if (wdev->iftype == NL80211_IFTYPE_MONITOR) {
-               struct ieee80211_channel *ch = wdev->preset_chandef.chan;
-
-               cmd.sniffer_cfg.mode = cpu_to_le32(WMI_SNIFFER_ON);
-               if (ch)
-                       cmd.sniffer_cfg.channel = ch->hw_value - 1;
-               cmd.sniffer_cfg.phy_info_mode =
-                       cpu_to_le32(ndev->type == ARPHRD_IEEE80211_RADIOTAP);
-               cmd.sniffer_cfg.phy_support =
-                       cpu_to_le32((wil->monitor_flags & MONITOR_FLAG_CONTROL)
-                                   ? WMI_SNIFFER_CP : WMI_SNIFFER_DP);
-       }
-       /* typical time for secure PCP is 840ms */
-       rc = wmi_call(wil, WMI_CFG_RX_CHAIN_CMDID, &cmd, sizeof(cmd),
-                     WMI_CFG_RX_CHAIN_DONE_EVENTID, &evt, sizeof(evt), 2000);
+       rc = wmi_rx_chain_add(wil, vring);
        if (rc)
                goto err_free;
 
-       vring->hwtail = le32_to_cpu(evt.evt.rx_ring_tail_ptr);
-
-       wil_dbg_MISC(wil, "Rx init: status %d tail 0x%08x\n",
-                    le32_to_cpu(evt.evt.status), vring->hwtail);
-
        rc = wil_rx_refill(wil, vring->size);
        if (rc)
                goto err_free;
@@ -547,22 +512,7 @@ void wil_rx_fini(struct wil6210_priv *wil)
        struct vring *vring = &wil->vring_rx;
 
        if (vring->va) {
-               int rc;
-               struct wmi_cfg_rx_chain_cmd cmd = {
-                       .action = cpu_to_le32(WMI_RX_CHAIN_DEL),
-                       .rx_sw_ring = {
-                               .max_mpdu_size = cpu_to_le16(RX_BUF_LEN),
-                       },
-               };
-               struct {
-                       struct wil6210_mbox_hdr_wmi wmi;
-                       struct wmi_cfg_rx_chain_done_event cfg;
-               } __packed wmi_rx_cfg_reply;
-
-               rc = wmi_call(wil, WMI_CFG_RX_CHAIN_CMDID, &cmd, sizeof(cmd),
-                             WMI_CFG_RX_CHAIN_DONE_EVENTID,
-                             &wmi_rx_cfg_reply, sizeof(wmi_rx_cfg_reply),
-                             100);
+               wmi_rx_chain_del(wil);
                wil_vring_free(wil, vring, 0);
        }
 }
index a9b6f70f585f87a95bd8fd92c14d35d04da77ed8..9b2ebdd20de8fffc2942330f127fef85b0e2cff7 100644 (file)
@@ -329,6 +329,8 @@ int wmi_add_cipher_key(struct wil6210_priv *wil, u8 key_index,
                       const void *mac_addr, int key_len, const void *key);
 int wmi_echo(struct wil6210_priv *wil);
 int wmi_set_ie(struct wil6210_priv *wil, u8 type, u16 ie_len, const void *ie);
+int wmi_rx_chain_del(struct wil6210_priv *wil);
+int wmi_rx_chain_add(struct wil6210_priv *wil, struct vring *vring);
 
 int wil6210_init_irq(struct wil6210_priv *wil, int irq);
 void wil6210_fini_irq(struct wil6210_priv *wil, int irq);
index 12915f6e7617627ceabf025b02c9769d9ac31305..d109c3f7e5e9c1b66fd24024cc036ecb6856020c 100644 (file)
 #include <linux/io.h>
 #include <linux/list.h>
 #include <linux/etherdevice.h>
+#include <linux/if_arp.h>
 
 #include "wil6210.h"
+#include "txrx.h"
 #include "wmi.h"
 
 /**
@@ -853,6 +855,77 @@ int wmi_set_ie(struct wil6210_priv *wil, u8 type, u16 ie_len, const void *ie)
        return rc;
 }
 
+int wmi_rx_chain_add(struct wil6210_priv *wil, struct vring *vring)
+{
+       struct wireless_dev *wdev = wil->wdev;
+       struct net_device *ndev = wil_to_ndev(wil);
+       struct wmi_cfg_rx_chain_cmd cmd = {
+               .action = WMI_RX_CHAIN_ADD,
+               .rx_sw_ring = {
+                       .max_mpdu_size = cpu_to_le16(RX_BUF_LEN),
+                       .ring_mem_base = cpu_to_le64(vring->pa),
+                       .ring_size = cpu_to_le16(vring->size),
+               },
+               .mid = 0, /* TODO - what is it? */
+               .decap_trans_type = WMI_DECAP_TYPE_802_3,
+       };
+       struct {
+               struct wil6210_mbox_hdr_wmi wmi;
+               struct wmi_cfg_rx_chain_done_event evt;
+       } __packed evt;
+       int rc;
+
+       if (wdev->iftype == NL80211_IFTYPE_MONITOR) {
+               struct ieee80211_channel *ch = wdev->preset_chandef.chan;
+
+               cmd.sniffer_cfg.mode = cpu_to_le32(WMI_SNIFFER_ON);
+               if (ch)
+                       cmd.sniffer_cfg.channel = ch->hw_value - 1;
+               cmd.sniffer_cfg.phy_info_mode =
+                       cpu_to_le32(ndev->type == ARPHRD_IEEE80211_RADIOTAP);
+               cmd.sniffer_cfg.phy_support =
+                       cpu_to_le32((wil->monitor_flags & MONITOR_FLAG_CONTROL)
+                                   ? WMI_SNIFFER_CP : WMI_SNIFFER_DP);
+       }
+       /* typical time for secure PCP is 840ms */
+       rc = wmi_call(wil, WMI_CFG_RX_CHAIN_CMDID, &cmd, sizeof(cmd),
+                     WMI_CFG_RX_CHAIN_DONE_EVENTID, &evt, sizeof(evt), 2000);
+       if (rc)
+               return rc;
+
+       vring->hwtail = le32_to_cpu(evt.evt.rx_ring_tail_ptr);
+
+       wil_dbg_MISC(wil, "Rx init: status %d tail 0x%08x\n",
+                    le32_to_cpu(evt.evt.status), vring->hwtail);
+
+       if (le32_to_cpu(evt.evt.status) != WMI_CFG_RX_CHAIN_SUCCESS)
+               rc = -EINVAL;
+
+       return rc;
+}
+
+int wmi_rx_chain_del(struct wil6210_priv *wil)
+{
+       int rc;
+       struct wmi_cfg_rx_chain_cmd cmd = {
+               .action = cpu_to_le32(WMI_RX_CHAIN_DEL),
+               .rx_sw_ring = {
+                       .max_mpdu_size = cpu_to_le16(RX_BUF_LEN),
+               },
+       };
+       struct {
+               struct wil6210_mbox_hdr_wmi wmi;
+               struct wmi_cfg_rx_chain_done_event cfg;
+       } __packed wmi_rx_cfg_reply;
+
+       rc = wmi_call(wil, WMI_CFG_RX_CHAIN_CMDID, &cmd, sizeof(cmd),
+                     WMI_CFG_RX_CHAIN_DONE_EVENTID,
+                     &wmi_rx_cfg_reply, sizeof(wmi_rx_cfg_reply),
+                     100);
+
+       return rc;
+}
+
 void wmi_event_flush(struct wil6210_priv *wil)
 {
        struct pending_wmi_event *evt, *t;