DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Khromenok <roma55592@yandex.ru>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Thomas Monjalon <thomas@monjalon.net>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Subject: [PATCH 2/2] test: check SFF-8472 external Rx power calibration
Date: Tue, 29 Sep 2026 19:22:10 +0200	[thread overview]
Message-ID: <20260929172210.1212967-3-roma55592@yandex.ru> (raw)
In-Reply-To: <20260929172210.1212967-1-roma55592@yandex.ru>

Add a test case with all the SFF-8472 Rx power calibration
coefficients set, so that the whole fourth order polynomial
is checked, including RX_PWR(4).

Signed-off-by: Roman Khromenok <roma55592@yandex.ru>
---
 app/test/test_ethdev_module_eeprom.c | 37 ++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/app/test/test_ethdev_module_eeprom.c b/app/test/test_ethdev_module_eeprom.c
index d76bdc0060..b07a18aa06 100644
--- a/app/test/test_ethdev_module_eeprom.c
+++ b/app/test/test_ethdev_module_eeprom.c
@@ -269,6 +269,42 @@ test_module_eeprom_sfp_8472_ext_cal_unaligned(void)
 	return TEST_SUCCESS;
 }
 
+static void
+put_be_float(uint8_t *data, unsigned int offset, uint32_t bits)
+{
+	data[offset] = bits >> 24;
+	data[offset + 1] = (bits >> 16) & 0xff;
+	data[offset + 2] = (bits >> 8) & 0xff;
+	data[offset + 3] = bits & 0xff;
+}
+
+static int
+test_module_eeprom_sfp_8472_rx_power_polynomial(void)
+{
+	uint8_t data[RTE_ETH_MODULE_SFF_8472_LEN];
+	uint8_t *a2 = data + RTE_ETH_MODULE_SFF_8079_LEN;
+
+	fill_sfp(data);
+	/* diagnostics implemented, externally calibrated, average RX power */
+	data[92] = 0x58;
+	a2[76] = 1;	/* TX bias slope */
+	a2[80] = 1;	/* TX power slope */
+	a2[84] = 1;	/* temperature slope */
+	a2[88] = 1;	/* voltage slope */
+	put_u16(a2, 104, 10);	/* raw RX power x = 10 */
+	/* 0.125 x^4 + 0.25 x^3 + 0.5 x^2 + x = 1250 + 250 + 50 + 10 = 1560 */
+	put_be_float(a2, 56, 0x3e000000);	/* RX_PWR(4) = 0.125 */
+	put_be_float(a2, 60, 0x3e800000);	/* RX_PWR(3) = 0.25 */
+	put_be_float(a2, 64, 0x3f000000);	/* RX_PWR(2) = 0.5 */
+	put_be_float(a2, 68, 0x3f800000);	/* RX_PWR(1) = 1.0 */
+	put_be_float(a2, 72, 0);		/* RX_PWR(0) = 0 */
+
+	TEST_ASSERT_SUCCESS(parse(RTE_ETH_MODULE_SFF_8472, data, sizeof(data)),
+		"Failed to parse externally calibrated SFF-8472 data");
+	CHECK_FIELD("Receiver signal average optical power", "0.1560 mW / -8.07 dBm");
+	return TEST_SUCCESS;
+}
+
 static int
 test_module_eeprom_invalid(void)
 {
@@ -318,6 +354,7 @@ static struct unit_test_suite module_eeprom_testsuite = {
 		TEST_CASE(test_module_eeprom_sfp_8472),
 		TEST_CASE(test_module_eeprom_sfp_8472_short),
 		TEST_CASE(test_module_eeprom_sfp_8472_ext_cal_unaligned),
+		TEST_CASE(test_module_eeprom_sfp_8472_rx_power_polynomial),
 		TEST_CASE(test_module_eeprom_qsfp_8636),
 		TEST_CASE(test_module_eeprom_qsfp_8636_thresholds),
 		TEST_CASE(test_module_eeprom_invalid),
-- 
2.47.3


  parent reply	other threads:[~2026-09-29 17:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 17:22 [PATCH 0/2] ethdev: fix SFF-8472 external Rx power calibration Roman Khromenok
2026-09-29 17:22 ` [PATCH 1/2] " Roman Khromenok
2026-09-29 17:22 ` Roman Khromenok [this message]
2026-09-30 16:27 ` [PATCH 0/2] " Stephen Hemminger

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=20260929172210.1212967-3-roma55592@yandex.ru \
    --to=roma55592@yandex.ru \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox