iwlagn: separate and enhance the fixed rate from
[deliverable/linux.git] / drivers / net / wireless / iwlwifi / iwl-dev.h
index 214e4658c4951ffaff35ddc379b2dec5ffcb0f3e..a0cca02032e7d718e009a2d5219e749c1782d812 100644 (file)
@@ -48,7 +48,7 @@
 #include "iwl-agn-rs.h"
 #include "iwl-agn-tt.h"
 
-#define U32_PAD(n)             ((4-(n))&0x3)
+#define DRV_NAME        "iwlagn"
 
 struct iwl_tx_queue;
 
@@ -83,7 +83,7 @@ struct iwl_tx_queue;
 #define MAX_RTS_THRESHOLD         2347U
 #define MAX_MSDU_SIZE            2304U
 #define MAX_MPDU_SIZE            2346U
-#define DEFAULT_BEACON_INTERVAL   100U
+#define DEFAULT_BEACON_INTERVAL   200U
 #define        DEFAULT_SHORT_RETRY_LIMIT 7U
 #define        DEFAULT_LONG_RETRY_LIMIT  4U
 
@@ -112,8 +112,6 @@ struct iwl_cmd_meta {
                         struct iwl_device_cmd *cmd,
                         struct iwl_rx_packet *pkt);
 
-       /* The CMD_SIZE_HUGE flag bit indicates that the command
-        * structure is stored at the end of the shared queue memory. */
        u32 flags;
 
        DEFINE_DMA_UNMAP_ADDR(mapping);
@@ -123,7 +121,23 @@ struct iwl_cmd_meta {
 /*
  * Generic queue structure
  *
- * Contains common data for Rx and Tx queues
+ * Contains common data for Rx and Tx queues.
+ *
+ * Note the difference between n_bd and n_window: the hardware
+ * always assumes 256 descriptors, so n_bd is always 256 (unless
+ * there might be HW changes in the future). For the normal TX
+ * queues, n_window, which is the size of the software queue data
+ * is also 256; however, for the command queue, n_window is only
+ * 32 since we don't need so many commands pending. Since the HW
+ * still uses 256 BDs for DMA though, n_bd stays 256. As a result,
+ * the software buffers (in the variables @meta, @txb in struct
+ * iwl_tx_queue) only have 32 entries, while the HW buffers (@tfds
+ * in the same struct) have 256.
+ * This means that we end up with the following:
+ *  HW entries: | 0 | ... | N * 32 | ... | N * 32 + 31 | ... | 255 |
+ *  SW entries:           | 0      | ... | 31          |
+ * where N is a number between 0 and 7. This means that the SW
+ * data is a window overlayed over the HW queue.
  */
 struct iwl_queue {
        int n_bd;              /* number of BDs in this queue */
@@ -165,7 +179,7 @@ struct iwl_tx_info {
 
 struct iwl_tx_queue {
        struct iwl_queue q;
-       void *tfds;
+       struct iwl_tfd *tfds;
        struct iwl_device_cmd **cmd;
        struct iwl_cmd_meta *meta;
        struct iwl_tx_info *txb;
@@ -245,12 +259,9 @@ struct iwl_channel_info {
 
 enum {
        CMD_SYNC = 0,
-       CMD_SIZE_NORMAL = 0,
-       CMD_NO_SKB = 0,
-       CMD_SIZE_HUGE = (1 << 0),
-       CMD_ASYNC = (1 << 1),
-       CMD_WANT_SKB = (1 << 2),
-       CMD_MAPPED = (1 << 3),
+       CMD_ASYNC = BIT(0),
+       CMD_WANT_SKB = BIT(1),
+       CMD_ON_DEMAND = BIT(2),
 };
 
 #define DEF_CMD_PAYLOAD_SIZE 320
@@ -259,8 +270,8 @@ enum {
  * struct iwl_device_cmd
  *
  * For allocation of the command and tx queues, this establishes the overall
- * size of the largest command we send to uCode, except for a scan command
- * (which is relatively huge; space is allocated separately).
+ * size of the largest command we send to uCode, except for commands that
+ * aren't fully copied and use other TFD space.
  */
 struct iwl_device_cmd {
        struct iwl_cmd_header hdr;      /* uCode API */
@@ -277,15 +288,31 @@ struct iwl_device_cmd {
 
 #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))
 
+#define IWL_MAX_CMD_TFDS       2
+
+enum iwl_hcmd_dataflag {
+       IWL_HCMD_DFL_NOCOPY     = BIT(0),
+};
 
+/**
+ * struct iwl_host_cmd - Host command to the uCode
+ * @data: array of chunks that composes the data of the host command
+ * @reply_page: pointer to the page that holds the response to the host command
+ * @callback:
+ * @flags: can be CMD_* note CMD_WANT_SKB is incompatible withe CMD_ASYNC
+ * @len: array of the lenths of the chunks in data
+ * @dataflags:
+ * @id: id of the host command
+ */
 struct iwl_host_cmd {
-       const void *data;
+       const void *data[IWL_MAX_CMD_TFDS];
        unsigned long reply_page;
        void (*callback)(struct iwl_priv *priv,
                         struct iwl_device_cmd *cmd,
                         struct iwl_rx_packet *pkt);
        u32 flags;
-       u16 len;
+       u16 len[IWL_MAX_CMD_TFDS];
+       u8 dataflags[IWL_MAX_CMD_TFDS];
        u8 id;
 };
 
@@ -614,7 +641,6 @@ struct iwl_sensitivity_ranges {
 /**
  * struct iwl_hw_params
  * @max_txq_num: Max # Tx queues supported
- * @dma_chnl_num: Number of Tx DMA/FIFO channels
  * @scd_bc_tbls_size: size of scheduler byte count tables
  * @tfd_size: TFD size
  * @tx/rx_chains_num: Number of TX/RX chains
@@ -636,7 +662,6 @@ struct iwl_sensitivity_ranges {
  */
 struct iwl_hw_params {
        u8 max_txq_num;
-       u8 dma_chnl_num;
        u16 scd_bc_tbls_size;
        u32 tfd_size;
        u8  tx_chains_num;
@@ -646,7 +671,6 @@ struct iwl_hw_params {
        u16 max_rxq_size;
        u16 max_rxq_log;
        u32 rx_page_order;
-       u32 rx_wrt_ptr_reg;
        u8  max_stations;
        u8  ht40_channel;
        u8  max_beacon_itrvl;   /* in 1024 ms */
@@ -677,8 +701,6 @@ struct iwl_hw_params {
  ****************************************************************************/
 extern void iwl_update_chain_flags(struct iwl_priv *priv);
 extern const u8 iwl_bcast_addr[ETH_ALEN];
-extern int iwl_rxq_stop(struct iwl_priv *priv);
-extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
 extern int iwl_queue_space(const struct iwl_queue *q);
 static inline int iwl_queue_used(const struct iwl_queue *q, int i)
 {
@@ -688,17 +710,8 @@ static inline int iwl_queue_used(const struct iwl_queue *q, int i)
 }
 
 
-static inline u8 get_cmd_index(struct iwl_queue *q, u32 index, int is_huge)
+static inline u8 get_cmd_index(struct iwl_queue *q, u32 index)
 {
-       /*
-        * This is for init calibration result and scan command which
-        * required buffer > TFD_MAX_PAYLOAD_SIZE,
-        * the big buffer at end of command array
-        */
-       if (is_huge)
-               return q->n_window;     /* must be power of 2 */
-
-       /* Otherwise, use normal size buffers */
        return index & (q->n_window - 1);
 }
 
@@ -973,17 +986,6 @@ struct traffic_stats {
 #endif
 };
 
-/*
- * iwl_switch_rxon: "channel switch" structure
- *
- * @ switch_in_progress: channel switch in progress
- * @ channel: new channel
- */
-struct iwl_switch_rxon {
-       bool switch_in_progress;
-       __le16 channel;
-};
-
 /*
  * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
  * to perform continuous uCode event logging operation if enabled
@@ -1171,6 +1173,100 @@ enum iwl_scan_type {
        IWL_SCAN_OFFCH_TX,
 };
 
+enum iwlagn_ucode_type {
+       IWL_UCODE_NONE,
+       IWL_UCODE_REGULAR,
+       IWL_UCODE_INIT,
+       IWL_UCODE_WOWLAN,
+};
+
+#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
+struct iwl_testmode_trace {
+       u32 buff_size;
+       u32 total_size;
+       u32 num_chunks;
+       u8 *cpu_addr;
+       u8 *trace_addr;
+       dma_addr_t dma_addr;
+       bool trace_enabled;
+};
+#endif
+
+struct iwl_bus;
+
+/**
+ * struct iwl_bus_ops - bus specific operations
+
+ * @get_pm_support: must returns true if the bus can go to sleep
+ * @apm_config: will be called during the config of the APM configuration
+ * @set_drv_data: set the priv pointer to the bus layer
+ * @get_dev: returns the device struct
+ * @get_irq: returns the irq number
+ * @get_hw_id: prints the hw_id in the provided buffer
+ * @write8: write a byte to register at offset ofs
+ * @write32: write a dword to register at offset ofs
+ * @wread32: read a dword at register at offset ofs
+ */
+struct iwl_bus_ops {
+       bool (*get_pm_support)(struct iwl_bus *bus);
+       void (*apm_config)(struct iwl_bus *bus);
+       void (*set_drv_data)(struct iwl_bus *bus, void *priv);
+       struct device *(*get_dev)(const struct iwl_bus *bus);
+       unsigned int (*get_irq)(const struct iwl_bus *bus);
+       void (*get_hw_id)(struct iwl_bus *bus, char buf[], int buf_len);
+       void (*write8)(struct iwl_bus *bus, u32 ofs, u8 val);
+       void (*write32)(struct iwl_bus *bus, u32 ofs, u32 val);
+       u32 (*read32)(struct iwl_bus *bus, u32 ofs);
+};
+
+struct iwl_bus {
+       /* pointer to bus specific struct */
+       void *bus_specific;
+
+       /* Common data to all buses */
+       struct iwl_priv *priv; /* driver's context */
+       struct device *dev;
+       struct iwl_bus_ops *ops;
+       unsigned int irq;
+};
+
+struct iwl_trans;
+
+/**
+ * struct iwl_trans_ops - transport specific operations
+
+ * @rx_init: inits the rx memory, allocate it if needed
+ * @rx_stop: stop the rx
+ * @rx_free: frees the rx memory
+ * @tx_init:inits the tx memory, allocate if needed
+ * @tx_stop: stop the tx
+ * @tx_free: frees the tx memory
+ * @send_cmd:send a host command
+ * @send_cmd_pdu:send a host command: flags can be CMD_*
+ */
+struct iwl_trans_ops {
+       int (*rx_init)(struct iwl_priv *priv);
+       int (*rx_stop)(struct iwl_priv *priv);
+       void (*rx_free)(struct iwl_priv *priv);
+
+       int (*tx_init)(struct iwl_priv *priv);
+       int (*tx_stop)(struct iwl_priv *priv);
+       void (*tx_free)(struct iwl_priv *priv);
+
+       int (*send_cmd)(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
+
+       int (*send_cmd_pdu)(struct iwl_priv *priv, u8 id, u32 flags, u16 len,
+                    const void *data);
+};
+
+struct iwl_trans {
+       const struct iwl_trans_ops *ops;
+};
+
+/* uCode ownership */
+#define IWL_OWNERSHIP_DRIVER   0
+#define IWL_OWNERSHIP_TM       1
+
 struct iwl_priv {
 
        /* ieee device used by generic ieee processing code */
@@ -1238,11 +1334,8 @@ struct iwl_priv {
        spinlock_t reg_lock;    /* protect hw register access */
        struct mutex mutex;
 
-       /* basic pci-network driver stuff */
-       struct pci_dev *pci_dev;
-
-       /* pci hardware address support */
-       void __iomem *hw_base;
+       struct iwl_bus bus;     /* bus specific data */
+       struct iwl_trans trans;
 
        /* microcode/device supports multiple contexts */
        u8 valid_contexts;
@@ -1262,16 +1355,20 @@ struct iwl_priv {
        int fw_index;                   /* firmware we're trying to load */
        u32 ucode_ver;                  /* version of ucode, copy of
                                           iwl_ucode.ver */
+
+       /* uCode owner: default: IWL_OWNERSHIP_DRIVER */
+       u8 ucode_owner;
+
        struct fw_img ucode_rt;
        struct fw_img ucode_init;
 
-       enum iwlagn_ucode_subtype ucode_type;
+       enum iwlagn_ucode_type ucode_type;
        u8 ucode_write_complete;        /* the image write is complete */
        char firmware_name[25];
 
        struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
 
-       struct iwl_switch_rxon switch_rxon;
+       __le16 switch_channel;
 
        struct {
                u32 error_event_table;
@@ -1437,6 +1534,9 @@ struct iwl_priv {
        u16 dynamic_frag_thresh;
        u8 bt_ci_compliance;
        struct work_struct bt_traffic_change_work;
+       bool bt_enable_pspoll;
+       struct iwl_rxon_context *cur_rssi_ctx;
+       bool bt_is_sco;
 
        struct iwl_hw_params hw_params;
 
@@ -1452,6 +1552,7 @@ struct iwl_priv {
        struct work_struct beacon_update;
        struct iwl_rxon_context *beacon_ctx;
        struct sk_buff *beacon_skb;
+       void *beacon_cmd;
 
        struct work_struct tt_work;
        struct work_struct ct_enter;
@@ -1501,6 +1602,11 @@ struct iwl_priv {
        struct led_classdev led;
        unsigned long blink_on, blink_off;
        bool led_registered;
+#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
+       struct iwl_testmode_trace testmode_trace;
+#endif
+       u32 tm_fixed_rate;
+
 }; /*iwl_priv */
 
 static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
This page took 0.029879 seconds and 5 git commands to generate.