1a4cc719bSEmanuele Giuseppe Esposito /*
2a4cc719bSEmanuele Giuseppe Esposito * libqos driver framework
3a4cc719bSEmanuele Giuseppe Esposito *
4a4cc719bSEmanuele Giuseppe Esposito * Copyright (c) 2018 Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
5a4cc719bSEmanuele Giuseppe Esposito *
6a4cc719bSEmanuele Giuseppe Esposito * This library is free software; you can redistribute it and/or
7a4cc719bSEmanuele Giuseppe Esposito * modify it under the terms of the GNU Lesser General Public
8dc0ad02dSThomas Huth * License version 2.1 as published by the Free Software Foundation.
9a4cc719bSEmanuele Giuseppe Esposito *
10a4cc719bSEmanuele Giuseppe Esposito * This library is distributed in the hope that it will be useful,
11a4cc719bSEmanuele Giuseppe Esposito * but WITHOUT ANY WARRANTY; without even the implied warranty of
12a4cc719bSEmanuele Giuseppe Esposito * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13a4cc719bSEmanuele Giuseppe Esposito * Lesser General Public License for more details.
14a4cc719bSEmanuele Giuseppe Esposito *
15a4cc719bSEmanuele Giuseppe Esposito * You should have received a copy of the GNU Lesser General Public
16a4cc719bSEmanuele Giuseppe Esposito * License along with this library; if not, see <http://www.gnu.org/licenses/>
17a4cc719bSEmanuele Giuseppe Esposito */
18a4cc719bSEmanuele Giuseppe Esposito
19a8b991b5SMarkus Armbruster #ifndef QGRAPH_E1000E_H
20a8b991b5SMarkus Armbruster #define QGRAPH_E1000E_H
21a4cc719bSEmanuele Giuseppe Esposito
22a2ce7dbdSPaolo Bonzini #include "qgraph.h"
23a4cc719bSEmanuele Giuseppe Esposito #include "pci.h"
24a4cc719bSEmanuele Giuseppe Esposito
25a4cc719bSEmanuele Giuseppe Esposito #define E1000E_RX0_MSG_ID (0)
26a4cc719bSEmanuele Giuseppe Esposito #define E1000E_TX0_MSG_ID (1)
27a4cc719bSEmanuele Giuseppe Esposito
2800dc9a59SAkihiko Odaki #define E1000E_ADDRESS { 0x52, 0x54, 0x00, 0x12, 0x34, 0x56 }
2900dc9a59SAkihiko Odaki
30a4cc719bSEmanuele Giuseppe Esposito typedef struct QE1000E QE1000E;
31a4cc719bSEmanuele Giuseppe Esposito typedef struct QE1000E_PCI QE1000E_PCI;
32a4cc719bSEmanuele Giuseppe Esposito
33a4cc719bSEmanuele Giuseppe Esposito struct QE1000E {
34a4cc719bSEmanuele Giuseppe Esposito uint64_t tx_ring;
35a4cc719bSEmanuele Giuseppe Esposito uint64_t rx_ring;
36a4cc719bSEmanuele Giuseppe Esposito };
37a4cc719bSEmanuele Giuseppe Esposito
38a4cc719bSEmanuele Giuseppe Esposito struct QE1000E_PCI {
39a4cc719bSEmanuele Giuseppe Esposito QOSGraphObject obj;
40a4cc719bSEmanuele Giuseppe Esposito QPCIDevice pci_dev;
41a4cc719bSEmanuele Giuseppe Esposito QPCIBar mac_regs;
42a4cc719bSEmanuele Giuseppe Esposito QE1000E e1000e;
43a4cc719bSEmanuele Giuseppe Esposito };
44a4cc719bSEmanuele Giuseppe Esposito
e1000e_macreg_write(QE1000E * d,uint32_t reg,uint32_t val)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
e1000e_macreg_read(QE1000E * d,uint32_t reg)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
57a4cc719bSEmanuele Giuseppe Esposito void e1000e_wait_isr(QE1000E *d, uint16_t msg_id);
58a4cc719bSEmanuele Giuseppe Esposito void e1000e_tx_ring_push(QE1000E *d, void *descr);
59a4cc719bSEmanuele Giuseppe Esposito void e1000e_rx_ring_push(QE1000E *d, void *descr);
60a4cc719bSEmanuele Giuseppe Esposito
61a4cc719bSEmanuele Giuseppe Esposito #endif
62