Skip to contentSkip to conversation

RapidIO: Add Port-Write handling for EM

PATCH In review Alexandre Bounine 3 participants 5 messages Feb 24, 2010 – Feb 26, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/7 RapidIO: Add Port-Write handling for EM

From: Alexandre Bounine <[email protected]>

Add RapidIO Port-Write message handling in the context of Error Management Extensions Specification Rev.1.3.

---

 drivers/rapidio/rio-scan.c        |  197 +++++++++++++++++++-----
 drivers/rapidio/rio.c             |  307 ++++++++++++++++++++++++++++++++++++++
 drivers/rapidio/rio.h             |   29 +++
 drivers/rapidio/switches/tsi568.c |   24 ++
 drivers/rapidio/switches/tsi57x.c |  153 ++++++++++++++++++
 include/asm-generic/vmlinux.lds.h |    5 
 include/linux/rio.h               |   30 +++
 include/linux/rio_drv.h           |    6 
 include/linux/rio_regs.h          |   60 +++++++
 9 files changed, 771 insertions(+), 40 deletions(-)
drivers/rapidio/rio-scan.c +161 -36
diff -x '*.pj' -X dontdiff_2.6.32-rc5 -pNur w33r7a/drivers/rapidio/rio-scan.c w33r7b/drivers/rapidio/rio-scan.c
@@ -4,6 +4,10 @@
  * Copyright 2005 MontaVista Software, Inc.
  * Matt Porter <[email protected]>
  *
+ * Copyright 2009 Integrated Device Technology, Inc.
+ * Alex Bounine <[email protected]>
+ * - Added Port-Write/Error Management initialization and handling
+ *
  * 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
@@ -31,15 +35,16 @@
 LIST_HEAD(rio_devices);
 static LIST_HEAD(rio_switches);
 
-#define RIO_ENUM_CMPL_MAGIC	0xdeadbeef
-
 static void rio_enum_timeout(unsigned long);
 
+static void rio_init_em(struct rio_dev *rdev);
+
 DEFINE_SPINLOCK(rio_global_list_lock);
 
 static int next_destid = 0;
 static int next_switchid = 0;
 static int next_net = 0;
+static int next_comptag;
 
 static struct timer_list rio_enum_timer =
 TIMER_INITIALIZER(rio_enum_timeout, 0, 0);
@@ -52,13 +57,6 @@ static int rio_mport_phys_table[] = {
 	-1,
 };
 
-static int rio_sport_phys_table[] = {
-	RIO_EFB_PAR_EP_FREE_ID,
-	RIO_EFB_SER_EP_FREE_ID,
-	RIO_EFB_SER_EP_FREC_ID,
-	-1,
-};
-
 /**
  * rio_get_device_id - Get the base/extended device id for a device
  * @port: RIO master port
@@ -119,12 +117,26 @@ static int rio_clear_locks(struct rio_mp
 	u32 result;
 	int ret = 0;
 
-	/* Write component tag CSR magic complete value */
-	rio_local_write_config_32(port, RIO_COMPONENT_TAG_CSR,
-				  RIO_ENUM_CMPL_MAGIC);
-	list_for_each_entry(rdev, &rio_devices, global_list)
-	    rio_write_config_32(rdev, RIO_COMPONENT_TAG_CSR,
-				RIO_ENUM_CMPL_MAGIC);
+	/* Assign component tag to all devices */
+	next_comptag = 1;
+	rio_local_write_config_32(port, RIO_COMPONENT_TAG_CSR, next_comptag++);
+
+	list_for_each_entry(rdev, &rio_devices, global_list) {
+		/* Mark device as discovered */
+		rio_read_config_32(rdev,
+				   rdev->phys_efptr + RIO_PORT_GEN_CTL_CSR,
+				   &result);
+		rio_write_config_32(rdev,
+				    rdev->phys_efptr + RIO_PORT_GEN_CTL_CSR,
+				    result | RIO_PORT_GEN_DISCOVERED);
+
+		rio_write_config_32(rdev, RIO_COMPONENT_TAG_CSR, next_comptag);
+		rdev->comp_tag = next_comptag++;
+		if (next_comptag >= 0x10000) {
+			pr_err("RIO: Component Tag Counter Overflow\n");
+			break;
+		}
+	}
 
 	/* Release host device id locks */
 	rio_local_write_config_32(port, RIO_HOST_DID_LOCK_CSR,
@@ -267,6 +279,30 @@ static void rio_route_set_ops(struct rio
 }
 
 /**
+ * rio_em_set_ops- Sets Error Managment operations for a particular vendor switch
+ * @rdev: RIO device
+ *
+ * Searches the RIO EM ops table for known switch types. If the vid
+ * and did match a switch table entry, then set the em_init() and
+ * em_handle() ops to the table entry values.
+ */
+static void rio_em_set_ops(struct rio_dev *rdev)
+{
+	struct rio_em_ops *cur = __start_rio_em_ops;
+	struct rio_em_ops *end = __end_rio_em_ops;
+
+	while (cur < end) {
+		if ((cur->vid == rdev->vid) && (cur->did == rdev->did)) {
+			pr_debug("RIO: adding EM ops for %s\n", rio_name(rdev));
+			rdev->rswitch->em_init = cur->init_hook;
+			rdev->rswitch->em_handle = cur->handler_hook;
+			break;
+		}
+		cur++;
+	}
+}
+
+/**
  * rio_add_device- Adds a RIO device to the device model
  * @rdev: RIO device
  *
@@ -336,8 +372,14 @@ static struct rio_dev __devinit *rio_set
 	rdev->asm_rev = result >> 16;
 	rio_mport_read_config_32(port, destid, hopcount, RIO_PEF_CAR,
 				 &rdev->pef);
-	if (rdev->pef & RIO_PEF_EXT_FEATURES)
+	if (rdev->pef & RIO_PEF_EXT_FEATURES) {
 		rdev->efptr = result & 0xffff;
+		rdev->phys_efptr = rio_mport_get_physefb(port, 0, destid,
+							 hopcount);
+
+		rdev->em_efptr = rio_mport_get_feature(port, 0, destid,
+						hopcount, RIO_EFB_ERR_MGMNT);
+	}
 
 	rio_mport_read_config_32(port, destid, hopcount, RIO_SRC_OPS_CAR,
 				 &rdev->src_ops);
@@ -366,6 +408,7 @@ static struct rio_dev __devinit *rio_set
 		rswitch->switchid = next_switchid;
 		rswitch->hopcount = hopcount;
 		rswitch->destid = destid;
+		rswitch->port_ok = 0;
 		rswitch->route_table = kzalloc(sizeof(u8)*
 					RIO_MAX_ROUTE_ENTRIES(port->sys_size),
 					GFP_KERNEL);
@@ -379,6 +422,7 @@ static struct rio_dev __devinit *rio_set
 		dev_set_name(&rdev->dev, "%02x:s:%04x", rdev->net->id,
 			     rdev->rswitch->switchid);
 		rio_route_set_ops(rdev);
+		rio_em_set_ops(rdev);
 
 		if (do_enum && rdev->rswitch->clr_table)
 			rdev->rswitch->clr_table(port, destid, hopcount,
@@ -429,23 +473,29 @@ cleanup:
  *
  * Reads the port error status CSR for a particular switch port to
  * determine if the port has an active link.  Returns
- * %PORT_N_ERR_STS_PORT_OK if the port is active or %0 if it is
+ * %RIO_PORT_N_ERR_STS_PORT_OK if the port is active or %0 if it is
  * inactive.
  */
 static int
 rio_sport_is_active(struct rio_mport *port, u16 destid, u8 hopcount, int sport)
 {
-	u32 result;
+	u32 result = 0;
 	u32 ext_ftr_ptr;
 
-	int *entry = rio_sport_phys_table;
-
-	do {
-		if ((ext_ftr_ptr =
-		     rio_mport_get_feature(port, 0, destid, hopcount, *entry)))
+	ext_ftr_ptr = rio_mport_get_efb(port, 0, destid, hopcount, 0);
 
+	while (ext_ftr_ptr) {
+		rio_mport_read_config_32(port, destid, hopcount,
+					 ext_ftr_ptr, &result);
+		result = RIO_GET_BLOCK_ID(result);
+		if ((result == RIO_EFB_SER_EP_FREE_ID) ||
+		    (result == RIO_EFB_SER_EP_FREE_ID_V13P) ||
+		    (result == RIO_EFB_SER_EP_FREC_ID))
 			break;
-	} while (*++entry >= 0);
+
+		ext_ftr_ptr = rio_mport_get_efb(port, 0, destid, hopcount,
+						ext_ftr_ptr);
+	}
 
 	if (ext_ftr_ptr)
 		rio_mport_read_config_32(port, destid, hopcount,
@@ -453,7 +503,38 @@ rio_sport_is_active(struct rio_mport *po
 					 RIO_PORT_N_ERR_STS_CSR(sport),
 					 &result);
 
-	return (result & PORT_N_ERR_STS_PORT_OK);
+	return result & RIO_PORT_N_ERR_STS_PORT_OK;
+}
+
+/**
+ * rio_set_port_lockout - Sets/clears LOCKOUT bit (RIO EM 1.3) for a switch port.
+ * @rdev: Pointer to RIO device control structure
+ * @pnum: Switch port number to set LOCKOUT bit
+ * @lock: Operation : set (=1) or clear (=0)
+ */
+static int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock)
+{
+	u8 hopcount = 0xff;
+	u16 destid = rdev->destid;
+	u32 regval;
+
+	if (rdev->rswitch) {
+		destid = rdev->rswitch->destid;
+		hopcount = rdev->rswitch->hopcount;
+	}
+
+	rio_mport_read_config_32(rdev->net->hport, destid, hopcount,
+				 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(pnum),
+				 &regval);
+	if (lock)
+		regval |= RIO_PORT_N_CTL_LOCKOUT;
+	else
+		regval &= ~RIO_PORT_N_CTL_LOCKOUT;
+
+	rio_mport_write_config_32(rdev->net->hport, destid, hopcount,
+				  rdev->phys_efptr + RIO_PORT_N_CTL_CSR(pnum),
+				  regval);
+	return 0;
 }
 
 /**
@@ -659,8 +740,10 @@ static int __devinit rio_enum_peer(struc
 		    rio_name(rdev), rdev->vid, rdev->did, num_ports);
 		sw_destid = next_destid;
 		for (port_num = 0; port_num < num_ports; port_num++) {
-			if (sw_inport == port_num)
+			if (sw_inport == port_num) {
+				rdev->rswitch->port_ok |= (1 << port_num);
 				continue;
+			}
 
 			cur_destid = next_destid;
 
@@ -670,6 +753,7 @@ static int __devinit rio_enum_peer(struc
 				pr_debug(
 				    "RIO: scanning device on port %d\n",
 				    port_num);
+				rdev->rswitch->port_ok |= (1 << port_num);
 				rio_route_add_entry(port, rdev->rswitch,
 						RIO_GLOBAL_TABLE,
 						RIO_ANY_DESTID(port->sys_size),
@@ -693,9 +777,28 @@ static int __devinit rio_enum_peer(struc
 						    port_num;
 					}
 				}
+			} else {
+				/* If switch supports Error Management,
+				 * set PORT_LOCKOUT bit for unused port
+				 */
+				if (rdev->em_efptr)
+					rio_set_port_lockout(rdev, port_num, 1);
+
+				rdev->rswitch->port_ok &= ~(1 << port_num);
 			}
 		}
 
+		/* Direct Port-write messages to the enumeratiing host */
+		if ((rdev->src_ops & RIO_SRC_OPS_PORT_WRITE) &&
+		    (rdev->em_efptr)) {
+			rio_write_config_32(rdev,
+					rdev->em_efptr + RIO_EM_PW_TGT_DEVID,
+					(port->host_deviceid << 16) |
+					(port->sys_size << 15));
+		}
+
+		rio_init_em(rdev);
+
 		/* Check for empty switch */
 		if (next_destid == sw_destid) {
 			next_destid++;
@@ -715,21 +818,16 @@ static int __devinit rio_enum_peer(struc
  * rio_enum_complete- Tests if enumeration of a network is complete
  * @port: Master port to send transaction
  *
- * Tests the Component Tag CSR for presence of the magic enumeration
- * complete flag. Return %1 if enumeration is complete or %0 if
+ * Tests the Component Tag CSR for non-zero value (enumeration
+ * complete flag). Return %1 if enumeration is complete or %0 if
  * enumeration is incomplete.
  */
 static int rio_enum_complete(struct rio_mport *port)
 {
 	u32 tag_csr;
-	int ret = 0;
 
 	rio_local_read_config_32(port, RIO_COMPONENT_TAG_CSR, &tag_csr);
-
-	if (tag_csr == RIO_ENUM_CMPL_MAGIC)
-		ret = 1;
-
-	return ret;
+	return (tag_csr & 0xffff) ? 1 : 0;
 }
 
 /**
@@ -842,7 +940,7 @@ rio_disc_peer(struct rio_net *net, struc
  *
  * Reads the port error status CSR for the master port to
  * determine if the port has an active link.  Returns
- * %PORT_N_ERR_STS_PORT_OK if the  master port is active
+ * %RIO_PORT_N_ERR_STS_PORT_OK if the  master port is active
  * or %0 if it is inactive.
  */
 static int rio_mport_is_active(struct rio_mport *port)
@@ -863,7 +961,7 @@ static int rio_mport_is_active(struct ri
 					 RIO_PORT_N_ERR_STS_CSR(port->index),
 					 &result);
 
-	return (result & PORT_N_ERR_STS_PORT_OK);
+	return result & RIO_PORT_N_ERR_STS_PORT_OK;
 }
 
 /**
@@ -930,6 +1028,32 @@ static void rio_update_route_tables(stru
 }
 
 /**
+ * rio_init_em - Initializes RIO Error Management (for switches)
+ * @port: Master port associated with the RIO network
+ *
+ * For each enumerated switch, call device-specific error management
+ * initialization routine (if supplied by the switch driver).
+ */
+static void rio_init_em(struct rio_dev *rdev)
+{
+	if (rio_is_switch(rdev) && (rdev->em_efptr) &&
+	    (rdev->rswitch->em_init)) {
+		rdev->rswitch->em_init(rdev);
+	}
+}
+
+/**
+ * rio_pw_enable - Enables/disables port-write handling by a master port
+ * @port: Master port associated with port-write handling
+ * @enable:  1=enable,  0=disable
+ */
+static void rio_pw_enable(struct rio_mport *port, int enable)
+{
+	if (port->ops->pwenable)
+		port->ops->pwenable(port, enable);
+}
+
+/**
  * rio_enum_mport- Start enumeration through a master port
  * @mport: Master port to send transactions
  *
@@ -972,6 +1096,7 @@ int __devinit rio_enum_mport(struct rio_
 		}
 		rio_update_route_tables(mport);
 		rio_clear_locks(mport);
+		rio_pw_enable(mport, 1);
 	} else {
 		printk(KERN_INFO "RIO: master port %d link inactive\n",
 		       mport->id);
drivers/rapidio/rio.c +307 -0

325 lines not on this page · raw message

drivers/rapidio/rio.h +29 -0
diff -x '*.pj' -X dontdiff_2.6.32-rc5 -pNur w33r7a/drivers/rapidio/rio.h w33r7b/drivers/rapidio/rio.h
@@ -18,6 +18,10 @@
 
 extern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid,
 				 u8 hopcount, int ftr);
+extern u32 rio_mport_get_physefb(struct rio_mport *port, int local,
+				 u16 destid, u8 hopcount);
+extern u32 rio_mport_get_efb(struct rio_mport *port, int local, u16 destid,
+			     u8 hopcount, u32 from);
 extern int rio_create_sysfs_dev_files(struct rio_dev *rdev);
 extern int rio_enum_mport(struct rio_mport *mport);
 extern int rio_disc_mport(struct rio_mport *mport);
@@ -61,3 +65,28 @@ extern struct rio_route_ops __end_rio_ro
 
 #define RIO_GET_DID(size, x)	(size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16))
 #define RIO_SET_DID(size, x)	(size ? (x & 0xffff) : ((x & 0x000000ff) << 16))
+
+/*
+ *   RapidIO Error Management
+ */
+extern struct rio_em_ops __start_rio_em_ops[];
+extern struct rio_em_ops __end_rio_em_ops[];
+
+/* Helpers internal to the RIO core code */
+#define DECLARE_RIO_EM_SECTION(section, name, vid, did, init_hook, em_hook)  \
+	static const struct rio_em_ops __rio_em_##name __used   \
+	__section(section) = { vid, did, init_hook, em_hook };
+
+/**
+ * DECLARE_RIO_EM_OPS - Registers switch EM operations
+ * @vid: RIO vendor ID
+ * @did: RIO device ID
+ * @init_hook: Callback that initializes device specific EM
+ * @em_hook: Callback that handles device specific EM
+ *
+ * A &struct rio_em_ops is initialized with the ops and placed into a
+ * RIO-specific kernel section.
+ */
+#define DECLARE_RIO_EM_OPS(vid, did, init_hook, em_hook)	\
+	DECLARE_RIO_EM_SECTION(.rio_em_ops, vid##did,		\
+			vid, did, init_hook, em_hook)
drivers/rapidio/switches/tsi568.c +24 -0
diff -x '*.pj' -X dontdiff_2.6.32-rc5 -pNur w33r7a/drivers/rapidio/switches/tsi568.c w33r7b/drivers/rapidio/switches/tsi568.c
@@ -25,6 +25,9 @@
 #define SPP_ROUTE_CFG_DESTID(n)	(0x11070 + 0x100*n)
 #define SPP_ROUTE_CFG_PORT(n)	(0x11074 + 0x100*n)
 
+#define TSI568_SP_MODE_BC	0x10004
+#define  TSI568_SP_MODE_PW_DIS	0x08000000
+
 static int
 tsi568_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount,
 		       u16 table, u16 route_destid, u8 route_port)
@@ -104,3 +107,24 @@ tsi568_route_clr_table(struct rio_mport 
 }
 
 DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI568, tsi568_route_add_entry, tsi568_route_get_entry, tsi568_route_clr_table);
+
+static int
+tsi568_em_init(struct rio_dev *rdev)
+{
+	struct rio_mport *mport = rdev->net->hport;
+	u16 destid = rdev->rswitch->destid;
+	u8 hopcount = rdev->rswitch->hopcount;
+	u32 regval;
+
+	pr_debug("TSI568 %s [%d:%d]\n", __func__, destid, hopcount);
+
+	/* Make sure that Port-Writes are disabled (for all ports) */
+	rio_mport_read_config_32(mport, destid, hopcount,
+			TSI568_SP_MODE_BC, &regval);
+	rio_mport_write_config_32(mport, destid, hopcount,
+			TSI568_SP_MODE_BC, regval | TSI568_SP_MODE_PW_DIS);
+
+	return 0;
+}
+
+DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI568, tsi568_em_init, NULL);
drivers/rapidio/switches/tsi57x.c +153 -0

162 lines not on this page · raw message

include/asm-generic/vmlinux.lds.h +4 -1
diff -x '*.pj' -X dontdiff_2.6.32-rc5 -pNur w33r7a/include/asm-generic/vmlinux.lds.h w33r7b/include/asm-generic/vmlinux.lds.h
@@ -247,10 +247,13 @@
 	}								\
 									\
 	/* RapidIO route ops */						\
-	.rio_route        : AT(ADDR(.rio_route) - LOAD_OFFSET) {	\
+	.rio_ops        : AT(ADDR(.rio_ops) - LOAD_OFFSET) {		\
 		VMLINUX_SYMBOL(__start_rio_route_ops) = .;		\
 		*(.rio_route_ops)					\
 		VMLINUX_SYMBOL(__end_rio_route_ops) = .;		\
+		VMLINUX_SYMBOL(__start_rio_em_ops) = .;			\
+		*(.rio_em_ops)						\
+		VMLINUX_SYMBOL(__end_rio_em_ops) = .;			\
 	}								\
 									\
 	TRACEDATA							\
include/linux/rio.h +30 -0
diff -x '*.pj' -X dontdiff_2.6.32-rc5 -pNur w33r7a/include/linux/rio.h w33r7b/include/linux/rio.h
@@ -64,6 +64,8 @@
 #define RIO_INB_MBOX_RESOURCE	1
 #define RIO_OUTB_MBOX_RESOURCE	2
 
+#define RIO_PW_MSG_SIZE		64
+
 extern struct bus_type rio_bus_type;
 extern struct list_head rio_devices;	/* list of all devices */
 
@@ -107,11 +109,15 @@ struct rio_dev {
 	u32 swpinfo;		/* Only used for switches */
 	u32 src_ops;
 	u32 dst_ops;
+	u32 comp_tag;
+	u32 phys_efptr;
+	u32 em_efptr;
 	u64 dma_mask;
 	struct rio_switch *rswitch;	/* RIO switch info */
 	struct rio_driver *driver;	/* RIO driver claiming this device */
 	struct device dev;	/* LDM device structure */
 	struct resource riores[RIO_MAX_DEV_RESOURCES];
+	int (*pwcback) (struct rio_dev *rdev, u32* msg, int step);
 	u16 destid;
 };
 
@@ -211,9 +217,12 @@ struct rio_net {
  * @hopcount: Hopcount to this switch
  * @destid: Associated destid in the path
  * @route_table: Copy of switch routing table
+ * @port_ok: Status of each port (one bit per port) - OK=1 or UNINIT=0
  * @add_entry: Callback for switch-specific route add function
  * @get_entry: Callback for switch-specific route get function
  * @clr_table: Callback for switch-specific clear route table function
+ * @em_init: Callback for switch-specific error management initialization function
+ * @em_handle: Callback for switch-specific error management handler function
  */
 struct rio_switch {
 	struct list_head node;
@@ -221,12 +230,15 @@ struct rio_switch {
 	u16 hopcount;
 	u16 destid;
 	u8 *route_table;
+	u32 port_ok;
 	int (*add_entry) (struct rio_mport * mport, u16 destid, u8 hopcount,
 			  u16 table, u16 route_destid, u8 route_port);
 	int (*get_entry) (struct rio_mport * mport, u16 destid, u8 hopcount,
 			  u16 table, u16 route_destid, u8 * route_port);
 	int (*clr_table) (struct rio_mport *mport, u16 destid, u8 hopcount,
 			  u16 table);
+	int (*em_init) (struct rio_dev *dev);
+	int (*em_handle) (struct rio_dev *dev, u8 swport);
 };
 
 /* Low-level architecture-dependent routines */
@@ -238,6 +250,7 @@ struct rio_switch {
  * @cread: Callback to perform network read of config space.
  * @cwrite: Callback to perform network write of config space.
  * @dsend: Callback to send a doorbell message.
+ * @pwenable: Callback to enable/disable port-write message handling.
  */
 struct rio_ops {
 	int (*lcread) (struct rio_mport *mport, int index, u32 offset, int len,
@@ -249,6 +262,7 @@ struct rio_ops {
 	int (*cwrite) (struct rio_mport *mport, int index, u16 destid,
 			u8 hopcount, u32 offset, int len, u32 data);
 	int (*dsend) (struct rio_mport *mport, int index, u16 destid, u16 data);
+	int (*pwenable) (struct rio_mport *mport, int enable);
 };
 
 #define RIO_RESOURCE_MEM	0x00000100
@@ -325,6 +339,22 @@ struct rio_route_ops {
 			 u16 table);
 };
 
+/**
+ * struct rio_em_ops - Per-switch error management operations
+ * @vid: RIO vendor ID
+ * @did: RIO device ID
+ * @init_hook: Switch specific error management initialization (may be NULL)
+ * @handler_hook: Switch specific error management handler (may be NULL)
+ *
+ * Defines the operations that are necessary to initialize and handle
+ * error management events for a particular RIO switch device.
+ */
+struct rio_em_ops {
+	u16 vid, did;
+	int (*init_hook) (struct rio_dev *dev);
+	int (*handler_hook) (struct rio_dev *dev, u8 swport);
+};
+
 /* Architecture and hardware-specific functions */
 extern int rio_init_mports(void);
 extern void rio_register_mport(struct rio_mport *);
include/linux/rio_drv.h +6 -0
diff -x '*.pj' -X dontdiff_2.6.32-rc5 -pNur w33r7a/include/linux/rio_drv.h w33r7b/include/linux/rio_drv.h
@@ -413,6 +413,12 @@ void rio_release_regions(struct rio_dev 
 int rio_request_region(struct rio_dev *, int, char *);
 void rio_release_region(struct rio_dev *, int);
 
+/* Port-Write management */
+extern int rio_request_inb_pwrite(struct rio_dev *,
+				  int (*)(struct rio_dev *, u32*, int));
+extern int rio_release_inb_pwrite(struct rio_dev *);
+extern int rio_inb_pwrite_handler(u32 *pw_msg);
+
 /* LDM support */
 int rio_register_driver(struct rio_driver *);
 void rio_unregister_driver(struct rio_driver *);
include/linux/rio_regs.h +57 -3

82 lines not on this page · raw message

---

Important Notice: This message is intended for the use of the individual to whom it is addressed and may contain information which is privileged, confidential and/or exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or is not the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by telephone or return e-mail and delete the original message from your systems. Thank you.

#1 lore raw
Quoted 7 lines · Alexandre Bounine

/**
+ * rio_em_set_ops- Sets Error Managment operations for a particular vendor switch
+ * @rdev: RIO device
+ *
+ * Searches the RIO EM ops table for known switch types. If the vid
+ * and did match a switch table entry, then set the em_init() and
+ * em_handle() ops to the table entry values.

Shouldn't any RIO device be able to support error management, not just switches?

drivers/rapidio/rio-scan.c static void rio_update_route_tables(stru · line 1055

Quoted 11 lines
drivers/rapidio/rio-scan.c +11 -0
+/**
+ * rio_pw_enable - Enables/disables port-write handling by a master port
+ * @port: Master port associated with port-write handling
+ * @enable:  1=enable,  0=disable
+ */
+static void rio_pw_enable(struct rio_mport *port, int enable)
+{
+	if (port->ops->pwenable)
+		port->ops->pwenable(port, enable);
+}
+

Maybe this can be done by switch->init function?

drivers/rapidio/rio.c int rio_release_outb_dbell(struct rio_de · line 472

Quoted 9 lines
drivers/rapidio/rio.c +9 -0
+/**
+ * rio_inb_pwrite_handler - process inbound port-write message
+ * @pw_msg: pointer to inbound port-write message
+ *
+ * Processes an inbound port-write message. Returns 0 if the request
+ * has been satisfied.
+ */
+int rio_inb_pwrite_handler(u32 *pw_msg)
+{

Perhaps map this pw_msg to a struct? Or read it into named variables?

drivers/rapidio/rio.c int rio_release_outb_dbell(struct rio_de · line 562

Quoted 4 lines
drivers/rapidio/rio.c +4 -0
+	/* Clear Port Errors */
+	rio_mport_write_config_32(mport, destid, hopcount,
+			rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum),
+			err_status & 0x07120204);

Hardcoded value!

drivers/rapidio/rio.c int rio_release_outb_dbell(struct rio_de · line 572

Quoted 10 lines
drivers/rapidio/rio.c +10 -0
+
+	if (rdev->rswitch->port_ok & (1 << portnum)) {
+		if (err_status & RIO_PORT_N_ERR_STS_PORT_UNINIT) {
+			rdev->rswitch->port_ok &= ~(1 << portnum);
+			rio_mport_read_config_32(mport, destid, hopcount,
+				rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
+				&regval);
+			rio_mport_write_config_32(mport, destid, hopcount,
+				rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
+				regval | RIO_PORT_N_CTL_LOCKOUT);

You have a function for this?

drivers/rapidio/rio.c int rio_release_outb_dbell(struct rio_de · line 577

Quoted 4 lines
drivers/rapidio/rio.c +4 -0
+			rio_mport_write_config_32(mport, destid, hopcount,
+				rdev->phys_efptr +
+					RIO_PORT_N_ACK_STS_CSR(portnum),
+				RIO_PORT_N_ACK_CLEAR);

This doesn't work for the 568; but the 568 has no special handling?

drivers/rapidio/switches/tsi57x.c DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RI · line 259

Quoted 8 lines
drivers/rapidio/switches/tsi57x.c +8 -0
+	/* Clear Port-Write Pending bit */
+	rio_mport_write_config_32(mport, destid, hopcount,
+			rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum),
+			RIO_PORT_N_ERR_STS_PW_PEND);
+DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI572, tsi57x_em_init, tsi57x_em_handler);
+DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI574, tsi57x_em_init, tsi57x_em_handler);
+DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI577, tsi57x_em_init, tsi57x_em_handler);
+DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI578, tsi57x_em_init, tsi57x_em_handler);

Why not declare these along with the other ops?

Micha

#2 lore raw
Quoted 4 lines · Micha Nelissen

=20

Quoted 2 lines · Alexandre Bounine

/**
+ * rio_em_set_ops- Sets Error Managment operations for a particular

vendor switch

Quoted 8 lines
Quoted 5 lines

+ * @rdev: RIO device
+ *
+ * Searches the RIO EM ops table for known switch types. If the vid
+ * and did match a switch table entry, then set the em_init() and
+ * em_handle() ops to the table entry values.

=20
Shouldn't any RIO device be able to support error management, not just switches?

Only if a device reports this capability by having Error Management Extended Features block.
Ideally, we have to provide default handler for every such device (I am planning it for some future updates). It should be the same as for routing operations - if the standard feature exists, it has to be used unless something else takes over.

For now I keep all port-write messages from end-points serviced by their individual drivers. One of reasons for this: the EM PW message format definitions lacks any hint that allows to identify type of the message. In theory endpoints may send port-writes of any format (up to max size of 64 bytes), what makes unifying handling of endpoints more difficult
(at least at this stage of SRIO evolution). =20
=20

Quoted 2 lines
Quoted 2 lines

+/**
+ * rio_pw_enable - Enables/disables port-write handling by a master

port

Quoted 11 lines

drivers/rapidio/rio-scan.c static void rio_update_route_tables(stru · line 1055

Quoted 9 lines

+ * @port: Master port associated with port-write handling
+ * @enable: 1=3Denable, 0=3Ddisable
+ */

drivers/rapidio/rio-scan.c +6 -0
+static void rio_pw_enable(struct rio_mport *port, int enable)
+{
+	if (port->ops->pwenable)
+		port->ops->pwenable(port, enable);
+}
+

=20
Maybe this can be done by switch->init function?

This is not per-switch function. This function enables mport to receive incoming PW messages. Per-switch PW enable is done in switch->init as for Tsi57x.=20

Quoted 6 lines

=20

Quoted 5 lines

+/**
+ * rio_inb_pwrite_handler - process inbound port-write message
+ * @pw_msg: pointer to inbound port-write message
+ *
+ * Processes an inbound port-write message. Returns 0 if the

request

Quoted 6 lines

Review

Quoted 4 lines

+ * has been satisfied.
+ */

(quoted diff) +2 -0
+int rio_inb_pwrite_handler(u32 *pw_msg)
+{

=20
Perhaps map this pw_msg to a struct? Or read it into named variables?

Agree - this is not nice. The best way may be defining it as a union which combines different message formats (EM at this point) and raw array. Will change for next update.

Quoted 4 lines

=20

drivers/rapidio/rio.c int rio_release_outb_dbell(struct rio_de · line 575

Quoted 3 lines
drivers/rapidio/rio.c +3 -0
+	/* Clear Port Errors */
+	rio_mport_write_config_32(mport, destid, hopcount,
+			rdev->phys_efptr +

RIO_PORT_N_ERR_STS_CSR(portnum),

Quoted 3 lines

drivers/rapidio/rio.c int rio_release_outb_dbell(struct rio_de · line 562

Quoted 1 line
drivers/rapidio/rio.c +1 -0
+			err_status & 0x07120204);

=20
Hardcoded value!

Agree. Tagged for next drop.

Quoted 6 lines

=20

drivers/rapidio/rio.c int rio_release_outb_dbell(struct rio_de

Quoted 5 lines
drivers/rapidio/rio.c +5 -0
+
+	if (rdev->rswitch->port_ok & (1 << portnum)) {
+		if (err_status & RIO_PORT_N_ERR_STS_PORT_UNINIT) {
+			rdev->rswitch->port_ok &=3D ~(1 << portnum);
+			rio_mport_read_config_32(mport, destid,

hopcount,

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+				rdev->phys_efptr +

RIO_PORT_N_CTL_CSR(portnum),

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+				&regval);
+			rio_mport_write_config_32(mport, destid,

hopcount,

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+				rdev->phys_efptr +

RIO_PORT_N_CTL_CSR(portnum),

Quoted 3 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+				regval | RIO_PORT_N_CTL_LOCKOUT);

=20
You have a function for this?

Yes, I do. Will be fixed for the next drop.

Quoted 2 lines

=20

Review

Quoted 1 line
(quoted diff) +1 -0
+			rio_mport_write_config_32(mport, destid,

hopcount,

Quoted 5 lines

drivers/rapidio/rio.c int rio_release_outb_dbell(struct rio_de · line 577

Quoted 3 lines
drivers/rapidio/rio.c +3 -0
+				rdev->phys_efptr +
+					RIO_PORT_N_ACK_STS_CSR(portnum),
+				RIO_PORT_N_ACK_CLEAR);

=20
This doesn't work for the 568; but the 568 has no special handling?

Tsi568 will not send EM PW message. Tsi568 PWs are disabled in its em_init().

Quoted 4 lines

=20

drivers/rapidio/rio.c int rio_release_outb_dbell(struct rio_de

Quoted 3 lines
drivers/rapidio/rio.c +3 -0
+	/* Clear Port-Write Pending bit */
+	rio_mport_write_config_32(mport, destid, hopcount,
+			rdev->phys_efptr +

RIO_PORT_N_ERR_STS_CSR(portnum),

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+			RIO_PORT_N_ERR_STS_PW_PEND);
+DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI572, tsi57x_em_init,

tsi57x_em_handler);

Quoted 1 line
Quoted 1 line

+DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI574, tsi57x_em_init,

tsi57x_em_handler);

Quoted 1 line
Quoted 1 line

+DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI577, tsi57x_em_init,

tsi57x_em_handler);

Quoted 1 line
Quoted 1 line

+DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI578, tsi57x_em_init,

tsi57x_em_handler);

Quoted 2 lines

=20
Why not declare these along with the other ops?

Because the EM extensions is a separate capability. It is not guaranteed to be in every switch.

Alex.

#3 lore raw
Quoted 13 lines · Alexandre
Quoted 3 lines · Micha Nelissen
Quoted 2 lines · Alexandre Bounine

/**
+ * rio_em_set_ops- Sets Error Managment operations for a particular

vendor switch

Quoted 7 lines
Quoted 5 lines

+ * @rdev: RIO device
+ *
+ * Searches the RIO EM ops table for known switch types. If the vid
+ * and did match a switch table entry, then set the em_init() and
+ * em_handle() ops to the table entry values.

Shouldn't any RIO device be able to support error management, not just switches?

Quoted 6 lines

Only if a device reports this capability by having Error Management Extended Features block.
Ideally, we have to provide default handler for every such device (I am planning it for some future updates). It should be the same as for routing operations - if the standard feature exists, it has to be used unless something else takes over.

Yes, therefore I thought that: or the EM_OPS are per driver, or they can be integrated in the switch hooks list.

Quoted 2 lines

For now I keep all port-write messages from end-points serviced by their individual drivers. One of reasons for this: the EM PW message format

Maybe have a generic rio function that can be called by any driver that knows a particular port-write was due to error management causes? This function would read the standard defined EF block registers. Then the driver part can be quite small.

Quoted 9 lines
Quoted 5 lines

drivers/rapidio/rio-scan.c static void rio_update_route_tables(stru · line 1055

Quoted 4 lines
drivers/rapidio/rio-scan.c +4 -0
+	if (port->ops->pwenable)
+		port->ops->pwenable(port, enable);
+}
+

Maybe this can be done by switch->init function?

This is not per-switch function. This function enables mport to receive incoming PW messages. Per-switch PW enable is done in switch->init as for Tsi57x.

Oops, I meant this comment for the em_init function call.

Quoted 9 lines
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+			rio_mport_write_config_32(mport, destid,

hopcount,

Quoted 4 lines

drivers/rapidio/rio.c int rio_release_outb_dbell(struct rio_de · line 577

Quoted 3 lines
drivers/rapidio/rio.c +3 -0
+				rdev->phys_efptr +
+					RIO_PORT_N_ACK_STS_CSR(portnum),
+				RIO_PORT_N_ACK_CLEAR);

This doesn't work for the 568; but the 568 has no special handling?

Tsi568 will not send EM PW message. Tsi568 PWs are disabled in its em_init().

Why?

Quoted 6 lines
Quoted 1 line
Quoted 1 line

+DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI578, tsi57x_em_init,

tsi57x_em_handler);

Quoted 1 line

Why not declare these along with the other ops?

Because the EM extensions is a separate capability. It is not guaranteed to be in every switch.

They might initialize them with NULL to indicate they don't support it?

Micha

#4 lore raw
Quoted 5 lines · Micha Nelissen
Quoted 4 lines · Alexandre
Quoted 3 lines · Micha Nelissen
Quoted 2 lines · Alexandre Bounine

/**
+ * rio_em_set_ops- Sets Error Managment operations for a

particular

Quoted 4 lines
Quoted 4 lines

vendor switch

Quoted 3 lines
Quoted 3 lines

+ * @rdev: RIO device
+ *
+ * Searches the RIO EM ops table for known switch types. If the

vid

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

+ * and did match a switch table entry, then set the em_init() and
+ * em_handle() ops to the table entry values.

Shouldn't any RIO device be able to support error management, not

just

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

switches?

Only if a device reports this capability by having Error Management Extended Features block.
Ideally, we have to provide default handler for every such device (I

am

Quoted 2 lines
Quoted 2 lines

planning it for some future updates). It should be the same as for routing operations - if the standard feature exists, it has to be

used

Quoted 3 lines
Quoted 1 line

unless something else takes over.

=20
Yes, therefore I thought that: or the EM_OPS are per driver, or they

can

Quoted 1 line

be integrated in the switch hooks list.

Or combination of both methods as I implemented it. I want to have it flexible enough to be adopted to further development of RapidIO ecosystem. =20
=20

Quoted 1 line
Quoted 1 line

For now I keep all port-write messages from end-points serviced by

their

Quoted 1 line
Quoted 1 line

individual drivers. One of reasons for this: the EM PW message

format

Quoted 2 lines

=20
Maybe have a generic rio function that can be called by any driver

that

Quoted 3 lines

knows a particular port-write was due to error management causes? This function would read the standard defined EF block registers. Then the driver part can be quite small.

I think this echoes what I mentioned above as default handler.

Quoted 8 lines

=20

Quoted 7 lines
Quoted 5 lines

drivers/rapidio/rio-scan.c static void rio_update_route_tables(stru · line 1055

Quoted 4 lines
drivers/rapidio/rio-scan.c +4 -0
+	if (port->ops->pwenable)
+		port->ops->pwenable(port, enable);
+}
+

Maybe this can be done by switch->init function?

This is not per-switch function. This function enables mport to

receive

Quoted 1 line
Quoted 1 line

incoming PW messages. Per-switch PW enable is done in switch->init

as

Quoted 11 lines
Quoted 1 line

for Tsi57x.

=20
Oops, I meant this comment for the em_init function call. =20

Quoted 7 lines
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+			rio_mport_write_config_32(mport, destid,

hopcount,

Quoted 4 lines

drivers/rapidio/rio.c int rio_release_outb_dbell(struct rio_de · line 577

Quoted 3 lines
drivers/rapidio/rio.c +3 -0
+				rdev->phys_efptr +
+					RIO_PORT_N_ACK_STS_CSR(portnum),
+				RIO_PORT_N_ACK_CLEAR);

This doesn't work for the 568; but the 568 has no special handling?

Quoted 4 lines
Quoted 2 lines

Tsi568 will not send EM PW message. Tsi568 PWs are disabled in its em_init().

=20
Why?

Because Tsi568 requires special handling which is not implemented (yet?).=20
=20

Quoted 2 lines

=20

Quoted 1 line
Quoted 1 line
Quoted 1 line

+DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI578,

tsi57x_em_init,

Quoted 4 lines
Quoted 4 lines

tsi57x_em_handler);

Quoted 1 line

Why not declare these along with the other ops?

Because the EM extensions is a separate capability. It is not

guaranteed

Quoted 3 lines
Quoted 1 line

to be in every switch.

=20
They might initialize them with NULL to indicate they don't support

it?

My preference is to keep unrelated capabilities separately. Otherwise, these long ops lists may become unmanageable later when new extensions will be added into RIO spec.

Cheers,

Alex.