Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *  PS3 gelic network driver.
0004  *
0005  * Copyright (C) 2007 Sony Computer Entertainment Inc.
0006  * Copyright 2007 Sony Corporation
0007  */
0008 #ifndef _GELIC_WIRELESS_H
0009 #define _GELIC_WIRELESS_H
0010 
0011 #include <linux/wireless.h>
0012 #include <net/iw_handler.h>
0013 
0014 
0015 /* return value from  GELIC_LV1_GET_WLAN_EVENT netcontrol */
0016 enum gelic_lv1_wl_event {
0017     GELIC_LV1_WL_EVENT_DEVICE_READY   = 0x01, /* Eurus ready */
0018     GELIC_LV1_WL_EVENT_SCAN_COMPLETED = 0x02, /* Scan has completed */
0019     GELIC_LV1_WL_EVENT_DEAUTH         = 0x04, /* Deauthed by the AP */
0020     GELIC_LV1_WL_EVENT_BEACON_LOST    = 0x08, /* Beacon lost detected */
0021     GELIC_LV1_WL_EVENT_CONNECTED      = 0x10, /* Connected to AP */
0022     GELIC_LV1_WL_EVENT_WPA_CONNECTED  = 0x20, /* WPA connection */
0023     GELIC_LV1_WL_EVENT_WPA_ERROR      = 0x40, /* MIC error */
0024 };
0025 
0026 /* arguments for GELIC_LV1_POST_WLAN_COMMAND netcontrol */
0027 enum gelic_eurus_command {
0028     GELIC_EURUS_CMD_ASSOC       =  1, /* association start */
0029     GELIC_EURUS_CMD_DISASSOC    =  2, /* disassociate      */
0030     GELIC_EURUS_CMD_START_SCAN  =  3, /* scan start        */
0031     GELIC_EURUS_CMD_GET_SCAN    =  4, /* get scan result   */
0032     GELIC_EURUS_CMD_SET_COMMON_CFG  =  5, /* set common config */
0033     GELIC_EURUS_CMD_GET_COMMON_CFG  =  6, /* set common config */
0034     GELIC_EURUS_CMD_SET_WEP_CFG =  7, /* set WEP config    */
0035     GELIC_EURUS_CMD_GET_WEP_CFG =  8, /* get WEP config    */
0036     GELIC_EURUS_CMD_SET_WPA_CFG =  9, /* set WPA config    */
0037     GELIC_EURUS_CMD_GET_WPA_CFG = 10, /* get WPA config    */
0038     GELIC_EURUS_CMD_GET_RSSI_CFG    = 11, /* get RSSI info.    */
0039     GELIC_EURUS_CMD_MAX_INDEX
0040 };
0041 
0042 /* for GELIC_EURUS_CMD_COMMON_CFG */
0043 enum gelic_eurus_bss_type {
0044     GELIC_EURUS_BSS_INFRA = 0,
0045     GELIC_EURUS_BSS_ADHOC = 1, /* not supported */
0046 };
0047 
0048 enum gelic_eurus_auth_method {
0049     GELIC_EURUS_AUTH_OPEN = 0, /* FIXME: WLAN_AUTH_OPEN */
0050     GELIC_EURUS_AUTH_SHARED = 1, /* not supported */
0051 };
0052 
0053 enum gelic_eurus_opmode {
0054     GELIC_EURUS_OPMODE_11BG = 0, /* 802.11b/g */
0055     GELIC_EURUS_OPMODE_11B = 1, /* 802.11b only */
0056     GELIC_EURUS_OPMODE_11G = 2, /* 802.11g only */
0057 };
0058 
0059 struct gelic_eurus_common_cfg {
0060     /* all fields are big endian */
0061     u16 scan_index;
0062     u16 bss_type;    /* infra or adhoc */
0063     u16 auth_method; /* shared key or open */
0064     u16 op_mode; /* B/G */
0065 } __packed;
0066 
0067 
0068 /* for GELIC_EURUS_CMD_WEP_CFG */
0069 enum gelic_eurus_wep_security {
0070     GELIC_EURUS_WEP_SEC_NONE    = 0,
0071     GELIC_EURUS_WEP_SEC_40BIT   = 1,
0072     GELIC_EURUS_WEP_SEC_104BIT  = 2,
0073 };
0074 
0075 struct gelic_eurus_wep_cfg {
0076     /* all fields are big endian */
0077     u16 security;
0078     u8 key[4][16];
0079 } __packed;
0080 
0081 /* for GELIC_EURUS_CMD_WPA_CFG */
0082 enum gelic_eurus_wpa_security {
0083     GELIC_EURUS_WPA_SEC_NONE        = 0x0000,
0084     /* group=TKIP, pairwise=TKIP */
0085     GELIC_EURUS_WPA_SEC_WPA_TKIP_TKIP   = 0x0001,
0086     /* group=AES, pairwise=AES */
0087     GELIC_EURUS_WPA_SEC_WPA_AES_AES     = 0x0002,
0088     /* group=TKIP, pairwise=TKIP */
0089     GELIC_EURUS_WPA_SEC_WPA2_TKIP_TKIP  = 0x0004,
0090     /* group=AES, pairwise=AES */
0091     GELIC_EURUS_WPA_SEC_WPA2_AES_AES    = 0x0008,
0092     /* group=TKIP, pairwise=AES */
0093     GELIC_EURUS_WPA_SEC_WPA_TKIP_AES    = 0x0010,
0094     /* group=TKIP, pairwise=AES */
0095     GELIC_EURUS_WPA_SEC_WPA2_TKIP_AES   = 0x0020,
0096 };
0097 
0098 enum gelic_eurus_wpa_psk_type {
0099     GELIC_EURUS_WPA_PSK_PASSPHRASE  = 0, /* passphrase string   */
0100     GELIC_EURUS_WPA_PSK_BIN     = 1, /* 32 bytes binary key */
0101 };
0102 
0103 #define GELIC_WL_EURUS_PSK_MAX_LEN  64
0104 #define WPA_PSK_LEN         32 /* WPA spec says 256bit */
0105 
0106 struct gelic_eurus_wpa_cfg {
0107     /* all fields are big endian */
0108     u16 security;
0109     u16 psk_type; /* psk key encoding type */
0110     u8 psk[GELIC_WL_EURUS_PSK_MAX_LEN]; /* psk key; hex or passphrase */
0111 } __packed;
0112 
0113 /* for GELIC_EURUS_CMD_{START,GET}_SCAN */
0114 enum gelic_eurus_scan_capability {
0115     GELIC_EURUS_SCAN_CAP_ADHOC  = 0x0000,
0116     GELIC_EURUS_SCAN_CAP_INFRA  = 0x0001,
0117     GELIC_EURUS_SCAN_CAP_MASK   = 0x0001,
0118 };
0119 
0120 enum gelic_eurus_scan_sec_type {
0121     GELIC_EURUS_SCAN_SEC_NONE   = 0x0000,
0122     GELIC_EURUS_SCAN_SEC_WEP    = 0x0100,
0123     GELIC_EURUS_SCAN_SEC_WPA    = 0x0200,
0124     GELIC_EURUS_SCAN_SEC_WPA2   = 0x0400,
0125     GELIC_EURUS_SCAN_SEC_MASK   = 0x0f00,
0126 };
0127 
0128 enum gelic_eurus_scan_sec_wep_type {
0129     GELIC_EURUS_SCAN_SEC_WEP_UNKNOWN    = 0x0000,
0130     GELIC_EURUS_SCAN_SEC_WEP_40     = 0x0001,
0131     GELIC_EURUS_SCAN_SEC_WEP_104        = 0x0002,
0132     GELIC_EURUS_SCAN_SEC_WEP_MASK       = 0x0003,
0133 };
0134 
0135 enum gelic_eurus_scan_sec_wpa_type {
0136     GELIC_EURUS_SCAN_SEC_WPA_UNKNOWN    = 0x0000,
0137     GELIC_EURUS_SCAN_SEC_WPA_TKIP       = 0x0001,
0138     GELIC_EURUS_SCAN_SEC_WPA_AES        = 0x0002,
0139     GELIC_EURUS_SCAN_SEC_WPA_MASK       = 0x0003,
0140 };
0141 
0142 /*
0143  * hw BSS information structure returned from GELIC_EURUS_CMD_GET_SCAN
0144  */
0145 struct gelic_eurus_scan_info {
0146     /* all fields are big endian */
0147     __be16 size;
0148     __be16 rssi; /* percentage */
0149     __be16 channel; /* channel number */
0150     __be16 beacon_period; /* FIXME: in msec unit */
0151     __be16 capability;
0152     __be16 security;
0153     u8  bssid[8]; /* last ETH_ALEN are valid. bssid[0],[1] are unused */
0154     u8  essid[32]; /* IW_ESSID_MAX_SIZE */
0155     u8  rate[16]; /* first 12 are valid */
0156     u8  ext_rate[16]; /* first 16 are valid */
0157     __be32 reserved1;
0158     __be32 reserved2;
0159     __be32 reserved3;
0160     __be32 reserved4;
0161     u8 elements[]; /* ie */
0162 } __packed;
0163 
0164 /* the hypervisor returns bbs up to 16 */
0165 #define GELIC_EURUS_MAX_SCAN  (16)
0166 struct gelic_wl_scan_info {
0167     struct list_head list;
0168     struct gelic_eurus_scan_info *hwinfo;
0169 
0170     int valid; /* set 1 if this entry was in latest scanned list
0171              * from Eurus */
0172     unsigned int eurus_index; /* index in the Eurus list */
0173     unsigned long last_scanned; /* acquired time */
0174 
0175     unsigned int rate_len;
0176     unsigned int rate_ext_len;
0177     unsigned int essid_len;
0178 };
0179 
0180 /* for GELIC_EURUS_CMD_GET_RSSI */
0181 struct gelic_eurus_rssi_info {
0182     /* big endian */
0183     __be16 rssi;
0184 } __packed;
0185 
0186 
0187 /* for 'stat' member of gelic_wl_info */
0188 enum gelic_wl_info_status_bit {
0189     GELIC_WL_STAT_CONFIGURED,
0190     GELIC_WL_STAT_CH_INFO,   /* ch info acquired */
0191     GELIC_WL_STAT_ESSID_SET, /* ESSID specified by userspace */
0192     GELIC_WL_STAT_BSSID_SET, /* BSSID specified by userspace */
0193     GELIC_WL_STAT_WPA_PSK_SET, /* PMK specified by userspace */
0194     GELIC_WL_STAT_WPA_LEVEL_SET, /* WEP or WPA[2] selected */
0195 };
0196 
0197 /* for 'scan_stat' member of gelic_wl_info */
0198 enum gelic_wl_scan_state {
0199     /* just initialized or get last scan result failed */
0200     GELIC_WL_SCAN_STAT_INIT,
0201     /* scan request issued, accepted or chip is scanning */
0202     GELIC_WL_SCAN_STAT_SCANNING,
0203     /* scan results retrieved */
0204     GELIC_WL_SCAN_STAT_GOT_LIST,
0205 };
0206 
0207 /* for 'cipher_method' */
0208 enum gelic_wl_cipher_method {
0209     GELIC_WL_CIPHER_NONE,
0210     GELIC_WL_CIPHER_WEP,
0211     GELIC_WL_CIPHER_TKIP,
0212     GELIC_WL_CIPHER_AES,
0213 };
0214 
0215 /* for 'wpa_level' */
0216 enum gelic_wl_wpa_level {
0217     GELIC_WL_WPA_LEVEL_NONE,
0218     GELIC_WL_WPA_LEVEL_WPA,
0219     GELIC_WL_WPA_LEVEL_WPA2,
0220 };
0221 
0222 /* for 'assoc_stat' */
0223 enum gelic_wl_assoc_state {
0224     GELIC_WL_ASSOC_STAT_DISCONN,
0225     GELIC_WL_ASSOC_STAT_ASSOCIATING,
0226     GELIC_WL_ASSOC_STAT_ASSOCIATED,
0227 };
0228 /* part of private data alloc_etherdev() allocated */
0229 #define GELIC_WEP_KEYS 4
0230 struct gelic_wl_info {
0231     /* bss list */
0232     struct mutex scan_lock;
0233     struct list_head network_list;
0234     struct list_head network_free_list;
0235     struct gelic_wl_scan_info *networks;
0236 
0237     unsigned long scan_age; /* last scanned time */
0238     enum gelic_wl_scan_state scan_stat;
0239     struct completion scan_done;
0240 
0241     /* eurus command queue */
0242     struct workqueue_struct *eurus_cmd_queue;
0243     struct completion cmd_done_intr;
0244 
0245     /* eurus event handling */
0246     struct workqueue_struct *event_queue;
0247     struct delayed_work event_work;
0248 
0249     /* wl status bits */
0250     unsigned long stat;
0251     enum gelic_eurus_auth_method auth_method; /* open/shared */
0252     enum gelic_wl_cipher_method group_cipher_method;
0253     enum gelic_wl_cipher_method pairwise_cipher_method;
0254     enum gelic_wl_wpa_level wpa_level; /* wpa/wpa2 */
0255 
0256     /* association handling */
0257     struct mutex assoc_stat_lock;
0258     struct delayed_work assoc_work;
0259     enum gelic_wl_assoc_state assoc_stat;
0260     struct completion assoc_done;
0261 
0262     spinlock_t lock;
0263     u16 ch_info; /* available channels. bit0 = ch1 */
0264     /* WEP keys */
0265     u8 key[GELIC_WEP_KEYS][IW_ENCODING_TOKEN_MAX];
0266     unsigned long key_enabled;
0267     unsigned int key_len[GELIC_WEP_KEYS];
0268     unsigned int current_key;
0269     /* WWPA PSK */
0270     u8 psk[GELIC_WL_EURUS_PSK_MAX_LEN];
0271     enum gelic_eurus_wpa_psk_type psk_type;
0272     unsigned int psk_len;
0273 
0274     u8 essid[IW_ESSID_MAX_SIZE];
0275     u8 bssid[ETH_ALEN]; /* userland requested */
0276     u8 active_bssid[ETH_ALEN]; /* associated bssid */
0277     unsigned int essid_len;
0278 
0279     struct iw_public_data wireless_data;
0280     struct iw_statistics iwstat;
0281 };
0282 
0283 #define GELIC_WL_BSS_MAX_ENT 32
0284 #define GELIC_WL_ASSOC_RETRY 50
0285 static inline struct gelic_port *wl_port(struct gelic_wl_info *wl)
0286 {
0287     return container_of((void *)wl, struct gelic_port, priv);
0288 }
0289 static inline struct gelic_wl_info *port_wl(struct gelic_port *port)
0290 {
0291     return port_priv(port);
0292 }
0293 
0294 struct gelic_eurus_cmd {
0295     struct work_struct work;
0296     struct gelic_wl_info *wl;
0297     unsigned int cmd; /* command code */
0298     u64 tag;
0299     u64 size;
0300     void *buffer;
0301     unsigned int buf_size;
0302     struct completion done;
0303     int status;
0304     u64 cmd_status;
0305 };
0306 
0307 /* private ioctls to pass PSK */
0308 #define GELIC_WL_PRIV_SET_PSK       (SIOCIWFIRSTPRIV + 0)
0309 #define GELIC_WL_PRIV_GET_PSK       (SIOCIWFIRSTPRIV + 1)
0310 
0311 int gelic_wl_driver_probe(struct gelic_card *card);
0312 int gelic_wl_driver_remove(struct gelic_card *card);
0313 void gelic_wl_interrupt(struct net_device *netdev, u64 status);
0314 #endif /* _GELIC_WIRELESS_H */