forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase optoe's write-max to support i2c block write (sonic-net#230)
Dynamic write_max support for optoe driver Signed-off-by: Prince George <[email protected]>
- Loading branch information
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
From ca9daf437f0910493a6eb8ced900662223ea3cf7 Mon Sep 17 00:00:00 2001 | ||
From: Prince George <[email protected]> | ||
Date: Mon, 16 Aug 2021 16:04:15 +0000 | ||
Subject: [PATCH] Dynamic write_max support for optoe driver | ||
In current optoe driver, the value of write_max is hardcoded to one byte. | ||
CMIS spec supports firmware upgrade on QSFP-DD transceivers which means | ||
there is significant overhead due to this one byte write limit when a | ||
platform wants to upgrade the firmware over an i2c bus at 100Khz. | ||
The overhead is more pronounced when a platform has shared master and | ||
platform needs to perform firmware upgrade on multiple transceivers. | ||
|
||
Added sysfs file 'write_max' for each i2c device (that use optoe driver) | ||
so that the platform can override the default write max which is one byte. | ||
|
||
Test result:- | ||
Firmware file of size 1.9MB takes ~ 33 mins with write-max size = 1 Byte | ||
Firmware file of size 1.9MB takes ~ 8 mins with write-max size = 64 Bytes | ||
|
||
Signed-off-by: Prince George <[email protected]> | ||
--- | ||
drivers/misc/eeprom/optoe.c | 36 ++++++++++++++++++++++++++++++++++++ | ||
1 file changed, 36 insertions(+) | ||
|
||
diff --git a/drivers/misc/eeprom/optoe.c b/drivers/misc/eeprom/optoe.c | ||
index 16287fdc5..cacfb1848 100644 | ||
--- a/drivers/misc/eeprom/optoe.c | ||
+++ b/drivers/misc/eeprom/optoe.c | ||
@@ -822,6 +822,39 @@ static int optoe_remove(struct i2c_client *client) | ||
return 0; | ||
} | ||
|
||
+static ssize_t show_dev_write_max_size(struct device *dev, | ||
+ struct device_attribute *dattr, char *buf) | ||
+{ | ||
+ struct i2c_client *client = to_i2c_client(dev); | ||
+ struct optoe_data *optoe = i2c_get_clientdata(client); | ||
+ ssize_t count; | ||
+ | ||
+ mutex_lock(&optoe->lock); | ||
+ count = sprintf(buf, "%u\n", optoe->write_max); | ||
+ mutex_unlock(&optoe->lock); | ||
+ | ||
+ return count; | ||
+} | ||
+ | ||
+static ssize_t set_dev_write_max_size(struct device *dev, | ||
+ struct device_attribute *attr, | ||
+ const char *buf, size_t count) | ||
+{ | ||
+ struct i2c_client *client = to_i2c_client(dev); | ||
+ struct optoe_data *optoe = i2c_get_clientdata(client); | ||
+ int write_max_size; | ||
+ | ||
+ if (kstrtouint(buf, 0, &write_max_size) != 0 || | ||
+ write_max_size < 1 || write_max_size > OPTOE_PAGE_SIZE) | ||
+ return -EINVAL; | ||
+ | ||
+ mutex_lock(&optoe->lock); | ||
+ optoe->write_max = write_max_size; | ||
+ mutex_unlock(&optoe->lock); | ||
+ | ||
+ return count; | ||
+} | ||
+ | ||
static ssize_t show_dev_class(struct device *dev, | ||
struct device_attribute *dattr, char *buf) | ||
{ | ||
@@ -928,12 +961,15 @@ static ssize_t set_port_name(struct device *dev, | ||
static DEVICE_ATTR(port_name, 0644, show_port_name, set_port_name); | ||
#endif /* if NOT defined EEPROM_CLASS, the common case */ | ||
|
||
+static DEVICE_ATTR(write_max, 0644, show_dev_write_max_size, | ||
+ set_dev_write_max_size); | ||
static DEVICE_ATTR(dev_class, 0644, show_dev_class, set_dev_class); | ||
|
||
static struct attribute *optoe_attrs[] = { | ||
#ifndef EEPROM_CLASS | ||
&dev_attr_port_name.attr, | ||
#endif | ||
+ &dev_attr_write_max.attr, | ||
&dev_attr_dev_class.attr, | ||
NULL, | ||
}; | ||
-- | ||
2.17.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters