Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/next/external/cache/sources/wl/include/dbus.h
Views: 3959
/*1* Dongle BUS interface Abstraction layer2* target serial buses like USB, SDIO, SPI, etc.3*4* $Copyright Open 2008 Broadcom Corporation$5*6* $Id: dbus.h 394558 2013-04-03 00:11:01Z $7*/89#ifndef __DBUS_H__10#define __DBUS_H__1112#include "typedefs.h"1314#define DBUSTRACE(args)15#define DBUSERR(args)16#define DBUSINFO(args)17#define DBUSTRACE(args)18#define DBUSDBGLOCK(args)1920#define BCM_OTP_SIZE_43236 84 /* number of 16 bit values */21#define BCM_OTP_SW_RGN_43236 24 /* start offset of SW config region */22#define BCM_OTP_ADDR_43236 0x18000800 /* address of otp base */2324#define ERR_CBMASK_TXFAIL 0x0000000125#define ERR_CBMASK_RXFAIL 0x0000000226#define ERR_CBMASK_ALL 0xFFFFFFFF2728#define DBUS_CBCTL_WRITE 029#define DBUS_CBCTL_READ 13031#define DBUS_TX_RETRY_LIMIT 3 /* retries for failed txirb */32#define DBUS_TX_TIMEOUT_INTERVAL 250 /* timeout for txirb complete, in ms */3334#define DBUS_BUFFER_SIZE_TX 3200035#define DBUS_BUFFER_SIZE_RX 240003637#define DBUS_BUFFER_SIZE_TX_NOAGG 204838#define DBUS_BUFFER_SIZE_RX_NOAGG 20483940enum {41DBUS_OK = 0,42DBUS_ERR = -200,43DBUS_ERR_TIMEOUT,44DBUS_ERR_DISCONNECT,45DBUS_ERR_NODEVICE,46DBUS_ERR_UNSUPPORTED,47DBUS_ERR_PENDING,48DBUS_ERR_NOMEM,49DBUS_ERR_TXFAIL,50DBUS_ERR_TXTIMEOUT,51DBUS_ERR_TXDROP,52DBUS_ERR_RXFAIL,53DBUS_ERR_RXDROP,54DBUS_ERR_TXCTLFAIL,55DBUS_ERR_RXCTLFAIL,56DBUS_ERR_REG_PARAM,57DBUS_STATUS_CANCELLED,58DBUS_ERR_NVRAM,59DBUS_JUMBO_NOMATCH,60DBUS_JUMBO_BAD_FORMAT,61DBUS_NVRAM_NONTXT62};6364/* DBUS types */65enum {66DBUS_USB,67DBUS_SDIO,68DBUS_SPI,69DBUS_UNKNOWN70};7172enum dbus_state {73DBUS_STATE_DL_PENDING,74DBUS_STATE_DL_DONE,75DBUS_STATE_UP,76DBUS_STATE_DOWN,77DBUS_STATE_PNP_FWDL,78DBUS_STATE_DISCONNECT,79DBUS_STATE_SLEEP80};8182enum dbus_pnp_state {83DBUS_PNP_DISCONNECT,84DBUS_PNP_SLEEP,85DBUS_PNP_RESUME86};8788enum dbus_file {89DBUS_FIRMWARE,90DBUS_NVFILE91};9293typedef enum _DEVICE_SPEED {94INVALID_SPEED = -1,95LOW_SPEED = 1, /* USB 1.1: 1.5 Mbps */96FULL_SPEED, /* USB 1.1: 12 Mbps */97HIGH_SPEED, /* USB 2.0: 480 Mbps */98SUPER_SPEED, /* USB 3.0: 4.8 Gbps */99} DEVICE_SPEED;100101typedef struct {102int bustype;103int vid;104int pid;105int devid;106int chiprev; /* chip revsion number */107int mtu;108int nchan; /* Data Channels */109int has_2nd_bulk_in_ep;110} dbus_attrib_t;111112/* FIX: Account for errors related to DBUS;113* Let upper layer account for packets/bytes114*/115typedef struct {116uint32 rx_errors;117uint32 tx_errors;118uint32 rx_dropped;119uint32 tx_dropped;120} dbus_stats_t;121122/*123* Configurable BUS parameters124*/125typedef struct {126bool rxctl_deferrespok;127} dbus_config_t;128129/*130* External Download Info131*/132typedef struct dbus_extdl {133uint8 *fw;134int fwlen;135uint8 *vars;136int varslen;137} dbus_extdl_t;138139struct dbus_callbacks;140struct exec_parms;141142typedef void *(*probe_cb_t)(void *arg, const char *desc, uint32 bustype, uint32 hdrlen);143typedef void (*disconnect_cb_t)(void *arg);144typedef void *(*exec_cb_t)(struct exec_parms *args);145146/* Client callbacks registered during dbus_attach() */147typedef struct dbus_callbacks {148void (*send_complete)(void *cbarg, void *info, int status);149void (*recv_buf)(void *cbarg, uint8 *buf, int len);150void (*recv_pkt)(void *cbarg, void *pkt);151void (*txflowcontrol)(void *cbarg, bool onoff);152void (*errhandler)(void *cbarg, int err);153void (*ctl_complete)(void *cbarg, int type, int status);154void (*state_change)(void *cbarg, int state);155void *(*pktget)(void *cbarg, uint len, bool send);156void (*pktfree)(void *cbarg, void *p, bool send);157} dbus_callbacks_t;158159struct dbus_pub;160struct bcmstrbuf;161struct dbus_irb;162struct dbus_irb_rx;163struct dbus_irb_tx;164struct dbus_intf_callbacks;165166typedef struct {167void* (*attach)(struct dbus_pub *pub, void *cbarg, struct dbus_intf_callbacks *cbs);168void (*detach)(struct dbus_pub *pub, void *bus);169170int (*up)(void *bus);171int (*down)(void *bus);172int (*send_irb)(void *bus, struct dbus_irb_tx *txirb);173int (*recv_irb)(void *bus, struct dbus_irb_rx *rxirb);174int (*cancel_irb)(void *bus, struct dbus_irb_tx *txirb);175int (*send_ctl)(void *bus, uint8 *buf, int len);176int (*recv_ctl)(void *bus, uint8 *buf, int len);177int (*get_stats)(void *bus, dbus_stats_t *stats);178int (*get_attrib)(void *bus, dbus_attrib_t *attrib);179180int (*pnp)(void *bus, int evnt);181int (*remove)(void *bus);182int (*resume)(void *bus);183int (*suspend)(void *bus);184int (*stop)(void *bus);185int (*reset)(void *bus);186187/* Access to bus buffers directly */188void *(*pktget)(void *bus, int len);189void (*pktfree)(void *bus, void *pkt);190191int (*iovar_op)(void *bus, const char *name, void *params, int plen, void *arg, int len,192bool set);193void (*dump)(void *bus, struct bcmstrbuf *strbuf);194int (*set_config)(void *bus, dbus_config_t *config);195int (*get_config)(void *bus, dbus_config_t *config);196197bool (*device_exists)(void *bus);198bool (*dlneeded)(void *bus);199int (*dlstart)(void *bus, uint8 *fw, int len);200int (*dlrun)(void *bus);201bool (*recv_needed)(void *bus);202203void *(*exec_rxlock)(void *bus, exec_cb_t func, struct exec_parms *args);204void *(*exec_txlock)(void *bus, exec_cb_t func, struct exec_parms *args);205206int (*tx_timer_init)(void *bus);207int (*tx_timer_start)(void *bus, uint timeout);208int (*tx_timer_stop)(void *bus);209210int (*sched_dpc)(void *bus);211int (*lock)(void *bus);212int (*unlock)(void *bus);213int (*sched_probe_cb)(void *bus);214215int (*shutdown)(void *bus);216217int (*recv_stop)(void *bus);218int (*recv_resume)(void *bus);219220int (*recv_irb_from_ep)(void *bus, struct dbus_irb_rx *rxirb, uint ep_idx);221222int (*readreg)(void *bus, uint32 regaddr, int datalen, uint32 *value);223224/* Add from the bottom */225} dbus_intf_t;226227typedef struct dbus_pub {228struct osl_info *osh;229dbus_stats_t stats;230dbus_attrib_t attrib;231enum dbus_state busstate;232DEVICE_SPEED device_speed;233int ntxq, nrxq, rxsize;234void *bus;235struct shared_info *sh;236void *dev_info;237} dbus_pub_t;238239#define BUS_INFO(bus, type) (((type *) bus)->pub->bus)240241#define ALIGNED_LOCAL_VARIABLE(var, align) \242uint8 buffer[SDALIGN+64]; \243uint8 *var = (uint8 *)(((uintptr)&buffer[0]) & ~(align-1)) + align;244245/* IO Request Block (IRB) */246typedef struct dbus_irb {247struct dbus_irb *next; /* it's casted from dbus_irb_tx or dbus_irb_rx struct */248} dbus_irb_t;249250/* General info for all BUS */251typedef struct dbus_irbq {252dbus_irb_t *head;253dbus_irb_t *tail;254int cnt;255} dbus_irbq_t;256257typedef struct dbus_irb_rx {258struct dbus_irb irb; /* Must be first */259uint8 *buf;260int buf_len;261int actual_len;262void *pkt;263void *info;264void *arg;265} dbus_irb_rx_t;266267typedef struct dbus_irb_tx {268struct dbus_irb irb; /* Must be first */269uint8 *buf;270int len;271void *pkt;272int retry_count;273void *info;274void *arg;275void *send_buf; /* linear bufffer for LINUX when aggreagtion is enabled */276} dbus_irb_tx_t;277278279/* DBUS interface callbacks are different from user callbacks280* so, internally, different info can be passed to upper layer281*/282typedef struct dbus_intf_callbacks {283void (*send_irb_timeout)(void *cbarg, dbus_irb_tx_t *txirb);284void (*send_irb_complete)(void *cbarg, dbus_irb_tx_t *txirb, int status);285void (*recv_irb_complete)(void *cbarg, dbus_irb_rx_t *rxirb, int status);286void (*errhandler)(void *cbarg, int err);287void (*ctl_complete)(void *cbarg, int type, int status);288void (*state_change)(void *cbarg, int state);289bool (*isr)(void *cbarg, bool *wantdpc);290bool (*dpc)(void *cbarg, bool bounded);291void (*watchdog)(void *cbarg);292void *(*pktget)(void *cbarg, uint len, bool send);293void (*pktfree)(void *cbarg, void *p, bool send);294struct dbus_irb* (*getirb)(void *cbarg, bool send);295void (*rxerr_indicate)(void *cbarg, bool on);296} dbus_intf_callbacks_t;297298299#if defined(EHCI_FASTPATH_TX) || defined(EHCI_FASTPATH_RX)300301302#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))303/* Backward compatibility */304typedef unsigned int gfp_t;305306#define dma_pool pci_pool307#define dma_pool_create(name, dev, size, align, alloc) \308pci_pool_create(name, dev, size, align, alloc, GFP_DMA | GFP_ATOMIC)309#define dma_pool_destroy(pool) pci_pool_destroy(pool)310#define dma_pool_alloc(pool, flags, handle) pci_pool_alloc(pool, flags, handle)311#define dma_pool_free(pool, vaddr, addr) pci_pool_free(pool, vaddr, addr)312#define dma_map_single(dev, addr, size, dir) pci_map_single(dev, addr, size, dir)313#define dma_unmap_single(dev, hnd, size, dir) pci_unmap_single(dev, hnd, size, dir)314#define DMA_FROM_DEVICE PCI_DMA_FROMDEVICE315#define DMA_TO_DEVICE PCI_DMA_TODEVICE316#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)) */317318/* Availability of these functions varies (when present, they have two arguments) */319#ifndef hc32_to_cpu320#define hc32_to_cpu(x) le32_to_cpu(x)321#define cpu_to_hc32(x) cpu_to_le32(x)322typedef unsigned int __hc32;323#else324#error Two-argument functions needed325#endif326327/* Private USB opcode base */328#define EHCI_FASTPATH 0x31329#define EHCI_SET_EP_BYPASS EHCI_FASTPATH330#define EHCI_SET_BYPASS_CB (EHCI_FASTPATH + 1)331#define EHCI_SET_BYPASS_DEV (EHCI_FASTPATH + 2)332#define EHCI_DUMP_STATE (EHCI_FASTPATH + 3)333#define EHCI_SET_BYPASS_POOL (EHCI_FASTPATH + 4)334#define EHCI_CLR_EP_BYPASS (EHCI_FASTPATH + 5)335336/*337* EHCI QTD structure (hardware and extension)338* NOTE that is does not need to (and does not) match its kernel counterpart339*/340#define EHCI_QTD_NBUFFERS 5341#define EHCI_QTD_ALIGN 32342#define EHCI_BULK_PACKET_SIZE 512343#define EHCI_QTD_XACTERR_MAX 32344345struct ehci_qtd {346/* Hardware map */347volatile uint32_t qtd_next;348volatile uint32_t qtd_altnext;349volatile uint32_t qtd_status;350#define EHCI_QTD_GET_BYTES(x) (((x)>>16) & 0x7fff)351#define EHCI_QTD_IOC 0x00008000352#define EHCI_QTD_GET_CERR(x) (((x)>>10) & 0x3)353#define EHCI_QTD_SET_CERR(x) ((x) << 10)354#define EHCI_QTD_GET_PID(x) (((x)>>8) & 0x3)355#define EHCI_QTD_SET_PID(x) ((x) << 8)356#define EHCI_QTD_ACTIVE 0x80357#define EHCI_QTD_HALTED 0x40358#define EHCI_QTD_BUFERR 0x20359#define EHCI_QTD_BABBLE 0x10360#define EHCI_QTD_XACTERR 0x08361#define EHCI_QTD_MISSEDMICRO 0x04362volatile uint32_t qtd_buffer[EHCI_QTD_NBUFFERS];363volatile uint32_t qtd_buffer_hi[EHCI_QTD_NBUFFERS];364365/* Implementation extension */366dma_addr_t qtd_self; /* own hardware address */367struct ehci_qtd *obj_next; /* software link to the next QTD */368void *rpc; /* pointer to the rpc buffer */369size_t length; /* length of the data in the buffer */370void *buff; /* pointer to the reassembly buffer */371int xacterrs; /* retry counter for qtd xact error */372} __attribute__ ((aligned(EHCI_QTD_ALIGN)));373374#define EHCI_NULL __constant_cpu_to_le32(1) /* HW null pointer shall be odd */375376#define SHORT_READ_Q(token) (EHCI_QTD_GET_BYTES(token) != 0 && EHCI_QTD_GET_PID(token) == 1)377378/* Queue Head */379/* NOTE This structure is slightly different from the one in the kernel; but needs to stay380* compatible381*/382struct ehci_qh {383/* Hardware map */384volatile uint32_t qh_link;385volatile uint32_t qh_endp;386volatile uint32_t qh_endphub;387volatile uint32_t qh_curqtd;388389/* QTD overlay */390volatile uint32_t ow_next;391volatile uint32_t ow_altnext;392volatile uint32_t ow_status;393volatile uint32_t ow_buffer [EHCI_QTD_NBUFFERS];394volatile uint32_t ow_buffer_hi [EHCI_QTD_NBUFFERS];395396/* Extension (should match the kernel layout) */397dma_addr_t unused0;398void *unused1;399struct list_head unused2;400struct ehci_qtd *dummy;401struct ehci_qh *unused3;402403struct ehci_hcd *unused4;404#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))405struct kref unused5;406unsigned unused6;407408uint8_t unused7;409410/* periodic schedule info */411uint8_t unused8;412uint8_t unused9;413uint8_t unused10;414uint16_t unused11;415uint16_t unused12;416uint16_t unused13;417struct usb_device *unused14;418#else419unsigned unused5;420u8 unused6;421422/* periodic schedule info */423u8 unused7;424u8 unused8;425u8 unused9;426unsigned short unused10;427unsigned short unused11;428#define NO_FRAME ((unsigned short)~0)429#ifdef EHCI_QUIRK_FIX430struct usb_device *unused12;431#endif /* EHCI_QUIRK_FIX */432#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)) */433struct ehci_qtd *first_qtd;434/* Link to the first QTD; this is an optimized equivalent of the qtd_list field */435/* NOTE that ehci_qh in ehci.h shall reserve this word */436} __attribute__ ((aligned(EHCI_QTD_ALIGN)));437438#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))439/* The corresponding structure in the kernel is used to get the QH */440struct hcd_dev { /* usb_device.hcpriv points to this */441struct list_head unused0;442struct list_head unused1;443444/* array of QH pointers */445void *ep[32];446};447#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)) */448#endif /* EHCI_FASTPATH_TX || EHCI_FASTPATH_RX */449450/*451* Public Bus Function Interface452*/453extern int dbus_register(int vid, int pid, probe_cb_t prcb, disconnect_cb_t discb, void *prarg,454void *param1, void *param2);455extern int dbus_deregister(void);456extern dbus_pub_t *dbus_attach(struct osl_info *osh, int rxsize, int nrxq, int ntxq,457void *cbarg, dbus_callbacks_t *cbs, dbus_extdl_t *extdl, struct shared_info *sh);458extern void dbus_detach(dbus_pub_t *pub);459extern int dbus_up(dbus_pub_t *pub);460extern int dbus_down(dbus_pub_t *pub);461extern int dbus_stop(dbus_pub_t *pub);462extern int dbus_shutdown(dbus_pub_t *pub);463extern void dbus_flowctrl_rx(dbus_pub_t *pub, bool on);464extern int dbus_send_buf(dbus_pub_t *pub, uint8 *buf, int len, void *info);465extern int dbus_send_pkt(dbus_pub_t *pub, void *pkt, void *info);466extern int dbus_send_ctl(dbus_pub_t *pub, uint8 *buf, int len);467extern int dbus_recv_ctl(dbus_pub_t *pub, uint8 *buf, int len);468extern int dbus_recv_bulk(dbus_pub_t *pub, uint32 ep_idx);469extern int dbus_get_stats(dbus_pub_t *pub, dbus_stats_t *stats);470extern int dbus_get_attrib(dbus_pub_t *pub, dbus_attrib_t *attrib);471extern int dbus_get_device_speed(dbus_pub_t *pub);472extern int dbus_set_config(dbus_pub_t *pub, dbus_config_t *config);473extern int dbus_get_config(dbus_pub_t *pub, dbus_config_t *config);474extern void * dbus_get_devinfo(dbus_pub_t *pub);475extern void *dbus_pktget(dbus_pub_t *pub, int len);476extern void dbus_pktfree(dbus_pub_t *pub, void* pkt);477extern int dbus_set_errmask(dbus_pub_t *pub, uint32 mask);478extern int dbus_pnp_sleep(dbus_pub_t *pub);479extern int dbus_pnp_resume(dbus_pub_t *pub, int *fw_reload);480extern int dbus_pnp_disconnect(dbus_pub_t *pub);481extern int dbus_iovar_op(dbus_pub_t *pub, const char *name,482void *params, int plen, void *arg, int len, bool set);483extern void *dhd_dbus_txq(const dbus_pub_t *pub);484extern uint dhd_dbus_hdrlen(const dbus_pub_t *pub);485extern void dbus_flowctrl_tx(void *dbi, bool on);486#if defined(BCM_REQUEST_FW)487extern void *dbus_get_fw_nvfile(int devid, uint8 **fw, int *fwlen, int type,488uint16 boardtype, uint16 boardrev);489extern void dbus_release_fw_nvfile(void *firmware);490#endif /* #if defined(BCM_REQUEST_FW) */491492/*493* Bus specific Interface494* Implemented by dbus_usb.c/dbus_sdio.c495*/496extern int dbus_bus_register(int vid, int pid, probe_cb_t prcb, disconnect_cb_t discb, void *prarg,497dbus_intf_t **intf, void *param1, void *param2);498extern int dbus_bus_deregister(void);499extern void dbus_bus_fw_get(void *bus, uint8 **fw, int *fwlen, int *decomp);500501/*502* Bus-specific and OS-specific Interface503* Implemented by dbus_usb_[linux/ndis].c/dbus_sdio_[linux/ndis].c504*/505extern int dbus_bus_osl_register(int vid, int pid, probe_cb_t prcb, disconnect_cb_t discb,506void *prarg, dbus_intf_t **intf, void *param1, void *param2);507extern int dbus_bus_osl_deregister(void);508extern int dbus_bus_osl_hw_register(int vid, int pid, probe_cb_t prcb, disconnect_cb_t discb,509void *prarg, dbus_intf_t **intf);510extern int dbus_bus_osl_hw_deregister(void);511extern uint usbdev_bulkin_eps(void);512513#if defined(EHCI_FASTPATH_TX) || defined(EHCI_FASTPATH_RX)514extern int optimize_qtd_fill_with_rpc(const dbus_pub_t *pub, int epn, struct ehci_qtd *qtd,515void *rpc, int token, int len);516extern int optimize_submit_async(struct ehci_qtd *qtd, int epn);517extern struct ehci_qtd *optimize_ehci_qtd_alloc(gfp_t flags);518extern void optimize_ehci_qtd_free(struct ehci_qtd *qtd);519extern void optimize_submit_rx_request(const dbus_pub_t *pub, int epn, struct ehci_qtd *qtd_in,520void *buf);521#endif /* EHCI_FASTPATH_TX || EHCI_FASTPATH_RX */522#endif /* __DBUS_H__ */523524525