Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / minix / netdriver.h @ 13

History | View | Annotate | Download (2.45 KB)

1 13 up20180614
#ifndef _MINIX_NETDRIVER_H
2
#define _MINIX_NETDRIVER_H
3
4
/*
5
 * Prototypes and definitions for network drivers.
6
 */
7
#include <minix/config.h>
8
#include <minix/endpoint.h>
9
#include <minix/ipc.h>
10
#include <minix/com.h>
11
12
#include <net/if_media.h>
13
14
/* Opaque data structure for copying in and out actual packet data. */
15
struct netdriver_data;
16
17
/* Network (ethernet) address structure. */
18
typedef struct {
19
        uint8_t na_addr[NDEV_HWADDR_MAX];
20
} netdriver_addr_t;
21
22
/* Information and function call table for network drivers. */
23
struct netdriver {
24
        const char *ndr_name;
25
        int (* ndr_init)(unsigned int instance, netdriver_addr_t * hwaddr,
26
            uint32_t * caps, unsigned int * ticks);
27
        void (* ndr_stop)(void);
28
        void (* ndr_set_mode)(unsigned int mode,
29
            const netdriver_addr_t * mcast_list, unsigned int mcast_count);
30
        void (* ndr_set_caps)(uint32_t caps);
31
        void (* ndr_set_flags)(uint32_t flags);
32
        void (* ndr_set_media)(uint32_t media);
33
        void (* ndr_set_hwaddr)(const netdriver_addr_t * hwaddr);
34
        ssize_t (* ndr_recv)(struct netdriver_data * data, size_t max);
35
        int (* ndr_send)(struct netdriver_data * data, size_t size);
36
        unsigned int (* ndr_get_link)(uint32_t * media);
37
        void (* ndr_intr)(unsigned int mask);
38
        void (* ndr_tick)(void);
39
        void (* ndr_other)(const message * m_ptr, int ipc_status);
40
};
41
42
/* Functions defined by libnetdriver. */
43
void netdriver_task(const struct netdriver * ndp);
44
45
int netdriver_init(const struct netdriver * ndp);
46
void netdriver_process(const struct netdriver * __restrict ndp,
47
        const message * __restrict m_ptr, int ipc_status);
48
void netdriver_terminate(void);
49
50
const char *netdriver_name(void);
51
52
void netdriver_recv(void);
53
void netdriver_send(void);
54
void netdriver_link(void);
55
56
void netdriver_stat_oerror(uint32_t count);
57
void netdriver_stat_coll(uint32_t count);
58
void netdriver_stat_ierror(uint32_t count);
59
void netdriver_stat_iqdrop(uint32_t count);
60
61
void netdriver_copyin(struct netdriver_data * __restrict data, size_t off,
62
        void * __restrict ptr, size_t size);
63
void netdriver_copyout(struct netdriver_data * __restrict data, size_t off,
64
        const void * __restrict ptr, size_t size);
65
66
void netdriver_portinb(struct netdriver_data * data, size_t off, long port,
67
        size_t size);
68
void netdriver_portoutb(struct netdriver_data * data, size_t off, long port,
69
        size_t size);
70
void netdriver_portinw(struct netdriver_data * data, size_t off, long port,
71
        size_t size);
72
void netdriver_portoutw(struct netdriver_data * data, size_t off, long port,
73
        size_t size);
74
75
#endif /* _MINIX_NETDRIVER_H */