|
|
89ea86 |
From 21367ae2b8ebbe5173cbed22dfa51680a3fe48d2 Mon Sep 17 00:00:00 2001
|
|
|
89ea86 |
From: Ido Schimmel <idosch@nvidia.com>
|
|
|
89ea86 |
Date: Tue, 23 Nov 2021 19:40:58 +0200
|
|
|
89ea86 |
Subject: [PATCH 30/35] cmis: Initialize Banked Page 11h in memory map
|
|
|
89ea86 |
|
|
|
89ea86 |
Banked Page 11h stores, among other things, lane-specific flags and
|
|
|
89ea86 |
monitors that are going to be parsed and displayed in subsequent
|
|
|
89ea86 |
patches.
|
|
|
89ea86 |
|
|
|
89ea86 |
Request it via the 'MODULE_EEPROM_GET' netlink message and initialize it
|
|
|
89ea86 |
in the memory map.
|
|
|
89ea86 |
|
|
|
89ea86 |
Only initialize it in supported Banks.
|
|
|
89ea86 |
|
|
|
89ea86 |
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
|
|
|
89ea86 |
---
|
|
|
89ea86 |
cmis.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
89ea86 |
cmis.h | 7 +++++++
|
|
|
89ea86 |
2 files changed, 54 insertions(+), 2 deletions(-)
|
|
|
89ea86 |
|
|
|
89ea86 |
diff --git a/cmis.c b/cmis.c
|
|
|
89ea86 |
index 55b9d1b959cd..83ced4d253ae 100644
|
|
|
89ea86 |
--- a/cmis.c
|
|
|
89ea86 |
+++ b/cmis.c
|
|
|
89ea86 |
@@ -15,9 +15,17 @@
|
|
|
89ea86 |
#include "cmis.h"
|
|
|
89ea86 |
#include "netlink/extapi.h"
|
|
|
89ea86 |
|
|
|
89ea86 |
+/* The maximum number of supported Banks. Relevant documents:
|
|
|
89ea86 |
+ * [1] CMIS Rev. 5, page. 128, section 8.4.4, Table 8-40
|
|
|
89ea86 |
+ */
|
|
|
89ea86 |
+#define CMIS_MAX_BANKS 4
|
|
|
89ea86 |
+
|
|
|
89ea86 |
+/* We are not parsing further than Page 11h. */
|
|
|
89ea86 |
+#define CMIS_MAX_PAGES 18
|
|
|
89ea86 |
+
|
|
|
89ea86 |
struct cmis_memory_map {
|
|
|
89ea86 |
const __u8 *lower_memory;
|
|
|
89ea86 |
- const __u8 *upper_memory[1][3]; /* Bank, Page */
|
|
|
89ea86 |
+ const __u8 *upper_memory[CMIS_MAX_BANKS][CMIS_MAX_PAGES];
|
|
|
89ea86 |
#define page_00h upper_memory[0x0][0x0]
|
|
|
89ea86 |
#define page_01h upper_memory[0x0][0x1]
|
|
|
89ea86 |
#define page_02h upper_memory[0x0][0x2]
|
|
|
89ea86 |
@@ -399,12 +407,33 @@ static void cmis_request_init(struct ethtool_module_eeprom *request, u8 bank,
|
|
|
89ea86 |
request->data = NULL;
|
|
|
89ea86 |
}
|
|
|
89ea86 |
|
|
|
89ea86 |
+static int cmis_num_banks_get(const struct cmis_memory_map *map,
|
|
|
89ea86 |
+ int *p_num_banks)
|
|
|
89ea86 |
+{
|
|
|
89ea86 |
+ switch (map->page_01h[CMIS_PAGES_ADVER_OFFSET] &
|
|
|
89ea86 |
+ CMIS_BANKS_SUPPORTED_MASK) {
|
|
|
89ea86 |
+ case CMIS_BANK_0_SUPPORTED:
|
|
|
89ea86 |
+ *p_num_banks = 1;
|
|
|
89ea86 |
+ break;
|
|
|
89ea86 |
+ case CMIS_BANK_0_1_SUPPORTED:
|
|
|
89ea86 |
+ *p_num_banks = 2;
|
|
|
89ea86 |
+ break;
|
|
|
89ea86 |
+ case CMIS_BANK_0_3_SUPPORTED:
|
|
|
89ea86 |
+ *p_num_banks = 4;
|
|
|
89ea86 |
+ break;
|
|
|
89ea86 |
+ default:
|
|
|
89ea86 |
+ return -EINVAL;
|
|
|
89ea86 |
+ }
|
|
|
89ea86 |
+
|
|
|
89ea86 |
+ return 0;
|
|
|
89ea86 |
+}
|
|
|
89ea86 |
+
|
|
|
89ea86 |
static int
|
|
|
89ea86 |
cmis_memory_map_init_pages(struct cmd_context *ctx,
|
|
|
89ea86 |
struct cmis_memory_map *map)
|
|
|
89ea86 |
{
|
|
|
89ea86 |
struct ethtool_module_eeprom request;
|
|
|
89ea86 |
- int ret;
|
|
|
89ea86 |
+ int num_banks, i, ret;
|
|
|
89ea86 |
|
|
|
89ea86 |
/* Lower Memory and Page 00h are always present.
|
|
|
89ea86 |
*
|
|
|
89ea86 |
@@ -443,6 +472,22 @@ cmis_memory_map_init_pages(struct cmd_context *ctx,
|
|
|
89ea86 |
return ret;
|
|
|
89ea86 |
map->page_02h = request.data - CMIS_PAGE_SIZE;
|
|
|
89ea86 |
|
|
|
89ea86 |
+ /* Bank 0 of Page 11h provides lane-specific registers for the first 8
|
|
|
89ea86 |
+ * lanes, and each additional Banks provides support for an additional
|
|
|
89ea86 |
+ * 8 lanes. Only initialize supported Banks.
|
|
|
89ea86 |
+ */
|
|
|
89ea86 |
+ ret = cmis_num_banks_get(map, &num_banks);
|
|
|
89ea86 |
+ if (ret < 0)
|
|
|
89ea86 |
+ return ret;
|
|
|
89ea86 |
+
|
|
|
89ea86 |
+ for (i = 0; i < num_banks; i++) {
|
|
|
89ea86 |
+ cmis_request_init(&request, i, 0x11, CMIS_PAGE_SIZE);
|
|
|
89ea86 |
+ ret = nl_get_eeprom_page(ctx, &request);
|
|
|
89ea86 |
+ if (ret < 0)
|
|
|
89ea86 |
+ return ret;
|
|
|
89ea86 |
+ map->upper_memory[i][0x11] = request.data - CMIS_PAGE_SIZE;
|
|
|
89ea86 |
+ }
|
|
|
89ea86 |
+
|
|
|
89ea86 |
return 0;
|
|
|
89ea86 |
}
|
|
|
89ea86 |
|
|
|
89ea86 |
diff --git a/cmis.h b/cmis.h
|
|
|
89ea86 |
index 911491dc5c8f..8d90a04756ad 100644
|
|
|
89ea86 |
--- a/cmis.h
|
|
|
89ea86 |
+++ b/cmis.h
|
|
|
89ea86 |
@@ -114,6 +114,13 @@
|
|
|
89ea86 |
#define CMIS_WAVELENGTH_TOL_MSB 0x8C
|
|
|
89ea86 |
#define CMIS_WAVELENGTH_TOL_LSB 0x8D
|
|
|
89ea86 |
|
|
|
89ea86 |
+/* Supported Pages Advertising (Page 1) */
|
|
|
89ea86 |
+#define CMIS_PAGES_ADVER_OFFSET 0x8E
|
|
|
89ea86 |
+#define CMIS_BANKS_SUPPORTED_MASK 0x03
|
|
|
89ea86 |
+#define CMIS_BANK_0_SUPPORTED 0x00
|
|
|
89ea86 |
+#define CMIS_BANK_0_1_SUPPORTED 0x01
|
|
|
89ea86 |
+#define CMIS_BANK_0_3_SUPPORTED 0x02
|
|
|
89ea86 |
+
|
|
|
89ea86 |
/* Signal integrity controls */
|
|
|
89ea86 |
#define CMIS_SIG_INTEG_TX_OFFSET 0xA1
|
|
|
89ea86 |
#define CMIS_SIG_INTEG_RX_OFFSET 0xA2
|
|
|
89ea86 |
--
|
|
|
89ea86 |
2.35.1
|
|
|
89ea86 |
|