1 // SPDX-License-Identifier: ISC
3 * Copyright (c) 2010 Broadcom Corporation
10 #ifndef BRCMFMAC_CORE_H
11 #define BRCMFMAC_CORE_H
13 #include <net/cfg80211.h>
16 #if IS_MODULE(CONFIG_BRCMFMAC)
17 #define BRCMF_EXPORT_SYMBOL_GPL(__sym) EXPORT_SYMBOL_NS_GPL(__sym, "BRCMFMAC")
19 #define BRCMF_EXPORT_SYMBOL_GPL(__sym)
22 #define TOE_TX_CSUM_OL 0x00000001
23 #define TOE_RX_CSUM_OL 0x00000002
25 /* For supporting multiple interfaces */
26 #define BRCMF_MAX_IFS 16
28 /* Small, medium and maximum buffer size for dcmd
30 #define BRCMF_DCMD_SMLEN 256
31 #define BRCMF_DCMD_MEDLEN 1536
32 #define BRCMF_DCMD_MAXLEN 8192
34 /* IOCTL from host to device are limited in length. A device can only handle
35 * ethernet frame size. This limitation is to be applied by protocol layer.
37 #define BRCMF_TX_IOCTL_MAX_MSG_SIZE (ETH_FRAME_LEN+ETH_FCS_LEN)
39 #define BRCMF_AMPDU_RX_REORDER_MAXFLOWS 256
41 /* Length of firmware version string stored for
42 * ethtool driver info which uses 32 bytes as well.
44 #define BRCMF_DRIVER_FIRMWARE_VERSION_LEN 32
46 #define NDOL_MAX_ENTRIES 8
49 * struct brcmf_ampdu_rx_reorder - AMPDU receive reorder info
51 * @flow_id: AMPDU flow identifier.
52 * @cur_idx: last AMPDU index from firmware.
53 * @exp_idx: expected next AMPDU index.
54 * @max_idx: maximum amount of packets per AMPDU.
55 * @pend_pkts: number of packets currently in @pktslots.
56 * @pktslots: array for ordering AMPDU packets.
58 struct brcmf_ampdu_rx_reorder
{
64 struct sk_buff
*pktslots
[];
67 /* Forward decls for struct brcmf_pub (see below) */
68 struct brcmf_proto
; /* device communication protocol info */
69 struct brcmf_fws_info
; /* firmware signalling info */
70 struct brcmf_mp_device
; /* module paramateres, device specific */
73 * struct brcmf_rev_info
75 * The result field stores the error code of the
76 * revision info request from firmware. For the
77 * other fields see struct brcmf_rev_info_le in
80 struct brcmf_rev_info
{
100 /* Common structure for module and instance linkage */
102 /* Linkage ponters */
103 struct brcmf_bus
*bus_if
;
104 struct brcmf_proto
*proto
;
106 struct cfg80211_ops
*ops
;
107 struct brcmf_cfg80211_info
*config
;
109 /* Internal brcmf items */
110 uint hdrlen
; /* Total BRCMF header length (proto + bus) */
112 /* Dongle media info */
113 char fwver
[BRCMF_DRIVER_FIRMWARE_VERSION_LEN
];
114 u8 mac
[ETH_ALEN
]; /* MAC address obtained from dongle */
116 struct mac_address addresses
[BRCMF_MAX_IFS
];
118 struct brcmf_if
*iflist
[BRCMF_MAX_IFS
];
119 s32 if2bss
[BRCMF_MAX_IFS
];
120 struct brcmf_if
*mon_if
;
122 struct mutex proto_block
;
123 unsigned char proto_buf
[BRCMF_DCMD_MAXLEN
];
125 struct brcmf_fweh_info
*fweh
;
127 struct brcmf_ampdu_rx_reorder
128 *reorder_flows
[BRCMF_AMPDU_RX_REORDER_MAXFLOWS
];
133 struct brcmf_rev_info revinfo
;
135 struct dentry
*dbgfs_dir
;
138 struct notifier_block inetaddr_notifier
;
139 struct notifier_block inet6addr_notifier
;
140 struct brcmf_mp_device
*settings
;
142 struct work_struct bus_reset
;
144 u8 clmver
[BRCMF_DCMD_SMLEN
];
146 const struct brcmf_fwvid_ops
*vops
;
150 /* forward declarations */
151 struct brcmf_cfg80211_vif
;
152 struct brcmf_fws_mac_descriptor
;
155 * enum brcmf_netif_stop_reason - reason for stopping netif queue.
157 * @BRCMF_NETIF_STOP_REASON_FWS_FC:
158 * netif stopped due to firmware signalling flow control.
159 * @BRCMF_NETIF_STOP_REASON_FLOW:
160 * netif stopped due to flowring full.
161 * @BRCMF_NETIF_STOP_REASON_DISCONNECTED:
162 * netif stopped due to not being connected (STA mode).
164 enum brcmf_netif_stop_reason
{
165 BRCMF_NETIF_STOP_REASON_FWS_FC
= BIT(0),
166 BRCMF_NETIF_STOP_REASON_FLOW
= BIT(1),
167 BRCMF_NETIF_STOP_REASON_DISCONNECTED
= BIT(2)
171 * struct brcmf_if - interface control information.
173 * @drvr: points to device related information.
174 * @vif: points to cfg80211 specific interface information.
175 * @ndev: associated network device.
176 * @multicast_work: worker object for multicast provisioning.
177 * @ndoffload_work: worker object for neighbor discovery offload configuration.
178 * @fws_desc: interface specific firmware-signalling descriptor.
179 * @ifidx: interface index in device firmware.
180 * @bsscfgidx: index of bss associated with this interface.
181 * @mac_addr: assigned mac address.
182 * @netif_stop: bitmap indicates reason why netif queues are stopped.
183 * @netif_stop_lock: spinlock for update netif_stop from multiple sources.
184 * @pend_8021x_cnt: tracks outstanding number of 802.1x frames.
185 * @pend_8021x_wait: used for signalling change in count.
186 * @fwil_fwerr: flag indicating fwil layer should return firmware error codes.
189 struct brcmf_pub
*drvr
;
190 struct brcmf_cfg80211_vif
*vif
;
191 struct net_device
*ndev
;
192 struct work_struct multicast_work
;
193 struct work_struct ndoffload_work
;
194 struct brcmf_fws_mac_descriptor
*fws_desc
;
197 u8 mac_addr
[ETH_ALEN
];
199 spinlock_t netif_stop_lock
;
200 atomic_t pend_8021x_cnt
;
201 wait_queue_head_t pend_8021x_wait
;
202 struct in6_addr ipv6_addr_tbl
[NDOL_MAX_ENTRIES
];
207 int brcmf_netdev_wait_pend8021x(struct brcmf_if
*ifp
);
209 /* Return pointer to interface name */
210 char *brcmf_ifname(struct brcmf_if
*ifp
);
211 struct brcmf_if
*brcmf_get_ifp(struct brcmf_pub
*drvr
, int ifidx
);
212 void brcmf_configure_arp_nd_offload(struct brcmf_if
*ifp
, bool enable
);
213 int brcmf_net_attach(struct brcmf_if
*ifp
, bool locked
);
214 struct brcmf_if
*brcmf_add_if(struct brcmf_pub
*drvr
, s32 bsscfgidx
, s32 ifidx
,
215 bool is_p2pdev
, const char *name
, u8
*mac_addr
);
216 void brcmf_remove_interface(struct brcmf_if
*ifp
, bool locked
);
217 void brcmf_txflowblock_if(struct brcmf_if
*ifp
,
218 enum brcmf_netif_stop_reason reason
, bool state
);
219 void brcmf_txfinalize(struct brcmf_if
*ifp
, struct sk_buff
*txp
, bool success
);
220 void brcmf_netif_rx(struct brcmf_if
*ifp
, struct sk_buff
*skb
);
221 void brcmf_netif_mon_rx(struct brcmf_if
*ifp
, struct sk_buff
*skb
);
222 void brcmf_net_detach(struct net_device
*ndev
, bool locked
);
223 int brcmf_net_mon_attach(struct brcmf_if
*ifp
);
224 void brcmf_net_setcarrier(struct brcmf_if
*ifp
, bool on
);
225 int __init
brcmf_core_init(void);
226 void __exit
brcmf_core_exit(void);
228 #endif /* BRCMFMAC_CORE_H */