[][kernel][common][eth][Fix MINI-GBIC-GT v8.1 SFP IOT issue]

[Description]
Fix MINI-GBIC-GT v8.1 SFP IOT issue.

MINI-GBIC-GT v8.1 SFP has a RL8211F PHY device, but it cannot
reflect correct BMSR/ADVERTISE from the PHY.
In order to bypass this PHY device, we add a revision field to the
sfp_quirk structure.

If without this patch, the GMAC cannot link up with the link partner.

[Release-log]
N/A


Change-Id: Ic40e3f880e8b80fa608d5452fb551b364f4f7074
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7475437
diff --git a/target/linux/mediatek/patches-5.4/755-net-phy-sfp-add-rollball-support.patch b/target/linux/mediatek/patches-5.4/755-net-phy-sfp-add-rollball-support.patch
index a7a4481..03b6001 100644
--- a/target/linux/mediatek/patches-5.4/755-net-phy-sfp-add-rollball-support.patch
+++ b/target/linux/mediatek/patches-5.4/755-net-phy-sfp-add-rollball-support.patch
@@ -676,7 +676,7 @@
  
  #if IS_ENABLED(CONFIG_HWMON)
  	struct sfp_diag diag;
-@@ -303,6 +313,144 @@ static const struct of_device_id sfp_of_
+@@ -303,6 +313,155 @@ static const struct of_device_id sfp_of_
  };
  MODULE_DEVICE_TABLE(of, sfp_of_match);
  
@@ -690,6 +690,11 @@
 +	sfp->tx_fault_ignore = true;
 +}
 +
++static void sfp_fixup_ruijie_gbic(struct sfp *sfp)
++{
++	sfp->mdio_protocol = MDIO_I2C_NONE;
++}
++
 +static void sfp_fixup_halny_gsfp(struct sfp *sfp)
 +{
 +	/* Ignore the TX_FAULT and LOS signals on this module.
@@ -738,44 +743,48 @@
 +	linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT, modes);
 +}
 +
-+#define SFP_QUIRK(_v, _p, _m, _f) \
-+	{ .vendor = _v, .part = _p, .modes = _m, .fixup = _f, }
-+#define SFP_QUIRK_M(_v, _p, _m) SFP_QUIRK(_v, _p, _m, NULL)
-+#define SFP_QUIRK_F(_v, _p, _f) SFP_QUIRK(_v, _p, NULL, _f)
++#define SFP_QUIRK(_v, _p, _r, _m, _f) \
++	{ .vendor = _v, .part = _p, .revision = _r, .modes = _m, .fixup = _f, }
++#define SFP_QUIRK_M(_v, _p, _r, _m) SFP_QUIRK(_v, _p, _r, _m, NULL)
++#define SFP_QUIRK_F(_v, _p, _r, _f) SFP_QUIRK(_v, _p, _r, NULL, _f)
 +
 +static const struct sfp_quirk sfp_quirks[] = {
++	// Ruijie MINI-GBIC-GT81 has a RL8211F PHY device, but it cannot
++	// reflect correct BMSR/ADVERTISE from the PHY.
++	SFP_QUIRK_F("RUIJIE", "MINI-GBIC-GT", "81", sfp_fixup_ruijie_gbic),
++
 +	// Alcatel Lucent G-010S-P can operate at 2500base-X, but incorrectly
 +	// report 2500MBd NRZ in their EEPROM
-+	SFP_QUIRK_M("ALCATELLUCENT", "G010SP", sfp_quirk_2500basex),
++	SFP_QUIRK_M("ALCATELLUCENT", "G010SP", '\0', sfp_quirk_2500basex),
 +
 +	// Alcatel Lucent G-010S-A can operate at 2500base-X, but report 3.2GBd
 +	// NRZ in their EEPROM
-+	SFP_QUIRK("ALCATELLUCENT", "3FE46541AA", sfp_quirk_2500basex,
++	SFP_QUIRK("ALCATELLUCENT", "3FE46541AA", '\0', sfp_quirk_2500basex,
 +		  sfp_fixup_long_startup),
 +
-+	SFP_QUIRK_F("HALNy", "HL-GSFP", sfp_fixup_halny_gsfp),
++	SFP_QUIRK_F("HALNy", "HL-GSFP", '\0', sfp_fixup_halny_gsfp),
 +
 +	// Huawei MA5671A can operate at 2500base-X, but report 1.2GBd NRZ in
 +	// their EEPROM
-+	SFP_QUIRK("HUAWEI", "MA5671A", sfp_quirk_2500basex,
++	SFP_QUIRK("HUAWEI", "MA5671A", '\0', sfp_quirk_2500basex,
 +		  sfp_fixup_ignore_tx_fault),
 +
 +	// Lantech 8330-262D-E can operate at 2500base-X, but incorrectly report
 +	// 2500MBd NRZ in their EEPROM
-+	SFP_QUIRK_M("Lantech", "8330-262D-E", sfp_quirk_2500basex),
++	SFP_QUIRK_M("Lantech", "8330-262D-E", '\0', sfp_quirk_2500basex),
 +
-+	SFP_QUIRK_M("CISCO-JDSU", "PLRXPL-VC-S43-CG", sfp_quirk_10000baseSR),
++	SFP_QUIRK_M("CISCO-JDSU", "PLRXPL-VC-S43-CG", '\0', sfp_quirk_10000baseSR),
 +
-+	SFP_QUIRK_M("UBNT", "UF-INSTANT", sfp_quirk_ubnt_uf_instant),
++	SFP_QUIRK_M("UBNT", "UF-INSTANT", '\0', sfp_quirk_ubnt_uf_instant),
 +
-+	SFP_QUIRK_F("ETU", "ESP-T5-R", sfp_fixup_rollball_cc),
-+	SFP_QUIRK_F("OEM", "SFP-10G-T", sfp_fixup_rollball_cc),
-+	SFP_QUIRK_F("OEM", "RTSFP-10", sfp_fixup_rollball_cc),
-+	SFP_QUIRK_F("OEM", "RTSFP-10G", sfp_fixup_rollball_cc),
-+	SFP_QUIRK_F("OEM", "TNBYV02-C0X-C3", sfp_fixup_rollball_cc),
-+	SFP_QUIRK_F("Turris", "RTSFP-10", sfp_fixup_rollball),
-+	SFP_QUIRK_F("Turris", "RTSFP-10G", sfp_fixup_rollball),
-+	SFP_QUIRK_F("JESS-LINK", "P60000BBC001-1", sfp_fixup_rollball),
++	SFP_QUIRK_F("ETU", "ESP-T5-R", '\0', sfp_fixup_rollball_cc),
++	SFP_QUIRK_F("OEM", "SFP-10G-T", '\0', sfp_fixup_rollball_cc),
++	SFP_QUIRK_F("OEM", "RTSFP-10", '\0', sfp_fixup_rollball_cc),
++	SFP_QUIRK_F("OEM", "RTSFP-10G", '\0', sfp_fixup_rollball_cc),
++	SFP_QUIRK_F("OEM", "TNBYV02-C0X-C3", '\0', sfp_fixup_rollball_cc),
++	SFP_QUIRK_F("Turris", "RTSFP-10", '\0', sfp_fixup_rollball),
++	SFP_QUIRK_F("Turris", "RTSFP-10G", '\0', sfp_fixup_rollball),
++	SFP_QUIRK_F("JESS-LINK", "P60000BBC001-1", '\0', sfp_fixup_rollball),
 +};
 +
 +static size_t sfp_strlen(const char *str, size_t maxlen)
@@ -805,14 +814,16 @@
 +{
 +	const struct sfp_quirk *q;
 +	unsigned int i;
-+	size_t vs, ps;
++	size_t vs, ps, rs;
 +
 +	vs = sfp_strlen(id->base.vendor_name, ARRAY_SIZE(id->base.vendor_name));
 +	ps = sfp_strlen(id->base.vendor_pn, ARRAY_SIZE(id->base.vendor_pn));
++	rs = sfp_strlen(id->base.vendor_rev, ARRAY_SIZE(id->base.vendor_rev));
 +
 +	for (i = 0, q = sfp_quirks; i < ARRAY_SIZE(sfp_quirks); i++, q++)
 +		if (sfp_match(q->vendor, id->base.vendor_name, vs) &&
-+		    sfp_match(q->part, id->base.vendor_pn, ps))
++		    sfp_match(q->part, id->base.vendor_pn, ps) &&
++		    sfp_match(q->revision, id->base.vendor_rev, rs))
 +			return q;
 +
 +	return NULL;
@@ -1072,13 +1083,14 @@
  
 --- a/drivers/net/phy/sfp.h
 +++ b/drivers/net/phy/sfp.h
-@@ -6,6 +6,13 @@
+@@ -6,6 +6,14 @@
  
  struct sfp;
  
 +struct sfp_quirk {
 +	const char *vendor;
 +	const char *part;
++	const char *revision;
 +	void (*modes)(const struct sfp_eeprom_id *id, unsigned long *modes);
 +	void (*fixup)(struct sfp *sfp);
 +};