These changes are the raw update to qemu-2.6.
[kvmfornfv.git] / qemu / roms / ipxe / src / drivers / net / intelvf.h
1 #ifndef _INTELVF_H
2 #define _INTELVF_H
3
4 /** @file
5  *
6  * Intel 10/100/1000 virtual function network card driver
7  *
8  */
9
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
12 #include "intel.h"
13
14 /** Intel VF BAR size */
15 #define INTELVF_BAR_SIZE ( 16 * 1024 )
16
17 /** Mailbox Control Register */
18 #define INTELVF_MBCTRL 0x0c40UL
19 #define INTELVF_MBCTRL_REQ      0x00000001UL    /**< Request for PF ready */
20 #define INTELVF_MBCTRL_ACK      0x00000002UL    /**< PF message received */
21 #define INTELVF_MBCTRL_VFU      0x00000004UL    /**< Buffer taken by VF */
22 #define INTELVF_MBCTRL_PFU      0x00000008UL    /**< Buffer taken to PF */
23 #define INTELVF_MBCTRL_PFSTS    0x00000010UL    /**< PF wrote a message */
24 #define INTELVF_MBCTRL_PFACK    0x00000020UL    /**< PF acknowledged message */
25 #define INTELVF_MBCTRL_RSTI     0x00000040UL    /**< PF reset in progress */
26 #define INTELVF_MBCTRL_RSTD     0x00000080UL    /**< PF reset complete */
27
28 /** Mailbox Memory Register Base */
29 #define INTELVF_MBMEM 0x0800UL
30
31 /** Reset mailbox message */
32 #define INTELVF_MSG_TYPE_RESET 0x00000001UL
33
34 /** Set MAC address mailbox message */
35 #define INTELVF_MSG_TYPE_SET_MAC 0x00000002UL
36
37 /** Set MTU mailbox message */
38 #define INTELVF_MSG_TYPE_SET_MTU 0x00000005UL
39
40 /** Control ("ping") mailbox message */
41 #define INTELVF_MSG_TYPE_CONTROL 0x00000100UL
42
43 /** Message type mask */
44 #define INTELVF_MSG_TYPE_MASK 0x0000ffffUL
45
46 /** Message NACK flag */
47 #define INTELVF_MSG_NACK 0x40000000UL
48
49 /** Message ACK flag */
50 #define INTELVF_MSG_ACK 0x80000000UL
51
52 /** Message is a response */
53 #define INTELVF_MSG_RESPONSE ( INTELVF_MSG_ACK | INTELVF_MSG_NACK )
54
55 /** MAC address mailbox message */
56 struct intelvf_msg_mac {
57         /** Message header */
58         uint32_t hdr;
59         /** MAC address */
60         uint8_t mac[ETH_ALEN];
61         /** Alignment padding */
62         uint8_t reserved[ (-ETH_ALEN) & 0x3 ];
63 } __attribute__ (( packed ));
64
65 /** Version number mailbox message */
66 struct intelvf_msg_version {
67         /** Message header */
68         uint32_t hdr;
69         /** API version */
70         uint32_t version;
71 } __attribute__ (( packed ));
72
73 /** MTU mailbox message */
74 struct intelvf_msg_mtu {
75         /** Message header */
76         uint32_t hdr;
77         /** Maximum packet size */
78         uint32_t mtu;
79 } __attribute__ (( packed ));
80
81 /** Mailbox message */
82 union intelvf_msg {
83         /** Message header */
84         uint32_t hdr;
85         /** MAC address message */
86         struct intelvf_msg_mac mac;
87         /** Version number message */
88         struct intelvf_msg_version version;
89         /** MTU message */
90         struct intelvf_msg_mtu mtu;
91         /** Raw dwords */
92         uint32_t dword[0];
93 };
94
95 /** Maximum time to wait for mailbox message
96  *
97  * This is a policy decision.
98  */
99 #define INTELVF_MBOX_MAX_WAIT_MS 500
100
101 extern int intelvf_mbox_msg ( struct intel_nic *intel, union intelvf_msg *msg );
102 extern int intelvf_mbox_poll ( struct intel_nic *intel );
103 extern int intelvf_mbox_wait ( struct intel_nic *intel );
104 extern int intelvf_mbox_reset ( struct intel_nic *intel, uint8_t *hw_addr );
105 extern int intelvf_mbox_set_mac ( struct intel_nic *intel,
106                                   const uint8_t *ll_addr );
107 extern int intelvf_mbox_set_mtu ( struct intel_nic *intel, size_t mtu );
108
109 #endif /* _INTELVF_H */