11cf4323eSThomas Huth /* 21cf4323eSThomas Huth * libqos driver framework 31cf4323eSThomas Huth * 41cf4323eSThomas Huth * Copyright (c) 2018 Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> 51cf4323eSThomas Huth * 61cf4323eSThomas Huth * This library is free software; you can redistribute it and/or 71cf4323eSThomas Huth * modify it under the terms of the GNU Lesser General Public 8dc0ad02dSThomas Huth * License version 2.1 as published by the Free Software Foundation. 91cf4323eSThomas Huth * 101cf4323eSThomas Huth * This library is distributed in the hope that it will be useful, 111cf4323eSThomas Huth * but WITHOUT ANY WARRANTY; without even the implied warranty of 121cf4323eSThomas Huth * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 131cf4323eSThomas Huth * Lesser General Public License for more details. 141cf4323eSThomas Huth * 151cf4323eSThomas Huth * You should have received a copy of the GNU Lesser General Public 161cf4323eSThomas Huth * License along with this library; if not, see <http://www.gnu.org/licenses/> 171cf4323eSThomas Huth */ 181cf4323eSThomas Huth 191cf4323eSThomas Huth #ifndef QGRAPH_E1000E_H 201cf4323eSThomas Huth #define QGRAPH_E1000E_H 211cf4323eSThomas Huth 22a2ce7dbdSPaolo Bonzini #include "qgraph.h" 231cf4323eSThomas Huth #include "pci.h" 241cf4323eSThomas Huth 251cf4323eSThomas Huth #define E1000E_RX0_MSG_ID (0) 261cf4323eSThomas Huth #define E1000E_TX0_MSG_ID (1) 271cf4323eSThomas Huth 2800dc9a59SAkihiko Odaki #define E1000E_ADDRESS { 0x52, 0x54, 0x00, 0x12, 0x34, 0x56 } 2900dc9a59SAkihiko Odaki 301cf4323eSThomas Huth typedef struct QE1000E QE1000E; 311cf4323eSThomas Huth typedef struct QE1000E_PCI QE1000E_PCI; 321cf4323eSThomas Huth 331cf4323eSThomas Huth struct QE1000E { 341cf4323eSThomas Huth uint64_t tx_ring; 351cf4323eSThomas Huth uint64_t rx_ring; 361cf4323eSThomas Huth }; 371cf4323eSThomas Huth 381cf4323eSThomas Huth struct QE1000E_PCI { 391cf4323eSThomas Huth QOSGraphObject obj; 401cf4323eSThomas Huth QPCIDevice pci_dev; 411cf4323eSThomas Huth QPCIBar mac_regs; 421cf4323eSThomas Huth QE1000E e1000e; 431cf4323eSThomas Huth }; 441cf4323eSThomas Huth 45*0caa7effSAkihiko Odaki static inline void e1000e_macreg_write(QE1000E *d, uint32_t reg, uint32_t val) 46*0caa7effSAkihiko Odaki { 47*0caa7effSAkihiko Odaki QE1000E_PCI *d_pci = container_of(d, QE1000E_PCI, e1000e); 48*0caa7effSAkihiko Odaki qpci_io_writel(&d_pci->pci_dev, d_pci->mac_regs, reg, val); 49*0caa7effSAkihiko Odaki } 50*0caa7effSAkihiko Odaki 51*0caa7effSAkihiko Odaki static inline uint32_t e1000e_macreg_read(QE1000E *d, uint32_t reg) 52*0caa7effSAkihiko Odaki { 53*0caa7effSAkihiko Odaki QE1000E_PCI *d_pci = container_of(d, QE1000E_PCI, e1000e); 54*0caa7effSAkihiko Odaki return qpci_io_readl(&d_pci->pci_dev, d_pci->mac_regs, reg); 55*0caa7effSAkihiko Odaki } 56*0caa7effSAkihiko Odaki 571cf4323eSThomas Huth void e1000e_wait_isr(QE1000E *d, uint16_t msg_id); 581cf4323eSThomas Huth void e1000e_tx_ring_push(QE1000E *d, void *descr); 591cf4323eSThomas Huth void e1000e_rx_ring_push(QE1000E *d, void *descr); 601cf4323eSThomas Huth 611cf4323eSThomas Huth #endif 62