1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*
* Written by Oron Peled <oron@actcom.co.il>
* Copyright (C) 2004-2006, Xorcom
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef XBUS_CORE_H
#define XBUS_CORE_H
#include "xpd.h"
#define MAX_BUSES 32
#define XFRAME_DATASIZE 512
struct xframe {
atomic_t frame_len;
xbus_t *xbus;
struct timeval tv_created;
byte *packets; /* max XFRAME_DATASIZE */
};
#define XFRAME_LEN(frame) atomic_read(&(frame)->frame_len)
int xbus_core_init(void); /* Initializer */
void xbus_core_shutdown(void); /* Terminator */
#ifdef XPP_DEBUGFS
/* Debugfs handling */
int xbus_log(xbus_t *xbus, xpd_t *xpd, int direction, const void *buf, unsigned long len);
#endif
/* Frame handling */
xframe_t *xbus_frame_new(xbus_t *xbus, gfp_t flags);
void xbus_frame_free(xbus_t *xbus, xframe_t *p);
void dump_xframe(const char msg[], const xbus_t *xbus, const xframe_t *xframe);
int xframe_send(xbus_t *xbus, xframe_t *xframe);
int send_cmd_frame(xbus_t *xbus, xframe_t *xframe);
/*
* Return pointer to next packet slot in the frame
* or NULL if the frame is full.
*/
xpacket_t *xframe_next_packet(xframe_t *xframe, int len);
/* XBUS handling */
/*
* Map: unit+subunit <--> index in xbus->xpds[]
*/
#define XPD_IDX(unit,subunit) ((unit) * MAX_SUBUNIT + (subunit))
#define XBUS_UNIT(idx) ((idx) / MAX_SUBUNIT)
#define XBUS_SUBUNIT(idx) ((idx) % MAX_SUBUNIT)
xbus_t *xbus_of(int xbus_num);
xpd_t *xpd_of(const xbus_t *xbus, int xpd_num);
xpd_t *xpd_byaddr(const xbus_t *xbus, uint unit, uint subunit);
xbus_t *xbus_new(xbus_ops_t *ops);
void xbus_remove(xbus_t *xbus);
void xbus_activate(xbus_t *xbus);
void xbus_disconnect(xbus_t *xbus);
void xbus_poller_notify(xbus_t *xbus, struct card_desc_struct *card_desc);
void xbus_reset_counters(xbus_t *xbus);
int xbus_register_xpd(xbus_t *xbus, xpd_t *xpd);
int xbus_unregister_xpd(xbus_t *xbus, xpd_t *xpd);
/* sysfs */
int register_xpp_bus(void);
void unregister_xpp_bus(void);
int xbus_sysfs_create(xbus_t *xbus);
void xbus_sysfs_remove(xbus_t *xbus);
#endif /* XBUS_CORE_H */
|