wlcore/wl12xx: add hw op for setting blocks in hw_tx_desc
authorArik Nemtsov <arik@wizery.com>
Mon, 12 Dec 2011 09:44:27 +0000 (11:44 +0200)
committerLuciano Coelho <coelho@ti.com>
Thu, 12 Apr 2012 05:43:59 +0000 (08:43 +0300)
Each chip family has a slightly different Tx descriptor. Set the
descriptor values according to family.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
drivers/net/wireless/ti/wl12xx/main.c
drivers/net/wireless/ti/wlcore/hw_ops.h
drivers/net/wireless/ti/wlcore/tx.c
drivers/net/wireless/ti/wlcore/wlcore.h

index e1bdeae89506b810ad14c9f9a97e8071116b9926..c8f314814e5dc7a69fe60d62d6a37f964245f2b3 100644 (file)
@@ -597,6 +597,18 @@ static u32 wl12xx_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks)
        return (align_len + blk_size - 1) / blk_size + spare_blks;
 }
 
+static void
+wl12xx_set_tx_desc_blocks(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
+                         u32 blks, u32 spare_blks)
+{
+       if (wl->chip.id == CHIP_ID_1283_PG20) {
+               desc->wl128x_mem.total_mem_blocks = blks;
+       } else {
+               desc->wl127x_mem.extra_blocks = spare_blks;
+               desc->wl127x_mem.total_mem_blocks = blks;
+       }
+}
+
 static bool wl12xx_mac_in_fuse(struct wl1271 *wl)
 {
        bool supported = false;
@@ -661,13 +673,14 @@ static void wl12xx_get_mac(struct wl1271 *wl)
 }
 
 static struct wlcore_ops wl12xx_ops = {
-       .identify_chip  = wl12xx_identify_chip,
-       .boot           = wl12xx_boot,
-       .trigger_cmd    = wl12xx_trigger_cmd,
-       .ack_event      = wl12xx_ack_event,
-       .calc_tx_blocks = wl12xx_calc_tx_blocks,
-       .get_pg_ver     = wl12xx_get_pg_ver,
-       .get_mac        = wl12xx_get_mac,
+       .identify_chip          = wl12xx_identify_chip,
+       .boot                   = wl12xx_boot,
+       .trigger_cmd            = wl12xx_trigger_cmd,
+       .ack_event              = wl12xx_ack_event,
+       .calc_tx_blocks         = wl12xx_calc_tx_blocks,
+       .set_tx_desc_blocks     = wl12xx_set_tx_desc_blocks,
+       .get_pg_ver             = wl12xx_get_pg_ver,
+       .get_mac                = wl12xx_get_mac,
 };
 
 struct wl12xx_priv {
index 5a9a3c9b47596bedd0e0f64c8a4ce0cc5a55fade..02b55936aaab6dba6dd7a0b8812584ffde702321 100644 (file)
@@ -33,4 +33,14 @@ wlcore_hw_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks)
        return wl->ops->calc_tx_blocks(wl, len, spare_blks);
 }
 
+static inline void
+wlcore_hw_set_tx_desc_blocks(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
+                            u32 blks, u32 spare_blks)
+{
+       if (!wl->ops->set_tx_desc_blocks)
+               BUG_ON(1);
+
+       return wl->ops->set_tx_desc_blocks(wl, desc, blks, spare_blks);
+}
+
 #endif
index 3891f9662c187369784c810d8aeb8b7086ebb824..d834758b1a375880b127268d3c155daecaf4a6c2 100644 (file)
@@ -213,13 +213,8 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct wl12xx_vif *wlvif,
                desc = (struct wl1271_tx_hw_descr *)skb_push(
                        skb, total_len - skb->len);
 
-               /* HW descriptor fields change between wl127x and wl128x */
-               if (wl->chip.id == CHIP_ID_1283_PG20) {
-                       desc->wl128x_mem.total_mem_blocks = total_blocks;
-               } else {
-                       desc->wl127x_mem.extra_blocks = spare_blocks;
-                       desc->wl127x_mem.total_mem_blocks = total_blocks;
-               }
+               wlcore_hw_set_tx_desc_blocks(wl, desc, total_blocks,
+                                            spare_blocks);
 
                desc->id = id;
 
index e3d5d738967127318d420782502868f91d457a98..f0ce69dd13ab37ca7183ee5662eefd01a48e77d1 100644 (file)
@@ -27,6 +27,8 @@
 #include "wl12xx.h"
 #include "event.h"
 
+struct wl1271_tx_hw_descr;
+
 /* The maximum number of Tx descriptors in all chip families */
 #define WLCORE_MAX_TX_DESCRIPTORS 32
 
@@ -36,6 +38,9 @@ struct wlcore_ops {
        void (*trigger_cmd)(struct wl1271 *wl);
        void (*ack_event)(struct wl1271 *wl);
        u32 (*calc_tx_blocks)(struct wl1271 *wl, u32 len, u32 spare_blks);
+       void (*set_tx_desc_blocks)(struct wl1271 *wl,
+                                  struct wl1271_tx_hw_descr *desc,
+                                  u32 blks, u32 spare_blks);
        s8 (*get_pg_ver)(struct wl1271 *wl);
        void (*get_mac)(struct wl1271 *wl);
 };