/* Intel iwlwifi PCIe transport: the 7000 family (7265D/3165, MVM firmware) * and the 6000 family (6200/6300, DVM firmware). * * 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 /* DVM (6000 family) queues: the four AC queues in Linux's default * iwlagn_default_queue_to_tx_fifo order, command queue on 4. */ #define IWL_DVM_Q_VO 0 /* FIFO 3: management frames */ #define IWL_DVM_Q_VI 1 /* FIFO 2 */ #define IWL_DVM_Q_BE 2 /* FIFO 1: non-QoS data */ #define IWL_DVM_Q_BK 3 /* FIFO 0 */ #define IWL_DVM_Q_CMD 4 /* IWL_DEFAULT_CMD_QUEUE_NUM, FIFO 7 */ /* Device sub-families (iwl_subfamily()). */ #define IWL_SUB_7265 1 /* 7265D / 3165: MVM firmware */ #define IWL_SUB_6000I 2 /* 6200 (6000i): DVM, antennas B+C */ #define IWL_SUB_6000 3 /* 6300: DVM, antennas A+B+C */ /* 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_is_dvm(void); /* 6000 family (DVM firmware) */ int iwl_fatal(void); /* firmware crashed (SW/HW error) */ unsigned int iwl_subfamily(void); /* IWL_SUB_* */ /* DVM: radio SKU / config bits written during NIC init, before rings. */ void iwl_set_nic_config(void (*fn)(void)); /* DVM AC queue: scheduler programmed by the transport (FIFO, window). */ void iwl_txq_enable_fifo(int q, unsigned int fifo); 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