Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Apr 2011 01:21:02 +0000 (UTC)
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r220509 - stable/8/sys/dev/cxgbe
Message-ID:  <201104100121.p3A1L2r0031072@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: np
Date: Sun Apr 10 01:21:02 2011
New Revision: 220509
URL: http://svn.freebsd.org/changeset/base/220509

Log:
  MFC r220410
  
  Modify read/write ioctls to work with 64 bit registers too.

Modified:
  stable/8/sys/dev/cxgbe/t4_ioctl.h
  stable/8/sys/dev/cxgbe/t4_main.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/dev/cxgbe/t4_ioctl.h
==============================================================================
--- stable/8/sys/dev/cxgbe/t4_ioctl.h	Sun Apr 10 00:29:00 2011	(r220508)
+++ stable/8/sys/dev/cxgbe/t4_ioctl.h	Sun Apr 10 01:21:02 2011	(r220509)
@@ -35,24 +35,25 @@
  * Ioctl commands specific to this driver.
  */
 enum {
-	T4_GET32 = 0x40,		/* read 32 bit register */
-	T4_SET32,			/* write 32 bit register */
+	T4_GETREG = 0x40,		/* read register */
+	T4_SETREG,			/* write register */
 	T4_REGDUMP,			/* dump of all registers */
 };
 
-struct t4_reg32 {
+struct t4_reg {
 	uint32_t addr;
-	uint32_t val;
+	uint32_t size;
+	uint64_t val;
 };
 
 #define T4_REGDUMP_SIZE  (160 * 1024)
 struct t4_regdump {
-	uint32_t  version;
-	uint32_t  len; /* bytes */
-	uint8_t   *data;
+	uint32_t version;
+	uint32_t len; /* bytes */
+	uint32_t *data;
 };
 
-#define CHELSIO_T4_GETREG32	_IOWR('f', T4_GET32, struct t4_reg32)
-#define CHELSIO_T4_SETREG32	_IOW('f', T4_SET32, struct t4_reg32)
+#define CHELSIO_T4_GETREG	_IOWR('f', T4_GETREG, struct t4_reg)
+#define CHELSIO_T4_SETREG	_IOW('f', T4_SETREG, struct t4_reg)
 #define CHELSIO_T4_REGDUMP	_IOWR('f', T4_REGDUMP, struct t4_regdump)
 #endif

Modified: stable/8/sys/dev/cxgbe/t4_main.c
==============================================================================
--- stable/8/sys/dev/cxgbe/t4_main.c	Sun Apr 10 00:29:00 2011	(r220508)
+++ stable/8/sys/dev/cxgbe/t4_main.c	Sun Apr 10 01:21:02 2011	(r220509)
@@ -2803,18 +2803,35 @@ t4_ioctl(struct cdev *dev, unsigned long
 		return (rc);
 
 	switch (cmd) {
-	case CHELSIO_T4_GETREG32: {
-		struct t4_reg32 *edata = (struct t4_reg32 *)data;
+	case CHELSIO_T4_GETREG: {
+		struct t4_reg *edata = (struct t4_reg *)data;
+
 		if ((edata->addr & 0x3) != 0 || edata->addr >= sc->mmio_len)
 			return (EFAULT);
-		edata->val = t4_read_reg(sc, edata->addr);
+
+		if (edata->size == 4)
+			edata->val = t4_read_reg(sc, edata->addr);
+		else if (edata->size == 8)
+			edata->val = t4_read_reg64(sc, edata->addr);
+		else
+			return (EINVAL);
+
 		break;
 	}
-	case CHELSIO_T4_SETREG32: {
-		struct t4_reg32 *edata = (struct t4_reg32 *)data;
+	case CHELSIO_T4_SETREG: {
+		struct t4_reg *edata = (struct t4_reg *)data;
+
 		if ((edata->addr & 0x3) != 0 || edata->addr >= sc->mmio_len)
 			return (EFAULT);
-		t4_write_reg(sc, edata->addr, edata->val);
+
+		if (edata->size == 4) {
+			if (edata->val & 0xffffffff00000000)
+				return (EINVAL);
+			t4_write_reg(sc, edata->addr, (uint32_t) edata->val);
+		} else if (edata->size == 8)
+			t4_write_reg64(sc, edata->addr, edata->val);
+		else
+			return (EINVAL);
 		break;
 	}
 	case CHELSIO_T4_REGDUMP: {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104100121.p3A1L2r0031072>