[PATCH] ipw2200: Enable rtap interface for RF promiscuous mode while associated
[safe/jmp/linux-2.6] / drivers / net / wireless / ipw2200.h
index 5405ba1..14fe79a 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
 
-  Copyright(c) 2003 - 2005 Intel Corporation. All rights reserved.
+  Copyright(c) 2003 - 2006 Intel Corporation. All rights reserved.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of version 2 of the GNU General Public License as
@@ -246,8 +246,10 @@ enum connection_manager_assoc_states {
 #define HOST_NOTIFICATION_S36_MEASUREMENT_REFUSED       31
 
 #define HOST_NOTIFICATION_STATUS_BEACON_MISSING         1
-#define IPW_MB_DISASSOCIATE_THRESHOLD_DEFAULT           24
+#define IPW_MB_ROAMING_THRESHOLD_MIN                    1
 #define IPW_MB_ROAMING_THRESHOLD_DEFAULT                8
+#define IPW_MB_ROAMING_THRESHOLD_MAX                    30
+#define IPW_MB_DISASSOCIATE_THRESHOLD_DEFAULT           3*IPW_MB_ROAMING_THRESHOLD_DEFAULT
 #define IPW_REAL_RATE_RX_PACKET_THRESHOLD               300
 
 #define MACADRR_BYTE_LEN                     6
@@ -618,13 +620,16 @@ struct notif_tgi_tx_key {
        u8 reserved;
 } __attribute__ ((packed));
 
+#define SILENCE_OVER_THRESH (1)
+#define SILENCE_UNDER_THRESH (2)
+
 struct notif_link_deterioration {
        struct ipw_cmd_stats stats;
        u8 rate;
        u8 modulation;
        struct rate_histogram histogram;
-       u8 reserved1;
-       u16 reserved2;
+       u8 silence_notification_type;   /* SILENCE_OVER/UNDER_THRESH */
+       u16 silence_count;
 } __attribute__ ((packed));
 
 struct notif_association {
@@ -782,9 +787,9 @@ struct ipw_sys_config {
        u8 enable_cts_to_self;
        u8 enable_multicast_filtering;
        u8 bt_coexist_collision_thr;
-       u8 reserved2;
+       u8 silence_threshold;
        u8 accept_all_mgmt_bcpr;
-       u8 accept_all_mgtm_frames;
+       u8 accept_all_mgmt_frames;
        u8 pass_noise_stats_to_host;
        u8 reserved3;
 } __attribute__ ((packed));
@@ -1117,6 +1122,52 @@ struct ipw_fw_error {
        u8 payload[0];
 } __attribute__ ((packed));
 
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+
+enum ipw_prom_filter {
+       IPW_PROM_CTL_HEADER_ONLY = (1 << 0),
+       IPW_PROM_MGMT_HEADER_ONLY = (1 << 1),
+       IPW_PROM_DATA_HEADER_ONLY = (1 << 2),
+       IPW_PROM_ALL_HEADER_ONLY = 0xf, /* bits 0..3 */
+       IPW_PROM_NO_TX = (1 << 4),
+       IPW_PROM_NO_RX = (1 << 5),
+       IPW_PROM_NO_CTL = (1 << 6),
+       IPW_PROM_NO_MGMT = (1 << 7),
+       IPW_PROM_NO_DATA = (1 << 8),
+};
+
+struct ipw_priv;
+struct ipw_prom_priv {
+       struct ipw_priv *priv;
+       struct ieee80211_device *ieee;
+       enum ipw_prom_filter filter;
+       int tx_packets;
+       int rx_packets;
+};
+#endif
+
+#if defined(CONFIG_IEEE80211_RADIOTAP) || defined(CONFIG_IPW2200_PROMISCUOUS)
+/* Magic struct that slots into the radiotap header -- no reason
+ * to build this manually element by element, we can write it much
+ * more efficiently than we can parse it. ORDER MATTERS HERE
+ *
+ * When sent to us via the simulated Rx interface in sysfs, the entire
+ * structure is provided regardless of any bits unset.
+ */
+struct ipw_rt_hdr {
+       struct ieee80211_radiotap_header rt_hdr;
+       u64 rt_tsf;      /* TSF */
+       u8 rt_flags;    /* radiotap packet flags */
+       u8 rt_rate;     /* rate in 500kb/s */
+       u16 rt_channel; /* channel in mhz */
+       u16 rt_chbitmask;       /* channel bitfield */
+       s8 rt_dbmsignal;        /* signal in dbM, kluged to signed */
+       s8 rt_dbmnoise;
+       u8 rt_antenna;  /* antenna number */
+       u8 payload[0];  /* payload... */
+} __attribute__ ((packed));
+#endif
+
 struct ipw_priv {
        /* ieee device used by generic ieee processing code */
        struct ieee80211_device *ieee;
@@ -1128,6 +1179,12 @@ struct ipw_priv {
        struct pci_dev *pci_dev;
        struct net_device *net_dev;
 
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+       /* Promiscuous mode */
+       struct ipw_prom_priv *prom_priv;
+       struct net_device *prom_net_dev;
+#endif
+
        /* pci hardware address support */
        void __iomem *hw_base;
        unsigned long hw_len;
@@ -1148,11 +1205,9 @@ struct ipw_priv {
        u32 config;
        u32 capability;
 
-       u8 last_rx_rssi;
-       u8 last_noise;
        struct average average_missed_beacons;
-       struct average average_rssi;
-       struct average average_noise;
+       s16 exp_avg_rssi;
+       s16 exp_avg_noise;
        u32 port_type;
        int rx_bufs_min;          /**< minimum number of bufs in Rx queue */
        int rx_pend_max;          /**< maximum pending buffers for one IRQ */
@@ -1303,6 +1358,29 @@ struct ipw_priv {
 
 /* debug macros */
 
+/* Debug and printf string expansion helpers for printing bitfields */
+#define BIT_FMT8 "%c%c%c%c-%c%c%c%c"
+#define BIT_FMT16 BIT_FMT8 ":" BIT_FMT8
+#define BIT_FMT32 BIT_FMT16 " " BIT_FMT16
+
+#define BITC(x,y) (((x>>y)&1)?'1':'0')
+#define BIT_ARG8(x) \
+BITC(x,7),BITC(x,6),BITC(x,5),BITC(x,4),\
+BITC(x,3),BITC(x,2),BITC(x,1),BITC(x,0)
+
+#define BIT_ARG16(x) \
+BITC(x,15),BITC(x,14),BITC(x,13),BITC(x,12),\
+BITC(x,11),BITC(x,10),BITC(x,9),BITC(x,8),\
+BIT_ARG8(x)
+
+#define BIT_ARG32(x) \
+BITC(x,31),BITC(x,30),BITC(x,29),BITC(x,28),\
+BITC(x,27),BITC(x,26),BITC(x,25),BITC(x,24),\
+BITC(x,23),BITC(x,22),BITC(x,21),BITC(x,20),\
+BITC(x,19),BITC(x,18),BITC(x,17),BITC(x,16),\
+BIT_ARG16(x)
+
+
 #ifdef CONFIG_IPW2200_DEBUG
 #define IPW_DEBUG(level, fmt, args...) \
 do { if (ipw_debug_level & (level)) \
@@ -1892,6 +1970,7 @@ struct ipw_cmd_log {
 #define CFG_SYS_ANTENNA_BOTH            0x00   /* NIC selects best antenna */
 #define CFG_SYS_ANTENNA_A               0x01   /* force antenna A */
 #define CFG_SYS_ANTENNA_B               0x03   /* force antenna B */
+#define CFG_SYS_ANTENNA_SLOW_DIV        0x02   /* consider background noise */
 
 /*
  * The definitions below were lifted off the ipw2100 driver, which only
@@ -1907,27 +1986,4 @@ struct ipw_cmd_log {
 
 #define IPW_MAX_CONFIG_RETRIES 10
 
-static inline u32 frame_hdr_len(struct ieee80211_hdr_4addr *hdr)
-{
-       u32 retval;
-       u16 fc;
-
-       retval = sizeof(struct ieee80211_hdr_3addr);
-       fc = le16_to_cpu(hdr->frame_ctl);
-
-       /*
-        * Function     ToDS    FromDS
-        * IBSS         0       0
-        * To AP        1       0
-        * From AP      0       1
-        * WDS (bridge) 1       1
-        *
-        * Only WDS frames use Address4 among them. --YZ
-        */
-       if (!(fc & IEEE80211_FCTL_TODS) || !(fc & IEEE80211_FCTL_FROMDS))
-               retval -= ETH_ALEN;
-
-       return retval;
-}
-
 #endif                         /* __ipw2200_h__ */