Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Jun 2011 04:20:17 +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: r223066 - stable/8/sys/dev/cxgbe
Message-ID:  <201106140420.p5E4KHQQ013066@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: np
Date: Tue Jun 14 04:20:17 2011
New Revision: 223066
URL: http://svn.freebsd.org/changeset/base/223066

Log:
  MFC r222973:
  
  - driver ioctl to get SGE context for any given queue
  - sysctls to display the context id, cidx, and pidx of all kinds of queues.

Modified:
  stable/8/sys/dev/cxgbe/adapter.h
  stable/8/sys/dev/cxgbe/t4_ioctl.h
  stable/8/sys/dev/cxgbe/t4_main.c
  stable/8/sys/dev/cxgbe/t4_sge.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/adapter.h
==============================================================================
--- stable/8/sys/dev/cxgbe/adapter.h	Tue Jun 14 04:02:30 2011	(r223065)
+++ stable/8/sys/dev/cxgbe/adapter.h	Tue Jun 14 04:20:17 2011	(r223066)
@@ -307,7 +307,7 @@ struct sge_eq {
 	uint16_t pidx;		/* producer idx (desc idx) */
 	uint16_t pending;	/* # of descriptors used since last doorbell */
 	uint16_t iqid;		/* iq that gets egr_update for the eq */
-	uint32_t cntxt_id;	/* SGE context id for the eq */
+	unsigned int  cntxt_id;	/* SGE context id for the eq */
 };
 
 struct sge_fl {

Modified: stable/8/sys/dev/cxgbe/t4_ioctl.h
==============================================================================
--- stable/8/sys/dev/cxgbe/t4_ioctl.h	Tue Jun 14 04:02:30 2011	(r223065)
+++ stable/8/sys/dev/cxgbe/t4_ioctl.h	Tue Jun 14 04:20:17 2011	(r223066)
@@ -46,6 +46,7 @@ enum {
 	T4_GET_FILTER,			/* get information about a filter */
 	T4_SET_FILTER,			/* program a filter */
 	T4_DEL_FILTER,			/* delete a filter */
+	T4_GET_SGE_CONTEXT,		/* get SGE context for a queue */
 };
 
 struct t4_reg {
@@ -184,6 +185,20 @@ struct t4_filter {
 	struct t4_filter_specification fs;
 };
 
+#define T4_SGE_CONTEXT_SIZE 24
+enum {
+	SGE_CONTEXT_EGRESS,
+	SGE_CONTEXT_INGRESS,
+	SGE_CONTEXT_FLM,
+	SGE_CONTEXT_CNM
+};
+
+struct t4_sge_context {
+	uint32_t mem_id;
+	uint32_t cid;
+	uint32_t data[T4_SGE_CONTEXT_SIZE / 4];
+};
+
 #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)
@@ -192,4 +207,6 @@ struct t4_filter {
 #define CHELSIO_T4_GET_FILTER	_IOWR('f', T4_GET_FILTER, struct t4_filter)
 #define CHELSIO_T4_SET_FILTER	_IOW('f', T4_SET_FILTER, struct t4_filter)
 #define CHELSIO_T4_DEL_FILTER	_IOW('f', T4_DEL_FILTER, struct t4_filter)
+#define CHELSIO_T4_GET_SGE_CONTEXT _IOWR('f', T4_GET_SGE_CONTEXT, \
+    struct t4_sge_context)
 #endif

Modified: stable/8/sys/dev/cxgbe/t4_main.c
==============================================================================
--- stable/8/sys/dev/cxgbe/t4_main.c	Tue Jun 14 04:02:30 2011	(r223065)
+++ stable/8/sys/dev/cxgbe/t4_main.c	Tue Jun 14 04:20:17 2011	(r223066)
@@ -315,6 +315,7 @@ static void clear_filter(struct filter_e
 static int set_filter_wr(struct adapter *, int);
 static int del_filter_wr(struct adapter *, int);
 void filter_rpl(struct adapter *, const struct cpl_set_tcb_rpl *);
+static int get_sge_context(struct adapter *, struct t4_sge_context *);
 static int t4_mod_event(module_t, int, void *);
 
 struct t4_pciids {
@@ -3423,6 +3424,35 @@ filter_rpl(struct adapter *sc, const str
 	}
 }
 
+static int
+get_sge_context(struct adapter *sc, struct t4_sge_context *cntxt)
+{
+	int rc = EINVAL;
+
+	if (cntxt->cid > M_CTXTQID)
+		return (rc);
+
+	if (cntxt->mem_id != CTXT_EGRESS && cntxt->mem_id != CTXT_INGRESS &&
+	    cntxt->mem_id != CTXT_FLM && cntxt->mem_id != CTXT_CNM)
+		return (rc);
+
+	if (sc->flags & FW_OK) {
+		ADAPTER_LOCK(sc);	/* Avoid parallel t4_wr_mbox */
+		rc = -t4_sge_ctxt_rd(sc, sc->mbox, cntxt->cid, cntxt->mem_id,
+		    &cntxt->data[0]);
+		ADAPTER_UNLOCK(sc);
+	}
+
+	if (rc != 0) {
+		/* Read via firmware failed or wasn't even attempted */
+
+		rc = -t4_sge_ctxt_rd_bd(sc, cntxt->cid, cntxt->mem_id,
+		    &cntxt->data[0]);
+	}
+
+	return (rc);
+}
+
 int
 t4_os_find_pci_capability(struct adapter *sc, int cap)
 {
@@ -3586,6 +3616,9 @@ t4_ioctl(struct cdev *dev, unsigned long
 		rc = del_filter(sc, (struct t4_filter *)data);
 		ADAPTER_UNLOCK(sc);
 		break;
+	case CHELSIO_T4_GET_SGE_CONTEXT:
+		rc = get_sge_context(sc, (struct t4_sge_context *)data);
+		break;
 	default:
 		rc = EINVAL;
 	}

Modified: stable/8/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- stable/8/sys/dev/cxgbe/t4_sge.c	Tue Jun 14 04:02:30 2011	(r223065)
+++ stable/8/sys/dev/cxgbe/t4_sge.c	Tue Jun 14 04:20:17 2011	(r223066)
@@ -1368,6 +1368,12 @@ alloc_fwq(struct adapter *sc, int intr_i
 
 	children = SYSCTL_CHILDREN(sc->oid_fwq);
 
+	SYSCTL_ADD_PROC(&sc->ctx, children, OID_AUTO, "abs_id",
+	    CTLTYPE_INT | CTLFLAG_RD, &fwq->abs_id, 0, sysctl_uint16, "I",
+	    "absolute id of the queue");
+	SYSCTL_ADD_PROC(&sc->ctx, children, OID_AUTO, "cntxt_id",
+	    CTLTYPE_INT | CTLFLAG_RD, &fwq->cntxt_id, 0, sysctl_uint16, "I",
+	    "SGE context id of the queue");
 	SYSCTL_ADD_PROC(&sc->ctx, children, OID_AUTO, "cidx",
 	    CTLTYPE_INT | CTLFLAG_RD, &fwq->cidx, 0, sysctl_uint16, "I",
 	    "consumer index");
@@ -1418,6 +1424,12 @@ alloc_rxq(struct port_info *pi, struct s
 	SYSCTL_ADD_PROC(&pi->ctx, children, OID_AUTO, "abs_id",
 	    CTLTYPE_INT | CTLFLAG_RD, &rxq->iq.abs_id, 0, sysctl_uint16, "I",
 	    "absolute id of the queue");
+	SYSCTL_ADD_PROC(&pi->ctx, children, OID_AUTO, "cntxt_id",
+	    CTLTYPE_INT | CTLFLAG_RD, &rxq->iq.cntxt_id, 0, sysctl_uint16, "I",
+	    "SGE context id of the queue");
+	SYSCTL_ADD_PROC(&pi->ctx, children, OID_AUTO, "cidx",
+	    CTLTYPE_INT | CTLFLAG_RD, &rxq->iq.cidx, 0, sysctl_uint16, "I",
+	    "consumer index");
 #ifdef INET
 	SYSCTL_ADD_INT(&pi->ctx, children, OID_AUTO, "lro_queued", CTLFLAG_RD,
 	    &rxq->lro.lro_queued, 0, NULL);
@@ -1430,6 +1442,19 @@ alloc_rxq(struct port_info *pi, struct s
 	    CTLFLAG_RD, &rxq->vlan_extraction,
 	    "# of times hardware extracted 802.1Q tag");
 
+	children = SYSCTL_CHILDREN(oid);
+	oid = SYSCTL_ADD_NODE(&pi->ctx, children, OID_AUTO, "fl", CTLFLAG_RD,
+	    NULL, "freelist");
+	children = SYSCTL_CHILDREN(oid);
+
+	SYSCTL_ADD_PROC(&pi->ctx, children, OID_AUTO, "cntxt_id",
+	    CTLTYPE_INT | CTLFLAG_RD, &rxq->fl.cntxt_id, 0, sysctl_uint16, "I",
+	    "SGE context id of the queue");
+	SYSCTL_ADD_UINT(&pi->ctx, children, OID_AUTO, "cidx", CTLFLAG_RD,
+	    &rxq->fl.cidx, 0, "consumer index");
+	SYSCTL_ADD_UINT(&pi->ctx, children, OID_AUTO, "pidx", CTLFLAG_RD,
+	    &rxq->fl.pidx, 0, "producer index");
+
 	return (rc);
 }
 
@@ -1652,6 +1677,15 @@ alloc_txq(struct port_info *pi, struct s
 	    NULL, "tx queue");
 	children = SYSCTL_CHILDREN(oid);
 
+	SYSCTL_ADD_UINT(&pi->ctx, children, OID_AUTO, "cntxt_id", CTLFLAG_RD,
+	    &eq->cntxt_id, 0, "SGE context id of the queue");
+	SYSCTL_ADD_PROC(&pi->ctx, children, OID_AUTO, "cidx",
+	    CTLTYPE_INT | CTLFLAG_RD, &eq->cidx, 0, sysctl_uint16, "I",
+	    "consumer index");
+	SYSCTL_ADD_PROC(&pi->ctx, children, OID_AUTO, "pidx",
+	    CTLTYPE_INT | CTLFLAG_RD, &eq->pidx, 0, sysctl_uint16, "I",
+	    "producer index");
+
 	SYSCTL_ADD_UQUAD(&pi->ctx, children, OID_AUTO, "txcsum", CTLFLAG_RD,
 	    &txq->txcsum, "# of times hardware assisted with checksum");
 	SYSCTL_ADD_UQUAD(&pi->ctx, children, OID_AUTO, "vlan_insertion",



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