Lines Matching +full:100 +full:base +full:- +full:fx
1 // SPDX-License-Identifier: GPL-2.0-only
14 * struct sfp_bus - internal representation of a sfp bus
36 * sfp_parse_port() - Parse the EEPROM base ID, setting the port type
43 * %PORT_TP, %PORT_FIBRE or %PORT_OTHER. If @support is non-%NULL,
55 switch (id->base.connector) { in sfp_parse_port()
76 if (id->base.e1000_base_t) { in sfp_parse_port()
88 dev_warn(bus->sfp_dev, "SFP: unknown connector id 0x%02x\n", in sfp_parse_port()
89 id->base.connector); in sfp_parse_port()
111 * sfp_may_have_phy() - indicate whether the module may have a PHY
120 if (id->base.e1000_base_t) in sfp_may_have_phy()
123 if (id->base.phys_id != SFF8024_ID_DWDM_SFP) { in sfp_may_have_phy()
124 switch (id->base.extended_cc) { in sfp_may_have_phy()
138 * sfp_parse_support() - Parse the eeprom id for supported link modes
156 if (id->base.br_nominal) { in sfp_parse_support()
157 if (id->base.br_nominal != 255) { in sfp_parse_support()
158 br_nom = id->base.br_nominal * 100; in sfp_parse_support()
159 br_min = br_nom - id->base.br_nominal * id->ext.br_min; in sfp_parse_support()
160 br_max = br_nom + id->base.br_nominal * id->ext.br_max; in sfp_parse_support()
161 } else if (id->ext.br_max) { in sfp_parse_support()
162 br_nom = 250 * id->ext.br_max; in sfp_parse_support()
163 br_max = br_nom + br_nom * id->ext.br_min / 100; in sfp_parse_support()
164 br_min = br_nom - br_nom * id->ext.br_min / 100; in sfp_parse_support()
171 if (br_min == br_max && id->base.sfp_ct_passive) in sfp_parse_support()
176 if (id->base.e10g_base_sr) { in sfp_parse_support()
180 if (id->base.e10g_base_lr) { in sfp_parse_support()
184 if (id->base.e10g_base_lrm) { in sfp_parse_support()
188 if (id->base.e10g_base_er) { in sfp_parse_support()
192 if (id->base.e1000_base_sx || in sfp_parse_support()
193 id->base.e1000_base_lx || in sfp_parse_support()
194 id->base.e1000_base_cx) { in sfp_parse_support()
198 if (id->base.e1000_base_t) { in sfp_parse_support()
205 /* 1000Base-PX or 1000Base-BX10 */ in sfp_parse_support()
206 if ((id->base.e_base_px || id->base.e_base_bx10) && in sfp_parse_support()
212 /* 100Base-FX, 100Base-LX, 100Base-PX, 100Base-BX10 */ in sfp_parse_support()
213 if (id->base.e100_base_fx || id->base.e100_base_lx) { in sfp_parse_support()
214 phylink_set(modes, 100baseFX_Full); in sfp_parse_support()
217 if ((id->base.e_base_px || id->base.e_base_bx10) && br_nom == 100) { in sfp_parse_support()
218 phylink_set(modes, 100baseFX_Full); in sfp_parse_support()
225 if ((id->base.sfp_ct_passive || id->base.sfp_ct_active) && br_nom) { in sfp_parse_support()
240 if (id->base.sfp_ct_passive) { in sfp_parse_support()
241 if (id->base.passive.sff8431_app_e) { in sfp_parse_support()
246 if (id->base.sfp_ct_active) { in sfp_parse_support()
247 if (id->base.active.sff8431_app_e || in sfp_parse_support()
248 id->base.active.sff8431_lim) { in sfp_parse_support()
254 switch (id->base.extended_cc) { in sfp_parse_support()
288 dev_warn(bus->sfp_dev, in sfp_parse_support()
290 id->base.extended_cc); in sfp_parse_support()
295 if (id->base.fc_speed_100 || in sfp_parse_support()
296 id->base.fc_speed_200 || in sfp_parse_support()
297 id->base.fc_speed_400) { in sfp_parse_support()
298 if (id->base.br_nominal >= 31) { in sfp_parse_support()
302 if (id->base.br_nominal >= 12) { in sfp_parse_support()
310 * 1310nm/1550nm) are not 1000BASE-BX compliant due to the differing in sfp_parse_support()
313 * Do the same for modules supporting 2500BASE-X. Note that some in sfp_parse_support()
315 * 2500BASE-X, so we allow some slack here. in sfp_parse_support()
328 if (bus->sfp_quirk && bus->sfp_quirk->modes) in sfp_parse_support()
329 bus->sfp_quirk->modes(id, modes, interfaces); in sfp_parse_support()
340 * sfp_select_interface() - Select appropriate phy_interface_t mode
376 if (phylink_test(link_modes, 100baseFX_Full)) in sfp_select_interface()
379 dev_warn(bus->sfp_dev, "Unable to ascertain link mode\n"); in sfp_select_interface()
390 return bus->registered ? bus->upstream_ops : NULL; in sfp_get_upstream_ops()
402 if (sfp->fwnode == fwnode) { in sfp_bus_get()
403 kref_get(&sfp->kref); in sfp_bus_get()
410 kref_init(&new->kref); in sfp_bus_get()
411 new->fwnode = fwnode; in sfp_bus_get()
412 list_add(&new->node, &sfp_buses); in sfp_bus_get()
428 list_del(&bus->node); in sfp_bus_release()
434 * sfp_bus_put() - put a reference on the &struct sfp_bus
443 kref_put_mutex(&bus->kref, sfp_bus_release, &sfp_mutex); in sfp_bus_put()
449 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_register_bus()
453 if (ops->link_down) in sfp_register_bus()
454 ops->link_down(bus->upstream); in sfp_register_bus()
455 if (ops->connect_phy && bus->phydev) { in sfp_register_bus()
456 ret = ops->connect_phy(bus->upstream, bus->phydev); in sfp_register_bus()
461 bus->registered = true; in sfp_register_bus()
462 bus->socket_ops->attach(bus->sfp); in sfp_register_bus()
463 if (bus->started) in sfp_register_bus()
464 bus->socket_ops->start(bus->sfp); in sfp_register_bus()
465 bus->upstream_ops->attach(bus->upstream, bus); in sfp_register_bus()
471 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_unregister_bus()
473 if (bus->registered) { in sfp_unregister_bus()
474 bus->upstream_ops->detach(bus->upstream, bus); in sfp_unregister_bus()
475 if (bus->started) in sfp_unregister_bus()
476 bus->socket_ops->stop(bus->sfp); in sfp_unregister_bus()
477 bus->socket_ops->detach(bus->sfp); in sfp_unregister_bus()
478 if (bus->phydev && ops && ops->disconnect_phy) in sfp_unregister_bus()
479 ops->disconnect_phy(bus->upstream); in sfp_unregister_bus()
481 bus->registered = false; in sfp_unregister_bus()
485 * sfp_get_module_info() - Get the ethtool_modinfo for a SFP module
496 return bus->socket_ops->module_info(bus->sfp, modinfo); in sfp_get_module_info()
501 * sfp_get_module_eeprom() - Read the SFP module EEPROM
504 * @data: buffer to contain the EEPROM data (must be at least @ee->len bytes)
514 return bus->socket_ops->module_eeprom(bus->sfp, ee, data); in sfp_get_module_eeprom()
519 * sfp_get_module_eeprom_by_page() - Read a page from the SFP module EEPROM
534 return bus->socket_ops->module_eeprom_by_page(bus->sfp, page, extack); in sfp_get_module_eeprom_by_page()
539 * sfp_upstream_start() - Inform the SFP that the network device is up
549 if (bus->registered) in sfp_upstream_start()
550 bus->socket_ops->start(bus->sfp); in sfp_upstream_start()
551 bus->started = true; in sfp_upstream_start()
556 * sfp_upstream_stop() - Inform the SFP that the network device is down
566 if (bus->registered) in sfp_upstream_stop()
567 bus->socket_ops->stop(bus->sfp); in sfp_upstream_stop()
568 bus->started = false; in sfp_upstream_stop()
574 bus->upstream_ops = NULL; in sfp_upstream_clear()
575 bus->upstream = NULL; in sfp_upstream_clear()
579 * sfp_bus_find_fwnode() - parse and locate the SFP bus from fwnode
587 * - on success, a pointer to the sfp_bus structure,
588 * - %NULL if no SFP is specified,
589 * - on failure, an error pointer value:
591 * - corresponding to the errors detailed for
593 * - %-ENOMEM if we failed to allocate the bus.
594 * - an error from the upstream's connect_phy() method.
604 if (ret == -ENOENT) in sfp_bus_find_fwnode()
617 return ERR_PTR(-ENOMEM); in sfp_bus_find_fwnode()
624 * sfp_bus_add_upstream() - parse and register the neighbouring device
634 * - on success, a pointer to the sfp_bus structure,
635 * - %NULL if no SFP is specified,
636 * - on failure, an error pointer value:
638 * - corresponding to the errors detailed for
640 * - %-ENOMEM if we failed to allocate the bus.
641 * - an error from the upstream's connect_phy() method.
653 kref_get(&bus->kref); in sfp_bus_add_upstream()
654 bus->upstream_ops = ops; in sfp_bus_add_upstream()
655 bus->upstream = upstream; in sfp_bus_add_upstream()
657 if (bus->sfp) { in sfp_bus_add_upstream()
674 * sfp_bus_del_upstream() - Delete a sfp bus
684 if (bus->sfp) in sfp_bus_del_upstream()
700 if (ops && ops->connect_phy) in sfp_add_phy()
701 ret = ops->connect_phy(bus->upstream, phydev); in sfp_add_phy()
704 bus->phydev = phydev; in sfp_add_phy()
714 if (ops && ops->disconnect_phy) in sfp_remove_phy()
715 ops->disconnect_phy(bus->upstream); in sfp_remove_phy()
716 bus->phydev = NULL; in sfp_remove_phy()
724 if (ops && ops->link_up) in sfp_link_up()
725 ops->link_up(bus->upstream); in sfp_link_up()
733 if (ops && ops->link_down) in sfp_link_down()
734 ops->link_down(bus->upstream); in sfp_link_down()
744 bus->sfp_quirk = quirk; in sfp_module_insert()
746 if (ops && ops->module_insert) in sfp_module_insert()
747 ret = ops->module_insert(bus->upstream, id); in sfp_module_insert()
757 if (ops && ops->module_remove) in sfp_module_remove()
758 ops->module_remove(bus->upstream); in sfp_module_remove()
760 bus->sfp_quirk = NULL; in sfp_module_remove()
769 if (ops && ops->module_start) in sfp_module_start()
770 ret = ops->module_start(bus->upstream); in sfp_module_start()
780 if (ops && ops->module_stop) in sfp_module_stop()
781 ops->module_stop(bus->upstream); in sfp_module_stop()
787 bus->sfp_dev = NULL; in sfp_socket_clear()
788 bus->sfp = NULL; in sfp_socket_clear()
789 bus->socket_ops = NULL; in sfp_socket_clear()
795 struct sfp_bus *bus = sfp_bus_get(dev->fwnode); in sfp_register_socket()
800 bus->sfp_dev = dev; in sfp_register_socket()
801 bus->sfp = sfp; in sfp_register_socket()
802 bus->socket_ops = ops; in sfp_register_socket()
804 if (bus->upstream_ops) { in sfp_register_socket()
824 if (bus->upstream_ops) in sfp_unregister_socket()