| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- /* Intel 7265D/3165 (iwlwifi "7000" family) PCIe transport.
- *
- * Polled, single RX queue, gen1 TFD TX queues. Every ring and buffer comes
- * from the page allocator (nothing big in BSS: the kernel image must stay
- * below 0x90000). iwl_mvm.c sits on top and speaks the firmware command
- * protocol; wifi.c is the netdev / 802.11 layer. */
- #ifndef IWL_TRANS_H
- #define IWL_TRANS_H
- /* TX queues used in DQA mode (fw/api/txq.h). */
- #define IWL_Q_CMD 0 /* host commands, FIFO 7 */
- #define IWL_Q_AUX 1 /* aux station (scan probes) */
- #define IWL_Q_BSS 4 /* AP station: management + data */
- #define IWL_NUM_Q 31
- /* Firmware images in the .ucode file. */
- #define IWL_IMG_RT 0
- #define IWL_IMG_INIT 1
- /* Received firmware packet (struct iwl_rx_packet). */
- struct iwl_pkt {
- unsigned int len_n_flags; /* bits 0..13: length incl. 4-byte hdr */
- unsigned char cmd;
- unsigned char group;
- unsigned short seq; /* bit 15: unsolicited (SEQ_RX_FRAME) */
- unsigned char data[];
- } __attribute__((packed));
- static inline unsigned int iwl_pkt_payload_len(const struct iwl_pkt *p)
- {
- unsigned int l = p->len_n_flags & 0x3FFFu;
- return l >= 4 ? l - 4 : 0;
- }
- /* Notification handler (set by iwl_mvm.c): called for every packet that is
- * not the response a synchronous command is waiting for. */
- typedef void (*iwl_rx_handler)(const struct iwl_pkt *pkt);
- struct iwl_fw_info {
- unsigned int api[4], capa[4];
- unsigned int phy_sku;
- unsigned int flow_trigger[2], event_trigger[2]; /* [IWL_IMG_*] */
- unsigned int ver; /* ucode API version from the header */
- char human[24];
- int present;
- };
- /* --- probe / lifecycle ------------------------------------------------- */
- int iwl_probe(void); /* PCI scan + BAR map: 0 = found */
- int iwl_present(void);
- const char *iwl_chip_name(void);
- unsigned int iwl_hw_rev(void);
- const struct iwl_fw_info *iwl_fw(void);
- int iwl_fw_parse(void); /* find + parse firmware in /ramfs */
- int iwl_start_hw(void); /* prepare, reset, APM init */
- int iwl_load_fw(int img); /* rings + sections + release reset */
- void iwl_fw_alive(unsigned int scd_base); /* SCD setup + cmd queue enable */
- void iwl_stop_device(void); /* stop DMA, APM stop (kexec, retry) */
- int iwl_rfkill(void); /* 1 = hardware RF-kill asserted */
- /* --- firmware I/O ------------------------------------------------------- */
- void iwl_set_rx_handler(iwl_rx_handler h);
- /* Poll the RX ring once; returns the number of packets handled, -1 on a
- * firmware error (CSR_INT SW_ERR / HW_ERR). */
- int iwl_rx_poll(void);
- /* Wait for a notification (cmd id in the legacy group) for up to `ms`.
- * The handler still sees it; returns 0 when it arrived. */
- int iwl_wait_notif(unsigned char cmd, unsigned int ms);
- /* Synchronous host command. `id` is (group << 8) | opcode; `resp` (may be
- * NULL) receives up to `resp_max` payload bytes. Returns the payload
- * length, or -1 on timeout/error. */
- int iwl_send_cmd(unsigned int id, const void *data, unsigned int len,
- void *resp, unsigned int resp_max);
- /* Fire-and-forget command (no response expected or awaited). */
- int iwl_send_cmd_async(unsigned int id, const void *data, unsigned int len);
- /* TX_CMD on a data/management queue: `txcmd` is the struct iwl_tx_cmd
- * (header copied in, 802.11 header + payload follow in `frame`). */
- int iwl_tx(int q, const void *txcmd, unsigned int txlen,
- const void *frame, unsigned int flen, unsigned char sta_id,
- unsigned int mic_len);
- /* TX response for queue q, slot idx: release the entries up to idx. */
- void iwl_tx_reclaim(int q, unsigned int idx);
- /* Activate a data/mgmt queue (trans side of SCD_QUEUE_CFG, DQA mode). */
- void iwl_txq_enable(int q, unsigned short ssn);
- unsigned int iwl_txq_wptr(int q);
- /* Firmware section data (for the NVM/PHY-DB helpers): returns the image. */
- const unsigned char *iwl_fw_data(unsigned int *size);
- /* Byte helpers (`rep movsb/stosb`; the kernel has no libc). */
- void iwl_memcpy(void *dst, const void *src, unsigned int n);
- void iwl_memzero(void *dst, unsigned int n);
- unsigned int iwl_mem_rd32(unsigned int addr); /* device SRAM */
- /* Register helpers (also used by the mvm layer for diagnostics). */
- unsigned int iwl_rd(unsigned int reg);
- void iwl_wr(unsigned int reg, unsigned int val);
- unsigned int iwl_rd_prph(unsigned int addr);
- void iwl_wr_prph(unsigned int addr, unsigned int val);
- void iwl_udelay(unsigned int us);
- void iwl_log(const char *s);
- void iwl_loghex(const char *s, unsigned int v);
- #endif
|