Add Lib, Readme
[profile/ivi/OpenAVB.git] / lib / igb.h
1 /******************************************************************************
2
3   Copyright (c) 2001-2012, Intel Corporation 
4   All rights reserved.
5   
6   Redistribution and use in source and binary forms, with or without 
7   modification, are permitted provided that the following conditions are met:
8   
9    1. Redistributions of source code must retain the above copyright notice, 
10       this list of conditions and the following disclaimer.
11   
12    2. Redistributions in binary form must reproduce the above copyright 
13       notice, this list of conditions and the following disclaimer in the 
14       documentation and/or other materials provided with the distribution.
15   
16    3. Neither the name of the Intel Corporation nor the names of its 
17       contributors may be used to endorse or promote products derived from 
18       this software without specific prior written permission.
19   
20   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
22   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
23   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
24   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
25   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
26   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
27   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
28   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
29   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   POSSIBILITY OF SUCH DAMAGE.
31
32 ******************************************************************************/
33 /*$FreeBSD$*/
34
35 #ifndef _IGB_H_DEFINED_
36 #define _IGB_H_DEFINED_
37
38 struct resource {
39         u_int64_t       paddr;
40         u_int32_t       mmap_size;
41 };
42
43 /* datastructure used to transmit a timed packet */
44 #define IGB_PACKET_LAUNCHTIME   1       /* control when packet transmitted */
45 #define IGB_PACKET_LATCHTIME    2       /* grab a timestamp of transmission */
46
47 struct igb_packet {
48         struct resource map;            /* bus_dma map for packet */
49         unsigned int    offset;         /* offset into physical page */
50         void            *vaddr;
51         u_int32_t       len;
52         u_int32_t       flags;
53         u_int64_t       attime;         /* launchtime */
54         u_int64_t       dmatime;        /* when dma tx desc wb*/
55         struct igb_packet *next;        /* used in the clean routine */
56 };
57
58 typedef struct _device_t {
59         void    *private_data;
60         u_int16_t pci_vendor_id;
61         u_int16_t pci_device_id;
62         u_int16_t domain;
63         u_int8_t        bus;
64         u_int8_t        dev;
65         u_int8_t        func;
66 } device_t;
67
68 /*
69  * Bus dma allocation structure used by
70  * e1000_dma_malloc_page and e1000_dma_free_page.
71  */
72 struct igb_dma_alloc {
73         u_int64_t               dma_paddr;
74         void                    *dma_vaddr;
75         unsigned int            mmap_size;
76 };
77
78 int     igb_probe( device_t *dev );
79 int     igb_attach(char *dev_path, device_t *pdev);
80 int     igb_detach(device_t *dev);
81 int     igb_suspend(device_t *dev);
82 int     igb_resume(device_t *dev);
83 int     igb_init(device_t *dev);
84 int     igb_dma_malloc_page(device_t *dev, struct igb_dma_alloc *page);
85 void    igb_dma_free_page(device_t *dev, struct igb_dma_alloc *page);
86 int     igb_xmit(device_t *dev, unsigned int queue_index, struct igb_packet *packet);
87 void    igb_clean(device_t *dev, struct igb_packet **cleaned_packets);
88 int     igb_get_wallclock(device_t *dev, u_int64_t      *curtime, u_int64_t *rdtsc);
89 int     igb_set_class_bandwidth(device_t *dev, u_int32_t class_a, u_int32_t class_b, u_int32_t tpktsz);
90
91 void    igb_trigger(device_t *dev, u_int32_t data);
92 void    igb_readreg(device_t *dev, u_int32_t reg, u_int32_t *data);
93 void    igb_writereg(device_t *dev, u_int32_t reg, u_int32_t data);
94
95 #endif /* _IGB_H_DEFINED_ */
96
97