/* SPDX-License-Identifier: GPL-2.0+ */ /* FDDI network adapter driver for DEC FDDIcontroller 700/700-C devices. * * Copyright (c) 2018 Maciej W. Rozycki * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * * References: * * Dave Sawyer & Phil Weeks & Frank Itkowsky, * "DEC FDDIcontroller 700 Port Specification", * Revision 1.1, Digital Equipment Corporation
*/
/* Reset register constants. Bits 1:0 are r/w, others are fixed at 0. */ #define FZA_RESET_DLU 0x0002 /* OR with INIT to blast flash memory */ #define FZA_RESET_INIT 0x0001 /* switch into the reset state */ #define FZA_RESET_CLR 0x0000 /* run self-test and return to work */
/* Which interrupts to receive: 0/1 is mask/unmask. */ #define FZA_MASK_NONE 0x0000 #define FZA_MASK_NORMAL \
((~(FZA_MASK_RESERVED | FZA_MASK_DLU_DONE | \
FZA_MASK_PM_PARITY_ERR | FZA_MASK_HB_PARITY_ERR | \
FZA_MASK_NXM_ERR)) & 0xffff)
/* Control A register constants. */ #define FZA_CONTROL_A_HB_PARITY_ERR 0x8000 /* host bus parity error */ #define FZA_CONTROL_A_NXM_ERR 0x4000 /* adapter non-existent memory * reference
*/ #define FZA_CONTROL_A_SMT_RX_OVFL 0x0040 /* SMT receive overflow */ #define FZA_CONTROL_A_FLUSH_DONE 0x0020 /* flush tx request complete */ #define FZA_CONTROL_A_SHUT 0x0010 /* turn the interface off */ #define FZA_CONTROL_A_HALT 0x0008 /* halt the controller */ #define FZA_CONTROL_A_CMD_POLL 0x0004 /* command ring poll */ #define FZA_CONTROL_A_SMT_RX_POLL 0x0002 /* SMT receive ring poll */ #define FZA_CONTROL_A_TX_POLL 0x0001 /* transmit poll */
/* Control B register constants. All bits are r/w. * * Possible values: * 0x0000 after booting into REX, * 0x0003 after issuing `boot #/mop'.
*/ #define FZA_CONTROL_B_CONSOLE 0x0002 /* OR with DRIVER for console * (TC firmware) mode
*/ #define FZA_CONTROL_B_DRIVER 0x0001 /* driver mode */ #define FZA_CONTROL_B_IDLE 0x0000 /* no driver installed */
/* Layout of registers. */ struct fza_regs {
u8 pad0[FZA_RESET_PAD];
u16 reset; /* reset register */
u8 pad1[FZA_INT_EVENT_PAD];
u16 int_event; /* interrupt event register */
u16 status; /* status register */
u16 int_mask; /* interrupt mask register */
u8 pad2[FZA_CONTROL_A_PAD];
u16 control_a; /* control A register */
u16 control_b; /* control B register */
};
/* Command descriptor ring entry. */ struct fza_ring_cmd {
u32 cmd_own; /* bit 31: ownership, bits [30:0]: command */
u32 stat; /* command status */
u32 buffer; /* address of the buffer in the FZA space */
u32 pad0;
};
#define FZA_RING_CMD 0x200400 /* command ring address */ #define FZA_RING_CMD_SIZE 0x40 /* command descriptor ring * size
*/ /* Command constants. */ #define FZA_RING_CMD_MASK 0x7fffffff #define FZA_RING_CMD_NOP 0x00000000 /* nop */ #define FZA_RING_CMD_INIT 0x00000001 /* initialize */ #define FZA_RING_CMD_MODCAM 0x00000002 /* modify CAM */ #define FZA_RING_CMD_PARAM 0x00000003 /* set system parameters */ #define FZA_RING_CMD_MODPROM 0x00000004 /* modify promiscuous mode */ #define FZA_RING_CMD_SETCHAR 0x00000005 /* set link characteristics */ #define FZA_RING_CMD_RDCNTR 0x00000006 /* read counters */ #define FZA_RING_CMD_STATUS 0x00000007 /* get link status */ #define FZA_RING_CMD_RDCAM 0x00000008 /* read CAM */
/* Command status constants. */ #define FZA_RING_STAT_SUCCESS 0x00000000
/* Unsolicited event descriptor ring entry. */ struct fza_ring_uns {
u32 own; /* bit 31: ownership, bits [30:0]: reserved */
u32 id; /* event ID */
u32 buffer; /* address of the buffer in the FZA space */
u32 pad0; /* reserved */
};
#define FZA_RING_UNS 0x200800 /* unsolicited ring address */ #define FZA_RING_UNS_SIZE 0x40 /* unsolicited descriptor ring * size
*/ /* Unsolicited event constants. */ #define FZA_RING_UNS_UND 0x00000000 /* undefined event ID */ #define FZA_RING_UNS_INIT_IN 0x00000001 /* ring init initiated */ #define FZA_RING_UNS_INIT_RX 0x00000002 /* ring init received */ #define FZA_RING_UNS_BEAC_IN 0x00000003 /* ring beaconing initiated */ #define FZA_RING_UNS_DUP_ADDR 0x00000004 /* duplicate address detected */ #define FZA_RING_UNS_DUP_TOK 0x00000005 /* duplicate token detected */ #define FZA_RING_UNS_PURG_ERR 0x00000006 /* ring purger error */ #define FZA_RING_UNS_STRIP_ERR 0x00000007 /* bridge strip error */ #define FZA_RING_UNS_OP_OSC 0x00000008 /* ring op oscillation */ #define FZA_RING_UNS_BEAC_RX 0x00000009 /* directed beacon received */ #define FZA_RING_UNS_PCT_IN 0x0000000a /* PC trace initiated */ #define FZA_RING_UNS_PCT_RX 0x0000000b /* PC trace received */ #define FZA_RING_UNS_TX_UNDER 0x0000000c /* transmit underrun */ #define FZA_RING_UNS_TX_FAIL 0x0000000d /* transmit failure */ #define FZA_RING_UNS_RX_OVER 0x0000000e /* receive overrun */
/* RMC (Ring Memory Control) transmit descriptor ring entry. */ struct fza_ring_rmc_tx {
u32 rmc; /* RMC information */
u32 avl; /* available for host (unused by RMC) */
u32 own; /* bit 31: ownership, bits [30:0]: reserved */
u32 pad0; /* reserved */
};
/* INIT command buffer. * * Values of default link parameters given are as obtained from a * DEFZA-AA rev. C03 board. The board counts time in units of 80ns.
*/ struct fza_cmd_init {
u32 tx_mode; /* transmit mode */
u32 hst_rx_size; /* host receive ring entries */
u32 hst_rx; /* base of host rx descriptor ring */
u32 rmc_tx; /* base of RMC tx descriptor ring */
u32 rmc_tx_size; /* size of RMC tx descriptor ring */
u32 smt_tx; /* base of SMT tx descriptor ring */
u32 smt_tx_size; /* size of SMT tx descriptor ring */
u32 smt_rx; /* base of SMT rx descriptor ring */
u32 smt_rx_size; /* size of SMT rx descriptor ring */
/* Packet request header byte #0. */ #define FZA_PRH0_FMT_TYPE_MASK 0xc0 /* type of packet, always zero */ #define FZA_PRH0_TOK_TYPE_MASK 0x30 /* type of token required * to send this frame
*/ #define FZA_PRH0_TKN_TYPE_ANY 0x30 /* use either token type */ #define FZA_PRH0_TKN_TYPE_UNR 0x20 /* use an unrestricted token */ #define FZA_PRH0_TKN_TYPE_RST 0x10 /* use a restricted token */ #define FZA_PRH0_TKN_TYPE_IMM 0x00 /* send immediately, no token required
*/ #define FZA_PRH0_FRAME_MASK 0x08 /* type of frame to send */ #define FZA_PRH0_FRAME_SYNC 0x08 /* send a synchronous frame */ #define FZA_PRH0_FRAME_ASYNC 0x00 /* send an asynchronous frame */ #define FZA_PRH0_MODE_MASK 0x04 /* send mode */ #define FZA_PRH0_MODE_IMMED 0x04 /* an immediate mode, send regardless * of the ring operational state
*/ #define FZA_PRH0_MODE_NORMAL 0x00 /* a normal mode, send only if ring * operational
*/ #define FZA_PRH0_SF_MASK 0x02 /* send frame first */ #define FZA_PRH0_SF_FIRST 0x02 /* send this frame first * with this token capture
*/ #define FZA_PRH0_SF_NORMAL 0x00 /* treat this frame normally */ #define FZA_PRH0_BCN_MASK 0x01 /* beacon frame */ #define FZA_PRH0_BCN_BEACON 0x01 /* send the frame only * if in the beacon state
*/ #define FZA_PRH0_BCN_DATA 0x01 /* send the frame only * if in the data state
*/ /* Packet request header byte #1. */ /* bit 7 always zero */ #define FZA_PRH1_SL_MASK 0x40 /* send frame last */ #define FZA_PRH1_SL_LAST 0x40 /* send this frame last, releasing * the token afterwards
*/ #define FZA_PRH1_SL_NORMAL 0x00 /* treat this frame normally */ #define FZA_PRH1_CRC_MASK 0x20 /* CRC append */ #define FZA_PRH1_CRC_NORMAL 0x20 /* calculate the CRC and append it * as the FCS field to the frame
*/ #define FZA_PRH1_CRC_SKIP 0x00 /* leave the frame as is */ #define FZA_PRH1_TKN_SEND_MASK 0x18 /* type of token to send after the * frame if this is the last frame
*/ #define FZA_PRH1_TKN_SEND_ORIG 0x18 /* send a token of the same type as the * originally captured one
*/ #define FZA_PRH1_TKN_SEND_RST 0x10 /* send a restricted token */ #define FZA_PRH1_TKN_SEND_UNR 0x08 /* send an unrestricted token */ #define FZA_PRH1_TKN_SEND_NONE 0x00 /* send no token */ #define FZA_PRH1_EXTRA_FS_MASK 0x07 /* send extra frame status indicators
*/ #define FZA_PRH1_EXTRA_FS_ST 0x07 /* TR RR ST II */ #define FZA_PRH1_EXTRA_FS_SS 0x06 /* TR RR SS II */ #define FZA_PRH1_EXTRA_FS_SR 0x05 /* TR RR SR II */ #define FZA_PRH1_EXTRA_FS_NONE1 0x04 /* TR RR II II */ #define FZA_PRH1_EXTRA_FS_RT 0x03 /* TR RR RT II */ #define FZA_PRH1_EXTRA_FS_RS 0x02 /* TR RR RS II */ #define FZA_PRH1_EXTRA_FS_RR 0x01 /* TR RR RR II */ #define FZA_PRH1_EXTRA_FS_NONE 0x00 /* TR RR II II */ /* Packet request header byte #2. */ #define FZA_PRH2_NORMAL 0x00 /* always zero */
/* PRH used for LLC frames. */ #define FZA_PRH0_LLC (FZA_PRH0_TKN_TYPE_UNR) #define FZA_PRH1_LLC (FZA_PRH1_CRC_NORMAL | FZA_PRH1_TKN_SEND_UNR) #define FZA_PRH2_LLC (FZA_PRH2_NORMAL)
/* PRH used for SMT frames. */ #define FZA_PRH0_SMT (FZA_PRH0_TKN_TYPE_UNR) #define FZA_PRH1_SMT (FZA_PRH1_CRC_NORMAL | FZA_PRH1_TKN_SEND_UNR) #define FZA_PRH2_SMT (FZA_PRH2_NORMAL)
#if ((FZA_RING_RX_SIZE) < 2) || ((FZA_RING_RX_SIZE) > 256) # error FZA_RING_RX_SIZE has to be from 2 up to 256 #endif #if ((FZA_RING_TX_MODE) != 0) && ((FZA_RING_TX_MODE) != 1) # error FZA_RING_TX_MODE has to be either 0 or 1 #endif
struct fza_private { struct device *bdev; /* pointer to the bus device */ constchar *name; /* printable device name */ void __iomem *mmio; /* MMIO ioremap cookie */ struct fza_regs __iomem *regs; /* pointer to FZA registers */
struct sk_buff *rx_skbuff[FZA_RING_RX_SIZE]; /* all skbs assigned to the host * receive descriptors
*/
dma_addr_t rx_dma[FZA_RING_RX_SIZE]; /* their corresponding DMA addresses */
struct fza_ring_cmd __iomem *ring_cmd; /* pointer to the command descriptor * ring
*/ int ring_cmd_index; /* index to the command descriptor ring * for the next command
*/ struct fza_ring_uns __iomem *ring_uns; /* pointer to the unsolicited * descriptor ring
*/ int ring_uns_index; /* index to the unsolicited descriptor * ring for the next event
*/
struct fza_ring_rmc_tx __iomem *ring_rmc_tx; /* pointer to the RMC transmit * descriptor ring (obtained from the * INIT command)
*/ int ring_rmc_tx_size; /* number of entries in the RMC * transmit descriptor ring (obtained * from the INIT command)
*/ int ring_rmc_tx_index; /* index to the RMC transmit descriptor * ring for the next transmission
*/ int ring_rmc_txd_index; /* index to the RMC transmit descriptor * ring for the next transmit done * acknowledge
*/
struct fza_ring_hst_rx __iomem *ring_hst_rx; /* pointer to the host receive * descriptor ring (obtained from the * INIT command)
*/ int ring_hst_rx_size; /* number of entries in the host * receive descriptor ring (set by the * INIT command)
*/ int ring_hst_rx_index; /* index to the host receive descriptor * ring for the next transmission
*/
struct fza_ring_smt __iomem *ring_smt_tx; /* pointer to the SMT transmit * descriptor ring (obtained from the * INIT command)
*/ int ring_smt_tx_size; /* number of entries in the SMT * transmit descriptor ring (obtained * from the INIT command)
*/ int ring_smt_tx_index; /* index to the SMT transmit descriptor * ring for the next transmission
*/
struct fza_ring_smt __iomem *ring_smt_rx; /* pointer to the SMT transmit * descriptor ring (obtained from the * INIT command)
*/ int ring_smt_rx_size; /* number of entries in the SMT * receive descriptor ring (obtained * from the INIT command)
*/ int ring_smt_rx_index; /* index to the SMT receive descriptor * ring for the next transmission
*/
struct fza_buffer_tx __iomem *buffer_tx; /* pointer to the RMC transmit buffers
*/
uint state; /* adapter expected state */
spinlock_t lock; /* for device & private data access */
uint int_mask; /* interrupt source selector */
int cmd_done_flag; /* command completion trigger */
wait_queue_head_t cmd_done_wait;
int state_chg_flag; /* state change trigger */
wait_queue_head_t state_chg_wait;
struct timer_list reset_timer; /* RESET time-out trigger */ int timer_state; /* RESET trigger state */
int queue_active; /* whether to enable queueing */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.