/* Packet size info */ #define XAE_HDR_SIZE 14 /* Size of Ethernet header */ #define XAE_TRL_SIZE 4 /* Size of Ethernet trailer (FCS) */ #define XAE_MTU 1500 /* Max MTU of an Ethernet frame */ #define XAE_JUMBO_MTU 9000 /* Max MTU of a jumbo Eth. frame */
/* Enable recognition of flow control frames on Rx. Default: enabled (set) */ #define XAE_OPTION_FLOW_CONTROL BIT(4)
/* Strip FCS and PAD from incoming frames. Note: PAD from VLAN frames is not * stripped. Default: disabled (set)
*/ #define XAE_OPTION_FCS_STRIP BIT(5)
/* Generate FCS field and add PAD automatically for outgoing frames. * Default: enabled (set)
*/ #define XAE_OPTION_FCS_INSERT BIT(6)
/* Enable Length/Type error checking for incoming frames. When this option is * set, the MAC will filter frames that have a mismatched type/length field * and if XAE_OPTION_REPORT_RXERR is set, the user is notified when these * types of frames are encountered. When this option is cleared, the MAC will * allow these types of frames to be received. Default: enabled (set)
*/ #define XAE_OPTION_LENTYPE_ERR BIT(7)
#define XAXIDMA_BD_NDESC_OFFSET 0x00 /* Next descriptor pointer */ #define XAXIDMA_BD_BUFA_OFFSET 0x08 /* Buffer address */ #define XAXIDMA_BD_CTRL_LEN_OFFSET 0x18 /* Control/buffer length */ #define XAXIDMA_BD_STS_OFFSET 0x1C /* Status */ #define XAXIDMA_BD_USR0_OFFSET 0x20 /* User IP specific word0 */ #define XAXIDMA_BD_USR1_OFFSET 0x24 /* User IP specific word1 */ #define XAXIDMA_BD_USR2_OFFSET 0x28 /* User IP specific word2 */ #define XAXIDMA_BD_USR3_OFFSET 0x2C /* User IP specific word3 */ #define XAXIDMA_BD_USR4_OFFSET 0x30 /* User IP specific word4 */ #define XAXIDMA_BD_ID_OFFSET 0x34 /* Sw ID */ #define XAXIDMA_BD_HAS_STSCNTRL_OFFSET 0x38 /* Whether has stscntrl strm */ #define XAXIDMA_BD_HAS_DRE_OFFSET 0x3C /* Whether has DRE */
#define XAXIDMA_BD_HAS_DRE_SHIFT 8 /* Whether has DRE shift */ #define XAXIDMA_BD_HAS_DRE_MASK 0xF00 /* Whether has DRE mask */ #define XAXIDMA_BD_WORDLEN_MASK 0xFF /* Whether has DRE mask */
#define XAXIDMA_BD_CTRL_LENGTH_MASK 0x007FFFFF /* Requested len */ #define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */ #define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */ #define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */
/* Bit Masks for Axi Ethernet TPF and IFGP registers */ #define XAE_TPF_TPFV_MASK 0x0000FFFF /* Tx pause frame value */ /* Transmit inter-frame gap adjustment value */ #define XAE_IFGP0_IFGP_MASK 0x0000007F
/* Bit Masks for Axi Ethernet IS, IE and IP registers, Same masks apply * for all 3 registers.
*/ /* Hard register access complete */ #define XAE_INT_HARDACSCMPLT_MASK 0x00000001 /* Auto negotiation complete */ #define XAE_INT_AUTONEG_MASK 0x00000002 #define XAE_INT_RXCMPIT_MASK 0x00000004 /* Rx complete */ #define XAE_INT_RXRJECT_MASK 0x00000008 /* Rx frame rejected */ #define XAE_INT_RXFIFOOVR_MASK 0x00000010 /* Rx fifo overrun */ #define XAE_INT_TXCMPIT_MASK 0x00000020 /* Tx complete */ #define XAE_INT_RXDCMLOCK_MASK 0x00000040 /* Rx Dcm Lock */ #define XAE_INT_MGTRDY_MASK 0x00000080 /* MGT clock Lock */ #define XAE_INT_PHYRSTCMPLT_MASK 0x00000100 /* Phy Reset complete */ #define XAE_INT_ALL_MASK 0x0000003F /* All the ints */
/* INT bits that indicate receive errors */ #define XAE_INT_RECV_ERROR_MASK \
(XAE_INT_RXRJECT_MASK | XAE_INT_RXFIFOOVR_MASK)
/* Bit masks for Axi Ethernet VLAN TPID Word 0 register */ #define XAE_TPID_0_MASK 0x0000FFFF /* TPID 0 */ #define XAE_TPID_1_MASK 0xFFFF0000 /* TPID 1 */
/* Bit masks for Axi Ethernet VLAN TPID Word 1 register */ #define XAE_TPID_2_MASK 0x0000FFFF /* TPID 0 */ #define XAE_TPID_3_MASK 0xFFFF0000 /* TPID 1 */
/* Bit masks for Axi Ethernet MDIO interface MIS, MIP, MIE, MIC registers */ #define XAE_MDIO_INT_MIIM_RDY_MASK 0x00000001 /* MIIM Interrupt */
/* Bit masks for Axi Ethernet UAW1 register */ /* Station address bits [47:32]; Station address * bits [31:0] are stored in register UAW0
*/ #define XAE_UAW1_UNICASTADDR_MASK 0x0000FFFF
/* Bit masks for Axi Ethernet FMC register */ #define XAE_FMI_PM_MASK 0x80000000 /* Promis. mode enable */ #define XAE_FMI_IND_MASK 0x00000003 /* Index Mask */
/* Xilinx PCS/PMA PHY register for switching 1000BaseX or SGMII */ #define XLNX_MII_STD_SELECT_REG 0x11 #define XLNX_MII_STD_SELECT_SGMII BIT(0)
/* enum temac_stat - TEMAC statistics counters * * Index of statistics counters within the TEMAC. This must match the * order/offset of hardware registers exactly.
*/ enum temac_stat {
STAT_RX_BYTES = 0,
STAT_TX_BYTES,
STAT_UNDERSIZE_FRAMES,
STAT_FRAGMENT_FRAMES,
STAT_RX_64_BYTE_FRAMES,
STAT_RX_65_127_BYTE_FRAMES,
STAT_RX_128_255_BYTE_FRAMES,
STAT_RX_256_511_BYTE_FRAMES,
STAT_RX_512_1023_BYTE_FRAMES,
STAT_RX_1024_MAX_BYTE_FRAMES,
STAT_RX_OVERSIZE_FRAMES,
STAT_TX_64_BYTE_FRAMES,
STAT_TX_65_127_BYTE_FRAMES,
STAT_TX_128_255_BYTE_FRAMES,
STAT_TX_256_511_BYTE_FRAMES,
STAT_TX_512_1023_BYTE_FRAMES,
STAT_TX_1024_MAX_BYTE_FRAMES,
STAT_TX_OVERSIZE_FRAMES,
STAT_RX_GOOD_FRAMES,
STAT_RX_FCS_ERRORS,
STAT_RX_BROADCAST_FRAMES,
STAT_RX_MULTICAST_FRAMES,
STAT_RX_CONTROL_FRAMES,
STAT_RX_LENGTH_ERRORS,
STAT_RX_VLAN_FRAMES,
STAT_RX_PAUSE_FRAMES,
STAT_RX_CONTROL_OPCODE_ERRORS,
STAT_TX_GOOD_FRAMES,
STAT_TX_BROADCAST_FRAMES,
STAT_TX_MULTICAST_FRAMES,
STAT_TX_UNDERRUN_ERRORS,
STAT_TX_CONTROL_FRAMES,
STAT_TX_VLAN_FRAMES,
STAT_TX_PAUSE_FRAMES,
STAT_TX_SINGLE_COLLISION_FRAMES,
STAT_TX_MULTIPLE_COLLISION_FRAMES,
STAT_TX_DEFERRED_FRAMES,
STAT_TX_LATE_COLLISIONS,
STAT_TX_EXCESS_COLLISIONS,
STAT_TX_EXCESS_DEFERRAL,
STAT_RX_ALIGNMENT_ERRORS,
STAT_TX_PFC_FRAMES,
STAT_RX_PFC_FRAMES,
STAT_USER_DEFINED0,
STAT_USER_DEFINED1,
STAT_USER_DEFINED2,
STAT_COUNT,
};
/** * struct axidma_bd - Axi Dma buffer descriptor layout * @next: MM2S/S2MM Next Descriptor Pointer * @next_msb: MM2S/S2MM Next Descriptor Pointer (high 32 bits) * @phys: MM2S/S2MM Buffer Address * @phys_msb: MM2S/S2MM Buffer Address (high 32 bits) * @reserved3: Reserved and not used * @reserved4: Reserved and not used * @cntrl: MM2S/S2MM Control value * @status: MM2S/S2MM Status value * @app0: MM2S/S2MM User Application Field 0. * @app1: MM2S/S2MM User Application Field 1. * @app2: MM2S/S2MM User Application Field 2. * @app3: MM2S/S2MM User Application Field 3. * @app4: MM2S/S2MM User Application Field 4. * @skb: Pointer to SKB transferred using DMA
*/ struct axidma_bd {
u32 next; /* Physical address of next buffer descriptor */
u32 next_msb; /* high 32 bits for IP >= v7.1, reserved on older IP */
u32 phys;
u32 phys_msb; /* for IP >= v7.1, reserved for older IP */
u32 reserved3;
u32 reserved4;
u32 cntrl;
u32 status;
u32 app0;
u32 app1; /* TX start << 16 | insert */
u32 app2; /* TX csum seed */
u32 app3;
u32 app4; /* Last field used by HW */ struct sk_buff *skb;
} __aligned(XAXIDMA_BD_MINIMUM_ALIGNMENT);
#define XAE_NUM_MISC_CLOCKS 3
/** * struct skbuf_dma_descriptor - skb for each dma descriptor * @sgl: Pointer for sglist. * @desc: Pointer to dma descriptor. * @dma_address: dma address of sglist. * @skb: Pointer to SKB transferred using DMA * @sg_len: number of entries in the sglist.
*/ struct skbuf_dma_descriptor { struct scatterlist sgl[MAX_SKB_FRAGS + 1]; struct dma_async_tx_descriptor *desc;
dma_addr_t dma_address; struct sk_buff *skb; int sg_len;
};
/** * struct axienet_local - axienet private per device data * @ndev: Pointer for net_device to which it will be attached. * @dev: Pointer to device structure * @phylink: Pointer to phylink instance * @phylink_config: phylink configuration settings * @pcs_phy: Reference to PCS/PMA PHY if used * @pcs: phylink pcs structure for PCS PHY * @switch_x_sgmii: Whether switchable 1000BaseX/SGMII mode is enabled in the core * @axi_clk: AXI4-Lite bus clock * @misc_clks: Misc ethernet clocks (AXI4-Stream, Ref, MGT clocks) * @mii_bus: Pointer to MII bus structure * @mii_clk_div: MII bus clock divider value * @regs_start: Resource start for axienet device addresses * @regs: Base address for the axienet_local device address space * @dma_regs: Base address for the axidma device address space * @napi_rx: NAPI RX control structure * @rx_dim: DIM state for the receive queue * @rx_dim_enabled: Whether DIM is enabled or not * @rx_irqs: Number of interrupts * @rx_cr_lock: Lock protecting @rx_dma_cr, its register, and @rx_dma_started * @rx_dma_cr: Nominal content of RX DMA control register * @rx_dma_started: Set when RX DMA is started * @rx_bd_v: Virtual address of the RX buffer descriptor ring * @rx_bd_p: Physical address(start address) of the RX buffer descr. ring * @rx_bd_num: Size of RX buffer descriptor ring * @rx_bd_ci: Stores the index of the Rx buffer descriptor in the ring being * accessed currently. * @rx_packets: RX packet count for statistics * @rx_bytes: RX byte count for statistics * @rx_stat_sync: Synchronization object for RX stats * @napi_tx: NAPI TX control structure * @tx_cr_lock: Lock protecting @tx_dma_cr, its register, and @tx_dma_started * @tx_dma_cr: Nominal content of TX DMA control register * @tx_dma_started: Set when TX DMA is started * @tx_bd_v: Virtual address of the TX buffer descriptor ring * @tx_bd_p: Physical address(start address) of the TX buffer descr. ring * @tx_bd_num: Size of TX buffer descriptor ring * @tx_bd_ci: Stores the next Tx buffer descriptor in the ring that may be * complete. Only updated at runtime by TX NAPI poll. * @tx_bd_tail: Stores the index of the next Tx buffer descriptor in the ring * to be populated. * @tx_packets: TX packet count for statistics * @tx_bytes: TX byte count for statistics * @tx_stat_sync: Synchronization object for TX stats * @hw_stat_base: Base offset for statistics counters. This may be nonzero if * the statistics counteres were reset or wrapped around. * @hw_last_counter: Last-seen value of each statistic counter * @reset_in_progress: Set while we are performing a reset and statistics * counters may be invalid * @hw_stats_seqcount: Sequence counter for @hw_stat_base, @hw_last_counter, * and @reset_in_progress. * @stats_lock: Lock for @hw_stats_seqcount * @stats_work: Work for reading the hardware statistics counters often enough * to catch overflows. * @dma_err_task: Work structure to process Axi DMA errors * @stopping: Set when @dma_err_task shouldn't do anything because we are * about to stop the device. * @tx_irq: Axidma TX IRQ number * @rx_irq: Axidma RX IRQ number * @eth_irq: Ethernet core IRQ number * @phy_mode: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X * @options: AxiEthernet option word * @features: Stores the extended features supported by the axienet hw * @max_frm_size: Stores the maximum size of the frame that can be that * Txed/Rxed in the existing hardware. If jumbo option is * supported, the maximum frame size would be 9k. Else it is * 1522 bytes (assuming support for basic VLAN) * @rxmem: Stores rx memory size for jumbo frame handling. * @use_dmaengine: flag to check dmaengine framework usage. * @tx_chan: TX DMA channel. * @rx_chan: RX DMA channel. * @tx_skb_ring: Pointer to TX skb ring buffer array. * @rx_skb_ring: Pointer to RX skb ring buffer array. * @tx_ring_head: TX skb ring buffer head index. * @tx_ring_tail: TX skb ring buffer tail index. * @rx_ring_head: RX skb ring buffer head index. * @rx_ring_tail: RX skb ring buffer tail index.
*/ struct axienet_local { struct net_device *ndev; struct device *dev;
int tx_irq; int rx_irq; int eth_irq;
phy_interface_t phy_mode;
u32 options;
u32 features;
u32 max_frm_size;
u32 rxmem;
u8 use_dmaengine; struct dma_chan *tx_chan; struct dma_chan *rx_chan; struct skbuf_dma_descriptor **tx_skb_ring; struct skbuf_dma_descriptor **rx_skb_ring; int tx_ring_head; int tx_ring_tail; int rx_ring_head; int rx_ring_tail;
};
/** * struct axienet_option - Used to set axi ethernet hardware options * @opt: Option to be set. * @reg: Register offset to be written for setting the option * @m_or: Mask to be ORed for setting the option in the register
*/ struct axienet_option {
u32 opt;
u32 reg;
u32 m_or;
};
/** * axienet_ior - Memory mapped Axi Ethernet register read * @lp: Pointer to axienet local structure * @offset: Address offset from the base address of Axi Ethernet core * * Return: The contents of the Axi Ethernet register * * This function returns the contents of the corresponding register.
*/ staticinline u32 axienet_ior(struct axienet_local *lp, off_t offset)
{ return ioread32(lp->regs + offset);
}
staticinlinevoid axienet_lock_mii(struct axienet_local *lp)
{ if (lp->mii_bus)
mutex_lock(&lp->mii_bus->mdio_lock);
}
staticinlinevoid axienet_unlock_mii(struct axienet_local *lp)
{ if (lp->mii_bus)
mutex_unlock(&lp->mii_bus->mdio_lock);
}
/** * axienet_iow - Memory mapped Axi Ethernet register write * @lp: Pointer to axienet local structure * @offset: Address offset from the base address of Axi Ethernet core * @value: Value to be written into the Axi Ethernet register * * This function writes the desired value into the corresponding Axi Ethernet * register.
*/ staticinlinevoid axienet_iow(struct axienet_local *lp, off_t offset,
u32 value)
{
iowrite32(value, lp->regs + offset);
}
/** * axienet_dma_out32 - Memory mapped Axi DMA register write. * @lp: Pointer to axienet local structure * @reg: Address offset from the base address of the Axi DMA core * @value: Value to be written into the Axi DMA register * * This function writes the desired value into the corresponding Axi DMA * register.
*/
#ifdefined(CONFIG_64BIT) && defined(iowrite64) /** * axienet_dma_out64 - Memory mapped Axi DMA register write. * @lp: Pointer to axienet local structure * @reg: Address offset from the base address of the Axi DMA core * @value: Value to be written into the Axi DMA register * * This function writes the desired value into the corresponding Axi DMA * register.
*/ staticinlinevoid axienet_dma_out64(struct axienet_local *lp,
off_t reg, u64 value)
{
iowrite64(value, lp->dma_regs + reg);
}
/* Function prototypes visible in xilinx_axienet_mdio.c for other files */ int axienet_mdio_setup(struct axienet_local *lp); void axienet_mdio_teardown(struct axienet_local *lp);
#endif/* XILINX_AXI_ENET_H */
Messung V0.5
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet)
¤
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.