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