blob: b53c5ec276a541089c2d55abbf3b52694d48aa68 [file] [log] [blame]
Matt Porter394b7012005-11-07 01:00:15 -08001/*
2 * RapidIO interconnect services
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/device.h>
14#include <linux/list.h>
15#include <linux/rio.h>
16
17/* Functions internal to the RIO core code */
18
19extern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid,
20 u8 hopcount, int ftr);
21extern int rio_create_sysfs_dev_files(struct rio_dev *rdev);
22extern int rio_enum_mport(struct rio_mport *mport);
23extern int rio_disc_mport(struct rio_mport *mport);
Alexandre Bounine07590ff2010-05-26 14:43:57 -070024extern int rio_std_route_add_entry(struct rio_mport *mport, u16 destid,
25 u8 hopcount, u16 table, u16 route_destid,
26 u8 route_port);
27extern int rio_std_route_get_entry(struct rio_mport *mport, u16 destid,
28 u8 hopcount, u16 table, u16 route_destid,
29 u8 *route_port);
30extern int rio_std_route_clr_table(struct rio_mport *mport, u16 destid,
31 u8 hopcount, u16 table);
Matt Porter394b7012005-11-07 01:00:15 -080032
33/* Structures internal to the RIO core code */
34extern struct device_attribute rio_dev_attrs[];
35extern spinlock_t rio_global_list_lock;
36
Matt Porterfa78cc52005-11-07 01:00:18 -080037extern struct rio_route_ops __start_rio_route_ops[];
38extern struct rio_route_ops __end_rio_route_ops[];
39
Matt Porter394b7012005-11-07 01:00:15 -080040/* Helpers internal to the RIO core code */
Alexandre Bounine07590ff2010-05-26 14:43:57 -070041#define DECLARE_RIO_ROUTE_SECTION(section, name, vid, did, add_hook, get_hook, clr_hook) \
42 static const struct rio_route_ops __rio_route_##name __used \
43 __section(section) = { vid, did, add_hook, get_hook, clr_hook };
Matt Porter394b7012005-11-07 01:00:15 -080044
45/**
46 * DECLARE_RIO_ROUTE_OPS - Registers switch routing operations
47 * @vid: RIO vendor ID
48 * @did: RIO device ID
49 * @add_hook: Callback that adds a route entry
50 * @get_hook: Callback that gets a route entry
51 *
52 * Manipulating switch route tables in RIO is switch specific. This
53 * registers a switch by vendor and device ID with two callbacks for
54 * modifying and retrieving route entries in a switch. A &struct
55 * rio_route_ops is initialized with the ops and placed into a
56 * RIO-specific kernel section.
57 */
Alexandre Bounine07590ff2010-05-26 14:43:57 -070058#define DECLARE_RIO_ROUTE_OPS(vid, did, add_hook, get_hook, clr_hook) \
59 DECLARE_RIO_ROUTE_SECTION(.rio_route_ops, vid##did, \
60 vid, did, add_hook, get_hook, clr_hook)
Matt Porter394b7012005-11-07 01:00:15 -080061
Zhang Weie0423232008-04-18 13:33:42 -070062#define RIO_GET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16))
63#define RIO_SET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x000000ff) << 16))