From: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Dean Luick <dean.luick-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 18/21] IB/hfi1: Extract RSM map table init from QOS
Date: Tue, 12 Apr 2016 11:30:51 -0700 [thread overview]
Message-ID: <20160412183043.27656.49185.stgit@scvm10.sc.intel.com> (raw)
In-Reply-To: <20160412174746.24485.92280.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
From: Dean Luick <dean.luick-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Refactor the allocation, tracking, and writing of the RSM map table
into its own set of routines. This will allow the map table to be
passed to multiple users to fill in as needed. Start with the original
user, QOS.
Reviewed-by: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Dean Luick <dean.luick-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
drivers/staging/rdma/hfi1/chip.c | 91 ++++++++++++++++++++++------
drivers/staging/rdma/hfi1/chip_registers.h | 1
2 files changed, 71 insertions(+), 21 deletions(-)
diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 96badb4..234c078 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -123,6 +123,8 @@ struct flag_table {
#define MIN_KERNEL_KCTXTS 2
#define FIRST_KERNEL_KCTXT 1
+/* sizes for both the QP and RSM map tables */
+#define NUM_MAP_ENTRIES 256
#define NUM_MAP_REGS 32
/* Bit offset into the GUID which carries HFI id information */
@@ -13422,9 +13424,52 @@ static void init_qpmap_table(struct hfi1_devdata *dd,
| RCV_CTRL_RCV_BYPASS_ENABLE_SMASK);
}
+struct rsm_map_table {
+ u64 map[NUM_MAP_REGS];
+ unsigned int used;
+};
+
+/*
+ * Return an initialized RMT map table for users to fill in. OK if it
+ * returns NULL, indicating no table.
+ */
+static struct rsm_map_table *alloc_rsm_map_table(struct hfi1_devdata *dd)
+{
+ struct rsm_map_table *rmt;
+ u8 rxcontext = is_ax(dd) ? 0 : 0xff; /* 0 is default if a0 ver. */
+
+ rmt = kmalloc(sizeof(*rmt), GFP_KERNEL);
+ if (rmt) {
+ memset(rmt->map, rxcontext, sizeof(rmt->map));
+ rmt->used = 0;
+ }
+
+ return rmt;
+}
+
+/*
+ * Write the final RMT map table to the chip and free the table. OK if
+ * table is NULL.
+ */
+static void complete_rsm_map_table(struct hfi1_devdata *dd,
+ struct rsm_map_table *rmt)
+{
+ int i;
+
+ if (rmt) {
+ /* write table to chip */
+ for (i = 0; i < NUM_MAP_REGS; i++)
+ write_csr(dd, RCV_RSM_MAP_TABLE + (8 * i), rmt->map[i]);
+
+ /* enable RSM */
+ add_rcvctrl(dd, RCV_CTRL_RCV_RSM_ENABLE_SMASK);
+ }
+}
+
/**
* init_qos - init RX qos
* @dd - device data
+ * @rmt - RSM map table
*
* This routine initializes Rule 0 and the RSM map table to implement
* quality of service (qos).
@@ -13435,16 +13480,16 @@ static void init_qpmap_table(struct hfi1_devdata *dd,
* The number of vl bits (n) and the number of qpn bits (m) are computed to
* feed both the RSM map table and the single rule.
*/
-static void init_qos(struct hfi1_devdata *dd)
+static void init_qos(struct hfi1_devdata *dd, struct rsm_map_table *rmt)
{
u8 max_by_vl = 0;
unsigned qpns_per_vl, ctxt, i, qpn, n = 1, m;
- u64 *rsmmap;
+ unsigned int rmt_entries;
u64 reg;
- u8 rxcontext = is_ax(dd) ? 0 : 0xff; /* 0 is default if a0 ver. */
/* validate */
- if (dd->n_krcv_queues <= MIN_KERNEL_KCTXTS ||
+ if (!rmt ||
+ dd->n_krcv_queues <= MIN_KERNEL_KCTXTS ||
num_vls == 1 ||
krcvqsset <= 1)
goto bail;
@@ -13460,11 +13505,11 @@ static void init_qos(struct hfi1_devdata *dd)
m = ilog2(qpns_per_vl);
if ((m + n) > 7)
goto bail;
- rsmmap = kmalloc_array(NUM_MAP_REGS, sizeof(u64), GFP_KERNEL);
- if (!rsmmap)
+ /* enough room in the map table? */
+ rmt_entries = 1 << (m + n);
+ if (rmt->used + rmt_entries >= NUM_MAP_ENTRIES)
goto bail;
- memset(rsmmap, rxcontext, NUM_MAP_REGS * sizeof(u64));
- /* init the local copy of the table */
+ /* add qos entries to the the RSM map table */
for (i = 0, ctxt = FIRST_KERNEL_KCTXT; i < num_vls; i++) {
unsigned tctxt;
@@ -13472,26 +13517,24 @@ static void init_qos(struct hfi1_devdata *dd)
krcvqs[i] && qpn < qpns_per_vl; qpn++) {
unsigned idx, regoff, regidx;
- /* generate index <= 128 */
- idx = (qpn << n) ^ i;
+ /* generate the index the hardware will produce */
+ idx = rmt->used + ((qpn << n) ^ i);
regoff = (idx % 8) * 8;
regidx = idx / 8;
- reg = rsmmap[regidx];
- /* replace 0xff with context number */
+ /* replace default with context number */
+ reg = rmt->map[regidx];
reg &= ~(RCV_RSM_MAP_TABLE_RCV_CONTEXT_A_MASK
<< regoff);
reg |= (u64)(tctxt++) << regoff;
- rsmmap[regidx] = reg;
+ rmt->map[regidx] = reg;
if (tctxt == ctxt + krcvqs[i])
tctxt = ctxt;
}
ctxt += krcvqs[i];
}
- /* flush cached copies to chip */
- for (i = 0; i < NUM_MAP_REGS; i++)
- write_csr(dd, RCV_RSM_MAP_TABLE + (8 * i), rsmmap[i]);
/* add rule0 */
write_csr(dd, RCV_RSM_CFG /* + (8 * 0) */,
+ (u64)rmt->used << RCV_RSM_CFG_OFFSET_SHIFT |
RCV_RSM_CFG_ENABLE_OR_CHAIN_RSM0_MASK <<
RCV_RSM_CFG_ENABLE_OR_CHAIN_RSM0_SHIFT |
2ull << RCV_RSM_CFG_PACKET_TYPE_SHIFT);
@@ -13507,9 +13550,8 @@ static void init_qos(struct hfi1_devdata *dd)
LRH_BTH_VALUE << RCV_RSM_MATCH_VALUE1_SHIFT |
LRH_SC_MASK << RCV_RSM_MATCH_MASK2_SHIFT |
LRH_SC_VALUE << RCV_RSM_MATCH_VALUE2_SHIFT);
- /* Enable RSM */
- add_rcvctrl(dd, RCV_CTRL_RCV_RSM_ENABLE_SMASK);
- kfree(rsmmap);
+ /* mark RSM map entries as used */
+ rmt->used += rmt_entries;
/* map everything else to the mcast/err/vl15 context */
init_qpmap_table(dd, HFI1_CTRL_CTXT, HFI1_CTRL_CTXT);
dd->qos_shift = n + 1;
@@ -13521,10 +13563,17 @@ bail:
static void init_rxe(struct hfi1_devdata *dd)
{
+ struct rsm_map_table *rmt;
+
/* enable all receive errors */
write_csr(dd, RCV_ERR_MASK, ~0ull);
- /* setup QPN map table - start where VL15 context leaves off */
- init_qos(dd);
+
+ rmt = alloc_rsm_map_table(dd);
+ /* set up QOS, including the QPN map table */
+ init_qos(dd, rmt);
+ complete_rsm_map_table(dd, rmt);
+ kfree(rmt);
+
/*
* make sure RcvCtrl.RcvWcb <= PCIe Device Control
* Register Max_Payload_Size (PCI_EXP_DEVCTL in Linux PCIe config
diff --git a/drivers/staging/rdma/hfi1/chip_registers.h b/drivers/staging/rdma/hfi1/chip_registers.h
index 770f05c..8744de6 100644
--- a/drivers/staging/rdma/hfi1/chip_registers.h
+++ b/drivers/staging/rdma/hfi1/chip_registers.h
@@ -771,6 +771,7 @@
#define RCV_RSM_CFG_ENABLE_OR_CHAIN_RSM0_MASK 0x1ull
#define RCV_RSM_CFG_ENABLE_OR_CHAIN_RSM0_SHIFT 0
#define RCV_RSM_CFG_PACKET_TYPE_SHIFT 60
+#define RCV_RSM_CFG_OFFSET_SHIFT 32
#define RCV_RSM_MAP_TABLE (RXE + 0x000000000900)
#define RCV_RSM_MAP_TABLE_RCV_CONTEXT_A_MASK 0xFFull
#define RCV_RSM_MATCH (RXE + 0x000000000800)
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-04-12 18:30 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-12 17:49 [PATCH 00/21] IB/hfi1: First round of fixes for 4.7 Dennis Dalessandro
[not found] ` <20160412174746.24485.92280.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2016-04-12 17:49 ` [PATCH 01/21] IB/hfi1: Fix sysfs file offset usage Dennis Dalessandro
2016-04-12 17:50 ` [PATCH 02/21] IB/hfi1: Fix i2c resource reservation checks Dennis Dalessandro
2016-04-12 17:50 ` [PATCH 03/21] IB/hfi1: Fix QOS num_vl bit width Dennis Dalessandro
2016-04-12 17:50 ` [PATCH 04/21] IB/hfi1: Remove invalid QOS check Dennis Dalessandro
2016-04-12 17:50 ` [PATCH 05/21] IB/hfi1: Fix QOS rule mappings Dennis Dalessandro
2016-04-12 17:50 ` [PATCH 06/21] IB/hfi1: Correctly obtain the full service class Dennis Dalessandro
2016-04-12 17:50 ` [PATCH 07/21] IB/hfi1: Simplify init_qpmap_table() Dennis Dalessandro
2016-04-12 18:17 ` [PATCH] [PATCH 08/21] IB/hfi1: Adjust default MTU to be 10KB Dennis Dalessandro
[not found] ` <20160412181708.21853.23423.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2016-04-12 18:35 ` Dennis Dalessandro
2016-04-18 7:07 ` Leon Romanovsky
[not found] ` <20160418070708.GJ6349-2ukJVAZIZ/Y@public.gmane.org>
2016-04-18 12:03 ` Dennis Dalessandro
[not found] ` <20160418120335.GB17987-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
2016-04-18 12:30 ` Leon Romanovsky
[not found] ` <20160418123032.GM6349-2ukJVAZIZ/Y@public.gmane.org>
2016-04-18 18:42 ` David Woodhouse
[not found] ` <1461004942.3765.78.camel-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-04-19 3:31 ` Ira Weiny
2016-04-12 18:22 ` [PATCH 09/21] IB/hfi1: Check P_KEY for all sent packets from user mode Dennis Dalessandro
2016-04-12 18:25 ` [PATCH 10/21] IB/hfi1: Always turn on CDRs for low power QSFP modules Dennis Dalessandro
2016-04-12 18:25 ` [PATCH 11/21] IB/hfi1: Remove module presence check outside pre-LNI checks Dennis Dalessandro
2016-04-12 18:26 ` [PATCH 12/21] IB/hfi1: Guard against concurrent I2C access across all chains Dennis Dalessandro
2016-04-12 18:28 ` [PATCH 13/21] IB/hfi1: Fix double QSFP resource acquire on cache refresh Dennis Dalessandro
2016-04-12 18:28 ` [PATCH 14/21] IB/hfi1: Remove unreachable code Dennis Dalessandro
2016-04-12 18:29 ` [PATCH 15/21] IB/hfi1: Use global defines for upper bits in opcode Dennis Dalessandro
2016-04-12 18:30 ` [PATCH 16/21] IB/hfi1: Change default number of user contexts Dennis Dalessandro
2016-04-12 18:30 ` [PATCH 17/21] IB/hfi1: Reduce kernel context pio buffer allocation Dennis Dalessandro
2016-04-12 18:30 ` Dennis Dalessandro [this message]
2016-04-12 18:31 ` [PATCH 19/21] IB/hfi1: Move QOS decision logic into its own function Dennis Dalessandro
2016-04-12 18:31 ` [PATCH 20/21] IB/hfi1: Create a routine to set a receive side mapping rule Dennis Dalessandro
2016-04-12 18:32 ` [PATCH 21/21] IB/hfi1: Add RSM rule for user FECN handling Dennis Dalessandro
2016-04-18 7:09 ` [PATCH 00/21] IB/hfi1: First round of fixes for 4.7 Leon Romanovsky
[not found] ` <20160418070936.GK6349-2ukJVAZIZ/Y@public.gmane.org>
2016-04-18 12:07 ` Dennis Dalessandro
[not found] ` <20160418120754.GC17987-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
2016-04-18 12:19 ` Leon Romanovsky
[not found] ` <20160418121944.GL6349-2ukJVAZIZ/Y@public.gmane.org>
2016-04-18 13:38 ` Dennis Dalessandro
[not found] ` <20160418133842.GA7596-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
2016-04-18 13:56 ` Leon Romanovsky
2016-05-05 19:58 ` Doug Ledford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160412183043.27656.49185.stgit@scvm10.sc.intel.com \
--to=dennis.dalessandro-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=dean.luick-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.