18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* drivers/atm/zatm.h - ZeitNet ZN122x device driver declarations */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci/* Written 1995-1998 by Werner Almesberger, EPFL LRC/ICA */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef DRIVER_ATM_ZATM_H 88c2ecf20Sopenharmony_ci#define DRIVER_ATM_ZATM_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/skbuff.h> 118c2ecf20Sopenharmony_ci#include <linux/atm.h> 128c2ecf20Sopenharmony_ci#include <linux/atmdev.h> 138c2ecf20Sopenharmony_ci#include <linux/sonet.h> 148c2ecf20Sopenharmony_ci#include <linux/pci.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define DEV_LABEL "zatm" 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define MAX_AAL5_PDU 10240 /* allocate for AAL5 PDUs of this size */ 208c2ecf20Sopenharmony_ci#define MAX_RX_SIZE_LD 14 /* ceil(log2((MAX_AAL5_PDU+47)/48)) */ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define LOW_MARK 12 /* start adding new buffers if less than 12 */ 238c2ecf20Sopenharmony_ci#define HIGH_MARK 30 /* stop adding buffers after reaching 30 */ 248c2ecf20Sopenharmony_ci#define OFF_CNG_THRES 5 /* threshold for offset changes */ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define RX_SIZE 2 /* RX lookup entry size (in bytes) */ 278c2ecf20Sopenharmony_ci#define NR_POOLS 32 /* number of free buffer pointers */ 288c2ecf20Sopenharmony_ci#define POOL_SIZE 8 /* buffer entry size (in bytes) */ 298c2ecf20Sopenharmony_ci#define NR_SHAPERS 16 /* number of shapers */ 308c2ecf20Sopenharmony_ci#define SHAPER_SIZE 4 /* shaper entry size (in bytes) */ 318c2ecf20Sopenharmony_ci#define VC_SIZE 32 /* VC dsc (TX or RX) size (in bytes) */ 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define RING_ENTRIES 32 /* ring entries (without back pointer) */ 348c2ecf20Sopenharmony_ci#define RING_WORDS 4 /* ring element size */ 358c2ecf20Sopenharmony_ci#define RING_SIZE (sizeof(unsigned long)*(RING_ENTRIES+1)*RING_WORDS) 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define NR_MBX 4 /* four mailboxes */ 388c2ecf20Sopenharmony_ci#define MBX_RX_0 0 /* mailbox indices */ 398c2ecf20Sopenharmony_ci#define MBX_RX_1 1 408c2ecf20Sopenharmony_ci#define MBX_TX_0 2 418c2ecf20Sopenharmony_ci#define MBX_TX_1 3 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistruct zatm_vcc { 448c2ecf20Sopenharmony_ci /*-------------------------------- RX part */ 458c2ecf20Sopenharmony_ci int rx_chan; /* RX channel, 0 if none */ 468c2ecf20Sopenharmony_ci int pool; /* free buffer pool */ 478c2ecf20Sopenharmony_ci /*-------------------------------- TX part */ 488c2ecf20Sopenharmony_ci int tx_chan; /* TX channel, 0 if none */ 498c2ecf20Sopenharmony_ci int shaper; /* shaper, <0 if none */ 508c2ecf20Sopenharmony_ci struct sk_buff_head tx_queue; /* list of buffers in transit */ 518c2ecf20Sopenharmony_ci wait_queue_head_t tx_wait; /* for close */ 528c2ecf20Sopenharmony_ci u32 *ring; /* transmit ring */ 538c2ecf20Sopenharmony_ci int ring_curr; /* current write position */ 548c2ecf20Sopenharmony_ci int txing; /* number of transmits in progress */ 558c2ecf20Sopenharmony_ci struct sk_buff_head backlog; /* list of buffers waiting for ring */ 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistruct zatm_dev { 598c2ecf20Sopenharmony_ci /*-------------------------------- TX part */ 608c2ecf20Sopenharmony_ci int tx_bw; /* remaining bandwidth */ 618c2ecf20Sopenharmony_ci u32 free_shapers; /* bit set */ 628c2ecf20Sopenharmony_ci int ubr; /* UBR shaper; -1 if none */ 638c2ecf20Sopenharmony_ci int ubr_ref_cnt; /* number of VCs using UBR shaper */ 648c2ecf20Sopenharmony_ci /*-------------------------------- RX part */ 658c2ecf20Sopenharmony_ci int pool_ref[NR_POOLS]; /* free buffer pool usage counters */ 668c2ecf20Sopenharmony_ci volatile struct sk_buff *last_free[NR_POOLS]; 678c2ecf20Sopenharmony_ci /* last entry in respective pool */ 688c2ecf20Sopenharmony_ci struct sk_buff_head pool[NR_POOLS];/* free buffer pools */ 698c2ecf20Sopenharmony_ci struct zatm_pool_info pool_info[NR_POOLS]; /* pool information */ 708c2ecf20Sopenharmony_ci /*-------------------------------- maps */ 718c2ecf20Sopenharmony_ci struct atm_vcc **tx_map; /* TX VCCs */ 728c2ecf20Sopenharmony_ci struct atm_vcc **rx_map; /* RX VCCs */ 738c2ecf20Sopenharmony_ci int chans; /* map size, must be 2^n */ 748c2ecf20Sopenharmony_ci /*-------------------------------- mailboxes */ 758c2ecf20Sopenharmony_ci unsigned long mbx_start[NR_MBX];/* start addresses */ 768c2ecf20Sopenharmony_ci dma_addr_t mbx_dma[NR_MBX]; 778c2ecf20Sopenharmony_ci u16 mbx_end[NR_MBX]; /* end offset (in bytes) */ 788c2ecf20Sopenharmony_ci /*-------------------------------- other pointers */ 798c2ecf20Sopenharmony_ci u32 pool_base; /* Free buffer pool dsc (word addr) */ 808c2ecf20Sopenharmony_ci /*-------------------------------- ZATM links */ 818c2ecf20Sopenharmony_ci struct atm_dev *more; /* other ZATM devices */ 828c2ecf20Sopenharmony_ci /*-------------------------------- general information */ 838c2ecf20Sopenharmony_ci int mem; /* RAM on board (in bytes) */ 848c2ecf20Sopenharmony_ci int khz; /* timer clock */ 858c2ecf20Sopenharmony_ci int copper; /* PHY type */ 868c2ecf20Sopenharmony_ci unsigned char irq; /* IRQ */ 878c2ecf20Sopenharmony_ci unsigned int base; /* IO base address */ 888c2ecf20Sopenharmony_ci struct pci_dev *pci_dev; /* PCI stuff */ 898c2ecf20Sopenharmony_ci spinlock_t lock; 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#define ZATM_DEV(d) ((struct zatm_dev *) (d)->dev_data) 948c2ecf20Sopenharmony_ci#define ZATM_VCC(d) ((struct zatm_vcc *) (d)->dev_data) 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistruct zatm_skb_prv { 988c2ecf20Sopenharmony_ci struct atm_skb_data _; /* reserved */ 998c2ecf20Sopenharmony_ci u32 *dsc; /* pointer to skb's descriptor */ 1008c2ecf20Sopenharmony_ci}; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define ZATM_PRV_DSC(skb) (((struct zatm_skb_prv *) (skb)->cb)->dsc) 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#endif 105