123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- #ifndef _INTEL_H
- #define _INTEL_H
-
-
-
- FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
-
- #include <stdint.h>
- #include <ipxe/if_ether.h>
- #include <ipxe/nvs.h>
-
-
- #define INTEL_BAR_SIZE ( 128 * 1024 )
-
-
- struct intel_descriptor {
-
- uint64_t address;
-
- uint16_t length;
-
- uint8_t reserved_a;
-
- uint8_t command;
-
- uint8_t status;
-
- uint8_t errors;
-
- uint16_t reserved_b;
- } __attribute__ (( packed ));
-
-
- enum intel_descriptor_command {
-
- INTEL_DESC_CMD_RS = 0x08,
-
- INTEL_DESC_CMD_IFCS = 0x02,
-
- INTEL_DESC_CMD_EOP = 0x01,
- };
-
-
- enum intel_descriptor_status {
-
- INTEL_DESC_STATUS_DD = 0x01,
- };
-
-
- #define INTEL_CTRL 0x00000UL
- #define INTEL_CTRL_LRST 0x00000008UL
- #define INTEL_CTRL_ASDE 0x00000020UL
- #define INTEL_CTRL_SLU 0x00000040UL
- #define INTEL_CTRL_FRCSPD 0x00000800UL
- #define INTEL_CTRL_FRCDPLX 0x00001000UL
- #define INTEL_CTRL_RST 0x04000000UL
- #define INTEL_CTRL_PHY_RST 0x80000000UL
-
-
- #define INTEL_RESET_DELAY_MS 20
-
-
- #define INTEL_STATUS 0x00008UL
- #define INTEL_STATUS_LU 0x00000002UL
-
-
- #define INTEL_EERD 0x00014UL
- #define INTEL_EERD_START 0x00000001UL
- #define INTEL_EERD_DONE_SMALL 0x00000010UL
- #define INTEL_EERD_DONE_LARGE 0x00000002UL
- #define INTEL_EERD_ADDR_SHIFT_SMALL 8
- #define INTEL_EERD_ADDR_SHIFT_LARGE 2
- #define INTEL_EERD_DATA(value) ( (value) >> 16 )
-
-
- #define INTEL_EEPROM_MAX_WAIT_MS 100
-
-
- #define INTEL_EEPROM_WORD_LEN_LOG2 1
-
-
- #define INTEL_EEPROM_MIN_SIZE_WORDS 64
-
-
- #define INTEL_EEPROM_MAC 0x00
-
-
- #define INTEL_ICR 0x000c0UL
- #define INTEL_IRQ_TXDW 0x00000001UL
- #define INTEL_IRQ_TXQE 0x00000002UL
- #define INTEL_IRQ_LSC 0x00000004UL
- #define INTEL_IRQ_RXDMT0 0x00000010UL
- #define INTEL_IRQ_RXT0 0x00000080UL
- #define INTEL_IRQ_RXO 0x00000400UL
-
-
- #define INTEL_IMS 0x000d0UL
-
-
- #define INTEL_IMC 0x000d8UL
-
-
- #define INTEL_RCTL 0x00100UL
- #define INTEL_RCTL_EN 0x00000002UL
- #define INTEL_RCTL_UPE 0x00000008UL
- #define INTEL_RCTL_MPE 0x00000010UL
- #define INTEL_RCTL_BAM 0x00008000UL
- #define INTEL_RCTL_BSIZE_BSEX(bsex,bsize) \
- ( ( (bsize) << 16 ) | ( (bsex) << 25 ) )
- #define INTEL_RCTL_BSIZE_2048 INTEL_RCTL_BSIZE_BSEX ( 0, 0 )
- #define INTEL_RCTL_BSIZE_BSEX_MASK INTEL_RCTL_BSIZE_BSEX ( 1, 3 )
- #define INTEL_RCTL_SECRC 0x04000000UL
-
-
- #define INTEL_TCTL 0x00400UL
- #define INTEL_TCTL_EN 0x00000002UL
- #define INTEL_TCTL_PSP 0x00000008UL
- #define INTEL_TCTL_CT(x) ( (x) << 4 )
- #define INTEL_TCTL_CT_DEFAULT INTEL_TCTL_CT ( 0x0f )
- #define INTEL_TCTL_CT_MASK INTEL_TCTL_CT ( 0xff )
- #define INTEL_TCTL_COLD(x) ( (x) << 12 )
- #define INTEL_TCTL_COLD_DEFAULT INTEL_TCTL_COLD ( 0x040 )
- #define INTEL_TCTL_COLD_MASK INTEL_TCTL_COLD ( 0x3ff )
-
-
- #define INTEL_PBA 0x01000UL
-
-
- #define INTEL_PBS 0x01008UL
-
-
- #define INTEL_RD 0x02800UL
-
-
- #define INTEL_NUM_RX_DESC 16
-
-
- #define INTEL_RX_FILL 8
-
-
- #define INTEL_RX_MAX_LEN 2048
-
-
- #define INTEL_TD 0x03800UL
-
-
- #define INTEL_NUM_TX_DESC 16
-
-
- #define INTEL_TX_FILL ( INTEL_NUM_TX_DESC - 1 )
-
-
- #define INTEL_xDBAL 0x00
-
-
- #define INTEL_xDBAH 0x04
-
-
- #define INTEL_xDLEN 0x08
-
-
- #define INTEL_xDH 0x10
-
-
- #define INTEL_xDT 0x18
-
-
- #define INTEL_xDCTL 0x28
- #define INTEL_xDCTL_ENABLE 0x02000000UL
-
-
- #define INTEL_RAL0 0x05400UL
-
-
- #define INTEL_RAH0 0x05404UL
- #define INTEL_RAH0_AV 0x80000000UL
-
-
- union intel_receive_address {
- struct {
- uint32_t low;
- uint32_t high;
- } __attribute__ (( packed )) reg;
- uint8_t raw[ETH_ALEN];
- };
-
-
- struct intel_ring {
-
- struct intel_descriptor *desc;
-
- unsigned int prod;
-
- unsigned int cons;
-
-
- unsigned int reg;
-
- size_t len;
- };
-
-
- static inline __attribute__ (( always_inline)) void
- intel_init_ring ( struct intel_ring *ring, unsigned int count,
- unsigned int reg ) {
- ring->len = ( count * sizeof ( ring->desc[0] ) );
- ring->reg = reg;
- }
-
-
- struct intel_nic {
-
- void *regs;
-
- unsigned int port;
-
- unsigned int flags;
-
- unsigned int force_icr;
-
-
- struct nvs_device eeprom;
-
- uint32_t eerd_done;
-
- unsigned int eerd_addr_shift;
-
-
- struct intel_ring tx;
-
- struct intel_ring rx;
-
- struct io_buffer *rx_iobuf[INTEL_NUM_RX_DESC];
- };
-
-
- enum intel_flags {
-
- INTEL_PBS_ERRATA = 0x0001,
-
- INTEL_VMWARE = 0x0002,
- };
-
- extern int intel_create_ring ( struct intel_nic *intel,
- struct intel_ring *ring );
- extern void intel_destroy_ring ( struct intel_nic *intel,
- struct intel_ring *ring );
- extern void intel_refill_rx ( struct intel_nic *intel );
- extern void intel_empty_rx ( struct intel_nic *intel );
- extern int intel_transmit ( struct net_device *netdev,
- struct io_buffer *iobuf );
- extern void intel_poll_tx ( struct net_device *netdev );
- extern void intel_poll_rx ( struct net_device *netdev );
-
- #endif
|