Matt Porter | 394b701 | 2005-11-07 01:00:15 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 19 | extern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid, |
| 20 | u8 hopcount, int ftr); |
Alexandre Bounine | e5cabeb | 2010-05-26 14:43:59 -0700 | [diff] [blame] | 21 | extern u32 rio_mport_get_physefb(struct rio_mport *port, int local, |
| 22 | u16 destid, u8 hopcount); |
| 23 | extern u32 rio_mport_get_efb(struct rio_mport *port, int local, u16 destid, |
| 24 | u8 hopcount, u32 from); |
Matt Porter | 394b701 | 2005-11-07 01:00:15 -0800 | [diff] [blame] | 25 | extern int rio_create_sysfs_dev_files(struct rio_dev *rdev); |
| 26 | extern int rio_enum_mport(struct rio_mport *mport); |
| 27 | extern int rio_disc_mport(struct rio_mport *mport); |
Alexandre Bounine | 07590ff | 2010-05-26 14:43:57 -0700 | [diff] [blame] | 28 | extern int rio_std_route_add_entry(struct rio_mport *mport, u16 destid, |
| 29 | u8 hopcount, u16 table, u16 route_destid, |
| 30 | u8 route_port); |
| 31 | extern int rio_std_route_get_entry(struct rio_mport *mport, u16 destid, |
| 32 | u8 hopcount, u16 table, u16 route_destid, |
| 33 | u8 *route_port); |
| 34 | extern int rio_std_route_clr_table(struct rio_mport *mport, u16 destid, |
| 35 | u8 hopcount, u16 table); |
Alexandre Bounine | e5cabeb | 2010-05-26 14:43:59 -0700 | [diff] [blame] | 36 | extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock); |
Matt Porter | 394b701 | 2005-11-07 01:00:15 -0800 | [diff] [blame] | 37 | |
| 38 | /* Structures internal to the RIO core code */ |
| 39 | extern struct device_attribute rio_dev_attrs[]; |
| 40 | extern spinlock_t rio_global_list_lock; |
| 41 | |
Matt Porter | fa78cc5 | 2005-11-07 01:00:18 -0800 | [diff] [blame] | 42 | extern struct rio_route_ops __start_rio_route_ops[]; |
| 43 | extern struct rio_route_ops __end_rio_route_ops[]; |
| 44 | |
Matt Porter | 394b701 | 2005-11-07 01:00:15 -0800 | [diff] [blame] | 45 | /* Helpers internal to the RIO core code */ |
Alexandre Bounine | 07590ff | 2010-05-26 14:43:57 -0700 | [diff] [blame] | 46 | #define DECLARE_RIO_ROUTE_SECTION(section, name, vid, did, add_hook, get_hook, clr_hook) \ |
| 47 | static const struct rio_route_ops __rio_route_##name __used \ |
| 48 | __section(section) = { vid, did, add_hook, get_hook, clr_hook }; |
Matt Porter | 394b701 | 2005-11-07 01:00:15 -0800 | [diff] [blame] | 49 | |
| 50 | /** |
| 51 | * DECLARE_RIO_ROUTE_OPS - Registers switch routing operations |
| 52 | * @vid: RIO vendor ID |
| 53 | * @did: RIO device ID |
| 54 | * @add_hook: Callback that adds a route entry |
| 55 | * @get_hook: Callback that gets a route entry |
| 56 | * |
| 57 | * Manipulating switch route tables in RIO is switch specific. This |
| 58 | * registers a switch by vendor and device ID with two callbacks for |
| 59 | * modifying and retrieving route entries in a switch. A &struct |
| 60 | * rio_route_ops is initialized with the ops and placed into a |
| 61 | * RIO-specific kernel section. |
| 62 | */ |
Alexandre Bounine | 07590ff | 2010-05-26 14:43:57 -0700 | [diff] [blame] | 63 | #define DECLARE_RIO_ROUTE_OPS(vid, did, add_hook, get_hook, clr_hook) \ |
| 64 | DECLARE_RIO_ROUTE_SECTION(.rio_route_ops, vid##did, \ |
| 65 | vid, did, add_hook, get_hook, clr_hook) |
Matt Porter | 394b701 | 2005-11-07 01:00:15 -0800 | [diff] [blame] | 66 | |
Zhang Wei | e042323 | 2008-04-18 13:33:42 -0700 | [diff] [blame] | 67 | #define RIO_GET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16)) |
| 68 | #define RIO_SET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x000000ff) << 16)) |
Alexandre Bounine | e5cabeb | 2010-05-26 14:43:59 -0700 | [diff] [blame] | 69 | |
| 70 | /* |
| 71 | * RapidIO Error Management |
| 72 | */ |
| 73 | extern struct rio_em_ops __start_rio_em_ops[]; |
| 74 | extern struct rio_em_ops __end_rio_em_ops[]; |
| 75 | |
| 76 | /* Helpers internal to the RIO core code */ |
| 77 | #define DECLARE_RIO_EM_SECTION(section, name, vid, did, init_hook, em_hook) \ |
| 78 | static const struct rio_em_ops __rio_em_##name __used \ |
| 79 | __section(section) = { vid, did, init_hook, em_hook }; |
| 80 | |
| 81 | /** |
| 82 | * DECLARE_RIO_EM_OPS - Registers switch EM operations |
| 83 | * @vid: RIO vendor ID |
| 84 | * @did: RIO device ID |
| 85 | * @init_hook: Callback that initializes device specific EM |
| 86 | * @em_hook: Callback that handles device specific EM |
| 87 | * |
| 88 | * A &struct rio_em_ops is initialized with the ops and placed into a |
| 89 | * RIO-specific kernel section. |
| 90 | */ |
| 91 | #define DECLARE_RIO_EM_OPS(vid, did, init_hook, em_hook) \ |
| 92 | DECLARE_RIO_EM_SECTION(.rio_em_ops, vid##did, \ |
| 93 | vid, did, init_hook, em_hook) |