Home | History | Annotate | Line # | Download | only in ic
bwfmvar.h revision 1.3.6.2
      1 /* $NetBSD: bwfmvar.h,v 1.3.6.2 2020/08/17 11:22:45 martin Exp $ */
      2 /* $OpenBSD: bwfmvar.h,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
      3 /*
      4  * Copyright (c) 2010-2016 Broadcom Corporation
      5  * Copyright (c) 2016,2017 Patrick Wildt <patrick (at) blueri.se>
      6  *
      7  * Permission to use, copy, modify, and/or distribute this software for any
      8  * purpose with or without fee is hereby granted, provided that the above
      9  * copyright notice and this permission notice appear in all copies.
     10  *
     11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     18  */
     19 
     20 #ifndef        _DEV_IC_BWFMVAR_H
     21 #define        _DEV_IC_BWFMVAR_H
     22 
     23 #include <sys/types.h>
     24 
     25 #include <sys/cdefs.h>
     26 #include <sys/device_if.h>
     27 #include <sys/queue.h>
     28 #include <sys/workqueue.h>
     29 
     30 #include <net/if_ether.h>
     31 
     32 #include <net80211/ieee80211.h>
     33 #include <net80211/ieee80211_proto.h>
     34 #include <net80211/ieee80211_var.h>
     35 
     36 struct ieee80211_key;
     37 struct mbuf;
     38 struct pool_cache;
     39 
     40 /* Chipcommon Core Chip IDs */
     41 #define BRCM_CC_43143_CHIP_ID		43143
     42 #define BRCM_CC_43235_CHIP_ID		43235
     43 #define BRCM_CC_43236_CHIP_ID		43236
     44 #define BRCM_CC_43238_CHIP_ID		43238
     45 #define BRCM_CC_43241_CHIP_ID		0x4324
     46 #define BRCM_CC_43242_CHIP_ID		43242
     47 #define BRCM_CC_4329_CHIP_ID		0x4329
     48 #define BRCM_CC_4330_CHIP_ID		0x4330
     49 #define BRCM_CC_4334_CHIP_ID		0x4334
     50 #define BRCM_CC_43340_CHIP_ID		43340
     51 #define BRCM_CC_43362_CHIP_ID		43362
     52 #define BRCM_CC_4335_CHIP_ID		0x4335
     53 #define BRCM_CC_4339_CHIP_ID		0x4339
     54 #define BRCM_CC_43430_CHIP_ID		43430
     55 #define BRCM_CC_4345_CHIP_ID		0x4345
     56 #define BRCM_CC_43465_CHIP_ID		43465
     57 #define BRCM_CC_4350_CHIP_ID		0x4350
     58 #define BRCM_CC_43525_CHIP_ID		43525
     59 #define BRCM_CC_4354_CHIP_ID		0x4354
     60 #define BRCM_CC_4356_CHIP_ID		0x4356
     61 #define BRCM_CC_43566_CHIP_ID		43566
     62 #define BRCM_CC_43567_CHIP_ID		43567
     63 #define BRCM_CC_43569_CHIP_ID		43569
     64 #define BRCM_CC_43570_CHIP_ID		43570
     65 #define BRCM_CC_4358_CHIP_ID		0x4358
     66 #define BRCM_CC_4359_CHIP_ID		0x4359
     67 #define BRCM_CC_43602_CHIP_ID		43602
     68 #define BRCM_CC_4365_CHIP_ID		0x4365
     69 #define BRCM_CC_4366_CHIP_ID		0x4366
     70 #define BRCM_CC_4371_CHIP_ID		0x4371
     71 #define CY_CC_4373_CHIP_ID		0x4373
     72 
     73 /* Defaults */
     74 #define BWFM_DEFAULT_SCAN_CHANNEL_TIME	40
     75 #define BWFM_DEFAULT_SCAN_UNASSOC_TIME	40
     76 #define BWFM_DEFAULT_SCAN_PASSIVE_TIME	120
     77 
     78 #define	BWFM_TASK_COUNT			256
     79 
     80 
     81 struct bwfm_softc;
     82 
     83 struct bwfm_core {
     84 	uint16_t	 co_id;
     85 	uint16_t	 co_rev;
     86 	uint32_t	 co_base;
     87 	uint32_t	 co_wrapbase;
     88 	LIST_ENTRY(bwfm_core) co_link;
     89 };
     90 
     91 struct bwfm_chip {
     92 	uint32_t	 ch_chip;
     93 	uint32_t	 ch_chiprev;
     94 	uint32_t	 ch_cc_caps;
     95 	uint32_t	 ch_cc_caps_ext;
     96 	uint32_t	 ch_pmucaps;
     97 	uint32_t	 ch_pmurev;
     98 	uint32_t	 ch_rambase;
     99 	uint32_t	 ch_ramsize;
    100 	uint32_t	 ch_srsize;
    101 	char		 ch_name[8];
    102 	LIST_HEAD(,bwfm_core) ch_list;
    103 	int (*ch_core_isup)(struct bwfm_softc *, struct bwfm_core *);
    104 	void (*ch_core_disable)(struct bwfm_softc *, struct bwfm_core *,
    105 	    uint32_t prereset, uint32_t reset);
    106 	void (*ch_core_reset)(struct bwfm_softc *, struct bwfm_core *,
    107 	    uint32_t prereset, uint32_t reset, uint32_t postreset);
    108 };
    109 
    110 struct bwfm_bus_ops {
    111 	void (*bs_init)(struct bwfm_softc *);
    112 	void (*bs_stop)(struct bwfm_softc *);
    113 	int (*bs_txcheck)(struct bwfm_softc *);
    114 	int (*bs_txdata)(struct bwfm_softc *, struct mbuf **);
    115 	int (*bs_txctl)(struct bwfm_softc *, char *, size_t);
    116 	int (*bs_rxctl)(struct bwfm_softc *, char *, size_t *);
    117 };
    118 
    119 struct bwfm_buscore_ops {
    120 	uint32_t (*bc_read)(struct bwfm_softc *, uint32_t);
    121 	void (*bc_write)(struct bwfm_softc *, uint32_t, uint32_t);
    122 	int (*bc_prepare)(struct bwfm_softc *);
    123 	int (*bc_reset)(struct bwfm_softc *);
    124 	int (*bc_setup)(struct bwfm_softc *);
    125 	void (*bc_activate)(struct bwfm_softc *, const uint32_t);
    126 };
    127 
    128 struct bwfm_proto_ops {
    129 	int (*proto_query_dcmd)(struct bwfm_softc *, int, int,
    130 	    char *, size_t *);
    131 	int (*proto_set_dcmd)(struct bwfm_softc *, int, int,
    132 	    char *, size_t);
    133 };
    134 extern struct bwfm_proto_ops bwfm_proto_bcdc_ops;
    135 
    136 enum bwfm_task_cmd {
    137 	BWFM_TASK_NEWSTATE,
    138 	BWFM_TASK_KEY_SET,
    139 	BWFM_TASK_KEY_DELETE,
    140 	BWFM_TASK_RX_EVENT,
    141 };
    142 
    143 struct bwfm_cmd_newstate {
    144 	enum ieee80211_state	 state;
    145 	int			 arg;
    146 };
    147 
    148 struct bwfm_cmd_key {
    149 	const struct ieee80211_key *key;
    150 	uint8_t			 mac[IEEE80211_ADDR_LEN];
    151 };
    152 
    153 struct bwfm_task {
    154 	struct work		 t_work;
    155 	struct bwfm_softc	*t_sc;
    156 	enum bwfm_task_cmd	 t_cmd;
    157 	union {
    158 		struct bwfm_cmd_newstate	newstate;
    159 		struct bwfm_cmd_key		key;
    160 		struct mbuf			*mbuf;
    161 	} t_u;
    162 #define	t_newstate	t_u.newstate
    163 #define	t_key		t_u.key
    164 #define	t_mbuf		t_u.mbuf
    165 };
    166 
    167 struct bwfm_softc {
    168 	device_t		 sc_dev;
    169 	struct ieee80211com	 sc_ic;
    170 	struct ethercom		 sc_ec;
    171 #define	sc_if			 sc_ec.ec_if
    172 
    173 	struct bwfm_bus_ops	*sc_bus_ops;
    174 	struct bwfm_buscore_ops	*sc_buscore_ops;
    175 	struct bwfm_proto_ops	*sc_proto_ops;
    176 	struct bwfm_chip	 sc_chip;
    177 	uint8_t			 sc_io_type;
    178 #define		BWFM_IO_TYPE_D11N		1
    179 #define		BWFM_IO_TYPE_D11AC		2
    180 
    181 	int			 sc_tx_timer;
    182 
    183 	bool			 sc_if_attached;
    184 	struct pool_cache	*sc_freetask;
    185 	struct workqueue	*sc_taskq;
    186 
    187 	int			(*sc_newstate)(struct ieee80211com *,
    188 				    enum ieee80211_state, int);
    189 
    190 	int			 sc_bcdc_reqid;
    191 };
    192 
    193 void bwfm_attach(struct bwfm_softc *);
    194 void bwfm_chip_socram_ramsize(struct bwfm_softc *, struct bwfm_core *);
    195 void bwfm_chip_sysmem_ramsize(struct bwfm_softc *, struct bwfm_core *);
    196 void bwfm_chip_tcm_ramsize(struct bwfm_softc *, struct bwfm_core *);
    197 void bwfm_chip_tcm_rambase(struct bwfm_softc *);
    198 void bwfm_start(struct ifnet *);
    199 int bwfm_detach(struct bwfm_softc *, int);
    200 int bwfm_chip_attach(struct bwfm_softc *);
    201 int bwfm_chip_set_active(struct bwfm_softc *, uint32_t);
    202 void bwfm_chip_set_passive(struct bwfm_softc *);
    203 int bwfm_chip_sr_capable(struct bwfm_softc *);
    204 struct bwfm_core *bwfm_chip_get_core(struct bwfm_softc *, int);
    205 struct bwfm_core *bwfm_chip_get_pmu(struct bwfm_softc *);
    206 void bwfm_rx(struct bwfm_softc *, struct mbuf *m);
    207 
    208 #endif /* _DEV_IC_BWFMVAR_H */
    209