Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: ISC
0002 /*
0003  * Copyright (c) 2010 Broadcom Corporation
0004  */
0005 
0006 /****************
0007  * Common types *
0008  */
0009 
0010 #ifndef BRCMFMAC_CORE_H
0011 #define BRCMFMAC_CORE_H
0012 
0013 #include <net/cfg80211.h>
0014 #include "fweh.h"
0015 
0016 #define TOE_TX_CSUM_OL      0x00000001
0017 #define TOE_RX_CSUM_OL      0x00000002
0018 
0019 /* For supporting multiple interfaces */
0020 #define BRCMF_MAX_IFS   16
0021 
0022 /* Small, medium and maximum buffer size for dcmd
0023  */
0024 #define BRCMF_DCMD_SMLEN    256
0025 #define BRCMF_DCMD_MEDLEN   1536
0026 #define BRCMF_DCMD_MAXLEN   8192
0027 
0028 /* IOCTL from host to device are limited in length. A device can only handle
0029  * ethernet frame size. This limitation is to be applied by protocol layer.
0030  */
0031 #define BRCMF_TX_IOCTL_MAX_MSG_SIZE (ETH_FRAME_LEN+ETH_FCS_LEN)
0032 
0033 #define BRCMF_AMPDU_RX_REORDER_MAXFLOWS     256
0034 
0035 /* Length of firmware version string stored for
0036  * ethtool driver info which uses 32 bytes as well.
0037  */
0038 #define BRCMF_DRIVER_FIRMWARE_VERSION_LEN   32
0039 
0040 #define NDOL_MAX_ENTRIES    8
0041 
0042 /**
0043  * struct brcmf_ampdu_rx_reorder - AMPDU receive reorder info
0044  *
0045  * @pktslots: dynamic allocated array for ordering AMPDU packets.
0046  * @flow_id: AMPDU flow identifier.
0047  * @cur_idx: last AMPDU index from firmware.
0048  * @exp_idx: expected next AMPDU index.
0049  * @max_idx: maximum amount of packets per AMPDU.
0050  * @pend_pkts: number of packets currently in @pktslots.
0051  */
0052 struct brcmf_ampdu_rx_reorder {
0053     struct sk_buff **pktslots;
0054     u8 flow_id;
0055     u8 cur_idx;
0056     u8 exp_idx;
0057     u8 max_idx;
0058     u8 pend_pkts;
0059 };
0060 
0061 /* Forward decls for struct brcmf_pub (see below) */
0062 struct brcmf_proto; /* device communication protocol info */
0063 struct brcmf_fws_info;  /* firmware signalling info */
0064 struct brcmf_mp_device; /* module paramateres, device specific */
0065 
0066 /*
0067  * struct brcmf_rev_info
0068  *
0069  * The result field stores the error code of the
0070  * revision info request from firmware. For the
0071  * other fields see struct brcmf_rev_info_le in
0072  * fwil_types.h
0073  */
0074 struct brcmf_rev_info {
0075     int result;
0076     u32 vendorid;
0077     u32 deviceid;
0078     u32 radiorev;
0079     u32 corerev;
0080     u32 boardid;
0081     u32 boardvendor;
0082     u32 boardrev;
0083     u32 driverrev;
0084     u32 ucoderev;
0085     u32 bus;
0086     char chipname[12];
0087     u32 phytype;
0088     u32 phyrev;
0089     u32 anarev;
0090     u32 chippkg;
0091     u32 nvramrev;
0092 };
0093 
0094 /* Common structure for module and instance linkage */
0095 struct brcmf_pub {
0096     /* Linkage ponters */
0097     struct brcmf_bus *bus_if;
0098     struct brcmf_proto *proto;
0099     struct wiphy *wiphy;
0100     struct cfg80211_ops *ops;
0101     struct brcmf_cfg80211_info *config;
0102 
0103     /* Internal brcmf items */
0104     uint hdrlen;        /* Total BRCMF header length (proto + bus) */
0105 
0106     /* Dongle media info */
0107     char fwver[BRCMF_DRIVER_FIRMWARE_VERSION_LEN];
0108     u8 mac[ETH_ALEN];       /* MAC address obtained from dongle */
0109 
0110     struct mac_address addresses[BRCMF_MAX_IFS];
0111 
0112     struct brcmf_if *iflist[BRCMF_MAX_IFS];
0113     s32 if2bss[BRCMF_MAX_IFS];
0114     struct brcmf_if *mon_if;
0115 
0116     struct mutex proto_block;
0117     unsigned char proto_buf[BRCMF_DCMD_MAXLEN];
0118 
0119     struct brcmf_fweh_info fweh;
0120 
0121     struct brcmf_ampdu_rx_reorder
0122         *reorder_flows[BRCMF_AMPDU_RX_REORDER_MAXFLOWS];
0123 
0124     u32 feat_flags;
0125     u32 chip_quirks;
0126 
0127     struct brcmf_rev_info revinfo;
0128 #ifdef DEBUG
0129     struct dentry *dbgfs_dir;
0130 #endif
0131 
0132     struct notifier_block inetaddr_notifier;
0133     struct notifier_block inet6addr_notifier;
0134     struct brcmf_mp_device *settings;
0135 
0136     struct work_struct bus_reset;
0137 
0138     u8 clmver[BRCMF_DCMD_SMLEN];
0139 };
0140 
0141 /* forward declarations */
0142 struct brcmf_cfg80211_vif;
0143 struct brcmf_fws_mac_descriptor;
0144 
0145 /**
0146  * enum brcmf_netif_stop_reason - reason for stopping netif queue.
0147  *
0148  * @BRCMF_NETIF_STOP_REASON_FWS_FC:
0149  *  netif stopped due to firmware signalling flow control.
0150  * @BRCMF_NETIF_STOP_REASON_FLOW:
0151  *  netif stopped due to flowring full.
0152  * @BRCMF_NETIF_STOP_REASON_DISCONNECTED:
0153  *  netif stopped due to not being connected (STA mode).
0154  */
0155 enum brcmf_netif_stop_reason {
0156     BRCMF_NETIF_STOP_REASON_FWS_FC = BIT(0),
0157     BRCMF_NETIF_STOP_REASON_FLOW = BIT(1),
0158     BRCMF_NETIF_STOP_REASON_DISCONNECTED = BIT(2)
0159 };
0160 
0161 /**
0162  * struct brcmf_if - interface control information.
0163  *
0164  * @drvr: points to device related information.
0165  * @vif: points to cfg80211 specific interface information.
0166  * @ndev: associated network device.
0167  * @multicast_work: worker object for multicast provisioning.
0168  * @ndoffload_work: worker object for neighbor discovery offload configuration.
0169  * @fws_desc: interface specific firmware-signalling descriptor.
0170  * @ifidx: interface index in device firmware.
0171  * @bsscfgidx: index of bss associated with this interface.
0172  * @mac_addr: assigned mac address.
0173  * @netif_stop: bitmap indicates reason why netif queues are stopped.
0174  * @netif_stop_lock: spinlock for update netif_stop from multiple sources.
0175  * @pend_8021x_cnt: tracks outstanding number of 802.1x frames.
0176  * @pend_8021x_wait: used for signalling change in count.
0177  * @fwil_fwerr: flag indicating fwil layer should return firmware error codes.
0178  */
0179 struct brcmf_if {
0180     struct brcmf_pub *drvr;
0181     struct brcmf_cfg80211_vif *vif;
0182     struct net_device *ndev;
0183     struct work_struct multicast_work;
0184     struct work_struct ndoffload_work;
0185     struct brcmf_fws_mac_descriptor *fws_desc;
0186     int ifidx;
0187     s32 bsscfgidx;
0188     u8 mac_addr[ETH_ALEN];
0189     u8 netif_stop;
0190     spinlock_t netif_stop_lock;
0191     atomic_t pend_8021x_cnt;
0192     wait_queue_head_t pend_8021x_wait;
0193     struct in6_addr ipv6_addr_tbl[NDOL_MAX_ENTRIES];
0194     u8 ipv6addr_idx;
0195     bool fwil_fwerr;
0196 };
0197 
0198 int brcmf_netdev_wait_pend8021x(struct brcmf_if *ifp);
0199 
0200 /* Return pointer to interface name */
0201 char *brcmf_ifname(struct brcmf_if *ifp);
0202 struct brcmf_if *brcmf_get_ifp(struct brcmf_pub *drvr, int ifidx);
0203 void brcmf_configure_arp_nd_offload(struct brcmf_if *ifp, bool enable);
0204 int brcmf_net_attach(struct brcmf_if *ifp, bool locked);
0205 struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bsscfgidx, s32 ifidx,
0206                   bool is_p2pdev, const char *name, u8 *mac_addr);
0207 void brcmf_remove_interface(struct brcmf_if *ifp, bool locked);
0208 void brcmf_txflowblock_if(struct brcmf_if *ifp,
0209               enum brcmf_netif_stop_reason reason, bool state);
0210 void brcmf_txfinalize(struct brcmf_if *ifp, struct sk_buff *txp, bool success);
0211 void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff *skb);
0212 void brcmf_netif_mon_rx(struct brcmf_if *ifp, struct sk_buff *skb);
0213 void brcmf_net_detach(struct net_device *ndev, bool locked);
0214 int brcmf_net_mon_attach(struct brcmf_if *ifp);
0215 void brcmf_net_setcarrier(struct brcmf_if *ifp, bool on);
0216 int __init brcmf_core_init(void);
0217 void __exit brcmf_core_exit(void);
0218 
0219 #endif /* BRCMFMAC_CORE_H */