From: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Easwar Hariharan
<easwar.hariharan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Dean Luick <dean.luick-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 04/54] staging/rdma/hfi1: Fix QSFP memory read/write across 128 byte boundary
Date: Wed, 03 Feb 2016 14:31:05 -0800 [thread overview]
Message-ID: <20160203223102.5923.24152.stgit@scvm10.sc.intel.com> (raw)
In-Reply-To: <20160203222512.5923.30980.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
From: Mike Marciniszyn <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
The QSFP memory cache reads both lower and upper page 0H in one shot,
which leads to the address counter wrapping around to the beginning of
lower page 00H at byte 128, as defined by SFF-8636.
This patch fixes this by modifying the underlying QSFP read and writes
to avoid this wrap around.
Reviewed-by: Dean Luick <dean.luick-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Reviewed-by: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Easwar Hariharan <easwar.hariharan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
drivers/staging/rdma/hfi1/qsfp.c | 44 +++++++++++++++++++++++++-------------
drivers/staging/rdma/hfi1/qsfp.h | 28 +++++++++++++++++-------
2 files changed, 49 insertions(+), 23 deletions(-)
diff --git a/drivers/staging/rdma/hfi1/qsfp.c b/drivers/staging/rdma/hfi1/qsfp.c
index 6e9c56f..0d2ec97 100644
--- a/drivers/staging/rdma/hfi1/qsfp.c
+++ b/drivers/staging/rdma/hfi1/qsfp.c
@@ -186,6 +186,10 @@ int i2c_read(struct hfi1_pportdata *ppd, u32 target, int i2c_addr, int offset,
return ret;
}
+/*
+ * Write page n, offset m of QSFP memory as defined by SFF 8636
+ * in the cache by writing @addr = ((256 * n) + m)
+ */
int qsfp_write(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
int len)
{
@@ -217,15 +221,15 @@ int qsfp_write(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
break;
}
- /* truncate write to end of page if crossing page boundary */
offset = addr % QSFP_PAGESIZE;
nwrite = len - count;
- if ((offset + nwrite) > QSFP_PAGESIZE)
- nwrite = QSFP_PAGESIZE - offset;
+ /* truncate write to boundary if crossing boundary */
+ if (((addr % QSFP_RW_BOUNDARY) + nwrite) > QSFP_RW_BOUNDARY)
+ nwrite = QSFP_RW_BOUNDARY - (addr % QSFP_RW_BOUNDARY);
ret = __i2c_write(ppd, target, QSFP_DEV, offset, bp + count,
nwrite);
- if (ret <= 0) /* stop on error or nothing read */
+ if (ret <= 0) /* stop on error or nothing written */
break;
count += ret;
@@ -239,6 +243,10 @@ int qsfp_write(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
return count;
}
+/*
+ * Access page n, offset m of QSFP memory as defined by SFF 8636
+ * in the cache by reading @addr = ((256 * n) + m)
+ */
int qsfp_read(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
int len)
{
@@ -269,11 +277,11 @@ int qsfp_read(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
break;
}
- /* truncate read to end of page if crossing page boundary */
offset = addr % QSFP_PAGESIZE;
nread = len - count;
- if ((offset + nread) > QSFP_PAGESIZE)
- nread = QSFP_PAGESIZE - offset;
+ /* truncate read to boundary if crossing boundary */
+ if (((addr % QSFP_RW_BOUNDARY) + nread) > QSFP_RW_BOUNDARY)
+ nread = QSFP_RW_BOUNDARY - (addr % QSFP_RW_BOUNDARY);
ret = __i2c_read(ppd, target, QSFP_DEV, offset, bp + count,
nread);
@@ -295,6 +303,11 @@ int qsfp_read(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
* This function caches the QSFP memory range in 128 byte chunks.
* As an example, the next byte after address 255 is byte 128 from
* upper page 01H (if existing) rather than byte 0 from lower page 00H.
+ * Access page n, offset m of QSFP memory as defined by SFF 8636
+ * in the cache by reading byte ((128 * n) + m)
+ * The calls to qsfp_{read,write} in this function correctly handle the
+ * address map difference between this mapping and the mapping implemented
+ * by those functions
*/
int refresh_qsfp_cache(struct hfi1_pportdata *ppd, struct qsfp_data *cp)
{
@@ -305,23 +318,24 @@ int refresh_qsfp_cache(struct hfi1_pportdata *ppd, struct qsfp_data *cp)
/* ensure sane contents on invalid reads, for cable swaps */
memset(cache, 0, (QSFP_MAX_NUM_PAGES*128));
- dd_dev_info(ppd->dd, "%s: called\n", __func__);
+ spin_lock_irqsave(&ppd->qsfp_info.qsfp_lock, flags);
+ ppd->qsfp_info.cache_valid = 0;
+ spin_unlock_irqrestore(&ppd->qsfp_info.qsfp_lock, flags);
+
+ dd_dev_info(ppd->dd, "%s called\n", __func__);
if (!qsfp_mod_present(ppd)) {
ret = -ENODEV;
goto bail;
}
- ret = qsfp_read(ppd, target, 0, cache, 256);
- if (ret != 256) {
+ ret = qsfp_read(ppd, target, 0, cache, QSFP_PAGESIZE);
+ if (ret != QSFP_PAGESIZE) {
dd_dev_info(ppd->dd,
- "%s: Read of pages 00H failed, expected 256, got %d\n",
- __func__, ret);
+ "%s: Page 0 read failed, expected %d, got %d\n",
+ __func__, QSFP_PAGESIZE, ret);
goto bail;
}
- if (cache[0] != 0x0C && cache[0] != 0x0D)
- goto bail;
-
/* Is paging enabled? */
if (!(cache[2] & 4)) {
diff --git a/drivers/staging/rdma/hfi1/qsfp.h b/drivers/staging/rdma/hfi1/qsfp.h
index 16aebdc..3422250 100644
--- a/drivers/staging/rdma/hfi1/qsfp.h
+++ b/drivers/staging/rdma/hfi1/qsfp.h
@@ -67,15 +67,16 @@
/* QSFP is paged at 256 bytes */
#define QSFP_PAGESIZE 256
+/* Reads/writes cannot cross 128 byte boundaries */
+#define QSFP_RW_BOUNDARY 128
/* Defined fields that Intel requires of qualified cables */
/* Byte 0 is Identifier, not checked */
/* Byte 1 is reserved "status MSB" */
-/* Byte 2 is "status LSB" We only care that D2 "Flat Mem" is set. */
-/*
- * Rest of first 128 not used, although 127 is reserved for page select
- * if module is not "Flat memory".
- */
+#define QSFP_TX_CTRL_BYTE_OFFS 86
+#define QSFP_PWR_CTRL_BYTE_OFFS 93
+#define QSFP_CDR_CTRL_BYTE_OFFS 98
+
#define QSFP_PAGE_SELECT_BYTE_OFFS 127
/* Byte 128 is Identifier: must be 0x0c for QSFP, or 0x0d for QSFP+ */
#define QSFP_MOD_ID_OFFS 128
@@ -87,7 +88,8 @@
/* Byte 130 is Connector type. Not Intel req'd */
/* Bytes 131..138 are Transceiver types, bit maps for various tech, none IB */
/* Byte 139 is encoding. code 0x01 is 8b10b. Not Intel req'd */
-/* byte 140 is nominal bit-rate, in units of 100Mbits/sec Not Intel req'd */
+/* byte 140 is nominal bit-rate, in units of 100Mbits/sec */
+#define QSFP_NOM_BIT_RATE_100_OFFS 140
/* Byte 141 is Extended Rate Select. Not Intel req'd */
/* Bytes 142..145 are lengths for various fiber types. Not Intel req'd */
/* Byte 146 is length for Copper. Units of 1 meter */
@@ -135,11 +137,18 @@ extern const char *const hfi1_qsfp_devtech[16];
*/
#define QSFP_ATTEN_OFFS 186
#define QSFP_ATTEN_LEN 2
-/* Bytes 188,189 are Wavelength tolerance, not Intel req'd */
+/*
+ * Bytes 188,189 are Wavelength tolerance, if optical
+ * If copper, they are attenuation in dB:
+ * Byte 188 is at 12.5 Gb/s, Byte 189 at 25 Gb/s
+ */
+#define QSFP_CU_ATTEN_7G_OFFS 188
+#define QSFP_CU_ATTEN_12G_OFFS 189
/* Byte 190 is Max Case Temp. Not Intel req'd */
/* Byte 191 is LSB of sum of bytes 128..190. Not Intel req'd */
#define QSFP_CC_OFFS 191
-/* Bytes 192..195 are Options implemented in qsfp. Not Intel req'd */
+#define QSFP_EQ_INFO_OFFS 193
+#define QSFP_CDR_INFO_OFFS 194
/* Bytes 196..211 are Serial Number, String */
#define QSFP_SN_OFFS 196
#define QSFP_SN_LEN 16
@@ -150,6 +159,8 @@ extern const char *const hfi1_qsfp_devtech[16];
#define QSFP_LOT_OFFS 218
#define QSFP_LOT_LEN 2
/* Bytes 220, 221 indicate monitoring options, Not Intel req'd */
+/* Byte 222 indicates nominal bitrate in units of 250Mbits/sec */
+#define QSFP_NOM_BIT_RATE_250_OFFS 222
/* Byte 223 is LSB of sum of bytes 192..222 */
#define QSFP_CC_EXT_OFFS 223
@@ -191,6 +202,7 @@ extern const char *const hfi1_qsfp_devtech[16];
*/
#define QSFP_PWR(pbyte) (((pbyte) >> 6) & 3)
+#define QSFP_HIGH_PWR(pbyte) (((pbyte) & 3) | 4)
#define QSFP_ATTEN_SDR(attenarray) (attenarray[0])
#define QSFP_ATTEN_DDR(attenarray) (attenarray[1])
--
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-02-03 22:31 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-03 22:30 [PATCH 00/54] staging/rdma/hfi1: Various bug fixes for hfi1 post rdmavt Dennis Dalessandro
[not found] ` <20160203222512.5923.30980.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2016-02-03 22:30 ` [PATCH 01/54] staging/rdma/hfi1: Remove srq functionality Dennis Dalessandro
2016-02-03 22:30 ` [PATCH 02/54] staging/rdma/hfi1: HFI reports wrong offline disabled reason when cable removed Dennis Dalessandro
2016-02-03 22:30 ` [PATCH 03/54] staging/rdma/hfi1: cleanup messages on qsfp_read() failure Dennis Dalessandro
2016-02-03 22:31 ` Dennis Dalessandro [this message]
2016-02-03 22:31 ` [PATCH 05/54] staging/rdma/hfi1: Add active and optical cable support Dennis Dalessandro
2016-02-03 22:31 ` [PATCH 06/54] staging/rdma/hfi1: Get port type from configuration file Dennis Dalessandro
2016-02-03 22:31 ` [PATCH 07/54] staging/rdma/hfi1: Support external device configuration requests from 8051 Dennis Dalessandro
2016-02-03 22:31 ` [PATCH 08/54] staging/rdma/hfi1: Fix missing firmware NULL dereference Dennis Dalessandro
2016-02-03 22:31 ` [PATCH 09/54] staging/rdma/hfi1: Fix per-VL transmit discard counts Dennis Dalessandro
2016-02-03 22:31 ` [PATCH 10/54] staging/rdma/hfi1: Only warn when board description is not found Dennis Dalessandro
2016-02-03 22:32 ` [PATCH 11/54] staging/rdma/hfi1: Make firmware failure messages warnings Dennis Dalessandro
2016-02-03 22:32 ` [PATCH 12/54] staging/rdma/hfi1: Don't attempt to qualify or tune loopback plugs Dennis Dalessandro
2016-02-03 22:32 ` [PATCH 13/54] staging/rdma/hfi1: No firmware retry for simulation Dennis Dalessandro
2016-02-03 22:32 ` [PATCH 14/54] staging/rdma/hfi1: Skip lcb init " Dennis Dalessandro
2016-02-03 22:32 ` [PATCH 15/54] staging/rdma/hfi1: Fix for 32-bit counter overflow in driver and hfi1stats Dennis Dalessandro
2016-02-03 22:32 ` [PATCH 16/54] staging/rdma/hfi1: Correctly set RcvCtxtCtrl register Dennis Dalessandro
2016-02-03 22:32 ` [PATCH 17/54] staging/rdma/hfi1: Method to toggle "fast ECN" detection Dennis Dalessandro
2016-02-03 22:33 ` [PATCH 18/54] staging/rdma/hfi1: Add support for enabling/disabling PCIe ASPM Dennis Dalessandro
[not found] ` <20160203223302.5923.92377.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2016-02-23 11:57 ` Andy Shevchenko
[not found] ` <20160223115728.GA6058-XvqNBM/wLWRrdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2016-02-25 3:00 ` Ashutosh Dixit
[not found] ` <tnm1t60xd334v.fsf-f6XKxGr23Gihg59KIB+fZth3ngVCH38I@public.gmane.org>
2016-02-25 13:38 ` Shevchenko, Andriy
2016-02-03 22:33 ` [PATCH 19/54] staging/rdma/hfi1: Fix SL->SC checks Dennis Dalessandro
2016-02-03 22:33 ` [PATCH 20/54] staging/rdma/hfi1: Remove unused code Dennis Dalessandro
2016-02-03 22:33 ` [PATCH 21/54] staging/rdma/hfi1: Remove unnecessary duplicated variable Dennis Dalessandro
2016-02-03 22:33 ` [PATCH 22/54] staging/rdma/hfi1: Consolidate CPU/IRQ affinity support Dennis Dalessandro
2016-02-03 22:33 ` [PATCH 23/54] staging/rdma/hfi1: Allocate send ctxt on device NUMA node Dennis Dalessandro
2016-02-03 22:33 ` [PATCH 24/54] staging/rdma/hfi1: Verbs Mem affinity support Dennis Dalessandro
2016-02-03 22:34 ` [PATCH 25/54] staging/rdma/hfi1: Change send_schedule counter to a per cpu counter Dennis Dalessandro
2016-02-03 22:34 ` [PATCH 26/54] staging/rdma/hfi1: Fix for generic I2C interface Dennis Dalessandro
2016-02-03 22:34 ` [PATCH 27/54] staging/rdma/hfi1: Allow a fair scheduling of QPs Dennis Dalessandro
2016-02-03 22:34 ` [PATCH 28/54] staging/rdma/hfi1: Fix for module parameter rcvhdrcnt when it's 2097152 Dennis Dalessandro
2016-02-03 22:34 ` [PATCH 29/54] staging/rdma/hfi1: Improve performance of TID cache look up Dennis Dalessandro
2016-02-03 22:34 ` [PATCH 30/54] staging/rdma/hfi1: Reduce syslog message severity and provide speed information Dennis Dalessandro
2016-02-03 22:34 ` [PATCH 31/54] staging/rdma/hfi1: Use device file minor to identify EPROM Dennis Dalessandro
2016-02-03 22:35 ` [PATCH 32/54] staging/rdma/hfi1: Improve performance of SDMA transfers Dennis Dalessandro
2016-02-03 22:35 ` [PATCH 33/54] staging/rdma/hfi1: correctly check for post-interrupt packets Dennis Dalessandro
2016-02-03 22:35 ` [PATCH 34/54] staging/rdma/hfi1: Properly determine error status of SDMA slots Dennis Dalessandro
2016-02-03 22:35 ` [PATCH 35/54] staging/rdma/hfi1: Report physical state changes per device instead of globally Dennis Dalessandro
2016-02-03 22:35 ` [PATCH 36/54] staging/rdma/hfi1: Fix fabric serdes reset by re-downloading firmware Dennis Dalessandro
2016-02-03 22:35 ` [PATCH 37/54] staging/rdma/hfi1: Split last 8 bytes of copy to user buffer Dennis Dalessandro
2016-02-03 22:35 ` [PATCH 38/54] staging/rdma/hfi1: Implement LED beaconing for maintenance Dennis Dalessandro
2016-02-03 22:36 ` [PATCH 39/54] staging/rdma/hfi1: Remove PCIe AER diagnostic message Dennis Dalessandro
2016-02-03 22:36 ` [PATCH 40/54] staging/rdma/hfi1: Correct TWSI reset Dennis Dalessandro
2016-02-03 22:36 ` [PATCH 41/54] staging/rdma/hfi1: Fix snoop packet length calculation Dennis Dalessandro
2016-02-03 22:36 ` [PATCH 42/54] staging/rdma/hfi1: Clean up init_cntrs() Dennis Dalessandro
2016-02-03 22:36 ` [PATCH 43/54] staging/rdma/hfi1: Support query gid in rdmavt Dennis Dalessandro
2016-02-03 22:36 ` [PATCH 44/54] staging/rdma/hfi1: Remove modify_port and port_immutable functions Dennis Dalessandro
2016-02-03 22:36 ` [PATCH 45/54] staging/rdma/hfi1, IB/core: Fix LinkDownReason define for consistency Dennis Dalessandro
2016-02-03 22:37 ` [PATCH 46/54] staging/rdma/hfi1: Improve performance of user SDMA Dennis Dalessandro
2016-02-03 22:37 ` [PATCH 47/54] staging/rdma/hfi1: Add credits for VL0 to VL7 in snoop mode Dennis Dalessandro
2016-02-03 22:37 ` [PATCH 48/54] staging/rdma/hfi1: Make EPROM check per device Dennis Dalessandro
2016-02-03 22:37 ` [PATCH 49/54] staging/rdma/hfi1: Remove unused variable nsbr Dennis Dalessandro
2016-02-03 22:37 ` [PATCH 50/54] staging/rdma/hfi1: Fix bug that could block the process on context exit Dennis Dalessandro
2016-02-03 22:37 ` [PATCH 51/54] staging/rdma/hfi1: Change for data type of port number Dennis Dalessandro
2016-02-03 22:37 ` [PATCH 52/54] staging/rdma/hfi1: Replacement of goto's for break/returns Dennis Dalessandro
2016-02-03 22:38 ` [PATCH 53/54] staging/rdma/hfi1: Adding support for hfi counters via sysfs Dennis Dalessandro
2016-02-03 22:38 ` [PATCH 54/54] staging/rdma/hfi1: Removing unused struct hfi1_verbs_counters Dennis Dalessandro
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=20160203223102.5923.24152.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=easwar.hariharan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=ira.weiny-ral2JQCrhuEAvxtiuMwx3w@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.